1 /*************************************************************************** 2 * * 3 * This program is free software; you can redistribute it and/or modify * 4 * it under the terms of the GNU General Public License as published by * 5 * the Free Software Foundation; either version 3 of the License, or * 6 * (at your option) any later version. * 7 * * 8 ***************************************************************************/ 9 10 #pragma once 11 12 #include <QDialog> 13 #include <QAbstractItemModel> 14 #include <QStringList> 15 16 #include "ui_UIScriptManager.h" 17 18 class ScriptManagerModel; 19 20 class ScriptManagerDialog : 21 public QDialog, 22 private Ui::UIScriptManager 23 { 24 Q_OBJECT 25 public: 26 explicit ScriptManagerDialog(QWidget *parent = 0); 27 virtual ~ScriptManagerDialog(); 28 29 private Q_SLOTS: 30 void slotSetChangedAction(int index); 31 32 private: 33 ScriptManagerModel *model; 34 }; 35 36 class ScriptManagerItem{ 37 38 public: 39 ScriptManagerItem(ScriptManagerItem* = NULL); 40 virtual ~ScriptManagerItem(); 41 42 void appendChild(ScriptManagerItem *child); 43 44 ScriptManagerItem *child(int row); 45 int childCount() const; 46 int columnCount() const; 47 int row() const; 48 ScriptManagerItem *parent(); 49 QList<ScriptManagerItem*> childItems; 50 51 bool isOn; 52 QString desc; 53 QString auth; 54 QString name; 55 QString path; 56 QIcon icon; 57 private: 58 ScriptManagerItem *parentItem; 59 }; 60 61 class ScriptManagerModel: public QAbstractItemModel{ 62 Q_OBJECT 63 public: 64 ScriptManagerModel(QObject* = NULL); 65 virtual ~ScriptManagerModel(); 66 67 int rowCount(const QModelIndex &parent) const; 68 int columnCount(const QModelIndex &parent) const; 69 Qt::ItemFlags flags(const QModelIndex& index) const; 70 QVariant data(const QModelIndex& index, int role) const; 71 bool setData(const QModelIndex& index, const QVariant& value, int role); 72 QVariant headerData(int, Qt::Orientation, int) const; 73 virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; 74 virtual QModelIndex parent(const QModelIndex & parent) const; 75 76 public Q_SLOTS: 77 void save(); 78 79 private: 80 void load(); 81 void loadDir(const QString&); 82 83 ScriptManagerItem *rootItem; 84 QStringList enabled; 85 }; 86