Merge the list of ignored files/symlinks into one Activity notification.
authorCamila San <hello@camila.codes>
Thu, 17 Oct 2019 16:45:33 +0000 (18:45 +0200)
committerCamila San <hello@camila.codes>
Thu, 17 Oct 2019 16:45:33 +0000 (18:45 +0200)
Signed-off-by: Camila San <hello@camila.codes>
src/gui/activitylistmodel.cpp
src/gui/activitylistmodel.h
src/gui/activitywidget.cpp

index d35fd1368a200d02f53d1f0f1f3ba002541765cd..eab049af72e9a91ed0d6d39dea1a19741daa92f6 100644 (file)
@@ -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<QVariant> 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);
index 2bffabca1821e0a6f2c3a4d705b2f4c31cbf573f..cbb823f1f44e98f5039908e633c48e270ab528b2 100644 (file)
@@ -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;
index c293a0384a8a059adf4ba03c774a27210f692be0..7ce4471d32d5ad277180879cb5e42b84dad0679c 100644 (file)
@@ -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);
+            }
         }
     }
 }