itom 1.0.14
D:/git-itom/sources/itom/Qitom/models/PlugInModel.h
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         QString filename;
00054         QList< QPair<tPluginLoadStatusFlag, QString> > messages;
00055     };
00056 
00065     class PlugInModel : public QAbstractItemModel
00066     {
00067         Q_OBJECT
00068 
00069         public:
00070             PlugInModel(/*const QString &data, QObject *parent = 0*/);
00071             ~PlugInModel();
00072 
00073             enum tItemType {
00074                 itemUnknown = 0x0000,
00075                 itemCatDataIO = 0x0001,
00076                 itemCatActuator = 0x0002,
00077                 itemCatAlgo = 0x0004,
00078                 itemSubCategoryDataIO_Grabber = 0x0008,
00079                 itemSubCategoryDataIO_ADDA = 0x0010,
00080                 itemSubCategoryDataIO_RawIO = 0x0020,
00081                 itemPlugin = 0x0040,
00082                 itemInstance = 0x0080,
00083                 itemFilter = 0x0100,
00084                 itemWidget = 0x0200,
00085                 itemCatMainAll = itemCatDataIO | itemCatActuator | itemCatAlgo,
00086                 itemCatSubAll = itemSubCategoryDataIO_Grabber | itemSubCategoryDataIO_ADDA | itemSubCategoryDataIO_RawIO,
00087                 itemCatAll = itemCatMainAll | itemCatSubAll
00088             };
00089 
00090             QVariant data(const QModelIndex &index, int role) const;
00091             Qt::ItemFlags flags(const QModelIndex &index) const;
00092             QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00093             QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00094             QModelIndex parent(const QModelIndex &index) const;
00095             int rowCount(const QModelIndex &parent = QModelIndex()) const;
00096             int columnCount(const QModelIndex &parent = QModelIndex()) const;
00097             int update(void) { emit(beginResetModel()); emit(endResetModel()); return 0; };
00098 
00099             bool insertInstance(ito::AddInInterfaceBase* addInInterface, bool beginOperation);
00100             bool deleteInstance(ito::AddInInterfaceBase* addInInterface, ito::AddInBase *addInInstance, bool beginOperation);
00101             bool resetModel(bool beginOperation);
00102 
00103             QModelIndex getIndexByAddIn(ito::AddInBase *ai) const;
00104             QModelIndex getIndexByAddInInterface(ito::AddInInterfaceBase *aib) const;
00105             bool getModelIndexInfo(const QModelIndex &index, tItemType &type, size_t &internalData) const;
00106 
00107             bool getIsAlgoPlugIn(tItemType &itemType, size_t &internalData) const;
00108             bool getIsGrabberInstance(tItemType &itemType, size_t &internalData) const;
00109 
00110             QModelIndex getTypeNode(const int type) const;
00111 
00112         protected:
00113             QVariant getFixedNodeInfo(const QModelIndex &index, const QVariant &name, const tItemType &itemType, const int &role, const QIcon icon) const;
00114             QVariant getPluginNodeInfo(const QModelIndex &index, const int &role) const;
00115             QVariant getInstanceNodeInfo(const QModelIndex &index, const int &role) const;
00116             QVariant getFilterOrWidgetNodeInfo(const QModelIndex &index, const int &role, bool filterNotWidget) const;
00117 
00118         private:
00119 //            void setupModelData(const QStringList &lines, AddInItem *parent);
00120             QList<QString> m_headers;               
00121             QList<QVariant> m_alignment;            
00122 
00123             int m_treeFixNodes[6];
00124             QModelIndex m_treeFixIndizes[6];
00125 
00126             QIcon m_iconActuator;
00127             QIcon m_iconGrabber;
00128             QIcon m_iconADDA;
00129             QIcon m_iconRawIO;
00130             QIcon m_iconFilter;
00131             QIcon m_iconDataIO;
00132             QIcon m_iconAlgo;
00133             QIcon m_iconWidget;
00134             QIcon m_iconPlots;
00135     };
00136 
00137 }; // namespace ito
00138 
00139 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends