Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
1111 tsoots 7
/***************************************************************************
8
 *   Copyright (C) 2005 by Riku Leino                                      *
9
 *   tsoots@gmail.com                                                      *
10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 *   This program is distributed in the hope that it will be useful,       *
17
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19
 *   GNU General Public License for more details.                          *
20
 *                                                                         *
21
 *   You should have received a copy of the GNU General Public License     *
22
 *   along with this program; if not, write to the                         *
23
 *   Free Software Foundation, Inc.,                                       *
24
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
25
 ***************************************************************************/
26
 
27
#include "undostate.h"
28
 
29
UndoState::UndoState(const QString& name, const QString& description, QPixmap* pixmap)
30
{
31
        actionName        = name;
32
        actionDescription = description;
33
        actionPixmap      = pixmap;
34
}
35
 
36
QString UndoState::getName()
37
{
38
        return actionName;
39
}
40
 
1213 tsoots 41
void UndoState::setName(const QString &newName)
42
{
43
        actionName = newName;
44
}
45
 
1111 tsoots 46
QString UndoState::getDescription()
47
{
48
        return actionDescription;
49
}
50
 
1213 tsoots 51
void UndoState::setDescription(const QString &newDescription)
52
{
53
        actionDescription = newDescription;
54
}
55
 
1111 tsoots 56
QPixmap* UndoState::getPixmap()
57
{
1213 tsoots 58
        return actionPixmap;
1111 tsoots 59
}
60
 
1213 tsoots 61
void UndoState::setPixmap(QPixmap *pixmap)
62
{
63
        actionPixmap = pixmap;
64
}
65
 
1111 tsoots 66
UndoState::~UndoState()
67
{
1518 tsoots 68
 
1111 tsoots 69
}
70
 
71
/*** SimpleState **************************************************************/
72
 
73
SimpleState::SimpleState(const QString& name, const QString& description, QPixmap* pixmap)
74
: UndoState(name, description, pixmap)
75
{
76
 
77
}
78
 
79
bool SimpleState::contains(const QString& key)
80
{
81
        return values.contains(key);
82
}
83
 
84
QString SimpleState::get(const QString& key, const QString& def)
85
{
86
        if (values.contains(key))
87
                return values[key];
88
 
89
        values[key] = def;
90
        return values[key];
91
}
92
 
93
int SimpleState::getInt(const QString& key, int def)
94
{
95
        bool ok = false;
96
        QString retString = get(key, QString("%1").arg(def));
97
        int ret = retString.toInt(&ok);
98
        if (!ok)
99
                ret = def;
100
        return ret;
101
}
102
 
1238 tsoots 103
uint SimpleState::getUInt(const QString& key, uint def)
104
{
105
        bool ok = false;
106
        QString retString = get(key, QString("%1").arg(def));
107
        uint ret = retString.toUInt(&ok);
108
        if (!ok)
109
                ret = def;
110
        return ret;
111
}
112
 
1111 tsoots 113
double SimpleState::getDouble(const QString& key, double def)
114
{
115
        bool ok = false;
116
        QString retString = get(key, QString("%1").arg(def));
117
        double ret = retString.toDouble(&ok);
118
        if (!ok)
119
                ret = def;
120
        return ret;
121
}
122
 
1179 tsoots 123
bool SimpleState::getBool(const QString& key, bool def)
124
{
125
        bool ok = false;
126
        QString retString = get(key, QString("%1").arg(def));
127
        int ret = retString.toInt(&ok);
128
        if (!ok)
129
                ret = def;
130
        return ret;
131
}
132
 
1111 tsoots 133
void SimpleState::set(const QString& key, const QString& value)
134
{
135
        values[key] = value;
136
}
137
 
138
void SimpleState::set(const QString& key, int value)
139
{
140
        values[key] = QString("%1").arg(value);
141
}
142
 
1238 tsoots 143
void SimpleState::set(const QString& key, uint value)
144
{
145
        values[key] = QString("%1").arg(value);
146
}
147
 
1111 tsoots 148
void SimpleState::set(const QString& key, double value)
149
{
1152 tsoots 150
        values[key] = QString("%1").arg(value, 0, 'f', 20);
1111 tsoots 151
}
152
 
1179 tsoots 153
void SimpleState::set(const QString& key, bool value)
154
{
155
        values[key] = QString("%1").arg(value);
156
}
1111 tsoots 157
 
1179 tsoots 158
 
1518 tsoots 159
SimpleState::~SimpleState()
1111 tsoots 160
{
161
 
162
}