added two options to periodically delete old documents in trash

preferencesAboutTextFull
Clément Fauconnier 5 years ago
parent e3bfd85b31
commit 05d672a8f8
  1. 2
      resources/etc/OpenBoard.config
  2. 60
      resources/forms/preferences.ui
  3. 6
      src/core/UBApplication.cpp
  4. 11
      src/core/UBPreferencesController.cpp
  5. 2
      src/core/UBSettings.cpp
  6. 3
      src/core/UBSettings.h
  7. 89
      src/document/UBDocumentController.cpp
  8. 5
      src/document/UBDocumentController.h

@ -93,6 +93,8 @@ SortOrder=0
SplitterLeftSize=200
SplitterRightSize=800
ShowDateColumnOnAlphabeticalSort=false
emptyTrashForOlderDocuments=true
emptyTrashDaysValue=30
[IntranetPodcast]
Author=

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>825</width>
<height>748</height>
<height>767</height>
</rect>
</property>
<property name="windowTitle">
@ -552,7 +552,7 @@
<string>Documents Mode</string>
</property>
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_18">
<item row="0" column="1">
<widget class="QCheckBox" name="showDateColumnOnAlphabeticalSort">
@ -567,24 +567,54 @@
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<item row="3" column="1">
<widget class="QCheckBox" name="emptyTrashForOlderDocuments">
<property name="text">
<string>Empty trash for documents older than</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="emptyTrashDaysValue"/>
</item>
<item row="3" column="3">
<widget class="QLabel" name="emptyTrashDaysLabel">
<property name="text">
<string>days</string>
</property>
</spacer>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" rowspan="2">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

