itom 1.2.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef PLUGINMODEL_H 00024 #define PLUGINMODEL_H 00025 00026 #include "../../common/addInInterface.h" 00027 #include <qabstractitemmodel.h> 00028 00029 #include <qicon.h> 00030 00031 namespace ito 00032 { 00033 class AddInBase; 00034 00039 enum tPluginLoadStatusFlag 00040 { 00041 plsfOk = 0x0, 00042 plsfWarning = 0x1, 00043 plsfError = 0x2, 00044 plsfIgnored = 0x4 00045 }; 00046 00051 struct PluginLoadStatus 00052 { 00053 PluginLoadStatus() : filename("") {} 00054 QString filename; 00055 QList< QPair<tPluginLoadStatusFlag, QString> > messages; 00056 }; 00057 00066 class PlugInModel : public QAbstractItemModel 00067 { 00068 Q_OBJECT 00069 00070 public: 00071 PlugInModel(/*const QString &data, QObject *parent = 0*/); 00072 ~PlugInModel(); 00073 00074 enum tItemType { 00075 itemUnknown = 0x0000, 00076 itemCatDataIO = 0x0001, 00077 itemCatActuator = 0x0002, 00078 itemCatAlgo = 0x0004, 00079 itemSubCategoryDataIO_Grabber = 0x0008, 00080 itemSubCategoryDataIO_ADDA = 0x0010, 00081 itemSubCategoryDataIO_RawIO = 0x0020, 00082 itemPlugin = 0x0040, 00083 itemInstance = 0x0080, 00084 itemFilter = 0x0100, 00085 itemWidget = 0x0200, 00086 itemCatMainAll = itemCatDataIO | itemCatActuator | itemCatAlgo, 00087 itemCatSubAll = itemSubCategoryDataIO_Grabber | itemSubCategoryDataIO_ADDA | itemSubCategoryDataIO_RawIO, 00088 itemCatAll = itemCatMainAll | itemCatSubAll 00089 }; 00090 00091 QVariant data(const QModelIndex &index, int role) const; 00092 Qt::ItemFlags flags(const QModelIndex &index) const; 00093 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 00094 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; 00095 QModelIndex parent(const QModelIndex &index) const; 00096 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00097 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00098 int update(void) { emit(beginResetModel()); emit(endResetModel()); return 0; }; 00099 00100 bool insertInstance(ito::AddInInterfaceBase* addInInterface, bool beginOperation); 00101 bool deleteInstance(ito::AddInInterfaceBase* addInInterface, ito::AddInBase *addInInstance, bool beginOperation); 00102 bool resetModel(bool beginOperation); 00103 00104 QModelIndex getIndexByAddIn(ito::AddInBase *ai) const; 00105 QModelIndex getIndexByAddInInterface(ito::AddInInterfaceBase *aib) const; 00106 bool getModelIndexInfo(const QModelIndex &index, tItemType &type, size_t &internalData) const; 00107 00108 bool getIsAlgoPlugIn(tItemType &itemType, size_t &internalData) const; 00109 bool getIsGrabberInstance(tItemType &itemType, size_t &internalData) const; 00110 00111 QModelIndex getTypeNode(const int type) const; 00112 00113 protected: 00114 QVariant getFixedNodeInfo(const QModelIndex &index, const QVariant &name, const tItemType &itemType, const int &role, const QIcon icon) const; 00115 QVariant getPluginNodeInfo(const QModelIndex &index, const int &role) const; 00116 QVariant getInstanceNodeInfo(const QModelIndex &index, const int &role) const; 00117 QVariant getFilterOrWidgetNodeInfo(const QModelIndex &index, const int &role, bool filterNotWidget) const; 00118 00119 private: 00120 // void setupModelData(const QStringList &lines, AddInItem *parent); 00121 QList<QString> m_headers; 00122 QList<QVariant> m_alignment; 00123 00124 int m_treeFixNodes[6]; 00125 QModelIndex m_treeFixIndizes[6]; 00126 00127 QIcon m_iconActuator; 00128 QIcon m_iconGrabber; 00129 QIcon m_iconADDA; 00130 QIcon m_iconRawIO; 00131 QIcon m_iconFilter; 00132 QIcon m_iconDataIO; 00133 QIcon m_iconAlgo; 00134 QIcon m_iconWidget; 00135 QIcon m_iconPlots; 00136 }; 00137 00138 }; // namespace ito 00139 00140 #endif