Import fmit upstream version 0.97.6
[fmit.git] / src / AutoQSettings.h
1 // Copyright 2007 "Gilles Degottex"
2
3 // This file is part of "fmit"
4
5 // "Music" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or
8 // (at your option) any later version.
9 //
10 // "Music" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19 #include <assert.h>
20 #include <list>
21 #include <qsettings.h>
22 #include <qcheckbox.h>
23 #include <qspinbox.h>
24 #include <qlineedit.h>
25 #include <qcombobox.h>
26 #include <qgroupbox.h>
27 #include <qradiobutton.h>
28
29 class AutoQSettings : public QSettings
30 {
31         std::list<QCheckBox*> m_elements_checkbox;
32         std::list<QSpinBox*> m_elements_spinbox;
33         std::list<QLineEdit*> m_elements_lineedit;
34         std::list<QComboBox*> m_elements_combobox;
35         std::list<QGroupBox*> m_elements_qgroupbox;
36         std::list<QRadioButton*> m_elements_qradiobutton;
37
38   public:
39         AutoQSettings(const QString& domain, const QString& product, const QString& setting_version);
40
41         void add(QCheckBox* el)                 {assert(el->name()!=""); m_elements_checkbox.push_back(el);}
42         void add(QSpinBox* el)                  {assert(el->name()!=""); m_elements_spinbox.push_back(el);}
43         void add(QLineEdit* el)                 {assert(el->name()!=""); m_elements_lineedit.push_back(el);}
44         void add(QComboBox* el)                 {assert(el->name()!=""); m_elements_combobox.push_back(el);}
45         void add(QGroupBox* el)                 {assert(el->name()!=""); m_elements_qgroupbox.push_back(el);}
46         void add(QRadioButton* el)              {assert(el->name()!=""); m_elements_qradiobutton.push_back(el);}
47
48         void save(QCheckBox* el);
49         void load(QCheckBox* el);
50
51         void save();
52         void load();
53         void clear();
54 };