Bring back the red box for errors #3796
authorJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 Jan 2016 09:56:07 +0000 (10:56 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 Jan 2016 11:37:35 +0000 (12:37 +0100)
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
src/gui/folderstatusdelegate.h
src/gui/folderstatusmodel.cpp

index 8c8848567d0f7591e36c3d30c4360014a59a091b..a173321d8a2c845938080f09ef0551afb428490e 100644 (file)
@@ -141,10 +141,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
     QString itemString    = qvariant_cast<QString>(index.data(SyncProgressItemString));
     int warningCount      = qvariant_cast<int>(index.data(WarningCount));
     bool syncOngoing      = qvariant_cast<bool>(index.data(SyncRunning));
-
-    // QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
-    bool syncEnabled = index.data(FolderAccountConnected).toBool();
-    // QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
+    bool syncEnabled      = qvariant_cast<bool>(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 );
index b299a30fe87450034dadffe7e93df14d4f8daa57..59acc87ae8d5d1199a97aa94bd315b5c82ba5824 100644 (file)
@@ -33,8 +33,6 @@ public:
                     HeaderRole,
                     FolderPathRole,
                     FolderSecondPathRole,
-                    FolderRemotePath,
-                    FolderStatus,
                     FolderErrorMsg,
                     FolderSyncPaused,
                     FolderStatusIconRole,
index 86be5e90200f130dac9f4b0075ef77c71bc0199c..fc3fc81c642ab9e76536f2177c0c90c695d64ad6 100644 (file)
@@ -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<int>() << 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