1
/* This file is part of the KDE project
2
Copyright (C) 2006-2012 Jarosław Staniek <staniek@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#ifndef SQLITE_VACUUM_H
21
#define SQLITE_VACUUM_H
27
#include <db/tristate.h>
29
class KProgressDialog;
31
//! @short Helper class performing interactive compacting (VACUUM) of the SQLite database
32
/*! Proved SQLite database filename in the constructor.
33
Then execute run() should be executed.
35
KProgressDialog will be displayed. Its progress bar will be updated whenever another
36
table's data compacting is performed. User can click "Cancel" button in any time
37
(except the final committing) to cancel the operation. In this case,
38
it's guaranteed that the original file remains unchanged.
40
This is possible because we rely on SQLite's VACUUM SQL command, which itself temporarily
41
creates a copy of the original database file, and replaces the orginal with the new only
44
class SQLiteVacuum : public QObject
48
SQLiteVacuum(const QString& filePath);
51
/*! Performs compacting procedure.
52
\return true on success, false on failure and cancelled if user
53
clicked "Cancel" button in the progress dialog. */
57
void readFromStdErr();
58
void dumpProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
59
void sqliteProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
64
QString m_tmpFilePath;
65
QProcess *m_dumpProcess;
66
QProcess *m_sqliteProcess;
67
KProgressDialog* m_dlg;