Account Settings: Don't expand while clicking on the '...' button
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 19 Oct 2015 16:23:56 +0000 (18:23 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Mon, 19 Oct 2015 16:23:56 +0000 (18:23 +0200)
src/gui/accountsettings.cpp
src/gui/accountsettings.h

index 39cbdd2269485f2c065e06fcaa9fca3f9dcd93bf..2df2060cf9ab97f71d2926640719ebfb7c566e7b 100644 (file)
@@ -104,7 +104,8 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
     connect(syncNowAction, SIGNAL(triggered()), SLOT(slotSyncCurrentFolderNow()));
     addAction(syncNowAction);
 
-    connect(ui->_folderList, SIGNAL(clicked(QModelIndex)), SLOT(slotFolderActivated(QModelIndex)));
+    connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
+            this, SLOT(slotFolderListClicked(const QModelIndex&)));
 
     connect(ui->selectiveSyncApply, SIGNAL(clicked()), _model, SLOT(slotApplySelectiveSync()));
     connect(ui->selectiveSyncCancel, SIGNAL(clicked()), _model, SLOT(resetFolders()));
@@ -125,9 +126,6 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
 
     connect(ui->signInButton, SIGNAL(clicked()) , this, SLOT(slotSignInAccount()));
     connect(ui->deleteButton, SIGNAL(clicked()) , this, SLOT(slotDeleteAccount()));
-
-    QObject::connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
-                     this, SLOT(slotFolderListClicked(const QModelIndex&)));
 }
 
 void AccountSettings::doExpand()
@@ -135,15 +133,6 @@ void AccountSettings::doExpand()
     ui->_folderList->expandToDepth(0);
 }
 
-void AccountSettings::slotFolderListClicked( const QModelIndex& indx )
-{
-    if( _model->classify(indx) == FolderStatusModel::RootFolder  &&
-            _accountState && _accountState->state() == AccountState::Connected ) {
-        bool expanded = ! (ui->_folderList->isExpanded(indx));
-        ui->_folderList->setExpanded(indx, expanded);
-    }
-}
-
 void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
 {
     QTreeView *tv = ui->_folderList;
@@ -180,7 +169,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
     menu->exec(tv->mapToGlobal(pos));
 }
 
-void AccountSettings::slotFolderActivated( const QModelIndex& indx )
+void AccountSettings::slotFolderListClicked(const QModelIndex& indx)
 {
     if (indx.data(FolderStatusDelegate::AddButton).toBool()) {
         if (indx.flags() & Qt::ItemIsEnabled) {
@@ -199,6 +188,13 @@ void AccountSettings::slotFolderActivated( const QModelIndex& indx )
         auto pos = tv->mapFromGlobal(QCursor::pos());
         if (FolderStatusDelegate::optionsButtonRect(tv->visualRect(indx)).contains(pos)) {
             slotCustomContextMenuRequested(pos);
+            return;
+        }
+
+        // Expand root items on single click
+        if(_accountState && _accountState->state() == AccountState::Connected ) {
+            bool expanded = ! (ui->_folderList->isExpanded(indx));
+            ui->_folderList->setExpanded(indx, expanded);
         }
     }
 }
index 4ec7dbd1a62c27e24adcd1ef7eae1e3f2771a4f8..20b0da24b3f025a441f132038889f36ebc36a46c 100644 (file)
@@ -61,7 +61,6 @@ signals:
     void openFolderAlias( const QString& );
 
 public slots:
-    void slotFolderActivated( const QModelIndex& );
     void slotOpenOC();
     void slotUpdateQuota( qint64,qint64 );
     void slotAccountStateChanged(int state);