mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-14 17:51:41 +03:00
Account settings: add the progress back on the new ui
This commit is contained in:
parent
426d2338d9
commit
85ff245aef
4 changed files with 66 additions and 151 deletions
|
@ -232,70 +232,6 @@ void AccountSettings::setGeneralErrors( const QStringList& errors )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f, bool accountConnected )
|
|
||||||
{
|
|
||||||
if( ! item || !f ) return;
|
|
||||||
|
|
||||||
item->setData( f->nativePath(), FolderStatusDelegate::FolderPathRole );
|
|
||||||
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();
|
|
||||||
|
|
||||||
QStringList errorList = res.errorStrings();
|
|
||||||
|
|
||||||
Theme *theme = Theme::instance();
|
|
||||||
item->setData( theme->statusHeaderText( status ), Qt::ToolTipRole );
|
|
||||||
if ( accountConnected ) {
|
|
||||||
if( f->syncPaused() ) {
|
|
||||||
item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before
|
|
||||||
_wasDisabledBefore = false;
|
|
||||||
} else {
|
|
||||||
if( status == SyncResult::SyncPrepare ) {
|
|
||||||
if( _wasDisabledBefore ) {
|
|
||||||
// if the folder was disabled before, set the sync icon
|
|
||||||
item->setData( theme->syncStateIcon( SyncResult::SyncRunning), FolderStatusDelegate::FolderStatusIconRole );
|
|
||||||
} // we keep the previous icon for the SyncPrepare state.
|
|
||||||
} else if( status == SyncResult::Undefined ) {
|
|
||||||
// startup, the sync was never done.
|
|
||||||
qDebug() << "XXX FIRST time sync, setting icon to sync running!";
|
|
||||||
item->setData( theme->syncStateIcon( SyncResult::SyncRunning), FolderStatusDelegate::FolderStatusIconRole );
|
|
||||||
} else {
|
|
||||||
// kepp the previous icon for the prepare phase.
|
|
||||||
if( status == SyncResult::Problem) {
|
|
||||||
item->setData( theme->syncStateIcon( SyncResult::Success), FolderStatusDelegate::FolderStatusIconRole );
|
|
||||||
} else {
|
|
||||||
item->setData( theme->syncStateIcon( status ), FolderStatusDelegate::FolderStatusIconRole );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item->setData( theme->folderOfflineIcon(), FolderStatusDelegate::FolderStatusIconRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
item->setData( theme->statusHeaderText( status ), FolderStatusDelegate::FolderStatus );
|
|
||||||
|
|
||||||
if( errorList.isEmpty() ) {
|
|
||||||
if( (status == SyncResult::Error ||
|
|
||||||
status == SyncResult::SetupError ||
|
|
||||||
status == SyncResult::SyncAbortRequested )) {
|
|
||||||
errorList << theme->statusHeaderText(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item->setData( errorList, 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()
|
void AccountSettings::slotRemoveCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||||
|
@ -452,27 +388,13 @@ void AccountSettings::slotSyncCurrentFolderNow()
|
||||||
|
|
||||||
void AccountSettings::slotUpdateFolderState( Folder *folder )
|
void AccountSettings::slotUpdateFolderState( Folder *folder )
|
||||||
{
|
{
|
||||||
QStandardItem *item = 0;
|
|
||||||
int row = 0;
|
|
||||||
|
|
||||||
if( ! folder ) return;
|
if( ! folder ) return;
|
||||||
#if 0
|
|
||||||
item = _model->item( row );
|
|
||||||
|
|
||||||
while( item ) {
|
auto folderList = FolderMan::instance()->map().values();
|
||||||
if( item->data( FolderStatusDelegate::FolderAliasRole ) == folder->alias() ) {
|
auto folderIndex = folderList.indexOf(folder);
|
||||||
// its the item to update!
|
if (folderIndex < 0) { return; }
|
||||||
break;
|
emit _model->dataChanged(_model->index(folderIndex), _model->index(folderIndex),
|
||||||
}
|
QVector<int>() << FolderStatusDelegate::AddProgressSpace);
|
||||||
item = _model->item( ++row );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( item ) {
|
|
||||||
folderToModelItem( item, folder, _accountState->isConnectedOrMaintenance() );
|
|
||||||
} else {
|
|
||||||
// the dialog is not visible.
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotOpenOC()
|
void AccountSettings::slotOpenOC()
|
||||||
|
@ -481,11 +403,6 @@ void AccountSettings::slotOpenOC()
|
||||||
QDesktopServices::openUrl( _OCUrl );
|
QDesktopServices::openUrl( _OCUrl );
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem* AccountSettings::itemForFolder(const QString& folder)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccountSettings::shortenFilename( const QString& folder, const QString& file ) const
|
QString AccountSettings::shortenFilename( const QString& folder, const QString& file ) const
|
||||||
{
|
{
|
||||||
// strip off the server prefix from the file name
|
// strip off the server prefix from the file name
|
||||||
|
@ -508,26 +425,35 @@ QString AccountSettings::shortenFilename( const QString& folder, const QString&
|
||||||
|
|
||||||
void AccountSettings::slotSetProgress(const QString& folder, const Progress::Info &progress )
|
void AccountSettings::slotSetProgress(const QString& folder, const Progress::Info &progress )
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (!isVisible()) {
|
if (!isVisible()) {
|
||||||
return; // for https://github.com/owncloud/client/issues/2648#issuecomment-71377909
|
return; // for https://github.com/owncloud/client/issues/2648#issuecomment-71377909
|
||||||
}
|
}
|
||||||
QStandardItem *item = itemForFolder( folder );
|
|
||||||
if( !item ) return;
|
|
||||||
|
|
||||||
// switch on extra space.
|
Folder *f = FolderMan::instance()->folder(folder);
|
||||||
item->setData( QVariant(true), FolderStatusDelegate::AddProgressSpace );
|
if( !f ) { return; }
|
||||||
|
|
||||||
|
auto folderList = FolderMan::instance()->map().values();
|
||||||
|
auto folderIndex = folderList.indexOf(f);
|
||||||
|
if (folderIndex < 0) { return; }
|
||||||
|
|
||||||
|
if (_model->_progresses.size() <= folderIndex) {
|
||||||
|
_model->_progresses.resize(folderIndex + 1);
|
||||||
|
}
|
||||||
|
FolderStatusModel::ProgressInfo *progressInfo = &_model->_progresses[folderIndex];
|
||||||
|
|
||||||
|
QVector<int> roles;
|
||||||
|
roles << FolderStatusDelegate::AddProgressSpace << FolderStatusDelegate::SyncProgressItemString
|
||||||
|
<< FolderStatusDelegate::WarningCount;
|
||||||
|
|
||||||
if (!progress._currentDiscoveredFolder.isEmpty()) {
|
if (!progress._currentDiscoveredFolder.isEmpty()) {
|
||||||
item->setData( tr("Discovering '%1'").arg(progress._currentDiscoveredFolder) , FolderStatusDelegate::SyncProgressItemString );
|
progressInfo->_progressString = tr("Discovering '%1'").arg(progress._currentDiscoveredFolder);
|
||||||
|
emit _model->dataChanged(_model->index(folderIndex), _model->index(folderIndex), roles);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!progress._lastCompletedItem.isEmpty()
|
if(!progress._lastCompletedItem.isEmpty()
|
||||||
&& Progress::isWarningKind(progress._lastCompletedItem._status)) {
|
&& Progress::isWarningKind(progress._lastCompletedItem._status)) {
|
||||||
int warnCount = item->data(FolderStatusDelegate::WarningCount).toInt();
|
progressInfo->_warningCount++;
|
||||||
warnCount++;
|
|
||||||
item->setData( QVariant(warnCount), FolderStatusDelegate::WarningCount );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the single item to display: This is going to be the bigger item, or the last completed
|
// find the single item to display: This is going to be the bigger item, or the last completed
|
||||||
|
@ -571,7 +497,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
||||||
//: Example text: "uploading foobar.png"
|
//: Example text: "uploading foobar.png"
|
||||||
fileProgressString = tr("%1 %2").arg(kindString, itemFileName);
|
fileProgressString = tr("%1 %2").arg(kindString, itemFileName);
|
||||||
}
|
}
|
||||||
item->setData( fileProgressString,FolderStatusDelegate::SyncProgressItemString);
|
progressInfo->_progressString = fileProgressString;
|
||||||
|
|
||||||
// overall progress
|
// overall progress
|
||||||
quint64 completedSize = progress.completedSize();
|
quint64 completedSize = progress.completedSize();
|
||||||
|
@ -593,81 +519,56 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
||||||
overallSyncString = tr("file %1 of %2") .arg(currentFile).arg(totalFileCount);
|
overallSyncString = tr("file %1 of %2") .arg(currentFile).arg(totalFileCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setData( overallSyncString, FolderStatusDelegate::SyncProgressOverallString );
|
progressInfo->_overallSyncString = overallSyncString;
|
||||||
|
|
||||||
int overallPercent = 0;
|
int overallPercent = 0;
|
||||||
if( totalFileCount > 0 ) {
|
if( totalFileCount > 0 ) {
|
||||||
// Add one 'byte' for each files so the percentage is moving when deleting or renaming files
|
// Add one 'byte' for each files so the percentage is moving when deleting or renaming files
|
||||||
overallPercent = qRound(double(completedSize + progress._completedFileCount)/double(totalSize + totalFileCount) * 100.0);
|
overallPercent = qRound(double(completedSize + progress._completedFileCount)/double(totalSize + totalFileCount) * 100.0);
|
||||||
}
|
}
|
||||||
overallPercent = qBound(0, overallPercent, 100);
|
progressInfo->_overallPercent = qBound(0, overallPercent, 100);
|
||||||
item->setData( overallPercent, FolderStatusDelegate::SyncProgressOverallPercent);
|
emit _model->dataChanged(_model->index(folderIndex), _model->index(folderIndex), roles);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotHideProgress()
|
void AccountSettings::slotHideProgress()
|
||||||
{
|
{
|
||||||
#if 0
|
auto folderIndex = sender()->property("owncloud_folderIndex").toInt();
|
||||||
QTimer *send_timer = qobject_cast<QTimer*>(this->sender());
|
if (folderIndex < 0) { return; }
|
||||||
QHash<QStandardItem*, QTimer*>::const_iterator i = _hideProgressTimers.constBegin();
|
|
||||||
while (i != _hideProgressTimers.constEnd()) {
|
|
||||||
if( i.value() == send_timer ) {
|
|
||||||
QStandardItem *item = i.key();
|
|
||||||
|
|
||||||
/* Check if this item is still existing */
|
if (_model->_progresses.size() <= folderIndex) {
|
||||||
bool ok = false;
|
return;
|
||||||
for( int r = 0; !ok && r < _model->rowCount(); r++) {
|
|
||||||
if( item == _model->item(r,0) ) {
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ok ) {
|
_model->_progresses[folderIndex] = FolderStatusModel::ProgressInfo();
|
||||||
item->setData( false, FolderStatusDelegate::AddProgressSpace );
|
emit _model->dataChanged(_model->index(folderIndex), _model->index(folderIndex),
|
||||||
item->setData( QString(), FolderStatusDelegate::SyncProgressOverallString );
|
QVector<int>() << FolderStatusDelegate::AddProgressSpace);
|
||||||
item->setData( QString(), FolderStatusDelegate::SyncProgressItemString );
|
|
||||||
item->setData( 0, FolderStatusDelegate::SyncProgressOverallPercent );
|
|
||||||
}
|
|
||||||
_hideProgressTimers.remove(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
send_timer->deleteLater();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotFolderSyncStateChange()
|
void AccountSettings::slotFolderSyncStateChange()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
Folder* folder = qobject_cast<Folder *>(sender());
|
Folder* folder = qobject_cast<Folder *>(sender());
|
||||||
if (!folder) return;
|
if (!folder) return;
|
||||||
|
auto folderList = FolderMan::instance()->map().values();
|
||||||
QStandardItem *item = itemForFolder( folder->alias() );
|
auto folderIndex = folderList.indexOf(folder);
|
||||||
if( !item ) return;
|
if (folderIndex < 0) { return; }
|
||||||
|
|
||||||
SyncResult::Status state = folder->syncResult().status();
|
SyncResult::Status state = folder->syncResult().status();
|
||||||
if (state == SyncResult::SyncPrepare) {
|
if (state == SyncResult::SyncPrepare) {
|
||||||
item->setData( QVariant(0), FolderStatusDelegate::WarningCount );
|
if (_model->_progresses.size() > folderIndex) {
|
||||||
|
_model->_progresses[folderIndex] = FolderStatusModel::ProgressInfo();
|
||||||
|
}
|
||||||
} else if (state == SyncResult::Success || state == SyncResult::Problem) {
|
} else if (state == SyncResult::Success || state == SyncResult::Problem) {
|
||||||
// start a timer to stop the progress display
|
// start a timer to stop the progress display
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
if( _hideProgressTimers.contains(item) ) {
|
|
||||||
timer = _hideProgressTimers[item];
|
|
||||||
// there is already one timer running.
|
|
||||||
} else {
|
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(slotHideProgress()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(slotHideProgress()));
|
||||||
|
connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
_hideProgressTimers.insert(item, timer);
|
timer->setProperty("owncloud_folderIndex", folderIndex);
|
||||||
}
|
|
||||||
timer->start(5000);
|
timer->start(5000);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
|
void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
|
||||||
{
|
{
|
||||||
if( total > 0 ) {
|
if( total > 0 ) {
|
||||||
|
|
|
@ -19,14 +19,11 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QStandardItem>
|
|
||||||
|
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
#include "progressdispatcher.h"
|
#include "progressdispatcher.h"
|
||||||
|
|
||||||
class QStandardItemModel;
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QStandardItem;
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
@ -83,15 +80,12 @@ protected slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString shortenFilename( const QString& folder, const QString& file ) const;
|
QString shortenFilename( const QString& folder, const QString& file ) const;
|
||||||
void folderToModelItem(QStandardItem *, Folder * , bool accountConnected);
|
|
||||||
QStandardItem* itemForFolder(const QString& );
|
|
||||||
void showConnectionLabel( const QString& message, const QString& tooltip = QString() );
|
void showConnectionLabel( const QString& message, const QString& tooltip = QString() );
|
||||||
|
|
||||||
Ui::AccountSettings *ui;
|
Ui::AccountSettings *ui;
|
||||||
|
|
||||||
FolderStatusModel *_model;
|
FolderStatusModel *_model;
|
||||||
QUrl _OCUrl;
|
QUrl _OCUrl;
|
||||||
QHash<QStandardItem*, QTimer*> _hideProgressTimers;
|
|
||||||
QStringList _generalErrors;
|
QStringList _generalErrors;
|
||||||
bool _wasDisabledBefore;
|
bool _wasDisabledBefore;
|
||||||
AccountState *_accountState;
|
AccountState *_accountState;
|
||||||
|
|
|
@ -131,6 +131,16 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
||||||
} else {
|
} else {
|
||||||
return Theme::instance()->folderOfflineIcon();
|
return Theme::instance()->folderOfflineIcon();
|
||||||
}
|
}
|
||||||
|
case FolderStatusDelegate::AddProgressSpace:
|
||||||
|
return !_progresses.value(index.row()).isNull();
|
||||||
|
case FolderStatusDelegate::SyncProgressItemString:
|
||||||
|
return _progresses.value(index.row())._progressString;
|
||||||
|
case FolderStatusDelegate::WarningCount:
|
||||||
|
return _progresses.value(index.row())._warningCount;
|
||||||
|
case FolderStatusDelegate::SyncProgressOverallPercent:
|
||||||
|
return _progresses.value(index.row())._overallPercent;
|
||||||
|
case FolderStatusDelegate::SyncProgressOverallString:
|
||||||
|
return _progresses.value(index.row())._overallSyncString;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
struct SubFolderInfo {
|
struct SubFolderInfo {
|
||||||
// QWeakPointer<SubFolderInfo> parent;
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _path;
|
QString _path;
|
||||||
QVector<int> _pathIdx;
|
QVector<int> _pathIdx;
|
||||||
|
@ -68,6 +67,17 @@ public:
|
||||||
|
|
||||||
bool isDirty() { return _dirty; }
|
bool isDirty() { return _dirty; }
|
||||||
|
|
||||||
|
struct ProgressInfo {
|
||||||
|
bool isNull() const
|
||||||
|
{ return _progressString.isEmpty() && _warningCount == 0 && _overallSyncString.isEmpty(); }
|
||||||
|
QString _progressString;
|
||||||
|
QString _overallSyncString;
|
||||||
|
int _warningCount = 0;
|
||||||
|
int _overallPercent = 0;
|
||||||
|
};
|
||||||
|
QVector<ProgressInfo> _progresses;
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotApplySelectiveSync();
|
void slotApplySelectiveSync();
|
||||||
void resetFolders();
|
void resetFolders();
|
||||||
|
|
Loading…
Reference in a new issue