Skip to content

Commit

Permalink
Merge pull request owncloud#3884 from owncloud/fix_3860
Browse files Browse the repository at this point in the history
AccountSettings: Do not allow to expand folder list when disconnected.
  • Loading branch information
Klaas Freitag committed Sep 25, 2015
2 parents e7e0e5b + b72e2b1 commit 7b97b96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,23 @@ 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()
{
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;
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ protected slots:
void slotDeleteAccount();
void refreshSelectiveSyncStatus();
void slotCustomContextMenuRequested(const QPoint&);
void slotFolderListClicked( const QModelIndex& indx );
void doExpand();

private:
Expand Down

0 comments on commit 7b97b96

Please sign in to comment.