File indexing completed on 2025-01-19 03:53:33
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-09-27 0007 * Description : Database engine gui error handler 0008 * 0009 * SPDX-FileCopyrightText: 2009-2010 by Holger Foerster <Hamsi2k at freenet dot de> 0010 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_DB_ENGINE_GUI_ERROR_HANDLER_H 0017 #define DIGIKAM_DB_ENGINE_GUI_ERROR_HANDLER_H 0018 0019 // Qt includes 0020 0021 #include <QThread> 0022 0023 // Local includes 0024 0025 #include "dbenginebackend.h" 0026 #include "dbengineerrorhandler.h" 0027 #include "digikam_export.h" 0028 0029 namespace Digikam 0030 { 0031 0032 class DIGIKAM_EXPORT DbEngineConnectionChecker : public QThread 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 0038 explicit DbEngineConnectionChecker(const DbEngineParameters& parameters); 0039 ~DbEngineConnectionChecker() override; 0040 0041 bool checkSuccessful() const; 0042 0043 public Q_SLOTS: 0044 0045 void stopChecking(); 0046 0047 protected: 0048 0049 void run() override; 0050 0051 Q_SIGNALS: 0052 0053 void failedAttempt(); 0054 void done(); 0055 0056 private: 0057 0058 // Disable 0059 DbEngineConnectionChecker(QObject*) = delete; 0060 0061 class Private; 0062 Private* const d; 0063 }; 0064 0065 // -------------------------------------------------------------- 0066 0067 class DIGIKAM_EXPORT DbEngineGuiErrorHandler : public DbEngineErrorHandler 0068 { 0069 Q_OBJECT 0070 0071 public: 0072 0073 explicit DbEngineGuiErrorHandler(const DbEngineParameters& parameters); 0074 ~DbEngineGuiErrorHandler() override; 0075 0076 bool checkDatabaseConnection(); 0077 0078 public Q_SLOTS: 0079 0080 void connectionError(DbEngineErrorAnswer* answer, const QSqlError& error, const QString& query) override; 0081 void consultUserForError(DbEngineErrorAnswer* answer, const QSqlError& error, const QString& query) override; 0082 0083 private Q_SLOTS: 0084 0085 void showProgressDialog(); 0086 0087 private: 0088 0089 // Disabled 0090 DbEngineGuiErrorHandler(QObject*) = delete; 0091 0092 class Private; 0093 Private* const d; 0094 }; 0095 0096 } // namespace Digikam 0097 0098 #endif // DIGIKAM_DB_ENGINE_GUI_ERROR_HANDLER_H