itom  3.0.0
workspaceWidget.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 WORKSPACEWIDGET_H
24 #define WORKSPACEWIDGET_H
25 
26 #ifndef Q_MOC_RUN
27  //python
28  // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
29  #if (defined _DEBUG) && (defined WIN32)
30  #undef _DEBUG
31  #include "Python.h"
32  #define _DEBUG
33  #else
34  #include "Python.h"
35  #endif
36 #endif
37 
38 #include "../global.h"
39 #include "../common/sharedStructures.h"
40 #include "../common/sharedStructuresQt.h"
41 
42 #include "../python/pythonWorkspace.h"
43 
44 #include <qtreewidget.h>
45 #include <qmimedata.h>
46 #include <qpixmap.h>
47 #include <qhash.h>
48 #include <qset.h>
49 
50 namespace ito
51 {
52 
53 class WorkspaceWidget : public QTreeWidget
54 {
55  Q_OBJECT
56 public:
57  WorkspaceWidget(bool globalNotLocal, QWidget* parent = NULL);
59 
60  int numberOfSelectedItems(bool ableToBeRenamed = false) const;
61  int numberOfSelectedMainItems() const;
62  inline ito::PyWorkspaceContainer* getWorkspaceContainer() { return m_workspaceContainer; }
63 
65  {
66  RoleFullName = Qt::UserRole + 1,
67  RoleCompatibleTypes = Qt::UserRole + 2,
68  RoleType = Qt::UserRole + 3
69  };
70 
71  QString getPythonReadableName(const QTreeWidgetItem *item) const;
72 
73 protected:
74  QStringList mimeTypes() const;
75  QMimeData * mimeData(const QList<QTreeWidgetItem *> items) const;
76  void startDrag(Qt::DropActions supportedActions);
77 
78 private:
79  void updateView(QHash<QString,ito::PyWorkspaceItem*> items, QString baseName, QTreeWidgetItem *parent = NULL);
80  void recursivelyDeleteHash(QTreeWidgetItem *item);
81  void recursivelyDeleteHash(const QString &fullBaseName);
82 
84  QHash<QString,QTreeWidgetItem*> m_itemHash;
85  ito::PyWorkspaceContainer *m_workspaceContainer;
86 
87  QPixmap m_dragPixmap;
88 #if QT_VERSION >= 0x050000
89  Qt::DropActions supportedDragActions() const;
90 #endif
91 
92 signals:
93 
94 public slots:
95  void workspaceContainerUpdated(PyWorkspaceItem *rootItem, QString fullNameRoot, QStringList recentlyDeletedFullNames);
96 
97 private slots:
98  void itemDoubleClicked(QTreeWidgetItem* item, int column);
99  void itemExpanded(QTreeWidgetItem* item);
100  void itemCollapsed(QTreeWidgetItem* item);
101 };
102 
103 } //end namespace ito
104 
105 #endif
WorkspaceWidget(bool globalNotLocal, QWidget *parent=NULL)
constructor
Definition: workspaceWidget.cpp:46
bool m_globalNotLocal
Definition: workspaceWidget.h:83
Definition: apiFunctionsGraph.cpp:39
the workspaceWidget displays either a global or a local workspace given by a python dictionary...
Definition: workspaceWidget.h:53
WorkspaceRole
Definition: workspaceWidget.h:64
Definition: workspaceWidget.h:66
every item in the workspace is represented by one PyWorkspaceItem
Definition: pythonWorkspace.h:87
void itemDoubleClicked(QTreeWidgetItem *item, int column)
slot, invoked if item is double-clicked
Definition: workspaceWidget.cpp:373
Definition: pythonWorkspace.h:115
~WorkspaceWidget()
destructor
Definition: workspaceWidget.cpp:105