[Pkg-owncloud-commits] [owncloud-client] 146/333: Fix the file count in the progress

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit d744b5e48123f28ed341d901a4e94ac2ce47bf75
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Mar 14 18:29:23 2014 +0100

    Fix the file count in the progress
    
    And clear the ignored files between syncs
---
 src/mirall/csyncthread.cpp    | 27 +++++++++++----------------
 src/mirall/protocolwidget.cpp | 38 ++++++++++++--------------------------
 src/mirall/protocolwidget.h   |  5 ++---
 3 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp
index 14553d2..defadcc 100644
--- a/src/mirall/csyncthread.cpp
+++ b/src/mirall/csyncthread.cpp
@@ -312,20 +312,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.
         _journal->setFileRecord(SyncJournalFileRecord(item, _localPath + item._file));
@@ -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 19b47a3..012acea 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<QTreeWidgetItem*> ProtocolWidget::errorItems( const QString& folder )
+void ProtocolWidget::cleanIgnoreItems(const QString& folder)
 {
-    QList<QTreeWidgetItem*> 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<QTreeWidgetItem*> 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 3599b31..88e2ee7 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<QTreeWidgetItem*> 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;
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list