[Pkg-owncloud-commits] [owncloud-client] 183/333: restore the last change menu

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:51 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 23f3a6b31987038d0859d0d8e248c4eb507fbb38
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu Mar 20 14:43:10 2014 +0100

    restore the last change menu
    
    It was not yet implemented after the progress refactoring
---
 src/mirall/owncloudgui.cpp | 54 +++++++++++++++++++++++++---------------------
 src/mirall/owncloudgui.h   |  2 ++
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index 8dcde6f..c8f96b3 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -370,28 +370,15 @@ void ownCloudGui::slotRefreshQuotaDisplay( qint64 total, qint64 used )
 void ownCloudGui::slotRebuildRecentMenus()
 {
     _recentActionsMenu->clear();
-    // TODO
-    //_recentActionsMenu->addAction(tr("No items synced recently"))->setEnabled(false);
-/*           QString kindStr = Progress::asResultString(info);
-           QString timeStr = info.timestamp.toString("hh:mm");
-           QString actionText = tr("%1 (%2, %3)").arg(info.current_file).arg(kindStr).arg(timeStr);
-           QAction *action = _recentActionsMenu->addAction( actionText );
-            Folder *folder = FolderMan::instance()->folder(info.folder);
-            if (folder) {
-                QString fullPath = folder->path() + '/' + info.current_file;
-                if (QFile(fullPath).exists()) {
-                    _recentItemsMapper->setMapping(action, fullPath);
-                    connect(action, SIGNAL(triggered()), _recentItemsMapper, SLOT(map()));
-                } else {
-                    action->setEnabled(false);
-                }
-            }
+    if (!_recentItemsActions.isEmpty()) {
+        foreach(QAction *a, _recentItemsActions) {
+            _recentActionsMenu->addAction(a);
         }
-    }*/
-
-
+        _recentActionsMenu->addSeparator();
+    } else {
+        _recentActionsMenu->addAction(tr("No items synced recently"))->setEnabled(false);
+    }
     // add a more... entry.
-//    _recentActionsMenu->addSeparator();
     _recentActionsMenu->addAction(_actionRecent);
 }
 
@@ -408,7 +395,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
     _actionStatus->setText(tr("Syncing %1 of %2 (%3 of %4)")
         .arg(currentFile).arg(progress._totalFileCount).arg(s1, s2));
 
-            _actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
+    _actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
 
     if (!progress._lastCompletedItem.isEmpty()) {
 
@@ -418,11 +405,30 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
             _actionRecent->setIcon(warnIcon);
         }
 
+        QString kindStr = Progress::asResultString(progress._lastCompletedItem);
+        QString timeStr = QTime::currentTime().toString("hh:mm");
+        QString actionText = tr("%1 (%2, %3)").arg(progress._lastCompletedItem._file, kindStr, timeStr);
+        QAction *action = new QAction(actionText, this);
+        Folder *f = FolderMan::instance()->folder(folder);
+        if (f) {
+            QString fullPath = f->path() + '/' + progress._lastCompletedItem._file;
+            if (QFile(fullPath).exists()) {
+                _recentItemsMapper->setMapping(action, fullPath);
+                connect(action, SIGNAL(triggered()), _recentItemsMapper, SLOT(map()));
+            } else {
+                action->setEnabled(false);
+            }
+        }
+        if (_recentItemsActions.length() > 5) {
+            _recentItemsActions.takeFirst()->deleteLater();
+        }
+        _recentItemsActions.append(action);
+
         slotRebuildRecentMenus();
+    }
 
-        if (progress._completedFileCount == progress._totalFileCount) {
-            QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
-        }
+    if (progress._completedFileCount == progress._totalFileCount) {
+        QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
     }
 }
 
diff --git a/src/mirall/owncloudgui.h b/src/mirall/owncloudgui.h
index 684d6f9..8156746 100644
--- a/src/mirall/owncloudgui.h
+++ b/src/mirall/owncloudgui.h
@@ -91,6 +91,8 @@ private:
     QAction *_actionHelp;
     QAction *_actionQuit;
 
+    QList<QAction*> _recentItemsActions;
+
     QSignalMapper *_folderOpenActionMapper;
     QSignalMapper *_recentItemsMapper;
 

-- 
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