From a63ebe09049c3f8108bd7af8126192583ee33ee6 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 6 Jan 2016 10:56:07 +0100 Subject: [PATCH] Bring back the red box for errors #3796 This use the previous code by resetting the progress to hide the progress back and then return errors in the FolderErrorMsg data role of the folder model. This also remove the unused FolderRemotePath role, remove FolderStatus in favor of invalidating all roles in dataChanged and make sure that the SyncRunning role is transfered properly from the SyncResult to show the warning icon during sync. --- src/gui/folderstatusdelegate.cpp | 10 +++++----- src/gui/folderstatusdelegate.h | 2 -- src/gui/folderstatusmodel.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index 8c8848567..a173321d8 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -141,10 +141,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & QString itemString = qvariant_cast(index.data(SyncProgressItemString)); int warningCount = qvariant_cast(index.data(WarningCount)); bool syncOngoing = qvariant_cast(index.data(SyncRunning)); - - // QString statusText = qvariant_cast(index.data(FolderStatus)); - bool syncEnabled = index.data(FolderAccountConnected).toBool(); - // QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" ); + bool syncEnabled = qvariant_cast(index.data(FolderAccountConnected)); QRect iconRect = option.rect; QRect aliasRect = option.rect; @@ -327,6 +324,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & painter->restore(); { + QRect rectWithoutErrors = option.rect; + rectWithoutErrors.setTop(iconRect.top()); + rectWithoutErrors.setBottom(iconRect.bottom()); QStyleOptionToolButton btnOpt; //btnOpt.text = QLatin1String("..."); btnOpt.state = option.state; @@ -334,7 +334,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & btnOpt.state |= QStyle::State_Raised; btnOpt.arrowType = Qt::NoArrow; btnOpt.subControls = QStyle::SC_ToolButton; - btnOpt.rect = optionsButtonRect(option.rect); + btnOpt.rect = optionsButtonRect(rectWithoutErrors); btnOpt.icon = m_moreIcon; btnOpt.iconSize = btnOpt.rect.size(); QApplication::style()->drawComplexControl( QStyle::CC_ToolButton, &btnOpt, painter ); diff --git a/src/gui/folderstatusdelegate.h b/src/gui/folderstatusdelegate.h index b299a30fe..59acc87ae 100644 --- a/src/gui/folderstatusdelegate.h +++ b/src/gui/folderstatusdelegate.h @@ -33,8 +33,6 @@ public: HeaderRole, FolderPathRole, FolderSecondPathRole, - FolderRemotePath, - FolderStatus, FolderErrorMsg, FolderSyncPaused, FolderStatusIconRole, diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 86be5e902..fc3fc81c6 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -187,6 +187,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const switch (role) { case FolderStatusDelegate::FolderPathRole : return f->shortGuiPath(); case FolderStatusDelegate::FolderSecondPathRole : return f->remotePath(); + case FolderStatusDelegate::FolderErrorMsg : return f->syncResult().errorStrings(); + case FolderStatusDelegate::SyncRunning : return f->syncResult().status() == SyncResult::SyncRunning; case FolderStatusDelegate::HeaderRole : return f->aliasGui(); case FolderStatusDelegate::FolderAliasRole : return f->alias(); case FolderStatusDelegate::FolderSyncPaused : return f->syncPaused(); @@ -708,8 +710,7 @@ void FolderStatusModel::slotUpdateFolderState(Folder *folder) if( ! folder ) return; for (int i = 0; i < _folders.count(); ++i) { if (_folders.at(i)._folder == folder) { - emit dataChanged(index(i), index(i), - QVector() << FolderStatusDelegate::FolderStatus); + emit dataChanged(index(i), index(i)); } } } @@ -970,7 +971,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f) // Reset the progress info after a sync. _folders[folderIndex]._progress = SubFolderInfo::Progress(); } else if (state == SyncResult::Error) { - _folders[folderIndex]._progress._progressString = f->syncResult().errorString(); + _folders[folderIndex]._progress = SubFolderInfo::Progress(); } // update the icon etc. now -- 2.30.2