Accountsettings: Show a notification when there are new unconfirmed folders

This commit is contained in:
Olivier Goffart 2015-06-12 11:28:56 +02:00
parent 53f2468430
commit 81c10da8dc
5 changed files with 69 additions and 35 deletions

View file

@ -85,7 +85,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
connect(ui->_folderList, SIGNAL(expanded(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus())); connect(ui->_folderList, SIGNAL(expanded(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
connect(ui->_folderList, SIGNAL(collapsed(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus())); connect(ui->_folderList, SIGNAL(collapsed(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
connect(_model, SIGNAL(dirtyChanged()), this, SLOT(refreshSelectiveSyncStatus())); connect(_model, SIGNAL(dirtyChanged()), this, SLOT(refreshSelectiveSyncStatus()));
ui->selectiveSyncStatus->hide(); refreshSelectiveSyncStatus();
QAction *resetFolderAction = new QAction(this); QAction *resetFolderAction = new QAction(this);
resetFolderAction->setShortcut(QKeySequence(Qt::Key_F5)); resetFolderAction->setShortcut(QKeySequence(Qt::Key_F5));
@ -443,13 +443,31 @@ AccountSettings::~AccountSettings()
void AccountSettings::refreshSelectiveSyncStatus() void AccountSettings::refreshSelectiveSyncStatus()
{ {
ui->selectiveSyncApply->setEnabled(_model->isDirty());
ui->selectiveSyncCancel->setEnabled(_model->isDirty());
bool shouldBeVisible = _model->isDirty(); bool shouldBeVisible = _model->isDirty();
QStringList undecidedFolder;
for (int i = 0; !shouldBeVisible && i < _model->rowCount(); ++i) { for (int i = 0; !shouldBeVisible && i < _model->rowCount(); ++i) {
if (ui->_folderList->isExpanded(_model->index(i))) if (ui->_folderList->isExpanded(_model->index(i)))
shouldBeVisible = true; shouldBeVisible = true;
} }
foreach (Folder *folder, FolderMan::instance()->map().values()) {
if (folder->accountState() != _accountState) { continue; }
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
foreach(const auto &it, undecidedList) {
undecidedFolder += ( folder->alias() + QLatin1String("/") + it);
}
}
if (undecidedFolder.isEmpty()) {
ui->selectiveSyncNotification->setText(QString());
} else {
ui->selectiveSyncNotification->setText(
tr("There are new shared folders that were not synchronized because they are too big: %1")
.arg(undecidedFolder.join(tr(", "))));
shouldBeVisible = true;
}
ui->selectiveSyncApply->setEnabled(_model->isDirty() || !undecidedFolder.isEmpty());
ui->selectiveSyncCancel->setEnabled(_model->isDirty());
bool wasVisible = ui->selectiveSyncApply->isVisible(); bool wasVisible = ui->selectiveSyncApply->isVisible();
if (wasVisible != shouldBeVisible) { if (wasVisible != shouldBeVisible) {
QSize hint = ui->selectiveSyncStatus->sizeHint(); QSize hint = ui->selectiveSyncStatus->sizeHint();

View file

@ -37,13 +37,13 @@
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Connected with &lt;server&gt; as &lt;user&gt;</string> <string>Connected with &lt;server&gt; as &lt;user&gt;</string>
</property> </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -136,22 +136,39 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint"> <item row="0" column="0" rowspan="2">
<enum>QLayout::SetNoConstraint</enum> <layout class="QVBoxLayout" name="verticalLayout_3">
</property> <item>
<item row="1" column="1"> <widget class="QLabel" name="selectiveSyncLabel">
<widget class="QPushButton" name="selectiveSyncCancel"> <property name="sizePolicy">
<property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum"> <horstretch>0</horstretch>
<horstretch>0</horstretch> <verstretch>0</verstretch>
<verstretch>0</verstretch> </sizepolicy>
</sizepolicy> </property>
</property> <property name="text">
<property name="text"> <string>Unchecked folders will be &lt;b&gt;removed&lt;/b&gt; from your local file system and will not be synchronized to this computer anymore</string>
<string>Cancel</string> </property>
</property> <property name="wordWrap">
</widget> <bool>true</bool>
</property>
</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>
</item>
</layout>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="selectiveSyncApply"> <widget class="QPushButton" name="selectiveSyncApply">
@ -166,19 +183,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" rowspan="2"> <item row="1" column="1">
<widget class="QLabel" name="label"> <widget class="QPushButton" name="selectiveSyncCancel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum"> <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Unchecked folders will be &lt;b&gt;removed&lt;/b&gt; from your local file system and will not be synchronized to this computer anymore</string> <string>Cancel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

View file

@ -1022,7 +1022,7 @@ void Folder::slotNewSharedBigFolderDiscovered(const QString &newF)
if (!undecidedList.contains(newFolder)) { if (!undecidedList.contains(newFolder)) {
undecidedList.append(newFolder); undecidedList.append(newFolder);
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList); journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
emit newSharedBigFolderDiscovered(); emit newSharedBigFolderDiscovered(newFolder);
} }
} }

View file

@ -174,7 +174,7 @@ signals:
void syncFinished(const SyncResult &result); void syncFinished(const SyncResult &result);
void scheduleToSync(Folder*); void scheduleToSync(Folder*);
void progressInfo(const ProgressInfo& progress); void progressInfo(const ProgressInfo& progress);
void newSharedBigFolderDiscovered(); // A new folder bigger than the threshold was discovered void newSharedBigFolderDiscovered(const QString &); // A new folder bigger than the threshold was discovered
public slots: public slots:

View file

@ -59,9 +59,11 @@ void FolderStatusModel::setAccount(const AccountPtr& account)
connect(f, SIGNAL(progressInfo(ProgressInfo)), this, SLOT(slotSetProgress(ProgressInfo)), Qt::UniqueConnection); connect(f, SIGNAL(progressInfo(ProgressInfo)), this, SLOT(slotSetProgress(ProgressInfo)), Qt::UniqueConnection);
connect(f, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection); connect(f, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
connect(f, SIGNAL(newSharedBigFolderDiscovered(QString)), this, SIGNAL(dirtyChanged()), Qt::UniqueConnection);
} }
endResetModel(); endResetModel();
emit dirtyChanged();
} }
@ -514,11 +516,11 @@ void FolderStatusModel::slotUpdateFolderState(Folder *folder)
void FolderStatusModel::slotApplySelectiveSync() void FolderStatusModel::slotApplySelectiveSync()
{ {
if (!_dirty)
return;
for (int i = 0; i < _folders.count(); ++i) { for (int i = 0; i < _folders.count(); ++i) {
if (!_folders[i]._fetched) continue; if (!_folders[i]._fetched) {
_folders[i]._folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
continue;
}
auto folder = _folders.at(i)._folder; auto folder = _folders.at(i)._folder;
auto oldBlackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList); auto oldBlackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);