itom  3.0.0
widgetPropHelpDock.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet 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 #ifndef WIDGETPROPHELPDOCK_H
24 #define WIDGETPROPHELPDOCK_H
25 
26 #include "abstractPropertyPageWidget.h"
27 
28 #include <qwidget.h>
29 #include <qstring.h>
30 
31 #include "ui_widgetPropHelpDock.h"
32 #include "helper/fileDownloader.h"
33 #include <qlist.h>
34 #include <qdir.h>
35 #include <qxmlstream.h>
36 
37 namespace ito
38 {
39 
41 {
42  Q_OBJECT
43 
44 public:
45  WidgetPropHelpDock(QWidget *parent = NULL);
47 
48 protected:
49  bool event (QEvent * event);
50 
51 private:
52  Ui::WidgetPropHelpDock ui;
53 
54  enum UpdateState
55  {
56  stateUnknown = 0,
57  stateUpToDate,
58  stateUpdateAvailable,
59  stateDownloadAvailable,
60  stateWrongScheme,
61  };
62 
63  struct DatabaseInfo
64  {
65  bool isChecked;
66  UpdateState updateState;
67  int version;
68  int schemeID;
69  QString name;
70  QString date;
71  QFileInfo path;
72  QUrl url;
73  };
74 
75  // Functions
76  void readSettings();
77  void writeSettings();
78  void getHelpList();
79  void refreshExistingDBs();
80  void initMenus();
81  void compareDatabaseVersions();
82  void updateCheckedIdList();
83  void setExistingDBsChecks();
84  QPair<int, DatabaseInfo> parseFile(QXmlStreamReader& xml);
85  void updateTreeWidget();
86  void refreshUpdatableDBs();
87  void setUpdateColumnText(QTreeWidgetItem *widget);
88  void showInGraphicalShell(const QString & filePath);
89  void showErrorMessage(const QString &error);
90 
91 
92 
93  // Variables
94  QString m_pdbPath;
95  bool m_listChanged;
96  bool m_treeIsUpdating;
97  bool m_downloadTimeoutReached;
101  // Lists and Co
102  QMap< int, DatabaseInfo > existingDBs;
103  QMap< int, DatabaseInfo > updatableDBs;
104  QList< int > checkedIdList;
106  // Menu
107  QMenu* m_pContextMenu;
108  std::map<QString,QAction*> contextMenuActions;
110  // Consts
111  static const int m_urID = Qt::UserRole + 1;
112  static const int m_urUD = Qt::UserRole + 2;
113  static const int m_urFD = Qt::UserRole + 3;
114  static const int SCHEME_ID = 1;
115  QString m_xmlFileName;
116 
117 signals:
118 
119 public slots:
120 
121 
122 private slots:
123  void on_treeWidgetDB_itemChanged(QTreeWidgetItem * item, int column);
124  void on_checkModules_stateChanged (int state);
125  void on_checkFilters_stateChanged (int state);
126  void on_checkWidgets_stateChanged (int state);
127  void on_checkDataIO_stateChanged (int state);
128  void on_spinTimeout_valueChanged(int i);
129  void refreshButtonClicked();
130  void mnuDownloadUpdate();
131  void mnuLocateOnDisk();
132  void mnuRemoveDatabase();
133  void treeWidgetContextMenuRequested(const QPoint &pos);
134  void downloadTimeoutReached();
135 };
136 
137 } //end namespace ito
138 
139 #endif
Definition: abstractPropertyPageWidget.h:31
static const int m_urUD
Definition: widgetPropHelpDock.h:112
int m_downloadTimeout
Definition: widgetPropHelpDock.h:98
static const int m_urFD
Definition: widgetPropHelpDock.h:113
void readSettings()
Definition: widgetPropHelpDock.cpp:130
QMap< int, DatabaseInfo > updatableDBs
Definition: widgetPropHelpDock.h:103
Definition: widgetPropHelpDock.h:40
std::map< QString, QAction * > contextMenuActions
Definition: widgetPropHelpDock.h:108
Definition: apiFunctionsGraph.cpp:39
static const int m_urID
Definition: widgetPropHelpDock.h:111
static const int SCHEME_ID
Definition: widgetPropHelpDock.h:114
QMap< int, DatabaseInfo > existingDBs
Definition: widgetPropHelpDock.h:102
void writeSettings()
Definition: widgetPropHelpDock.cpp:173
QList< int > checkedIdList
Definition: widgetPropHelpDock.h:104
Definition: widgetPropHelpDock.h:63
QMenu * m_pContextMenu
Definition: widgetPropHelpDock.h:107
QUrl m_serverAdress
Definition: widgetPropHelpDock.h:99