~ubuntu-branches/ubuntu/maverick/juffed/maverick-proposed

« back to all changes in this revision

Viewing changes to src/lib/SettingsCheckItem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2010-07-22 15:01:58 UTC
  • Revision ID: james.westby@ubuntu.com-20100722150158-m3792gi6tj0y8zl6
Tags: upstream-0.8.1
ImportĀ upstreamĀ versionĀ 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
JuffEd - An advanced text editor
 
3
Copyright 2007-2009 Mikhail Murzin
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License 
 
7
version 2 as published by the Free Software Foundation.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
GNU General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU General Public License
 
15
along with this program; if not, write to the Free Software
 
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
17
*/
 
18
 
 
19
#include "SettingsCheckItem.h"
 
20
 
 
21
#include <QtGui/QCheckBox>
 
22
 
 
23
SettingsCheckItem::SettingsCheckItem(const QString& section, const QString& key, 
 
24
                                     QCheckBox* cb)
 
25
{
 
26
        checkBox_ = cb;
 
27
        section_ = section;
 
28
        key_ = key;
 
29
//      default_ = Settings::defaultValue(section, key);
 
30
        readValue();
 
31
        
 
32
        connect(cb, SIGNAL(toggled(bool)), SLOT(onChecked(bool)));
 
33
}
 
34
 
 
35
void SettingsCheckItem::readValue() {
 
36
        curValue_ = Settings::boolValue(section_, key_);
 
37
        checkBox_->setChecked(curValue_);
 
38
}
 
39
 
 
40
void SettingsCheckItem::writeValue() {
 
41
        if ( checkBox_->isChecked() != curValue_ ) {
 
42
                curValue_ = checkBox_->isChecked();
 
43
                Settings::setValue(section_, key_, curValue_);
 
44
                oneLessChanged();
 
45
        }
 
46
}
 
47
 
 
48
void SettingsCheckItem::onChecked(bool checked) {
 
49
        if ( checked != curValue_ )
 
50
                oneMoreChanged();
 
51
        else
 
52
                oneLessChanged();
 
53
}