itom  4.1.0
helpTreeDockWidget.h
1 #ifndef HELPTREEDOCKWIDGET_H
2 #define HELPTREEDOCKWIDGET_H
3 
4 #include "../../common/sharedStructures.h"
5 
6 #include <qwidget.h>
7 #include <qstandarditemmodel.h>
8 #include <qtimer.h>
9 #include <qfuturewatcher.h>
10 #include <qmovie.h>
11 
12 #include "../widgets/abstractDockWidget.h"
13 
14 #include "ui_helpTreeDockWidget.h"
15 
16 class QShowEvent; //forward declaration
17 
18 namespace ito
19 {
20 
21 class LeafFilterProxyModel; //forward declaration
22 
23 class HelpTreeDockWidget : public QWidget
24 {
25  Q_OBJECT
26 
27  // the following properties replace $<name>$ tags in the help_style.css file,
28  // where <name> is the name of the property
29  Q_PROPERTY(QColor backgroundColorHeading READ backgroundColorHeading WRITE setBackgroundColorHeading) // default: #efefef;
30  Q_PROPERTY(QColor textColorHeading READ textColorHeading WRITE setTextColorHeading) // default: #0c3762;
31  Q_PROPERTY(QColor linkColor READ linkColor WRITE setLinkColor); // default: #dc3c01
32  Q_PROPERTY(QColor backgroundParamName READ backgroundParamName WRITE setBackgroundParamName); // default: #dcb8aa
33  Q_PROPERTY(QColor textColorSection READ textColorSection WRITE setTextColorSection); // default: #dc3c01
34  Q_PROPERTY(QColor backgroundColorSection READ backgroundColorSection WRITE setBackgroundColorSection); // default: #eeeeee
35 
36  Q_FLAGS(State States)
37 
38 public:
39  HelpTreeDockWidget(QWidget *parent, ito::AbstractDockWidget *dock = 0, Qt::WindowFlags flags = 0);
41 
42  enum HelpItemType
43  {
44  typeFilter = 2, /* a filter method from an algorithm plugin */
45  typeWidget = 3, /* a widget method from an algorithm plugin */
46  typeFPlugin = 4, /* an algorithm plugin in the filter section */
47  typeWPlugin = 5, /* an algorithm plugin in the widget section */
48  typeCategory = 6, /* a category */
49  typeDataIO = 7, /* a dataIO plugin */
50  typeActuator = 8 /* an actuator plugin */
51  };
52 
53  enum IconType
54  {
55  iconFilter = 100,
56  iconPluginAlgo = 101,
57  iconPluginFilter = 102,
58  iconWidget = 103,
59  iconPluginDataIO = 104,
60  iconPluginGrabber = 105,
61  iconPluginAdda = 106,
62  iconPluginRawIO = 107,
63  iconPluginActuator = 108
64  };
65 
66  enum State
67  {
68  stateIdle = 0x00,
69  stateVisible = 0x01,
70  stateContentLoaded = 0x02
71  };
72  Q_DECLARE_FLAGS(States, State)
73 
74 
75  QColor backgroundColorHeading() const;
76  void setBackgroundColorHeading(const QColor &color);
77 
78  QColor textColorHeading() const;
79  void setTextColorHeading(const QColor &color);
80 
81  QColor backgroundColorSection() const;
82  void setBackgroundColorSection(const QColor &color);
83 
84  QColor textColorSection() const;
85  void setTextColorSection(const QColor &color);
86 
87  QColor linkColor() const;
88  void setLinkColor(const QColor &color);
89 
90  QColor backgroundParamName() const;
91  void setBackgroundParamName(const QColor &color);
92 
93 
94 
95 public slots:
96  void navigateBackwards();
97  void navigateForwards();
98  void expandTree();
99  void collapseTree();
100  void reloadHelpResources();
101  void liveFilter(const QString &filterText);
102  void propertiesChanged();
103  void showPluginInfo(const QString &name, HelpItemType type, const QModelIndex &modelIndex, bool fromLink);
104  ito::RetVal showFilterWidgetPluginHelp(const QString &filtername, HelpItemType type);
105 
106 private slots:
107  void on_splitter_splitterMoved ( int pos, int index );
108  void on_helpTreeContent_anchorClicked(const QUrl & link);
109 
110  void loadHelpResourcesFinished(int index);
111 
112  void on_treeView_expanded(const QModelIndex &index);
113  void on_treeView_collapsed(const QModelIndex &index);
114 
115  void selectedItemChanged(const QModelIndex &current, const QModelIndex &previous);
116 
117 private:
118 
119  static void createFilterWidgetNode(int fOrW, QStandardItemModel* model, const QMap<int,QIcon> *iconGallery);
120  static ito::RetVal loadHelpResources(QStandardItemModel *mainModel, const QMap<int,QIcon> *iconGallery);
121 
122  void storeSettings();
123  void restoreSettings();
124  QStringList separateLink(const QUrl &link);
125  ito::RetVal highlightContent(const QString &prefix , const QString &name , const QString &param , const QString &shortDesc, const QString &helpText, const QString &error, QTextDocument *document, const QMap<QString, QImage> &images);
126  QModelIndex findIndexByPath(const int type, QStringList path, const QStandardItem* current);
127 
128  QString parseFilterWidgetContent(const QString &input);
129  ito::RetVal parseParamVector(const QString &sectionname, const QVector<ito::Param> &paramVector, QString &content);
130  QString parseParam(const QString &tmpl, const ito::Param &param);
131 
132  void loadAndProcessCssStyleSheet();
133 
134  // Const
135  static const int rolePath = Qt::UserRole + 1;
136  static const int roleType = Qt::UserRole + 2;
137  static const int roleFilename = Qt::UserRole + 3;
138 
139  QString minText(int minimum) const;
140  QString minText(double minimum) const;
141  QString minText(char minimum) const;
142  QString maxText(int minimum) const;
143  QString maxText(double minimum) const;
144  QString maxText(char minimum) const;
145  QString minmaxText(int value) const;
146  QString minmaxText(double value) const;
147  QString minmaxText(char value) const;
148 
149  // Variables
150  Ui::HelpTreeDockWidget ui;
151  QStandardItemModel *m_pMainModel;
154  QList<QModelIndex> m_history;
155  QMovie *m_previewMovie;
156  QMap<int, QIcon> m_iconGallery;
157  int m_historyIndex;
161  bool m_treeVisible;
162  bool m_plaintext;
163  bool m_autoCollTree;
166  States m_state;
167  QString m_filterTextPending;
168  int m_filterTextPendingTimer;
169 
170  QColor m_backgroundColorHeading; // default: #efefef;
171  QColor m_textColorHeading; // default: #0c3762;
172  QColor m_linkColor; // default: #dc3c01
173  QColor m_backgroundParamName; // default: #dcb8aa
174  QColor m_textColorSection; // default: #dc3c01
175  QColor m_backgroundColorSection; // default: #eeeeee
176 
177  QFutureWatcher<ito::RetVal> m_loaderWatcher;
178  QMutex m_dbLoaderMutex;
179 
180 protected:
181  void showEvent(QShowEvent *event);
182  void timerEvent(QTimerEvent *event);
183 };
184 
185 } //end namespace ito
186 
187 #endif // HELPTREEDOCKWIDGET_H
double m_treeWidthInvisible
Definition: helpTreeDockWidget.h:160
void liveFilter(const QString &filterText)
slot invoked by toolbar
Definition: helpTreeDockWidget.cpp:1808
static void createFilterWidgetNode(int fOrW, QStandardItemModel *model, const QMap< int, QIcon > *iconGallery)
Get The Filters and put them into a node of the Tree.
Definition: helpTreeDockWidget.cpp:120
void propertiesChanged()
(Re)load the help resources if some properties have changed
Definition: helpTreeDockWidget.cpp:1526
ito::RetVal parseParamVector(const QString &sectionname, const QVector< ito::Param > &paramVector, QString &content)
Creates the Parameter- and Return- sections in html-Code.
Definition: helpTreeDockWidget.cpp:954
void showPluginInfo(const QString &name, HelpItemType type, const QModelIndex &modelIndex, bool fromLink)
slot invoked by different widgets to display a help page from extern
Definition: helpTreeDockWidget.cpp:1896
void storeSettings()
Save Gui positions to Main-ini-File.
Definition: helpTreeDockWidget.cpp:1476
bool m_doingExpandAll
Definition: helpTreeDockWidget.h:165
QStandardItemModel * m_pMainModel
Definition: helpTreeDockWidget.h:151
Class for managing status values (like errors or warning)
Definition: retVal.h:54
class for parameter handling e.g. to pass paramters to plugins
Definition: param.h:283
static ito::RetVal loadHelpResources(QStandardItemModel *mainModel, const QMap< int, QIcon > *iconGallery)
Load help resources from various plugins in a different thread.
Definition: helpTreeDockWidget.cpp:1643
void reloadHelpResources()
Reload different help resources and clear search-edit and start the new thread.
Definition: helpTreeDockWidget.cpp:1555
QString minText(int minimum) const
This function detects if a range minimum of a variable is equal to the minimum of the type...
Definition: helpTreeDockWidget.cpp:1314
QString minmaxText(int value) const
This function detects if a range minimum or maximum of a variable is equal to the minimum or maximum ...
Definition: helpTreeDockWidget.cpp:1416
QString parseFilterWidgetContent(const QString &input)
Reformats all help strings that come from the widgets and plugins.
Definition: helpTreeDockWidget.cpp:937
void loadHelpResourcesFinished(int index)
This slot is called when the loading thread is finished.
Definition: helpTreeDockWidget.cpp:1599
Definition: apiFunctionsGraph.cpp:39
QMovie * m_previewMovie
Definition: helpTreeDockWidget.h:155
bool m_internalCall
Definition: helpTreeDockWidget.h:164
QModelIndex findIndexByPath(const int type, QStringList path, const QStandardItem *current)
finds a Modelindex related to MainModel (not FilterModel)belonging to an Itemname ...
Definition: helpTreeDockWidget.cpp:1965
void restoreSettings()
Load Gui positions to Main-ini-File.
Definition: helpTreeDockWidget.cpp:1489
Definition: helpTreeDockWidget.h:23
QString parseParam(const QString &tmpl, const ito::Param &param)
Parses a single Parameter to html code (called by parseParamVector)
Definition: helpTreeDockWidget.cpp:1002
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition: abstractDockWidget.h:54
ito::AbstractDockWidget * m_pParent
Definition: helpTreeDockWidget.h:153
LeafFilterProxyModel * m_pMainFilterModel
Definition: helpTreeDockWidget.h:152
QList< QModelIndex > m_history
Definition: helpTreeDockWidget.h:154
double m_treeWidthVisible
Definition: helpTreeDockWidget.h:159
QStringList separateLink(const QUrl &link)
Returns a list containing the protocol[0] and the real link[1].
Definition: helpTreeDockWidget.cpp:1839
States m_state
Definition: helpTreeDockWidget.h:166
QString maxText(int minimum) const
This function detects if a range maximum of a variable is equal to the maximum of the type...
Definition: helpTreeDockWidget.cpp:1365
bool m_plaintext
Definition: helpTreeDockWidget.h:162
ito::RetVal showFilterWidgetPluginHelp(const QString &filtername, HelpItemType type)
Get the DocString from a Filter and parse is to html.
Definition: helpTreeDockWidget.cpp:329
This class provides a special search function to the help model. The normal filtermodel hides nodes i...
Definition: leafFilterProxyModel.h:31
int m_autoCollTime
Definition: helpTreeDockWidget.h:158