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

« back to all changes in this revision

Viewing changes to src/modules/objects/KvsObject_slider.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 : KvsObject_slider.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 "KvsObject_slider.h"
 
27
#include "KviError.h"
 
28
#include "kvi_debug.h"
 
29
#include "KviLocale.h"
 
30
#include "KviIconManager.h"
 
31
 
 
32
#include <QSlider>
 
33
 
 
34
 
 
35
/*
 
36
@doc:   slider
 
37
        @keyterms:
 
38
                slider object class
 
39
        @title:
 
40
                slider class
 
41
        @type:
 
42
                class
 
43
        @short:
 
44
                The slider widget provides a vertical or horizontal slider.
 
45
        @inherits:
 
46
                [class]object[/class]
 
47
                [class]widget[/class]
 
48
        @description:
 
49
                The slider is the classic widget for controlling a bounded value.[br]
 
50
                It lets the user move a slider along a horizontal or vertical groove [br]
 
51
                and translates the slider's position into an integer value within the legal range.[/classfnc]()
 
52
        @functions:
 
53
                !fn: $setOrientation(<orientation:string>)
 
54
                Sets the slider's orientation.[br]
 
55
                Orientation value can be "Horizontal" or "Vertical".
 
56
                !fn: $setTracking(<bTracking:boolean>)
 
57
                Sets whether slider tracking is enabled to enable.[br]
 
58
                Value can be 1 or 0.
 
59
                !fn: $setMaxValue(<value:integer>)
 
60
                Sets maximum value for slider's range.
 
61
                !fn: $setMinValue(<minv_value:integer>)
 
62
                Sets minimum value for slider's range.
 
63
                !fn: $setLineStep(<line_step:integer>)
 
64
                Sets the  line step to <line_step>.
 
65
                !fn: $setPageStep(<page_step:integer>)
 
66
                Sets the  page step to <page_step>.
 
67
                !fn: $setTickmarks(<tick_marks:string>)
 
68
                Sets the tickmark settings for this slider.[br]
 
69
                Values are:[br]
 
70
                NoMarks - do not draw any tickmarks.[br]
 
71
                Both - draw tickmarks on both sides of the groove.[br]
 
72
                Above - draw tickmarks above the (horizontal) slider[br]
 
73
                Below - draw tickmarks below the (horizontal) slider[br]
 
74
                Left - draw tickmarks to the left of the (vertical) slider[br]
 
75
                Right - draw tickmarks to the right of the (vertical) slider
 
76
                !fn: $setTickInterval(<value>)
 
77
                Sets the interval between tickmarks.
 
78
                !fn: <integer> $value()
 
79
                Returns slider value.
 
80
                !fn: <integer> $minValue()
 
81
                Returns slider minValue.
 
82
                !fn: <integer> $maxValue()
 
83
                Returns slider maxValue.
 
84
                !fn: <integer> $lineStep()
 
85
                Returns slider lineStep value.
 
86
                !fn: <integer>$pageStep()
 
87
                Returns slider pageStep value.
 
88
                !fn: $valueChangedEvent(<new slider value:integer>)
 
89
                This function is called by the framework when the slider value is changed and return the new slider value as its argument.[br]
 
90
                The default implementation emits the [classfnc]$valueChanged[/classfnc]() signal,
 
91
                so it is easy to handle the values from many sliders without reimplementing
 
92
                the [classfnc]$valueChangedEvent[/classfnc]() for every one.[br]
 
93
                Note: If you reimplement this function to catch the slider value, you will have to emit the signal by yourself (if you still need it, obviously).
 
94
                @signals:
 
95
                !sg: $valueChanged()
 
96
                This signal is emitted by the default implementation of [classfnc]valueChangedEvent[/classfnc]().[br]
 
97
                If you reimplement that function you will have to emit the signal manually (if you still need it).
 
98
 
 
99
*/
 
100
 
 
101
 
 
102
 
 
103
KVSO_BEGIN_REGISTERCLASS(KvsObject_slider,"slider","widget")
 
104
 
 
105
 
 
106
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setTracking);
 
107
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setValue);
 
108
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setMinValue);
 
109
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setMaxValue);
 
110
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setLineStep);
 
111
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setPageStep);
 
112
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setTickInterval);
 
113
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,value);
 
114
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,minValue);
 
115
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,maxValue);
 
116
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,lineStep);
 
117
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,pageStep);
 
118
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setTickmarks);
 
119
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,setOrientation);
 
120
 
 
121
 
 
122
        KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_slider,valueChangedEvent);
 
