OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tool_options_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-2011 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_TOOL_OPTIONS_WIDGET_HH
20 #define OST_GUI_TOOL_OPTIONS_WIDGET_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 
26 #include <ost/gui/module_config.hh>
27 
29 
30 #include <QWidget>
31 
32 namespace ost { namespace gui {
33 
34 class DLLEXPORT_OST_GUI EnumOptBinder : public QObject {
35  Q_OBJECT
36 public:
38  EnumOptBinder(QObject* parent, ToolOptionEnum* enum_opt):
39  QObject(parent), enum_opt_(enum_opt)
40  { }
41 public slots:
42  void IndexChanged(int index)
43  {
44  enum_opt_->SetIndex(index);
45  }
46 private:
47  ToolOptionEnum* enum_opt_;
48 };
49 
50 class DLLEXPORT_OST_GUI IntOptBinder : public QObject {
51  Q_OBJECT
52 public:
54  IntOptBinder(QObject* parent, ToolOptionInt* int_opt):
55  QObject(parent), int_opt_(int_opt)
56  { }
57 public slots:
58  void TextChanged(const QString& text)
59  {
60  int_opt_->SetValue(text.toInt());
61  }
62 private:
63  ToolOptionInt* int_opt_;
64 };
65 
66 class DLLEXPORT_OST_GUI FloatOptBinder : public QObject {
67  Q_OBJECT
68 public:
70  FloatOptBinder(QObject* parent, ToolOptionFloat* float_opt):
71  QObject(parent), float_opt_(float_opt)
72  { }
73 public slots:
74  void TextChanged(const QString& text)
75  {
76  float_opt_->SetValue(text.toFloat());
77  }
78 private:
79  ToolOptionFloat* float_opt_;
80 };
81 
82 class DLLEXPORT_OST_GUI ToolOptionsWidget : public QWidget {
83 public:
84  ToolOptionsWidget(ToolOptions* options, QWidget* parent=NULL);
85 private:
86  void Populate();
87  QWidget* MakeIntWidget(ToolOptionInt* opts);
88  QWidget* MakeEnumWidget(ToolOptionEnum* opts);
89  QWidget* MakeFloatWidget(ToolOptionFloat* opts);
90  QWidget* MakeButtonWidget(ToolOptionButton* opts);
91  ToolOptions* options_;
92 };
93 
94 }}
95 
96 #endif