Commit de0c4a6e authored by Martin Straka's avatar Martin Straka Committed by Karel Slaný

First prototype of vacuum operation

parent 651ad7c1
......@@ -116,8 +116,15 @@ ApplicationWindow {
Connections {
target: isds
onStatusBarTextChanged: {
// console.log(textFontSizeInPixels)
// console.log(textFontSizeSmall)
statusBar.visible = true
statusBarText.text = txt
busyuIndicator.running = busy
timerId.running = !busy
}
}
Connections {
target: files
onStatusBarTextChanged: {
statusBar.visible = true
statusBarText.text = txt
busyuIndicator.running = busy
......
......@@ -98,6 +98,15 @@ Component {
isds.syncAllAccounts()
}
}
MenuItem {
id: vacuumAllMenu
text: qsTr("Vaccum databases")
iconSource: "qrc:/ui/sync-all.svg"
onTriggered: {
statusBarText.text = ""
files.vaccumFileDbs()
}
}
}
MouseArea {
anchors.fill: parent
......
......@@ -415,3 +415,29 @@ void Files::deleteFileDb(const QString &userName)
return;
}
}
/* ========================================================================= */
/*
* Slot: Vaccum all file databases.
*/
void Files::vaccumFileDbs(void)
/* ========================================================================= */
{
qDebug("%s()", __func__);
emit statusBarTextChanged(tr("Vaccum databases"), true);
QStringList userNameList = AccountListModel::globAccounts.keys();
foreach (const QString &userName, userNameList) {
FileDb *fDb = NULL;
fDb = globFileDbsPtr->accessFileDb(userName);
if (fDb == NULL) {
qDebug() << "ERROR: File database cannot open!" << userName;
return;
}
fDb->vaccumFileDb();
}
emit statusBarTextChanged(tr("Operation Vaccum has finished"), false);
}
......@@ -78,6 +78,11 @@ public:
*/
void deleteExpiredFilesFromDbs(int days);
/*!
* @brief Vaccum all file databases.
*/
Q_INVOKABLE void vaccumFileDbs(void);
class File {
public:
File(void)
......@@ -101,6 +106,18 @@ public:
QString _dmDownloadDate;
QString _icon;
};
signals:
/*!
* @brief Set new statusbar text and active busy indicator to QML.
*
* @param[in] txt - text message for statusbar.
* @param[in] busy - true means the statusbar busy indicator is active
* and shown, false = disabled and hidden
*/
void statusBarTextChanged(QString txt, bool busy);
};
#endif // FILES_H
......@@ -176,8 +176,6 @@ bool FileDb::deleteFilesFromDb(qint64 dmId)
goto fail;
}
query.exec("VACUUM");
return true;
fail:
return false;
......@@ -346,9 +344,26 @@ QStringList FileDb::cleanFilesInDb(int days)
return QStringList();
}
query.exec("VACUUM");
msgIDList.removeDuplicates();
return msgIDList;
}
/* ========================================================================= */
/*
* Vaccum file database.
*/
bool FileDb::vaccumFileDb(void)
/* ========================================================================= */
{
QSqlQuery query(m_db);
/* Operation Vaccum can take a long time */
if (query.exec("VACUUM")) {
return true;
}
return false;
}
......@@ -112,6 +112,13 @@ public:
*/
QStringList cleanFilesInDb(int days);
/*!
* @brief Vaccum file database.
*
* @return True on success.
*/
bool vaccumFileDb(void);
private:
/*!
* @brief Returns list of tables.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment