• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

palapeli/libpala

  • sources
  • kde-4.14
  • kdegames
  • palapeli
  • libpala
slicerproperty.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2009, 2010 Stefan Majewsky <majewsky@gmx.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***************************************************************************/
18 
19 #include "slicerproperty.h"
20 
21 #include <QMutableListIterator>
22 
23 //BEGIN private classes
24 
25 struct Pala::SlicerProperty::Private
26 {
27  Private() : m_advanced(false), m_enabled(true) {}
28 
29  QVariant::Type m_type;
30  QString m_caption;
31  QByteArray m_key;
32 
33  QVariantList m_choices;
34  QVariant m_defaultValue;
35 
36  bool m_advanced, m_enabled;
37 };
38 
39 struct Pala::BooleanProperty::Private {};
40 
41 struct Pala::IntegerProperty::Private
42 {
43  QPair<int, int> m_range;
44  Pala::IntegerProperty::Representation m_representation;
45 };
46 
47 struct Pala::StringProperty::Private {};
48 
49 //END private classes
50 
51 //BEGIN Pala::SlicerProperty
52 
53 Pala::SlicerProperty::SlicerProperty(QVariant::Type type, const QString& caption)
54  : p(new Pala::SlicerProperty::Private)
55 {
56  p->m_type = type;
57  p->m_caption = caption;
58 }
59 
60 Pala::SlicerProperty::~SlicerProperty()
61 {
62  delete p;
63 }
64 
65 QString Pala::SlicerProperty::caption() const
66 {
67  return p->m_caption;
68 }
69 
70 QVariantList Pala::SlicerProperty::choices() const
71 {
72  return p->m_choices;
73 }
74 
75 QVariant Pala::SlicerProperty::defaultValue() const
76 {
77  return p->m_defaultValue;
78 }
79 
80 bool Pala::SlicerProperty::isAdvanced() const
81 {
82  return p->m_advanced;
83 }
84 
85 bool Pala::SlicerProperty::isEnabled() const
86 {
87  return p->m_enabled;
88 }
89 
90 QByteArray Pala::SlicerProperty::key() const
91 {
92  return p->m_key;
93 }
94 
95 QVariant::Type Pala::SlicerProperty::type() const
96 {
97  return p->m_type;
98 }
99 
100 void Pala::SlicerProperty::setAdvanced(bool advanced)
101 {
102  p->m_advanced = advanced;
103 }
104 
105 void Pala::SlicerProperty::setChoices(const QVariantList& choices)
106 {
107  p->m_choices = choices;
108  QMutableListIterator<QVariant> iter(p->m_choices);
109  while (iter.hasNext())
110  iter.next().convert(p->m_type);
111 }
112 
113 void Pala::SlicerProperty::setDefaultValue(const QVariant& value)
114 {
115  p->m_defaultValue = value;
116  p->m_defaultValue.convert(p->m_type);
117 }
118 
119 void Pala::SlicerProperty::setEnabled(bool enabled)
120 {
121  p->m_enabled = enabled;
122 }
123 
124 void Pala::SlicerProperty::setKey(const QByteArray& key)
125 {
126  p->m_key = key;
127 }
128 
129 //END Pala::SlicerProperty
130 
131 //BEGIN concrete implementations
132 
133 Pala::BooleanProperty::BooleanProperty(const QString& caption)
134  : Pala::SlicerProperty(QVariant::Bool, caption)
135  , p(0)
136 {
137 }
138 
139 Pala::BooleanProperty::~BooleanProperty()
140 {
141  delete p;
142 }
143 
144 Pala::IntegerProperty::IntegerProperty(const QString& caption)
145  : Pala::SlicerProperty(QVariant::Int, caption)
146  , p(new Pala::IntegerProperty::Private)
147 {
148  p->m_range.first = p->m_range.second = 0;
149  p->m_representation = Pala::IntegerProperty::DefaultRepresentation;
150 }
151 
152 Pala::IntegerProperty::~IntegerProperty()
153 {
154  delete p;
155 }
156 
157 QPair<int, int> Pala::IntegerProperty::range() const
158 {
159  return p->m_range;
160 }
161 
162 Pala::IntegerProperty::Representation Pala::IntegerProperty::representation() const
163 {
164  return p->m_representation;
165 }
166 
167 void Pala::IntegerProperty::setRange(int min, int max)
168 {
169  p->m_range.first = min;
170  p->m_range.second = max;
171 }
172 
173 void Pala::IntegerProperty::setRepresentation(Pala::IntegerProperty::Representation representation)
174 {
175  p->m_representation = representation;
176 }
177 
178 Pala::StringProperty::StringProperty(const QString& caption)
179  : Pala::SlicerProperty(QVariant::String, caption)
180  , p(0)
181 {
182 }
183 
184 Pala::StringProperty::~StringProperty()
185 {
186  delete p;
187 }
188 
189 //END concrete implementations
Pala::SlicerProperty::setDefaultValue
void setDefaultValue(const QVariant &value)
Sets the default value of this property.
Definition: slicerproperty.cpp:113
Pala::SlicerProperty::isEnabled
bool isEnabled() const
Definition: slicerproperty.cpp:85
Pala::BooleanProperty::~BooleanProperty
virtual ~BooleanProperty()
Definition: slicerproperty.cpp:139
QByteArray
Pala::SlicerProperty::key
QByteArray key() const
Definition: slicerproperty.cpp:90
Pala::IntegerProperty::setRange
void setRange(int min, int max)
Limits the user input to the selection of a number inside the given range (including the bounds)...
Definition: slicerproperty.cpp:167
Pala::SlicerProperty::defaultValue
QVariant defaultValue() const
Definition: slicerproperty.cpp:75
Pala::SlicerProperty::isAdvanced
bool isAdvanced() const
Definition: slicerproperty.cpp:80
Pala::SlicerProperty::~SlicerProperty
virtual ~SlicerProperty()
Deletes this slicer property.
Definition: slicerproperty.cpp:60
Pala::SlicerProperty::SlicerProperty
SlicerProperty(QVariant::Type type, const QString &caption)
Definition: slicerproperty.cpp:53
Pala::SlicerProperty::caption
QString caption() const
Definition: slicerproperty.cpp:65
Pala::SlicerProperty::choices
QVariantList choices() const
Definition: slicerproperty.cpp:70
Pala::StringProperty::~StringProperty
virtual ~StringProperty()
Definition: slicerproperty.cpp:184
Pala::IntegerProperty::range
QPair< int, int > range() const
Definition: slicerproperty.cpp:157
Pala::SlicerProperty::setChoices
void setChoices(const QVariantList &choices)
Limits the user input to the selection of one of the given values.
Definition: slicerproperty.cpp:105
Pala::IntegerProperty
Definition: slicerproperty.h:106
QString
QPair< int, int >
QMutableListIterator::hasNext
bool hasNext() const
slicerproperty.h
Pala::IntegerProperty::DefaultRepresentation
Definition: slicerproperty.h:110
Pala::IntegerProperty::setRepresentation
void setRepresentation(Representation representation)
Decides how the property is represented in the user interface of Palapeli.
Definition: slicerproperty.cpp:173
Pala::SlicerProperty::type
QVariant::Type type() const
Definition: slicerproperty.cpp:95
QMutableListIterator::next
T & next()
QMutableListIterator
Pala::SlicerProperty::setKey
void setKey(const QByteArray &key)
Definition: slicerproperty.cpp:124
Pala::SlicerProperty::setAdvanced
void setAdvanced(bool advanced=true)
Sets whether this property is advanced (false by default).
Definition: slicerproperty.cpp:100
Pala::IntegerProperty::~IntegerProperty
virtual ~IntegerProperty()
Definition: slicerproperty.cpp:152
Pala::IntegerProperty::Representation
Representation
Decides how the property is represented in the user interface of Palapeli.
Definition: slicerproperty.h:110
Pala::StringProperty::StringProperty
StringProperty(const QString &caption)
Definition: slicerproperty.cpp:178
Pala::BooleanProperty::BooleanProperty
BooleanProperty(const QString &caption)
Definition: slicerproperty.cpp:133
Pala::IntegerProperty::IntegerProperty
IntegerProperty(const QString &caption)
Definition: slicerproperty.cpp:144
Pala::IntegerProperty::representation
Representation representation() const
Definition: slicerproperty.cpp:162
QVariant::convert
bool convert(Type t)
Pala::SlicerProperty
Representation of a single configurable parameter of a slicing algorithm.
Definition: slicerproperty.h:44
Pala::SlicerProperty::setEnabled
void setEnabled(bool enabled)
Sets whether this property is enabled (true by default).
Definition: slicerproperty.cpp:119
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

palapeli/libpala

Skip menu "palapeli/libpala"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal