Account Settings: Show selective sync buttons after list load
authorMarkus Goetz <markus@woboq.com>
Thu, 15 Oct 2015 16:50:54 +0000 (18:50 +0200)
committerMarkus Goetz <markus@woboq.com>
Thu, 15 Oct 2015 16:52:16 +0000 (18:52 +0200)
Especially nice when having a slower network.
For #3839

src/gui/accountsettings.cpp

index 6dcf06064d926f7c192a5c69dde67cf9074e6f17..2ef99f29305852f8256d474618eaaa39a44fc44d 100644 (file)
@@ -91,6 +91,8 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
     connect(_model, SIGNAL(suggestExpand(QModelIndex)), ui->_folderList, SLOT(expand(QModelIndex)));
     connect(_model, SIGNAL(dirtyChanged()), this, SLOT(refreshSelectiveSyncStatus()));
     refreshSelectiveSyncStatus();
+    connect(_model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(refreshSelectiveSyncStatus()));
 
     QAction *resetFolderAction = new QAction(this);
     resetFolderAction->setShortcut(QKeySequence(Qt::Key_F5));
@@ -517,6 +519,13 @@ AccountSettings::~AccountSettings()
 
 void AccountSettings::refreshSelectiveSyncStatus()
 {
+    if (_model->_folders.first()._subs.count() == 0) {
+        // Don't show when there is no items in model yet.
+        // It will be called again via rowsInserted()
+        ui->selectiveSyncStatus->setVisible(false);
+        return;
+    }
+
     bool shouldBeVisible = _model->isDirty();
     QStringList undecidedFolder;
     for (int i = 0; !shouldBeVisible && i < _model->rowCount(); ++i) {