digiKam
coredbschemaupdater.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-04-16
7  * Description : Core database Schema updater
8  *
9  * Copyright (C) 2007-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_COREDB_SCHEMA_UPDATER_H
26 #define DIGIKAM_COREDB_SCHEMA_UPDATER_H
27 
28 // Qt includes
29 
30 #include <QString>
31 #include <QVariant>
32 
33 // Local includes
34 
35 #include "coredb.h"
36 #include "coredbaccess.h"
37 #include "coredbbackend.h"
38 #include "dbengineparameters.h"
39 
40 namespace Digikam
41 {
42 
43 class CoreDbAccess;
44 class InitializationObserver;
45 
46 class DIGIKAM_DATABASE_EXPORT CoreDbSchemaUpdater
47 {
48 public:
49 
50  static int schemaVersion();
51  static int filterSettingsVersion();
52  static int uniqueHashVersion();
53  static bool isUniqueHashUpToDate();
54 
55 public:
56 
57  explicit CoreDbSchemaUpdater(CoreDB* const albumDB,
58  CoreDbBackend* const backend,
59  const DbEngineParameters& parameters);
60  virtual ~CoreDbSchemaUpdater();
61 
62  bool update();
63  bool updateUniqueHash();
64  void setObserver(InitializationObserver* const observer);
65  const QString getLastErrorMessage();
66  void setCoreDbAccess(CoreDbAccess* const dbAccess);
67 
68 private:
69 
70  bool startUpdates();
71  bool makeUpdates();
72  bool beginWrapSchemaUpdateStep();
73  bool endWrapSchemaUpdateStep(bool stepOperationSuccess, const QString& errorMsg);
74  void defaultFilterSettings(QStringList& defaultItemFilter,
75  QStringList& defaultVideoFilter,
76  QStringList& defaultAudioFilter);
77  void defaultIgnoreDirectoryFilterSettings(QStringList& defaultIgnoreDirectoryFilter);
78  bool createFilterSettings();
79  bool updateFilterSettings();
80  bool createDatabase();
81  bool createTables();
82  bool createIndices();
83  bool createTriggers();
84  bool copyV3toV4(const QString& digikam3DBPath, const QString& currentDBPath);
85  bool performUpdateToVersion(const QString& actionName, int newVersion, int newRequiredVersion);
86  bool updateToVersion(int targetVersion);
87  bool updateV4toV7();
88  void setLegacySettingEntries();
89  void readVersionSettings();
90  void setVersionSettings();
91 
92 private:
93 
94  // cppcheck-suppress unusedPrivateFunction
95  bool createTablesV3();
96  // cppcheck-suppress unusedPrivateFunction
97  void preAlpha010Update1();
98  // cppcheck-suppress unusedPrivateFunction
99  void preAlpha010Update2();
100  // cppcheck-suppress unusedPrivateFunction
101  void preAlpha010Update3();
102  // cppcheck-suppress unusedPrivateFunction
103  void beta010Update1();
104  // cppcheck-suppress unusedPrivateFunction
105  void beta010Update2();
106 
107 private:
108 
109  // Disable
110  CoreDbSchemaUpdater(const CoreDbSchemaUpdater&) = delete;
111  CoreDbSchemaUpdater& operator=(const CoreDbSchemaUpdater&) = delete;
112 
113 private:
114 
115  class Private;
116  Private* const d;
117 };
118 
119 } // namespace Digikam
120 
121 #endif // DIGIKAM_COREDB_SCHEMA_UPDATER_H
Definition: coredb.h:57
Definition: coredbaccess.h:56
Definition: coredbbackend.h:42
Definition: coredbschemaupdater.h:47
Definition: dbengineparameters.h:49
Definition: collectionscannerobserver.h:57
Definition: datefolderview.cpp:43