summaryrefslogtreecommitdiff
path: root/library
Side-by-side diff
Diffstat (limited to 'library') (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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qdir.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "global.h"
#include "resource.h"
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
-#include "qcopenvelope_qws.h"
+#include <qpe/qcopenvelope_qws.h>
#endif
#include "alarmserver.h"
#include <qpe/timeconversion.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
struct timerEventItem {
time_t UTCtime;
QCString channel, message;
int data;
bool operator==( const timerEventItem &right ) const
{
return ( UTCtime == right.UTCtime
&& channel == right.channel
&& message == right.message
&& data == right.data );
}
};
class TimerReceiverObject : public QObject
{
public:
TimerReceiverObject() { }
~TimerReceiverObject() { }
void resetTimer();
void setTimerEventItem();
void deleteTimer();
protected:
void timerEvent( QTimerEvent *te );
private:
QString atfilename;
};
TimerReceiverObject *timerEventReceiver = NULL;
QList<timerEventItem> timerEventList;
timerEventItem *nearestTimerEvent = NULL;
// set the timer to go off on the next event in the list
void setNearestTimerEvent()
{
nearestTimerEvent = NULL;
QListIterator<timerEventItem> it( timerEventList );
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.
#define yynerrs mime_nerrs
#define yyerrflag mime_errflag
#define yyss mime_ss
#define yyssp mime_ssp
#define yyvs mime_vs
#define yyvsp mime_vsp
#define yylhs mime_lhs
#define yylen mime_len
#define yydefred mime_defred
#define yydgoto mime_dgoto
#define yysindex mime_sindex
#define yyrindex mime_rindex
#define yygindex mime_gindex
#define yytable mime_table
#define yycheck mime_check
#define yyname mime_name
#define yyrule mime_rule
#ifdef YYPREFIX
#undef YYPREFIX
#endif
#define YYPREFIX "mime_"
#endif
#ifndef _NO_LINE_FOLDING
#define _SUPPORT_LINE_FOLDING 1
#endif
/* undef below if compile with MFC */
/* #define INCLUDEMFC 1 */
#if defined(WIN32) || defined(_WIN32)
#ifdef INCLUDEMFC
#include <afx.h>
#endif
#endif
#include <string.h>
#ifndef __MWERKS__
#include <stdlib.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//#ifdef PALMTOPCENTER
//#include <qpe/vobject_p.h>
//#else
-#include "vobject_p.h"
+#include <qtopia/private/vobject_p.h>
//#endif
/**** Types, Constants ****/
#define YYDEBUG 0 /* 1 to compile in some debugging code */
#define MAXTOKEN 256 /* maximum token (line) length */
#define YYSTACKSIZE 100 // ~unref ?
#define MAXLEVEL 10 /* max # of nested objects parseable */
/* (includes outermost) */
/**** Global Variables ****/
int mime_lineNum, mime_numErrors; /* yyerror() can use these */
static VObject* vObjList;
static VObject *curProp;
static VObject *curObj;
static VObject* ObjStack[MAXLEVEL];
static int ObjStackTop;
/* A helpful utility for the rest of the app. */
#if __CPLUSPLUS__
extern "C" {
#endif
extern void yyerror(char *s);
#if __CPLUSPLUS__
};
#endif
int yyparse();
enum LexMode {
L_NORMAL,
L_VCARD,
L_VCAL,
L_VEVENT,
L_VTODO,
L_VALUES,
L_BASE64,
L_QUOTED_PRINTABLE
};
/**** Private Forward Declarations ****/
static int pushVObject(const char *prop);
static VObject* popVObject();
static 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.
#define yynerrs mime_nerrs
#define yyerrflag mime_errflag
#define yyss mime_ss
#define yyssp mime_ssp
#define yyvs mime_vs
#define yyvsp mime_vsp
#define yylhs mime_lhs
#define yylen mime_len
#define yydefred mime_defred
#define yydgoto mime_dgoto
#define yysindex mime_sindex
#define yyrindex mime_rindex
#define yygindex mime_gindex
#define yytable mime_table
#define yycheck mime_check
#define yyname mime_name
#define yyrule mime_rule
#ifdef YYPREFIX
#undef YYPREFIX
#endif
#define YYPREFIX "mime_"
#endif
#ifndef _NO_LINE_FOLDING
#define _SUPPORT_LINE_FOLDING 1
#endif
/* undef below if compile with MFC */
/* #define INCLUDEMFC 1 */
#if defined(WIN32) || defined(_WIN32)
#ifdef INCLUDEMFC
#include <afx.h>
#endif
#endif
#include <string.h>
#ifndef __MWERKS__
#include <stdlib.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
/*#ifdef PALMTOPCENTER */
/*#include <qpe/vobject_p.h> */
/*#else */
-#include "vobject_p.h"
+#include <qtopia/private/vobject_p.h>
/*#endif */
/**** Types, Constants ****/
#define YYDEBUG 0 /* 1 to compile in some debugging code */
#define MAXTOKEN 256 /* maximum token (line) length */
#define YYSTACKSIZE 100 /* ~unref ? */
#define MAXLEVEL 10 /* max # of nested objects parseable */
/* (includes outermost) */
/**** Global Variables ****/
int mime_lineNum, mime_numErrors; /* yyerror() can use these */
static VObject* vObjList;
static VObject *curProp;
static VObject *curObj;
static VObject* ObjStack[MAXLEVEL];
static int ObjStackTop;
/* A helpful utility for the rest of the app. */
#if __CPLUSPLUS__
extern "C" {
#endif
extern void yyerror(char *s);
#if __CPLUSPLUS__
};
#endif
int yyparse();
enum LexMode {
L_NORMAL,
L_VCARD,
L_VCAL,
L_VEVENT,
L_VTODO,
L_VALUES,
L_BASE64,
L_QUOTED_PRINTABLE
};
/**** Private Forward Declarations ****/
static int pushVObject(const char *prop);
static VObject* popVObject();
static 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 @@
/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
+(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
+Business Machines Corporation and Siemens Rolm Communications Inc.
+
+For purposes of this license notice, the term Licensors shall mean,
+collectively, Apple Computer, Inc., AT&T Corp., International
+Business Machines Corporation and Siemens Rolm Communications Inc.
+The term Licensor shall mean any of the Licensors.
+
+Subject to acceptance of the following conditions, permission is hereby
+granted by Licensors without the need for written agreement and without
+license or royalty fees, to use, copy, modify and distribute this
+software for any purpose.
+
+The above copyright notice and the following four paragraphs must be
+reproduced in all copies of this software and any software including
+this software.
+
+THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
+ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
+MODIFICATIONS.
+
+IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
+INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
+OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.
+
+The software is provided with RESTRICTED RIGHTS. Use, duplication, or
+disclosure by the government are subject to restrictions set forth in
+DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
***************************************************************************/
/*
* src: vobject.c
- * doc: vobject and APIs to construct vobject, APIs pretty print
+ * doc: vobject and APIs to construct vobject, APIs pretty print
* vobject, and convert a vobject into its textual representation.
*/
#ifndef MWERKS
#include <malloc.h>
#endif
-#include "vobject_p.h"
-#include "qfiledirect_p.h"
+#include <qtopia/private/vobject_p.h>
+#include <qtopia/private/qfiledirect_p.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
//#include <io.h>
#define NAME_OF(o) o->id
#define VALUE_TYPE(o) o->valType
#define STRINGZ_VALUE_OF(o) o->val.strs
#define INTEGER_VALUE_OF(o) o->val.i
#define LONG_VALUE_OF(o) o->val.l
#define ANY_VALUE_OF(o) o->val.any
#define VOBJECT_VALUE_OF(o) o->val.vobj
typedef union ValueItem {
const char *strs;
unsigned int i;
unsigned long l;
void *any;
VObject *vobj;
} ValueItem;
struct VObject {
VObject *next;
const char *id;
VObject *prop;
unsigned short valType;
ValueItem val;
};
typedef struct StrItem StrItem;
struct StrItem {
StrItem *next;
const char *s;
unsigned int refCnt;
};
const char** fieldedProp;
/*----------------------------------------------------------------------
The following functions involve with memory allocation:
newVObject
deleteVObject
dupStr
deleteStr
@@ -282,173 +282,173 @@ DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
{
return addVObjectProp(o,newVObject(id));
}
DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
{
return addVObjectProp(o,newVObject_(id));
}
DLLEXPORT(void) addList(VObject **o, VObject *p)
{
p->next = 0;
if (*o == 0) {
*o = p;
}
else {
VObject *t = *o;
while (t->next) {
t = t->next;
}
t->next = p;
}
}
DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
{
return o->next;
}
DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
{
VObject *sizeProp;
setVObjectAnyValue(prop, val);
sizeProp = addProp(prop,VCDataSizeProp);
setVObjectLongValue(sizeProp, size);
return prop;
}
DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
{
void *p = dupStr((const char *)val,size);
return setValueWithSize_(prop,p,p?size:0);
}
DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
{
- i->start = o->prop;
+ i->start = o->prop;
i->next = 0;
}
DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
{
- i->start = o->next;
+ i->start = o->next;
i->next = 0;
}
DLLEXPORT(int) moreIteration(VObjectIterator *i)
-{
+{
return (i->start && (i->next==0 || i->next!=i->start));
}
DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
{
if (i->start && i->next != i->start) {
if (i->next == 0) {
i->next = i->start->next;
return i->next;
}
else {
i->next = i->next->next;
return i->next;
}
}
else return (VObject*)0;
}
DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
{
VObjectIterator i;
initPropIterator(&i,o);
while (moreIteration(&i)) {
VObject *each = nextVObject(&i);
if (!qstricmp(id,each->id))
return each;
}
return (VObject*)0;
}
DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
{
/*
a.b.c
-->
prop(c)
prop(VCGrouping=b)
prop(VCGrouping=a)
*/
char *dot = strrchr(g,'.');
if (dot) {
VObject *p, *t;
char *gs, *n = dot+1;
gs = dupStr(g,0); /* so we can write to it. */
/* used to be
* t = p = addProp_(o,lookupProp_(n));
*/
t = p = addProp_(o,lookupProp(n));
dot = strrchr(gs,'.');
*dot = 0;
do {
dot = strrchr(gs,'.');
if (dot) {
n = dot+1;
*dot=0;
}
else
n = gs;
/* property(VCGroupingProp=n);
* and the value may have VCGrouping property
*/
t = addProp(t,VCGroupingProp);
setVObjectStringZValue(t,lookupProp_(n));
} while (n != gs);
- deleteStr(gs);
+ deleteStr(gs);
return p;
}
else
return addProp_(o,lookupProp(g));
}
DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
{
VObject *prop;
prop = addProp(o,p);
setVObjectStringZValue_(prop, strdup( v ) );
return prop;
}
DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
unsigned int size)
{
VObject *prop;
prop = addProp(o,p);
setValueWithSize_(prop, (void*)v, size);
return prop;
}
DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
unsigned int size)
{
return addPropSizedValue_(o,p,dupStr(v,size),size);
}
DLLEXPORT(void) cleanVObject(VObject *o)
{
if (o == 0) return;
if (o->prop) {
/* destroy time: cannot use the iterator here.
Have to break the cycle in the circular link
list and turns it into regular NULL-terminated
list -- since at some point of destruction,
the reference entry for the iterator to work
will not longer be valid.
*/
VObject *p;
p = o->prop->next;
o->prop->next = 0;
do {
VObject *t = p->next;
cleanVObject(p);
p = t;
@@ -754,124 +754,124 @@ static struct PreDefProp propNames[] = {
{ VCQPProp, VCQuotedPrintableProp, 0, 0 },
{ VCQuickTimeProp, 0, 0, 0 },
{ VCQuotedPrintableProp, 0, 0, 0 },
{ VCRDateProp, 0, 0, 0 },
{ VCRegionProp, 0, 0, 0 },
{ VCRelatedToProp, 0, 0, 0 },
{ VCRepeatCountProp, 0, 0, 0 },
{ VCResourcesProp, 0, 0, 0 },
{ VCRNumProp, 0, 0, 0 },
{ VCRoleProp, 0, 0, 0 },
{ VCRRuleProp, 0, 0, 0 },
{ VCRSVPProp, 0, 0, 0 },
{ VCRunTimeProp, 0, 0, 0 },
{ VCSequenceProp, 0, 0, 0 },
{ VCSnoozeTimeProp, 0, 0, 0 },
{ VCStartProp, 0, 0, 0 },
{ VCStatusProp, 0, 0, 0 },
{ VCStreetAddressProp, 0, 0, 0 },
{ VCSubTypeProp, 0, 0, 0 },
{ VCSummaryProp, 0, 0, 0 },
{ VCTelephoneProp, 0, 0, 0 },
{ VCTIFFProp, 0, 0, 0 },
{ VCTimeZoneProp, 0, 0, 0 },
{ VCTitleProp, 0, 0, 0 },
{ VCTLXProp, 0, 0, 0 },
{ VCTodoProp, 0, 0, PD_BEGIN },
{ VCTranspProp, 0, 0, 0 },
{ VCUniqueStringProp, 0, 0, 0 },
{ VCURLProp, 0, 0, 0 },
{ VCURLValueProp, 0, 0, 0 },
{ VCValueProp, 0, 0, 0 },
{ VCVersionProp, 0, 0, 0 },
{ VCVideoProp, 0, 0, 0 },
{ VCVoiceProp, 0, 0, 0 },
{ VCWAVEProp, 0, 0, 0 },
{ VCWMFProp, 0, 0, 0 },
{ VCWorkProp, 0, 0, 0 },
{ VCX400Prop, 0, 0, 0 },
{ VCX509Prop, 0, 0, 0 },
{ VCXRuleProp, 0, 0, 0 },
{ 0,0,0,0 }
};
static struct PreDefProp* lookupPropInfo(const char* str)
{
/* brute force for now, could use a hash table here. */
int i;
-
+
for (i = 0; propNames[i].name; i++)
if (qstricmp(str, propNames[i].name) == 0) {
return &propNames[i];
}
-
+
return 0;
}
DLLEXPORT(const char*) lookupProp_(const char* str)
{
int i;
-
+
for (i = 0; propNames[i].name; i++)
if (qstricmp(str, propNames[i].name) == 0) {
const char* s;
s = propNames[i].alias?propNames[i].alias:propNames[i].name;
return lookupStr(s);
}
return lookupStr(str);
}
DLLEXPORT(const char*) lookupProp(const char* str)
{
int i;
-
+
for (i = 0; propNames[i].name; i++)
if (qstricmp(str, propNames[i].name) == 0) {
const char *s;
fieldedProp = propNames[i].fields;
s = propNames[i].alias?propNames[i].alias:propNames[i].name;
return lookupStr(s);
}
fieldedProp = 0;
return lookupStr(str);
}
/*----------------------------------------------------------------------
APIs to Output text form.
----------------------------------------------------------------------*/
#define OFILE_REALLOC_SIZE 256
typedef struct OFile {
FILE *fp;
char *s;
int len;
int limit;
int alloc:1;
int fail:1;
} OFile;
#if 0
static void appendsOFile(OFile *fp, const char *s)
{
int slen;
if (fp->fail) return;
slen = strlen(s);
if (fp->fp) {
fwrite(s,1,slen,fp->fp);
}
else {
stuff:
if (fp->len + slen < fp->limit) {
memcpy(fp->s+fp->len,s,slen);
fp->len += slen;
return;
}
else if (fp->alloc) {
fp->limit = fp->limit + OFILE_REALLOC_SIZE;
if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
fp->s = (char *) realloc(fp->s,fp->limit);
if (fp->s) goto stuff;
}
if (fp->alloc)
@@ -960,185 +960,185 @@ static void initOFile(OFile *fp, FILE *ofp)
fp->len = 0;
fp->limit = 0;
fp->alloc = 0;
fp->fail = 0;
}
static int writeBase64(OFile *fp, unsigned char *s, long len)
{
long cur = 0;
int i, numQuads = 0;
unsigned long trip;
unsigned char b;
char quad[5];
#define MAXQUADS 16
quad[4] = 0;
while (cur < len) {
// collect the triplet of bytes into 'trip'
trip = 0;
for (i = 0; i < 3; i++) {
b = (cur < len) ? *(s + cur) : 0;
cur++;
trip = trip << 8 | b;
}
// fill in 'quad' with the appropriate four characters
for (i = 3; i >= 0; i--) {
b = (unsigned char)(trip & 0x3F);
trip = trip >> 6;
if ((3 - i) < (cur - len))
quad[i] = '='; // pad char
else if (b < 26) quad[i] = (char)b + 'A';
else if (b < 52) quad[i] = (char)(b - 26) + 'a';
else if (b < 62) quad[i] = (char)(b - 52) + '0';
else if (b == 62) quad[i] = '+';
else quad[i] = '/';
}
// now output 'quad' with appropriate whitespace and line ending
appendsOFile(fp, (numQuads == 0 ? " " : ""));
appendsOFile(fp, quad);
appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
numQuads = (numQuads + 1) % MAXQUADS;
}
appendcOFile(fp,'\n');
return 1;
}
-static const char *replaceChar(unsigned char c)
+static const char *replaceChar(unsigned char c)
{
if (c == '\n') {
return "=0A=\n";
} else if (
- (c >= 'A' && c <= 'Z')
+ (c >= 'A' && c <= 'Z')
||
- (c >= 'a' && c <= 'z')
+ (c >= 'a' && c <= 'z')
||
- (c >= '0' && c <= '9')
+ (c >= '0' && c <= '9')
||
- (c >= '\'' && c <= ')')
+ (c >= '\'' && c <= ')')
||
- (c >= '+' && c <= '-')
+ (c >= '+' && c <= '-')
||
(c == '/')
||
- (c == '?')
+ (c == '?')
||
- (c == ' '))
- {
+ (c == ' '))
+ {
return 0;
}
static char trans[4];
trans[0] = '=';
trans[3] = '\0';
int rem = c % 16;
int div = c / 16;
if (div < 10)
trans[1] = '0' + div;
else
trans[1] = 'A' + (div - 10);
if (rem < 10)
trans[2] = '0' + rem;
else
trans[2] = 'A' + (rem - 10);
return trans;
}
static void writeQPString(OFile *fp, const char *s)
{
/*
- only A-Z, 0-9 and
+ only A-Z, 0-9 and
"'" (ASCII code 39)
"(" (ASCII code 40)
")" (ASCII code 41)
"+" (ASCII code 43)
"," (ASCII code 44)
"-" (ASCII code 45)
"/" (ASCII code 47)
"?" (ASCII code 63)
-
+
should remain un-encoded.
'=' needs to be encoded as it is the escape character.
';' needs to be as it is a field separator.
*/
const char *p = s;
while (*p) {
const char *rep = replaceChar(*p);
if (rep)
appendsOFile(fp, rep);
else
appendcOFile(fp, *p);
p++;
}
}
static bool includesUnprintable(VObject *o)
{
if (o) {
if (VALUE_TYPE(o) == VCVT_STRINGZ) {
const char *p = STRINGZ_VALUE_OF(o);
if (p) {
while (*p) {
if (replaceChar(*p))
return TRUE;
p++;
}
}
}
}
return FALSE;
}
-
+
static void writeVObject_(OFile *fp, VObject *o);
static void writeValue(OFile *fp, VObject *o, unsigned long size)
{
if (o == 0) return;
switch (VALUE_TYPE(o)) {
case VCVT_STRINGZ: {
writeQPString(fp, STRINGZ_VALUE_OF(o));
break;
}
case VCVT_UINT: {
char buf[16];
sprintf(buf,"%u", INTEGER_VALUE_OF(o));
appendsOFile(fp,buf);
break;
}
case VCVT_ULONG: {
char buf[16];
sprintf(buf,"%lu", LONG_VALUE_OF(o));
appendsOFile(fp,buf);
break;
}
case VCVT_RAW: {
appendcOFile(fp,'\n');
writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
break;
}
case VCVT_VOBJECT:
appendcOFile(fp,'\n');
writeVObject_(fp,VOBJECT_VALUE_OF(o));
break;
}
}
static void writeAttrValue(OFile *fp, VObject *o)
{
if (NAME_OF(o)) {
struct PreDefProp *pi;
pi = lookupPropInfo(NAME_OF(o));
if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
if ( includesUnprintable(o) ) {
appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
}
appendcOFile(fp,';');
appendsOFile(fp,NAME_OF(o));
}
else
@@ -1184,97 +1184,97 @@ static void writeProp(OFile *fp, VObject *o)
writeVObject_(fp,o);
return;
}
if (isAPropertyOf(o,VCGroupingProp))
writeGroup(fp,o);
else
appendsOFile(fp,NAME_OF(o));
if (pi) fields_ = pi->fields;
initPropIterator(&t,o);
while (moreIteration(&t)) {
const char *s;
VObject *eachProp = nextVObject(&t);
s = NAME_OF(eachProp);
if (qstricmp(VCGroupingProp,s) && !inList(fields_,s))
writeAttrValue(fp,eachProp);
}
if (fields_) {
int i = 0, n = 0;
const char** fields = fields_;
/* output prop as fields */
bool printable = TRUE;
while (*fields && printable) {
VObject *t = isAPropertyOf(o,*fields);
if (includesUnprintable(t))
printable = FALSE;
fields++;
}
fields = fields_;
if (!printable) {
appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
}
appendcOFile(fp,':');
while (*fields) {
VObject *t = isAPropertyOf(o,*fields);
i++;
if (t) n = i;
fields++;
}
fields = fields_;
for (i=0;i<n;i++) {
writeValue(fp,isAPropertyOf(o,*fields),0);
fields++;
if (i<(n-1)) appendcOFile(fp,';');
}
}
}
-
+
if (VALUE_TYPE(o)) {
if ( includesUnprintable(o) ) {
appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
}
unsigned long size = 0;
VObject *p = isAPropertyOf(o,VCDataSizeProp);
if (p) size = LONG_VALUE_OF(p);
appendcOFile(fp,':');
writeValue(fp,o,size);
}
appendcOFile(fp,'\n');
}
static void writeVObject_(OFile *fp, VObject *o)
{
if (NAME_OF(o)) {
struct PreDefProp *pi;
pi = lookupPropInfo(NAME_OF(o));
if (pi && ((pi->flags & PD_BEGIN) != 0)) {
VObjectIterator t;
const char *begin = NAME_OF(o);
appendsOFile(fp,"BEGIN:");
appendsOFile(fp,begin);
appendcOFile(fp,'\n');
initPropIterator(&t,o);
while (moreIteration(&t)) {
VObject *eachProp = nextVObject(&t);
writeProp(fp, eachProp);
}
appendsOFile(fp,"END:");
appendsOFile(fp,begin);
appendsOFile(fp,"\n\n");
}
}
}
void writeVObject(FILE *fp, VObject *o)
{
OFile ofp;
// #####
//_setmode(_fileno(fp), _O_BINARY);
initOFile(&ofp,fp);
writeVObject_(&ofp,o);
}
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "config.h"
#include "datebookmonth.h"
#include "datebookdb.h"
#include <qtopia/private/event.h>
#include "resource.h"
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "timestring.h"
#include <qtoolbutton.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qdatetime.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qvaluestack.h>
#include <qwhatsthis.h>
DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name )
: QHBox( parent, name )
{
setBackgroundMode( PaletteButton );
begin = new QToolButton( this );
begin->setFocusPolicy(NoFocus);
begin->setPixmap( Resource::loadPixmap( "start" ) );
begin->setAutoRaise( TRUE );
begin->setFixedSize( begin->sizeHint() );
QWhatsThis::add( begin, tr("Show January in the selected year") );
back = new QToolButton( this );
back->setFocusPolicy(NoFocus);
back->setPixmap( Resource::loadPixmap( "back" ) );
back->setAutoRaise( TRUE );
back->setFixedSize( back->sizeHint() );
QWhatsThis::add( back, tr("Show the previous month") );
month = new QComboBox( FALSE, this );
for ( int i = 0; i < 12; ++i )
month->insertItem( Calendar::nameOfMonth( i + 1 ) );
year = new QSpinBox( 1752, 8000, 1, this );
next = new QToolButton( this );
next->setFocusPolicy(NoFocus);
next->setPixmap( Resource::loadPixmap( "forward" ) );
next->setAutoRaise( TRUE );
next->setFixedSize( next->sizeHint() );
QWhatsThis::add( next, tr("Show the next month") );
end = new QToolButton( this );
end->setFocusPolicy(NoFocus);
end->setPixmap( Resource::loadPixmap( "finish" ) );
end->setAutoRaise( TRUE );
@@ -509,160 +509,160 @@ DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t )
: QTableItem( table, et, t )
{
d = new DayItemMonthPrivate();
}
DayItemMonth::~DayItemMonth()
{
daysEvents.clear();
delete d;
}
void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv )
{
d->mDayEvents = effEv;
}
void DayItemMonth::clearEffEvents()
{
d->mDayEvents.clear();
}
void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
const QRect &cr, bool selected )
{
p->save();
QColorGroup g( cg );
g.setBrush( QColorGroup::Base, back );
g.setColor( QColorGroup::Text, forg );
if ( selected )
p->setPen( g.highlightedText() );
else
p->setPen( g.text() );
QValueStack<int> normalLine;
QValueStack<int> repeatLine;
QValueStack<int> travelLine;
bool normalAllDay = FALSE;
bool repeatAllDay = FALSE;
bool travelAllDay = FALSE;
QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin();
for ( ; itDays != d->mDayEvents.end(); ++itDays ) {
int w = cr.width();
Event ev = (*itDays).event();
- int f = (*itDays).start().hour(); // assume Effective event
+ int f = (*itDays).start().hour(); // assume Effective event
int t = (*itDays).end().hour(); // is truncated.
- if (ev.isAllDay()) {
+ if (ev.isAllDay()) {
if (!ev.hasRepeat())
normalAllDay = TRUE;
else
repeatAllDay = TRUE;
} else {
int sLine, eLine;
if (f == 0)
sLine = 0;
else if (f < 8 )
sLine = 1;
else if (f >= 17)
sLine = w - 4;
else {
sLine = (f - 8) * (w - 8);
if (sLine)
sLine /= 8;
sLine += 4;
}
if (t == 23)
eLine = w;
else if (t < 8)
eLine = 4;
else if (t >= 17)
eLine = w - 1;
else {
eLine = (t - 8) * (w - 8);
if (eLine)
eLine /= 8;
eLine += 4;
}
if (!ev.hasRepeat()) {
normalLine.push(sLine);
normalLine.push(eLine);
} else {
repeatLine.push(sLine);
repeatLine.push(eLine);
}
}
}
// draw the background
if (normalAllDay || repeatAllDay || travelAllDay) {
p->save();
if (normalAllDay)
if (repeatAllDay) {
p->fillRect( 0, 0, cr.width(), cr.height() / 2,
colorNormalLight );
p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2,
colorRepeatLight );
} else
p->fillRect( 0, 0, cr.width(), cr.height(),
colorNormalLight );
else if (repeatAllDay)
p->fillRect( 0, 0, cr.width(), cr.height(),
colorRepeatLight );
} else {
- p->fillRect( 0, 0, cr.width(),
- cr.height(), selected
- ? g.brush( QColorGroup::Highlight )
+ p->fillRect( 0, 0, cr.width(),
+ cr.height(), selected
+ ? g.brush( QColorGroup::Highlight )
: g.brush( QColorGroup::Base ) );
}
// The lines
// now for the lines.
int h = 5;
int y = cr.height() / 2 - h;
while(normalLine.count() >= 2) {
int x2 = normalLine.pop();
int x1 = normalLine.pop();
if (x2 < x1 + 2)
x2 = x1 + 2;
p->fillRect(x1, y, x2 - x1, h, colorNormal);
}
y += h;
while(repeatLine.count() >= 2) {
int x2 = repeatLine.pop();
int x1 = repeatLine.pop();
if (x2 < x1 + 2)
x2 = x1 + 2;
p->fillRect(x1, y, x2 - x1, h, colorRepeat);
}
// Finally, draw the number.
QFont f = p->font();
f.setPointSize( ( f.pointSize() / 3 ) * 2 );
p->setFont( f );
QFontMetrics fm( f );
p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) );
p->restore();
}
void DayItemMonth::setType( Calendar::Day::Type t )
{
switch ( t ) {
case Calendar::Day::PrevMonth:
case Calendar::Day::NextMonth:
back = QBrush( QColor( 224, 224, 224 ) );
forg = black;
break;
case Calendar::Day::ThisMonth:
@@ -688,63 +688,63 @@ DateButton::DateButton( bool longDate, QWidget *parent, const char * name )
}
void DateButton::pickDate()
{
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
connect( picker, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( setDate( int, int, int ) ) );
connect( picker, SIGNAL( dateClicked( int, int, int ) ),
this, SIGNAL( dateSelected( int, int, int ) ) );
connect( m1, SIGNAL( aboutToHide() ),
this, SLOT( gotHide() ) );
}
picker->slotWeekChange( weekStartsMonday );
picker->setDate( currDate.year(), currDate.month(), currDate.day() );
m1->popup(mapToGlobal(QPoint(0,height())));
picker->setFocus();
}
void DateButton::gotHide()
{
// we have to redo the button...
setDown( false );
}
// void dateSelected( int year, int month, int day );
void DateButton::setWeekStartsMonday( int b )
{
weekStartsMonday = b;
}
void DateButton::setDate( int y, int m, int d )
{
setDate( QDate( y,m,d) );
}
void DateButton::setDate( QDate d )
{
currDate = d;
setText( longFormat ? TimeString::longDateString( d, df ) :
- TimeString::shortDate( d, df ) );
+ TimeString::shortDate( d, df ) );
}
void DateButton::setDateFormat( DateFormat f )
{
df = f;
setDate( currDate );
}
bool DateButton::customWhatsThis() const
{
return TRUE;
}
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
// have this class.
#define QTOPIA_INTERNAL_FSLP
#include "fileselector.h"
#include "fileselector_p.h"
#include "global.h"
#include "resource.h"
#include "config.h"
#include "applnk.h"
#include "storage.h"
#include "qpemenubar.h"
#ifdef QWS
-#include "qcopchannel_qws.h"
+#include <qcopchannel_qws.h>
#endif
#include "lnkproperties.h"
#include "applnk.h"
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "categorymenu.h"
#include "categoryselect.h"
#include "mimetype.h"
-#include "categories.h"
+#include <qpe/categories.h>
#include <stdlib.h>
#include <qdir.h>
#include <qwidget.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qheader.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
class TypeCombo : public QComboBox
{
Q_OBJECT
public:
TypeCombo( QWidget *parent, const char *name=0 )
: QComboBox( parent, name )
{
connect( this, SIGNAL(activated(int)), this, SLOT(selectType(int)) );
}
void reread( DocLnkSet &files, const QString &filter );
signals:
void selected( const QString & );
protected slots:
void selectType( int idx ) {
emit selected( typelist[idx] );
}
protected:
QStringList typelist;
QString prev;
};
void TypeCombo::reread( DocLnkSet &files, const QString &filter )
{
typelist.clear();
QStringList filters = QStringList::split( ';', filter );
int pos = filter.find( '/' );
//### do for each filter
if ( filters.count() == 1 && pos >= 0 && filter[pos+1] != '*' ) {
typelist.append( filter );
clear();
QString minor = filter.mid( pos+1 );
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "fontfactoryinterface.h"
#include "fontdatabase.h"
#include <qpe/qlibrary.h>
#ifdef QWS
#include <qfontmanager_qws.h>
#endif
#include <qdir.h>
#include <qdict.h>
#include <stdio.h>
#include <stdlib.h>
static QString fontDir()
{
QString qtdir = getenv("QTDIR");
if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded";
return qtdir+"/lib/fonts/";
}
#ifdef QT_NO_FONTDATABASE
static QString fontFamily( const QString& key )
{
int u0 = key.find('_');
int u1 = key.find('_',u0+1);
int u2 = key.find('_',u1+1);
QString family = key.left(u0);
//int pointSize = key.mid(u0+1,u1-u0-1).toInt();
//int weight = key.mid(u1+1,u2-u1-1).toInt();
//bool italic = key.mid(u2-1,1) == "i";
// #### ignores _t and _I fields
return family;
}
#endif
QValueList<FontFactory> *FontDatabase::factoryList = 0;
/*!
\class FontDatabase fontdatabase.h
\brief The FontDatabase class provides information about available fonts.
Most often you will simply want to query the database for the
available font families().
Use FontDatabase rather than QFontDatabase when you may need access
to fonts that are not normally available. For example, if the
freetype library and the Qtopia freetype plugin are installed,
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef FONTFACTORY_H
#define FONTFACTORY_H
#include <qpe/fontfactoryinterface.h>
#include <qfontdatabase.h>
#include <qvaluelist.h>
class QLibrary;
struct FontFactory
{
#ifndef QT_NO_COMPONENT
QLibrary *library;
#endif
FontFactoryInterface *interface;
QFontFactory *factory;
};
+#undef QT_NO_FONTDATABASE
class FontDatabase
#ifndef QT_NO_FONTDATABASE
: public QFontDatabase
#endif
{
public:
FontDatabase();
// minimal functionality
QStringList families () const;
#ifdef QT_NO_FONTDATABASE
static QValueList<int> standardSizes ();
#endif
static void loadRenderers();
private:
static void readFonts( QFontFactory *factory );
private:
static QValueList<FontFactory> *factoryList;
};
#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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define QTOPIA_INTERNAL_MIMEEXT
#include "mimetype.h"
#include "applnk.h"
#include "resource.h"
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "config.h"
#include <qfile.h>
#include <qdict.h>
#include <qregexp.h>
#include <qstringlist.h>
#include <qtextstream.h>
#include <qmap.h>
static void cleanupMime()
{
MimeType::clear();
}
class MimeTypeData {
public:
MimeTypeData(const QString& i) :
id(i)
{
apps.setAutoDelete(TRUE);
}
QString id;
QString extension;
QList<AppLnk> apps;
QString description()
{
if ( desc.isEmpty() )
desc = QPEApplication::tr("%1 document").arg(apps.first()->name());
return desc;
}
QPixmap regIcon()
{
if ( regicon.isNull() )
loadPixmaps();
return regicon;
}
QPixmap bigIcon()
{
if ( bigicon.isNull() )
loadPixmaps();
return bigicon;
}
private:
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define protected public
#include <qdialog.h>
#undef protected
#include "qpedialog.h"
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
QPEDialogListener::QPEDialogListener(QDialog *di ) : QObject(di)
{
dialog = di;
connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
this, SLOT(appMessage(const QCString&, const QByteArray&)) );
}
QPEDialogListener::~QPEDialogListener() {}
void QPEDialogListener::appMessage( const QCString &msg, const QByteArray & )
{
- if (!dialog)
+ if (!dialog)
return;
if (msg == "accept()") {
dialog->accept();
} else if (msg == "reject()") {
dialog->reject();
}
}
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 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "qpestyle.h"
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include <qpushbutton.h>
#include <qpainter.h>
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
#if QT_VERSION >= 300
#include <qdrawutil.h>
#include <qcombobox.h>
#include <qtabbar.h>
QPEStyle::QPEStyle()
{
}
QPEStyle::~QPEStyle()
{
}
void QPEStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r,
const QColorGroup &cg, SFlags flags, const QStyleOption &data) const
{
switch ( pe ) {
case PE_ButtonTool:
{
QColorGroup mycg = cg;
if ( flags & Style_On ) {
QBrush fill( cg.mid(), Dense4Pattern );
mycg.setBrush( QColorGroup::Button, fill );
}
drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
break;
}
case PE_ButtonCommand:
case PE_ButtonDefault:
case PE_ButtonBevel:
case PE_HeaderSection:
{
QPen oldPen = p->pen();
p->fillRect( r.x()+1, r.y()+1, r.width()-2, r.height()-2, cg.brush(QColorGroup::Button) );
int x2 = r.right();
int y2 = r.bottom();
if ( flags & (Style_Sunken | Style_Down | Style_On) )
p->setPen( cg.dark() );
else
@@ -179,97 +179,97 @@ void QPEStyle::drawControl( ControlElement ce, QPainter *p,
flags |= Style_Enabled;
if ( btn->isDefault() )
flags |= Style_Default;
if (! btn->isFlat() && !(flags & Style_Down))
flags |= Style_Raised;
p->setPen( cg.foreground() );
p->setBrush( QBrush(cg.button(), NoBrush) );
QColorGroup mycg( cg );
if ( flags & Style_On ) {
QBrush fill = QBrush( cg.mid(), Dense4Pattern );
mycg.setBrush( QColorGroup::Button, fill );
}
drawPrimitive( PE_ButtonBevel, p, r, mycg, flags, data );
break;
}
case CE_TabBarTab:
{
if ( !widget || !widget->parentWidget() )
break;
const QTabBar *tb = (const QTabBar *) widget;
bool selected = how & Style_Selected;
QRect r2(r);
if ( tb->shape() == QTabBar::RoundedAbove ) {
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
if ( r2.left() == 0 )
p->drawPoint( tb->rect().bottomLeft() );
else {
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
}
if ( selected ) {
p->setPen( cg.background() );
p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-2),
cg.brush( QColorGroup::Background ));
} else {
r2.setRect( r2.left() + 2, r2.top() + 2,
r2.width() - 4, r2.height() - 2 );
p->setPen( cg.button() );
p->drawLine( r2.left()+2, r2.top()+1, r2.right()-2, r2.top()+1 );
p->fillRect( QRect( r2.left()+1, r2.top()+2, r2.width()-2, r2.height()-3),
cg.brush( QColorGroup::Button ));
//do shading; will not work for pixmap brushes
- QColor bg = cg.button();
+ QColor bg = cg.button();
// int h,s,v;
// bg.hsv( &h, &s, &v );
int n = r2.height()/2;
int dark = 100;
for ( int i = 1; i < n; i++ ) {
dark = (dark * (100+(i*15)/n) )/100;
p->setPen( bg.dark( dark ) );
int y = r2.bottom()-n+i;
int x1 = r2.left()+1;
int x2 = r2.right()-1;
p->drawLine( x1, y, x2, y );
}
}
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.bottom()-1, r2.left(), r2.top() + 2 );
p->drawPoint( r2.left()+1, r2.top() + 1 );
p->drawLine( r2.left()+2, r2.top(),
r2.right() - 2, r2.top() );
p->setPen( cg.dark() );
p->drawPoint( r2.right() - 1, r2.top() + 1 );
p->drawLine( r2.right(), r2.top() + 2, r2.right(), r2.bottom() - 1);
} else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( selected ) {
p->setPen( cg.background() );
p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-2, r2.height()-2),
tb->palette().normal().brush( QColorGroup::Background ));
} else {
p->setPen( cg.dark() );
p->drawLine( r2.left(), r2.top(),
r2.right(), r2.top() );
r2.setRect( r2.left() + 2, r2.top(),
r2.width() - 4, r2.height() - 2 );
p->setPen( cg.button() );
p->drawLine( r2.left()+2, r2.bottom()-1, r2.right()-2, r2.bottom()-1 );
p->fillRect( QRect( r2.left()+1, r2.top()+1, r2.width()-2, r2.height()-3),
tb->palette().normal().brush( QColorGroup::Button ));
}
p->setPen( cg.dark() );
p->drawLine( r2.right(), r2.top(),
r2.right(), r2.bottom() - 2 );
p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
p->drawLine( r2.right() - 2, r2.bottom(),
r2.left() + 2, r2.bottom() );
@@ -488,98 +488,98 @@ int QPEStyle::defaultFrameWidth() const
void QPEStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill )
{
qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill );
}
void QPEStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill )
{
QPen oldPen = p->pen();
if ( sunken )
p->setPen( g.dark() );
else
p->setPen( g.light() );
int x2 = x+w-1;
int y2 = y+h-1;
p->drawLine( x, y, x, y2 );
p->drawLine( x, y, x2, y );
if ( sunken )
p->setPen( g.light() );
else
p->setPen( g.dark() );
p->drawLine( x2, y, x2, y2 );
p->drawLine( x, y2, x2, y2 );
p->setPen( oldPen );
p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
}
void QPEStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
{
p->fillRect( x, y, w, h, color1 );
}
void QPEStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill )
{
drawButton( p, x, y, w, h, g, sunken, fill );
}
QRect QPEStyle::comboButtonRect( int x, int y, int w, int h)
{
return QRect(x+1, y+1, w-2-14, h-2);
}
-
-
+
+
QRect QPEStyle::comboButtonFocusRect( int x, int y, int w, int h)
{
return QRect(x+2, y+2, w-4-14, h-4);
}
void QPEStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool /*editable*/,
bool enabled,
const QBrush *fill )
{
drawBevelButton( p, x, y, w, h, g, FALSE, fill );
drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
drawArrow( p, QStyle::DownArrow, sunken,
x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
&g.brush( QColorGroup::Button ) );
}
void QPEStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
int h, const QColorGroup & g, bool on, bool down, bool enabled )
{
static const QCOORD pts1[] = { // dark lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const QCOORD pts4[] = { // white lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
static const QCOORD pts5[] = { // inner fill
4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
p->eraseRect( x, y, w, h );
QPointArray a( QCOORDARRLEN(pts1), pts1 );
a.translate( x, y );
p->setPen( g.dark() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts4), pts4 );
a.translate( x, y );
p->setPen( g.light() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts5), pts5 );
a.translate( x, y );
QColor fillColor = ( down || !enabled ) ? g.button() : g.base();
p->setPen( fillColor );
p->setBrush( fillColor ) ;
p->drawPolygon( a );
if ( on ) {
p->setPen( NoPen );
@@ -873,97 +873,97 @@ void QPEStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
if ( o == Horizontal )
p->fillRect( x, y+a, w, h-a-b, color1 );
else
p->fillRect( x+a, y, w-a-b, h, color1 );
}
/*!\reimp
*/
void QPEStyle::drawSliderGrooveMask( QPainter *p,
int x, int y, int w, int h,
const QColorGroup& , QCOORD c,
Orientation orient )
{
if ( orient == Horizontal )
p->fillRect( x, y + c - 2, w, 4, color1 );
else
p->fillRect( x + c - 2, y, 4, h, color1 );
}
void QPEStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
{
QRect r( t->rect() );
if ( tb->shape() == QTabBar::RoundedAbove ) {
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
if ( r.left() == 0 )
p->drawPoint( tb->rect().bottomLeft() );
else {
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
}
if ( selected ) {
p->setPen( tb->colorGroup().background() );
p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
tb->colorGroup().brush( QColorGroup::Background ));
} else {
r.setRect( r.left() + 2, r.top() + 2,
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
tb->colorGroup().brush( QColorGroup::Button ));
//do shading; will not work for pixmap brushes
- QColor bg = tb->colorGroup().button();
+ QColor bg = tb->colorGroup().button();
// int h,s,v;
// bg.hsv( &h, &s, &v );
int n = r.height()/2;
int dark = 100;
for ( int i = 1; i < n; i++ ) {
dark = (dark * (100+(i*15)/n) )/100;
p->setPen( bg.dark( dark ) );
int y = r.bottom()-n+i;
int x1 = r.left()+1;
int x2 = r.right()-1;
p->drawLine( x1, y, x2, y );
}
}
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
p->drawPoint( r.left()+1, r.top() + 1 );
p->drawLine( r.left()+2, r.top(),
r.right() - 2, r.top() );
p->setPen( tb->colorGroup().dark() );
p->drawPoint( r.right() - 1, r.top() + 1 );
p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
} else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( selected ) {
p->setPen( tb->colorGroup().background() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
tb->palette().normal().brush( QColorGroup::Background ));
} else {
p->setPen( tb->colorGroup().dark() );
p->drawLine( r.left(), r.top(),
r.right(), r.top() );
r.setRect( r.left() + 2, r.top(),
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
tb->palette().normal().brush( QColorGroup::Button ));
}
p->setPen( tb->colorGroup().dark() );
p->drawLine( r.right(), r.top(),
r.right(), r.bottom() - 2 );
p->drawPoint( r.right() - 1, r.bottom() - 1 );
p->drawLine( r.right() - 2, r.bottom(),
r.left() + 2, r.bottom() );
@@ -983,119 +983,119 @@ static const int motifItemFrame = 0; // menu item frame width
static const int motifSepHeight = 2; // separator item height
static const int motifItemHMargin = 1; // menu item hor text margin
static const int motifItemVMargin = 2; // menu item ver text margin
static const int motifArrowHMargin = 0; // arrow horizontal margin
static const int motifTabSpacing = 12; // space between text and tab
static const int motifCheckMarkHMargin = 1; // horiz. margins of check mark
static const int windowsRightBorder = 8; // right border on windows
static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
/*! \reimp
*/
int QPEStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
{
#ifndef QT_NO_MENUDATA
int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
if ( mi->isSeparator() )
return 10; // arbitrary
else if ( mi->pixmap() )
w += mi->pixmap()->width(); // pixmap only
if ( !mi->text().isNull() ) {
if ( mi->text().find('\t') >= 0 ) // string contains tab
w += motifTabSpacing;
}
if ( maxpmw ) { // we have iconsets
w += maxpmw;
w += 6; // add a little extra border around the iconset
}
if ( checkable && maxpmw < windowsCheckMarkWidth ) {
w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
}
if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
w += motifCheckMarkHMargin; // add space to separate the columns
w += windowsRightBorder; // windows has a strange wide border on the right side
return w;
#endif
}
/*! \reimp
*/
int QPEStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
int h = 0;
if ( mi->isSeparator() ) // separator height
h = motifSepHeight;
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
}
if ( mi->custom() )
h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
return h;
#endif
}
void QPEStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
const QPalette& pal,
bool act, bool enabled, int x, int y, int w, int h)
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
const QColorGroup & g = pal.active();
bool dis = !enabled;
QColorGroup itemg = dis ? pal.disabled() : pal.active();
if ( checkable )
maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
int checkcol = maxpmw;
if ( mi && mi->isSeparator() ) { // draw separator
p->setPen( g.dark() );
p->drawLine( x, y, x+w, y );
p->setPen( g.light() );
p->drawLine( x, y+1, x+w, y+1 );
return;
}
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x, y, w, h, fill);
if ( !mi )
return;
if ( mi->isChecked() ) {
if ( act && !dis ) {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Button ) );
} else {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
}
} else if ( !act ) {
p->fillRect(x, y, checkcol , h,
g.brush( QColorGroup::Button ));
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !dis )
mode = QIconSet::Active;
QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define QTOPIA_INTERNAL_MIMEEXT
-#include "qpeapplication.h"
+#include <qpe/qpeapplication.h>
#include "resource.h"
#include "mimetype.h"
#include <qdir.h>
#include <qfile.h>
#include <qregexp.h>
#include <qpixmapcache.h>
#include <qpainter.h>
// this namespace is just a workaround for a gcc bug
// gcc exports inline functions in the generated file
// inlinepics_p.h
namespace {
#include "inlinepics_p.h"
}
/*!
\class Resource resource.h
\brief The Resource class provides access to named resources.
The resources may be provided from files or other sources.
The allSounds() function returns a list of all the sounds available.
A particular sound can be searched for using findSound().
Images can be loaded with loadImage(), loadPixmap(), loadBitmap()
and loadIconSet().
\ingroup qtopiaemb
*/
/*!
\fn Resource::Resource()
\internal
*/
/*!
Returns the QPixmap called \a pix. You should avoid including
any filename type extension (e.g. .png, .xpm).
*/
QPixmap Resource::loadPixmap( const QString &pix )
{
QPixmap pm;
QString key="QPE_"+pix;
if ( !QPixmapCache::find(key,pm) ) {
pm.convertFromImage(loadImage(pix));
QPixmapCache::insert(key,pm);
}
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "timestring.h"
#include <qobject.h>
-#include "qpeapplication.h" //for qApp
+#include <qpe/qpeapplication.h> //for qApp
#include "config.h"
class TimeStringFormatKeeper : public QObject
{
Q_OBJECT
public:
static DateFormat currentFormat()
{
if ( !self )
self = new TimeStringFormatKeeper;
return self->format;
}
private slots:
void formatChanged( DateFormat f )
{
format = f;
}
private:
static TimeStringFormatKeeper *self;
DateFormat format;
TimeStringFormatKeeper()
: QObject( qApp )
{
Config config("qpe");
config.setGroup( "Date" );
format = DateFormat(QChar(config.readEntry("Separator", "/")[0]),
- (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
+ (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
(DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ),
this, SLOT( formatChanged( DateFormat ) ) );
}
};
TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0;
QString DateFormat::toNumberString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_shortOrder >> (i * 3)) & 0x0007) {
+ switch((_shortOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "D" );
break;
case 0x0002:
buf += QObject::tr( "M" );
break;
case 0x0004:
buf += QObject::tr( "Y" );
break;
}
if (i < 2)
buf += _shortSeparator;
}
return buf;
}
QString DateFormat::toWordString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_longOrder >> (i * 3)) & 0x0007) {
+ switch((_longOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "day" );
- if (i < 2) {
+ if (i < 2) {
if ((_shortOrder << ((i+1) * 3)) & 0x0007)
buf += ", ";
- else
+ else
buf += " ";
}
break;
case 0x0002:
buf += QObject::tr( "month" );
- if (i < 2)
+ if (i < 2)
buf += " ";
break;
case 0x0004:
buf += QObject::tr( "year" );
- if (i < 2)
+ if (i < 2)
buf += ", ";
break;
}
}
return buf;
}
QString DateFormat::numberDate(const QDate &d, int v) const
{
QString buf = "";
int pad = 2;
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_shortOrder >> (i * 3)) & 0x0007) {
+ switch((_shortOrder >> (i * 3)) & 0x0007) {
case 0x0001:
if (pad==2) buf += QString().sprintf("%02d",d.day());
else buf += QString().sprintf("%d",d.day());
break;
case 0x0002:
if (i==0) { // no padding with only MM/DD/YY format
pad=0;
}
if (pad==2) buf += QString().sprintf("%02d",d.month());
else buf += QString().sprintf("%d",d.month());
break;
case 0x0004:
{
int year = d.year();
if (!(v & longNumber))
year = year % 100;
buf += QString().sprintf("%02d",year);
}
break;
}
if (i < 2)
buf += _shortSeparator;
}
return buf;
}
QString DateFormat::wordDate(const QDate &d, int v) const
{
QString buf = "";
// for each part of the order
if (v & showWeekDay) {
QString weekDay = d.dayName(d.dayOfWeek());
if (!(v & longWord)) {
weekDay = weekDay.left(3);
}
buf += weekDay;
if ((_longOrder & 0x0007) == 0x0002)
buf += ' ';
- else
+ else
buf += ", ";
}
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
- switch((_longOrder >> (i * 3)) & 0x0007) {
+ switch((_longOrder >> (i * 3)) & 0x0007) {
case 0x0001:
if (i==1) {
buf += QString().sprintf("%02d, ",d.day());
} else {
buf += QString().sprintf("%2d",d.day());
- if (separator()=='.') // 2002/1/11
+ if (separator()=='.') // 2002/1/11
buf += ". ";
- else
+ else
buf += " ";
}
break;
case 0x0002:
{
QString monthName = d.monthName(d.month());
if (!(v & longWord)) {
monthName = monthName.left(3);
}
buf += monthName;
}
- if (i < 2)
+ if (i < 2)
buf += " ";
break;
case 0x0004:
{
int year = d.year();
if (!(v & longNumber))
year = year % 100;
if (year < 10)
buf += "0";
buf += QString::number(year);
}
- if (i < 2)
+ if (i < 2)
buf += ", ";
break;
}
}
return buf;
}
#ifndef QT_NO_DATASTREAM
void DateFormat::save(QDataStream &d) const
{
d << _shortSeparator.unicode();
uint v= _shortOrder;
d << v;
v = _longOrder;
d << v;
}
-void DateFormat::load(QDataStream &d)
+void DateFormat::load(QDataStream &d)
{
ushort value;
d >> value;
_shortSeparator = QChar(value);
uint v = 0;
d >> v;
_shortOrder = (Order)v;
v = 0;
d >> v;
_longOrder = (Order)v;
}
QDataStream &operator<<(QDataStream &s, const DateFormat&df)
{
df.save(s);
return s;
}
QDataStream &operator>>(QDataStream &s, DateFormat&df)
{
df.load(s);
return s;
}
#endif
QString TimeString::shortDate( const QDate &d, DateFormat dtf )
{
return dtf.wordDate(d);
}
QString TimeString::dateString( const QDate &d, DateFormat dtf )
{
return dtf.wordDate(d, DateFormat::longNumber | DateFormat::longWord);
}
QString TimeString::longDateString( const QDate &d, DateFormat dtf )
{
- return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber
+ return dtf.wordDate(d, DateFormat::showWeekDay | DateFormat::longNumber
| DateFormat::longWord);
}
DateFormat TimeString::currentDateFormat()
{
return TimeStringFormatKeeper::currentFormat();
}
QString TimeString::dateString( const QDateTime &dt, bool ampm, bool seconds, DateFormat dtf )
{
const QDate& d = dt.date();
const QTime& t = dt.time();
// based on QDateTime::toString()
QString buf = timeString(t,ampm,seconds);
buf += " ";
buf += longDateString( d, dtf );
return buf;
}
QString TimeString::timeString( const QTime &t, bool ampm, bool seconds )
{
if ( !ampm ) {
if ( seconds )
return t.toString();
QString r = QString::number(t.hour());
if ( t.hour() < 10 ) r.prepend( "0" );
r.append( ":" );
if ( t.minute() < 10 ) r.append( "0" );
r.append(QString::number(t.minute()));
return r;
}
// ### else the hard case that should disappear in Qt 3.0
QString argString = seconds ? "%4:%5:%6 %7" : "%4:%5 %7";
int hour = t.hour();
QString strMin = QString::number( t.minute() );
QString strSec = QString::number( t.second() );
if ( hour > 12 )
argString = argString.arg( hour - 12, 2 );
else {
if ( hour == 0 )
argString = argString.arg( 12 );
else
argString = argString.arg( hour, 2 );
}
if ( t.minute() < 10 )