blob: 38c4fe139a25f270464f4d01b3fb177231c23cfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
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);
MappingTableItemModel *model() { return mModel; }
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;
void setDecorationIcon(const QIcon &icon) { mDecorationIcon = icon; }
const QIcon decorationIcon() const { return mDecorationIcon; }
//find
int lowerBound(const QString &value) const;
QModelIndex find(const QString &value) const;
private:
QIcon mDecorationIcon;
};
#endif // MAPPINGTABLEWIDGET_H
|