/* 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 #include #include #include "smdialog.h" #include "smtreeview.h" 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 searchItem(); void addItem(); void removeItem(); private: SmTreeView* mView; QPushButton *mAddItem; QPushButton *mRemoveItem; QPushButton *mSearchItem; 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; }; class MappingTableResultDialog : public SmDialog { Q_OBJECT public: explicit MappingTableResultDialog(const QStringList &results, QWidget *parent = 0, Qt::WindowFlags f = 0); QString selectedText() const { return mSelectedText; } private slots: void accept(); private: SmTreeView *mView; QStringListModel *mModel; QPushButton *mOk; QPushButton *mCancel; QString mSelectedText; }; #endif // MAPPINGTABLEWIDGET_H