digiKam
dbsettingswidget.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 : 2009-11-14
7  * Description : database settings widget
8  *
9  * Copyright (C) 2009-2010 by Holger Foerster <Hamsi2k at freenet dot de>
10  * Copyright (C) 2010-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_DB_SETTINGS_WIDGET_H
26 #define DIGIKAM_DB_SETTINGS_WIDGET_H
27 
28 // Qt includes
29 
30 #include <QWidget>
31 #include <QString>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class ApplicationSettings;
41 class DbEngineParameters;
42 
43 class DIGIKAM_GUI_EXPORT DatabaseSettingsWidget : public QWidget
44 {
45  Q_OBJECT
46 
47 public:
48 
50  {
51  SQlite = 0,
52  MysqlInternal = 1,
53  MysqlServer = 2
54  };
55 
56 public:
57 
58  explicit DatabaseSettingsWidget(QWidget* const parent = nullptr);
59  ~DatabaseSettingsWidget() override;
60 
61 public:
62 
63  void setParametersFromSettings(const ApplicationSettings* const settings,
64  const bool& migration = false);
65  DbEngineParameters getDbEngineParameters() const;
66 
67  void setDatabaseType(int type);
68  int databaseType() const;
69 
70  QString databaseBackend() const;
71 
72  void setDatabasePath(const QString& path);
73  QString databasePath() const;
74 
75  DbEngineParameters orgDatabasePrm() const;
76 
81  bool checkDatabaseSettings();
82 
83 private:
84 
85  void setupMainArea();
86  void handleInternalServer(int index);
87  void setDatabaseInputFields(int index);
88  bool isNotEqualToThumbName(const QString& name);
89  bool checkMysqlServerConnection(QString& error);
90  bool checkMysqlServerConnectionConfig(QString& error);
91  bool checkMysqlServerDbNamesConfig(QString& error);
92  bool checkDatabasePath();
93 
94 private Q_SLOTS:
95 
96  void slotHandleDBTypeIndexChanged(int index);
97  void slotDatabasePathEditedDelayed();
98  void slotDatabasePathEdited();
99  void slotUpdateSqlInit();
100  void slotCheckMysqlServerConnection();
101  void slotResetMysqlServerDBNames();
102 
103 private:
104 
105  class Private;
106  Private* const d;
107 };
108 
109 } // namespace Digikam
110 
111 #endif // DIGIKAM_DB_SETTINGS_WIDGET_H
Definition: applicationsettings.h:57
Definition: dbsettingswidget_p.h:79
Definition: dbsettingswidget.h:44
DatabaseType
Definition: dbsettingswidget.h:50
Definition: dbengineparameters.h:49
Definition: datefolderview.cpp:43