123
KVSO_END_REGISTERCLASS(KvsObject_slider)
 
124
 
 
125
KVSO_BEGIN_CONSTRUCTOR(KvsObject_slider,KvsObject_widget)
 
126
 
 
127
KVSO_END_CONSTRUCTOR(KvsObject_slider)
 
128
 
 
129
 
 
130
KVSO_BEGIN_DESTRUCTOR(KvsObject_slider)
 
131
 
 
132
KVSO_END_CONSTRUCTOR(KvsObject_slider)
 
133
 
 
134
bool KvsObject_slider::init(KviKvsRunTimeContext *,KviKvsVariantList *)
 
135
{
 
136
        SET_OBJECT(QSlider)
 
137
        connect(widget(),SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
 
138
        return true;
 
139
}
 
140
 
 
141
KVSO_CLASS_FUNCTION(slider,setTracking)
 
142
{
 
143
        CHECK_INTERNAL_POINTER(widget())
 
144
        bool bEnabled;
 
145
        KVSO_PARAMETERS_BEGIN(c)
 
146
                KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
 
147
        KVSO_PARAMETERS_END(c)
 
148
        ((QSlider *)widget())->setTracking(bEnabled);
 
149
        return true;
 
150
}
 
151
 
 
152
 
 
153
KVSO_CLASS_FUNCTION(slider,setValue)
 
154
{
 
155
        CHECK_INTERNAL_POINTER(widget())
 
156
        kvs_int_t iValue;
 
157
        KVSO_PARAMETERS_BEGIN(c)
 
158
                KVSO_PARAMETER("value",KVS_PT_INT,0,iValue)
 
159
        KVSO_PARAMETERS_END(c)
 
160
    ((QSlider *)widget())->setValue(iValue);
 
161
        return true;
 
162
}
 
163
KVSO_CLASS_FUNCTION(slider,setMinValue)
 
164
{
 
165
        CHECK_INTERNAL_POINTER(widget())
 
166
        kvs_int_t iMinvalue;
 
167
        KVSO_PARAMETERS_BEGIN(c)
 
168
                KVSO_PARAMETER("minimum_value",KVS_PT_INT,0,iMinvalue)
 
169
        KVSO_PARAMETERS_END(c)
 
170
        ((QSlider *)widget())->setMinimum(iMinvalue);
 
171
        return true;
 
172
}
 
173
KVSO_CLASS_FUNCTION(slider,setMaxValue)
 
174
{
 
175
        CHECK_INTERNAL_POINTER(widget())
 
176
        kvs_int_t iMaxvalue;
 
177
        KVSO_PARAMETERS_BEGIN(c)
 
178
                KVSO_PARAMETER("max_value",KVS_PT_INT,0,iMaxvalue)
 
179
        KVSO_PARAMETERS_END(c)
 
180
    ((QSlider *)widget())->setMaximum(iMaxvalue);
 
181
        return true;
 
182
}
 
183
 
 
184
KVSO_CLASS_FUNCTION(slider,setLineStep)
 
185
{
 
186
        CHECK_INTERNAL_POINTER(widget())
 
187
        kvs_int_t iLinestep;
 
188
        KVSO_PARAMETERS_BEGIN(c)
 
189
                KVSO_PARAMETER("line_step",KVS_PT_INT,0,iLinestep)
 
190
        KVSO_PARAMETERS_END(c)
 
191
        ((QSlider *)widget())->setSingleStep(iLinestep);
 
192
        return true;
 
193
}
 
194
KVSO_CLASS_FUNCTION(slider,setPageStep)
 
195
{
 
196
        CHECK_INTERNAL_POINTER(widget())
 
197
        kvs_int_t iPagestep;
 
198
        KVSO_PARAMETERS_BEGIN(c)
 
199
                KVSO_PARAMETER("page_step",KVS_PT_INT,0,iPagestep)
 
200
        KVSO_PARAMETERS_END(c)
 
201
    if (widget()) ((QSlider *)widget())->setPageStep(iPagestep);
 
202
        return true;
 
203
}
 
204
 
 
205
KVSO_CLASS_FUNCTION(slider,setTickInterval)
 
206
{
 
207
        kvs_int_t iInterval;
 
208
        KVSO_PARAMETERS_BEGIN(c)
 
209
                KVSO_PARAMETER("tick_interval",KVS_PT_INT,0,iInterval)
 
210
        KVSO_PARAMETERS_END(c)
 
211
    ((QSlider *)widget())->setTickInterval(iInterval);
 
212
        return true;
 
213
}
 
214
 
 
215
KVSO_CLASS_FUNCTION(slider,value)
 
216
{
 
217
        CHECK_INTERNAL_POINTER(widget())
 
218
        c->returnValue()->setInteger(((QSlider *)widget())->value());
 
219
        return true;
 
220
}
 
221
 
 
222
KVSO_CLASS_FUNCTION(slider,minValue)
 
223
{
 
224
        CHECK_INTERNAL_POINTER(widget())
 
225
        c->returnValue()->setInteger(((QSlider *)widget())->minimum());
 
226
        return true;
 
227
}
 
228
KVSO_CLASS_FUNCTION(slider,maxValue)
 
229
{
 
230
        CHECK_INTERNAL_POINTER(widget())
 
231
        c->returnValue()->setInteger(((QSlider *)widget())->maximum());
 
232
        return true;
 
233
}
 
234
KVSO_CLASS_FUNCTION(slider,lineStep)
 
235
{
 
236
        CHECK_INTERNAL_POINTER(widget())
 
237
        c->returnValue()->setInteger(((QSlider *)widget())->singleStep());
 
238
        return true;
 
239
}
 
240
 
 
241
KVSO_CLASS_FUNCTION(slider,pageStep)
 
242
{
 
243
        CHECK_INTERNAL_POINTER(widget())
 
244
        c->returnValue()->setInteger(((QSlider *)widget())->pageStep());
 
245
        return true;
 
246
}
 
247
 
 
248
 
 
249
KVSO_CLASS_FUNCTION(slider,setTickmarks)
 
250
{
 
251
        CHECK_INTERNAL_POINTER(widget())
 
252
        QString szTick;
 
253
        KVSO_PARAMETERS_BEGIN(c)
 
254
                KVSO_PARAMETER("tick_marks",KVS_PT_STRING,0,szTick)
 
255
        KVSO_PARAMETERS_END(c)
 
256
        if(KviQString::equalCI(szTick,"NoMarks"))
 
257
                ((QSlider *)widget())->setTickPosition(QSlider::NoTicks);
 
258
        else if(KviQString::equalCI(szTick,"Both"))
 
259
                ((QSlider *)widget())->setTickPosition(QSlider::TicksBothSides);
 
260
        else if(KviQString::equalCI(szTick,"Above"))
 
261
                ((QSlider *)widget())->setTickPosition(QSlider::TicksAbove);
 
262
        else if(KviQString::equalCI(szTick,"Below"))
 
263
                ((QSlider *)widget())->setTickPosition(QSlider::TicksBelow);
 
264
        else if(KviQString::equalCI(szTick,"Left"))
 
265
                ((QSlider *)widget())->setTickPosition(QSlider::TicksLeft);
 
266
        else if(KviQString::equalCI(szTick,"Right"))
 
267
                        ((QSlider *)widget())->setTickPosition(QSlider::TicksRight);
 
268
        else c->warning( __tr2qs_ctx("Unknown tickmark '%Q'","objects"),&szTick);
 
269
        return true;
 
270
}
 
271
KVSO_CLASS_FUNCTION(slider,setOrientation)
 
272
{
 
273
        CHECK_INTERNAL_POINTER(widget())
 
274
        QString szOrientation;
 
275
        KVSO_PARAMETERS_BEGIN(c)
 
276
                KVSO_PARAMETER("orientation",KVS_PT_STRING,0,szOrientation)
 
277
        KVSO_PARAMETERS_END(c)
 
278
        if(KviQString::equalCI(szOrientation,"Horizontal"))
 
279
                ((QSlider *)widget())->setOrientation(Qt::Horizontal);
 
280
        else if(KviQString::equalCI(szOrientation,"Vertical"))
 
281
                ((QSlider *)widget())->setOrientation(Qt::Vertical);
 
282
        else c->warning( __tr2qs_ctx("Unknown orientation '%Q'","objects"),&szOrientation);
 
283
        return true;
 
284
}
 
285
KVSO_CLASS_FUNCTION(slider,valueChangedEvent)
 
286
{
 
287
        emitSignal("valueChanged",c,c->params());
 
288
        return true;
 
289
}
 
290
 
 
291
void KvsObject_slider::valueChanged(int value)
 
292
{
 
293
        KviKvsVariantList params(new KviKvsVariant((kvs_int_t)value));
 
294
        callFunction(this,"valueChangedEvent",&params);
 
295
}
 
296
 
 
297
 
 
298
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
 
299
#include "m_KvsObject_slider.moc"
 
300
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
 
301