Subversion Repositories Scribus

Rev

Rev 1340 | Rev 4430 | 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
 
1213 tsoots 35
void UndoState::setName(const QString &newName)
36
{
37
        actionName = newName;
38
}
39
 
1111 tsoots 40
QString UndoState::getDescription()
41
{
42
        return actionDescription;
43
}
44
 
1213 tsoots 45
void UndoState::setDescription(const QString &newDescription)
46
{
47
        actionDescription = newDescription;
48
}
49
 
1111 tsoots 50
QPixmap* UndoState::getPixmap()
51
{
1213 tsoots 52
        return actionPixmap;
1111 tsoots 53
}
54
 
1213 tsoots 55
void UndoState::setPixmap(QPixmap *pixmap)
56
{
57
        actionPixmap = pixmap;
58
}
59
 
1111 tsoots 60
UndoState::~UndoState()
61
{
1518 tsoots 62
 
1111 tsoots 63
}
64
 
65
/*** SimpleState **************************************************************/
66
 
67
SimpleState::SimpleState(const QString& name, const QString& description, QPixmap* pixmap)
68
: UndoState(name, description, pixmap)
69
{
70
 
71
}
72
 
73
bool SimpleState::contains(const QString& key)
74
{
75
        return values.contains(key);
76
}
77
 
78
QString SimpleState::get(const QString& key, const QString& def)
79
{
80
        if (values.contains(key))
81
                return values[key];
82
 
83
        values[key] = def;
84
        return values[key];
85
}
86
 
87
int SimpleState::getInt(const QString& key, int def)
88
{
89
        bool ok = false;
90
        QString retString = get(key, QString("%1").arg(def));
91
        int ret = retString.toInt(&ok);
92
        if (!ok)
93
                ret = def;
94
        return ret;
95
}
96
 
1238 tsoots 97
uint SimpleState::getUInt(const QString& key, uint def)
98
{
99
        bool ok = false;
100
        QString retString = get(key, QString("%1").arg(def));
101
        uint ret = retString.toUInt(&ok);
102
        if (!ok)
103
                ret = def;
104
        return ret;
105
}
106
 
1111 tsoots 107
double SimpleState::getDouble(const QString& key, double def)
108
{
109
        bool ok = false;
110
        QString retString = get(key, QString("%1").arg(def));
111
        double ret = retString.toDouble(&ok);
112
        if (!ok)
113
                ret = def;
114
        return ret;
115
}
116
 
1179 tsoots 117
bool SimpleState::getBool(const QString& key, bool def)
118
{
119
        bool ok = false;
120
        QString retString = get(key, QString("%1").arg(def));
121
        int ret = retString.toInt(&ok);
122
        if (!ok)
123
                ret = def;
124
        return ret;
125
}
126
 
1111 tsoots 127
void SimpleState::set(const QString& key, const QString& value)
128
{
129
        values[key] = value;
130
}
131
 
132
void SimpleState::set(const QString& key, int value)
133
{
134
        values[key] = QString("%1").arg(value);
135
}
136
 
1238 tsoots 137
void SimpleState::set(const QString& key, uint value)
138
{
139
        values[key] = QString("%1").arg(value);
140
}
141
 
1111 tsoots 142
void SimpleState::set(const QString& key, double value)
143
{
1152 tsoots 144
        values[key] = QString("%1").arg(value, 0, 'f', 20);
1111 tsoots 145
}
146
 
1179 tsoots 147
void SimpleState::set(const QString& key, bool value)
148
{
149
        values[key] = QString("%1").arg(value);
150
}
1111 tsoots 151
 
1179 tsoots 152
 
1518 tsoots 153
SimpleState::~SimpleState()
1111 tsoots 154
{
155
 
156
}