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