itom
Loading...
Searching...
No Matches
pluginModel.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#pragma once
24
25#if !defined(Q_MOC_RUN) || defined(ADDINMGR_DLL) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib
26
27#include "addInMgrDefines.h"
28#include "../common/addInInterface.h"
29
30#include <qabstractitemmodel.h>
31#include <qscopedpointer.h>
32#include <qcolor.h>
33#include <qicon.h>
34
35namespace ito
36{
37 class AddInBase;
38 class AddInManager;
39
45 {
46 plsfOk = 0x001,
47 plsfWarning = 0x002,
48 plsfError = 0x004,
49 plsfIgnored = 0x008,
50 plsfRelDbg = 0x100,
52 };
53 Q_DECLARE_FLAGS(PluginLoadStatusFlags, tPluginLoadStatusFlag)
54
55
56
61 {
62 PluginLoadStatus() : filename("") {}
63 QString filename;
64 QList< QPair<ito::PluginLoadStatusFlags, QString> > messages;
65 };
66
67 class PlugInModelPrivate; //forward declaration
68
77 class ADDINMGR_EXPORT PlugInModel : public QAbstractItemModel
78 {
79 Q_OBJECT
80
81 public:
82 PlugInModel(ito::AddInManager *addInManager, QObject *parent = NULL);
84
85 enum tItemType {
86 itemUnknown = 0x0000,
87 itemCatDataIO = 0x0001,
88 itemCatActuator = 0x0002,
89 itemCatAlgo = 0x0004,
90 itemSubCategoryDataIO_Grabber = 0x0008,
91 itemSubCategoryDataIO_ADDA = 0x0010,
92 itemSubCategoryDataIO_RawIO = 0x0020,
93 itemPlugin = 0x0040,
94 itemInstance = 0x0080,
95 itemFilter = 0x0100,
96 itemWidget = 0x0200,
97 itemCatMainAll = itemCatDataIO | itemCatActuator | itemCatAlgo,
98 itemCatSubAll = itemSubCategoryDataIO_Grabber | itemSubCategoryDataIO_ADDA | itemSubCategoryDataIO_RawIO,
99 itemCatAll = itemCatMainAll | itemCatSubAll
100 };
101
102 QVariant data(const QModelIndex &index, int role) const;
103 Qt::ItemFlags flags(const QModelIndex &index) const;
104 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
105 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
106 QModelIndex parent(const QModelIndex &index) const;
107 int rowCount(const QModelIndex &parent = QModelIndex()) const;
108 int columnCount(const QModelIndex &parent = QModelIndex()) const;
109 int update(void) { emit(beginResetModel()); emit(endResetModel()); return 0; };
110
111 bool insertInstance(ito::AddInInterfaceBase* addInInterface, bool beginOperation);
112 bool deleteInstance(ito::AddInBase *addInInstance, const bool beginOperation);
113 bool resetModel(bool beginOperation);
114
115 QModelIndex getIndexByAddIn(ito::AddInBase *ai) const;
116 QModelIndex getIndexByAddInInterface(ito::AddInInterfaceBase *aib) const;
117 bool getModelIndexInfo(const QModelIndex &index, tItemType &type, size_t &internalData) const;
118
119 bool getIsAlgoPlugIn(tItemType &itemType, size_t &internalData) const;
120 bool getIsGrabberInstance(tItemType &itemType, size_t &internalData) const;
121
122 QModelIndex getTypeNode(const int type) const;
123
125 QColor backgroundColorInstancesWithPythonRef() const;
126 void setBackgroundColorInstancesWithPythonRef(const QColor &bgColor);
127
128 protected:
129 QVariant getFixedNodeInfo(const QModelIndex &index, const QVariant &name, const tItemType &itemType, const int &role, const QIcon icon) const;
130 QVariant getPluginNodeInfo(const QModelIndex &index, const int &role) const;
131 QVariant getInstanceNodeInfo(const QModelIndex &index, const int &role) const;
132 QVariant getFilterOrWidgetNodeInfo(const QModelIndex &index, const int &role, bool filterNotWidget) const;
133 QMimeData* mimeData(const QModelIndexList &indexes) const;
134
135 private:
136 QScopedPointer<PlugInModelPrivate> d_ptr;
137 QString getInitCommand(const QModelIndex & item) const;
138 Q_DECLARE_PRIVATE(PlugInModel);
139 };
140
141}; // namespace ito
142
143#endif // #if !defined(Q_MOC_RUN) || defined(ADDINMGR_DLL)
Base class for all plugins.
Definition addInInterface.h:386
forward declaration to private container class of AddInAlog
Definition addInInterface.h:249
class for AddIn management
Definition addInManager.h:67
class for visualizing the available (loaded) plugins
Definition pluginModel.h:78
Definition pluginModel.cpp:33
Definition apiFunctionsGraph.cpp:40
tPluginLoadStatusFlag
Definition pluginModel.h:45
@ plsfOk
Definition pluginModel.h:46
@ plsfIncompatible
Definition pluginModel.h:51
@ plsfRelDbg
Definition pluginModel.h:50
@ plsfError
Definition pluginModel.h:48
@ plsfIgnored
Definition pluginModel.h:49
@ plsfWarning
Definition pluginModel.h:47
This struct provides a structure for saving the load status of any plugins or designerWidgets.
Definition pluginModel.h:61