Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/qt_gui/src/lib/gui/qt_gui/qt_gui_elements.cc @ 7632

Last change on this file since 7632 was 7632, checked in by bensch, 18 years ago

Saving and defaultValues introduced

File size: 2.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "qt_gui_elements.h"
19
20namespace OrxGui
21{
22
23
24
25  QtGuiCheckBox::QtGuiCheckBox(const std::string& name, SaveableGroup* group, bool defaultValue)
26  : QCheckBox(QString().fromStdString(name)), Saveable(name, group, defaultValue)
27  {
28    //this->load(this->value());
29  }
30
31  void QtGuiCheckBox::load()
32  {
33    Saveable::load();
34    if (this->value().getBool())
35      this->setCheckState(Qt::Checked);
36    else
37      this->setCheckState(Qt::Unchecked);
38  }
39
40
41
42  void QtGuiCheckBox::save()
43  {
44    this->value() = this->checkState();
45    Saveable::save();
46  }
47
48
49
50
51
52  QtGuiSlider::QtGuiSlider(const std::string& name, SaveableGroup* group, int defaultValue, Qt::Orientation orientation)
53  : QSlider(orientation), Saveable(name, group, defaultValue)
54  {
55
56  }
57
58  QtGuiSlider::~QtGuiSlider()
59  {}
60
61  void QtGuiSlider::load()
62  {
63    Saveable::load();
64    this->setValue(this->Saveable::value().getInt());
65  }
66
67  void QtGuiSlider::save()
68  {
69    this->Saveable::value() = this->QSlider::value();
70    Saveable::save();
71  }
72
73
74
75
76
77
78
79  QtGuiComboBox::QtGuiComboBox(const std::string& name, SaveableGroup* group, const std::string& defaultValue)
80  : QComboBox(), Saveable(name, group, defaultValue)
81  {
82
83
84  }
85
86  void QtGuiComboBox::load()
87  {
88    Saveable::load();
89    this->setCurrentIndex(this->findText(QString().fromStdString(this->value().getString())));
90  }
91
92  void QtGuiComboBox::save()
93  {
94    this->value() = this->currentText().toStdString();
95    Saveable::save();
96  }
97
98
99  QtGuiInputLine::QtGuiInputLine(const std::string& name, SaveableGroup* group, const std::string& defaultValue)
100  : QLineEdit(), Saveable(name, group, defaultValue)
101  {
102
103
104  }
105
106
107  void QtGuiInputLine::load()
108  {
109    Saveable::load();
110    this->setText(QString().fromStdString(this->value().getString()));
111  }
112
113
114
115  void QtGuiInputLine::save()
116  {
117    this->value() = this->text().toStdString();
118    Saveable::save();
119  }
120
121
122
123
124}
Note: See TracBrowser for help on using the repository browser.