File indexing completed on 2024-05-12 16:35:18

0001 /* This file is part of the KDE project
0002    Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
0003              (C) 2002 Ariya Hidayat <ariya@kde.org>
0004              (C) 2002 Laurent Montel <montel@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef CALLIGRA_SHEETS_DATABASE_DIALOG
0023 #define CALLIGRA_SHEETS_DATABASE_DIALOG
0024 
0025 #ifndef QT_NO_SQL
0026 
0027 #include <QRect>
0028 #include <QFrame>
0029 #include <QLabel>
0030 
0031 #include <kassistantdialog.h>
0032 #include <QSqlDatabase>
0033 
0034 class QCheckBox;
0035 class QFrame;
0036 class QLabel;
0037 class QTreeWidget;
0038 class QListWidget;
0039 class QListWidgetItem;
0040 class QRadioButton;
0041 class QPushButton;
0042 
0043 class KLineEdit;
0044 class KComboBox;
0045 class KTextEdit;
0046 class KPageWidgetItem;
0047 
0048 namespace Calligra
0049 {
0050 namespace Sheets
0051 {
0052 class Selection;
0053 
0054 /**
0055  * \ingroup UI
0056  * Dialog to import data from a database.
0057  */
0058 class DatabaseDialog : public KAssistantDialog
0059 {
0060     Q_OBJECT
0061 
0062 public:
0063     enum PageId { eDatabase = 0, eTables = 1, eColumns = 2, eOptions = 3, eResult = 4 };
0064 
0065     DatabaseDialog(QWidget* parent, Selection* selection);
0066     ~DatabaseDialog() override;
0067 
0068 private Q_SLOTS:
0069     void orBox_clicked();
0070     void andBox_clicked();
0071     void startingCell_clicked();
0072     void startingRegion_clicked();
0073     void connectButton_clicked();
0074     void databaseNameChanged(const QString & s);
0075     void databaseHostChanged(const QString & s);
0076     void databaseDriverChanged(int);
0077     //void popupTableViewMenu( QListWidgetItem *, const QPoint &, int );
0078     void tableViewClicked(QListWidgetItem *);
0079     void accept() override;
0080 
0081 protected:
0082     void next() override;
0083     void back() override;
0084 
0085 private:
0086     int            m_currentPage;
0087     Selection    * m_selection;
0088     QRect          m_targetRect;
0089     QSqlDatabase   m_dbConnection;
0090 
0091     KPageWidgetItem * m_database;
0092     QLabel       * m_databaseStatus;
0093     KLineEdit    * m_username;
0094     KLineEdit    * m_port;
0095     KLineEdit    * m_databaseName;
0096     KComboBox    * m_driver;
0097     KLineEdit    * m_password;
0098     KLineEdit    * m_host;
0099     QLabel       * m_Type;
0100     KPageWidgetItem * m_table;
0101     KComboBox    * m_databaseList;
0102     QPushButton  * m_connectButton;
0103     QLabel       * m_tableStatus;
0104     QLabel       * m_SelectTableLabel;
0105     QListWidget  * m_tableView;
0106     KPageWidgetItem * m_columns;
0107     QTreeWidget  * m_columnView;
0108     QLabel       * m_columnsStatus;
0109     KPageWidgetItem * m_options;
0110     KComboBox    * m_columns_1;
0111     KComboBox    * m_columns_2;
0112     KComboBox    * m_columns_3;
0113     KComboBox    * m_operator_1;
0114     KComboBox    * m_operator_2;
0115     KComboBox    * m_operator_3;
0116     KLineEdit    * m_operatorValue_1;
0117     KLineEdit    * m_operatorValue_2;
0118     KLineEdit    * m_operatorValue_3;
0119     QRadioButton * m_andBox;
0120     QRadioButton * m_orBox;
0121     KComboBox    * m_columnsSort_1;
0122     KComboBox    * m_columnsSort_2;
0123     KComboBox    * m_sortMode_1;
0124     KComboBox    * m_sortMode_2;
0125     QCheckBox    * m_distinct;
0126     KPageWidgetItem * m_result;
0127     KTextEdit    * m_sqlQuery;
0128     QRadioButton * m_startingRegion;
0129     KLineEdit    * m_cell;
0130     KLineEdit    * m_region;
0131     QRadioButton * m_startingCell;
0132 
0133     void switchPage(int id);
0134     bool databaseDoNext();
0135     bool tablesDoNext();
0136     bool columnsDoNext();
0137     bool optionsDoNext();
0138 
0139     QString exchangeWildcards(QString const & value);
0140     QString getWhereCondition(QString const &, QString const &, int);
0141 };
0142 
0143 } // namespace Sheets
0144 } // namespace Calligra
0145 
0146 #endif // QT_NO_SQL
0147 
0148 #endif // CALLIGRA_SHEETS_DATABASE_DIALOG