CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCmdLineModuleExplorerTreeWidget.h
Go to the documentation of this file.
1/*=============================================================================
2
3 Library: CTK
4
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics
7
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19
20=============================================================================*/
21
22#ifndef CTKCMDLINEMODULEEXPLORERTREEWIDGET_H
23#define CTKCMDLINEMODULEEXPLORERTREEWIDGET_H
24
26
27#include <QSortFilterProxyModel>
28#include <QTreeView>
29
33
34class QStandardItem;
35class QStandardItemModel;
36
37class ModuleSortFilterProxyModel : public QSortFilterProxyModel
38{
39 Q_OBJECT
40
41public:
42
43 ModuleSortFilterProxyModel(QObject *parent = 0);
44
45protected:
46
47 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
48
49 bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
50};
51
56class ctkCmdLineModuleExplorerTreeWidget : public QTreeView
57{
58 Q_OBJECT
59
60public:
61
62 explicit ctkCmdLineModuleExplorerTreeWidget(QWidget* parent = 0);
63
65
66 Q_SLOT void addModuleItem(const ctkCmdLineModuleReference& moduleRef);
67 Q_SLOT void removeModuleItem(const ctkCmdLineModuleReference& moduleRef);
68
69 Q_SIGNAL void moduleFrontendCreated(ctkCmdLineModuleFrontend* moduleFrontend);
70
71 Q_SLOT void setFilter(const QString& filter);
72
73protected:
74
75 void contextMenuEvent(QContextMenuEvent* event);
76
77private:
78
79 ctkCmdLineModuleFrontend* createFrontend(const ctkCmdLineModuleReference &moduleRef,
80 ctkCmdLineModuleFrontendFactory* frontendFactory);
81
82 Q_SLOT void moduleDoubleClicked(const QModelIndex& index);
83 Q_SLOT void frontendFactoryActionTriggered();
84
85 static QString CATEGORY_UNKNOWN;
86
87 QMenu* ContextMenu;
88 QMenu* ShowFrontendMenu;
89
91
92 ctkCmdLineModuleReference ContextReference;
94 ctkCmdLineModuleFrontendFactory* DefaultFrontendFactory;
95 QHash<QString, QStandardItem*> TreeWidgetCategories;
97 QHash<QAction*, ctkCmdLineModuleFrontendFactory*> ActionsToFrontendFactoryMap;
98
99 QStandardItemModel* TreeModel;
100 QSortFilterProxyModel* FilterProxyModel;
101};
102
103#endif // CTKCMDLINEMODULEEXPLORERTREEWIDGET_H
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
ModuleSortFilterProxyModel(QObject *parent=0)
Q_SLOT void addModuleItem(const ctkCmdLineModuleReference &moduleRef)
Q_SIGNAL void moduleFrontendCreated(ctkCmdLineModuleFrontend *moduleFrontend)
Q_SLOT void removeModuleItem(const ctkCmdLineModuleReference &moduleRef)
void setModuleFrontendFactories(const QList< ctkCmdLineModuleFrontendFactory * > &frontendFactories, ctkCmdLineModuleFrontendFactory *defaultFactory)
void contextMenuEvent(QContextMenuEvent *event)
ctkCmdLineModuleExplorerTreeWidget(QWidget *parent=0)
Q_SLOT void setFilter(const QString &filter)
Abstract base class for all front-end command line module implementations.
Defines a reference or handle to a module, including location, XML, description and access to the ass...
Factory class to create new front-ends.