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

0001 /* This file is part of the KDE project
0002    Copyright (C) 2009 Adam Pigg <adam@piggz.co.uk>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef ALTERSCHEMAWIDGET_H
0020 #define ALTERSCHEMAWIDGET_H
0021 
0022 #include <QWidget>
0023 #include <QTableView>
0024 #include <AlterSchemaTableModel.h>
0025 
0026 class QGridLayout;
0027 class QTableView;
0028 class QComboBox;
0029 class QCheckBox;
0030 class QLabel;
0031 class KDbTableSchema;
0032 class KexiNameWidget;
0033 
0034 namespace KexiMigration {
0035 
0036 class AlterSchemaWidget : public QWidget
0037 {
0038     Q_OBJECT
0039     public:
0040         explicit AlterSchemaWidget(QWidget* parent = 0);
0041         ~AlterSchemaWidget();
0042 
0043         void setTableSchema(KDbTableSchema *schema);
0044         void setData(QList<KDbRecordData*>* data);
0045 
0046         KDbTableSchema* newSchema();
0047         KDbTableSchema* takeTableSchema();
0048 
0049         KexiNameWidget* nameWidget();
0050         bool nameExists(const QString &name) const;
0051 
0052         AlterSchemaTableModel* model();
0053 
0054     private:
0055         QGridLayout *m_layout;
0056         QTableView *m_table;
0057         QComboBox *m_columnType;
0058         QCheckBox *m_columnPKey;
0059         KexiNameWidget *m_tableNameWidget;
0060 
0061         QStringList m_types;
0062 
0063         AlterSchemaTableModel *m_model;
0064 
0065         QLabel *m_columnNumLabel;
0066         QLabel *m_columnTypeLabel;
0067         QLabel *m_columnPKeyLabel;
0068 
0069         KDbTableSchema *m_schema;
0070 
0071         int m_selectedColumn;
0072 
0073         //! @todo Something like this could go in kexi utils/project?
0074         QString suggestedItemCaption(const QString& baseCaption);
0075 
0076     private Q_SLOTS:
0077         void tableClicked(const QModelIndex& idx);
0078         void typeActivated(int typ);
0079         void pkeyClicked(bool pkey);
0080 };
0081 }
0082 #endif // ALTERSCHEMAWIDGET_H