connect(ui->selectiveSyncApply, SIGNAL(clicked()), _model, SLOT(slotApplySelectiveSync()));
connect(ui->selectiveSyncCancel, SIGNAL(clicked()), _model, SLOT(resetFolders()));
+ connect(ui->bigFolderApply, SIGNAL(clicked(bool)), _model, SLOT(slotApplySelectiveSync()));
+ connect(ui->bigFolderSyncAll, SIGNAL(clicked(bool)), _model, SLOT(slotSyncAllPendingBigFolders()));
+ connect(ui->bigFolderSyncNone, SIGNAL(clicked(bool)), _model, SLOT(slotSyncNoPendingBigFolders()));
+
connect(FolderMan::instance(), SIGNAL(folderListChanged(Folder::Map)), _model, SLOT(resetFolders()));
connect(this, SIGNAL(folderChanged()), _model, SLOT(resetFolders()));
}
if (msg.isEmpty()) {
- ui->selectiveSyncNotification->setVisible(false);
- ui->selectiveSyncNotification->setText(QString());
+ ui->selectiveSyncButtons->setVisible(true);
+ ui->bigFolderUi->setVisible(false);
} else {
- ui->selectiveSyncNotification->setVisible(true);
QString wholeMsg = tr("There are new folders that were not synchronized because they are too big: ") + msg;
ui->selectiveSyncNotification->setText(wholeMsg);
+ ui->selectiveSyncButtons->setVisible(false);
+ ui->bigFolderUi->setVisible(true);
shouldBeVisible = true;
}
</widget>
</item>
<item>
- <widget class="QLabel" name="selectiveSyncNotification">
- <property name="styleSheet">
- <string notr="true">color: red</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
+ <widget class="QWidget" name="bigFolderUi" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="selectiveSyncNotification">
+ <property name="styleSheet">
+ <string notr="true">color: red</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="bigFolderSyncAll">
+ <property name="text">
+ <string>Synchronize all</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bigFolderSyncNone">
+ <property name="text">
+ <string>Synchronize none</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bigFolderApply">
+ <property name="text">
+ <string>Apply manual changes</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
</item>
</layout>
</item>
<item>
- <widget class="QPushButton" name="selectiveSyncCancel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="selectiveSyncApply">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Apply</string>
- </property>
+ <widget class="QWidget" name="selectiveSyncButtons" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="selectiveSyncCancel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="selectiveSyncApply">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
</layout>
setAccountState(_accountState);
}
+void FolderStatusModel::slotSyncAllPendingBigFolders()
+{
+ for (int i = 0; i < _folders.count(); ++i) {
+ if (!_folders[i]._fetched) {
+ _folders[i]._folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
+ continue;
+ }
+ auto folder = _folders.at(i)._folder;
+
+ bool ok;
+ auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
+ if( !ok ) {
+ qDebug() << Q_FUNC_INFO << "Could not read selective sync list from db.";
+ return;
+ }
+
+ // If this folder had no undecided entries, skip it.
+ if (undecidedList.isEmpty()) {
+ continue;
+ }
+
+ // Remove all undecided folders from the blacklist
+ auto blackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
+ if( !ok ) {
+ qDebug() << Q_FUNC_INFO << "Could not read selective sync list from db.";
+ return;
+ }
+ foreach (const auto& undecidedFolder, undecidedList) {
+ blackList.removeAll(undecidedFolder);
+ }
+ folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
+
+ // Add all undecided folders to the white list
+ auto whiteList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok);
+ if( !ok ) {
+ qDebug() << Q_FUNC_INFO << "Could not read selective sync list from db.";
+ return;
+ }
+ whiteList += undecidedList;
+ folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, whiteList);
+
+ // Clear the undecided list
+ folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
+
+ // Trigger a sync
+ if (folder->isBusy()) {
+ folder->slotTerminateSync();
+ }
+ // The part that changed should not be read from the DB on next sync because there might be new folders
+ // (the ones that are no longer in the blacklist)
+ foreach (const auto &it, undecidedList) {
+ folder->journalDb()->avoidReadFromDbOnNextSync(it);
+ }
+ FolderMan::instance()->slotScheduleSync(folder);
+ }
+
+ resetFolders();
+}
+
+void FolderStatusModel::slotSyncNoPendingBigFolders()
+{
+ for (int i = 0; i < _folders.count(); ++i) {
+ auto folder = _folders.at(i)._folder;
+
+ // clear the undecided list
+ folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
+ }
+
+ resetFolders();
+}
+
void FolderStatusModel::slotNewBigFolder()
{
auto f = qobject_cast<Folder *>(sender());
void slotUpdateFolderState(Folder *);
void slotApplySelectiveSync();
void resetFolders();
+ void slotSyncAllPendingBigFolders();
+ void slotSyncNoPendingBigFolders();
void slotSetProgress(const ProgressInfo &progress);
private slots: