mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Bring back the red box for errors #3796
This use the previous code by resetting the progress to hide the progress back and then return errors in the FolderErrorMsg data role of the folder model. This also remove the unused FolderRemotePath role, remove FolderStatus in favor of invalidating all roles in dataChanged and make sure that the SyncRunning role is transfered properly from the SyncResult to show the warning icon during sync.
This commit is contained in:
parent
ef9483c82d
commit
a63ebe0904
3 changed files with 9 additions and 10 deletions
|
@ -141,10 +141,7 @@ 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(FolderAccountConnected).toBool();
|
||||
// QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
|
||||
bool syncEnabled = qvariant_cast<bool>(index.data(FolderAccountConnected));
|
||||
|
||||
QRect iconRect = option.rect;
|
||||
QRect aliasRect = option.rect;
|
||||
|
@ -327,6 +324,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
painter->restore();
|
||||
|
||||
{
|
||||
QRect rectWithoutErrors = option.rect;
|
||||
rectWithoutErrors.setTop(iconRect.top());
|
||||
rectWithoutErrors.setBottom(iconRect.bottom());
|
||||
QStyleOptionToolButton btnOpt;
|
||||
//btnOpt.text = QLatin1String("...");
|
||||
btnOpt.state = option.state;
|
||||
|
@ -334,7 +334,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
btnOpt.state |= QStyle::State_Raised;
|
||||
btnOpt.arrowType = Qt::NoArrow;
|
||||
btnOpt.subControls = QStyle::SC_ToolButton;
|
||||
btnOpt.rect = optionsButtonRect(option.rect);
|
||||
btnOpt.rect = optionsButtonRect(rectWithoutErrors);
|
||||
btnOpt.icon = m_moreIcon;
|
||||
btnOpt.iconSize = btnOpt.rect.size();
|
||||
QApplication::style()->drawComplexControl( QStyle::CC_ToolButton, &btnOpt, painter );
|
||||
|
|
|
@ -33,8 +33,6 @@ public:
|
|||
HeaderRole,
|
||||
FolderPathRole,
|
||||
FolderSecondPathRole,
|
||||
FolderRemotePath,
|
||||
FolderStatus,
|
||||
FolderErrorMsg,
|
||||
FolderSyncPaused,
|
||||
FolderStatusIconRole,
|
||||
|
|
|
@ -187,6 +187,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
|||
switch (role) {
|
||||
case FolderStatusDelegate::FolderPathRole : return f->shortGuiPath();
|
||||
case FolderStatusDelegate::FolderSecondPathRole : return f->remotePath();
|
||||
case FolderStatusDelegate::FolderErrorMsg : return f->syncResult().errorStrings();
|
||||
case FolderStatusDelegate::SyncRunning : return f->syncResult().status() == SyncResult::SyncRunning;
|
||||
case FolderStatusDelegate::HeaderRole : return f->aliasGui();
|
||||
case FolderStatusDelegate::FolderAliasRole : return f->alias();
|
||||
case FolderStatusDelegate::FolderSyncPaused : return f->syncPaused();
|
||||
|
@ -708,8 +710,7 @@ void FolderStatusModel::slotUpdateFolderState(Folder *folder)
|
|||
if( ! folder ) return;
|
||||
for (int i = 0; i < _folders.count(); ++i) {
|
||||
if (_folders.at(i)._folder == folder) {
|
||||
emit dataChanged(index(i), index(i),
|
||||
QVector<int>() << FolderStatusDelegate::FolderStatus);
|
||||
emit dataChanged(index(i), index(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +971,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
|||
// Reset the progress info after a sync.
|
||||
_folders[folderIndex]._progress = SubFolderInfo::Progress();
|
||||
} else if (state == SyncResult::Error) {
|
||||
_folders[folderIndex]._progress._progressString = f->syncResult().errorString();
|
||||
_folders[folderIndex]._progress = SubFolderInfo::Progress();
|
||||
}
|
||||
|
||||
// update the icon etc. now
|
||||
|
|
Loading…
Reference in a new issue