digiKam
dbengineparameters.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-03-18
7  * Description : Database Engine storage container for connection parameters.
8  *
9  * Copyright (C) 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2018 by Mario Frank <mario dot frank at uni minus potsdam dot de>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_DB_ENGINE_PARAMETERS_H
27 #define DIGIKAM_DB_ENGINE_PARAMETERS_H
28 
29 // Qt includes
30 
31 #include <QString>
32 #include <QtGlobal>
33 #include <QUrl>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 #include "dbengineconfig.h"
39 
40 namespace Digikam
41 {
42 
48 class DIGIKAM_EXPORT DbEngineParameters
49 {
50 
51 public:
52 
53  DbEngineParameters(const QString& _type,
54  const QString& _databaseNameCore,
55  const QString& _connectOptions = QString(),
56  const QString& _hostName = QString(),
57  int _port = -1,
58  bool _internalServer = false,
59  const QString& _userName = QString(),
60  const QString& _password = QString(),
61  const QString& _databaseNameThumbnails = QString(),
62  const QString& _databaseNameFace = QString(),
63  const QString& _databaseNameSimilarity = QString(),
64  const QString& _internalServerDBPath = QString(),
65  const QString& _internalServerMysqlAdminCmd = QString(),
66  const QString& _internalServerMysqlServCmd = QString(),
67  const QString& _internalServerMysqlInitCmd = QString());
68 
70 
74  explicit DbEngineParameters(const QUrl& url);
75  void insertInUrl(QUrl& url) const;
76  static void removeFromUrl(QUrl& url);
77 
78  bool operator==(const DbEngineParameters& other) const;
79  bool operator!=(const DbEngineParameters& other) const;
80 
85  bool isValid() const;
86 
87  bool isSQLite() const;
88  bool isMySQL() const;
89  QString SQLiteDatabaseFile() const;
90 
96  static QString SQLiteDatabaseType();
97  static QString MySQLDatabaseType();
98 
102  QByteArray hash() const;
103 
107  static DbEngineParameters defaultParameters(const QString& databaseType);
108 
109  static DbEngineParameters parametersFromConfig(const QString& configGroup = QString());
114  void readFromConfig(const QString& configGroup = QString());
115  void writeToConfig(const QString& configGroup = QString()) const;
116 
121  QString getCoreDatabaseNameOrDir() const;
122  QString getThumbsDatabaseNameOrDir() const;
123  QString getFaceDatabaseNameOrDir() const;
124  QString getSimilarityDatabaseNameOrDir() const;
125 
129  void setCoreDatabasePath(const QString& folderOrFileOrName);
130  void setThumbsDatabasePath(const QString& folderOrFileOrName);
131  void setFaceDatabasePath(const QString& folderOrFileOrName);
132  void setSimilarityDatabasePath(const QString& folderOrFileOrName);
133 
134  static QString coreDatabaseFileSQLite(const QString& folderOrFile);
135  static QString thumbnailDatabaseFileSQLite(const QString& folderOrFile);
136  static QString faceDatabaseFileSQLite(const QString& folderOrFile);
137  static QString similarityDatabaseFileSQLite(const QString& folderOrFile);
138 
139  static QString coreDatabaseDirectorySQLite(const QString& path);
140  static QString thumbnailDatabaseDirectorySQLite(const QString& path);
141  static QString faceDatabaseDirectorySQLite(const QString& path);
142  static QString similarityDatabaseDirectorySQLite(const QString& path);
143 
147  void setInternalServerPath(const QString& path);
148  QString internalServerPath() const;
149 
153  DbEngineParameters thumbnailParameters() const;
154 
158  DbEngineParameters faceParameters() const;
159 
163  DbEngineParameters similarityParameters() const;
164 
165  void legacyAndDefaultChecks(const QString& suggestedPath = QString());
166  void removeLegacyConfig();
167 
172  static DbEngineParameters parametersForSQLite(const QString& databaseFile);
173  static DbEngineParameters parametersForSQLiteDefaultFile(const QString& directory);
174 
179  static QString internalServerPrivatePath();
180 
184  static QString defaultMysqlServerCmd();
185 
189  static QString defaultMysqlAdminCmd();
190 
194  static QString defaultMysqlInitCmd();
195 
196 public:
197 
198  QString databaseType;
200  QString connectOptions;
201  QString hostName;
202  int port;
204  QString userName;
205  QString password;
206 
211 
219 };
220 
221 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const DbEngineParameters& t);
222 
223 } // namespace Digikam
224 
225 #endif // DIGIKAM_DB_ENGINE_PARAMETERS_H
Definition: dbengineparameters.h:49
QString databaseType
Definition: dbengineparameters.h:198
QString userName
Definition: dbengineparameters.h:204
QString databaseNameFace
Definition: dbengineparameters.h:208
QString password
Definition: dbengineparameters.h:205
QString databaseNameThumbnails
Definition: dbengineparameters.h:207
QString internalServerMysqlAdminCmd
Definition: dbengineparameters.h:216
QString internalServerDBPath
Definition: dbengineparameters.h:210
QString hostName
Definition: dbengineparameters.h:201
bool internalServer
Definition: dbengineparameters.h:203
QString internalServerMysqlServCmd
Definition: dbengineparameters.h:217
int port
Definition: dbengineparameters.h:202
QString databaseNameCore
Definition: dbengineparameters.h:199
QString internalServerMysqlInitCmd
Definition: dbengineparameters.h:218
QString connectOptions
Definition: dbengineparameters.h:200
QString databaseNameSimilarity
Definition: dbengineparameters.h:209
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49