From 8546d53b05a76271e245f085d1caa5d405dadb8d Mon Sep 17 00:00:00 2001 From: Camila San Date: Thu, 17 Oct 2019 18:45:33 +0200 Subject: [PATCH] Merge the list of ignored files/symlinks into one Activity notification. Signed-off-by: Camila San --- src/gui/activitylistmodel.cpp | 36 ++++++++++++++++++++++++----------- src/gui/activitylistmodel.h | 3 +++ src/gui/activitywidget.cpp | 11 ++++++++--- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp index d35fd1368..eab049af7 100644 --- a/src/gui/activitylistmodel.cpp +++ b/src/gui/activitylistmodel.cpp @@ -64,20 +64,12 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const case ActivityItemDelegate::PathRole: if(!a._file.isEmpty()){ auto folder = FolderMan::instance()->folder(a._folder); - QString relPath(a._file); - if(folder) relPath.prepend(folder->remotePath()); - list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account()); - if (list.count() > 0) { - return QVariant(list.at(0)); - } - // File does not exist anymore? Let's try to open its path - list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(relPath).path(), ast->account()); + list = FolderMan::instance()->findFileInLocalFolders(folder->remotePath(), ast->account()); if (list.count() > 0) { return QVariant(list.at(0)); } } return QVariant(); - break; case ActivityItemDelegate::ActionsLinksRole:{ QList customList; foreach (ActivityLink customItem, a._links) { @@ -86,7 +78,6 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const customList << customVariant; } return customList; - break; } case ActivityItemDelegate::ActionIconRole: if(a._type == Activity::NotificationType){ @@ -229,6 +220,29 @@ void ActivityListModel::addErrorToActivityList(Activity activity) { combineActivityLists(); } +void ActivityListModel::addIgnoredFileToList(Activity newActivity) { + qCInfo(lcActivity) << "First checking for duplicates then add file to the notification list of ignored files: " << newActivity._file; + + bool duplicate = false; + if(_listOfIgnoredFiles.size() == 0){ + _notificationIgnoredFiles = newActivity; + _notificationIgnoredFiles._subject = tr("Files from the ignore list as well as symbolic links are not synced. This includes:"); + _listOfIgnoredFiles.append(newActivity); + return; + } + + foreach(Activity activity, _listOfIgnoredFiles){ + if(activity._file == newActivity._file){ + duplicate = true; + break; + } + } + + if(!duplicate){ + _notificationIgnoredFiles._message.append(", " + newActivity._file); + } +} + void ActivityListModel::addNotificationToActivityList(Activity activity) { qCInfo(lcActivity) << "Notification successfully added to the notification list: " << activity._subject; _notificationLists.prepend(activity); @@ -276,13 +290,13 @@ void ActivityListModel::removeActivityFromActivityList(Activity activity) { } } - void ActivityListModel::combineActivityLists() { ActivityList resultList; std::sort(_notificationErrorsLists.begin(), _notificationErrorsLists.end()); resultList.append(_notificationErrorsLists); + resultList.append(_notificationIgnoredFiles); std::sort(_notificationLists.begin(), _notificationLists.end()); resultList.append(_notificationLists); diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h index 2bffabca1..cbb823f1f 100644 --- a/src/gui/activitylistmodel.h +++ b/src/gui/activitylistmodel.h @@ -51,6 +51,7 @@ public: void addNotificationToActivityList(Activity activity); void clearNotifications(); void addErrorToActivityList(Activity activity); + void addIgnoredFileToList(Activity newActivity); void addSyncFileItemToActivityList(Activity activity); void removeActivityFromActivityList(int row); void removeActivityFromActivityList(Activity activity); @@ -73,6 +74,8 @@ private: ActivityList _activityLists; ActivityList _syncFileItemLists; ActivityList _notificationLists; + ActivityList _listOfIgnoredFiles; + Activity _notificationIgnoredFiles; ActivityList _notificationErrorsLists; ActivityList _finalList; AccountState *_accountState; diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp index c293a0384..7ce4471d3 100644 --- a/src/gui/activitywidget.cpp +++ b/src/gui/activitywidget.cpp @@ -127,11 +127,12 @@ void ActivityWidget::slotProgressInfo(const QString &folder, const ProgressInfo } - if(activity._status == SyncFileItem::FileIgnored && !QFileInfo(f->path() + activity._file).exists()){ + if(activity._status == SyncFileItem::FileIgnored && !QFileInfo(f->path() + activity._file).exists()) { _model->removeActivityFromActivityList(activity); continue; } + if(!QFileInfo(f->path() + activity._file).exists()){ _model->removeActivityFromActivityList(activity); continue; @@ -191,8 +192,12 @@ void ActivityWidget::slotItemCompleted(const QString &folder, const SyncFileItem qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in error " << item->_errorString; activity._subject = item->_errorString; - // add 'protocol error' to activity list - _model->addErrorToActivityList(activity); + if(item->_status == SyncFileItem::Status::FileIgnored) { + _model->addIgnoredFileToList(activity); + } else { + // add 'protocol error' to activity list + _model->addErrorToActivityList(activity); + } } } } -- 2.30.2