mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Add a textual display of the file size in progress.
This commit is contained in:
parent
b42c7e07e6
commit
3b00dfebed
@ -478,8 +478,15 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
||||
|
||||
if( item ) {
|
||||
if( p1 == p2 ) { // File upload finished.
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgress1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgress2);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgressPercent1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgressPercent2);
|
||||
if( p1 == 0 ) {
|
||||
item->setData( (qlonglong) _lastSyncProgress, FolderStatusDelegate::SyncProgressBytes1);
|
||||
item->setData( (qlonglong) _lastSyncProgress, FolderStatusDelegate::SyncProgressBytes2);
|
||||
} else {
|
||||
item->setData( (qlonglong) p1, FolderStatusDelegate::SyncProgressBytes1);
|
||||
item->setData( (qlonglong) p2, FolderStatusDelegate::SyncProgressBytes2);
|
||||
}
|
||||
// item->setData( QVariant(QString::null), FolderStatusDelegate::SyncFileName );
|
||||
|
||||
// start a timer to stop the progress display
|
||||
@ -504,8 +511,10 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
||||
// calculate the normalization factor and set the min and max
|
||||
_progressFactor = 100.0/p2;
|
||||
item->setData( QVariant(true), FolderStatusDelegate::AddProgressSpace );
|
||||
item->setData( 0, FolderStatusDelegate::SyncProgress1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgress2);
|
||||
item->setData( 0, FolderStatusDelegate::SyncProgressPercent1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgressPercent2);
|
||||
item->setData( (qlonglong) 0, FolderStatusDelegate::SyncProgressBytes1);
|
||||
item->setData( (qlonglong) p2, FolderStatusDelegate::SyncProgressBytes2);
|
||||
|
||||
// strip off the server prefix from the file name
|
||||
QString shortFile(file);
|
||||
@ -526,8 +535,10 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
||||
shortFile = kindString + QLatin1String(" ") + shortFile;
|
||||
item->setData( shortFile, FolderStatusDelegate::SyncFileName );
|
||||
} else { // File progress
|
||||
item->setData( int(_progressFactor * p1), FolderStatusDelegate::SyncProgress1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgress2);
|
||||
item->setData( int(_progressFactor * p1), FolderStatusDelegate::SyncProgressPercent1);
|
||||
item->setData( (qlonglong) p1, FolderStatusDelegate::SyncProgressBytes1);
|
||||
_lastSyncProgress = p1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -93,6 +93,7 @@ private:
|
||||
double _progressFactor;
|
||||
QHash<QStandardItem*, QTimer*> _hideProgressTimers;
|
||||
QTimer *_timer;
|
||||
long _lastSyncProgress;
|
||||
};
|
||||
|
||||
} // namespace Mirall
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
#include "mirall/folderstatusmodel.h"
|
||||
#include "mirall/utility.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
@ -122,8 +123,10 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole));
|
||||
QString errorText = qvariant_cast<QString>(index.data(FolderErrorMsg));
|
||||
QString syncFile = qvariant_cast<QString>(index.data(SyncFileName));
|
||||
long progress1 = qvariant_cast<long>(index.data(SyncProgress1));
|
||||
long progress2 = qvariant_cast<long>(index.data(SyncProgress2));
|
||||
int progressPercent1 = qvariant_cast<int>(index.data(SyncProgressPercent1));
|
||||
int progressPercent2 = qvariant_cast<int>(index.data(SyncProgressPercent2));
|
||||
qlonglong progressBytes1 = qvariant_cast<int>(index.data(SyncProgressBytes1));
|
||||
qlonglong progressBytes2 = qvariant_cast<int>(index.data(SyncProgressBytes2));
|
||||
|
||||
// QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
|
||||
bool syncEnabled = index.data(FolderSyncEnabled).toBool();
|
||||
@ -240,29 +243,45 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
QRect fileNameRect;
|
||||
fileNameRect.setTop(progressRect.top() + margin);
|
||||
fileNameRect.setLeft(progressRect.left() + margin);
|
||||
fileNameRect.setWidth( progressRect.width() - 2*margin);
|
||||
fileNameRect.setWidth( progressRect.width() - 2*margin );
|
||||
fileNameRect.setHeight(fileNameTextHeight);
|
||||
|
||||
QString pText = subFm.elidedText( tr("File %1: ").arg(syncFile), Qt::ElideLeft, fileNameRect.width());
|
||||
painter->drawText(fileNameRect, pText);
|
||||
painter->restore();
|
||||
|
||||
// Sizes-Text
|
||||
QString s1 = Utility::octetsToString( progressBytes2 );
|
||||
QRect octetRect = subFm.boundingRect( tr("%1 of %2").arg(s1).arg(s1) );
|
||||
|
||||
QRect pBRect;
|
||||
pBRect.setTop( fileNameRect.bottom() + margin );
|
||||
pBRect.setLeft( fileNameRect.left());
|
||||
pBRect.setHeight(barHeight);
|
||||
pBRect.setWidth( fileNameRect.width());
|
||||
pBRect.setWidth( fileNameRect.width() - octetRect.width()-margin );
|
||||
|
||||
QStyleOptionProgressBarV2 pBarOpt;
|
||||
pBarOpt.state = option.state | QStyle::State_Horizontal;
|
||||
pBarOpt.minimum = 0;
|
||||
pBarOpt.maximum = progress2;
|
||||
pBarOpt.progress = progress1;
|
||||
pBarOpt.maximum = progressPercent2;
|
||||
pBarOpt.progress = progressPercent1;
|
||||
pBarOpt.orientation = Qt::Horizontal;
|
||||
pBarOpt.palette = option.palette;
|
||||
pBarOpt.rect = pBRect;
|
||||
|
||||
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &pBarOpt, painter );
|
||||
|
||||
QRect sizeRect;
|
||||
sizeRect.setTop(pBRect.top());
|
||||
sizeRect.setHeight(pBRect.height());
|
||||
|
||||
sizeRect.setLeft(pBRect.right() + margin);
|
||||
sizeRect.setWidth( octetRect.width() );
|
||||
QString ps1 = Utility::octetsToString( progressBytes1 );
|
||||
QString ps2 = Utility::octetsToString( progressBytes2 );
|
||||
|
||||
painter->drawText(sizeRect, tr("%1 of %2").arg(ps1).arg(ps2));
|
||||
|
||||
}
|
||||
// painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText ));
|
||||
// painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus ));
|
||||
|
||||
@ -45,8 +45,10 @@ class FolderStatusDelegate : public QStyledItemDelegate
|
||||
FolderSyncEnabled,
|
||||
FolderStatusIconRole,
|
||||
SyncFileName,
|
||||
SyncProgress1,
|
||||
SyncProgress2,
|
||||
SyncProgressPercent1,
|
||||
SyncProgressPercent2,
|
||||
SyncProgressBytes1,
|
||||
SyncProgressBytes2,
|
||||
AddProgressSpace
|
||||
};
|
||||
void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user