~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/modules/objects/class_spinbox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//=============================================================================
2
 
//
3
 
//   File : class_spinbox.cpp
4
 
//   Creation date : Fri Mar 18 14:30:48 CEST 2005
5
 
//   by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
6
 
//
7
 
//   This file is part of the KVirc irc client distribution
8
 
//   Copyright (C) 2005-2008 Alessandro Carbone (elfonol at gmail dot com)
9
 
//
10
 
//   This program is FREE software. You can redistribute it and/or
11
 
//   modify it under the terms of the GNU General Public License
12
 
//   as published by the Free Software Foundation; either version 2
13
 
//   of the License, or (at your opinion) any later version.
14
 
//
15
 
//   This program is distributed in the HOPE that it will be USEFUL,
16
 
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
 
//   See the GNU General Public License for more details.
19
 
//
20
 
//   You should have received a copy of the GNU General Public License
21
 
//   along with this program. If not, write to the Free Software Foundation,
22
 
//   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
 
//
24
 
//=============================================================================
25
 
 
26
 
#include "class_spinbox.h"
27
 
#include "kvi_error.h"
28
 
#include "kvi_debug.h"
29
 
#include "kvi_locale.h"
30
 
#include "kvi_iconmanager.h"
31
 
 
32
 
#include <QSpinBox>
33
 
/*
34
 
        @doc:   spinbox
35
 
        @keyterms:
36
 
                spinbox object class,
37
 
        @title:
38
 
                spinbox class
39
 
        @type:
40
 
                class
41
 
        @short:
42
 
                Provides a simple spin button.
43
 
        @inherits:
44
 
                [class]object[/class]
45
 
                [class]widget[/class]
46
 
        @description:
47
 
                This widget allows the user to choose a value either by clicking the up/down buttons
48
 
                to increase/decrease the value currently displayed or by typing the value directly into the spin box.
49
 
        @functions:
50
 
                !fn: $setValue(<value:integer>)
51
 
                Sets the value of the spin box.[br]
52
 
                See also [classfnc]$value[/classfnc]()
53
 
                !fn: $setMinValue(<min_value:integer>)
54
 
                Sets the minimum value of the spin box.
55
 
                See also [classfnc]$MinValue[/classfnc]()
56
 
                !fn: $setMaxValue(<max_value:integer>)
57
 
                Sets the maximum value of the spin box.[br]
58
 
                See also [classfnc]$maxValue[/classfnc]()
59
 
                !fn: $setLineStep(<line_step:integer>)
60
 
                Sets the  line step: when the user uses the arrows to change the spin box's value the value will be
61
 
                incremented/decremented by the amount of the line step.
62
 
                See also [classfnc]$lineStep[/classfnc]()
63
 
                !fn: $setSpecialValueText(<text:string>)
64
 
                Sets the special-value text.
65
 
                If set, the spin box will display this text instead of a numeric value whenever the current value is equal to [classfnc]$minValue[/classfnc]().
66
 
                See also [classfnc]$setSpecialValueText[/classfnc]()
67
 
                !fn: $setPrefix(<text:string>)
68
 
                This property holds the spin box's prefix.[br]
69
 
                The prefix is prepended to the start of the displayed value.[br]
70
 
                Typical use is to display a unit of measurement or a currency symbol.
71
 
                See also [classfnc]$setSuffix[/classfnc]()
72
 
                !fn: $setSuffix(<text:string>);
73
 
                This property holds the suffix of the spin box.[br]
74
 
                The suffix is appended to the end of the displayed value.[br]
75
 
                See also [classfnc]$setPrefix[/classfnc]()
76
 
                !fn: <integer> $value()
77
 
                Returns the value of the spin box.
78
 
                See also [classfnc]$setValue[/classfnc]()
79
 
                !fn: <integer> $minValue
80
 
                Returns the minimum value of the spin box.
81
 
                See also [classfnc]$setMinValue[/classfnc]()
82
 
                !fn: <integer> $maxValue
83
 
                Returns the maximum value of the spin box.
84
 
                See also [classfnc]$setMaxValue[/classfnc]()
85
 
                !fn: <integer> $lineStep()
86
 
                Return the linestep.
87
 
                !fn: <string> $specialValueText()
88
 
                Returns the special-value text.
89
 
                See also [classfnc]$setSpecialValueText[/classfnc]()
90
 
                !fn: $valueChangedEvent(<new value:integer>)
91
 
                This function is called by the framework when the spinbox value is changed and return the new slider value as its argument.[br]
92
 
                The default implementation emits the [classfnc]$valueChanged[/classfnc]() signal,
93
 
                so it is easy to handle the values from many spinboxes without reimplementing
94
 
                the [classfnc]$valueChangedEvent[/classfnc]() for every one.[br]
95
 
                Note: If you reimplement this function to catch the spinbox value, you will have to emit the signal by yourself (if you still need it, obviously).
96
 
                @signals:
97
 
                !sg: $valueChanged()
98
 
                This signal is emitted by the default implementation of [classfnc]valueChangedEvent[/classfnc]().[br]
99
 
                If you reimplement that function you will have to emit the signal manually (if you still need it).
100
 
*/
101
 
 
102
 
 
103
 
