diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp index 14553d274..defadcca5 100644 --- a/src/mirall/csyncthread.cpp +++ b/src/mirall/csyncthread.cpp @@ -311,20 +311,6 @@ int CSyncThread::treewalkFile( TREE_WALK_FILE *file, bool remote ) int re = 0; - switch(file->instruction) { - case CSYNC_INSTRUCTION_NONE: - break; - case CSYNC_INSTRUCTION_NEW: - case CSYNC_INSTRUCTION_SYNC: - case CSYNC_INSTRUCTION_CONFLICT: - case CSYNC_INSTRUCTION_RENAME: - case CSYNC_INSTRUCTION_REMOVE: - _progressInfo._totalFileCount++; - _progressInfo._totalSize += file->size; - //fall trough - default: - _needsUpdate = true; - } switch(file->instruction) { case CSYNC_INSTRUCTION_UPDATED: // We need to update the database. @@ -376,8 +362,16 @@ int CSyncThread::treewalkFile( TREE_WALK_FILE *file, bool remote ) && file->instruction != CSYNC_INSTRUCTION_REMOVE) { _hasFiles = true; } - _syncedItems.append(item); + if (!item._isDirectory) { + _progressInfo._totalFileCount++; + if (Progress::isSizeDependent(file->instruction)) { + _progressInfo._totalSize += file->size; + } + } + _needsUpdate = true; + + _syncedItems.append(item); emit syncItemDisconvered(item); return re; } @@ -537,7 +531,6 @@ void CSyncThread::slotUpdateFinished(int updateResult) _progressInfo = Progress::Info(); - emit transmissionProgress(Progress::StartSync, _progressInfo); _hasFiles = false; bool walkOk = true; @@ -557,6 +550,8 @@ void CSyncThread::slotUpdateFinished(int updateResult) it->_file = adjustRenamedPath(it->_file); } + emit transmissionProgress(Progress::StartSync, _progressInfo); + if (!_hasFiles && !_syncedItems.isEmpty()) { qDebug() << Q_FUNC_INFO << "All the files are going to be removed, asking the user"; bool cancel = false; diff --git a/src/mirall/protocolwidget.cpp b/src/mirall/protocolwidget.cpp index 19b47a379..012aceab5 100644 --- a/src/mirall/protocolwidget.cpp +++ b/src/mirall/protocolwidget.cpp @@ -32,7 +32,7 @@ namespace Mirall { ProtocolWidget::ProtocolWidget(QWidget *parent) : QWidget(parent), - ErrorIndicatorRole( Qt::UserRole +1 ), + IgnoredIndicatorRole( Qt::UserRole +1 ), _ui(new Ui::ProtocolWidget) { _ui->setupUi(this); @@ -125,29 +125,17 @@ void ProtocolWidget::slotClearBlacklist() folderMan->slotScheduleAllFolders(); } -QList ProtocolWidget::errorItems( const QString& folder ) +void ProtocolWidget::cleanIgnoreItems(const QString& folder) { - QList list; - int itemCnt = _ui->_treeWidget->topLevelItemCount(); - - for( int cnt = 0; cnt < itemCnt; cnt++ ) { + for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) { QTreeWidgetItem *item = _ui->_treeWidget->topLevelItem(cnt); - bool isErrorItem = item->data(0, ErrorIndicatorRole).toBool(); + bool isErrorItem = item->data(0, IgnoredIndicatorRole).toBool(); QString itemFolder = item->data(2, Qt::DisplayRole).toString(); if( isErrorItem && itemFolder == folder ) { - list.append(item); + delete item; } } - return list; -} - -void ProtocolWidget::cleanErrorItems( const QString& folder ) // FIXME: Use the folder to detect which errors can be deleted. -{ - QList wipeList = errorItems(folder); - if( wipeList.count() > 0 ) { - qDeleteAll(wipeList.begin(), wipeList.end()); - } } QString ProtocolWidget::timeString(QDateTime dt, QLocale::FormatType format) const @@ -215,7 +203,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo QTreeWidgetItem *twitem = new QTreeWidgetItem(columns); if (item._status == SyncFileItem::FileIgnored) { // Tell that we want to remove it on the next sync. - twitem->setData(0, ErrorIndicatorRole, true); + twitem->setData(0, IgnoredIndicatorRole, true); } twitem->setIcon(0, icon); @@ -247,16 +235,14 @@ void ProtocolWidget::computeResyncButtonEnabled() void ProtocolWidget::slotProgressInfo( const QString& folder, const Progress::Info& progress ) { - /* - if( progress.kind == Progress::StartSync ) { - cleanErrorItems( folder ); - _clearBlacklistBtn->setEnabled(false); - } - - if( progress.kind == Progress::EndSync ) { + if( progress._completedFileCount == 0 ) { + // The sync is restarting, clean the old items + cleanIgnoreItems(folder); + computeResyncButtonEnabled(); + } else if (progress._totalFileCount == progress._completedFileCount) { + //Sync completed computeResyncButtonEnabled(); } - */ SyncFileItem last = progress._lastCompletedItem; if (last.isEmpty()) return; diff --git a/src/mirall/protocolwidget.h b/src/mirall/protocolwidget.h index 3599b313c..88e2ee722 100644 --- a/src/mirall/protocolwidget.h +++ b/src/mirall/protocolwidget.h @@ -54,15 +54,14 @@ signals: private: void setSyncResultStatus(const SyncResult& result ); - void cleanErrorItems( const QString& folder ); + void cleanIgnoreItems( const QString& folder ); void computeResyncButtonEnabled(); QTreeWidgetItem* createCompletedTreewidgetItem(const QString &folder, const SyncFileItem &item ); - QList errorItems(const QString &folder); QString timeString(QDateTime dt, QLocale::FormatType format = QLocale::NarrowFormat) const; - const int ErrorIndicatorRole; + const int IgnoredIndicatorRole; Ui::ProtocolWidget *_ui; QPushButton *_clearBlacklistBtn; };