Add "Reset Folder" option to status dialog

to recover from invalid databases. Features
a big fat warning.
This commit is contained in:
Daniel Molkentin 2013-06-20 14:05:42 +02:00
parent 12cc8bfd95
commit a662c85728
5 changed files with 72 additions and 19 deletions

View file

@ -140,6 +140,8 @@ Application::Application(int &argc, char **argv) :
connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
SLOT(slotRemoveFolder(const QString&)));
connect( _statusDialog, SIGNAL(resetFolderAlias( const QString&)),
SLOT(slotResetFolder(const QString&)));
connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
SLOT(slotEnableFolder(QString,bool)));
connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
@ -797,21 +799,36 @@ void Application::slotAbout()
void Application::slotRemoveFolder( const QString& alias )
{
int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"),
tr("<p>Do you really want to stop syncing the upload folder <i>%1</i>?</p>"
tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
"<p><b>Note:</b> This will not remove the files from your client.</p>").arg(alias),
QMessageBox::Yes|QMessageBox::No );
if( ret == QMessageBox::No ) {
return;
}
Folder *f = _folderMan->folder(alias);
_folderMan->slotRemoveFolder( alias );
_statusDialog->slotRemoveSelectedFolder( );
computeOverallSyncStatus();
setupContextMenu();
}
void Application::slotResetFolder( const QString & alias )
{
int ret = QMessageBox::question( 0, tr("Confirm Folder Reset"),
tr("<p>Do you really want to reset folder<i>%1</i> and rebuild your client database?</p>"
"<p><b>Note:</b> While no files will be removed, this can cause significant data "
"traffic and take several minutes to hours, depending on the size of the folder.</p>").arg(alias),
QMessageBox::Yes|QMessageBox::No );
if( ret == QMessageBox::No ) {
return;
}
Folder *f = _folderMan->folder(alias);
f->slotTerminateSync();
f->wipe();
_folderMan->slotScheduleAllFolders();
}
// Open the File list info dialog.
void Application::slotInfoFolder( const QString& alias )
{

View file

@ -61,6 +61,7 @@ protected slots:
void slotAddFolder();
void slotOpenStatus();
void slotRemoveFolder( const QString& );
void slotResetFolder( const QString& );
void slotEnableFolder( const QString&, const bool );
void slotInfoFolder( const QString& );
void slotConfigure();

View file

@ -237,6 +237,7 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_folderList->setEditTriggers( QAbstractItemView::NoEditTriggers );
connect(_ButtonClose, SIGNAL(clicked()), this, SLOT(accept()));
connect(_ButtonRemove, SIGNAL(clicked()), this, SLOT(slotRemoveFolder()));
connect(_ButtonReset, SIGNAL(clicked()), this, SLOT(slotResetFolder()));
connect(_ButtonEnable, SIGNAL(clicked()), this, SLOT(slotEnableFolder()));
connect(_ButtonInfo, SIGNAL(clicked()), this, SLOT(slotInfoFolder()));
@ -244,6 +245,7 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_ButtonRemove->setEnabled(false);
_ButtonEnable->setEnabled(false);
_ButtonReset->setEnabled(false);
_ButtonInfo->setEnabled(false);
_ButtonAdd->setEnabled(true);
@ -265,6 +267,7 @@ void StatusDialog::slotFolderActivated( const QModelIndex& indx )
_ButtonRemove->setEnabled( state );
_ButtonEnable->setEnabled( state );
_ButtonReset->setEnabled( state );
_ButtonInfo->setEnabled( state );
if ( state ) {
@ -316,7 +319,6 @@ void StatusDialog::buttonsSetEnabled()
{
bool haveFolders = _folderList->model()->rowCount() > 0;
_ButtonRemove->setEnabled(false);
if( _theme->singleSyncFolder() ) {
// only one folder synced folder allowed.
_ButtonAdd->setVisible(!haveFolders);
@ -331,6 +333,8 @@ void StatusDialog::buttonsSetEnabled()
_ButtonEnable->setEnabled(isSelected);
_ButtonRemove->setEnabled(isSelected);
_ButtonInfo->setEnabled(isSelected);
_ButtonReset->setEnabled(isSelected);
}
void StatusDialog::slotUpdateFolderState( Folder *folder )
@ -396,6 +400,15 @@ void StatusDialog::slotRemoveFolder()
slotCheckConnection();
}
void StatusDialog::slotResetFolder()
{
QModelIndex selected = _folderList->selectionModel()->currentIndex();
if( selected.isValid() ) {
QString alias = _model->data( selected, FolderViewDelegate::FolderAliasRole ).toString();
emit(resetFolderAlias( alias ));
}
}
void StatusDialog::slotRemoveSelectedFolder()
{
QModelIndex selected = _folderList->selectionModel()->currentIndex();

View file

@ -72,6 +72,7 @@ public:
signals:
void removeFolderAlias( const QString& );
void resetFolderAlias( const QString& );
void enableFolderAlias( const QString&, const bool );
void infoFolderAlias( const QString& );
void openFolderAlias( const QString& );
@ -81,6 +82,7 @@ signals:
public slots:
void slotRemoveFolder();
void slotResetFolder();
void slotRemoveSelectedFolder();
void slotFolderActivated( const QModelIndex& );
void slotOpenOC();

View file

@ -42,13 +42,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="_ButtonRemove">
<property name="text">
<string>Remove...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="_ButtonEnable">
<property name="text">
@ -56,13 +49,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="_ButtonInfo">
<property name="text">
<string>Info...</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -71,11 +57,45 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>56</height>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="_ButtonRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="_ButtonReset">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="_ButtonInfo">
<property name="text">
<string>Info...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">