KVSO_BEGIN_REGISTERCLASS(KviKvsObject_spinbox,"spinbox","widget")
104
 
 
105
 
 
106
 
 
107
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setValue);
108
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setMinValue);
109
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setMaxValue);
110
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setLineStep);
111
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setSpecialValueText);
112
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,value);
113
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,minValue);
114
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,maxValue);
115
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,lineStep);
116
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,specialValueText);
117
 
 
118
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setPrefix);
119
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,setSuffix);
120
 
 
121
 
 
122
 
        KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_spinbox,valueChangedEvent);
123
 
KVSO_END_REGISTERCLASS(KviKvsObject_spinbox)
124
 
 
125
 
KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_spinbox,KviKvsObject_widget)
126
 
 
127
 
KVSO_END_CONSTRUCTOR(KviKvsObject_spinbox)
128
 
 
129
 
 
130
 
KVSO_BEGIN_DESTRUCTOR(KviKvsObject_spinbox)
131
 
 
132
 
KVSO_END_CONSTRUCTOR(KviKvsObject_spinbox)
133
 
 
134
 
bool KviKvsObject_spinbox::init(KviKvsRunTimeContext *,KviKvsVariantList *)
135
 
{
136
 
        SET_OBJECT(QSpinBox)
137
 
        connect(widget(),SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
138
 
        return true;
139
 
}
140
 
 
141
 
 
142
 
 
143
 
KVSO_CLASS_FUNCTION(spinbox,setValue)
144
 
{
145
 
        CHECK_INTERNAL_POINTER(widget())
146
 
        kvs_int_t iValue;
147
 
        KVSO_PARAMETERS_BEGIN(c)
148
 
                KVSO_PARAMETER("value",KVS_PT_INT,0,iValue)
149
 
        KVSO_PARAMETERS_END(c)
150
 
        ((QSpinBox *)widget())->setValue(iValue);
151
 
        return true;
152
 
}
153
 
KVSO_CLASS_FUNCTION(spinbox,setMinValue)
154
 
{
155
 
        CHECK_INTERNAL_POINTER(widget())
156
 
        kvs_int_t iMinvalue;
157
 
        KVSO_PARAMETERS_BEGIN(c)
158
 
                KVSO_PARAMETER("min_value",KVS_PT_INT,0,iMinvalue)
159
 
        KVSO_PARAMETERS_END(c)
160
 
    ((QSpinBox *)widget())->setMinimum(iMinvalue);
161
 
        return true;
162
 
}
163
 
KVSO_CLASS_FUNCTION(spinbox,setMaxValue)
164
 
{
165
 
        CHECK_INTERNAL_POINTER(widget())
166
 
        kvs_int_t iMaxvalue;
167
 
        KVSO_PARAMETERS_BEGIN(c)
168
 
                KVSO_PARAMETER("max_value",KVS_PT_INT,0,iMaxvalue)
169
 
        KVSO_PARAMETERS_END(c)
170
 
    ((QSpinBox *)widget())->setMaximum(iMaxvalue);
171
 
        return true;
172
 
}
173
 
 
174
 
KVSO_CLASS_FUNCTION(spinbox,setLineStep)
175
 
{
176
 
        CHECK_INTERNAL_POINTER(widget())
177
 
        kvs_int_t iLinestep;
178
 
        KVSO_PARAMETERS_BEGIN(c)
179
 
                KVSO_PARAMETER("line_step",KVS_PT_INT,0,iLinestep)
180
 
        KVSO_PARAMETERS_END(c)
181
 
    ((QSpinBox *)widget())->setSingleStep(iLinestep);
182
 
        return true;
183
 
}
184
 
 
185
 
 
186
 
KVSO_CLASS_FUNCTION(spinbox,value)
187
 
{
188
 
        CHECK_INTERNAL_POINTER(widget())
189
 
        c->returnValue()->setInteger(((QSpinBox *)widget())->value());
190
 
        return true;
191
 
}
192
 
 
193
 
KVSO_CLASS_FUNCTION(spinbox,minValue)
194
 
{
195
 
        CHECK_INTERNAL_POINTER(widget())
196
 
        c->returnValue()->setInteger(((QSpinBox *)widget())->minimum());
197
 
        return true;
198
 
}
199
 
KVSO_CLASS_FUNCTION(spinbox,maxValue)
200
 
{
201
 
        CHECK_INTERNAL_POINTER(widget())
202
 
        c->returnValue()->setInteger(((QSpinBox *)widget())->maximum());
203
 
        return true;
204
 
}
205
 
KVSO_CLASS_FUNCTION(spinbox,lineStep)
206
 
{
207
 
        CHECK_INTERNAL_POINTER(widget())
208
 
        c->returnValue()->setInteger(((QSpinBox *)widget())->singleStep());
209
 
        return true;
210
 
}
211
 
 
212
 
 
213
 
KVSO_CLASS_FUNCTION(spinbox,specialValueText)
214
 
{
215
 
        CHECK_INTERNAL_POINTER(widget())
216
 
        c->returnValue()->setString(((QSpinBox *)widget())->specialValueText());
217
 
        return true;
218
 
}
219
 
 
220
 
 
221
 
KVSO_CLASS_FUNCTION(spinbox,setSpecialValueText)
222
 
{
223
 
        CHECK_INTERNAL_POINTER(widget())
224
 
        QString szText;
225
 
        KVSO_PARAMETERS_BEGIN(c)
226
 
                KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
227
 
        KVSO_PARAMETERS_END(c)
228
 
        ((QSpinBox *)widget())->setSpecialValueText(szText);
229
 
        return true;
230
 
}
231
 
KVSO_CLASS_FUNCTION(spinbox,setPrefix)
232
 
{
233
 
        CHECK_INTERNAL_POINTER(widget())
234
 
        QString szPrefix;
235
 
        KVSO_PARAMETERS_BEGIN(c)
236
 
                KVSO_PARAMETER("text",KVS_PT_STRING,0,szPrefix)
237
 
        KVSO_PARAMETERS_END(c)
238
 
        ((QSpinBox *)widget())->setPrefix(szPrefix);
239
 
        return true;
240
 
}
241
 
KVSO_CLASS_FUNCTION(spinbox,setSuffix)
242
 
{
243
 
        CHECK_INTERNAL_POINTER(widget())
244
 
        QString szSuffix;
245
 
        KVSO_PARAMETERS_BEGIN(c)
246
 
                KVSO_PARAMETER("text",KVS_PT_STRING,0,szSuffix)
247
 
        KVSO_PARAMETERS_END(c)
248
 
        ((QSpinBox *)widget())->setSuffix(szSuffix);
249
 
        return true;
250
 
}
251
 
 
252
 
KVSO_CLASS_FUNCTION(spinbox,valueChangedEvent)
253
 
{
254
 
        emitSignal("valueChanged",c,c->params());
255
 
        return true;
256
 
}
257
 
 
258
 
void KviKvsObject_spinbox::valueChanged(int value)
259
 
{
260
 
        KviKvsVariantList params(new KviKvsVariant((kvs_int_t)value));
261
 
        callFunction(this,"valueChangedEvent",&params);
262
 
}
263
 
 
264
 
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
265
 
#include "m_class_spinbox.moc"
266
 
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
267