summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/qprocess.cpp6
-rw-r--r--libopie2/opiecore/device/odevice.cpp6
-rw-r--r--libopie2/opiecore/oconfig.h2
-rw-r--r--libopie2/opiecore/odebug.h6
-rw-r--r--libopie2/opiecore/okeyconfigmanager.cpp2
-rw-r--r--libopie2/opiecore/okeyfilter.h8
-rw-r--r--libopie2/opiecore/opluginloader.cpp5
-rw-r--r--libopie2/opiecore/oprocess.h8
-rw-r--r--libopie2/opieui/oimageeffect.h6
-rw-r--r--libopie2/opieui/opixmapeffect.h11
-rw-r--r--libopie2/qt3/opieui/ocombobox.h4
-rw-r--r--libopie2/qt3/opieui/olineedit.h6
12 files changed, 33 insertions, 37 deletions
diff --git a/core/launcher/qprocess.cpp b/core/launcher/qprocess.cpp
index 3fe1238..aef7967 100644
--- a/core/launcher/qprocess.cpp
+++ b/core/launcher/qprocess.cpp
@@ -1,630 +1,630 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24#include "qprocess.h" 24#include "qprocess.h"
25 25
26#ifndef QT_NO_PROCESS 26#ifndef QT_NO_PROCESS
27 27
28#include "qapplication.h" 28#include "qapplication.h"
29 29
30 30
31//#define QT_QPROCESS_DEBUG 31//#define QT_QPROCESS_DEBUG
32 32
33 33
34/*! 34/*!
35 \class QProcess qprocess.h 35 \class QProcess qprocess.h
36 36
37 \brief The QProcess class is used to start external programs and to 37 \brief The QProcess class is used to start external programs and to
38 communicate with them. 38 communicate with them.
39 39
40 This is a temporary class. This will be replaced by Qt 3's QProcess class. 40 This is a temporary class. This will be replaced by Qt 3's QProcess class.
41 41
42 \ingroup qtopiaemb 42 \ingroup qtopiaemb
43*/ 43*/
44 44
45/*! 45/*!
46 \enum QProcess::Communication 46 \enum QProcess::Communication
47 47
48 This enum type defines the communication channels connected to the 48 This enum type defines the communication channels connected to the
49 process. 49 process.
50 50
51 \value Stdin Data can be written to the process's standard input. 51 \value Stdin Data can be written to the process's standard input.
52 52
53 \value Stdout Data can be read from the process's standard output. 53 \value Stdout Data can be read from the process's standard output.
54 54
55 \value Stderr Data can be read from the process's standard error. 55 \value Stderr Data can be read from the process's standard error.
56 56
57 \value DupStderr Duplicates standard error to standard output for new 57 \value DupStderr Duplicates standard error to standard output for new
58 processes; i.e. everything that the process writes to standard error, is 58 processes; i.e. everything that the process writes to standard error, is
59 reported by QProcess on standard output instead. This is especially useful if 59 reported by QProcess on standard output instead. This is especially useful if
60 your application requires that the output on standard output and standard 60 your application requires that the output on standard output and standard
61 error is read in the same order as the process output it. Please note that 61 error is read in the same order as the process output it. Please note that
62 this is a binary flag, so if you want to activate this together with standard 62 this is a binary flag, so if you want to activate this together with standard
63 input, output and error redirection (the default), you have to specify 63 input, output and error redirection (the default), you have to specify
64 \c{Stdin|Stdout|Stderr|DupStderr} for the setCommunication() call. 64 \c {Stdin|Stdout|Stderr|DupStderr} for the setCommunication() call.
65 65
66 \sa setCommunication() communication() 66 \sa setCommunication() communication()
67*/ 67*/
68 68
69/*! 69/*!
70 Constructs a QProcess object. The \a parent and \a name parameters are passed 70 Constructs a QProcess object. The \a parent and \a name parameters are passed
71 to the QObject constructor. 71 to the QObject constructor.
72 72
73 \sa setArguments() addArgument() start() 73 \sa setArguments() addArgument() start()
74*/ 74*/
75QProcess::QProcess( QObject *parent, const char *name ) 75QProcess::QProcess( QObject *parent, const char *name )
76 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), 76 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
77 wroteToStdinConnected( FALSE ), 77 wroteToStdinConnected( FALSE ),
78 readStdoutCalled( FALSE ), readStderrCalled( FALSE ), 78 readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
79 comms( Stdin|Stdout|Stderr ) 79 comms( Stdin|Stdout|Stderr )
80{ 80{
81 init(); 81 init();
82} 82}
83 83
84/*! 84/*!
85 Constructs a QProcess with \a arg0 as the command to be executed. The 85 Constructs a QProcess with \a arg0 as the command to be executed. The
86 \a parent and \a name parameters are passed to the QObject constructor. 86 \a parent and \a name parameters are passed to the QObject constructor.
87 87
88 The process is not started. You must call start() or launch() 88 The process is not started. You must call start() or launch()
89 to start the process. 89 to start the process.
90 90
91 \sa setArguments() addArgument() start() 91 \sa setArguments() addArgument() start()
92*/ 92*/
93QProcess::QProcess( const QString& arg0, QObject *parent, const char *name ) 93QProcess::QProcess( const QString& arg0, QObject *parent, const char *name )
94 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), 94 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
95 wroteToStdinConnected( FALSE ), 95 wroteToStdinConnected( FALSE ),
96 readStdoutCalled( FALSE ), readStderrCalled( FALSE ), 96 readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
97 comms( Stdin|Stdout|Stderr ) 97 comms( Stdin|Stdout|Stderr )
98{ 98{
99 init(); 99 init();
100 addArgument( arg0 ); 100 addArgument( arg0 );
101} 101}
102 102
103/*! 103/*!
104 Constructs a QProcess with \a args as the arguments of the process. The first 104 Constructs a QProcess with \a args as the arguments of the process. The first
105 element in the list is the command to be executed. The other elements in the 105 element in the list is the command to be executed. The other elements in the
106 list are the arguments to this command. The \a parent and \a name 106 list are the arguments to this command. The \a parent and \a name
107 parameters are passed to the QObject constructor. 107 parameters are passed to the QObject constructor.
108 108
109 The process is not started. You must call start() or launch() 109 The process is not started. You must call start() or launch()
110 to start the process. 110 to start the process.
111 111
112 \sa setArguments() addArgument() start() 112 \sa setArguments() addArgument() start()
113*/ 113*/
114QProcess::QProcess( const QStringList& args, QObject *parent, const char *name ) 114QProcess::QProcess( const QStringList& args, QObject *parent, const char *name )
115 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), 115 : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
116 wroteToStdinConnected( FALSE ), 116 wroteToStdinConnected( FALSE ),
117 readStdoutCalled( FALSE ), readStderrCalled( FALSE ), 117 readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
118 comms( Stdin|Stdout|Stderr ) 118 comms( Stdin|Stdout|Stderr )
119{ 119{
120 init(); 120 init();
121 setArguments( args ); 121 setArguments( args );
122} 122}
123 123
124 124
125/*! 125/*!
126 Returns the list of arguments that are set for the process. Arguments can be 126 Returns the list of arguments that are set for the process. Arguments can be
127 specified with the constructor or with the functions setArguments() and 127 specified with the constructor or with the functions setArguments() and
128 addArgument(). 128 addArgument().
129 129
130 \sa setArguments() addArgument() 130 \sa setArguments() addArgument()
131*/ 131*/
132QStringList QProcess::arguments() const 132QStringList QProcess::arguments() const
133{ 133{
134 return _arguments; 134 return _arguments;
135} 135}
136 136
137/*! 137/*!
138 Clears the list of arguments that are set for the process. 138 Clears the list of arguments that are set for the process.
139 139
140 \sa setArguments() addArgument() 140 \sa setArguments() addArgument()
141*/ 141*/
142void QProcess::clearArguments() 142void QProcess::clearArguments()
143{ 143{
144 _arguments.clear(); 144 _arguments.clear();
145} 145}
146 146
147/*! 147/*!
148 Sets \a args as the arguments for the process. The first element in the list 148 Sets \a args as the arguments for the process. The first element in the list
149 is the command to be executed. The other elements in the list are the 149 is the command to be executed. The other elements in the list are the
150 arguments to the command. Any previous arguments are deleted. 150 arguments to the command. Any previous arguments are deleted.
151 151
152 \sa arguments() addArgument() 152 \sa arguments() addArgument()
153*/ 153*/
154void QProcess::setArguments( const QStringList& args ) 154void QProcess::setArguments( const QStringList& args )
155{ 155{
156 _arguments = args; 156 _arguments = args;
157} 157}
158 158
159/*! 159/*!
160 Adds \a arg to the end of the list of arguments. 160 Adds \a arg to the end of the list of arguments.
161 161
162 The first element in the list of arguments is the command to be 162 The first element in the list of arguments is the command to be
163 executed; the following elements are the arguments to the command. 163 executed; the following elements are the arguments to the command.
164 164
165 \sa arguments() setArguments() 165 \sa arguments() setArguments()
166*/ 166*/
167void QProcess::addArgument( const QString& arg ) 167void QProcess::addArgument( const QString& arg )
168{ 168{
169 _arguments.append( arg ); 169 _arguments.append( arg );
170} 170}
171 171
172#ifndef QT_NO_DIR 172#ifndef QT_NO_DIR
173/*! 173/*!
174 Returns the working directory that was set with 174 Returns the working directory that was set with
175 setWorkingDirectory(), or the current directory if none has been 175 setWorkingDirectory(), or the current directory if none has been
176 set. 176 set.
177 177
178 \sa setWorkingDirectory() QDir::current() 178 \sa setWorkingDirectory() QDir::current()
179*/ 179*/
180QDir QProcess::workingDirectory() const 180QDir QProcess::workingDirectory() const
181{ 181{
182 return workingDir; 182 return workingDir;
183} 183}
184 184
185/*! 185/*!
186 Sets \a dir as the working directory for a process. This does not affect 186 Sets \a dir as the working directory for a process. This does not affect
187 running processes; only processes that are started afterwards are affected. 187 running processes; only processes that are started afterwards are affected.
188 188
189 Setting the working directory is especially useful for processes that try to 189 Setting the working directory is especially useful for processes that try to
190 access files with relative filenames. 190 access files with relative filenames.
191 191
192 \sa workingDirectory() start() 192 \sa workingDirectory() start()
193*/ 193*/
194void QProcess::setWorkingDirectory( const QDir& dir ) 194void QProcess::setWorkingDirectory( const QDir& dir )
195{ 195{
196 workingDir = dir; 196 workingDir = dir;
197} 197}
198#endif //QT_NO_DIR 198#endif //QT_NO_DIR
199 199
200/*! 200/*!
201 Returns the communication required with the process. 201 Returns the communication required with the process.
202 202
203 \sa setCommunication() 203 \sa setCommunication()
204*/ 204*/
205int QProcess::communication() const 205int QProcess::communication() const
206{ 206{
207 return comms; 207 return comms;
208} 208}
209 209
210/*! 210/*!
211 Sets \a commFlags as the communication required with the process. 211 Sets \a commFlags as the communication required with the process.
212 212
213 \a commFlags is a bitwise OR between the flags defined in \c Communication. 213 \a commFlags is a bitwise OR between the flags defined in \c Communication.
214 214
215 The default is \c{Stdin|Stdout|Stderr}. 215 The default is \c {Stdin|Stdout|Stderr}.
216 216
217 \sa communication() 217 \sa communication()
218*/ 218*/
219void QProcess::setCommunication( int commFlags ) 219void QProcess::setCommunication( int commFlags )
220{ 220{
221 comms = commFlags; 221 comms = commFlags;
222} 222}
223 223
224/*! 224/*!
225 Returns TRUE if the process has exited normally; otherwise returns 225 Returns TRUE if the process has exited normally; otherwise returns
226 FALSE. This implies that this function returns FALSE if the process 226 FALSE. This implies that this function returns FALSE if the process
227 is still running. 227 is still running.
228 228
229 \sa isRunning() exitStatus() processExited() 229 \sa isRunning() exitStatus() processExited()
230*/ 230*/
231bool QProcess::normalExit() const 231bool QProcess::normalExit() const
232{ 232{
233 // isRunning() has the side effect that it determines the exit status! 233 // isRunning() has the side effect that it determines the exit status!
234 if ( isRunning() ) 234 if ( isRunning() )
235 return FALSE; 235 return FALSE;
236 else 236 else
237 return exitNormal; 237 return exitNormal;
238} 238}
239 239
240/*! 240/*!
241 Returns the exit status of the process or 0 if the process is still 241 Returns the exit status of the process or 0 if the process is still
242 running. This function returns immediately and does not wait until 242 running. This function returns immediately and does not wait until
243 the process is finished. 243 the process is finished.
244 244
245 If normalExit() is FALSE (e.g. if the program was killed or 245 If normalExit() is FALSE (e.g. if the program was killed or
246 crashed), this function returns 0, so you should check the return 246 crashed), this function returns 0, so you should check the return
247 value of normalExit() before relying on this value. 247 value of normalExit() before relying on this value.
248 248
249 \sa normalExit() processExited() 249 \sa normalExit() processExited()
250*/ 250*/
251int QProcess::exitStatus() const 251int QProcess::exitStatus() const
252{ 252{
253 // isRunning() has the side effect that it determines the exit status! 253 // isRunning() has the side effect that it determines the exit status!
254 if ( isRunning() ) 254 if ( isRunning() )
255 return 0; 255 return 0;
256 else 256 else
257 return exitStat; 257 return exitStat;
258} 258}
259 259
260 260
261/*! 261/*!
262 Reads the data that the process has written to standard output. When 262 Reads the data that the process has written to standard output. When
263 new data is written to standard output, the class emits the signal 263 new data is written to standard output, the class emits the signal
264 readyReadStdout(). 264 readyReadStdout().
265 265
266 If there is no data to read, this function returns a QByteArray of 266 If there is no data to read, this function returns a QByteArray of
267 size 0: it does not wait until there is something to read. 267 size 0: it does not wait until there is something to read.
268 268
269 \sa readyReadStdout() readLineStdout() readStderr() writeToStdin() 269 \sa readyReadStdout() readLineStdout() readStderr() writeToStdin()
270*/ 270*/
271QByteArray QProcess::readStdout() 271QByteArray QProcess::readStdout()
272{ 272{
273 if ( readStdoutCalled ) { 273 if ( readStdoutCalled ) {
274 return QByteArray(); 274 return QByteArray();
275 } 275 }
276 readStdoutCalled = TRUE; 276 readStdoutCalled = TRUE;
277 277
278 QByteArray buf = bufStdout()->copy(); 278 QByteArray buf = bufStdout()->copy();
279 consumeBufStdout( -1 ); // consume everything 279 consumeBufStdout( -1 ); // consume everything
280 280
281 readStdoutCalled = FALSE; 281 readStdoutCalled = FALSE;
282 return buf; 282 return buf;
283} 283}
284 284
285/*! 285/*!
286 Reads the data that the process has written to standard error. When 286 Reads the data that the process has written to standard error. When
287 new data is written to standard error, the class emits the signal 287 new data is written to standard error, the class emits the signal
288 readyReadStderr(). 288 readyReadStderr().
289 289
290 If there is no data to read, this function returns a QByteArray of 290 If there is no data to read, this function returns a QByteArray of
291 size 0: it does not wait until there is something to read. 291 size 0: it does not wait until there is something to read.
292 292
293 \sa readyReadStderr() readLineStderr() readStdout() writeToStdin() 293 \sa readyReadStderr() readLineStderr() readStdout() writeToStdin()
294*/ 294*/
295QByteArray QProcess::readStderr() 295QByteArray QProcess::readStderr()
296{ 296{
297 if ( readStderrCalled ) { 297 if ( readStderrCalled ) {
298 return QByteArray(); 298 return QByteArray();
299 } 299 }
300 readStderrCalled = TRUE; 300 readStderrCalled = TRUE;
301 301
302 QByteArray buf = bufStderr()->copy(); 302 QByteArray buf = bufStderr()->copy();
303 consumeBufStderr( -1 ); // consume everything 303 consumeBufStderr( -1 ); // consume everything
304 304
305 readStderrCalled = FALSE; 305 readStderrCalled = FALSE;
306 return buf; 306 return buf;
307} 307}
308 308
309/*! 309/*!
310 Returns TRUE if it's possible to read an entire line of text from 310 Returns TRUE if it's possible to read an entire line of text from
311 standard output at this time; otherwise returns FALSE. 311 standard output at this time; otherwise returns FALSE.
312 312
313 \sa readLineStdout() canReadLineStderr() 313 \sa readLineStdout() canReadLineStderr()
314*/ 314*/
315bool QProcess::canReadLineStdout() const 315bool QProcess::canReadLineStdout() const
316{ 316{
317 QProcess *that = (QProcess*)this; 317 QProcess *that = (QProcess*)this;
318 return that->scanNewline( TRUE, 0 ); 318 return that->scanNewline( TRUE, 0 );
319} 319}
320 320
321/*! 321/*!
322 Returns TRUE if it's possible to read an entire line of text from 322 Returns TRUE if it's possible to read an entire line of text from
323 standard error at this time; otherwise returns FALSE. 323 standard error at this time; otherwise returns FALSE.
324 324
325 \sa readLineStderr() canReadLineStdout() 325 \sa readLineStderr() canReadLineStdout()
326*/ 326*/
327bool QProcess::canReadLineStderr() const 327bool QProcess::canReadLineStderr() const
328{ 328{
329 QProcess *that = (QProcess*)this; 329 QProcess *that = (QProcess*)this;
330 return that->scanNewline( FALSE, 0 ); 330 return that->scanNewline( FALSE, 0 );
331} 331}
332 332
333/*! 333/*!
334 Reads a line of text from standard output, excluding any trailing newline or 334 Reads a line of text from standard output, excluding any trailing newline or
335 carriage return characters, and returns it. Returns QString::null if 335 carriage return characters, and returns it. Returns QString::null if
336 canReadLineStdout() returns FALSE. 336 canReadLineStdout() returns FALSE.
337 337
338 \sa canReadLineStdout() readyReadStdout() readStdout() readLineStderr() 338 \sa canReadLineStdout() readyReadStdout() readStdout() readLineStderr()
339*/ 339*/
340QString QProcess::readLineStdout() 340QString QProcess::readLineStdout()
341{ 341{
342 QByteArray a; 342 QByteArray a;
343 QString s; 343 QString s;
344 if ( scanNewline( TRUE, &a ) ) { 344 if ( scanNewline( TRUE, &a ) ) {
345 if ( a.isEmpty() ) 345 if ( a.isEmpty() )
346 s = ""; 346 s = "";
347 else 347 else
348 s = QString( a ); 348 s = QString( a );
349 } 349 }
350 return s; 350 return s;
351} 351}
352 352
353/*! 353/*!
354 Reads a line of text from standard error, excluding any trailing newline or 354 Reads a line of text from standard error, excluding any trailing newline or
355 carriage return characters and returns it. Returns QString::null if 355 carriage return characters and returns it. Returns QString::null if
356 canReadLineStderr() returns FALSE. 356 canReadLineStderr() returns FALSE.
357 357
358 \sa canReadLineStderr() readyReadStderr() readStderr() readLineStdout() 358 \sa canReadLineStderr() readyReadStderr() readStderr() readLineStdout()
359*/ 359*/
360QString QProcess::readLineStderr() 360QString QProcess::readLineStderr()
361{ 361{
362 QByteArray a; 362 QByteArray a;
363 QString s; 363 QString s;
364 if ( scanNewline( FALSE, &a ) ) { 364 if ( scanNewline( FALSE, &a ) ) {
365 if ( a.isEmpty() ) 365 if ( a.isEmpty() )
366 s = ""; 366 s = "";
367 else 367 else
368 s = QString( a ); 368 s = QString( a );
369 } 369 }
370 return s; 370 return s;
371} 371}
372 372
373/*! 373/*!
374 This private function scans for any occurrence of \n or \r\n in the 374 This private function scans for any occurrence of \\n or \\r\\n in the
375 buffer \e buf. It stores the text in the byte array \a store if it is 375 buffer \e buf. It stores the text in the byte array \a store if it is
376 non-null. 376 non-null.
377*/ 377*/
378bool QProcess::scanNewline( bool stdOut, QByteArray *store ) 378bool QProcess::scanNewline( bool stdOut, QByteArray *store )
379{ 379{
380 QByteArray *buf; 380 QByteArray *buf;
381 if ( stdOut ) 381 if ( stdOut )
382 buf = bufStdout(); 382 buf = bufStdout();
383 else 383 else
384 buf = bufStderr(); 384 buf = bufStderr();
385 uint n = buf->size(); 385 uint n = buf->size();
386 uint i; 386 uint i;
387 for ( i=0; i<n; i++ ) { 387 for ( i=0; i<n; i++ ) {
388 if ( buf->at(i) == '\n' ) { 388 if ( buf->at(i) == '\n' ) {
389 break; 389 break;
390 } 390 }
391 } 391 }
392 if ( i >= n ) 392 if ( i >= n )
393 return FALSE; 393 return FALSE;
394 394
395 if ( store ) { 395 if ( store ) {
396 uint lineLength = i; 396 uint lineLength = i;
397 if ( lineLength>0 && buf->at(lineLength-1) == '\r' ) 397 if ( lineLength>0 && buf->at(lineLength-1) == '\r' )
398 lineLength--; // (if there are two \r, let one stay) 398 lineLength--; // (if there are two \r, let one stay)
399 store->resize( lineLength ); 399 store->resize( lineLength );
400 memcpy( store->data(), buf->data(), lineLength ); 400 memcpy( store->data(), buf->data(), lineLength );
401 if ( stdOut ) 401 if ( stdOut )
402 consumeBufStdout( i+1 ); 402 consumeBufStdout( i+1 );
403 else 403 else
404 consumeBufStderr( i+1 ); 404 consumeBufStderr( i+1 );
405 } 405 }
406 return TRUE; 406 return TRUE;
407} 407}
408 408
409/*! 409/*!
410 \fn void QProcess::launchFinished() 410 \fn void QProcess::launchFinished()
411 411
412 This signal is emitted when the process was started with launch(). 412 This signal is emitted when the process was started with launch().
413 If the start was successful, this signal is emitted after all the 413 If the start was successful, this signal is emitted after all the
414 data has been written to standard input. If the start failed, then 414 data has been written to standard input. If the start failed, then
415 this signal is emitted immediately. 415 this signal is emitted immediately.
416 416
417 \sa launch() QObject::deleteLater() 417 \sa launch() QObject::deleteLater()
418*/ 418*/
419 419
420/*! 420/*!
421 Runs the process and writes the data \a buf to the process's standard input. 421 Runs the process and writes the data \a buf to the process's standard input.
422 If all the data is written to standard input, standard input is 422 If all the data is written to standard input, standard input is
423 closed. The command is searched for in the path for executable programs; 423 closed. The command is searched for in the path for executable programs;
424 you can also use an absolute path in the command itself. 424 you can also use an absolute path in the command itself.
425 425
426 If \a env is null, then the process is started with the same environment as 426 If \a env is null, then the process is started with the same environment as
427 the starting process. If \a env is non-null, then the values in the 427 the starting process. If \a env is non-null, then the values in the
428 stringlist are interpreted as environment setttings of the form \c 428 stringlist are interpreted as environment setttings of the form \c
429 {key=value} and the process is started with these environment settings. For 429 {key=value} and the process is started with these environment settings. For
430 convenience, there is a small exception to this rule under Unix: if \a env 430 convenience, there is a small exception to this rule under Unix: if \a env
431 does not contain any settings for the environment variable \c 431 does not contain any settings for the environment variable \c
432 LD_LIBRARY_PATH, then this variable is inherited from the starting process. 432 LD_LIBRARY_PATH, then this variable is inherited from the starting process.
433 433
434 Returns TRUE if the process could be started; otherwise returns FALSE. 434 Returns TRUE if the process could be started; otherwise returns FALSE.
435 435
436 Note that you should not use the slots writeToStdin() and closeStdin() on 436 Note that you should not use the slots writeToStdin() and closeStdin() on
437 processes started with launch(), since the result is not well-defined. If you 437 processes started with launch(), since the result is not well-defined. If you
438 need these slots, use start() instead. 438 need these slots, use start() instead.
439 439
440 The process may or may not read the \a buf data sent to its standard 440 The process may or may not read the \a buf data sent to its standard
441 input. 441 input.
442 442
443 You can call this function even when a process that was started with 443 You can call this function even when a process that was started with
444 this instance is still running. Be aware that if you do this the 444 this instance is still running. Be aware that if you do this the
445 standard input of the process that was launched first will be 445 standard input of the process that was launched first will be
446 closed, with any pending data being deleted, and the process will be 446 closed, with any pending data being deleted, and the process will be
447 left to run out of your control. Similarly, if the process could not 447 left to run out of your control. Similarly, if the process could not
448 be started the standard input will be closed and the pending data 448 be started the standard input will be closed and the pending data
449 deleted. (On operating systems that have zombie processes, Qt will 449 deleted. (On operating systems that have zombie processes, Qt will
450 also wait() on the old process.) 450 also wait() on the old process.)
451 451
452 The object emits the signal launchFinished() when this function 452 The object emits the signal launchFinished() when this function
453 call is finished. If the start was successful, this signal is 453 call is finished. If the start was successful, this signal is
454 emitted after all the data has been written to standard input. If 454 emitted after all the data has been written to standard input. If
455 the start failed, then this signal is emitted immediately. 455 the start failed, then this signal is emitted immediately.
456 456
457 \sa start() launchFinished(); 457 \sa start() launchFinished();
458*/ 458*/
459bool QProcess::launch( const QByteArray& buf, QStringList *env ) 459bool QProcess::launch( const QByteArray& buf, QStringList *env )
460{ 460{
461 if ( start( env ) ) { 461 if ( start( env ) ) {
462 if ( !buf.isEmpty() ) { 462 if ( !buf.isEmpty() ) {
463 connect( this, SIGNAL(wroteToStdin()), 463 connect( this, SIGNAL(wroteToStdin()),
464 this, SLOT(closeStdinLaunch()) ); 464 this, SLOT(closeStdinLaunch()) );
465 writeToStdin( buf ); 465 writeToStdin( buf );
466 } else { 466 } else {
467 closeStdin(); 467 closeStdin();
468 emit launchFinished(); 468 emit launchFinished();
469 } 469 }
470 return TRUE; 470 return TRUE;
471 } else { 471 } else {
472 emit launchFinished(); 472 emit launchFinished();
473 return FALSE; 473 return FALSE;
474 } 474 }
475} 475}
476 476
477/*! \overload 477/*! \overload
478 478
479 The data \a buf is written to standard input with writeToStdin() 479 The data \a buf is written to standard input with writeToStdin()
480 using the QString::local8Bit() representation of the strings. 480 using the QString::local8Bit() representation of the strings.
481*/ 481*/
482bool QProcess::launch( const QString& buf, QStringList *env ) 482bool QProcess::launch( const QString& buf, QStringList *env )
483{ 483{
484 if ( start( env ) ) { 484 if ( start( env ) ) {
485 if ( !buf.isEmpty() ) { 485 if ( !buf.isEmpty() ) {
486 connect( this, SIGNAL(wroteToStdin()), 486 connect( this, SIGNAL(wroteToStdin()),
487 this, SLOT(closeStdinLaunch()) ); 487 this, SLOT(closeStdinLaunch()) );
488 writeToStdin( buf ); 488 writeToStdin( buf );
489 } else { 489 } else {
490 closeStdin(); 490 closeStdin();
491 emit launchFinished(); 491 emit launchFinished();
492 } 492 }
493 return TRUE; 493 return TRUE;
494 } else { 494 } else {
495 emit launchFinished(); 495 emit launchFinished();
496 return FALSE; 496 return FALSE;
497 } 497 }
498} 498}
499 499
500/*! 500/*!
501 This private slot is used by the launch() functions to close standard input. 501 This private slot is used by the launch() functions to close standard input.
502*/ 502*/
503void QProcess::closeStdinLaunch() 503void QProcess::closeStdinLaunch()
504{ 504{
505 disconnect( this, SIGNAL(wroteToStdin()), 505 disconnect( this, SIGNAL(wroteToStdin()),
506 this, SLOT(closeStdinLaunch()) ); 506 this, SLOT(closeStdinLaunch()) );
507 closeStdin(); 507 closeStdin();
508 emit launchFinished(); 508 emit launchFinished();
509} 509}
510 510
511 511
512/*! 512/*!
513 \fn void QProcess::readyReadStdout() 513 \fn void QProcess::readyReadStdout()
514 514
515 This signal is emitted when the process has written data to standard output. 515 This signal is emitted when the process has written data to standard output.
516 You can read the data with readStdout(). 516 You can read the data with readStdout().
517 517
518 Note that this signal is only emitted when there is new data and not 518 Note that this signal is only emitted when there is new data and not
519 when there is old, but unread data. In the slot connected to this signal, you 519 when there is old, but unread data. In the slot connected to this signal, you
520 should always read everything that is available at that moment to make sure 520 should always read everything that is available at that moment to make sure
521 that you don't lose any data. 521 that you don't lose any data.
522 522
523 \sa readStdout() readLineStdout() readyReadStderr() 523 \sa readStdout() readLineStdout() readyReadStderr()
524*/ 524*/
525/*! 525/*!
526 \fn void QProcess::readyReadStderr() 526 \fn void QProcess::readyReadStderr()
527 527
528 This signal is emitted when the process has written data to standard error. 528 This signal is emitted when the process has written data to standard error.
529 You can read the data with readStderr(). 529 You can read the data with readStderr().
530 530
531 Note that this signal is only emitted when there is new data and not 531 Note that this signal is only emitted when there is new data and not
532 when there is old, but unread data. In the slot connected to this signal, you 532 when there is old, but unread data. In the slot connected to this signal, you
533 should always read everything that is available at that moment to make sure 533 should always read everything that is available at that moment to make sure
534 that you don't lose any data. 534 that you don't lose any data.
535 535
536 \sa readStderr() readLineStderr() readyReadStdout() 536 \sa readStderr() readLineStderr() readyReadStdout()
537*/ 537*/
538/*! 538/*!
539 \fn void QProcess::processExited() 539 \fn void QProcess::processExited()
540 540
541 This signal is emitted when the process has exited. 541 This signal is emitted when the process has exited.
542 542
543 \sa isRunning() normalExit() exitStatus() start() launch() 543 \sa isRunning() normalExit() exitStatus() start() launch()
544*/ 544*/
545/*! 545/*!
546 \fn void QProcess::wroteToStdin() 546 \fn void QProcess::wroteToStdin()
547 547
548 This signal is emitted if the data sent to standard input (via 548 This signal is emitted if the data sent to standard input (via
549 writeToStdin()) was actually written to the process. This does not 549 writeToStdin()) was actually written to the process. This does not
550 imply that the process really read the data, since this class only detects 550 imply that the process really read the data, since this class only detects
551 when it was able to write the data to the operating system. But it is now 551 when it was able to write the data to the operating system. But it is now
552 safe to close standard input without losing pending data. 552 safe to close standard input without losing pending data.
553 553
554 \sa writeToStdin() closeStdin() 554 \sa writeToStdin() closeStdin()
555*/ 555*/
556 556
557 557
558/*! \overload 558/*! \overload
559 559
560 The string \a buf is handled as text using 560 The string \a buf is handled as text using
561 the QString::local8Bit() representation. 561 the QString::local8Bit() representation.
562*/ 562*/
563void QProcess::writeToStdin( const QString& buf ) 563void QProcess::writeToStdin( const QString& buf )
564{ 564{
565 QByteArray tmp = buf.local8Bit(); 565 QByteArray tmp = buf.local8Bit();
566 tmp.resize( buf.length() ); 566 tmp.resize( buf.length() );
567 writeToStdin( tmp ); 567 writeToStdin( tmp );
568} 568}
569 569
570 570
571/* 571/*
572 * Under Windows the implementation is not so nice: it is not that easy to 572 * Under Windows the implementation is not so nice: it is not that easy to
573 * detect when one of the signals should be emitted; therefore there are some 573 * detect when one of the signals should be emitted; therefore there are some
574 * timers that query the information. 574 * timers that query the information.
575 * To keep it a little efficient, use the timers only when they are needed. 575 * To keep it a little efficient, use the timers only when they are needed.
576 * They are needed, if you are interested in the signals. So use 576 * They are needed, if you are interested in the signals. So use
577 * connectNotify() and disconnectNotify() to keep track of your interest. 577 * connectNotify() and disconnectNotify() to keep track of your interest.
578 */ 578 */
579/*! \reimp 579/*! \reimp
580*/ 580*/
581void QProcess::connectNotify( const char * signal ) 581void QProcess::connectNotify( const char * signal )
582{ 582{
583#if defined(QT_QPROCESS_DEBUG) 583#if defined(QT_QPROCESS_DEBUG)
584 odebug << "QProcess::connectNotify(): signal " << signal << " has been connected" << oendl; 584 odebug << "QProcess::connectNotify(): signal " << signal << " has been connected" << oendl;
585#endif 585#endif
586 if ( !ioRedirection ) 586 if ( !ioRedirection )
587 if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 || 587 if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 ||
588 qstrcmp( signal, SIGNAL(readyReadStderr()) )==0 588 qstrcmp( signal, SIGNAL(readyReadStderr()) )==0
589 ) { 589 ) {
590#if defined(QT_QPROCESS_DEBUG) 590#if defined(QT_QPROCESS_DEBUG)
591 odebug << "QProcess::connectNotify(): set ioRedirection to TRUE" << oendl; 591 odebug << "QProcess::connectNotify(): set ioRedirection to TRUE" << oendl;
592#endif 592#endif
593 setIoRedirection( TRUE ); 593 setIoRedirection( TRUE );
594 return; 594 return;
595 } 595 }
596 if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) { 596 if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) {
597#if defined(QT_QPROCESS_DEBUG) 597#if defined(QT_QPROCESS_DEBUG)
598 odebug << "QProcess::connectNotify(): set notifyOnExit to TRUE" << oendl; 598 odebug << "QProcess::connectNotify(): set notifyOnExit to TRUE" << oendl;
599#endif 599#endif
600 setNotifyOnExit( TRUE ); 600 setNotifyOnExit( TRUE );
601 return; 601 return;
602 } 602 }
603 if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) { 603 if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) {
604#if defined(QT_QPROCESS_DEBUG) 604#if defined(QT_QPROCESS_DEBUG)
605 odebug << "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" << oendl; 605 odebug << "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" << oendl;
606#endif 606#endif
607 setWroteStdinConnected( TRUE ); 607 setWroteStdinConnected( TRUE );
608 return; 608 return;
609 } 609 }
610} 610}
611 611
612/*! \reimp 612/*! \reimp
613*/ 613*/
614void QProcess::disconnectNotify( const char * ) 614void QProcess::disconnectNotify( const char * )
615{ 615{
616 if ( ioRedirection && 616 if ( ioRedirection &&
617 receivers( SIGNAL(readyReadStdout()) ) ==0 && 617 receivers( SIGNAL(readyReadStdout()) ) ==0 &&
618 receivers( SIGNAL(readyReadStderr()) ) ==0 618 receivers( SIGNAL(readyReadStderr()) ) ==0
619 ) { 619 ) {
620#if defined(QT_QPROCESS_DEBUG) 620#if defined(QT_QPROCESS_DEBUG)
621 odebug << "QProcess::disconnectNotify(): set ioRedirection to FALSE" << oendl; 621 odebug << "QProcess::disconnectNotify(): set ioRedirection to FALSE" << oendl;
622#endif 622#endif
623 setIoRedirection( FALSE ); 623 setIoRedirection( FALSE );
624 } 624 }
625 if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) { 625 if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) {
626#if defined(QT_QPROCESS_DEBUG) 626#if defined(QT_QPROCESS_DEBUG)
627 odebug << "QProcess::disconnectNotify(): set notifyOnExit to FALSE" << oendl; 627 odebug << "QProcess::disconnectNotify(): set notifyOnExit to FALSE" << oendl;
628#endif 628#endif
629 setNotifyOnExit( FALSE ); 629 setNotifyOnExit( FALSE );
630 } 630 }
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b5ae4e5..8b64c41 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -81,518 +81,518 @@ static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
81} 81}
82 82
83/* EXPORT */ QCString makeChannel ( const char *str ){ 83/* EXPORT */ QCString makeChannel ( const char *str ){
84 if ( str && !::strchr ( str, '/' )) 84 if ( str && !::strchr ( str, '/' ))
85 return QCString ( "QPE/Application/" ) + str; 85 return QCString ( "QPE/Application/" ) + str;
86 else 86 else
87 return str; 87 return str;
88} 88}
89 89
90 90
91 91
92/* Now the default implementation of ODevice */ 92/* Now the default implementation of ODevice */
93 93
94struct default_button default_buttons [] = { 94struct default_button default_buttons [] = {
95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
96 "devicebuttons/z_calendar", 96 "devicebuttons/z_calendar",
97 "datebook", "nextView()", 97 "datebook", "nextView()",
98 "today", "raise()" }, 98 "today", "raise()" },
99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
100 "devicebuttons/z_contact", 100 "devicebuttons/z_contact",
101 "addressbook", "raise()", 101 "addressbook", "raise()",
102 "addressbook", "beamBusinessCard()" }, 102 "addressbook", "beamBusinessCard()" },
103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
104 "devicebuttons/z_home", 104 "devicebuttons/z_home",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
108 "devicebuttons/z_menu", 108 "devicebuttons/z_menu",
109 "QPE/TaskBar", "toggleMenu()", 109 "QPE/TaskBar", "toggleMenu()",
110 "QPE/TaskBar", "toggleStartMenu()" }, 110 "QPE/TaskBar", "toggleStartMenu()" },
111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
112 "devicebuttons/z_mail", 112 "devicebuttons/z_mail",
113 "opiemail", "raise()", 113 "opiemail", "raise()",
114 "opiemail", "newMail()" }, 114 "opiemail", "newMail()" },
115}; 115};
116 116
117ODevice *ODevice::inst() 117ODevice *ODevice::inst()
118{ 118{
119 static ODevice *dev = 0; 119 static ODevice *dev = 0;
120 120
121 // rewrite this to only use /proc/cpuinfo or so 121 // rewrite this to only use /proc/cpuinfo or so
122 QString cpu_info; 122 QString cpu_info;
123 123
124 if ( !dev ) 124 if ( !dev )
125 { 125 {
126 QFile f( PATH_PROC_CPUINFO ); 126 QFile f( PATH_PROC_CPUINFO );
127 if ( f.open( IO_ReadOnly ) ) 127 if ( f.open( IO_ReadOnly ) )
128 { 128 {
129 QTextStream s( &f ); 129 QTextStream s( &f );
130 while ( !s.atEnd() ) 130 while ( !s.atEnd() )
131 { 131 {
132 QString line; 132 QString line;
133 line = s.readLine(); 133 line = s.readLine();
134 if ( line.startsWith( "Hardware" ) ) 134 if ( line.startsWith( "Hardware" ) )
135 { 135 {
136 qDebug( "ODevice() - found '%s'", (const char*) line ); 136 qDebug( "ODevice() - found '%s'", (const char*) line );
137 cpu_info = line; 137 cpu_info = line;
138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
144 else qWarning( "ODevice() - unknown hardware - using default." ); 144 else qWarning( "ODevice() - unknown hardware - using default." );
145 break; 145 break;
146 } 146 }
147 } 147 }
148 } 148 }
149 else 149 else
150 { 150 {
151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
152 } 152 }
153 if ( !dev ) dev = new ODevice(); 153 if ( !dev ) dev = new ODevice();
154 dev->init(cpu_info); 154 dev->init(cpu_info);
155 } 155 }
156 return dev; 156 return dev;
157} 157}
158 158
159ODevice::ODevice() 159ODevice::ODevice()
160{ 160{
161 d = new ODeviceData; 161 d = new ODeviceData;
162 162
163 d->m_modelstr = "Unknown"; 163 d->m_modelstr = "Unknown";
164 d->m_model = Model_Unknown; 164 d->m_model = Model_Unknown;
165 d->m_vendorstr = "Unknown"; 165 d->m_vendorstr = "Unknown";
166 d->m_vendor = Vendor_Unknown; 166 d->m_vendor = Vendor_Unknown;
167 d->m_systemstr = "Unknown"; 167 d->m_systemstr = "Unknown";
168 d->m_system = System_Unknown; 168 d->m_system = System_Unknown;
169 d->m_sysverstr = "0.0"; 169 d->m_sysverstr = "0.0";
170 d->m_rotation = Rot0; 170 d->m_rotation = Rot0;
171 d->m_direction = CW; 171 d->m_direction = CW;
172 172
173 d->m_holdtime = 1000; // 1000ms 173 d->m_holdtime = 1000; // 1000ms
174 d->m_buttons = 0; 174 d->m_buttons = 0;
175 d->m_cpu_frequencies = new QStrList; 175 d->m_cpu_frequencies = new QStrList;
176 176
177 177
178 /* mixer */ 178 /* mixer */
179 d->m_sound = d->m_vol = d->m_mixer = -1; 179 d->m_sound = d->m_vol = d->m_mixer = -1;
180 180
181 // New distribution detection code first checks for legacy distributions, 181 // New distribution detection code first checks for legacy distributions,
182 // identified by /etc/familiar-version or /etc/oz_version. 182 // identified by /etc/familiar-version or /etc/oz_version.
183 // Then check for OpenEmbedded and lastly, read /etc/issue 183 // Then check for OpenEmbedded and lastly, read /etc/issue
184 184
185 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 185 for ( unsigned int i = 0; i < sizeof distributions; ++i )
186 { 186 {
187 if ( QFile::exists( distributions[i].sysvfile ) ) 187 if ( QFile::exists( distributions[i].sysvfile ) )
188 { 188 {
189 d->m_systemstr = distributions[i].sysstr; 189 d->m_systemstr = distributions[i].sysstr;
190 d->m_system = distributions[i].system; 190 d->m_system = distributions[i].system;
191 d->m_sysverstr = "<Unknown>"; 191 d->m_sysverstr = "<Unknown>";
192 QFile f( distributions[i].sysvfile ); 192 QFile f( distributions[i].sysvfile );
193 if ( f.open( IO_ReadOnly ) ) 193 if ( f.open( IO_ReadOnly ) )
194 { 194 {
195 QTextStream ts( &f ); 195 QTextStream ts( &f );
196 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 196 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
197 } 197 }
198 break; 198 break;
199 } 199 }
200 } 200 }
201} 201}
202 202
203void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 203void ODevice::systemMessage( const QCString &msg, const QByteArray & )
204{ 204{
205 if ( msg == "deviceButtonMappingChanged()" ) { 205 if ( msg == "deviceButtonMappingChanged()" ) {
206 reloadButtonMapping(); 206 reloadButtonMapping();
207 } 207 }
208} 208}
209 209
210void ODevice::init(const QString&) 210void ODevice::init(const QString&)
211{ 211{
212} 212}
213 213
214/** 214/**
215* This method initialises the button mapping 215* This method initialises the button mapping
216*/ 216*/
217void ODevice::initButtons() 217void ODevice::initButtons()
218{ 218{
219 if ( d->m_buttons ) 219 if ( d->m_buttons )
220 return; 220 return;
221 221
222 qDebug ( "init Buttons" ); 222 qDebug ( "init Buttons" );
223 d->m_buttons = new QValueList <ODeviceButton>; 223 d->m_buttons = new QValueList <ODeviceButton>;
224 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 224 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
225 default_button *db = default_buttons + i; 225 default_button *db = default_buttons + i;
226 ODeviceButton b; 226 ODeviceButton b;
227 b. setKeycode ( db->code ); 227 b. setKeycode ( db->code );
228 b. setUserText ( QObject::tr ( "Button", db->utext )); 228 b. setUserText ( QObject::tr ( "Button", db->utext ));
229 b. setPixmap ( Resource::loadPixmap ( db->pix )); 229 b. setPixmap ( Resource::loadPixmap ( db->pix ));
230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
231 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 231 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
232 d->m_buttons->append ( b ); 232 d->m_buttons->append ( b );
233 } 233 }
234 234
235 reloadButtonMapping(); 235 reloadButtonMapping();
236 236
237 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 237 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
238 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 238 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
239} 239}
240 240
241ODevice::~ODevice() 241ODevice::~ODevice()
242{ 242{
243// we leak m_devicebuttons and m_cpu_frequency 243// we leak m_devicebuttons and m_cpu_frequency
244// but it's a singleton and it is not so importantant 244// but it's a singleton and it is not so importantant
245// -zecke 245// -zecke
246 delete d; 246 delete d;
247} 247}
248 248
249bool ODevice::setSoftSuspend ( bool /*soft*/ ) 249bool ODevice::setSoftSuspend ( bool /*soft*/ )
250{ 250{
251 return false; 251 return false;
252} 252}
253 253
254//#include <linux/apm_bios.h> 254//#include <linux/apm_bios.h>
255 255
256#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 256#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
257 257
258/** 258/**
259* This method will try to suspend the device 259* This method will try to suspend the device
260* It only works if the user is the QWS Server and the apm application 260* It only works if the user is the QWS Server and the apm application
261* is installed. 261* is installed.
262* It tries to suspend and then waits some time cause some distributions 262* It tries to suspend and then waits some time cause some distributions
263* do have asynchronus apm implementations. 263* do have asynchronus apm implementations.
264* This method will either fail and return false or it'll suspend the 264* This method will either fail and return false or it'll suspend the
265* device and return once the device got woken up 265* device and return once the device got woken up
266* 266*
267* @return if the device got suspended 267* @return if the device got suspended
268*/ 268*/
269bool ODevice::suspend() 269bool ODevice::suspend()
270{ 270{
271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
272 return false; 272 return false;
273 273
274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
275 return false; 275 return false;
276 276
277 bool res = false; 277 bool res = false;
278 ODevice::sendSuspendmsg(); 278 ODevice::sendSuspendmsg();
279 279
280 struct timeval tvs, tvn; 280 struct timeval tvs, tvn;
281 ::gettimeofday ( &tvs, 0 ); 281 ::gettimeofday ( &tvs, 0 );
282 282
283 ::sync(); // flush fs caches 283 ::sync(); // flush fs caches
284 res = ( ::system ( "apm --suspend" ) == 0 ); 284 res = ( ::system ( "apm --suspend" ) == 0 );
285 285
286 // This is needed because the iPAQ apm implementation is asynchronous and we 286 // This is needed because the iPAQ apm implementation is asynchronous and we
287 // can not be sure when exactly the device is really suspended 287 // can not be sure when exactly the device is really suspended
288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
289 289
290 if ( res ) { 290 if ( res ) {
291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
292 ::usleep ( 200 * 1000 ); 292 ::usleep ( 200 * 1000 );
293 ::gettimeofday ( &tvn, 0 ); 293 ::gettimeofday ( &tvn, 0 );
294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
295 } 295 }
296 296
297 return res; 297 return res;
298} 298}
299 299
300//#include <linux/fb.h> better not rely on kernel headers in userspace ... 300//#include <linux/fb.h> better not rely on kernel headers in userspace ...
301 301
302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
303 303
304/* VESA Blanking Levels */ 304/* VESA Blanking Levels */
305#define VESA_NO_BLANKING 0 305#define VESA_NO_BLANKING 0
306#define VESA_VSYNC_SUSPEND 1 306#define VESA_VSYNC_SUSPEND 1
307#define VESA_HSYNC_SUSPEND 2 307#define VESA_HSYNC_SUSPEND 2
308#define VESA_POWERDOWN 3 308#define VESA_POWERDOWN 3
309 309
310/** 310/**
311* This sets the display on or off 311* This sets the display on or off
312*/ 312*/
313bool ODevice::setDisplayStatus ( bool on ) 313bool ODevice::setDisplayStatus ( bool on )
314{ 314{
315 qDebug("ODevice::setDisplayStatus(%d)", on); 315 qDebug("ODevice::setDisplayStatus(%d)", on);
316 316
317 if ( d->m_model == Model_Unknown ) 317 if ( d->m_model == Model_Unknown )
318 return false; 318 return false;
319 319
320 bool res = false; 320 bool res = false;
321 int fd; 321 int fd;
322 322
323#ifdef QT_QWS_DEVFS 323#ifdef QT_QWS_DEVFS
324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
325#else 325#else
326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
327#endif 327#endif
328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
329 ::close ( fd ); 329 ::close ( fd );
330 } 330 }
331 return res; 331 return res;
332} 332}
333 333
334/** 334/**
335* This sets the display brightness 335* This sets the display brightness
336* 336*
337* @param p The brightness to be set on a scale from 0 to 255 337* @param b The brightness to be set on a scale from 0 to 255
338* @return success or failure 338* @return success or failure
339*/ 339*/
340bool ODevice::setDisplayBrightness ( int p) 340bool ODevice::setDisplayBrightness ( int b)
341{ 341{
342 Q_UNUSED( p ) 342 Q_UNUSED( b )
343 return false; 343 return false;
344} 344}
345 345
346/** 346/**
347 * 347 *
348 * @return Returns the number of steppings on the brightness slider 348 * @return Returns the number of steppings on the brightness slider
349 * in the Light-'n-Power settings. Values smaller zero and bigger 349 * in the Light-'n-Power settings. Values smaller zero and bigger
350 * than 255 do not make sense. 350 * than 255 do not make sense.
351 * 351 *
352 * \sa QSlider::setLineStep 352 * \sa QSlider::setLineStep
353 * \sa QSlider::setPageStep 353 * \sa QSlider::setPageStep
354 */ 354 */
355int ODevice::displayBrightnessResolution() const 355int ODevice::displayBrightnessResolution() const
356{ 356{
357 return 16; 357 return 16;
358} 358}
359 359
360/** 360/**
361* This sets the display contrast 361* This sets the display contrast
362* @param p The contrast to be set on a scale from 0 to 255 362* @param p The contrast to be set on a scale from 0 to 255
363* @return success or failure 363* @return success or failure
364*/ 364*/
365bool ODevice::setDisplayContrast ( int p) 365bool ODevice::setDisplayContrast ( int p)
366{ 366{
367 Q_UNUSED( p ) 367 Q_UNUSED( p )
368 return false; 368 return false;
369} 369}
370 370
371/** 371/**
372* @return return the max value for the brightness settings slider 372* @return return the max value for the brightness settings slider
373* or 0 if the device doesn't support setting of a contrast 373* or 0 if the device doesn't support setting of a contrast
374*/ 374*/
375int ODevice::displayContrastResolution() const 375int ODevice::displayContrastResolution() const
376{ 376{
377 return 0; 377 return 0;
378} 378}
379 379
380/** 380/**
381* This returns the vendor as string 381* This returns the vendor as string
382* @return Vendor as QString 382* @return Vendor as QString
383*/ 383*/
384QString ODevice::vendorString() const 384QString ODevice::vendorString() const
385{ 385{
386 return d->m_vendorstr; 386 return d->m_vendorstr;
387} 387}
388 388
389/** 389/**
390* This returns the vendor as one of the values of OVendor 390* This returns the vendor as one of the values of OVendor
391* @return OVendor 391* @return OVendor
392*/ 392*/
393OVendor ODevice::vendor() const 393OVendor ODevice::vendor() const
394{ 394{
395 return d->m_vendor; 395 return d->m_vendor;
396} 396}
397 397
398/** 398/**
399* This returns the model as a string 399* This returns the model as a string
400* @return A string representing the model 400* @return A string representing the model
401*/ 401*/
402QString ODevice::modelString() const 402QString ODevice::modelString() const
403{ 403{
404 return d->m_modelstr; 404 return d->m_modelstr;
405} 405}
406 406
407/** 407/**
408* This does return the OModel used 408* This does return the OModel used
409*/ 409*/
410OModel ODevice::model() const 410OModel ODevice::model() const
411{ 411{
412 return d->m_model; 412 return d->m_model;
413} 413}
414 414
415/** 415/**
416* This does return the systen name 416* This does return the systen name
417*/ 417*/
418QString ODevice::systemString() const 418QString ODevice::systemString() const
419{ 419{
420 return d->m_systemstr; 420 return d->m_systemstr;
421} 421}
422 422
423/** 423/**
424* Return System as OSystem value 424* Return System as OSystem value
425*/ 425*/
426OSystem ODevice::system() const 426OSystem ODevice::system() const
427{ 427{
428 return d->m_system; 428 return d->m_system;
429} 429}
430 430
431/** 431/**
432* @return the version string of the base system 432* @return the version string of the base system
433*/ 433*/
434QString ODevice::systemVersionString() const 434QString ODevice::systemVersionString() const
435{ 435{
436 return d->m_sysverstr; 436 return d->m_sysverstr;
437} 437}
438 438
439/** 439/**
440* @return the current Transformation 440* @return the current Transformation
441*/ 441*/
442Transformation ODevice::rotation() const 442Transformation ODevice::rotation() const
443{ 443{
444 return d->m_rotation; 444 return d->m_rotation;
445} 445}
446 446
447/** 447/**
448* @return the current rotation direction 448* @return the current rotation direction
449*/ 449*/
450ODirection ODevice::direction() const 450ODirection ODevice::direction() const
451{ 451{
452 return d->m_direction; 452 return d->m_direction;
453} 453}
454 454
455/** 455/**
456* This plays an alarm sound 456* This plays an alarm sound
457*/ 457*/
458void ODevice::playAlarmSound() 458void ODevice::playAlarmSound()
459{ 459{
460#ifndef QT_NO_SOUND 460#ifndef QT_NO_SOUND
461 static Sound snd ( "alarm" ); 461 static Sound snd ( "alarm" );
462 462
463 if ( snd. isFinished()) 463 if ( snd. isFinished())
464 snd. play(); 464 snd. play();
465#endif 465#endif
466} 466}
467 467
468/** 468/**
469* This plays a key sound 469* This plays a key sound
470*/ 470*/
471void ODevice::playKeySound() 471void ODevice::playKeySound()
472{ 472{
473#ifndef QT_NO_SOUND 473#ifndef QT_NO_SOUND
474 static Sound snd ( "keysound" ); 474 static Sound snd ( "keysound" );
475 475
476 if ( snd. isFinished()) 476 if ( snd. isFinished())
477 snd. play(); 477 snd. play();
478#endif 478#endif
479} 479}
480 480
481/** 481/**
482* This plays a touch sound 482* This plays a touch sound
483*/ 483*/
484void ODevice::playTouchSound() 484void ODevice::playTouchSound()
485{ 485{
486#ifndef QT_NO_SOUND 486#ifndef QT_NO_SOUND
487 static Sound snd ( "touchsound" ); 487 static Sound snd ( "touchsound" );
488 488
489 if ( snd. isFinished()) 489 if ( snd. isFinished())
490 snd. play(); 490 snd. play();
491#endif 491#endif
492} 492}
493 493
494/** 494/**
495* This method will return a list of leds 495* This method will return a list of leds
496* available on this device 496* available on this device
497* @return a list of LEDs. 497* @return a list of LEDs.
498*/ 498*/
499QValueList <OLed> ODevice::ledList() const 499QValueList <OLed> ODevice::ledList() const
500{ 500{
501 return QValueList <OLed>(); 501 return QValueList <OLed>();
502} 502}
503 503
504/** 504/**
505* This does return the state of the LEDs 505* This does return the state of the LEDs
506*/ 506*/
507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
508{ 508{
509 return QValueList <OLedState>(); 509 return QValueList <OLedState>();
510} 510}
511 511
512/** 512/**
513* @return the state for a given OLed 513* @return the state for a given OLed
514*/ 514*/
515OLedState ODevice::ledState ( OLed /*which*/ ) const 515OLedState ODevice::ledState ( OLed /*which*/ ) const
516{ 516{
517 return Led_Off; 517 return Led_Off;
518} 518}
519 519
520/** 520/**
521* Set the state for a LED 521* Set the state for a LED
522* @param which Which OLed to use 522* @param which Which OLed to use
523* @param st The state to set 523* @param st The state to set
524* @return success or failure 524* @return success or failure
525*/ 525*/
526bool ODevice::setLedState ( OLed which, OLedState st ) 526bool ODevice::setLedState ( OLed which, OLedState st )
527{ 527{
528 Q_UNUSED( which ) 528 Q_UNUSED( which )
529 Q_UNUSED( st ) 529 Q_UNUSED( st )
530 return false; 530 return false;
531} 531}
532 532
533/** 533/**
534* @return if the device has a light sensor 534* @return if the device has a light sensor
535*/ 535*/
536bool ODevice::hasLightSensor() const 536bool ODevice::hasLightSensor() const
537{ 537{
538 return false; 538 return false;
539} 539}
540 540
541/** 541/**
542* @return a value from the light sensor 542* @return a value from the light sensor
543*/ 543*/
544int ODevice::readLightSensor() 544int ODevice::readLightSensor()
545{ 545{
546 return -1; 546 return -1;
547} 547}
548 548
549/** 549/**
550* @return the light sensor resolution 550* @return the light sensor resolution
551*/ 551*/
552int ODevice::lightSensorResolution() const 552int ODevice::lightSensorResolution() const
553{ 553{
554 return 0; 554 return 0;
555} 555}
556 556
557/** 557/**
558* @return if the device has a hinge sensor 558* @return if the device has a hinge sensor
559*/ 559*/
560bool ODevice::hasHingeSensor() const 560bool ODevice::hasHingeSensor() const
561{ 561{
562 return false; 562 return false;
563} 563}
564 564
565/** 565/**
566* @return a value from the hinge sensor 566* @return a value from the hinge sensor
567*/ 567*/
568OHingeStatus ODevice::readHingeSensor() 568OHingeStatus ODevice::readHingeSensor()
569{ 569{
570 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
571} 571}
572 572
573/** 573/**
574* @return a list with CPU frequencies supported by the hardware 574* @return a list with CPU frequencies supported by the hardware
575*/ 575*/
576const QStrList &ODevice::allowedCpuFrequencies() const 576const QStrList &ODevice::allowedCpuFrequencies() const
577{ 577{
578 return *d->m_cpu_frequencies; 578 return *d->m_cpu_frequencies;
579} 579}
580 580
581 581
582/** 582/**
583* Set desired CPU frequency 583* Set desired CPU frequency
584* 584*
585* @param index index into d->m_cpu_frequencies of the frequency to be set 585* @param index index into d->m_cpu_frequencies of the frequency to be set
586*/ 586*/
587bool ODevice::setCurrentCpuFrequency(uint index) 587bool ODevice::setCurrentCpuFrequency(uint index)
588{ 588{
589 if (index >= d->m_cpu_frequencies->count()) 589 if (index >= d->m_cpu_frequencies->count())
590 return false; 590 return false;
591 591
592 char *freq = d->m_cpu_frequencies->at(index); 592 char *freq = d->m_cpu_frequencies->at(index);
593 qWarning("set freq to %s", freq); 593 qWarning("set freq to %s", freq);
594 594
595 int fd; 595 int fd;
596 596
597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
598 char writeCommand[50]; 598 char writeCommand[50];
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index ab95dc3..05a1a25 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,163 +1,163 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 5
6 Inspired by the config classes from the KDE Project which are 6 Inspired by the config classes from the KDE Project which are
7 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 7 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33#ifndef OCONFIG_H 33#ifndef OCONFIG_H
34#define OCONFIG_H 34#define OCONFIG_H
35 35
36//FIXME: Implement for X11 or reuse libqpe/Config there also? 36//FIXME: Implement for X11 or reuse libqpe/Config there also?
37//FIXME: Or rather use QSettings also for libqpe? 37//FIXME: Or rather use QSettings also for libqpe?
38 38
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41class QColor; 41class QColor;
42class QFont; 42class QFont;
43 43
44namespace Opie { 44namespace Opie {
45namespace Core { 45namespace Core {
46 46
47/** 47/**
48 * A Configuration class based on the Qtopia @ref Config class 48 * A Configuration class based on the Qtopia @ref Config class
49 * featuring additional handling of color and font entries 49 * featuring additional handling of color and font entries
50 */ 50 */
51 51
52class OConfig : public Config 52class OConfig : public Config
53{ 53{
54 public: 54 public:
55 /** 55 /**
56 * Constructs a OConfig object with a @a name. 56 * Constructs a OConfig object with a @a name.
57 */ 57 */
58 OConfig( const QString &name, Domain domain = User ); 58 OConfig( const QString &name, Domain domain = User );
59 /** 59 /**
60 * Destructs the OConfig object. 60 * Destructs the OConfig object.
61 * 61 *
62 * Writes back any dirty configuration entries, and destroys 62 * Writes back any dirty configuration entries, and destroys
63 * dynamically created objects. 63 * dynamically created objects.
64 */ 64 */
65 virtual ~OConfig(); 65 virtual ~OConfig();
66 /** 66 /**
67 * @returns the name of the current group. 67 * @returns the name of the current group.
68 * The current group is used for searching keys and accessing entries. 68 * The current group is used for searching keys and accessing entries.
69 * @todo make const 69 * @todo make const
70 */ 70 */
71 const QString& group()const { return git.key(); }; 71 const QString& group()const { return git.key(); };
72 /** 72 /**
73 * @returns a @ref QColor entry or a @a default value if the key is not found. 73 * @returns a @ref QColor entry or a @a default value if the key is not found.
74 */ 74 */
75 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 75 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
76 /** 76 /**
77 * @returns a @ref QFont value or a @a default value if the key is not found. 77 * @returns a @ref QFont value or a @a default value if the key is not found.
78 */ 78 */
79 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 79 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
80 80
81private: 81private:
82 class Private; 82 class Private;
83 Private *d; 83 Private *d;
84}; 84};
85 85
86/** 86/**
87 * @brief Helper class for easier use of OConfig groups. 87 * @brief Helper class for easier use of OConfig groups.
88 * 88 *
89 * Careful programmers always set the group of a 89 * Careful programmers always set the group of a
90 * @ref OConfig object to the group they want to read from 90 * @ref OConfig object to the group they want to read from
91 * and set it back to the old one of afterwards. This is usually 91 * and set it back to the old one of afterwards. This is usually
92 * written as: 92 * written as:
93 * <pre> 93 * <pre>
94 * 94 *
95 * QString oldgroup config()->group(); 95 * QString oldgroup config()->group();
96 * config()->setGroup( "TheGroupThatIWant" ); 96 * config()->setGroup( "TheGroupThatIWant" );
97 * ... 97 * ...
98 * config()->writeEntry( "Blah", "Blubb" ); 98 * config()->writeEntry( "Blah", "Blubb" );
99 * 99 *
100 * config()->setGroup( oldgroup ); 100 * config()->setGroup( oldgroup );
101 * </pre> 101 * </pre>
102 * 102 *
103 * In order to facilitate this task, you can use 103 * In order to facilitate this task, you can use
104 * OConfigGroupSaver. Simply construct such an object ON THE STACK 104 * OConfigGroupSaver. Simply construct such an object ON THE STACK
105 * when you want to switch to a new group. Then, when the object goes 105 * when you want to switch to a new group. Then, when the object goes
106 * out of scope, the group will automatically be restored. If you 106 * out of scope, the group will automatically be restored. If you
107 * want to use several different groups within a function or method, 107 * want to use several different groups within a function or method,
108 * you can still use OConfigGroupSaver: Simply enclose all work with 108 * you can still use OConfigGroupSaver: Simply enclose all work with
109 * one group (including the creation of the OConfigGroupSaver object) 109 * one group (including the creation of the OConfigGroupSaver object)
110 * in one block. 110 * in one block.
111 * 111 *
112 * \code 112 * \code
113 * OConfigGroupSaver saver(cfg,"TheGroupThatInWhat"); 113 * OConfigGroupSaver saver(cfg,"TheGroupThatInWhat");
114 * \endcode 114 * \endcode
115 * 115 *
116 * Note that OConfigGroupSaver (cfg,"TheGroupThatInWhat"); would get imediately 116 * Note that OConfigGroupSaver (cfg,"TheGroupThatInWhat"); would get imediately
117 * destructed after created and that you would save in the old group which 117 * destructed after created and that you would save in the old group which
118 * is unwished. 118 * is unwished.
119 * 119 *
120 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 120 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
121 * @version $Id$ 121 * @version $Id$
122 * @see OConfig 122 * @see OConfig
123 */ 123 */
124 124
125class OConfigGroupSaver 125class OConfigGroupSaver
126{ 126{
127 public: 127 public:
128 /** 128 /**
129 * Constructor. 129 * Constructor.
130 * Create the object giving a @config object and a @a group to become 130 * Create the object giving a OConfig object and a @a group to become
131 * the current group. 131 * the current group.
132 */ 132 */
133 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 133 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
134 { _config->setGroup( group ); } 134 { _config->setGroup( group ); }
135 135
136 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 136 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
137 { _config->setGroup( group ); } 137 { _config->setGroup( group ); }
138 138
139 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 139 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
140 { _config->setGroup( group ); } 140 { _config->setGroup( group ); }
141 /** 141 /**
142 * Destructor. 142 * Destructor.
143 * Restores the last current group. 143 * Restores the last current group.
144 * @todo make it not inline for bc reasons. See KDE BC guide 144 * @todo make it not inline for bc reasons. See KDE BC guide
145 */ 145 */
146 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 146 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
147 147
148 OConfig* config() { return _config; }; 148 OConfig* config() { return _config; };
149 149
150 private: 150 private:
151 OConfig* _config; 151 OConfig* _config;
152 QString _oldgroup; 152 QString _oldgroup;
153 153
154 OConfigGroupSaver( const OConfigGroupSaver& ); 154 OConfigGroupSaver( const OConfigGroupSaver& );
155 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 155 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
156 156
157 class Private; 157 class Private;
158 Private *d; 158 Private *d;
159}; 159};
160} 160}
161} 161}
162 162
163#endif // OCONFIG_H 163#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 21a6c26..18dc09e 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -163,329 +163,329 @@ class odbgstream
163 * Flushes the output. 163 * Flushes the output.
164 */ 164 */
165 virtual void flush(); 165 virtual void flush();
166 /** 166 /**
167 * Prints the given value. 167 * Prints the given value.
168 * @param string the string to print 168 * @param string the string to print
169 * @return this stream 169 * @return this stream
170 */ 170 */
171 odbgstream &operator<<(const QString& string); 171 odbgstream &operator<<(const QString& string);
172 /** 172 /**
173 * Prints the given value. 173 * Prints the given value.
174 * @param string the string to print 174 * @param string the string to print
175 * @return this stream 175 * @return this stream
176 */ 176 */
177 odbgstream &operator<<(const char *string); 177 odbgstream &operator<<(const char *string);
178 /** 178 /**
179 * Prints the given value. 179 * Prints the given value.
180 * @param string the string to print 180 * @param string the string to print
181 * @return this stream 181 * @return this stream
182 */ 182 */
183 odbgstream &operator<<(const QCString& string); 183 odbgstream &operator<<(const QCString& string);
184 /** 184 /**
185 * Prints the given value. 185 * Prints the given value.
186 * @param p a pointer to print (in number form) 186 * @param p a pointer to print (in number form)
187 * @return this stream 187 * @return this stream
188 */ 188 */
189 odbgstream& operator<<(const void * p); 189 odbgstream& operator<<(const void * p);
190 /** 190 /**
191 * Prints the given value. 191 * Prints the given value.
192 * @param d the double to print 192 * @param d the double to print
193 * @return this stream 193 * @return this stream
194 */ 194 */
195 odbgstream& operator<<(double d); 195 odbgstream& operator<<(double d);
196 /** 196 /**
197 * Prints the string @p format which can contain 197 * Prints the string @p format which can contain
198 * printf-style formatted values. 198 * printf-style formatted values.
199 * @param format the printf-style format 199 * @param format the printf-style format
200 * @return this stream 200 * @return this stream
201 */ 201 */
202 odbgstream &form(const char *format, ...); 202 odbgstream &form(const char *format, ...);
203 /** Operator to print out basic information about a QWidget. 203 /** Operator to print out basic information about a QWidget.
204 * Output of class names only works if the class is moc'ified. 204 * Output of class names only works if the class is moc'ified.
205 * @param widget the widget to print 205 * @param widget the widget to print
206 * @return this stream 206 * @return this stream
207 */ 207 */
208 odbgstream& operator<< (QWidget* widget); 208 odbgstream& operator<< (QWidget* widget);
209 209
210 /** 210 /**
211 * Prints the given value. 211 * Prints the given value.
212 * @param dateTime the datetime to print 212 * @param dateTime the datetime to print
213 * @return this stream 213 * @return this stream
214 */ 214 */
215 odbgstream& operator<< ( const QDateTime& dateTime ); 215 odbgstream& operator<< ( const QDateTime& dateTime );
216 216
217 /** 217 /**
218 * Prints the given value. 218 * Prints the given value.
219 * @param date the date to print 219 * @param date the date to print
220 * @return this stream 220 * @return this stream
221 */ 221 */
222 odbgstream& operator<< ( const QDate& date ); 222 odbgstream& operator<< ( const QDate& date );
223 223
224 /** 224 /**
225 * Prints the given value. 225 * Prints the given value.
226 * @param time the time to print 226 * @param time the time to print
227 * @return this stream 227 * @return this stream
228 */ 228 */
229 odbgstream& operator<< ( const QTime& time ); 229 odbgstream& operator<< ( const QTime& time );
230 230
231 /** 231 /**
232 * Prints the given value. 232 * Prints the given value.
233 * @param point the point to print 233 * @param point the point to print
234 * @return this stream 234 * @return this stream
235 */ 235 */
236 odbgstream& operator<< ( const QPoint& point ); 236 odbgstream& operator<< ( const QPoint& point );
237 237
238 /** 238 /**
239 * Prints the given value. 239 * Prints the given value.
240 * @param size the QSize to print 240 * @param size the QSize to print
241 * @return this stream 241 * @return this stream
242 */ 242 */
243 odbgstream& operator<< ( const QSize& size ); 243 odbgstream& operator<< ( const QSize& size );
244 244
245 /** 245 /**
246 * Prints the given value. 246 * Prints the given value.
247 * @param rect the QRect to print 247 * @param rect the QRect to print
248 * @return this stream 248 * @return this stream
249 */ 249 */
250 odbgstream& operator<< ( const QRect& rect); 250 odbgstream& operator<< ( const QRect& rect);
251 251
252 /** 252 /**
253 * Prints the given value. 253 * Prints the given value.
254 * @param region the QRegion to print 254 * @param region the QRegion to print
255 * @return this stream 255 * @return this stream
256 */ 256 */
257 odbgstream& operator<< ( const QRegion& region); 257 odbgstream& operator<< ( const QRegion& region);
258 258
259 /** 259 /**
260 * Prints the given value. 260 * Prints the given value.
261 * @param list the stringlist to print 261 * @param list the stringlist to print
262 * @return this stream 262 * @return this stream
263 */ 263 */
264 odbgstream& operator<< ( const QStringList& list); 264 odbgstream& operator<< ( const QStringList& list);
265 265
266 /** 266 /**
267 * Prints the given value. 267 * Prints the given value.
268 * @param color the color to print 268 * @param color the color to print
269 * @return this stream 269 * @return this stream
270 */ 270 */
271 odbgstream& operator<< ( const QColor& color); 271 odbgstream& operator<< ( const QColor& color);
272 272
273 /** 273 /**
274 * Prints the given value. 274 * Prints the given value.
275 * @param brush the brush to print 275 * @param brush the brush to print
276 * @return this stream 276 * @return this stream
277 */ 277 */
278 odbgstream& operator<< ( const QBrush& brush ); 278 odbgstream& operator<< ( const QBrush& brush );
279 279
280 private: 280 private:
281 QString output; 281 QString output;
282 unsigned int area, level; 282 unsigned int area, level;
283 bool print; 283 bool print;
284 odbgstreamprivate* d; 284 odbgstreamprivate* d;
285}; 285};
286 286
287/** 287/**
288 * Prints an "\n". 288 * Prints an "\n".
289 * @param s the debug stream to write to 289 * @param s the debug stream to write to
290 * @return the debug stream (@p s) 290 * @return the debug stream (@p s)
291 */ 291 */
292inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; } 292inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; }
293/** 293/**
294 * Flushes the stream. 294 * Flushes the stream.
295 * @param s the debug stream to write to 295 * @param s the debug stream to write to
296 * @return the debug stream (@p s) 296 * @return the debug stream (@p s)
297 */ 297 */
298inline odbgstream& flush( odbgstream &s) { s.flush(); return s; } 298inline odbgstream& flush( odbgstream &s) { s.flush(); return s; }
299 299
300odbgstream &perror( odbgstream &s); 300odbgstream &perror( odbgstream &s);
301 301
302/** 302/**
303 * ondbgstream is a dummy variant of @ref odbgstream. All functions do 303 * ondbgstream is a dummy variant of @ref odbgstream. All functions do
304 * nothing. 304 * nothing.
305 * @see ondDebug() 305 * @see ondDebug()
306 */ 306 */
307class ondbgstream { 307class ondbgstream {
308 public: 308 public:
309 /// Empty constructor. 309 /// Empty constructor.
310 ondbgstream() {} 310 ondbgstream() {}
311 ~ondbgstream() {} 311 ~ondbgstream() {}
312 /** 312 /**
313 * Does nothing. 313 * Does nothing.
314 * @return this stream 314 * @return this stream
315 */ 315 */
316 ondbgstream &operator<<(short int ) { return *this; } 316 ondbgstream &operator<<(short int ) { return *this; }
317 /** 317 /**
318 * Does nothing. 318 * Does nothing.
319 * @return this stream 319 * @return this stream
320 */ 320 */
321 ondbgstream &operator<<(unsigned short int ) { return *this; } 321 ondbgstream &operator<<(unsigned short int ) { return *this; }
322 /** 322 /**
323 * Does nothing. 323 * Does nothing.
324 * @return this stream 324 * @return this stream
325 */ 325 */
326 ondbgstream &operator<<(char ) { return *this; } 326 ondbgstream &operator<<(char ) { return *this; }
327 /** 327 /**
328 * Does nothing. 328 * Does nothing.
329 * @return this stream 329 * @return this stream
330 */ 330 */
331 ondbgstream &operator<<(unsigned char ) { return *this; } 331 ondbgstream &operator<<(unsigned char ) { return *this; }
332 /** 332 /**
333 * Does nothing. 333 * Does nothing.
334 * @return this stream 334 * @return this stream
335 */ 335 */
336 ondbgstream &operator<<(int ) { return *this; } 336 ondbgstream &operator<<(int ) { return *this; }
337 /** 337 /**
338 * Does nothing. 338 * Does nothing.
339 * @return this stream 339 * @return this stream
340 */ 340 */
341 ondbgstream &operator<<(unsigned int ) { return *this; } 341 ondbgstream &operator<<(unsigned int ) { return *this; }
342 /** 342 /**
343 * Does nothing. 343 * Does nothing.
344 */ 344 */
345 void flush() {} 345 void flush() {}
346 /** 346 /**
347 * Does nothing. 347 * Does nothing.
348 * @return this stream 348 * @return this stream
349 */ 349 */
350 ondbgstream &operator<<(const QString& ) { return *this; } 350 ondbgstream &operator<<(const QString& ) { return *this; }
351 /** 351 /**
352 * Does nothing. 352 * Does nothing.
353 * @return this stream 353 * @return this stream
354 */ 354 */
355 ondbgstream &operator<<(const QCString& ) { return *this; } 355 ondbgstream &operator<<(const QCString& ) { return *this; }
356 /** 356 /**
357 * Does nothing. 357 * Does nothing.
358 * @return this stream 358 * @return this stream
359 */ 359 */
360 ondbgstream &operator<<(const char *) { return *this; } 360 ondbgstream &operator<<(const char *) { return *this; }
361 /** 361 /**
362 * Does nothing. 362 * Does nothing.
363 * @return this stream 363 * @return this stream
364 */ 364 */
365 ondbgstream& operator<<(const void *) { return *this; } 365 ondbgstream& operator<<(const void *) { return *this; }
366 /** 366 /**
367 * Does nothing. 367 * Does nothing.
368 * @return this stream 368 * @return this stream
369 */ 369 */
370 ondbgstream& operator<<(void *) { return *this; } 370 ondbgstream& operator<<(void *) { return *this; }
371 /** 371 /**
372 * Does nothing. 372 * Does nothing.
373 * @return this stream 373 * @return this stream
374 */ 374 */
375 ondbgstream& operator<<(double) { return *this; } 375 ondbgstream& operator<<(double) { return *this; }
376 /** 376 /**
377 * Does nothing. 377 * Does nothing.
378 * @return this stream 378 * @return this stream
379 */ 379 */
380 ondbgstream& operator<<(long) { return *this; } 380 ondbgstream& operator<<(long) { return *this; }
381 /** 381 /**
382 * Does nothing. 382 * Does nothing.
383 * @return this stream 383 * @return this stream
384 */ 384 */
385 ondbgstream& operator<<(unsigned long) { return *this; } 385 ondbgstream& operator<<(unsigned long) { return *this; }
386 /** 386 /**
387 * Does nothing. 387 * Does nothing.
388 * @return this stream 388 * @return this stream
389 */ 389 */
390 ondbgstream& operator << (QWidget*) { return *this; } 390 ondbgstream& operator << (QWidget*) { return *this; }
391 /** 391 /**
392 * Does nothing. 392 * Does nothing.
393 * @return this stream 393 * @return this stream
394 */ 394 */
395 ondbgstream &form(const char *, ...) { return *this; } 395 ondbgstream &form(const char *, ...) { return *this; }
396 396
397 ondbgstream& operator<<( const QDateTime& ) { return *this; } 397 ondbgstream& operator<<( const QDateTime& ) { return *this; }
398 ondbgstream& operator<<( const QDate& ) { return *this; } 398 ondbgstream& operator<<( const QDate& ) { return *this; }
399 ondbgstream& operator<<( const QTime& ) { return *this; } 399 ondbgstream& operator<<( const QTime& ) { return *this; }
400 ondbgstream& operator<<( const QPoint & ) { return *this; } 400 ondbgstream& operator<<( const QPoint & ) { return *this; }
401 ondbgstream& operator<<( const QSize & ) { return *this; } 401 ondbgstream& operator<<( const QSize & ) { return *this; }
402 ondbgstream& operator<<( const QRect & ) { return *this; } 402 ondbgstream& operator<<( const QRect & ) { return *this; }
403 ondbgstream& operator<<( const QRegion & ) { return *this; } 403 ondbgstream& operator<<( const QRegion & ) { return *this; }
404 ondbgstream& operator<<( const QStringList & ) { return *this; } 404 ondbgstream& operator<<( const QStringList & ) { return *this; }
405 ondbgstream& operator<<( const QColor & ) { return *this; } 405 ondbgstream& operator<<( const QColor & ) { return *this; }
406 ondbgstream& operator<<( const QBrush & ) { return *this; } 406 ondbgstream& operator<<( const QBrush & ) { return *this; }
407 407
408private: 408private:
409 class Private; 409 class Private;
410 Private *d; 410 Private *d;
411}; 411};
412 412
413/*====================================================================================== 413/*======================================================================================
414 * related functions 414 * related functions
415 *======================================================================================*/ 415 *======================================================================================*/
416 416
417/** 417/**
418 * Does nothing. 418 * Does nothing.
419 * @param a stream 419 * @param s stream
420 * @return the given @p s 420 * @return the given @p s
421 */ 421 */
422inline ondbgstream& endl( ondbgstream & s) { return s; } 422inline ondbgstream& endl( ondbgstream & s) { return s; }
423/** 423/**
424 * Does nothing. 424 * Does nothing.
425 * @param a stream 425 * @param s stream
426 * @return the given @p s 426 * @return the given @p s
427 */ 427 */
428inline ondbgstream& flush( ondbgstream & s) { return s; } 428inline ondbgstream& flush( ondbgstream & s) { return s; }
429inline ondbgstream& perror( ondbgstream & s) { return s; } 429inline ondbgstream& perror( ondbgstream & s) { return s; }
430 430
431/** 431/**
432 * Returns a debug stream. You can use it to print debug 432 * Returns a debug stream. You can use it to print debug
433 * information. 433 * information.
434 * @param area an id to identify the output, 0 for default 434 * @param area an id to identify the output, 0 for default
435 */ 435 */
436odbgstream odDebug(int area = 0); 436odbgstream odDebug(int area = 0);
437odbgstream odDebug(bool cond, int area = 0); 437odbgstream odDebug(bool cond, int area = 0);
438/** 438/**
439 * Returns a backtrace. 439 * Returns a backtrace.
440 * @param levels the number of levels (-1 for unlimited) of the backtrace 440 * @param levels the number of levels (-1 for unlimited) of the backtrace
441 * @return a backtrace 441 * @return a backtrace
442 */ 442 */
443QString odBacktrace(int levels = -1); 443QString odBacktrace(int levels = -1);
444/** 444/**
445 * Returns a dummy debug stream. The stream does not print anything. 445 * Returns a dummy debug stream. The stream does not print anything.
446 * @param area an id to identify the output, 0 for default 446 * @param area an id to identify the output, 0 for default
447 * @see odDebug() 447 * @see odDebug()
448 */ 448 */
449inline ondbgstream ondDebug(int = 0) { return ondbgstream(); } 449inline ondbgstream ondDebug(int area = 0) { return ondbgstream(); }
450inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); } 450inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
451inline QString ondBacktrace() { return QString::null; } 451inline QString ondBacktrace() { return QString::null; }
452inline QString ondBacktrace(int) { return QString::null; } 452inline QString ondBacktrace(int) { return QString::null; }
453 453
454/** 454/**
455 * Returns a warning stream. You can use it to print warning 455 * Returns a warning stream. You can use it to print warning
456 * information. 456 * information.
457 * @param area an id to identify the output, 0 for default 457 * @param area an id to identify the output, 0 for default
458 */ 458 */
459odbgstream odWarning(int area = 0); 459odbgstream odWarning(int area = 0);
460odbgstream odWarning(bool cond, int area = 0); 460odbgstream odWarning(bool cond, int area = 0);
461/** 461/**
462 * Returns an error stream. You can use it to print error 462 * Returns an error stream. You can use it to print error
463 * information. 463 * information.
464 * @param area an id to identify the output, 0 for default 464 * @param area an id to identify the output, 0 for default
465 */ 465 */
466odbgstream odError(int area = 0); 466odbgstream odError(int area = 0);
467odbgstream odError(bool cond, int area = 0); 467odbgstream odError(bool cond, int area = 0);
468/** 468/**
469 * Returns a fatal error stream. You can use it to print fatal error 469 * Returns a fatal error stream. You can use it to print fatal error
470 * information. 470 * information.
471 * @param area an id to identify the output, 0 for default 471 * @param area an id to identify the output, 0 for default
472 */ 472 */
473odbgstream odFatal(int area = 0); 473odbgstream odFatal(int area = 0);
474odbgstream odFatal(bool cond, int area = 0); 474odbgstream odFatal(bool cond, int area = 0);
475 475
476/** 476/**
477 * Deletes the odebugrc cache and therefore forces KDebug to reread the 477 * Deletes the odebugrc cache and therefore forces KDebug to reread the
478 * config file 478 * config file
479 */ 479 */
480void odClearDebugConfig(); 480void odClearDebugConfig();
481 481
482#ifdef OPIE_NO_DEBUG 482#ifdef OPIE_NO_DEBUG
483#define odDebug ondDebug 483#define odDebug ondDebug
484#define odBacktrace ondBacktrace 484#define odBacktrace ondBacktrace
485#endif 485#endif
486 486
487} 487}
488} 488}
489 489
490#endif 490#endif
491 491
diff --git a/libopie2/opiecore/okeyconfigmanager.cpp b/libopie2/opiecore/okeyconfigmanager.cpp
index 891cda7..48546bd 100644
--- a/libopie2/opiecore/okeyconfigmanager.cpp
+++ b/libopie2/opiecore/okeyconfigmanager.cpp
@@ -1,356 +1,356 @@
1#include "okeyconfigmanager.h" 1#include "okeyconfigmanager.h"
2 2
3#include "okeyconfigmanager_p.h" 3#include "okeyconfigmanager_p.h"
4 4
5namespace Opie { 5namespace Opie {
6namespace Core { 6namespace Core {
7namespace Internal { 7namespace Internal {
8 /* 8 /*
9 * the virtual and hardware key events have both issues... 9 * the virtual and hardware key events have both issues...
10 */ 10 */
11 void fixupKeys( int& key, int &mod, QKeyEvent* e ) { 11 void fixupKeys( int& key, int &mod, QKeyEvent* e ) {
12 key = e->key(); 12 key = e->key();
13 mod = e->state(); 13 mod = e->state();
14 /* 14 /*
15 * virtual keyboard 15 * virtual keyboard
16 * else change the button mod only 16 * else change the button mod only
17 */ 17 */
18 if ( key == 0 ) { 18 if ( key == 0 ) {
19 key = e->ascii(); 19 key = e->ascii();
20 if ( key > 96 && key < 123) 20 if ( key > 96 && key < 123)
21 key -= 32; 21 key -= 32;
22 }else{ 22 }else{
23 int new_mod = 0; 23 int new_mod = 0;
24 if ( mod & 256 ) 24 if ( mod & 256 )
25 new_mod |= Qt::ShiftButton; 25 new_mod |= Qt::ShiftButton;
26 else if ( mod & 512 ) 26 else if ( mod & 512 )
27 new_mod |= Qt::ControlButton; 27 new_mod |= Qt::ControlButton;
28 else if ( mod & 1024 ) 28 else if ( mod & 1024 )
29 new_mod |= Qt::AltButton; 29 new_mod |= Qt::AltButton;
30 30
31 mod = new_mod == 0? mod : new_mod; 31 mod = new_mod == 0? mod : new_mod;
32 } 32 }
33 } 33 }
34} 34}
35 35
36/** 36/**
37 * The default Constructor of a OKeyPair. 37 * The default Constructor of a OKeyPair.
38 * A Key and a Modifier ( Alt/Shift/Ctrl ) 38 * A Key and a Modifier ( Alt/Shift/Ctrl )
39 * needs to be supplied. 39 * needs to be supplied.
40 * Use Qt::Key for the information. 40 * Use Qt::Key for the information.
41 * The default arguments create an Empty OKeyPair. If you 41 * The default arguments create an Empty OKeyPair. If you
42 * want to get an empty OKeyPair use the static method for getting 42 * want to get an empty OKeyPair use the static method for getting
43 * the emptyKey() 43 * the emptyKey()
44 * 44 *
45 * @see OKeyPair OKeyPair::emptyKey() 45 * @see OKeyPair OKeyPair::emptyKey()
46 */ 46 */
47OKeyPair::OKeyPair( int key, int mod ) 47OKeyPair::OKeyPair( int key, int mod )
48 : m_key( key ), m_mod( mod ) 48 : m_key( key ), m_mod( mod )
49{} 49{}
50 50
51/** 51/**
52 * The destructor 52 * The destructor
53 */ 53 */
54OKeyPair::~OKeyPair() {} 54OKeyPair::~OKeyPair() {}
55 55
56 56
57/** 57/**
58 * Is this OKeyPair empty/valid? 58 * Is this OKeyPair empty/valid?
59 */ 59 */
60bool OKeyPair::isEmpty()const { 60bool OKeyPair::isEmpty()const {
61 return ( ( m_key == -1 )&& ( m_mod == -1 ) ); 61 return ( ( m_key == -1 )&& ( m_mod == -1 ) );
62} 62}
63 63
64/** 64/**
65 * get the keycode for this OKeyPair. The Key relates to Qt::Key. 65 * get the keycode for this OKeyPair. The Key relates to Qt::Key.
66 * 66 *
67 * @see Qt::Key 67 * @see Qt::Key
68 * @see setKey 68 * @see setKey
69 */ 69 */
70int OKeyPair::keycode()const { 70int OKeyPair::keycode()const {
71 return m_key; 71 return m_key;
72} 72}
73 73
74/** 74/**
75 * get the modifier key for this OKeyPair. The Modifier State relates 75 * get the modifier key for this OKeyPair. The Modifier State relates
76 * to the Qt::ButtonState 76 * to the Qt::ButtonState
77 * 77 *
78 * @see Qt::ButtonState 78 * @see Qt::ButtonState
79 * @see setModifier 79 * @see setModifier
80 */ 80 */
81int OKeyPair::modifier()const { 81int OKeyPair::modifier()const {
82 return m_mod; 82 return m_mod;
83} 83}
84 84
85 85
86/** 86/**
87 * Set the keycode 87 * Set the keycode
88 * @param key The Keycode to set 88 * @param key The Keycode to set
89 * 89 *
90 * @see keycode() 90 * @see keycode()
91 * @see Qt::Key 91 * @see Qt::Key
92 */ 92 */
93void OKeyPair::setKeycode( int key ) { 93void OKeyPair::setKeycode( int key ) {
94 m_key = key; 94 m_key = key;
95} 95}
96 96
97/** 97/**
98 * Set the modifier key 98 * Set the modifier key
99 * 99 *
100 * @param the Modifier key 100 * @param mod the Modifier key
101 * @see Qt::ButtonState 101 * @see Qt::ButtonState
102 * @see modifier() 102 * @see modifier()
103 */ 103 */
104void OKeyPair::setModifier( int mod ) { 104void OKeyPair::setModifier( int mod ) {
105 m_mod = mod; 105 m_mod = mod;
106} 106}
107 107
108/** 108/**
109 * Return an OKeyPair for the Return Key without any modifier. 109 * Return an OKeyPair for the Return Key without any modifier.
110 */ 110 */
111OKeyPair OKeyPair::returnKey() { 111OKeyPair OKeyPair::returnKey() {
112 return OKeyPair( Qt::Key_Return, 0 ); 112 return OKeyPair( Qt::Key_Return, 0 );
113} 113}
114 114
115/** 115/**
116 * Return an OKeyPair for the Left Arrow Key 116 * Return an OKeyPair for the Left Arrow Key
117 * without any modifier Key 117 * without any modifier Key
118 */ 118 */
119OKeyPair OKeyPair::leftArrowKey() { 119OKeyPair OKeyPair::leftArrowKey() {
120 return OKeyPair( Qt::Key_Left, 0 ); 120 return OKeyPair( Qt::Key_Left, 0 );
121} 121}
122 122
123/** 123/**
124 * Return an OKeyPair for the Right Arrow Key 124 * Return an OKeyPair for the Right Arrow Key
125 * without any modifier Key 125 * without any modifier Key
126 */ 126 */
127OKeyPair OKeyPair::rightArrowKey() { 127OKeyPair OKeyPair::rightArrowKey() {
128 return OKeyPair( Qt::Key_Right, 0 ); 128 return OKeyPair( Qt::Key_Right, 0 );
129} 129}
130 130
131/** 131/**
132 * Return an OKeyPair for the Up Arrow Key 132 * Return an OKeyPair for the Up Arrow Key
133 * without any modifier Key 133 * without any modifier Key
134 */ 134 */
135OKeyPair OKeyPair::upArrowKey() { 135OKeyPair OKeyPair::upArrowKey() {
136 return OKeyPair( Qt::Key_Up, 0 ); 136 return OKeyPair( Qt::Key_Up, 0 );
137} 137}
138 138
139/** 139/**
140 * Return an OKeyPair for the Down Arrow Key 140 * Return an OKeyPair for the Down Arrow Key
141 * without any modifier Key 141 * without any modifier Key
142 */ 142 */
143OKeyPair OKeyPair::downArrowKey() { 143OKeyPair OKeyPair::downArrowKey() {
144 return OKeyPair( Qt::Key_Down, 0 ); 144 return OKeyPair( Qt::Key_Down, 0 );
145} 145}
146 146
147/** 147/**
148 * Return an Empty OKeyPair 148 * Return an Empty OKeyPair
149 */ 149 */
150OKeyPair OKeyPair::emptyKey() { 150OKeyPair OKeyPair::emptyKey() {
151 return OKeyPair(); 151 return OKeyPair();
152} 152}
153 153
154/** 154/**
155 * This functions uses the Opie::Core::ODevice::buttons 155 * This functions uses the Opie::Core::ODevice::buttons
156 * for OKeyPairList 156 * for OKeyPairList
157 * 157 *
158 * @see Opie::Core::ODevice 158 * @see Opie::Core::ODevice
159 * @see Opie::Core::ODeviceButton 159 * @see Opie::Core::ODeviceButton
160 * @see Opie::Core::ODevice::button 160 * @see Opie::Core::ODevice::button
161 */ 161 */
162OKeyPair::List OKeyPair::hardwareKeys() { 162OKeyPair::List OKeyPair::hardwareKeys() {
163 const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons(); 163 const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons();
164 OKeyPair::List lst; 164 OKeyPair::List lst;
165 165
166 for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin(); 166 for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin();
167 it != but.end(); ++it ) 167 it != but.end(); ++it )
168 lst.append( OKeyPair( (*it).keycode(), 0 ) ); 168 lst.append( OKeyPair( (*it).keycode(), 0 ) );
169 169
170 170
171 return lst; 171 return lst;
172} 172}
173 173
174/** 174/**
175 * Equals operator. Check if two OKeyPairs have the same key and modifier 175 * Equals operator. Check if two OKeyPairs have the same key and modifier
176 * @see operator!= 176 * @see operator!=
177 */ 177 */
178bool OKeyPair::operator==( const OKeyPair& pair)const { 178bool OKeyPair::operator==( const OKeyPair& pair)const {
179 if ( m_key != pair.m_key ) return false; 179 if ( m_key != pair.m_key ) return false;
180 if ( m_mod != pair.m_mod ) return false; 180 if ( m_mod != pair.m_mod ) return false;
181 181
182 return true; 182 return true;
183} 183}
184 184
185/** 185/**
186 * Not equal operator. calls the equal operator internally 186 * Not equal operator. calls the equal operator internally
187 */ 187 */
188bool OKeyPair::operator!=( const OKeyPair& pair)const { 188bool OKeyPair::operator!=( const OKeyPair& pair)const {
189 return !(*this == pair); 189 return !(*this == pair);
190} 190}
191 191
192 192
193/** 193/**
194 * The normal Constructor to create a OKeyConfigItem 194 * The normal Constructor to create a OKeyConfigItem
195 * 195 *
196 * You can set the the key paramater of this item but if 196 * You can set the the key paramater of this item but if
197 * you use this item with the OKeyConfigManager your setting 197 * you use this item with the OKeyConfigManager your setting
198 * will be overwritten. 198 * will be overwritten.
199 * You can also specify a QObject and slot which sould get called 199 * You can also specify a QObject and slot which sould get called
200 * once this item is activated. This slot only works if you 200 * once this item is activated. This slot only works if you
201 * use the OKeyConfigManager. 201 * use the OKeyConfigManager.
202 * The actual Key is read by load() 202 * The actual Key is read by load()
203 * 203 *
204 * \code 204 * \code
205 * void MySlot::create(){ 205 * void MySlot::create(){
206 * OKeyConfigItem item(tr("Delete"),"delete",Resource::loadPixmap("trash"), 206 * OKeyConfigItem item(tr("Delete"),"delete",Resource::loadPixmap("trash"),
207 * 123, OKeyPair(Qt::Key_D,Qt::ControlButton), 207 * 123, OKeyPair(Qt::Key_D,Qt::ControlButton),
208 * this,SLOT(slotDelete(QWidget*,QKeyEvent*))); 208 * this,SLOT(slotDelete(QWidget*,QKeyEvent*)));
209 * } 209 * }
210 * \endcode 210 * \endcode
211 * 211 *
212 * @param text The text exposed to the user 212 * @param text The text exposed to the user
213 * @param config_key The key used in the config 213 * @param config_key The key used in the config
214 * @param pix A Pixmap associated with this Item 214 * @param pix A Pixmap associated with this Item
215 * @param def The OKeyPair used as default 215 * @param def The OKeyPair used as default
216 * @param caller The object where the slot exists 216 * @param caller The object where the slot exists
217 * @param slot The slot which should get called 217 * @param slot The slot which should get called
218 * 218 *
219 */ 219 */
220OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key, 220OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key,
221 const QPixmap& pix, int id, const OKeyPair& def, 221 const QPixmap& pix, int id, const OKeyPair& def,
222 QObject *caller, 222 QObject *caller,
223 const char* slot ) 223 const char* slot )
224 : m_text( text ), m_config( config_key ), m_pix( pix ), 224 : m_text( text ), m_config( config_key ), m_pix( pix ),
225 m_id( id ), m_def( def ), 225 m_id( id ), m_def( def ),
226 m_obj( caller ), m_str( slot ) {} 226 m_obj( caller ), m_str( slot ) {}
227 227
228/** 228/**
229 * A special Constructor for converting from an Opie::Core::ODeviceButton 229 * A special Constructor for converting from an Opie::Core::ODeviceButton
230 * delivered by Opie::Core::ODevice::buttons() 230 * delivered by Opie::Core::ODevice::buttons()
231 * There is no Config Key set and both default key and key are set 231 * There is no Config Key set and both default key and key are set
232 * to Opie::Core::ODeviceButton::keycode() and 0 to modifier 232 * to Opie::Core::ODeviceButton::keycode() and 0 to modifier
233 * 233 *
234 * @see Opie::Core::ODevice 234 * @see Opie::Core::ODevice
235 * @see Opie::Core::ODeviceButton 235 * @see Opie::Core::ODeviceButton
236 * @see Opie::Core::ODevice::buttons() 236 * @see Opie::Core::ODevice::buttons()
237 */ 237 */
238OKeyConfigItem::OKeyConfigItem( const Opie::Core::ODeviceButton& b ) 238OKeyConfigItem::OKeyConfigItem( const Opie::Core::ODeviceButton& b )
239 : m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ), 239 : m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ),
240 m_key( OKeyPair( b.keycode(), 0 ) ), m_def( OKeyPair( b.keycode(), 0 ) ) 240 m_key( OKeyPair( b.keycode(), 0 ) ), m_def( OKeyPair( b.keycode(), 0 ) )
241{} 241{}
242 242
243 243
244/** 244/**
245 * Destructor 245 * Destructor
246 */ 246 */
247OKeyConfigItem::~OKeyConfigItem() {} 247OKeyConfigItem::~OKeyConfigItem() {}
248 248
249 249
250/** 250/**
251 * The text exposed to the user 251 * The text exposed to the user
252 * 252 *
253 * @see setText 253 * @see setText
254 */ 254 */
255QString OKeyConfigItem::text()const { 255QString OKeyConfigItem::text()const {
256 return m_text; 256 return m_text;
257} 257}
258 258
259/** 259/**
260 * The pixmap shown to the user for your action/key 260 * The pixmap shown to the user for your action/key
261 * 261 *
262 * @see setPixmap 262 * @see setPixmap
263 */ 263 */
264QPixmap OKeyConfigItem::pixmap()const { 264QPixmap OKeyConfigItem::pixmap()const {
265 return m_pix; 265 return m_pix;
266} 266}
267 267
268/** 268/**
269 * Return the OKeyPair this OKeyConfigItem is configured for. 269 * Return the OKeyPair this OKeyConfigItem is configured for.
270 * 270 *
271 * @see setKeyPair 271 * @see setKeyPair
272 */ 272 */
273OKeyPair OKeyConfigItem::keyPair()const { 273OKeyPair OKeyConfigItem::keyPair()const {
274 return m_key; 274 return m_key;
275} 275}
276 276
277/** 277/**
278 * Return the default OKeyPair 278 * Return the default OKeyPair
279 * @see setDefaultKeyPair 279 * @see setDefaultKeyPair
280 */ 280 */
281OKeyPair OKeyConfigItem::defaultKeyPair()const { 281OKeyPair OKeyConfigItem::defaultKeyPair()const {
282 return m_def; 282 return m_def;
283} 283}
284 284
285 285
286/** 286/**
287 * Return the Id you assigned to this item. 287 * Return the Id you assigned to this item.
288 * setting is only possible by the constructor 288 * setting is only possible by the constructor
289 */ 289 */
290int OKeyConfigItem::id()const{ 290int OKeyConfigItem::id()const{
291 return m_id; 291 return m_id;
292} 292}
293 293
294/** 294/**
295 * reutrn the Config Key. Setting it is only possible 295 * reutrn the Config Key. Setting it is only possible
296 * by the constructor 296 * by the constructor
297 */ 297 */
298QCString OKeyConfigItem::configKey()const { 298QCString OKeyConfigItem::configKey()const {
299 return m_config; 299 return m_config;
300} 300}
301 301
302/** 302/**
303 * @internal 303 * @internal
304 */ 304 */
305QObject* OKeyConfigItem::object()const{ 305QObject* OKeyConfigItem::object()const{
306 return m_obj; 306 return m_obj;
307} 307}
308 308
309/** 309/**
310 * @internal 310 * @internal
311 */ 311 */
312QCString OKeyConfigItem::slot()const { 312QCString OKeyConfigItem::slot()const {
313 return m_str; 313 return m_str;
314} 314}
315 315
316/** 316/**
317 * Set the text 317 * Set the text
318 * 318 *
319 * @param text Set the Text of this Action to text 319 * @param text Set the Text of this Action to text
320 * @see text() 320 * @see text()
321 */ 321 */
322void OKeyConfigItem::setText( const QString& text ) { 322void OKeyConfigItem::setText( const QString& text ) {
323 m_text = text; 323 m_text = text;
324} 324}
325 325
326/** 326/**
327 * Set the pixmap of this action 327 * Set the pixmap of this action
328 * 328 *
329 * @param pix The Pixmap to set 329 * @param pix The Pixmap to set
330 * @see pixmap() 330 * @see pixmap()
331 */ 331 */
332void OKeyConfigItem::setPixmap( const QPixmap& pix ) { 332void OKeyConfigItem::setPixmap( const QPixmap& pix ) {
333 m_pix = pix; 333 m_pix = pix;
334} 334}
335 335
336/** 336/**
337 * Set the KeyPair the OKeyConfigItem uses. 337 * Set the KeyPair the OKeyConfigItem uses.
338 * Your set Key could get overwritten if you use 338 * Your set Key could get overwritten if you use
339 * the manager or GUI to configure the key 339 * the manager or GUI to configure the key
340 * 340 *
341 * @param key Set the OKeyPair used 341 * @param key Set the OKeyPair used
342 * @see keyPair() 342 * @see keyPair()
343 */ 343 */
344void OKeyConfigItem::setKeyPair( const OKeyPair& key) { 344void OKeyConfigItem::setKeyPair( const OKeyPair& key) {
345 m_key = key; 345 m_key = key;
346} 346}
347 347
348/** 348/**
349 * Set the default KeyPair. 349 * Set the default KeyPair.
350 * 350 *
351 * @param key The default keypair 351 * @param key The default keypair
352 * @see defaultKeyPair() 352 * @see defaultKeyPair()
353 */ 353 */
354void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) { 354void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) {
355 m_def = key; 355 m_def = key;
356} 356}
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h
index d183641..1871247 100644
--- a/libopie2/opiecore/okeyfilter.h
+++ b/libopie2/opiecore/okeyfilter.h
@@ -1,100 +1,100 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> 3 =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org>
4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .>+-= 5 .>+-=
6_;:, .> :=|. This program is free software; you can 6_;:, .> :=|. This program is free software; you can
7.> <`_, > . <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
9.="- .-=="i, .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10- . .-<_> .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11 ._= =} : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12 .%`+i> _;_. 12 .%`+i> _;_.
13 .i_,=:_. -<s. This program is distributed in the hope that 13 .i_,=:_. -<s. This program is distributed in the hope that
14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15 : .. .:, . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.= = ; Library General Public License for more 18..}^=.= = ; Library General Public License for more
19++= -. .` .: details. 19++= -. .` .: details.
20: = ...= . :.=- 20: = ...= . :.=-
21-. .:....=;==+<; You should have received a copy of the GNU 21-. .:....=;==+<; You should have received a copy of the GNU
22 -_. . . )=. = Library General Public License along with 22 -_. . . )=. = Library General Public License along with
23 -- :-=` this library; see the file COPYING.LIB. 23 -- :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29/* QT */ 29/* QT */
30#include <qwindowsystem_qws.h> 30#include <qwindowsystem_qws.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32 32
33namespace Opie { 33namespace Opie {
34namespace Core { 34namespace Core {
35 class ODevice; 35 class ODevice;
36 36
37 37
38/** 38/**
39 * A singleton which will manage all possible keyboard filters inside opie. 39 * A singleton which will manage all possible keyboard filters inside opie.
40 * It makes sure that key handlers of odevice are checked first than the 40 * It makes sure that key handlers of odevice are checked first than the
41 * keyfilters of software. 41 * keyfilters of software.
42 * @short a keyfilter proxy 42 * @short a keyfilter proxy
43 * @see QWSServer::KeyboardFilter 43 * @see QWSServer::KeyboardFilter
44 * @author Rajko Albrecht 44 * @author Rajko Albrecht
45 * @version 1.0 45 * @version 1.0
46 */ 46 */
47class OKeyFilter 47class OKeyFilter
48{ 48{
49 friend class Opie::Core::ODevice; 49 friend class Opie::Core::ODevice;
50 50
51protected: 51protected:
52 /** 52 /**
53 * Protected constructor - generate class via inst() 53 * Protected constructor - generate class via inst()
54 * @see inst() 54 * @see inst()
55 */ 55 */
56 OKeyFilter(); 56 OKeyFilter();
57 /** 57 /**
58 * Protected constructor - generate class via inst() 58 * Protected constructor - generate class via inst()
59 * @see inst() 59 * @see inst()
60 */ 60 */
61 OKeyFilter(const OKeyFilter&){}; 61 OKeyFilter(const OKeyFilter&){};
62 /** 62 /**
63 * Append filter to the primary list. 63 * Append filter to the primary list.
64 * This is only allowed for friend classes from odevice 64 * This is only allowed for friend classes from odevice
65 * @param aFilter a filter to append 65 * @param aFilter a filter to append
66 * @see addHandler 66 * @see addHandler
67 */ 67 */
68 virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0; 68 virtual void addPreHandler(QWSServer::KeyboardFilter *aFilter)=0;
69 /** 69 /**
70 * Remove the specified filter from list and give back ownership. 70 * Remove the specified filter from list and give back ownership.
71 * This is only allowed for friend classes from odevice 71 * This is only allowed for friend classes from odevice
72 * @param aFilter a filter to remove 72 * @param aFilter a filter to remove
73 * @see remHandler 73 * @see remHandler
74 */ 74 */
75 virtual void remPreHandler(QWSServer::KeyboardFilter*aFilter)=0; 75 virtual void remPreHandler(QWSServer::KeyboardFilter *aFilter)=0;
76 76
77public: 77public:
78 virtual ~OKeyFilter(); 78 virtual ~OKeyFilter();
79 /** 79 /**
80 * Append filter to the secondary list. 80 * Append filter to the secondary list.
81 * @param aFilter a filter to append 81 * @param aFilter a filter to append
82 * @see addPreHandler 82 * @see addPreHandler
83 */ 83 */
84 virtual void addHandler(QWSServer::KeyboardFilter*)=0; 84 virtual void addHandler(QWSServer::KeyboardFilter *aFilter)=0;
85 /** 85 /**
86 * Remove the specified filter from list and give back ownership. 86 * Remove the specified filter from list and give back ownership.
87 * @param aFilter a filter to remove 87 * @param aFilter a filter to remove
88 * @see remPreHandler 88 * @see remPreHandler
89 */ 89 */
90 virtual void remHandler(QWSServer::KeyboardFilter*)=0; 90 virtual void remHandler(QWSServer::KeyboardFilter *aFilter)=0;
91 91
92 /** 92 /**
93 * Returns a handler to an instance of OKeyFilter 93 * Returns a handler to an instance of OKeyFilter
94 * @return a pointer to a working OKeyFilter 94 * @return a pointer to a working OKeyFilter
95 */ 95 */
96 static OKeyFilter*inst(); 96 static OKeyFilter*inst();
97}; 97};
98 98
99} 99}
100} 100}
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index ec19fa0..2a6e369 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -270,637 +270,636 @@ void OPluginItem::setPosition( int pos ) {
270 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 270 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
271 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 271 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
272 * } 272 * }
273 * ... 273 * ...
274 * loader.clear(); 274 * loader.clear();
275 * 275 *
276 * \endcode 276 * \endcode
277 * 277 *
278 * @param name The name of the plugin directory. 278 * @param name The name of the plugin directory.
279 * @param isSorted Tell the PluginLoader if your Plugins are sorted 279 * @param isSorted Tell the PluginLoader if your Plugins are sorted
280 */ 280 */
281OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted) 281OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted)
282 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ), 282 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ),
283 m_isSorted( isSorted ) 283 m_isSorted( isSorted )
284{ 284{
285 setPluginDir( QPEApplication::qpeDir() + "plugins/"+name ); 285 setPluginDir( QPEApplication::qpeDir() + "plugins/"+name );
286 readConfig(); 286 readConfig();
287} 287}
288 288
289 289
290/** 290/**
291 * \brief simple d'tor that cleans up depending on autoDelete 291 * \brief simple d'tor that cleans up depending on autoDelete
292 * 292 *
293 * calls clear if autoDelete is true. This will release all interfaces 293 * calls clear if autoDelete is true. This will release all interfaces
294 * and remove the library from this process if the refcount falls to zero 294 * and remove the library from this process if the refcount falls to zero
295 */ 295 */
296OGenericPluginLoader::~OGenericPluginLoader() { 296OGenericPluginLoader::~OGenericPluginLoader() {
297 if ( m_autoDelete ) 297 if ( m_autoDelete )
298 clear(); 298 clear();
299} 299}
300 300
301/** 301/**
302 * \brief Enable or disable autoDelete on destruction 302 * \brief Enable or disable autoDelete on destruction
303 * 303 *
304 * enable autoDelete. This will call clear on the d'tor 304 * enable autoDelete. This will call clear on the d'tor
305 * 305 *
306 * @see ~OGenericPluginLoader 306 * @see ~OGenericPluginLoader
307 * @see clear() 307 * @see clear()
308 */ 308 */
309void OGenericPluginLoader::setAutoDelete( bool t ) { 309void OGenericPluginLoader::setAutoDelete( bool t ) {
310 m_autoDelete = t; 310 m_autoDelete = t;
311} 311}
312 312
313/** 313/**
314 * \brief See if autoDelete is enabled. 314 * \brief See if autoDelete is enabled.
315 */ 315 */
316bool OGenericPluginLoader::autoDelete()const{ 316bool OGenericPluginLoader::autoDelete()const{
317 return m_autoDelete; 317 return m_autoDelete;
318} 318}
319 319
320/** 320/**
321 * \brief unload all loaded Plugins 321 * \brief unload all loaded Plugins
322 * 322 *
323 * This will unload all returned QUnknownInterfaces by load. Unload 323 * This will unload all returned QUnknownInterfaces by load. Unload
324 * will be called. 324 * will be called.
325 */ 325 */
326void OGenericPluginLoader::clear() { 326void OGenericPluginLoader::clear() {
327 QPtrDictIterator<QLibrary> it( m_library ); 327 QPtrDictIterator<QLibrary> it( m_library );
328 for ( ;it.current(); ) 328 for ( ;it.current(); )
329 unload( static_cast<QUnknownInterface*>( it.currentKey() ) ); 329 unload( static_cast<QUnknownInterface*>( it.currentKey() ) );
330} 330}
331 331
332/** 332/**
333 * \brief unload the Plugin and the accompanied Resources. 333 * \brief unload the Plugin and the accompanied Resources.
334 * 334 *
335 * This will take the iface from the internal QPtrDict, Release it, 335 * This will take the iface from the internal QPtrDict, Release it,
336 * and deref the libray used. 336 * and deref the libray used.
337 * The visibility depends on the QPtrDict. 337 * The visibility depends on the QPtrDict.
338 * @see QPtrDict::insert 338 * @see QPtrDict::insert
339 */ 339 */
340void OGenericPluginLoader::unload( QUnknownInterface* iface ) { 340void OGenericPluginLoader::unload( QUnknownInterface* iface ) {
341 if ( !iface ) 341 if ( !iface )
342 return; 342 return;
343 343
344 iface->release(); 344 iface->release();
345 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) ); 345 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) );
346} 346}
347 347
348/** 348/**
349 * \brief The name of the plugins. 349 * \brief The name of the plugins.
350 * 350 *
351 * Return the name/type you specified in the constructor. 351 * Return the name/type you specified in the constructor.
352 * This is at least used by the OPluginManager to find the right config 352 * This is at least used by the OPluginManager to find the right config
353 */ 353 */
354QString OGenericPluginLoader::name()const { 354QString OGenericPluginLoader::name()const {
355 return m_dir; 355 return m_dir;
356} 356}
357 357
358 358
359/** 359/**
360 * \brief See if loading of a plugin segfaulted 360 * \brief See if loading of a plugin segfaulted
361 * This tells you 361 * This tells you
362 * if by previous tries to load, loading crashed your application. 362 * if by previous tries to load, loading crashed your application.
363 * If isInSafeMode you can use the GUI to configure the plugins prior to loading 363 * If isInSafeMode you can use the GUI to configure the plugins prior to loading
364 * 364 *
365 * @return true if prior loading failed 365 * @return true if prior loading failed
366 */ 366 */
367bool OGenericPluginLoader::isInSafeMode()const { 367bool OGenericPluginLoader::isInSafeMode()const {
368 return m_isSafeMode; 368 return m_isSafeMode;
369} 369}
370 370
371 371
372/** 372/**
373 * \brief Return all Plugins found in the plugins dirs. 373 * \brief Return all Plugins found in the plugins dirs.
374 * Return the list of all available plugins. This will go through all plugin 374 * Return the list of all available plugins. This will go through all plugin
375 * directories and search for your type of plugins ( by subdir ) 375 * directories and search for your type of plugins ( by subdir )
376 * 376 *
377 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you 377 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you
378 */ 378 */
379OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { 379OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const {
380 OPluginItem::List lst; 380 OPluginItem::List lst;
381 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 381 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
382 lst += plugins( *it, sorted, false ); 382 lst += plugins( *it, sorted, false );
383 383
384 if ( sorted ) 384 if ( sorted )
385 qHeapSort( lst ); 385 qHeapSort( lst );
386 return lst; 386 return lst;
387} 387}
388 388
389/** 389/**
390 * \brief Return only the enabled plugins 390 * \brief Return only the enabled plugins
391 * Return only activated plugins. 391 * Return only activated plugins.
392 * 392 *
393 * @param sorted If the list should be sorted 393 * @param sorted If the list should be sorted
394 */ 394 */
395OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { 395OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const {
396 OPluginItem::List lst; 396 OPluginItem::List lst;
397 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 397 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
398 lst += plugins( *it, sorted, true ); 398 lst += plugins( *it, sorted, true );
399 399
400 if ( sorted ) 400 if ( sorted )
401 qHeapSort( lst ); 401 qHeapSort( lst );
402 return lst; 402 return lst;
403} 403}
404 404
405 405
406/** 406/**
407 * \brief Load a OPluginItem for the specified interface 407 * \brief Load a OPluginItem for the specified interface
408 * This will open the resource of the OPluginItem::path() and then will query 408 * This will open the resource of the OPluginItem::path() and then will query
409 * if the Interface specified in the uuid is available and then will manage the 409 * if the Interface specified in the uuid is available and then will manage the
410 * resource and Interface. 410 * resource and Interface.
411 * 411 *
412 * @param item The OPluginItem that should be loaded 412 * @param item The OPluginItem that should be loaded
413 * @param uuid The Interface to query for 413 * @param uuid The Interface to query for
414 * 414 *
415 * @return Either 0 in case of failure or the Plugin as QUnknownInterface* 415 * @return Either 0 in case of failure or the Plugin as QUnknownInterface*
416 */ 416 */
417QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { 417QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
418 /* 418 /*
419 * Check if there could be a library 419 * Check if there could be a library
420 */ 420 */
421 QString pa = item.path(); 421 QString pa = item.path();
422 if ( pa.isEmpty() ) 422 if ( pa.isEmpty() )
423 return 0l; 423 return 0l;
424 424
425 /* 425 /*
426 * See if we get a library 426 * See if we get a library
427 * return if we've none 427 * return if we've none
428 */ 428 */
429 setSafeMode( pa, true ); 429 setSafeMode( pa, true );
430 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); 430 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
431 if ( !lib ) { 431 if ( !lib ) {
432 setSafeMode(); 432 setSafeMode();
433 return 0l; 433 return 0l;
434 } 434 }
435 435
436 /** 436 /**
437 * try to load the plugin and just in case initialize the pointer to a pointer again 437 * try to load the plugin and just in case initialize the pointer to a pointer again
438 */ 438 */
439 QUnknownInterface* iface=0; 439 QUnknownInterface* iface=0;
440 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { 440 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) {
441 installTranslators( item.name() ); 441 installTranslators( item.name() );
442 m_library.insert( iface, lib ); 442 m_library.insert( iface, lib );
443 }else 443 }else
444 iface = 0; 444 iface = 0;
445 445
446 setSafeMode(); 446 setSafeMode();
447 447
448 return iface; 448 return iface;
449} 449}
450 450
451/** 451/**
452 * @internal and reads in the safe mode 452 * @internal and reads in the safe mode
453 */ 453 */
454void OGenericPluginLoader::readConfig() { 454void OGenericPluginLoader::readConfig() {
455 455
456 456
457/* read the config for SafeMode */ 457/* read the config for SafeMode */
458 OConfig conf( m_dir + "-odpplugins" ); 458 OConfig conf( m_dir + "-odpplugins" );
459 conf.setGroup( "General" ); 459 conf.setGroup( "General" );
460 m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); 460 m_isSafeMode = conf.readBoolEntry( "SafeMode", false );
461} 461}
462 462
463/** 463/**
464 * @internal Enter or leave SafeMode 464 * @internal Enter or leave SafeMode
465 */ 465 */
466void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { 466void OGenericPluginLoader::setSafeMode(const QString& str, bool b) {
467 OConfig conf( m_dir + "-odpplugins" ); 467 OConfig conf( m_dir + "-odpplugins" );
468 conf.setGroup( "General" ); 468 conf.setGroup( "General" );
469 conf.writeEntry( "SafeMode", b ); 469 conf.writeEntry( "SafeMode", b );
470 conf.writeEntry( "CrashedPlugin", str ); 470 conf.writeEntry( "CrashedPlugin", str );
471} 471}
472 472
473/** 473/**
474 * @internal 474 * @internal
475 * 475 *
476 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype 476 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype
477 * is used as plugin dir 477 * is used as plugin dir
478 */ 478 */
479void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { 479void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) {
480 m_plugDirs = lst; 480 m_plugDirs = lst;
481} 481}
482 482
483/** 483/**
484 * 484 *
485 * @internal 485 * @internal
486 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs 486 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs
487 */ 487 */
488void OGenericPluginLoader::setPluginDir( const QString& str) { 488void OGenericPluginLoader::setPluginDir( const QString& str) {
489 m_plugDirs.clear(); 489 m_plugDirs.clear();
490 m_plugDirs.append( str ); 490 m_plugDirs.append( str );
491} 491}
492 492
493 493
494/** 494/**
495 * @internal 495 * @internal
496 */ 496 */
497bool OGenericPluginLoader::isSorted()const{ 497bool OGenericPluginLoader::isSorted()const{
498 return m_isSorted; 498 return m_isSorted;
499} 499}
500 500
501/* 501/*
502 * make libfoo.so.1.0.0 -> foo on UNIX 502 * make libfoo.so.1.0.0 -> foo on UNIX
503 * make libfoo.dylib -> foo on MAC OS X Unix 503 * make libfoo.dylib -> foo on MAC OS X Unix
504 * windows is obviously missing 504 * windows is obviously missing
505 */ 505 */
506/** 506/**
507 * @internal 507 * @internal
508 */ 508 */
509QString OGenericPluginLoader::unlibify( const QString& str ) { 509QString OGenericPluginLoader::unlibify( const QString& str ) {
510 QString st = str.mid( str.find( "lib" )+3 ); 510 QString st = str.mid( str.find( "lib" )+3 );
511#ifdef Q_OS_MACX 511#ifdef Q_OS_MACX
512 return st.left( st.findRev( ".dylib" ) ); 512 return st.left( st.findRev( ".dylib" ) );
513#else 513#else
514 return st.left( st.findRev( ".so" ) ); 514 return st.left( st.findRev( ".so" ) );
515#endif 515#endif
516} 516}
517 517
518/** 518/**
519 * @internal 519 * @internal
520 * 520 *
521 * \brief method to return available plugins. Internal and for reeimplementations 521 * \brief method to return available plugins. Internal and for reeimplementations
522 * 522 *
523 *Return a List of Plugins for a dir and add positions and remove disabled. 523 *Return a List of Plugins for a dir and add positions and remove disabled.
524 * If a plugin is on the excluded list assign position -2 524 * If a plugin is on the excluded list assign position -2
525 * 525 *
526 * @param dir The dir to look in 526 * @param _dir The dir to look in
527 * @param sorted Should positions be read? 527 * @param sorted Should positions be read?
528 * @param disabled Remove excluded from the list 528 * @param disabled Remove excluded from the list
529 */ 529 */
530OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { 530OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
531#ifdef Q_OS_MACX 531#ifdef Q_OS_MACX
532 QDir dir( _dir, "lib*.dylib" ); 532 QDir dir( _dir, "lib*.dylib" );
533#else 533#else
534 QDir dir( _dir, "lib*.so" ); 534 QDir dir( _dir, "lib*.so" );
535#endif 535#endif
536 536
537 537
538 OPluginItem::List lst; 538 OPluginItem::List lst;
539 539
540 /* 540 /*
541 * get excluded list and then iterate over them 541 * get excluded list and then iterate over them
542 * Excluded list contains the name 542 * Excluded list contains the name
543 * Position is a list with 'name.pos.name.pos.name.pos' 543 * Position is a list with 'name.pos.name.pos.name.pos'
544 * 544 *
545 * For the look up we will create two QMap<QString,pos> 545 * For the look up we will create two QMap<QString,pos>
546 */ 546 */
547 QMap<QString, int> positionMap; 547 QMap<QString, int> positionMap;
548 QMap<QString, int> excludedMap; 548 QMap<QString, int> excludedMap;
549 549
550 550
551 OConfig cfg( m_dir+"-odpplugins" ); 551 OConfig cfg( m_dir+"-odpplugins" );
552 cfg.setGroup( _dir ); 552 cfg.setGroup( _dir );
553 553
554 554
555 QStringList excludes = cfg.readListEntry( "Excluded", ',' ); 555 QStringList excludes = cfg.readListEntry( "Excluded", ',' );
556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) 556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
557 excludedMap.insert( *it, -2 ); 557 excludedMap.insert( *it, -2 );
558 558
559 if ( sorted ) { 559 if ( sorted ) {
560 QStringList pos = cfg.readListEntry( "Positions", '.' ); 560 QStringList pos = cfg.readListEntry( "Positions", '.' );
561 QStringList::Iterator it = pos.begin(); 561 QStringList::Iterator it = pos.begin();
562 QString tmp; int i; 562 QString tmp; int i;
563 while ( it != pos.end() ) { 563 while ( it != pos.end() ) {
564 tmp = *it++; i = (*it++).toInt(); 564 tmp = *it++; i = (*it++).toInt();
565 positionMap.insert( tmp, i ); 565 positionMap.insert( tmp, i );
566 } 566 }
567 567
568 } 568 }
569 569
570 570
571 571
572 572
573 QStringList list = dir.entryList(); 573 QStringList list = dir.entryList();
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QString str = unlibify( *it ); 575 QString str = unlibify( *it );
576 OPluginItem item( str, _dir + "/" + *it ); 576 OPluginItem item( str, _dir + "/" + *it );
577 577
578 bool ex = excludedMap.contains( str ); 578 bool ex = excludedMap.contains( str );
579 /* 579 /*
580 * if disabled but we should show all mark it as disabled 580 * if disabled but we should show all mark it as disabled
581 * else continue because we don't want to add the item 581 * else continue because we don't want to add the item
582 * else if sorted we assign the right position 582 * else if sorted we assign the right position
583 */ 583 */
584 if ( ex && !disabled) 584 if ( ex && !disabled)
585 item.setEnabled( false ); 585 item.setEnabled( false );
586 else if ( ex && disabled ) 586 else if ( ex && disabled )
587 continue; 587 continue;
588 else if ( sorted ) 588 else if ( sorted )
589 item.setPosition( positionMap[str] ); 589 item.setPosition( positionMap[str] );
590 590
591 591
592 lst.append( item ); 592 lst.append( item );
593 } 593 }
594 594
595 return lst; 595 return lst;
596} 596}
597 597
598/** 598/**
599 * @internal generate a list of languages from $LANG 599 * @internal generate a list of languages from $LANG
600 */ 600 */
601QStringList OGenericPluginLoader::languageList() { 601QStringList OGenericPluginLoader::languageList() {
602 if ( m_languages.isEmpty() ) { 602 if ( m_languages.isEmpty() ) {
603 /* 603 /*
604 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be 604 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
605 * to our list of languages. 605 * to our list of languages.
606 * Also for de_DE@euro we will add de_DE@eurp, de_DE, de 606 * Also for de_DE@euro we will add de_DE@eurp, de_DE, de
607 * to our list of languages 607 * to our list of languages
608 */ 608 */
609 QString str = ::getenv( "LANG" ); 609 QString str = ::getenv( "LANG" );
610 m_languages += str; 610 m_languages += str;
611 int pos = str.find( '@' ); 611 int pos = str.find( '@' );
612 if( pos > 0 ) 612 if( pos > 0 )
613 m_languages += str.left( pos ); 613 m_languages += str.left( pos );
614 614
615 615
616 pos = str.find( '.' ); 616 pos = str.find( '.' );
617 if ( pos > 0 ) 617 if ( pos > 0 )
618 m_languages += str.left( pos ); 618 m_languages += str.left( pos );
619 619
620 int n_pos = str.find( '_' ); 620 int n_pos = str.find( '_' );
621 if ( n_pos > 0 ) 621 if ( n_pos > 0 )
622 m_languages += str.left( n_pos ); 622 m_languages += str.left( n_pos );
623 623
624 } 624 }
625 return m_languages; 625 return m_languages;
626} 626}
627 627
628/** 628/**
629 * @internal 629 * @internal
630 * Tries to install languages using the languageList for the type 630 * Tries to install languages using the languageList for the type
631 */ 631 */
632void OGenericPluginLoader::installTranslators(const QString& type) { 632void OGenericPluginLoader::installTranslators(const QString& type) {
633 QStringList lst = languageList(); 633 QStringList lst = languageList();
634 634
635 /* 635 /*
636 * for each language and maybe later for each language dir... 636 * for each language and maybe later for each language dir...
637 * try to load a Translator 637 * try to load a Translator
638 */ 638 */
639 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 639 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
640 QTranslator* trans = new QTranslator( qApp ); 640 QTranslator* trans = new QTranslator( qApp );
641 QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ; 641 QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ;
642 642
643 /* 643 /*
644 * If loaded then install else clean up and don't leak 644 * If loaded then install else clean up and don't leak
645 */ 645 */
646 if ( trans->load( tfn ) ) 646 if ( trans->load( tfn ) )
647 qApp->installTranslator( trans ); 647 qApp->installTranslator( trans );
648 else 648 else
649 delete trans; 649 delete trans;
650 } 650 }
651} 651}
652 652
653/** 653/**
654 * \brief Simple c'tor. 654 * \brief Simple c'tor.
655 * 655 *
656 * Simple C'tor same as the one of the base class. Additional this 656 * Simple C'tor same as the one of the base class. Additional this
657 * class can cast for you if you nee it. 657 * class can cast for you if you nee it.
658 * 658 *
659 * 659 *
660 * @param name The name of your plugin class 660 * @param name The name of your plugin class
661 * @param sorted If plugins are sorted 661 * @param sorted If plugins are sorted
662 * 662 *
663 * @see OGenericPluginLoader 663 * @see OGenericPluginLoader
664 */ 664 */
665OPluginLoader::OPluginLoader( const QString& name, bool sorted ) 665OPluginLoader::OPluginLoader( const QString& name, bool sorted )
666 : OGenericPluginLoader( name, sorted ) 666 : OGenericPluginLoader( name, sorted )
667{ 667{
668} 668}
669 669
670/** 670/**
671 * d'tor 671 * d'tor
672 * @see OGenericPluginLoader::~OGenericPluginLoader 672 * @see OGenericPluginLoader::~OGenericPluginLoader
673 */ 673 */
674OPluginLoader::~OPluginLoader() { 674OPluginLoader::~OPluginLoader() {
675} 675}
676 676
677/** 677/**
678 * \brief C'Tor using a OGenericPluginLoader 678 * \brief C'Tor using a OGenericPluginLoader
679 * The C'tor. Pass your OGenericPluginLoader to manage 679 * The C'tor. Pass your OGenericPluginLoader to manage
680 * OGenericPluginLoader::allAvailable plugins. 680 * OGenericPluginLoader::allAvailable plugins.
681 * 681 *
682 * 682 *
683 * @param loader A Pointer to your OGenericPluginLoader 683 * @param loader A Pointer to your OGenericPluginLoader
684 * @param name The name
685 */ 684 */
686OPluginManager::OPluginManager( OGenericPluginLoader* loader) 685OPluginManager::OPluginManager( OGenericPluginLoader* loader)
687 : m_loader( loader ), m_isSorted( false ) 686 : m_loader( loader ), m_isSorted( false )
688{ 687{
689} 688}
690 689
691/** 690/**
692 * \brief Overloaded c'tor using a List of Plugins and a type name 691 * \brief Overloaded c'tor using a List of Plugins and a type name
693 * Overloaded Constructor to work with a 'Type' of plugins 692 * Overloaded Constructor to work with a 'Type' of plugins
694 * and a correspending list of those. In this case calling load 693 * and a correspending list of those. In this case calling load
695 * is a no operation. 694 * is a no operation.
696 * 695 *
697 * @param name The name of your plugin ('today','inputmethods','applets') 696 * @param name The name of your plugin ('today','inputmethods','applets')
698 * @param lst A List with plugins of your type to manage 697 * @param lst A List with plugins of your type to manage
699 * @param isSorted If the List should be treated sorted 698 * @param isSorted If the List should be treated sorted
700 */ 699 */
701OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted) 700OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted)
702 : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted ) 701 : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted )
703{ 702{
704} 703}
705 704
706/** 705/**
707 * \brief A simple d'tor 706 * \brief A simple d'tor
708 */ 707 */
709OPluginManager::~OPluginManager() { 708OPluginManager::~OPluginManager() {
710} 709}
711 710
712/** 711/**
713 * \brief Return the OPluginItem where loading is likely to have crashed on. 712 * \brief Return the OPluginItem where loading is likely to have crashed on.
714 713
715 * Return the Item that made the OGenericPluginLoader crash 714 * Return the Item that made the OGenericPluginLoader crash
716 * the returned OPluginItem could be empty if no crash occured 715 * the returned OPluginItem could be empty if no crash occured
717 * which should apply most of the time. It could also be empty if the crashed 716 * which should apply most of the time. It could also be empty if the crashed
718 * plugin is not in the current list of available/managed plugins 717 * plugin is not in the current list of available/managed plugins
719 * 718 *
720 * @see OPluginItem::isEmpty 719 * @see OPluginItem::isEmpty
721 * @return OPluginItem that crashed the loader 720 * @return OPluginItem that crashed the loader
722 */ 721 */
723OPluginItem OPluginManager::crashedPlugin()const { 722OPluginItem OPluginManager::crashedPlugin()const {
724 return m_crashed; 723 return m_crashed;
725} 724}
726 725
727/** 726/**
728 * \brief Return a list of plugins that are managed by this OPluginManager 727 * \brief Return a list of plugins that are managed by this OPluginManager
729 * 728 *
730 * Return the list of managed plugins. This could either result 729 * Return the list of managed plugins. This could either result
731 * from passing a OGenericPluginLoader and calling load or by 730 * from passing a OGenericPluginLoader and calling load or by
732 * giving name and a list of plugins. 731 * giving name and a list of plugins.
733 */ 732 */
734OPluginItem::List OPluginManager::managedPlugins()const { 733OPluginItem::List OPluginManager::managedPlugins()const {
735 return m_plugins; 734 return m_plugins;
736} 735}
737 736
738/** 737/**
739 * \brief Set the position of the items 738 * \brief Set the position of the items
740 * 739 *
741 * Replace the OPluginItem with the name and path and this way 740 * Replace the OPluginItem with the name and path and this way
742 * apply the new position. The search is linear and this way O(n/2) 741 * apply the new position. The search is linear and this way O(n/2)
743 * You still need to call save() to make your changes effective. After saving 742 * You still need to call save() to make your changes effective. After saving
744 * a call to OGenericPluginLoader::filtered() returns the newly configured order and items 743 * a call to OGenericPluginLoader::filtered() returns the newly configured order and items
745 * 744 *
746 * @param item The OPluginItem to be replaced internall 745 * @param item The OPluginItem to be replaced internall
747 * 746 *
748 */ 747 */
749void OPluginManager::setPosition( const OPluginItem& item) { 748void OPluginManager::setPosition( const OPluginItem& item) {
750 replace( item ); 749 replace( item );
751} 750}
752 751
753/** 752/**
754 * \brief Enable the item specified as argument 753 * \brief Enable the item specified as argument
755 * 754 *
756 * This will make sure that OPluginItem::setEnabled is called and then will replace 755 * This will make sure that OPluginItem::setEnabled is called and then will replace
757 * the item with one that matches name and path internally. 756 * the item with one that matches name and path internally.
758 * @see setPosition 757 * @see setPosition
759 * 758 *
760 * @param the Item to enable 759 * @param item the Item to enable
761 */ 760 */
762void OPluginManager::enable( const OPluginItem& item ) { 761void OPluginManager::enable( const OPluginItem& item ) {
763 setEnabled( item, true ); 762 setEnabled( item, true );
764} 763}
765 764
766/** 765/**
767 * \brief disable the Item. 766 * \brief disable the Item.
768 * 767 *
769 * Disable the OPluginItem. Same applies as in 768 * Disable the OPluginItem. Same applies as in
770 * @see setPosition and @see enable 769 * @see setPosition and @see enable
771 * 770 *
772 * @param item Item to disable 771 * @param item Item to disable
773 */ 772 */
774void OPluginManager::disable( const OPluginItem& item) { 773void OPluginManager::disable( const OPluginItem& item) {
775 setEnabled( item, false ); 774 setEnabled( item, false );
776} 775}
777 776
778/** 777/**
779 * \brief Enable or disable the OPluginItem. 778 * \brief Enable or disable the OPluginItem.
780 * Depending on the value of the parameter this will either disable 779 * Depending on the value of the parameter this will either disable
781 * or enable the pluginitem. 780 * or enable the pluginitem.
782 * Beside that same as in @see disable, @see enable, @see setPosition 781 * Beside that same as in @see disable, @see enable, @see setPosition
783 * applies. 782 * applies.
784 * 783 *
785 * @param _item The OPluginItem to enable or to disable. 784 * @param _item The OPluginItem to enable or to disable.
786 * @param b Enable or disable the plugin. 785 * @param b Enable or disable the plugin.
787 * 786 *
788 */ 787 */
789void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) { 788void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
790 OPluginItem item = _item; 789 OPluginItem item = _item;
791 item.setEnabled( b ); 790 item.setEnabled( b );
792 replace( item ); 791 replace( item );
793} 792}
794 793
795/** 794/**
796 * \brief Load necessary information after constructing the object 795 * \brief Load necessary information after constructing the object
797 * If you speified a OGenericPluginLoader you need to call this method 796 * If you speified a OGenericPluginLoader you need to call this method
798 * so that this manager knows what to manage and have a right value for \sa crashedPlugin 797 * so that this manager knows what to manage and have a right value for \sa crashedPlugin
799 * For the name and the list of plugins this does only try to find out the crashed plugin 798 * For the name and the list of plugins this does only try to find out the crashed plugin
800 */ 799 */
801void OPluginManager::load() { 800void OPluginManager::load() {
802 OConfig cfg( configName() ); 801 OConfig cfg( configName() );
803 cfg.setGroup( "General" ); 802 cfg.setGroup( "General" );
804 QString crashedPath = cfg.readEntry( "CrashedPlugin" ); 803 QString crashedPath = cfg.readEntry( "CrashedPlugin" );
805 804
806 /* if we've a loader this applies if we were called from the first part */ 805 /* if we've a loader this applies if we were called from the first part */
807 if ( m_loader ) 806 if ( m_loader )
808 m_plugins = m_loader->allAvailable( m_loader->isSorted() ); 807 m_plugins = m_loader->allAvailable( m_loader->isSorted() );
809 808
810 /* fast and normal route if we did not crash... */ 809 /* fast and normal route if we did not crash... */
811 if ( crashedPath.isEmpty() ) 810 if ( crashedPath.isEmpty() )
812 return; 811 return;
813 812
814 /* lets try to find the plugin path and this way the associated item */ 813 /* lets try to find the plugin path and this way the associated item */
815 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) 814 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it )
816 if ( (*it).path() == crashedPath ) { 815 if ( (*it).path() == crashedPath ) {
817 m_crashed = *it; 816 m_crashed = *it;
818 break; 817 break;
819 } 818 }
820} 819}
821 820
822 821
823/** 822/**
824 * \brief Save the values and this way make it available. 823 * \brief Save the values and this way make it available.
825 * 824 *
826 * Save the current set of data. A call to @see OGenericPluginLoader::filtered 825 * Save the current set of data. A call to @see OGenericPluginLoader::filtered
827 * now would return your saved changes. 826 * now would return your saved changes.
828 */ 827 */
829void OPluginManager::save() { 828void OPluginManager::save() {
830 QMap<QString, QStringList> excluded; // map for path to excluded name 829 QMap<QString, QStringList> excluded; // map for path to excluded name
831 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs 830 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
832 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; 831 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
833 832
834 /* 833 /*
835 * We will create some maps for the groups to include positions a 834 * We will create some maps for the groups to include positions a
836 */ 835 */
837 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { 836 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
838 OPluginItem item = *it; 837 OPluginItem item = *it;
839 QString path = QFileInfo( item.path() ).dirPath(true); 838 QString path = QFileInfo( item.path() ).dirPath(true);
840 if ( sorted ) { 839 if ( sorted ) {
841 positions[path].append( item.name() ); 840 positions[path].append( item.name() );
842 positions[path].append( QString::number( item.position() ) ); 841 positions[path].append( QString::number( item.position() ) );
843 } 842 }
844 843
845 if ( !item.isEnabled() ) 844 if ( !item.isEnabled() )
846 excluded[path].append( item.name() ); 845 excluded[path].append( item.name() );
847 if ( !excluded.contains( path ) ) 846 if ( !excluded.contains( path ) )
848 excluded[path] = QString::null; 847 excluded[path] = QString::null;
849 848
850 } 849 }
851 850
852/* 851/*
853 * The code below wouldn't work because we can't delete groups/keys from the config 852 * The code below wouldn't work because we can't delete groups/keys from the config
854 * ### for ODP make Config right! 853 * ### for ODP make Config right!
855 */ 854 */
856// if ( excluded.isEmpty() && positions.isEmpty() ) return; 855// if ( excluded.isEmpty() && positions.isEmpty() ) return;
857 /* 856 /*
858 * Now safe for each path 857 * Now safe for each path
859 */ 858 */
860 OConfig cfg( configName() ); 859 OConfig cfg( configName() );
861 860
862 /* safe excluded items */ 861 /* safe excluded items */
863 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { 862 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
864 OConfigGroupSaver saver( &cfg, it.key() ); 863 OConfigGroupSaver saver( &cfg, it.key() );
865 cfg.writeEntry("Excluded", it.data(), ',' ); 864 cfg.writeEntry("Excluded", it.data(), ',' );
866 } 865 }
867 866
868 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop 867 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop
869 * ### Write a Test Suite that can profile these runs... 868 * ### Write a Test Suite that can profile these runs...
870 */ 869 */
871 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { 870 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) {
872 OConfigGroupSaver saver( &cfg, it.key() ); 871 OConfigGroupSaver saver( &cfg, it.key() );
873 cfg.writeEntry("Positions", it.data(), '.' ); 872 cfg.writeEntry("Positions", it.data(), '.' );
874 } 873 }
875} 874}
876 875
877/** 876/**
878 * @internal 877 * @internal
879 */ 878 */
880QString OPluginManager::configName()const { 879QString OPluginManager::configName()const {
881 QString str = m_loader ? m_loader->name() : m_cfgName; 880 QString str = m_loader ? m_loader->name() : m_cfgName;
882 return str + "-odpplugins"; 881 return str + "-odpplugins";
883} 882}
884 883
885/** 884/**
886 * @internal.. replace in m_plugins by path... this is linear search O(n/2) 885 * @internal.. replace in m_plugins by path... this is linear search O(n/2)
887 */ 886 */
888void OPluginManager::replace( const OPluginItem& item ) { 887void OPluginManager::replace( const OPluginItem& item ) {
889 OPluginItem _item; 888 OPluginItem _item;
890 889
891 /* for all plugins */ 890 /* for all plugins */
892 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) { 891 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) {
893 _item = *it; 892 _item = *it;
894 /* if path and name are the same we will remove, readd and return */ 893 /* if path and name are the same we will remove, readd and return */
895 if ( _item.path() == item.path() && 894 if ( _item.path() == item.path() &&
896 _item.name() == item.name() ) { 895 _item.name() == item.name() ) {
897 it = m_plugins.remove( it ); 896 it = m_plugins.remove( it );
898 m_plugins.append( item ); 897 m_plugins.append( item );
899 return; 898 return;
900 } 899 }
901 900
902 } 901 }
903} 902}
904 903
905} 904}
906} 905}
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index be1436c..ac6be98 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,761 +1,763 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
4 Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) 5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
6 .=l. 6 .=l.
7          .>+-= 7          .>+-=
8_;:,     .>    :=|. This program is free software; you can 8_;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12- .   .-<_>     .<> Foundation; either version 2 of the License, 12- .   .-<_>     .<> Foundation; either version 2 of the License,
13    ._= =}       : or (at your option) any later version. 13    ._= =}       : or (at your option) any later version.
14   .%`+i>       _;_. 14   .%`+i>       _;_.
15   .i_,=:_.      -<s. This program is distributed in the hope that 15   .i_,=:_.      -<s. This program is distributed in the hope that
16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17   : ..    .:,     . . . without even the implied warranty of 17   : ..    .:,     . . . without even the implied warranty of
18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22:     =  ...= . :.=- 22:     =  ...= . :.=-
23-.   .:....=;==+<; You should have received a copy of the GNU 23-.   .:....=;==+<; You should have received a copy of the GNU
24 -_. . .   )=.  = Library General Public License along with 24 -_. . .   )=.  = Library General Public License along with
25   --        :-=` this library; see the file COPYING.LIB. 25   --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#ifndef OPROCESS_H 31#ifndef OPROCESS_H
32#define OPROCESS_H 32#define OPROCESS_H
33 33
34/* QT */ 34/* QT */
35#include <qcstring.h> 35#include <qcstring.h>
36#include <qobject.h> 36#include <qobject.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38 38
39/* STD */ 39/* STD */
40#include <sys/types.h> // for pid_t 40#include <sys/types.h> // for pid_t
41#include <sys/wait.h> 41#include <sys/wait.h>
42#include <signal.h> 42#include <signal.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45class QSocketNotifier; 45class QSocketNotifier;
46 46
47namespace Opie { 47namespace Opie {
48namespace Core { 48namespace Core {
49namespace Internal { 49namespace Internal {
50class OProcessController; 50class OProcessController;
51class OProcessPrivate; 51class OProcessPrivate;
52} 52}
53 53
54/** 54/**
55 * Child process invocation, monitoring and control. 55 * Child process invocation, monitoring and control.
56 * 56 *
57 * @sect General usage and features 57 * @par General usage and features
58 * 58 *
59 *This class allows a KDE and OPIE application to start child processes without having 59 *This class allows a KDE and OPIE application to start child processes without having
60 *to worry about UN*X signal handling issues and zombie process reaping. 60 *to worry about UN*X signal handling issues and zombie process reaping.
61 * 61 *
62 *@see KProcIO 62 *@see KProcIO
63 * 63 *
64 *Basically, this class distinguishes three different ways of running 64 *Basically, this class distinguishes three different ways of running
65 *child processes: 65 *child processes:
66 * 66 *
67 *@li OProcess::DontCare -- The child process is invoked and both the child 67 *@li OProcess::DontCare -- The child process is invoked and both the child
68 *process and the parent process continue concurrently. 68 *process and the parent process continue concurrently.
69 * 69 *
70 *Starting a DontCare child process means that the application is 70 *Starting a DontCare child process means that the application is
71 *not interested in any notification to determine whether the 71 *not interested in any notification to determine whether the
72 *child process has already exited or not. 72 *child process has already exited or not.
73 * 73 *
74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the 74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the
75 *child and the parent process run concurrently. 75 *child and the parent process run concurrently.
76 * 76 *
77 *When the child process exits, the OProcess instance 77 *When the child process exits, the OProcess instance
78 *corresponding to it emits the Qt signal @ref processExited(). 78 *corresponding to it emits the Qt signal @ref processExited().
79 * 79 *
80 *Since this signal is @em not emitted from within a UN*X 80 *Since this signal is @em not emitted from within a UN*X
81 *signal handler, arbitrary function calls can be made. 81 *signal handler, arbitrary function calls can be made.
82 * 82 *
83 *Be aware: When the OProcess objects gets destructed, the child 83 *Be aware: When the OProcess objects gets destructed, the child
84 *process will be killed if it is still running! 84 *process will be killed if it is still running!
85 *This means in particular, that you cannot use a OProcess on the stack 85 *This means in particular, that you cannot use a OProcess on the stack
86 *with OProcess::NotifyOnExit. 86 *with OProcess::NotifyOnExit.
87 * 87 *
88 *@li OProcess::Block -- The child process starts and the parent process 88 *@li OProcess::Block -- The child process starts and the parent process
89 *is suspended until the child process exits. (@em Really not recommended 89 *is suspended until the child process exits. (@em Really not recommended
90 *for programs with a GUI.) 90 *for programs with a GUI.)
91 * 91 *
92 *OProcess also provides several functions for determining the exit status 92 *OProcess also provides several functions for determining the exit status
93 *and the pid of the child process it represents. 93 *and the pid of the child process it represents.
94 * 94 *
95 *Furthermore it is possible to supply command-line arguments to the process 95 *Furthermore it is possible to supply command-line arguments to the process
96 *in a clean fashion (no null -- terminated stringlists and such...) 96 *in a clean fashion (no null -- terminated stringlists and such...)
97 * 97 *
98 *A small usage example: 98 *A small usage example:
99 *<pre> 99 *<pre>
100 *OProcess *proc = new OProcess; 100 *OProcess *proc = new OProcess;
101 * 101 *
102 **proc << "my_executable"; 102 **proc << "my_executable";
103 **proc << "These" << "are" << "the" << "command" << "line" << "args"; 103 **proc << "These" << "are" << "the" << "command" << "line" << "args";
104 *QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)), 104 *QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)),
105 * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *))); 105 * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *)));
106 *proc->start(); 106 *proc->start();
107 *</pre> 107 *</pre>
108 * 108 *
109 *This will start "my_executable" with the commandline arguments "These"... 109 *This will start "my_executable" with the commandline arguments "These"...
110 * 110 *
111 *When the child process exits, the respective Qt signal will be emitted. 111 *When the child process exits, the respective Qt signal will be emitted.
112 * 112 *
113 *@sect Communication with the child process 113 *@par Communication with the child process
114 * 114 *
115 *OProcess supports communication with the child process through 115 *OProcess supports communication with the child process through
116 *stdin/stdout/stderr. 116 *stdin/stdout/stderr.
117 * 117 *
118 *The following functions are provided for getting data from the child 118 *The following functions are provided for getting data from the child
119 *process or sending data to the child's stdin (For more information, 119 *process or sending data to the child's stdin (For more information,
120 *have a look at the documentation of each function): 120 *have a look at the documentation of each function):
121 * 121 *
122 *@li bool @ref writeStdin(char *buffer, int buflen); 122 *@li bool @ref writeStdin(char *buffer, int buflen);
123 *@li -- Transmit data to the child process's stdin. 123 *@li -- Transmit data to the child process's stdin.
124 * 124 *
125 *@li bool @ref closeStdin(); 125 *@li bool @ref closeStdin();
126 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)). 126 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)).
127 *Returns false if you try to close stdin for a process that has been started 127 *Returns false if you try to close stdin for a process that has been started
128 *without a communication channel to stdin. 128 *without a communication channel to stdin.
129 * 129 *
130 *@li bool @ref closeStdout(); 130 *@li bool @ref closeStdout();
131 *@li -- Closes the child process's stdout. 131 *@li -- Closes the child process's stdout.
132 *Returns false if you try to close stdout for a process that has been started 132 *Returns false if you try to close stdout for a process that has been started
133 *without a communication channel to stdout. 133 *without a communication channel to stdout.
134 * 134 *
135 *@li bool @ref closeStderr(); 135 *@li bool @ref closeStderr();
136 *@li -- Closes the child process's stderr. 136 *@li -- Closes the child process's stderr.
137 *Returns false if you try to close stderr for a process that has been started 137 *Returns false if you try to close stderr for a process that has been started
138 *without a communication channel to stderr. 138 *without a communication channel to stderr.
139 * 139 *
140 * 140 *
141 *@sect QT signals: 141 *@par QT signals:
142 * 142 *
143 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen); 143 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen);
144 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen); 144 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen);
145 *@li -- Indicates that new data has arrived from either the 145 *@li -- Indicates that new data has arrived from either the
146 *child process's stdout or stderr. 146 *child process's stdout or stderr.
147 * 147 *
148 *@li void @ref wroteStdin(OProcess *proc); 148 *@li void @ref wroteStdin(OProcess *proc);
149 *@li -- Indicates that all data that has been sent to the child process 149 *@li -- Indicates that all data that has been sent to the child process
150 *by a prior call to @ref writeStdin() has actually been transmitted to the 150 *by a prior call to @ref writeStdin() has actually been transmitted to the
151 *client . 151 *client .
152 * 152 *
153 *@author Christian Czezakte e9025461@student.tuwien.ac.at 153 *@author Christian Czezakte e9025461@student.tuwien.ac.at
154 *@author Holger Freyther (Opie Port) 154 *@author Holger Freyther (Opie Port)
155 * 155 *
156 **/ 156 **/
157class OProcess : public QObject 157class OProcess : public QObject
158{ 158{
159 Q_OBJECT 159 Q_OBJECT
160 160
161public: 161public:
162 162
163 /** 163 /**
164 * Modes in which the communication channel can be opened. 164 * Modes in which the communication channel can be opened.
165 * 165 *
166 * If communication for more than one channel is required, 166 * If communication for more than one channel is required,
167 * the values have to be or'ed together, for example to get 167 * the values have to be or'ed together, for example to get
168 * communication with stdout as well as with stdin, you would 168 * communication with stdout as well as with stdin, you would
169 * specify @p Stdin @p | @p Stdout 169 * specify @p Stdin @p | @p Stdout
170 * 170 *
171 * If @p NoRead is specified in conjunction with @p Stdout, 171 * If @p NoRead is specified in conjunction with @p Stdout,
172 * no data is actually read from @p Stdout but only 172 * no data is actually read from @p Stdout but only
173 * the signal @ref childOutput(int fd) is emitted. 173 * the signal @ref childOutput(int fd) is emitted.
174 */ 174 */
175 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4, 175 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4,
176 AllOutput = 6, All = 7, 176 AllOutput = 6, All = 7,
177 NoRead }; 177 NoRead };
178 178
179 /** 179 /**
180 * Run-modes for a child process. 180 * Run-modes for a child process.
181 */ 181 */
182 enum RunMode { 182 enum RunMode {
183 /** 183 /**
184 * The application does not receive notifications from the subprocess when 184 * The application does not receive notifications from the subprocess when
185 * it is finished or aborted. 185 * it is finished or aborted.
186 */ 186 */
187 DontCare, 187 DontCare,
188 /** 188 /**
189 * The application is notified when the subprocess dies. 189 * The application is notified when the subprocess dies.
190 */ 190 */
191 NotifyOnExit, 191 NotifyOnExit,
192 /** 192 /**
193 * The application is suspended until the started process is finished. 193 * The application is suspended until the started process is finished.
194 */ 194 */
195 Block }; 195 Block };
196 196
197 /** 197 /**
198 * Constructor 198 * Constructor
199 */ 199 */
200 OProcess( QObject *parent = 0, const char *name = 0 ); 200 OProcess( QObject *parent = 0, const char *name = 0 );
201 /** 201 /**
202 * Constructor 202 * Constructor
203 */ 203 */
204 OProcess( const QString &arg0, QObject *parent = 0, const char *name = 0 ); 204 OProcess( const QString &arg0, QObject *parent = 0, const char *name = 0 );
205 /** 205 /**
206 * Constructor 206 * Constructor
207 */ 207 */
208 OProcess( const QStringList &args, QObject *parent = 0, const char *name = 0 ); 208 OProcess( const QStringList &args, QObject *parent = 0, const char *name = 0 );
209 209
210 /** 210 /**
211 *Destructor: 211 *Destructor:
212 * 212 *
213 * If the process is running when the destructor for this class 213 * If the process is running when the destructor for this class
214 * is called, the child process is killed with a SIGKILL, but 214 * is called, the child process is killed with a SIGKILL, but
215 * only if the run mode is not of type @p DontCare. 215 * only if the run mode is not of type @p DontCare.
216 * Processes started as @p DontCare keep running anyway. 216 * Processes started as @p DontCare keep running anyway.
217 */ 217 */
218 virtual ~OProcess(); 218 virtual ~OProcess();
219 219
220 /** 220 /**
221 @deprecated 221 @deprecated
222 222
223 The use of this function is now deprecated. -- Please use the 223 The use of this function is now deprecated. -- Please use the
224 "operator<<" instead of "setExecutable". 224 "operator<<" instead of "setExecutable".
225 225
226 Sets the executable to be started with this OProcess object. 226 Sets the executable to be started with this OProcess object.
227 Returns false if the process is currently running (in that 227 Returns false if the process is currently running (in that
228 case the executable remains unchanged.) 228 case the executable remains unchanged.)
229 229
230 @see operator<< 230 @see operator<<
231 231
232 */ 232 */
233 bool setExecutable( const QString& proc ); 233 bool setExecutable( const QString& proc );
234 234
235 235
236 /** 236 /**
237 * Sets the executable and the command line argument list for this process. 237 * Sets the executable and the command line argument list for this process.
238 * 238 *
239 * For example, doing an "ls -l /usr/local/bin" can be achieved by: 239 * For example, doing an "ls -l /usr/local/bin" can be achieved by:
240 * <pre> 240 * <pre>
241 * OProcess p; 241 * OProcess p;
242 * ... 242 * ...
243 * p << "ls" << "-l" << "/usr/local/bin" 243 * p << "ls" << "-l" << "/usr/local/bin"
244 * </pre> 244 * </pre>
245 * 245 *
246 **/ 246 **/
247 OProcess &operator<<( const QString& arg ); 247 OProcess &operator<<( const QString& arg );
248 /** 248 /**
249 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already. 249 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already.
250 */ 250 */
251 OProcess &operator<<( const char * arg ); 251 OProcess &operator<<( const char * arg );
252 /** 252 /**
253 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already. 253 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already.
254 */ 254 */
255 OProcess &operator<<( const QCString & arg ); 255 OProcess &operator<<( const QCString & arg );
256 256
257 /** 257 /**
258 * Sets the executable and the command line argument list for this process, 258 * Sets the executable and the command line argument list for this process,
259 * in a single method call, or add a list of arguments. 259 * in a single method call, or add a list of arguments.
260 **/ 260 **/
261 OProcess &operator<<( const QStringList& args ); 261 OProcess &operator<<( const QStringList& args );
262 262
263 /** 263 /**
264 * Clear a command line argument list that has been set by using 264 * Clear a command line argument list that has been set by using
265 * the "operator<<". 265 * the "operator<<".
266 */ 266 */
267 void clearArguments(); 267 void clearArguments();
268 268
269 /** 269 /**
270 * Starts the process. 270 * Starts the process.
271 * For a detailed description of the 271 * For a detailed description of the
272 * various run modes and communication semantics, have a look at the 272 * various run modes and communication semantics, have a look at the
273 * general description of the OProcess class. 273 * general description of the OProcess class.
274 * 274 *
275 * The following problems could cause this function to 275 * The following problems could cause this function to
276 * return false: 276 * return false:
277 * 277 *
278 * @li The process is already running. 278 * @li The process is already running.
279 * @li The command line argument list is empty. 279 * @li The command line argument list is empty.
280 * @li The starting of the process failed (could not fork). 280 * @li The starting of the process failed (could not fork).
281 * @li The executable was not found. 281 * @li The executable was not found.
282 * 282 *
283 * @param comm Specifies which communication links should be 283 * @param comm Specifies which communication links should be
284 * established to the child process (stdin/stdout/stderr). By default, 284 * established to the child process (stdin/stdout/stderr). By default,
285 * no communication takes place and the respective communication 285 * no communication takes place and the respective communication
286 * signals will never get emitted. 286 * signals will never get emitted.
287 * 287 *
288 * @return true on success, false on error 288 * @return true on success, false on error
289 * (see above for error conditions) 289 * (see above for error conditions)
290 **/ 290 **/
291 virtual bool start( RunMode runmode = NotifyOnExit, 291 virtual bool start( RunMode runmode = NotifyOnExit,
292 Communication comm = NoCommunication ); 292 Communication comm = NoCommunication );
293 293
294 /** 294 /**
295 * Stop the process (by sending it a signal). 295 * Stop the process (by sending it a signal).
296 * 296 *
297 * @param signoThe signal to send. The default is SIGTERM. 297 * @param signoThe signal to send. The default is SIGTERM.
298 * @return @p true if the signal was delivered successfully. 298 * @return @p true if the signal was delivered successfully.
299 */ 299 */
300 virtual bool kill( int signo = SIGTERM ); 300 virtual bool kill( int signo = SIGTERM );
301 301
302 /** 302 /**
303 @return @p true if the process is (still) considered to be running 303 @return @p true if the process is (still) considered to be running
304 */ 304 */
305 bool isRunning() const; 305 bool isRunning() const;
306 306
307 /** Returns the process id of the process. 307 /** Returns the process id of the process.
308 * 308 *
309 * If it is called after 309 * If it is called after
310 * the process has exited, it returns the process id of the last 310 * the process has exited, it returns the process id of the last
311 * child process that was created by this instance of OProcess. 311 * child process that was created by this instance of OProcess.
312 * 312 *
313 * Calling it before any child process has been started by this 313 * Calling it before any child process has been started by this
314 * OProcess instance causes pid() to return 0. 314 * OProcess instance causes pid() to return 0.
315 **/ 315 **/
316 pid_t pid() const; 316 pid_t pid() const;
317 317
318 /** 318 /**
319 * Suspend processing of data from stdout of the child process. 319 * Suspend processing of data from stdout of the child process.
320 */ 320 */
321 void suspend(); 321 void suspend();
322 322
323 /** 323 /**
324 * Resume processing of data from stdout of the child process. 324 * Resume processing of data from stdout of the child process.
325 */ 325 */
326 void resume(); 326 void resume();
327 327
328 /** 328 /**
329 * @return @p true if the process has already finished and has exited 329 * @return @p true if the process has already finished and has exited
330 * "voluntarily", ie: it has not been killed by a signal. 330 * "voluntarily", ie: it has not been killed by a signal.
331 * 331 *
332 * Note that you should check @ref OProcess::exitStatus() to determine 332 * Note that you should check @ref OProcess::exitStatus() to determine
333 * whether the process completed its task successful or not. 333 * whether the process completed its task successful or not.
334 */ 334 */
335 bool normalExit() const; 335 bool normalExit() const;
336 336
337 /** 337 /**
338 * Returns the exit status of the process. 338 * Returns the exit status of the process.
339 * 339 *
340 * Please use 340 * Please use
341 * @ref OProcess::normalExit() to check whether the process has exited 341 * @ref OProcess::normalExit() to check whether the process has exited
342 * cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling 342 * cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling
343 * this function because if the process did not exit normally, 343 * this function because if the process did not exit normally,
344 * it does not have a valid exit status. 344 * it does not have a valid exit status.
345 */ 345 */
346 int exitStatus() const; 346 int exitStatus() const;
347 347
348 348
349 /** 349 /**
350 * Transmit data to the child process's stdin. 350 * Transmit data to the child process's stdin.
351 * 351 *
352 * OProcess::writeStdin may return false in the following cases: 352 * OProcess::writeStdin may return false in the following cases:
353 * 353 *
354 * @li The process is not currently running. 354 * @li The process is not currently running.
355 * 355 *
356 * @li Communication to stdin has not been requested in the @ref start() call. 356 * @li Communication to stdin has not been requested in the @ref start() call.
357 * 357 *
358 * @li Transmission of data to the child process by a previous call to 358 * @li Transmission of data to the child process by a previous call to
359 * @ref writeStdin() is still in progress. 359 * @ref writeStdin() is still in progress.
360 * 360 *
361 * Please note that the data is sent to the client asynchronously, 361 * Please note that the data is sent to the client asynchronously,
362 * so when this function returns, the data might not have been 362 * so when this function returns, the data might not have been
363 * processed by the child process. 363 * processed by the child process.
364 * 364 *
365 * If all the data has been sent to the client, the signal 365 * If all the data has been sent to the client, the signal
366 * @ref wroteStdin() will be emitted. 366 * @ref wroteStdin() will be emitted.
367 * 367 *
368 * Please note that you must not free "buffer" or call @ref writeStdin() 368 * Please note that you must not free "buffer" or call @ref writeStdin()
369 * again until either a @ref wroteStdin() signal indicates that the 369 * again until either a @ref wroteStdin() signal indicates that the
370 * data has been sent or a @ref processHasExited() signal shows that 370 * data has been sent or a @ref processHasExited() signal shows that
371 * the child process is no longer alive... 371 * the child process is no longer alive...
372 **/ 372 **/
373 bool writeStdin( const char *buffer, int buflen ); 373 bool writeStdin( const char *buffer, int buflen );
374 374
375 void flushStdin(); 375 void flushStdin();
376 376
377 /** 377 /**
378 * This causes the stdin file descriptor of the child process to be 378 * This causes the stdin file descriptor of the child process to be
379 * closed indicating an "EOF" to the child. 379 * closed indicating an "EOF" to the child.
380 * 380 *
381 * @return @p false if no communication to the process's stdin 381 * @return @p false if no communication to the process's stdin
382 * had been specified in the call to @ref start(). 382 * had been specified in the call to @ref start().
383 */ 383 */
384 bool closeStdin(); 384 bool closeStdin();
385 385
386 /** 386 /**
387 * This causes the stdout file descriptor of the child process to be 387 * This causes the stdout file descriptor of the child process to be
388 * closed. 388 * closed.
389 * 389 *
390 * @return @p false if no communication to the process's stdout 390 * @return @p false if no communication to the process's stdout
391 * had been specified in the call to @ref start(). 391 * had been specified in the call to @ref start().
392 */ 392 */
393 bool closeStdout(); 393 bool closeStdout();
394 394
395 /** 395 /**
396 * This causes the stderr file descriptor of the child process to be 396 * This causes the stderr file descriptor of the child process to be
397 * closed. 397 * closed.
398 * 398 *
399 * @return @p false if no communication to the process's stderr 399 * @return @p false if no communication to the process's stderr
400 * had been specified in the call to @ref start(). 400 * had been specified in the call to @ref start().
401 */ 401 */
402 bool closeStderr(); 402 bool closeStderr();
403 403
404 /** 404 /**
405 * Lets you see what your arguments are for debugging. 405 * Lets you see what your arguments are for debugging.
406 * \todo make const 406 * \todo make const
407 */ 407 */
408 408
409 const QValueList<QCString> &args() 409 const QValueList<QCString> &args()
410 { 410 {
411 return arguments; 411 return arguments;
412 } 412 }
413 413
414 /** 414 /**
415 * Controls whether the started process should drop any 415 * Controls whether the started process should drop any
416 * setuid/segid privileges or whether it should keep them 416 * setuid/segid privileges or whether it should keep them
417 * 417 *
418 * The default is @p false : drop privileges 418 * The default is @p false : drop privileges
419 */ 419 */
420 void setRunPrivileged( bool keepPrivileges ); 420 void setRunPrivileged( bool keepPrivileges );
421 421
422 /** 422 /**
423 * Returns whether the started process will drop any 423 * Returns whether the started process will drop any
424 * setuid/segid privileges or whether it will keep them 424 * setuid/segid privileges or whether it will keep them
425 */ 425 */
426 bool runPrivileged() const; 426 bool runPrivileged() const;
427 427
428 /** 428 /**
429 * Modifies the environment of the process to be started. 429 * Modifies the environment of the process to be started.
430 * This function must be called before starting the process. 430 * This function must be called before starting the process.
431 */ 431 */
432 void setEnvironment( const QString &name, const QString &value ); 432 void setEnvironment( const QString &name, const QString &value );
433 433
434 /** 434 /**
435 * Changes the current working directory (CWD) of the process 435 * Changes the current working directory (CWD) of the process
436 * to be started. 436 * to be started.
437 * This function must be called before starting the process. 437 * This function must be called before starting the process.
438 */ 438 */
439 void setWorkingDirectory( const QString &dir ); 439 void setWorkingDirectory( const QString &dir );
440 440
441 /** 441 /**
442 * Specify whether to start the command via a shell or directly. 442 * Specify whether to start the command via a shell or directly.
443 * The default is to start the command directly. 443 * The default is to start the command directly.
444 * If @p useShell is true @p shell will be used as shell, or 444 * If @p useShell is true @p shell will be used as shell, or
445 * if shell is empty, the standard shell is used. 445 * if shell is empty, the standard shell is used.
446 * @p quote A flag indicating whether to quote the arguments. 446 * @p quote A flag indicating whether to quote the arguments.
447 * 447 *
448 * When using a shell, the caller should make sure that all filenames etc. 448 * When using a shell, the caller should make sure that all filenames etc.
449 * are properly quoted when passed as argument. 449 * are properly quoted when passed as argument.
450 * @see quote() 450 * @see quote()
451 */ 451 */
452 void setUseShell( bool useShell, const char *shell = 0 ); 452 void setUseShell( bool useShell, const char *shell = 0 );
453 453
454 /** 454 /**
455 * This function can be used to quote an argument string such that 455 * This function can be used to quote an argument string such that
456 * the shell processes it properly. This is e. g. necessary for 456 * the shell processes it properly. This is e. g. necessary for
457 * user-provided file names which may contain spaces or quotes. 457 * user-provided file names which may contain spaces or quotes.
458 * It also prevents expansion of wild cards and environment variables. 458 * It also prevents expansion of wild cards and environment variables.
459 */ 459 */
460 static QString quote( const QString &arg ); 460 static QString quote( const QString &arg );
461 461
462 /** 462 /**
463 * Detaches OProcess from child process. All communication is closed. 463 * Detaches OProcess from child process. All communication is closed.
464 * No exit notification is emitted any more for the child process. 464 * No exit notification is emitted any more for the child process.
465 * Deleting the OProcess will no longer kill the child process. 465 * Deleting the OProcess will no longer kill the child process.
466 * Note that the current process remains the parent process of the 466 * Note that the current process remains the parent process of the
467 * child process. 467 * child process.
468 */ 468 */
469 void detach(); 469 void detach();
470 470
471 /** 471 /**
472 * @return the PID of @a process, or -1 if the process is not running 472 * @return the PID of @a process, or -1 if the process is not running
473 */ 473 */
474 static int processPID( const QString& process ); 474 static int processPID( const QString& process );
475 475
476signals: 476signals:
477 477
478 /** 478 /**
479 * Emitted after the process has terminated when 479 * Emitted after the process has terminated when
480 * the process was run in the @p NotifyOnExit (==default option to 480 * the process was run in the @p NotifyOnExit (==default option to
481 * @ref start()) or the @ref Block mode. 481 * @ref start()) or the @ref Block mode.
482 **/ 482 **/
483 void processExited( Opie::Core::OProcess *proc ); 483 void processExited( Opie::Core::OProcess *proc );
484 484
485 485
486 /** 486 /**
487 * Emitted, when output from the child process has 487 * Emitted, when output from the child process has
488 * been received on stdout. 488 * been received on stdout.
489 * 489 *
490 * To actually get 490 * To actually get
491 * these signals, the respective communication link (stdout/stderr) 491 * these signals, the respective communication link (stdout/stderr)
492 * has to be turned on in @ref start(). 492 * has to be turned on in @ref start().
493 * 493 *
494 * @param proc The process
494 * @param buffer The data received. 495 * @param buffer The data received.
495 * @param buflen The number of bytes that are available. 496 * @param buflen The number of bytes that are available.
496 * 497 *
497 * You should copy the information contained in @p buffer to your private 498 * You should copy the information contained in @p buffer to your private
498 * data structures before returning from this slot. 499 * data structures before returning from this slot.
499 **/ 500 **/
500 void receivedStdout( Opie::Core::OProcess *proc, char *buffer, int buflen ); 501 void receivedStdout( Opie::Core::OProcess *proc, char *buffer, int buflen );
501 502
502 /** 503 /**
503 * Emitted when output from the child process has 504 * Emitted when output from the child process has
504 * been received on stdout. 505 * been received on stdout.
505 * 506 *
506 * To actually get these signals, the respective communications link 507 * To actually get these signals, the respective communications link
507 * (stdout/stderr) has to be turned on in @ref start() and the 508 * (stdout/stderr) has to be turned on in @ref start() and the
508 * @p NoRead flag should have been passed. 509 * @p NoRead flag should have been passed.
509 * 510 *
510 * You will need to explicitly call resume() after your call to start() 511 * You will need to explicitly call resume() after your call to start()
511 * to begin processing data from the child process's stdout. This is 512 * to begin processing data from the child process's stdout. This is
512 * to ensure that this signal is not emitted when no one is connected 513 * to ensure that this signal is not emitted when no one is connected
513 * to it, otherwise this signal will not be emitted. 514 * to it, otherwise this signal will not be emitted.
514 * 515 *
515 * The data still has to be read from file descriptor @p fd. 516 * The data still has to be read from file descriptor @p fd.
516 **/ 517 **/
517 void receivedStdout( int fd, int &len ); 518 void receivedStdout( int fd, int &len );
518 519
519 520
520 /** 521 /**
521 * Emitted, when output from the child process has 522 * Emitted, when output from the child process has
522 * been received on stderr. 523 * been received on stderr.
523 * To actually get 524 * To actually get
524 * these signals, the respective communication link (stdout/stderr) 525 * these signals, the respective communication link (stdout/stderr)
525 * has to be turned on in @ref start(). 526 * has to be turned on in @ref start().
526 * 527 *
528 * @param proc The process
527 * @param buffer The data received. 529 * @param buffer The data received.
528 * @param buflen The number of bytes that are available. 530 * @param buflen The number of bytes that are available.
529 * 531 *
530 * You should copy the information contained in @p buffer to your private 532 * You should copy the information contained in @p buffer to your private
531 * data structures before returning from this slot. 533 * data structures before returning from this slot.
532 */ 534 */
533 void receivedStderr( Opie::Core::OProcess *proc, char *buffer, int buflen ); 535 void receivedStderr( Opie::Core::OProcess *proc, char *buffer, int buflen );
534 536
535 /** 537 /**
536 * Emitted after all the data that has been 538 * Emitted after all the data that has been
537 * specified by a prior call to @ref writeStdin() has actually been 539 * specified by a prior call to @ref writeStdin() has actually been
538 * written to the child process. 540 * written to the child process.
539 **/ 541 **/
540 void wroteStdin( Opie::Core::OProcess *proc ); 542 void wroteStdin( Opie::Core::OProcess *proc );
541 543
542protected slots: 544protected slots:
543 545
544 /** 546 /**
545 * This slot gets activated when data from the child's stdout arrives. 547 * This slot gets activated when data from the child's stdout arrives.
546 * It usually calls "childOutput" 548 * It usually calls "childOutput"
547 */ 549 */
548 void slotChildOutput( int fdno ); 550 void slotChildOutput( int fdno );
549 551
550 /** 552 /**
551 * This slot gets activated when data from the child's stderr arrives. 553 * This slot gets activated when data from the child's stderr arrives.
552 * It usually calls "childError" 554 * It usually calls "childError"
553 */ 555 */
554 void slotChildError( int fdno ); 556 void slotChildError( int fdno );
555 /* 557 /*
556 Slot functions for capturing stdout and stderr of the child 558 Slot functions for capturing stdout and stderr of the child
557 */ 559 */
558 560
559 /** 561 /**
560 * Called when another bulk of data can be sent to the child's 562 * Called when another bulk of data can be sent to the child's
561 * stdin. If there is no more data to be sent to stdin currently 563 * stdin. If there is no more data to be sent to stdin currently
562 * available, this function must disable the QSocketNotifier "innot". 564 * available, this function must disable the QSocketNotifier "innot".
563 */ 565 */
564 void slotSendData( int dummy ); 566 void slotSendData( int dummy );
565 567
566protected: 568protected:
567 569
568 /** 570 /**
569 * Sets up the environment according to the data passed via 571 * Sets up the environment according to the data passed via
570 * setEnvironment(...) 572 * setEnvironment(...)
571 */ 573 */
572 void setupEnvironment(); 574 void setupEnvironment();
573 575
574 /** 576 /**
575 * The list of the process' command line arguments. The first entry 577 * The list of the process' command line arguments. The first entry
576 * in this list is the executable itself. 578 * in this list is the executable itself.
577 */ 579 */
578 QValueList<QCString> arguments; 580 QValueList<QCString> arguments;
579 /** 581 /**
580 * How to run the process (Block, NotifyOnExit, DontCare). You should 582 * How to run the process (Block, NotifyOnExit, DontCare). You should
581 * not modify this data member directly from derived classes. 583 * not modify this data member directly from derived classes.
582 */ 584 */
583 RunMode run_mode; 585 RunMode run_mode;
584 /** 586 /**
585 * true if the process is currently running. You should not 587 * true if the process is currently running. You should not
586 * modify this data member directly from derived classes. For 588 * modify this data member directly from derived classes. For
587 * reading the value of this data member, please use "isRunning()" 589 * reading the value of this data member, please use "isRunning()"
588 * since "runs" will probably be made private in later versions 590 * since "runs" will probably be made private in later versions
589 * of OProcess. 591 * of OProcess.
590 */ 592 */
591 bool runs; 593 bool runs;
592 594
593 /** 595 /**
594 * The PID of the currently running process (see "getPid()"). 596 * The PID of the currently running process (see "getPid()").
595 * You should not modify this data member in derived classes. 597 * You should not modify this data member in derived classes.
596 * Please use "getPid()" instead of directly accessing this 598 * Please use "getPid()" instead of directly accessing this
597 * member function since it will probably be made private in 599 * member function since it will probably be made private in
598 * later versions of OProcess. 600 * later versions of OProcess.
599 */ 601 */
600 pid_t pid_; 602 pid_t pid_;
601 603
602 /** 604 /**
603 * The process' exit status as returned by "waitpid". You should not 605 * The process' exit status as returned by "waitpid". You should not
604 * modify the value of this data member from derived classes. You should 606 * modify the value of this data member from derived classes. You should
605 * rather use @ref exitStatus than accessing this data member directly 607 * rather use @ref exitStatus than accessing this data member directly
606 * since it will probably be made private in further versions of 608 * since it will probably be made private in further versions of
607 * OProcess. 609 * OProcess.
608 */ 610 */
609 int status; 611 int status;
610 612
611 613
612 /** 614 /**
613 * See setRunPrivileged() 615 * See setRunPrivileged()
614 */ 616 */
615 bool keepPrivs; 617 bool keepPrivs;
616 618
617 /* 619 /*
618 Functions for setting up the sockets for communication. 620 Functions for setting up the sockets for communication.
619 setupCommunication 621 setupCommunication
620 -- is called from "start" before "fork"ing. 622 -- is called from "start" before "fork"ing.
621 commSetupDoneP 623 commSetupDoneP
622 -- completes communication socket setup in the parent 624 -- completes communication socket setup in the parent
623 commSetupDoneC 625 commSetupDoneC
624 -- completes communication setup in the child process 626 -- completes communication setup in the child process
625 commClose 627 commClose
626 -- frees all allocated communication resources in the parent 628 -- frees all allocated communication resources in the parent
627 after the process has exited 629 after the process has exited
628 */ 630 */
629 631
630 /** 632 /**
631 * This function is called from "OProcess::start" right before a "fork" takes 633 * This function is called from "OProcess::start" right before a "fork" takes
632 * place. According to 634 * place. According to
633 * the "comm" parameter this function has to initialize the "in", "out" and 635 * the "comm" parameter this function has to initialize the "in", "out" and
634 * "err" data member of OProcess. 636 * "err" data member of OProcess.
635 * 637 *
636 * This function should return 0 if setting the needed communication channels 638 * This function should return 0 if setting the needed communication channels
637 * was successful. 639 * was successful.
638 * 640 *
639 * The default implementation is to create UNIX STREAM sockets for the communication, 641 * The default implementation is to create UNIX STREAM sockets for the communication,
640 * but you could overload this function and establish a TCP/IP communication for 642 * but you could overload this function and establish a TCP/IP communication for
641 * network communication, for example. 643 * network communication, for example.
642 */ 644 */
643 virtual int setupCommunication( Communication comm ); 645 virtual int setupCommunication( Communication comm );
644 646
645 /** 647 /**
646 * Called right after a (successful) fork on the parent side. This function 648 * Called right after a (successful) fork on the parent side. This function
647 * will usually do some communications cleanup, like closing the reading end 649 * will usually do some communications cleanup, like closing the reading end
648 * of the "stdin" communication channel. 650 * of the "stdin" communication channel.
649 * 651 *
650 * Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and 652 * Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and
651 * "errnot" and connect their Qt slots to the respective OProcess member functions. 653 * "errnot" and connect their Qt slots to the respective OProcess member functions.
652 * 654 *
653 * For a more detailed explanation, it is best to have a look at the default 655 * For a more detailed explanation, it is best to have a look at the default
654 * implementation of "setupCommunication" in kprocess.cpp. 656 * implementation of "setupCommunication" in kprocess.cpp.
655 */ 657 */
656 virtual int commSetupDoneP(); 658 virtual int commSetupDoneP();
657 659
658 /** 660 /**
659 * Called right after a (successful) fork, but before an "exec" on the child 661 * Called right after a (successful) fork, but before an "exec" on the child
660 * process' side. It usually just closes the unused communication ends of 662 * process' side. It usually just closes the unused communication ends of
661 * "in", "out" and "err" (like the writing end of the "in" communication 663 * "in", "out" and "err" (like the writing end of the "in" communication
662 * channel. 664 * channel.
663 */ 665 */
664 virtual int commSetupDoneC(); 666 virtual int commSetupDoneC();
665 667
666 668
667 /** 669 /**
668 * Immediately called after a process has exited. This function normally 670 * Immediately called after a process has exited. This function normally
669 * calls commClose to close all open communication channels to this 671 * calls commClose to close all open communication channels to this
670 * process and emits the "processExited" signal (if the process was 672 * process and emits the "processExited" signal (if the process was
671 * not running in the "DontCare" mode). 673 * not running in the "DontCare" mode).
672 */ 674 */
673 virtual void processHasExited( int state ); 675 virtual void processHasExited( int state );
674 676
675 /** 677 /**
676 * Should clean up the communication links to the child after it has 678 * Should clean up the communication links to the child after it has
677 * exited. Should be called from "processHasExited". 679 * exited. Should be called from "processHasExited".
678 */ 680 */
679 virtual void commClose(); 681 virtual void commClose();
680 682
681 683
682 /** 684 /**
683 * the socket descriptors for stdin/stdout/stderr. 685 * the socket descriptors for stdin/stdout/stderr.
684 */ 686 */
685 int out[ 2 ]; 687 int out[ 2 ];
686 int in[ 2 ]; 688 int in[ 2 ];
687 int err[ 2 ]; 689 int err[ 2 ];
688 690
689 /** 691 /**
690 * The socket notifiers for the above socket descriptors. 692 * The socket notifiers for the above socket descriptors.
691 */ 693 */
692 QSocketNotifier *innot; 694 QSocketNotifier *innot;
693 QSocketNotifier *outnot; 695 QSocketNotifier *outnot;
694 QSocketNotifier *errnot; 696 QSocketNotifier *errnot;
695 697
696 /** 698 /**
697 * Lists the communication links that are activated for the child 699 * Lists the communication links that are activated for the child
698 * process. Should not be modified from derived classes. 700 * process. Should not be modified from derived classes.
699 */ 701 */
700 Communication communication; 702 Communication communication;
701 703
702 /** 704 /**
703 * Called by "slotChildOutput" this function copies data arriving from the 705 * Called by "slotChildOutput" this function copies data arriving from the
704 * child process's stdout to the respective buffer and emits the signal 706 * child process's stdout to the respective buffer and emits the signal
705 * "@ref receivedStderr". 707 * "@ref receivedStderr".
706 */ 708 */
707 int childOutput( int fdno ); 709 int childOutput( int fdno );
708 710
709 /** 711 /**
710 * Called by "slotChildOutput" this function copies data arriving from the 712 * Called by "slotChildOutput" this function copies data arriving from the
711 * child process's stdout to the respective buffer and emits the signal 713 * child process's stdout to the respective buffer and emits the signal
712 * "@ref receivedStderr" 714 * "@ref receivedStderr"
713 */ 715 */
714 int childError( int fdno ); 716 int childError( int fdno );
715 717
716 // information about the data that has to be sent to the child: 718 // information about the data that has to be sent to the child:
717 719
718 const char *input_data; // the buffer holding the data 720 const char *input_data; // the buffer holding the data
719 int input_sent; // # of bytes already transmitted 721 int input_sent; // # of bytes already transmitted
720 int input_total; // total length of input_data 722 int input_total; // total length of input_data
721 723
722 /** 724 /**
723 * @ref OProcessController is a friend of OProcess because it has to have 725 * @ref OProcessController is a friend of OProcess because it has to have
724 * access to various data members. 726 * access to various data members.
725 */ 727 */
726 friend class Internal::OProcessController; 728 friend class Internal::OProcessController;
727 729
728private: 730private:
729 /** 731 /**
730 * Searches for a valid shell. 732 * Searches for a valid shell.
731 * Here is the algorithm used for finding an executable shell: 733 * Here is the algorithm used for finding an executable shell:
732 * 734 *
733 * @li Try the executable pointed to by the "SHELL" environment 735 * @li Try the executable pointed to by the "SHELL" environment
734 * variable with white spaces stripped off 736 * variable with white spaces stripped off
735 * 737 *
736 * @li If your process runs with uid != euid or gid != egid, a shell 738 * @li If your process runs with uid != euid or gid != egid, a shell
737 * not listed in /etc/shells will not used. 739 * not listed in /etc/shells will not used.
738 * 740 *
739 * @li If no valid shell could be found, "/bin/sh" is used as a last resort. 741 * @li If no valid shell could be found, "/bin/sh" is used as a last resort.
740 */ 742 */
741 QCString searchShell(); 743 QCString searchShell();
742 744
743 /** 745 /**
744 * Used by @ref searchShell in order to find out whether the shell found 746 * Used by @ref searchShell in order to find out whether the shell found
745 * is actually executable at all. 747 * is actually executable at all.
746 */ 748 */
747 bool isExecutable( const QCString &filename ); 749 bool isExecutable( const QCString &filename );
748 750
749 // Disallow assignment and copy-construction 751 // Disallow assignment and copy-construction
750 OProcess( const OProcess& ); 752 OProcess( const OProcess& );
751 OProcess& operator= ( const OProcess& ); 753 OProcess& operator= ( const OProcess& );
752 754
753private: 755private:
754 void init ( ); 756 void init ( );
755 Internal::OProcessPrivate *d; 757 Internal::OProcessPrivate *d;
756}; 758};
757} 759}
758} 760}
759 761
760#endif 762#endif
761 763
diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h
index 4f86d5b..4422741 100644
--- a/libopie2/opieui/oimageeffect.h
+++ b/libopie2/opieui/oimageeffect.h
@@ -1,564 +1,564 @@
1//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? 1//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's?
2//FIXME: Maybe not on SL5xxx, but surely on C700 :)) 2//FIXME: Maybe not on SL5xxx, but surely on C700 :))
3//FIXME: I think we don#t need that -zecke 3//FIXME: I think we don#t need that -zecke
4 4
5/* This file is part of the KDE libraries 5/* This file is part of the KDE libraries
6 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> 6 Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
7 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 7 (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
8 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 8 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
9 9
10Redistribution and use in source and binary forms, with or without 10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions 11modification, are permitted provided that the following conditions
12are met: 12are met:
13 13
141. Redistributions of source code must retain the above copyright 141. Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer. 15 notice, this list of conditions and the following disclaimer.
162. Redistributions in binary form must reproduce the above copyright 162. Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the 17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution. 18 documentation and/or other materials provided with the distribution.
19 19
20THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31*/ 31*/
32 32
33// $Id$ 33// $Id$
34 34
35#ifndef OIMAGEEFFECT_H 35#ifndef OIMAGEEFFECT_H
36#define OIMAGEEFFECT_H 36#define OIMAGEEFFECT_H
37 37
38class QImage; 38class QImage;
39class QSize; 39class QSize;
40class QColor; 40class QColor;
41 41
42namespace Opie { 42namespace Opie {
43namespace Ui { 43namespace Ui {
44/** 44/**
45 * This class includes various @ref QImage based graphical effects. 45 * This class includes various @ref QImage based graphical effects.
46 * 46 *
47 * Everything is 47 * Everything is
48 * static, so there is no need to create an instance of this class. You can 48 * static, so there is no need to create an instance of this class. You can
49 * just call the static methods. They are encapsulated here merely to provide 49 * just call the static methods. They are encapsulated here merely to provide
50 * a common namespace. 50 * a common namespace.
51 */ 51 */
52 52
53class OImageEffect 53class OImageEffect
54{ 54{
55public: 55public:
56 enum GradientType { VerticalGradient, HorizontalGradient, 56 enum GradientType { VerticalGradient, HorizontalGradient,
57 DiagonalGradient, CrossDiagonalGradient, 57 DiagonalGradient, CrossDiagonalGradient,
58 PyramidGradient, RectangleGradient, 58 PyramidGradient, RectangleGradient,
59 PipeCrossGradient, EllipticGradient }; 59 PipeCrossGradient, EllipticGradient };
60 enum RGBComponent { Red, Green, Blue, Gray, All }; 60 enum RGBComponent { Red, Green, Blue, Gray, All };
61 61
62 enum Lighting {NorthLite, NWLite, WestLite, SWLite, 62 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
63 SouthLite, SELite, EastLite, NELite}; 63 SouthLite, SELite, EastLite, NELite};
64 64
65 enum ModulationType { Intensity, Saturation, HueShift, Contrast }; 65 enum ModulationType { Intensity, Saturation, HueShift, Contrast };
66 66
67 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, 67 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
68 ImpulseNoise, LaplacianNoise, PoissonNoise}; 68 ImpulseNoise, LaplacianNoise, PoissonNoise};
69 69
70 enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; 70 enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
71 71
72 /** 72 /**
73 * Create a gradient from color a to color b of the specified type. 73 * Create a gradient from color a to color b of the specified type.
74 * 74 *
75 * @param size The desired size of the gradient. 75 * @param size The desired size of the gradient.
76 * @param ca Color a 76 * @param ca Color a
77 * @param cb Color b 77 * @param cb Color b
78 * @param type The type of gradient. 78 * @param type The type of gradient.
79 * @param ncols The number of colors to use when not running on a 79 * @param ncols The number of colors to use when not running on a
80 * truecolor display. The gradient will be dithered to this number of 80 * truecolor display. The gradient will be dithered to this number of
81 * colors. Pass 0 to prevent dithering. 81 * colors. Pass 0 to prevent dithering.
82 */ 82 */
83 static QImage gradient(const QSize &size, const QColor &ca, 83 static QImage gradient(const QSize &size, const QColor &ca,
84 const QColor &cb, GradientType type, int ncols=3); 84 const QColor &cb, GradientType type, int ncols=3);
85 85
86 /** 86 /**
87 * Create an unbalanced gradient. 87 * Create an unbalanced gradient.
88 88
89 * An unbalanced gradient is a gradient where the transition from 89 * An unbalanced gradient is a gradient where the transition from
90 * color a to color b is not linear, but in this case, exponential. 90 * color a to color b is not linear, but in this case, exponential.
91 * 91 *
92 * @param size The desired size of the gradient. 92 * @param size The desired size of the gradient.
93 * @param ca Color a 93 * @param ca Color a
94 * @param cb Color b 94 * @param cb Color b
95 * @param type The type of gradient. 95 * @param type The type of gradient.
96 * @param xfactor The x decay length. Use a value between -200 and 200. 96 * @param xfactor The x decay length. Use a value between -200 and 200.
97 * @param yfactor The y decay length. 97 * @param yfactor The y decay length.
98 * @param ncols The number of colors. See OPixmapEffect:gradient. 98 * @param ncols The number of colors. See OPixmapEffect:gradient.
99 */ 99 */
100 static QImage unbalancedGradient(const QSize &size, const QColor &ca, 100 static QImage unbalancedGradient(const QSize &size, const QColor &ca,
101 const QColor &cb, GradientType type, int xfactor = 100, 101 const QColor &cb, GradientType type, int xfactor = 100,
102 int yfactor = 100, int ncols = 3); 102 int yfactor = 100, int ncols = 3);
103 103
104 /** 104 /**
105 * Blends a color into the destination image, using an opacity 105 * Blends a color into the destination image, using an opacity
106 * value for blending one into another. Very fast direct pixel 106 * value for blending one into another. Very fast direct pixel
107 * manipulation is used. 107 * manipulation is used.
108 * 108 *
109 * @author Karol Szwed (gallium@kde.org) 109 * @author Karol Szwed (gallium@kde.org)
110 * @param clr source color to be blended into the destination image. 110 * @param clr source color to be blended into the destination image.
111 * @param dst destination image in which the source will be blended into. 111 * @param dst destination image in which the source will be blended into.
112 * @param opacity opacity (in percent) which determines how much the source 112 * @param opacity opacity (in percent) which determines how much the source
113 * color will be blended into the destination image. 113 * color will be blended into the destination image.
114 * @return The destination image (dst) containing the result. 114 * @return The destination image (dst) containing the result.
115 */ 115 */
116 static QImage& blend(const QColor& clr, QImage& dst, float opacity); 116 static QImage& blend(const QColor& clr, QImage& dst, float opacity);
117 117
118 /** 118 /**
119 * Blend the src image into the destination image, using an opacity 119 * Blend the src image into the destination image, using an opacity
120 * value for blending one into another. Very fast direct pixel 120 * value for blending one into another. Very fast direct pixel
121 * manipulation is used. 121 * manipulation is used.
122 * 122 *
123 * @author Karol Szwed (gallium@kde.org) 123 * @author Karol Szwed (gallium@kde.org)
124 * @param src source image to be blended into the destination image. 124 * @param src source image to be blended into the destination image.
125 * @param dst destination image in which the source will be blended into. 125 * @param dst destination image in which the source will be blended into.
126 * @param opacity opacity (in percent) which determines how much the source 126 * @param opacity opacity (in percent) which determines how much the source
127 * image will be blended into the destination image. 127 * image will be blended into the destination image.
128 * @return The destination image (dst) containing the result. 128 * @return The destination image (dst) containing the result.
129 */ 129 */
130 static QImage& blend(QImage& src, QImage& dst, float opacity); 130 static QImage& blend(QImage& src, QImage& dst, float opacity);
131 131
132 /** 132 /**
133 * Blend the provided image into a background of the indicated color. 133 * Blend the provided image into a background of the indicated color.
134 * 134 *
135 * @param initial_intensity this parameter takes values from -1 to 1: 135 * @param initial_intensity this parameter takes values from -1 to 1:
136 * a) if positive: how much to fade the image in its 136 * a) if positive: how much to fade the image in its
137 * less affected spot 137 * less affected spot
138 * b) if negative: roughly indicates how much of the image 138 * b) if negative: roughly indicates how much of the image
139 * remains unaffected 139 * remains unaffected
140 * @param bgnd indicates the color of the background to blend in 140 * @param bgnd indicates the color of the background to blend in
141 * @param eff lets you choose what kind of blending you like 141 * @param eff lets you choose what kind of blending you like
142 * @param anti_dir blend in the opposite direction (makes no much sense 142 * @param anti_dir blend in the opposite direction (makes no much sense
143 * with concentric blending effects) 143 * with concentric blending effects)
144 * @param image must be 32bpp 144 * @param image must be 32bpp
145 */ 145 */
146 static QImage& blend(QImage &image, float initial_intensity, 146 static QImage& blend(QImage &image, float initial_intensity,
147 const QColor &bgnd, GradientType eff, 147 const QColor &bgnd, GradientType eff,
148 bool anti_dir=false); 148 bool anti_dir=false);
149 149
150 /** 150 /**
151 * Blend an image into another one, using a gradient type 151 * Blend an image into another one, using a gradient type
152 * for blending from one to another. 152 * for blending from one to another.
153 * 153 *
154 * @param image1 source1 and result of blending 154 * @param image1 source1 and result of blending
155 * @param image2 source2 of blending 155 * @param image2 source2 of blending
156 * @param gt gradient type for blending between source1 and source2 156 * @param gt gradient type for blending between source1 and source2
157 * @param xf x decay length for unbalanced gradient tpye 157 * @param xf x decay length for unbalanced gradient tpye
158 * @param yf y decay length for unbalanced gradient tpye 158 * @param yf y decay length for unbalanced gradient tpye
159 */ 159 */
160 static QImage& blend(QImage &image1,QImage &image2, 160 static QImage& blend(QImage &image1,QImage &image2,
161 GradientType gt, int xf=100, int yf=100); 161 GradientType gt, int xf=100, int yf=100);
162 162
163 /** 163 /**
164 * Blend an image into another one, using a color channel of a 164 * Blend an image into another one, using a color channel of a
165 * third image for the decision of blending from one to another. 165 * third image for the decision of blending from one to another.
166 * 166 *
167 * @param image1 Source 1 and result of blending 167 * @param image1 Source 1 and result of blending
168 * @param image2 Source 2 of blending 168 * @param image2 Source 2 of blending
169 * @param blendImage If the gray value of of pixel is 0, the result 169 * @param blendImage If the gray value of of pixel is 0, the result
170 * for this pixel is that of image1; for a gray value 170 * for this pixel is that of image1; for a gray value
171 * of 1, the pixel of image2 is used; for a value 171 * of 1, the pixel of image2 is used; for a value
172 * inbetween, a corresponding blending is used. 172 * inbetween, a corresponding blending is used.
173 * @param channel The RBG channel to use for the blending decision. 173 * @param channel The RBG channel to use for the blending decision.
174 */ 174 */
175 static QImage& blend(QImage &image1, QImage &image2, 175 static QImage& blend(QImage &image1, QImage &image2,
176 QImage &blendImage, RGBComponent channel); 176 QImage &blendImage, RGBComponent channel);
177 177
178 /** 178 /**
179 * Blend an image into another one, using alpha in the expected way. 179 * Blend an image into another one, using alpha in the expected way.
180 * @author Rik Hemsley (rikkus) <rik@kde.org> 180 * @author Rik Hemsley (rikkus) <rik@kde.org>
181 */ 181 */
182 static bool blend(const QImage & upper, const QImage & lower, QImage & output); 182 static bool blend(const QImage & upper, const QImage & lower, QImage & output);
183// Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect); 183// Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
184 184
185 /** 185 /**
186 * Blend an image into another one, using alpha in the expected way and 186 * Blend an image into another one, using alpha in the expected way and
187 * over coordinates @p x and @p y with respect to the lower image. 187 * over coordinates @p x and @p y with respect to the lower image.
188 * The output is a QImage which is the @p upper image already blended 188 * The output is a QImage which is the @p upper image already blended
189 * with the @p lower one, so its size will be (in general) the same than 189 * with the @p lower one, so its size will be (in general) the same than
190 * @p upper instead of the same size than @p lower like the method above. 190 * @p upper instead of the same size than @p lower like the method above.
191 * In fact, the size of @p output is like upper's one only when it can be 191 * In fact, the size of @p output is like upper's one only when it can be
192 * painted on lower, if there has to be some clipping, output's size will 192 * painted on lower, if there has to be some clipping, output's size will
193 * be the clipped area and x and y will be set to the correct up-left corner 193 * be the clipped area and x and y will be set to the correct up-left corner
194 * where the clipped rectangle begins. 194 * where the clipped rectangle begins.
195 */ 195 */
196 static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output); 196 static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
197 /** 197 /**
198 * Blend an image into another one, using alpha in the expected way and 198 * Blend an image into another one, using alpha in the expected way and
199 * over coordinates @p x and @p y with respect to the lower image. 199 * over coordinates @p x and @p y with respect to the lower image.
200 * The output is painted in the own @p lower image. This is an optimization 200 * The output is painted in the own @p lower image. This is an optimization
201 * of the blend method above provided by convenience. 201 * of the blend method above provided by convenience.
202 */ 202 */
203 static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower); 203 static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
204 204
205 /** 205 /**
206 * Modifies the intensity of a pixmap's RGB channel component. 206 * Modifies the intensity of a pixmap's RGB channel component.
207 * 207 *
208 * @author Daniel M. Duley (mosfet) 208 * @author Daniel M. Duley (mosfet)
209 * @param image The QImage to process. 209 * @param image The QImage to process.
210 * @param percent Percent value. Use a negative value to dim. 210 * @param percent Percent value. Use a negative value to dim.
211 * @param channel Which channel(s) should be modified 211 * @param channel Which channel(s) should be modified
212 * @return The @p image, provided for convenience. 212 * @return The @p image, provided for convenience.
213 */ 213 */
214 static QImage& channelIntensity(QImage &image, float percent, 214 static QImage& channelIntensity(QImage &image, float percent,
215 RGBComponent channel); 215 RGBComponent channel);
216 216
217 /** 217 /**
218 * Fade an image to a certain background color. 218 * Fade an image to a certain background color.
219 * 219 *
220 * The number of colors will not be changed. 220 * The number of colors will not be changed.
221 * 221 *
222 * @param image The QImage to process. 222 * @param img The QImage to process.
223 * @param val The strength of the effect. 0 <= val <= 1. 223 * @param val The strength of the effect. 0 <= val <= 1.
224 * @param color The background color. 224 * @param color The background color.
225 * @return Returns the @ref image(), provided for convenience. 225 * @return Returns the @ref image(), provided for convenience.
226 */ 226 */
227 static QImage& fade(QImage &img, float val, const QColor &color); 227 static QImage& fade(QImage &img, float val, const QColor &color);
228 228
229 229
230 /** 230 /**
231 * This recolors a pixmap. The most dark color will become color a, 231 * This recolors a pixmap. The most dark color will become color a,
232 * the most bright one color b, and in between. 232 * the most bright one color b, and in between.
233 * 233 *
234 * @param image A QImage to process. 234 * @param image A QImage to process.
235 * @param ca Color a 235 * @param ca Color a
236 * @param cb Color b 236 * @param cb Color b
237 */ 237 */
238 static QImage& flatten(QImage &image, const QColor &ca, 238 static QImage& flatten(QImage &image, const QColor &ca,
239 const QColor &cb, int ncols=0); 239 const QColor &cb, int ncols=0);
240 240
241 /** 241 /**
242 * Build a hash on any given @ref QImage 242 * Build a hash on any given @ref QImage
243 * 243 *
244 * @param image The QImage to process 244 * @param image The QImage to process
245 * @param lite The hash faces the indicated lighting (cardinal poles). 245 * @param lite The hash faces the indicated lighting (cardinal poles).
246 * @param spacing How many unmodified pixels inbetween hashes. 246 * @param spacing How many unmodified pixels inbetween hashes.
247 * @return Returns the @ref image(), provided for convenience. 247 * @return Returns the @ref image(), provided for convenience.
248 */ 248 */
249 static QImage& hash(QImage &image, Lighting lite=NorthLite, 249 static QImage& hash(QImage &image, Lighting lite=NorthLite,
250 unsigned int spacing=0); 250 unsigned int spacing=0);
251 251
252 /** 252 /**
253 * Either brighten or dim the image by a specified percent. 253 * Either brighten or dim the image by a specified percent.
254 * For example, .50 will modify the colors by 50%. 254 * For example, .50 will modify the colors by 50%.
255 * 255 *
256 * @author Daniel M. Duley (mosfet) 256 * @author Daniel M. Duley (mosfet)
257 * @param image The QImage to process. 257 * @param image The QImage to process.
258 * @param percent The percent value. Use a negative value to dim. 258 * @param percent The percent value. Use a negative value to dim.
259 * @return Returns The @ref image(), provided for convenience. 259 * @return Returns The @ref image(), provided for convenience.
260 */ 260 */
261 static QImage& intensity(QImage &image, float percent); 261 static QImage& intensity(QImage &image, float percent);
262 262
263 /** 263 /**
264 * Modulate the image with a color channel of another image. 264 * Modulate the image with a color channel of another image.
265 * 265 *
266 * @param image The QImage to modulate and result. 266 * @param image The QImage to modulate and result.
267 * @param modImage The QImage to use for modulation. 267 * @param modImage The QImage to use for modulation.
268 * @param reverse Invert the meaning of image/modImage; result is image! 268 * @param reverse Invert the meaning of image/modImage; result is image!
269 * @param type The modulation Type to use. 269 * @param type The modulation Type to use.
270 * @param factor The modulation amplitude; with 0 no effect [-200;200]. 270 * @param factor The modulation amplitude; with 0 no effect [-200;200].
271 * @param channel The RBG channel of image2 to use for modulation. 271 * @param channel The RBG channel of image2 to use for modulation.
272 * @return Returns the @ref image(), provided for convenience. 272 * @return Returns the @ref image(), provided for convenience.
273 */ 273 */
274 static QImage& modulate(QImage &image, QImage &modImage, bool reverse, 274 static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
275 ModulationType type, int factor, RGBComponent channel); 275 ModulationType type, int factor, RGBComponent channel);
276 276
277 /** 277 /**
278 * Convert an image to grayscale. 278 * Convert an image to grayscale.
279 * 279 *
280 * @author Daniel M. Duley (mosfet) 280 * @author Daniel M. Duley (mosfet)
281 * @param image The @ref QImage to process. 281 * @param image The @ref QImage to process.
282 * @param fast Set to @p true in order to use a faster but non-photographic 282 * @param fast Set to @p true in order to use a faster but non-photographic
283 * quality algorithm. Appropriate for things such as toolbar icons. 283 * quality algorithm. Appropriate for things such as toolbar icons.
284 * @return Returns the @ref image(), provided for convenience. 284 * @return Returns the @ref image(), provided for convenience.
285 */ 285 */
286 static QImage& toGray(QImage &image, bool fast = false); 286 static QImage& toGray(QImage &image, bool fast = false);
287 287
288 /** 288 /**
289 * Desaturate an image evenly. 289 * Desaturate an image evenly.
290 * 290 *
291 * @param image The QImage to process. 291 * @param image The QImage to process.
292 * @param desat A value between 0 and 1 setting the degree of desaturation 292 * @param desat A value between 0 and 1 setting the degree of desaturation
293 * @return Returns the @ref image(), provided for convenience. 293 * @return Returns the @ref image(), provided for convenience.
294 */ 294 */
295 static QImage& desaturate(QImage &image, float desat = 0.3); 295 static QImage& desaturate(QImage &image, float desat = 0.3);
296 296
297 /** 297 /**
298 * Fast, but low quality contrast of an image. Also see contrastHSV. 298 * Fast, but low quality contrast of an image. Also see contrastHSV.
299 * 299 *
300 * @author Daniel M. Duley (mosfet) 300 * @author Daniel M. Duley (mosfet)
301 * @param image The QImage to process. 301 * @param image The QImage to process.
302 * @param c A contrast value between -255 to 255. 302 * @param c A contrast value between -255 to 255.
303 * @return The @ref image(), provided for convenience. 303 * @return The @ref image(), provided for convenience.
304 */ 304 */
305 static QImage& contrast(QImage &image, int c); 305 static QImage& contrast(QImage &image, int c);
306 306
307 /** 307 /**
308 * Dither an image using Floyd-Steinberg dithering for low-color 308 * Dither an image using Floyd-Steinberg dithering for low-color
309 * situations. 309 * situations.
310 * 310 *
311 * @param image The QImage to process. 311 * @param img The QImage to process.
312 * @param palette The color palette to use 312 * @param palette The color palette to use
313 * @param size The size of the palette 313 * @param size The size of the palette
314 * @return Returns the @ref image(), provided for convenience. 314 * @return Returns the @ref image(), provided for convenience.
315 */ 315 */
316 static QImage& dither(QImage &img, const QColor *palette, int size); 316 static QImage& dither(QImage &img, const QColor *palette, int size);
317 317
318 /** 318 /**
319 * Calculate the image for a selected image, for instance a selected icon 319 * Calculate the image for a selected image, for instance a selected icon
320 * on the desktop. 320 * on the desktop.
321 * @param img the QImage to select 321 * @param img the QImage to select
322 * @param col the selected color, usually from QColorGroup::highlight(). 322 * @param col the selected color, usually from QColorGroup::highlight().
323 */ 323 */
324 static QImage& selectedImage( QImage &img, const QColor &col ); 324 static QImage& selectedImage( QImage &img, const QColor &col );
325 325
326 /** 326 /**
327 * High quality, expensive HSV contrast. You can do a faster one by just 327 * High quality, expensive HSV contrast. You can do a faster one by just
328 * taking a intensity threshold (ie: 128) and incrementing RGB color 328 * taking a intensity threshold (ie: 128) and incrementing RGB color
329 * channels above it and decrementing those below it, but this gives much 329 * channels above it and decrementing those below it, but this gives much
330 * better results. 330 * better results.
331 * 331 *
332 * @author Daniel M. Duley (mosfet) 332 * @author Daniel M. Duley (mosfet)
333 * @param img The QImage to process. 333 * @param img The QImage to process.
334 * @param sharpen If true sharpness is increase, (spiffed). Otherwise 334 * @param sharpen If true sharpness is increase, (spiffed). Otherwise
335 * it is decreased, (dulled). 335 * it is decreased, (dulled).
336 */ 336 */
337 static void contrastHSV(QImage &img, bool sharpen=true); 337 static void contrastHSV(QImage &img, bool sharpen=true);
338 338
339 /** 339 /**
340 * Normalizes the pixel values to span the full range of color values. 340 * Normalizes the pixel values to span the full range of color values.
341 * This is a contrast enhancement technique. 341 * This is a contrast enhancement technique.
342 * @author Daniel M. Duley (mosfet) 342 * @author Daniel M. Duley (mosfet)
343 */ 343 */
344 static void normalize(QImage &img); 344 static void normalize(QImage &img);
345 345
346 /** 346 /**
347 * Performs histogram equalization on the reference 347 * Performs histogram equalization on the reference
348 * image. 348 * image.
349 * @author Daniel M. Duley (mosfet) 349 * @author Daniel M. Duley (mosfet)
350 */ 350 */
351 static void equalize(QImage &img); 351 static void equalize(QImage &img);
352 352
353 /** 353 /**
354 * Thresholds the reference image. You can also threshold images by using 354 * Thresholds the reference image. You can also threshold images by using
355 * ThresholdDither in the various QPixmap/QImage convert methods, but this 355 * ThresholdDither in the various QPixmap/QImage convert methods, but this
356 * lets you specify a threshold value. 356 * lets you specify a threshold value.
357 * 357 *
358 * @author Daniel M. Duley (mosfet) 358 * @author Daniel M. Duley (mosfet)
359 * @param img The QImage to process. 359 * @param img The QImage to process.
360 * @param value The threshold value. 360 * @param value The threshold value.
361 */ 361 */
362 static void threshold(QImage &img, unsigned int value=128); 362 static void threshold(QImage &img, unsigned int value=128);
363 363
364 /** 364 /**
365 * Produces a 'solarization' effect seen when exposing a photographic 365 * Produces a 'solarization' effect seen when exposing a photographic
366 * film to light during the development process. 366 * film to light during the development process.
367 * 367 *
368 * @author Daniel M. Duley (mosfet) 368 * @author Daniel M. Duley (mosfet)
369 * @param img The QImage to process. 369 * @param img The QImage to process.
370 * @param factor The extent of the solarization (0-99.9) 370 * @param factor The extent of the solarization (0-99.9)
371 */ 371 */
372 static void solarize(QImage &img, double factor=50.0); 372 static void solarize(QImage &img, double factor=50.0);
373 373
374 /** 374 /**
375 * Embosses the source image. This involves highlighting the edges 375 * Embosses the source image. This involves highlighting the edges
376 * and applying various other enhancements in order to get a metal 376 * and applying various other enhancements in order to get a metal
377 * effect. 377 * effect.
378 * 378 *
379 * @author Daniel M. Duley (mosfet) 379 * @author Daniel M. Duley (mosfet)
380 * @param src The QImage to process. 380 * @param src The QImage to process.
381 * @return The embossed image. The original is not changed. 381 * @return The embossed image. The original is not changed.
382 */ 382 */
383 static QImage emboss(QImage &src); 383 static QImage emboss(QImage &src);
384 384
385 /** 385 /**
386 * Minimizes speckle noise in the source image using the 8 hull 386 * Minimizes speckle noise in the source image using the 8 hull
387 * algorithm. 387 * algorithm.
388 * 388 *
389 * @author Daniel M. Duley (mosfet) 389 * @author Daniel M. Duley (mosfet)
390 * @param src The QImage to process. 390 * @param src The QImage to process.
391 * @return The despeckled image. The original is not changed. 391 * @return The despeckled image. The original is not changed.
392 */ 392 */
393 static QImage despeckle(QImage &src); 393 static QImage despeckle(QImage &src);
394 394
395 /** 395 /**
396 * Produces a neat little "charcoal" effect. 396 * Produces a neat little "charcoal" effect.
397 * 397 *
398 * @author Daniel M. Duley (mosfet) 398 * @author Daniel M. Duley (mosfet)
399 * @param src The QImage to process. 399 * @param src The QImage to process.
400 * @param factor The factor for detecting lines (0-99.0). 400 * @param factor The factor for detecting lines (0-99.0).
401 * @return The charcoal image. The original is not changed. 401 * @return The charcoal image. The original is not changed.
402 */ 402 */
403 static QImage charcoal(QImage &src, double factor=50.0); 403 static QImage charcoal(QImage &src, double factor=50.0);
404 404
405 /** 405 /**
406 * Rotates the image by the specified amount 406 * Rotates the image by the specified amount
407 * 407 *
408 * @author Daniel M. Duley (mosfet) 408 * @author Daniel M. Duley (mosfet)
409 * @param src The QImage to process. 409 * @param src The QImage to process.
410 * @param r The rotate direction. 410 * @param r The rotate direction.
411 * @return The rotated image. The original is not changed. 411 * @return The rotated image. The original is not changed.
412 */ 412 */
413 static QImage rotate(QImage &src, RotateDirection r); 413 static QImage rotate(QImage &src, RotateDirection r);
414 414
415 /** 415 /**
416 * Scales an image using simple pixel sampling. This does not produce 416 * Scales an image using simple pixel sampling. This does not produce
417 * nearly as nice a result as QImage::smoothScale(), but has the 417 * nearly as nice a result as QImage::smoothScale(), but has the
418 * advantage of being much faster - only a few milliseconds. 418 * advantage of being much faster - only a few milliseconds.
419 * 419 *
420 * @author Daniel M. Duley (mosfet) 420 * @author Daniel M. Duley (mosfet)
421 * @param src The QImage to process. 421 * @param src The QImage to process.
422 * @param w The new width. 422 * @param w The new width.
423 * @param h The new height. 423 * @param h The new height.
424 * @return The scaled image. The original is not changed. 424 * @return The scaled image. The original is not changed.
425 */ 425 */
426 static QImage sample(QImage &src, int w, int h); 426 static QImage sample(QImage &src, int w, int h);
427 427
428 /** 428 /**
429 * Adds noise to an image. 429 * Adds noise to an image.
430 * 430 *
431 * @author Daniel M. Duley (mosfet) 431 * @author Daniel M. Duley (mosfet)
432 * @param src The QImage to process. 432 * @param src The QImage to process.
433 * @param type The algorithm used to generate the noise. 433 * @param type The algorithm used to generate the noise.
434 * @return The image with noise added. The original is not changed. 434 * @return The image with noise added. The original is not changed.
435 */ 435 */
436 static QImage addNoise(QImage &src, NoiseType type = GaussianNoise); 436 static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
437 437
438 /** 438 /**
439 * Blurs an image by convolving pixel neighborhoods. 439 * Blurs an image by convolving pixel neighborhoods.
440 * 440 *
441 * @author Daniel M. Duley (mosfet) 441 * @author Daniel M. Duley (mosfet)
442 * @param src The QImage to process. 442 * @param src The QImage to process.
443 * @param factor The percent weight to give to the center pixel. 443 * @param factor The percent weight to give to the center pixel.
444 * @return The blurred image. The original is not changed. 444 * @return The blurred image. The original is not changed.
445 */ 445 */
446 static QImage blur(QImage &src, double factor=50.0); 446 static QImage blur(QImage &src, double factor=50.0);
447 447
448 /** 448 /**
449 * Detects edges in an image using pixel neighborhoods and an edge 449 * Detects edges in an image using pixel neighborhoods and an edge
450 * detection mask. 450 * detection mask.
451 * 451 *
452 * @author Daniel M. Duley (mosfet) 452 * @author Daniel M. Duley (mosfet)
453 * @param src The QImage to process. 453 * @param src The QImage to process.
454 * @param factor The percent weight to give to the center pixel. 454 * @param factor The percent weight to give to the center pixel.
455 * @return The image with edges detected. The original is not changed. 455 * @return The image with edges detected. The original is not changed.
456 */ 456 */
457 static QImage edge(QImage &src, double factor=50.0); 457 static QImage edge(QImage &src, double factor=50.0);
458 458
459 /** 459 /**
460 * Implodes an image by a specified percent. 460 * Implodes an image by a specified percent.
461 * 461 *
462 * @author Daniel M. Duley (mosfet) 462 * @author Daniel M. Duley (mosfet)
463 * @param src The QImage to process. 463 * @param src The QImage to process.
464 * @param factor The extent of the implosion. 464 * @param factor The extent of the implosion.
465 * @param background An RGBA value to use for the background. After the 465 * @param background An RGBA value to use for the background. After the
466 * effect some pixels may be "empty". This value is used for those pixels. 466 * effect some pixels may be "empty". This value is used for those pixels.
467 * @return The imploded image. The original is not changed. 467 * @return The imploded image. The original is not changed.
468 */ 468 */
469 static QImage implode(QImage &src, double factor=30.0, 469 static QImage implode(QImage &src, double factor=30.0,
470 unsigned int background = 0xFFFFFFFF); 470 unsigned int background = 0xFFFFFFFF);
471 /** 471 /**
472 * Produces an oil painting effect. 472 * Produces an oil painting effect.
473 * 473 *
474 * @author Daniel M. Duley (mosfet) 474 * @author Daniel M. Duley (mosfet)
475 * @param src The QImage to process. 475 * @param src The QImage to process.
476 * @param radius The radius of the pixel neighborhood used in applying the 476 * @param radius The radius of the pixel neighborhood used in applying the
477 * effect. 477 * effect.
478 * @return The new image. The original is not changed. 478 * @return The new image. The original is not changed.
479 */ 479 */
480 static QImage oilPaint(QImage &src, int radius=3); 480 static QImage oilPaint(QImage &src, int radius=3);
481 481
482 /** 482 /**
483 * Sharpens the pixels in the image using pixel neighborhoods. 483 * Sharpens the pixels in the image using pixel neighborhoods.
484 * 484 *
485 * @author Daniel M. Duley (mosfet) 485 * @author Daniel M. Duley (mosfet)
486 * @param src The QImage to process. 486 * @param src The QImage to process.
487 * @param factor The percent weight to give to the center pixel. 487 * @param factor The percent weight to give to the center pixel.
488 * @return The sharpened image. The original is not changed. 488 * @return The sharpened image. The original is not changed.
489 */ 489 */
490 static QImage sharpen(QImage &src, double factor=30.0); 490 static QImage sharpen(QImage &src, double factor=30.0);
491 491
492 /** 492 /**
493 * Randomly displaces pixels. 493 * Randomly displaces pixels.
494 * 494 *
495 * @author Daniel M. Duley (mosfet) 495 * @author Daniel M. Duley (mosfet)
496 * @param src The QImage to process. 496 * @param src The QImage to process.
497 * @param amount The vicinity for choosing a random pixel to swap. 497 * @param amount The vicinity for choosing a random pixel to swap.
498 * @return The image with pixels displaced. The original is not changed. 498 * @return The image with pixels displaced. The original is not changed.
499 */ 499 */
500 static QImage spread(QImage &src, unsigned int amount=3); 500 static QImage spread(QImage &src, unsigned int amount=3);
501 501
502 /** 502 /**
503 * Shades the image using a distance light source. 503 * Shades the image using a distance light source.
504 * 504 *
505 * @author Daniel M. Duley (mosfet) 505 * @author Daniel M. Duley (mosfet)
506 * @param src The QImage to process. 506 * @param src The QImage to process.
507 * @param color_shading If true do color shading, otherwise do grayscale. 507 * @param color_shading If true do color shading, otherwise do grayscale.
508 * @param azimuth Determines the light source and direction. 508 * @param azimuth Determines the light source and direction.
509 * @param elevation Determines the light source and direction. 509 * @param elevation Determines the light source and direction.
510 * @return The shaded image. The original is not changed. 510 * @return The shaded image. The original is not changed.
511 */ 511 */
512 static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0, 512 static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
513 double elevation=30.0); 513 double elevation=30.0);
514 /** 514 /**
515 * Swirls the image by a specified amount 515 * Swirls the image by a specified amount
516 * 516 *
517 * @author Daniel M. Duley (mosfet) 517 * @author Daniel M. Duley (mosfet)
518 * @param src The QImage to process. 518 * @param src The QImage to process.
519 * @param degrees The tightness of the swirl. 519 * @param degrees The tightness of the swirl.
520 * @param background An RGBA value to use for the background. After the 520 * @param background An RGBA value to use for the background. After the
521 * effect some pixels may be "empty". This value is used for those pixels. 521 * effect some pixels may be "empty". This value is used for those pixels.
522 * @return The swirled image. The original is not changed. 522 * @return The swirled image. The original is not changed.
523 */ 523 */
524 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background = 524 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
525 0xFFFFFFFF); 525 0xFFFFFFFF);
526 526
527 /** 527 /**
528 * Modifies the pixels along a sine wave. 528 * Modifies the pixels along a sine wave.
529 * 529 *
530 * @author Daniel M. Duley (mosfet) 530 * @author Daniel M. Duley (mosfet)
531 * @param src The QImage to process. 531 * @param src The QImage to process.
532 * @param amplitude The amplitude of the sine wave. 532 * @param amplitude The amplitude of the sine wave.
533 * @param wavelength The frequency of the sine wave. 533 * @param frequency The frequency of the sine wave.
534 * @return The new image. The original is not changed. 534 * @return The new image. The original is not changed.
535 */ 535 */
536 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0, 536 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
537 unsigned int background = 0xFFFFFFFF); 537 unsigned int background = 0xFFFFFFFF);
538 538
539private: 539private:
540 540
541 /** 541 /**
542 * Helper function to fast calc some altered (lighten, shaded) colors 542 * Helper function to fast calc some altered (lighten, shaded) colors
543 * 543 *
544 */ 544 */
545 static unsigned int lHash(unsigned int c); 545 static unsigned int lHash(unsigned int c);
546 static unsigned int uHash(unsigned int c); 546 static unsigned int uHash(unsigned int c);
547 547
548 /** 548 /**
549 * Helper function to find the nearest color to the RBG triplet 549 * Helper function to find the nearest color to the RBG triplet
550 */ 550 */
551 static int nearestColor( int r, int g, int b, const QColor *pal, int size ); 551 static int nearestColor( int r, int g, int b, const QColor *pal, int size );
552 552
553 static void hull(const int x_offset, const int y_offset, const int polarity, 553 static void hull(const int x_offset, const int y_offset, const int polarity,
554 const int width, const int height, 554 const int width, const int height,
555 unsigned int *f, unsigned int *g); 555 unsigned int *f, unsigned int *g);
556 static unsigned int generateNoise(unsigned int pixel, NoiseType type); 556 static unsigned int generateNoise(unsigned int pixel, NoiseType type);
557 static unsigned int interpolateColor(QImage *image, double x, double y, 557 static unsigned int interpolateColor(QImage *image, double x, double y,
558 unsigned int background); 558 unsigned int background);
559}; 559};
560 560
561} 561}
562} 562}
563 563
564#endif 564#endif
diff --git a/libopie2/opieui/opixmapeffect.h b/libopie2/opieui/opixmapeffect.h
index b780f9f..85a1e25 100644
--- a/libopie2/opieui/opixmapeffect.h
+++ b/libopie2/opieui/opixmapeffect.h
@@ -1,219 +1,214 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> 2 Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> 3 (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> 4 (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
5 5
6*/ 6*/
7 7
8// $Id$ 8// $Id$
9 9
10#ifndef __OPIXMAP_EFFECT_H 10#ifndef __OPIXMAP_EFFECT_H
11#define __OPIXMAP_EFFECT_H 11#define __OPIXMAP_EFFECT_H
12 12
13 13
14#include <qsize.h> 14#include <qsize.h>
15typedef QPixmap OPixmap; 15typedef QPixmap OPixmap;
16class QColor; 16class QColor;
17 17
18 18
19namespace Opie { 19namespace Opie {
20namespace Ui { 20namespace Ui {
21/** 21/**
22 * This class includes various pixmap-based graphical effects. 22 * This class includes various pixmap-based graphical effects.
23 * 23 *
24 * Everything is 24 * Everything is
25 * static, so there is no need to create an instance of this class. You can 25 * static, so there is no need to create an instance of this class. You can
26 * just call the static methods. They are encapsulated here merely to provide 26 * just call the static methods. They are encapsulated here merely to provide
27 * a common namespace. 27 * a common namespace.
28 */ 28 */
29class OPixmapEffect 29class OPixmapEffect
30{ 30{
31public: 31public:
32 enum GradientType { VerticalGradient, HorizontalGradient, 32 enum GradientType { VerticalGradient, HorizontalGradient,
33 DiagonalGradient, CrossDiagonalGradient, 33 DiagonalGradient, CrossDiagonalGradient,
34 PyramidGradient, RectangleGradient, 34 PyramidGradient, RectangleGradient,
35 PipeCrossGradient, EllipticGradient }; 35 PipeCrossGradient, EllipticGradient };
36 enum RGBComponent { Red, Green, Blue }; 36 enum RGBComponent { Red, Green, Blue };
37 37
38 enum Lighting {NorthLite, NWLite, WestLite, SWLite, 38 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
39 SouthLite, SELite, EastLite, NELite}; 39 SouthLite, SELite, EastLite, NELite};
40 40
41 /** 41 /**
42 * Creates a gradient from color a to color b of the specified type. 42 * Creates a gradient from color a to color b of the specified type.
43 * 43 *
44 * @param pixmap The pixmap to process. 44 * @param pixmap The pixmap to process.
45 * @param ca Color a. 45 * @param ca Color a.
46 * @param cb Color b. 46 * @param cb Color b.
47 * @param type The type of gradient. 47 * @param type The type of gradient.
48 * @param ncols The number of colors to use when not running on a 48 * @param ncols The number of colors to use when not running on a
49 * truecolor display. The gradient will be dithered to this number of 49 * truecolor display. The gradient will be dithered to this number of
50 * colors. Pass 0 to prevent dithering. 50 * colors. Pass 0 to prevent dithering.
51 * @return Returns the generated pixmap, for convenience. 51 * @return Returns the generated pixmap, for convenience.
52 */ 52 */
53 static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb, 53 static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb,
54 GradientType type, int ncols=3); 54 GradientType type, int ncols=3);
55 55
56 /** 56 /**
57 * Creates an unbalanced gradient. 57 * Creates an unbalanced gradient.
58 * 58 *
59 * An unbalanced gradient is a gradient where the transition from 59 * An unbalanced gradient is a gradient where the transition from
60 * color a to color b is not linear, but in this case, exponential. 60 * color a to color b is not linear, but in this case, exponential.
61 * 61 *
62 * @param pixmap The pixmap that should be written. 62 * @param pixmap The pixmap that should be written.
63 * @param ca Color a. 63 * @param ca Color a.
64 * @param cb Color b. 64 * @param cb Color b.
65 * @param type The type of gradient. 65 * @param type The type of gradient.
66 * @param xfactor The x decay length. Use a value between -200 and 200. 66 * @param xfactor The x decay length. Use a value between -200 and 200.
67 * @param yfactor The y decay length. 67 * @param yfactor The y decay length.
68 * @param ncols The number of colors. See #gradient. 68 * @param ncols The number of colors. See #gradient.
69 * @return The generated pixmap, for convencience. 69 * @return The generated pixmap, for convencience.
70 */ 70 */
71 static OPixmap& unbalancedGradient(OPixmap& pixmap, const QColor &ca, 71 static OPixmap& unbalancedGradient(OPixmap& pixmap, const QColor &ca,
72 const QColor &cb, GradientType type, int xfactor = 100, 72 const QColor &cb, GradientType type, int xfactor = 100,
73 int yfactor = 100, int ncols=3); 73 int yfactor = 100, int ncols=3);
74 74
75 /** 75 /**
76 * Creates a pixmap of a given size with the given pixmap. 76 * Creates a pixmap of a given size with the given pixmap.
77 * 77 *
78 * if the 78 * if the
79 * given size is bigger than the size of the pixmap, the pixmap is 79 * given size is bigger than the size of the pixmap, the pixmap is
80 * tiled. 80 * tiled.
81 * 81 *
82 * @param pixmap This is the source pixmap 82 * @param pixmap This is the source pixmap
83 * @param size The size the new pixmap should have. 83 * @param size The size the new pixmap should have.
84 * @return The generated, tiled pixmap. 84 * @return The generated, tiled pixmap.
85 */ 85 */
86 static OPixmap createTiled(const OPixmap& pixmap, QSize size); 86 static OPixmap createTiled(const OPixmap& pixmap, QSize size);
87 87
88 /** 88 /**
89 * Either brightens or dims a pixmap by a specified ratio. 89 * Either brightens or dims a pixmap by a specified ratio.
90 * 90 *
91 * @param pixmap The pixmap to process. 91 * @param pixmap The pixmap to process.
92 * @param ratio The ratio to use. Use negative value to dim. 92 * @param ratio The ratio to use. Use negative value to dim.
93 * @return Returns The @ref pixmap(), provided for convenience. 93 * @return Returns The @ref pixmap(), provided for convenience.
94 */ 94 */
95 static OPixmap& intensity(OPixmap& pixmap, float ratio); 95 static OPixmap& intensity(OPixmap& pixmap, float ratio);
96 96
97 /** 97 /**
98 * Modifies the intensity of a pixmap's RGB channel component. 98 * Modifies the intensity of a pixmap's RGB channel component.
99 * 99 *
100 * @param pixmap The pixmap to process. 100 * @param pixmap The pixmap to process.
101 * @param ratio value. Use negative value to dim. 101 * @param ratio value. Use negative value to dim.
102 * @param channel Which channel(s) should be modified 102 * @param channel Which channel(s) should be modified
103 * @return Returns the @ref pixmap(), provided for convenience. 103 * @return Returns the @ref pixmap(), provided for convenience.
104 */ 104 */
105 static OPixmap& channelIntensity(OPixmap& pixmap, float ratio, 105 static OPixmap& channelIntensity(OPixmap& pixmap, float ratio,
106 RGBComponent channel); 106 RGBComponent channel);
107 107
108 /** 108 /**
109 * Blends the provided pixmap into a background of the indicated color. 109 * Blends the provided pixmap into a background of the indicated color.
110 * 110 *
111 * @param pixmap The pixmap to process. 111 * @param pixmap The pixmap to process.
112 * @param initial_intensity this parameter takes values from -1 to 1: 112 * @param initial_intensity this parameter takes values from -1 to 1:
113 * @li If positive, it tells how much to fade the image in its 113 * @li If positive, it tells how much to fade the image in its
114 * less affected spot. 114 * less affected spot.
115 * @li If negative, it tells roughly indicates how much of the image 115 * @li If negative, it tells roughly indicates how much of the image
116 * remains unaffected 116 * remains unaffected
117 * @param bgnd Indicates the color of the background to blend in. 117 * @param bgnd Indicates the color of the background to blend in.
118 * @param eff Lets you choose what kind of blending you like. 118 * @param eff Lets you choose what kind of blending you like.
119 * @param anti_dir Blend in the opposite direction (makes no much sense 119 * @param anti_dir Blend in the opposite direction (makes no much sense
120 * with concentric blending effects). 120 * with concentric blending effects).
121 * @return Returns the @ref pixmap(), provided for convenience. 121 * @return Returns the @ref pixmap(), provided for convenience.
122 */ 122 */
123 static OPixmap& blend(OPixmap& pixmap, float initial_intensity, 123 static OPixmap& blend(OPixmap& pixmap, float initial_intensity,
124 const QColor &bgnd, GradientType eff, 124 const QColor &bgnd, GradientType eff,
125 bool anti_dir=false, int ncols=3); 125 bool anti_dir=false, int ncols=3);
126 126
127 /** 127 /**
128 * Builds a hash on any given pixmap. 128 * Builds a hash on any given pixmap.
129 * 129 *
130 * @param pixmap The pixmap to process. 130 * @param pixmap The pixmap to process.
131 * @param lite The hash faces the indicated lighting (cardinal poles) 131 * @param lite The hash faces the indicated lighting (cardinal poles)
132 * @param spacing How many unmodified pixels inbetween hashes. 132 * @param spacing How many unmodified pixels inbetween hashes.
133 * @return Returns The @ref pixmap(), provided for convenience. 133 * @return Returns The @ref pixmap(), provided for convenience.
134 */ 134 */
135 static OPixmap& hash(OPixmap& pixmap, Lighting lite=NorthLite, 135 static OPixmap& hash(OPixmap& pixmap, Lighting lite=NorthLite,
136 unsigned int spacing=0, int ncols=3); 136 unsigned int spacing=0, int ncols=3);
137 137
138 /** 138 /**
139 * Creates a pattern from a pixmap. 139 * Creates a pattern from a pixmap.
140 * 140 *
141 * The given pixmap is "flattened" 141 * The given pixmap is "flattened"
142 * between color a to color b. 142 * between color a to color b.
143 * 143 *
144 * @param pixmap The pixmap to process. 144 * @param pixmap The pixmap to process.
145 * @param ca Color a. 145 * @param ca Color a.
146 * @param cb Color b. 146 * @param cb Color b.
147 * @param ncols The number of colors to use. The image will be 147 * @param ncols The number of colors to use. The image will be
148 * dithered to this depth. Pass zero to prevent dithering. 148 * dithered to this depth. Pass zero to prevent dithering.
149 * @return The @ref pixmap(), provided for convenience. 149 * @return The @ref pixmap(), provided for convenience.
150 */ 150 */
151 static OPixmap pattern(const OPixmap& pixmap, QSize size, 151 static OPixmap pattern(const OPixmap& pixmap, QSize size,
152 const QColor &ca, const QColor &cb, int ncols=8); 152 const QColor &ca, const QColor &cb, int ncols=8);
153 153
154 /** 154 /**
155 * Recolors a pixmap. 155 * Fades a pixmap to a certain color.
156 *
157 * The most dark color will become color a,
158 * the most bright one color b, and in between.
159 * 156 *
160 * @param pixmap The pixmap to process. 157 * @param pixmap The pixmap to process.
161 * @param ca Color a. 158 * @param val The strength of the effect. 0 <= val <= 1.
162 * @param cb Color b. 159 * @param color The color to blend to.
163 * @param ncols The number of colors to use. Pass zero to prevent
164 * dithering.
165 * @return Returns the @ref pixmap(), provided for convenience. 160 * @return Returns the @ref pixmap(), provided for convenience.
166 */ 161 */
167 static OPixmap& fade(OPixmap& pixmap, double val, const QColor &color); 162 static OPixmap& fade(OPixmap& pixmap, double val, const QColor &color);
168 163
169 /** 164 /**
170 * Converts a pixmap to grayscale. 165 * Converts a pixmap to grayscale.
171 * 166 *
172 * @param pixmap The pixmap to process. 167 * @param pixmap The pixmap to process.
173 * @param fast Set to @p true in order to use a faster but non-photographic 168 * @param fast Set to @p true in order to use a faster but non-photographic
174 * quality algorithm. Appropriate for things such as toolbar icons. 169 * quality algorithm. Appropriate for things such as toolbar icons.
175 * @return Returns the @ref pixmap(), provided for convenience. 170 * @return Returns the @ref pixmap(), provided for convenience.
176 */ 171 */
177 static OPixmap& toGray(OPixmap& pixmap, bool fast=false); 172 static OPixmap& toGray(OPixmap& pixmap, bool fast=false);
178 173
179 /** 174 /**
180 * Desaturates a pixmap. 175 * Desaturates a pixmap.
181 * 176 *
182 * @param pixmap The pixmap to process. 177 * @param pixmap The pixmap to process.
183 * @param desat A value between 0 and 1 setting the degree of desaturation 178 * @param desat A value between 0 and 1 setting the degree of desaturation
184 * @return Returns The @ref pixmap(), provided for convenience. 179 * @return Returns The @ref pixmap(), provided for convenience.
185 */ 180 */
186 static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3); 181 static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3);
187 182
188 /** 183 /**
189 * Modifies the contrast of a pixmap. 184 * Modifies the contrast of a pixmap.
190 * 185 *
191 * @param pixmap The pixmap to process. 186 * @param pixmap The pixmap to process.
192 * @param c A contrast value between -255 and 255. 187 * @param c A contrast value between -255 and 255.
193 * @return Returns the @ref pixmap(), provided for convenience. 188 * @return Returns the @ref pixmap(), provided for convenience.
194 */ 189 */
195 static OPixmap& contrast(OPixmap& pixmap, int c); 190 static OPixmap& contrast(OPixmap& pixmap, int c);
196 191
197 /** 192 /**
198 * Dithers a pixmap using Floyd-Steinberg dithering for low-color 193 * Dithers a pixmap using Floyd-Steinberg dithering for low-color
199 * situations. 194 * situations.
200 * 195 *
201 * @param pixmap The pixmap to process. 196 * @param pixmap The pixmap to process.
202 * @param palette The color palette to use. 197 * @param palette The color palette to use.
203 * @param size The size of the palette. 198 * @param size The size of the palette.
204 * @return Returns the @ref pixmap(), provided for convenience. 199 * @return Returns the @ref pixmap(), provided for convenience.
205 */ 200 */
206 static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size); 201 static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size);
207 202
208 /** 203 /**
209 * Calculate a 'selected' pixmap, for instance a selected icon 204 * Calculate a 'selected' pixmap, for instance a selected icon
210 * on the desktop. 205 * on the desktop.
211 * @param pixmap the pixmap to select 206 * @param pixmap the pixmap to select
212 * @param col the selected color, usually from QColorGroup::highlight(). 207 * @param col the selected color, usually from QColorGroup::highlight().
213 */ 208 */
214 static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col ); 209 static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col );
215}; 210};
216} 211}
217} 212}
218 213
219#endif 214#endif
diff --git a/libopie2/qt3/opieui/ocombobox.h b/libopie2/qt3/opieui/ocombobox.h
index 4e35b61..3f60f54 100644
--- a/libopie2/qt3/opieui/ocombobox.h
+++ b/libopie2/qt3/opieui/ocombobox.h
@@ -1,356 +1,356 @@
1/* 1/*
2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
3 is part of the Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 3 is part of the Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
4 Opie Project Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org> 4 Opie Project Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
5 5
6 =. Originally part of the KDE projects 6 =. Originally part of the KDE projects
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OCOMBOBOX_H 33#ifndef OCOMBOBOX_H
34#define OCOMBOBOX_H 34#define OCOMBOBOX_H
35 35
36/* QT */ 36/* QT */
37 37
38#include <qcombobox.h> 38#include <qcombobox.h>
39 39
40/* OPIE */ 40/* OPIE */
41 41
42#include <opie2/olineedit.h> 42#include <opie2/olineedit.h>
43#include <opie2/ocompletion.h> 43#include <opie2/ocompletion.h>
44#include <opie2/ocompletionbase.h> 44#include <opie2/ocompletionbase.h>
45 45
46/* FORWARDS */ 46/* FORWARDS */
47 47
48class QListBoxItem; 48class QListBoxItem;
49class QPopupMenu; 49class QPopupMenu;
50class OCompletionBox; 50class OCompletionBox;
51typedef QString OURL; 51typedef QString OURL;
52 52
53/** 53/**
54 * A combined button, line-edit and a popup list widget. 54 * A combined button, line-edit and a popup list widget.
55 * 55 *
56 * @sect Detail 56 * @par Detail
57 * 57 *
58 * This widget inherits from @ref QComboBox and implements 58 * This widget inherits from @ref QComboBox and implements
59 * the following additional functionalities: a completion 59 * the following additional functionalities: a completion
60 * object that provides both automatic and manual text 60 * object that provides both automatic and manual text
61 * completion as well as text rotation features, configurable 61 * completion as well as text rotation features, configurable
62 * key-bindings to activate these features, and a popup-menu 62 * key-bindings to activate these features, and a popup-menu
63 * item that can be used to allow the user to set text completion 63 * item that can be used to allow the user to set text completion
64 * modes on the fly based on their preference. 64 * modes on the fly based on their preference.
65 * 65 *
66 * To support these new features OComboBox also emits a few 66 * To support these new features OComboBox also emits a few
67 * more additional signals as well. The main ones are the 67 * more additional signals as well. The main ones are the
68 * @ref completion( const QString& ) and @ref textRotation( KeyBindingType ) 68 * @ref completion( const QString& ) and @ref textRotation( KeyBindingType )
69 * signals. The completion signal is intended to be connected to a slot 69 * signals. The completion signal is intended to be connected to a slot
70 * that will assist the user in filling out the remaining text while 70 * that will assist the user in filling out the remaining text while
71 * the rotation signals is intended to be used to traverse through all 71 * the rotation signals is intended to be used to traverse through all
72 * possible matches whenever text completion results in multiple matches. 72 * possible matches whenever text completion results in multiple matches.
73 * The @ref returnPressed() and @ref returnPressed( const QString& ) 73 * The @ref returnPressed() and @ref returnPressed( const QString& )
74 * signal is emitted when the user presses the Enter/Return key. 74 * signal is emitted when the user presses the Enter/Return key.
75 * 75 *
76 * This widget by default creates a completion object when you invoke 76 * This widget by default creates a completion object when you invoke
77 * the @ref completionObject( bool ) member function for the first time 77 * the @ref completionObject( bool ) member function for the first time
78 * or use @ref setCompletionObject( OCompletion*, bool ) to assign your 78 * or use @ref setCompletionObject( OCompletion*, bool ) to assign your
79 * own completion object. Additionally, to make this widget more functional, 79 * own completion object. Additionally, to make this widget more functional,
80 * OComboBox will by default handle the text rotation and completion 80 * OComboBox will by default handle the text rotation and completion
81 * events internally whenever a completion object is created through either 81 * events internally whenever a completion object is created through either
82 * one of the methods mentioned above. If you do not need this functionality, 82 * one of the methods mentioned above. If you do not need this functionality,
83 * simply use @ref OCompletionBase::setHandleSignals( bool ) or alternatively 83 * simply use @ref OCompletionBase::setHandleSignals( bool ) or alternatively
84 * set the boolean parameter in the above methods to FALSE. 84 * set the boolean parameter in the above methods to FALSE.
85 * 85 *
86 * The default key-bindings for completion and rotation is determined 86 * The default key-bindings for completion and rotation is determined
87 * from the global settings in @ref OStdAccel. These values, however, 87 * from the global settings in @ref OStdAccel. These values, however,
88 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding(). 88 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
89 * The values can easily be reverted back to the default setting, by simply 89 * The values can easily be reverted back to the default setting, by simply
90 * calling @ref useGlobalSettings(). An alternate method would be to default 90 * calling @ref useGlobalSettings(). An alternate method would be to default
91 * individual key-bindings by usning @ref setKeyBinding() with the default 91 * individual key-bindings by usning @ref setKeyBinding() with the default
92 * second argument. 92 * second argument.
93 * 93 *
94 * Note that if this widget is not editable ( i.e. select-only ), then only 94 * Note that if this widget is not editable ( i.e. select-only ), then only
95 * one completion mode, @p CompletionAuto, will work. All the other modes are 95 * one completion mode, @p CompletionAuto, will work. All the other modes are
96 * simply ignored. The @p CompletionAuto mode in this case allows you to 96 * simply ignored. The @p CompletionAuto mode in this case allows you to
97 * automatically select an item from the list by trying to match the pressed 97 * automatically select an item from the list by trying to match the pressed
98 * keycode with the first letter of the enteries in the combo box. 98 * keycode with the first letter of the enteries in the combo box.
99 * 99 *
100 * @sect Useage 100 * @par Usage
101 * 101 *
102 * To enable the basic completion feature: 102 * To enable the basic completion feature:
103 * 103 *
104 * <pre> 104 * <pre>
105 * OComboBox *combo = new OComboBox( true, this, "mywidget" ); 105 * OComboBox *combo = new OComboBox( true, this, "mywidget" );
106 * OCompletion *comp = combo->completionObject(); 106 * OCompletion *comp = combo->completionObject();
107 * // Connect to the return pressed signal - optional 107 * // Connect to the return pressed signal - optional
108 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 108 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
109 * </pre> 109 * </pre>
110 * 110 *
111 * To use your own completion object: 111 * To use your own completion object:
112 * 112 *
113 * <pre> 113 * <pre>
114 * OComboBox *combo = new OComboBox( this,"mywidget" ); 114 * OComboBox *combo = new OComboBox( this,"mywidget" );
115 * OURLCompletion *comp = new OURLCompletion(); 115 * OURLCompletion *comp = new OURLCompletion();
116 * combo->setCompletionObject( comp ); 116 * combo->setCompletionObject( comp );
117 * // Connect to the return pressed signal - optional 117 * // Connect to the return pressed signal - optional
118 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 118 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
119 * </pre> 119 * </pre>
120 * 120 *
121 * Note that you have to either delete the allocated completion object 121 * Note that you have to either delete the allocated completion object
122 * when you don't need it anymore, or call 122 * when you don't need it anymore, or call
123 * setAutoDeleteCompletionObject( true ); 123 * setAutoDeleteCompletionObject( true );
124 * 124 *
125 * Miscellaneous function calls: 125 * Miscellaneous function calls:
126 * 126 *
127 * <pre> 127 * <pre>
128 * // Tell the widget not to handle completion and rotation 128 * // Tell the widget not to handle completion and rotation
129 * combo->setHandleSignals( false ); 129 * combo->setHandleSignals( false );
130 * // Set your own completion key for manual completions. 130 * // Set your own completion key for manual completions.
131 * combo->setKeyBinding( OCompletionBase::TextCompletion, Qt::End ); 131 * combo->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
132 * // Hide the context (popup) menu 132 * // Hide the context (popup) menu
133 * combo->setContextMenuEnabled( false ); 133 * combo->setContextMenuEnabled( false );
134 * // Temporarly disable signal emition 134 * // Temporarly disable signal emition
135 * combo->disableSignals(); 135 * combo->disableSignals();
136 * // Default the all key-bindings to their system-wide settings. 136 * // Default the all key-bindings to their system-wide settings.
137 * combo->useGlobalKeyBindings(); 137 * combo->useGlobalKeyBindings();
138 * </pre> 138 * </pre>
139 * 139 *
140 * @short An enhanced combo box. 140 * @short An enhanced combo box.
141 * @author Dawit Alemayehu <adawit@kde.org> 141 * @author Dawit Alemayehu <adawit@kde.org>
142 */ 142 */
143class OComboBox : public QComboBox, public OCompletionBase 143class OComboBox : public QComboBox, public OCompletionBase
144{ 144{
145 Q_OBJECT 145 Q_OBJECT
146 146
147 //Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion ) 147 //Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
148 //Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 148 //Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
149 //Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 149 //Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
150 150
151public: 151public:
152 152
153 /** 153 /**
154 * Constructs a read-only or rather select-only combo box with a 154 * Constructs a read-only or rather select-only combo box with a
155 * parent object and a name. 155 * parent object and a name.
156 * 156 *
157 * @param parent The parent object of this widget 157 * @param parent The parent object of this widget
158 * @param name The name of this widget 158 * @param name The name of this widget
159 */ 159 */
160 OComboBox( QWidget *parent=0, const char *name=0 ); 160 OComboBox( QWidget *parent=0, const char *name=0 );
161 161
162 /** 162 /**
163 * Constructs a "read-write" or "read-only" combo box depending on 163 * Constructs a "read-write" or "read-only" combo box depending on
164 * the value of the first argument( @p rw ) with a parent, a 164 * the value of the first argument( @p rw ) with a parent, a
165 * name. 165 * name.
166 * 166 *
167 * @param rw When @p true, widget will be editable. 167 * @param rw When @p true, widget will be editable.
168 * @param parent The parent object of this widget. 168 * @param parent The parent object of this widget.
169 * @param name The name of this widget. 169 * @param name The name of this widget.
170 */ 170 */
171 OComboBox( bool rw, QWidget *parent=0, const char *name=0 ); 171 OComboBox( bool rw, QWidget *parent=0, const char *name=0 );
172 172
173 /** 173 /**
174 * Destructor. 174 * Destructor.
175 */ 175 */
176 virtual ~OComboBox(); 176 virtual ~OComboBox();
177 177
178 /** 178 /**
179 * Sets @p url into the edit field of the combobox. It uses 179 * Sets @p url into the edit field of the combobox. It uses
180 * @ref OURL::prettyURL() so that the url is properly decoded for 180 * @ref OURL::prettyURL() so that the url is properly decoded for
181 * displaying. 181 * displaying.
182 */ 182 */
183 //void setEditURL( const OURL& url ); 183 //void setEditURL( const OURL& url );
184 184
185 /** 185 /**
186 * Inserts @p url at position @p index into the combobox. The item will 186 * Inserts @p url at position @p index into the combobox. The item will
187 * be appended if @p index is negative. @ref OURL::prettyURL() is used 187 * be appended if @p index is negative. @ref OURL::prettyURL() is used
188 * so that the url is properly decoded for displaying. 188 * so that the url is properly decoded for displaying.
189 */ 189 */
190 //void insertURL( const OURL& url, int index = -1 ); 190 //void insertURL( const OURL& url, int index = -1 );
191 191
192 /** 192 /**
193 * Inserts @p url with the pixmap &p pixmap at position @p index into 193 * Inserts @p url with the pixmap &p pixmap at position @p index into
194 * the combobox. The item will be appended if @p index is negative. 194 * the combobox. The item will be appended if @p index is negative.
195 * @ref OURL::prettyURL() is used so that the url is properly decoded 195 * @ref OURL::prettyURL() is used so that the url is properly decoded
196 * for displaying. 196 * for displaying.
197 */ 197 */
198 //void insertURL( const QPixmap& pixmap, const OURL& url, int index = -1 ); 198 //void insertURL( const QPixmap& pixmap, const OURL& url, int index = -1 );
199 199
200 /** 200 /**
201 * Replaces the item at position @p index with @p url. 201 * Replaces the item at position @p index with @p url.
202 * @ref OURL::prettyURL() is used so that the url is properly decoded 202 * @ref OURL::prettyURL() is used so that the url is properly decoded
203 * for displaying. 203 * for displaying.
204 */ 204 */
205 //void changeURL( const OURL& url, int index ); 205 //void changeURL( const OURL& url, int index );
206 206
207 /** 207 /**
208 * Replaces the item at position @p index with @p url and pixmap @p pixmap. 208 * Replaces the item at position @p index with @p url and pixmap @p pixmap.
209 * @ref OURL::prettyURL() is used so that the url is properly decoded 209 * @ref OURL::prettyURL() is used so that the url is properly decoded
210 * for displaying. 210 * for displaying.
211 */ 211 */
212 //void changeURL( const QPixmap& pixmap, const OURL& url, int index ); 212 //void changeURL( const QPixmap& pixmap, const OURL& url, int index );
213 213
214 /** 214 /**
215 * Returns the current cursor position. 215 * Returns the current cursor position.
216 * 216 *
217 * This method always returns a -1 if the combo-box is @em not 217 * This method always returns a -1 if the combo-box is @em not
218 * editable (read-write). 218 * editable (read-write).
219 * 219 *
220 * @return Current cursor position. 220 * @return Current cursor position.
221 */ 221 */
222 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; } 222 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
223 223
224 /** 224 /**
225 * Re-implemented from @ref QComboBox. 225 * Re-implemented from @ref QComboBox.
226 * 226 *
227 * If @p true, the completion mode will be set to automatic. 227 * If @p true, the completion mode will be set to automatic.
228 * Otherwise, it is defaulted to the global setting. This 228 * Otherwise, it is defaulted to the global setting. This
229 * method has been replaced by the more comprehensive 229 * method has been replaced by the more comprehensive
230 * @ref setCompletionMode(). 230 * @ref setCompletionMode().
231 * 231 *
232 * @param autocomplete Flag to enable/disable automatic completion mode. 232 * @param autocomplete Flag to enable/disable automatic completion mode.
233 */ 233 */
234 virtual void setAutoCompletion( bool autocomplete ); 234 virtual void setAutoCompletion( bool autocomplete );
235 235
236 /** 236 /**
237 * Re-implemented from QComboBox. 237 * Re-implemented from QComboBox.
238 * 238 *
239 * Returns @p true if the current completion mode is set 239 * Returns @p true if the current completion mode is set
240 * to automatic. See its more comprehensive replacement 240 * to automatic. See its more comprehensive replacement
241 * @ref completionMode(). 241 * @ref completionMode().
242 * 242 *
243 * @return @p true when completion mode is automatic. 243 * @return @p true when completion mode is automatic.
244 */ 244 */
245 bool autoCompletion() const { 245 bool autoCompletion() const {
246 return completionMode() == OGlobalSettings::CompletionAuto; 246 return completionMode() == OGlobalSettings::CompletionAuto;
247 } 247 }
248 248
249 /** 249 /**
250 * Enables or disable the popup (context) menu. 250 * Enables or disable the popup (context) menu.
251 * 251 *
252 * This method only works if this widget is editable, i.e. 252 * This method only works if this widget is editable, i.e.
253 * read-write and allows you to enable/disable the context 253 * read-write and allows you to enable/disable the context
254 * menu. It does nothing if invoked for a none-editable 254 * menu. It does nothing if invoked for a none-editable
255 * combo-box. Note that by default the mode changer item 255 * combo-box. Note that by default the mode changer item
256 * is made visiable whenever the context menu is enabled. 256 * is made visiable whenever the context menu is enabled.
257 * Use @ref hideModechanger() if you want to hide this 257 * Use @ref hideModechanger() if you want to hide this
258 * item. Also by default, the context menu is created if 258 * item. Also by default, the context menu is created if
259 * this widget is editable. Call this function with the 259 * this widget is editable. Call this function with the
260 * argument set to false to disable the popup menu. 260 * argument set to false to disable the popup menu.
261 * 261 *
262 * @param showMenu If @p true, show the context menu. 262 * @param showMenu If @p true, show the context menu.
263 * @param showMode If @p true, show the mode changer. 263 * @param showMode If @p true, show the mode changer.
264 */ 264 */
265 virtual void setContextMenuEnabled( bool showMenu ); 265 virtual void setContextMenuEnabled( bool showMenu );
266 266
267 /** 267 /**
268 * Returns @p true when the context menu is enabled. 268 * Returns @p true when the context menu is enabled.
269 */ 269 */
270 bool isContextMenuEnabled() const { return m_bEnableMenu; } 270 bool isContextMenuEnabled() const { return m_bEnableMenu; }
271 271
272 /** 272 /**
273 * Enables/Disables handling of URL drops. If enabled and the user 273 * Enables/Disables handling of URL drops. If enabled and the user
274 * drops an URL, the decoded URL will be inserted. Otherwise the default 274 * drops an URL, the decoded URL will be inserted. Otherwise the default
275 * behaviour of QComboBox is used, which inserts the encoded URL. 275 * behaviour of QComboBox is used, which inserts the encoded URL.
276 * 276 *
277 * @param enable If @p true, insert decoded URLs 277 * @param enable If @p true, insert decoded URLs
278 */ 278 */
279 //void setURLDropsEnabled( bool enable ); 279 //void setURLDropsEnabled( bool enable );
280 280
281 /** 281 /**
282 * Returns @p true when decoded URL drops are enabled 282 * Returns @p true when decoded URL drops are enabled
283 */ 283 */
284 //bool isURLDropsEnabled() const; 284 //bool isURLDropsEnabled() const;
285 285
286 /** 286 /**
287 * Convenience method which iterates over all items and checks if 287 * Convenience method which iterates over all items and checks if
288 * any of them is equal to @p text. 288 * any of them is equal to @p text.
289 * 289 *
290 * If @p text is an empty string, @p false 290 * If @p text is an empty string, @p false
291 * is returned. 291 * is returned.
292 * 292 *
293 * @return @p true if an item with the string @p text is in the combobox. 293 * @return @p true if an item with the string @p text is in the combobox.
294 */ 294 */
295 bool contains( const QString& text ) const; 295 bool contains( const QString& text ) const;
296 296
297 /** 297 /**
298 * By default, OComboBox recognizes Key_Return and Key_Enter 298 * By default, OComboBox recognizes Key_Return and Key_Enter
299 * and emits 299 * and emits
300 * the @ref returnPressed() signals, but it also lets the event pass, 300 * the @ref returnPressed() signals, but it also lets the event pass,
301 * for example causing a dialog's default-button to be called. 301 * for example causing a dialog's default-button to be called.
302 * 302 *
303 * Call this method with @p trap equal to true to make OComboBox 303 * Call this method with @p trap equal to true to make OComboBox
304 * stop these 304 * stop these
305 * events. The signals will still be emitted of course. 305 * events. The signals will still be emitted of course.
306 * 306 *
307 * Only affects read-writable comboboxes. 307 * Only affects read-writable comboboxes.
308 * 308 *
309 * @see setTrapReturnKey() 309 * @see setTrapReturnKey()
310 */ 310 */
311 void setTrapReturnKey( bool trap ); 311 void setTrapReturnKey( bool trap );
312 312
313 /** 313 /**
314 * @return @p true if keyevents of Key_Return or Key_Enter will 314 * @return @p true if keyevents of Key_Return or Key_Enter will
315 * be stopped or if they will be propagated. 315 * be stopped or if they will be propagated.
316 * 316 *
317 * @see setTrapReturnKey () 317 * @see setTrapReturnKey ()
318 */ 318 */
319 bool trapReturnKey() const; 319 bool trapReturnKey() const;
320 320
321 /** 321 /**
322 * Re-implemented for internal reasons. API not affected. 322 * Re-implemented for internal reasons. API not affected.
323 * 323 *
324 * @reimplemented 324 * @reimplemented
325 */ 325 */
326 virtual bool eventFilter( QObject *, QEvent * ); 326 virtual bool eventFilter( QObject *, QEvent * );
327 327
328 /** 328 /**
329 * @returns the completion-box, that is used in completion mode 329 * @returns the completion-box, that is used in completion mode
330 * @ref OGlobalSettings::CompletionPopup and @ref OGlobalSettings::CompletionPopupAuto. 330 * @ref OGlobalSettings::CompletionPopup and @ref OGlobalSettings::CompletionPopupAuto.
331 * This method will create a completion-box by calling 331 * This method will create a completion-box by calling
332 * @ref OLineEdit::completionBox, if none is there, yet. 332 * @ref OLineEdit::completionBox, if none is there, yet.
333 * 333 *
334 * @param create Set this to false if you don't want the box to be created 334 * @param create Set this to false if you don't want the box to be created
335 * i.e. to test if it is available. 335 * i.e. to test if it is available.
336 */ 336 */
337 OCompletionBox * completionBox( bool create = true ); 337 OCompletionBox * completionBox( bool create = true );
338 338
339 virtual void setLineEdit( OLineEdit * ); 339 virtual void setLineEdit( OLineEdit * );
340 340
341signals: 341signals:
342 /** 342 /**
343 * Emitted when the user presses the Enter key. 343 * Emitted when the user presses the Enter key.
344 * 344 *
345 * Note that this signal is only 345 * Note that this signal is only
346 * emitted if this widget is editable. 346 * emitted if this widget is editable.
347 */ 347 */
348 void returnPressed(); 348 void returnPressed();
349 349
350 /** 350 /**
351 * Emitted when the user presses 351 * Emitted when the user presses
352 * the Enter key. 352 * the Enter key.
353 * 353 *
354 * The argument is the current 354 * The argument is the current
355 * text being edited. This signal is just like 355 * text being edited. This signal is just like
356 * @ref returnPressed() except it contains the 356 * @ref returnPressed() except it contains the
diff --git a/libopie2/qt3/opieui/olineedit.h b/libopie2/qt3/opieui/olineedit.h
index ecfca27..db3d7ef 100644
--- a/libopie2/qt3/opieui/olineedit.h
+++ b/libopie2/qt3/opieui/olineedit.h
@@ -1,384 +1,384 @@
1/* 1/*
2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
3 is part of the Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org> 3 is part of the Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org>
4 Opie Project Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com> 4 Opie Project Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
5 Copyright (C) 1997 Sven Radej (sven.radej@iname.com) 5 Copyright (C) 1997 Sven Radej (sven.radej@iname.com)
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OLINEEDIT_H 33#ifndef OLINEEDIT_H
34#define OLINEEDIT_H 34#define OLINEEDIT_H
35 35
36/* QT */ 36/* QT */
37 37
38#include <qlineedit.h> 38#include <qlineedit.h>
39 39
40/* OPIE */ 40/* OPIE */
41 41
42#include <opie2/ocompletion.h> 42#include <opie2/ocompletion.h>
43#include <opie2/ocompletionbase.h> 43#include <opie2/ocompletionbase.h>
44 44
45class QPopupMenu; 45class QPopupMenu;
46 46
47class OCompletionBox; 47class OCompletionBox;
48typedef QString KURL; //class KURL; 48typedef QString KURL; //class KURL;
49 49
50/** 50/**
51 * An enhanced QLineEdit widget for inputting text. 51 * An enhanced QLineEdit widget for inputting text.
52 * 52 *
53 * @sect Detail 53 * @par Detail
54 * 54 *
55 * This widget inherits from @ref QLineEdit and implements the following 55 * This widget inherits from @ref QLineEdit and implements the following
56 * additional functionalities: q completion object that provides both 56 * additional functionalities: q completion object that provides both
57 * automatic and manual text completion as well as multiple match iteration 57 * automatic and manual text completion as well as multiple match iteration
58 * features, configurable key-bindings to activate these features and a 58 * features, configurable key-bindings to activate these features and a
59 * popup-menu item that can be used to allow the user to set text completion 59 * popup-menu item that can be used to allow the user to set text completion
60 * modes on the fly based on their preference. 60 * modes on the fly based on their preference.
61 * 61 *
62 * To support these new features OLineEdit also emits a few more 62 * To support these new features OLineEdit also emits a few more
63 * additional signals. These are: @ref completion( const QString& ), 63 * additional signals. These are: @ref completion( const QString& ),
64 * textRotation( KeyBindingType ), and @ref returnPressed( const QString& ). 64 * textRotation( KeyBindingType ), and @ref returnPressed( const QString& ).
65 * The completion signal can be connected to a slot that will assist the 65 * The completion signal can be connected to a slot that will assist the
66 * user in filling out the remaining text. The text rotation signal is 66 * user in filling out the remaining text. The text rotation signal is
67 * intended to be used to iterate through the list of all possible matches 67 * intended to be used to iterate through the list of all possible matches
68 * whenever there is more than one match for the entered text. The 68 * whenever there is more than one match for the entered text. The
69 * @p returnPressed( const QString& ) signals are the same as QLineEdit's 69 * @p returnPressed( const QString& ) signals are the same as QLineEdit's
70 * except it provides the current text in the widget as its argument whenever 70 * except it provides the current text in the widget as its argument whenever
71 * appropriate. 71 * appropriate.
72 * 72 *
73 * This widget by default creates a completion object when you invoke 73 * This widget by default creates a completion object when you invoke
74 * the @ref completionObject( bool ) member function for the first time or 74 * the @ref completionObject( bool ) member function for the first time or
75 * use @ref setCompletionObject( OCompletion*, bool ) to assign your own 75 * use @ref setCompletionObject( OCompletion*, bool ) to assign your own
76 * completion object. Additionally, to make this widget more functional, 76 * completion object. Additionally, to make this widget more functional,
77 * OLineEdit will by default handle the text rotation and completion 77 * OLineEdit will by default handle the text rotation and completion
78 * events internally when a completion object is created through either one 78 * events internally when a completion object is created through either one
79 * of the methods mentioned above. If you do not need this functionality, 79 * of the methods mentioned above. If you do not need this functionality,
80 * simply use @ref OCompletionBase::setHandleSignals( bool ) or set the 80 * simply use @ref OCompletionBase::setHandleSignals( bool ) or set the
81 * boolean parameter in the above functions to FALSE. 81 * boolean parameter in the above functions to FALSE.
82 * 82 *
83 * The default key-bindings for completion and rotation is determined 83 * The default key-bindings for completion and rotation is determined
84 * from the global settings in @ref OStdAccel. These values, however, 84 * from the global settings in @ref OStdAccel. These values, however,
85 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding(). 85 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
86 * The values can easily be reverted back to the default setting, by simply 86 * The values can easily be reverted back to the default setting, by simply
87 * calling @ref useGlobalSettings(). An alternate method would be to default 87 * calling @ref useGlobalSettings(). An alternate method would be to default
88 * individual key-bindings by usning @ref setKeyBinding() with the default 88 * individual key-bindings by usning @ref setKeyBinding() with the default
89 * second argument. 89 * second argument.
90 * 90 *
91 * NOTE that if the @p EchoMode for this widget is set to something other 91 * NOTE that if the @p EchoMode for this widget is set to something other
92 * than @p QLineEdit::Normal, the completion mode will always be defaulted 92 * than @p QLineEdit::Normal, the completion mode will always be defaulted
93 * to @ref PGlobalSettings::CompletionNone. This is done purposefully to guard 93 * to @ref PGlobalSettings::CompletionNone. This is done purposefully to guard
94 * against protected entries such as passwords being cached in @ref OCompletion's 94 * against protected entries such as passwords being cached in @ref OCompletion's
95 * list. Hence, if the @p EchoMode is not @ref QLineEdit::Normal, the completion 95 * list. Hence, if the @p EchoMode is not @ref QLineEdit::Normal, the completion
96 * mode is automatically disabled. 96 * mode is automatically disabled.
97 * 97 *
98 * @sect Useage 98 * @par Usage
99 * 99 *
100 * To enable the basic completion feature : 100 * To enable the basic completion feature :
101 * 101 *
102 * <pre> 102 * <pre>
103 * OLineEdit *edit = new OLineEdit( this, "mywidget" ); 103 * OLineEdit *edit = new OLineEdit( this, "mywidget" );
104 * OCompletion *comp = edit->completionObject(); 104 * OCompletion *comp = edit->completionObject();
105 * // Fill the completion object with a list of possible matches 105 * // Fill the completion object with a list of possible matches
106 * QStringList list; 106 * QStringList list;
107 * list << "mickeyl@handhelds.org" << "mickey@tm.informatik.uni-frankfurt.de>" << "mickey@Vanille.de"; 107 * list << "mickeyl@handhelds.org" << "mickey@tm.informatik.uni-frankfurt.de>" << "mickey@Vanille.de";
108 * comp->setItems( list ); 108 * comp->setItems( list );
109 * // Connect to the return pressed signal (optional) 109 * // Connect to the return pressed signal (optional)
110 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 110 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
111 * </pre> 111 * </pre>
112 * 112 *
113 * To use a customized completion objects or your 113 * To use a customized completion objects or your
114 * own completion object : 114 * own completion object :
115 * 115 *
116 * <pre> 116 * <pre>
117 * OLineEdit *edit = new OLineEdit( this,"mywidget" ); 117 * OLineEdit *edit = new OLineEdit( this,"mywidget" );
118 * KURLCompletion *comp = new KURLCompletion(); 118 * KURLCompletion *comp = new KURLCompletion();
119 * edit->setCompletionObject( comp ); 119 * edit->setCompletionObject( comp );
120 * // Connect to the return pressed signal - optional 120 * // Connect to the return pressed signal - optional
121 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 121 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
122 * </pre> 122 * </pre>
123 * 123 *
124 * Note that you have to either delete the allocated completion object 124 * Note that you have to either delete the allocated completion object
125 * when you don't need it anymore, or call 125 * when you don't need it anymore, or call
126 * setAutoDeleteCompletionObject( true ); 126 * setAutoDeleteCompletionObject( true );
127 * 127 *
128 * @sect Miscellaneous function calls : 128 * @par Miscellaneous function calls :
129 * 129 *
130 * <pre> 130 * <pre>
131 * // Tell the widget not to handle completion and 131 * // Tell the widget not to handle completion and
132 * // iteration internally. 132 * // iteration internally.
133 * edit->setHandleSignals( false ); 133 * edit->setHandleSignals( false );
134 * // Set your own completion key for manual completions. 134 * // Set your own completion key for manual completions.
135 * edit->setKeyBinding( OCompletionBase::TextCompletion, Qt::End ); 135 * edit->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
136 * // Hide the context (popup) menu 136 * // Hide the context (popup) menu
137 * edit->setContextMenuEnabled( false ); 137 * edit->setContextMenuEnabled( false );
138 * // Temporarly disable signal emitions 138 * // Temporarly disable signal emitions
139 * // (both completion & iteration signals) 139 * // (both completion & iteration signals)
140 * edit->disableSignals(); 140 * edit->disableSignals();
141 * // Default the key-bindings to system settings. 141 * // Default the key-bindings to system settings.
142 * edit->useGlobalKeyBindings(); 142 * edit->useGlobalKeyBindings();
143 * </pre> 143 * </pre>
144 * 144 *
145 * @short An enhanced single line input widget. 145 * @short An enhanced single line input widget.
146 * @author Dawit Alemayehu <adawit@kde.org> 146 * @author Dawit Alemayehu <adawit@kde.org>
147 * @author Opie adaption by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 147 * @author Opie adaption by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
148 */ 148 */
149 149
150class OLineEdit : public QLineEdit, public OCompletionBase 150class OLineEdit : public QLineEdit, public OCompletionBase
151{ 151{
152 friend class OComboBox; 152 friend class OComboBox;
153 153
154 Q_OBJECT 154 Q_OBJECT
155 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 155 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
156 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 156 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
157 157
158public: 158public:
159 159
160 /** 160 /**
161 * Constructs a OLineEdit object with a default text, a parent, 161 * Constructs a OLineEdit object with a default text, a parent,
162 * and a name. 162 * and a name.
163 * 163 *
164 * @param string Text to be shown in the edit widget. 164 * @param string Text to be shown in the edit widget.
165 * @param parent The parent object of this widget. 165 * @param parent The parent object of this widget.
166 * @param name the name of this widget 166 * @param name the name of this widget
167 */ 167 */
168 OLineEdit( const QString &string, QWidget *parent, const char *name = 0 ); 168 OLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
169 169
170 /** 170 /**
171 * Constructs a OLineEdit object with a parent and a name. 171 * Constructs a OLineEdit object with a parent and a name.
172 * 172 *
173 * @param string Text to be shown in the edit widget. 173 * @param string Text to be shown in the edit widget.
174 * @param parent The parent object of this widget. 174 * @param parent The parent object of this widget.
175 * @param name The name of this widget. 175 * @param name The name of this widget.
176 */ 176 */
177 OLineEdit ( QWidget *parent=0, const char *name=0 ); 177 OLineEdit ( QWidget *parent=0, const char *name=0 );
178 178
179 /** 179 /**
180 * Destructor. 180 * Destructor.
181 */ 181 */
182 virtual ~OLineEdit (); 182 virtual ~OLineEdit ();
183 183
184 /** 184 /**
185 * Sets @p url into the lineedit. It uses @ref KURL::prettyURL() so 185 * Sets @p url into the lineedit. It uses @ref KURL::prettyURL() so
186 * that the url is properly decoded for displaying. 186 * that the url is properly decoded for displaying.
187 */ 187 */
188 void setURL( const KURL& url ); 188 void setURL( const KURL& url );
189 189
190 /** 190 /**
191 * Puts the text cursor at the end of the string. 191 * Puts the text cursor at the end of the string.
192 * 192 *
193 * This method is deprecated. Use @ref QLineEdit::end() 193 * This method is deprecated. Use @ref QLineEdit::end()
194 * instead. 194 * instead.
195 * 195 *
196 * @deprecated 196 * @deprecated
197 * @ref QLineEdit::end() 197 * @ref QLineEdit::end()
198 */ 198 */
199 void cursorAtEnd() { end( false ); } 199 void cursorAtEnd() { end( false ); }
200 200
201 /** 201 /**
202 * Re-implemented from @ref OCompletionBase for internal reasons. 202 * Re-implemented from @ref OCompletionBase for internal reasons.
203 * 203 *
204 * This function is re-implemented in order to make sure that 204 * This function is re-implemented in order to make sure that
205 * the EchoMode is acceptable before we set the completion mode. 205 * the EchoMode is acceptable before we set the completion mode.
206 * 206 *
207 * See @ref OCompletionBase::setCompletionMode 207 * See @ref OCompletionBase::setCompletionMode
208 */ 208 */
209 virtual void setCompletionMode( OGlobalSettings::Completion mode ); 209 virtual void setCompletionMode( OGlobalSettings::Completion mode );
210 210
211 /** 211 /**
212 * Enables/disables the popup (context) menu. 212 * Enables/disables the popup (context) menu.
213 * 213 *
214 * Note that when this function is invoked with its argument 214 * Note that when this function is invoked with its argument
215 * set to @p true, then both the context menu and the completion 215 * set to @p true, then both the context menu and the completion
216 * menu item are enabled. If you do not want to the completion 216 * menu item are enabled. If you do not want to the completion
217 * item to be visible simply invoke @ref hideModechanger() right 217 * item to be visible simply invoke @ref hideModechanger() right
218 * after calling this method. Also by default, the context 218 * after calling this method. Also by default, the context
219 * menu is automatically created if this widget is editable. Thus 219 * menu is automatically created if this widget is editable. Thus
220 * you need to call this function with the argument set to false 220 * you need to call this function with the argument set to false
221 * if you do not want this behaviour. 221 * if you do not want this behaviour.
222 * 222 *
223 * @param showMenu If @p true, show the context menu. 223 * @param showMenu If @p true, show the context menu.
224 */ 224 */
225 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; } 225 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; }
226 226
227 /** 227 /**
228 * Returns @p true when the context menu is enabled. 228 * Returns @p true when the context menu is enabled.
229 */ 229 */
230 bool isContextMenuEnabled() const { return m_bEnableMenu; } 230 bool isContextMenuEnabled() const { return m_bEnableMenu; }
231 231
232 /** 232 /**
233 * Enables/Disables handling of URL drops. If enabled and the user 233 * Enables/Disables handling of URL drops. If enabled and the user
234 * drops an URL, the decoded URL will be inserted. Otherwise the default 234 * drops an URL, the decoded URL will be inserted. Otherwise the default
235 * behaviour of QLineEdit is used, which inserts the encoded URL. 235 * behaviour of QLineEdit is used, which inserts the encoded URL.
236 * 236 *
237 * @param enable If @p true, insert decoded URLs 237 * @param enable If @p true, insert decoded URLs
238 */ 238 */
239 void setURLDropsEnabled( bool enable ); 239 void setURLDropsEnabled( bool enable );
240 240
241 /** 241 /**
242 * Returns @p true when decoded URL drops are enabled 242 * Returns @p true when decoded URL drops are enabled
243 */ 243 */
244 bool isURLDropsEnabled() const; 244 bool isURLDropsEnabled() const;
245 245
246 /** 246 /**
247 * By default, OLineEdit recognizes @p Key_Return and @p Key_Enter and emits 247 * By default, OLineEdit recognizes @p Key_Return and @p Key_Enter and emits
248 * the @ref returnPressed() signals, but it also lets the event pass, 248 * the @ref returnPressed() signals, but it also lets the event pass,
249 * for example causing a dialog's default-button to be called. 249 * for example causing a dialog's default-button to be called.
250 * 250 *
251 * Call this method with @p trap = @p true to make @p OLineEdit stop these 251 * Call this method with @p trap = @p true to make @p OLineEdit stop these
252 * events. The signals will still be emitted of course. 252 * events. The signals will still be emitted of course.
253 * 253 *
254 * @see trapReturnKey() 254 * @see trapReturnKey()
255 */ 255 */
256 void setTrapReturnKey( bool trap ); 256 void setTrapReturnKey( bool trap );
257 257
258 /** 258 /**
259 * @returns @p true if keyevents of @p Key_Return or 259 * @returns @p true if keyevents of @p Key_Return or
260 * @p Key_Enter will be stopped or if they will be propagated. 260 * @p Key_Enter will be stopped or if they will be propagated.
261 * 261 *
262 * @see setTrapReturnKey () 262 * @see setTrapReturnKey ()
263 */ 263 */
264 bool trapReturnKey() const; 264 bool trapReturnKey() const;
265 265
266 /** 266 /**
267 * Re-implemented for internal reasons. API not affected. 267 * Re-implemented for internal reasons. API not affected.
268 * 268 *
269 * @reimplemented 269 * @reimplemented
270 */ 270 */
271 virtual bool eventFilter( QObject *, QEvent * ); 271 virtual bool eventFilter( QObject *, QEvent * );
272 272
273 /** 273 /**
274 * @returns the completion-box, that is used in completion mode 274 * @returns the completion-box, that is used in completion mode
275 * @ref KGlobalSettings::CompletionPopup. 275 * @ref KGlobalSettings::CompletionPopup.
276 * This method will create a completion-box if none is there, yet. 276 * This method will create a completion-box if none is there, yet.
277 * 277 *
278 * @param create Set this to false if you don't want the box to be created 278 * @param create Set this to false if you don't want the box to be created
279 * i.e. to test if it is available. 279 * i.e. to test if it is available.
280 */ 280 */
281 OCompletionBox * completionBox( bool create = true ); 281 OCompletionBox * completionBox( bool create = true );
282 282
283 /** 283 /**
284 * Reimplemented for internal reasons, the API is not affected. 284 * Reimplemented for internal reasons, the API is not affected.
285 */ 285 */
286 virtual void setCompletionObject( OCompletion *, bool hsig = true ); 286 virtual void setCompletionObject( OCompletion *, bool hsig = true );
287 287
288 288
289signals: 289signals:
290 290
291 /** 291 /**
292 * Emitted when the user presses the return key. 292 * Emitted when the user presses the return key.
293 * 293 *
294 * The argument is the current text. Note that this 294 * The argument is the current text. Note that this
295 * signal is @em not emitted if the widget's @p EchoMode is set to 295 * signal is @em not emitted if the widget's @p EchoMode is set to
296 * @ref QLineEdit::EchoMode. 296 * @ref QLineEdit::EchoMode.
297 */ 297 */
298 void returnPressed( const QString& ); 298 void returnPressed( const QString& );
299 299
300 /** 300 /**
301 * Emitted when the completion key is pressed. 301 * Emitted when the completion key is pressed.
302 * 302 *
303 * Please note that this signal is @em not emitted if the 303 * Please note that this signal is @em not emitted if the
304 * completion mode is set to @p CompletionNone or @p EchoMode is 304 * completion mode is set to @p CompletionNone or @p EchoMode is
305 * @em normal. 305 * @em normal.
306 */ 306 */
307 void completion( const QString& ); 307 void completion( const QString& );
308 308
309 /** 309 /**
310 * Emitted when the shortcut for substring completion is pressed. 310 * Emitted when the shortcut for substring completion is pressed.
311 */ 311 */
312 void substringCompletion( const QString& ); 312 void substringCompletion( const QString& );
313 313
314 /** 314 /**
315 * Emitted when the text rotation key-bindings are pressed. 315 * Emitted when the text rotation key-bindings are pressed.
316 * 316 *
317 * The argument indicates which key-binding was pressed. 317 * The argument indicates which key-binding was pressed.
318 * In OLineEdit's case this can be either one of two values: 318 * In OLineEdit's case this can be either one of two values:
319 * @ref PrevCompletionMatch or @ref NextCompletionMatch. See 319 * @ref PrevCompletionMatch or @ref NextCompletionMatch. See
320 * @ref OCompletionBase::setKeyBinding for details. 320 * @ref OCompletionBase::setKeyBinding for details.
321 * 321 *
322 * Note that this signal is @em not emitted if the completion 322 * Note that this signal is @em not emitted if the completion
323 * mode is set to @p KGlobalSettings::CompletionNone or @p echoMode() is @em not normal. 323 * mode is set to @p KGlobalSettings::CompletionNone or @p echoMode() is @em not normal.
324 */ 324 */
325 void textRotation( OCompletionBase::KeyBindingType ); 325 void textRotation( OCompletionBase::KeyBindingType );
326 326
327 /** 327 /**
328 * Emitted when the user changed the completion mode by using the 328 * Emitted when the user changed the completion mode by using the
329 * popupmenu. 329 * popupmenu.
330 */ 330 */
331 void completionModeChanged( OGlobalSettings::Completion ); 331 void completionModeChanged( OGlobalSettings::Completion );
332 332
333 /** 333 /**
334 * Emitted before the context menu is displayed. 334 * Emitted before the context menu is displayed.
335 * 335 *
336 * The signal allows you to add your own entries into the 336 * The signal allows you to add your own entries into the
337 * the context menu that is created on demand. 337 * the context menu that is created on demand.
338 * 338 *
339 * NOTE: Do not store the pointer to the QPopupMenu 339 * NOTE: Do not store the pointer to the QPopupMenu
340 * provided through since it is created and deleted 340 * provided through since it is created and deleted
341 * on demand. 341 * on demand.
342 * 342 *
343 * @param the context menu about to be displayed 343 * @param the context menu about to be displayed
344 */ 344 */
345 void aboutToShowContextMenu( QPopupMenu* ); 345 void aboutToShowContextMenu( QPopupMenu* );
346 346
347public slots: 347public slots:
348 348
349 /** 349 /**
350 * Re-implemented for internal reasons. API not changed. 350 * Re-implemented for internal reasons. API not changed.
351 */ 351 */
352 virtual void setReadOnly(bool); 352 virtual void setReadOnly(bool);
353 353
354 /** 354 /**
355 * Iterates through all possible matches of the completed text or 355 * Iterates through all possible matches of the completed text or
356 * the history list. 356 * the history list.
357 * 357 *
358 * This function simply iterates over all possible matches in case 358 * This function simply iterates over all possible matches in case
359 * multimple matches are found as a result of a text completion request. 359 * multimple matches are found as a result of a text completion request.
360 * It will have no effect if only a single match is found. 360 * It will have no effect if only a single match is found.
361 * 361 *
362 * @param type The key-binding invoked. 362 * @param type The key-binding invoked.
363 */ 363 */
364 void rotateText( OCompletionBase::KeyBindingType /* type */ ); 364 void rotateText( OCompletionBase::KeyBindingType /* type */ );
365 365
366 /** 366 /**
367 * See @ref OCompletionBase::setCompletedText. 367 * See @ref OCompletionBase::setCompletedText.
368 */ 368 */
369 virtual void setCompletedText( const QString& ); 369 virtual void setCompletedText( const QString& );
370 370
371 /** 371 /**
372 * Sets @p items into the completion-box if @ref completionMode() is 372 * Sets @p items into the completion-box if @ref completionMode() is
373 * CompletionPopup. The popup will be shown immediately. 373 * CompletionPopup. The popup will be shown immediately.
374 */ 374 */
375 void setCompletedItems( const QStringList& items ); 375 void setCompletedItems( const QStringList& items );
376 376
377 /** 377 /**
378 * Reimplemented to workaround a buggy QLineEdit::clear() 378 * Reimplemented to workaround a buggy QLineEdit::clear()
379 * (changing the clipboard to the text we just had in the lineedit) 379 * (changing the clipboard to the text we just had in the lineedit)
380 */ 380 */
381 virtual void clear(); 381 virtual void clear();
382 382
383protected slots: 383protected slots:
384 384