Folders: Show as disconnected when account is disconnected.

Previously you could get a green folder icon even when the account
was signed out or disconnected for another reason.
This commit is contained in:
Christian Kamm 2015-07-03 15:03:18 +02:00
parent 1a58e6606c
commit ae69ff032b
4 changed files with 11 additions and 9 deletions

View file

@ -68,7 +68,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
ui->setupUi(this);
_model = new FolderStatusModel;
_model->setAccount(_accountState->account());
_model->setAccountState(_accountState);
_model->setParent(this);
FolderStatusDelegate *delegate = new FolderStatusDelegate;
delegate->setParent(this);

View file

@ -37,16 +37,16 @@ FolderStatusModel::~FolderStatusModel()
{ }
void FolderStatusModel::setAccount(const AccountPtr& account)
void FolderStatusModel::setAccountState(const AccountState* accountState)
{
beginResetModel();
_dirty = false;
_folders.clear();
_account = account;
_accountState = accountState;
auto folders = FolderMan::instance()->map();
foreach (auto f, folders) {
if (f->accountState()->account() != account)
if (f->accountState() != accountState)
continue;
SubFolderInfo info;
info._pathIdx << _folders.size();
@ -121,7 +121,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return QVariant();
const SubFolderInfo::Progress & progress = folderInfo._progress;
bool accountConnected = true; // FIXME
const bool accountConnected = _accountState->isConnected();
switch (role) {
case FolderStatusDelegate::FolderPathRole : return f->nativePath();
@ -373,7 +373,7 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
}
path += info->_path;
}
LsColJob *job = new LsColJob(_account, path, this);
LsColJob *job = new LsColJob(_accountState->account(), path, this);
job->setProperties(QList<QByteArray>() << "resourcetype" << "quota-used-bytes");
job->setTimeout(5 * 1000);
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
@ -721,7 +721,7 @@ void FolderStatusModel::slotFolderSyncStateChange()
void FolderStatusModel::resetFolders()
{
setAccount(_account);
setAccountState(_accountState);
}
} // namespace OCC

View file

@ -36,7 +36,7 @@ class FolderStatusModel : public QAbstractItemModel
public:
FolderStatusModel(QObject * parent = 0);
~FolderStatusModel();
void setAccount(const OCC::AccountPtr& account);
void setAccountState(const AccountState* accountState);
Qt::ItemFlags flags( const QModelIndex& ) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
@ -100,7 +100,7 @@ private slots:
private:
QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo* root,
const QStringList& oldBlackList) const;
AccountPtr _account;
const AccountState* _accountState;
bool _dirty; // If the selective sync checkboxes were changed
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)

View file

@ -20,6 +20,8 @@ namespace OCC {
class Account;
typedef QSharedPointer<Account> AccountPtr;
class AccountState;
typedef QSharedPointer<AccountState> AccountStatePtr;
} // namespace OCC