Akonadi

dbupdater.h
1 /*
2  SPDX-FileCopyrightText: 2007 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QMap>
10 #include <QObject>
11 #include <QSqlDatabase>
12 #include <QStringList>
13 
14 class QDomElement;
15 class DbUpdaterTest;
16 
17 namespace Akonadi
18 {
19 namespace Server
20 {
21 /**
22  * @short A helper class that contains an update set.
23  */
24 class UpdateSet
25 {
26 public:
27  using Map = QMap<int, UpdateSet>;
28 
29  UpdateSet()
30  : version(-1)
31  , abortOnFailure(false)
32  , complex(false)
33  {
34  }
35 
36  int version;
37  bool abortOnFailure;
38  QStringList statements;
39  bool complex;
40 };
41 
42 /**
43  Updates the database schema.
44 */
45 class DbUpdater : public QObject
46 {
47  Q_OBJECT
48 
49 public:
50  /**
51  * Creates a new database updates.
52  *
53  * @param database The reference to the database.
54  * @param filename The file containing the update descriptions.
55  */
56  DbUpdater(const QSqlDatabase &database, const QString &filename);
57 
58  /**
59  * Starts the update process.
60  * On success true is returned, false otherwise.
61  */
62  bool run();
63 
64 private Q_SLOTS:
65  bool complexUpdate_25();
66  bool complexUpdate_36();
67 
68 private:
69  friend class ::DbUpdaterTest;
70 
71  bool updateApplicable(const QString &backends) const;
72  QString buildRawSqlStatement(const QDomElement &element) const;
73 
74  bool parseUpdateSets(int, UpdateSet::Map &updates) const;
75 
76  QSqlDatabase m_database;
77  QString m_filename;
78 };
79 
80 } // namespace Server
81 } // namespace Akonadi
82 
Q_OBJECTQ_OBJECT
Updates the database schema.
Definition: dbupdater.h:45
Q_SLOTSQ_SLOTS
A helper class that contains an update set.
Definition: dbupdater.h:24
bool run()
Starts the update process.
Definition: dbupdater.cpp:43
DbUpdater(const QSqlDatabase &database, const QString &filename)
Creates a new database updates.
Definition: dbupdater.cpp:37
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.