From 05d31e2e53d30e2ec10ceb832608427291a109fd Mon Sep 17 00:00:00 2001 From: Felix Weilbach Date: Tue, 9 Mar 2021 10:00:25 +0100 Subject: [PATCH] Split content of User::isValueableActivity() Refactoring of User::isValueableactivity() because of changes introduced with merge commit f17c52d. Signed-off-by: Felix Weilbach --- src/gui/tray/UserModel.cpp | 108 +++++++++++++++++++------------------ src/gui/tray/UserModel.h | 3 +- 2 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index b048b329b..9763a79d0 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -413,19 +413,19 @@ void User::slotAddError(const QString &folderAlias, const QString &message, Erro } } -bool User::isValueableActivity(const Folder *folder, const SyncFileItemPtr &item) const +bool User::isActivityOfCurrentAccount(const Folder *folder) const { - // Ignore activity from a different account - if (folder->accountState() != _account.data()) { - return false; - } + return folder->accountState() == _account.data(); +} +bool User::isActivityIgnored(const SyncFileItemPtr &item) const +{ // We just care about conflict issues that we are able to resolve if (item->_status == SyncFileItem::Conflict && !Utility::isConflictFile(item->_file)) { - return false; + return true; } - return true; + return false; } void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item) @@ -435,56 +435,62 @@ void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item) if (!folderInstance) return; - if (isValueableActivity(folderInstance, item)) { - qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in " << item->_errorString; + if (!isActivityOfCurrentAccount(folderInstance)) { + return; + } - Activity activity; - activity._type = Activity::SyncFileItemType; //client activity - activity._status = item->_status; - activity._dateTime = QDateTime::currentDateTime(); - activity._message = item->_originalFile; - activity._link = folderInstance->accountState()->account()->url(); - activity._accName = folderInstance->accountState()->account()->displayName(); - activity._file = item->_file; - activity._folder = folder; - activity._fileAction = ""; - - if (item->_instruction == CSYNC_INSTRUCTION_REMOVE) { - activity._fileAction = "file_deleted"; - } else if (item->_instruction == CSYNC_INSTRUCTION_NEW) { - activity._fileAction = "file_created"; - } else if (item->_instruction == CSYNC_INSTRUCTION_RENAME) { - activity._fileAction = "file_renamed"; + if (isActivityIgnored(item)) { + return; + } + + qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in " << item->_errorString; + + Activity activity; + activity._type = Activity::SyncFileItemType; //client activity + activity._status = item->_status; + activity._dateTime = QDateTime::currentDateTime(); + activity._message = item->_originalFile; + activity._link = folderInstance->accountState()->account()->url(); + activity._accName = folderInstance->accountState()->account()->displayName(); + activity._file = item->_file; + activity._folder = folder; + activity._fileAction = ""; + + if (item->_instruction == CSYNC_INSTRUCTION_REMOVE) { + activity._fileAction = "file_deleted"; + } else if (item->_instruction == CSYNC_INSTRUCTION_NEW) { + activity._fileAction = "file_created"; + } else if (item->_instruction == CSYNC_INSTRUCTION_RENAME) { + activity._fileAction = "file_renamed"; + } else { + activity._fileAction = "file_changed"; + } + + if (item->_status == SyncFileItem::NoStatus || item->_status == SyncFileItem::Success) { + qCWarning(lcActivity) << "Item " << item->_file << " retrieved successfully."; + + if (item->_direction != SyncFileItem::Up) { + activity._message = tr("Synced %1").arg(item->_originalFile); + } else if (activity._fileAction == "file_renamed") { + activity._message = tr("You renamed %1").arg(item->_originalFile); + } else if (activity._fileAction == "file_deleted") { + activity._message = tr("You deleted %1").arg(item->_originalFile); + } else if (activity._fileAction == "file_created") { + activity._message = tr("You created %1").arg(item->_originalFile); } else { - activity._fileAction = "file_changed"; + activity._message = tr("You changed %1").arg(item->_originalFile); } - if (item->_status == SyncFileItem::NoStatus || item->_status == SyncFileItem::Success) { - qCWarning(lcActivity) << "Item " << item->_file << " retrieved successfully."; - - if (item->_direction != SyncFileItem::Up) { - activity._message = tr("Synced %1").arg(item->_originalFile); - } else if (activity._fileAction == "file_renamed") { - activity._message = tr("You renamed %1").arg(item->_originalFile); - } else if (activity._fileAction == "file_deleted") { - activity._message = tr("You deleted %1").arg(item->_originalFile); - } else if (activity._fileAction == "file_created") { - activity._message = tr("You created %1").arg(item->_originalFile); - } else { - activity._message = tr("You changed %1").arg(item->_originalFile); - } + _activityModel->addSyncFileItemToActivityList(activity); + } else { + qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in error " << item->_errorString; + activity._subject = item->_errorString; - _activityModel->addSyncFileItemToActivityList(activity); + if (item->_status == SyncFileItem::Status::FileIgnored) { + _activityModel->addIgnoredFileToList(activity); } else { - qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in error " << item->_errorString; - activity._subject = item->_errorString; - - if (item->_status == SyncFileItem::Status::FileIgnored) { - _activityModel->addIgnoredFileToList(activity); - } else { - // add 'protocol error' to activity list - _activityModel->addErrorToActivityList(activity); - } + // add 'protocol error' to activity list + _activityModel->addErrorToActivityList(activity); } } } diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index 535c9ad43..be92e8aec 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -80,7 +80,8 @@ private: void connectPushNotifications() const; bool checkPushNotificationsAreReady() const; - bool isValueableActivity(const Folder *folder, const SyncFileItemPtr &item) const; + bool isActivityOfCurrentAccount(const Folder *folder) const; + bool isActivityIgnored(const SyncFileItemPtr &item) const; private: AccountStatePtr _account; -- 2.30.2