Propagate soft errors into SyncResult, icon fixes.

This commit is contained in:
Klaas Freitag 2013-08-02 14:22:01 +02:00
parent 1e50620f53
commit 49be4a3be2
9 changed files with 81 additions and 11 deletions

View file

@ -214,10 +214,18 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
if( f->syncEnabled() ) {
item->setData( theme->syncStateIcon( status ), FolderStatusDelegate::FolderStatusIconRole );
} else {
item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before
item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before
}
item->setData( theme->statusHeaderText( status ), FolderStatusDelegate::FolderStatus );
item->setData( errors, FolderStatusDelegate::FolderErrorMsg );
item->setData( errors, FolderStatusDelegate::FolderErrorMsg );
bool ongoing = false;
item->setData( QVariant(res.warnCount()), FolderStatusDelegate::WarningCount );
if( status == SyncResult::SyncRunning ) {
ongoing = true;
}
item->setData( ongoing, FolderStatusDelegate::SyncRunning);
}
void AccountSettings::slotRemoveCurrentFolder()
@ -493,6 +501,18 @@ QString AccountSettings::shortenFilename( const QString& folder, const QString&
return shortFile;
}
void AccountSettings::slotProgressProblem(const QString& folder, const Progress::SyncProblem& problem)
{
Q_UNUSED(problem);
QStandardItem *item = itemForFolder( folder );
if( !item ) return;
int warnCount = qvariant_cast<int>( item->data(FolderStatusDelegate::WarningCount) );
warnCount++;
item->setData( QVariant(warnCount), FolderStatusDelegate::WarningCount );
}
void AccountSettings::slotSetProgress(const QString& folder, const Progress::Info &progress )
{
// qDebug() << "================================> Progress for folder " << folder << " file " << file << ": "<< p1;
@ -522,6 +542,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
switch( progress.kind ) {
case Progress::StartSync:
item->setData( QVariant(0), FolderStatusDelegate::WarningCount );
break;
case Progress::StartDownload:
case Progress::StartUpload:

View file

@ -69,6 +69,7 @@ public slots:
void slotDoubleClicked( const QModelIndex& );
void slotFolderOpenAction( const QString& );
void slotSetProgress(const QString&, const Progress::Info& progress);
void slotProgressProblem(const QString& folder, const Progress::SyncProblem& problem);
void slotUpdateQuota( qint64,qint64 );
void slotIgnoreFilesEditor();

View file

@ -617,6 +617,9 @@ void Folder::slotCSyncFinished()
qDebug() << " * owncloud csync thread finished with error";
} else if (_csyncUnavail) {
_syncResult.setStatus(SyncResult::Unavailable);
} else if( _syncResult.warnCount() > 0 ) {
// there have been warnings on the way.
_syncResult.setStatus(SyncResult::Problem);
} else {
_syncResult.setStatus(SyncResult::Success);
}
@ -647,6 +650,14 @@ void Folder::slotTransmissionProgress(const Progress::Info& progress)
newInfo.current_file = newInfo.current_file.right( newInfo.current_file.length() - localPath.length());
}
// remember problems happening to set the correct Sync status in slot slotCSyncFinished.
if( newInfo.kind == Progress::StartSync ) {
_syncResult.setWarnCount(0);
}
if( newInfo.kind == Progress::Error ) {
_syncResult.setWarnCount( _syncResult.warnCount()+1 );
}
ProgressDispatcher::instance()->setProgressInfo(alias(), newInfo);
}

View file

@ -118,16 +118,17 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
int aliasMargin = aliasFm.height()/2;
int margin = subFm.height()/4;
QIcon statusIcon = qvariant_cast<QIcon>(index.data(FolderStatusIconRole));
QString aliasText = qvariant_cast<QString>(index.data(FolderAliasRole));
QString pathText = qvariant_cast<QString>(index.data(FolderPathRole));
QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole));
QString errorText = qvariant_cast<QString>(index.data(FolderErrorMsg));
QIcon statusIcon = qvariant_cast<QIcon>(index.data(FolderStatusIconRole));
QString aliasText = qvariant_cast<QString>(index.data(FolderAliasRole));
QString pathText = qvariant_cast<QString>(index.data(FolderPathRole));
QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole));
QString errorText = qvariant_cast<QString>(index.data(FolderErrorMsg));
int overallPercent = qvariant_cast<int>(index.data(SyncProgressOverallPercent));
QString overallString = qvariant_cast<QString>(index.data(SyncProgressOverallString));
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();
// QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
@ -166,6 +167,20 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QPixmap pm = statusIcon.pixmap(iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled );
painter->drawPixmap(QPoint(iconRect.left(), iconRect.top()), pm);
// only show the warning icon if the sync is running. Otherwise its
// encoded in the status icon.
if( warningCount > 0 && syncOngoing) {
QRect warnRect;
warnRect.setLeft(iconRect.left());
warnRect.setTop(iconRect.bottom()-17);
warnRect.setWidth(16);
warnRect.setHeight(16);
QIcon warnIcon(":/mirall/resources/warning-16");
QPixmap pm = warnIcon.pixmap(16,16, syncEnabled ? QIcon::Normal : QIcon::Disabled );
painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()),pm );
}
if ((option.state & QStyle::State_Selected)
&& (option.state & QStyle::State_Active)
// Hack: Windows Vista's light blue is not contrasting enough for white

View file

@ -48,7 +48,9 @@ class FolderStatusDelegate : public QStyledItemDelegate
SyncProgressOverallPercent,
SyncProgressOverallString,
SyncProgressItemString,
AddProgressSpace
AddProgressSpace,
WarningCount,
SyncRunning
};
void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const;
QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const;

View file

@ -81,6 +81,8 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent) :
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
connect( ProgressDispatcher::instance(), SIGNAL(progressSyncProblem(QString,Progress::SyncProblem)),
_accountSettings, SLOT(slotProgressProblem(QString,Progress::SyncProblem)) );
_ui->labelWidget->setCurrentRow(_ui->labelWidget->row(general));

View file

@ -18,12 +18,14 @@ namespace Mirall
{
SyncResult::SyncResult()
: _status( Undefined )
: _status( Undefined ),
_warnCount(0)
{
}
SyncResult::SyncResult(SyncResult::Status status )
: _status(status)
: _status(status),
_warnCount(0)
{
}
@ -87,6 +89,16 @@ QDateTime SyncResult::syncTime() const
return _syncTime;
}
void SyncResult::setWarnCount(int wc)
{
_warnCount = wc;
}
int SyncResult::warnCount() const
{
return _warnCount;
}
void SyncResult::setErrorStrings( const QStringList& list )
{
_errors = list;

View file

@ -47,6 +47,8 @@ public:
void setErrorStrings( const QStringList& );
QString errorString() const;
QStringList errorStrings() const;
int warnCount() const;
void setWarnCount(int wc);
void clearErrors();
// handle a list of changed items.
@ -66,6 +68,7 @@ private:
* when the sync tool support this...
*/
QStringList _errors;
int _warnCount;
};
}

View file

@ -56,6 +56,9 @@ QString Theme::statusHeaderText( SyncResult::Status status ) const
case SyncResult::Success:
resultStr = QObject::tr("Sync Success");
break;
case SyncResult::Problem:
resultStr = QObject::tr("Sync Success, problems with individual files.");
break;
case SyncResult::Error:
resultStr = QObject::tr("Sync Error - Click info button for details.");
break;