summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 15:58:07 (UTC)
committer chicken <chicken>2004-03-01 15:58:07 (UTC)
commit931c55406a043195712955c732a875e17899df90 (patch) (unidiff)
tree8097c88ee3e96f8fb613ccca1ebf36bf73070dcc
parent87676b131aad1bfe979570a48107527db4040020 (diff)
downloadopie-931c55406a043195712955c732a875e17899df90.zip
opie-931c55406a043195712955c732a875e17899df90.tar.gz
opie-931c55406a043195712955c732a875e17899df90.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/odebug.cpp11
-rw-r--r--libopie2/opiecore/oglobal.cpp1
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp3
-rw-r--r--libopie2/opiecore/oprocctrl.cpp1
-rw-r--r--libopie2/opiecore/oprocess.cpp2
-rw-r--r--libopie2/opiedb/osqlbackendmanager.cpp1
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp1
-rw-r--r--libopie2/opiedb/osqlmanager.cpp2
-rw-r--r--libopie2/opiedb/osqlresult.cpp1
-rw-r--r--libopie2/opiemm/osoundsystem.cpp1
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp1
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp2
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp4
-rw-r--r--libopie2/opiepim/core/opimcontactfields.cpp2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp3
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp1
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp1
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp3
-rw-r--r--libopie2/opieui/ofontselector.cpp1
-rw-r--r--libopie2/opieui/olistview.cpp3
-rw-r--r--libopie2/opieui/opopupmenu.cpp7
-rw-r--r--libopie2/opieui/oselector.cpp1
-rw-r--r--libopie2/opieui/oseparator.cpp1
-rw-r--r--libopie2/opieui/otimepicker.cpp3
-rw-r--r--libopie2/opieui/oversatileview.cpp11
25 files changed, 1 insertions, 67 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index 4505ce7..a40ef53 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,447 +1,436 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 (C) 2002 Holger Freyther (freyther@kde.org) 4 (C) 2002 Holger Freyther (freyther@kde.org)
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
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// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
33// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
34 34
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
38#undef odDebug 38#undef odDebug
39#undef odBacktrace 39#undef odBacktrace
40#endif 40#endif
41 41
42/* OPIE */ 42/* OPIE */
43 43
44#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
47 47
48/* QT */ 48/* QT */
49 49
50#include <qbrush.h>
51#include <qdatetime.h>
52#include <qfile.h> 50#include <qfile.h>
53#include <qhostaddress.h>
54#include <qmessagebox.h> 51#include <qmessagebox.h>
55#include <qintdict.h>
56#include <qpoint.h>
57#include <qrect.h>
58#include <qregion.h>
59#include <qsize.h>
60#include <qsocketdevice.h> 52#include <qsocketdevice.h>
61#include <qstring.h>
62#include <qstringlist.h>
63#include <qtextstream.h>
64 53
65/* UNIX */ 54/* UNIX */
66 55
67#include <stdlib.h> // abort 56#include <stdlib.h> // abort
68#include <unistd.h> // getpid 57#include <unistd.h> // getpid
69#include <stdarg.h> // vararg stuff 58#include <stdarg.h> // vararg stuff
70#include <ctype.h> // isprint 59#include <ctype.h> // isprint
71#include <syslog.h> 60#include <syslog.h>
72#include <errno.h> 61#include <errno.h>
73#include <string.h> 62#include <string.h>
74 63
75#ifndef OPIE_NO_BACKTRACE 64#ifndef OPIE_NO_BACKTRACE
76#include <execinfo.h> 65#include <execinfo.h>
77#endif 66#endif
78 67
79 68
80/*====================================================================================== 69/*======================================================================================
81 * debug levels 70 * debug levels
82 *======================================================================================*/ 71 *======================================================================================*/
83 72
84enum DebugLevels { 73enum DebugLevels {
85 ODEBUG_INFO = 0, 74 ODEBUG_INFO = 0,
86 ODEBUG_WARN = 1, 75 ODEBUG_WARN = 1,
87 ODEBUG_ERROR = 2, 76 ODEBUG_ERROR = 2,
88 ODEBUG_FATAL = 3 77 ODEBUG_FATAL = 3
89}; 78};
90 79
91/*====================================================================================== 80/*======================================================================================
92 * oDebug private data 81 * oDebug private data
93 *======================================================================================*/ 82 *======================================================================================*/
94 83
95/*====================================================================================== 84/*======================================================================================
96 * the main debug function 85 * the main debug function
97 *======================================================================================*/ 86 *======================================================================================*/
98 87
99static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 88static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
100{ 89{
101 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 90 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
102 91
103 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 92 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
104 // ML: example use. I think it's not necessary to implement such a strategy here. 93 // ML: example use. I think it's not necessary to implement such a strategy here.
105 // ML: Comments? 94 // ML: Comments?
106 95
107 int priority = 0; 96 int priority = 0;
108 QString caption; 97 QString caption;
109 QString lev; 98 QString lev;
110 switch( level ) 99 switch( level )
111 { 100 {
112 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 101 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
113 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 102 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
114 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 103 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
115 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 104 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
116 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 105 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
117 } 106 }
118 107
119 short output = OGlobalSettings::debugMode(); 108 short output = OGlobalSettings::debugMode();
120 if (!oApp && (output == 1)) 109 if (!oApp && (output == 1))
121 { 110 {
122 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 111 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
123 output = 2; // need an application object to use MsgBox 112 output = 2; // need an application object to use MsgBox
124 } 113 }
125 114
126 // gcc 2.9x is dumb and sucks... can you hear it? 115 // gcc 2.9x is dumb and sucks... can you hear it?
127 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 116 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
128 QString areaName; 117 QString areaName;
129 if ( oApp ) areaName = oApp->appName(); 118 if ( oApp ) areaName = oApp->appName();
130 else areaName = "<unknown>"; 119 else areaName = "<unknown>";
131 120
132 // Output 121 // Output
133 switch( output ) 122 switch( output )
134 { 123 {
135 case -1: // ignore 124 case -1: // ignore
136 { 125 {
137 return; 126 return;
138 } 127 }
139 case 0: // File 128 case 0: // File
140 { 129 {
141 QString outputFilename = OGlobalSettings::debugOutput(); 130 QString outputFilename = OGlobalSettings::debugOutput();
142 131
143 const int BUFSIZE = 4096; 132 const int BUFSIZE = 4096;
144 char buf[BUFSIZE] = ""; 133 char buf[BUFSIZE] = "";
145 buf[BUFSIZE-1] = '\0'; 134 buf[BUFSIZE-1] = '\0';
146 int nSize; 135 int nSize;
147 136
148 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); 137 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data);
149 138
150 QFile outputFile( outputFilename ); 139 QFile outputFile( outputFilename );
151 if ( outputFile.open( IO_WriteOnly | IO_Append ) ) 140 if ( outputFile.open( IO_WriteOnly | IO_Append ) )
152 { 141 {
153 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) 142 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
154 { 143 {
155 outputFile.writeBlock( buf, BUFSIZE-1 ); 144 outputFile.writeBlock( buf, BUFSIZE-1 );
156 } 145 }
157 else 146 else
158 { 147 {
159 outputFile.writeBlock( buf, nSize ); 148 outputFile.writeBlock( buf, nSize );
160 } 149 }
161 } 150 }
162 else 151 else
163 { 152 {
164 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); 153 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) );
165 } 154 }
166 break; 155 break;
167 } // automatic close of file here 156 } // automatic close of file here
168 157
169 case 1: // Message Box 158 case 1: // Message Box
170 { 159 {
171 // Since we are in opiecore here, we cannot use OMsgBox and use 160 // Since we are in opiecore here, we cannot use OMsgBox and use
172 // QMessageBox instead 161 // QMessageBox instead
173 162
174 caption += QString("(") + areaName + ")"; 163 caption += QString("(") + areaName + ")";
175 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? 164 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr?
176 break; 165 break;
177 } 166 }
178 167
179 case 2: // Shell 168 case 2: // Shell
180 { 169 {
181 FILE *output = stderr; 170 FILE *output = stderr;
182 fprintf( output, "%s: ", (const char*) areaName ); 171 fprintf( output, "%s: ", (const char*) areaName );
183 fputs( data, output); 172 fputs( data, output);
184 break; 173 break;
185 } 174 }
186 175
187 case 3: // syslog 176 case 3: // syslog
188 { 177 {
189 syslog( priority, "%s", data); 178 syslog( priority, "%s", data);
190 break; 179 break;
191 } 180 }
192 181
193 case 4: // socket 182 case 4: // socket
194 { 183 {
195 QString destination = OGlobalSettings::debugOutput(); 184 QString destination = OGlobalSettings::debugOutput();
196 if ( destination && destination.find(":") != -1 ) 185 if ( destination && destination.find(":") != -1 )
197 { 186 {
198 QString host = destination.left( destination.find(":") ); 187 QString host = destination.left( destination.find(":") );
199 QString port = destination.right( destination.length()-host.length()-1 ); 188 QString port = destination.right( destination.length()-host.length()-1 );
200 QHostAddress addr; 189 QHostAddress addr;
201 addr.setAddress( host ); 190 addr.setAddress( host );
202 // TODO: sanity check the address 191 // TODO: sanity check the address
203 QString line; 192 QString line;
204 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); 193 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data );
205 QSocketDevice s( QSocketDevice::Datagram ); 194 QSocketDevice s( QSocketDevice::Datagram );
206 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); 195 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() );
207 if ( result == -1 ) 196 if ( result == -1 )
208 { 197 {
209 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); 198 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) );
210 } 199 }
211 } 200 }
212 break; 201 break;
213 } 202 }
214 } 203 }
215 204
216 // check if we should abort 205 // check if we should abort
217 206
218 /* 207 /*
219 208
220 if( ( nLevel == ODEBUG_FATAL ) 209 if( ( nLevel == ODEBUG_FATAL )
221 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) 210 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) )
222 abort(); 211 abort();
223 212
224 */ 213 */
225} 214}
226 215
227/*====================================================================================== 216/*======================================================================================
228 * odbgstream 217 * odbgstream
229 *======================================================================================*/ 218 *======================================================================================*/
230 219
231odbgstream& perror( odbgstream &s) 220odbgstream& perror( odbgstream &s)
232{ 221{
233 return s << QString::fromLocal8Bit(strerror(errno)); 222 return s << QString::fromLocal8Bit(strerror(errno));
234} 223}
235 224
236odbgstream odDebug(int area) 225odbgstream odDebug(int area)
237{ 226{
238 return odbgstream(area, ODEBUG_INFO); 227 return odbgstream(area, ODEBUG_INFO);
239} 228}
240odbgstream odDebug(bool cond, int area) 229odbgstream odDebug(bool cond, int area)
241{ 230{
242 if (cond) return odbgstream(area, ODEBUG_INFO); 231 if (cond) return odbgstream(area, ODEBUG_INFO);
243 else return odbgstream(0, 0, false); 232 else return odbgstream(0, 0, false);
244} 233}
245 234
246odbgstream odError(int area) 235odbgstream odError(int area)
247{ 236{
248 return odbgstream("ERROR: ", area, ODEBUG_ERROR); 237 return odbgstream("ERROR: ", area, ODEBUG_ERROR);
249} 238}
250 239
251odbgstream odError(bool cond, int area) 240odbgstream odError(bool cond, int area)
252{ 241{
253 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); 242 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false);
254} 243}
255 244
256odbgstream odWarning(int area) 245odbgstream odWarning(int area)
257{ 246{
258 return odbgstream("WARNING: ", area, ODEBUG_WARN); 247 return odbgstream("WARNING: ", area, ODEBUG_WARN);
259} 248}
260 249
261odbgstream odWarning(bool cond, int area) 250odbgstream odWarning(bool cond, int area)
262{ 251{
263 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false); 252 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false);
264} 253}
265 254
266odbgstream odFatal(int area) 255odbgstream odFatal(int area)
267{ 256{
268 return odbgstream("FATAL: ", area, ODEBUG_FATAL); 257 return odbgstream("FATAL: ", area, ODEBUG_FATAL);
269} 258}
270 259
271odbgstream odFatal(bool cond, int area) 260odbgstream odFatal(bool cond, int area)
272{ 261{
273 if (cond) return odbgstream("FATAL: ", area, ODEBUG_FATAL); else return odbgstream(0,0,false); 262 if (cond) return odbgstream("FATAL: ", area, ODEBUG_FATAL); else return odbgstream(0,0,false);
274} 263}
275 264
276odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print) 265odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print)
277 :area(_area), level(_level), print(_print) 266 :area(_area), level(_level), print(_print)
278{ 267{
279} 268}
280 269
281 270
282odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print) 271odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print)
283 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) 272 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print)
284{ 273{
285} 274}
286 275
287 276
288odbgstream::odbgstream(odbgstream &str) 277odbgstream::odbgstream(odbgstream &str)
289 :output(str.output), area(str.area), level(str.level), print(str.print) 278 :output(str.output), area(str.area), level(str.level), print(str.print)
290{ 279{
291 str.output.truncate(0); 280 str.output.truncate(0);
292} 281}
293 282
294 283
295odbgstream::odbgstream(const odbgstream &str) 284odbgstream::odbgstream(const odbgstream &str)
296 :output(str.output), area(str.area), level(str.level), print(str.print) 285 :output(str.output), area(str.area), level(str.level), print(str.print)
297{ 286{
298} 287}
299 288
300odbgstream& odbgstream::operator<<(bool i) 289odbgstream& odbgstream::operator<<(bool i)
301{ 290{
302 if (!print) return *this; 291 if (!print) return *this;
303 output += QString::fromLatin1(i ? "true" : "false"); 292 output += QString::fromLatin1(i ? "true" : "false");
304 return *this; 293 return *this;
305} 294}
306 295
307 296
308odbgstream& odbgstream::operator<<(short i) 297odbgstream& odbgstream::operator<<(short i)
309{ 298{
310 if (!print) return *this; 299 if (!print) return *this;
311 QString tmp; tmp.setNum(i); output += tmp; 300 QString tmp; tmp.setNum(i); output += tmp;
312 return *this; 301 return *this;
313} 302}
314 303
315 304
316odbgstream& odbgstream::operator<<(unsigned short i) 305odbgstream& odbgstream::operator<<(unsigned short i)
317{ 306{
318 if (!print) return *this; 307 if (!print) return *this;
319 QString tmp; tmp.setNum(i); output += tmp; 308 QString tmp; tmp.setNum(i); output += tmp;
320 return *this; 309 return *this;
321} 310}
322 311
323 312
324odbgstream& odbgstream::operator<<(unsigned char i) 313odbgstream& odbgstream::operator<<(unsigned char i)
325{ 314{
326 return operator<<( static_cast<char>( i ) ); 315 return operator<<( static_cast<char>( i ) );
327} 316}
328 317
329 318
330odbgstream& odbgstream::operator<<(int i) 319odbgstream& odbgstream::operator<<(int i)
331{ 320{
332 if (!print) return *this; 321 if (!print) return *this;
333 QString tmp; tmp.setNum(i); output += tmp; 322 QString tmp; tmp.setNum(i); output += tmp;
334 return *this; 323 return *this;
335} 324}
336 325
337 326
338odbgstream& odbgstream::operator<<(unsigned int i) 327odbgstream& odbgstream::operator<<(unsigned int i)
339{ 328{
340 if (!print) return *this; 329 if (!print) return *this;
341 QString tmp; tmp.setNum(i); output += tmp; 330 QString tmp; tmp.setNum(i); output += tmp;
342 return *this; 331 return *this;
343} 332}
344 333
345 334
346odbgstream& odbgstream::operator<<(long i) 335odbgstream& odbgstream::operator<<(long i)
347{ 336{
348 if (!print) return *this; 337 if (!print) return *this;
349 QString tmp; tmp.setNum(i); output += tmp; 338 QString tmp; tmp.setNum(i); output += tmp;
350 return *this; 339 return *this;
351} 340}
352 341
353 342
354odbgstream& odbgstream::operator<<(unsigned long i) 343odbgstream& odbgstream::operator<<(unsigned long i)
355{ 344{
356 if (!print) return *this; 345 if (!print) return *this;
357 QString tmp; tmp.setNum(i); output += tmp; 346 QString tmp; tmp.setNum(i); output += tmp;
358 return *this; 347 return *this;
359} 348}
360 349
361 350
362odbgstream& odbgstream::operator<<(const QString& string) 351odbgstream& odbgstream::operator<<(const QString& string)
363{ 352{
364 if (!print) return *this; 353 if (!print) return *this;
365 output += string; 354 output += string;
366 if (output.at(output.length() -1 ) == '\n') 355 if (output.at(output.length() -1 ) == '\n')
367 flush(); 356 flush();
368 return *this; 357 return *this;
369} 358}
370 359
371 360
372odbgstream& odbgstream::operator<<(const char *string) 361odbgstream& odbgstream::operator<<(const char *string)
373{ 362{
374 if (!print) return *this; 363 if (!print) return *this;
375 output += QString::fromUtf8(string); 364 output += QString::fromUtf8(string);
376 if (output.at(output.length() - 1) == '\n') 365 if (output.at(output.length() - 1) == '\n')
377 flush(); 366 flush();
378 return *this; 367 return *this;
379} 368}
380 369
381 370
382odbgstream& odbgstream::operator<<(const QCString& string) 371odbgstream& odbgstream::operator<<(const QCString& string)
383{ 372{
384 *this << string.data(); 373 *this << string.data();
385 return *this; 374 return *this;
386} 375}
387 376
388 377
389odbgstream& odbgstream::operator<<(const void * p) 378odbgstream& odbgstream::operator<<(const void * p)
390{ 379{
391 form("%p", p); 380 form("%p", p);
392 return *this; 381 return *this;
393} 382}
394 383
395odbgstream& odbgstream::operator<<(double d) 384odbgstream& odbgstream::operator<<(double d)
396{ 385{
397 QString tmp; tmp.setNum(d); output += tmp; 386 QString tmp; tmp.setNum(d); output += tmp;
398 return *this; 387 return *this;
399} 388}
400 389
401/* 390/*
402odbgstream::odbgstream &form(const char *format, ...) 391odbgstream::odbgstream &form(const char *format, ...)
403#ifdef __GNUC__ 392#ifdef __GNUC__
404 __attribute__ ( ( format ( printf, 2, 3 ) ) ) 393 __attribute__ ( ( format ( printf, 2, 3 ) ) )
405#endif 394#endif
406 ; 395 ;
407*/ 396*/
408 397
409void odbgstream::flush() 398void odbgstream::flush()
410{ 399{
411 if ( output.isEmpty() || !print ) 400 if ( output.isEmpty() || !print )
412 { 401 {
413 return; 402 return;
414 } 403 }
415 else 404 else
416 { 405 {
417 oDebugBackend( level, area, output.local8Bit().data() ); 406 oDebugBackend( level, area, output.local8Bit().data() );
418 output = QString::null; 407 output = QString::null;
419 } 408 }
420} 409}
421 410
422odbgstream& odbgstream::form(const char *format, ...) 411odbgstream& odbgstream::form(const char *format, ...)
423{ 412{
424 char buf[4096]; 413 char buf[4096];
425 va_list arguments; 414 va_list arguments;
426 va_start( arguments, format ); 415 va_start( arguments, format );
427 buf[sizeof(buf)-1] = '\0'; 416 buf[sizeof(buf)-1] = '\0';
428 vsnprintf( buf, sizeof(buf)-1, format, arguments ); 417 vsnprintf( buf, sizeof(buf)-1, format, arguments );
429 va_end(arguments); 418 va_end(arguments);
430 *this << buf; 419 *this << buf;
431 return *this; 420 return *this;
432} 421}
433 422
434odbgstream::~odbgstream() 423odbgstream::~odbgstream()
435{ 424{
436 if (!output.isEmpty()) 425 if (!output.isEmpty())
437 { 426 {
438 fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); 427 fprintf(stderr, "ASSERT: debug output not ended with \\n\n");
439 *this << "\n"; 428 *this << "\n";
440 } 429 }
441} 430}
442 431
443odbgstream& odbgstream::operator<<(char ch) 432odbgstream& odbgstream::operator<<(char ch)
444{ 433{
445 if (!print) return *this; 434 if (!print) return *this;
446 if (!isprint(ch)) 435 if (!isprint(ch))
447 { 436 {
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index 879e80f..1aa206e 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -1,411 +1,410 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org> 4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <opie2/oglobal.h> 30#include <opie2/oglobal.h>
31 31
32#include <qfile.h>
33#include <qtextstream.h> 32#include <qtextstream.h>
34#include <qdir.h> 33#include <qdir.h>
35#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
36#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
37#include <qpe/storage.h> 36#include <qpe/storage.h>
38 37
39#include <unistd.h> 38#include <unistd.h>
40#include <sys/types.h> 39#include <sys/types.h>
41 40
42static const char Base64EncMap[64] = 41static const char Base64EncMap[64] =
43{ 42{
44 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 43 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
45 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 44 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
46 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 45 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
47 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 46 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
48 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 47 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
49 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 48 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
50 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 49 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
51 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F 50 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
52}; 51};
53 52
54static char Base64DecMap[128] = 53static char Base64DecMap[128] =
55{ 54{
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 60 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
62 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 61 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
63 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 63 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
65 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 64 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
66 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 65 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
67 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 66 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 67 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
69 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 68 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
70 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 69 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
71 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 70 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
72}; 71};
73 72
74 73
75OConfig* OGlobal::_config = 0; 74OConfig* OGlobal::_config = 0;
76OConfig* OGlobal::_qpe_config = 0; 75OConfig* OGlobal::_qpe_config = 0;
77 76
78OConfig* OGlobal::config() 77OConfig* OGlobal::config()
79{ 78{
80 if ( !OGlobal::_config ) 79 if ( !OGlobal::_config )
81 { 80 {
82 // odebug classes are reading config, so can't use them here! 81 // odebug classes are reading config, so can't use them here!
83 qDebug( "OGlobal::creating global configuration instance." ); 82 qDebug( "OGlobal::creating global configuration instance." );
84 OGlobal::_config = new OConfig( "global" ); 83 OGlobal::_config = new OConfig( "global" );
85 } 84 }
86 return OGlobal::_config; 85 return OGlobal::_config;
87} 86}
88 87
89 88
90/** 89/**
91 * Return the internal builtin Global::Command object 90 * Return the internal builtin Global::Command object
92 * 91 *
93 */ 92 */
94Global::Command* OGlobal::builtinCommands() { 93Global::Command* OGlobal::builtinCommands() {
95 return builtin; 94 return builtin;
96} 95}
97 96
98 97
99/** 98/**
100 * Return the internal builtin QGuardedPtr<QWidget> object 99 * Return the internal builtin QGuardedPtr<QWidget> object
101 */ 100 */
102QGuardedPtr<QWidget>* OGlobal::builtinRunning() { 101QGuardedPtr<QWidget>* OGlobal::builtinRunning() {
103 return running; 102 return running;
104} 103}
105 104
106 105
107/** 106/**
108 * \brief generate a new UUID as QString 107 * \brief generate a new UUID as QString
109 * Return a new UUID as QString. UUID are global unique 108 * Return a new UUID as QString. UUID are global unique
110 * 109 *
111 * 110 *
112 * @return the UUID or QString::null 111 * @return the UUID or QString::null
113 */ 112 */
114QString OGlobal::generateUuid() { 113QString OGlobal::generateUuid() {
115 QFile file( "/proc/sys/kernel/random/uuid" ); 114 QFile file( "/proc/sys/kernel/random/uuid" );
116 if (!file.open(IO_ReadOnly ) ) 115 if (!file.open(IO_ReadOnly ) )
117 return QString::null; 116 return QString::null;
118 117
119 QTextStream stream(&file); 118 QTextStream stream(&file);
120 119
121 return "{" + stream.read().stripWhiteSpace() + "}"; 120 return "{" + stream.read().stripWhiteSpace() + "}";
122} 121}
123 122
124 123
125/** 124/**
126 * \brief Encode a QByteArray in base64 125 * \brief Encode a QByteArray in base64
127 * 126 *
128 * An Implementation of the RF1521 base64 encoding. 127 * An Implementation of the RF1521 base64 encoding.
129 * 128 *
130 * The boolean argument determines if the encoded data is 129 * The boolean argument determines if the encoded data is
131 * going to be restricted to 76 characters or less per line 130 * going to be restricted to 76 characters or less per line
132 * as specified by RFC 2045. If @p insertLFs is true, then 131 * as specified by RFC 2045. If @p insertLFs is true, then
133 * there will be 76 characters or less per line. 132 * there will be 76 characters or less per line.
134 * 133 *
135 * If you use this to create a QCString remember that it is null terminated! 134 * If you use this to create a QCString remember that it is null terminated!
136 * \code 135 * \code
137 * QByteArray ar = OGlobal::encodeBase64(&array); 136 * QByteArray ar = OGlobal::encodeBase64(&array);
138 * QCString str(ar.data(),ar.size()+1); // the NUL at the end 137 * QCString str(ar.data(),ar.size()+1); // the NUL at the end
139 * 138 *
140 * \endcode 139 * \endcode
141 * 140 *
142 * @param in The QByteArray to encode 141 * @param in The QByteArray to encode
143 * @param insertLFs Limit number of characters per line 142 * @param insertLFs Limit number of characters per line
144 * @return The argument as base64 encoded or QByteArray() if in.isEmpty() 143 * @return The argument as base64 encoded or QByteArray() if in.isEmpty()
145 * @see QByteArray 144 * @see QByteArray
146 * @see QArray 145 * @see QArray
147 * @see QMemArray 146 * @see QMemArray
148 * @see QCString 147 * @see QCString
149 */ 148 */
150/* 149/*
151 * LGPL by Rik Hemsely of the KDE Project. taken from kmdcodec.cpp 150 * LGPL by Rik Hemsely of the KDE Project. taken from kmdcodec.cpp
152 */ 151 */
153QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) { 152QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) {
154 if ( in.isEmpty() ) 153 if ( in.isEmpty() )
155 return QByteArray(); 154 return QByteArray();
156 155
157 unsigned int sidx = 0; 156 unsigned int sidx = 0;
158 unsigned int didx = 0; 157 unsigned int didx = 0;
159 const char* data = in.data(); 158 const char* data = in.data();
160 const unsigned int len = in.size(); 159 const unsigned int len = in.size();
161 160
162 unsigned int out_len = ((len+2)/3)*4; 161 unsigned int out_len = ((len+2)/3)*4;
163 162
164 // Deal with the 76 characters or less per 163 // Deal with the 76 characters or less per
165 // line limit specified in RFC 2045 on a 164 // line limit specified in RFC 2045 on a
166 // pre request basis. 165 // pre request basis.
167 insertLFs = (insertLFs && out_len > 76); 166 insertLFs = (insertLFs && out_len > 76);
168 if ( insertLFs ) 167 if ( insertLFs )
169 out_len += ((out_len-1)/76); 168 out_len += ((out_len-1)/76);
170 169
171 int count = 0; 170 int count = 0;
172 QByteArray out( out_len ); 171 QByteArray out( out_len );
173 172
174 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion 173 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion
175 if ( len > 1 ) 174 if ( len > 1 )
176 { 175 {
177 while (sidx < len-2) 176 while (sidx < len-2)
178 { 177 {
179 if ( insertLFs ) 178 if ( insertLFs )
180 { 179 {
181 if ( count && (count%76) == 0 ) 180 if ( count && (count%76) == 0 )
182 out[didx++] = '\n'; 181 out[didx++] = '\n';
183 count += 4; 182 count += 4;
184 } 183 }
185 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; 184 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077];
186 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | 185 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 |
187 (data[sidx] << 4) & 077]; 186 (data[sidx] << 4) & 077];
188 out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 | 187 out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 |
189 (data[sidx+1] << 2) & 077]; 188 (data[sidx+1] << 2) & 077];
190 out[didx++] = Base64EncMap[data[sidx+2] & 077]; 189 out[didx++] = Base64EncMap[data[sidx+2] & 077];
191 sidx += 3; 190 sidx += 3;
192 } 191 }
193 } 192 }
194 193
195 if (sidx < len) 194 if (sidx < len)
196 { 195 {
197 if ( insertLFs && (count > 0) && (count%76) == 0 ) 196 if ( insertLFs && (count > 0) && (count%76) == 0 )
198 out[didx++] = '\n'; 197 out[didx++] = '\n';
199 198
200 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; 199 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077];
201 if (sidx < len-1) 200 if (sidx < len-1)
202 { 201 {
203 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | 202 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 |
204 (data[sidx] << 4) & 077]; 203 (data[sidx] << 4) & 077];
205 out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; 204 out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077];
206 } 205 }
207 else 206 else
208 { 207 {
209 out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; 208 out[didx++] = Base64EncMap[(data[sidx] << 4) & 077];
210 } 209 }
211 } 210 }
212 211
213 // Add padding 212 // Add padding
214 while (didx < out.size()) 213 while (didx < out.size())
215 { 214 {
216 out[didx] = '='; 215 out[didx] = '=';
217 didx++; 216 didx++;
218 } 217 }
219 218
220 return out; 219 return out;
221} 220}
222 221
223/** 222/**
224 * Decodes the given data that was encoded with the base64 223 * Decodes the given data that was encoded with the base64
225 * algorithm. 224 * algorithm.
226 * 225 *
227 * 226 *
228 * @param in the encoded data to be decoded. 227 * @param in the encoded data to be decoded.
229 * @return the decoded QByteArray or QByteArray() in case of failure 228 * @return the decoded QByteArray or QByteArray() in case of failure
230 * @see OGlobal::encodeBase64 229 * @see OGlobal::encodeBase64
231 */ 230 */
232QByteArray OGlobal::decodeBase64( const QByteArray& in) { 231QByteArray OGlobal::decodeBase64( const QByteArray& in) {
233 if ( in.isEmpty() ) 232 if ( in.isEmpty() )
234 return QByteArray(); 233 return QByteArray();
235 234
236 QByteArray out; 235 QByteArray out;
237 unsigned int count = 0; 236 unsigned int count = 0;
238 unsigned int len = in.size(), tail = len; 237 unsigned int len = in.size(), tail = len;
239 const char* data = in.data(); 238 const char* data = in.data();
240 239
241 // Deal with possible *nix "BEGIN" marker!! 240 // Deal with possible *nix "BEGIN" marker!!
242 while ( count < len && (data[count] == '\n' || data[count] == '\r' || 241 while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
243 data[count] == '\t' || data[count] == ' ') ) 242 data[count] == '\t' || data[count] == ' ') )
244 count++; 243 count++;
245 244
246 if ( strncasecmp(data+count, "begin", 5) == 0 ) 245 if ( strncasecmp(data+count, "begin", 5) == 0 )
247 { 246 {
248 count += 5; 247 count += 5;
249 while ( count < len && data[count] != '\n' && data[count] != '\r' ) 248 while ( count < len && data[count] != '\n' && data[count] != '\r' )
250 count++; 249 count++;
251 250
252 while ( count < len && (data[count] == '\n' || data[count] == '\r') ) 251 while ( count < len && (data[count] == '\n' || data[count] == '\r') )
253 count ++; 252 count ++;
254 253
255 data += count; 254 data += count;
256 tail = (len -= count); 255 tail = (len -= count);
257 } 256 }
258 257
259 // Find the tail end of the actual encoded data even if 258 // Find the tail end of the actual encoded data even if
260 // there is/are trailing CR and/or LF. 259 // there is/are trailing CR and/or LF.
261 while ( data[tail-1] == '=' || data[tail-1] == '\n' || 260 while ( data[tail-1] == '=' || data[tail-1] == '\n' ||
262 data[tail-1] == '\r' ) 261 data[tail-1] == '\r' )
263 if ( data[--tail] != '=' ) len = tail; 262 if ( data[--tail] != '=' ) len = tail;
264 263
265 unsigned int outIdx = 0; 264 unsigned int outIdx = 0;
266 out.resize( (count=len) ); 265 out.resize( (count=len) );
267 for (unsigned int idx = 0; idx < count; idx++) 266 for (unsigned int idx = 0; idx < count; idx++)
268 { 267 {
269 // Adhere to RFC 2045 and ignore characters 268 // Adhere to RFC 2045 and ignore characters
270 // that are not part of the encoding table. 269 // that are not part of the encoding table.
271 unsigned char ch = data[idx]; 270 unsigned char ch = data[idx];
272 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) || 271 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
273 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=') 272 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
274 { 273 {
275 out[outIdx++] = Base64DecMap[ch]; 274 out[outIdx++] = Base64DecMap[ch];
276 } 275 }
277 else 276 else
278 { 277 {
279 len--; 278 len--;
280 tail--; 279 tail--;
281 } 280 }
282 } 281 }
283 282
284 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; 283 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
285 284
286 // 4-byte to 3-byte conversion 285 // 4-byte to 3-byte conversion
287 len = (tail>(len/4)) ? tail-(len/4) : 0; 286 len = (tail>(len/4)) ? tail-(len/4) : 0;
288 unsigned int sidx = 0, didx = 0; 287 unsigned int sidx = 0, didx = 0;
289 if ( len > 1 ) 288 if ( len > 1 )
290 { 289 {
291 while (didx < len-2) 290 while (didx < len-2)
292 { 291 {
293 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 292 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
294 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 293 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
295 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); 294 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
296 sidx += 4; 295 sidx += 4;
297 didx += 3; 296 didx += 3;
298 } 297 }
299 } 298 }
300 299
301 if (didx < len) 300 if (didx < len)
302 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 301 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
303 302
304 if (++didx < len ) 303 if (++didx < len )
305 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 304 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
306 305
307 // Resize the output buffer 306 // Resize the output buffer
308 if ( len == 0 || len < out.size() ) 307 if ( len == 0 || len < out.size() )
309 out.resize(len); 308 out.resize(len);
310 309
311 return out; 310 return out;
312} 311}
313 312
314bool OGlobal::isAppLnkFileName( const QString& str ) 313bool OGlobal::isAppLnkFileName( const QString& str )
315{ 314{
316 if (str.length()==0||str.at(str.length()-1)==QDir::separator()) return false; 315 if (str.length()==0||str.at(str.length()-1)==QDir::separator()) return false;
317 return str.startsWith(MimeType::appsFolderName()+QDir::separator()); 316 return str.startsWith(MimeType::appsFolderName()+QDir::separator());
318} 317}
319 318
320/* ToDo: 319/* ToDo:
321 * This fun should check the document-path value for the mounted media 320 * This fun should check the document-path value for the mounted media
322 * which has to be implemented later. this moment we just check for a 321 * which has to be implemented later. this moment we just check for a
323 * mounted media name. 322 * mounted media name.
324 */ 323 */
325bool OGlobal::isDocumentFileName( const QString& file ) 324bool OGlobal::isDocumentFileName( const QString& file )
326{ 325{
327 if (file.length()==0||file.at(file.length()-1)==QDir::separator()) return false; 326 if (file.length()==0||file.at(file.length()-1)==QDir::separator()) return false;
328 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true; 327 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
329 StorageInfo si; 328 StorageInfo si;
330 QList< FileSystem > fl = si.fileSystems(); 329 QList< FileSystem > fl = si.fileSystems();
331 FileSystem*fs; 330 FileSystem*fs;
332 for (fs = fl.first();fs!=0;fs=fl.next()) { 331 for (fs = fl.first();fs!=0;fs=fl.next()) {
333 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator())) 332 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
334 return true; 333 return true;
335 } 334 }
336 if (file.startsWith(homeDirPath())+"/Documents/") return true; 335 if (file.startsWith(homeDirPath())+"/Documents/") return true;
337 return false; 336 return false;
338} 337}
339 338
340QString OGlobal::tempDirPath() 339QString OGlobal::tempDirPath()
341{ 340{
342 static QString defstring="/tmp"; 341 static QString defstring="/tmp";
343 char * tmpp = 0; 342 char * tmpp = 0;
344 if ( (tmpp=getenv("TEMP"))) { 343 if ( (tmpp=getenv("TEMP"))) {
345 return tmpp; 344 return tmpp;
346 } 345 }
347 return defstring; 346 return defstring;
348} 347}
349 348
350QString OGlobal::homeDirPath() 349QString OGlobal::homeDirPath()
351{ 350{
352 char * tmpp = getenv("HOME"); 351 char * tmpp = getenv("HOME");
353 return (tmpp?tmpp:"/"); 352 return (tmpp?tmpp:"/");
354} 353}
355 354
356bool OGlobal::weekStartsOnMonday() 355bool OGlobal::weekStartsOnMonday()
357{ 356{
358 OConfig*conf=OGlobal::qpe_config(); 357 OConfig*conf=OGlobal::qpe_config();
359 if (!conf)return false; 358 if (!conf)return false;
360 conf->setGroup("Time"); 359 conf->setGroup("Time");
361 return conf->readBoolEntry("MONDAY",true); 360 return conf->readBoolEntry("MONDAY",true);
362} 361}
363 362
364void OGlobal::setWeekStartsOnMonday( bool what) 363void OGlobal::setWeekStartsOnMonday( bool what)
365{ 364{
366 OConfig*conf=OGlobal::qpe_config(); 365 OConfig*conf=OGlobal::qpe_config();
367 if (!conf)return; 366 if (!conf)return;
368 conf->setGroup("Time"); 367 conf->setGroup("Time");
369 return conf->writeEntry("MONDAY",what); 368 return conf->writeEntry("MONDAY",what);
370} 369}
371 370
372bool OGlobal::useAMPM() 371bool OGlobal::useAMPM()
373{ 372{
374 OConfig*conf=OGlobal::qpe_config(); 373 OConfig*conf=OGlobal::qpe_config();
375 if (!conf)return false; 374 if (!conf)return false;
376 conf->setGroup("Time"); 375 conf->setGroup("Time");
377 return conf->readBoolEntry("AMPM",false); 376 return conf->readBoolEntry("AMPM",false);
378} 377}
379 378
380void OGlobal::setUseAMPM( bool what) 379void OGlobal::setUseAMPM( bool what)
381{ 380{
382 OConfig*conf=OGlobal::qpe_config(); 381 OConfig*conf=OGlobal::qpe_config();
383 if (!conf)return; 382 if (!conf)return;
384 conf->setGroup("Time"); 383 conf->setGroup("Time");
385 return conf->writeEntry("AMPM",what); 384 return conf->writeEntry("AMPM",what);
386} 385}
387 386
388OConfig* OGlobal::qpe_config() 387OConfig* OGlobal::qpe_config()
389{ 388{
390 if ( !OGlobal::_qpe_config ) { 389 if ( !OGlobal::_qpe_config ) {
391 OGlobal::_qpe_config = new OConfig( "qpe" ); 390 OGlobal::_qpe_config = new OConfig( "qpe" );
392 } 391 }
393 return OGlobal::_qpe_config; 392 return OGlobal::_qpe_config;
394} 393}
395 394
396bool OGlobal::truncateFile( QFile &f, off_t size ) 395bool OGlobal::truncateFile( QFile &f, off_t size )
397{ 396{
398 /* or should we let enlarge Files? then remove this 397 /* or should we let enlarge Files? then remove this
399 f.size()< part! - Alwin 398 f.size()< part! - Alwin
400 */ 399 */
401 if (!f.exists()||f.size()<(unsigned)size) return false; 400 if (!f.exists()||f.size()<(unsigned)size) return false;
402 bool closeit=false; 401 bool closeit=false;
403 if (!f.isOpen()) { 402 if (!f.isOpen()) {
404 closeit=true; 403 closeit=true;
405 f.open(IO_Raw | IO_ReadWrite | IO_Append); 404 f.open(IO_Raw | IO_ReadWrite | IO_Append);
406 } 405 }
407 if (!f.isOpen()) { return false; } 406 if (!f.isOpen()) { return false; }
408 int r = ftruncate(f.handle(),size); 407 int r = ftruncate(f.handle(),size);
409 if (closeit) f.close(); 408 if (closeit) f.close();
410 return r==0; 409 return r==0;
411} 410}
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 66adbd0..192e55b 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -1,428 +1,425 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the KDE globalsettings which are 5 Inspired by the KDE globalsettings which are
6 Copyright (C) 2000 David Faure <faure@kde.org> 6 Copyright (C) 2000 David Faure <faure@kde.org>
7 =. 7 =.
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/* OPIE */ 33/* OPIE */
34 34
35#include <opie2/oglobalsettings.h> 35#include <opie2/oglobalsettings.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oglobal.h> 37#include <opie2/oglobal.h>
38 38
39/* QT */ 39/* QT */
40 40
41#include <qobject.h>
42#include <qdir.h> 41#include <qdir.h>
43#include <qpixmap.h>
44#include <qfontinfo.h>
45 42
46/* UNIX */ 43/* UNIX */
47 44
48#include <stdlib.h> 45#include <stdlib.h>
49 46
50QString* OGlobalSettings::s_desktopPath = 0; 47QString* OGlobalSettings::s_desktopPath = 0;
51QString* OGlobalSettings::s_autostartPath = 0; 48QString* OGlobalSettings::s_autostartPath = 0;
52QString* OGlobalSettings::s_trashPath = 0; 49QString* OGlobalSettings::s_trashPath = 0;
53QString* OGlobalSettings::s_documentPath = 0; 50QString* OGlobalSettings::s_documentPath = 0;
54QFont *OGlobalSettings::_generalFont = 0; 51QFont *OGlobalSettings::_generalFont = 0;
55QFont *OGlobalSettings::_fixedFont = 0; 52QFont *OGlobalSettings::_fixedFont = 0;
56QFont *OGlobalSettings::_toolBarFont = 0; 53QFont *OGlobalSettings::_toolBarFont = 0;
57QFont *OGlobalSettings::_menuFont = 0; 54QFont *OGlobalSettings::_menuFont = 0;
58QFont *OGlobalSettings::_windowTitleFont = 0; 55QFont *OGlobalSettings::_windowTitleFont = 0;
59QFont *OGlobalSettings::_taskbarFont = 0; 56QFont *OGlobalSettings::_taskbarFont = 0;
60 57
61QColor *OGlobalSettings::OpieGray = 0; 58QColor *OGlobalSettings::OpieGray = 0;
62QColor *OGlobalSettings::OpieHighlight = 0; 59QColor *OGlobalSettings::OpieHighlight = 0;
63QColor *OGlobalSettings::OpieAlternate = 0; 60QColor *OGlobalSettings::OpieAlternate = 0;
64 61
65OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; 62OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
66 63
67//FIXME: Add manipulators to the accessors 64//FIXME: Add manipulators to the accessors
68 65
69int OGlobalSettings::dndEventDelay() 66int OGlobalSettings::dndEventDelay()
70{ 67{
71 OConfig *c = OGlobal::config(); 68 OConfig *c = OGlobal::config();
72 OConfigGroupSaver cgs( c, "General" ); 69 OConfigGroupSaver cgs( c, "General" );
73 return c->readNumEntry("DndDelay", 2); 70 return c->readNumEntry("DndDelay", 2);
74} 71}
75 72
76bool OGlobalSettings::singleClick() 73bool OGlobalSettings::singleClick()
77{ 74{
78 OConfig *c = OGlobal::config(); 75 OConfig *c = OGlobal::config();
79 OConfigGroupSaver cgs( c, "OPIE" ); 76 OConfigGroupSaver cgs( c, "OPIE" );
80 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); 77 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
81} 78}
82 79
83bool OGlobalSettings::insertTearOffHandle() 80bool OGlobalSettings::insertTearOffHandle()
84{ 81{
85 OConfig *c = OGlobal::config(); 82 OConfig *c = OGlobal::config();
86 OConfigGroupSaver cgs( c, "OPIE" ); 83 OConfigGroupSaver cgs( c, "OPIE" );
87 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); 84 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
88} 85}
89 86
90bool OGlobalSettings::changeCursorOverIcon() 87bool OGlobalSettings::changeCursorOverIcon()
91{ 88{
92 OConfig *c = OGlobal::config(); 89 OConfig *c = OGlobal::config();
93 OConfigGroupSaver cgs( c, "OPIE" ); 90 OConfigGroupSaver cgs( c, "OPIE" );
94 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); 91 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
95} 92}
96 93
97bool OGlobalSettings::visualActivate() 94bool OGlobalSettings::visualActivate()
98{ 95{
99 OConfig *c = OGlobal::config(); 96 OConfig *c = OGlobal::config();
100 OConfigGroupSaver cgs( c, "OPIE" ); 97 OConfigGroupSaver cgs( c, "OPIE" );
101 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); 98 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE);
102} 99}
103 100
104unsigned int OGlobalSettings::visualActivateSpeed() 101unsigned int OGlobalSettings::visualActivateSpeed()
105{ 102{
106 OConfig *c = OGlobal::config(); 103 OConfig *c = OGlobal::config();
107 OConfigGroupSaver cgs( c, "OPIE" ); 104 OConfigGroupSaver cgs( c, "OPIE" );
108 return 105 return
109 c->readNumEntry( 106 c->readNumEntry(
110 "VisualActivateSpeed", 107 "VisualActivateSpeed",
111 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 108 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED
112 ); 109 );
113} 110}
114 111
115int OGlobalSettings::autoSelectDelay() 112int OGlobalSettings::autoSelectDelay()
116{ 113{
117 OConfig *c = OGlobal::config(); 114 OConfig *c = OGlobal::config();
118 OConfigGroupSaver cgs( c, "OPIE" ); 115 OConfigGroupSaver cgs( c, "OPIE" );
119 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); 116 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY);
120} 117}
121 118
122OGlobalSettings::Completion OGlobalSettings::completionMode() 119OGlobalSettings::Completion OGlobalSettings::completionMode()
123{ 120{
124 int completion; 121 int completion;
125 OConfig *c = OGlobal::config(); 122 OConfig *c = OGlobal::config();
126 OConfigGroupSaver cgs( c, "General" ); 123 OConfigGroupSaver cgs( c, "General" );
127 completion = c->readNumEntry("completionMode", -1); 124 completion = c->readNumEntry("completionMode", -1);
128 if ((completion < (int) CompletionNone) || 125 if ((completion < (int) CompletionNone) ||
129 (completion > (int) CompletionPopupAuto)) 126 (completion > (int) CompletionPopupAuto))
130 { 127 {
131 completion = (int) CompletionPopup; // Default 128 completion = (int) CompletionPopup; // Default
132 } 129 }
133 return (Completion) completion; 130 return (Completion) completion;
134} 131}
135 132
136 133
137bool OGlobalSettings::showContextMenusOnPress () 134bool OGlobalSettings::showContextMenusOnPress ()
138{ 135{
139 OConfig *c = OGlobal::config(); 136 OConfig *c = OGlobal::config();
140 OConfigGroupSaver cgs (c, "ContextMenus"); 137 OConfigGroupSaver cgs (c, "ContextMenus");
141 138
142 return cgs.config()->readBoolEntry("ShowOnPress", true); 139 return cgs.config()->readBoolEntry("ShowOnPress", true);
143} 140}
144 141
145 142
146int OGlobalSettings::contextMenuKey () 143int OGlobalSettings::contextMenuKey ()
147{ 144{
148 OConfig *c = OGlobal::config(); 145 OConfig *c = OGlobal::config();
149 OConfigGroupSaver cgs (c, "Shortcuts"); 146 OConfigGroupSaver cgs (c, "Shortcuts");
150 147
151 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); 148 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu"));
152 //return cut.keyCodeQt(); 149 //return cut.keyCodeQt();
153 150
154 return 0; // FIXME 151 return 0; // FIXME
155} 152}
156 153
157 154
158OGlobalSettings::Debug OGlobalSettings::debugMode() 155OGlobalSettings::Debug OGlobalSettings::debugMode()
159{ 156{
160 OConfig *c = OGlobal::config(); 157 OConfig *c = OGlobal::config();
161 OConfigGroupSaver cgs( c, "General" ); 158 OConfigGroupSaver cgs( c, "General" );
162 int debug = c->readNumEntry( "debugMode", -1 ); 159 int debug = c->readNumEntry( "debugMode", -1 );
163 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) 160 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) )
164 { 161 {
165 debug = (int) DebugStdErr; // Default 162 debug = (int) DebugStdErr; // Default
166 } 163 }
167 return (Debug) debug; 164 return (Debug) debug;
168} 165}
169 166
170 167
171QString OGlobalSettings::debugOutput() 168QString OGlobalSettings::debugOutput()
172{ 169{
173 OConfig *c = OGlobal::config(); 170 OConfig *c = OGlobal::config();
174 OConfigGroupSaver cgs( c, "General" ); 171 OConfigGroupSaver cgs( c, "General" );
175 QString deflt = QString::null; 172 QString deflt = QString::null;
176 switch( debugMode() ) 173 switch( debugMode() )
177 { 174 {
178 case DebugNone: break; // no additional information needed 175 case DebugNone: break; // no additional information needed
179 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in 176 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in
180 case DebugMsgBox: break; // no additional information needed 177 case DebugMsgBox: break; // no additional information needed
181 case DebugStdErr: break; // no additional information needed 178 case DebugStdErr: break; // no additional information needed
182 case DebugSysLog: break; // no additional information needed 179 case DebugSysLog: break; // no additional information needed
183 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to 180 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to
184 } 181 }
185 182
186 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); 183 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt );
187} 184}
188 185
189 186
190QColor OGlobalSettings::toolBarHighlightColor() 187QColor OGlobalSettings::toolBarHighlightColor()
191{ 188{
192 initColors(); 189 initColors();
193 OConfig *c = OGlobal::config(); 190 OConfig *c = OGlobal::config();
194 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); 191 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") );
195 return c->readColorEntry("HighlightColor", OpieHighlight); 192 return c->readColorEntry("HighlightColor", OpieHighlight);
196} 193}
197 194
198QColor OGlobalSettings::inactiveTitleColor() 195QColor OGlobalSettings::inactiveTitleColor()
199{ 196{
200 if (!OpieGray) OpieGray = new QColor(220, 220, 220); 197 if (!OpieGray) OpieGray = new QColor(220, 220, 220);
201 OConfig *c = OGlobal::config(); 198 OConfig *c = OGlobal::config();
202 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 199 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
203 return c->readColorEntry( "inactiveBackground", OpieGray ); 200 return c->readColorEntry( "inactiveBackground", OpieGray );
204} 201}
205 202
206QColor OGlobalSettings::inactiveTextColor() 203QColor OGlobalSettings::inactiveTextColor()
207{ 204{
208 OConfig *c = OGlobal::config(); 205 OConfig *c = OGlobal::config();
209 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 206 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
210 return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); 207 return c->readColorEntry( "inactiveForeground", &Qt::darkGray );
211} 208}
212 209
213QColor OGlobalSettings::activeTitleColor() 210QColor OGlobalSettings::activeTitleColor()
214{ 211{
215 initColors(); 212 initColors();
216 OConfig *c = OGlobal::config(); 213 OConfig *c = OGlobal::config();
217 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 214 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
218 return c->readColorEntry( "activeBackground", OpieHighlight); 215 return c->readColorEntry( "activeBackground", OpieHighlight);
219} 216}
220 217
221QColor OGlobalSettings::activeTextColor() 218QColor OGlobalSettings::activeTextColor()
222{ 219{
223 OConfig *c = OGlobal::config(); 220 OConfig *c = OGlobal::config();
224 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 221 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
225 return c->readColorEntry( "activeForeground", &Qt::white ); 222 return c->readColorEntry( "activeForeground", &Qt::white );
226} 223}
227 224
228int OGlobalSettings::contrast() 225int OGlobalSettings::contrast()
229{ 226{
230 OConfig *c = OGlobal::config(); 227 OConfig *c = OGlobal::config();
231 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); 228 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") );
232 return c->readNumEntry( "contrast", 7 ); 229 return c->readNumEntry( "contrast", 7 );
233} 230}
234 231
235// following functions should work in OPIE - how to sync with appearance changes? 232// following functions should work in OPIE - how to sync with appearance changes?
236 233
237QColor OGlobalSettings::baseColor() 234QColor OGlobalSettings::baseColor()
238{ 235{
239 OConfig *c = OGlobal::config(); 236 OConfig *c = OGlobal::config();
240 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 237 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
241 return c->readColorEntry( "Base", &Qt::white ); 238 return c->readColorEntry( "Base", &Qt::white );
242} 239}
243 240
244QColor OGlobalSettings::textColor() 241QColor OGlobalSettings::textColor()
245{ 242{
246 OConfig *c = OGlobal::config(); 243 OConfig *c = OGlobal::config();
247 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 244 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
248 return c->readColorEntry( "Text", &Qt::black ); 245 return c->readColorEntry( "Text", &Qt::black );
249} 246}
250 247
251QColor OGlobalSettings::highlightedTextColor() 248QColor OGlobalSettings::highlightedTextColor()
252{ 249{
253 OConfig *c = OGlobal::config(); 250 OConfig *c = OGlobal::config();
254 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 251 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
255 return c->readColorEntry( "HighlightedText", &Qt::white ); 252 return c->readColorEntry( "HighlightedText", &Qt::white );
256} 253}
257 254
258QColor OGlobalSettings::highlightColor() 255QColor OGlobalSettings::highlightColor()
259{ 256{
260 initColors(); 257 initColors();
261 OConfig *c = OGlobal::config(); 258 OConfig *c = OGlobal::config();
262 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 259 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
263 return c->readColorEntry( "Highlight", OpieHighlight ); 260 return c->readColorEntry( "Highlight", OpieHighlight );
264} 261}
265 262
266QColor OGlobalSettings::alternateBackgroundColor() 263QColor OGlobalSettings::alternateBackgroundColor()
267{ 264{
268 initColors(); 265 initColors();
269 OConfig *c = OGlobal::config(); 266 OConfig *c = OGlobal::config();
270 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 267 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
271 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); 268 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() );
272 return c->readColorEntry( "alternateBackground", OpieAlternate ); 269 return c->readColorEntry( "alternateBackground", OpieAlternate );
273} 270}
274 271
275QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) 272QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
276{ 273{
277 if (base == Qt::white) 274 if (base == Qt::white)
278 return QColor(238,246,255); 275 return QColor(238,246,255);
279 else 276 else
280 { 277 {
281 int h, s, v; 278 int h, s, v;
282 base.hsv( &h, &s, &v ); 279 base.hsv( &h, &s, &v );
283 if (v > 128) 280 if (v > 128)
284 return base.dark(106); 281 return base.dark(106);
285 else if (base != Qt::black) 282 else if (base != Qt::black)
286 return base.light(110); 283 return base.light(110);
287 284
288 return QColor(32,32,32); 285 return QColor(32,32,32);
289 } 286 }
290} 287}
291 288
292QColor OGlobalSettings::linkColor() 289QColor OGlobalSettings::linkColor()
293{ 290{
294 initColors(); 291 initColors();
295 OConfig *c = OGlobal::config(); 292 OConfig *c = OGlobal::config();
296 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 293 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
297 return c->readColorEntry( "linkColor", OpieGray ); 294 return c->readColorEntry( "linkColor", OpieGray );
298} 295}
299 296
300QColor OGlobalSettings::visitedLinkColor() 297QColor OGlobalSettings::visitedLinkColor()
301{ 298{
302 OConfig *c = OGlobal::config(); 299 OConfig *c = OGlobal::config();
303 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 300 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
304 return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); 301 return c->readColorEntry( "visitedLinkColor", &Qt::magenta );
305} 302}
306 303
307// FIXME: font stuff currently uses a different format in OPIE, so the 304// FIXME: font stuff currently uses a different format in OPIE, so the
308// functions below are not yet applicable. The whole font stuff for OPIE 305// functions below are not yet applicable. The whole font stuff for OPIE
309// has to be revised anyway 306// has to be revised anyway
310 307
311QFont OGlobalSettings::generalFont() 308QFont OGlobalSettings::generalFont()
312{ 309{
313 if (_generalFont) 310 if (_generalFont)
314 return *_generalFont; 311 return *_generalFont;
315 312
316 _generalFont = new QFont("helvetica", 10); 313 _generalFont = new QFont("helvetica", 10);
317 _generalFont->setPixelSize(10); 314 _generalFont->setPixelSize(10);
318 _generalFont->setStyleHint(QFont::SansSerif); 315 _generalFont->setStyleHint(QFont::SansSerif);
319 316
320 OConfig *c = OGlobal::config(); 317 OConfig *c = OGlobal::config();
321 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 318 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
322 *_generalFont = c->readFontEntry("font", _generalFont); 319 *_generalFont = c->readFontEntry("font", _generalFont);
323 320
324 return *_generalFont; 321 return *_generalFont;
325} 322}
326 323
327QFont OGlobalSettings::fixedFont() 324QFont OGlobalSettings::fixedFont()
328{ 325{
329 if (_fixedFont) 326 if (_fixedFont)
330 return *_fixedFont; 327 return *_fixedFont;
331 328
332 _fixedFont = new QFont("courier", 12); 329 _fixedFont = new QFont("courier", 12);
333 _fixedFont->setPixelSize(12); 330 _fixedFont->setPixelSize(12);
334 _fixedFont->setStyleHint(QFont::TypeWriter); 331 _fixedFont->setStyleHint(QFont::TypeWriter);
335 332
336 OConfig *c = OGlobal::config(); 333 OConfig *c = OGlobal::config();
337 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 334 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
338 *_fixedFont = c->readFontEntry("fixed", _fixedFont); 335 *_fixedFont = c->readFontEntry("fixed", _fixedFont);
339 336
340 return *_fixedFont; 337 return *_fixedFont;
341} 338}
342 339
343QFont OGlobalSettings::toolBarFont() 340QFont OGlobalSettings::toolBarFont()
344{ 341{
345 if(_toolBarFont) 342 if(_toolBarFont)
346 return *_toolBarFont; 343 return *_toolBarFont;
347 344
348 _toolBarFont = new QFont("helvetica", 10); 345 _toolBarFont = new QFont("helvetica", 10);
349 _toolBarFont->setPixelSize(10); 346 _toolBarFont->setPixelSize(10);
350 _toolBarFont->setStyleHint(QFont::SansSerif); 347 _toolBarFont->setStyleHint(QFont::SansSerif);
351 348
352 OConfig *c = OGlobal::config(); 349 OConfig *c = OGlobal::config();
353 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 350 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
354 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); 351 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont);
355 352
356 return *_toolBarFont; 353 return *_toolBarFont;
357} 354}
358 355
359QFont OGlobalSettings::menuFont() 356QFont OGlobalSettings::menuFont()
360{ 357{
361 if(_menuFont) 358 if(_menuFont)
362 return *_menuFont; 359 return *_menuFont;
363 360
364 _menuFont = new QFont("helvetica", 12); 361 _menuFont = new QFont("helvetica", 12);
365 _menuFont->setPixelSize(12); 362 _menuFont->setPixelSize(12);
366 _menuFont->setStyleHint(QFont::SansSerif); 363 _menuFont->setStyleHint(QFont::SansSerif);
367 364
368 OConfig *c = OGlobal::config(); 365 OConfig *c = OGlobal::config();
369 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 366 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
370 *_menuFont = c->readFontEntry("menuFont", _menuFont); 367 *_menuFont = c->readFontEntry("menuFont", _menuFont);
371 368
372 return *_menuFont; 369 return *_menuFont;
373} 370}
374 371
375QFont OGlobalSettings::windowTitleFont() 372QFont OGlobalSettings::windowTitleFont()
376{ 373{
377 if(_windowTitleFont) 374 if(_windowTitleFont)
378 return *_windowTitleFont; 375 return *_windowTitleFont;
379 376
380 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); 377 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold);
381 _windowTitleFont->setPixelSize(12); 378 _windowTitleFont->setPixelSize(12);
382 _windowTitleFont->setStyleHint(QFont::SansSerif); 379 _windowTitleFont->setStyleHint(QFont::SansSerif);
383 380
384 OConfig *c = OGlobal::config(); 381 OConfig *c = OGlobal::config();
385 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 382 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
386 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency 383 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency
387 384
388 return *_windowTitleFont; 385 return *_windowTitleFont;
389} 386}
390 387
391QFont OGlobalSettings::taskbarFont() 388QFont OGlobalSettings::taskbarFont()
392{ 389{
393 if(_taskbarFont) 390 if(_taskbarFont)
394 return *_taskbarFont; 391 return *_taskbarFont;
395 392
396 _taskbarFont = new QFont("helvetica", 8); 393 _taskbarFont = new QFont("helvetica", 8);
397 _taskbarFont->setPixelSize(8); 394 _taskbarFont->setPixelSize(8);
398 _taskbarFont->setStyleHint(QFont::SansSerif); 395 _taskbarFont->setStyleHint(QFont::SansSerif);
399 396
400 OConfig *c = OGlobal::config(); 397 OConfig *c = OGlobal::config();
401 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 398 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
402 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); 399 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont);
403 400
404 return *_taskbarFont; 401 return *_taskbarFont;
405} 402}
406 403
407// FIXME: the whole path stuff has to be revised for OPIE 404// FIXME: the whole path stuff has to be revised for OPIE
408 405
409void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. 406void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
410{ 407{
411 if ( s_desktopPath != 0 ) 408 if ( s_desktopPath != 0 )
412 return; 409 return;
413 410
414 s_desktopPath = new QString(); 411 s_desktopPath = new QString();
415 s_autostartPath = new QString(); 412 s_autostartPath = new QString();
416 s_trashPath = new QString(); 413 s_trashPath = new QString();
417 s_documentPath = new QString(); 414 s_documentPath = new QString();
418 415
419 OConfig *config = OGlobal::config(); 416 OConfig *config = OGlobal::config();
420 //bool dollarExpansion = config->isDollarExpansion(); 417 //bool dollarExpansion = config->isDollarExpansion();
421 //config->setDollarExpansion(true); 418 //config->setDollarExpansion(true);
422 OConfigGroupSaver cgs( config, "Paths" ); 419 OConfigGroupSaver cgs( config, "Paths" );
423 420
424 // Desktop Path 421 // Desktop Path
425 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; 422 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/";
426 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); 423 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath);
427 if ( (*s_desktopPath)[0] != '/' ) 424 if ( (*s_desktopPath)[0] != '/' )
428 s_desktopPath->prepend( QDir::homeDirPath() + "/" ); 425 s_desktopPath->prepend( QDir::homeDirPath() + "/" );
diff --git a/libopie2/opiecore/oprocctrl.cpp b/libopie2/opiecore/oprocctrl.cpp
index b3d57c8..0403526 100644
--- a/libopie2/opiecore/oprocctrl.cpp
+++ b/libopie2/opiecore/oprocctrl.cpp
@@ -1,284 +1,283 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESSCONTROLLER -- A helper class for KProcess 20// KPROCESSCONTROLLER -- A helper class for KProcess
21// 21//
22// version 0.3.1, Jan, 8th 1997 22// version 0.3.1, Jan, 8th 1997
23// 23//
24// (C) Christian Czezatke 24// (C) Christian Czezatke
25// e9025461@student.tuwien.ac.at 25// e9025461@student.tuwien.ac.at
26// Ported by Holger Freyther 26// Ported by Holger Freyther
27// 27//
28 28
29//#include <config.h> 29//#include <config.h>
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/socket.h> 32#include <sys/socket.h>
33 33
34#include <errno.h> 34#include <errno.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <stdio.h> 36#include <stdio.h>
37#include <string.h> 37#include <string.h>
38#include <unistd.h> 38#include <unistd.h>
39#include <assert.h> 39#include <assert.h>
40 40
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include "oprocess.h"
43#include "oprocctrl.h" 42#include "oprocctrl.h"
44 43
45OProcessController *OProcessController::theOProcessController = 0; 44OProcessController *OProcessController::theOProcessController = 0;
46 45
47struct sigaction OProcessController::oldChildHandlerData; 46struct sigaction OProcessController::oldChildHandlerData;
48bool OProcessController::handlerSet = false; 47bool OProcessController::handlerSet = false;
49 48
50OProcessController::OProcessController() 49OProcessController::OProcessController()
51{ 50{
52 assert( theOProcessController == 0 ); 51 assert( theOProcessController == 0 );
53 52
54 if (0 > pipe(fd)) 53 if (0 > pipe(fd))
55 printf(strerror(errno)); 54 printf(strerror(errno));
56 55
57 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); 56 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read);
58 notifier->setEnabled(true); 57 notifier->setEnabled(true);
59 QObject::connect(notifier, SIGNAL(activated(int)), 58 QObject::connect(notifier, SIGNAL(activated(int)),
60 this, SLOT(slotDoHousekeeping(int))); 59 this, SLOT(slotDoHousekeeping(int)));
61 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), 60 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()),
62 SLOT( delayedChildrenCleanup())); 61 SLOT( delayedChildrenCleanup()));
63 62
64 theOProcessController = this; 63 theOProcessController = this;
65 64
66 setupHandlers(); 65 setupHandlers();
67} 66}
68 67
69 68
70void OProcessController::setupHandlers() 69void OProcessController::setupHandlers()
71{ 70{
72 if( handlerSet ) 71 if( handlerSet )
73 return; 72 return;
74 struct sigaction act; 73 struct sigaction act;
75 act.sa_handler=theSigCHLDHandler; 74 act.sa_handler=theSigCHLDHandler;
76 sigemptyset(&(act.sa_mask)); 75 sigemptyset(&(act.sa_mask));
77 sigaddset(&(act.sa_mask), SIGCHLD); 76 sigaddset(&(act.sa_mask), SIGCHLD);
78 // Make sure we don't block this signal. gdb tends to do that :-( 77 // Make sure we don't block this signal. gdb tends to do that :-(
79 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); 78 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0);
80 79
81 act.sa_flags = SA_NOCLDSTOP; 80 act.sa_flags = SA_NOCLDSTOP;
82 81
83 // CC: take care of SunOS which automatically restarts interrupted system 82 // CC: take care of SunOS which automatically restarts interrupted system
84 // calls (and thus does not have SA_RESTART) 83 // calls (and thus does not have SA_RESTART)
85 84
86#ifdef SA_RESTART 85#ifdef SA_RESTART
87 act.sa_flags |= SA_RESTART; 86 act.sa_flags |= SA_RESTART;
88#endif 87#endif
89 88
90 sigaction( SIGCHLD, &act, &oldChildHandlerData ); 89 sigaction( SIGCHLD, &act, &oldChildHandlerData );
91 90
92 act.sa_handler=SIG_IGN; 91 act.sa_handler=SIG_IGN;
93 sigemptyset(&(act.sa_mask)); 92 sigemptyset(&(act.sa_mask));
94 sigaddset(&(act.sa_mask), SIGPIPE); 93 sigaddset(&(act.sa_mask), SIGPIPE);
95 act.sa_flags = 0; 94 act.sa_flags = 0;
96 sigaction( SIGPIPE, &act, 0L); 95 sigaction( SIGPIPE, &act, 0L);
97 handlerSet = true; 96 handlerSet = true;
98} 97}
99 98
100void OProcessController::resetHandlers() 99void OProcessController::resetHandlers()
101{ 100{
102 if( !handlerSet ) 101 if( !handlerSet )
103 return; 102 return;
104 sigaction( SIGCHLD, &oldChildHandlerData, 0 ); 103 sigaction( SIGCHLD, &oldChildHandlerData, 0 );
105 // there should be no problem with SIGPIPE staying SIG_IGN 104 // there should be no problem with SIGPIPE staying SIG_IGN
106 handlerSet = false; 105 handlerSet = false;
107} 106}
108 107
109// block SIGCHLD handler, because it accesses processList 108// block SIGCHLD handler, because it accesses processList
110void OProcessController::addOProcess( OProcess* p ) 109void OProcessController::addOProcess( OProcess* p )
111{ 110{
112 sigset_t newset, oldset; 111 sigset_t newset, oldset;
113 sigemptyset( &newset ); 112 sigemptyset( &newset );
114 sigaddset( &newset, SIGCHLD ); 113 sigaddset( &newset, SIGCHLD );
115 sigprocmask( SIG_BLOCK, &newset, &oldset ); 114 sigprocmask( SIG_BLOCK, &newset, &oldset );
116 processList.append( p ); 115 processList.append( p );
117 sigprocmask( SIG_SETMASK, &oldset, 0 ); 116 sigprocmask( SIG_SETMASK, &oldset, 0 );
118} 117}
119 118
120void OProcessController::removeOProcess( OProcess* p ) 119void OProcessController::removeOProcess( OProcess* p )
121{ 120{
122 sigset_t newset, oldset; 121 sigset_t newset, oldset;
123 sigemptyset( &newset ); 122 sigemptyset( &newset );
124 sigaddset( &newset, SIGCHLD ); 123 sigaddset( &newset, SIGCHLD );
125 sigprocmask( SIG_BLOCK, &newset, &oldset ); 124 sigprocmask( SIG_BLOCK, &newset, &oldset );
126 processList.remove( p ); 125 processList.remove( p );
127 sigprocmask( SIG_SETMASK, &oldset, 0 ); 126 sigprocmask( SIG_SETMASK, &oldset, 0 );
128} 127}
129 128
130//using a struct which contains both the pid and the status makes it easier to write 129//using a struct which contains both the pid and the status makes it easier to write
131//and read the data into the pipe 130//and read the data into the pipe
132//especially this solves a problem which appeared on my box where slotDoHouseKeeping() received 131//especially this solves a problem which appeared on my box where slotDoHouseKeeping() received
133//only 4 bytes (with some debug output around the write()'s it received all 8 bytes) 132//only 4 bytes (with some debug output around the write()'s it received all 8 bytes)
134//don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX 133//don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX
135struct waitdata 134struct waitdata
136{ 135{
137 pid_t pid; 136 pid_t pid;
138 int status; 137 int status;
139}; 138};
140 139
141void OProcessController::theSigCHLDHandler(int arg) 140void OProcessController::theSigCHLDHandler(int arg)
142{ 141{
143 struct waitdata wd; 142 struct waitdata wd;
144 // int status; 143 // int status;
145 // pid_t this_pid; 144 // pid_t this_pid;
146 int saved_errno; 145 int saved_errno;
147 146
148 saved_errno = errno; 147 saved_errno = errno;
149 // since waitpid and write change errno, we have to save it and restore it 148 // since waitpid and write change errno, we have to save it and restore it
150 // (Richard Stevens, Advanced programming in the Unix Environment) 149 // (Richard Stevens, Advanced programming in the Unix Environment)
151 150
152 bool found = false; 151 bool found = false;
153 if( theOProcessController != 0 ) 152 if( theOProcessController != 0 )
154 { 153 {
155 // iterating the list doesn't perform any system call 154 // iterating the list doesn't perform any system call
156 for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin(); 155 for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin();
157 it != theOProcessController->processList.end(); 156 it != theOProcessController->processList.end();
158 ++it ) 157 ++it )
159 { 158 {
160 if( !(*it)->isRunning()) 159 if( !(*it)->isRunning())
161 continue; 160 continue;
162 wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG ); 161 wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG );
163 if ( wd.pid > 0 ) 162 if ( wd.pid > 0 )
164 { 163 {
165 ::write(theOProcessController->fd[1], &wd, sizeof(wd)); 164 ::write(theOProcessController->fd[1], &wd, sizeof(wd));
166 found = true; 165 found = true;
167 } 166 }
168 } 167 }
169 } 168 }
170 if( !found && oldChildHandlerData.sa_handler != SIG_IGN 169 if( !found && oldChildHandlerData.sa_handler != SIG_IGN
171 && oldChildHandlerData.sa_handler != SIG_DFL ) 170 && oldChildHandlerData.sa_handler != SIG_DFL )
172 oldChildHandlerData.sa_handler( arg ); // call the old handler 171 oldChildHandlerData.sa_handler( arg ); // call the old handler
173 // handle the rest 172 // handle the rest
174 if( theOProcessController != 0 ) 173 if( theOProcessController != 0 )
175 { 174 {
176 static const struct waitdata dwd = { 0, 0 } 175 static const struct waitdata dwd = { 0, 0 }
177 ; // delayed waitpid() 176 ; // delayed waitpid()
178 ::write(theOProcessController->fd[1], &dwd, sizeof(dwd)); 177 ::write(theOProcessController->fd[1], &dwd, sizeof(dwd));
179 } 178 }
180 else 179 else
181 { 180 {
182 int dummy; 181 int dummy;
183 while( waitpid( -1, &dummy, WNOHANG ) > 0 ) 182 while( waitpid( -1, &dummy, WNOHANG ) > 0 )
184 ; 183 ;
185 } 184 }
186 185
187 errno = saved_errno; 186 errno = saved_errno;
188} 187}
189 188
190 189
191 190
192void OProcessController::slotDoHousekeeping(int ) 191void OProcessController::slotDoHousekeeping(int )
193{ 192{
194 unsigned int bytes_read = 0; 193 unsigned int bytes_read = 0;
195 unsigned int errcnt=0; 194 unsigned int errcnt=0;
196 // read pid and status from the pipe. 195 // read pid and status from the pipe.
197 struct waitdata wd; 196 struct waitdata wd;
198 while ((bytes_read < sizeof(wd)) && (errcnt < 50)) 197 while ((bytes_read < sizeof(wd)) && (errcnt < 50))
199 { 198 {
200 int r = ::read(fd[0], ((char *)&wd) + bytes_read, sizeof(wd) - bytes_read); 199 int r = ::read(fd[0], ((char *)&wd) + bytes_read, sizeof(wd) - bytes_read);
201 if (r > 0) bytes_read += r; 200 if (r > 0) bytes_read += r;
202 else if (r < 0) errcnt++; 201 else if (r < 0) errcnt++;
203 } 202 }
204 if (errcnt >= 50) 203 if (errcnt >= 50)
205 { 204 {
206 fprintf(stderr, 205 fprintf(stderr,
207 "Error: Max. error count for pipe read " 206 "Error: Max. error count for pipe read "
208 "exceeded in OProcessController::slotDoHousekeeping\n"); 207 "exceeded in OProcessController::slotDoHousekeeping\n");
209 return; // it makes no sense to continue here! 208 return; // it makes no sense to continue here!
210 } 209 }
211 if (bytes_read != sizeof(wd)) 210 if (bytes_read != sizeof(wd))
212 { 211 {
213 fprintf(stderr, 212 fprintf(stderr,
214 "Error: Could not read info from signal handler %d <> %d!\n", 213 "Error: Could not read info from signal handler %d <> %d!\n",
215 bytes_read, sizeof(wd)); 214 bytes_read, sizeof(wd));
216 return; // it makes no sense to continue here! 215 return; // it makes no sense to continue here!
217 } 216 }
218 if (wd.pid==0) 217 if (wd.pid==0)
219 { // special case, see delayedChildrenCleanup() 218 { // special case, see delayedChildrenCleanup()
220 delayedChildrenCleanupTimer.start( 1000, true ); 219 delayedChildrenCleanupTimer.start( 1000, true );
221 return; 220 return;
222 } 221 }
223 222
224 for( QValueList<OProcess*>::ConstIterator it = processList.begin(); 223 for( QValueList<OProcess*>::ConstIterator it = processList.begin();
225 it != processList.end(); 224 it != processList.end();
226 ++it ) 225 ++it )
227 { 226 {
228 OProcess* proc = *it; 227 OProcess* proc = *it;
229 if (proc->pid() == wd.pid) 228 if (proc->pid() == wd.pid)
230 { 229 {
231 // process has exited, so do emit the respective events 230 // process has exited, so do emit the respective events
232 if (proc->run_mode == OProcess::Block) 231 if (proc->run_mode == OProcess::Block)
233 { 232 {
234 // If the reads are done blocking then set the status in proc 233 // If the reads are done blocking then set the status in proc
235 // but do nothing else because OProcess will perform the other 234 // but do nothing else because OProcess will perform the other
236 // actions of processHasExited. 235 // actions of processHasExited.
237 proc->status = wd.status; 236 proc->status = wd.status;
238 proc->runs = false; 237 proc->runs = false;
239 } 238 }
240 else 239 else
241 { 240 {
242 proc->processHasExited(wd.status); 241 proc->processHasExited(wd.status);
243 } 242 }
244 return; 243 return;
245 } 244 }
246 } 245 }
247} 246}
248 247
249// this is needed e.g. for popen(), which calls waitpid() checking 248// this is needed e.g. for popen(), which calls waitpid() checking
250// for its forked child, if we did waitpid() directly in the SIGCHLD 249// for its forked child, if we did waitpid() directly in the SIGCHLD
251// handler, popen()'s waitpid() call would fail 250// handler, popen()'s waitpid() call would fail
252void OProcessController::delayedChildrenCleanup() 251void OProcessController::delayedChildrenCleanup()
253{ 252{
254 struct waitdata wd; 253 struct waitdata wd;
255 while(( wd.pid = waitpid( -1, &wd.status, WNOHANG ) ) > 0 ) 254 while(( wd.pid = waitpid( -1, &wd.status, WNOHANG ) ) > 0 )
256 { 255 {
257 for( QValueList<OProcess*>::ConstIterator it = processList.begin(); 256 for( QValueList<OProcess*>::ConstIterator it = processList.begin();
258 it != processList.end(); 257 it != processList.end();
259 ++it ) 258 ++it )
260 { 259 {
261 if( !(*it)->isRunning() || (*it)->pid() != wd.pid ) 260 if( !(*it)->isRunning() || (*it)->pid() != wd.pid )
262 continue; 261 continue;
263 // it's OProcess, handle it 262 // it's OProcess, handle it
264 ::write(fd[1], &wd, sizeof(wd)); 263 ::write(fd[1], &wd, sizeof(wd));
265 break; 264 break;
266 } 265 }
267 } 266 }
268} 267}
269 268
270OProcessController::~OProcessController() 269OProcessController::~OProcessController()
271{ 270{
272 assert( theOProcessController == this ); 271 assert( theOProcessController == this );
273 resetHandlers(); 272 resetHandlers();
274 273
275 notifier->setEnabled(false); 274 notifier->setEnabled(false);
276 275
277 close(fd[0]); 276 close(fd[0]);
278 close(fd[1]); 277 close(fd[1]);
279 278
280 delete notifier; 279 delete notifier;
281 theOProcessController = 0; 280 theOProcessController = 0;
282} 281}
283 282
284//#include "kprocctrl.moc" 283//#include "kprocctrl.moc"
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index 83677aa..0a361a1 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -1,426 +1,424 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org>
4 and The Opie Team <opie-devel@handhelds.org> 4 and 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#include "oprocctrl.h" 31#include "oprocctrl.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oprocess.h> 34#include <opie2/oprocess.h>
35 35
36/* QT */ 36/* QT */
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h>
41#include <qmap.h> 40#include <qmap.h>
42#include <qregexp.h>
43#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
44#include <qtextstream.h> 42#include <qtextstream.h>
45 43
46/* STD */ 44/* STD */
47#include <errno.h> 45#include <errno.h>
48#include <fcntl.h> 46#include <fcntl.h>
49#include <pwd.h> 47#include <pwd.h>
50#include <stdlib.h> 48#include <stdlib.h>
51#include <signal.h> 49#include <signal.h>
52#include <stdio.h> 50#include <stdio.h>
53#include <string.h> 51#include <string.h>
54#include <sys/time.h> 52#include <sys/time.h>
55#include <sys/types.h> 53#include <sys/types.h>
56#include <sys/stat.h> 54#include <sys/stat.h>
57#include <sys/socket.h> 55#include <sys/socket.h>
58#include <unistd.h> 56#include <unistd.h>
59#ifdef HAVE_SYS_SELECT_H 57#ifdef HAVE_SYS_SELECT_H
60#include <sys/select.h> 58#include <sys/select.h>
61#endif 59#endif
62#ifdef HAVE_INITGROUPS 60#ifdef HAVE_INITGROUPS
63#include <grp.h> 61#include <grp.h>
64#endif 62#endif
65 63
66class OProcessPrivate 64class OProcessPrivate
67{ 65{
68public: 66public:
69 OProcessPrivate() : useShell( false ) 67 OProcessPrivate() : useShell( false )
70 { } 68 { }
71 69
72 bool useShell; 70 bool useShell;
73 QMap<QString, QString> env; 71 QMap<QString, QString> env;
74 QString wd; 72 QString wd;
75 QCString shell; 73 QCString shell;
76}; 74};
77 75
78 76
79OProcess::OProcess( QObject *parent, const char *name ) 77OProcess::OProcess( QObject *parent, const char *name )
80 : QObject( parent, name ) 78 : QObject( parent, name )
81{ 79{
82 init ( ); 80 init ( );
83} 81}
84 82
85OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 83OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
86 : QObject( parent, name ) 84 : QObject( parent, name )
87{ 85{
88 init ( ); 86 init ( );
89 *this << arg0; 87 *this << arg0;
90} 88}
91 89
92OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 90OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
93 : QObject( parent, name ) 91 : QObject( parent, name )
94{ 92{
95 init ( ); 93 init ( );
96 *this << args; 94 *this << args;
97} 95}
98 96
99void OProcess::init ( ) 97void OProcess::init ( )
100{ 98{
101 run_mode = NotifyOnExit; 99 run_mode = NotifyOnExit;
102 runs = false; 100 runs = false;
103 pid_ = 0; 101 pid_ = 0;
104 status = 0; 102 status = 0;
105 keepPrivs = false; 103 keepPrivs = false;
106 innot = 0; 104 innot = 0;
107 outnot = 0; 105 outnot = 0;
108 errnot = 0; 106 errnot = 0;
109 communication = NoCommunication; 107 communication = NoCommunication;
110 input_data = 0; 108 input_data = 0;
111 input_sent = 0; 109 input_sent = 0;
112 input_total = 0; 110 input_total = 0;
113 d = 0; 111 d = 0;
114 112
115 if ( 0 == OProcessController::theOProcessController ) 113 if ( 0 == OProcessController::theOProcessController )
116 { 114 {
117 ( void ) new OProcessController(); 115 ( void ) new OProcessController();
118 CHECK_PTR( OProcessController::theOProcessController ); 116 CHECK_PTR( OProcessController::theOProcessController );
119 } 117 }
120 118
121 OProcessController::theOProcessController->addOProcess( this ); 119 OProcessController::theOProcessController->addOProcess( this );
122 out[ 0 ] = out[ 1 ] = -1; 120 out[ 0 ] = out[ 1 ] = -1;
123 in[ 0 ] = in[ 1 ] = -1; 121 in[ 0 ] = in[ 1 ] = -1;
124 err[ 0 ] = err[ 1 ] = -1; 122 err[ 0 ] = err[ 1 ] = -1;
125} 123}
126 124
127void OProcess::setEnvironment( const QString &name, const QString &value ) 125void OProcess::setEnvironment( const QString &name, const QString &value )
128{ 126{
129 if ( !d ) 127 if ( !d )
130 d = new OProcessPrivate; 128 d = new OProcessPrivate;
131 d->env.insert( name, value ); 129 d->env.insert( name, value );
132} 130}
133 131
134void OProcess::setWorkingDirectory( const QString &dir ) 132void OProcess::setWorkingDirectory( const QString &dir )
135{ 133{
136 if ( !d ) 134 if ( !d )
137 d = new OProcessPrivate; 135 d = new OProcessPrivate;
138 d->wd = dir; 136 d->wd = dir;
139} 137}
140 138
141void OProcess::setupEnvironment() 139void OProcess::setupEnvironment()
142{ 140{
143 if ( d ) 141 if ( d )
144 { 142 {
145 QMap<QString, QString>::Iterator it; 143 QMap<QString, QString>::Iterator it;
146 for ( it = d->env.begin(); it != d->env.end(); ++it ) 144 for ( it = d->env.begin(); it != d->env.end(); ++it )
147 setenv( QFile::encodeName( it.key() ).data(), 145 setenv( QFile::encodeName( it.key() ).data(),
148 QFile::encodeName( it.data() ).data(), 1 ); 146 QFile::encodeName( it.data() ).data(), 1 );
149 if ( !d->wd.isEmpty() ) 147 if ( !d->wd.isEmpty() )
150 chdir( QFile::encodeName( d->wd ).data() ); 148 chdir( QFile::encodeName( d->wd ).data() );
151 } 149 }
152} 150}
153 151
154void OProcess::setRunPrivileged( bool keepPrivileges ) 152void OProcess::setRunPrivileged( bool keepPrivileges )
155{ 153{
156 keepPrivs = keepPrivileges; 154 keepPrivs = keepPrivileges;
157} 155}
158 156
159bool OProcess::runPrivileged() const 157bool OProcess::runPrivileged() const
160{ 158{
161 return keepPrivs; 159 return keepPrivs;
162} 160}
163 161
164OProcess::~OProcess() 162OProcess::~OProcess()
165{ 163{
166 // destroying the OProcess instance sends a SIGKILL to the 164 // destroying the OProcess instance sends a SIGKILL to the
167 // child process (if it is running) after removing it from the 165 // child process (if it is running) after removing it from the
168 // list of valid processes (if the process is not started as 166 // list of valid processes (if the process is not started as
169 // "DontCare") 167 // "DontCare")
170 168
171 OProcessController::theOProcessController->removeOProcess( this ); 169 OProcessController::theOProcessController->removeOProcess( this );
172 // this must happen before we kill the child 170 // this must happen before we kill the child
173 // TODO: block the signal while removing the current process from the process list 171 // TODO: block the signal while removing the current process from the process list
174 172
175 if ( runs && ( run_mode != DontCare ) ) 173 if ( runs && ( run_mode != DontCare ) )
176 kill( SIGKILL ); 174 kill( SIGKILL );
177 175
178 // Clean up open fd's and socket notifiers. 176 // Clean up open fd's and socket notifiers.
179 closeStdin(); 177 closeStdin();
180 closeStdout(); 178 closeStdout();
181 closeStderr(); 179 closeStderr();
182 180
183 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess 181 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess
184 delete d; 182 delete d;
185} 183}
186 184
187void OProcess::detach() 185void OProcess::detach()
188{ 186{
189 OProcessController::theOProcessController->removeOProcess( this ); 187 OProcessController::theOProcessController->removeOProcess( this );
190 188
191 runs = false; 189 runs = false;
192 pid_ = 0; 190 pid_ = 0;
193 191
194 // Clean up open fd's and socket notifiers. 192 // Clean up open fd's and socket notifiers.
195 closeStdin(); 193 closeStdin();
196 closeStdout(); 194 closeStdout();
197 closeStderr(); 195 closeStderr();
198} 196}
199 197
200bool OProcess::setExecutable( const QString& proc ) 198bool OProcess::setExecutable( const QString& proc )
201{ 199{
202 if ( runs ) 200 if ( runs )
203 return false; 201 return false;
204 202
205 if ( proc.isEmpty() ) 203 if ( proc.isEmpty() )
206 return false; 204 return false;
207 205
208 if ( !arguments.isEmpty() ) 206 if ( !arguments.isEmpty() )
209 arguments.remove( arguments.begin() ); 207 arguments.remove( arguments.begin() );
210 arguments.prepend( QFile::encodeName( proc ) ); 208 arguments.prepend( QFile::encodeName( proc ) );
211 209
212 return true; 210 return true;
213} 211}
214 212
215OProcess &OProcess::operator<<( const QStringList& args ) 213OProcess &OProcess::operator<<( const QStringList& args )
216{ 214{
217 QStringList::ConstIterator it = args.begin(); 215 QStringList::ConstIterator it = args.begin();
218 for ( ; it != args.end() ; ++it ) 216 for ( ; it != args.end() ; ++it )
219 arguments.append( QFile::encodeName( *it ) ); 217 arguments.append( QFile::encodeName( *it ) );
220 return *this; 218 return *this;
221} 219}
222 220
223OProcess &OProcess::operator<<( const QCString& arg ) 221OProcess &OProcess::operator<<( const QCString& arg )
224{ 222{
225 return operator<< ( arg.data() ); 223 return operator<< ( arg.data() );
226} 224}
227 225
228OProcess &OProcess::operator<<( const char* arg ) 226OProcess &OProcess::operator<<( const char* arg )
229{ 227{
230 arguments.append( arg ); 228 arguments.append( arg );
231 return *this; 229 return *this;
232} 230}
233 231
234OProcess &OProcess::operator<<( const QString& arg ) 232OProcess &OProcess::operator<<( const QString& arg )
235{ 233{
236 arguments.append( QFile::encodeName( arg ) ); 234 arguments.append( QFile::encodeName( arg ) );
237 return *this; 235 return *this;
238} 236}
239 237
240void OProcess::clearArguments() 238void OProcess::clearArguments()
241{ 239{
242 arguments.clear(); 240 arguments.clear();
243} 241}
244 242
245bool OProcess::start( RunMode runmode, Communication comm ) 243bool OProcess::start( RunMode runmode, Communication comm )
246{ 244{
247 uint i; 245 uint i;
248 uint n = arguments.count(); 246 uint n = arguments.count();
249 char **arglist; 247 char **arglist;
250 248
251 if ( runs || ( 0 == n ) ) 249 if ( runs || ( 0 == n ) )
252 { 250 {
253 return false; // cannot start a process that is already running 251 return false; // cannot start a process that is already running
254 // or if no executable has been assigned 252 // or if no executable has been assigned
255 } 253 }
256 run_mode = runmode; 254 run_mode = runmode;
257 status = 0; 255 status = 0;
258 256
259 QCString shellCmd; 257 QCString shellCmd;
260 if ( d && d->useShell ) 258 if ( d && d->useShell )
261 { 259 {
262 if ( d->shell.isEmpty() ) 260 if ( d->shell.isEmpty() )
263 { 261 {
264 qWarning( "Could not find a valid shell" ); 262 qWarning( "Could not find a valid shell" );
265 return false; 263 return false;
266 } 264 }
267 265
268 arglist = static_cast<char **>( malloc( ( 4 ) * sizeof( char * ) ) ); 266 arglist = static_cast<char **>( malloc( ( 4 ) * sizeof( char * ) ) );
269 for ( i = 0; i < n; i++ ) 267 for ( i = 0; i < n; i++ )
270 { 268 {
271 shellCmd += arguments[ i ]; 269 shellCmd += arguments[ i ];
272 shellCmd += " "; // CC: to separate the arguments 270 shellCmd += " "; // CC: to separate the arguments
273 } 271 }
274 272
275 arglist[ 0 ] = d->shell.data(); 273 arglist[ 0 ] = d->shell.data();
276 arglist[ 1 ] = ( char * ) "-c"; 274 arglist[ 1 ] = ( char * ) "-c";
277 arglist[ 2 ] = shellCmd.data(); 275 arglist[ 2 ] = shellCmd.data();
278 arglist[ 3 ] = 0; 276 arglist[ 3 ] = 0;
279 } 277 }
280 else 278 else
281 { 279 {
282 arglist = static_cast<char **>( malloc( ( n + 1 ) * sizeof( char * ) ) ); 280 arglist = static_cast<char **>( malloc( ( n + 1 ) * sizeof( char * ) ) );
283 for ( i = 0; i < n; i++ ) 281 for ( i = 0; i < n; i++ )
284 arglist[ i ] = arguments[ i ].data(); 282 arglist[ i ] = arguments[ i ].data();
285 arglist[ n ] = 0; 283 arglist[ n ] = 0;
286 } 284 }
287 285
288 if ( !setupCommunication( comm ) ) 286 if ( !setupCommunication( comm ) )
289 qWarning( "Could not setup Communication!" ); 287 qWarning( "Could not setup Communication!" );
290 288
291 // We do this in the parent because if we do it in the child process 289 // We do this in the parent because if we do it in the child process
292 // gdb gets confused when the application runs from gdb. 290 // gdb gets confused when the application runs from gdb.
293 uid_t uid = getuid(); 291 uid_t uid = getuid();
294 gid_t gid = getgid(); 292 gid_t gid = getgid();
295#ifdef HAVE_INITGROUPS 293#ifdef HAVE_INITGROUPS
296 294
297 struct passwd *pw = getpwuid( uid ); 295 struct passwd *pw = getpwuid( uid );
298#endif 296#endif
299 297
300 int fd[ 2 ]; 298 int fd[ 2 ];
301 if ( 0 > pipe( fd ) ) 299 if ( 0 > pipe( fd ) )
302 { 300 {
303 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue 301 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue
304 } 302 }
305 303
306 runs = true; 304 runs = true;
307 305
308 QApplication::flushX(); 306 QApplication::flushX();
309 307
310 // WABA: Note that we use fork() and not vfork() because 308 // WABA: Note that we use fork() and not vfork() because
311 // vfork() has unclear semantics and is not standardized. 309 // vfork() has unclear semantics and is not standardized.
312 pid_ = fork(); 310 pid_ = fork();
313 311
314 if ( 0 == pid_ ) 312 if ( 0 == pid_ )
315 { 313 {
316 if ( fd[ 0 ] ) 314 if ( fd[ 0 ] )
317 close( fd[ 0 ] ); 315 close( fd[ 0 ] );
318 if ( !runPrivileged() ) 316 if ( !runPrivileged() )
319 { 317 {
320 setgid( gid ); 318 setgid( gid );
321#if defined( HAVE_INITGROUPS) 319#if defined( HAVE_INITGROUPS)
322 320
323 if ( pw ) 321 if ( pw )
324 initgroups( pw->pw_name, pw->pw_gid ); 322 initgroups( pw->pw_name, pw->pw_gid );
325#endif 323#endif
326 324
327 setuid( uid ); 325 setuid( uid );
328 } 326 }
329 // The child process 327 // The child process
330 if ( !commSetupDoneC() ) 328 if ( !commSetupDoneC() )
331 qWarning( "Could not finish comm setup in child!" ); 329 qWarning( "Could not finish comm setup in child!" );
332 330
333 setupEnvironment(); 331 setupEnvironment();
334 332
335 // Matthias 333 // Matthias
336 if ( run_mode == DontCare ) 334 if ( run_mode == DontCare )
337 setpgid( 0, 0 ); 335 setpgid( 0, 0 );
338 // restore default SIGPIPE handler (Harri) 336 // restore default SIGPIPE handler (Harri)
339 struct sigaction act; 337 struct sigaction act;
340 sigemptyset( &( act.sa_mask ) ); 338 sigemptyset( &( act.sa_mask ) );
341 sigaddset( &( act.sa_mask ), SIGPIPE ); 339 sigaddset( &( act.sa_mask ), SIGPIPE );
342 act.sa_handler = SIG_DFL; 340 act.sa_handler = SIG_DFL;
343 act.sa_flags = 0; 341 act.sa_flags = 0;
344 sigaction( SIGPIPE, &act, 0L ); 342 sigaction( SIGPIPE, &act, 0L );
345 343
346 // We set the close on exec flag. 344 // We set the close on exec flag.
347 // Closing of fd[1] indicates that the execvp succeeded! 345 // Closing of fd[1] indicates that the execvp succeeded!
348 if ( fd[ 1 ] ) 346 if ( fd[ 1 ] )
349 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC ); 347 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC );
350 execvp( arglist[ 0 ], arglist ); 348 execvp( arglist[ 0 ], arglist );
351 char resultByte = 1; 349 char resultByte = 1;
352 if ( fd[ 1 ] ) 350 if ( fd[ 1 ] )
353 write( fd[ 1 ], &resultByte, 1 ); 351 write( fd[ 1 ], &resultByte, 1 );
354 _exit( -1 ); 352 _exit( -1 );
355 } 353 }
356 else if ( -1 == pid_ ) 354 else if ( -1 == pid_ )
357 { 355 {
358 // forking failed 356 // forking failed
359 357
360 runs = false; 358 runs = false;
361 free( arglist ); 359 free( arglist );
362 return false; 360 return false;
363 } 361 }
364 else 362 else
365 { 363 {
366 if ( fd[ 1 ] ) 364 if ( fd[ 1 ] )
367 close( fd[ 1 ] ); 365 close( fd[ 1 ] );
368 // the parent continues here 366 // the parent continues here
369 367
370 // Discard any data for stdin that might still be there 368 // Discard any data for stdin that might still be there
371 input_data = 0; 369 input_data = 0;
372 370
373 // Check whether client could be started. 371 // Check whether client could be started.
374 if ( fd[ 0 ] ) 372 if ( fd[ 0 ] )
375 for ( ;; ) 373 for ( ;; )
376 { 374 {
377 char resultByte; 375 char resultByte;
378 int n = ::read( fd[ 0 ], &resultByte, 1 ); 376 int n = ::read( fd[ 0 ], &resultByte, 1 );
379 if ( n == 1 ) 377 if ( n == 1 )
380 { 378 {
381 // Error 379 // Error
382 runs = false; 380 runs = false;
383 close( fd[ 0 ] ); 381 close( fd[ 0 ] );
384 free( arglist ); 382 free( arglist );
385 pid_ = 0; 383 pid_ = 0;
386 return false; 384 return false;
387 } 385 }
388 if ( n == -1 ) 386 if ( n == -1 )
389 { 387 {
390 if ( ( errno == ECHILD ) || ( errno == EINTR ) ) 388 if ( ( errno == ECHILD ) || ( errno == EINTR ) )
391 continue; // Ignore 389 continue; // Ignore
392 } 390 }
393 break; // success 391 break; // success
394 } 392 }
395 if ( fd[ 0 ] ) 393 if ( fd[ 0 ] )
396 close( fd[ 0 ] ); 394 close( fd[ 0 ] );
397 395
398 if ( !commSetupDoneP() ) // finish communication socket setup for the parent 396 if ( !commSetupDoneP() ) // finish communication socket setup for the parent
399 qWarning( "Could not finish comm setup in parent!" ); 397 qWarning( "Could not finish comm setup in parent!" );
400 398
401 if ( run_mode == Block ) 399 if ( run_mode == Block )
402 { 400 {
403 commClose(); 401 commClose();
404 402
405 // The SIGCHLD handler of the process controller will catch 403 // The SIGCHLD handler of the process controller will catch
406 // the exit and set the status 404 // the exit and set the status
407 while ( runs ) 405 while ( runs )
408 { 406 {
409 OProcessController::theOProcessController-> 407 OProcessController::theOProcessController->
410 slotDoHousekeeping( 0 ); 408 slotDoHousekeeping( 0 );
411 } 409 }
412 runs = FALSE; 410 runs = FALSE;
413 emit processExited( this ); 411 emit processExited( this );
414 } 412 }
415 } 413 }
416 free( arglist ); 414 free( arglist );
417 return true; 415 return true;
418} 416}
419 417
420 418
421 419
422bool OProcess::kill( int signo ) 420bool OProcess::kill( int signo )
423{ 421{
424 bool rv = false; 422 bool rv = false;
425 423
426 if ( 0 != pid_ ) 424 if ( 0 != pid_ )
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp
index 0f261b9..95ed77b 100644
--- a/libopie2/opiedb/osqlbackendmanager.cpp
+++ b/libopie2/opiedb/osqlbackendmanager.cpp
@@ -1,99 +1,98 @@
1#include <qdir.h> 1#include <qdir.h>
2#include <qfile.h>
3#include <qmap.h> 2#include <qmap.h>
4 3
5#include "osqlbackendmanager.h" 4#include "osqlbackendmanager.h"
6 5
7namespace { 6namespace {
8 class Config { 7 class Config {
9 typedef QMap<QString, QString> List; 8 typedef QMap<QString, QString> List;
10 public: 9 public:
11 Config( const QString& fileName ); 10 Config( const QString& fileName );
12 /** 11 /**
13 * Quite simple layout in nature 12 * Quite simple layout in nature
14 * BeginFile 13 * BeginFile
15 * Key = Value 14 * Key = Value
16 */ 15 */
17 bool load(); 16 bool load();
18 QString value( const QString& key ); 17 QString value( const QString& key );
19 private: 18 private:
20 List m_list; 19 List m_list;
21 QString m_fileName; 20 QString m_fileName;
22 }; 21 };
23 Config::Config( const QString& fileName ) 22 Config::Config( const QString& fileName )
24 : m_fileName( fileName ) { 23 : m_fileName( fileName ) {
25 } 24 }
26 25
27 bool Config::load() { 26 bool Config::load() {
28 if (!QFile::exists( m_fileName ) ) 27 if (!QFile::exists( m_fileName ) )
29 return false; 28 return false;
30 QFile file( m_fileName ); 29 QFile file( m_fileName );
31 if (!file.open(IO_ReadOnly ) ) 30 if (!file.open(IO_ReadOnly ) )
32 return false; 31 return false;
33 QStringList list = QStringList::split( '\n', file.readAll() ); 32 QStringList list = QStringList::split( '\n', file.readAll() );
34 QStringList::Iterator it; 33 QStringList::Iterator it;
35 QString line; 34 QString line;
36 for (it = list.begin(); it != list.end(); ++it ) { 35 for (it = list.begin(); it != list.end(); ++it ) {
37 line = (*it).stripWhiteSpace(); 36 line = (*it).stripWhiteSpace();
38 qWarning("Anonymous::Config:" + line ); 37 qWarning("Anonymous::Config:" + line );
39 QStringList test = QStringList::split(' ', line ); 38 QStringList test = QStringList::split(' ', line );
40 m_list.insert( test[0], test[2] ); 39 m_list.insert( test[0], test[2] );
41 } 40 }
42 return true; 41 return true;
43 } 42 }
44 QString Config::value( const QString& key ) { 43 QString Config::value( const QString& key ) {
45 return m_list[key]; 44 return m_list[key];
46 } 45 }
47}; 46};
48OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) 47OSQLBackEndManager::OSQLBackEndManager( const QStringList& path )
49 :m_path( path ) 48 :m_path( path )
50{ 49{
51} 50}
52OSQLBackEndManager::~OSQLBackEndManager() { 51OSQLBackEndManager::~OSQLBackEndManager() {
53} 52}
54/** 53/**
55 * scan dirs 54 * scan dirs
56 */ 55 */
57OSQLBackEnd::ValueList OSQLBackEndManager::scan() { 56OSQLBackEnd::ValueList OSQLBackEndManager::scan() {
58 OSQLBackEnd::ValueList list; 57 OSQLBackEnd::ValueList list;
59 if (!m_path.isEmpty() ) { 58 if (!m_path.isEmpty() ) {
60 QStringList::Iterator it; 59 QStringList::Iterator it;
61 for ( it = m_path.begin(); it != m_path.end(); ++it ) { 60 for ( it = m_path.begin(); it != m_path.end(); ++it ) {
62 list += scanDir( (*it) ); 61 list += scanDir( (*it) );
63 } 62 }
64 } 63 }
65 return list; 64 return list;
66} 65}
67/** 66/**
68 * scan a specified dir for *.osql 67 * scan a specified dir for *.osql
69 */ 68 */
70OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { 69OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) {
71 OSQLBackEnd::ValueList list; 70 OSQLBackEnd::ValueList list;
72 QDir dir( dirName ); 71 QDir dir( dirName );
73 if (dir.exists() ) { 72 if (dir.exists() ) {
74 QStringList files = dir.entryList( "*.osql" ); 73 QStringList files = dir.entryList( "*.osql" );
75 QStringList::Iterator it; 74 QStringList::Iterator it;
76 for ( it = files.begin(); it != files.end(); ++it ) { 75 for ( it = files.begin(); it != files.end(); ++it ) {
77 list.append( file2backend( (*it) ) ); 76 list.append( file2backend( (*it) ) );
78 } 77 }
79 } 78 }
80 return list; 79 return list;
81} 80}
82 81
83/** 82/**
84 * read a config file and convert it to a OSQLBackEnd 83 * read a config file and convert it to a OSQLBackEnd
85 */ 84 */
86OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { 85OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) {
87 OSQLBackEnd end; 86 OSQLBackEnd end;
88 qWarning("fileName: " + file ); 87 qWarning("fileName: " + file );
89 Config cfg( file ); 88 Config cfg( file );
90 if (cfg.load() ) { 89 if (cfg.load() ) {
91 end.setName( cfg.value( "Name") ); 90 end.setName( cfg.value( "Name") );
92 end.setVendor( cfg.value("Vendor") ); 91 end.setVendor( cfg.value("Vendor") );
93 end.setLicense( cfg.value("License") ); 92 end.setLicense( cfg.value("License") );
94 end.setLibrary( cfg.value("Library").local8Bit() ); 93 end.setLibrary( cfg.value("Library").local8Bit() );
95 end.setDefault( cfg.value("Default").toInt() ); 94 end.setDefault( cfg.value("Default").toInt() );
96 end.setPreference( cfg.value("Preference").toInt() ); 95 end.setPreference( cfg.value("Preference").toInt() );
97 } 96 }
98 return end; 97 return end;
99} 98}
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index b857534..6141504 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -1,189 +1,188 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "osqlresult.h"
32#include "osqlquery.h" 31#include "osqlquery.h"
33#include "osqlitedriver.h" 32#include "osqlitedriver.h"
34 33
35#include <opie2/odebug.h> 34#include <opie2/odebug.h>
36 35
37#include <stdlib.h> 36#include <stdlib.h>
38 37
39// fromLocal8Bit() does not work as expected. Thus it 38// fromLocal8Bit() does not work as expected. Thus it
40// is replaced by fromLatin1() (eilers) 39// is replaced by fromLatin1() (eilers)
41#define __BUGGY_LOCAL8BIT_ 40#define __BUGGY_LOCAL8BIT_
42 41
43 42
44namespace { 43namespace {
45 struct Query { 44 struct Query {
46 OSQLError::ValueList errors; 45 OSQLError::ValueList errors;
47 OSQLResultItem::ValueList items; 46 OSQLResultItem::ValueList items;
48 OSQLiteDriver *driver; 47 OSQLiteDriver *driver;
49 }; 48 };
50} 49}
51 50
52 51
53OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) 52OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
54 : OSQLDriver( lib ) 53 : OSQLDriver( lib )
55{ 54{
56 m_sqlite = 0l; 55 m_sqlite = 0l;
57} 56}
58 57
59 58
60OSQLiteDriver::~OSQLiteDriver() { 59OSQLiteDriver::~OSQLiteDriver() {
61 close(); 60 close();
62} 61}
63 62
64 63
65QString OSQLiteDriver::id()const { 64QString OSQLiteDriver::id()const {
66 return QString::fromLatin1("SQLite"); 65 return QString::fromLatin1("SQLite");
67} 66}
68 67
69void OSQLiteDriver::setUserName( const QString& ) {} 68void OSQLiteDriver::setUserName( const QString& ) {}
70 69
71 70
72void OSQLiteDriver::setPassword( const QString& ) {} 71void OSQLiteDriver::setPassword( const QString& ) {}
73 72
74 73
75void OSQLiteDriver::setUrl( const QString& url ) { 74void OSQLiteDriver::setUrl( const QString& url ) {
76 m_url = url; 75 m_url = url;
77} 76}
78 77
79 78
80void OSQLiteDriver::setOptions( const QStringList& ) { 79void OSQLiteDriver::setOptions( const QStringList& ) {
81} 80}
82 81
83 82
84/* 83/*
85 * try to open a db specified via setUrl 84 * try to open a db specified via setUrl
86 * and options 85 * and options
87 */ 86 */
88bool OSQLiteDriver::open() { 87bool OSQLiteDriver::open() {
89 char *error; 88 char *error;
90 odebug << "OSQLiteDriver::open: about to open" << oendl; 89 odebug << "OSQLiteDriver::open: about to open" << oendl;
91 m_sqlite = sqlite_open(m_url.local8Bit(), 90 m_sqlite = sqlite_open(m_url.local8Bit(),
92 0, 91 0,
93 &error ); 92 &error );
94 93
95 /* failed to open */ 94 /* failed to open */
96 if (m_sqlite == 0l ) { 95 if (m_sqlite == 0l ) {
97 // FIXME set the last error 96 // FIXME set the last error
98 owarn << "OSQLiteDriver::open: " << error << oendl; 97 owarn << "OSQLiteDriver::open: " << error << oendl;
99 free( error ); 98 free( error );
100 return false; 99 return false;
101 } 100 }
102 return true; 101 return true;
103} 102}
104 103
105 104
106/* close the db 105/* close the db
107 * sqlite closes them without 106 * sqlite closes them without
108 * telling failure or success 107 * telling failure or success
109 */ 108 */
110bool OSQLiteDriver::close() { 109bool OSQLiteDriver::close() {
111 if (m_sqlite ) 110 if (m_sqlite )
112 sqlite_close( m_sqlite ), m_sqlite=0l; 111 sqlite_close( m_sqlite ), m_sqlite=0l;
113 112
114 return true; 113 return true;
115} 114}
116 115
117 116
118/* Query */ 117/* Query */
119OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 118OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
120 if ( !m_sqlite ) { 119 if ( !m_sqlite ) {
121 // FIXME set error code 120 // FIXME set error code
122 OSQLResult result( OSQLResult::Failure ); 121 OSQLResult result( OSQLResult::Failure );
123 return result; 122 return result;
124 } 123 }
125 Query query; 124 Query query;
126 query.driver = this; 125 query.driver = this;
127 char *err; 126 char *err;
128 /* SQLITE_OK 0 if return code > 0 == failure */ 127 /* SQLITE_OK 0 if return code > 0 == failure */
129 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 128 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
130 owarn << "OSQLiteDriver::query: Error while executing" << oendl; 129 owarn << "OSQLiteDriver::query: Error while executing" << oendl;
131 free(err ); 130 free(err );
132 // FixMe Errors 131 // FixMe Errors
133 } 132 }
134 133
135 OSQLResult result(OSQLResult::Success, 134 OSQLResult result(OSQLResult::Success,
136 query.items, 135 query.items,
137 query.errors ); 136 query.errors );
138 return result; 137 return result;
139} 138}
140 139
141 140
142OSQLTable::ValueList OSQLiteDriver::tables() const { 141OSQLTable::ValueList OSQLiteDriver::tables() const {
143 142
144} 143}
145 144
146 145
147OSQLError OSQLiteDriver::lastError() { 146OSQLError OSQLiteDriver::lastError() {
148 OSQLError error; 147 OSQLError error;
149 return error; 148 return error;
150}; 149};
151 150
152 151
153/* handle a callback add the row to the global 152/* handle a callback add the row to the global
154 * OSQLResultItem 153 * OSQLResultItem
155 */ 154 */
156int OSQLiteDriver::handleCallBack( int, char**, char** ) { 155int OSQLiteDriver::handleCallBack( int, char**, char** ) {
157 return 0; 156 return 0;
158} 157}
159 158
160 159
161/* callback_handler add the values to the list*/ 160/* callback_handler add the values to the list*/
162int OSQLiteDriver::call_back( void* voi, int argc, 161int OSQLiteDriver::call_back( void* voi, int argc,
163 char** argv, char** columns) { 162 char** argv, char** columns) {
164 Query* qu = (Query*)voi; 163 Query* qu = (Query*)voi;
165 164
166 //copy them over to a OSQLResultItem 165 //copy them over to a OSQLResultItem
167 QMap<QString, QString> tableString; 166 QMap<QString, QString> tableString;
168 QMap<int, QString> tableInt; 167 QMap<int, QString> tableInt;
169 for (int i = 0; i < argc; i++ ) { 168 for (int i = 0; i < argc; i++ ) {
170 169
171#ifdef __BUGGY_LOCAL8BIT_ 170#ifdef __BUGGY_LOCAL8BIT_
172 tableInt.insert( i, QString::fromLatin1( argv[i] ) ); 171 tableInt.insert( i, QString::fromLatin1( argv[i] ) );
173 tableString.insert( QString::fromLatin1( columns[i] ), 172 tableString.insert( QString::fromLatin1( columns[i] ),
174 QString::fromLatin1( argv[i] ) ); 173 QString::fromLatin1( argv[i] ) );
175#else 174#else
176 tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) ); 175 tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) );
177 tableString.insert( QString::fromLocal8Bit( columns[i] ), 176 tableString.insert( QString::fromLocal8Bit( columns[i] ),
178 QString::fromLocal8Bit( argv[i] ) ); 177 QString::fromLocal8Bit( argv[i] ) );
179#endif 178#endif
180 } 179 }
181 OSQLResultItem item( tableString, tableInt ); 180 OSQLResultItem item( tableString, tableInt );
182 qu->items.append( item ); 181 qu->items.append( item );
183 182
184 return ((Query*)voi)->driver->handleCallBack( argc, 183 return ((Query*)voi)->driver->handleCallBack( argc,
185 argv, 184 argv,
186 columns ); 185 columns );
187 186
188 187
189} 188}
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp
index b0fea04..766ebe1 100644
--- a/libopie2/opiedb/osqlmanager.cpp
+++ b/libopie2/opiedb/osqlmanager.cpp
@@ -1,83 +1,81 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "osqlbackend.h"
5#include "osqldriver.h"
6#include "osqlmanager.h" 4#include "osqlmanager.h"
7#include "osqlbackendmanager.h" 5#include "osqlbackendmanager.h"
8#include "osqlitedriver.h" 6#include "osqlitedriver.h"
9 7
10OSQLManager::OSQLManager() { 8OSQLManager::OSQLManager() {
11} 9}
12OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { 10OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
13 m_list.clear(); 11 m_list.clear();
14 QString opie = QString::fromLatin1( getenv("OPIEDIR") ); 12 QString opie = QString::fromLatin1( getenv("OPIEDIR") );
15 QString qpe = QString::fromLatin1( getenv("QPEDIR") ); 13 QString qpe = QString::fromLatin1( getenv("QPEDIR") );
16 14
17 if ( !m_path.contains(opie) && !opie.isEmpty() ) 15 if ( !m_path.contains(opie) && !opie.isEmpty() )
18 m_path << opie; 16 m_path << opie;
19 if ( !m_path.contains(qpe) && !qpe.isEmpty() ) 17 if ( !m_path.contains(qpe) && !qpe.isEmpty() )
20 m_path << qpe; 18 m_path << qpe;
21 19
22 OSQLBackEndManager mng( m_path ); 20 OSQLBackEndManager mng( m_path );
23 m_list = mng.scan(); 21 m_list = mng.scan();
24 m_list += builtIn(); 22 m_list += builtIn();
25 23
26 return m_list; 24 return m_list;
27} 25}
28/* 26/*
29 * loading dso's is currently not enabled due problems with QLibrary 27 * loading dso's is currently not enabled due problems with QLibrary
30 * beeing in libqpe and not libqte 28 * beeing in libqpe and not libqte
31 */ 29 */
32OSQLDriver* OSQLManager::load( const QString& name ) { 30OSQLDriver* OSQLManager::load( const QString& name ) {
33 OSQLDriver* driver = 0l; 31 OSQLDriver* driver = 0l;
34 32
35 if ( name == "SQLite" ) { 33 if ( name == "SQLite" ) {
36 driver = new OSQLiteDriver(); 34 driver = new OSQLiteDriver();
37 } 35 }
38 return driver; 36 return driver;
39} 37}
40/* 38/*
41 * same as above 39 * same as above
42 */ 40 */
43OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { 41OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
44 OSQLDriver *driver = 0l; 42 OSQLDriver *driver = 0l;
45 if ( end.library() == "builtin" && 43 if ( end.library() == "builtin" &&
46 end.name() == "SQLite" ) 44 end.name() == "SQLite" )
47 driver = new OSQLiteDriver(); 45 driver = new OSQLiteDriver();
48 46
49 return driver; 47 return driver;
50} 48}
51/* 49/*
52 * let's find the a default with the highes preference 50 * let's find the a default with the highes preference
53 */ 51 */
54OSQLDriver* OSQLManager::standard() { 52OSQLDriver* OSQLManager::standard() {
55 OSQLDriver* driver =0l; 53 OSQLDriver* driver =0l;
56 if ( m_list.isEmpty() ) queryBackEnd(); 54 if ( m_list.isEmpty() ) queryBackEnd();
57 OSQLBackEnd::ValueList::Iterator it; 55 OSQLBackEnd::ValueList::Iterator it;
58 OSQLBackEnd back; 56 OSQLBackEnd back;
59 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 57 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
60 if ( (*it).isDefault() && 58 if ( (*it).isDefault() &&
61 back.preference() < (*it).preference() ) { 59 back.preference() < (*it).preference() ) {
62 back = (*it); 60 back = (*it);
63 } 61 }
64 } 62 }
65 driver = load( back ); 63 driver = load( back );
66 return driver; 64 return driver;
67} 65}
68void OSQLManager::registerPath( const QString& path ) { 66void OSQLManager::registerPath( const QString& path ) {
69 m_path << path; 67 m_path << path;
70} 68}
71bool OSQLManager::unregisterPath( const QString& path ) { 69bool OSQLManager::unregisterPath( const QString& path ) {
72 m_path.remove( path ); 70 m_path.remove( path );
73 return true; 71 return true;
74} 72}
75OSQLBackEnd::ValueList OSQLManager::builtIn()const { 73OSQLBackEnd::ValueList OSQLManager::builtIn()const {
76 OSQLBackEnd::ValueList list; 74 OSQLBackEnd::ValueList list;
77 // create the OSQLiteBackend 75 // create the OSQLiteBackend
78 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); 76 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" );
79 back.setDefault( true ); 77 back.setDefault( true );
80 back.setPreference( 50 ); 78 back.setPreference( 50 );
81 list.append( back ); 79 list.append( back );
82 return list; 80 return list;
83} 81}
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp
index 490fb45..42da356 100644
--- a/libopie2/opiedb/osqlresult.cpp
+++ b/libopie2/opiedb/osqlresult.cpp
@@ -1,127 +1,126 @@
1 1
2#include "osqlquery.h"
3#include "osqlresult.h" 2#include "osqlresult.h"
4 3
5OSQLResultItem::OSQLResultItem( const TableString& string, 4OSQLResultItem::OSQLResultItem( const TableString& string,
6 const TableInt& Int) 5 const TableInt& Int)
7 : m_string( string ), m_int( Int ) 6 : m_string( string ), m_int( Int )
8{ 7{
9 8
10} 9}
11OSQLResultItem::~OSQLResultItem() { 10OSQLResultItem::~OSQLResultItem() {
12} 11}
13OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { 12OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
14 *this = item; 13 *this = item;
15} 14}
16OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { 15OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
17 m_string = other.m_string; 16 m_string = other.m_string;
18 m_int = other.m_int; 17 m_int = other.m_int;
19 return *this; 18 return *this;
20} 19}
21OSQLResultItem::TableString OSQLResultItem::tableString()const{ 20OSQLResultItem::TableString OSQLResultItem::tableString()const{
22 return m_string; 21 return m_string;
23} 22}
24OSQLResultItem::TableInt OSQLResultItem::tableInt()const { 23OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
25 return m_int; 24 return m_int;
26} 25}
27QString OSQLResultItem::data( const QString& columnName, bool *ok ) { 26QString OSQLResultItem::data( const QString& columnName, bool *ok ) {
28 TableString::Iterator it = m_string.find( columnName ); 27 TableString::Iterator it = m_string.find( columnName );
29 28
30 /* if found */ 29 /* if found */
31 if ( it != m_string.end() ) { 30 if ( it != m_string.end() ) {
32 if ( ok ) *ok = true; 31 if ( ok ) *ok = true;
33 return it.data(); 32 return it.data();
34 }else{ 33 }else{
35 if ( ok ) *ok = false; 34 if ( ok ) *ok = false;
36 return QString::null; 35 return QString::null;
37 } 36 }
38 37
39} 38}
40QString OSQLResultItem::data( int column, bool *ok ) { 39QString OSQLResultItem::data( int column, bool *ok ) {
41 TableInt::Iterator it = m_int.find( column ); 40 TableInt::Iterator it = m_int.find( column );
42 41
43 /* if found */ 42 /* if found */
44 if ( it != m_int.end() ) { 43 if ( it != m_int.end() ) {
45 if ( ok ) *ok = true; 44 if ( ok ) *ok = true;
46 return it.data(); 45 return it.data();
47 }else{ 46 }else{
48 if ( ok ) *ok = false; 47 if ( ok ) *ok = false;
49 return QString::null; 48 return QString::null;
50 } 49 }
51} 50}
52/* 51/*
53 * DateFormat is 'YYYY-MM-DD' 52 * DateFormat is 'YYYY-MM-DD'
54 */ 53 */
55QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { 54QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) {
56 QDate date = QDate::currentDate(); 55 QDate date = QDate::currentDate();
57 QString str = data( column, ok ); 56 QString str = data( column, ok );
58 if (!str.isEmpty() ) { 57 if (!str.isEmpty() ) {
59 ;// convert 58 ;// convert
60 } 59 }
61 return date; 60 return date;
62} 61}
63QDate OSQLResultItem::dataToDate( int column, bool *ok ) { 62QDate OSQLResultItem::dataToDate( int column, bool *ok ) {
64 QDate date = QDate::currentDate(); 63 QDate date = QDate::currentDate();
65 QString str = data( column, ok ); 64 QString str = data( column, ok );
66 if (!str.isEmpty() ) { 65 if (!str.isEmpty() ) {
67 ;// convert 66 ;// convert
68 } 67 }
69 return date; 68 return date;
70 69
71} 70}
72QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { 71QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) {
73 QDateTime time = QDateTime::currentDateTime(); 72 QDateTime time = QDateTime::currentDateTime();
74 return time; 73 return time;
75} 74}
76QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { 75QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) {
77 QDateTime time = QDateTime::currentDateTime(); 76 QDateTime time = QDateTime::currentDateTime();
78 return time; 77 return time;
79} 78}
80 79
81OSQLResult::OSQLResult( enum State state, 80OSQLResult::OSQLResult( enum State state,
82 const OSQLResultItem::ValueList& list, 81 const OSQLResultItem::ValueList& list,
83 const OSQLError::ValueList& error ) 82 const OSQLError::ValueList& error )
84 : m_state( state ), m_list( list ), m_error( error ) 83 : m_state( state ), m_list( list ), m_error( error )
85{ 84{
86 85
87} 86}
88OSQLResult::~OSQLResult() { 87OSQLResult::~OSQLResult() {
89 88
90} 89}
91OSQLResult::State OSQLResult::state()const { 90OSQLResult::State OSQLResult::state()const {
92 return m_state; 91 return m_state;
93} 92}
94void OSQLResult::setState( OSQLResult::State state ) { 93void OSQLResult::setState( OSQLResult::State state ) {
95 m_state = state; 94 m_state = state;
96} 95}
97OSQLError::ValueList OSQLResult::errors()const { 96OSQLError::ValueList OSQLResult::errors()const {
98 return m_error; 97 return m_error;
99} 98}
100void OSQLResult::setErrors( const OSQLError::ValueList& err ) { 99void OSQLResult::setErrors( const OSQLError::ValueList& err ) {
101 m_error = err; 100 m_error = err;
102} 101}
103OSQLResultItem::ValueList OSQLResult::results()const { 102OSQLResultItem::ValueList OSQLResult::results()const {
104 return m_list; 103 return m_list;
105} 104}
106void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { 105void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) {
107 m_list = result; 106 m_list = result;
108} 107}
109OSQLResultItem OSQLResult::first() { 108OSQLResultItem OSQLResult::first() {
110 it = m_list.begin(); 109 it = m_list.begin();
111 return (*it); 110 return (*it);
112} 111}
113OSQLResultItem OSQLResult::next(){ 112OSQLResultItem OSQLResult::next(){
114 ++it; 113 ++it;
115 return (*it); 114 return (*it);
116} 115}
117bool OSQLResult::atEnd(){ 116bool OSQLResult::atEnd(){
118 if ( it == m_list.end() ) 117 if ( it == m_list.end() )
119 return true; 118 return true;
120 119
121 return false; 120 return false;
122} 121}
123OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { 122OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const {
124 OSQLResultItem::ValueList::ConstIterator it; 123 OSQLResultItem::ValueList::ConstIterator it;
125 it = m_list.begin(); 124 it = m_list.begin();
126 return it; 125 return it;
127} 126}
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index ca63389..51e088c 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,314 +1,313 @@
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 .=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 31
32#include <opie2/osoundsystem.h> 32#include <opie2/osoundsystem.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35#include <errno.h> 35#include <errno.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <string.h> 37#include <string.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/soundcard.h> 40#include <sys/soundcard.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42 42
43#include <qstringlist.h>
44 43
45/*====================================================================================== 44/*======================================================================================
46 * OSoundSystem 45 * OSoundSystem
47 *======================================================================================*/ 46 *======================================================================================*/
48 47
49OSoundSystem* OSoundSystem::_instance = 0; 48OSoundSystem* OSoundSystem::_instance = 0;
50 49
51OSoundSystem::OSoundSystem() 50OSoundSystem::OSoundSystem()
52{ 51{
53 odebug << "OSoundSystem::OSoundSystem()" << oendl; 52 odebug << "OSoundSystem::OSoundSystem()" << oendl;
54 synchronize(); 53 synchronize();
55} 54}
56 55
57void OSoundSystem::synchronize() 56void OSoundSystem::synchronize()
58{ 57{
59 // gather available interfaces by inspecting /dev 58 // gather available interfaces by inspecting /dev
60 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 59 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
61 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 60 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
62 61
63 _interfaces.clear(); 62 _interfaces.clear();
64 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 63 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
65 64
66 65
67 /* 66 /*
68 67
69 QString str; 68 QString str;
70 QFile f( "/dev/sound" ); 69 QFile f( "/dev/sound" );
71 bool hasFile = f.open( IO_ReadOnly ); 70 bool hasFile = f.open( IO_ReadOnly );
72 if ( !hasFile ) 71 if ( !hasFile )
73 { 72 {
74 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
75 return; 74 return;
76 } 75 }
77 QTextStream s( &f ); 76 QTextStream s( &f );
78 s.readLine(); 77 s.readLine();
79 s.readLine(); 78 s.readLine();
80 while ( !s.atEnd() ) 79 while ( !s.atEnd() )
81 { 80 {
82 s >> str; 81 s >> str;
83 str.truncate( str.find( ':' ) ); 82 str.truncate( str.find( ':' ) );
84 qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); 83 qDebug( "OSoundSystem: found interface '%s'", (const char*) str );
85 OAudioInterface* iface; 84 OAudioInterface* iface;
86 iface = new OAudioInterface( this, (const char*) str ); 85 iface = new OAudioInterface( this, (const char*) str );
87 86
88 _interfaces.insert( str, iface ); 87 _interfaces.insert( str, iface );
89 s.readLine(); 88 s.readLine();
90 } 89 }
91*/ 90*/
92} 91}
93 92
94 93
95int OSoundSystem::count() const 94int OSoundSystem::count() const
96{ 95{
97 return _interfaces.count(); 96 return _interfaces.count();
98} 97}
99 98
100 99
101OSoundCard* OSoundSystem::card( const QString& iface ) const 100OSoundCard* OSoundSystem::card( const QString& iface ) const
102{ 101{
103 return _interfaces[iface]; 102 return _interfaces[iface];
104} 103}
105 104
106 105
107OSoundSystem* OSoundSystem::instance() 106OSoundSystem* OSoundSystem::instance()
108{ 107{
109 if ( !_instance ) _instance = new OSoundSystem(); 108 if ( !_instance ) _instance = new OSoundSystem();
110 return _instance; 109 return _instance;
111} 110}
112 111
113 112
114OSoundSystem::CardIterator OSoundSystem::iterator() const 113OSoundSystem::CardIterator OSoundSystem::iterator() const
115{ 114{
116 return OSoundSystem::CardIterator( _interfaces ); 115 return OSoundSystem::CardIterator( _interfaces );
117} 116}
118 117
119 118
120/*====================================================================================== 119/*======================================================================================
121 * OSoundCard 120 * OSoundCard
122 *======================================================================================*/ 121 *======================================================================================*/
123 122
124OSoundCard::OSoundCard( QObject* parent, const char* name ) 123OSoundCard::OSoundCard( QObject* parent, const char* name )
125 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 124 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
126{ 125{
127 odebug << "OSoundCard::OSoundCard()" << oendl; 126 odebug << "OSoundCard::OSoundCard()" << oendl;
128 init(); 127 init();
129} 128}
130 129
131 130
132OSoundCard::~OSoundCard() 131OSoundCard::~OSoundCard()
133{ 132{
134} 133}
135 134
136 135
137void OSoundCard::init() 136void OSoundCard::init()
138{ 137{
139 _audio = new OAudioInterface( this, "/dev/dsp" ); 138 _audio = new OAudioInterface( this, "/dev/dsp" );
140 _mixer = new OMixerInterface( this, "/dev/mixer" ); 139 _mixer = new OMixerInterface( this, "/dev/mixer" );
141} 140}
142 141
143 142
144/*====================================================================================== 143/*======================================================================================
145 * OAudioInterface 144 * OAudioInterface
146 *======================================================================================*/ 145 *======================================================================================*/
147 146
148OAudioInterface::OAudioInterface( QObject* parent, const char* name ) 147OAudioInterface::OAudioInterface( QObject* parent, const char* name )
149 :QObject( parent, name ) 148 :QObject( parent, name )
150{ 149{
151 odebug << "OAudioInterface::OAudioInterface()" << oendl; 150 odebug << "OAudioInterface::OAudioInterface()" << oendl;
152 init(); 151 init();
153} 152}
154 153
155 154
156OAudioInterface::~OAudioInterface() 155OAudioInterface::~OAudioInterface()
157{ 156{
158} 157}
159 158
160 159
161void OAudioInterface::init() 160void OAudioInterface::init()
162{ 161{
163 162
164 163
165} 164}
166 165
167 166
168/*====================================================================================== 167/*======================================================================================
169 * OMixerInterface 168 * OMixerInterface
170 *======================================================================================*/ 169 *======================================================================================*/
171 170
172OMixerInterface::OMixerInterface( QObject* parent, const char* name ) 171OMixerInterface::OMixerInterface( QObject* parent, const char* name )
173 :QObject( parent, name ) 172 :QObject( parent, name )
174{ 173{
175 odebug << "OMixerInterface::OMixerInterface()" << oendl; 174 odebug << "OMixerInterface::OMixerInterface()" << oendl;
176 init(); 175 init();
177} 176}
178 177
179 178
180OMixerInterface::~OMixerInterface() 179OMixerInterface::~OMixerInterface()
181{ 180{
182} 181}
183 182
184 183
185void OMixerInterface::init() 184void OMixerInterface::init()
186{ 185{
187 // open the device 186 // open the device
188 _fd = ::open( name(), O_RDWR ); 187 _fd = ::open( name(), O_RDWR );
189 if ( _fd == -1 ) 188 if ( _fd == -1 )
190 { 189 {
191 owarn << "OMixerInterface::init(): Can't open mixer." << oendl; 190 owarn << "OMixerInterface::init(): Can't open mixer." << oendl;
192 return; 191 return;
193 } 192 }
194 193
195 // construct the device capabilities 194 // construct the device capabilities
196 int devmask = 0; 195 int devmask = 0;
197 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) 196 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 )
198 { 197 {
199 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); 198 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME );
200 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); 199 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS );
201 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); 200 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE );
202 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); 201 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH );
203 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); 202 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM );
204 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); 203 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER );
205 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); 204 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE );
206 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); 205 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC );
207 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); 206 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD );
208 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); 207 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX );
209 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); 208 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM );
210 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); 209 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV );
211 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); 210 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN );
212 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); 211 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN );
213 //odebug << "devmask available and constructed." << oendl; 212 //odebug << "devmask available and constructed." << oendl;
214 } 213 }
215 214
216 devmask = 0; 215 devmask = 0;
217 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) 216 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 )
218 { 217 {
219 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); 218 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME );
220 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); 219 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS );
221 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); 220 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE );
222 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); 221 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH );
223 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); 222 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM );
224 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); 223 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER );
225 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); 224 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE );
226 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); 225 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC );
227 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); 226 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD );
228 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); 227 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX );
229 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); 228 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM );
230 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); 229 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV );
231 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); 230 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN );
232 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); 231 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN );
233 //odebug << "recmask available and constructed." << oendl; 232 //odebug << "recmask available and constructed." << oendl;
234 } 233 }
235 234
236/* ChannelIterator it; 235/* ChannelIterator it;
237 for ( it = _channels.begin(); it != _channels.end(); ++it ) 236 for ( it = _channels.begin(); it != _channels.end(); ++it )
238 { 237 {
239 qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() ); 238 qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() );
240 qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 ); 239 qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 );
241 } 240 }
242*/ 241*/
243} 242}
244 243
245QStringList OMixerInterface::allChannels() const 244QStringList OMixerInterface::allChannels() const
246{ 245{
247 ChannelIterator it = _channels.begin(); 246 ChannelIterator it = _channels.begin();
248 QStringList channels; 247 QStringList channels;
249 while ( it != _channels.end() ) 248 while ( it != _channels.end() )
250 { 249 {
251 channels += it.key(); 250 channels += it.key();
252 it++; 251 it++;
253 } 252 }
254 return channels; 253 return channels;
255} 254}
256 255
257 256
258QStringList OMixerInterface::recChannels() const 257QStringList OMixerInterface::recChannels() const
259{ 258{
260 owarn << "NYI" << oendl; 259 owarn << "NYI" << oendl;
261} 260}
262 261
263 262
264QStringList OMixerInterface::playChannels() const 263QStringList OMixerInterface::playChannels() const
265{ 264{
266 owarn << "NYI" << oendl; 265 owarn << "NYI" << oendl;
267} 266}
268 267
269 268
270bool OMixerInterface::hasChannel( const QString& channel ) 269bool OMixerInterface::hasChannel( const QString& channel )
271{ 270{
272 return _channels.contains( channel ); 271 return _channels.contains( channel );
273} 272}
274 273
275 274
276void OMixerInterface::setVolume( const QString& channel, int left, int right ) 275void OMixerInterface::setVolume( const QString& channel, int left, int right )
277{ 276{
278 int volume = left; 277 int volume = left;
279 volume |= ( right == -1 ) ? left << 8 : right << 8; 278 volume |= ( right == -1 ) ? left << 8 : right << 8;
280 279
281 if ( _channels.contains( channel ) ) 280 if ( _channels.contains( channel ) )
282 { 281 {
283 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); 282 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume );
284 if ( result == -1 ) 283 if ( result == -1 )
285 { 284 {
286 owarn << "Can't set volume: " << strerror( errno ) << oendl; 285 owarn << "Can't set volume: " << strerror( errno ) << oendl;
287 } 286 }
288 else 287 else
289 { 288 {
290 if ( result & 0xff != left ) 289 if ( result & 0xff != left )
291 { 290 {
292 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; 291 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl;
293 } 292 }
294 } 293 }
295 } 294 }
296} 295}
297 296
298 297
299int OMixerInterface::volume( const QString& channel ) const 298int OMixerInterface::volume( const QString& channel ) const
300{ 299{
301 int volume; 300 int volume;
302 301
303 if ( _channels.contains( channel ) ) 302 if ( _channels.contains( channel ) )
304 { 303 {
305 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) 304 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 )
306 { 305 {
307 owarn << "Can't get volume: " << strerror( errno ) << oendl; 306 owarn << "Can't get volume: " << strerror( errno ) << oendl;
308 } 307 }
309 else return volume; 308 else return volume;
310 } 309 }
311 return -1; 310 return -1;
312} 311}
313 312
314 313
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index 2da549c..b93b752 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,136 +1,135 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
32 32
33#define OPIE_IMPROVE_GUI_LATENCY 1 33#define OPIE_IMPROVE_GUI_LATENCY 1
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#ifdef OPIE_IMPROVE_GUI_LATENCY 37#ifdef OPIE_IMPROVE_GUI_LATENCY
38#include <qpe/global.h> 38#include <qpe/global.h>
39#endif 39#endif
40 40
41/* QT */ 41/* QT */
42#include <qapplication.h> 42#include <qapplication.h>
43#include <qstring.h>
44#include <qfile.h> 43#include <qfile.h>
45#include <qtextstream.h> 44#include <qtextstream.h>
46 45
47OManufacturerDB* OManufacturerDB::_instance = 0; 46OManufacturerDB* OManufacturerDB::_instance = 0;
48 47
49OManufacturerDB* OManufacturerDB::instance() 48OManufacturerDB* OManufacturerDB::instance()
50{ 49{
51 if ( !OManufacturerDB::_instance ) 50 if ( !OManufacturerDB::_instance )
52 { 51 {
53 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 52 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
54 _instance = new OManufacturerDB(); 53 _instance = new OManufacturerDB();
55 } 54 }
56 return _instance; 55 return _instance;
57} 56}
58 57
59 58
60OManufacturerDB::OManufacturerDB() 59OManufacturerDB::OManufacturerDB()
61{ 60{
62 #ifdef OPIE_IMPROVE_GUI_LATENCY 61 #ifdef OPIE_IMPROVE_GUI_LATENCY
63 Global::statusMessage( "Reading Manufacturers..." ); 62 Global::statusMessage( "Reading Manufacturers..." );
64 #endif 63 #endif
65 QString filename( "/etc/manufacturers" ); 64 QString filename( "/etc/manufacturers" );
66 odebug << "OManufacturerDB: trying to read " << filename << oendl; 65 odebug << "OManufacturerDB: trying to read " << filename << oendl;
67 if ( !QFile::exists( filename ) ) 66 if ( !QFile::exists( filename ) )
68 { 67 {
69 filename = "/opt/QtPalmtop/etc/manufacturers"; 68 filename = "/opt/QtPalmtop/etc/manufacturers";
70 odebug << "OManufacturerDB: trying to read " << filename << oendl; 69 odebug << "OManufacturerDB: trying to read " << filename << oendl;
71 if ( !QFile::exists( filename ) ) 70 if ( !QFile::exists( filename ) )
72 { 71 {
73 filename = "/usr/share/wellenreiter/manufacturers"; 72 filename = "/usr/share/wellenreiter/manufacturers";
74 odebug << "OManufacturerDB: trying to read " << filename << oendl; 73 odebug << "OManufacturerDB: trying to read " << filename << oendl;
75 } 74 }
76 } 75 }
77 76
78 QFile file( filename ); 77 QFile file( filename );
79 bool hasFile = file.open( IO_ReadOnly ); 78 bool hasFile = file.open( IO_ReadOnly );
80 if (!hasFile) 79 if (!hasFile)
81 { 80 {
82 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 81 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
83 } 82 }
84 else 83 else
85 { 84 {
86 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 85 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
87 QTextStream s( &file ); 86 QTextStream s( &file );
88 QString addr; 87 QString addr;
89 QString manu; 88 QString manu;
90 QString extManu; 89 QString extManu;
91 #ifdef OPIE_IMPROVE_GUI_LATENCY 90 #ifdef OPIE_IMPROVE_GUI_LATENCY
92 int counter = 0; 91 int counter = 0;
93 #endif 92 #endif
94 while (!s.atEnd()) 93 while (!s.atEnd())
95 { 94 {
96 s >> addr; 95 s >> addr;
97 s >> manu; 96 s >> manu;
98 s >> extManu; 97 s >> extManu;
99 98
100 manufacturers.insert( addr, manu ); 99 manufacturers.insert( addr, manu );
101 manufacturersExt.insert( addr, extManu ); 100 manufacturersExt.insert( addr, extManu );
102 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 101 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
103 #ifdef OPIE_IMPROVE_GUI_LATENCY 102 #ifdef OPIE_IMPROVE_GUI_LATENCY
104 counter++; 103 counter++;
105 if ( counter == 50 ) 104 if ( counter == 50 )
106 { 105 {
107 qApp->processEvents(); 106 qApp->processEvents();
108 counter = 0; 107 counter = 0;
109 } 108 }
110 #endif 109 #endif
111 } 110 }
112 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 111 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
113 #ifdef OPIE_IMPROVE_GUI_LATENCY 112 #ifdef OPIE_IMPROVE_GUI_LATENCY
114 Global::statusMessage( "Manufacturers Complete..." ); 113 Global::statusMessage( "Manufacturers Complete..." );
115 #endif 114 #endif
116 } 115 }
117} 116}
118 117
119 118
120OManufacturerDB::~OManufacturerDB() 119OManufacturerDB::~OManufacturerDB()
121{ 120{
122} 121}
123 122
124 123
125const QString& OManufacturerDB::lookup( const QString& macaddr ) const 124const QString& OManufacturerDB::lookup( const QString& macaddr ) const
126{ 125{
127 return manufacturers[macaddr.upper().left(8)]; 126 return manufacturers[macaddr.upper().left(8)];
128} 127}
129 128
130 129
131const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 130const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
132{ 131{
133 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 132 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
134 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 133 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
135} 134}
136 135
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 0adba68..5d92b8f 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,426 +1,424 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include <opie2/ocontactaccessbackend_xml.h> 33#include <opie2/ocontactaccessbackend_xml.h>
34 34
35#include <qasciidict.h> 35#include <qasciidict.h>
36#include <qdatetime.h>
37#include <qfile.h> 36#include <qfile.h>
38#include <qfileinfo.h> 37#include <qfileinfo.h>
39#include <qregexp.h> 38#include <qregexp.h>
40#include <qarray.h> 39#include <qarray.h>
41#include <qmap.h> 40#include <qmap.h>
42#include <qdatetime.h>
43 41
44#include <qpe/global.h> 42#include <qpe/global.h>
45 43
46#include <opie2/xmltree.h> 44#include <opie2/xmltree.h>
47#include <opie2/ocontactaccessbackend.h> 45#include <opie2/ocontactaccessbackend.h>
48#include <opie2/ocontactaccess.h> 46#include <opie2/ocontactaccess.h>
49 47
50#include <stdlib.h> 48#include <stdlib.h>
51#include <errno.h> 49#include <errno.h>
52 50
53using namespace Opie; 51using namespace Opie;
54 52
55 53
56namespace Opie { 54namespace Opie {
57OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): 55OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
58 m_changed( false ) 56 m_changed( false )
59{ 57{
60 // Just m_contactlist should call delete if an entry 58 // Just m_contactlist should call delete if an entry
61 // is removed. 59 // is removed.
62 m_contactList.setAutoDelete( true ); 60 m_contactList.setAutoDelete( true );
63 m_uidToContact.setAutoDelete( false ); 61 m_uidToContact.setAutoDelete( false );
64 62
65 m_appName = appname; 63 m_appName = appname;
66 64
67 /* Set journalfile name ... */ 65 /* Set journalfile name ... */
68 m_journalName = getenv("HOME"); 66 m_journalName = getenv("HOME");
69 m_journalName +="/.abjournal" + appname; 67 m_journalName +="/.abjournal" + appname;
70 68
71 /* Expecting to access the default filename if nothing else is set */ 69 /* Expecting to access the default filename if nothing else is set */
72 if ( filename.isEmpty() ){ 70 if ( filename.isEmpty() ){
73 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 71 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
74 } else 72 } else
75 m_fileName = filename; 73 m_fileName = filename;
76 74
77 /* Load Database now */ 75 /* Load Database now */
78 load (); 76 load ();
79} 77}
80 78
81bool OPimContactAccessBackend_XML::save() 79bool OPimContactAccessBackend_XML::save()
82{ 80{
83 81
84 if ( !m_changed ) 82 if ( !m_changed )
85 return true; 83 return true;
86 84
87 QString strNewFile = m_fileName + ".new"; 85 QString strNewFile = m_fileName + ".new";
88 QFile f( strNewFile ); 86 QFile f( strNewFile );
89 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 87 if ( !f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 88 return false;
91 89
92 int total_written; 90 int total_written;
93 int idx_offset = 0; 91 int idx_offset = 0;
94 QString out; 92 QString out;
95 93
96 // Write Header 94 // Write Header
97 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 95 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
98 " <Groups>\n" 96 " <Groups>\n"
99 " </Groups>\n" 97 " </Groups>\n"
100 " <Contacts>\n"; 98 " <Contacts>\n";
101 QCString cstr = out.utf8(); 99 QCString cstr = out.utf8();
102 f.writeBlock( cstr.data(), cstr.length() ); 100 f.writeBlock( cstr.data(), cstr.length() );
103 idx_offset += cstr.length(); 101 idx_offset += cstr.length();
104 out = ""; 102 out = "";
105 103
106 // Write all contacts 104 // Write all contacts
107 QListIterator<OPimContact> it( m_contactList ); 105 QListIterator<OPimContact> it( m_contactList );
108 for ( ; it.current(); ++it ) { 106 for ( ; it.current(); ++it ) {
109 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 107 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
110 out += "<Contact "; 108 out += "<Contact ";
111 (*it)->save( out ); 109 (*it)->save( out );
112 out += "/>\n"; 110 out += "/>\n";
113 cstr = out.utf8(); 111 cstr = out.utf8();
114 total_written = f.writeBlock( cstr.data(), cstr.length() ); 112 total_written = f.writeBlock( cstr.data(), cstr.length() );
115 idx_offset += cstr.length(); 113 idx_offset += cstr.length();
116 if ( total_written != int(cstr.length()) ) { 114 if ( total_written != int(cstr.length()) ) {
117 f.close(); 115 f.close();
118 QFile::remove( strNewFile ); 116 QFile::remove( strNewFile );
119 return false; 117 return false;
120 } 118 }
121 out = ""; 119 out = "";
122 } 120 }
123 out += " </Contacts>\n</AddressBook>\n"; 121 out += " </Contacts>\n</AddressBook>\n";
124 122
125 // Write Footer 123 // Write Footer
126 cstr = out.utf8(); 124 cstr = out.utf8();
127 total_written = f.writeBlock( cstr.data(), cstr.length() ); 125 total_written = f.writeBlock( cstr.data(), cstr.length() );
128 if ( total_written != int( cstr.length() ) ) { 126 if ( total_written != int( cstr.length() ) ) {
129 f.close(); 127 f.close();
130 QFile::remove( strNewFile ); 128 QFile::remove( strNewFile );
131 return false; 129 return false;
132 } 130 }
133 f.close(); 131 f.close();
134 132
135 // move the file over, I'm just going to use the system call 133 // move the file over, I'm just going to use the system call
136 // because, I don't feel like using QDir. 134 // because, I don't feel like using QDir.
137 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { 135 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
138 qWarning( "problem renaming file %s to %s, errno: %d", 136 qWarning( "problem renaming file %s to %s, errno: %d",
139 strNewFile.latin1(), m_journalName.latin1(), errno ); 137 strNewFile.latin1(), m_journalName.latin1(), errno );
140 // remove the tmp file... 138 // remove the tmp file...
141 QFile::remove( strNewFile ); 139 QFile::remove( strNewFile );
142 } 140 }
143 141
144 /* The journalfile should be removed now... */ 142 /* The journalfile should be removed now... */
145 removeJournal(); 143 removeJournal();
146 144
147 m_changed = false; 145 m_changed = false;
148 return true; 146 return true;
149} 147}
150 148
151bool OPimContactAccessBackend_XML::load () 149bool OPimContactAccessBackend_XML::load ()
152{ 150{
153 m_contactList.clear(); 151 m_contactList.clear();
154 m_uidToContact.clear(); 152 m_uidToContact.clear();
155 153
156 /* Load XML-File and journal if it exists */ 154 /* Load XML-File and journal if it exists */
157 if ( !load ( m_fileName, false ) ) 155 if ( !load ( m_fileName, false ) )
158 return false; 156 return false;
159 /* The returncode of the journalfile is ignored due to the 157 /* The returncode of the journalfile is ignored due to the
160 * fact that it does not exist when this class is instantiated ! 158 * fact that it does not exist when this class is instantiated !
161 * But there may such a file exist, if the application crashed. 159 * But there may such a file exist, if the application crashed.
162 * Therefore we try to load it to get the changes before the # 160 * Therefore we try to load it to get the changes before the #
163 * crash happened... 161 * crash happened...
164 */ 162 */
165 load (m_journalName, true); 163 load (m_journalName, true);
166 164
167 return true; 165 return true;
168} 166}
169 167
170void OPimContactAccessBackend_XML::clear () 168void OPimContactAccessBackend_XML::clear ()
171{ 169{
172 m_contactList.clear(); 170 m_contactList.clear();
173 m_uidToContact.clear(); 171 m_uidToContact.clear();
174 172
175 m_changed = false; 173 m_changed = false;
176} 174}
177 175
178bool OPimContactAccessBackend_XML::wasChangedExternally() 176bool OPimContactAccessBackend_XML::wasChangedExternally()
179{ 177{
180 QFileInfo fi( m_fileName ); 178 QFileInfo fi( m_fileName );
181 179
182 QDateTime lastmod = fi.lastModified (); 180 QDateTime lastmod = fi.lastModified ();
183 181
184 return (lastmod != m_readtime); 182 return (lastmod != m_readtime);
185} 183}
186 184
187QArray<int> OPimContactAccessBackend_XML::allRecords() const 185QArray<int> OPimContactAccessBackend_XML::allRecords() const
188{ 186{
189 QArray<int> uid_list( m_contactList.count() ); 187 QArray<int> uid_list( m_contactList.count() );
190 188
191 uint counter = 0; 189 uint counter = 0;
192 QListIterator<OPimContact> it( m_contactList ); 190 QListIterator<OPimContact> it( m_contactList );
193 for( ; it.current(); ++it ){ 191 for( ; it.current(); ++it ){
194 uid_list[counter++] = (*it)->uid(); 192 uid_list[counter++] = (*it)->uid();
195 } 193 }
196 194
197 return ( uid_list ); 195 return ( uid_list );
198} 196}
199 197
200OPimContact OPimContactAccessBackend_XML::find ( int uid ) const 198OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
201{ 199{
202 OPimContact foundContact; //Create empty contact 200 OPimContact foundContact; //Create empty contact
203 201
204 OPimContact* found = m_uidToContact.find( QString().setNum( uid ) ); 202 OPimContact* found = m_uidToContact.find( QString().setNum( uid ) );
205 203
206 if ( found ){ 204 if ( found ){
207 foundContact = *found; 205 foundContact = *found;
208 } 206 }
209 207
210 return ( foundContact ); 208 return ( foundContact );
211} 209}
212 210
213QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, 211QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings,
214 const QDateTime& d ) 212 const QDateTime& d )
215{ 213{
216 214
217 QArray<int> m_currentQuery( m_contactList.count() ); 215 QArray<int> m_currentQuery( m_contactList.count() );
218 QListIterator<OPimContact> it( m_contactList ); 216 QListIterator<OPimContact> it( m_contactList );
219 uint arraycounter = 0; 217 uint arraycounter = 0;
220 218
221 for( ; it.current(); ++it ){ 219 for( ; it.current(); ++it ){
222 /* Search all fields and compare them with query object. Store them into list 220 /* Search all fields and compare them with query object. Store them into list
223 * if all fields matches. 221 * if all fields matches.
224 */ 222 */
225 QDate* queryDate = 0l; 223 QDate* queryDate = 0l;
226 QDate* checkDate = 0l; 224 QDate* checkDate = 0l;
227 bool allcorrect = true; 225 bool allcorrect = true;
228 for ( int i = 0; i < Qtopia::Groups; i++ ) { 226 for ( int i = 0; i < Qtopia::Groups; i++ ) {
229 // Birthday and anniversary are special nonstring fields and should 227 // Birthday and anniversary are special nonstring fields and should
230 // be handled specially 228 // be handled specially
231 switch ( i ){ 229 switch ( i ){
232 case Qtopia::Birthday: 230 case Qtopia::Birthday:
233 queryDate = new QDate( query.birthday() ); 231 queryDate = new QDate( query.birthday() );
234 checkDate = new QDate( (*it)->birthday() ); 232 checkDate = new QDate( (*it)->birthday() );
235 case Qtopia::Anniversary: 233 case Qtopia::Anniversary:
236 if ( queryDate == 0l ){ 234 if ( queryDate == 0l ){
237 queryDate = new QDate( query.anniversary() ); 235 queryDate = new QDate( query.anniversary() );
238 checkDate = new QDate( (*it)->anniversary() ); 236 checkDate = new QDate( (*it)->anniversary() );
239 } 237 }
240 238
241 if ( queryDate->isValid() ){ 239 if ( queryDate->isValid() ){
242 if( checkDate->isValid() ){ 240 if( checkDate->isValid() ){
243 if ( settings & OPimContactAccess::DateYear ){ 241 if ( settings & OPimContactAccess::DateYear ){
244 if ( queryDate->year() != checkDate->year() ) 242 if ( queryDate->year() != checkDate->year() )
245 allcorrect = false; 243 allcorrect = false;
246 } 244 }
247 if ( settings & OPimContactAccess::DateMonth ){ 245 if ( settings & OPimContactAccess::DateMonth ){
248 if ( queryDate->month() != checkDate->month() ) 246 if ( queryDate->month() != checkDate->month() )
249 allcorrect = false; 247 allcorrect = false;
250 } 248 }
251 if ( settings & OPimContactAccess::DateDay ){ 249 if ( settings & OPimContactAccess::DateDay ){
252 if ( queryDate->day() != checkDate->day() ) 250 if ( queryDate->day() != checkDate->day() )
253 allcorrect = false; 251 allcorrect = false;
254 } 252 }
255 if ( settings & OPimContactAccess::DateDiff ) { 253 if ( settings & OPimContactAccess::DateDiff ) {
256 QDate current; 254 QDate current;
257 // If we get an additional date, we 255 // If we get an additional date, we
258 // will take this date instead of 256 // will take this date instead of
259 // the current one.. 257 // the current one..
260 if ( !d.date().isValid() ) 258 if ( !d.date().isValid() )
261 current = QDate::currentDate(); 259 current = QDate::currentDate();
262 else 260 else
263 current = d.date(); 261 current = d.date();
264 262
265 // We have to equalize the year, otherwise 263 // We have to equalize the year, otherwise
266 // the search will fail.. 264 // the search will fail..
267 checkDate->setYMD( current.year(), 265 checkDate->setYMD( current.year(),
268 checkDate->month(), 266 checkDate->month(),
269 checkDate->day() ); 267 checkDate->day() );
270 if ( *checkDate < current ) 268 if ( *checkDate < current )
271 checkDate->setYMD( current.year()+1, 269 checkDate->setYMD( current.year()+1,
272 checkDate->month(), 270 checkDate->month(),
273 checkDate->day() ); 271 checkDate->day() );
274 272
275 // Check whether the birthday/anniversary date is between 273 // Check whether the birthday/anniversary date is between
276 // the current/given date and the maximum date 274 // the current/given date and the maximum date
277 // ( maximum time range ) ! 275 // ( maximum time range ) !
278 qWarning("Checking if %s is between %s and %s ! ", 276 qWarning("Checking if %s is between %s and %s ! ",
279 checkDate->toString().latin1(), 277 checkDate->toString().latin1(),
280 current.toString().latin1(), 278 current.toString().latin1(),
281 queryDate->toString().latin1() ); 279 queryDate->toString().latin1() );
282 if ( current.daysTo( *queryDate ) >= 0 ){ 280 if ( current.daysTo( *queryDate ) >= 0 ){
283 if ( !( ( *checkDate >= current ) && 281 if ( !( ( *checkDate >= current ) &&
284 ( *checkDate <= *queryDate ) ) ){ 282 ( *checkDate <= *queryDate ) ) ){
285 allcorrect = false; 283 allcorrect = false;
286 qWarning (" Nope!.."); 284 qWarning (" Nope!..");
287 } 285 }
288 } 286 }
289 } 287 }
290 } else{ 288 } else{
291 // checkDate is invalid. Therefore this entry is always rejected 289 // checkDate is invalid. Therefore this entry is always rejected
292 allcorrect = false; 290 allcorrect = false;
293 } 291 }
294 } 292 }
295 293
296 delete queryDate; 294 delete queryDate;
297 queryDate = 0l; 295 queryDate = 0l;
298 delete checkDate; 296 delete checkDate;
299 checkDate = 0l; 297 checkDate = 0l;
300 break; 298 break;
301 default: 299 default:
302 /* Just compare fields which are not empty in the query object */ 300 /* Just compare fields which are not empty in the query object */
303 if ( !query.field(i).isEmpty() ){ 301 if ( !query.field(i).isEmpty() ){
304 switch ( settings & ~( OPimContactAccess::IgnoreCase 302 switch ( settings & ~( OPimContactAccess::IgnoreCase
305 | OPimContactAccess::DateDiff 303 | OPimContactAccess::DateDiff
306 | OPimContactAccess::DateYear 304 | OPimContactAccess::DateYear
307 | OPimContactAccess::DateMonth 305 | OPimContactAccess::DateMonth
308 | OPimContactAccess::DateDay 306 | OPimContactAccess::DateDay
309 | OPimContactAccess::MatchOne 307 | OPimContactAccess::MatchOne
310 ) ){ 308 ) ){
311 309
312 case OPimContactAccess::RegExp:{ 310 case OPimContactAccess::RegExp:{
313 QRegExp expr ( query.field(i), 311 QRegExp expr ( query.field(i),
314 !(settings & OPimContactAccess::IgnoreCase), 312 !(settings & OPimContactAccess::IgnoreCase),
315 false ); 313 false );
316 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 314 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
317 allcorrect = false; 315 allcorrect = false;
318 } 316 }
319 break; 317 break;
320 case OPimContactAccess::WildCards:{ 318 case OPimContactAccess::WildCards:{
321 QRegExp expr ( query.field(i), 319 QRegExp expr ( query.field(i),
322 !(settings & OPimContactAccess::IgnoreCase), 320 !(settings & OPimContactAccess::IgnoreCase),
323 true ); 321 true );
324 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 322 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
325 allcorrect = false; 323 allcorrect = false;
326 } 324 }
327 break; 325 break;
328 case OPimContactAccess::ExactMatch:{ 326 case OPimContactAccess::ExactMatch:{
329 if (settings & OPimContactAccess::IgnoreCase){ 327 if (settings & OPimContactAccess::IgnoreCase){
330 if ( query.field(i).upper() != 328 if ( query.field(i).upper() !=
331 (*it)->field(i).upper() ) 329 (*it)->field(i).upper() )
332 allcorrect = false; 330 allcorrect = false;
333 }else{ 331 }else{
334 if ( query.field(i) != (*it)->field(i) ) 332 if ( query.field(i) != (*it)->field(i) )
335 allcorrect = false; 333 allcorrect = false;
336 } 334 }
337 } 335 }
338 break; 336 break;
339 } 337 }
340 } 338 }
341 } 339 }
342 } 340 }
343 if ( allcorrect ){ 341 if ( allcorrect ){
344 m_currentQuery[arraycounter++] = (*it)->uid(); 342 m_currentQuery[arraycounter++] = (*it)->uid();
345 } 343 }
346 } 344 }
347 345
348 // Shrink to fit.. 346 // Shrink to fit..
349 m_currentQuery.resize(arraycounter); 347 m_currentQuery.resize(arraycounter);
350 348
351 return m_currentQuery; 349 return m_currentQuery;
352} 350}
353 351
354QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const 352QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
355{ 353{
356 QArray<int> m_currentQuery( m_contactList.count() ); 354 QArray<int> m_currentQuery( m_contactList.count() );
357 QListIterator<OPimContact> it( m_contactList ); 355 QListIterator<OPimContact> it( m_contactList );
358 uint arraycounter = 0; 356 uint arraycounter = 0;
359 357
360 for( ; it.current(); ++it ){ 358 for( ; it.current(); ++it ){
361 if ( (*it)->match( r ) ){ 359 if ( (*it)->match( r ) ){
362 m_currentQuery[arraycounter++] = (*it)->uid(); 360 m_currentQuery[arraycounter++] = (*it)->uid();
363 } 361 }
364 362
365 } 363 }
366 // Shrink to fit.. 364 // Shrink to fit..
367 m_currentQuery.resize(arraycounter); 365 m_currentQuery.resize(arraycounter);
368 366
369 return m_currentQuery; 367 return m_currentQuery;
370} 368}
371 369
372const uint OPimContactAccessBackend_XML::querySettings() 370const uint OPimContactAccessBackend_XML::querySettings()
373{ 371{
374 return ( OPimContactAccess::WildCards 372 return ( OPimContactAccess::WildCards
375 | OPimContactAccess::IgnoreCase 373 | OPimContactAccess::IgnoreCase
376 | OPimContactAccess::RegExp 374 | OPimContactAccess::RegExp
377 | OPimContactAccess::ExactMatch 375 | OPimContactAccess::ExactMatch
378 | OPimContactAccess::DateDiff 376 | OPimContactAccess::DateDiff
379 | OPimContactAccess::DateYear 377 | OPimContactAccess::DateYear
380 | OPimContactAccess::DateMonth 378 | OPimContactAccess::DateMonth
381 | OPimContactAccess::DateDay 379 | OPimContactAccess::DateDay
382 ); 380 );
383} 381}
384 382
385bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const 383bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
386{ 384{
387 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 385 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
388 * may be added with any of the other settings. IgnoreCase should never used alone. 386 * may be added with any of the other settings. IgnoreCase should never used alone.
389 * Wildcards, RegExp, ExactMatch should never used at the same time... 387 * Wildcards, RegExp, ExactMatch should never used at the same time...
390 */ 388 */
391 389
392 // Step 1: Check whether the given settings are supported by this backend 390 // Step 1: Check whether the given settings are supported by this backend
393 if ( ( querySettings & ( 391 if ( ( querySettings & (
394 OPimContactAccess::IgnoreCase 392 OPimContactAccess::IgnoreCase
395 | OPimContactAccess::WildCards 393 | OPimContactAccess::WildCards
396 | OPimContactAccess::DateDiff 394 | OPimContactAccess::DateDiff
397 | OPimContactAccess::DateYear 395 | OPimContactAccess::DateYear
398 | OPimContactAccess::DateMonth 396 | OPimContactAccess::DateMonth
399 | OPimContactAccess::DateDay 397 | OPimContactAccess::DateDay
400 | OPimContactAccess::RegExp 398 | OPimContactAccess::RegExp
401 | OPimContactAccess::ExactMatch 399 | OPimContactAccess::ExactMatch
402 ) ) != querySettings ) 400 ) ) != querySettings )
403 return false; 401 return false;
404 402
405 // Step 2: Check whether the given combinations are ok.. 403 // Step 2: Check whether the given combinations are ok..
406 404
407 // IngoreCase alone is invalid 405 // IngoreCase alone is invalid
408 if ( querySettings == OPimContactAccess::IgnoreCase ) 406 if ( querySettings == OPimContactAccess::IgnoreCase )
409 return false; 407 return false;
410 408
411 // WildCards, RegExp and ExactMatch should never used at the same time 409 // WildCards, RegExp and ExactMatch should never used at the same time
412 switch ( querySettings & ~( OPimContactAccess::IgnoreCase 410 switch ( querySettings & ~( OPimContactAccess::IgnoreCase
413 | OPimContactAccess::DateDiff 411 | OPimContactAccess::DateDiff
414 | OPimContactAccess::DateYear 412 | OPimContactAccess::DateYear
415 | OPimContactAccess::DateMonth 413 | OPimContactAccess::DateMonth
416 | OPimContactAccess::DateDay 414 | OPimContactAccess::DateDay
417 ) 415 )
418 ){ 416 ){
419 case OPimContactAccess::RegExp: 417 case OPimContactAccess::RegExp:
420 return ( true ); 418 return ( true );
421 case OPimContactAccess::WildCards: 419 case OPimContactAccess::WildCards:
422 return ( true ); 420 return ( true );
423 case OPimContactAccess::ExactMatch: 421 case OPimContactAccess::ExactMatch:
424 return ( true ); 422 return ( true );
425 case 0: // one of the upper removed bits were set.. 423 case 0: // one of the upper removed bits were set..
426 return ( true ); 424 return ( true );
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index a5df597..4a774e8 100644
--- a/libopie2/opiepim/core/opimcontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -1,430 +1,426 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#define QTOPIA_INTERNAL_CONTACT_MRE 30#define QTOPIA_INTERNAL_CONTACT_MRE
31 31
32#include "opimcontact.h" 32#include "opimcontact.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/opimresolver.h> 35#include <opie2/opimresolver.h>
36#include <opie2/opimdateconversion.h> 36#include <opie2/opimdateconversion.h>
37#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
38#include <qpe/timestring.h> 38#include <qpe/timestring.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41/* QT */ 41/* QT */
42#include <qobject.h>
43#include <qregexp.h>
44#include <qstylesheet.h> 42#include <qstylesheet.h>
45#include <qfileinfo.h>
46#include <qmap.h>
47 43
48/* STD */ 44/* STD */
49#include <stdio.h> 45#include <stdio.h>
50 46
51/*! 47/*!
52 \class Contact contact.h 48 \class Contact contact.h
53 \brief The Contact class holds the data of an address book entry. 49 \brief The Contact class holds the data of an address book entry.
54 50
55 This data includes information the name of the person, contact 51 This data includes information the name of the person, contact
56 information, and business information such as deparment and job title. 52 information, and business information such as deparment and job title.
57 53
58 \ingroup qtopiaemb 54 \ingroup qtopiaemb
59 \ingroup qtopiadesktop 55 \ingroup qtopiadesktop
60*/ 56*/
61 57
62 58
63namespace Opie 59namespace Opie
64{ 60{
65/*! 61/*!
66 Creates a new, empty contact. 62 Creates a new, empty contact.
67*/ 63*/
68OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) 64OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 )
69{} 65{}
70 66
71/*! 67/*!
72 \internal 68 \internal
73 Creates a new contact. The properties of the contact are 69 Creates a new contact. The properties of the contact are
74 set from \a fromMap. 70 set from \a fromMap.
75*/ 71*/
76OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) 72OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
77{ 73{
78 QString cats = mMap[ Qtopia::AddressCategory ]; 74 QString cats = mMap[ Qtopia::AddressCategory ];
79 if ( !cats.isEmpty() ) 75 if ( !cats.isEmpty() )
80 setCategories( idsFromString( cats ) ); 76 setCategories( idsFromString( cats ) );
81 77
82 QString uidStr = find( Qtopia::AddressUid ); 78 QString uidStr = find( Qtopia::AddressUid );
83 79
84 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) 80 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
85 { 81 {
86 qWarning( "Invalid UID found. Generate new one.." ); 82 qWarning( "Invalid UID found. Generate new one.." );
87 setUid( uidGen().generate() ); 83 setUid( uidGen().generate() );
88 } 84 }
89 else 85 else
90 setUid( uidStr.toInt() ); 86 setUid( uidStr.toInt() );
91 87
92 // if ( !uidStr.isEmpty() ) 88 // if ( !uidStr.isEmpty() )
93 // setUid( uidStr.toInt() ); 89 // setUid( uidStr.toInt() );
94} 90}
95 91
96/*! 92/*!
97 Destroys a contact. 93 Destroys a contact.
98*/ 94*/
99OPimContact::~OPimContact() 95OPimContact::~OPimContact()
100{} 96{}
101 97
102/*! \fn void OPimContact::setTitle( const QString &str ) 98/*! \fn void OPimContact::setTitle( const QString &str )
103 Sets the title of the contact to \a str. 99 Sets the title of the contact to \a str.
104*/ 100*/
105 101
106/*! \fn void OPimContact::setFirstName( const QString &str ) 102/*! \fn void OPimContact::setFirstName( const QString &str )
107 Sets the first name of the contact to \a str. 103 Sets the first name of the contact to \a str.
108*/ 104*/
109 105
110/*! \fn void OPimContact::setMiddleName( const QString &str ) 106/*! \fn void OPimContact::setMiddleName( const QString &str )
111 Sets the middle name of the contact to \a str. 107 Sets the middle name of the contact to \a str.
112*/ 108*/
113 109
114/*! \fn void OPimContact::setLastName( const QString &str ) 110/*! \fn void OPimContact::setLastName( const QString &str )
115 Sets the last name of the contact to \a str. 111 Sets the last name of the contact to \a str.
116*/ 112*/
117 113
118/*! \fn void OPimContact::setSuffix( const QString &str ) 114/*! \fn void OPimContact::setSuffix( const QString &str )
119 Sets the suffix of the contact to \a str. 115 Sets the suffix of the contact to \a str.
120*/ 116*/
121 117
122/*! \fn void OPimContact::setFileAs( const QString &str ) 118/*! \fn void OPimContact::setFileAs( const QString &str )
123 Sets the contact to filed as \a str. 119 Sets the contact to filed as \a str.
124*/ 120*/
125 121
126/*! \fn void OPimContact::setDefaultEmail( const QString &str ) 122/*! \fn void OPimContact::setDefaultEmail( const QString &str )
127 Sets the default email of the contact to \a str. 123 Sets the default email of the contact to \a str.
128*/ 124*/
129 125
130/*! \fn void OPimContact::setHomeStreet( const QString &str ) 126/*! \fn void OPimContact::setHomeStreet( const QString &str )
131 Sets the home street address of the contact to \a str. 127 Sets the home street address of the contact to \a str.
132*/ 128*/
133 129
134/*! \fn void OPimContact::setHomeCity( const QString &str ) 130/*! \fn void OPimContact::setHomeCity( const QString &str )
135 Sets the home city of the contact to \a str. 131 Sets the home city of the contact to \a str.
136*/ 132*/
137 133
138/*! \fn void OPimContact::setHomeState( const QString &str ) 134/*! \fn void OPimContact::setHomeState( const QString &str )
139 Sets the home state of the contact to \a str. 135 Sets the home state of the contact to \a str.
140*/ 136*/
141 137
142/*! \fn void OPimContact::setHomeZip( const QString &str ) 138/*! \fn void OPimContact::setHomeZip( const QString &str )
143 Sets the home zip code of the contact to \a str. 139 Sets the home zip code of the contact to \a str.
144*/ 140*/
145 141
146/*! \fn void OPimContact::setHomeCountry( const QString &str ) 142/*! \fn void OPimContact::setHomeCountry( const QString &str )
147 Sets the home country of the contact to \a str. 143 Sets the home country of the contact to \a str.
148*/ 144*/
149 145
150/*! \fn void OPimContact::setHomePhone( const QString &str ) 146/*! \fn void OPimContact::setHomePhone( const QString &str )
151 Sets the home phone number of the contact to \a str. 147 Sets the home phone number of the contact to \a str.
152*/ 148*/
153 149
154/*! \fn void OPimContact::setHomeFax( const QString &str ) 150/*! \fn void OPimContact::setHomeFax( const QString &str )
155 Sets the home fax number of the contact to \a str. 151 Sets the home fax number of the contact to \a str.
156*/ 152*/
157 153
158/*! \fn void OPimContact::setHomeMobile( const QString &str ) 154/*! \fn void OPimContact::setHomeMobile( const QString &str )
159 Sets the home mobile phone number of the contact to \a str. 155 Sets the home mobile phone number of the contact to \a str.
160*/ 156*/
161 157
162/*! \fn void OPimContact::setHomeWebpage( const QString &str ) 158/*! \fn void OPimContact::setHomeWebpage( const QString &str )
163 Sets the home webpage of the contact to \a str. 159 Sets the home webpage of the contact to \a str.
164*/ 160*/
165 161
166/*! \fn void OPimContact::setCompany( const QString &str ) 162/*! \fn void OPimContact::setCompany( const QString &str )
167 Sets the company for contact to \a str. 163 Sets the company for contact to \a str.
168*/ 164*/
169 165
170/*! \fn void OPimContact::setJobTitle( const QString &str ) 166/*! \fn void OPimContact::setJobTitle( const QString &str )
171 Sets the job title of the contact to \a str. 167 Sets the job title of the contact to \a str.
172*/ 168*/
173 169
174/*! \fn void OPimContact::setDepartment( const QString &str ) 170/*! \fn void OPimContact::setDepartment( const QString &str )
175 Sets the department for contact to \a str. 171 Sets the department for contact to \a str.
176*/ 172*/
177 173
178/*! \fn void OPimContact::setOffice( const QString &str ) 174/*! \fn void OPimContact::setOffice( const QString &str )
179 Sets the office for contact to \a str. 175 Sets the office for contact to \a str.
180*/ 176*/
181 177
182/*! \fn void OPimContact::setBusinessStreet( const QString &str ) 178/*! \fn void OPimContact::setBusinessStreet( const QString &str )
183 Sets the business street address of the contact to \a str. 179 Sets the business street address of the contact to \a str.
184*/ 180*/
185 181
186/*! \fn void OPimContact::setBusinessCity( const QString &str ) 182/*! \fn void OPimContact::setBusinessCity( const QString &str )
187 Sets the business city of the contact to \a str. 183 Sets the business city of the contact to \a str.
188*/ 184*/
189 185
190/*! \fn void OPimContact::setBusinessState( const QString &str ) 186/*! \fn void OPimContact::setBusinessState( const QString &str )
191 Sets the business state of the contact to \a str. 187 Sets the business state of the contact to \a str.
192*/ 188*/
193 189
194/*! \fn void OPimContact::setBusinessZip( const QString &str ) 190/*! \fn void OPimContact::setBusinessZip( const QString &str )
195 Sets the business zip code of the contact to \a str. 191 Sets the business zip code of the contact to \a str.
196*/ 192*/
197 193
198/*! \fn void OPimContact::setBusinessCountry( const QString &str ) 194/*! \fn void OPimContact::setBusinessCountry( const QString &str )
199 Sets the business country of the contact to \a str. 195 Sets the business country of the contact to \a str.
200*/ 196*/
201 197
202/*! \fn void OPimContact::setBusinessPhone( const QString &str ) 198/*! \fn void OPimContact::setBusinessPhone( const QString &str )
203 Sets the business phone number of the contact to \a str. 199 Sets the business phone number of the contact to \a str.
204*/ 200*/
205 201
206/*! \fn void OPimContact::setBusinessFax( const QString &str ) 202/*! \fn void OPimContact::setBusinessFax( const QString &str )
207 Sets the business fax number of the contact to \a str. 203 Sets the business fax number of the contact to \a str.
208*/ 204*/
209 205
210/*! \fn void OPimContact::setBusinessMobile( const QString &str ) 206/*! \fn void OPimContact::setBusinessMobile( const QString &str )
211 Sets the business mobile phone number of the contact to \a str. 207 Sets the business mobile phone number of the contact to \a str.
212*/ 208*/
213 209
214/*! \fn void OPimContact::setBusinessPager( const QString &str ) 210/*! \fn void OPimContact::setBusinessPager( const QString &str )
215 Sets the business pager number of the contact to \a str. 211 Sets the business pager number of the contact to \a str.
216*/ 212*/
217 213
218/*! \fn void OPimContact::setBusinessWebpage( const QString &str ) 214/*! \fn void OPimContact::setBusinessWebpage( const QString &str )
219 Sets the business webpage of the contact to \a str. 215 Sets the business webpage of the contact to \a str.
220*/ 216*/
221 217
222/*! \fn void OPimContact::setProfession( const QString &str ) 218/*! \fn void OPimContact::setProfession( const QString &str )
223 Sets the profession of the contact to \a str. 219 Sets the profession of the contact to \a str.
224*/ 220*/
225 221
226/*! \fn void OPimContact::setAssistant( const QString &str ) 222/*! \fn void OPimContact::setAssistant( const QString &str )
227 Sets the assistant of the contact to \a str. 223 Sets the assistant of the contact to \a str.
228*/ 224*/
229 225
230/*! \fn void OPimContact::setManager( const QString &str ) 226/*! \fn void OPimContact::setManager( const QString &str )
231 Sets the manager of the contact to \a str. 227 Sets the manager of the contact to \a str.
232*/ 228*/
233 229
234/*! \fn void OPimContact::setSpouse( const QString &str ) 230/*! \fn void OPimContact::setSpouse( const QString &str )
235 Sets the spouse of the contact to \a str. 231 Sets the spouse of the contact to \a str.
236*/ 232*/
237 233
238/*! \fn void OPimContact::setGender( const QString &str ) 234/*! \fn void OPimContact::setGender( const QString &str )
239 Sets the gender of the contact to \a str. 235 Sets the gender of the contact to \a str.
240*/ 236*/
241 237
242/*! \fn void OPimContact::setNickname( const QString &str ) 238/*! \fn void OPimContact::setNickname( const QString &str )
243 Sets the nickname of the contact to \a str. 239 Sets the nickname of the contact to \a str.
244*/ 240*/
245 241
246/*! \fn void OPimContact::setNotes( const QString &str ) 242/*! \fn void OPimContact::setNotes( const QString &str )
247 Sets the notes about the contact to \a str. 243 Sets the notes about the contact to \a str.
248*/ 244*/
249 245
250/*! \fn QString OPimContact::title() const 246/*! \fn QString OPimContact::title() const
251 Returns the title of the contact. 247 Returns the title of the contact.
252*/ 248*/
253 249
254/*! \fn QString OPimContact::firstName() const 250/*! \fn QString OPimContact::firstName() const
255 Returns the first name of the contact. 251 Returns the first name of the contact.
256*/ 252*/
257 253
258/*! \fn QString OPimContact::middleName() const 254/*! \fn QString OPimContact::middleName() const
259 Returns the middle name of the contact. 255 Returns the middle name of the contact.
260*/ 256*/
261 257
262/*! \fn QString OPimContact::lastName() const 258/*! \fn QString OPimContact::lastName() const
263 Returns the last name of the contact. 259 Returns the last name of the contact.
264*/ 260*/
265 261
266/*! \fn QString OPimContact::suffix() const 262/*! \fn QString OPimContact::suffix() const
267 Returns the suffix of the contact. 263 Returns the suffix of the contact.
268*/ 264*/
269 265
270/*! \fn QString OPimContact::fileAs() const 266/*! \fn QString OPimContact::fileAs() const
271 Returns the string the contact is filed as. 267 Returns the string the contact is filed as.
272*/ 268*/
273 269
274/*! \fn QString OPimContact::defaultEmail() const 270/*! \fn QString OPimContact::defaultEmail() const
275 Returns the default email address of the contact. 271 Returns the default email address of the contact.
276*/ 272*/
277 273
278/*! \fn QString OPimContact::emails() const 274/*! \fn QString OPimContact::emails() const
279 Returns the list of email address for a contact separated by ';'s in a single 275 Returns the list of email address for a contact separated by ';'s in a single
280 string. 276 string.
281*/ 277*/
282 278
283/*! \fn QString OPimContact::homeStreet() const 279/*! \fn QString OPimContact::homeStreet() const
284 Returns the home street address of the contact. 280 Returns the home street address of the contact.
285*/ 281*/
286 282
287/*! \fn QString OPimContact::homeCity() const 283/*! \fn QString OPimContact::homeCity() const
288 Returns the home city of the contact. 284 Returns the home city of the contact.
289*/ 285*/
290 286
291/*! \fn QString OPimContact::homeState() const 287/*! \fn QString OPimContact::homeState() const
292 Returns the home state of the contact. 288 Returns the home state of the contact.
293*/ 289*/
294 290
295/*! \fn QString OPimContact::homeZip() const 291/*! \fn QString OPimContact::homeZip() const
296 Returns the home zip of the contact. 292 Returns the home zip of the contact.
297*/ 293*/
298 294
299/*! \fn QString OPimContact::homeCountry() const 295/*! \fn QString OPimContact::homeCountry() const
300 Returns the home country of the contact. 296 Returns the home country of the contact.
301*/ 297*/
302 298
303/*! \fn QString OPimContact::homePhone() const 299/*! \fn QString OPimContact::homePhone() const
304 Returns the home phone number of the contact. 300 Returns the home phone number of the contact.
305*/ 301*/
306 302
307/*! \fn QString OPimContact::homeFax() const 303/*! \fn QString OPimContact::homeFax() const
308 Returns the home fax number of the contact. 304 Returns the home fax number of the contact.
309*/ 305*/
310 306
311/*! \fn QString OPimContact::homeMobile() const 307/*! \fn QString OPimContact::homeMobile() const
312 Returns the home mobile number of the contact. 308 Returns the home mobile number of the contact.
313*/ 309*/
314 310
315/*! \fn QString OPimContact::homeWebpage() const 311/*! \fn QString OPimContact::homeWebpage() const
316 Returns the home webpage of the contact. 312 Returns the home webpage of the contact.
317*/ 313*/
318 314
319/*! \fn QString OPimContact::company() const 315/*! \fn QString OPimContact::company() const
320 Returns the company for the contact. 316 Returns the company for the contact.
321*/ 317*/
322 318
323/*! \fn QString OPimContact::department() const 319/*! \fn QString OPimContact::department() const
324 Returns the department for the contact. 320 Returns the department for the contact.
325*/ 321*/
326 322
327/*! \fn QString OPimContact::office() const 323/*! \fn QString OPimContact::office() const
328 Returns the office for the contact. 324 Returns the office for the contact.
329*/ 325*/
330 326
331/*! \fn QString OPimContact::jobTitle() const 327/*! \fn QString OPimContact::jobTitle() const
332 Returns the job title of the contact. 328 Returns the job title of the contact.
333*/ 329*/
334 330
335/*! \fn QString OPimContact::profession() const 331/*! \fn QString OPimContact::profession() const
336 Returns the profession of the contact. 332 Returns the profession of the contact.
337*/ 333*/
338 334
339/*! \fn QString OPimContact::assistant() const 335/*! \fn QString OPimContact::assistant() const
340 Returns the assistant of the contact. 336 Returns the assistant of the contact.
341*/ 337*/
342 338
343/*! \fn QString OPimContact::manager() const 339/*! \fn QString OPimContact::manager() const
344 Returns the manager of the contact. 340 Returns the manager of the contact.
345*/ 341*/
346 342
347/*! \fn QString OPimContact::businessStreet() const 343/*! \fn QString OPimContact::businessStreet() const
348 Returns the business street address of the contact. 344 Returns the business street address of the contact.
349*/ 345*/
350 346
351/*! \fn QString OPimContact::businessCity() const 347/*! \fn QString OPimContact::businessCity() const
352 Returns the business city of the contact. 348 Returns the business city of the contact.
353*/ 349*/
354 350
355/*! \fn QString OPimContact::businessState() const 351/*! \fn QString OPimContact::businessState() const
356 Returns the business state of the contact. 352 Returns the business state of the contact.
357*/ 353*/
358 354
359/*! \fn QString OPimContact::businessZip() const 355/*! \fn QString OPimContact::businessZip() const
360 Returns the business zip of the contact. 356 Returns the business zip of the contact.
361*/ 357*/
362 358
363/*! \fn QString OPimContact::businessCountry() const 359/*! \fn QString OPimContact::businessCountry() const
364 Returns the business country of the contact. 360 Returns the business country of the contact.
365*/ 361*/
366 362
367/*! \fn QString OPimContact::businessPhone() const 363/*! \fn QString OPimContact::businessPhone() const
368 Returns the business phone number of the contact. 364 Returns the business phone number of the contact.
369*/ 365*/
370 366
371/*! \fn QString OPimContact::businessFax() const 367/*! \fn QString OPimContact::businessFax() const
372 Returns the business fax number of the contact. 368 Returns the business fax number of the contact.
373*/ 369*/
374 370
375/*! \fn QString OPimContact::businessMobile() const 371/*! \fn QString OPimContact::businessMobile() const
376 Returns the business mobile number of the contact. 372 Returns the business mobile number of the contact.
377*/ 373*/
378 374
379/*! \fn QString OPimContact::businessPager() const 375/*! \fn QString OPimContact::businessPager() const
380 Returns the business pager number of the contact. 376 Returns the business pager number of the contact.
381*/ 377*/
382 378
383/*! \fn QString OPimContact::businessWebpage() const 379/*! \fn QString OPimContact::businessWebpage() const
384 Returns the business webpage of the contact. 380 Returns the business webpage of the contact.
385*/ 381*/
386 382
387/*! \fn QString OPimContact::spouse() const 383/*! \fn QString OPimContact::spouse() const
388 Returns the spouse of the contact. 384 Returns the spouse of the contact.
389*/ 385*/
390 386
391/*! \fn QString OPimContact::gender() const 387/*! \fn QString OPimContact::gender() const
392 Returns the gender of the contact. 388 Returns the gender of the contact.
393*/ 389*/
394 390
395/*! \fn QString OPimContact::nickname() const 391/*! \fn QString OPimContact::nickname() const
396 Returns the nickname of the contact. 392 Returns the nickname of the contact.
397*/ 393*/
398 394
399/*! \fn QString OPimContact::children() const 395/*! \fn QString OPimContact::children() const
400 Returns the children of the contact. 396 Returns the children of the contact.
401*/ 397*/
402 398
403/*! \fn QString OPimContact::notes() const 399/*! \fn QString OPimContact::notes() const
404 Returns the notes relating to the the contact. 400 Returns the notes relating to the the contact.
405*/ 401*/
406 402
407/*! \fn QString OPimContact::groups() const 403/*! \fn QString OPimContact::groups() const
408 \internal 404 \internal
409 Returns the groups for the contact. 405 Returns the groups for the contact.
410*/ 406*/
411 407
412/*! \fn QStringList OPimContact::groupList() const 408/*! \fn QStringList OPimContact::groupList() const
413 \internal 409 \internal
414*/ 410*/
415 411
416/*! \fn QString OPimContact::field(int) const 412/*! \fn QString OPimContact::field(int) const
417 \internal 413 \internal
418*/ 414*/
419 415
420/*! \fn void OPimContact::saveJournal( journal_action, const QString & = QString::null ) 416/*! \fn void OPimContact::saveJournal( journal_action, const QString & = QString::null )
421 \internal 417 \internal
422*/ 418*/
423 419
424/*! \fn void OPimContact::setUid( int id ) 420/*! \fn void OPimContact::setUid( int id )
425 \internal 421 \internal
426 Sets the uid for this record to \a id. 422 Sets the uid for this record to \a id.
427*/ 423*/
428 424
429/*! \enum OPimContact::journal_action 425/*! \enum OPimContact::journal_action
430 \internal 426 \internal
diff --git a/libopie2/opiepim/core/opimcontactfields.cpp b/libopie2/opiepim/core/opimcontactfields.cpp
index 4b0ba3b..120beb6 100644
--- a/libopie2/opiepim/core/opimcontactfields.cpp
+++ b/libopie2/opiepim/core/opimcontactfields.cpp
@@ -1,423 +1,421 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimcontactfields.h" 30#include "opimcontactfields.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimcontact.h> 33#include <opie2/opimcontact.h>
34#include <qpe/recordfields.h> // We should use our own enum in the future ..
35#include <qpe/config.h> 34#include <qpe/config.h>
36 35
37/* QT */ 36/* QT */
38#include <qobject.h> 37#include <qobject.h>
39#include <qstringlist.h>
40 38
41 39
42namespace Opie 40namespace Opie
43{ 41{
44/*! 42/*!
45 \internal 43 \internal
46 Returns a list of personal field names for a contact. 44 Returns a list of personal field names for a contact.
47*/ 45*/
48QStringList OPimContactFields::personalfields( bool sorted, bool translated ) 46QStringList OPimContactFields::personalfields( bool sorted, bool translated )
49{ 47{
50 QStringList list; 48 QStringList list;
51 QMap<int, QString> mapIdToStr; 49 QMap<int, QString> mapIdToStr;
52 if ( translated ) 50 if ( translated )
53 mapIdToStr = idToTrFields(); 51 mapIdToStr = idToTrFields();
54 else 52 else
55 mapIdToStr = idToUntrFields(); 53 mapIdToStr = idToUntrFields();
56 54
57 list.append( mapIdToStr[ Qtopia::AddressUid ] ); 55 list.append( mapIdToStr[ Qtopia::AddressUid ] );
58 list.append( mapIdToStr[ Qtopia::AddressCategory ] ); 56 list.append( mapIdToStr[ Qtopia::AddressCategory ] );
59 57
60 list.append( mapIdToStr[ Qtopia::Title ] ); 58 list.append( mapIdToStr[ Qtopia::Title ] );
61 list.append( mapIdToStr[ Qtopia::FirstName ] ); 59 list.append( mapIdToStr[ Qtopia::FirstName ] );
62 list.append( mapIdToStr[ Qtopia::MiddleName ] ); 60 list.append( mapIdToStr[ Qtopia::MiddleName ] );
63 list.append( mapIdToStr[ Qtopia::LastName ] ); 61 list.append( mapIdToStr[ Qtopia::LastName ] );
64 list.append( mapIdToStr[ Qtopia::Suffix ] ); 62 list.append( mapIdToStr[ Qtopia::Suffix ] );
65 list.append( mapIdToStr[ Qtopia::FileAs ] ); 63 list.append( mapIdToStr[ Qtopia::FileAs ] );
66 64
67 list.append( mapIdToStr[ Qtopia::JobTitle ] ); 65 list.append( mapIdToStr[ Qtopia::JobTitle ] );
68 list.append( mapIdToStr[ Qtopia::Department ] ); 66 list.append( mapIdToStr[ Qtopia::Department ] );
69 list.append( mapIdToStr[ Qtopia::Company ] ); 67 list.append( mapIdToStr[ Qtopia::Company ] );
70 68
71 list.append( mapIdToStr[ Qtopia::Notes ] ); 69 list.append( mapIdToStr[ Qtopia::Notes ] );
72 list.append( mapIdToStr[ Qtopia::Groups ] ); 70 list.append( mapIdToStr[ Qtopia::Groups ] );
73 71
74 if ( sorted ) list.sort(); 72 if ( sorted ) list.sort();
75 return list; 73 return list;
76} 74}
77 75
78/*! 76/*!
79 \internal 77 \internal
80 Returns a list of details field names for a contact. 78 Returns a list of details field names for a contact.
81*/ 79*/
82QStringList OPimContactFields::detailsfields( bool sorted, bool translated ) 80QStringList OPimContactFields::detailsfields( bool sorted, bool translated )
83{ 81{
84 QStringList list; 82 QStringList list;
85 QMap<int, QString> mapIdToStr; 83 QMap<int, QString> mapIdToStr;
86 if ( translated ) 84 if ( translated )
87 mapIdToStr = idToTrFields(); 85 mapIdToStr = idToTrFields();
88 else 86 else
89 mapIdToStr = idToUntrFields(); 87 mapIdToStr = idToUntrFields();
90 88
91 list.append( mapIdToStr[ Qtopia::Office ] ); 89 list.append( mapIdToStr[ Qtopia::Office ] );
92 list.append( mapIdToStr[ Qtopia::Profession ] ); 90 list.append( mapIdToStr[ Qtopia::Profession ] );
93 list.append( mapIdToStr[ Qtopia::Assistant ] ); 91 list.append( mapIdToStr[ Qtopia::Assistant ] );
94 list.append( mapIdToStr[ Qtopia::Manager ] ); 92 list.append( mapIdToStr[ Qtopia::Manager ] );
95 93
96 list.append( mapIdToStr[ Qtopia::Spouse ] ); 94 list.append( mapIdToStr[ Qtopia::Spouse ] );
97 list.append( mapIdToStr[ Qtopia::Gender ] ); 95 list.append( mapIdToStr[ Qtopia::Gender ] );
98 list.append( mapIdToStr[ Qtopia::Birthday ] ); 96 list.append( mapIdToStr[ Qtopia::Birthday ] );
99 list.append( mapIdToStr[ Qtopia::Anniversary ] ); 97 list.append( mapIdToStr[ Qtopia::Anniversary ] );
100 list.append( mapIdToStr[ Qtopia::Nickname ] ); 98 list.append( mapIdToStr[ Qtopia::Nickname ] );
101 list.append( mapIdToStr[ Qtopia::Children ] ); 99 list.append( mapIdToStr[ Qtopia::Children ] );
102 100
103 if ( sorted ) list.sort(); 101 if ( sorted ) list.sort();
104 return list; 102 return list;
105} 103}
106 104
107/*! 105/*!
108 \internal 106 \internal
109 Returns a list of phone field names for a contact. 107 Returns a list of phone field names for a contact.
110*/ 108*/
111QStringList OPimContactFields::phonefields( bool sorted, bool translated ) 109QStringList OPimContactFields::phonefields( bool sorted, bool translated )
112{ 110{
113 QStringList list; 111 QStringList list;
114 QMap<int, QString> mapIdToStr; 112 QMap<int, QString> mapIdToStr;
115 if ( translated ) 113 if ( translated )
116 mapIdToStr = idToTrFields(); 114 mapIdToStr = idToTrFields();
117 else 115 else
118 mapIdToStr = idToUntrFields(); 116 mapIdToStr = idToUntrFields();
119 117
120 list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); 118 list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
121 list.append( mapIdToStr[ Qtopia::BusinessFax ] ); 119 list.append( mapIdToStr[ Qtopia::BusinessFax ] );
122 list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); 120 list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
123 list.append( mapIdToStr[ Qtopia::BusinessPager ] ); 121 list.append( mapIdToStr[ Qtopia::BusinessPager ] );
124 list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); 122 list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
125 123
126 list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); 124 list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
127 list.append( mapIdToStr[ Qtopia::Emails ] ); 125 list.append( mapIdToStr[ Qtopia::Emails ] );
128 126
129 list.append( mapIdToStr[ Qtopia::HomePhone ] ); 127 list.append( mapIdToStr[ Qtopia::HomePhone ] );
130 list.append( mapIdToStr[ Qtopia::HomeFax ] ); 128 list.append( mapIdToStr[ Qtopia::HomeFax ] );
131 list.append( mapIdToStr[ Qtopia::HomeMobile ] ); 129 list.append( mapIdToStr[ Qtopia::HomeMobile ] );
132 // list.append( mapIdToStr[Qtopia::HomePager] ); 130 // list.append( mapIdToStr[Qtopia::HomePager] );
133 list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); 131 list.append( mapIdToStr[ Qtopia::HomeWebPage ] );
134 132
135 if ( sorted ) list.sort(); 133 if ( sorted ) list.sort();
136 134
137 return list; 135 return list;
138} 136}
139 137
140/*! 138/*!
141 \internal 139 \internal
142 Returns a list of field names for a contact. 140 Returns a list of field names for a contact.
143*/ 141*/
144QStringList OPimContactFields::fields( bool sorted, bool translated ) 142QStringList OPimContactFields::fields( bool sorted, bool translated )
145{ 143{
146 QStringList list; 144 QStringList list;
147 QMap<int, QString> mapIdToStr; 145 QMap<int, QString> mapIdToStr;
148 if ( translated ) 146 if ( translated )
149 mapIdToStr = idToTrFields(); 147 mapIdToStr = idToTrFields();
150 else 148 else
151 mapIdToStr = idToUntrFields(); 149 mapIdToStr = idToUntrFields();
152 150
153 list += personalfields( sorted, translated ); 151 list += personalfields( sorted, translated );
154 152
155 list += phonefields( sorted, translated ); 153 list += phonefields( sorted, translated );
156 154
157 list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); 155 list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
158 list.append( mapIdToStr[ Qtopia::BusinessCity ] ); 156 list.append( mapIdToStr[ Qtopia::BusinessCity ] );
159 list.append( mapIdToStr[ Qtopia::BusinessState ] ); 157 list.append( mapIdToStr[ Qtopia::BusinessState ] );
160 list.append( mapIdToStr[ Qtopia::BusinessZip ] ); 158 list.append( mapIdToStr[ Qtopia::BusinessZip ] );
161 list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); 159 list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
162 160
163 list.append( mapIdToStr[ Qtopia::HomeStreet ] ); 161 list.append( mapIdToStr[ Qtopia::HomeStreet ] );
164 list.append( mapIdToStr[ Qtopia::HomeCity ] ); 162 list.append( mapIdToStr[ Qtopia::HomeCity ] );
165 list.append( mapIdToStr[ Qtopia::HomeState ] ); 163 list.append( mapIdToStr[ Qtopia::HomeState ] );
166 list.append( mapIdToStr[ Qtopia::HomeZip ] ); 164 list.append( mapIdToStr[ Qtopia::HomeZip ] );
167 list.append( mapIdToStr[ Qtopia::HomeCountry ] ); 165 list.append( mapIdToStr[ Qtopia::HomeCountry ] );
168 166
169 list += detailsfields( sorted, translated ); 167 list += detailsfields( sorted, translated );
170 168
171 if ( sorted ) list.sort(); 169 if ( sorted ) list.sort();
172 170
173 return list; 171 return list;
174} 172}
175 173
176 174
177/*! 175/*!
178 \internal 176 \internal
179 Returns an untranslated list of personal field names for a contact. 177 Returns an untranslated list of personal field names for a contact.
180*/ 178*/
181QStringList OPimContactFields::untrpersonalfields( bool sorted ) 179QStringList OPimContactFields::untrpersonalfields( bool sorted )
182{ 180{
183 return personalfields( sorted, false ); 181 return personalfields( sorted, false );
184} 182}
185 183
186 184
187/*! 185/*!
188 \internal 186 \internal
189 Returns a translated list of personal field names for a contact. 187 Returns a translated list of personal field names for a contact.
190*/ 188*/
191QStringList OPimContactFields::trpersonalfields( bool sorted ) 189QStringList OPimContactFields::trpersonalfields( bool sorted )
192{ 190{
193 return personalfields( sorted, true ); 191 return personalfields( sorted, true );
194} 192}
195 193
196 194
197/*! 195/*!
198 \internal 196 \internal
199 Returns an untranslated list of details field names for a contact. 197 Returns an untranslated list of details field names for a contact.
200*/ 198*/
201QStringList OPimContactFields::untrdetailsfields( bool sorted ) 199QStringList OPimContactFields::untrdetailsfields( bool sorted )
202{ 200{
203 return detailsfields( sorted, false ); 201 return detailsfields( sorted, false );
204} 202}
205 203
206 204
207/*! 205/*!
208 \internal 206 \internal
209 Returns a translated list of details field names for a contact. 207 Returns a translated list of details field names for a contact.
210*/ 208*/
211QStringList OPimContactFields::trdetailsfields( bool sorted ) 209QStringList OPimContactFields::trdetailsfields( bool sorted )
212{ 210{
213 return detailsfields( sorted, true ); 211 return detailsfields( sorted, true );
214} 212}
215 213
216 214
217/*! 215/*!
218 \internal 216 \internal
219 Returns a translated list of phone field names for a contact. 217 Returns a translated list of phone field names for a contact.
220*/ 218*/
221QStringList OPimContactFields::trphonefields( bool sorted ) 219QStringList OPimContactFields::trphonefields( bool sorted )
222{ 220{
223 return phonefields( sorted, true ); 221 return phonefields( sorted, true );
224} 222}
225 223
226/*! 224/*!
227 \internal 225 \internal
228 Returns an untranslated list of phone field names for a contact. 226 Returns an untranslated list of phone field names for a contact.
229*/ 227*/
230QStringList OPimContactFields::untrphonefields( bool sorted ) 228QStringList OPimContactFields::untrphonefields( bool sorted )
231{ 229{
232 return phonefields( sorted, false ); 230 return phonefields( sorted, false );
233} 231}
234 232
235 233
236/*! 234/*!
237 \internal 235 \internal
238 Returns a translated list of field names for a contact. 236 Returns a translated list of field names for a contact.
239*/ 237*/
240QStringList OPimContactFields::trfields( bool sorted ) 238QStringList OPimContactFields::trfields( bool sorted )
241{ 239{
242 return fields( sorted, true ); 240 return fields( sorted, true );
243} 241}
244 242
245/*! 243/*!
246 \internal 244 \internal
247 Returns an untranslated list of field names for a contact. 245 Returns an untranslated list of field names for a contact.
248*/ 246*/
249QStringList OPimContactFields::untrfields( bool sorted ) 247QStringList OPimContactFields::untrfields( bool sorted )
250{ 248{
251 return fields( sorted, false ); 249 return fields( sorted, false );
252} 250}
253 251
254QMap<int, QString> OPimContactFields::idToTrFields() 252QMap<int, QString> OPimContactFields::idToTrFields()
255{ 253{
256 QMap<int, QString> ret_map; 254 QMap<int, QString> ret_map;
257 255
258 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); 256 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
259 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); 257 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
260 258
261 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) ); 259 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) );
262 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); 260 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
263 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); 261 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
264 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); 262 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
265 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) ); 263 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) );
266 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); 264 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
267 265
268 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); 266 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
269 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); 267 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
270 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); 268 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
271 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); 269 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
272 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); 270 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
273 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) ); 271 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) );
274 272
275 // email 273 // email
276 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); 274 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
277 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); 275 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
278 276
279 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); 277 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
280 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); 278 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
281 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); 279 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
282 280
283 // business 281 // business
284 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); 282 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
285 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); 283 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
286 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); 284 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
287 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); 285 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
288 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); 286 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
289 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); 287 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
290 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); 288 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
291 289
292 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); 290 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
293 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); 291 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
294 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); 292 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
295 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); 293 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
296 294
297 // home 295 // home
298 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); 296 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
299 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); 297 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
300 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); 298 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
301 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); 299 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
302 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); 300 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
303 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); 301 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
304 302
305 //personal 303 //personal
306 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); 304 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
307 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); 305 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
308 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); 306 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
309 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); 307 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
310 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); 308 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
311 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); 309 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
312 310
313 // other 311 // other
314 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); 312 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
315 313
316 314
317 return ret_map; 315 return ret_map;
318} 316}
319 317
320QMap<int, QString> OPimContactFields::idToUntrFields() 318QMap<int, QString> OPimContactFields::idToUntrFields()
321{ 319{
322 QMap<int, QString> ret_map; 320 QMap<int, QString> ret_map;
323 321
324 ret_map.insert( Qtopia::AddressUid, "User Id" ); 322 ret_map.insert( Qtopia::AddressUid, "User Id" );
325 ret_map.insert( Qtopia::AddressCategory, "Categories" ); 323 ret_map.insert( Qtopia::AddressCategory, "Categories" );
326 324
327 ret_map.insert( Qtopia::Title, "Name Title" ); 325 ret_map.insert( Qtopia::Title, "Name Title" );
328 ret_map.insert( Qtopia::FirstName, "First Name" ); 326 ret_map.insert( Qtopia::FirstName, "First Name" );
329 ret_map.insert( Qtopia::MiddleName, "Middle Name" ); 327 ret_map.insert( Qtopia::MiddleName, "Middle Name" );
330 ret_map.insert( Qtopia::LastName, "Last Name" ); 328 ret_map.insert( Qtopia::LastName, "Last Name" );
331 ret_map.insert( Qtopia::Suffix, "Suffix" ); 329 ret_map.insert( Qtopia::Suffix, "Suffix" );
332 ret_map.insert( Qtopia::FileAs, "File As" ); 330 ret_map.insert( Qtopia::FileAs, "File As" );
333 331
334 ret_map.insert( Qtopia::JobTitle, "Job Title" ); 332 ret_map.insert( Qtopia::JobTitle, "Job Title" );
335 ret_map.insert( Qtopia::Department, "Department" ); 333 ret_map.insert( Qtopia::Department, "Department" );
336 ret_map.insert( Qtopia::Company, "Company" ); 334 ret_map.insert( Qtopia::Company, "Company" );
337 ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); 335 ret_map.insert( Qtopia::BusinessPhone, "Business Phone" );
338 ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); 336 ret_map.insert( Qtopia::BusinessFax, "Business Fax" );
339 ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); 337 ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" );
340 338
341 // email 339 // email
342 ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); 340 ret_map.insert( Qtopia::DefaultEmail, "Default Email" );
343 ret_map.insert( Qtopia::Emails, "Emails" ); 341 ret_map.insert( Qtopia::Emails, "Emails" );
344 342
345 ret_map.insert( Qtopia::HomePhone, "Home Phone" ); 343 ret_map.insert( Qtopia::HomePhone, "Home Phone" );
346 ret_map.insert( Qtopia::HomeFax, "Home Fax" ); 344 ret_map.insert( Qtopia::HomeFax, "Home Fax" );
347 ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); 345 ret_map.insert( Qtopia::HomeMobile, "Home Mobile" );
348 346
349 // business 347 // business
350 ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); 348 ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
351 ret_map.insert( Qtopia::BusinessCity, "Business City" ); 349 ret_map.insert( Qtopia::BusinessCity, "Business City" );
352 ret_map.insert( Qtopia::BusinessState, "Business State" ); 350 ret_map.insert( Qtopia::BusinessState, "Business State" );
353 ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); 351 ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
354 ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); 352 ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
355 ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); 353 ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
356 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); 354 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
357 355
358 ret_map.insert( Qtopia::Office, "Office" ); 356 ret_map.insert( Qtopia::Office, "Office" );
359 ret_map.insert( Qtopia::Profession, "Profession" ); 357 ret_map.insert( Qtopia::Profession, "Profession" );
360 ret_map.insert( Qtopia::Assistant, "Assistant" ); 358 ret_map.insert( Qtopia::Assistant, "Assistant" );
361 ret_map.insert( Qtopia::Manager, "Manager" ); 359 ret_map.insert( Qtopia::Manager, "Manager" );
362 360
363 // home 361 // home
364 ret_map.insert( Qtopia::HomeStreet, "Home Street" ); 362 ret_map.insert( Qtopia::HomeStreet, "Home Street" );
365 ret_map.insert( Qtopia::HomeCity, "Home City" ); 363 ret_map.insert( Qtopia::HomeCity, "Home City" );
366 ret_map.insert( Qtopia::HomeState, "Home State" ); 364 ret_map.insert( Qtopia::HomeState, "Home State" );
367 ret_map.insert( Qtopia::HomeZip, "Home Zip" ); 365 ret_map.insert( Qtopia::HomeZip, "Home Zip" );
368 ret_map.insert( Qtopia::HomeCountry, "Home Country" ); 366 ret_map.insert( Qtopia::HomeCountry, "Home Country" );
369 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); 367 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
370 368
371 //personal 369 //personal
372 ret_map.insert( Qtopia::Spouse, "Spouse" ); 370 ret_map.insert( Qtopia::Spouse, "Spouse" );
373 ret_map.insert( Qtopia::Gender, "Gender" ); 371 ret_map.insert( Qtopia::Gender, "Gender" );
374 ret_map.insert( Qtopia::Birthday, "Birthday" ); 372 ret_map.insert( Qtopia::Birthday, "Birthday" );
375 ret_map.insert( Qtopia::Anniversary, "Anniversary" ); 373 ret_map.insert( Qtopia::Anniversary, "Anniversary" );
376 ret_map.insert( Qtopia::Nickname, "Nickname" ); 374 ret_map.insert( Qtopia::Nickname, "Nickname" );
377 ret_map.insert( Qtopia::Children, "Children" ); 375 ret_map.insert( Qtopia::Children, "Children" );
378 376
379 // other 377 // other
380 ret_map.insert( Qtopia::Notes, "Notes" ); 378 ret_map.insert( Qtopia::Notes, "Notes" );
381 ret_map.insert( Qtopia::Groups, "Groups" ); 379 ret_map.insert( Qtopia::Groups, "Groups" );
382 380
383 381
384 return ret_map; 382 return ret_map;
385} 383}
386 384
387QMap<QString, int> OPimContactFields::trFieldsToId() 385QMap<QString, int> OPimContactFields::trFieldsToId()
388{ 386{
389 QMap<int, QString> idtostr = idToTrFields(); 387 QMap<int, QString> idtostr = idToTrFields();
390 QMap<QString, int> ret_map; 388 QMap<QString, int> ret_map;
391 389
392 390
393 QMap<int, QString>::Iterator it; 391 QMap<int, QString>::Iterator it;
394 for ( it = idtostr.begin(); it != idtostr.end(); ++it ) 392 for ( it = idtostr.begin(); it != idtostr.end(); ++it )
395 ret_map.insert( *it, it.key() ); 393 ret_map.insert( *it, it.key() );
396 394
397 395
398 return ret_map; 396 return ret_map;
399} 397}
400 398
401/* ======================================================================= */ 399/* ======================================================================= */
402 400
403QMap<QString, int> OPimContactFields::untrFieldsToId() 401QMap<QString, int> OPimContactFields::untrFieldsToId()
404{ 402{
405 QMap<int, QString> idtostr = idToUntrFields(); 403 QMap<int, QString> idtostr = idToUntrFields();
406 QMap<QString, int> ret_map; 404 QMap<QString, int> ret_map;
407 405
408 406
409 QMap<int, QString>::Iterator it; 407 QMap<int, QString>::Iterator it;
410 for ( it = idtostr.begin(); it != idtostr.end(); ++it ) 408 for ( it = idtostr.begin(); it != idtostr.end(); ++it )
411 ret_map.insert( *it, it.key() ); 409 ret_map.insert( *it, it.key() );
412 410
413 411
414 return ret_map; 412 return ret_map;
415} 413}
416 414
417 415
418OPimContactFields::OPimContactFields() : 416OPimContactFields::OPimContactFields() :
419 fieldOrder( DEFAULT_FIELD_ORDER ), 417 fieldOrder( DEFAULT_FIELD_ORDER ),
420 changedFieldOrder( false ) 418 changedFieldOrder( false )
421{ 419{
422 // Get the global field order from the config file and 420 // Get the global field order from the config file and
423 // use it as a start pattern 421 // use it as a start pattern
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 3ddbf85..77730e9 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -1,426 +1,423 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimevent.h" 30#include "opimevent.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecurrence.h> 33#include <opie2/opimrecurrence.h>
34#include <opie2/opimresolver.h> 34#include <opie2/opimresolver.h>
35#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <qpe/categories.h> 36#include <qpe/categories.h>
37#include <qpe/palmtopuidgen.h>
38#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
39 38
40/* QT */ 39/* QT */
41#include <qshared.h>
42#include <qarray.h>
43 40
44namespace Opie 41namespace Opie
45{ 42{
46 43
47int OCalendarHelper::week( const QDate& date ) 44int OCalendarHelper::week( const QDate& date )
48{ 45{
49 // Calculates the week this date is in within that 46 // Calculates the week this date is in within that
50 // month. Equals the "row" is is in in the month view 47 // month. Equals the "row" is is in in the month view
51 int week = 1; 48 int week = 1;
52 QDate tmp( date.year(), date.month(), 1 ); 49 QDate tmp( date.year(), date.month(), 1 );
53 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 50 if ( date.dayOfWeek() < tmp.dayOfWeek() )
54 ++week; 51 ++week;
55 52
56 week += ( date.day() - 1 ) / 7; 53 week += ( date.day() - 1 ) / 7;
57 54
58 return week; 55 return week;
59} 56}
60 57
61 58
62int OCalendarHelper::ocurrence( const QDate& date ) 59int OCalendarHelper::ocurrence( const QDate& date )
63{ 60{
64 // calculates the number of occurrances of this day of the 61 // calculates the number of occurrances of this day of the
65 // week till the given date (e.g 3rd Wednesday of the month) 62 // week till the given date (e.g 3rd Wednesday of the month)
66 return ( date.day() - 1 ) / 7 + 1; 63 return ( date.day() - 1 ) / 7 + 1;
67} 64}
68 65
69 66
70int OCalendarHelper::dayOfWeek( char day ) 67int OCalendarHelper::dayOfWeek( char day )
71{ 68{
72 int dayOfWeek = 1; 69 int dayOfWeek = 1;
73 char i = OPimRecurrence::MON; 70 char i = OPimRecurrence::MON;
74 while ( !( i & day ) && i <= OPimRecurrence::SUN ) 71 while ( !( i & day ) && i <= OPimRecurrence::SUN )
75 { 72 {
76 i <<= 1; 73 i <<= 1;
77 ++dayOfWeek; 74 ++dayOfWeek;
78 } 75 }
79 return dayOfWeek; 76 return dayOfWeek;
80} 77}
81 78
82 79
83int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) 80int OCalendarHelper::monthDiff( const QDate& first, const QDate& second )
84{ 81{
85 return ( second.year() - first.year() ) * 12 + 82 return ( second.year() - first.year() ) * 12 +
86 second.month() - first.month(); 83 second.month() - first.month();
87} 84}
88 85
89 86
90struct OPimEvent::Data : public QShared 87struct OPimEvent::Data : public QShared
91{ 88{
92 Data() : QShared() 89 Data() : QShared()
93 { 90 {
94 child = 0; 91 child = 0;
95 recur = 0; 92 recur = 0;
96 manager = 0; 93 manager = 0;
97 isAllDay = false; 94 isAllDay = false;
98 parent = 0; 95 parent = 0;
99 } 96 }
100 ~Data() 97 ~Data()
101 { 98 {
102 delete manager; 99 delete manager;
103 delete recur; 100 delete recur;
104 } 101 }
105 QString description; 102 QString description;
106 QString location; 103 QString location;
107 OPimNotifyManager* manager; 104 OPimNotifyManager* manager;
108 OPimRecurrence* recur; 105 OPimRecurrence* recur;
109 QString note; 106 QString note;
110 QDateTime created; 107 QDateTime created;
111 QDateTime start; 108 QDateTime start;
112 QDateTime end; 109 QDateTime end;
113bool isAllDay : 1; 110bool isAllDay : 1;
114 QString timezone; 111 QString timezone;
115 QArray<int>* child; 112 QArray<int>* child;
116 int parent; 113 int parent;
117}; 114};
118 115
119 116
120OPimEvent::OPimEvent( int uid ) 117OPimEvent::OPimEvent( int uid )
121 : OPimRecord( uid ) 118 : OPimRecord( uid )
122{ 119{
123 data = new Data; 120 data = new Data;
124} 121}
125 122
126 123
127OPimEvent::OPimEvent( const OPimEvent& ev ) 124OPimEvent::OPimEvent( const OPimEvent& ev )
128 : OPimRecord( ev ), data( ev.data ) 125 : OPimRecord( ev ), data( ev.data )
129{ 126{
130 data->ref(); 127 data->ref();
131} 128}
132 129
133 130
134OPimEvent::OPimEvent( const QMap<int, QString> map ) 131OPimEvent::OPimEvent( const QMap<int, QString> map )
135 : OPimRecord( 0 ) 132 : OPimRecord( 0 )
136{ 133{
137 data = new Data; 134 data = new Data;
138 135
139 fromMap( map ); 136 fromMap( map );
140} 137}
141 138
142 139
143OPimEvent::~OPimEvent() 140OPimEvent::~OPimEvent()
144{ 141{
145 if ( data->deref() ) 142 if ( data->deref() )
146 { 143 {
147 delete data; 144 delete data;
148 data = 0; 145 data = 0;
149 } 146 }
150} 147}
151 148
152 149
153OPimEvent& OPimEvent::operator=( const OPimEvent& ev ) 150OPimEvent& OPimEvent::operator=( const OPimEvent& ev )
154{ 151{
155 if ( this == &ev ) return * this; 152 if ( this == &ev ) return * this;
156 153
157 OPimRecord::operator=( ev ); 154 OPimRecord::operator=( ev );
158 ev.data->ref(); 155 ev.data->ref();
159 deref(); 156 deref();
160 data = ev.data; 157 data = ev.data;
161 158
162 159
163 return *this; 160 return *this;
164} 161}
165 162
166 163
167QString OPimEvent::description() const 164QString OPimEvent::description() const
168{ 165{
169 return data->description; 166 return data->description;
170} 167}
171 168
172 169
173void OPimEvent::setDescription( const QString& description ) 170void OPimEvent::setDescription( const QString& description )
174{ 171{
175 changeOrModify(); 172 changeOrModify();
176 data->description = description; 173 data->description = description;
177} 174}
178 175
179 176
180void OPimEvent::setLocation( const QString& loc ) 177void OPimEvent::setLocation( const QString& loc )
181{ 178{
182 changeOrModify(); 179 changeOrModify();
183 data->location = loc; 180 data->location = loc;
184} 181}
185 182
186 183
187QString OPimEvent::location() const 184QString OPimEvent::location() const
188{ 185{
189 return data->location; 186 return data->location;
190} 187}
191 188
192 189
193OPimNotifyManager &OPimEvent::notifiers() const 190OPimNotifyManager &OPimEvent::notifiers() const
194{ 191{
195 // I hope we can skip the changeOrModify here 192 // I hope we can skip the changeOrModify here
196 // the notifier should take care of it 193 // the notifier should take care of it
197 // and OPimNotify is shared too 194 // and OPimNotify is shared too
198 if ( !data->manager ) 195 if ( !data->manager )
199 data->manager = new OPimNotifyManager; 196 data->manager = new OPimNotifyManager;
200 197
201 return *data->manager; 198 return *data->manager;
202} 199}
203 200
204 201
205bool OPimEvent::hasNotifiers() const 202bool OPimEvent::hasNotifiers() const
206{ 203{
207 if ( !data->manager ) 204 if ( !data->manager )
208 return false; 205 return false;
209 if ( data->manager->reminders().isEmpty() && 206 if ( data->manager->reminders().isEmpty() &&
210 data->manager->alarms().isEmpty() ) 207 data->manager->alarms().isEmpty() )
211 return false; 208 return false;
212 209
213 return true; 210 return true;
214} 211}
215 212
216 213
217OPimRecurrence OPimEvent::recurrence() const 214OPimRecurrence OPimEvent::recurrence() const
218{ 215{
219 if ( !data->recur ) 216 if ( !data->recur )
220 data->recur = new OPimRecurrence; 217 data->recur = new OPimRecurrence;
221 218
222 return *data->recur; 219 return *data->recur;
223} 220}
224 221
225 222
226void OPimEvent::setRecurrence( const OPimRecurrence& rec ) 223void OPimEvent::setRecurrence( const OPimRecurrence& rec )
227{ 224{
228 changeOrModify(); 225 changeOrModify();
229 if ( data->recur ) 226 if ( data->recur )
230 ( *data->recur ) = rec; 227 ( *data->recur ) = rec;
231 else 228 else
232 data->recur = new OPimRecurrence( rec ); 229 data->recur = new OPimRecurrence( rec );
233} 230}
234 231
235 232
236bool OPimEvent::hasRecurrence() const 233bool OPimEvent::hasRecurrence() const
237{ 234{
238 if ( !data->recur ) return false; 235 if ( !data->recur ) return false;
239 return data->recur->doesRecur(); 236 return data->recur->doesRecur();
240} 237}
241 238
242 239
243QString OPimEvent::note() const 240QString OPimEvent::note() const
244{ 241{
245 return data->note; 242 return data->note;
246} 243}
247 244
248 245
249void OPimEvent::setNote( const QString& note ) 246void OPimEvent::setNote( const QString& note )
250{ 247{
251 changeOrModify(); 248 changeOrModify();
252 data->note = note; 249 data->note = note;
253} 250}
254 251
255 252
256QDateTime OPimEvent::createdDateTime() const 253QDateTime OPimEvent::createdDateTime() const
257{ 254{
258 return data->created; 255 return data->created;
259} 256}
260 257
261 258
262void OPimEvent::setCreatedDateTime( const QDateTime& time ) 259void OPimEvent::setCreatedDateTime( const QDateTime& time )
263{ 260{
264 changeOrModify(); 261 changeOrModify();
265 data->created = time; 262 data->created = time;
266} 263}
267 264
268 265
269QDateTime OPimEvent::startDateTime() const 266QDateTime OPimEvent::startDateTime() const
270{ 267{
271 if ( data->isAllDay ) 268 if ( data->isAllDay )
272 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) ); 269 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) );
273 return data->start; 270 return data->start;
274} 271}
275 272
276 273
277QDateTime OPimEvent::startDateTimeInZone() const 274QDateTime OPimEvent::startDateTimeInZone() const
278{ 275{
279 /* if no timezone, or all day event or if the current and this timeZone match... */ 276 /* if no timezone, or all day event or if the current and this timeZone match... */
280 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return startDateTime(); 277 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return startDateTime();
281 278
282 OPimTimeZone zone( data->timezone ); 279 OPimTimeZone zone( data->timezone );
283 return zone.toDateTime( data->start, OPimTimeZone::current() ); 280 return zone.toDateTime( data->start, OPimTimeZone::current() );
284} 281}
285 282
286 283
287void OPimEvent::setStartDateTime( const QDateTime& dt ) 284void OPimEvent::setStartDateTime( const QDateTime& dt )
288{ 285{
289 changeOrModify(); 286 changeOrModify();
290 data->start = dt; 287 data->start = dt;
291} 288}
292 289
293 290
294QDateTime OPimEvent::endDateTime() const 291QDateTime OPimEvent::endDateTime() const
295{ 292{
296 /* 293 /*
297 * if all Day event the end time needs 294 * if all Day event the end time needs
298 * to be on the same day as the start 295 * to be on the same day as the start
299 */ 296 */
300 if ( data->isAllDay ) 297 if ( data->isAllDay )
301 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); 298 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) );
302 return data->end; 299 return data->end;
303} 300}
304 301
305 302
306QDateTime OPimEvent::endDateTimeInZone() const 303QDateTime OPimEvent::endDateTimeInZone() const
307{ 304{
308 /* if no timezone, or all day event or if the current and this timeZone match... */ 305 /* if no timezone, or all day event or if the current and this timeZone match... */
309 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); 306 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime();
310 307
311 OPimTimeZone zone( data->timezone ); 308 OPimTimeZone zone( data->timezone );
312 return zone.toDateTime( data->end, OPimTimeZone::current() ); 309 return zone.toDateTime( data->end, OPimTimeZone::current() );
313} 310}
314 311
315 312
316void OPimEvent::setEndDateTime( const QDateTime& dt ) 313void OPimEvent::setEndDateTime( const QDateTime& dt )
317{ 314{
318 changeOrModify(); 315 changeOrModify();
319 data->end = dt; 316 data->end = dt;
320} 317}
321 318
322 319
323bool OPimEvent::isMultipleDay() const 320bool OPimEvent::isMultipleDay() const
324{ 321{
325 return data->end.date().day() - data->start.date().day(); 322 return data->end.date().day() - data->start.date().day();
326} 323}
327 324
328 325
329bool OPimEvent::isAllDay() const 326bool OPimEvent::isAllDay() const
330{ 327{
331 return data->isAllDay; 328 return data->isAllDay;
332} 329}
333 330
334 331
335void OPimEvent::setAllDay( bool allDay ) 332void OPimEvent::setAllDay( bool allDay )
336{ 333{
337 changeOrModify(); 334 changeOrModify();
338 data->isAllDay = allDay; 335 data->isAllDay = allDay;
339 if ( allDay ) data->timezone = "UTC"; 336 if ( allDay ) data->timezone = "UTC";
340} 337}
341 338
342 339
343void OPimEvent::setTimeZone( const QString& tz ) 340void OPimEvent::setTimeZone( const QString& tz )
344{ 341{
345 changeOrModify(); 342 changeOrModify();
346 data->timezone = tz; 343 data->timezone = tz;
347} 344}
348 345
349 346
350QString OPimEvent::timeZone() const 347QString OPimEvent::timeZone() const
351{ 348{
352 if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); 349 if ( data->isAllDay ) return QString::fromLatin1( "UTC" );
353 return data->timezone; 350 return data->timezone;
354} 351}
355 352
356 353
357bool OPimEvent::match( const QRegExp& re ) const 354bool OPimEvent::match( const QRegExp& re ) const
358{ 355{
359 if ( re.match( data->description ) != -1 ) 356 if ( re.match( data->description ) != -1 )
360 { 357 {
361 setLastHitField( Qtopia::DatebookDescription ); 358 setLastHitField( Qtopia::DatebookDescription );
362 return true; 359 return true;
363 } 360 }
364 if ( re.match( data->note ) != -1 ) 361 if ( re.match( data->note ) != -1 )
365 { 362 {
366 setLastHitField( Qtopia::Note ); 363 setLastHitField( Qtopia::Note );
367 return true; 364 return true;
368 } 365 }
369 if ( re.match( data->location ) != -1 ) 366 if ( re.match( data->location ) != -1 )
370 { 367 {
371 setLastHitField( Qtopia::Location ); 368 setLastHitField( Qtopia::Location );
372 return true; 369 return true;
373 } 370 }
374 if ( re.match( data->start.toString() ) != -1 ) 371 if ( re.match( data->start.toString() ) != -1 )
375 { 372 {
376 setLastHitField( Qtopia::StartDateTime ); 373 setLastHitField( Qtopia::StartDateTime );
377 return true; 374 return true;
378 } 375 }
379 if ( re.match( data->end.toString() ) != -1 ) 376 if ( re.match( data->end.toString() ) != -1 )
380 { 377 {
381 setLastHitField( Qtopia::EndDateTime ); 378 setLastHitField( Qtopia::EndDateTime );
382 return true; 379 return true;
383 } 380 }
384 return false; 381 return false;
385} 382}
386 383
387 384
388QString OPimEvent::toRichText() const 385QString OPimEvent::toRichText() const
389{ 386{
390 QString text, value; 387 QString text, value;
391 388
392 // description 389 // description
393 text += "<b><h3><img src=\"datebook/DateBook\">"; 390 text += "<b><h3><img src=\"datebook/DateBook\">";
394 if ( !description().isEmpty() ) 391 if ( !description().isEmpty() )
395 { 392 {
396 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" ); 393 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" );
397 } 394 }
398 text += "</h3></b><br><hr><br>"; 395 text += "</h3></b><br><hr><br>";
399 396
400 // location 397 // location
401 if ( !( value = location() ).isEmpty() ) 398 if ( !( value = location() ).isEmpty() )
402 { 399 {
403 text += "<b>" + QObject::tr( "Location:" ) + "</b> "; 400 text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
404 text += Qtopia::escapeString( value ) + "<br>"; 401 text += Qtopia::escapeString( value ) + "<br>";
405 } 402 }
406 403
407 // all day event 404 // all day event
408 if ( isAllDay() ) 405 if ( isAllDay() )
409 { 406 {
410 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; 407 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
411 } 408 }
412 // multiple day event 409 // multiple day event
413 else if ( isMultipleDay () ) 410 else if ( isMultipleDay () )
414 { 411 {
415 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; 412 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
416 } 413 }
417 // start & end times 414 // start & end times
418 else 415 else
419 { 416 {
420 // start time 417 // start time
421 if ( startDateTime().isValid() ) 418 if ( startDateTime().isValid() )
422 { 419 {
423 text += "<b>" + QObject::tr( "Start:" ) + "</b> "; 420 text += "<b>" + QObject::tr( "Start:" ) + "</b> ";
424 text += Qtopia::escapeString( startDateTime().toString() ). 421 text += Qtopia::escapeString( startDateTime().toString() ).
425 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 422 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
426 } 423 }
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp
index 43858f0..417b0b9 100644
--- a/libopie2/opiepim/core/opimnotify.cpp
+++ b/libopie2/opiepim/core/opimnotify.cpp
@@ -1,379 +1,378 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimnotify.h" 30#include "opimnotify.h"
31 31
32/* QT */ 32/* QT */
33#include <qshared.h>
34 33
35namespace Opie 34namespace Opie
36{ 35{
37 36
38struct OPimNotify::Data : public QShared 37struct OPimNotify::Data : public QShared
39{ 38{
40 Data() : QShared(), dur( -1 ), parent( 0 ) 39 Data() : QShared(), dur( -1 ), parent( 0 )
41 { 40 {
42 } 41 }
43 QDateTime start; 42 QDateTime start;
44 int dur; 43 int dur;
45 QString application; 44 QString application;
46 int parent; 45 int parent;
47}; 46};
48 47
49OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) 48OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent )
50{ 49{
51 data = new Data; 50 data = new Data;
52 data->start = start; 51 data->start = start;
53 data->dur = duration; 52 data->dur = duration;
54 data->parent = parent; 53 data->parent = parent;
55} 54}
56 55
57 56
58OPimNotify::OPimNotify( const OPimNotify& noti ) 57OPimNotify::OPimNotify( const OPimNotify& noti )
59 : data( noti.data ) 58 : data( noti.data )
60{ 59{
61 data->ref(); 60 data->ref();
62} 61}
63 62
64 63
65OPimNotify::~OPimNotify() 64OPimNotify::~OPimNotify()
66{ 65{
67 if ( data->deref() ) 66 if ( data->deref() )
68 { 67 {
69 delete data; 68 delete data;
70 data = 0l; 69 data = 0l;
71 } 70 }
72} 71}
73 72
74 73
75OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) 74OPimNotify &OPimNotify::operator=( const OPimNotify& noti )
76{ 75{
77 noti.data->ref(); 76 noti.data->ref();
78 deref(); 77 deref();
79 data = noti.data; 78 data = noti.data;
80 79
81 return *this; 80 return *this;
82} 81}
83 82
84 83
85bool OPimNotify::operator==( const OPimNotify& noti ) 84bool OPimNotify::operator==( const OPimNotify& noti )
86{ 85{
87 if ( data == noti.data ) return true; 86 if ( data == noti.data ) return true;
88 if ( data->dur != noti.data->dur ) return false; 87 if ( data->dur != noti.data->dur ) return false;
89 if ( data->parent != noti.data->parent ) return false; 88 if ( data->parent != noti.data->parent ) return false;
90 if ( data->application != noti.data->application ) return false; 89 if ( data->application != noti.data->application ) return false;
91 if ( data->start != noti.data->start ) return false; 90 if ( data->start != noti.data->start ) return false;
92 91
93 return true; 92 return true;
94} 93}
95 94
96 95
97QDateTime OPimNotify::dateTime() const 96QDateTime OPimNotify::dateTime() const
98{ 97{
99 return data->start; 98 return data->start;
100} 99}
101 100
102 101
103QString OPimNotify::service() const 102QString OPimNotify::service() const
104{ 103{
105 return data->application; 104 return data->application;
106} 105}
107 106
108 107
109int OPimNotify::parent() const 108int OPimNotify::parent() const
110{ 109{
111 return data->parent; 110 return data->parent;
112} 111}
113 112
114 113
115int OPimNotify::duration() const 114int OPimNotify::duration() const
116{ 115{
117 return data->dur; 116 return data->dur;
118} 117}
119 118
120 119
121QDateTime OPimNotify::endTime() const 120QDateTime OPimNotify::endTime() const
122{ 121{
123 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) ); 122 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) );
124} 123}
125 124
126 125
127void OPimNotify::setDateTime( const QDateTime& time ) 126void OPimNotify::setDateTime( const QDateTime& time )
128{ 127{
129 copyIntern(); 128 copyIntern();
130 data->start = time; 129 data->start = time;
131} 130}
132 131
133 132
134void OPimNotify::setDuration( int dur ) 133void OPimNotify::setDuration( int dur )
135{ 134{
136 copyIntern(); 135 copyIntern();
137 data->dur = dur; 136 data->dur = dur;
138} 137}
139 138
140 139
141void OPimNotify::setParent( int uid ) 140void OPimNotify::setParent( int uid )
142{ 141{
143 copyIntern(); 142 copyIntern();
144 data->parent = uid; 143 data->parent = uid;
145} 144}
146 145
147 146
148void OPimNotify::setService( const QString& str ) 147void OPimNotify::setService( const QString& str )
149{ 148{
150 copyIntern(); 149 copyIntern();
151 data->application = str; 150 data->application = str;
152} 151}
153 152
154 153
155void OPimNotify::copyIntern() 154void OPimNotify::copyIntern()
156{ 155{
157 if ( data->count != 1 ) 156 if ( data->count != 1 )
158 { 157 {
159 data->deref(); 158 data->deref();
160 Data* dat = new Data; 159 Data* dat = new Data;
161 dat->start = data->start; 160 dat->start = data->start;
162 dat->dur = data->dur; 161 dat->dur = data->dur;
163 dat->application = data->application; 162 dat->application = data->application;
164 dat->parent = data->parent; 163 dat->parent = data->parent;
165 data = dat; 164 data = dat;
166 } 165 }
167} 166}
168 167
169 168
170void OPimNotify::deref() 169void OPimNotify::deref()
171{ 170{
172 if ( data->deref() ) 171 if ( data->deref() )
173 { 172 {
174 delete data; 173 delete data;
175 data = 0; 174 data = 0;
176 } 175 }
177} 176}
178 177
179 178
180/***********************************************************/ 179/***********************************************************/
181struct OPimAlarm::Data : public QShared 180struct OPimAlarm::Data : public QShared
182{ 181{
183 Data() : QShared() 182 Data() : QShared()
184 { 183 {
185 sound = 1; 184 sound = 1;
186 } 185 }
187 int sound; 186 int sound;
188 QString file; 187 QString file;
189}; 188};
190 189
191 190
192OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) 191OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
193 : OPimNotify( start, duration, parent ) 192 : OPimNotify( start, duration, parent )
194{ 193{
195 data = new Data; 194 data = new Data;
196 data->sound = sound; 195 data->sound = sound;
197} 196}
198 197
199 198
200OPimAlarm::OPimAlarm( const OPimAlarm& al ) 199OPimAlarm::OPimAlarm( const OPimAlarm& al )
201 : OPimNotify( al ), data( al.data ) 200 : OPimNotify( al ), data( al.data )
202{ 201{
203 data->ref(); 202 data->ref();
204} 203}
205 204
206 205
207OPimAlarm::~OPimAlarm() 206OPimAlarm::~OPimAlarm()
208{ 207{
209 if ( data->deref() ) 208 if ( data->deref() )
210 { 209 {
211 delete data; 210 delete data;
212 data = 0l; 211 data = 0l;
213 } 212 }
214} 213}
215 214
216 215
217OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) 216OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al )
218{ 217{
219 OPimNotify::operator=( al ); 218 OPimNotify::operator=( al );
220 deref(); 219 deref();
221 al.data->ref(); 220 al.data->ref();
222 221
223 data = al.data; 222 data = al.data;
224 223
225 224
226 return *this; 225 return *this;
227} 226}
228 227
229 228
230bool OPimAlarm::operator==( const OPimAlarm& al ) 229bool OPimAlarm::operator==( const OPimAlarm& al )
231{ 230{
232 if ( data->sound != al.data->sound ) return false; 231 if ( data->sound != al.data->sound ) return false;
233 else if ( data->sound == Custom && data->file != al.data->file ) 232 else if ( data->sound == Custom && data->file != al.data->file )
234 return false; 233 return false;
235 234
236 return OPimNotify::operator==( al ); 235 return OPimNotify::operator==( al );
237} 236}
238 237
239 238
240QString OPimAlarm::type() const 239QString OPimAlarm::type() const
241{ 240{
242 return QString::fromLatin1( "OPimAlarm" ); 241 return QString::fromLatin1( "OPimAlarm" );
243} 242}
244 243
245 244
246int OPimAlarm::sound() const 245int OPimAlarm::sound() const
247{ 246{
248 return data->sound; 247 return data->sound;
249} 248}
250 249
251 250
252QString OPimAlarm::file() const 251QString OPimAlarm::file() const
253{ 252{
254 return data->file; 253 return data->file;
255} 254}
256 255
257 256
258void OPimAlarm::setSound( int snd ) 257void OPimAlarm::setSound( int snd )
259{ 258{
260 copyIntern(); 259 copyIntern();
261 data->sound = snd; 260 data->sound = snd;
262} 261}
263 262
264 263
265void OPimAlarm::setFile( const QString& sound ) 264void OPimAlarm::setFile( const QString& sound )
266{ 265{
267 copyIntern(); 266 copyIntern();
268 data->file = sound; 267 data->file = sound;
269} 268}
270 269
271 270
272void OPimAlarm::deref() 271void OPimAlarm::deref()
273{ 272{
274 if ( data->deref() ) 273 if ( data->deref() )
275 { 274 {
276 delete data; 275 delete data;
277 data = 0l; 276 data = 0l;
278 } 277 }
279} 278}
280 279
281 280
282void OPimAlarm::copyIntern() 281void OPimAlarm::copyIntern()
283{ 282{
284 if ( data->count != 1 ) 283 if ( data->count != 1 )
285 { 284 {
286 data->deref(); 285 data->deref();
287 Data *newDat = new Data; 286 Data *newDat = new Data;
288 newDat->sound = data->sound; 287 newDat->sound = data->sound;
289 newDat->file = data->file; 288 newDat->file = data->file;
290 data = newDat; 289 data = newDat;
291 } 290 }
292} 291}
293 292
294 293
295/************************/ 294/************************/
296struct OPimReminder::Data : public QShared 295struct OPimReminder::Data : public QShared
297{ 296{
298 Data() : QShared(), record( 0 ) 297 Data() : QShared(), record( 0 )
299 {} 298 {}
300 int record; 299 int record;
301 300
302}; 301};
303 302
304 303
305OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) 304OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
306 : OPimNotify( start, dur, parent ) 305 : OPimNotify( start, dur, parent )
307{ 306{
308 data = new Data; 307 data = new Data;
309 data->record = uid; 308 data->record = uid;
310} 309}
311 310
312 311
313OPimReminder::OPimReminder( const OPimReminder& rem ) 312OPimReminder::OPimReminder( const OPimReminder& rem )
314 : OPimNotify( rem ), data( rem.data ) 313 : OPimNotify( rem ), data( rem.data )
315{ 314{
316 data->ref(); 315 data->ref();
317} 316}
318 317
319 318
320OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) 319OPimReminder& OPimReminder::operator=( const OPimReminder& rem )
321{ 320{
322 OPimNotify::operator=( rem ); 321 OPimNotify::operator=( rem );
323 322
324 deref(); 323 deref();
325 rem.data->ref(); 324 rem.data->ref();
326 data = rem.data; 325 data = rem.data;
327 326
328 return *this; 327 return *this;
329} 328}
330 329
331 330
332bool OPimReminder::operator==( const OPimReminder& rem ) 331bool OPimReminder::operator==( const OPimReminder& rem )
333{ 332{
334 if ( data->record != rem.data->record ) return false; 333 if ( data->record != rem.data->record ) return false;
335 334
336 return OPimNotify::operator==( rem ); 335 return OPimNotify::operator==( rem );
337} 336}
338 337
339 338
340QString OPimReminder::type() const 339QString OPimReminder::type() const
341{ 340{
342 return QString::fromLatin1( "OPimReminder" ); 341 return QString::fromLatin1( "OPimReminder" );
343} 342}
344 343
345 344
346int OPimReminder::recordUid() const 345int OPimReminder::recordUid() const
347{ 346{
348 return data->record; 347 return data->record;
349} 348}
350 349
351 350
352void OPimReminder::setRecordUid( int uid ) 351void OPimReminder::setRecordUid( int uid )
353{ 352{
354 copyIntern(); 353 copyIntern();
355 data->record = uid; 354 data->record = uid;
356} 355}
357 356
358 357
359void OPimReminder::deref() 358void OPimReminder::deref()
360{ 359{
361 if ( data->deref() ) 360 if ( data->deref() )
362 { 361 {
363 delete data; 362 delete data;
364 data = 0l; 363 data = 0l;
365 } 364 }
366} 365}
367 366
368 367
369void OPimReminder::copyIntern() 368void OPimReminder::copyIntern()
370{ 369{
371 if ( data->count != 1 ) 370 if ( data->count != 1 )
372 { 371 {
373 Data * da = new Data; 372 Data * da = new Data;
374 da->record = data->record; 373 da->record = data->record;
375 data = da; 374 data = da;
376 } 375 }
377} 376}
378 377
379} 378}
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index c603f44..67eed41 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,274 +1,273 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimrecord.h" 30#include "opimrecord.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <qpe/categories.h> 33#include <qpe/categories.h>
34#include <qpe/categoryselect.h> 34#include <qpe/categoryselect.h>
35 35
36/* QT */ 36/* QT */
37#include <qarray.h>
38 37
39namespace Opie 38namespace Opie
40{ 39{
41Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 40Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
42 41
43 42
44OPimRecord::OPimRecord( int uid ) 43OPimRecord::OPimRecord( int uid )
45 : Qtopia::Record() 44 : Qtopia::Record()
46{ 45{
47 46
48 m_lastHit = -1; 47 m_lastHit = -1;
49 setUid( uid ); 48 setUid( uid );
50} 49}
51 50
52 51
53OPimRecord::~OPimRecord() 52OPimRecord::~OPimRecord()
54{} 53{}
55 54
56 55
57OPimRecord::OPimRecord( const OPimRecord& rec ) 56OPimRecord::OPimRecord( const OPimRecord& rec )
58 : Qtopia::Record( rec ) 57 : Qtopia::Record( rec )
59{ 58{
60 ( *this ) = rec; 59 ( *this ) = rec;
61} 60}
62 61
63 62
64OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) 63OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
65{ 64{
66 if ( this == &rec ) return * this; 65 if ( this == &rec ) return * this;
67 66
68 Qtopia::Record::operator=( rec ); 67 Qtopia::Record::operator=( rec );
69 m_xrefman = rec.m_xrefman; 68 m_xrefman = rec.m_xrefman;
70 m_lastHit = rec.m_lastHit; 69 m_lastHit = rec.m_lastHit;
71 70
72 return *this; 71 return *this;
73} 72}
74 73
75 74
76/* 75/*
77 * category names 76 * category names
78 */ 77 */
79QStringList OPimRecord::categoryNames( const QString& appname ) const 78QStringList OPimRecord::categoryNames( const QString& appname ) const
80{ 79{
81 QStringList list; 80 QStringList list;
82 QArray<int> cats = categories(); 81 QArray<int> cats = categories();
83 Categories catDB; 82 Categories catDB;
84 catDB.load( categoryFileName() ); 83 catDB.load( categoryFileName() );
85 84
86 for ( uint i = 0; i < cats.count(); i++ ) 85 for ( uint i = 0; i < cats.count(); i++ )
87 { 86 {
88 list << catDB.label( appname, cats[ i ] ); 87 list << catDB.label( appname, cats[ i ] );
89 } 88 }
90 89
91 return list; 90 return list;
92} 91}
93 92
94 93
95void OPimRecord::setCategoryNames( const QStringList& ) 94void OPimRecord::setCategoryNames( const QStringList& )
96{ 95{
97} 96}
98 97
99 98
100void OPimRecord::addCategoryName( const QString& ) 99void OPimRecord::addCategoryName( const QString& )
101{ 100{
102 Categories catDB; 101 Categories catDB;
103 catDB.load( categoryFileName() ); 102 catDB.load( categoryFileName() );
104 103
105 104
106} 105}
107 106
108 107
109bool OPimRecord::isEmpty() const 108bool OPimRecord::isEmpty() const
110{ 109{
111 return ( uid() == 0 ); 110 return ( uid() == 0 );
112} 111}
113 112
114 113
115/*QString OPimRecord::crossToString()const { 114/*QString OPimRecord::crossToString()const {
116 QString str; 115 QString str;
117 QMap<QString, QArray<int> >::ConstIterator it; 116 QMap<QString, QArray<int> >::ConstIterator it;
118 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 117 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
119 QArray<int> id = it.data(); 118 QArray<int> id = it.data();
120 for ( uint i = 0; i < id.size(); ++i ) { 119 for ( uint i = 0; i < id.size(); ++i ) {
121 str += it.key() + "," + QString::number( i ) + ";"; 120 str += it.key() + "," + QString::number( i ) + ";";
122 } 121 }
123 } 122 }
124 str = str.remove( str.length()-1, 1); // strip the ; 123 str = str.remove( str.length()-1, 1); // strip the ;
125 //qWarning("IDS " + str ); 124 //qWarning("IDS " + str );
126 125
127 return str; 126 return str;
128 }*/ 127 }*/
129/* if uid = 1 assign a new one */ 128/* if uid = 1 assign a new one */
130void OPimRecord::setUid( int uid ) 129void OPimRecord::setUid( int uid )
131{ 130{
132 if ( uid == 1 ) 131 if ( uid == 1 )
133 uid = uidGen().generate(); 132 uid = uidGen().generate();
134 133
135 Qtopia::Record::setUid( uid ); 134 Qtopia::Record::setUid( uid );
136}; 135};
137 136
138 137
139Qtopia::UidGen &OPimRecord::uidGen() 138Qtopia::UidGen &OPimRecord::uidGen()
140{ 139{
141 return m_uidGen; 140 return m_uidGen;
142} 141}
143 142
144 143
145OPimXRefManager &OPimRecord::xrefmanager() 144OPimXRefManager &OPimRecord::xrefmanager()
146{ 145{
147 return m_xrefman; 146 return m_xrefman;
148} 147}
149 148
150 149
151int OPimRecord::rtti() 150int OPimRecord::rtti()
152{ 151{
153 return 0; 152 return 0;
154} 153}
155 154
156/** 155/**
157 * now let's put our data into the stream 156 * now let's put our data into the stream
158 */ 157 */
159/* 158/*
160 * First read UID 159 * First read UID
161 * Categories 160 * Categories
162 * XRef 161 * XRef
163 */ 162 */
164bool OPimRecord::loadFromStream( QDataStream& stream ) 163bool OPimRecord::loadFromStream( QDataStream& stream )
165{ 164{
166 int Int; 165 int Int;
167 uint UInt; 166 uint UInt;
168 stream >> Int; 167 stream >> Int;
169 setUid( Int ); 168 setUid( Int );
170 169
171 /** Categories */ 170 /** Categories */
172 stream >> UInt; 171 stream >> UInt;
173 QArray<int> array( UInt ); 172 QArray<int> array( UInt );
174 for ( uint i = 0; i < UInt; i++ ) 173 for ( uint i = 0; i < UInt; i++ )
175 { 174 {
176 stream >> array[ i ]; 175 stream >> array[ i ];
177 } 176 }
178 setCategories( array ); 177 setCategories( array );
179 178
180 /* 179 /*
181 * now we do the X-Ref stuff 180 * now we do the X-Ref stuff
182 */ 181 */
183 OPimXRef xref; 182 OPimXRef xref;
184 stream >> UInt; 183 stream >> UInt;
185 for ( uint i = 0; i < UInt; i++ ) 184 for ( uint i = 0; i < UInt; i++ )
186 { 185 {
187 xref.setPartner( OPimXRef::One, partner( stream ) ); 186 xref.setPartner( OPimXRef::One, partner( stream ) );
188 xref.setPartner( OPimXRef::Two, partner( stream ) ); 187 xref.setPartner( OPimXRef::Two, partner( stream ) );
189 m_xrefman.add( xref ); 188 m_xrefman.add( xref );
190 } 189 }
191 190
192 return true; 191 return true;
193} 192}
194 193
195 194
196bool OPimRecord::saveToStream( QDataStream& stream ) const 195bool OPimRecord::saveToStream( QDataStream& stream ) const
197{ 196{
198 /** UIDs */ 197 /** UIDs */
199 198
200 stream << uid(); 199 stream << uid();
201 200
202 /** Categories */ 201 /** Categories */
203 stream << categories().count(); 202 stream << categories().count();
204 for ( uint i = 0; i < categories().count(); i++ ) 203 for ( uint i = 0; i < categories().count(); i++ )
205 { 204 {
206 stream << categories() [ i ]; 205 stream << categories() [ i ];
207 } 206 }
208 207
209 /* 208 /*
210 * first the XRef count 209 * first the XRef count
211 * then the xrefs 210 * then the xrefs
212 */ 211 */
213 stream << m_xrefman.list().count(); 212 stream << m_xrefman.list().count();
214 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 213 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
215 it != m_xrefman.list().end(); ++it ) 214 it != m_xrefman.list().end(); ++it )
216 { 215 {
217 flush( ( *it ).partner( OPimXRef::One ), stream ); 216 flush( ( *it ).partner( OPimXRef::One ), stream );
218 flush( ( *it ).partner( OPimXRef::Two ), stream ); 217 flush( ( *it ).partner( OPimXRef::Two ), stream );
219 } 218 }
220 return true; 219 return true;
221} 220}
222 221
223 222
224void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const 223void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const
225{ 224{
226 str << par.service(); 225 str << par.service();
227 str << par.uid(); 226 str << par.uid();
228 str << par.field(); 227 str << par.field();
229} 228}
230 229
231 230
232OPimXRefPartner OPimRecord::partner( QDataStream& stream ) 231OPimXRefPartner OPimRecord::partner( QDataStream& stream )
233{ 232{
234 OPimXRefPartner par; 233 OPimXRefPartner par;
235 QString str; 234 QString str;
236 int i; 235 int i;
237 236
238 stream >> str; 237 stream >> str;
239 par.setService( str ); 238 par.setService( str );
240 239
241 stream >> i; 240 stream >> i;
242 par.setUid( i ); 241 par.setUid( i );
243 242
244 stream >> i ; 243 stream >> i ;
245 par.setField( i ); 244 par.setField( i );
246 245
247 return par; 246 return par;
248} 247}
249 248
250 249
251void OPimRecord::setLastHitField( int lastHit ) const 250void OPimRecord::setLastHitField( int lastHit ) const
252{ 251{
253 m_lastHit = lastHit; 252 m_lastHit = lastHit;
254} 253}
255 254
256 255
257int OPimRecord::lastHitField() const 256int OPimRecord::lastHitField() const
258{ 257{
259 return m_lastHit; 258 return m_lastHit;
260} 259}
261 260
262 261
263QMap<QString, QString> OPimRecord::toExtraMap() const 262QMap<QString, QString> OPimRecord::toExtraMap() const
264{ 263{
265 return customMap; 264 return customMap;
266} 265}
267 266
268 267
269void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) 268void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
270{ 269{
271 customMap = map; 270 customMap = map;
272} 271}
273 272
274} 273}
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 34df807..f246bfd 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -1,427 +1,426 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimtodo.h" 30#include "opimtodo.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimstate.h> 33#include <opie2/opimstate.h>
34#include <opie2/opimrecurrence.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimmaintainer.h> 35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h> 36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
39#include <qpe/stringutil.h>
40#include <qpe/palmtoprecord.h> 39#include <qpe/palmtoprecord.h>
41#include <qpe/stringutil.h>
42#include <qpe/categories.h> 40#include <qpe/categories.h>
43#include <qpe/categoryselect.h> 41#include <qpe/categoryselect.h>
42#include <qpe/stringutil.h>
44 43
45/* QT */ 44/* QT */
46#include <qobject.h> 45#include <qobject.h>
47#include <qshared.h> 46#include <qshared.h>
48 47
49namespace Opie 48namespace Opie
50{ 49{
51 50
52struct OPimTodo::OPimTodoData : public QShared 51struct OPimTodo::OPimTodoData : public QShared
53{ 52{
54 OPimTodoData() : QShared() 53 OPimTodoData() : QShared()
55 { 54 {
56 recur = 0; 55 recur = 0;
57 state = 0; 56 state = 0;
58 maintainer = 0; 57 maintainer = 0;
59 notifiers = 0; 58 notifiers = 0;
60 }; 59 };
61 ~OPimTodoData() 60 ~OPimTodoData()
62 { 61 {
63 delete recur; 62 delete recur;
64 delete maintainer; 63 delete maintainer;
65 delete notifiers; 64 delete notifiers;
66 } 65 }
67 66
68 QDate date; 67 QDate date;
69 bool isCompleted: 1; 68 bool isCompleted: 1;
70 bool hasDate: 1; 69 bool hasDate: 1;
71 int priority; 70 int priority;
72 QString desc; 71 QString desc;
73 QString sum; 72 QString sum;
74 QMap<QString, QString> extra; 73 QMap<QString, QString> extra;
75 ushort prog; 74 ushort prog;
76 OPimState *state; 75 OPimState *state;
77 OPimRecurrence *recur; 76 OPimRecurrence *recur;
78 OPimMaintainer *maintainer; 77 OPimMaintainer *maintainer;
79 QDate start; 78 QDate start;
80 QDate completed; 79 QDate completed;
81 OPimNotifyManager *notifiers; 80 OPimNotifyManager *notifiers;
82}; 81};
83 82
84 83
85OPimTodo::OPimTodo( const OPimTodo &event ) 84OPimTodo::OPimTodo( const OPimTodo &event )
86 : OPimRecord( event ), data( event.data ) 85 : OPimRecord( event ), data( event.data )
87{ 86{
88 data->ref(); 87 data->ref();
89 // qWarning("ref up"); 88 // qWarning("ref up");
90} 89}
91 90
92 91
93OPimTodo::~OPimTodo() 92OPimTodo::~OPimTodo()
94{ 93{
95 94
96 // qWarning("~OPimTodo " ); 95 // qWarning("~OPimTodo " );
97 if ( data->deref() ) 96 if ( data->deref() )
98 { 97 {
99 // qWarning("OPimTodo::dereffing"); 98 // qWarning("OPimTodo::dereffing");
100 delete data; 99 delete data;
101 data = 0l; 100 data = 0l;
102 } 101 }
103} 102}
104 103
105 104
106OPimTodo::OPimTodo( bool completed, int priority, 105OPimTodo::OPimTodo( bool completed, int priority,
107 const QArray<int> &category, 106 const QArray<int> &category,
108 const QString& summary, 107 const QString& summary,
109 const QString &description, 108 const QString &description,
110 ushort progress, 109 ushort progress,
111 bool hasDate, QDate date, int uid ) 110 bool hasDate, QDate date, int uid )
112 : OPimRecord( uid ) 111 : OPimRecord( uid )
113{ 112{
114 // qWarning("OPimTodoData " + summary); 113 // qWarning("OPimTodoData " + summary);
115 setCategories( category ); 114 setCategories( category );
116 115
117 data = new OPimTodoData; 116 data = new OPimTodoData;
118 117
119 data->date = date; 118 data->date = date;
120 data->isCompleted = completed; 119 data->isCompleted = completed;
121 data->hasDate = hasDate; 120 data->hasDate = hasDate;
122 data->priority = priority; 121 data->priority = priority;
123 data->sum = summary; 122 data->sum = summary;
124 data->prog = progress; 123 data->prog = progress;
125 data->desc = Qtopia::simplifyMultiLineSpace( description ); 124 data->desc = Qtopia::simplifyMultiLineSpace( description );
126} 125}
127 126
128 127
129OPimTodo::OPimTodo( bool completed, int priority, 128OPimTodo::OPimTodo( bool completed, int priority,
130 const QStringList &category, 129 const QStringList &category,
131 const QString& summary, 130 const QString& summary,
132 const QString &description, 131 const QString &description,
133 ushort progress, 132 ushort progress,
134 bool hasDate, QDate date, int uid ) 133 bool hasDate, QDate date, int uid )
135 : OPimRecord( uid ) 134 : OPimRecord( uid )
136{ 135{
137 // qWarning("OPimTodoData" + summary); 136 // qWarning("OPimTodoData" + summary);
138 setCategories( idsFromString( category.join( ";" ) ) ); 137 setCategories( idsFromString( category.join( ";" ) ) );
139 138
140 data = new OPimTodoData; 139 data = new OPimTodoData;
141 140
142 data->date = date; 141 data->date = date;
143 data->isCompleted = completed; 142 data->isCompleted = completed;
144 data->hasDate = hasDate; 143 data->hasDate = hasDate;
145 data->priority = priority; 144 data->priority = priority;
146 data->sum = summary; 145 data->sum = summary;
147 data->prog = progress; 146 data->prog = progress;
148 data->desc = Qtopia::simplifyMultiLineSpace( description ); 147 data->desc = Qtopia::simplifyMultiLineSpace( description );
149} 148}
150 149
151 150
152bool OPimTodo::match( const QRegExp &regExp ) const 151bool OPimTodo::match( const QRegExp &regExp ) const
153{ 152{
154 if ( QString::number( data->priority ).find( regExp ) != -1 ) 153 if ( QString::number( data->priority ).find( regExp ) != -1 )
155 { 154 {
156 setLastHitField( Priority ); 155 setLastHitField( Priority );
157 return true; 156 return true;
158 } 157 }
159 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) 158 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
160 { 159 {
161 setLastHitField( HasDate ); 160 setLastHitField( HasDate );
162 return true; 161 return true;
163 } 162 }
164 else if ( data->desc.find( regExp ) != -1 ) 163 else if ( data->desc.find( regExp ) != -1 )
165 { 164 {
166 setLastHitField( Description ); 165 setLastHitField( Description );
167 return true; 166 return true;
168 } 167 }
169 else if ( data->sum.find( regExp ) != -1 ) 168 else if ( data->sum.find( regExp ) != -1 )
170 { 169 {
171 setLastHitField( Summary ); 170 setLastHitField( Summary );
172 return true; 171 return true;
173 } 172 }
174 return false; 173 return false;
175} 174}
176 175
177 176
178bool OPimTodo::isCompleted() const 177bool OPimTodo::isCompleted() const
179{ 178{
180 return data->isCompleted; 179 return data->isCompleted;
181} 180}
182 181
183 182
184bool OPimTodo::hasDueDate() const 183bool OPimTodo::hasDueDate() const
185{ 184{
186 return data->hasDate; 185 return data->hasDate;
187} 186}
188 187
189 188
190bool OPimTodo::hasStartDate() const 189bool OPimTodo::hasStartDate() const
191{ 190{
192 return data->start.isValid(); 191 return data->start.isValid();
193} 192}
194 193
195 194
196bool OPimTodo::hasCompletedDate() const 195bool OPimTodo::hasCompletedDate() const
197{ 196{
198 return data->completed.isValid(); 197 return data->completed.isValid();
199} 198}
200 199
201 200
202int OPimTodo::priority() const 201int OPimTodo::priority() const
203{ 202{
204 return data->priority; 203 return data->priority;
205} 204}
206 205
207 206
208QString OPimTodo::summary() const 207QString OPimTodo::summary() const
209{ 208{
210 return data->sum; 209 return data->sum;
211} 210}
212 211
213 212
214ushort OPimTodo::progress() const 213ushort OPimTodo::progress() const
215{ 214{
216 return data->prog; 215 return data->prog;
217} 216}
218 217
219 218
220QDate OPimTodo::dueDate() const 219QDate OPimTodo::dueDate() const
221{ 220{
222 return data->date; 221 return data->date;
223} 222}
224 223
225 224
226QDate OPimTodo::startDate() const 225QDate OPimTodo::startDate() const
227{ 226{
228 return data->start; 227 return data->start;
229} 228}
230 229
231 230
232QDate OPimTodo::completedDate() const 231QDate OPimTodo::completedDate() const
233{ 232{
234 return data->completed; 233 return data->completed;
235} 234}
236 235
237 236
238QString OPimTodo::description() const 237QString OPimTodo::description() const
239{ 238{
240 return data->desc; 239 return data->desc;
241} 240}
242 241
243 242
244bool OPimTodo::hasState() const 243bool OPimTodo::hasState() const
245{ 244{
246 if ( !data->state ) return false; 245 if ( !data->state ) return false;
247 return ( data->state->state() != OPimState::Undefined ); 246 return ( data->state->state() != OPimState::Undefined );
248} 247}
249 248
250 249
251OPimState OPimTodo::state() const 250OPimState OPimTodo::state() const
252{ 251{
253 if ( !data->state ) 252 if ( !data->state )
254 { 253 {
255 OPimState state; 254 OPimState state;
256 return state; 255 return state;
257 } 256 }
258 257
259 return ( *data->state ); 258 return ( *data->state );
260} 259}
261 260
262 261
263bool OPimTodo::hasRecurrence() const 262bool OPimTodo::hasRecurrence() const
264{ 263{
265 if ( !data->recur ) return false; 264 if ( !data->recur ) return false;
266 return data->recur->doesRecur(); 265 return data->recur->doesRecur();
267} 266}
268 267
269 268
270OPimRecurrence OPimTodo::recurrence() const 269OPimRecurrence OPimTodo::recurrence() const
271{ 270{
272 if ( !data->recur ) return OPimRecurrence(); 271 if ( !data->recur ) return OPimRecurrence();
273 272
274 return ( *data->recur ); 273 return ( *data->recur );
275} 274}
276 275
277 276
278bool OPimTodo::hasMaintainer() const 277bool OPimTodo::hasMaintainer() const
279{ 278{
280 if ( !data->maintainer ) return false; 279 if ( !data->maintainer ) return false;
281 280
282 return ( data->maintainer->mode() != OPimMaintainer::Undefined ); 281 return ( data->maintainer->mode() != OPimMaintainer::Undefined );
283} 282}
284 283
285 284
286OPimMaintainer OPimTodo::maintainer() const 285OPimMaintainer OPimTodo::maintainer() const
287{ 286{
288 if ( !data->maintainer ) return OPimMaintainer(); 287 if ( !data->maintainer ) return OPimMaintainer();
289 288
290 return ( *data->maintainer ); 289 return ( *data->maintainer );
291} 290}
292 291
293 292
294void OPimTodo::setCompleted( bool completed ) 293void OPimTodo::setCompleted( bool completed )
295{ 294{
296 changeOrModify(); 295 changeOrModify();
297 data->isCompleted = completed; 296 data->isCompleted = completed;
298} 297}
299 298
300 299
301void OPimTodo::setHasDueDate( bool hasDate ) 300void OPimTodo::setHasDueDate( bool hasDate )
302{ 301{
303 changeOrModify(); 302 changeOrModify();
304 data->hasDate = hasDate; 303 data->hasDate = hasDate;
305} 304}
306 305
307 306
308void OPimTodo::setDescription( const QString &desc ) 307void OPimTodo::setDescription( const QString &desc )
309{ 308{
310 // qWarning( "desc " + desc ); 309 // qWarning( "desc " + desc );
311 changeOrModify(); 310 changeOrModify();
312 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 311 data->desc = Qtopia::simplifyMultiLineSpace( desc );
313} 312}
314 313
315 314
316void OPimTodo::setSummary( const QString& sum ) 315void OPimTodo::setSummary( const QString& sum )
317{ 316{
318 changeOrModify(); 317 changeOrModify();
319 data->sum = sum; 318 data->sum = sum;
320} 319}
321 320
322 321
323void OPimTodo::setPriority( int prio ) 322void OPimTodo::setPriority( int prio )
324{ 323{
325 changeOrModify(); 324 changeOrModify();
326 data->priority = prio; 325 data->priority = prio;
327} 326}
328 327
329 328
330void OPimTodo::setDueDate( const QDate& date ) 329void OPimTodo::setDueDate( const QDate& date )
331{ 330{
332 changeOrModify(); 331 changeOrModify();
333 data->date = date; 332 data->date = date;
334} 333}
335 334
336 335
337void OPimTodo::setStartDate( const QDate& date ) 336void OPimTodo::setStartDate( const QDate& date )
338{ 337{
339 changeOrModify(); 338 changeOrModify();
340 data->start = date; 339 data->start = date;
341} 340}
342 341
343 342
344void OPimTodo::setCompletedDate( const QDate& date ) 343void OPimTodo::setCompletedDate( const QDate& date )
345{ 344{
346 changeOrModify(); 345 changeOrModify();
347 data->completed = date; 346 data->completed = date;
348} 347}
349 348
350 349
351void OPimTodo::setState( const OPimState& state ) 350void OPimTodo::setState( const OPimState& state )
352{ 351{
353 changeOrModify(); 352 changeOrModify();
354 if ( data->state ) 353 if ( data->state )
355 ( *data->state ) = state; 354 ( *data->state ) = state;
356 else 355 else
357 data->state = new OPimState( state ); 356 data->state = new OPimState( state );
358} 357}
359 358
360 359
361void OPimTodo::setRecurrence( const OPimRecurrence& rec ) 360void OPimTodo::setRecurrence( const OPimRecurrence& rec )
362{ 361{
363 changeOrModify(); 362 changeOrModify();
364 if ( data->recur ) 363 if ( data->recur )
365 ( *data->recur ) = rec; 364 ( *data->recur ) = rec;
366 else 365 else
367 data->recur = new OPimRecurrence( rec ); 366 data->recur = new OPimRecurrence( rec );
368} 367}
369 368
370 369
371void OPimTodo::setMaintainer( const OPimMaintainer& pim ) 370void OPimTodo::setMaintainer( const OPimMaintainer& pim )
372{ 371{
373 changeOrModify(); 372 changeOrModify();
374 373
375 if ( data->maintainer ) 374 if ( data->maintainer )
376 ( *data->maintainer ) = pim; 375 ( *data->maintainer ) = pim;
377 else 376 else
378 data->maintainer = new OPimMaintainer( pim ); 377 data->maintainer = new OPimMaintainer( pim );
379} 378}
380 379
381 380
382bool OPimTodo::isOverdue( ) 381bool OPimTodo::isOverdue( )
383{ 382{
384 if ( data->hasDate && !data->isCompleted ) 383 if ( data->hasDate && !data->isCompleted )
385 return QDate::currentDate() > data->date; 384 return QDate::currentDate() > data->date;
386 return false; 385 return false;
387} 386}
388 387
389 388
390void OPimTodo::setProgress( ushort progress ) 389void OPimTodo::setProgress( ushort progress )
391{ 390{
392 changeOrModify(); 391 changeOrModify();
393 data->prog = progress; 392 data->prog = progress;
394} 393}
395 394
396 395
397QString OPimTodo::toShortText() const 396QString OPimTodo::toShortText() const
398{ 397{
399 return summary(); 398 return summary();
400} 399}
401 400
402 401
403/*! 402/*!
404 Returns a richt text string 403 Returns a richt text string
405*/ 404*/
406QString OPimTodo::toRichText() const 405QString OPimTodo::toRichText() const
407{ 406{
408 QString text; 407 QString text;
409 QStringList catlist; 408 QStringList catlist;
410 409
411 // summary 410 // summary
412 text += "<b><h3><img src=\"todo/TodoList\"> "; 411 text += "<b><h3><img src=\"todo/TodoList\"> ";
413 if ( !summary().isEmpty() ) 412 if ( !summary().isEmpty() )
414 { 413 {
415 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); 414 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" );
416 } 415 }
417 text += "</h3></b><br><hr><br>"; 416 text += "</h3></b><br><hr><br>";
418 417
419 // description 418 // description
420 if ( !description().isEmpty() ) 419 if ( !description().isEmpty() )
421 { 420 {
422 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 421 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
423 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 422 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
424 } 423 }
425 424
426 // priority 425 // priority
427 int priorityval = priority(); 426 int priorityval = priority();
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index 49628c9..49ddeb6 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.cpp
@@ -1,423 +1,422 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org> 3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/ofontselector.h> 31#include <opie2/ofontselector.h>
32#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33 33
34/* QT */ 34/* QT */
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qlistbox.h> 36#include <qlistbox.h>
37#include <qcombobox.h> 37#include <qcombobox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qfont.h>
40#include <qmultilineedit.h> 39#include <qmultilineedit.h>
41 40
42using namespace Opie; 41using namespace Opie;
43 42
44namespace Opie 43namespace Opie
45{ 44{
46 45
47class OFontSelectorPrivate 46class OFontSelectorPrivate
48{ 47{
49public: 48public:
50 QListBox * m_font_family_list; 49 QListBox * m_font_family_list;
51 QComboBox * m_font_style_list; 50 QComboBox * m_font_style_list;
52 QComboBox * m_font_size_list; 51 QComboBox * m_font_size_list;
53 QMultiLineEdit *m_preview; 52 QMultiLineEdit *m_preview;
54 53
55 bool m_pointbug : 1; 54 bool m_pointbug : 1;
56 55
57 FontDatabase m_fdb; 56 FontDatabase m_fdb;
58}; 57};
59 58
60}; 59};
61 60
62namespace 61namespace
63{ 62{
64 63
65class FontListItem : public QListBoxText 64class FontListItem : public QListBoxText
66{ 65{
67public: 66public:
68 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() 67 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText()
69 { 68 {
70 m_name = t; 69 m_name = t;
71 m_styles = styles; 70 m_styles = styles;
72 m_sizes = sizes; 71 m_sizes = sizes;
73 72
74 QString str = t; 73 QString str = t;
75 str [0] = str [0]. upper(); 74 str [0] = str [0]. upper();
76 setText ( str ); 75 setText ( str );
77 } 76 }
78 77
79 QString family() const 78 QString family() const
80 { 79 {
81 return m_name; 80 return m_name;
82 } 81 }
83 82
84 const QStringList &styles() const 83 const QStringList &styles() const
85 { 84 {
86 return m_styles; 85 return m_styles;
87 } 86 }
88 87
89 const QValueList<int> &sizes() const 88 const QValueList<int> &sizes() const
90 { 89 {
91 return m_sizes; 90 return m_sizes;
92 } 91 }
93 92
94private: 93private:
95 QStringList m_styles; 94 QStringList m_styles;
96 QValueList<int> m_sizes; 95 QValueList<int> m_sizes;
97 QString m_name; 96 QString m_name;
98}; 97};
99 98
100 99
101static int findItemCB( QComboBox *box, const QString &str ) 100static int findItemCB( QComboBox *box, const QString &str )
102{ 101{
103 for ( int i = 0; i < box->count(); i++ ) 102 for ( int i = 0; i < box->count(); i++ )
104 { 103 {
105 if ( box->text ( i ) == str ) 104 if ( box->text ( i ) == str )
106 return i; 105 return i;
107 } 106 }
108 return -1; 107 return -1;
109} 108}
110 109
111} 110}
112/* static same as anon. namespace */ 111/* static same as anon. namespace */
113static int qt_version() 112static int qt_version()
114{ 113{
115 const char *qver = qVersion(); 114 const char *qver = qVersion();
116 115
117 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
118} 117}
119 118
120/** 119/**
121 * Constructs the Selector object 120 * Constructs the Selector object
122 * @param withpreview If a font preview should be given 121 * @param withpreview If a font preview should be given
123 * @param parent The parent of the Font Selector 122 * @param parent The parent of the Font Selector
124 * @param name The name of the object 123 * @param name The name of the object
125 * @param fl WidgetFlags 124 * @param fl WidgetFlags
126 */ 125 */
127OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
128{ 127{
129 d = new OFontSelectorPrivate(); 128 d = new OFontSelectorPrivate();
130 129
131 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); 130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
132 gridLayout->setRowStretch( 4, 10 ); 131 gridLayout->setRowStretch( 4, 10 );
133 132
134 d->m_font_family_list = new QListBox( this, "FontListBox" ); 133 d->m_font_family_list = new QListBox( this, "FontListBox" );
135 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); 134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
136 connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); 135 connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) );
137 136
138 QLabel *label = new QLabel( tr( "Style" ), this ); 137 QLabel *label = new QLabel( tr( "Style" ), this );
139 gridLayout->addWidget( label, 0, 1 ); 138 gridLayout->addWidget( label, 0, 1 );
140 139
141 d->m_font_style_list = new QComboBox( this, "StyleListBox" ); 140 d->m_font_style_list = new QComboBox( this, "StyleListBox" );
142 connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); 141 connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) );
143 gridLayout->addWidget( d->m_font_style_list, 1, 1 ); 142 gridLayout->addWidget( d->m_font_style_list, 1, 1 );
144 143
145 label = new QLabel( tr( "Size" ), this ); 144 label = new QLabel( tr( "Size" ), this );
146 gridLayout->addWidget( label, 2, 1 ); 145 gridLayout->addWidget( label, 2, 1 );
147 146
148 d->m_font_size_list = new QComboBox( this, "SizeListBox" ); 147 d->m_font_size_list = new QComboBox( this, "SizeListBox" );
149 connect( d->m_font_size_list, SIGNAL( activated( int ) ), 148 connect( d->m_font_size_list, SIGNAL( activated( int ) ),
150 this, SLOT( fontSizeClicked( int ) ) ); 149 this, SLOT( fontSizeClicked( int ) ) );
151 gridLayout->addWidget( d->m_font_size_list, 3, 1 ); 150 gridLayout->addWidget( d->m_font_size_list, 3, 1 );
152 151
153 d->m_pointbug = ( qt_version() <= 233 ); 152 d->m_pointbug = ( qt_version() <= 233 );
154 153
155 if ( withpreview ) 154 if ( withpreview )
156 { 155 {
157 d->m_preview = new QMultiLineEdit ( this, "Preview" ); 156 d->m_preview = new QMultiLineEdit ( this, "Preview" );
158 d->m_preview->setAlignment ( AlignCenter ); 157 d->m_preview->setAlignment ( AlignCenter );
159 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); 158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
160 d->m_preview->setMargin ( 3 ); 159 d->m_preview->setMargin ( 3 );
161 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
162 gridLayout->addRowSpacing ( 5, 4 ); 161 gridLayout->addRowSpacing ( 5, 4 );
163 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); 162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
164 gridLayout->setRowStretch ( 6, 5 ); 163 gridLayout->setRowStretch ( 6, 5 );
165 } 164 }
166 else 165 else
167 d->m_preview = 0; 166 d->m_preview = 0;
168 167
169 loadFonts ( d->m_font_family_list ); 168 loadFonts ( d->m_font_family_list );
170} 169}
171 170
172OFontSelector::~OFontSelector() 171OFontSelector::~OFontSelector()
173{ 172{
174 delete d; 173 delete d;
175} 174}
176 175
177/** 176/**
178 * This methods tries to set the font 177 * This methods tries to set the font
179 * @param f The wishes font 178 * @param f The wishes font
180 * @return success or failure 179 * @return success or failure
181 */ 180 */
182bool OFontSelector::setSelectedFont ( const QFont &f ) 181bool OFontSelector::setSelectedFont ( const QFont &f )
183{ 182{
184 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); 183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
185} 184}
186 185
187 186
188/** 187/**
189 * This is an overloaded method @see setSelectedFont 188 * This is an overloaded method @see setSelectedFont
190 * @param familyStr The family of the font 189 * @param familyStr The family of the font
191 * @param styleStr The style of the font 190 * @param styleStr The style of the font
192 * @param sizeVal The size of font 191 * @param sizeVal The size of font
193 * @param charset The charset to be used. Will be deprecated by QT3 192 * @param charset The charset to be used. Will be deprecated by QT3
194 */ 193 */
195bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
196{ 195{
197 QString sizeStr = QString::number ( sizeVal ); 196 QString sizeStr = QString::number ( sizeVal );
198 197
199 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); 198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
200 if ( !family ) 199 if ( !family )
201 family = d->m_font_family_list->findItem ( "Helvetica" ); 200 family = d->m_font_family_list->findItem ( "Helvetica" );
202 if ( !family ) 201 if ( !family )
203 family = d->m_font_family_list->firstItem(); 202 family = d->m_font_family_list->firstItem();
204 d->m_font_family_list->setCurrentItem ( family ); 203 d->m_font_family_list->setCurrentItem ( family );
205 fontFamilyClicked ( d->m_font_family_list->index ( family )); 204 fontFamilyClicked ( d->m_font_family_list->index ( family ));
206 205
207 int style = findItemCB ( d->m_font_style_list, styleStr ); 206 int style = findItemCB ( d->m_font_style_list, styleStr );
208 if ( style < 0 ) 207 if ( style < 0 )
209 style = findItemCB ( d->m_font_style_list, "Regular" ); 208 style = findItemCB ( d->m_font_style_list, "Regular" );
210 if ( style < 0 && d->m_font_style_list->count() > 0 ) 209 if ( style < 0 && d->m_font_style_list->count() > 0 )
211 style = 0; 210 style = 0;
212 d->m_font_style_list->setCurrentItem ( style ); 211 d->m_font_style_list->setCurrentItem ( style );
213 fontStyleClicked ( style ); 212 fontStyleClicked ( style );
214 213
215 int size = findItemCB ( d->m_font_size_list, sizeStr ); 214 int size = findItemCB ( d->m_font_size_list, sizeStr );
216 if ( size < 0 ) 215 if ( size < 0 )
217 size = findItemCB ( d->m_font_size_list, "10" ); 216 size = findItemCB ( d->m_font_size_list, "10" );
218 if ( size < 0 && d->m_font_size_list->count() > 0 ) 217 if ( size < 0 && d->m_font_size_list->count() > 0 )
219 size = 0; 218 size = 0;
220 d->m_font_size_list->setCurrentItem ( size ); 219 d->m_font_size_list->setCurrentItem ( size );
221 fontSizeClicked ( size ); 220 fontSizeClicked ( size );
222 221
223 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 222 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
224} 223}
225 224
226/** 225/**
227 * This method returns the name, style and size of the currently selected 226 * This method returns the name, style and size of the currently selected
228 * font or false if no font is selected 227 * font or false if no font is selected
229 * @param family The font family will be written there 228 * @param family The font family will be written there
230 * @param style The style will be written there 229 * @param style The style will be written there
231 * @param size The size will be written there 230 * @param size The size will be written there
232 * @return success or failure 231 * @return success or failure
233 */ 232 */
234bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 233bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
235{ 234{
236 QString dummy; 235 QString dummy;
237 return selectedFont ( family, style, size, dummy ); 236 return selectedFont ( family, style, size, dummy );
238} 237}
239 238
240 239
241/** 240/**
242 * This method does return the font family or QString::null if there is 241 * This method does return the font family or QString::null if there is
243 * no font item selected 242 * no font item selected
244 * @return the font family 243 * @return the font family
245 */ 244 */
246QString OFontSelector::fontFamily() const 245QString OFontSelector::fontFamily() const
247{ 246{
248 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 247 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
249 248
250 return fli ? fli->family() : QString::null; 249 return fli ? fli->family() : QString::null;
251} 250}
252 251
253/** 252/**
254 * This method will return the style of the font or QString::null 253 * This method will return the style of the font or QString::null
255 * @return the style of the font 254 * @return the style of the font
256 */ 255 */
257QString OFontSelector::fontStyle() const 256QString OFontSelector::fontStyle() const
258{ 257{
259 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 258 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
260 int fst = d->m_font_style_list->currentItem(); 259 int fst = d->m_font_style_list->currentItem();
261 260
262 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; 261 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null;
263} 262}
264 263
265/** 264/**
266 * This method will return the font size or 10 if no font size is available 265 * This method will return the font size or 10 if no font size is available
267 */ 266 */
268int OFontSelector::fontSize() const 267int OFontSelector::fontSize() const
269{ 268{
270 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 269 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
271 int fsi = d->m_font_size_list->currentItem(); 270 int fsi = d->m_font_size_list->currentItem();
272 271
273 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; 272 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10;
274} 273}
275 274
276/** 275/**
277 * returns the charset of the font or QString::null 276 * returns the charset of the font or QString::null
278 */ 277 */
279QString OFontSelector::fontCharSet() const 278QString OFontSelector::fontCharSet() const
280{ 279{
281 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 280 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
282 281
283 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; 282 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null;
284} 283}
285 284
286/** 285/**
287 * Overloaded member function see above 286 * Overloaded member function see above
288 * @see selectedFont 287 * @see selectedFont
289 */ 288 */
290bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 289bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
291{ 290{
292 int ffa = d->m_font_family_list->currentItem(); 291 int ffa = d->m_font_family_list->currentItem();
293 int fst = d->m_font_style_list->currentItem(); 292 int fst = d->m_font_style_list->currentItem();
294 int fsi = d->m_font_size_list->currentItem(); 293 int fsi = d->m_font_size_list->currentItem();
295 294
296 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); 295 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa );
297 296
298 if ( fli ) 297 if ( fli )
299 { 298 {
300 family = fli->family(); 299 family = fli->family();
301 style = fst >= 0 ? fli->styles() [fst] : QString::null; 300 style = fst >= 0 ? fli->styles() [fst] : QString::null;
302 size = fsi >= 0 ? fli->sizes() [fsi] : 10; 301 size = fsi >= 0 ? fli->sizes() [fsi] : 10;
303 charset = d->m_fdb. charSets ( fli->family()) [0]; 302 charset = d->m_fdb. charSets ( fli->family()) [0];
304 303
305 return true; 304 return true;
306 } 305 }
307 else 306 else
308 return false; 307 return false;
309} 308}
310 309
311void OFontSelector::loadFonts ( QListBox *list ) 310void OFontSelector::loadFonts ( QListBox *list )
312{ 311{
313 QStringList f = d->m_fdb. families(); 312 QStringList f = d->m_fdb. families();
314 313
315 for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it ) 314 for ( QStringList::ConstIterator it = f. begin(); it != f. end(); ++it )
316 { 315 {
317 QValueList <int> ps = d->m_fdb. pointSizes ( *it ); 316 QValueList <int> ps = d->m_fdb. pointSizes ( *it );
318 317
319 if ( d->m_pointbug ) 318 if ( d->m_pointbug )
320 { 319 {
321 for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ ) 320 for ( QValueList <int>::Iterator it = ps. begin(); it != ps. end(); it++ )
322 *it /= 10; 321 *it /= 10;
323 } 322 }
324 323
325 list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps )); 324 list->insertItem ( new FontListItem ( *it, d->m_fdb. styles ( *it ), ps ));
326 } 325 }
327} 326}
328 327
329void OFontSelector::fontFamilyClicked ( int index ) 328void OFontSelector::fontFamilyClicked ( int index )
330{ 329{
331 QString oldstyle = d->m_font_style_list->currentText(); 330 QString oldstyle = d->m_font_style_list->currentText();
332 QString oldsize = d->m_font_size_list->currentText(); 331 QString oldsize = d->m_font_size_list->currentText();
333 332
334 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index ); 333 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( index );
335 334
336 d->m_font_style_list->clear(); 335 d->m_font_style_list->clear();
337 d->m_font_style_list->insertStringList ( fli->styles()); 336 d->m_font_style_list->insertStringList ( fli->styles());
338 d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty()); 337 d->m_font_style_list->setEnabled ( !fli->styles(). isEmpty());
339 338
340 int i; 339 int i;
341 340
342 i = findItemCB ( d->m_font_style_list, oldstyle ); 341 i = findItemCB ( d->m_font_style_list, oldstyle );
343 if ( i < 0 ) 342 if ( i < 0 )
344 i = findItemCB ( d->m_font_style_list, "Regular" ); 343 i = findItemCB ( d->m_font_style_list, "Regular" );
345 if (( i < 0 ) && ( d->m_font_style_list->count() > 0 )) 344 if (( i < 0 ) && ( d->m_font_style_list->count() > 0 ))
346 i = 0; 345 i = 0;
347 346
348 if ( i >= 0 ) 347 if ( i >= 0 )
349 { 348 {
350 d->m_font_style_list->setCurrentItem ( i ); 349 d->m_font_style_list->setCurrentItem ( i );
351 fontStyleClicked ( i ); 350 fontStyleClicked ( i );
352 } 351 }
353 352
354 d->m_font_size_list->clear(); 353 d->m_font_size_list->clear();
355 QValueList<int> sl = fli->sizes(); 354 QValueList<int> sl = fli->sizes();
356 355
357 for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it ) 356 for ( QValueList<int>::Iterator it = sl. begin(); it != sl. end(); ++it )
358 d->m_font_size_list->insertItem ( QString::number ( *it )); 357 d->m_font_size_list->insertItem ( QString::number ( *it ));
359 358
360 i = findItemCB ( d->m_font_size_list, oldsize ); 359 i = findItemCB ( d->m_font_size_list, oldsize );
361 if ( i < 0 ) 360 if ( i < 0 )
362 i = findItemCB ( d->m_font_size_list, "10" ); 361 i = findItemCB ( d->m_font_size_list, "10" );
363 if (( i < 0 ) && ( d->m_font_size_list->count() > 0 )) 362 if (( i < 0 ) && ( d->m_font_size_list->count() > 0 ))
364 i = 0; 363 i = 0;
365 364
366 if ( i >= 0 ) 365 if ( i >= 0 )
367 { 366 {
368 d->m_font_size_list->setCurrentItem ( i ); 367 d->m_font_size_list->setCurrentItem ( i );
369 fontSizeClicked ( i ); 368 fontSizeClicked ( i );
370 } 369 }
371 changeFont(); 370 changeFont();
372} 371}
373 372
374void OFontSelector::fontStyleClicked ( int /*index*/ ) 373void OFontSelector::fontStyleClicked ( int /*index*/ )
375{ 374{
376 changeFont(); 375 changeFont();
377} 376}
378 377
379void OFontSelector::fontSizeClicked ( int /*index*/ ) 378void OFontSelector::fontSizeClicked ( int /*index*/ )
380{ 379{
381 changeFont(); 380 changeFont();
382} 381}
383 382
384void OFontSelector::changeFont() 383void OFontSelector::changeFont()
385{ 384{
386 QFont f = selectedFont(); 385 QFont f = selectedFont();
387 386
388 if ( d->m_preview ) 387 if ( d->m_preview )
389 d->m_preview->setFont ( f ); 388 d->m_preview->setFont ( f );
390 389
391 emit fontSelected ( f ); 390 emit fontSelected ( f );
392} 391}
393 392
394/** 393/**
395 * Return the selected font 394 * Return the selected font
396 */ 395 */
397QFont OFontSelector::selectedFont() 396QFont OFontSelector::selectedFont()
398{ 397{
399 int ffa = d->m_font_family_list->currentItem(); 398 int ffa = d->m_font_family_list->currentItem();
400 int fst = d->m_font_style_list->currentItem(); 399 int fst = d->m_font_style_list->currentItem();
401 int fsi = d->m_font_size_list->currentItem(); 400 int fsi = d->m_font_size_list->currentItem();
402 401
403 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa ); 402 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( ffa );
404 403
405 if ( fli ) 404 if ( fli )
406 { 405 {
407 return d->m_fdb. font ( fli->family(), \ 406 return d->m_fdb. font ( fli->family(), \
408 fst >= 0 ? fli->styles() [fst] : QString::null, \ 407 fst >= 0 ? fli->styles() [fst] : QString::null, \
409 fsi >= 0 ? fli->sizes() [fsi] : 10, \ 408 fsi >= 0 ? fli->sizes() [fsi] : 10, \
410 d->m_fdb. charSets ( fli->family()) [0] ); 409 d->m_fdb. charSets ( fli->family()) [0] );
411 } 410 }
412 else 411 else
413 return QFont(); 412 return QFont();
414} 413}
415 414
416void OFontSelector::resizeEvent ( QResizeEvent *re ) 415void OFontSelector::resizeEvent ( QResizeEvent *re )
417{ 416{
418 if ( d->m_preview ) 417 if ( d->m_preview )
419 { 418 {
420 d->m_preview->setMinimumHeight ( 1 ); 419 d->m_preview->setMinimumHeight ( 1 );
421 d->m_preview->setMaximumHeight ( 32767 ); 420 d->m_preview->setMaximumHeight ( 32767 );
422 } 421 }
423 422
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index 38f3fe2..84617f8 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -1,418 +1,415 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
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 29
30/* QT */ 30/* QT */
31 31
32#include <qcolor.h>
33#include <qheader.h>
34#include <qpainter.h>
35#include <qpixmap.h> 32#include <qpixmap.h>
36 33
37/* OPIE */ 34/* OPIE */
38 35
39#include <opie2/odebug.h> 36#include <opie2/odebug.h>
40#include <opie2/olistview.h> 37#include <opie2/olistview.h>
41 38
42/*====================================================================================== 39/*======================================================================================
43 * OListView 40 * OListView
44 *======================================================================================*/ 41 *======================================================================================*/
45 42
46OListView::OListView( QWidget *parent, const char *name ) 43OListView::OListView( QWidget *parent, const char *name )
47 :QListView( parent, name ) 44 :QListView( parent, name )
48{ 45{
49 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 46 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
50 47
51 m_alternateBackground = QColor( 238, 246, 255 ); 48 m_alternateBackground = QColor( 238, 246, 255 );
52 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 49 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
53 m_fullWidth = true; 50 m_fullWidth = true;
54 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 51 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
55} 52}
56 53
57OListView::~OListView() 54OListView::~OListView()
58{ 55{
59} 56}
60 57
61void OListView::setFullWidth( bool fullWidth ) 58void OListView::setFullWidth( bool fullWidth )
62{ 59{
63 m_fullWidth = m_fullWidth; 60 m_fullWidth = m_fullWidth;
64 #if QT_VERSION > 290 61 #if QT_VERSION > 290
65 header()->setStretchEnabled( fullWidth, columns()-1 ); 62 header()->setStretchEnabled( fullWidth, columns()-1 );
66 #endif 63 #endif
67} 64}
68 65
69bool OListView::fullWidth() const 66bool OListView::fullWidth() const
70{ 67{
71 return m_fullWidth; 68 return m_fullWidth;
72} 69}
73 70
74int OListView::addColumn( const QString& label, int width ) 71int OListView::addColumn( const QString& label, int width )
75{ 72{
76 int result = QListView::addColumn( label, width ); 73 int result = QListView::addColumn( label, width );
77 #if QT_VERSION > 290 74 #if QT_VERSION > 290
78 if (m_fullWidth) { 75 if (m_fullWidth) {
79 header()->setStretchEnabled( false, columns()-2 ); 76 header()->setStretchEnabled( false, columns()-2 );
80 header()->setStretchEnabled( true, columns()-1 ); 77 header()->setStretchEnabled( true, columns()-1 );
81 } 78 }
82 #endif 79 #endif
83 return result; 80 return result;
84} 81}
85 82
86int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 83int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
87{ 84{
88 int result = QListView::addColumn( iconset, label, width ); 85 int result = QListView::addColumn( iconset, label, width );
89 #if QT_VERSION > 290 86 #if QT_VERSION > 290
90 if (m_fullWidth) { 87 if (m_fullWidth) {
91 header()->setStretchEnabled( false, columns()-2 ); 88 header()->setStretchEnabled( false, columns()-2 );
92 header()->setStretchEnabled( true, columns()-1 ); 89 header()->setStretchEnabled( true, columns()-1 );
93 } 90 }
94 #endif 91 #endif
95 return result; 92 return result;
96} 93}
97 94
98void OListView::removeColumn( int index ) 95void OListView::removeColumn( int index )
99{ 96{
100 QListView::removeColumn(index); 97 QListView::removeColumn(index);
101 #if QT_VERSION > 290 98 #if QT_VERSION > 290
102 if ( m_fullWidth && index == columns() ) 99 if ( m_fullWidth && index == columns() )
103 { 100 {
104 header()->setStretchEnabled( true, columns()-1 ); 101 header()->setStretchEnabled( true, columns()-1 );
105 } 102 }
106 #endif 103 #endif
107} 104}
108 105
109const QColor& OListView::alternateBackground() const 106const QColor& OListView::alternateBackground() const
110{ 107{
111 return m_alternateBackground; 108 return m_alternateBackground;
112} 109}
113 110
114void OListView::setAlternateBackground( const QColor &c ) 111void OListView::setAlternateBackground( const QColor &c )
115{ 112{
116 m_alternateBackground = c; 113 m_alternateBackground = c;
117 repaint(); 114 repaint();
118} 115}
119 116
120const QPen& OListView::columnSeparator() const 117const QPen& OListView::columnSeparator() const
121{ 118{
122 return m_columnSeparator; 119 return m_columnSeparator;
123} 120}
124 121
125void OListView::setColumnSeparator( const QPen& p ) 122void OListView::setColumnSeparator( const QPen& p )
126{ 123{
127 m_columnSeparator = p; 124 m_columnSeparator = p;
128 repaint(); 125 repaint();
129} 126}
130 127
131void OListView::expand(QListViewItem *item) 128void OListView::expand(QListViewItem *item)
132{ 129{
133 ((OListViewItem*)item)->expand(); 130 ((OListViewItem*)item)->expand();
134} 131}
135 132
136OListViewItem* OListView::childFactory() 133OListViewItem* OListView::childFactory()
137{ 134{
138 return new OListViewItem( this ); 135 return new OListViewItem( this );
139} 136}
140 137
141#ifndef QT_NO_DATASTREAM 138#ifndef QT_NO_DATASTREAM
142void OListView::serializeTo( QDataStream& s ) const 139void OListView::serializeTo( QDataStream& s ) const
143{ 140{
144 #warning Caution... the binary format is still under construction... 141 #warning Caution... the binary format is still under construction...
145 odebug << "storing OListView..." << oendl; 142 odebug << "storing OListView..." << oendl;
146 143
147 // store number of columns and the labels 144 // store number of columns and the labels
148 s << columns(); 145 s << columns();
149 for ( int i = 0; i < columns(); ++i ) 146 for ( int i = 0; i < columns(); ++i )
150 s << columnText( i ); 147 s << columnText( i );
151 148
152 // calculate the number of top-level items to serialize 149 // calculate the number of top-level items to serialize
153 int items = 0; 150 int items = 0;
154 QListViewItem* item = firstChild(); 151 QListViewItem* item = firstChild();
155 while ( item ) 152 while ( item )
156 { 153 {
157 item = item->nextSibling(); 154 item = item->nextSibling();
158 items++; 155 items++;
159 } 156 }
160 157
161 // store number of items and the items itself 158 // store number of items and the items itself
162 s << items; 159 s << items;
163 item = firstChild(); 160 item = firstChild();
164 for ( int i = 0; i < items; ++i ) 161 for ( int i = 0; i < items; ++i )
165 { 162 {
166 s << *static_cast<OListViewItem*>( item ); 163 s << *static_cast<OListViewItem*>( item );
167 item = item->nextSibling(); 164 item = item->nextSibling();
168 } 165 }
169 166
170 odebug << "OListview stored." << oendl; 167 odebug << "OListview stored." << oendl;
171} 168}
172 169
173void OListView::serializeFrom( QDataStream& s ) 170void OListView::serializeFrom( QDataStream& s )
174{ 171{
175 #warning Caution... the binary format is still under construction... 172 #warning Caution... the binary format is still under construction...
176 odebug << "loading OListView..." << oendl; 173 odebug << "loading OListView..." << oendl;
177 174
178 int cols; 175 int cols;
179 s >> cols; 176 s >> cols;
180 qDebug( "read number of columns = %d", cols ); 177 qDebug( "read number of columns = %d", cols );
181 178
182 while ( columns() < cols ) addColumn( QString::null ); 179 while ( columns() < cols ) addColumn( QString::null );
183 180
184 for ( int i = 0; i < cols; ++i ) 181 for ( int i = 0; i < cols; ++i )
185 { 182 {
186 QString coltext; 183 QString coltext;
187 s >> coltext; 184 s >> coltext;
188 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 185 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
189 setColumnText( i, coltext ); 186 setColumnText( i, coltext );
190 } 187 }
191 188
192 int items; 189 int items;
193 s >> items; 190 s >> items;
194 qDebug( "read number of items = %d", items ); 191 qDebug( "read number of items = %d", items );
195 192
196 for ( int i = 0; i < items; ++i ) 193 for ( int i = 0; i < items; ++i )
197 { 194 {
198 OListViewItem* item = childFactory(); 195 OListViewItem* item = childFactory();
199 s >> *item; 196 s >> *item;
200 } 197 }
201 198
202 odebug << "OListView loaded." << oendl; 199 odebug << "OListView loaded." << oendl;
203 200
204} 201}
205 202
206QDataStream& operator<<( QDataStream& s, const OListView& lv ) 203QDataStream& operator<<( QDataStream& s, const OListView& lv )
207{ 204{
208 lv.serializeTo( s ); 205 lv.serializeTo( s );
209} 206}
210 207
211QDataStream& operator>>( QDataStream& s, OListView& lv ) 208QDataStream& operator>>( QDataStream& s, OListView& lv )
212{ 209{
213 lv.serializeFrom( s ); 210 lv.serializeFrom( s );
214} 211}
215#endif // QT_NO_DATASTREAM 212#endif // QT_NO_DATASTREAM
216 213
217/*====================================================================================== 214/*======================================================================================
218 * OListViewItem 215 * OListViewItem
219 *======================================================================================*/ 216 *======================================================================================*/
220 217
221OListViewItem::OListViewItem(QListView *parent) 218OListViewItem::OListViewItem(QListView *parent)
222 : QListViewItem(parent) 219 : QListViewItem(parent)
223{ 220{
224 init(); 221 init();
225} 222}
226 223
227 224
228OListViewItem::OListViewItem(QListViewItem *parent) 225OListViewItem::OListViewItem(QListViewItem *parent)
229 : QListViewItem(parent) 226 : QListViewItem(parent)
230{ 227{
231 init(); 228 init();
232} 229}
233 230
234 231
235OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 232OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
236 : QListViewItem(parent, after) 233 : QListViewItem(parent, after)
237{ 234{
238 init(); 235 init();
239} 236}
240 237
241 238
242OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 239OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
243 : QListViewItem(parent, after) 240 : QListViewItem(parent, after)
244{ 241{
245 init(); 242 init();
246} 243}
247 244
248 245
249OListViewItem::OListViewItem(QListView *parent, 246OListViewItem::OListViewItem(QListView *parent,
250 QString label1, QString label2, QString label3, QString label4, 247 QString label1, QString label2, QString label3, QString label4,
251 QString label5, QString label6, QString label7, QString label8) 248 QString label5, QString label6, QString label7, QString label8)
252 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 249 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
253{ 250{
254 init(); 251 init();
255} 252}
256 253
257 254
258OListViewItem::OListViewItem(QListViewItem *parent, 255OListViewItem::OListViewItem(QListViewItem *parent,
259 QString label1, QString label2, QString label3, QString label4, 256 QString label1, QString label2, QString label3, QString label4,
260 QString label5, QString label6, QString label7, QString label8) 257 QString label5, QString label6, QString label7, QString label8)
261 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 258 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
262{ 259{
263 init(); 260 init();
264} 261}
265 262
266 263
267OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, 264OListViewItem::OListViewItem(QListView *parent, QListViewItem *after,
268 QString label1, QString label2, QString label3, QString label4, 265 QString label1, QString label2, QString label3, QString label4,
269 QString label5, QString label6, QString label7, QString label8) 266 QString label5, QString label6, QString label7, QString label8)
270 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 267 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
271{ 268{
272 init(); 269 init();
273} 270}
274 271
275 272
276OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, 273OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after,
277 QString label1, QString label2, QString label3, QString label4, 274 QString label1, QString label2, QString label3, QString label4,
278 QString label5, QString label6, QString label7, QString label8) 275 QString label5, QString label6, QString label7, QString label8)
279 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 276 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
280{ 277{
281 init(); 278 init();
282} 279}
283 280
284 281
285OListViewItem::~OListViewItem() 282OListViewItem::~OListViewItem()
286{ 283{
287} 284}
288 285
289 286
290void OListViewItem::init() 287void OListViewItem::init()
291{ 288{
292 m_known = false; 289 m_known = false;
293} 290}
294 291
295 292
296const QColor &OListViewItem::backgroundColor() 293const QColor &OListViewItem::backgroundColor()
297{ 294{
298 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 295 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
299 listView()->viewport()->colorGroup().base(); 296 listView()->viewport()->colorGroup().base();
300} 297}
301 298
302 299
303bool OListViewItem::isAlternate() 300bool OListViewItem::isAlternate()
304{ 301{
305 OListView *lv = static_cast<OListView*>( listView() ); 302 OListView *lv = static_cast<OListView*>( listView() );
306 303
307 // check if the item above is an OListViewItem 304 // check if the item above is an OListViewItem
308 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); 305 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
309 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ 306 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
310 307
311 // check if we have a valid alternate background color 308 // check if we have a valid alternate background color
312 if (!(lv && lv->alternateBackground().isValid())) return false; 309 if (!(lv && lv->alternateBackground().isValid())) return false;
313 310
314 m_known = above ? above->m_known : true; 311 m_known = above ? above->m_known : true;
315 if (m_known) 312 if (m_known)
316 { 313 {
317 m_odd = above ? !above->m_odd : false; 314 m_odd = above ? !above->m_odd : false;
318 } 315 }
319 else 316 else
320 { 317 {
321 OListViewItem *item; 318 OListViewItem *item;
322 bool previous = true; 319 bool previous = true;
323 if (parent()) 320 if (parent())
324 { 321 {
325 item = static_cast<OListViewItem *>(parent()); 322 item = static_cast<OListViewItem *>(parent());
326 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 323 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
327 item = static_cast<OListViewItem *>(parent()->firstChild()); 324 item = static_cast<OListViewItem *>(parent()->firstChild());
328 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 325 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
329 } 326 }
330 else 327 else
331 { 328 {
332 item = static_cast<OListViewItem *>(lv->firstChild()); 329 item = static_cast<OListViewItem *>(lv->firstChild());
333 } 330 }
334 331
335 while(item) 332 while(item)
336 { 333 {
337 item->m_odd = previous = !previous; 334 item->m_odd = previous = !previous;
338 item->m_known = true; 335 item->m_known = true;
339 item = static_cast<OListViewItem *>(item->nextSibling()); 336 item = static_cast<OListViewItem *>(item->nextSibling());
340 /* if (!item.inherits( "OListViewItem" ) ) break; */ 337 /* if (!item.inherits( "OListViewItem" ) ) break; */
341 } 338 }
342 } 339 }
343 return m_odd; 340 return m_odd;
344} 341}
345 342
346 343
347void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 344void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
348{ 345{
349 QColorGroup _cg = cg; 346 QColorGroup _cg = cg;
350 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 347 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
351 if (pm && !pm->isNull()) 348 if (pm && !pm->isNull())
352 { 349 {
353 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 350 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
354 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 351 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
355 } 352 }
356 else if ( isAlternate() ) 353 else if ( isAlternate() )
357 { 354 {
358 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 355 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
359 } 356 }
360 QListViewItem::paintCell( p, _cg, column, width, alignment ); 357 QListViewItem::paintCell( p, _cg, column, width, alignment );
361 358
362 //FIXME: Use styling here! 359 //FIXME: Use styling here!
363 360
364 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 361 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
365 p->setPen( pen ); 362 p->setPen( pen );
366 p->drawLine( width-1, 0, width-1, height() ); 363 p->drawLine( width-1, 0, width-1, height() );
367} 364}
368 365
369 366
370OListViewItem* OListViewItem::childFactory() 367OListViewItem* OListViewItem::childFactory()
371{ 368{
372 return new OListViewItem( this ); 369 return new OListViewItem( this );
373} 370}
374 371
375 372
376#ifndef QT_NO_DATASTREAM 373#ifndef QT_NO_DATASTREAM
377void OListViewItem::serializeTo( QDataStream& s ) const 374void OListViewItem::serializeTo( QDataStream& s ) const
378{ 375{
379 #warning Caution... the binary format is still under construction... 376 #warning Caution... the binary format is still under construction...
380 odebug << "storing OListViewItem..." << oendl; 377 odebug << "storing OListViewItem..." << oendl;
381 378
382 // store item text 379 // store item text
383 for ( int i = 0; i < listView()->columns(); ++i ) 380 for ( int i = 0; i < listView()->columns(); ++i )
384 { 381 {
385 s << text( i ); 382 s << text( i );
386 } 383 }
387 384
388 // calculate the number of children to serialize 385 // calculate the number of children to serialize
389 int items = 0; 386 int items = 0;
390 QListViewItem* item = firstChild(); 387 QListViewItem* item = firstChild();
391 while ( item ) 388 while ( item )
392 { 389 {
393 item = item->nextSibling(); 390 item = item->nextSibling();
394 items++; 391 items++;
395 } 392 }
396 393
397 // store number of items and the items itself 394 // store number of items and the items itself
398 s << items; 395 s << items;
399 item = firstChild(); 396 item = firstChild();
400 for ( int i = 0; i < items; ++i ) 397 for ( int i = 0; i < items; ++i )
401 { 398 {
402 s << *static_cast<OListViewItem*>( item ); 399 s << *static_cast<OListViewItem*>( item );
403 item = item->nextSibling(); 400 item = item->nextSibling();
404 } 401 }
405 402
406 odebug << "OListviewItem stored." << oendl; 403 odebug << "OListviewItem stored." << oendl;
407} 404}
408 405
409 406
410void OListViewItem::serializeFrom( QDataStream& s ) 407void OListViewItem::serializeFrom( QDataStream& s )
411{ 408{
412 #warning Caution... the binary format is still under construction... 409 #warning Caution... the binary format is still under construction...
413 odebug << "loading OListViewItem..." << oendl; 410 odebug << "loading OListViewItem..." << oendl;
414 411
415 for ( int i = 0; i < listView()->columns(); ++i ) 412 for ( int i = 0; i < listView()->columns(); ++i )
416 { 413 {
417 QString coltext; 414 QString coltext;
418 s >> coltext; 415 s >> coltext;
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp
index ac73188..d5cc575 100644
--- a/libopie2/opieui/opopupmenu.cpp
+++ b/libopie2/opieui/opopupmenu.cpp
@@ -1,414 +1,407 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> 2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> 3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* QT */ 20/* QT */
21 21
22#include <qapplication.h>
23#include <qcursor.h>
24#include <qpainter.h>
25#include <qdrawutil.h> 22#include <qdrawutil.h>
26#include <qtimer.h> 23#include <qtimer.h>
27#include <qfont.h>
28#include <qfontmetrics.h>
29#include <qregexp.h>
30#include <qstyle.h>
31 24
32/* OPIE */ 25/* OPIE */
33 26
34#include <opie2/opopupmenu.h> 27#include <opie2/opopupmenu.h>
35#include <opie2/oconfig.h> 28#include <opie2/oconfig.h>
36 29
37OPopupTitle::OPopupTitle(QWidget *parent, const char *name) 30OPopupTitle::OPopupTitle(QWidget *parent, const char *name)
38 : QWidget(parent, name) 31 : QWidget(parent, name)
39{ 32{
40 setMinimumSize(16, fontMetrics().height()+8); 33 setMinimumSize(16, fontMetrics().height()+8);
41} 34}
42 35
43OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, 36OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */,
44 const QColor &/* color */, const QColor &/* textColor */, 37 const QColor &/* color */, const QColor &/* textColor */,
45 QWidget *parent, const char *name) 38 QWidget *parent, const char *name)
46 : QWidget(parent, name) 39 : QWidget(parent, name)
47{ 40{
48 setMinimumSize(16, fontMetrics().height()+8); 41 setMinimumSize(16, fontMetrics().height()+8);
49} 42}
50 43
51OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, 44OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */,
52 const QColor &/* textColor */, QWidget *parent, 45 const QColor &/* textColor */, QWidget *parent,
53 const char *name) 46 const char *name)
54 : QWidget(parent, name) 47 : QWidget(parent, name)
55{ 48{
56 setMinimumSize(16, fontMetrics().height()+8); 49 setMinimumSize(16, fontMetrics().height()+8);
57} 50}
58 51
59void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) 52void OPopupTitle::setTitle(const QString &text, const QPixmap *icon)
60{ 53{
61 titleStr = text; 54 titleStr = text;
62 if (icon) 55 if (icon)
63 miniicon = *icon; 56 miniicon = *icon;
64 else 57 else
65 miniicon.resize(0, 0); 58 miniicon.resize(0, 0);
66 59
67 int w = miniicon.width()+fontMetrics().width(titleStr); 60 int w = miniicon.width()+fontMetrics().width(titleStr);
68 int h = QMAX( fontMetrics().height(), miniicon.height() ); 61 int h = QMAX( fontMetrics().height(), miniicon.height() );
69 setMinimumSize( w+16, h+8 ); 62 setMinimumSize( w+16, h+8 );
70} 63}
71 64
72void OPopupTitle::setText( const QString &text ) 65void OPopupTitle::setText( const QString &text )
73{ 66{
74 titleStr = text; 67 titleStr = text;
75 int w = miniicon.width()+fontMetrics().width(titleStr); 68 int w = miniicon.width()+fontMetrics().width(titleStr);
76 int h = QMAX( fontMetrics().height(), miniicon.height() ); 69 int h = QMAX( fontMetrics().height(), miniicon.height() );
77 setMinimumSize( w+16, h+8 ); 70 setMinimumSize( w+16, h+8 );
78} 71}
79 72
80void OPopupTitle::setIcon( const QPixmap &pix ) 73void OPopupTitle::setIcon( const QPixmap &pix )
81{ 74{
82 miniicon = pix; 75 miniicon = pix;
83 int w = miniicon.width()+fontMetrics().width(titleStr); 76 int w = miniicon.width()+fontMetrics().width(titleStr);
84 int h = QMAX( fontMetrics().height(), miniicon.height() ); 77 int h = QMAX( fontMetrics().height(), miniicon.height() );
85 setMinimumSize( w+16, h+8 ); 78 setMinimumSize( w+16, h+8 );
86} 79}
87 80
88void OPopupTitle::paintEvent(QPaintEvent *) 81void OPopupTitle::paintEvent(QPaintEvent *)
89{ 82{
90 QRect r(rect()); 83 QRect r(rect());
91 QPainter p(this); 84 QPainter p(this);
92 #if QT_VERSION > 290 85 #if QT_VERSION > 290
93 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); 86 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active());
94 #else 87 #else
95 #warning OPopupMenu is not fully functional on Qt2 88 #warning OPopupMenu is not fully functional on Qt2
96 #endif 89 #endif
97 90
98 if (!miniicon.isNull()) 91 if (!miniicon.isNull())
99 p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); 92 p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon);
100 93
101 if (!titleStr.isNull()) 94 if (!titleStr.isNull())
102 { 95 {
103 p.setPen(palette().active().text()); 96 p.setPen(palette().active().text());
104 QFont f = p.font(); 97 QFont f = p.font();
105 f.setBold(true); 98 f.setBold(true);
106 p.setFont(f); 99 p.setFont(f);
107 if(!miniicon.isNull()) 100 if(!miniicon.isNull())
108 { 101 {
109 p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), 102 p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8),
110 height(), AlignLeft | AlignVCenter | SingleLine, 103 height(), AlignLeft | AlignVCenter | SingleLine,
111 titleStr); 104 titleStr);
112 } 105 }
113 else 106 else
114 { 107 {
115 p.drawText(0, 0, width(), height(), 108 p.drawText(0, 0, width(), height(),
116 AlignCenter | SingleLine, titleStr); 109 AlignCenter | SingleLine, titleStr);
117 } 110 }
118 } 111 }
119 112
120 p.setPen(palette().active().highlight()); 113 p.setPen(palette().active().highlight());
121 p.drawLine(0, 0, r.right(), 0); 114 p.drawLine(0, 0, r.right(), 0);
122} 115}
123 116
124QSize OPopupTitle::sizeHint() const 117QSize OPopupTitle::sizeHint() const
125{ 118{
126 return(minimumSize()); 119 return(minimumSize());
127} 120}
128 121
129class OPopupMenu::OPopupMenuPrivate 122class OPopupMenu::OPopupMenuPrivate
130{ 123{
131public: 124public:
132 OPopupMenuPrivate () 125 OPopupMenuPrivate ()
133 : noMatches(false) 126 : noMatches(false)
134 , shortcuts(false) 127 , shortcuts(false)
135 , autoExec(false) 128 , autoExec(false)
136 , lastHitIndex(-1) 129 , lastHitIndex(-1)
137 , m_ctxMenu(0) 130 , m_ctxMenu(0)
138 {} 131 {}
139 132
140 ~OPopupMenuPrivate () 133 ~OPopupMenuPrivate ()
141 { 134 {
142 delete m_ctxMenu; 135 delete m_ctxMenu;
143 } 136 }
144 137
145 QString m_lastTitle; 138 QString m_lastTitle;
146 139
147 // variables for keyboard navigation 140 // variables for keyboard navigation
148 QTimer clearTimer; 141 QTimer clearTimer;
149 142
150 bool noMatches : 1; 143 bool noMatches : 1;
151 bool shortcuts : 1; 144 bool shortcuts : 1;
152 bool autoExec : 1; 145 bool autoExec : 1;
153 146
154 QString keySeq; 147 QString keySeq;
155 QString originalText; 148 QString originalText;
156 149
157 int lastHitIndex; 150 int lastHitIndex;
158 151
159 // support for RMB menus on menus 152 // support for RMB menus on menus
160 QPopupMenu* m_ctxMenu; 153 QPopupMenu* m_ctxMenu;
161 static bool s_continueCtxMenuShow; 154 static bool s_continueCtxMenuShow;
162 static int s_highlightedItem; 155 static int s_highlightedItem;
163 static OPopupMenu* s_contextedMenu; 156 static OPopupMenu* s_contextedMenu;
164}; 157};
165 158
166int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); 159int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1);
167OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); 160OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0);
168bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); 161bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true);
169 162
170OPopupMenu::OPopupMenu(QWidget *parent, const char *name) 163OPopupMenu::OPopupMenu(QWidget *parent, const char *name)
171 : QPopupMenu(parent, name) 164 : QPopupMenu(parent, name)
172{ 165{
173 d = new OPopupMenuPrivate; 166 d = new OPopupMenuPrivate;
174 resetKeyboardVars(); 167 resetKeyboardVars();
175 connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); 168 connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
176} 169}
177 170
178OPopupMenu::~OPopupMenu() 171OPopupMenu::~OPopupMenu()
179{ 172{
180 if (OPopupMenuPrivate::s_contextedMenu == this) 173 if (OPopupMenuPrivate::s_contextedMenu == this)
181 { 174 {
182 OPopupMenuPrivate::s_contextedMenu = 0; 175 OPopupMenuPrivate::s_contextedMenu = 0;
183 OPopupMenuPrivate::s_highlightedItem = -1; 176 OPopupMenuPrivate::s_highlightedItem = -1;
184 } 177 }
185 178
186 delete d; 179 delete d;
187} 180}
188 181
189int OPopupMenu::insertTitle(const QString &text, int id, int index) 182int OPopupMenu::insertTitle(const QString &text, int id, int index)
190{ 183{
191 OPopupTitle *titleItem = new OPopupTitle(); 184 OPopupTitle *titleItem = new OPopupTitle();
192 titleItem->setTitle(text); 185 titleItem->setTitle(text);
193 int ret = insertItem(titleItem, id, index); 186 int ret = insertItem(titleItem, id, index);
194 setItemEnabled(id, false); 187 setItemEnabled(id, false);
195 return ret; 188 return ret;
196} 189}
197 190
198int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, 191int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id,
199 int index) 192 int index)
200{ 193{
201 OPopupTitle *titleItem = new OPopupTitle(); 194 OPopupTitle *titleItem = new OPopupTitle();
202 titleItem->setTitle(text, &icon); 195 titleItem->setTitle(text, &icon);
203 int ret = insertItem(titleItem, id, index); 196 int ret = insertItem(titleItem, id, index);
204 setItemEnabled(id, false); 197 setItemEnabled(id, false);
205 return ret; 198 return ret;
206} 199}
207 200
208void OPopupMenu::changeTitle(int id, const QString &text) 201void OPopupMenu::changeTitle(int id, const QString &text)
209{ 202{
210 QMenuItem *item = findItem(id); 203 QMenuItem *item = findItem(id);
211 if(item){ 204 if(item){
212 if(item->widget()) 205 if(item->widget())
213 ((OPopupTitle *)item->widget())->setTitle(text); 206 ((OPopupTitle *)item->widget())->setTitle(text);
214#ifndef NDEBUG 207#ifndef NDEBUG
215 else 208 else
216 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); 209 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id );
217#endif 210#endif
218 } 211 }
219#ifndef NDEBUG 212#ifndef NDEBUG
220 else 213 else
221 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); 214 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id );
222#endif 215#endif
223} 216}
224 217
225void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text) 218void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text)
226{ 219{
227 QMenuItem *item = findItem(id); 220 QMenuItem *item = findItem(id);
228 if(item){ 221 if(item){
229 if(item->widget()) 222 if(item->widget())
230 ((OPopupTitle *)item->widget())->setTitle(text, &icon); 223 ((OPopupTitle *)item->widget())->setTitle(text, &icon);
231#ifndef NDEBUG 224#ifndef NDEBUG
232 else 225 else
233 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); 226 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id );
234#endif 227#endif
235 } 228 }
236#ifndef NDEBUG 229#ifndef NDEBUG
237 else 230 else
238 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); 231 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id );
239#endif 232#endif
240} 233}
241 234
242QString OPopupMenu::title(int id) const 235QString OPopupMenu::title(int id) const
243{ 236{
244 if(id == -1) // obsolete 237 if(id == -1) // obsolete
245 return(d->m_lastTitle); 238 return(d->m_lastTitle);
246 QMenuItem *item = findItem(id); 239 QMenuItem *item = findItem(id);
247 if(item){ 240 if(item){
248 if(item->widget()) 241 if(item->widget())
249 return(((OPopupTitle *)item->widget())->title()); 242 return(((OPopupTitle *)item->widget())->title());
250 else 243 else
251 qWarning("OPopupMenu: title() called with non-title id %d.", id); 244 qWarning("OPopupMenu: title() called with non-title id %d.", id);
252 } 245 }
253 else 246 else
254 qWarning("OPopupMenu: title() called with invalid id %d.", id); 247 qWarning("OPopupMenu: title() called with invalid id %d.", id);
255 return(QString::null); 248 return(QString::null);
256} 249}
257 250
258QPixmap OPopupMenu::titlePixmap(int id) const 251QPixmap OPopupMenu::titlePixmap(int id) const
259{ 252{
260 QMenuItem *item = findItem(id); 253 QMenuItem *item = findItem(id);
261 if(item){ 254 if(item){
262 if(item->widget()) 255 if(item->widget())
263 return(((OPopupTitle *)item->widget())->icon()); 256 return(((OPopupTitle *)item->widget())->icon());
264 else 257 else
265 qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id); 258 qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id);
266 } 259 }
267 else 260 else
268 qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id); 261 qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id);
269 QPixmap tmp; 262 QPixmap tmp;
270 return(tmp); 263 return(tmp);
271} 264}
272 265
273/** 266/**
274 * This is re-implemented for keyboard navigation. 267 * This is re-implemented for keyboard navigation.
275 */ 268 */
276void OPopupMenu::closeEvent(QCloseEvent*e) 269void OPopupMenu::closeEvent(QCloseEvent*e)
277{ 270{
278 if (d->shortcuts) 271 if (d->shortcuts)
279 resetKeyboardVars(); 272 resetKeyboardVars();
280 QPopupMenu::closeEvent(e); 273 QPopupMenu::closeEvent(e);
281} 274}
282 275
283void OPopupMenu::keyPressEvent(QKeyEvent* e) 276void OPopupMenu::keyPressEvent(QKeyEvent* e)
284{ 277{
285 if (!d->shortcuts) { 278 if (!d->shortcuts) {
286 // continue event processing by Qpopup 279 // continue event processing by Qpopup
287 //e->ignore(); 280 //e->ignore();
288 QPopupMenu::keyPressEvent(e); 281 QPopupMenu::keyPressEvent(e);
289 return; 282 return;
290 } 283 }
291 284
292 int i = 0; 285 int i = 0;
293 bool firstpass = true; 286 bool firstpass = true;
294 QString keyString = e->text(); 287 QString keyString = e->text();
295 288
296 // check for common commands dealt with by QPopup 289 // check for common commands dealt with by QPopup
297 int key = e->key(); 290 int key = e->key();
298 if (key == Key_Escape || key == Key_Return || key == Key_Enter 291 if (key == Key_Escape || key == Key_Return || key == Key_Enter
299 || key == Key_Up || key == Key_Down || key == Key_Left 292 || key == Key_Up || key == Key_Down || key == Key_Left
300 || key == Key_Right || key == Key_F1) { 293 || key == Key_Right || key == Key_F1) {
301 294
302 resetKeyboardVars(); 295 resetKeyboardVars();
303 // continue event processing by Qpopup 296 // continue event processing by Qpopup
304 //e->ignore(); 297 //e->ignore();
305 QPopupMenu::keyPressEvent(e); 298 QPopupMenu::keyPressEvent(e);
306 return; 299 return;
307 } 300 }
308 301
309 // check to see if the user wants to remove a key from the sequence (backspace) 302 // check to see if the user wants to remove a key from the sequence (backspace)
310 // or clear the sequence (delete) 303 // or clear the sequence (delete)
311 if (!d->keySeq.isNull()) { 304 if (!d->keySeq.isNull()) {
312 305
313 if (key == Key_Backspace) { 306 if (key == Key_Backspace) {
314 307
315 if (d->keySeq.length() == 1) { 308 if (d->keySeq.length() == 1) {
316 resetKeyboardVars(); 309 resetKeyboardVars();
317 return; 310 return;
318 } 311 }
319 312
320 // keep the last sequence in keyString 313 // keep the last sequence in keyString
321 keyString = d->keySeq.left(d->keySeq.length() - 1); 314 keyString = d->keySeq.left(d->keySeq.length() - 1);
322 315
323 // allow sequence matching to be tried again 316 // allow sequence matching to be tried again
324 resetKeyboardVars(); 317 resetKeyboardVars();
325 318
326 } else if (key == Key_Delete) { 319 } else if (key == Key_Delete) {
327 resetKeyboardVars(); 320 resetKeyboardVars();
328 321
329 // clear active item 322 // clear active item
330 setActiveItem(0); 323 setActiveItem(0);
331 return; 324 return;
332 325
333 } else if (d->noMatches) { 326 } else if (d->noMatches) {
334 // clear if there are no matches 327 // clear if there are no matches
335 resetKeyboardVars(); 328 resetKeyboardVars();
336 329
337 // clear active item 330 // clear active item
338 setActiveItem(0); 331 setActiveItem(0);
339 332
340 } else { 333 } else {
341 // the key sequence is not a null string 334 // the key sequence is not a null string
342 // therefore the lastHitIndex is valid 335 // therefore the lastHitIndex is valid
343 i = d->lastHitIndex; 336 i = d->lastHitIndex;
344 } 337 }
345 } else if (key == Key_Backspace && parentMenu) { 338 } else if (key == Key_Backspace && parentMenu) {
346 // backspace with no chars in the buffer... go back a menu. 339 // backspace with no chars in the buffer... go back a menu.
347 hide(); 340 hide();
348 resetKeyboardVars(); 341 resetKeyboardVars();
349 return; 342 return;
350 } 343 }
351 344
352 d->keySeq += keyString; 345 d->keySeq += keyString;
353 int seqLen = d->keySeq.length(); 346 int seqLen = d->keySeq.length();
354 347
355 for (; i < (int)count(); i++) { 348 for (; i < (int)count(); i++) {
356 // compare typed text with text of this entry 349 // compare typed text with text of this entry
357 int j = idAt(i); 350 int j = idAt(i);
358 351
359 // don't search disabled entries 352 // don't search disabled entries
360 if (!isItemEnabled(j)) 353 if (!isItemEnabled(j))
361 continue; 354 continue;
362 355
363 QString thisText; 356 QString thisText;
364 357
365 // retrieve the right text 358 // retrieve the right text
366 // (the last selected item one may have additional ampersands) 359 // (the last selected item one may have additional ampersands)
367 if (i == d->lastHitIndex) 360 if (i == d->lastHitIndex)
368 thisText = d->originalText; 361 thisText = d->originalText;
369 else 362 else
370 thisText = text(j); 363 thisText = text(j);
371 364
372 // if there is an accelerator present, remove it 365 // if there is an accelerator present, remove it
373 if ((int)accel(j) != 0) 366 if ((int)accel(j) != 0)
374 thisText = thisText.replace(QRegExp("&"), ""); 367 thisText = thisText.replace(QRegExp("&"), "");
375 368
376 // chop text to the search length 369 // chop text to the search length
377 thisText = thisText.left(seqLen); 370 thisText = thisText.left(seqLen);
378 371
379 // do the search 372 // do the search
380 if (thisText.find(d->keySeq, 0, false) == 0) { 373 if (thisText.find(d->keySeq, 0, false) == 0) {
381 374
382 if (firstpass) { 375 if (firstpass) {
383 // match 376 // match
384 setActiveItem(i); 377 setActiveItem(i);
385 378
386 // check to see if we're underlining a different item 379 // check to see if we're underlining a different item
387 if (d->lastHitIndex != i) 380 if (d->lastHitIndex != i)
388 // yes; revert the underlining 381 // yes; revert the underlining
389 changeItem(idAt(d->lastHitIndex), d->originalText); 382 changeItem(idAt(d->lastHitIndex), d->originalText);
390 383
391 // set the original text if it's a different item 384 // set the original text if it's a different item
392 if (d->lastHitIndex != i || d->lastHitIndex == -1) 385 if (d->lastHitIndex != i || d->lastHitIndex == -1)
393 d->originalText = text(j); 386 d->originalText = text(j);
394 387
395 // underline the currently selected item 388 // underline the currently selected item
396 changeItem(j, underlineText(d->originalText, d->keySeq.length())); 389 changeItem(j, underlineText(d->originalText, d->keySeq.length()));
397 390
398 // remeber what's going on 391 // remeber what's going on
399 d->lastHitIndex = i; 392 d->lastHitIndex = i;
400 393
401 // start/restart the clear timer 394 // start/restart the clear timer
402 d->clearTimer.start(5000, true); 395 d->clearTimer.start(5000, true);
403 396
404 // go around for another try, to see if we can execute 397 // go around for another try, to see if we can execute
405 firstpass = false; 398 firstpass = false;
406 } else { 399 } else {
407 // don't allow execution 400 // don't allow execution
408 return; 401 return;
409 } 402 }
410 } 403 }
411 404
412 // fall through to allow execution 405 // fall through to allow execution
413 } 406 }
414 407
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp
index ec5af6b..23b3ce3 100644
--- a/libopie2/opieui/oselector.cpp
+++ b/libopie2/opieui/oselector.cpp
@@ -1,407 +1,406 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* QT */ 20/* QT */
21 21
22#include <qimage.h> 22#include <qimage.h>
23#include <qpainter.h>
24#include <qdrawutil.h> 23#include <qdrawutil.h>
25 24
26/* OPIE */ 25/* OPIE */
27 26
28#include <opie2/oimageeffect.h> 27#include <opie2/oimageeffect.h>
29#include <opie2/oselector.h> 28#include <opie2/oselector.h>
30 29
31#define STORE_W 8 30#define STORE_W 8
32#define STORE_W2 STORE_W * 2 31#define STORE_W2 STORE_W * 2
33 32
34//----------------------------------------------------------------------------- 33//-----------------------------------------------------------------------------
35/* 34/*
36 * 2D value selector. 35 * 2D value selector.
37 * The contents of the selector are drawn by derived class. 36 * The contents of the selector are drawn by derived class.
38 */ 37 */
39 38
40OXYSelector::OXYSelector( QWidget *parent, const char *name ) 39OXYSelector::OXYSelector( QWidget *parent, const char *name )
41 : QWidget( parent, name ) 40 : QWidget( parent, name )
42{ 41{
43 xPos = 0; 42 xPos = 0;
44 yPos = 0; 43 yPos = 0;
45 minX = 0; 44 minX = 0;
46 minY = 0; 45 minY = 0;
47 maxX = 100; 46 maxX = 100;
48 maxY = 100; 47 maxY = 100;
49 store.setOptimization( QPixmap::BestOptim ); 48 store.setOptimization( QPixmap::BestOptim );
50 store.resize( STORE_W2, STORE_W2 ); 49 store.resize( STORE_W2, STORE_W2 );
51} 50}
52 51
53 52
54OXYSelector::~OXYSelector() 53OXYSelector::~OXYSelector()
55{} 54{}
56 55
57 56
58void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) 57void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
59{ 58{
60 px = 2; 59 px = 2;
61 py = 2; 60 py = 2;
62 minX = _minX; 61 minX = _minX;
63 minY = _minY; 62 minY = _minY;
64 maxX = _maxX; 63 maxX = _maxX;
65 maxY = _maxY; 64 maxY = _maxY;
66} 65}
67 66
68void OXYSelector::setValues( int _xPos, int _yPos ) 67void OXYSelector::setValues( int _xPos, int _yPos )
69{ 68{
70 xPos = _xPos; 69 xPos = _xPos;
71 yPos = _yPos; 70 yPos = _yPos;
72 71
73 if ( xPos > maxX ) 72 if ( xPos > maxX )
74 xPos = maxX; 73 xPos = maxX;
75 else if ( xPos < minX ) 74 else if ( xPos < minX )
76 xPos = minX; 75 xPos = minX;
77 76
78 if ( yPos > maxY ) 77 if ( yPos > maxY )
79 yPos = maxY; 78 yPos = maxY;
80 else if ( yPos < minY ) 79 else if ( yPos < minY )
81 yPos = minY; 80 yPos = minY;
82 81
83 int xp = 2 + (width() - 4) * xPos / (maxX - minX); 82 int xp = 2 + (width() - 4) * xPos / (maxX - minX);
84 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); 83 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);
85 84
86 setPosition( xp, yp ); 85 setPosition( xp, yp );
87} 86}
88 87
89QRect OXYSelector::contentsRect() const 88QRect OXYSelector::contentsRect() const
90{ 89{
91 return QRect( 2, 2, width()-4, height()-4 ); 90 return QRect( 2, 2, width()-4, height()-4 );
92} 91}
93 92
94void OXYSelector::paintEvent( QPaintEvent *ev ) 93void OXYSelector::paintEvent( QPaintEvent *ev )
95{ 94{
96 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); 95 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2);
97 QRect paintRect = ev->rect(); 96 QRect paintRect = ev->rect();
98 97
99 QPainter painter; 98 QPainter painter;
100 painter.begin( this ); 99 painter.begin( this );
101 100
102 QBrush brush; 101 QBrush brush;
103 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), 102 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(),
104 TRUE, 2, &brush ); 103 TRUE, 2, &brush );
105 104
106 drawContents( &painter ); 105 drawContents( &painter );
107 if (paintRect.contains(cursorRect)) 106 if (paintRect.contains(cursorRect))
108 { 107 {
109 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, 108 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W,
110 STORE_W2, STORE_W2, CopyROP ); 109 STORE_W2, STORE_W2, CopyROP );
111 drawCursor( &painter, px, py ); 110 drawCursor( &painter, px, py );
112 } 111 }
113 else if (paintRect.intersects(cursorRect)) 112 else if (paintRect.intersects(cursorRect))
114 { 113 {
115 repaint( cursorRect, false); 114 repaint( cursorRect, false);
116 } 115 }
117 116
118 painter.end(); 117 painter.end();
119} 118}
120 119
121void OXYSelector::mousePressEvent( QMouseEvent *e ) 120void OXYSelector::mousePressEvent( QMouseEvent *e )
122{ 121{
123 int xVal, yVal; 122 int xVal, yVal;
124 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); 123 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
125 setValues( xVal, yVal ); 124 setValues( xVal, yVal );
126 125
127 emit valueChanged( xPos, yPos ); 126 emit valueChanged( xPos, yPos );
128} 127}
129 128
130void OXYSelector::mouseMoveEvent( QMouseEvent *e ) 129void OXYSelector::mouseMoveEvent( QMouseEvent *e )
131{ 130{
132 int xVal, yVal; 131 int xVal, yVal;
133 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); 132 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
134 setValues( xVal, yVal ); 133 setValues( xVal, yVal );
135 134
136 emit valueChanged( xPos, yPos ); 135 emit valueChanged( xPos, yPos );
137} 136}
138 137
139void OXYSelector::wheelEvent( QWheelEvent *e ) 138void OXYSelector::wheelEvent( QWheelEvent *e )
140{ 139{
141 #if QT_VERSION > 290 140 #if QT_VERSION > 290
142 if ( e->orientation() == Qt::Horizontal ) 141 if ( e->orientation() == Qt::Horizontal )
143 setValues( xValue() + e->delta()/120, yValue() ); 142 setValues( xValue() + e->delta()/120, yValue() );
144 else 143 else
145 setValues( xValue(), yValue() + e->delta()/120 ); 144 setValues( xValue(), yValue() + e->delta()/120 );
146 145
147 emit valueChanged( xPos, yPos ); 146 emit valueChanged( xPos, yPos );
148 #endif 147 #endif
149} 148}
150 149
151void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const 150void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const
152{ 151{
153 xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); 152 xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 );
154 yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); 153 yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) );
155 154
156 if ( xVal > maxX ) 155 if ( xVal > maxX )
157 xVal = maxX; 156 xVal = maxX;
158 else if ( xVal < minX ) 157 else if ( xVal < minX )
159 xVal = minX; 158 xVal = minX;
160 159
161 if ( yVal > maxY ) 160 if ( yVal > maxY )
162 yVal = maxY; 161 yVal = maxY;
163 else if ( yVal < minY ) 162 else if ( yVal < minY )
164 yVal = minY; 163 yVal = minY;
165} 164}
166 165
167void OXYSelector::setPosition( int xp, int yp ) 166void OXYSelector::setPosition( int xp, int yp )
168{ 167{
169 if ( xp < 2 ) 168 if ( xp < 2 )
170 xp = 2; 169 xp = 2;
171 else if ( xp > width() - 2 ) 170 else if ( xp > width() - 2 )
172 xp = width() - 2; 171 xp = width() - 2;
173 172
174 if ( yp < 2 ) 173 if ( yp < 2 )
175 yp = 2; 174 yp = 2;
176 else if ( yp > height() - 2 ) 175 else if ( yp > height() - 2 )
177 yp = height() - 2; 176 yp = height() - 2;
178 177
179 QPainter painter; 178 QPainter painter;
180 painter.begin( this ); 179 painter.begin( this );
181 180
182 bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, 181 bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0,
183 STORE_W2, STORE_W2, CopyROP ); 182 STORE_W2, STORE_W2, CopyROP );
184 bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, 183 bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W,
185 STORE_W2, STORE_W2, CopyROP ); 184 STORE_W2, STORE_W2, CopyROP );
186 drawCursor( &painter, xp, yp ); 185 drawCursor( &painter, xp, yp );
187 px = xp; 186 px = xp;
188 py = yp; 187 py = yp;
189 188
190 painter.end(); 189 painter.end();
191} 190}
192 191
193void OXYSelector::drawContents( QPainter * ) 192void OXYSelector::drawContents( QPainter * )
194{} 193{}
195 194
196 195
197void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) 196void OXYSelector::drawCursor( QPainter *p, int xp, int yp )
198{ 197{
199 p->setPen( QPen( white ) ); 198 p->setPen( QPen( white ) );
200 199
201 p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); 200 p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 );
202 p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); 201 p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 );
203 p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); 202 p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 );
204 p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); 203 p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 );
205} 204}
206 205
207//----------------------------------------------------------------------------- 206//-----------------------------------------------------------------------------
208/* 207/*
209 * 1D value selector with contents drawn by derived class. 208 * 1D value selector with contents drawn by derived class.
210 * See OColorDialog for example. 209 * See OColorDialog for example.
211 */ 210 */
212 211
213 212
214OSelector::OSelector( QWidget *parent, const char *name ) 213OSelector::OSelector( QWidget *parent, const char *name )
215 : QWidget( parent, name ), QRangeControl() 214 : QWidget( parent, name ), QRangeControl()
216{ 215{
217 _orientation = Horizontal; 216 _orientation = Horizontal;
218 _indent = TRUE; 217 _indent = TRUE;
219} 218}
220 219
221OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) 220OSelector::OSelector( Orientation o, QWidget *parent, const char *name )
222 : QWidget( parent, name ), QRangeControl() 221 : QWidget( parent, name ), QRangeControl()
223{ 222{
224 _orientation = o; 223 _orientation = o;
225 _indent = TRUE; 224 _indent = TRUE;
226} 225}
227 226
228 227
229OSelector::~OSelector() 228OSelector::~OSelector()
230{} 229{}
231 230
232 231
233QRect OSelector::contentsRect() const 232QRect OSelector::contentsRect() const
234{ 233{
235 if ( orientation() == Vertical ) 234 if ( orientation() == Vertical )
236 return QRect( 2, 5, width()-9, height()-10 ); 235 return QRect( 2, 5, width()-9, height()-10 );
237 else 236 else
238 return QRect( 5, 2, width()-10, height()-9 ); 237 return QRect( 5, 2, width()-10, height()-9 );
239} 238}
240 239
241void OSelector::paintEvent( QPaintEvent * ) 240void OSelector::paintEvent( QPaintEvent * )
242{ 241{
243 QPainter painter; 242 QPainter painter;
244 243
245 painter.begin( this ); 244 painter.begin( this );
246 245
247 drawContents( &painter ); 246 drawContents( &painter );
248 247
249 QBrush brush; 248 QBrush brush;
250 249
251 if ( indent() ) 250 if ( indent() )
252 { 251 {
253 if ( orientation() == Vertical ) 252 if ( orientation() == Vertical )
254 qDrawShadePanel( &painter, 0, 3, width()-5, height()-6, 253 qDrawShadePanel( &painter, 0, 3, width()-5, height()-6,
255 colorGroup(), TRUE, 2, &brush ); 254 colorGroup(), TRUE, 2, &brush );
256 else 255 else
257 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5, 256 qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
258 colorGroup(), TRUE, 2, &brush ); 257 colorGroup(), TRUE, 2, &brush );
259 } 258 }
260 259
261 QPoint pos = calcArrowPos( value() ); 260 QPoint pos = calcArrowPos( value() );
262 drawArrow( &painter, TRUE, pos ); 261 drawArrow( &painter, TRUE, pos );
263 262
264 painter.end(); 263 painter.end();
265} 264}
266 265
267void OSelector::mousePressEvent( QMouseEvent *e ) 266void OSelector::mousePressEvent( QMouseEvent *e )
268{ 267{
269 moveArrow( e->pos() ); 268 moveArrow( e->pos() );
270} 269}
271 270
272void OSelector::mouseMoveEvent( QMouseEvent *e ) 271void OSelector::mouseMoveEvent( QMouseEvent *e )
273{ 272{
274 moveArrow( e->pos() ); 273 moveArrow( e->pos() );
275} 274}
276 275
277void OSelector::wheelEvent( QWheelEvent *e ) 276void OSelector::wheelEvent( QWheelEvent *e )
278{ 277{
279 int val = value() + e->delta()/120; 278 int val = value() + e->delta()/120;
280 emit valueChanged( val ); 279 emit valueChanged( val );
281 setValue( val ); 280 setValue( val );
282} 281}
283 282
284void OSelector::valueChange() 283void OSelector::valueChange()
285{ 284{
286 QPainter painter; 285 QPainter painter;
287 QPoint pos; 286 QPoint pos;
288 287
289 painter.begin( this ); 288 painter.begin( this );
290 289
291 pos = calcArrowPos( prevValue() ); 290 pos = calcArrowPos( prevValue() );
292 drawArrow( &painter, FALSE, pos ); 291 drawArrow( &painter, FALSE, pos );
293 292
294 pos = calcArrowPos( value() ); 293 pos = calcArrowPos( value() );
295 drawArrow( &painter, TRUE, pos ); 294 drawArrow( &painter, TRUE, pos );
296 295
297 painter.end(); 296 painter.end();
298} 297}
299 298
300void OSelector::moveArrow( const QPoint &pos ) 299void OSelector::moveArrow( const QPoint &pos )
301{ 300{
302 int val; 301 int val;
303 302
304 if ( orientation() == Vertical ) 303 if ( orientation() == Vertical )
305 val = ( maxValue() - minValue() ) * (height()-pos.y()-3) 304 val = ( maxValue() - minValue() ) * (height()-pos.y()-3)
306 / (height()-10) + minValue(); 305 / (height()-10) + minValue();
307 else 306 else
308 val = ( maxValue() - minValue() ) * (width()-pos.x()-3) 307 val = ( maxValue() - minValue() ) * (width()-pos.x()-3)
309 / (width()-10) + minValue(); 308 / (width()-10) + minValue();
310 309
311 if ( val > maxValue() ) 310 if ( val > maxValue() )
312 val = maxValue(); 311 val = maxValue();
313 if ( val < minValue() ) 312 if ( val < minValue() )
314 val = minValue(); 313 val = minValue();
315 314
316 emit valueChanged( val ); 315 emit valueChanged( val );
317 setValue( val ); 316 setValue( val );
318} 317}
319 318
320QPoint OSelector::calcArrowPos( int val ) 319QPoint OSelector::calcArrowPos( int val )
321{ 320{
322 QPoint p; 321 QPoint p;
323 322
324 if ( orientation() == Vertical ) 323 if ( orientation() == Vertical )
325 { 324 {
326 p.setY( height() - ( (height()-10) * val 325 p.setY( height() - ( (height()-10) * val
327 / ( maxValue() - minValue() ) + 5 ) ); 326 / ( maxValue() - minValue() ) + 5 ) );
328 p.setX( width() - 5 ); 327 p.setX( width() - 5 );
329 } 328 }
330 else 329 else
331 { 330 {
332 p.setX( width() - ( (width()-10) * val 331 p.setX( width() - ( (width()-10) * val
333 / ( maxValue() - minValue() ) + 5 ) ); 332 / ( maxValue() - minValue() ) + 5 ) );
334 p.setY( height() - 5 ); 333 p.setY( height() - 5 );
335 } 334 }
336 335
337 return p; 336 return p;
338} 337}
339 338
340void OSelector::drawContents( QPainter * ) 339void OSelector::drawContents( QPainter * )
341{} 340{}
342 341
343void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos ) 342void OSelector::drawArrow( QPainter *painter, bool show, const QPoint &pos )
344{ 343{
345 if ( show ) 344 if ( show )
346 { 345 {
347 QPointArray array(3); 346 QPointArray array(3);
348 347
349 painter->setPen( QPen() ); 348 painter->setPen( QPen() );
350 painter->setBrush( QBrush( colorGroup().buttonText() ) ); 349 painter->setBrush( QBrush( colorGroup().buttonText() ) );
351 if ( orientation() == Vertical ) 350 if ( orientation() == Vertical )
352 { 351 {
353 array.setPoint( 0, pos.x()+0, pos.y()+0 ); 352 array.setPoint( 0, pos.x()+0, pos.y()+0 );
354 array.setPoint( 1, pos.x()+5, pos.y()+5 ); 353 array.setPoint( 1, pos.x()+5, pos.y()+5 );
355 array.setPoint( 2, pos.x()+5, pos.y()-5 ); 354 array.setPoint( 2, pos.x()+5, pos.y()-5 );
356 } 355 }
357 else 356 else
358 { 357 {
359 array.setPoint( 0, pos.x()+0, pos.y()+0 ); 358 array.setPoint( 0, pos.x()+0, pos.y()+0 );
360 array.setPoint( 1, pos.x()+5, pos.y()+5 ); 359 array.setPoint( 1, pos.x()+5, pos.y()+5 );
361 array.setPoint( 2, pos.x()-5, pos.y()+5 ); 360 array.setPoint( 2, pos.x()-5, pos.y()+5 );
362 } 361 }
363 362
364 painter->drawPolygon( array ); 363 painter->drawPolygon( array );
365 } 364 }
366 else 365 else
367 { 366 {
368 if ( orientation() == Vertical ) 367 if ( orientation() == Vertical )
369 { 368 {
370 repaint(pos.x(), pos.y()-5, 6, 11, true); 369 repaint(pos.x(), pos.y()-5, 6, 11, true);
371 } 370 }
372 else 371 else
373 { 372 {
374 repaint(pos.x()-5, pos.y(), 11, 6, true); 373 repaint(pos.x()-5, pos.y(), 11, 6, true);
375 } 374 }
376 } 375 }
377} 376}
378 377
379//---------------------------------------------------------------------------- 378//----------------------------------------------------------------------------
380 379
381OGradientSelector::OGradientSelector( QWidget *parent, const char *name ) 380OGradientSelector::OGradientSelector( QWidget *parent, const char *name )
382 : OSelector( parent, name ) 381 : OSelector( parent, name )
383{ 382{
384 init(); 383 init();
385} 384}
386 385
387 386
388OGradientSelector::OGradientSelector( Orientation o, QWidget *parent, 387OGradientSelector::OGradientSelector( Orientation o, QWidget *parent,
389 const char *name ) 388 const char *name )
390 : OSelector( o, parent, name ) 389 : OSelector( o, parent, name )
391{ 390{
392 init(); 391 init();
393} 392}
394 393
395 394
396OGradientSelector::~OGradientSelector() 395OGradientSelector::~OGradientSelector()
397{} 396{}
398 397
399 398
400void OGradientSelector::init() 399void OGradientSelector::init()
401{ 400{
402 color1.setRgb( 0, 0, 0 ); 401 color1.setRgb( 0, 0, 0 );
403 color2.setRgb( 255, 255, 255 ); 402 color2.setRgb( 255, 255, 255 );
404 403
405 text1 = text2 = ""; 404 text1 = text2 = "";
406} 405}
407 406
diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp
index 98d42c7..b93c225 100644
--- a/libopie2/opieui/oseparator.cpp
+++ b/libopie2/opieui/oseparator.cpp
@@ -1,128 +1,127 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
5 =. 5 =.
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 31
32/* OPIE */ 32/* OPIE */
33 33
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oseparator.h> 35#include <opie2/oseparator.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qstyle.h>
40 39
41OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) 40OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
42 : QFrame(parent, name, f) 41 : QFrame(parent, name, f)
43{ 42{
44 setLineWidth(1); 43 setLineWidth(1);
45 setMidLineWidth(0); 44 setMidLineWidth(0);
46 setOrientation( HLine ); 45 setOrientation( HLine );
47} 46}
48 47
49 48
50 49
51OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) 50OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
52 : QFrame(parent, name, f) 51 : QFrame(parent, name, f)
53{ 52{
54 setLineWidth(1); 53 setLineWidth(1);
55 setMidLineWidth(0); 54 setMidLineWidth(0);
56 setOrientation( orientation ); 55 setOrientation( orientation );
57} 56}
58 57
59 58
60 59
61void OSeparator::setOrientation(int orientation) 60void OSeparator::setOrientation(int orientation)
62{ 61{
63 switch(orientation) 62 switch(orientation)
64 { 63 {
65 case Vertical: 64 case Vertical:
66 case VLine: 65 case VLine:
67 setFrameStyle( QFrame::VLine | QFrame::Sunken ); 66 setFrameStyle( QFrame::VLine | QFrame::Sunken );
68 setMinimumSize(2, 0); 67 setMinimumSize(2, 0);
69 break; 68 break;
70 69
71 default: 70 default:
72 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; 71 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
73 72
74 case Horizontal: 73 case Horizontal:
75 case HLine: 74 case HLine:
76 setFrameStyle( QFrame::HLine | QFrame::Sunken ); 75 setFrameStyle( QFrame::HLine | QFrame::Sunken );
77 setMinimumSize(0, 2); 76 setMinimumSize(0, 2);
78 break; 77 break;
79 } 78 }
80} 79}
81 80
82 81
83 82
84int OSeparator::orientation() const 83int OSeparator::orientation() const
85{ 84{
86 if ( frameStyle() & VLine ) 85 if ( frameStyle() & VLine )
87 return VLine; 86 return VLine;
88 87
89 if ( frameStyle() & HLine ) 88 if ( frameStyle() & HLine )
90 return HLine; 89 return HLine;
91 90
92 return 0; 91 return 0;
93} 92}
94 93
95void OSeparator::drawFrame(QPainter *p) 94void OSeparator::drawFrame(QPainter *p)
96{ 95{
97 QPointp1, p2; 96 QPointp1, p2;
98 QRectr = frameRect(); 97 QRectr = frameRect();
99 const QColorGroup & g = colorGroup(); 98 const QColorGroup & g = colorGroup();
100 99
101 if ( frameStyle() & HLine ) { 100 if ( frameStyle() & HLine ) {
102 p1 = QPoint( r.x(), r.height()/2 ); 101 p1 = QPoint( r.x(), r.height()/2 );
103 p2 = QPoint( r.x()+r.width(), p1.y() ); 102 p2 = QPoint( r.x()+r.width(), p1.y() );
104 } 103 }
105 else { 104 else {
106 p1 = QPoint( r.x()+r.width()/2, 0 ); 105 p1 = QPoint( r.x()+r.width()/2, 0 );
107 p2 = QPoint( p1.x(), r.height() ); 106 p2 = QPoint( p1.x(), r.height() );
108 } 107 }
109 108
110#if QT_VERSION < 300 109#if QT_VERSION < 300
111 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); 110 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() );
112#else 111#else
113 QStyleOption opt( lineWidth(), midLineWidth() ); 112 QStyleOption opt( lineWidth(), midLineWidth() );
114 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); 113 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt );
115#endif 114#endif
116} 115}
117 116
118 117
119QSize OSeparator::sizeHint() const 118QSize OSeparator::sizeHint() const
120{ 119{
121 if ( frameStyle() & VLine ) 120 if ( frameStyle() & VLine )
122 return QSize(2, 0); 121 return QSize(2, 0);
123 122
124 if ( frameStyle() & HLine ) 123 if ( frameStyle() & HLine )
125 return QSize(0, 2); 124 return QSize(0, 2);
126 125
127 return QSize(-1, -1); 126 return QSize(-1, -1);
128} 127}
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp
index 9f9f2c2..d4712a4 100644
--- a/libopie2/opieui/otimepicker.cpp
+++ b/libopie2/opieui/otimepicker.cpp
@@ -1,295 +1,292 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30/* QT */ 30/* QT */
31#include <qbuttongroup.h>
32#include <qlayout.h> 31#include <qlayout.h>
33#include <qlineedit.h> 32#include <qlineedit.h>
34#include <qstring.h>
35#include <qtoolbutton.h>
36 33
37/* OPIE */ 34/* OPIE */
38#include <opie2/otimepicker.h> 35#include <opie2/otimepicker.h>
39 36
40using namespace Opie; 37using namespace Opie;
41 38
42/** 39/**
43 * Constructs the widget 40 * Constructs the widget
44 * @param parent The parent of the OTimePicker 41 * @param parent The parent of the OTimePicker
45 * @param name The name of the object 42 * @param name The name of the object
46 * @param fl Window Flags 43 * @param fl Window Flags
47 */ 44 */
48OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) 45OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl)
49 :QWidget(parent,name,fl) 46 :QWidget(parent,name,fl)
50{ 47{
51 QVBoxLayout *vbox=new QVBoxLayout(this); 48 QVBoxLayout *vbox=new QVBoxLayout(this);
52 49
53 OClickableLabel *r; 50 OClickableLabel *r;
54 QString s; 51 QString s;
55 52
56 // Hour Row 53 // Hour Row
57 QWidget *row=new QWidget(this); 54 QWidget *row=new QWidget(this);
58 QHBoxLayout *l=new QHBoxLayout(row); 55 QHBoxLayout *l=new QHBoxLayout(row);
59 vbox->addWidget(row); 56 vbox->addWidget(row);
60 57
61 for (int i=0; i<24; i++) 58 for (int i=0; i<24; i++)
62 { 59 {
63 r=new OClickableLabel(row); 60 r=new OClickableLabel(row);
64 hourLst.append(r); 61 hourLst.append(r);
65 s.sprintf("%.2d",i); 62 s.sprintf("%.2d",i);
66 r->setText(s); 63 r->setText(s);
67 r->setToggleButton(true); 64 r->setToggleButton(true);
68 r->setAlignment(AlignHCenter | AlignVCenter); 65 r->setAlignment(AlignHCenter | AlignVCenter);
69 l->addWidget(r); 66 l->addWidget(r);
70 connect(r, SIGNAL(toggled(bool)), 67 connect(r, SIGNAL(toggled(bool)),
71 this, SLOT(slotHour(bool))); 68 this, SLOT(slotHour(bool)));
72 69
73 if (i==11) 70 if (i==11)
74 { // Second row 71 { // Second row
75 row=new QWidget(this); 72 row=new QWidget(this);
76 l=new QHBoxLayout(row); 73 l=new QHBoxLayout(row);
77 vbox->addWidget(row); 74 vbox->addWidget(row);
78 } 75 }
79 } 76 }
80 77
81 // Minute Row 78 // Minute Row
82 row=new QWidget(this); 79 row=new QWidget(this);
83 l=new QHBoxLayout(row); 80 l=new QHBoxLayout(row);
84 vbox->addWidget(row); 81 vbox->addWidget(row);
85 82
86 for (int i=0; i<60; i+=5) 83 for (int i=0; i<60; i+=5)
87 { 84 {
88 r=new OClickableLabel(row); 85 r=new OClickableLabel(row);
89 minuteLst.append(r); 86 minuteLst.append(r);
90 s.sprintf("%.2d",i); 87 s.sprintf("%.2d",i);
91 r->setText(s); 88 r->setText(s);
92 r->setToggleButton(true); 89 r->setToggleButton(true);
93 r->setAlignment(AlignHCenter | AlignVCenter); 90 r->setAlignment(AlignHCenter | AlignVCenter);
94 l->addWidget(r); 91 l->addWidget(r);
95 connect(r, SIGNAL(toggled(bool)), 92 connect(r, SIGNAL(toggled(bool)),
96 this, SLOT(slotMinute(bool))); 93 this, SLOT(slotMinute(bool)));
97 } 94 }
98} 95}
99 96
100/** 97/**
101 * This method return the current time 98 * This method return the current time
102 * @return the time 99 * @return the time
103 */ 100 */
104QTime OTimePicker::time()const 101QTime OTimePicker::time()const
105{ 102{
106 return tm; 103 return tm;
107} 104}
108 105
109void OTimePicker::slotHour(bool b) 106void OTimePicker::slotHour(bool b)
110{ 107{
111 108
112 OClickableLabel *r = (OClickableLabel *) sender(); 109 OClickableLabel *r = (OClickableLabel *) sender();
113 110
114 if (b) 111 if (b)
115 { 112 {
116 QValueListIterator<OClickableLabel *> it; 113 QValueListIterator<OClickableLabel *> it;
117 for (it=hourLst.begin(); it!=hourLst.end(); it++) 114 for (it=hourLst.begin(); it!=hourLst.end(); it++)
118 { 115 {
119 if (*it != r) (*it)->setOn(false); 116 if (*it != r) (*it)->setOn(false);
120 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 117 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
121 } 118 }
122 emit timeChanged(tm); 119 emit timeChanged(tm);
123 } 120 }
124 else 121 else
125 { 122 {
126 r->setOn(true); 123 r->setOn(true);
127 } 124 }
128 125
129} 126}
130 127
131void OTimePicker::slotMinute(bool b) 128void OTimePicker::slotMinute(bool b)
132{ 129{
133 130
134 OClickableLabel *r = (OClickableLabel *) sender(); 131 OClickableLabel *r = (OClickableLabel *) sender();
135 132
136 if (b) 133 if (b)
137 { 134 {
138 QValueListIterator<OClickableLabel *> it; 135 QValueListIterator<OClickableLabel *> it;
139 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) 136 for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
140 { 137 {
141 if (*it != r) (*it)->setOn(false); 138 if (*it != r) (*it)->setOn(false);
142 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); 139 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
143 } 140 }
144 emit timeChanged(tm); 141 emit timeChanged(tm);
145 } 142 }
146 else 143 else
147 { 144 {
148 r->setOn(true); 145 r->setOn(true);
149 } 146 }
150 147
151} 148}
152 149
153/** 150/**
154 * Method to set the time. No signal gets emitted during this method call 151 * Method to set the time. No signal gets emitted during this method call
155 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) 152 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
156 * @param t The time to be set 153 * @param t The time to be set
157 */ 154 */
158void OTimePicker::setTime( const QTime& t) 155void OTimePicker::setTime( const QTime& t)
159{ 156{
160 setTime( t.hour(), t.minute() ); 157 setTime( t.hour(), t.minute() );
161} 158}
162 159
163/** 160/**
164 * Method to set the time. No signal gets emitted during this method call 161 * Method to set the time. No signal gets emitted during this method call
165 * @param h The hour 162 * @param h The hour
166 * @param m The minute. Minutes need to set by 5 minute steps 163 * @param m The minute. Minutes need to set by 5 minute steps
167 */ 164 */
168void OTimePicker::setTime( int h, int m ) 165void OTimePicker::setTime( int h, int m )
169{ 166{
170 setHour(h); 167 setHour(h);
171 setMinute(m); 168 setMinute(m);
172} 169}
173 170
174/* 171/*
175 * FIXME round minutes to the 5 minute arrangement -zecke 172 * FIXME round minutes to the 5 minute arrangement -zecke
176 */ 173 */
177/** 174/**
178 * Method to set the minutes 175 * Method to set the minutes
179 * @param m minutes 176 * @param m minutes
180 */ 177 */
181void OTimePicker::setMinute(int m) 178void OTimePicker::setMinute(int m)
182{ 179{
183 180
184 QString minute; 181 QString minute;
185 minute.sprintf("%.2d",m); 182 minute.sprintf("%.2d",m);
186 183
187 QValueListIterator<OClickableLabel *> it; 184 QValueListIterator<OClickableLabel *> it;
188 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) 185 for (it=minuteLst.begin(); it!=minuteLst.end(); it++)
189 { 186 {
190 if ((*it)->text() == minute) (*it)->setOn(true); 187 if ((*it)->text() == minute) (*it)->setOn(true);
191 else (*it)->setOn(false); 188 else (*it)->setOn(false);
192 } 189 }
193 190
194 tm.setHMS(tm.hour(),m,0); 191 tm.setHMS(tm.hour(),m,0);
195} 192}
196 193
197/** 194/**
198 * Method to set the hour 195 * Method to set the hour
199 */ 196 */
200void OTimePicker::setHour(int h) 197void OTimePicker::setHour(int h)
201{ 198{
202 199
203 QString hour; 200 QString hour;
204 hour.sprintf("%.2d",h); 201 hour.sprintf("%.2d",h);
205 202
206 QValueListIterator<OClickableLabel *> it; 203 QValueListIterator<OClickableLabel *> it;
207 for (it=hourLst.begin(); it!=hourLst.end(); it++) 204 for (it=hourLst.begin(); it!=hourLst.end(); it++)
208 { 205 {
209 if ((*it)->text() == hour) (*it)->setOn(true); 206 if ((*it)->text() == hour) (*it)->setOn(true);
210 else (*it)->setOn(false); 207 else (*it)->setOn(false);
211 } 208 }
212 tm.setHMS(h,tm.minute(),0); 209 tm.setHMS(h,tm.minute(),0);
213} 210}
214 211
215 212
216/** 213/**
217 * This is a modal Dialog. 214 * This is a modal Dialog.
218 * 215 *
219 * @param parent The parent widget 216 * @param parent The parent widget
220 * @param name The name of the object 217 * @param name The name of the object
221 * @param fl Possible window flags 218 * @param fl Possible window flags
222 */ 219 */
223OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 220OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
224 : OTimePickerDialogBase (parent , name, true , fl) 221 : OTimePickerDialogBase (parent , name, true , fl)
225{ 222{
226 223
227 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), 224 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ),
228 this, SLOT( setTime ( const QTime& ) ) ); 225 this, SLOT( setTime ( const QTime& ) ) );
229 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), 226 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ),
230 this, SLOT ( setMinute ( const QString& ) ) ); 227 this, SLOT ( setMinute ( const QString& ) ) );
231 connect ( hourField, SIGNAL( textChanged ( const QString& ) ), 228 connect ( hourField, SIGNAL( textChanged ( const QString& ) ),
232 this, SLOT ( setHour ( const QString& ) ) ); 229 this, SLOT ( setHour ( const QString& ) ) );
233 230
234} 231}
235 232
236/** 233/**
237 * @return the time 234 * @return the time
238 */ 235 */
239QTime OTimePickerDialog::time()const 236QTime OTimePickerDialog::time()const
240{ 237{
241 return m_time; 238 return m_time;
242} 239}
243 240
244/** 241/**
245 * Set the time to time 242 * Set the time to time
246 * @param time The time to be set 243 * @param time The time to be set
247 */ 244 */
248void OTimePickerDialog::setTime( const QTime& time ) 245void OTimePickerDialog::setTime( const QTime& time )
249{ 246{
250 m_time = time; 247 m_time = time;
251 248
252 m_timePicker->setHour ( time.hour() ); 249 m_timePicker->setHour ( time.hour() );
253 m_timePicker->setMinute( time.minute() ); 250 m_timePicker->setMinute( time.minute() );
254 251
255 // Set Textfields 252 // Set Textfields
256 if ( time.hour() < 10 ) 253 if ( time.hour() < 10 )
257 hourField->setText( "0" + QString::number( time.hour() ) ); 254 hourField->setText( "0" + QString::number( time.hour() ) );
258 else 255 else
259 hourField->setText( QString::number( time.hour() ) ); 256 hourField->setText( QString::number( time.hour() ) );
260 257
261 if ( time.minute() < 10 ) 258 if ( time.minute() < 10 )
262 minuteField->setText( "0" + QString::number( time.minute() ) ); 259 minuteField->setText( "0" + QString::number( time.minute() ) );
263 else 260 else
264 minuteField->setText( QString::number( time.minute() ) ); 261 minuteField->setText( QString::number( time.minute() ) );
265 262
266} 263}
267 264
268/** 265/**
269 * This method takes the current minute and tries to set hour 266 * This method takes the current minute and tries to set hour
270 * to hour. This succeeds if the resulting date is valid 267 * to hour. This succeeds if the resulting date is valid
271 * @param hour The hour as a string 268 * @param hour The hour as a string
272 */ 269 */
273void OTimePickerDialog::setHour ( const QString& hour ) 270void OTimePickerDialog::setHour ( const QString& hour )
274{ 271{
275 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ) 272 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) )
276 { 273 {
277 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); 274 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
278 setTime ( m_time ); 275 setTime ( m_time );
279 } 276 }
280 277
281} 278}
282 279
283/** 280/**
284 * Method to set a new minute. It tries to convert the string to int and 281 * Method to set a new minute. It tries to convert the string to int and
285 * if the resulting date is valid a new date is set. 282 * if the resulting date is valid a new date is set.
286 * @see setHour 283 * @see setHour
287 */ 284 */
288void OTimePickerDialog::setMinute ( const QString& minute ) 285void OTimePickerDialog::setMinute ( const QString& minute )
289{ 286{
290 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ) 287 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) )
291 { 288 {
292 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); 289 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
293 setTime ( m_time ); 290 setTime ( m_time );
294 } 291 }
295} 292}
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp
index 65fe3d8..8839456 100644
--- a/libopie2/opieui/oversatileview.cpp
+++ b/libopie2/opieui/oversatileview.cpp
@@ -1,436 +1,425 @@
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 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34#include <opie2/oversatileview.h> 34#include <opie2/oversatileview.h>
35#include <opie2/oversatileviewitem.h> 35#include <opie2/oversatileviewitem.h>
36#include <opie2/olistview.h> 36#include <opie2/olistview.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qaction.h> 40#include <qaction.h>
41#include <qbrush.h>
42#include <qfont.h>
43#include <qiconset.h>
44#include <qiconview.h>
45#include <qlistview.h>
46#include <qpalette.h>
47#include <qpoint.h>
48#include <qpopupmenu.h> 41#include <qpopupmenu.h>
49#include <qrect.h>
50#include <qsize.h>
51#include <qstring.h>
52#include <qwidgetstack.h>
53 42
54/* XPM */ 43/* XPM */
55static const char * view_icon_xpm[] = { 44static const char * view_icon_xpm[] = {
56"16 16 16 1", 45"16 16 16 1",
57 " c None", 46 " c None",
58 ".c #87BD88", 47 ".c #87BD88",
59 "+c #8BBE8B", 48 "+c #8BBE8B",
60 "@c #81BA81", 49 "@c #81BA81",
61 "#c #6DAF6D", 50 "#c #6DAF6D",
62 "$c #87BD87", 51 "$c #87BD87",
63 "%c #FCFDFC", 52 "%c #FCFDFC",
64 "&c #AED0AE", 53 "&c #AED0AE",
65 "*c #4E9C4C", 54 "*c #4E9C4C",
66 "=c #91BD91", 55 "=c #91BD91",
67 "-c #72B172", 56 "-c #72B172",
68 ";c #448643", 57 ";c #448643",
69 ">c #519F50", 58 ">c #519F50",
70 ",c #499247", 59 ",c #499247",
71 "'c #356A35", 60 "'c #356A35",
72 ")c #686868", 61 ")c #686868",
73" ", 62" ",
74" .+@# .+@# ", 63" .+@# .+@# ",
75" $%&* $%&* ", 64" $%&* $%&* ",
76" @=-; @=-; ", 65" @=-; @=-; ",
77" #>,' #>,' ", 66" #>,' #>,' ",
78" ", 67" ",
79" )))))) )))))) ", 68" )))))) )))))) ",
80" ", 69" ",
81" ", 70" ",
82" .+@# .+@# ", 71" .+@# .+@# ",
83" $%&* $%&* ", 72" $%&* $%&* ",
84" @=-; @=-; ", 73" @=-; @=-; ",
85" #>,' #>,' ", 74" #>,' #>,' ",
86" ", 75" ",
87" )))))) )))))) ", 76" )))))) )))))) ",
88" "}; 77" "};
89 78
90/* XPM */ 79/* XPM */
91static const char * view_tree_xpm[] = { 80static const char * view_tree_xpm[] = {
92"16 16 17 1", 81"16 16 17 1",
93 " c None", 82 " c None",
94 ".c #3A3A3A", 83 ".c #3A3A3A",
95 "+c #87BD88", 84 "+c #87BD88",
96 "@c #8BBE8B", 85 "@c #8BBE8B",
97 "#c #81BA81", 86 "#c #81BA81",
98 "$c #6DAF6D", 87 "$c #6DAF6D",
99 "%c #87BD87", 88 "%c #87BD87",
100 "&c #FCFDFC", 89 "&c #FCFDFC",
101 "*c #AED0AE", 90 "*c #AED0AE",
102 "=c #4E9C4C", 91 "=c #4E9C4C",
103 "-c #91BD91", 92 "-c #91BD91",
104 ";c #72B172", 93 ";c #72B172",
105 ">c #448643", 94 ">c #448643",
106 ",c #686868", 95 ",c #686868",
107 "'c #519F50", 96 "'c #519F50",
108 ")c #499247", 97 ")c #499247",
109 "!c #356A35", 98 "!c #356A35",
110" . ", 99" . ",
111" . ", 100" . ",
112" . +@#$ ", 101" . +@#$ ",
113" . %&*= ", 102" . %&*= ",
114" .. #-;> ,, ,,,", 103" .. #-;> ,, ,,,",
115" . $')! ", 104" . $')! ",
116" . ", 105" . ",
117" . ", 106" . ",
118" . ", 107" . ",
119" . +@#$ ", 108" . +@#$ ",
120" . %&*= ", 109" . %&*= ",
121" .. #-;> ,, ,,,", 110" .. #-;> ,, ,,,",
122" $')! ", 111" $')! ",
123" ", 112" ",
124" ", 113" ",
125" "}; 114" "};
126 115
127OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) 116OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode )
128 :QWidgetStack( parent, name ), 117 :QWidgetStack( parent, name ),
129 _viewmode( mode ), _warningpolicy( None ), 118 _viewmode( mode ), _warningpolicy( None ),
130 _treeleaf(), _treeopened(), _treeclosed(), 119 _treeleaf(), _treeopened(), _treeclosed(),
131 _iconleaf(), _iconopened(), _iconclosed() 120 _iconleaf(), _iconopened(), _iconclosed()
132{ 121{
133 // 122 //
134 // Create child widgets and set some reasonable default styles 123 // Create child widgets and set some reasonable default styles
135 // 124 //
136 125
137 _listview = new OListView( this, "oversatileview embedded listview" ); 126 _listview = new OListView( this, "oversatileview embedded listview" );
138 _iconview = new QIconView( this, "oversatileview embedded iconview" ); 127 _iconview = new QIconView( this, "oversatileview embedded iconview" );
139 128
140 _listview->setAllColumnsShowFocus( true ); 129 _listview->setAllColumnsShowFocus( true );
141 _listview->setRootIsDecorated( true ); 130 _listview->setRootIsDecorated( true );
142 _listview->setShowSortIndicator( true ); 131 _listview->setShowSortIndicator( true );
143 _iconview->setGridX( 90 ); 132 _iconview->setGridX( 90 );
144 _iconview->setGridY( 42 ); 133 _iconview->setGridY( 42 );
145 _iconview->setAutoArrange( true ); 134 _iconview->setAutoArrange( true );
146 135
147 #ifdef QWS // TODO: Let this depend on current geometry (rotation) 136 #ifdef QWS // TODO: Let this depend on current geometry (rotation)
148 _iconview->setArrangement( QIconView::TopToBottom ); 137 _iconview->setArrangement( QIconView::TopToBottom );
149 #else 138 #else
150 _iconview->setArrangement( QIconView::LeftToRight ); 139 _iconview->setArrangement( QIconView::LeftToRight );
151 #endif 140 #endif
152 141
153 _iconview->setResizeMode( QIconView::Adjust ); 142 _iconview->setResizeMode( QIconView::Adjust );
154 143
155 // qt-embedded: map stylus right on hold to right button press 144 // qt-embedded: map stylus right on hold to right button press
156 145
157 #ifdef QWS 146 #ifdef QWS
158 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); 147 ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold );
159 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); 148 ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold );
160 #endif 149 #endif
161 150
162 setViewMode( mode ); // TODO: Read last style from config 151 setViewMode( mode ); // TODO: Read last style from config
163 // setSynchronization( true ); // TODO: Implement this 152 // setSynchronization( true ); // TODO: Implement this
164 153
165 // create context menu allowing to switch between the views 154 // create context menu allowing to switch between the views
166 155
167 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); 156 _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" );
168 _contextmenu->setCaption( "Style" ); 157 _contextmenu->setCaption( "Style" );
169 _contextmenu->setCheckable( true ); 158 _contextmenu->setCheckable( true );
170 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); 159 QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" );
171 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), 160 QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ),
172 "View Icons", 0, ag, "viewicon action", true ); 161 "View Icons", 0, ag, "viewicon action", true );
173 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), 162 QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ),
174 "View Tree", 0, ag, "viewtree action", true ); 163 "View Tree", 0, ag, "viewtree action", true );
175 ag->addTo( _contextmenu ); 164 ag->addTo( _contextmenu );
176 if ( mode == Icons ) 165 if ( mode == Icons )
177 a1->setOn( true ); 166 a1->setOn( true );
178 else if ( mode == Tree ) 167 else if ( mode == Tree )
179 a2->setOn( true ); 168 a2->setOn( true );
180 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); 169 connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) );
181 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); 170 connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) );
182 171
183 #if (QT_VERSION >= 0x030000) 172 #if (QT_VERSION >= 0x030000)
184 connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); 173 connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
185 connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); 174 connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) );
186 #else 175 #else
187 connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); 176 connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
188 connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); 177 connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) );
189 #endif 178 #endif
190 179
191 // 180 //
192 // signal forwarders 181 // signal forwarders
193 // 182 //
194 // unfortunately we can't short-circuit all the QListView and QIconView signals 183 // unfortunately we can't short-circuit all the QListView and QIconView signals
195 // to OVersatileView signals, because the signal/slot mechanism doesn't allow 184 // to OVersatileView signals, because the signal/slot mechanism doesn't allow
196 // type-conversion :-( 185 // type-conversion :-(
197 186
198 // common signals for listview 187 // common signals for listview
199 188
200 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 189 connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
201 connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) ); 190 connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) );
202 connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) ); 191 connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) );
203 connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) ); 192 connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) );
204 connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) ); 193 connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) );
205 194
206 connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) ); 195 connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) );
207 connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) ); 196 connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) );
208 197
209 connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) ); 198 connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) );
210 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 199 connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
211 200
212 // common signals for iconview 201 // common signals for iconview
213 202
214 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); 203 connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
215 connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) ); 204 connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) );
216 connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) ); 205 connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) );
217 connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) ); 206 connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) );
218 connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) ); 207 connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) );
219 208
220 connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) ); 209 connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) );
221 connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) ); 210 connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) );
222 211
223 connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) ); 212 connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) );
224 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); 213 connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) );
225 214
226 // listview only signals 215 // listview only signals
227 216
228 connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) ); 217 connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) );
229 connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) ); 218 connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) );
230 219
231 // iconview only signals 220 // iconview only signals
232 221
233 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); 222 connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) );
234} 223}
235 224
236OVersatileView::~OVersatileView() 225OVersatileView::~OVersatileView()
237{ 226{
238} 227}
239 228
240QPopupMenu* OVersatileView::contextMenu() const 229QPopupMenu* OVersatileView::contextMenu() const
241{ 230{
242 return _contextmenu; 231 return _contextmenu;
243} 232}
244 233
245void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) 234void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col )
246{ 235{
247 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, 236 // can't use QObject::inherits here, because ListViewItems, beit Q, O or K,
248 // do not inherit from QObject - assuming here the programmer is 237 // do not inherit from QObject - assuming here the programmer is
249 // disciplined enough to only add OVersatileViewItems to an OVersatileView 238 // disciplined enough to only add OVersatileViewItems to an OVersatileView
250 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col ); 239 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, col );
251} 240}
252 241
253void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos ) 242void OVersatileView::contextMenuRequested( QIconViewItem* item, const QPoint& pos )
254{ 243{
255 // see above 244 // see above
256 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 ); 245 popupContextMenu( static_cast<OVersatileViewItem*>( item ), pos, -1 );
257} 246}
258 247
259void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col ) 248void OVersatileView::popupContextMenu( OVersatileViewItem* item, const QPoint& pos, int col )
260{ 249{
261 if ( !item ) 250 if ( !item )
262 _contextmenu->exec( pos ); 251 _contextmenu->exec( pos );
263 else 252 else
264 emit( contextMenuRequested( item, pos, col ) ); 253 emit( contextMenuRequested( item, pos, col ) );
265} 254}
266 255
267void OVersatileView::setSynchronization( bool sync ) 256void OVersatileView::setSynchronization( bool sync )
268{ 257{
269 _synchronization = sync; 258 _synchronization = sync;
270} 259}
271 260
272bool OVersatileView::synchronization() 261bool OVersatileView::synchronization()
273{ 262{
274 return _synchronization; 263 return _synchronization;
275} 264}
276 265
277void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) 266void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed )
278{ 267{
279 if ( mode == Tree ) 268 if ( mode == Tree )
280 { 269 {
281 _treeleaf = leaf; 270 _treeleaf = leaf;
282 _treeopened = opened; 271 _treeopened = opened;
283 _treeclosed = closed; 272 _treeclosed = closed;
284 } 273 }
285 else if ( mode == Icons ) 274 else if ( mode == Icons )
286 { 275 {
287 _iconleaf = leaf; 276 _iconleaf = leaf;
288 _iconopened = opened; 277 _iconopened = opened;
289 _iconclosed = closed; 278 _iconclosed = closed;
290 } 279 }
291 else 280 else
292 { 281 {
293 odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; 282 odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl;
294 } 283 }
295} 284}
296 285
297QIconView* OVersatileView::iconView() const 286QIconView* OVersatileView::iconView() const
298{ 287{
299 return _iconview; 288 return _iconview;
300} 289}
301 290
302OListView* OVersatileView::listView() const 291OListView* OVersatileView::listView() const
303{ 292{
304 return _listview; 293 return _listview;
305} 294}
306 295
307void OVersatileView::setViewMode( int mode ) 296void OVersatileView::setViewMode( int mode )
308{ 297{
309 if ( mode == Tree ) 298 if ( mode == Tree )
310 { 299 {
311 _viewmode = mode; 300 _viewmode = mode;
312 raiseWidget( _listview ); 301 raiseWidget( _listview );
313 } 302 }
314 else if ( mode == Icons ) 303 else if ( mode == Icons )
315 { 304 {
316 _viewmode = mode; 305 _viewmode = mode;
317 raiseWidget( _iconview ); 306 raiseWidget( _iconview );
318 } 307 }
319 else 308 else
320 { 309 {
321 odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; 310 odebug << "OVersatileView::setViewMode(): invalid mode" << oendl;
322 } 311 }
323} 312}
324 313
325void OVersatileView::setIconViewMode() 314void OVersatileView::setIconViewMode()
326{ 315{
327 setViewMode( Icons ); 316 setViewMode( Icons );
328} 317}
329 318
330void OVersatileView::setTreeViewMode() 319void OVersatileView::setTreeViewMode()
331{ 320{
332 setViewMode( Tree ); 321 setViewMode( Tree );
333} 322}
334 323
335bool OVersatileView::isValidViewMode( int mode ) const 324bool OVersatileView::isValidViewMode( int mode ) const
336{ 325{
337 switch ( _warningpolicy ) 326 switch ( _warningpolicy )
338 { 327 {
339 case OVersatileView::None: 328 case OVersatileView::None:
340 { 329 {
341 return true; 330 return true;
342 } 331 }
343 case OVersatileView::Warn: 332 case OVersatileView::Warn:
344 { 333 {
345 if ( _viewmode != mode ) 334 if ( _viewmode != mode )
346 { 335 {
347 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; 336 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
348 return true; 337 return true;
349 } 338 }
350 } 339 }
351 case OVersatileView::WarnReturn: 340 case OVersatileView::WarnReturn:
352 { 341 {
353 if ( _viewmode != mode ) 342 if ( _viewmode != mode )
354 { 343 {
355 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; 344 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
356 return false; 345 return false;
357 } 346 }
358 } 347 }
359 default: 348 default:
360 { 349 {
361 owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; 350 owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl;
362 return true; 351 return true;
363 } 352 }
364 } 353 }
365} 354}
366void OVersatileView::setWarningPolicy( int policy ) const 355void OVersatileView::setWarningPolicy( int policy ) const
367{ 356{
368 _warningpolicy = policy; 357 _warningpolicy = policy;
369} 358}
370bool OVersatileView::warningPolicy() const 359bool OVersatileView::warningPolicy() const
371{ 360{
372 return _warningpolicy; 361 return _warningpolicy;
373} 362}
374//==============================================================================================// 363//==============================================================================================//
375// Stupid Signal forwarders... 364// Stupid Signal forwarders...
376// Folks, this is why I like python with its dynamic typing: 365// Folks, this is why I like python with its dynamic typing:
377// I can code the following dozens of lines C++ in four Python lines... 366// I can code the following dozens of lines C++ in four Python lines...
378//==============================================================================================// 367//==============================================================================================//
379 368
380void OVersatileView::selectionChanged( QListViewItem * item ) 369void OVersatileView::selectionChanged( QListViewItem * item )
381{ 370{
382 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 371 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
383} 372}
384 373
385void OVersatileView::selectionChanged( QIconViewItem * item ) 374void OVersatileView::selectionChanged( QIconViewItem * item )
386{ 375{
387 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 376 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
388} 377}
389 378
390void OVersatileView::currentChanged( QListViewItem * item ) 379void OVersatileView::currentChanged( QListViewItem * item )
391{ 380{
392 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 381 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
393} 382}
394 383
395void OVersatileView::currentChanged( QIconViewItem * item ) 384void OVersatileView::currentChanged( QIconViewItem * item )
396{ 385{
397 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) ); 386 emit( currentChanged( static_cast<OVersatileViewItem*>( item ) ) );
398} 387}
399 388
400void OVersatileView::clicked( QListViewItem * item ) 389void OVersatileView::clicked( QListViewItem * item )
401{ 390{
402 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 391 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
403} 392}
404 393
405void OVersatileView::clicked( QIconViewItem * item ) 394void OVersatileView::clicked( QIconViewItem * item )
406{ 395{
407 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) ); 396 emit( clicked( static_cast<OVersatileViewItem*>( item ) ) );
408} 397}
409 398
410void OVersatileView::pressed( QListViewItem * item ) 399void OVersatileView::pressed( QListViewItem * item )
411{ 400{
412 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 401 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
413} 402}
414 403
415void OVersatileView::pressed( QIconViewItem * item ) 404void OVersatileView::pressed( QIconViewItem * item )
416{ 405{
417 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) ); 406 emit( pressed( static_cast<OVersatileViewItem*>( item ) ) );
418} 407}
419 408
420void OVersatileView::doubleClicked( QListViewItem * item ) 409void OVersatileView::doubleClicked( QListViewItem * item )
421{ 410{
422 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); 411 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
423} 412}
424 413
425void OVersatileView::doubleClicked( QIconViewItem * item ) 414void OVersatileView::doubleClicked( QIconViewItem * item )
426{ 415{
427 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); 416 emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) );
428} 417}
429 418
430void OVersatileView::returnPressed( QListViewItem * item ) 419void OVersatileView::returnPressed( QListViewItem * item )
431{ 420{
432 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); 421 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
433} 422}
434 423
435void OVersatileView::returnPressed( QIconViewItem * item ) 424void OVersatileView::returnPressed( QIconViewItem * item )
436{ 425{