summaryrefslogtreecommitdiffstats
path: root/mappingtableeditor.h
diff options
context:
space:
mode:
Diffstat (limited to 'mappingtableeditor.h')
-rw-r--r--mappingtableeditor.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/mappingtableeditor.h b/mappingtableeditor.h
new file mode 100644
index 0000000..124f76e
--- /dev/null
+++ b/mappingtableeditor.h
@@ -0,0 +1,77 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef MAPPINGTABLEEDITOR_H
+#define MAPPINGTABLEEDITOR_H
+
+#include <QDialog>
+#include <QTreeView>
+#include <QSqlDatabase>
+
+class QSqlQuery;
+class QContextMenuEvent;
+class QPushButton;
+class QLineEdit;
+class QAction;
+class MappingTableEditorView;
+class MappingTableEditorModel;
+
+#include "smtreemodel.h"
+#include "smtreeitem.h"
+
+class MappingTableEditor : public QDialog {
+ Q_OBJECT
+ public:
+ explicit MappingTableEditor(const QString &table, QWidget *parent = 0);
+
+ private slots:
+ void selectionChanged(const QModelIndex &cur, const QModelIndex &prev);
+ void removeItem();
+ void renameItem();
+ void editItem();
+
+ private:
+ const QString mTable;
+ QPushButton *mClose;
+ QPushButton *mDelete;
+ QPushButton *mRename;
+ QLineEdit *mDataEdit;
+ QAction *mDeleteA;
+ QAction *mEditA;
+ MappingTableEditorView *mView;
+ MappingTableEditorModel *mModel;
+};
+
+class MappingTableEditorView : public QTreeView {
+ Q_OBJECT
+ public:
+ explicit MappingTableEditorView(QWidget *parent = 0);
+
+ protected:
+ virtual void contextMenuEvent(QContextMenuEvent *e);
+};
+
+class MappingTableEditorModel : public SmTreeModel {
+ Q_OBJECT
+ public:
+ enum Roles { NameRole = Qt::UserRole + 1, CountRole = Qt::UserRole +2, IdRole = Qt::UserRole + 3 };
+ enum Fields { Name = 0, Count = 1, Id = 2 };
+ explicit MappingTableEditorModel(const QString &table, const QStringList &headers, QObject *parent = 0);
+ virtual ~MappingTableEditorModel();
+ virtual Qt::ItemFlags flags(const QModelIndex &idx) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual bool setData(const QModelIndex &idx, const QVariant &value, int role);
+ virtual bool removeData(const QModelIndex &idx);
+
+ private:
+ void populate();
+ const QString mTable;
+ QSqlDatabase mDb;
+ QSqlQuery *mDataQuery;
+};
+
+#endif // MAPPINGTABLEEDITOR_H