Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
Workspace.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef WORKSPACE_H
22 #define WORKSPACE_H
23 
24 #include <QWidget>
25 #include <QMap>
26 #include <QVector>
27 
28 #include <tulip/tulipconf.h>
29 
30 class PlaceHolderWidget;
31 
32 namespace Ui {
33 class Workspace;
34 }
35 
36 class QPushButton;
37 class QLabel;
38 class QMimeData;
39 
40 namespace tlp {
41 class PluginProgress;
42 class View;
43 class WorkspacePanel;
44 class Graph;
45 class GraphHierarchiesModel;
46 class TulipProject;
47 
48 class TLP_QT_SCOPE Workspace: public QWidget {
49  Q_OBJECT
50 
51  Q_PROPERTY(bool bottomFrameVisible READ isBottomFrameVisible WRITE setBottomFrameVisible)
52 
53  Ui::Workspace* _ui;
54  QList<WorkspacePanel*> _panels;
55  int _currentPanelIndex;
56  QWidget* _oldWorkspaceMode;
57 
58  QMap<QWidget*,QVector<PlaceHolderWidget*> > _modeToSlots;
59  QMap<QWidget*,QWidget*> _modeSwitches;
60  GraphHierarchiesModel* _model;
61 
62  QString panelTitle(WorkspacePanel*) const;
63 
64  QLabel* _pageCountLabel;
65  bool _autoCenterViews;
66 
67 public:
68  explicit Workspace(QWidget *parent = NULL);
69  virtual ~Workspace();
70 
71  int addPanel(tlp::View*);
72  QList<tlp::View*> panels() const;
73 
74  bool isBottomFrameVisible() const;
75 
76 public slots:
77  void delView(tlp::View* view);
78  void switchToStartupMode();
79  void switchToSingleMode();
80  void setSingleModeSwitch(QWidget*);
81  void switchToSplitMode();
82  void setSplitModeSwitch(QWidget*);
83  void switchToSplit3Mode();
84  void setSplit3ModeSwitch(QWidget*);
85  void switchToSplit32Mode();
86  void setSplit32ModeSwitch(QWidget*);
87  void switchToSplit33Mode();
88  void setSplit33ModeSwitch(QWidget*);
89  void switchToGridMode();
90  void setGridModeSwitch(QWidget*);
91  void switchToSixMode();
92  void setSixModeSwitch(QWidget*);
93 
94  void nextPage();
95  void previousPage();
96  void setExposeModeSwitch(QPushButton *);
97  void expose(bool);
98  void showExposeMode();
99  void hideExposeMode();
100  void closeAll();
101  void setActivePanel(tlp::View*);
102  void setModel(tlp::GraphHierarchiesModel*);
103  tlp::GraphHierarchiesModel* graphModel() const;
104 
105  void writeProject(tlp::TulipProject*,QMap<tlp::Graph*,QString>, tlp::PluginProgress*);
106  void readProject(tlp::TulipProject*,QMap<QString,tlp::Graph*>,tlp::PluginProgress*);
107 
108  void setBottomFrameVisible(bool);
109  void setPageCountLabel(QLabel* l);
110 
111  void redrawPanels(bool center=false);
112 
113  void setAutoCenterPanelsOnDraw(bool);
114 
115 signals:
116  void panelFocused(tlp::View*);
117  void addPanelRequest(tlp::Graph* g = NULL);
118  void importGraphRequest();
119 
120 protected slots:
121  void viewNeedsDraw();
122  void switchWorkspaceMode(QWidget* page);
123  void panelDestroyed(QObject*);
124  void updatePageCountLabel();
125  void updateAvailableModes();
126  void updatePanels();
127  void uncheckExposeButton();
128  QWidget* suitableMode(QWidget* oldMode);
129  WorkspacePanel* panelForScene(QObject* obj);
130  void swapPanelsRequested(WorkspacePanel* panel);
131  void updateStartupMode();
132 
133 protected:
134 
135  virtual void dragEnterEvent(QDragEnterEvent* event);
136  virtual void dropEvent(QDropEvent* event);
137 
138  bool handleDragEnterEvent(QEvent* e, const QMimeData* mimedata);
139  bool handleDropEvent(const QMimeData* mimedata);
140 
141  bool eventFilter(QObject *, QEvent *);
142 
143  QWidget* currentModeWidget() const;
144  QVector<PlaceHolderWidget*> currentModeSlots() const;
145  unsigned int currentSlotsCount() const;
146 };
147 }
148 
149 #endif // WORKSPACE_H
150 ///@endcond