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 
00028 #include "../../common/sharedStructuresGraphics.h"
00029 
00030 #include <qabstractitemmodel.h>
00031 #include <qicon.h>
00032 
00033 namespace ito 
00034 {
00035     class AddInBase;
00036 
00041     struct PluginLoadStatus
00042     {
00043         QString filename;
00044         QList< QPair<ito::tRetValue, QString> > messages;
00045     };
00046 
00047     struct DesignerPlugin
00048     {
00049         QString filename;
00050         QString classname;
00051         PlotDataTypes plotDataTypes;
00052         PlotDataFormats plotDataFormats;
00053         PlotFeatures plotFeatures;
00054         QIcon icon;
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                 itemCatDesignerWidget = 0x0008,
00079                 itemSubCategoryDataIO_Grabber = 0x0010,
00080                 itemSubCategoryDataIO_ADDA = 0x0020,
00081                 itemSubCategoryDataIO_RawIO = 0x0040,
00082                 itemSubCategoryDesignerWidget = 0x0080,
00083                 itemPlugin = 0x0100,
00084                 itemInstance = 0x0200,
00085                 itemFilter = 0x0400,
00086                 itemWidget = 0x0800,
00087                 itemDesignerWidget = 0x1000,
00088                 itemCatMainAll = itemCatDataIO | itemCatActuator | itemCatAlgo | itemCatDesignerWidget,
00089                 itemCatSubAll = itemSubCategoryDataIO_Grabber | itemSubCategoryDataIO_ADDA | itemSubCategoryDataIO_RawIO,
00090                 itemCatAll = itemCatMainAll | itemCatSubAll
00091             };
00092 
00093             QVariant data(const QModelIndex &index, int role) const;
00094             Qt::ItemFlags flags(const QModelIndex &index) const;
00095             QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00096             QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00097             QModelIndex parent(const QModelIndex &index) const;
00098             int rowCount(const QModelIndex &parent = QModelIndex()) const;
00099             int columnCount(const QModelIndex &parent = QModelIndex()) const;
00100             int update(void) { emit(beginResetModel()); emit(endResetModel()); return 0; };
00101 
00102             bool insertInstance(ito::AddInInterfaceBase* addInInterface, bool beginOperation);
00103             bool deleteInstance(ito::AddInInterfaceBase* addInInterface, ito::AddInBase *addInInstance, bool beginOperation);
00104             bool resetModel(bool beginOperation);
00105 
00106             QModelIndex getIndexByAddIn(ito::AddInBase *ai) const;
00107             QModelIndex getIndexByAddInInterface(ito::AddInInterfaceBase *aib) const;
00108             bool getModelIndexInfo(const QModelIndex &index, tItemType &type, size_t &internalData) const;
00109 
00110             bool getIsAlgoPlugIn(size_t &internalData) const;
00111             bool getIsGrabberInstance(size_t &internalData) const;
00112 
00113             QModelIndex getTypeNode(const int type) const;
00114 
00115             void setDesignerPlugins( QList<DesignerPlugin> &designerPlugins );
00116 
00117         protected:
00118             QVariant getFixedNodeInfo(const QModelIndex &index, const QVariant &name, const tItemType &itemType, const int &role, const QIcon icon) const;
00119             QVariant getPluginNodeInfo(const QModelIndex &index, const int &role) const;
00120             QVariant getInstanceNodeInfo(const QModelIndex &index, const int &role) const;
00121             QVariant getFilterOrWidgetNodeInfo(const QModelIndex &index, const int &role, bool filterNotWidget) const;
00122 
00123         private:
00124 //            void setupModelData(const QStringList &lines, AddInItem *parent);
00125             QList<QString> m_headers;               
00126             QList<QVariant> m_alignment;            
00127 
00128             int *m_treeFixNodes;
00129             QModelIndex *m_treeFixIndizes;
00130 
00131             QIcon m_iconActuator;
00132             QIcon m_iconGrabber;
00133             QIcon m_iconADDA;
00134             QIcon m_iconRawIO;
00135             QIcon m_iconFilter;
00136             QIcon m_iconDataIO;
00137             QIcon m_iconAlgo;
00138             QIcon m_iconWidget;
00139             QIcon m_iconDesignerWidget;
00140 
00141             QList<DesignerPlugin> m_designerPlugins;
00142             QMap<int,QString> m_designerWidgetPlotTypes;
00143     };
00144 
00145 }; // namespace ito
00146 
00147 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends