summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/alarmserver.cpp4
-rw-r--r--library/backend/vcc.y2
-rw-r--r--library/backend/vcc_yacc.cpp2
-rw-r--r--library/backend/vobject.cpp116
-rw-r--r--library/datebookmonth.cpp14
-rw-r--r--library/fileselector.cpp6
-rw-r--r--library/fontdatabase.cpp2
-rw-r--r--library/fontdatabase.h1
-rw-r--r--library/mimetype.cpp2
-rw-r--r--library/qpedialog.cpp4
-rw-r--r--library/qpestyle.cpp14
-rw-r--r--library/resource.cpp2
-rw-r--r--library/timestring.cpp34
13 files changed, 102 insertions, 101 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index 1ee05c6..177a0cb 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -1,80 +1,80 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qdir.h> 21#include <qdir.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25 25
26 26
27#include "qpeapplication.h" 27#include <qpe/qpeapplication.h>
28#include "global.h" 28#include "global.h"
29#include "resource.h" 29#include "resource.h"
30 30
31#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 31#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
32#include "qcopenvelope_qws.h" 32#include <qpe/qcopenvelope_qws.h>
33#endif 33#endif
34#include "alarmserver.h" 34#include "alarmserver.h"
35#include <qpe/timeconversion.h> 35#include <qpe/timeconversion.h>
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/stat.h> 38#include <sys/stat.h>
39 39
40#include <stdlib.h> 40#include <stdlib.h>
41#include <unistd.h> 41#include <unistd.h>
42 42
43struct timerEventItem { 43struct timerEventItem {
44 time_t UTCtime; 44 time_t UTCtime;
45 QCString channel, message; 45 QCString channel, message;
46 int data; 46 int data;
47 bool operator==( const timerEventItem &right ) const 47 bool operator==( const timerEventItem &right ) const
48 { 48 {
49 return ( UTCtime == right.UTCtime 49 return ( UTCtime == right.UTCtime
50 && channel == right.channel 50 && channel == right.channel
51 && message == right.message 51 && message == right.message
52 && data == right.data ); 52 && data == right.data );
53 } 53 }
54}; 54};
55 55
56class TimerReceiverObject : public QObject 56class TimerReceiverObject : public QObject
57{ 57{
58public: 58public:
59 TimerReceiverObject() { } 59 TimerReceiverObject() { }
60 ~TimerReceiverObject() { } 60 ~TimerReceiverObject() { }
61 void resetTimer(); 61 void resetTimer();
62 void setTimerEventItem(); 62 void setTimerEventItem();
63 void deleteTimer(); 63 void deleteTimer();
64protected: 64protected:
65 void timerEvent( QTimerEvent *te ); 65 void timerEvent( QTimerEvent *te );
66private: 66private:
67 QString atfilename; 67 QString atfilename;
68}; 68};
69 69
70TimerReceiverObject *timerEventReceiver = NULL; 70TimerReceiverObject *timerEventReceiver = NULL;
71QList<timerEventItem> timerEventList; 71QList<timerEventItem> timerEventList;
72timerEventItem *nearestTimerEvent = NULL; 72timerEventItem *nearestTimerEvent = NULL;
73 73
74 74
75// set the timer to go off on the next event in the list 75// set the timer to go off on the next event in the list
76void setNearestTimerEvent() 76void setNearestTimerEvent()
77{ 77{
78 nearestTimerEvent = NULL; 78 nearestTimerEvent = NULL;
79 QListIterator<timerEventItem> it( timerEventList ); 79 QListIterator<timerEventItem> it( timerEventList );
80 if ( *it ) 80 if ( *it )
diff --git a/library/backend/vcc.y b/library/backend/vcc.y
index 5bcf0cb..6781312 100644
--- a/library/backend/vcc.y
+++ b/library/backend/vcc.y
@@ -77,97 +77,97 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
77#define yynerrs mime_nerrs 77#define yynerrs mime_nerrs
78#define yyerrflag mime_errflag 78#define yyerrflag mime_errflag
79#define yyss mime_ss 79#define yyss mime_ss
80#define yyssp mime_ssp 80#define yyssp mime_ssp
81#define yyvs mime_vs 81#define yyvs mime_vs
82#define yyvsp mime_vsp 82#define yyvsp mime_vsp
83#define yylhs mime_lhs 83#define yylhs mime_lhs
84#define yylen mime_len 84#define yylen mime_len
85#define yydefred mime_defred 85#define yydefred mime_defred
86#define yydgoto mime_dgoto 86#define yydgoto mime_dgoto
87#define yysindex mime_sindex 87#define yysindex mime_sindex
88#define yyrindex mime_rindex 88#define yyrindex mime_rindex
89#define yygindex mime_gindex 89#define yygindex mime_gindex
90#define yytable mime_table 90#define yytable mime_table
91#define yycheck mime_check 91#define yycheck mime_check
92#define yyname mime_name 92#define yyname mime_name
93#define yyrule mime_rule 93#define yyrule mime_rule
94#ifdef YYPREFIX 94#ifdef YYPREFIX
95#undef YYPREFIX 95#undef YYPREFIX
96#endif 96#endif
97#define YYPREFIX "mime_" 97#define YYPREFIX "mime_"
98#endif 98#endif
99 99
100 100
101#ifndef _NO_LINE_FOLDING 101#ifndef _NO_LINE_FOLDING
102#define _SUPPORT_LINE_FOLDING 1 102#define _SUPPORT_LINE_FOLDING 1
103#endif 103#endif
104 104
105/* undef below if compile with MFC */ 105/* undef below if compile with MFC */
106/* #define INCLUDEMFC 1 */ 106/* #define INCLUDEMFC 1 */
107 107
108#if defined(WIN32) || defined(_WIN32) 108#if defined(WIN32) || defined(_WIN32)
109#ifdef INCLUDEMFC 109#ifdef INCLUDEMFC
110#include <afx.h> 110#include <afx.h>
111#endif 111#endif
112#endif 112#endif
113 113
114#include <string.h> 114#include <string.h>
115#ifndef __MWERKS__ 115#ifndef __MWERKS__
116#include <stdlib.h> 116#include <stdlib.h>
117#endif 117#endif
118#include <stdio.h> 118#include <stdio.h>
119#include <stdlib.h> 119#include <stdlib.h>
120#include <ctype.h> 120#include <ctype.h>
121 121
122//#ifdef PALMTOPCENTER 122//#ifdef PALMTOPCENTER
123//#include <qpe/vobject_p.h> 123//#include <qpe/vobject_p.h>
124//#else 124//#else
125#include "vobject_p.h" 125#include <qtopia/private/vobject_p.h>
126//#endif 126//#endif
127 127
128/**** Types, Constants ****/ 128/**** Types, Constants ****/
129 129
130 #define YYDEBUG 0/* 1 to compile in some debugging code */ 130 #define YYDEBUG 0/* 1 to compile in some debugging code */
131 #define MAXTOKEN 256/* maximum token (line) length */ 131 #define MAXTOKEN 256/* maximum token (line) length */
132 #define YYSTACKSIZE 100// ~unref ? 132 #define YYSTACKSIZE 100// ~unref ?
133 #define MAXLEVEL 10/* max # of nested objects parseable */ 133 #define MAXLEVEL 10/* max # of nested objects parseable */
134 /* (includes outermost) */ 134 /* (includes outermost) */
135 135
136 136
137/**** Global Variables ****/ 137/**** Global Variables ****/
138int mime_lineNum, mime_numErrors; /* yyerror() can use these */ 138int mime_lineNum, mime_numErrors; /* yyerror() can use these */
139static VObject* vObjList; 139static VObject* vObjList;
140static VObject *curProp; 140static VObject *curProp;
141static VObject *curObj; 141static VObject *curObj;
142static VObject* ObjStack[MAXLEVEL]; 142static VObject* ObjStack[MAXLEVEL];
143static int ObjStackTop; 143static int ObjStackTop;
144 144
145 145
146/* A helpful utility for the rest of the app. */ 146/* A helpful utility for the rest of the app. */
147#if __CPLUSPLUS__ 147#if __CPLUSPLUS__
148extern "C" { 148extern "C" {
149#endif 149#endif
150 150
151 extern void yyerror(char *s); 151 extern void yyerror(char *s);
152 152
153#if __CPLUSPLUS__ 153#if __CPLUSPLUS__
154 }; 154 };
155#endif 155#endif
156 156
157int yyparse(); 157int yyparse();
158 158
159enum LexMode { 159enum LexMode {
160 L_NORMAL, 160 L_NORMAL,
161 L_VCARD, 161 L_VCARD,
162 L_VCAL, 162 L_VCAL,
163 L_VEVENT, 163 L_VEVENT,
164 L_VTODO, 164 L_VTODO,
165 L_VALUES, 165 L_VALUES,
166 L_BASE64, 166 L_BASE64,
167 L_QUOTED_PRINTABLE 167 L_QUOTED_PRINTABLE
168 }; 168 };
169 169
170/**** Private Forward Declarations ****/ 170/**** Private Forward Declarations ****/
171static int pushVObject(const char *prop); 171static int pushVObject(const char *prop);
172static VObject* popVObject(); 172static VObject* popVObject();
173static void lexPopMode(int top); 173static void lexPopMode(int top);
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp
index 19a108f..b2b0c14 100644
--- a/library/backend/vcc_yacc.cpp
+++ b/library/backend/vcc_yacc.cpp
@@ -113,97 +113,97 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
113#define yynerrs mime_nerrs 113#define yynerrs mime_nerrs
114#define yyerrflag mime_errflag 114#define yyerrflag mime_errflag
115#define yyss mime_ss 115#define yyss mime_ss
116#define yyssp mime_ssp 116#define yyssp mime_ssp
117#define yyvs mime_vs 117#define yyvs mime_vs
118#define yyvsp mime_vsp 118#define yyvsp mime_vsp
119#define yylhs mime_lhs 119#define yylhs mime_lhs
120#define yylen mime_len 120#define yylen mime_len
121#define yydefred mime_defred 121#define yydefred mime_defred
122#define yydgoto mime_dgoto 122#define yydgoto mime_dgoto
123#define yysindex mime_sindex 123#define yysindex mime_sindex
124#define yyrindex mime_rindex 124#define yyrindex mime_rindex
125#define yygindex mime_gindex 125#define yygindex mime_gindex
126#define yytable mime_table 126#define yytable mime_table
127#define yycheck mime_check 127#define yycheck mime_check
128#define yyname mime_name 128#define yyname mime_name
129#define yyrule mime_rule 129#define yyrule mime_rule
130#ifdef YYPREFIX 130#ifdef YYPREFIX
131#undef YYPREFIX 131#undef YYPREFIX
132#endif 132#endif
133#define YYPREFIX "mime_" 133#define YYPREFIX "mime_"
134#endif 134#endif
135 135
136 136
137#ifndef _NO_LINE_FOLDING 137#ifndef _NO_LINE_FOLDING
138#define _SUPPORT_LINE_FOLDING 1 138#define _SUPPORT_LINE_FOLDING 1
139#endif 139#endif
140 140
141/* undef below if compile with MFC */ 141/* undef below if compile with MFC */
142/* #define INCLUDEMFC 1 */ 142/* #define INCLUDEMFC 1 */
143 143
144#if defined(WIN32) || defined(_WIN32) 144#if defined(WIN32) || defined(_WIN32)
145#ifdef INCLUDEMFC 145#ifdef INCLUDEMFC
146#include <afx.h> 146#include <afx.h>
147#endif 147#endif
148#endif 148#endif
149 149
150#include <string.h> 150#include <string.h>
151#ifndef __MWERKS__ 151#ifndef __MWERKS__
152#include <stdlib.h> 152#include <stdlib.h>
153#endif 153#endif
154#include <stdio.h> 154#include <stdio.h>
155#include <stdlib.h> 155#include <stdlib.h>
156#include <ctype.h> 156#include <ctype.h>
157 157
158/*#ifdef PALMTOPCENTER */ 158/*#ifdef PALMTOPCENTER */
159/*#include <qpe/vobject_p.h> */ 159/*#include <qpe/vobject_p.h> */
160/*#else */ 160/*#else */
161#include "vobject_p.h" 161#include <qtopia/private/vobject_p.h>
162/*#endif */ 162/*#endif */
163 163
164/**** Types, Constants ****/ 164/**** Types, Constants ****/
165 165
166 #define YYDEBUG 0/* 1 to compile in some debugging code */ 166 #define YYDEBUG 0/* 1 to compile in some debugging code */
167 #define MAXTOKEN 256/* maximum token (line) length */ 167 #define MAXTOKEN 256/* maximum token (line) length */
168 #define YYSTACKSIZE 100/* ~unref ? */ 168 #define YYSTACKSIZE 100/* ~unref ? */
169 #define MAXLEVEL 10/* max # of nested objects parseable */ 169 #define MAXLEVEL 10/* max # of nested objects parseable */
170 /* (includes outermost) */ 170 /* (includes outermost) */
171 171
172 172
173/**** Global Variables ****/ 173/**** Global Variables ****/
174int mime_lineNum, mime_numErrors; /* yyerror() can use these */ 174int mime_lineNum, mime_numErrors; /* yyerror() can use these */
175static VObject* vObjList; 175static VObject* vObjList;
176static VObject *curProp; 176static VObject *curProp;
177static VObject *curObj; 177static VObject *curObj;
178static VObject* ObjStack[MAXLEVEL]; 178static VObject* ObjStack[MAXLEVEL];
179static int ObjStackTop; 179static int ObjStackTop;
180 180
181 181
182/* A helpful utility for the rest of the app. */ 182/* A helpful utility for the rest of the app. */
183#if __CPLUSPLUS__ 183#if __CPLUSPLUS__
184extern "C" { 184extern "C" {
185#endif 185#endif
186 186
187 extern void yyerror(char *s); 187 extern void yyerror(char *s);
188 188
189#if __CPLUSPLUS__ 189#if __CPLUSPLUS__
190 }; 190 };
191#endif 191#endif
192 192
193int yyparse(); 193int yyparse();
194 194
195enum LexMode { 195enum LexMode {
196 L_NORMAL, 196 L_NORMAL,
197 L_VCARD, 197 L_VCARD,
198 L_VCAL, 198 L_VCAL,
199 L_VEVENT, 199 L_VEVENT,
200 L_VTODO, 200 L_VTODO,
201 L_VALUES, 201 L_VALUES,
202 L_BASE64, 202 L_BASE64,
203 L_QUOTED_PRINTABLE 203 L_QUOTED_PRINTABLE
204 }; 204 };
205 205
206/**** Private Forward Declarations ****/ 206/**** Private Forward Declarations ****/
207static int pushVObject(const char *prop); 207static int pushVObject(const char *prop);
208static VObject* popVObject(); 208static VObject* popVObject();
209static void lexPopMode(int top); 209static void lexPopMode(int top);
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp
index e6f6b78..dab128e 100644
--- a/library/backend/vobject.cpp
+++ b/library/backend/vobject.cpp
@@ -1,98 +1,98 @@
1/*************************************************************************** 1/***************************************************************************
2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International 2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
3Business Machines Corporation and Siemens Rolm Communications Inc. 3Business Machines Corporation and Siemens Rolm Communications Inc.
4 4
5For purposes of this license notice, the term Licensors shall mean, 5For purposes of this license notice, the term Licensors shall mean,
6collectively, Apple Computer, Inc., AT&T Corp., International 6collectively, Apple Computer, Inc., AT&T Corp., International
7Business Machines Corporation and Siemens Rolm Communications Inc. 7Business Machines Corporation and Siemens Rolm Communications Inc.
8The term Licensor shall mean any of the Licensors. 8The term Licensor shall mean any of the Licensors.
9 9
10Subject to acceptance of the following conditions, permission is hereby 10Subject to acceptance of the following conditions, permission is hereby
11granted by Licensors without the need for written agreement and without 11granted by Licensors without the need for written agreement and without
12license or royalty fees, to use, copy, modify and distribute this 12license or royalty fees, to use, copy, modify and distribute this
13software for any purpose. 13software for any purpose.
14 14
15The above copyright notice and the following four paragraphs must be 15The above copyright notice and the following four paragraphs must be
16reproduced in all copies of this software and any software including 16reproduced in all copies of this software and any software including
17this software. 17this software.
18 18
19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE 19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR 20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
21MODIFICATIONS. 21MODIFICATIONS.
22 22
23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, 23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26DAMAGE. 26DAMAGE.
27 27
28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, 28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE 29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31PURPOSE. 31PURPOSE.
32 32
33The software is provided with RESTRICTED RIGHTS. Use, duplication, or 33The software is provided with RESTRICTED RIGHTS. Use, duplication, or
34disclosure by the government are subject to restrictions set forth in 34disclosure by the government are subject to restrictions set forth in
35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. 35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
36 36
37***************************************************************************/ 37***************************************************************************/
38 38
39/* 39/*
40 * src: vobject.c 40 * src: vobject.c
41 * doc: vobject and APIs to construct vobject, APIs pretty print 41 * doc: vobject and APIs to construct vobject, APIs pretty print
42 * vobject, and convert a vobject into its textual representation. 42 * vobject, and convert a vobject into its textual representation.
43 */ 43 */
44 44
45 #ifndef MWERKS 45 #ifndef MWERKS
46#include <malloc.h> 46#include <malloc.h>
47#endif 47#endif
48 48
49#include "vobject_p.h" 49#include <qtopia/private/vobject_p.h>
50#include "qfiledirect_p.h" 50#include <qtopia/private/qfiledirect_p.h>
51#include <string.h> 51#include <string.h>
52#include <stdio.h> 52#include <stdio.h>
53#include <fcntl.h> 53#include <fcntl.h>
54//#include <io.h> 54//#include <io.h>
55 55
56 56
57 #define NAME_OF(o) o->id 57 #define NAME_OF(o) o->id
58 #define VALUE_TYPE(o) o->valType 58 #define VALUE_TYPE(o) o->valType
59 #define STRINGZ_VALUE_OF(o) o->val.strs 59 #define STRINGZ_VALUE_OF(o) o->val.strs
60 #define INTEGER_VALUE_OF(o) o->val.i 60 #define INTEGER_VALUE_OF(o) o->val.i
61 #define LONG_VALUE_OF(o) o->val.l 61 #define LONG_VALUE_OF(o) o->val.l
62 #define ANY_VALUE_OF(o) o->val.any 62 #define ANY_VALUE_OF(o) o->val.any
63 #define VOBJECT_VALUE_OF(o) o->val.vobj 63 #define VOBJECT_VALUE_OF(o) o->val.vobj
64 64
65typedef union ValueItem { 65typedef union ValueItem {
66 const char *strs; 66 const char *strs;
67 unsigned int i; 67 unsigned int i;
68 unsigned long l; 68 unsigned long l;
69 void *any; 69 void *any;
70 VObject *vobj; 70 VObject *vobj;
71 } ValueItem; 71 } ValueItem;
72 72
73struct VObject { 73struct VObject {
74 VObject *next; 74 VObject *next;
75 const char *id; 75 const char *id;
76 VObject *prop; 76 VObject *prop;
77 unsigned short valType; 77 unsigned short valType;
78 ValueItem val; 78 ValueItem val;
79 }; 79 };
80 80
81typedef struct StrItem StrItem; 81typedef struct StrItem StrItem;
82 82
83struct StrItem { 83struct StrItem {
84 StrItem *next; 84 StrItem *next;
85 const char *s; 85 const char *s;
86 unsigned int refCnt; 86 unsigned int refCnt;
87 }; 87 };
88 88
89const char** fieldedProp; 89const char** fieldedProp;
90 90
91 91
92 92
93/*---------------------------------------------------------------------- 93/*----------------------------------------------------------------------
94 The following functions involve with memory allocation: 94 The following functions involve with memory allocation:
95 newVObject 95 newVObject
96 deleteVObject 96 deleteVObject
97 dupStr 97 dupStr
98 deleteStr 98 deleteStr
@@ -282,173 +282,173 @@ DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
282 282
283DLLEXPORT(VObject*) addProp(VObject *o, const char *id) 283DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
284{ 284{
285 return addVObjectProp(o,newVObject(id)); 285 return addVObjectProp(o,newVObject(id));
286} 286}
287 287
288DLLEXPORT(VObject*) addProp_(VObject *o, const char *id) 288DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
289{ 289{
290 return addVObjectProp(o,newVObject_(id)); 290 return addVObjectProp(o,newVObject_(id));
291} 291}
292 292
293DLLEXPORT(void) addList(VObject **o, VObject *p) 293DLLEXPORT(void) addList(VObject **o, VObject *p)
294{ 294{
295 p->next = 0; 295 p->next = 0;
296 if (*o == 0) { 296 if (*o == 0) {
297 *o = p; 297 *o = p;
298 } 298 }
299 else { 299 else {
300 VObject *t = *o; 300 VObject *t = *o;
301 while (t->next) { 301 while (t->next) {
302 t = t->next; 302 t = t->next;
303 } 303 }
304 t->next = p; 304 t->next = p;
305 } 305 }
306} 306}
307 307
308DLLEXPORT(VObject*) nextVObjectInList(VObject *o) 308DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
309{ 309{
310 return o->next; 310 return o->next;
311} 311}
312 312
313DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size) 313DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
314{ 314{
315 VObject *sizeProp; 315 VObject *sizeProp;
316 setVObjectAnyValue(prop, val); 316 setVObjectAnyValue(prop, val);
317 sizeProp = addProp(prop,VCDataSizeProp); 317 sizeProp = addProp(prop,VCDataSizeProp);
318 setVObjectLongValue(sizeProp, size); 318 setVObjectLongValue(sizeProp, size);
319 return prop; 319 return prop;
320} 320}
321 321
322DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size) 322DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
323{ 323{
324 void *p = dupStr((const char *)val,size); 324 void *p = dupStr((const char *)val,size);
325 return setValueWithSize_(prop,p,p?size:0); 325 return setValueWithSize_(prop,p,p?size:0);
326} 326}
327 327
328DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) 328DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
329{ 329{
330 i->start = o->prop; 330 i->start = o->prop;
331 i->next = 0; 331 i->next = 0;
332} 332}
333 333
334DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) 334DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
335{ 335{
336 i->start = o->next; 336 i->start = o->next;
337 i->next = 0; 337 i->next = 0;
338} 338}
339 339
340DLLEXPORT(int) moreIteration(VObjectIterator *i) 340DLLEXPORT(int) moreIteration(VObjectIterator *i)
341{ 341{
342 return (i->start && (i->next==0 || i->next!=i->start)); 342 return (i->start && (i->next==0 || i->next!=i->start));
343} 343}
344 344
345DLLEXPORT(VObject*) nextVObject(VObjectIterator *i) 345DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
346{ 346{
347 if (i->start && i->next != i->start) { 347 if (i->start && i->next != i->start) {
348 if (i->next == 0) { 348 if (i->next == 0) {
349 i->next = i->start->next; 349 i->next = i->start->next;
350 return i->next; 350 return i->next;
351 } 351 }
352 else { 352 else {
353 i->next = i->next->next; 353 i->next = i->next->next;
354 return i->next; 354 return i->next;
355 } 355 }
356 } 356 }
357 else return (VObject*)0; 357 else return (VObject*)0;
358} 358}
359 359
360DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id) 360DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
361{ 361{
362 VObjectIterator i; 362 VObjectIterator i;
363 initPropIterator(&i,o); 363 initPropIterator(&i,o);
364 while (moreIteration(&i)) { 364 while (moreIteration(&i)) {
365 VObject *each = nextVObject(&i); 365 VObject *each = nextVObject(&i);
366 if (!qstricmp(id,each->id)) 366 if (!qstricmp(id,each->id))
367 return each; 367 return each;
368 } 368 }
369 return (VObject*)0; 369 return (VObject*)0;
370} 370}
371 371
372DLLEXPORT(VObject*) addGroup(VObject *o, const char *g) 372DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
373{ 373{
374 /* 374 /*
375 a.b.c 375 a.b.c
376 --> 376 -->
377 prop(c) 377 prop(c)
378 prop(VCGrouping=b) 378 prop(VCGrouping=b)
379 prop(VCGrouping=a) 379 prop(VCGrouping=a)
380 */ 380 */
381 char *dot = strrchr(g,'.'); 381 char *dot = strrchr(g,'.');
382 if (dot) { 382 if (dot) {
383 VObject *p, *t; 383 VObject *p, *t;
384 char *gs, *n = dot+1; 384 char *gs, *n = dot+1;
385 gs = dupStr(g,0);/* so we can write to it. */ 385 gs = dupStr(g,0);/* so we can write to it. */
386 /* used to be 386 /* used to be
387 * t = p = addProp_(o,lookupProp_(n)); 387 * t = p = addProp_(o,lookupProp_(n));
388 */ 388 */
389 t = p = addProp_(o,lookupProp(n)); 389 t = p = addProp_(o,lookupProp(n));
390 dot = strrchr(gs,'.'); 390 dot = strrchr(gs,'.');
391 *dot = 0; 391 *dot = 0;
392 do { 392 do {
393 dot = strrchr(gs,'.'); 393 dot = strrchr(gs,'.');
394 if (dot) { 394 if (dot) {
395 n = dot+1; 395 n = dot+1;
396 *dot=0; 396 *dot=0;
397 } 397 }
398 else 398 else
399 n = gs; 399 n = gs;
400 /* property(VCGroupingProp=n); 400 /* property(VCGroupingProp=n);
401 *and the value may have VCGrouping property 401 *and the value may have VCGrouping property
402 */ 402 */
403 t = addProp(t,VCGroupingProp); 403 t = addProp(t,VCGroupingProp);
404 setVObjectStringZValue(t,lookupProp_(n)); 404 setVObjectStringZValue(t,lookupProp_(n));
405 } while (n != gs); 405 } while (n != gs);
406 deleteStr(gs); 406 deleteStr(gs);
407 return p; 407 return p;
408 } 408 }
409 else 409 else
410 return addProp_(o,lookupProp(g)); 410 return addProp_(o,lookupProp(g));
411} 411}
412 412
413DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v) 413DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
414{ 414{
415 VObject *prop; 415 VObject *prop;
416 prop = addProp(o,p); 416 prop = addProp(o,p);
417 setVObjectStringZValue_(prop, strdup( v ) ); 417 setVObjectStringZValue_(prop, strdup( v ) );
418 return prop; 418 return prop;
419} 419}
420 420
421DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, 421DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
422 unsigned int size) 422 unsigned int size)
423{ 423{
424 VObject *prop; 424 VObject *prop;
425 prop = addProp(o,p); 425 prop = addProp(o,p);
426 setValueWithSize_(prop, (void*)v, size); 426 setValueWithSize_(prop, (void*)v, size);
427 return prop; 427 return prop;
428} 428}
429 429
430DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, 430DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
431 unsigned int size) 431 unsigned int size)
432{ 432{
433 return addPropSizedValue_(o,p,dupStr(v,size),size); 433 return addPropSizedValue_(o,p,dupStr(v,size),size);
434} 434}
435 435
436 436
437DLLEXPORT(void) cleanVObject(VObject *o) 437DLLEXPORT(void) cleanVObject(VObject *o)
438{ 438{
439 if (o == 0) return; 439 if (o == 0) return;
440 if (o->prop) { 440 if (o->prop) {
441 /* destroy time: cannot use the iterator here. 441 /* destroy time: cannot use the iterator here.
442 Have to break the cycle in the circular link 442 Have to break the cycle in the circular link
443 list and turns it into regular NULL-terminated 443 list and turns it into regular NULL-terminated
444 list -- since at some point of destruction, 444 list -- since at some point of destruction,
445 the reference entry for the iterator to work 445 the reference entry for the iterator to work
446 will not longer be valid. 446 will not longer be valid.
447 */ 447 */
448 VObject *p; 448 VObject *p;
449 p = o->prop->next; 449 p = o->prop->next;
450 o->prop->next = 0; 450 o->prop->next = 0;
451 do { 451 do {
452 VObject *t = p->next; 452 VObject *t = p->next;
453 cleanVObject(p); 453 cleanVObject(p);
454 p = t; 454 p = t;
@@ -754,124 +754,124 @@ static struct PreDefProp propNames[] = {
754 { VCQPProp, VCQuotedPrintableProp, 0, 0 }, 754 { VCQPProp, VCQuotedPrintableProp, 0, 0 },
755 { VCQuickTimeProp, 0, 0, 0 }, 755 { VCQuickTimeProp, 0, 0, 0 },
756 { VCQuotedPrintableProp, 0, 0, 0 }, 756 { VCQuotedPrintableProp, 0, 0, 0 },
757 { VCRDateProp, 0, 0, 0 }, 757 { VCRDateProp, 0, 0, 0 },
758 { VCRegionProp, 0, 0, 0 }, 758 { VCRegionProp, 0, 0, 0 },
759 { VCRelatedToProp, 0, 0, 0 }, 759 { VCRelatedToProp, 0, 0, 0 },
760 { VCRepeatCountProp, 0, 0, 0 }, 760 { VCRepeatCountProp, 0, 0, 0 },
761 { VCResourcesProp, 0, 0, 0 }, 761 { VCResourcesProp, 0, 0, 0 },
762 { VCRNumProp, 0, 0, 0 }, 762 { VCRNumProp, 0, 0, 0 },
763 { VCRoleProp, 0, 0, 0 }, 763 { VCRoleProp, 0, 0, 0 },
764 { VCRRuleProp, 0, 0, 0 }, 764 { VCRRuleProp, 0, 0, 0 },
765 { VCRSVPProp, 0, 0, 0 }, 765 { VCRSVPProp, 0, 0, 0 },
766 { VCRunTimeProp, 0, 0, 0 }, 766 { VCRunTimeProp, 0, 0, 0 },
767 { VCSequenceProp, 0, 0, 0 }, 767 { VCSequenceProp, 0, 0, 0 },
768 { VCSnoozeTimeProp, 0, 0, 0 }, 768 { VCSnoozeTimeProp, 0, 0, 0 },
769 { VCStartProp, 0, 0, 0 }, 769 { VCStartProp, 0, 0, 0 },
770 { VCStatusProp, 0, 0, 0 }, 770 { VCStatusProp, 0, 0, 0 },
771 { VCStreetAddressProp, 0, 0, 0 }, 771 { VCStreetAddressProp, 0, 0, 0 },
772 { VCSubTypeProp, 0, 0, 0 }, 772 { VCSubTypeProp, 0, 0, 0 },
773 { VCSummaryProp, 0, 0, 0 }, 773 { VCSummaryProp, 0, 0, 0 },
774 { VCTelephoneProp, 0, 0, 0 }, 774 { VCTelephoneProp, 0, 0, 0 },
775 { VCTIFFProp, 0, 0, 0 }, 775 { VCTIFFProp, 0, 0, 0 },
776 { VCTimeZoneProp, 0, 0, 0 }, 776 { VCTimeZoneProp, 0, 0, 0 },
777 { VCTitleProp, 0, 0, 0 }, 777 { VCTitleProp, 0, 0, 0 },
778 { VCTLXProp, 0, 0, 0 }, 778 { VCTLXProp, 0, 0, 0 },
779 { VCTodoProp, 0, 0, PD_BEGIN }, 779 { VCTodoProp, 0, 0, PD_BEGIN },
780 { VCTranspProp, 0, 0, 0 }, 780 { VCTranspProp, 0, 0, 0 },
781 { VCUniqueStringProp, 0, 0, 0 }, 781 { VCUniqueStringProp, 0, 0, 0 },
782 { VCURLProp, 0, 0, 0 }, 782 { VCURLProp, 0, 0, 0 },
783 { VCURLValueProp, 0, 0, 0 }, 783 { VCURLValueProp, 0, 0, 0 },
784 { VCValueProp, 0, 0, 0 }, 784 { VCValueProp, 0, 0, 0 },
785 { VCVersionProp, 0, 0, 0 }, 785 { VCVersionProp, 0, 0, 0 },
786 { VCVideoProp, 0, 0, 0 }, 786 { VCVideoProp, 0, 0, 0 },
787 { VCVoiceProp, 0, 0, 0 }, 787 { VCVoiceProp, 0, 0, 0 },
788 { VCWAVEProp, 0, 0, 0 }, 788 { VCWAVEProp, 0, 0, 0 },
789 { VCWMFProp, 0, 0, 0 }, 789 { VCWMFProp, 0, 0, 0 },
790 { VCWorkProp, 0, 0, 0 }, 790 { VCWorkProp, 0, 0, 0 },
791 { VCX400Prop, 0, 0, 0 }, 791 { VCX400Prop, 0, 0, 0 },
792 { VCX509Prop, 0, 0, 0 }, 792 { VCX509Prop, 0, 0, 0 },
793 { VCXRuleProp, 0, 0, 0 }, 793 { VCXRuleProp, 0, 0, 0 },
794 { 0,0,0,0 } 794 { 0,0,0,0 }
795 }; 795 };
796 796
797 797
798static struct PreDefProp* lookupPropInfo(const char* str) 798static struct PreDefProp* lookupPropInfo(const char* str)
799{ 799{
800 /* brute force for now, could use a hash table here. */ 800 /* brute force for now, could use a hash table here. */
801 int i; 801 int i;
802 802
803 for (i = 0; propNames[i].name; i++) 803 for (i = 0; propNames[i].name; i++)
804 if (qstricmp(str, propNames[i].name) == 0) { 804 if (qstricmp(str, propNames[i].name) == 0) {
805 return &propNames[i]; 805 return &propNames[i];
806 } 806 }
807 807
808 return 0; 808 return 0;
809} 809}
810 810
811 811
812DLLEXPORT(const char*) lookupProp_(const char* str) 812DLLEXPORT(const char*) lookupProp_(const char* str)
813{ 813{
814 int i; 814 int i;
815 815
816 for (i = 0; propNames[i].name; i++) 816 for (i = 0; propNames[i].name; i++)
817 if (qstricmp(str, propNames[i].name) == 0) { 817 if (qstricmp(str, propNames[i].name) == 0) {
818 const char* s; 818 const char* s;
819 s = propNames[i].alias?propNames[i].alias:propNames[i].name; 819 s = propNames[i].alias?propNames[i].alias:propNames[i].name;
820 return lookupStr(s); 820 return lookupStr(s);
821 } 821 }
822 return lookupStr(str); 822 return lookupStr(str);
823} 823}
824 824
825 825
826DLLEXPORT(const char*) lookupProp(const char* str) 826DLLEXPORT(const char*) lookupProp(const char* str)
827{ 827{
828 int i; 828 int i;
829 829
830 for (i = 0; propNames[i].name; i++) 830 for (i = 0; propNames[i].name; i++)
831 if (qstricmp(str, propNames[i].name) == 0) { 831 if (qstricmp(str, propNames[i].name) == 0) {
832 const char *s; 832 const char *s;
833 fieldedProp = propNames[i].fields; 833 fieldedProp = propNames[i].fields;
834 s = propNames[i].alias?propNames[i].alias:propNames[i].name; 834 s = propNames[i].alias?propNames[i].alias:propNames[i].name;
835 return lookupStr(s); 835 return lookupStr(s);
836 } 836 }
837 fieldedProp = 0; 837 fieldedProp = 0;
838 return lookupStr(str); 838 return lookupStr(str);
839} 839}
840 840
841 841
842/*---------------------------------------------------------------------- 842/*----------------------------------------------------------------------
843 APIs to Output text form. 843 APIs to Output text form.
844 ----------------------------------------------------------------------*/ 844 ----------------------------------------------------------------------*/
845#define OFILE_REALLOC_SIZE 256 845#define OFILE_REALLOC_SIZE 256
846typedef struct OFile { 846typedef struct OFile {
847 FILE *fp; 847 FILE *fp;
848 char *s; 848 char *s;
849 int len; 849 int len;
850 int limit; 850 int limit;
851 int alloc:1; 851 int alloc:1;
852 int fail:1; 852 int fail:1;
853 } OFile; 853 } OFile;
854 854
855#if 0 855#if 0
856static void appendsOFile(OFile *fp, const char *s) 856static void appendsOFile(OFile *fp, const char *s)
857{ 857{
858 int slen; 858 int slen;
859 if (fp->fail) return; 859 if (fp->fail) return;
860 slen = strlen(s); 860 slen = strlen(s);
861 if (fp->fp) { 861 if (fp->fp) {
862 fwrite(s,1,slen,fp->fp); 862 fwrite(s,1,slen,fp->fp);
863 } 863 }
864 else { 864 else {
865stuff: 865stuff:
866 if (fp->len + slen < fp->limit) { 866 if (fp->len + slen < fp->limit) {
867 memcpy(fp->s+fp->len,s,slen); 867 memcpy(fp->s+fp->len,s,slen);
868 fp->len += slen; 868 fp->len += slen;
869 return; 869 return;
870 } 870 }
871 else if (fp->alloc) { 871 else if (fp->alloc) {
872 fp->limit = fp->limit + OFILE_REALLOC_SIZE; 872 fp->limit = fp->limit + OFILE_REALLOC_SIZE;
873 if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen; 873 if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
874 fp->s = (char *) realloc(fp->s,fp->limit); 874 fp->s = (char *) realloc(fp->s,fp->limit);
875 if (fp->s) goto stuff; 875 if (fp->s) goto stuff;
876 } 876 }
877 if (fp->alloc) 877 if (fp->alloc)
@@ -960,185 +960,185 @@ static void initOFile(OFile *fp, FILE *ofp)
960 fp->len = 0; 960 fp->len = 0;
961 fp->limit = 0; 961 fp->limit = 0;
962 fp->alloc = 0; 962 fp->alloc = 0;
963 fp->fail = 0; 963 fp->fail = 0;
964} 964}
965 965
966static int writeBase64(OFile *fp, unsigned char *s, long len) 966static int writeBase64(OFile *fp, unsigned char *s, long len)
967{ 967{
968 long cur = 0; 968 long cur = 0;
969 int i, numQuads = 0; 969 int i, numQuads = 0;
970 unsigned long trip; 970 unsigned long trip;
971 unsigned char b; 971 unsigned char b;
972 char quad[5]; 972 char quad[5];
973#define MAXQUADS 16 973#define MAXQUADS 16
974 974
975 quad[4] = 0; 975 quad[4] = 0;
976 976
977 while (cur < len) { 977 while (cur < len) {
978 // collect the triplet of bytes into 'trip' 978 // collect the triplet of bytes into 'trip'
979 trip = 0; 979 trip = 0;
980 for (i = 0; i < 3; i++) { 980 for (i = 0; i < 3; i++) {
981 b = (cur < len) ? *(s + cur) : 0; 981 b = (cur < len) ? *(s + cur) : 0;
982 cur++; 982 cur++;
983 trip = trip << 8 | b; 983 trip = trip << 8 | b;
984 } 984 }
985 // fill in 'quad' with the appropriate four characters 985 // fill in 'quad' with the appropriate four characters
986 for (i = 3; i >= 0; i--) { 986 for (i = 3; i >= 0; i--) {
987 b = (unsigned char)(trip & 0x3F); 987 b = (unsigned char)(trip & 0x3F);
988 trip = trip >> 6; 988 trip = trip >> 6;
989 if ((3 - i) < (cur - len)) 989 if ((3 - i) < (cur - len))
990 quad[i] = '='; // pad char 990 quad[i] = '='; // pad char
991 else if (b < 26) quad[i] = (char)b + 'A'; 991 else if (b < 26) quad[i] = (char)b + 'A';
992 else if (b < 52) quad[i] = (char)(b - 26) + 'a'; 992 else if (b < 52) quad[i] = (char)(b - 26) + 'a';
993 else if (b < 62) quad[i] = (char)(b - 52) + '0'; 993 else if (b < 62) quad[i] = (char)(b - 52) + '0';
994 else if (b == 62) quad[i] = '+'; 994 else if (b == 62) quad[i] = '+';
995 else quad[i] = '/'; 995 else quad[i] = '/';
996 } 996 }
997 // now output 'quad' with appropriate whitespace and line ending 997 // now output 'quad' with appropriate whitespace and line ending
998 appendsOFile(fp, (numQuads == 0 ? " " : "")); 998 appendsOFile(fp, (numQuads == 0 ? " " : ""));
999 appendsOFile(fp, quad); 999 appendsOFile(fp, quad);
1000 appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); 1000 appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
1001 numQuads = (numQuads + 1) % MAXQUADS; 1001 numQuads = (numQuads + 1) % MAXQUADS;
1002 } 1002 }
1003 appendcOFile(fp,'\n'); 1003 appendcOFile(fp,'\n');
1004 1004
1005 return 1; 1005 return 1;
1006} 1006}
1007 1007
1008static const char *replaceChar(unsigned char c) 1008static const char *replaceChar(unsigned char c)
1009{ 1009{
1010 if (c == '\n') { 1010 if (c == '\n') {
1011 return "=0A=\n"; 1011 return "=0A=\n";
1012 } else if ( 1012 } else if (
1013 (c >= 'A' && c <= 'Z') 1013 (c >= 'A' && c <= 'Z')
1014 || 1014 ||
1015 (c >= 'a' && c <= 'z') 1015 (c >= 'a' && c <= 'z')
1016 || 1016 ||
1017 (c >= '0' && c <= '9') 1017 (c >= '0' && c <= '9')
1018 || 1018 ||
1019 (c >= '\'' && c <= ')') 1019 (c >= '\'' && c <= ')')
1020 || 1020 ||
1021 (c >= '+' && c <= '-') 1021 (c >= '+' && c <= '-')
1022 || 1022 ||
1023 (c == '/') 1023 (c == '/')
1024 || 1024 ||
1025 (c == '?') 1025 (c == '?')
1026 || 1026 ||
1027 (c == ' ')) 1027 (c == ' '))
1028 { 1028 {
1029 return 0; 1029 return 0;
1030 } 1030 }
1031 1031
1032 static char trans[4]; 1032 static char trans[4];
1033 trans[0] = '='; 1033 trans[0] = '=';
1034 trans[3] = '\0'; 1034 trans[3] = '\0';
1035 int rem = c % 16; 1035 int rem = c % 16;
1036 int div = c / 16; 1036 int div = c / 16;
1037 1037
1038 if (div < 10) 1038 if (div < 10)
1039 trans[1] = '0' + div; 1039 trans[1] = '0' + div;
1040 else 1040 else
1041 trans[1] = 'A' + (div - 10); 1041 trans[1] = 'A' + (div - 10);
1042 1042
1043 if (rem < 10) 1043 if (rem < 10)
1044 trans[2] = '0' + rem; 1044 trans[2] = '0' + rem;
1045 else 1045 else
1046 trans[2] = 'A' + (rem - 10); 1046 trans[2] = 'A' + (rem - 10);
1047 1047
1048 return trans; 1048 return trans;
1049} 1049}
1050 1050
1051static void writeQPString(OFile *fp, const char *s) 1051static void writeQPString(OFile *fp, const char *s)
1052{ 1052{
1053 /* 1053 /*
1054 only A-Z, 0-9 and 1054 only A-Z, 0-9 and
1055 "'" (ASCII code 39) 1055 "'" (ASCII code 39)
1056 "(" (ASCII code 40) 1056 "(" (ASCII code 40)
1057 ")" (ASCII code 41) 1057 ")" (ASCII code 41)
1058 "+" (ASCII code 43) 1058 "+" (ASCII code 43)
1059 "," (ASCII code 44) 1059 "," (ASCII code 44)
1060 "-" (ASCII code 45) 1060 "-" (ASCII code 45)
1061 "/" (ASCII code 47) 1061 "/" (ASCII code 47)
1062 "?" (ASCII code 63) 1062 "?" (ASCII code 63)
1063 1063
1064 should remain un-encoded. 1064 should remain un-encoded.
1065 '=' needs to be encoded as it is the escape character. 1065 '=' needs to be encoded as it is the escape character.
1066 ';' needs to be as it is a field separator. 1066 ';' needs to be as it is a field separator.
1067 1067
1068 */ 1068 */
1069 const char *p = s; 1069 const char *p = s;
1070 while (*p) { 1070 while (*p) {
1071 const char *rep = replaceChar(*p); 1071 const char *rep = replaceChar(*p);
1072 if (rep) 1072 if (rep)
1073 appendsOFile(fp, rep); 1073 appendsOFile(fp, rep);
1074 else 1074 else
1075 appendcOFile(fp, *p); 1075 appendcOFile(fp, *p);
1076 p++; 1076 p++;
1077 } 1077 }
1078} 1078}
1079 1079
1080static bool includesUnprintable(VObject *o) 1080static bool includesUnprintable(VObject *o)
1081{ 1081{
1082 if (o) { 1082 if (o) {
1083 if (VALUE_TYPE(o) == VCVT_STRINGZ) { 1083 if (VALUE_TYPE(o) == VCVT_STRINGZ) {
1084 const char *p = STRINGZ_VALUE_OF(o); 1084 const char *p = STRINGZ_VALUE_OF(o);
1085 if (p) { 1085 if (p) {
1086 while (*p) { 1086 while (*p) {
1087 if (replaceChar(*p)) 1087 if (replaceChar(*p))
1088 return TRUE; 1088 return TRUE;
1089 p++; 1089 p++;
1090 } 1090 }
1091 } 1091 }
1092 } 1092 }
1093 } 1093 }
1094 return FALSE; 1094 return FALSE;
1095} 1095}
1096 1096
1097static void writeVObject_(OFile *fp, VObject *o); 1097static void writeVObject_(OFile *fp, VObject *o);
1098 1098
1099static void writeValue(OFile *fp, VObject *o, unsigned long size) 1099static void writeValue(OFile *fp, VObject *o, unsigned long size)
1100{ 1100{
1101 if (o == 0) return; 1101 if (o == 0) return;
1102 switch (VALUE_TYPE(o)) { 1102 switch (VALUE_TYPE(o)) {
1103 case VCVT_STRINGZ: { 1103 case VCVT_STRINGZ: {
1104 writeQPString(fp, STRINGZ_VALUE_OF(o)); 1104 writeQPString(fp, STRINGZ_VALUE_OF(o));
1105 break; 1105 break;
1106 } 1106 }
1107 case VCVT_UINT: { 1107 case VCVT_UINT: {
1108 char buf[16]; 1108 char buf[16];
1109 sprintf(buf,"%u", INTEGER_VALUE_OF(o)); 1109 sprintf(buf,"%u", INTEGER_VALUE_OF(o));
1110 appendsOFile(fp,buf); 1110 appendsOFile(fp,buf);
1111 break; 1111 break;
1112 } 1112 }
1113 case VCVT_ULONG: { 1113 case VCVT_ULONG: {
1114 char buf[16]; 1114 char buf[16];
1115 sprintf(buf,"%lu", LONG_VALUE_OF(o)); 1115 sprintf(buf,"%lu", LONG_VALUE_OF(o));
1116 appendsOFile(fp,buf); 1116 appendsOFile(fp,buf);
1117 break; 1117 break;
1118 } 1118 }
1119 case VCVT_RAW: { 1119 case VCVT_RAW: {
1120 appendcOFile(fp,'\n'); 1120 appendcOFile(fp,'\n');
1121 writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); 1121 writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
1122 break; 1122 break;
1123 } 1123 }
1124 case VCVT_VOBJECT: 1124 case VCVT_VOBJECT:
1125 appendcOFile(fp,'\n'); 1125 appendcOFile(fp,'\n');
1126 writeVObject_(fp,VOBJECT_VALUE_OF(o)); 1126 writeVObject_(fp,VOBJECT_VALUE_OF(o));
1127 break; 1127 break;
1128 } 1128 }
1129} 1129}
1130 1130
1131static void writeAttrValue(OFile *fp, VObject *o) 1131static void writeAttrValue(OFile *fp, VObject *o)
1132{ 1132{
1133 if (NAME_OF(o)) { 1133 if (NAME_OF(o)) {
1134 struct PreDefProp *pi; 1134 struct PreDefProp *pi;
1135 pi = lookupPropInfo(NAME_OF(o)); 1135 pi = lookupPropInfo(NAME_OF(o));
1136 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; 1136 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
1137 if ( includesUnprintable(o) ) { 1137 if ( includesUnprintable(o) ) {
1138 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); 1138 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1139 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); 1139 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1140 } 1140 }
1141 appendcOFile(fp,';'); 1141 appendcOFile(fp,';');
1142 appendsOFile(fp,NAME_OF(o)); 1142 appendsOFile(fp,NAME_OF(o));
1143 } 1143 }
1144 else 1144 else
@@ -1184,97 +1184,97 @@ static void writeProp(OFile *fp, VObject *o)
1184 writeVObject_(fp,o); 1184 writeVObject_(fp,o);
1185 return; 1185 return;
1186 } 1186 }
1187 if (isAPropertyOf(o,VCGroupingProp)) 1187 if (isAPropertyOf(o,VCGroupingProp))
1188 writeGroup(fp,o); 1188 writeGroup(fp,o);
1189 else 1189 else
1190 appendsOFile(fp,NAME_OF(o)); 1190 appendsOFile(fp,NAME_OF(o));
1191 if (pi) fields_ = pi->fields; 1191 if (pi) fields_ = pi->fields;
1192 initPropIterator(&t,o); 1192 initPropIterator(&t,o);
1193 while (moreIteration(&t)) { 1193 while (moreIteration(&t)) {
1194 const char *s; 1194 const char *s;
1195 VObject *eachProp = nextVObject(&t); 1195 VObject *eachProp = nextVObject(&t);
1196 s = NAME_OF(eachProp); 1196 s = NAME_OF(eachProp);
1197 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) 1197 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s))
1198 writeAttrValue(fp,eachProp); 1198 writeAttrValue(fp,eachProp);
1199 } 1199 }
1200 if (fields_) { 1200 if (fields_) {
1201 int i = 0, n = 0; 1201 int i = 0, n = 0;
1202 const char** fields = fields_; 1202 const char** fields = fields_;
1203 /* output prop as fields */ 1203 /* output prop as fields */
1204 bool printable = TRUE; 1204 bool printable = TRUE;
1205 while (*fields && printable) { 1205 while (*fields && printable) {
1206 VObject *t = isAPropertyOf(o,*fields); 1206 VObject *t = isAPropertyOf(o,*fields);
1207 if (includesUnprintable(t)) 1207 if (includesUnprintable(t))
1208 printable = FALSE; 1208 printable = FALSE;
1209 fields++; 1209 fields++;
1210 } 1210 }
1211 fields = fields_; 1211 fields = fields_;
1212 if (!printable) { 1212 if (!printable) {
1213 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); 1213 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1214 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); 1214 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1215 } 1215 }
1216 appendcOFile(fp,':'); 1216 appendcOFile(fp,':');
1217 while (*fields) { 1217 while (*fields) {
1218 VObject *t = isAPropertyOf(o,*fields); 1218 VObject *t = isAPropertyOf(o,*fields);
1219 i++; 1219 i++;
1220 if (t) n = i; 1220 if (t) n = i;
1221 fields++; 1221 fields++;
1222 } 1222 }
1223 fields = fields_; 1223 fields = fields_;
1224 for (i=0;i<n;i++) { 1224 for (i=0;i<n;i++) {
1225 writeValue(fp,isAPropertyOf(o,*fields),0); 1225 writeValue(fp,isAPropertyOf(o,*fields),0);
1226 fields++; 1226 fields++;
1227 if (i<(n-1)) appendcOFile(fp,';'); 1227 if (i<(n-1)) appendcOFile(fp,';');
1228 } 1228 }
1229 } 1229 }
1230 } 1230 }
1231 1231
1232 1232
1233 if (VALUE_TYPE(o)) { 1233 if (VALUE_TYPE(o)) {
1234 if ( includesUnprintable(o) ) { 1234 if ( includesUnprintable(o) ) {
1235 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); 1235 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1236 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); 1236 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1237 } 1237 }
1238 unsigned long size = 0; 1238 unsigned long size = 0;
1239 VObject *p = isAPropertyOf(o,VCDataSizeProp); 1239 VObject *p = isAPropertyOf(o,VCDataSizeProp);
1240 if (p) size = LONG_VALUE_OF(p); 1240 if (p) size = LONG_VALUE_OF(p);
1241 appendcOFile(fp,':'); 1241 appendcOFile(fp,':');
1242 writeValue(fp,o,size); 1242 writeValue(fp,o,size);
1243 } 1243 }
1244 1244
1245 appendcOFile(fp,'\n'); 1245 appendcOFile(fp,'\n');
1246} 1246}
1247 1247
1248static void writeVObject_(OFile *fp, VObject *o) 1248static void writeVObject_(OFile *fp, VObject *o)
1249{ 1249{
1250 if (NAME_OF(o)) { 1250 if (NAME_OF(o)) {
1251 struct PreDefProp *pi; 1251 struct PreDefProp *pi;
1252 pi = lookupPropInfo(NAME_OF(o)); 1252 pi = lookupPropInfo(NAME_OF(o));
1253 1253
1254 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1254 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1255 VObjectIterator t; 1255 VObjectIterator t;
1256 const char *begin = NAME_OF(o); 1256 const char *begin = NAME_OF(o);
1257 appendsOFile(fp,"BEGIN:"); 1257 appendsOFile(fp,"BEGIN:");
1258 appendsOFile(fp,begin); 1258 appendsOFile(fp,begin);
1259 appendcOFile(fp,'\n'); 1259 appendcOFile(fp,'\n');
1260 initPropIterator(&t,o); 1260 initPropIterator(&t,o);
1261 while (moreIteration(&t)) { 1261 while (moreIteration(&t)) {
1262 VObject *eachProp = nextVObject(&t); 1262 VObject *eachProp = nextVObject(&t);
1263 writeProp(fp, eachProp); 1263 writeProp(fp, eachProp);
1264 } 1264 }
1265 appendsOFile(fp,"END:"); 1265 appendsOFile(fp,"END:");
1266 appendsOFile(fp,begin); 1266 appendsOFile(fp,begin);
1267 appendsOFile(fp,"\n\n"); 1267 appendsOFile(fp,"\n\n");
1268 } 1268 }
1269 } 1269 }
1270} 1270}
1271 1271
1272void writeVObject(FILE *fp, VObject *o) 1272void writeVObject(FILE *fp, VObject *o)
1273{ 1273{
1274 OFile ofp; 1274 OFile ofp;
1275 // ##### 1275 // #####
1276 //_setmode(_fileno(fp), _O_BINARY); 1276 //_setmode(_fileno(fp), _O_BINARY);
1277 initOFile(&ofp,fp); 1277 initOFile(&ofp,fp);
1278 writeVObject_(&ofp,o); 1278 writeVObject_(&ofp,o);
1279} 1279}
1280 1280
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp
index 272c223..4a9dcbd 100644
--- a/library/datebookmonth.cpp
+++ b/library/datebookmonth.cpp
@@ -1,73 +1,73 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "config.h" 20#include "config.h"
21#include "datebookmonth.h" 21#include "datebookmonth.h"
22#include "datebookdb.h" 22#include "datebookdb.h"
23#include <qtopia/private/event.h> 23#include <qtopia/private/event.h>
24#include "resource.h" 24#include "resource.h"
25#include "qpeapplication.h" 25#include <qpe/qpeapplication.h>
26#include "timestring.h" 26#include "timestring.h"
27 27
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qspinbox.h> 29#include <qspinbox.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qvaluestack.h> 34#include <qvaluestack.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36 36
37 37
38DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) 38DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name )
39 : QHBox( parent, name ) 39 : QHBox( parent, name )
40{ 40{
41 setBackgroundMode( PaletteButton ); 41 setBackgroundMode( PaletteButton );
42 42
43 begin = new QToolButton( this ); 43 begin = new QToolButton( this );
44 begin->setFocusPolicy(NoFocus); 44 begin->setFocusPolicy(NoFocus);
45 begin->setPixmap( Resource::loadPixmap( "start" ) ); 45 begin->setPixmap( Resource::loadPixmap( "start" ) );
46 begin->setAutoRaise( TRUE ); 46 begin->setAutoRaise( TRUE );
47 begin->setFixedSize( begin->sizeHint() ); 47 begin->setFixedSize( begin->sizeHint() );
48 QWhatsThis::add( begin, tr("Show January in the selected year") ); 48 QWhatsThis::add( begin, tr("Show January in the selected year") );
49 49
50 back = new QToolButton( this ); 50 back = new QToolButton( this );
51 back->setFocusPolicy(NoFocus); 51 back->setFocusPolicy(NoFocus);
52 back->setPixmap( Resource::loadPixmap( "back" ) ); 52 back->setPixmap( Resource::loadPixmap( "back" ) );
53 back->setAutoRaise( TRUE ); 53 back->setAutoRaise( TRUE );
54 back->setFixedSize( back->sizeHint() ); 54 back->setFixedSize( back->sizeHint() );
55 QWhatsThis::add( back, tr("Show the previous month") ); 55 QWhatsThis::add( back, tr("Show the previous month") );
56 56
57 month = new QComboBox( FALSE, this ); 57 month = new QComboBox( FALSE, this );
58 for ( int i = 0; i < 12; ++i ) 58 for ( int i = 0; i < 12; ++i )
59 month->insertItem( Calendar::nameOfMonth( i + 1 ) ); 59 month->insertItem( Calendar::nameOfMonth( i + 1 ) );
60 60
61 year = new QSpinBox( 1752, 8000, 1, this ); 61 year = new QSpinBox( 1752, 8000, 1, this );
62 62
63 next = new QToolButton( this ); 63 next = new QToolButton( this );
64 next->setFocusPolicy(NoFocus); 64 next->setFocusPolicy(NoFocus);
65 next->setPixmap( Resource::loadPixmap( "forward" ) ); 65 next->setPixmap( Resource::loadPixmap( "forward" ) );
66 next->setAutoRaise( TRUE ); 66 next->setAutoRaise( TRUE );
67 next->setFixedSize( next->sizeHint() ); 67 next->setFixedSize( next->sizeHint() );
68 QWhatsThis::add( next, tr("Show the next month") ); 68 QWhatsThis::add( next, tr("Show the next month") );
69 69
70 end = new QToolButton( this ); 70 end = new QToolButton( this );
71 end->setFocusPolicy(NoFocus); 71 end->setFocusPolicy(NoFocus);
72 end->setPixmap( Resource::loadPixmap( "finish" ) ); 72 end->setPixmap( Resource::loadPixmap( "finish" ) );
73 end->setAutoRaise( TRUE ); 73 end->setAutoRaise( TRUE );
@@ -509,160 +509,160 @@ DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t )
509 : QTableItem( table, et, t ) 509 : QTableItem( table, et, t )
510{ 510{
511 d = new DayItemMonthPrivate(); 511 d = new DayItemMonthPrivate();
512} 512}
513 513
514DayItemMonth::~DayItemMonth() 514DayItemMonth::~DayItemMonth()
515{ 515{
516 daysEvents.clear(); 516 daysEvents.clear();
517 delete d; 517 delete d;
518} 518}
519 519
520void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) 520void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv )
521{ 521{
522 d->mDayEvents = effEv; 522 d->mDayEvents = effEv;
523} 523}
524 524
525void DayItemMonth::clearEffEvents() 525void DayItemMonth::clearEffEvents()
526{ 526{
527 d->mDayEvents.clear(); 527 d->mDayEvents.clear();
528} 528}
529 529
530void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, 530void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
531 const QRect &cr, bool selected ) 531 const QRect &cr, bool selected )
532{ 532{
533 p->save(); 533 p->save();
534 534
535 QColorGroup g( cg ); 535 QColorGroup g( cg );
536 g.setBrush( QColorGroup::Base, back ); 536 g.setBrush( QColorGroup::Base, back );
537 g.setColor( QColorGroup::Text, forg ); 537 g.setColor( QColorGroup::Text, forg );
538 if ( selected ) 538 if ( selected )
539 p->setPen( g.highlightedText() ); 539 p->setPen( g.highlightedText() );
540 else 540 else
541 p->setPen( g.text() ); 541 p->setPen( g.text() );
542 542
543 QValueStack<int> normalLine; 543 QValueStack<int> normalLine;
544 QValueStack<int> repeatLine; 544 QValueStack<int> repeatLine;
545 QValueStack<int> travelLine; 545 QValueStack<int> travelLine;
546 546
547 bool normalAllDay = FALSE; 547 bool normalAllDay = FALSE;
548 bool repeatAllDay = FALSE; 548 bool repeatAllDay = FALSE;
549 bool travelAllDay = FALSE; 549 bool travelAllDay = FALSE;
550 550
551 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); 551 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin();
552 552
553 for ( ; itDays != d->mDayEvents.end(); ++itDays ) { 553 for ( ; itDays != d->mDayEvents.end(); ++itDays ) {
554 int w = cr.width(); 554 int w = cr.width();
555 Event ev = (*itDays).event(); 555 Event ev = (*itDays).event();
556 556
557 int f = (*itDays).start().hour(); // assume Effective event 557 int f = (*itDays).start().hour(); // assume Effective event
558 int t = (*itDays).end().hour(); // is truncated. 558 int t = (*itDays).end().hour(); // is truncated.
559 559
560 if (ev.isAllDay()) { 560 if (ev.isAllDay()) {
561 if (!ev.hasRepeat()) 561 if (!ev.hasRepeat())
562 normalAllDay = TRUE; 562 normalAllDay = TRUE;
563 else 563 else
564 repeatAllDay = TRUE; 564 repeatAllDay = TRUE;
565 } else { 565 } else {
566 int sLine, eLine; 566 int sLine, eLine;
567 if (f == 0) 567 if (f == 0)
568 sLine = 0; 568 sLine = 0;
569 else if (f < 8 ) 569 else if (f < 8 )
570 sLine = 1; 570 sLine = 1;
571 else if (f >= 17) 571 else if (f >= 17)
572 sLine = w - 4; 572 sLine = w - 4;
573 else { 573 else {
574 sLine = (f - 8) * (w - 8); 574 sLine = (f - 8) * (w - 8);
575 if (sLine) 575 if (sLine)
576 sLine /= 8; 576 sLine /= 8;
577 sLine += 4; 577 sLine += 4;
578 } 578 }
579 if (t == 23) 579 if (t == 23)
580 eLine = w; 580 eLine = w;
581 else if (t < 8) 581 else if (t < 8)
582 eLine = 4; 582 eLine = 4;
583 else if (t >= 17) 583 else if (t >= 17)
584 eLine = w - 1; 584 eLine = w - 1;
585 else { 585 else {
586 eLine = (t - 8) * (w - 8); 586 eLine = (t - 8) * (w - 8);
587 if (eLine) 587 if (eLine)
588 eLine /= 8; 588 eLine /= 8;
589 eLine += 4; 589 eLine += 4;
590 } 590 }
591 if (!ev.hasRepeat()) { 591 if (!ev.hasRepeat()) {
592 normalLine.push(sLine); 592 normalLine.push(sLine);
593 normalLine.push(eLine); 593 normalLine.push(eLine);
594 } else { 594 } else {
595 repeatLine.push(sLine); 595 repeatLine.push(sLine);
596 repeatLine.push(eLine); 596 repeatLine.push(eLine);
597 } 597 }
598 } 598 }
599 } 599 }
600 600
601 // draw the background 601 // draw the background
602 if (normalAllDay || repeatAllDay || travelAllDay) { 602 if (normalAllDay || repeatAllDay || travelAllDay) {
603 p->save(); 603 p->save();
604 604
605 if (normalAllDay) 605 if (normalAllDay)
606 if (repeatAllDay) { 606 if (repeatAllDay) {
607 p->fillRect( 0, 0, cr.width(), cr.height() / 2, 607 p->fillRect( 0, 0, cr.width(), cr.height() / 2,
608 colorNormalLight ); 608 colorNormalLight );
609 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, 609 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2,
610 colorRepeatLight ); 610 colorRepeatLight );
611 } else 611 } else
612 p->fillRect( 0, 0, cr.width(), cr.height(), 612 p->fillRect( 0, 0, cr.width(), cr.height(),
613 colorNormalLight ); 613 colorNormalLight );
614 else if (repeatAllDay) 614 else if (repeatAllDay)
615 p->fillRect( 0, 0, cr.width(), cr.height(), 615 p->fillRect( 0, 0, cr.width(), cr.height(),
616 colorRepeatLight ); 616 colorRepeatLight );
617 } else { 617 } else {
618 p->fillRect( 0, 0, cr.width(), 618 p->fillRect( 0, 0, cr.width(),
619 cr.height(), selected 619 cr.height(), selected
620 ? g.brush( QColorGroup::Highlight ) 620 ? g.brush( QColorGroup::Highlight )
621 : g.brush( QColorGroup::Base ) ); 621 : g.brush( QColorGroup::Base ) );
622 } 622 }
623 623
624 // The lines 624 // The lines
625 // now for the lines. 625 // now for the lines.
626 int h = 5; 626 int h = 5;
627 int y = cr.height() / 2 - h; 627 int y = cr.height() / 2 - h;
628 628
629 while(normalLine.count() >= 2) { 629 while(normalLine.count() >= 2) {
630 int x2 = normalLine.pop(); 630 int x2 = normalLine.pop();
631 int x1 = normalLine.pop(); 631 int x1 = normalLine.pop();
632 if (x2 < x1 + 2) 632 if (x2 < x1 + 2)
633 x2 = x1 + 2; 633 x2 = x1 + 2;
634 p->fillRect(x1, y, x2 - x1, h, colorNormal); 634 p->fillRect(x1, y, x2 - x1, h, colorNormal);
635 } 635 }
636 636
637 y += h; 637 y += h;
638 638
639 while(repeatLine.count() >= 2) { 639 while(repeatLine.count() >= 2) {
640 int x2 = repeatLine.pop(); 640 int x2 = repeatLine.pop();
641 int x1 = repeatLine.pop(); 641 int x1 = repeatLine.pop();
642 if (x2 < x1 + 2) 642 if (x2 < x1 + 2)
643 x2 = x1 + 2; 643 x2 = x1 + 2;
644 p->fillRect(x1, y, x2 - x1, h, colorRepeat); 644 p->fillRect(x1, y, x2 - x1, h, colorRepeat);
645 } 645 }
646 646
647 647
648 // Finally, draw the number. 648 // Finally, draw the number.
649 QFont f = p->font(); 649 QFont f = p->font();
650 f.setPointSize( ( f.pointSize() / 3 ) * 2 ); 650 f.setPointSize( ( f.pointSize() / 3 ) * 2 );
651 p->setFont( f ); 651 p->setFont( f );
652 QFontMetrics fm( f ); 652 QFontMetrics fm( f );
653 p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); 653 p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) );
654 654
655 p->restore(); 655 p->restore();
656} 656}
657 657
658 658
659 659
660void DayItemMonth::setType( Calendar::Day::Type t ) 660void DayItemMonth::setType( Calendar::Day::Type t )
661{ 661{
662 switch ( t ) { 662 switch ( t ) {
663 case Calendar::Day::PrevMonth: 663 case Calendar::Day::PrevMonth:
664 case Calendar::Day::NextMonth: 664 case Calendar::Day::NextMonth:
665 back = QBrush( QColor( 224, 224, 224 ) ); 665 back = QBrush( QColor( 224, 224, 224 ) );
666 forg = black; 666 forg = black;
667 break; 667 break;
668 case Calendar::Day::ThisMonth: 668 case Calendar::Day::ThisMonth:
@@ -688,63 +688,63 @@ DateButton::DateButton( bool longDate, QWidget *parent, const char * name )
688} 688}
689 689
690 690
691void DateButton::pickDate() 691void DateButton::pickDate()
692{ 692{
693 static QPopupMenu *m1 = 0; 693 static QPopupMenu *m1 = 0;
694 static DateBookMonth *picker = 0; 694 static DateBookMonth *picker = 0;
695 if ( !m1 ) { 695 if ( !m1 ) {
696 m1 = new QPopupMenu( this ); 696 m1 = new QPopupMenu( this );
697 picker = new DateBookMonth( m1, 0, TRUE ); 697 picker = new DateBookMonth( m1, 0, TRUE );
698 m1->insertItem( picker ); 698 m1->insertItem( picker );
699 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 699 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
700 this, SLOT( setDate( int, int, int ) ) ); 700 this, SLOT( setDate( int, int, int ) ) );
701 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 701 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
702 this, SIGNAL( dateSelected( int, int, int ) ) ); 702 this, SIGNAL( dateSelected( int, int, int ) ) );
703 connect( m1, SIGNAL( aboutToHide() ), 703 connect( m1, SIGNAL( aboutToHide() ),
704 this, SLOT( gotHide() ) ); 704 this, SLOT( gotHide() ) );
705 } 705 }
706 picker->slotWeekChange( weekStartsMonday ); 706 picker->slotWeekChange( weekStartsMonday );
707 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 707 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
708 m1->popup(mapToGlobal(QPoint(0,height()))); 708 m1->popup(mapToGlobal(QPoint(0,height())));
709 picker->setFocus(); 709 picker->setFocus();
710} 710}
711 711
712 712
713void DateButton::gotHide() 713void DateButton::gotHide()
714{ 714{
715 // we have to redo the button... 715 // we have to redo the button...
716 setDown( false ); 716 setDown( false );
717} 717}
718 718
719 719
720// void dateSelected( int year, int month, int day ); 720// void dateSelected( int year, int month, int day );
721 721
722void DateButton::setWeekStartsMonday( int b ) 722void DateButton::setWeekStartsMonday( int b )
723{ 723{
724 weekStartsMonday = b; 724 weekStartsMonday = b;
725} 725}
726 726
727void DateButton::setDate( int y, int m, int d ) 727void DateButton::setDate( int y, int m, int d )
728{ 728{
729 setDate( QDate( y,m,d) ); 729 setDate( QDate( y,m,d) );
730} 730}
731 731
732void DateButton::setDate( QDate d ) 732void DateButton::setDate( QDate d )
733{ 733{
734 currDate = d; 734 currDate = d;
735 setText( longFormat ? TimeString::longDateString( d, df ) : 735 setText( longFormat ? TimeString::longDateString( d, df ) :
736 TimeString::shortDate( d, df ) ); 736 TimeString::shortDate( d, df ) );
737 737
738} 738}
739 739
740void DateButton::setDateFormat( DateFormat f ) 740void DateButton::setDateFormat( DateFormat f )
741{ 741{
742 df = f; 742 df = f;
743 setDate( currDate ); 743 setDate( currDate );
744} 744}
745 745
746bool DateButton::customWhatsThis() const 746bool DateButton::customWhatsThis() const
747{ 747{
748 return TRUE; 748 return TRUE;
749} 749}
750 750
diff --git a/library/fileselector.cpp b/library/fileselector.cpp
index 7ff09b4..052a29e 100644
--- a/library/fileselector.cpp
+++ b/library/fileselector.cpp
@@ -1,90 +1,90 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 22// have this class.
23#define QTOPIA_INTERNAL_FSLP 23#define QTOPIA_INTERNAL_FSLP
24 24
25#include "fileselector.h" 25#include "fileselector.h"
26#include "fileselector_p.h" 26#include "fileselector_p.h"
27#include "global.h" 27#include "global.h"
28#include "resource.h" 28#include "resource.h"
29#include "config.h" 29#include "config.h"
30#include "applnk.h" 30#include "applnk.h"
31#include "storage.h" 31#include "storage.h"
32#include "qpemenubar.h" 32#include "qpemenubar.h"
33#ifdef QWS 33#ifdef QWS
34#include "qcopchannel_qws.h" 34#include <qcopchannel_qws.h>
35#endif 35#endif
36#include "lnkproperties.h" 36#include "lnkproperties.h"
37#include "applnk.h" 37#include "applnk.h"
38#include "qpeapplication.h" 38#include <qpe/qpeapplication.h>
39#include "categorymenu.h" 39#include "categorymenu.h"
40#include "categoryselect.h" 40#include "categoryselect.h"
41#include "mimetype.h" 41#include "mimetype.h"
42#include "categories.h" 42#include <qpe/categories.h>
43 43
44#include <stdlib.h> 44#include <stdlib.h>
45 45
46#include <qdir.h> 46#include <qdir.h>
47#include <qwidget.h> 47#include <qwidget.h>
48#include <qpopupmenu.h> 48#include <qpopupmenu.h>
49#include <qtoolbutton.h> 49#include <qtoolbutton.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qheader.h> 51#include <qheader.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qwhatsthis.h> 53#include <qwhatsthis.h>
54 54
55class TypeCombo : public QComboBox 55class TypeCombo : public QComboBox
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58public: 58public:
59 TypeCombo( QWidget *parent, const char *name=0 ) 59 TypeCombo( QWidget *parent, const char *name=0 )
60 : QComboBox( parent, name ) 60 : QComboBox( parent, name )
61 { 61 {
62 connect( this, SIGNAL(activated(int)), this, SLOT(selectType(int)) ); 62 connect( this, SIGNAL(activated(int)), this, SLOT(selectType(int)) );
63 } 63 }
64 64
65 void reread( DocLnkSet &files, const QString &filter ); 65 void reread( DocLnkSet &files, const QString &filter );
66 66
67signals: 67signals:
68 void selected( const QString & ); 68 void selected( const QString & );
69 69
70protected slots: 70protected slots:
71 void selectType( int idx ) { 71 void selectType( int idx ) {
72 emit selected( typelist[idx] ); 72 emit selected( typelist[idx] );
73 } 73 }
74 74
75protected: 75protected:
76 QStringList typelist; 76 QStringList typelist;
77 QString prev; 77 QString prev;
78}; 78};
79 79
80void TypeCombo::reread( DocLnkSet &files, const QString &filter ) 80void TypeCombo::reread( DocLnkSet &files, const QString &filter )
81{ 81{
82 typelist.clear(); 82 typelist.clear();
83 QStringList filters = QStringList::split( ';', filter ); 83 QStringList filters = QStringList::split( ';', filter );
84 int pos = filter.find( '/' ); 84 int pos = filter.find( '/' );
85 //### do for each filter 85 //### do for each filter
86 if ( filters.count() == 1 && pos >= 0 && filter[pos+1] != '*' ) { 86 if ( filters.count() == 1 && pos >= 0 && filter[pos+1] != '*' ) {
87 typelist.append( filter ); 87 typelist.append( filter );
88 clear(); 88 clear();
89 QString minor = filter.mid( pos+1 ); 89 QString minor = filter.mid( pos+1 );
90 minor[0] = minor[0].upper(); 90 minor[0] = minor[0].upper();
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp
index c64e645..2b5e0d2 100644
--- a/library/fontdatabase.cpp
+++ b/library/fontdatabase.cpp
@@ -1,69 +1,69 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qpeapplication.h" 21#include <qpe/qpeapplication.h>
22#include "fontfactoryinterface.h" 22#include "fontfactoryinterface.h"
23#include "fontdatabase.h" 23#include "fontdatabase.h"
24 24
25#include <qpe/qlibrary.h> 25#include <qpe/qlibrary.h>
26 26
27#ifdef QWS 27#ifdef QWS
28#include <qfontmanager_qws.h> 28#include <qfontmanager_qws.h>
29#endif 29#endif
30#include <qdir.h> 30#include <qdir.h>
31#include <qdict.h> 31#include <qdict.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35static QString fontDir() 35static QString fontDir()
36{ 36{
37 QString qtdir = getenv("QTDIR"); 37 QString qtdir = getenv("QTDIR");
38 if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded"; 38 if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded";
39 return qtdir+"/lib/fonts/"; 39 return qtdir+"/lib/fonts/";
40} 40}
41 41
42#ifdef QT_NO_FONTDATABASE 42#ifdef QT_NO_FONTDATABASE
43static QString fontFamily( const QString& key ) 43static QString fontFamily( const QString& key )
44{ 44{
45 int u0 = key.find('_'); 45 int u0 = key.find('_');
46 int u1 = key.find('_',u0+1); 46 int u1 = key.find('_',u0+1);
47 int u2 = key.find('_',u1+1); 47 int u2 = key.find('_',u1+1);
48 QString family = key.left(u0); 48 QString family = key.left(u0);
49 //int pointSize = key.mid(u0+1,u1-u0-1).toInt(); 49 //int pointSize = key.mid(u0+1,u1-u0-1).toInt();
50 //int weight = key.mid(u1+1,u2-u1-1).toInt(); 50 //int weight = key.mid(u1+1,u2-u1-1).toInt();
51 //bool italic = key.mid(u2-1,1) == "i"; 51 //bool italic = key.mid(u2-1,1) == "i";
52 // #### ignores _t and _I fields 52 // #### ignores _t and _I fields
53 return family; 53 return family;
54} 54}
55#endif 55#endif
56 56
57QValueList<FontFactory> *FontDatabase::factoryList = 0; 57QValueList<FontFactory> *FontDatabase::factoryList = 0;
58 58
59/*! 59/*!
60 \class FontDatabase fontdatabase.h 60 \class FontDatabase fontdatabase.h
61 \brief The FontDatabase class provides information about available fonts. 61 \brief The FontDatabase class provides information about available fonts.
62 62
63 Most often you will simply want to query the database for the 63 Most often you will simply want to query the database for the
64 available font families(). 64 available font families().
65 65
66 Use FontDatabase rather than QFontDatabase when you may need access 66 Use FontDatabase rather than QFontDatabase when you may need access
67 to fonts that are not normally available. For example, if the 67 to fonts that are not normally available. For example, if the
68 freetype library and the Qtopia freetype plugin are installed, 68 freetype library and the Qtopia freetype plugin are installed,
69 TrueType fonts will be available to your application. Font renderer 69 TrueType fonts will be available to your application. Font renderer
diff --git a/library/fontdatabase.h b/library/fontdatabase.h
index 10aec91..991847b 100644
--- a/library/fontdatabase.h
+++ b/library/fontdatabase.h
@@ -1,62 +1,63 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef FONTFACTORY_H 20#ifndef FONTFACTORY_H
21#define FONTFACTORY_H 21#define FONTFACTORY_H
22 22
23#include <qpe/fontfactoryinterface.h> 23#include <qpe/fontfactoryinterface.h>
24 24
25#include <qfontdatabase.h> 25#include <qfontdatabase.h>
26#include <qvaluelist.h> 26#include <qvaluelist.h>
27 27
28class QLibrary; 28class QLibrary;
29 29
30struct FontFactory 30struct FontFactory
31{ 31{
32#ifndef QT_NO_COMPONENT 32#ifndef QT_NO_COMPONENT
33 QLibrary *library; 33 QLibrary *library;
34#endif 34#endif
35 FontFactoryInterface *interface; 35 FontFactoryInterface *interface;
36 QFontFactory *factory; 36 QFontFactory *factory;
37}; 37};
38 38
39#undef QT_NO_FONTDATABASE
39class FontDatabase 40class FontDatabase
40#ifndef QT_NO_FONTDATABASE 41#ifndef QT_NO_FONTDATABASE
41 : public QFontDatabase 42 : public QFontDatabase
42#endif 43#endif
43{ 44{
44public: 45public:
45 FontDatabase(); 46 FontDatabase();
46 47
47 // minimal functionality 48 // minimal functionality
48 QStringList families () const; 49 QStringList families () const;
49#ifdef QT_NO_FONTDATABASE 50#ifdef QT_NO_FONTDATABASE
50 static QValueList<int> standardSizes (); 51 static QValueList<int> standardSizes ();
51#endif 52#endif
52 53
53 static void loadRenderers(); 54 static void loadRenderers();
54 55
55private: 56private:
56 static void readFonts( QFontFactory *factory ); 57 static void readFonts( QFontFactory *factory );
57 58
58private: 59private:
59 static QValueList<FontFactory> *factoryList; 60 static QValueList<FontFactory> *factoryList;
60}; 61};
61 62
62#endif 63#endif
diff --git a/library/mimetype.cpp b/library/mimetype.cpp
index 92fe5e6..ef5d619 100644
--- a/library/mimetype.cpp
+++ b/library/mimetype.cpp
@@ -1,73 +1,73 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_MIMEEXT 21#define QTOPIA_INTERNAL_MIMEEXT
22#include "mimetype.h" 22#include "mimetype.h"
23#include "applnk.h" 23#include "applnk.h"
24#include "resource.h" 24#include "resource.h"
25#include "qpeapplication.h" 25#include <qpe/qpeapplication.h>
26#include "config.h" 26#include "config.h"
27 27
28#include <qfile.h> 28#include <qfile.h>
29#include <qdict.h> 29#include <qdict.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qmap.h> 33#include <qmap.h>
34 34
35 35
36static void cleanupMime() 36static void cleanupMime()
37{ 37{
38 MimeType::clear(); 38 MimeType::clear();
39} 39}
40 40
41class MimeTypeData { 41class MimeTypeData {
42public: 42public:
43 MimeTypeData(const QString& i) : 43 MimeTypeData(const QString& i) :
44 id(i) 44 id(i)
45 { 45 {
46 apps.setAutoDelete(TRUE); 46 apps.setAutoDelete(TRUE);
47 } 47 }
48 QString id; 48 QString id;
49 QString extension; 49 QString extension;
50 QList<AppLnk> apps; 50 QList<AppLnk> apps;
51 51
52 QString description() 52 QString description()
53 { 53 {
54 if ( desc.isEmpty() ) 54 if ( desc.isEmpty() )
55 desc = QPEApplication::tr("%1 document").arg(apps.first()->name()); 55 desc = QPEApplication::tr("%1 document").arg(apps.first()->name());
56 return desc; 56 return desc;
57 } 57 }
58 58
59 QPixmap regIcon() 59 QPixmap regIcon()
60 { 60 {
61 if ( regicon.isNull() ) 61 if ( regicon.isNull() )
62 loadPixmaps(); 62 loadPixmaps();
63 return regicon; 63 return regicon;
64 } 64 }
65 65
66 QPixmap bigIcon() 66 QPixmap bigIcon()
67 { 67 {
68 if ( bigicon.isNull() ) 68 if ( bigicon.isNull() )
69 loadPixmaps(); 69 loadPixmaps();
70 return bigicon; 70 return bigicon;
71 } 71 }
72 72
73private: 73private:
diff --git a/library/qpedialog.cpp b/library/qpedialog.cpp
index 0db161b..b98e42e 100644
--- a/library/qpedialog.cpp
+++ b/library/qpedialog.cpp
@@ -1,46 +1,46 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define protected public 21#define protected public
22#include <qdialog.h> 22#include <qdialog.h>
23#undef protected 23#undef protected
24 24
25#include "qpedialog.h" 25#include "qpedialog.h"
26#include "qpeapplication.h" 26#include <qpe/qpeapplication.h>
27 27
28QPEDialogListener::QPEDialogListener(QDialog *di ) : QObject(di) 28QPEDialogListener::QPEDialogListener(QDialog *di ) : QObject(di)
29{ 29{
30 dialog = di; 30 dialog = di;
31 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 31 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
32 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 32 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
33} 33}
34 34
35QPEDialogListener::~QPEDialogListener() {} 35QPEDialogListener::~QPEDialogListener() {}
36 36
37void QPEDialogListener::appMessage( const QCString &msg, const QByteArray & ) 37void QPEDialogListener::appMessage( const QCString &msg, const QByteArray & )
38{ 38{
39 if (!dialog) 39 if (!dialog)
40 return; 40 return;
41 if (msg == "accept()") { 41 if (msg == "accept()") {
42 dialog->accept(); 42 dialog->accept();
43 } else if (msg == "reject()") { 43 } else if (msg == "reject()") {
44 dialog->reject(); 44 dialog->reject();
45 } 45 }
46} 46}
diff --git a/library/qpestyle.cpp b/library/qpestyle.cpp
index dfd300f..665910c 100644
--- a/library/qpestyle.cpp
+++ b/library/qpestyle.cpp
@@ -1,70 +1,70 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qpestyle.h" 21#include "qpestyle.h"
22#include "qpeapplication.h" 22#include <qpe/qpeapplication.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25#include <qpainter.h> 25#include <qpainter.h>
26 26
27#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 27#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
28 28
29#if QT_VERSION >= 300 29#if QT_VERSION >= 300
30 30
31#include <qdrawutil.h> 31#include <qdrawutil.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qtabbar.h> 33#include <qtabbar.h>
34 34
35QPEStyle::QPEStyle() 35QPEStyle::QPEStyle()
36{ 36{
37} 37}
38 38
39QPEStyle::~QPEStyle() 39QPEStyle::~QPEStyle()
40{ 40{
41} 41}
42 42
43void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, 43void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r,
44 const QColorGroup &cg, SFlags flags, const QStyleOption &data) const 44 const QColorGroup &cg, SFlags flags, const QStyleOption &data) const
45{ 45{
46 switch ( pe ) { 46 switch ( pe ) {
47 case PE_ButtonTool: 47 case PE_ButtonTool:
48 { 48 {
49 QColorGroup mycg = cg; 49 QColorGroup mycg = cg;
50 if ( flags & Style_On ) { 50 if ( flags & Style_On ) {
51 QBrush fill( cg.mid(), Dense4Pattern ); 51 QBrush fill( cg.mid(), Dense4Pattern );
52 mycg.setBrush( QColorGroup::Button, fill ); 52 mycg.setBrush( QColorGroup::Button, fill );
53 } 53 }
54 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); 54 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
55 break; 55 break;
56 } 56 }
57 case PE_ButtonCommand: 57 case PE_ButtonCommand:
58 case PE_ButtonDefault: 58 case PE_ButtonDefault:
59 case PE_ButtonBevel: 59 case PE_ButtonBevel:
60 case PE_HeaderSection: 60 case PE_HeaderSection:
61 { 61 {
62 QPen oldPen = p->pen(); 62 QPen oldPen = p->pen();
63 p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) ); 63 p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) );
64 64
65 int x2 = r.right(); 65 int x2 = r.right();
66 int y2 = r.bottom(); 66 int y2 = r.bottom();
67 67
68 if ( flags & (Style_Sunken | Style_Down | Style_On) ) 68 if ( flags & (Style_Sunken | Style_Down | Style_On) )
69 p->setPen( cg.dark() ); 69 p->setPen( cg.dark() );
70 else 70 else
@@ -179,97 +179,97 @@ void QPEStyle::drawControl( ControlElement ce, QPainter *p,
179 flags |= Style_Enabled; 179 flags |= Style_Enabled;
180 if ( btn->isDefault() ) 180 if ( btn->isDefault() )
181 flags |= Style_Default; 181 flags |= Style_Default;
182 if (! btn->isFlat() && !(flags & Style_Down)) 182 if (! btn->isFlat() && !(flags & Style_Down))
183 flags |= Style_Raised; 183 flags |= Style_Raised;
184 p->setPen( cg.foreground() ); 184 p->setPen( cg.foreground() );
185 p->setBrush( QBrush(cg.button(), NoBrush) ); 185 p->setBrush( QBrush(cg.button(), NoBrush) );
186 QColorGroup mycg( cg ); 186 QColorGroup mycg( cg );
187 if ( flags & Style_On ) { 187 if ( flags & Style_On ) {
188 QBrush fill = QBrush( cg.mid(), Dense4Pattern ); 188 QBrush fill = QBrush( cg.mid(), Dense4Pattern );
189 mycg.setBrush( QColorGroup::Button, fill ); 189 mycg.setBrush( QColorGroup::Button, fill );
190 } 190 }
191 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data ); 191 drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
192 break; 192 break;
193 } 193 }
194 case CE_TabBarTab: 194 case CE_TabBarTab:
195 { 195 {
196 if ( !widget || !widget->parentWidget() ) 196 if ( !widget || !widget->parentWidget() )
197 break; 197 break;
198 198
199 const QTabBar *tb = (const QTabBar *) widget; 199 const QTabBar *tb = (const QTabBar *) widget;
200 bool selected = how & Style_Selected; 200 bool selected = how & Style_Selected;
201 201
202 QRect r2(r); 202 QRect r2(r);
203 if ( tb->shape() == QTabBar::RoundedAbove ) { 203 if ( tb->shape() == QTabBar::RoundedAbove ) {
204 p->setPen( cg.light() ); 204 p->setPen( cg.light() );
205 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); 205 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
206 if ( r2.left() == 0 ) 206 if ( r2.left() == 0 )
207 p->drawPoint( tb->rect().bottomLeft() ); 207 p->drawPoint( tb->rect().bottomLeft() );
208 else { 208 else {
209 p->setPen( cg.light() ); 209 p->setPen( cg.light() );
210 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); 210 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
211 } 211 }
212 212
213 if ( selected ) { 213 if ( selected ) {
214 p->setPen( cg.background() ); 214 p->setPen( cg.background() );
215 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); 215 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
216 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2), 216 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2),
217 cg.brush( QColorGroup::Background )); 217 cg.brush( QColorGroup::Background ));
218 } else { 218 } else {
219 r2.setRect( r2.left() + 2, r2.top() + 2, 219 r2.setRect( r2.left() + 2, r2.top() + 2,
220 r2.width() - 4, r2.height() - 2 ); 220 r2.width() - 4, r2.height() - 2 );
221 p->setPen( cg.button() ); 221 p->setPen( cg.button() );
222 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 ); 222 p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
223 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3), 223 p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3),
224 cg.brush( QColorGroup::Button )); 224 cg.brush( QColorGroup::Button ));
225 225
226 //do shading; will not work for pixmap brushes 226 //do shading; will not work for pixmap brushes
227 QColor bg = cg.button(); 227 QColor bg = cg.button();
228 // int h,s,v; 228 // int h,s,v;
229 // bg.hsv( &h, &s, &v ); 229 // bg.hsv( &h, &s, &v );
230 int n = r2.height()/2; 230 int n = r2.height()/2;
231 int dark = 100; 231 int dark = 100;
232 for ( int i = 1; i < n; i++ ) { 232 for ( int i = 1; i < n; i++ ) {
233 dark = (dark * (100+(i*15)/n) )/100; 233 dark = (dark * (100+(i*15)/n) )/100;
234 p->setPen( bg.dark( dark ) ); 234 p->setPen( bg.dark( dark ) );
235 int y = r2.bottom()-n+i; 235 int y = r2.bottom()-n+i;
236 int x1 = r2.left()+1; 236 int x1 = r2.left()+1;
237 int x2 = r2.right()-1; 237 int x2 = r2.right()-1;
238 p->drawLine( x1, y, x2, y ); 238 p->drawLine( x1, y, x2, y );
239 } 239 }
240 } 240 }
241 241
242 p->setPen( cg.light() ); 242 p->setPen( cg.light() );
243 p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 ); 243 p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 );
244 p->drawPoint( r2.left()+1, r2.top() + 1 ); 244 p->drawPoint( r2.left()+1, r2.top() + 1 );
245 p->drawLine( r2.left()+2, r2.top(), 245 p->drawLine( r2.left()+2, r2.top(),
246 r2.right() - 2, r2.top() ); 246 r2.right() - 2, r2.top() );
247 247
248 p->setPen( cg.dark() ); 248 p->setPen( cg.dark() );
249 p->drawPoint( r2.right() - 1, r2.top() + 1 ); 249 p->drawPoint( r2.right() - 1, r2.top() + 1 );
250 p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1); 250 p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1);
251 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 251 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
252 if ( selected ) { 252 if ( selected ) {
253 p->setPen( cg.background() ); 253 p->setPen( cg.background() );
254 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); 254 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
255 p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2), 255 p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2),
256 tb->palette().normal().brush( QColorGroup::Background )); 256 tb->palette().normal().brush( QColorGroup::Background ));
257 } else { 257 } else {
258 p->setPen( cg.dark() ); 258 p->setPen( cg.dark() );
259 p->drawLine( r2.left(), r2.top(), 259 p->drawLine( r2.left(), r2.top(),
260 r2.right(), r2.top() ); 260 r2.right(), r2.top() );
261 r2.setRect( r2.left() + 2, r2.top(), 261 r2.setRect( r2.left() + 2, r2.top(),
262 r2.width() - 4, r2.height() - 2 ); 262 r2.width() - 4, r2.height() - 2 );
263 p->setPen( cg.button() ); 263 p->setPen( cg.button() );
264 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 ); 264 p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
265 p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3), 265 p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3),
266 tb->palette().normal().brush( QColorGroup::Button )); 266 tb->palette().normal().brush( QColorGroup::Button ));
267 } 267 }
268 268
269 p->setPen( cg.dark() ); 269 p->setPen( cg.dark() );
270 p->drawLine( r2.right(), r2.top(), 270 p->drawLine( r2.right(), r2.top(),
271 r2.right(), r2.bottom() - 2 ); 271 r2.right(), r2.bottom() - 2 );
272 p->drawPoint( r2.right() - 1, r2.bottom() - 1 ); 272 p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
273 p->drawLine( r2.right() - 2, r2.bottom(), 273 p->drawLine( r2.right() - 2, r2.bottom(),
274 r2.left() + 2, r2.bottom() ); 274 r2.left() + 2, r2.bottom() );
275 275
@@ -488,98 +488,98 @@ int QPEStyle::defaultFrameWidth() const
488void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, 488void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
489 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill ) 489 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill )
490{ 490{
491 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill ); 491 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill );
492} 492}
493 493
494void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h, 494void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h,
495 const QColorGroup &g, bool sunken, const QBrush* fill ) 495 const QColorGroup &g, bool sunken, const QBrush* fill )
496{ 496{
497 QPen oldPen = p->pen(); 497 QPen oldPen = p->pen();
498 if ( sunken ) 498 if ( sunken )
499 p->setPen( g.dark() ); 499 p->setPen( g.dark() );
500 else 500 else
501 p->setPen( g.light() ); 501 p->setPen( g.light() );
502 502
503 int x2 = x+w-1; 503 int x2 = x+w-1;
504 int y2 = y+h-1; 504 int y2 = y+h-1;
505 505
506 p->drawLine( x, y, x, y2 ); 506 p->drawLine( x, y, x, y2 );
507 p->drawLine( x, y, x2, y ); 507 p->drawLine( x, y, x2, y );
508 508
509 if ( sunken ) 509 if ( sunken )
510 p->setPen( g.light() ); 510 p->setPen( g.light() );
511 else 511 else
512 p->setPen( g.dark() ); 512 p->setPen( g.dark() );
513 513
514 p->drawLine( x2, y, x2, y2 ); 514 p->drawLine( x2, y, x2, y2 );
515 p->drawLine( x, y2, x2, y2 ); 515 p->drawLine( x, y2, x2, y2 );
516 p->setPen( oldPen ); 516 p->setPen( oldPen );
517 517
518 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); 518 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
519} 519}
520 520
521void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) 521void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
522{ 522{
523 p->fillRect( x, y, w, h, color1 ); 523 p->fillRect( x, y, w, h, color1 );
524} 524}
525 525
526void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 526void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
527 const QColorGroup &g, bool sunken, const QBrush* fill ) 527 const QColorGroup &g, bool sunken, const QBrush* fill )
528{ 528{
529 drawButton( p, x, y, w, h, g, sunken, fill ); 529 drawButton( p, x, y, w, h, g, sunken, fill );
530} 530}
531 531
532QRect QPEStyle::comboButtonRect( int x, int y, int w, int h) 532QRect QPEStyle::comboButtonRect( int x, int y, int w, int h)
533{ 533{
534 return QRect(x+1, y+1, w-2-14, h-2); 534 return QRect(x+1, y+1, w-2-14, h-2);
535} 535}
536 536
537 537
538QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h) 538QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h)
539{ 539{
540 return QRect(x+2, y+2, w-4-14, h-4); 540 return QRect(x+2, y+2, w-4-14, h-4);
541} 541}
542 542
543void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 543void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
544 const QColorGroup &g, bool sunken, 544 const QColorGroup &g, bool sunken,
545 bool /*editable*/, 545 bool /*editable*/,
546 bool enabled, 546 bool enabled,
547 const QBrush *fill ) 547 const QBrush *fill )
548{ 548{
549 drawBevelButton( p, x, y, w, h, g, FALSE, fill ); 549 drawBevelButton( p, x, y, w, h, g, FALSE, fill );
550 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill ); 550 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
551 drawArrow( p, QStyle::DownArrow, sunken, 551 drawArrow( p, QStyle::DownArrow, sunken,
552 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled, 552 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
553 &g.brush( QColorGroup::Button ) ); 553 &g.brush( QColorGroup::Button ) );
554 554
555} 555}
556 556
557 557
558void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, 558void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
559 int h, const QColorGroup & g, bool on, bool down, bool enabled ) 559 int h, const QColorGroup & g, bool on, bool down, bool enabled )
560{ 560{
561 static const QCOORD pts1[] = { // dark lines 561 static const QCOORD pts1[] = { // dark lines
562 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 562 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
563 static const QCOORD pts4[] = { // white lines 563 static const QCOORD pts4[] = { // white lines
564 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 564 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
565 11,4, 10,3, 10,2 }; 565 11,4, 10,3, 10,2 };
566 static const QCOORD pts5[] = { // inner fill 566 static const QCOORD pts5[] = { // inner fill
567 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 567 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
568 568
569 p->eraseRect( x, y, w, h ); 569 p->eraseRect( x, y, w, h );
570 QPointArray a( QCOORDARRLEN(pts1), pts1 ); 570 QPointArray a( QCOORDARRLEN(pts1), pts1 );
571 a.translate( x, y ); 571 a.translate( x, y );
572 p->setPen( g.dark() ); 572 p->setPen( g.dark() );
573 p->drawPolyline( a ); 573 p->drawPolyline( a );
574 a.setPoints( QCOORDARRLEN(pts4), pts4 ); 574 a.setPoints( QCOORDARRLEN(pts4), pts4 );
575 a.translate( x, y ); 575 a.translate( x, y );
576 p->setPen( g.light() ); 576 p->setPen( g.light() );
577 p->drawPolyline( a ); 577 p->drawPolyline( a );
578 a.setPoints( QCOORDARRLEN(pts5), pts5 ); 578 a.setPoints( QCOORDARRLEN(pts5), pts5 );
579 a.translate( x, y ); 579 a.translate( x, y );
580 QColor fillColor = ( down || !enabled ) ? g.button() : g.base(); 580 QColor fillColor = ( down || !enabled ) ? g.button() : g.base();
581 p->setPen( fillColor ); 581 p->setPen( fillColor );
582 p->setBrush( fillColor ) ; 582 p->setBrush( fillColor ) ;
583 p->drawPolygon( a ); 583 p->drawPolygon( a );
584 if ( on ) { 584 if ( on ) {
585 p->setPen( NoPen ); 585 p->setPen( NoPen );
@@ -873,97 +873,97 @@ void QPEStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
873 int a = tickAbove ? 3 : 0; 873 int a = tickAbove ? 3 : 0;
874 int b = tickBelow ? 3 : 0; 874 int b = tickBelow ? 3 : 0;
875 if ( o == Horizontal ) 875 if ( o == Horizontal )
876 p->fillRect( x, y+a, w, h-a-b, color1 ); 876 p->fillRect( x, y+a, w, h-a-b, color1 );
877 else 877 else
878 p->fillRect( x+a, y, w-a-b, h, color1 ); 878 p->fillRect( x+a, y, w-a-b, h, color1 );
879} 879}
880 880
881/*!\reimp 881/*!\reimp
882 */ 882 */
883void QPEStyle::drawSliderGrooveMask( QPainter *p, 883void QPEStyle::drawSliderGrooveMask( QPainter *p,
884 int x, int y, int w, int h, 884 int x, int y, int w, int h,
885 const QColorGroup& , QCOORD c, 885 const QColorGroup& , QCOORD c,
886 Orientation orient ) 886 Orientation orient )
887{ 887{
888 if ( orient == Horizontal ) 888 if ( orient == Horizontal )
889 p->fillRect( x, y + c - 2, w, 4, color1 ); 889 p->fillRect( x, y + c - 2, w, 4, color1 );
890 else 890 else
891 p->fillRect( x + c - 2, y, 4, h, color1 ); 891 p->fillRect( x + c - 2, y, 4, h, color1 );
892} 892}
893 893
894void QPEStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) 894void QPEStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
895{ 895{
896 QRect r( t->rect() ); 896 QRect r( t->rect() );
897 if ( tb->shape() == QTabBar::RoundedAbove ) { 897 if ( tb->shape() == QTabBar::RoundedAbove ) {
898 p->setPen( tb->colorGroup().light() ); 898 p->setPen( tb->colorGroup().light() );
899 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 899 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
900 if ( r.left() == 0 ) 900 if ( r.left() == 0 )
901 p->drawPoint( tb->rect().bottomLeft() ); 901 p->drawPoint( tb->rect().bottomLeft() );
902 else { 902 else {
903 p->setPen( tb->colorGroup().light() ); 903 p->setPen( tb->colorGroup().light() );
904 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 904 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
905 } 905 }
906 906
907 if ( selected ) { 907 if ( selected ) {
908 p->setPen( tb->colorGroup().background() ); 908 p->setPen( tb->colorGroup().background() );
909 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 909 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
910 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), 910 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
911 tb->colorGroup().brush( QColorGroup::Background )); 911 tb->colorGroup().brush( QColorGroup::Background ));
912 } else { 912 } else {
913 r.setRect( r.left() + 2, r.top() + 2, 913 r.setRect( r.left() + 2, r.top() + 2,
914 r.width() - 4, r.height() - 2 ); 914 r.width() - 4, r.height() - 2 );
915 p->setPen( tb->colorGroup().button() ); 915 p->setPen( tb->colorGroup().button() );
916 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 916 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
917 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), 917 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
918 tb->colorGroup().brush( QColorGroup::Button )); 918 tb->colorGroup().brush( QColorGroup::Button ));
919 919
920 //do shading; will not work for pixmap brushes 920 //do shading; will not work for pixmap brushes
921 QColor bg = tb->colorGroup().button(); 921 QColor bg = tb->colorGroup().button();
922 // int h,s,v; 922 // int h,s,v;
923 // bg.hsv( &h, &s, &v ); 923 // bg.hsv( &h, &s, &v );
924 int n = r.height()/2; 924 int n = r.height()/2;
925 int dark = 100; 925 int dark = 100;
926 for ( int i = 1; i < n; i++ ) { 926 for ( int i = 1; i < n; i++ ) {
927 dark = (dark * (100+(i*15)/n) )/100; 927 dark = (dark * (100+(i*15)/n) )/100;
928 p->setPen( bg.dark( dark ) ); 928 p->setPen( bg.dark( dark ) );
929 int y = r.bottom()-n+i; 929 int y = r.bottom()-n+i;
930 int x1 = r.left()+1; 930 int x1 = r.left()+1;
931 int x2 = r.right()-1; 931 int x2 = r.right()-1;
932 p->drawLine( x1, y, x2, y ); 932 p->drawLine( x1, y, x2, y );
933 } 933 }
934 } 934 }
935 935
936 p->setPen( tb->colorGroup().light() ); 936 p->setPen( tb->colorGroup().light() );
937 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); 937 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
938 p->drawPoint( r.left()+1, r.top() + 1 ); 938 p->drawPoint( r.left()+1, r.top() + 1 );
939 p->drawLine( r.left()+2, r.top(), 939 p->drawLine( r.left()+2, r.top(),
940 r.right() - 2, r.top() ); 940 r.right() - 2, r.top() );
941 941
942 p->setPen( tb->colorGroup().dark() ); 942 p->setPen( tb->colorGroup().dark() );
943 p->drawPoint( r.right() - 1, r.top() + 1 ); 943 p->drawPoint( r.right() - 1, r.top() + 1 );
944 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); 944 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
945 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 945 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
946 if ( selected ) { 946 if ( selected ) {
947 p->setPen( tb->colorGroup().background() ); 947 p->setPen( tb->colorGroup().background() );
948 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 948 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
949 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), 949 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
950 tb->palette().normal().brush( QColorGroup::Background )); 950 tb->palette().normal().brush( QColorGroup::Background ));
951 } else { 951 } else {
952 p->setPen( tb->colorGroup().dark() ); 952 p->setPen( tb->colorGroup().dark() );
953 p->drawLine( r.left(), r.top(), 953 p->drawLine( r.left(), r.top(),
954 r.right(), r.top() ); 954 r.right(), r.top() );
955 r.setRect( r.left() + 2, r.top(), 955 r.setRect( r.left() + 2, r.top(),
956 r.width() - 4, r.height() - 2 ); 956 r.width() - 4, r.height() - 2 );
957 p->setPen( tb->colorGroup().button() ); 957 p->setPen( tb->colorGroup().button() );
958 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 958 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
959 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), 959 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
960 tb->palette().normal().brush( QColorGroup::Button )); 960 tb->palette().normal().brush( QColorGroup::Button ));
961 } 961 }
962 962
963 p->setPen( tb->colorGroup().dark() ); 963 p->setPen( tb->colorGroup().dark() );
964 p->drawLine( r.right(), r.top(), 964 p->drawLine( r.right(), r.top(),
965 r.right(), r.bottom() - 2 ); 965 r.right(), r.bottom() - 2 );
966 p->drawPoint( r.right() - 1, r.bottom() - 1 ); 966 p->drawPoint( r.right() - 1, r.bottom() - 1 );
967 p->drawLine( r.right() - 2, r.bottom(), 967 p->drawLine( r.right() - 2, r.bottom(),
968 r.left() + 2, r.bottom() ); 968 r.left() + 2, r.bottom() );
969 969
@@ -983,119 +983,119 @@ static const int motifItemFrame = 0; // menu item frame width
983 static const int motifSepHeight = 2;// separator item height 983 static const int motifSepHeight = 2;// separator item height
984 static const int motifItemHMargin = 1;// menu item hor text margin 984 static const int motifItemHMargin = 1;// menu item hor text margin
985 static const int motifItemVMargin = 2;// menu item ver text margin 985 static const int motifItemVMargin = 2;// menu item ver text margin
986 static const int motifArrowHMargin = 0;// arrow horizontal margin 986 static const int motifArrowHMargin = 0;// arrow horizontal margin
987 static const int motifTabSpacing = 12;// space between text and tab 987 static const int motifTabSpacing = 12;// space between text and tab
988 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark 988 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark
989 static const int windowsRightBorder= 8; // right border on windows 989 static const int windowsRightBorder= 8; // right border on windows
990static const int windowsCheckMarkWidth = 2; // checkmarks width on windows 990static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
991 991
992/*! \reimp 992/*! \reimp
993*/ 993*/
994int QPEStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) 994int QPEStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
995{ 995{
996#ifndef QT_NO_MENUDATA 996#ifndef QT_NO_MENUDATA
997 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm 997 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
998 998
999 if ( mi->isSeparator() ) 999 if ( mi->isSeparator() )
1000 return 10; // arbitrary 1000 return 10; // arbitrary
1001 else if ( mi->pixmap() ) 1001 else if ( mi->pixmap() )
1002 w += mi->pixmap()->width();// pixmap only 1002 w += mi->pixmap()->width();// pixmap only
1003 1003
1004 if ( !mi->text().isNull() ) { 1004 if ( !mi->text().isNull() ) {
1005 if ( mi->text().find('\t') >= 0 )// string contains tab 1005 if ( mi->text().find('\t') >= 0 )// string contains tab
1006 w += motifTabSpacing; 1006 w += motifTabSpacing;
1007 } 1007 }
1008 1008
1009 if ( maxpmw ) { // we have iconsets 1009 if ( maxpmw ) { // we have iconsets
1010 w += maxpmw; 1010 w += maxpmw;
1011 w += 6; // add a little extra border around the iconset 1011 w += 6; // add a little extra border around the iconset
1012 } 1012 }
1013 1013
1014 if ( checkable && maxpmw < windowsCheckMarkWidth ) { 1014 if ( checkable && maxpmw < windowsCheckMarkWidth ) {
1015 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks 1015 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
1016 } 1016 }
1017 1017
1018 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) 1018 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
1019 w += motifCheckMarkHMargin; // add space to separate the columns 1019 w += motifCheckMarkHMargin; // add space to separate the columns
1020 1020
1021 w += windowsRightBorder; // windows has a strange wide border on the right side 1021 w += windowsRightBorder; // windows has a strange wide border on the right side
1022 1022
1023 return w; 1023 return w;
1024#endif 1024#endif
1025} 1025}
1026 1026
1027/*! \reimp 1027/*! \reimp
1028*/ 1028*/
1029int QPEStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) 1029int QPEStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
1030{ 1030{
1031#ifndef QT_NO_MENUDATA 1031#ifndef QT_NO_MENUDATA
1032 int h = 0; 1032 int h = 0;
1033 if ( mi->isSeparator() ) // separator height 1033 if ( mi->isSeparator() ) // separator height
1034 h = motifSepHeight; 1034 h = motifSepHeight;
1035 else if ( mi->pixmap() ) // pixmap height 1035 else if ( mi->pixmap() ) // pixmap height
1036 h = mi->pixmap()->height() + 2*motifItemFrame; 1036 h = mi->pixmap()->height() + 2*motifItemFrame;
1037 else // text height 1037 else // text height
1038 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; 1038 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
1039 1039
1040 if ( !mi->isSeparator() && mi->iconSet() != 0 ) { 1040 if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
1041 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); 1041 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
1042 } 1042 }
1043 if ( mi->custom() ) 1043 if ( mi->custom() )
1044 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; 1044 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
1045 return h; 1045 return h;
1046#endif 1046#endif
1047} 1047}
1048 1048
1049void QPEStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 1049void QPEStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
1050 const QPalette& pal, 1050 const QPalette& pal,
1051 bool act, bool enabled, int x, int y, int w, int h) 1051 bool act, bool enabled, int x, int y, int w, int h)
1052{ 1052{
1053#ifndef QT_NO_MENUDATA 1053#ifndef QT_NO_MENUDATA
1054 const QColorGroup & g = pal.active(); 1054 const QColorGroup & g = pal.active();
1055 bool dis = !enabled; 1055 bool dis = !enabled;
1056 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 1056 QColorGroup itemg = dis ? pal.disabled() : pal.active();
1057 1057
1058 if ( checkable ) 1058 if ( checkable )
1059 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks 1059 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
1060 1060
1061 int checkcol = maxpmw; 1061 int checkcol = maxpmw;
1062 1062
1063 if ( mi && mi->isSeparator() ) { // draw separator 1063 if ( mi && mi->isSeparator() ) { // draw separator
1064 p->setPen( g.dark() ); 1064 p->setPen( g.dark() );
1065 p->drawLine( x, y, x+w, y ); 1065 p->drawLine( x, y, x+w, y );
1066 p->setPen( g.light() ); 1066 p->setPen( g.light() );
1067 p->drawLine( x, y+1, x+w, y+1 ); 1067 p->drawLine( x, y+1, x+w, y+1 );
1068 return; 1068 return;
1069 } 1069 }
1070 1070
1071 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 1071 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
1072 g.brush( QColorGroup::Button ); 1072 g.brush( QColorGroup::Button );
1073 p->fillRect( x, y, w, h, fill); 1073 p->fillRect( x, y, w, h, fill);
1074 1074
1075 if ( !mi ) 1075 if ( !mi )
1076 return; 1076 return;
1077 1077
1078 if ( mi->isChecked() ) { 1078 if ( mi->isChecked() ) {
1079 if ( act && !dis ) { 1079 if ( act && !dis ) {
1080 qDrawShadePanel( p, x, y, checkcol, h, 1080 qDrawShadePanel( p, x, y, checkcol, h,
1081 g, TRUE, 1, &g.brush( QColorGroup::Button ) ); 1081 g, TRUE, 1, &g.brush( QColorGroup::Button ) );
1082 } else { 1082 } else {
1083 qDrawShadePanel( p, x, y, checkcol, h, 1083 qDrawShadePanel( p, x, y, checkcol, h,
1084 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); 1084 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
1085 } 1085 }
1086 } else if ( !act ) { 1086 } else if ( !act ) {
1087 p->fillRect(x, y, checkcol , h, 1087 p->fillRect(x, y, checkcol , h,
1088 g.brush( QColorGroup::Button )); 1088 g.brush( QColorGroup::Button ));
1089 } 1089 }
1090 1090
1091 if ( mi->iconSet() ) { // draw iconset 1091 if ( mi->iconSet() ) { // draw iconset
1092 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1092 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1093 if (act && !dis ) 1093 if (act && !dis )
1094 mode = QIconSet::Active; 1094 mode = QIconSet::Active;
1095 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); 1095 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
1096 int pixw = pixmap.width(); 1096 int pixw = pixmap.width();
1097 int pixh = pixmap.height(); 1097 int pixh = pixmap.height();
1098 if ( act && !dis ) { 1098 if ( act && !dis ) {
1099 if ( !mi->isChecked() ) 1099 if ( !mi->isChecked() )
1100 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); 1100 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
1101 } 1101 }
diff --git a/library/resource.cpp b/library/resource.cpp
index bdcd603..0920b67 100644
--- a/library/resource.cpp
+++ b/library/resource.cpp
@@ -1,70 +1,70 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_MIMEEXT 21#define QTOPIA_INTERNAL_MIMEEXT
22#include "qpeapplication.h" 22#include <qpe/qpeapplication.h>
23#include "resource.h" 23#include "resource.h"
24#include "mimetype.h" 24#include "mimetype.h"
25#include <qdir.h> 25#include <qdir.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qregexp.h> 27#include <qregexp.h>
28#include <qpixmapcache.h> 28#include <qpixmapcache.h>
29#include <qpainter.h> 29#include <qpainter.h>
30 30
31// this namespace is just a workaround for a gcc bug 31// this namespace is just a workaround for a gcc bug
32// gcc exports inline functions in the generated file 32// gcc exports inline functions in the generated file
33// inlinepics_p.h 33// inlinepics_p.h
34 34
35namespace { 35namespace {
36#include "inlinepics_p.h" 36#include "inlinepics_p.h"
37} 37}
38 38
39/*! 39/*!
40 \class Resource resource.h 40 \class Resource resource.h
41 \brief The Resource class provides access to named resources. 41 \brief The Resource class provides access to named resources.
42 42
43 The resources may be provided from files or other sources. 43 The resources may be provided from files or other sources.
44 44
45 The allSounds() function returns a list of all the sounds available. 45 The allSounds() function returns a list of all the sounds available.
46 A particular sound can be searched for using findSound(). 46 A particular sound can be searched for using findSound().
47 47
48 Images can be loaded with loadImage(), loadPixmap(), loadBitmap() 48 Images can be loaded with loadImage(), loadPixmap(), loadBitmap()
49 and loadIconSet(). 49 and loadIconSet().
50 50
51 \ingroup qtopiaemb 51 \ingroup qtopiaemb
52*/ 52*/
53 53
54/*! 54/*!
55 \fn Resource::Resource() 55 \fn Resource::Resource()
56 \internal 56 \internal
57*/ 57*/
58 58
59/*! 59/*!
60 Returns the QPixmap called \a pix. You should avoid including 60 Returns the QPixmap called \a pix. You should avoid including
61 any filename type extension (e.g. .png, .xpm). 61 any filename type extension (e.g. .png, .xpm).
62*/ 62*/
63QPixmap Resource::loadPixmap( const QString &pix ) 63QPixmap Resource::loadPixmap( const QString &pix )
64{ 64{
65 QPixmap pm; 65 QPixmap pm;
66 QString key="QPE_"+pix; 66 QString key="QPE_"+pix;
67 if ( !QPixmapCache::find(key,pm) ) { 67 if ( !QPixmapCache::find(key,pm) ) {
68 pm.convertFromImage(loadImage(pix)); 68 pm.convertFromImage(loadImage(pix));
69 QPixmapCache::insert(key,pm); 69 QPixmapCache::insert(key,pm);
70 } 70 }
diff --git a/library/timestring.cpp b/library/timestring.cpp
index 4c6fa72..6443b6b 100644
--- a/library/timestring.cpp
+++ b/library/timestring.cpp
@@ -1,308 +1,308 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "timestring.h" 21#include "timestring.h"
22#include <qobject.h> 22#include <qobject.h>
23#include "qpeapplication.h" //for qApp 23#include <qpe/qpeapplication.h> //for qApp
24#include "config.h" 24#include "config.h"
25 25
26 26
27class TimeStringFormatKeeper : public QObject 27class TimeStringFormatKeeper : public QObject
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 static DateFormat currentFormat() 31 static DateFormat currentFormat()
32 { 32 {
33 if ( !self ) 33 if ( !self )
34 self = new TimeStringFormatKeeper; 34 self = new TimeStringFormatKeeper;
35 return self->format; 35 return self->format;
36 } 36 }
37private slots: 37private slots:
38 void formatChanged( DateFormat f ) 38 void formatChanged( DateFormat f )
39 { 39 {
40 format = f; 40 format = f;
41 } 41 }
42private: 42private:
43 static TimeStringFormatKeeper *self; 43 static TimeStringFormatKeeper *self;
44 DateFormat format; 44 DateFormat format;
45 45
46 TimeStringFormatKeeper() 46 TimeStringFormatKeeper()
47 : QObject( qApp ) 47 : QObject( qApp )
48 { 48 {
49 Config config("qpe"); 49 Config config("qpe");
50 config.setGroup( "Date" ); 50 config.setGroup( "Date" );
51 format = DateFormat(QChar(config.readEntry("Separator", "/")[0]), 51 format = DateFormat(QChar(config.readEntry("Separator", "/")[0]),
52 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 52 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
53 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 53 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
54 54
55 connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ), 55 connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ),
56 this, SLOT( formatChanged( DateFormat ) ) ); 56 this, SLOT( formatChanged( DateFormat ) ) );
57 } 57 }
58}; 58};
59 59
60TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0; 60TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0;
61 61
62QString DateFormat::toNumberString() const 62QString DateFormat::toNumberString() const
63{ 63{
64 QString buf = ""; 64 QString buf = "";
65 // for each part of the order 65 // for each part of the order
66 for (int i = 0; i < 3; i++) { 66 for (int i = 0; i < 3; i++) {
67 // switch on the relavent 3 bits. 67 // switch on the relavent 3 bits.
68 switch((_shortOrder >> (i * 3)) & 0x0007) { 68 switch((_shortOrder >> (i * 3)) & 0x0007) {
69 case 0x0001: 69 case 0x0001:
70 buf += QObject::tr( "D" ); 70 buf += QObject::tr( "D" );
71 break; 71 break;
72 case 0x0002: 72 case 0x0002:
73 buf += QObject::tr( "M" ); 73 buf += QObject::tr( "M" );
74 break; 74 break;
75 case 0x0004: 75 case 0x0004:
76 buf += QObject::tr( "Y" ); 76 buf += QObject::tr( "Y" );
77 break; 77 break;
78 } 78 }
79 if (i < 2) 79 if (i < 2)
80 buf += _shortSeparator; 80 buf += _shortSeparator;
81 } 81 }
82 return buf; 82 return buf;
83} 83}
84 84
85QString DateFormat::toWordString() const 85QString DateFormat::toWordString() const
86{ 86{
87 QString buf = ""; 87 QString buf = "";
88 // for each part of the order 88 // for each part of the order
89 for (int i = 0; i < 3; i++) { 89 for (int i = 0; i < 3; i++) {
90 // switch on the relavent 3 bits. 90 // switch on the relavent 3 bits.
91 switch((_longOrder >> (i * 3)) & 0x0007) { 91 switch((_longOrder >> (i * 3)) & 0x0007) {
92 case 0x0001: 92 case 0x0001:
93 buf += QObject::tr( "day" ); 93 buf += QObject::tr( "day" );
94 if (i < 2) { 94 if (i < 2) {
95 if ((_shortOrder << ((i+1) * 3)) & 0x0007) 95 if ((_shortOrder << ((i+1) * 3)) & 0x0007)
96 buf += ", "; 96 buf += ", ";
97 else 97 else
98 buf += " "; 98 buf += " ";
99 } 99 }
100 break; 100 break;
101 case 0x0002: 101 case 0x0002:
102 buf += QObject::tr( "month" ); 102 buf += QObject::tr( "month" );
103 if (i < 2) 103 if (i < 2)
104 buf += " "; 104 buf += " ";
105 break; 105 break;
106 case 0x0004: 106 case 0x0004:
107 buf += QObject::tr( "year" ); 107 buf += QObject::tr( "year" );
108 if (i < 2) 108 if (i < 2)
109 buf += ", "; 109 buf += ", ";
110 break; 110 break;
111 } 111 }
112 } 112 }
113 return buf; 113 return buf;
114} 114}
115 115
116QString DateFormat::numberDate(const QDate &d, int v) const 116QString DateFormat::numberDate(const QDate &d, int v) const
117{ 117{
118 QString buf = ""; 118 QString buf = "";
119 119
120 int pad = 2; 120 int pad = 2;
121 121
122 // for each part of the order 122 // for each part of the order
123 for (int i = 0; i < 3; i++) { 123 for (int i = 0; i < 3; i++) {
124 // switch on the relavent 3 bits. 124 // switch on the relavent 3 bits.
125 switch((_shortOrder >> (i * 3)) & 0x0007) { 125 switch((_shortOrder >> (i * 3)) & 0x0007) {
126 case 0x0001: 126 case 0x0001:
127 if (pad==2) buf += QString().sprintf("%02d",d.day()); 127 if (pad==2) buf += QString().sprintf("%02d",d.day());
128 else buf += QString().sprintf("%d",d.day()); 128 else buf += QString().sprintf("%d",d.day());
129 break; 129 break;
130 case 0x0002: 130 case 0x0002:
131 if (i==0) { // no padding with only MM/DD/YY format 131 if (i==0) { // no padding with only MM/DD/YY format
132 pad=0; 132 pad=0;
133 } 133 }
134 if (pad==2) buf += QString().sprintf("%02d",d.month()); 134 if (pad==2) buf += QString().sprintf("%02d",d.month());
135 else buf += QString().sprintf("%d",d.month()); 135 else buf += QString().sprintf("%d",d.month());
136 break; 136 break;
137 case 0x0004: 137 case 0x0004:
138 { 138 {
139 int year = d.year(); 139 int year = d.year();
140 if (!(v & longNumber)) 140 if (!(v & longNumber))
141 year = year % 100; 141 year = year % 100;
142 buf += QString().sprintf("%02d",year); 142 buf += QString().sprintf("%02d",year);
143 } 143 }
144 break; 144 break;
145 } 145 }
146 if (i < 2) 146 if (i < 2)
147 buf += _shortSeparator; 147 buf += _shortSeparator;
148 } 148 }
149 return buf; 149 return buf;
150} 150}
151 151
152QString DateFormat::wordDate(const QDate &d, int v) const 152QString DateFormat::wordDate(const QDate &d, int v) const
153{ 153{
154 QString buf = ""; 154 QString buf = "";
155 // for each part of the order 155 // for each part of the order
156 if (v & showWeekDay) { 156 if (v & showWeekDay) {
157 QString weekDay = d.dayName(d.dayOfWeek()); 157 QString weekDay = d.dayName(d.dayOfWeek());
158 if (!(v & longWord)) { 158 if (!(v & longWord)) {
159 weekDay = weekDay.left(3); 159 weekDay = weekDay.left(3);
160 } 160 }
161 buf += weekDay; 161 buf += weekDay;
162 if ((_longOrder & 0x0007) == 0x0002) 162 if ((_longOrder & 0x0007) == 0x0002)
163 buf += ' '; 163 buf += ' ';
164 else 164 else
165 buf += ", "; 165 buf += ", ";
166 } 166 }
167 167
168 for (int i = 0; i < 3; i++) { 168 for (int i = 0; i < 3; i++) {
169 // switch on the relavent 3 bits. 169 // switch on the relavent 3 bits.
170 switch((_longOrder >> (i * 3)) & 0x0007) { 170 switch((_longOrder >> (i * 3)) & 0x0007) {
171 case 0x0001: 171 case 0x0001:
172 if (i==1) { 172 if (i==1) {
173 buf += QString().sprintf("%02d, ",d.day()); 173 buf += QString().sprintf("%02d, ",d.day());
174 } else { 174 } else {
175 buf += QString().sprintf("%2d",d.day()); 175 buf += QString().sprintf("%2d",d.day());
176 if (separator()=='.') // 2002/1/11 176 if (separator()=='.') // 2002/1/11
177 buf += ". "; 177 buf += ". ";
178 else 178 else
179 buf += " "; 179 buf += " ";
180 } 180 }
181 break; 181 break;
182 case 0x0002: 182 case 0x0002:
183 { 183 {
184 QString monthName = d.monthName(d.month()); 184 QString monthName = d.monthName(d.month());
185 if (!(v & longWord)) { 185 if (!(v & longWord)) {
186 monthName = monthName.left(3); 186 monthName = monthName.left(3);
187 } 187 }
188 buf += monthName; 188 buf += monthName;
189 } 189 }
190 if (i < 2) 190 if (i < 2)
191 buf += " "; 191 buf += " ";
192 break; 192 break;
193 case 0x0004: 193 case 0x0004:
194 { 194 {
195 int year = d.year(); 195 int year = d.year();
196 if (!(v & longNumber)) 196 if (!(v & longNumber))
197 year = year % 100; 197 year = year % 100;
198 198
199 if (year < 10) 199 if (year < 10)
200 buf += "0"; 200 buf += "0";
201 201
202 buf += QString::number(year); 202 buf += QString::number(year);
203 } 203 }
204 if (i < 2) 204 if (i < 2)
205 buf += ", "; 205 buf += ", ";
206 break; 206 break;
207 } 207 }
208 } 208 }
209 return buf; 209 return buf;
210} 210}
211 211
212#ifndef QT_NO_DATASTREAM 212#ifndef QT_NO_DATASTREAM
213void DateFormat::save(QDataStream &d) const 213void DateFormat::save(QDataStream &d) const
214{ 214{
215 d << _shortSeparator.unicode(); 215 d << _shortSeparator.unicode();
216 uint v= _shortOrder; 216 uint v= _shortOrder;
217 d << v; 217 d << v;
218 v = _longOrder; 218 v = _longOrder;
219 d << v; 219 d << v;
220} 220}
221 221
222void DateFormat::load(QDataStream &d) 222void DateFormat::load(QDataStream &d)
223{ 223{
224 ushort value; 224 ushort value;
225 d >> value; 225 d >> value;
226 _shortSeparator = QChar(value); 226 _shortSeparator = QChar(value);
227 uint v = 0; 227 uint v = 0;
228 d >> v; 228 d >> v;
229 _shortOrder = (Order)v; 229 _shortOrder = (Order)v;
230 v = 0; 230 v = 0;
231 d >> v; 231 d >> v;
232 _longOrder = (Order)v; 232 _longOrder = (Order)v;
233} 233}
234 234
235QDataStream &operator<<(QDataStream &s, const DateFormat&df) 235QDataStream &operator<<(QDataStream &s, const DateFormat&df)
236{ 236{
237 df.save(s); 237 df.save(s);
238 return s; 238 return s;
239} 239}
240QDataStream &operator>>(QDataStream &s, DateFormat&df) 240QDataStream &operator>>(QDataStream &s, DateFormat&df)
241{ 241{
242 df.load(s); 242 df.load(s);
243 return s; 243 return s;
244} 244}
245#endif 245#endif
246 246
247QString TimeString::shortDate( const QDate &d, DateFormat dtf ) 247QString TimeString::shortDate( const QDate &d, DateFormat dtf )
248{ 248{
249 return dtf.wordDate(d); 249 return dtf.wordDate(d);
250} 250}
251 251
252QString TimeString::dateString( const QDate &d, DateFormat dtf ) 252QString TimeString::dateString( const QDate &d, DateFormat dtf )
253{ 253{
254 return dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord); 254 return dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord);
255} 255}
256 256
257 257
258QString TimeString::longDateString( const QDate &d, DateFormat dtf ) 258QString TimeString::longDateString( const QDate &d, DateFormat dtf )
259{ 259{
260 return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber 260 return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber
261 | DateFormat::longWord); 261 | DateFormat::longWord);
262} 262}
263 263
264DateFormat TimeString::currentDateFormat() 264DateFormat TimeString::currentDateFormat()
265{ 265{
266 return TimeStringFormatKeeper::currentFormat(); 266 return TimeStringFormatKeeper::currentFormat();
267} 267}
268 268
269 269
270QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf ) 270QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf )
271{ 271{
272 const QDate& d = dt.date(); 272 const QDate& d = dt.date();
273 const QTime& t = dt.time(); 273 const QTime& t = dt.time();
274 274
275 // based on QDateTime::toString() 275 // based on QDateTime::toString()
276 QString buf = timeString(t,ampm,seconds); 276 QString buf = timeString(t,ampm,seconds);
277 buf += " "; 277 buf += " ";
278 buf += longDateString( d, dtf ); 278 buf += longDateString( d, dtf );
279 279
280 return buf; 280 return buf;
281} 281}
282 282
283QString TimeString::timeString( const QTime &t, bool ampm, bool seconds ) 283QString TimeString::timeString( const QTime &t, bool ampm, bool seconds )
284{ 284{
285 if ( !ampm ) { 285 if ( !ampm ) {
286 if ( seconds ) 286 if ( seconds )
287 return t.toString(); 287 return t.toString();
288 QString r = QString::number(t.hour()); 288 QString r = QString::number(t.hour());
289 if ( t.hour() < 10 ) r.prepend( "0" ); 289 if ( t.hour() < 10 ) r.prepend( "0" );
290 r.append( ":" ); 290 r.append( ":" );
291 if ( t.minute() < 10 ) r.append( "0" ); 291 if ( t.minute() < 10 ) r.append( "0" );
292 r.append(QString::number(t.minute())); 292 r.append(QString::number(t.minute()));
293 return r; 293 return r;
294 } 294 }
295 // ### else the hard case that should disappear in Qt 3.0 295 // ### else the hard case that should disappear in Qt 3.0
296 QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7"; 296 QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7";
297 int hour = t.hour(); 297 int hour = t.hour();
298 QString strMin = QString::number( t.minute() ); 298 QString strMin = QString::number( t.minute() );
299 QString strSec = QString::number( t.second() ); 299 QString strSec = QString::number( t.second() );
300 if ( hour > 12 ) 300 if ( hour > 12 )
301 argString = argString.arg( hour - 12, 2 ); 301 argString = argString.arg( hour - 12, 2 );
302 else { 302 else {
303 if ( hour == 0 ) 303 if ( hour == 0 )
304 argString = argString.arg( 12 ); 304 argString = argString.arg( 12 );
305 else 305 else
306 argString = argString.arg( hour, 2 ); 306 argString = argString.arg( hour, 2 );
307 } 307 }
308 if ( t.minute() < 10 ) 308 if ( t.minute() < 10 )