Akonadi

dbconfigsqlite.h
1 /*
2  SPDX-FileCopyrightText: 2010 Tobias Koenig <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "dbconfig.h"
10 
11 namespace Akonadi
12 {
13 namespace Server
14 {
15 class DbConfigSqlite : public DbConfig
16 {
17 public:
18  enum Version {
19  Default, /** Uses the Qt sqlite driver */
20  Custom /** Uses the custom qsqlite driver from akonadi/qsqlite */
21  };
22 
23 public:
24  explicit DbConfigSqlite(Version driver);
25 
26  /**
27  * Returns the name of the used driver.
28  */
29  QString driverName() const override;
30 
31  /**
32  * Returns the database name.
33  */
34  QString databaseName() const override;
35 
36  /**
37  * This method is called whenever the Akonadi server is started
38  * and before the initial database connection is set up.
39  *
40  * At this point the default settings should be determined, merged
41  * with the given @p settings and written back if @p storeSettings is true.
42  */
43  bool init(QSettings &settings, bool storeSettings = true) override;
44 
45  /**
46  * This method checks if the requirements for this database connection are met
47  * in the system (QSQLITE/QSQLITE3 driver is available, object can be initialized, etc.).
48  */
49  bool isAvailable(QSettings &settings) override;
50 
51  /**
52  * This method applies the configured settings to the QtSql @p database
53  * instance.
54  */
55  void apply(QSqlDatabase &database) override;
56 
57  /**
58  * Returns whether an internal server needs to be used.
59  */
60  bool useInternalServer() const override;
61 
62  /**
63  * Sets sqlite journal mode to WAL and synchronous mode to NORMAL
64  */
65  void setup() override;
66 
67 private:
68  bool setPragma(QSqlDatabase &db, QSqlQuery &query, const QString &pragma);
69 
70  Version mDriverVersion;
71  QString mDatabaseName;
72  QString mHostName;
73  QString mUserName;
74  QString mPassword;
75  QString mConnectionOptions;
76 };
77 
78 } // namespace Server
79 } // namespace Akonadi
80 
KGuiItem apply()
QCA_EXPORT void init()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.