[Pkg-owncloud-commits] [owncloud-client] 60/218: FolderStatus: Show 'waiting for other folder' #3619
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 17 14:30:44 UTC 2015
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 641f56664ed9b2e900f35bf48287effb99049fe8
Author: Christian Kamm <mail at ckamm.de>
Date: Fri Sep 4 10:33:48 2015 +0200
FolderStatus: Show 'waiting for other folder' #3619
We monitor the scheduling queue and show messages like
"Waiting for 5 other folders...".
---
src/gui/folderman.cpp | 26 +++++++++++++++++++++-----
src/gui/folderman.h | 15 +++++++++++++++
src/gui/folderstatusmodel.cpp | 43 ++++++++++++++++++++++++++++++++++++-------
src/gui/folderstatusmodel.h | 3 ++-
4 files changed, 74 insertions(+), 13 deletions(-)
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index 3d0428b..b5edbe6 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -134,6 +134,7 @@ int FolderMan::unloadAndDeleteAllFolders()
_lastSyncFolder = 0;
_currentSyncFolder = 0;
_scheduleQueue.clear();
+ emit scheduleQueueChanged();
Q_ASSERT(_folderMap.count() == 0);
return cnt;
@@ -254,7 +255,7 @@ int FolderMan::setupFoldersMigration()
Folder *f = setupFolderFromOldConfigFile( alias, accountState );
if( f ) {
slotScheduleSync(f);
- emit( folderSyncStateChange( f ) );
+ emit folderSyncStateChange(f);
}
}
@@ -502,16 +503,17 @@ void FolderMan::slotScheduleSync( Folder *f )
qDebug() << "Schedule folder " << alias << " to sync!";
if( ! _scheduleQueue.contains(f) ) {
- if(f->canSync()) {
- f->prepareToSync();
- } else {
+ if( !f->canSync() ) {
qDebug() << "Folder is not ready to sync, not scheduled!";
if( _socketApi ) {
_socketApi->slotUpdateFolderView(f);
}
return;
}
+ f->prepareToSync();
+ emit folderSyncStateChange(f);
_scheduleQueue.enqueue(f);
+ emit scheduleQueueChanged();
} else {
qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!";
}
@@ -593,6 +595,7 @@ void FolderMan::slotAccountStateChanged()
it.remove();
}
}
+ emit scheduleQueueChanged();
}
}
@@ -685,6 +688,7 @@ void FolderMan::slotStartScheduledFolderSync()
// Try to start the top scheduled sync.
Folder *f = _scheduleQueue.dequeue();
+ emit scheduleQueueChanged();
Q_ASSERT(f);
// Start syncing this folder!
@@ -843,7 +847,9 @@ void FolderMan::slotRemoveFolder( Folder *f )
terminateSyncProcess();
}
- _scheduleQueue.removeAll(f);
+ if (_scheduleQueue.removeAll(f) > 0) {
+ emit scheduleQueueChanged();
+ }
f->wipe();
f->setSyncPaused(true);
@@ -1194,6 +1200,16 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore)
}
}
+QQueue<Folder*> FolderMan::scheduleQueue() const
+{
+ return _scheduleQueue;
+}
+
+Folder *FolderMan::currentSyncFolder() const
+{
+ return _currentSyncFolder;
+}
+
void FolderMan::restartApplication()
{
if( Utility::isLinux() ) {
diff --git a/src/gui/folderman.h b/src/gui/folderman.h
index 013ce83..0dd0522 100644
--- a/src/gui/folderman.h
+++ b/src/gui/folderman.h
@@ -109,6 +109,16 @@ public:
bool ignoreHiddenFiles() const;
void setIgnoreHiddenFiles(bool ignore);
+ /**
+ * Access to the current queue of scheduled folders.
+ */
+ QQueue<Folder*> scheduleQueue() const;
+
+ /**
+ * Access to the currently syncing folder.
+ */
+ Folder* currentSyncFolder() const;
+
signals:
/**
* signal to indicate a folder has changed its sync state.
@@ -117,6 +127,11 @@ signals:
*/
void folderSyncStateChange(Folder*);
+ /**
+ * Indicates when the schedule queue changes.
+ */
+ void scheduleQueueChanged();
+
void folderListLoaded(const Folder::Map &);
public slots:
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index e7f5705..19f5b5a 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -45,6 +45,11 @@ void FolderStatusModel::setAccountState(const AccountState* accountState)
_folders.clear();
_accountState = accountState;
+ connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)),
+ SLOT(slotFolderSyncStateChange(Folder*)), Qt::UniqueConnection);
+ connect(FolderMan::instance(), SIGNAL(scheduleQueueChanged()),
+ SLOT(slotFolderScheduleQueueChanged()), Qt::UniqueConnection);
+
auto folders = FolderMan::instance()->map();
foreach (auto f, folders) {
if (f->accountState() != accountState)
@@ -58,7 +63,6 @@ void FolderStatusModel::setAccountState(const AccountState* accountState)
_folders << info;
connect(f, SIGNAL(progressInfo(ProgressInfo)), this, SLOT(slotSetProgress(ProgressInfo)), Qt::UniqueConnection);
- connect(f, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
connect(f, SIGNAL(newBigFolderDiscovered(QString)), this, SLOT(slotNewBigFolder()), Qt::UniqueConnection);
}
@@ -840,9 +844,8 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
emit dataChanged(index(folderIndex), index(folderIndex), roles);
}
-void FolderStatusModel::slotFolderSyncStateChange()
+void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
{
- Folder *f = qobject_cast<Folder*>(sender());
if( !f ) { return; }
int folderIndex = -1;
@@ -855,10 +858,26 @@ void FolderStatusModel::slotFolderSyncStateChange()
if (folderIndex < 0) { return; }
SyncResult::Status state = f->syncResult().status();
- if (state == SyncResult::SyncPrepare
- || state == SyncResult::Problem
- || state == SyncResult::Success) {
- // Reset the progress info before and after a sync.
+ if (state == SyncResult::NotYetStarted) {
+ FolderMan* folderMan = FolderMan::instance();
+ int pos = folderMan->scheduleQueue().indexOf(f);
+ if (folderMan->currentSyncFolder()
+ && folderMan->currentSyncFolder() != f) {
+ pos += 1;
+ }
+ QString message;
+ if (pos <= 0) {
+ message = tr("Waiting...");
+ } else {
+ message = tr("Waiting for %n other folder(s)...", "", pos);
+ }
+ _folders[folderIndex]._progress = SubFolderInfo::Progress();
+ _folders[folderIndex]._progress._progressString = message;
+ } else if (state == SyncResult::SyncPrepare) {
+ _folders[folderIndex]._progress = SubFolderInfo::Progress();
+ _folders[folderIndex]._progress._progressString = tr("Preparing to sync...");
+ } else if (state == SyncResult::Problem || state == SyncResult::Success) {
+ // Reset the progress info after a sync.
_folders[folderIndex]._progress = SubFolderInfo::Progress();
} else if (state == SyncResult::Error) {
_folders[folderIndex]._progress._progressString = f->syncResult().errorString();
@@ -885,6 +904,16 @@ void FolderStatusModel::slotFolderSyncStateChange()
}
}
+void FolderStatusModel::slotFolderScheduleQueueChanged()
+{
+ // Update messages on waiting folders.
+ // It's ok to only update folders currently in the queue, because folders
+ // are only removed from the queue if they are deleted.
+ foreach (Folder* f, FolderMan::instance()->scheduleQueue()) {
+ slotFolderSyncStateChange(f);
+ }
+}
+
void FolderStatusModel::resetFolders()
{
setAccountState(_accountState);
diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h
index c19f0fe..c36ffc1 100644
--- a/src/gui/folderstatusmodel.h
+++ b/src/gui/folderstatusmodel.h
@@ -101,7 +101,8 @@ public slots:
private slots:
void slotUpdateDirectories(const QStringList &);
void slotLscolFinishedWithError(QNetworkReply *r);
- void slotFolderSyncStateChange();
+ void slotFolderSyncStateChange(Folder* f);
+ void slotFolderScheduleQueueChanged();
void slotNewBigFolder();
private:
--
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