@ -451,6 +451,12 @@ void UBApplication::closeEvent(QCloseEvent *event)
void UBApplication::closing()
{
if (UBSettings::settings()->emptyTrashForOlderDocuments->get().toBool())
{
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
documentController->deleteDocumentsInFolderOlderThan(docModel->trashIndex(), UBSettings::settings()->emptyTrashDaysValue->get().toInt());
documentController->deleteEmptyFolders(docModel->trashIndex());
}
if (boardController)
boardController->closing();

@ -138,8 +138,12 @@ void UBPreferencesController::wire()
connect(mPreferencesUI->useSystemOSKCheckBox, SIGNAL(clicked(bool)), settings->useSystemOnScreenKeyboard, SLOT(setBool(bool)));
connect(mPreferencesUI->useSystemOSKCheckBox, SIGNAL(clicked(bool)), this, SLOT(systemOSKCheckBoxToggled(bool)));
// Documents Mode preferences
connect(mPreferencesUI->showDateColumnOnAlphabeticalSort, SIGNAL(clicked(bool)), settings->showDateColumnOnAlphabeticalSort, SLOT(setBool(bool)));
connect(mPreferencesUI->showDateColumnOnAlphabeticalSort, SIGNAL(clicked(bool)), UBApplication::documentController, SLOT(refreshDateColumns()));
connect(mPreferencesUI->emptyTrashForOlderDocuments, SIGNAL(clicked(bool)), settings->emptyTrashForOlderDocuments, SLOT(setBool(bool)));
connect(mPreferencesUI->emptyTrashDaysValue, SIGNAL(valueChanged(int)), settings->emptyTrashDaysValue, SLOT(setInt(int)));
connect(mPreferencesUI->keyboardPaletteKeyButtonSize, SIGNAL(currentIndexChanged(const QString &)), settings->boardKeyboardPaletteKeyBtnSize, SLOT(setString(const QString &)));
connect(mPreferencesUI->startModeComboBox, SIGNAL(currentIndexChanged(int)), settings->appStartMode, SLOT(setInt(int)));
@ -279,6 +283,8 @@ void UBPreferencesController::init()
this->systemOSKCheckBoxToggled(mPreferencesUI->useSystemOSKCheckBox->isChecked());
mPreferencesUI->showDateColumnOnAlphabeticalSort->setChecked(settings->showDateColumnOnAlphabeticalSort->get().toBool());
mPreferencesUI->emptyTrashForOlderDocuments->setChecked(settings->emptyTrashForOlderDocuments->get().toBool());
mPreferencesUI->emptyTrashDaysValue->setValue(settings->emptyTrashDaysValue->get().toInt());
mPreferencesUI->startModeComboBox->setCurrentIndex(settings->appStartMode->get().toInt());
@ -344,8 +350,13 @@ void UBPreferencesController::defaultSettings()
mPreferencesUI->startModeComboBox->setCurrentIndex(0);
mPreferencesUI->useSystemOSKCheckBox->setChecked(settings->useSystemOnScreenKeyboard->reset().toBool());
mPreferencesUI->showDateColumnOnAlphabeticalSort->setChecked(settings->showDateColumnOnAlphabeticalSort->reset().toBool());
UBApplication::documentController->refreshDateColumns();
mPreferencesUI->emptyTrashForOlderDocuments->setChecked(settings->emptyTrashForOlderDocuments->reset().toBool());
mPreferencesUI->emptyTrashDaysValue->setValue(settings->emptyTrashDaysValue->reset().toInt());
}
else if (mPreferencesUI->mainTabWidget->currentWidget() == mPreferencesUI->penTab)
{

@ -459,6 +459,8 @@ void UBSettings::init()
useSystemOnScreenKeyboard = new UBSetting(this, "App", "UseSystemOnScreenKeyboard", true);
showDateColumnOnAlphabeticalSort = new UBSetting(this, "Document", "ShowDateColumnOnAlphabeticalSort", false);
emptyTrashForOlderDocuments = new UBSetting(this, "Document", "emptyTrashForOlderDocuments", true);
emptyTrashDaysValue = new UBSetting(this, "Document", "emptyTrashDaysValue", 30);
cleanNonPersistentSettings();
checkNewSettings();

@ -415,6 +415,9 @@ class UBSettings : public QObject
UBSetting* showDateColumnOnAlphabeticalSort;
UBSetting* emptyTrashForOlderDocuments;
UBSetting* emptyTrashDaysValue;
UBSetting* magnifierDrawingMode;
UBSetting* autoSaveInterval;

@ -762,6 +762,31 @@ bool UBDocumentTreeModel::removeRows(int row, int count, const QModelIndex &pare
return true;
}
bool UBDocumentTreeModel::containsDocuments(const QModelIndex &index)
{
for (int i = 0; i < rowCount(index); i++)
{
QModelIndex child = this->index(i, 0, index);
if (isCatalog(child))
{
if (containsDocuments(child))
{
return true;
}
}
else if (isDocument(child))
{
return true;
}
else
{
qDebug() << "Who the hell are you ?";
}
}
return false;
}
QModelIndex UBDocumentTreeModel::indexForNode(UBDocumentTreeNode *pNode) const
{
if (pNode == 0) {
@ -2054,7 +2079,6 @@ void UBDocumentController::setupViews()
}
}
//N/C - NNE - 20140403
void UBDocumentController::refreshDateColumns()
{
if (UBSettings::settings()->documentSortKind->get().toInt() == UBDocumentController::Alphabetical)
@ -2602,6 +2626,69 @@ void UBDocumentController::moveToTrash(QModelIndex &index, UBDocumentTreeModel*
}
//issue 1629 - NNE - 20131212 : END
void UBDocumentController::deleteDocumentsInFolderOlderThan(const QModelIndex &index, const int days)
{
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
QModelIndexList list;
for (int i = 0; i < docModel->rowCount(index); i++)
{
list << docModel->index(i, 0, index);
}
foreach (QModelIndex child, list)
{
UBDocumentProxy *documentProxy= docModel->proxyForIndex(child);
if (documentProxy)
{
if (documentProxy->lastUpdate() < QDateTime::currentDateTime().addDays(-days))
{
deleteIndexAndAssociatedData(child);
}
}
else
{
if (docModel->isCatalog(child))
{
deleteDocumentsInFolderOlderThan(child, days);
}
}
}
}
void UBDocumentController::deleteEmptyFolders(const QModelIndex &index)
{
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
QModelIndexList list;
for (int i = 0; i < docModel->rowCount(index); i++)
{
list << docModel->index(i, 0, index);
}
if (list.length() > 0)
{
foreach (QModelIndex child, list)
{
if (docModel->isCatalog(child))
{
if (!docModel->containsDocuments(child))
{
deleteIndexAndAssociatedData(child);
}
}
}
}
else
{
if (docModel->isCatalog(index))
{
deleteIndexAndAssociatedData(index);
}
}
}
void UBDocumentController::emptyFolder(const QModelIndex &index, DeletionType pDeletionType)
{
// Issue NC - CFA - 20131029 : ajout d'une popup de confirmation pour la suppression definitive

@ -187,6 +187,8 @@ public:
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
bool removeRows(int row, int count, const QModelIndex &parent);
bool containsDocuments(const QModelIndex& index);
QModelIndex indexForNode(UBDocumentTreeNode *pNode) const;
QPersistentModelIndex persistentIndexForNode(UBDocumentTreeNode *pNode);
// bool insertRow(int row, const QModelIndex &parent);
@ -414,6 +416,9 @@ class UBDocumentController : public UBDocumentContainer
*/
void moveToTrash(QModelIndex &index, UBDocumentTreeModel* docModel);
void deleteDocumentsInFolderOlderThan(const QModelIndex &index, const int days);
void deleteEmptyFolders(const QModelIndex &index);
QModelIndex mapIndexToSource(const QModelIndex &index);
QModelIndexList mapIndexesToSource(const QModelIndexList &indexes);

Loading…
Cancel
Save