Subversion Repositories Scribus

Rev

Rev 1152 | Rev 1213 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1111 tsoots 1
/***************************************************************************
2
 *   Copyright (C) 2005 by Riku Leino                                      *
3
 *   tsoots@gmail.com                                                      *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License, or     *
8
 *   (at your option) any later version.                                   *
9
 *                                                                         *
10
 *   This program 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 General Public License for more details.                          *
14
 *                                                                         *
15
 *   You should have received a copy of the GNU General Public License     *
16
 *   along with this program; if not, write to the                         *
17
 *   Free Software Foundation, Inc.,                                       *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 ***************************************************************************/
20
 
21
#include "undostate.h"
22
 
23
UndoState::UndoState(const QString& name, const QString& description, QPixmap* pixmap)
24
{
25
        actionName        = name;
26
        actionDescription = description;
27
        actionPixmap      = pixmap;
28
}
29
 
30
QString UndoState::getName()
31
{
32
        return actionName;
33
}
34
 
35
QString UndoState::getDescription()
36
{
37
        return actionDescription;
38
}
39
 
40
QPixmap* UndoState::getPixmap()
41
{
42
        return actionPixmap;   
43
}
44
 
45
UndoState::~UndoState()
46
{
47
 
48
}
49
 
50
/*** SimpleState **************************************************************/
51
 
52
SimpleState::SimpleState(const QString& name, const QString& description, QPixmap* pixmap)
53
: UndoState(name, description, pixmap)
54
{
55
 
56
}
57
 
58
bool SimpleState::contains(const QString& key)
59
{
60
        return values.contains(key);
61
}
62
 
63
QString SimpleState::get(const QString& key, const QString& def)
64
{
65
        if (values.contains(key))
66
                return values[key];
67
 
68
        values[key] = def;
69
        return values[key];
70
}
71
 
72
int SimpleState::getInt(const QString& key, int def)
73
{
74
        bool ok = false;
75
        QString retString = get(key, QString("%1").arg(def));
76
        int ret = retString.toInt(&ok);
77
        if (!ok)
78
                ret = def;
79
        return ret;
80
}
81
 
82
double SimpleState::getDouble(const QString& key, double def)
83
{
84
        bool ok = false;
85
        QString retString = get(key, QString("%1").arg(def));
86
        double ret = retString.toDouble(&ok);
87
        if (!ok)
88
                ret = def;
89
        return ret;
90
}
91
 
1179 tsoots 92
bool SimpleState::getBool(const QString& key, bool def)
93
{
94
        bool ok = false;
95
        QString retString = get(key, QString("%1").arg(def));
96
        int ret = retString.toInt(&ok);
97
        if (!ok)
98
                ret = def;
99
        return ret;
100
}
101
 
1111 tsoots 102
void SimpleState::set(const QString& key, const QString& value)
103
{
104
        values[key] = value;
105
}
106
 
107
void SimpleState::set(const QString& key, int value)
108
{
109
        values[key] = QString("%1").arg(value);
110
}
111
 
112
void SimpleState::set(const QString& key, double value)
113
{
1152 tsoots 114
        values[key] = QString("%1").arg(value, 0, 'f', 20);
1111 tsoots 115
}
116
 
1179 tsoots 117
void SimpleState::set(const QString& key, bool value)
118
{
119
        values[key] = QString("%1").arg(value);
120
}
1111 tsoots 121
 
1179 tsoots 122
 
1111 tsoots 123
SimpleState::~SimpleState()
124
{
125
 
126
}