From a1421ff74f535ba520c9372075bb88cb0ac69513 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 25 Sep 2015 12:22:51 +0200 Subject: [PATCH] AccountSettings: Do not allow to expand the folder list when disconnected. This is supposed to fix #3860 --- src/gui/accountsettings.cpp | 21 ++++++++++++++++++++- src/gui/accountsettings.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index e9956f75f..5210dcaec 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -125,7 +125,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) : // Expand already on single click ui->_folderList->setExpandsOnDoubleClick(false); QObject::connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)), - ui->_folderList, SLOT(expand(const QModelIndex &))); + this, SLOT(slotFolderListClicked(const QModelIndex&))); } void AccountSettings::doExpand() @@ -133,6 +133,13 @@ void AccountSettings::doExpand() ui->_folderList->expandToDepth(0); } +void AccountSettings::slotFolderListClicked( const QModelIndex& indx ) +{ + if( _accountState && _accountState->state() == AccountState::Connected ) { + ui->_folderList->expand(indx); + } +} + void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos) { QTreeView *tv = ui->_folderList; @@ -471,6 +478,18 @@ void AccountSettings::slotAccountStateChanged(int state) // ownCloud is not yet configured. showConnectionLabel( tr("No %1 connection configured.").arg(Theme::instance()->appNameGUI()) ); } + + /* Allow to expand the item if the account is connected. */ + ui->_folderList->setItemsExpandable( state == AccountState::Connected ); + + /* check if there are expanded root items, if so, close them, if the state is different from being Connected. */ + if( state != AccountState::Connected ) { + int i; + for (i = 0; i < _model->rowCount(); ++i) { + if (ui->_folderList->isExpanded(_model->index(i))) + ui->_folderList->setExpanded(_model->index(i), false); + } + } } AccountSettings::~AccountSettings() diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h index b63a75a58..4dac973e1 100644 --- a/src/gui/accountsettings.h +++ b/src/gui/accountsettings.h @@ -80,6 +80,7 @@ protected slots: void slotDeleteAccount(); void refreshSelectiveSyncStatus(); void slotCustomContextMenuRequested(const QPoint&); + void slotFolderListClicked( const QModelIndex& indx ); void doExpand(); private: