OpenStructure
panel_manager.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GUI_PANEL_BAR_PANEL_MANAGER
20 #define OST_GUI_PANEL_BAR_PANEL_MANAGER
21 
22 
23 #include <ost/gui/widget.hh>
24 #include <ost/gui/widget_pool.hh>
25 #include <ost/gui/thin_splitter.hh>
26 
28 #include "button_box.hh"
29 
30 #include <QWidget>
31 #include <QString>
32 #include <QList>
33 #include <QMenu>
34 #include <QDragEnterEvent>
35 namespace ost { namespace gui {
36 
38 {
42  NONE
43 };
44 
49  Q_OBJECT
50 public:
51  PanelManager(QWidget* widget);
53  virtual bool Save(const QString& prefix);
54  virtual bool Restore(const QString& prefix);
55 
62  virtual void AddWidgetToPool(const QString& class_name, int limit=-1);
68  virtual void AddWidgetToPool(const QString& name, Widget* widget);
69 
76  void AddWidget(PanelPosition pos, Widget* widget, bool is_hidden=false);
82  void AddWidgetByName(PanelPosition pos, const QString& class_name, bool is_hidden=false);
83 
89  void ReplaceWidget(Widget* w1, Widget* w2);
93  void ReplaceWidget(Widget* w1, QString& class_name);
94 
98  QMenu* GetMenu();
102  QList<QString> GetAvailableWidgets();
103 
107  void StartDrag();
110  void EndDrag();
111 
112 public slots:
117 
121 
125  void MoveWidget(Widget * widget, PanelPosition pos, int index);
126 
131  void MoveNextTo(Widget* target, Widget* widget);
132 
136  void RemoveWidget(Widget * widget);
137 
139  void ToggleHide();
143 
144 private slots:
145  void UpdateAddMenu();
146  void UpdateCurrentMenu();
147  void AddWidgetFromMenu(QAction * action);
148 
149 private:
150  PanelPosition GetParentPanel(Widget* widget);
151 
152  ThinSplitter* right_panel_splitter_;
153  ThinSplitter* left_panel_splitter_;
154  ThinSplitter* bottom_panel_splitter_;
155  QMap<PanelPosition, PanelBar*> panels_;
156  WidgetPool* pool_;
157  QMenu* add_menu_;
158  PanelPosition current_menu_;
159 };
160 
161 }}
162 
163 #endif
164 
Class which organizes all widgets which are in the side panels This class handles all side bar widget...
void ToggleHide()
Toggle the visibility of all Panels.
virtual void AddWidgetToPool(const QString &class_name, int limit=-1)
Add a widget to the widget pool.
virtual bool Save(const QString &prefix)
void RemoveWidget(Widget *widget)
Remove a Widget out of a PanelBar The widget will be removed if it is in a PanelBar.
void ToggleViewMode(PanelPosition pos)
Toggle between the ViewMode 's of the Given Panel.
void EndDrag()
End with dragging widgets This method should be called always when a drag event is over....
void ToggleHide(PanelPosition pos)
Toggle the visibility of the given Panel.
void StartDrag()
Begin with dragging widgets This method should be called, when someone tries to drop a widget on a Pa...
QList< QString > GetAvailableWidgets()
Get a List with available Widgets Get all the Widgets which have available resources in the WidgetPoo...
void ReplaceWidget(Widget *w1, Widget *w2)
Replace a Widget with another Widget With this Method you can replace a Widget which is in a PanelBar...
PanelManager(QWidget *widget)
void MoveNextTo(Widget *target, Widget *widget)
Move a Widget next to the given Widget The widget will be displayed next to the target Widget....
void AddWidgetByName(PanelPosition pos, const QString &class_name, bool is_hidden=false)
Display a Widget in a PanelBar Same as PanelManager::AddWidget(PanelPosition pos, Widget* widget,...
void MoveWidget(Widget *widget, PanelPosition pos, int index)
Move a Widget to the given Position The widget is being moved to the given position....
QMenu * GetAvailableWidgetsMenu()
get a QMenu with available Widget Same as GetMenu()
void ReplaceWidget(Widget *w1, QString &class_name)
QMenu * GetMenu()
Get Menu The GetMenu method returns a QMenu reference, which contains various actions....
virtual bool Restore(const QString &prefix)
void AddWidget(PanelPosition pos, Widget *widget, bool is_hidden=false)
Display a Widget in a PanelBar With Method you can add a widget to the given PanelBar....
virtual void AddWidgetToPool(const QString &name, Widget *widget)
Add a widget to the widget pool.
splitter with 1 pixel wide handles.
Base class for widgets.
Definition: widget.hh:40
This Widget pool manages instances of widgets Widgets can be added to this pool by simply passing the...
Definition: widget_pool.hh:45
#define DLLEXPORT_OST_GUI
Definition: base.dox:1