File indexing completed on 2024-05-12 16:40:14

0001 /* This file is part of the KDE project
0002    Copyright (C) 2009 Adam Pigg <adam@piggz.co.uk>
0003    Copyright (C) 2014-2016 Jarosław Staniek <staniek@kde.org>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License version 2 as published by the Free Software Foundation.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef IMPORTTABLEWIZARD_H
0021 #define IMPORTTABLEWIZARD_H
0022 
0023 #include "keximigrate_export.h"
0024 #include "migratemanager.h"
0025 
0026 #include <KAssistantDialog>
0027 
0028 #include <QPointer>
0029 
0030 class QDialogButtonBox;
0031 class QListWidget;
0032 class QLabel;
0033 class QProgressBar;
0034 class QCheckBox;
0035 class KDbConnection;
0036 class KexiConnectionSelectorWidget;
0037 class KexiProjectSelectorWidget;
0038 class KexiProjectSet;
0039 
0040 namespace Kexi {
0041     class ObjectStatus;
0042 }
0043 
0044 namespace KexiMigration {
0045 
0046 class MigrateManager;
0047 class KexiMigrate;
0048 class AlterSchemaWidget;
0049 
0050 class KEXIMIGRATE_EXPORT ImportTableWizard : public KAssistantDialog
0051 {
0052 Q_OBJECT
0053     public:
0054         explicit ImportTableWizard(KDbConnection* curDB, QWidget* parent = 0, QMap<QString, QString>* args = 0, Qt::WindowFlags flags = 0);
0055         virtual ~ImportTableWizard( );
0056 
0057         virtual void back() override;
0058         virtual void next() override;
0059         virtual void accept() override;
0060         virtual void reject() override;
0061 
0062     protected Q_SLOTS:
0063         void slot_currentPageChanged(KPageWidgetItem*,KPageWidgetItem*);
0064 
0065     private:
0066 
0067         KDbConnection* m_connection;
0068         KexiConnectionSelectorWidget *m_srcConnSel;
0069         KexiMigration::MigrateManager m_migrateManager;
0070         QPointer<KexiMigration::KexiMigrate> m_migrateDriver;
0071         QListWidget *m_tableListWidget;
0072         AlterSchemaWidget *m_alterSchemaWidget;
0073         KexiProjectSelectorWidget *m_srcDBName;
0074         KexiProjectSet* m_prjSet;
0075         QString m_importTableName;
0076         QMap<QString, QString>* m_args;
0077 
0078         bool fileBasedSrcSelected() const;
0079         QString driverIdForSelectedSource();
0080         KexiMigrate* prepareImport(Kexi::ObjectStatus* result);
0081 
0082         QLabel *m_lblImportingTxt, *m_lblImportingErrTxt, *m_progressLbl, *m_rowsImportedLbl, *m_finishLbl;
0083         QProgressBar *m_importingProgressBar;
0084         QCheckBox *m_finishCheckBox;
0085         QPushButton* m_importOptionsButton;
0086         bool m_importComplete;
0087         bool m_importWasCanceled;
0088         unsigned m_recordCount;
0089         //! Encoding for source db. Currently only used for MDB driver.
0090         //! @todo Hardcoded. Move to KexiMigrate driver's impl.
0091         QString m_sourceDbEncoding;
0092 
0093         bool doImport();
0094         bool readFromTable();
0095 
0096         //Page Items
0097         KPageWidgetItem *m_introPageItem, *m_srcConnPageItem, *m_srcDBPageItem, *m_tablesPageItem,
0098                         *m_alterTablePageItem, *m_importingPageItem, *m_progressPageItem, *m_finishPageItem;
0099 
0100         //Page Widgets
0101         QWidget *m_introPageWidget, *m_srcConnPageWidget, *m_srcDBPageWidget, *m_tablesPageWidget,
0102                 *m_alterTablePageWidget, *m_importingPageWidget, *m_progressPageWidget, *m_finishPageWidget;
0103 
0104         //Page Setup
0105         void setupIntroPage();
0106         void setupSrcConn();
0107         void setupSrcDB();
0108         void setupTableSelectPage();
0109         void setupAlterTablePage();
0110         void setupImportingPage();
0111         void setupProgressPage();
0112         void setupFinishPage();
0113 
0114         //Page Arrival
0115         void arriveSrcConnPage();
0116         void arriveSrcDBPage();
0117         void arriveTableSelectPage(KPageWidgetItem *prevPage);
0118         void arriveAlterTablePage();
0119         void arriveImportingPage();
0120         void arriveProgressPage();
0121         void arriveFinishPage();
0122     private Q_SLOTS:
0123         void slotConnPageItemSelected(bool isSelected);
0124         void slotTableListWidgetSelectionChanged();
0125         void slotNameChanged();
0126         void slotCancelClicked();
0127         void slotOptionsButtonClicked();
0128 };
0129 }
0130 #endif // IMPORTTABLEWIZARD_H