From: Claudio Cambra Date: Tue, 25 Apr 2023 03:44:47 +0000 (+0800) Subject: Notify change in tags when maxTags set in filetagmodel X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~10^2~49^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1bab57b17632a36e527264c83e9d546195c5873b;p=nextcloud-desktop.git Notify change in tags when maxTags set in filetagmodel Signed-off-by: Claudio Cambra --- diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp index a9bd35bbd..5927ffcd4 100644 --- a/src/gui/filetagmodel.cpp +++ b/src/gui/filetagmodel.cpp @@ -164,7 +164,22 @@ void FileTagModel::setMaxTags(const int maxTags) return; } + const auto totalTagCount = totalTags(); + const auto tagsWillBeTruncated = maxTags < totalTagCount; + + // Summary tag will be after the last tag + const auto notifyOverflowingTagsRemoved = tagsWillBeTruncated && totalTagCount > maxTags; + + if (notifyOverflowingTagsRemoved) { + beginResetModel(); + } + _maxTags = maxTags; + + if (notifyOverflowingTagsRemoved) { + endResetModel(); + } + Q_EMIT maxTagsChanged(); } diff --git a/src/gui/filetagmodel.h b/src/gui/filetagmodel.h index d0f41f6cb..ac82b20a5 100644 --- a/src/gui/filetagmodel.h +++ b/src/gui/filetagmodel.h @@ -67,7 +67,6 @@ private: QStringList _tags; int _maxTags = 0; - int _totalTags = 0; }; }