| 1 | #ifndef PREFERENCES_H |
| 2 | #define PREFERENCES_H |
| 3 | |
| 4 | #include <QDialog> |
| 5 | #include <QSettings> |
| 6 | #include <QAbstractTableModel> |
| 7 | |
| 8 | namespace Ui { |
| 9 | class Preferences; |
| 10 | } |
| 11 | |
| 12 | class Engine |
| 13 | { |
| 14 | public: |
| 15 | Engine(QString p, QString a) : |
| 16 | path(p), arguments(a) {} |
| 17 | QString path; |
| 18 | QString arguments; |
| 19 | }; |
| 20 | |
| 21 | class EngineTableModel : public QAbstractTableModel |
| 22 | { |
| 23 | Q_OBJECT |
| 24 | |
| 25 | public: |
| 26 | enum EngineTableColumn { ENGINE_DEFAULT, ENGINE_PATH, ENGINE_ARGUMENTS, ENGINE_NUMITEMS }; |
| 27 | |
| 28 | EngineTableModel(QObject * parent = 0); |
| 29 | ~EngineTableModel(); |
| 30 | int rowCount(const QModelIndex & parent = QModelIndex()) const; |
| 31 | int columnCount(const QModelIndex & parent = QModelIndex()) const; |
| 32 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; |
| 33 | QVariant data(const QModelIndex & index, int role) const; |
| 34 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
| 35 | Qt::ItemFlags flags(const QModelIndex & index) const; |
| 36 | bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); |
| 37 | bool removeRows(int row, int count, const QModelIndex &parent); |
| 38 | |
| 39 | void addEngine(Engine e); |
| 40 | void loadEngines(void); |
| 41 | void saveEngines(void); |
| 42 | public: |
| 43 | QList <Engine> engines; |
| 44 | int selected_engine; |
| 45 | }; |
| 46 | |
| 47 | class Preferences : public QDialog |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | |
| 51 | public: |
| 52 | explicit Preferences(QWidget *parent = 0); |
| 53 | ~Preferences(); |
| 54 | |
| 55 | void addEngine(); |
| 56 | void removeEngine(); |
| 57 | void saveSettings(); |
| 58 | void loadSettings(); |
| 59 | void slot_getGobanPath(); |
| 60 | void slot_getTablePath(); |
| 61 | |
| 62 | private: |
| 63 | Ui::Preferences *ui; |
| 64 | QSettings settings; |
| 65 | EngineTableModel * engineTableModel; |
| 66 | QString currentWorkingDir; |
| 67 | }; |
| 68 | |
| 69 | #endif // PREFERENCES_H |