summaryrefslogtreecommitdiffstats
path: root/mappingtablewidget.h
diff options
context:
space:
mode:
Diffstat (limited to 'mappingtablewidget.h')
-rw-r--r--mappingtablewidget.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/mappingtablewidget.h b/mappingtablewidget.h
new file mode 100644
index 0000000..d6df991
--- /dev/null
+++ b/mappingtablewidget.h
@@ -0,0 +1,59 @@
+/*
+ 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 MAPPINGTABLEWIDGET_H
+#define MAPPINGTABLEWIDGET_H
+
+#include <QWidget>
+#include <QStringListModel>
+
+class QTreeView;
+class QLineEdit;
+class QPushButton;
+class MappingTableItemModel;
+class MappingTableModel;
+
+class MappingTableWidget : public QWidget{
+ Q_OBJECT
+ public:
+ explicit MappingTableWidget(const QString &table, QWidget *parent = 0);
+
+ public slots:
+ void setStringList(const QStringList &list);
+ void setEditEnabled(bool enabled);
+ void setCurrentId(int id) { mCurrentId = id; }
+
+ private slots:
+ void addItem();
+ void removeItem();
+
+ private:
+ QTreeView *mView;
+ QPushButton *mAddItem;
+ QPushButton *mRemoveItem;
+ QLineEdit *mItemEdit;
+ MappingTableItemModel *mModel;
+ MappingTableModel *mMappingModel;
+ const QString mTable;
+ int mCurrentId;
+};
+
+class MappingTableItemModel : public QStringListModel {
+ Q_OBJECT
+ public:
+ explicit MappingTableItemModel(QObject *parent = 0);
+
+ //data + flags
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ //find
+ int lowerBound(const QString &value) const;
+ QModelIndex find(const QString &value) const;
+};
+
+#endif // MAPPINGTABLEWIDGET_H