QAction *syncNowAction = new QAction(this);
syncNowAction->setShortcut(QKeySequence(Qt::Key_F6));
- connect(syncNowAction, SIGNAL(triggered()), SLOT(slotSyncCurrentFolderNow()));
+ connect(syncNowAction, SIGNAL(triggered()), SLOT(slotScheduleCurrentFolder()));
addAction(syncNowAction);
connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
connect(ac, SIGNAL(triggered(bool)), this, SLOT(doExpand()));
}
+ if (!folderPaused) {
+ ac = menu->addAction(tr("Force sync now"));
+ connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotForceSyncCurrentFolder()));
+ }
+
ac = menu->addAction(folderPaused ? tr("Resume sync") : tr("Pause sync"));
connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotEnableCurrentFolder()));
}
}
-void AccountSettings::slotSyncCurrentFolderNow()
+void AccountSettings::slotScheduleCurrentFolder()
{
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
if( !selected.isValid() )
folderMan->scheduleFolder(folderMan->folder(alias));
}
+void AccountSettings::slotForceSyncCurrentFolder()
+{
+ QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
+ if( !selected.isValid() )
+ return;
+ QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
+ FolderMan *folderMan = FolderMan::instance();
+
+ // Terminate and reschedule any running sync
+ if (Folder* current = folderMan->currentSyncFolder()) {
+ folderMan->terminateSyncProcess();
+ folderMan->scheduleFolder(current);
+ }
+
+ // Insert the selected folder at the front of the queue
+ folderMan->scheduleFolderNext(folderMan->folder(alias));
+}
+
void AccountSettings::slotOpenOC()
{
if( _OCUrl.isValid() )
protected slots:
void slotAddFolder();
void slotEnableCurrentFolder();
- void slotSyncCurrentFolderNow();
+ void slotScheduleCurrentFolder();
+ void slotForceSyncCurrentFolder();
void slotRemoveCurrentFolder();
void slotOpenCurrentFolder();
void slotFolderWizardAccepted();
startScheduledSyncSoon();
}
+void FolderMan::scheduleFolderNext(Folder* f)
+{
+ auto alias = f->alias();
+ qDebug() << "Schedule folder " << alias << " to sync! Front-of-queue.";
+
+ if( !f->canSync() ) {
+ qDebug() << "Folder is not ready to sync, not scheduled!";
+ return;
+ }
+
+ _scheduledFolders.removeAll(f);
+
+ f->prepareToSync();
+ emit folderSyncStateChange(f);
+ _scheduledFolders.prepend(f);
+ emit scheduleQueueChanged();
+
+ startScheduledSyncSoon();
+}
+
void FolderMan::slotScheduleETagJob(const QString &/*alias*/, RequestEtagJob *job)
{
QObject::connect(job, SIGNAL(destroyed(QObject*)), this, SLOT(slotEtagJobDestroyed(QObject*)));
/** Queues a folder for syncing. */
void scheduleFolder(Folder*);
+ /** Puts a folder in the very front of the queue. */
+ void scheduleFolderNext(Folder*);
+
/** Queues all folders for syncing. */
void scheduleAllFolders();
void setDirtyProxy(bool value = true);
void setDirtyNetworkLimits();
+ /**
+ * Terminates the current folder sync.
+ *
+ * It does not switch the folder to paused state.
+ */
+ void terminateSyncProcess();
+
signals:
/**
* signal to indicate a folder has changed its sync state.
void slotScheduleFolderByTime();
private:
- /**
- * Terminates the current folder sync.
- *
- * It does not switch the folder to paused state.
- */
- void terminateSyncProcess();
/** Adds a new folder, does not add it to the account settings and
* does not set an account on the new folder.