File indexing completed on 2025-01-19 03:53:29

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-11-14
0007  * Description : Core database copy manager for migration operations.
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_CORE_DB_COPY_MANAGER_H
0017 #define DIGIKAM_CORE_DB_COPY_MANAGER_H
0018 
0019 // Qt includes
0020 
0021 #include <QObject>
0022 
0023 // Local includes
0024 
0025 #include "digikam_export.h"
0026 #include "coredbbackend.h"
0027 
0028 namespace Digikam
0029 {
0030 
0031 class DIGIKAM_DATABASE_EXPORT CoreDbCopyManager : public QObject
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036 
0037     enum FinishStates
0038     {
0039         success,
0040         failed,
0041         canceled
0042     };
0043 
0044 public:
0045 
0046     CoreDbCopyManager();
0047     ~CoreDbCopyManager() override;
0048 
0049     void copyDatabases(const DbEngineParameters& fromDBParameters,
0050                        const DbEngineParameters& toDBParameters);
0051 
0052 Q_SIGNALS:
0053 
0054     void stepStarted(const QString& stepName);
0055     void smallStepStarted(int currValue, int maxValue);
0056     void finished(int finishState, const QString& errorMsg);
0057 
0058 public Q_SLOTS:
0059 
0060     void stopProcessing();
0061 
0062 private:
0063 
0064     // Disabled
0065     explicit CoreDbCopyManager(QObject*) = delete;
0066 
0067     bool copyTable(CoreDbBackend& fromDBbackend,
0068                    const QString& fromActionName,
0069                    CoreDbBackend& toDBbackend,
0070                    const QString& toActionName);
0071 
0072     void handleClosing(bool isstopThread,
0073                        CoreDbBackend& fromDBbackend,
0074                        CoreDbBackend& toDBbackend);
0075 
0076 private:
0077 
0078     volatile bool m_isStopProcessing;
0079 };
0080 
0081 } // namespace Digikam
0082 
0083 #endif // DIGIKAM_CORE_DB_COPY_MANAGER_H