Merge pull request #3884 from owncloud/fix_3860

AccountSettings: Do not allow to expand folder list when disconnected.
This commit is contained in:
Klaas Freitag 2015-09-25 17:52:39 +02:00
commit 7b97b96115
2 changed files with 23 additions and 1 deletions

View file

@ -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,15 @@ 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;
@ -471,6 +480,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()

View file

@ -80,6 +80,7 @@ protected slots:
void slotDeleteAccount();
void refreshSelectiveSyncStatus();
void slotCustomContextMenuRequested(const QPoint&);
void slotFolderListClicked( const QModelIndex& indx );
void doExpand();
private: