Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the list of ignored files/symlinks into one Activity notification. #1523

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions src/gui/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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){
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/gui/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ActivityListModel : public QAbstractListModel
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);
Expand All @@ -73,6 +74,8 @@ private slots:
ActivityList _activityLists;
ActivityList _syncFileItemLists;
ActivityList _notificationLists;
ActivityList _listOfIgnoredFiles;
Activity _notificationIgnoredFiles;
ActivityList _notificationErrorsLists;
ActivityList _finalList;
AccountState *_accountState;
Expand Down
11 changes: 8 additions & 3 deletions src/gui/activitywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down