StatusModel: Have another property accountConnected.

With that , make the status model aware of the account connection state.
With that, we can grey out the correct state icon if the account is not
connected and display the normal icon if the account is connected.
This commit is contained in:
Klaas Freitag 2014-08-19 14:06:28 +02:00
parent 1245ed6f06
commit bb3bd6930a
4 changed files with 10 additions and 7 deletions

View file

@ -227,7 +227,7 @@ void AccountSettings::slotAddFolder( Folder *folder )
if( ! folder || folder->alias().isEmpty() ) return;
QStandardItem *item = new QStandardItem();
folderToModelItem( item, folder );
folderToModelItem( item, folder, _account->state() == Account::Connected );
_model->appendRow( item );
// in order to update the enabled state of the "Sync now" button
connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
@ -249,7 +249,7 @@ void AccountSettings::setGeneralErrors( const QStringList& errors )
}
}
void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f, bool accountConnected )
{
if( ! item || !f ) return;
@ -257,6 +257,7 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
item->setData( f->remotePath(), FolderStatusDelegate::FolderSecondPathRole );
item->setData( f->alias(), FolderStatusDelegate::FolderAliasRole );
item->setData( f->syncPaused(), FolderStatusDelegate::FolderSyncPaused );
item->setData( accountConnected, FolderStatusDelegate::FolderAccountConnected );
SyncResult res = f->syncResult();
SyncResult::Status status = res.status();
@ -516,7 +517,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder )
}
if( item ) {
folderToModelItem( item, folder );
folderToModelItem( item, folder, _account->state() == Account::Connected );
} else {
// the dialog is not visible.
}
@ -782,10 +783,10 @@ void AccountSettings::slotSyncStateChange(const QString& alias)
{
Q_UNUSED(alias);
FolderMan *folderMan = FolderMan::instance();
SyncResult state = folderMan->accountStatus(folderMan->map().values());
QIcon icon;
if (_account && _account->state() == Account::Connected) {
FolderMan *folderMan = FolderMan::instance();
SyncResult state = folderMan->accountStatus(folderMan->map().values());
icon = Theme::instance()->syncStateIcon(state.status());
} else {
icon = Theme::instance()->folderOfflineIcon();

View file

@ -86,7 +86,7 @@ protected slots:
private:
QString shortenFilename( const QString& folder, const QString& file ) const;
void folderToModelItem( QStandardItem *, Folder * );
void folderToModelItem(QStandardItem *, Folder * , bool accountConnected);
QStandardItem* itemForFolder(const QString& );
void showConnectionLabel( const QString& message, const QString& tooltip = QString() );

View file

@ -133,8 +133,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QString itemString = qvariant_cast<QString>(index.data(SyncProgressItemString));
int warningCount = qvariant_cast<int>(index.data(WarningCount));
bool syncOngoing = qvariant_cast<bool>(index.data(SyncRunning));
// QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
bool syncEnabled = index.data(FolderSyncEnabled).toBool();
bool syncEnabled = index.data(FolderAccountConnected).toBool();
// QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
QRect iconRect = option.rect;

View file

@ -44,6 +44,7 @@ class FolderStatusDelegate : public QStyledItemDelegate
FolderErrorMsg,
FolderSyncPaused,
FolderStatusIconRole,
FolderAccountConnected,
SyncProgressOverallPercent,
SyncProgressOverallString,