OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
widget.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_WIDGET_HH
20 #define OST_GUI_WIDGET_HH
21 
22 
23 #include <ost/gui/module_config.hh>
24 
25 #include <QWidget>
26 #include <QMetaType>
27 /*
28  Author: Marco Biasini
29  */
30 
31 namespace ost { namespace gui {
32 
33 typedef QList<QAction*> ActionList;
34 
40 class DLLEXPORT_OST_GUI Widget : public QWidget {
41  Q_OBJECT
42 
43 public:
44  Widget(QWidget* widget, QWidget* parent=NULL);
45 
47  void SetDestroyOnClose(bool flag);
48 
51  bool DestroyOnClose() const;
52 
54  virtual ActionList GetActions();
55 
56  QWidget* GetInternalWidget();
57  void SetInternalWidget(QWidget* widget);
58 
59 
60  const QString& GetUniqueID() const
61  {
62  if (unique_id_.size()==0) {
63  unique_id_=this->metaObject()->className();
64  }
65  return unique_id_;
66  }
67 
68  void SetUniqueID(const QString& id)
69  {
70  unique_id_=id;
71  }
72 
73  virtual bool Restore(const QString& prefix)=0;
74 
75  virtual bool Save(const QString& prefix)=0;
76 
77 private:
78  mutable QString unique_id_;
79  QWidget* internal_;
80  bool destroy_on_close_;
81 };
82 
83 }}
84 
86 
87 #endif
void SetUniqueID(const QString &id)
Definition: widget.hh:68
#define DLLEXPORT_OST_GUI
QList< QAction * > ActionList
Definition: widget.hh:33
const QString & GetUniqueID() const
Definition: widget.hh:60
Base class for widgets.
Definition: widget.hh:40
Q_DECLARE_METATYPE(ost::io::EntityIOHandlerFactoryBaseP)