mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
Improved timestamp formatting in item sync progress dialog.
This commit is contained in:
parent
32b44e3d87
commit
0a9491ff46
5 changed files with 34 additions and 8 deletions
|
@ -494,7 +494,7 @@ void CSyncThread::cb_progress( CSYNC_PROGRESS *progress, void *userdata )
|
||||||
pInfo.current_file_no = progress->current_file_no;
|
pInfo.current_file_no = progress->current_file_no;
|
||||||
pInfo.overall_transmission_size = progress->overall_transmission_size;
|
pInfo.overall_transmission_size = progress->overall_transmission_size;
|
||||||
pInfo.overall_current_bytes = progress->current_overall_bytes;
|
pInfo.overall_current_bytes = progress->current_overall_bytes;
|
||||||
pInfo.timestamp = QTime::currentTime();
|
pInfo.timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
// Connect to something in folder!
|
// Connect to something in folder!
|
||||||
thread->transmissionProgress( pInfo );
|
thread->transmissionProgress( pInfo );
|
||||||
|
|
|
@ -139,13 +139,15 @@ void ItemProgressDialog::setSyncResult( const SyncResult& result )
|
||||||
|
|
||||||
SyncFileItemVector::const_iterator i;
|
SyncFileItemVector::const_iterator i;
|
||||||
const SyncFileItemVector& items = result.syncFileItemVector();
|
const SyncFileItemVector& items = result.syncFileItemVector();
|
||||||
|
QDateTime dt = QDateTime::currentDateTime();
|
||||||
|
|
||||||
for (i = items.begin(); i != items.end(); ++i) {
|
for (i = items.begin(); i != items.end(); ++i) {
|
||||||
const SyncFileItem& item = *i;
|
const SyncFileItem& item = *i;
|
||||||
QString errMsg;
|
QString errMsg;
|
||||||
if( item._instruction == CSYNC_INSTRUCTION_IGNORE ) {
|
if( item._instruction == CSYNC_INSTRUCTION_IGNORE ) {
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
QString timeStr = QTime::currentTime().toString("hh:mm");
|
QString timeStr = timeString(dt);
|
||||||
|
QString longTimeStr = timeString(dt, QLocale::LongFormat);
|
||||||
|
|
||||||
columns << timeStr;
|
columns << timeStr;
|
||||||
columns << item._file;
|
columns << item._file;
|
||||||
|
@ -162,6 +164,7 @@ void ItemProgressDialog::setSyncResult( const SyncResult& result )
|
||||||
|
|
||||||
QTreeWidgetItem *twitem = new QTreeWidgetItem(folderItem, columns);
|
QTreeWidgetItem *twitem = new QTreeWidgetItem(folderItem, columns);
|
||||||
twitem->setData(0, ErrorIndicatorRole, QVariant(true) );
|
twitem->setData(0, ErrorIndicatorRole, QVariant(true) );
|
||||||
|
twitem->setToolTip(0, longTimeStr);
|
||||||
twitem->setIcon(0, Theme::instance()->syncStateIcon(SyncResult::Problem, true));
|
twitem->setIcon(0, Theme::instance()->syncStateIcon(SyncResult::Problem, true));
|
||||||
|
|
||||||
Q_UNUSED(twitem);
|
Q_UNUSED(twitem);
|
||||||
|
@ -321,6 +324,24 @@ void ItemProgressDialog::cleanErrors( const QString& folder )
|
||||||
qDeleteAll(wipeList.begin(), wipeList.end());
|
qDeleteAll(wipeList.begin(), wipeList.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ItemProgressDialog::timeString(QDateTime dt, QLocale::FormatType format) const
|
||||||
|
{
|
||||||
|
QLocale loc = QLocale::system();
|
||||||
|
QString timeStr;
|
||||||
|
QDate today = QDate::currentDate();
|
||||||
|
|
||||||
|
if( format == QLocale::NarrowFormat ) {
|
||||||
|
if( dt.date().day() == today.day() ) {
|
||||||
|
timeStr = loc.toString(dt.time(), QLocale::NarrowFormat);
|
||||||
|
} else {
|
||||||
|
timeStr = loc.toString(dt, QLocale::NarrowFormat);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
timeStr = loc.toString(dt, format);
|
||||||
|
}
|
||||||
|
return timeStr;
|
||||||
|
}
|
||||||
|
|
||||||
void ItemProgressDialog::slotProgressErrors( const QString& folder, const Progress::SyncProblem& problem )
|
void ItemProgressDialog::slotProgressErrors( const QString& folder, const Progress::SyncProblem& problem )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *folderItem;
|
QTreeWidgetItem *folderItem;
|
||||||
|
@ -329,7 +350,8 @@ void ItemProgressDialog::slotProgressErrors( const QString& folder, const Progre
|
||||||
if( !folderItem ) return;
|
if( !folderItem ) return;
|
||||||
|
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
QString timeStr = problem.timestamp.toString("hh:mm");
|
QString timeStr = timeString(problem.timestamp);
|
||||||
|
QString longTimeStr = timeString(problem.timestamp, QLocale::LongFormat);
|
||||||
|
|
||||||
columns << timeStr;
|
columns << timeStr;
|
||||||
columns << problem.current_file;
|
columns << problem.current_file;
|
||||||
|
@ -340,7 +362,7 @@ void ItemProgressDialog::slotProgressErrors( const QString& folder, const Progre
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(folderItem, columns);
|
QTreeWidgetItem *item = new QTreeWidgetItem(folderItem, columns);
|
||||||
item->setData(0, ErrorIndicatorRole, QVariant(true) );
|
item->setData(0, ErrorIndicatorRole, QVariant(true) );
|
||||||
item->setIcon(0, Theme::instance()->syncStateIcon(SyncResult::Problem, true));
|
item->setIcon(0, Theme::instance()->syncStateIcon(SyncResult::Problem, true));
|
||||||
|
item->setToolTip(0, longTimeStr);
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +387,8 @@ void ItemProgressDialog::slotProgressInfo( const QString& folder, const Progress
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
QString timeStr = progress.timestamp.toString("hh:mm");
|
QString timeStr = timeString(progress.timestamp);
|
||||||
|
QString longTimeStr = timeString(progress.timestamp, QLocale::LongFormat);
|
||||||
|
|
||||||
columns << timeStr;
|
columns << timeStr;
|
||||||
columns << progress.current_file;
|
columns << progress.current_file;
|
||||||
|
@ -373,6 +396,7 @@ void ItemProgressDialog::slotProgressInfo( const QString& folder, const Progress
|
||||||
columns << Utility::octetsToString( progress.file_size );
|
columns << Utility::octetsToString( progress.file_size );
|
||||||
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(folderItem, columns);
|
QTreeWidgetItem *item = new QTreeWidgetItem(folderItem, columns);
|
||||||
|
item->setToolTip(0, longTimeStr);
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "mirall/progressdispatcher.h"
|
#include "mirall/progressdispatcher.h"
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ private:
|
||||||
QTreeWidgetItem *findFolderItem( const QString& folder );
|
QTreeWidgetItem *findFolderItem( const QString& folder );
|
||||||
void cleanErrors( const QString& folder );
|
void cleanErrors( const QString& folder );
|
||||||
void decorateFolderItem( const QString& folder );
|
void decorateFolderItem( const QString& folder );
|
||||||
|
QString timeString(QDateTime dt, QLocale::FormatType format = QLocale::NarrowFormat) const;
|
||||||
|
|
||||||
QHash<QString, QTreeWidgetItem*> _folderItems;
|
QHash<QString, QTreeWidgetItem*> _folderItems;
|
||||||
const int ErrorIndicatorRole;
|
const int ErrorIndicatorRole;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void ProgressDispatcher::setProgressInfo(const QString& folder, const Progress::
|
||||||
err.current_file = newProgress.current_file;
|
err.current_file = newProgress.current_file;
|
||||||
err.error_message = QString::fromLocal8Bit( (const char*)newProgress.file_size );
|
err.error_message = QString::fromLocal8Bit( (const char*)newProgress.file_size );
|
||||||
err.error_code = newProgress.file_size;
|
err.error_code = newProgress.file_size;
|
||||||
err.timestamp = QTime::currentTime();
|
err.timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
_recentProblems.enqueue( err );
|
_recentProblems.enqueue( err );
|
||||||
if( _recentProblems.size() > _problemQueueSize ) {
|
if( _recentProblems.size() > _problemQueueSize ) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
qint64 overall_transmission_size;
|
qint64 overall_transmission_size;
|
||||||
qint64 overall_current_bytes;
|
qint64 overall_current_bytes;
|
||||||
|
|
||||||
QTime timestamp;
|
QDateTime timestamp;
|
||||||
|
|
||||||
} Info;
|
} Info;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
QString current_file;
|
QString current_file;
|
||||||
QString error_message;
|
QString error_message;
|
||||||
int error_code;
|
int error_code;
|
||||||
QTime timestamp;
|
QDateTime timestamp;
|
||||||
} SyncProblem;
|
} SyncProblem;
|
||||||
|
|
||||||
static QString asActionString( Kind );
|
static QString asActionString( Kind );
|
||||||
|
|
Loading…
Reference in a new issue