author | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
commit | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (unidiff) | |
tree | 9a784686c1795f8b1f81eb344598f3b549d43467 /library | |
parent | dfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff) | |
download | opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2 |
Backing out unintentional merge from TT branch.
-rw-r--r-- | library/alarmserver.h | 3 | ||||
-rw-r--r-- | library/applnk.h | 3 | ||||
-rw-r--r-- | library/backend/categories.cpp | 146 | ||||
-rw-r--r-- | library/backend/categories.h | 12 | ||||
-rw-r--r-- | library/backend/contact.cpp | 107 | ||||
-rw-r--r-- | library/backend/contact.h | 7 | ||||
-rw-r--r-- | library/backend/event.h | 5 | ||||
-rw-r--r-- | library/backend/recordfields.h | 46 | ||||
-rw-r--r-- | library/backend/task.h | 4 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 9 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 3 | ||||
-rw-r--r-- | library/categoryedit_p.cpp | 6 | ||||
-rw-r--r-- | library/categoryselect.cpp | 185 | ||||
-rw-r--r-- | library/categoryselect.h | 26 | ||||
-rw-r--r-- | library/config.cpp | 13 | ||||
-rw-r--r-- | library/custom-linux-sharp-g++.h | 147 | ||||
-rw-r--r-- | library/datebookmonth.h | 1 | ||||
-rw-r--r-- | library/fileselector.h | 32 | ||||
-rw-r--r-- | library/finddialog.cpp | 4 | ||||
-rw-r--r-- | library/finddialog.h | 11 | ||||
-rw-r--r-- | library/mimetype.cpp | 19 | ||||
-rw-r--r-- | library/mimetype.h | 5 | ||||
-rw-r--r-- | library/network.cpp | 19 | ||||
-rw-r--r-- | library/power.cpp | 2 | ||||
-rw-r--r-- | library/qcopmessage_qws.h | 99 | ||||
-rw-r--r-- | library/qpedecoration_qws.cpp | 9 |
26 files changed, 432 insertions, 491 deletions
diff --git a/library/alarmserver.h b/library/alarmserver.h index 665c3ae..f12a63d 100644 --- a/library/alarmserver.h +++ b/library/alarmserver.h | |||
@@ -1,35 +1,38 @@ | |||
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 | #ifndef ALARM_SERVER_H | 20 | #ifndef ALARM_SERVER_H |
21 | #define ALARM_SERVER_H | 21 | #define ALARM_SERVER_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | class AlarmServer | 26 | class AlarmServer |
27 | { | 27 | { |
28 | public: | 28 | public: |
29 | static void addAlarm ( QDateTime when, const QCString& channel, const QCString& msg, int data=0); | 29 | static void addAlarm ( QDateTime when, const QCString& channel, const QCString& msg, int data=0); |
30 | static void deleteAlarm (QDateTime when, const QCString& channel, const QCString& msg, int data=0); | 30 | static void deleteAlarm (QDateTime when, const QCString& channel, const QCString& msg, int data=0); |
31 | |||
32 | private: | ||
33 | friend int initApplication(int, char **); | ||
31 | static void initialize(); | 34 | static void initialize(); |
32 | }; | 35 | }; |
33 | 36 | ||
34 | #endif | 37 | #endif |
35 | 38 | ||
diff --git a/library/applnk.h b/library/applnk.h index c6f92a3..18e20b6 100644 --- a/library/applnk.h +++ b/library/applnk.h | |||
@@ -1,169 +1,172 @@ | |||
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 | #ifndef __APPLNK_H__ | 20 | #ifndef __APPLNK_H__ |
21 | #define __APPLNK_H__ | 21 | #define __APPLNK_H__ |
22 | 22 | ||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qiconset.h> | 24 | #include <qiconset.h> |
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | class AppLnkSetPrivate; | 29 | class AppLnkSetPrivate; |
30 | class AppLnkPrivate; | 30 | class AppLnkPrivate; |
31 | 31 | ||
32 | class AppLnk | 32 | class AppLnk |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | AppLnk(); | 35 | AppLnk(); |
36 | AppLnk( const QString &file ); | 36 | AppLnk( const QString &file ); |
37 | AppLnk( const AppLnk © ); // copy constructor | 37 | AppLnk( const AppLnk © ); // copy constructor |
38 | virtual ~AppLnk(); | 38 | virtual ~AppLnk(); |
39 | 39 | ||
40 | bool isValid() const { return !mLinkFile.isNull(); } | 40 | bool isValid() const { return !mLinkFile.isNull(); } |
41 | 41 | ||
42 | static void setSmallIconSize(int); | 42 | static void setSmallIconSize(int); |
43 | static void setBigIconSize(int); | 43 | static void setBigIconSize(int); |
44 | static int smallIconSize(); | 44 | static int smallIconSize(); |
45 | static int bigIconSize(); | 45 | static int bigIconSize(); |
46 | 46 | ||
47 | QString name() const { return mName; } | 47 | QString name() const { return mName; } |
48 | const QPixmap& pixmap() const; | 48 | const QPixmap& pixmap() const; |
49 | const QPixmap& bigPixmap() const; | 49 | const QPixmap& bigPixmap() const; |
50 | virtual QString exec() const { return mExec; } | 50 | virtual QString exec() const { return mExec; } |
51 | QString type() const; | 51 | QString type() const; |
52 | QString rotation() const { return mRotation; } | 52 | QString rotation() const { return mRotation; } |
53 | QString comment() const { return mComment; } | 53 | QString comment() const { return mComment; } |
54 | QString file() const; | 54 | QString file() const; |
55 | QString linkFile() const; | 55 | QString linkFile() const; |
56 | QStringList mimeTypes() const { return mMimeTypes; } | 56 | QStringList mimeTypes() const { return mMimeTypes; } |
57 | QStringList mimeTypeIcons() const { return mMimeTypeIcons; } | 57 | QStringList mimeTypeIcons() const { return mMimeTypeIcons; } |
58 | const QArray<int> &categories() const; | 58 | const QArray<int> &categories() const; |
59 | int id() const { return mId; } | 59 | int id() const { return mId; } |
60 | 60 | ||
61 | bool linkFileKnown() const { return !mLinkFile.isNull(); } | ||
62 | |||
61 | void execute() const; | 63 | void execute() const; |
62 | void execute(const QStringList& args) const; | 64 | void execute(const QStringList& args) const; |
63 | void removeFiles(); | 65 | void removeFiles(); |
64 | void removeLinkFile(); | 66 | void removeLinkFile(); |
65 | 67 | ||
66 | void setName( const QString& docname ); | 68 | void setName( const QString& docname ); |
67 | void setExec( const QString& exec ); | 69 | void setExec( const QString& exec ); |
68 | void setFile( const QString& filename ); | 70 | void setFile( const QString& filename ); |
69 | void setLinkFile( const QString& filename ); | 71 | void setLinkFile( const QString& filename ); |
70 | void setComment( const QString& comment ); | 72 | void setComment( const QString& comment ); |
71 | void setType( const QString& mimetype ); | 73 | void setType( const QString& mimetype ); |
72 | void setIcon( const QString& iconname ); | 74 | void setIcon( const QString& iconname ); |
73 | void setCategories( const QArray<int> &v ); | 75 | void setCategories( const QArray<int> &v ); |
74 | bool writeLink() const; | 76 | bool writeLink() const; |
75 | 77 | ||
76 | void setProperty(const QString& key, const QString& value); | 78 | void setProperty(const QString& key, const QString& value); |
77 | QString property(const QString& key) const; | 79 | QString property(const QString& key) const; |
78 | 80 | ||
79 | protected: | 81 | protected: |
80 | QString mName; | 82 | QString mName; |
81 | QPixmap mPixmap; | 83 | QPixmap mPixmap; |
82 | QPixmap mBigPixmap; | 84 | QPixmap mBigPixmap; |
83 | QString mExec; | 85 | QString mExec; |
84 | QString mType; | 86 | QString mType; |
85 | QString mRotation; | 87 | QString mRotation; |
86 | QString mComment; | 88 | QString mComment; |
87 | QString mFile; | 89 | QString mFile; |
88 | QString mLinkFile; | 90 | QString mLinkFile; |
89 | QString mIconFile; | 91 | QString mIconFile; |
90 | QStringList mMimeTypes; | 92 | QStringList mMimeTypes; |
91 | QStringList mMimeTypeIcons; | 93 | QStringList mMimeTypeIcons; |
92 | int mId; | 94 | int mId; |
93 | static int lastId; | 95 | static int lastId; |
94 | AppLnkPrivate *d; | 96 | AppLnkPrivate *d; |
95 | friend class AppLnkSet; | 97 | friend class AppLnkSet; |
96 | 98 | ||
97 | virtual void invoke(const QStringList& args) const; | 99 | virtual void invoke(const QStringList& args) const; |
98 | bool ensureLinkExists() const; | 100 | bool ensureLinkExists() const; |
101 | void storeLink() const; | ||
99 | }; | 102 | }; |
100 | 103 | ||
101 | class DocLnk : public AppLnk | 104 | class DocLnk : public AppLnk |
102 | { | 105 | { |
103 | public: | 106 | public: |
104 | DocLnk(); | 107 | DocLnk(); |
105 | DocLnk( const DocLnk &o ) : AppLnk(o) { } | 108 | DocLnk( const DocLnk &o ) : AppLnk(o) { } |
106 | DocLnk( const QString &file ); | 109 | DocLnk( const QString &file ); |
107 | DocLnk( const QString &file, bool may_be_desktopfile ); | 110 | DocLnk( const QString &file, bool may_be_desktopfile ); |
108 | virtual ~DocLnk(); | 111 | virtual ~DocLnk(); |
109 | 112 | ||
110 | QString exec() const; | 113 | QString exec() const; |
111 | 114 | ||
112 | protected: | 115 | protected: |
113 | void invoke(const QStringList& args) const; | 116 | void invoke(const QStringList& args) const; |
114 | 117 | ||
115 | private: | 118 | private: |
116 | void init(const QString &file); | 119 | void init(const QString &file); |
117 | }; | 120 | }; |
118 | 121 | ||
119 | class AppLnkSet | 122 | class AppLnkSet |
120 | { | 123 | { |
121 | public: | 124 | public: |
122 | AppLnkSet(); | 125 | AppLnkSet(); |
123 | AppLnkSet( const QString &dir ); | 126 | AppLnkSet( const QString &dir ); |
124 | ~AppLnkSet(); | 127 | ~AppLnkSet(); |
125 | 128 | ||
126 | const AppLnk *find( int id ) const; | 129 | const AppLnk *find( int id ) const; |
127 | const AppLnk *findExec( const QString& execname ) const; | 130 | const AppLnk *findExec( const QString& execname ) const; |
128 | 131 | ||
129 | QStringList types() const { return typs; } | 132 | QStringList types() const { return typs; } |
130 | QString typeName( const QString& ) const; | 133 | QString typeName( const QString& ) const; |
131 | QPixmap typePixmap( const QString& ) const; | 134 | QPixmap typePixmap( const QString& ) const; |
132 | QPixmap typeBigPixmap( const QString& ) const; | 135 | QPixmap typeBigPixmap( const QString& ) const; |
133 | 136 | ||
134 | void add(AppLnk*); | 137 | void add(AppLnk*); |
135 | bool remove(AppLnk*); | 138 | bool remove(AppLnk*); |
136 | 139 | ||
137 | const QList<AppLnk> &children() const { return mApps; } | 140 | const QList<AppLnk> &children() const { return mApps; } |
138 | void detachChildren(); | 141 | void detachChildren(); |
139 | 142 | ||
140 | protected: | 143 | protected: |
141 | friend class AppLnk; | 144 | friend class AppLnk; |
142 | QList<AppLnk> mApps; | 145 | QList<AppLnk> mApps; |
143 | QString mFile; | 146 | QString mFile; |
144 | QStringList typs; | 147 | QStringList typs; |
145 | AppLnkSetPrivate *d; | 148 | AppLnkSetPrivate *d; |
146 | 149 | ||
147 | private: | 150 | private: |
148 | AppLnkSet( const AppLnkSet & ); // no copying! | 151 | AppLnkSet( const AppLnkSet & ); // no copying! |
149 | void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); | 152 | void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); |
150 | }; | 153 | }; |
151 | 154 | ||
152 | class DocLnkSet : public AppLnkSet | 155 | class DocLnkSet : public AppLnkSet |
153 | { | 156 | { |
154 | public: | 157 | public: |
155 | DocLnkSet(); | 158 | DocLnkSet(); |
156 | DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); | 159 | DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); |
157 | 160 | ||
158 | const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } | 161 | const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } |
159 | 162 | ||
160 | void appendFrom( DocLnkSet& other ); | 163 | void appendFrom( DocLnkSet& other ); |
161 | 164 | ||
162 | private: | 165 | private: |
163 | DocLnkSet( const DocLnkSet & ); // no copying! | 166 | DocLnkSet( const DocLnkSet & ); // no copying! |
164 | void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); | 167 | void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); |
165 | }; | 168 | }; |
166 | 169 | ||
167 | 170 | ||
168 | #endif // __APPLNK_H__ | 171 | #endif // __APPLNK_H__ |
169 | 172 | ||
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index 91331db..6e011c4 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp | |||
@@ -1,701 +1,677 @@ | |||
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 | 7 | ** GNU General Public License version 2 as published by the Free |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Software Foundation and appearing in the file LICENSE.GPL included |
9 | ** in the packaging of this file. | 9 | ** in the packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A |
13 | ** PARTICULAR PURPOSE. | 13 | ** PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | #include "categories.h" | 21 | #include "categories.h" |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcstring.h> | 23 | #include <qcstring.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | #include "stringutil.h" | 25 | #include "stringutil.h" |
26 | 26 | ||
27 | using namespace Qtopia; | 27 | using namespace Qtopia; |
28 | 28 | ||
29 | /*********************************************************** | 29 | /*********************************************************** |
30 | * | 30 | * |
31 | * CategoryGroup | 31 | * CategoryGroup |
32 | * | 32 | * |
33 | **********************************************************/ | 33 | **********************************************************/ |
34 | 34 | ||
35 | #ifdef PALMTOPCENTER | 35 | #ifdef PALMTOPCENTER |
36 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); | 36 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); |
37 | #else | 37 | #else |
38 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); | 38 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | int CategoryGroup::add( const QString &label ) | 41 | int CategoryGroup::add( const QString &label ) |
42 | { | 42 | { |
43 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 43 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
44 | return 0; | 44 | return 0; |
45 | 45 | ||
46 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 46 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
47 | if ( findIt != mLabelIdMap.end() ) | 47 | if ( findIt != mLabelIdMap.end() ) |
48 | return 0; | 48 | return 0; |
49 | int newUid = uidGen().generate(); | 49 | int newUid = uidGen().generate(); |
50 | insert( newUid, label ); | 50 | insert( newUid, label ); |
51 | return newUid; | 51 | return newUid; |
52 | } | 52 | } |
53 | 53 | ||
54 | void CategoryGroup::insert( int uid, const QString &label ) | 54 | void CategoryGroup::insert( int uid, const QString &label ) |
55 | { | 55 | { |
56 | uidGen().store( uid ); | 56 | uidGen().store( uid ); |
57 | mIdLabelMap[uid] = label; | 57 | mIdLabelMap[uid] = label; |
58 | mLabelIdMap[label] = uid; | 58 | mLabelIdMap[label] = uid; |
59 | } | 59 | } |
60 | 60 | ||
61 | bool CategoryGroup::add( int uid, const QString &label ) | 61 | bool CategoryGroup::add( int uid, const QString &label ) |
62 | { | 62 | { |
63 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 63 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
64 | return FALSE; | 64 | return FALSE; |
65 | 65 | ||
66 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 66 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
67 | if ( labelIt != mLabelIdMap.end() ) | 67 | if ( labelIt != mLabelIdMap.end() ) |
68 | return FALSE; | 68 | return FALSE; |
69 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 69 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
70 | if ( idIt != mIdLabelMap.end() ) | 70 | if ( idIt != mIdLabelMap.end() ) |
71 | return FALSE; | 71 | return FALSE; |
72 | insert( uid, label ); | 72 | insert( uid, label ); |
73 | return TRUE; | 73 | return TRUE; |
74 | } | 74 | } |
75 | 75 | ||
76 | bool CategoryGroup::remove( const QString &label ) | 76 | bool CategoryGroup::remove( const QString &label ) |
77 | { | 77 | { |
78 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 78 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
79 | if ( findIt == mLabelIdMap.end() ) | 79 | if ( findIt == mLabelIdMap.end() ) |
80 | return FALSE; | 80 | return FALSE; |
81 | 81 | ||
82 | mIdLabelMap.remove( *findIt ); | 82 | mIdLabelMap.remove( *findIt ); |
83 | mLabelIdMap.remove( findIt ); | 83 | mLabelIdMap.remove( findIt ); |
84 | 84 | ||
85 | return TRUE; | 85 | return TRUE; |
86 | } | 86 | } |
87 | 87 | ||
88 | bool CategoryGroup::remove( int uid ) | 88 | bool CategoryGroup::remove( int uid ) |
89 | { | 89 | { |
90 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); | 90 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); |
91 | if ( idIt == mIdLabelMap.end() ) | 91 | if ( idIt == mIdLabelMap.end() ) |
92 | return FALSE; | 92 | return FALSE; |
93 | 93 | ||
94 | mLabelIdMap.remove( *idIt ); | 94 | mLabelIdMap.remove( *idIt ); |
95 | mIdLabelMap.remove( idIt ); | 95 | mIdLabelMap.remove( idIt ); |
96 | 96 | ||
97 | return TRUE; | 97 | return TRUE; |
98 | } | 98 | } |
99 | 99 | ||
100 | bool CategoryGroup::rename( int uid, const QString &newLabel ) | 100 | bool CategoryGroup::rename( int uid, const QString &newLabel ) |
101 | { | 101 | { |
102 | if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) | 102 | if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) |
103 | return FALSE; | 103 | return FALSE; |
104 | 104 | ||
105 | QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid ); | 105 | QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid ); |
106 | if ( idIt == mIdLabelMap.end() ) | 106 | if ( idIt == mIdLabelMap.end() ) |
107 | return FALSE; | 107 | return FALSE; |
108 | 108 | ||
109 | mLabelIdMap.remove( *idIt ); | 109 | mLabelIdMap.remove( *idIt ); |
110 | mLabelIdMap[newLabel] = uid; | 110 | mLabelIdMap[newLabel] = uid; |
111 | *idIt = newLabel; | 111 | *idIt = newLabel; |
112 | 112 | ||
113 | return TRUE; | 113 | return TRUE; |
114 | } | 114 | } |
115 | 115 | ||
116 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) | 116 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) |
117 | { | 117 | { |
118 | return rename( id(oldLabel), newLabel ); | 118 | return rename( id(oldLabel), newLabel ); |
119 | } | 119 | } |
120 | 120 | ||
121 | bool CategoryGroup::contains(int uid) const | 121 | bool CategoryGroup::contains(int uid) const |
122 | { | 122 | { |
123 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); | 123 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | bool CategoryGroup::contains(const QString &label) const | 126 | bool CategoryGroup::contains(const QString &label) const |
127 | { | 127 | { |
128 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); | 128 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); |
129 | } | 129 | } |
130 | 130 | ||
131 | /** Returns label associated with the uid or QString::null if | 131 | /** Returns label associated with the uid or QString::null if |
132 | * not found | 132 | * not found |
133 | */ | 133 | */ |
134 | const QString &CategoryGroup::label(int uid) const | 134 | const QString &CategoryGroup::label(int uid) const |
135 | { | 135 | { |
136 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 136 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
137 | if ( idIt == mIdLabelMap.end() ) | 137 | if ( idIt == mIdLabelMap.end() ) |
138 | return QString::null; | 138 | return QString::null; |
139 | return *idIt; | 139 | return *idIt; |
140 | } | 140 | } |
141 | 141 | ||
142 | /** Returns the uid associated with label or 0 if not found */ | 142 | /** Returns the uid associated with label or 0 if not found */ |
143 | int CategoryGroup::id(const QString &label) const | 143 | int CategoryGroup::id(const QString &label) const |
144 | { | 144 | { |
145 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 145 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
146 | if ( labelIt == mLabelIdMap.end() ) | 146 | if ( labelIt == mLabelIdMap.end() ) |
147 | return 0; | 147 | return 0; |
148 | return *labelIt; | 148 | return *labelIt; |
149 | } | 149 | } |
150 | 150 | ||
151 | QStringList CategoryGroup::labels() const | 151 | QStringList CategoryGroup::labels() const |
152 | { | 152 | { |
153 | QStringList labels; | 153 | QStringList labels; |
154 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 154 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
155 | it != mIdLabelMap.end(); ++it ) | 155 | it != mIdLabelMap.end(); ++it ) |
156 | labels += *it; | 156 | labels += *it; |
157 | // ### I don't think this is the place for this... | 157 | // ### I don't think this is the place for this... |
158 | // labels.sort(); | 158 | // labels.sort(); |
159 | return labels; | 159 | return labels; |
160 | } | 160 | } |
161 | 161 | ||
162 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const | 162 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const |
163 | { | 163 | { |
164 | QStringList labels; | 164 | QStringList labels; |
165 | if ( catids.count() == 0 ) | 165 | if ( catids.count() == 0 ) |
166 | return labels; | 166 | return labels; |
167 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 167 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
168 | it != mIdLabelMap.end(); ++it ) | 168 | it != mIdLabelMap.end(); ++it ) |
169 | if ( catids.find( it.key() ) != -1 ) | 169 | if ( catids.find( it.key() ) != -1 ) |
170 | labels += *it; | 170 | labels += *it; |
171 | return labels; | 171 | return labels; |
172 | } | 172 | } |
173 | 173 | ||
174 | QArray<int> CategoryGroup::ids( const QStringList &cats ) const | ||
175 | { | ||
176 | QArray<int> results; | ||
177 | |||
178 | for ( QStringList::ConstIterator catIt = cats.begin(); | ||
179 | catIt != cats.end(); ++catIt ) { | ||
180 | if ( *catIt == QObject::tr("All") || *catIt == QObject::tr("Unfiled") ) | ||
181 | continue; | ||
182 | int value = id( *catIt ); | ||
183 | if ( value != 0 ) { | ||
184 | int tmp = results.size(); | ||
185 | results.resize( tmp + 1 ); | ||
186 | results[ tmp ] = value; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | return results; | ||
191 | } | ||
192 | |||
193 | QArray<int> CategoryGroup::ids() const | ||
194 | { | ||
195 | QArray<int> results( mIdLabelMap.count() ); | ||
196 | int i = 0; | ||
197 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | ||
198 | it != mIdLabelMap.end(); ++it ) | ||
199 | results[i++] = it.key(); | ||
200 | |||
201 | return results; | ||
202 | } | ||
203 | |||
204 | /*********************************************************** | 174 | /*********************************************************** |
205 | * | 175 | * |
206 | * Categories | 176 | * Categories |
207 | * | 177 | * |
208 | **********************************************************/ | 178 | **********************************************************/ |
209 | 179 | ||
210 | /** Add the category name as long as it doesn't already exist locally | 180 | /** Add the category name as long as it doesn't already exist locally |
211 | * or globally. Return TRUE if added, FALSE if conflicts. | 181 | * or globally. Return TRUE if added, FALSE if conflicts. |
212 | */ | 182 | */ |
213 | int Categories::addCategory( const QString &appname, | 183 | int Categories::addCategory( const QString &appname, |
214 | const QString &catname, | 184 | const QString &catname, |
215 | int uid ) | 185 | int uid ) |
216 | { | 186 | { |
217 | if ( mGlobalCats.contains(catname) ) | 187 | if ( mGlobalCats.contains(catname) ) |
218 | return 0; | 188 | return 0; |
219 | 189 | ||
220 | QMap< QString, CategoryGroup >::Iterator | 190 | QMap< QString, CategoryGroup >::Iterator |
221 | appIt = mAppCats.find( appname ); | 191 | appIt = mAppCats.find( appname ); |
222 | 192 | ||
223 | if ( appIt == mAppCats.end() ) { | 193 | if ( appIt == mAppCats.end() ) { |
224 | CategoryGroup newgroup; | 194 | CategoryGroup newgroup; |
225 | newgroup.add( uid, catname ); | 195 | newgroup.add( uid, catname ); |
226 | mAppCats.insert( appname, newgroup ); | 196 | mAppCats.insert( appname, newgroup ); |
227 | emit categoryAdded( *this, appname, uid ); | 197 | emit categoryAdded( *this, appname, uid ); |
228 | return uid; | 198 | return uid; |
229 | } | 199 | } |
230 | 200 | ||
231 | CategoryGroup &cats = *appIt; | 201 | CategoryGroup &cats = *appIt; |
232 | cats.add( uid, catname ); | 202 | cats.add( uid, catname ); |
233 | emit categoryAdded( *this, appname, uid ); | 203 | emit categoryAdded( *this, appname, uid ); |
234 | return uid; | 204 | return uid; |
235 | } | 205 | } |
236 | 206 | ||
237 | int Categories::addCategory( const QString &appname, | 207 | int Categories::addCategory( const QString &appname, |
238 | const QString &catname ) | 208 | const QString &catname ) |
239 | { | 209 | { |
240 | if ( mGlobalCats.contains(catname) ) | 210 | if ( mGlobalCats.contains(catname) ) |
241 | return 0; | 211 | return 0; |
242 | 212 | ||
243 | QMap< QString, CategoryGroup >::Iterator | 213 | QMap< QString, CategoryGroup >::Iterator |
244 | appIt = mAppCats.find( appname ); | 214 | appIt = mAppCats.find( appname ); |
245 | 215 | ||
246 | if ( appIt == mAppCats.end() ) { | 216 | if ( appIt == mAppCats.end() ) { |
247 | CategoryGroup newgroup; | 217 | CategoryGroup newgroup; |
248 | int uid = newgroup.add( catname ); | 218 | int uid = newgroup.add( catname ); |
249 | mAppCats.insert( appname, newgroup ); | 219 | mAppCats.insert( appname, newgroup ); |
250 | emit categoryAdded( *this, appname, uid ); | 220 | emit categoryAdded( *this, appname, uid ); |
251 | return uid; | 221 | return uid; |
252 | } | 222 | } |
253 | 223 | ||
254 | CategoryGroup &cats = *appIt; | 224 | CategoryGroup &cats = *appIt; |
255 | int uid = cats.add( catname ); | 225 | int uid = cats.add( catname ); |
256 | if ( !uid ) | 226 | if ( !uid ) |
257 | return 0; | 227 | return 0; |
258 | emit categoryAdded( *this, appname, uid ); | 228 | emit categoryAdded( *this, appname, uid ); |
259 | return uid; | 229 | return uid; |
260 | } | 230 | } |
261 | 231 | ||
262 | int Categories::addGlobalCategory( const QString &catname, int uid ) | 232 | int Categories::addGlobalCategory( const QString &catname, int uid ) |
263 | { | 233 | { |
264 | mGlobalCats.add( uid, catname ); | 234 | mGlobalCats.add( uid, catname ); |
265 | emit categoryAdded( *this, QString::null, uid ); | 235 | emit categoryAdded( *this, QString::null, uid ); |
266 | return uid; | 236 | return uid; |
267 | } | 237 | } |
268 | 238 | ||
269 | int Categories::addGlobalCategory( const QString &catname ) | 239 | int Categories::addGlobalCategory( const QString &catname ) |
270 | { | 240 | { |
271 | int uid = mGlobalCats.add( catname ); | 241 | int uid = mGlobalCats.add( catname ); |
272 | if ( !uid ) | 242 | if ( !uid ) |
273 | return 0; | 243 | return 0; |
274 | emit categoryAdded( *this, QString::null, uid ); | 244 | emit categoryAdded( *this, QString::null, uid ); |
275 | return uid; | 245 | return uid; |
276 | } | 246 | } |
277 | 247 | ||
278 | /** Removes the category from the application; if it is not found | 248 | /** Removes the category from the application; if it is not found |
279 | * in the application, then it attempts to remove it from | 249 | * in the application, then it attempts to remove it from |
280 | * the global list | 250 | * the global list |
281 | */ | 251 | */ |
282 | bool Categories::removeCategory( const QString &appname, | 252 | bool Categories::removeCategory( const QString &appname, |
283 | const QString &catname, | 253 | const QString &catname, |
284 | bool checkGlobal ) | 254 | bool checkGlobal ) |
285 | { | 255 | { |
286 | QMap< QString, CategoryGroup >::Iterator | 256 | QMap< QString, CategoryGroup >::Iterator |
287 | appIt = mAppCats.find( appname ); | 257 | appIt = mAppCats.find( appname ); |
288 | if ( appIt != mAppCats.end() ) { | 258 | if ( appIt != mAppCats.end() ) { |
289 | CategoryGroup &cats = *appIt; | 259 | CategoryGroup &cats = *appIt; |
290 | int uid = cats.id( catname ); | 260 | int uid = cats.id( catname ); |
291 | if ( cats.remove( uid ) ) { | 261 | if ( cats.remove( uid ) ) { |
292 | emit categoryRemoved( *this, appname, uid ); | 262 | emit categoryRemoved( *this, appname, uid ); |
293 | return TRUE; | 263 | return TRUE; |
294 | } | 264 | } |
295 | } | 265 | } |
296 | if ( !checkGlobal ) | 266 | if ( !checkGlobal ) |
297 | return FALSE; | 267 | return FALSE; |
298 | return removeGlobalCategory( catname ); | 268 | return removeGlobalCategory( catname ); |
299 | } | 269 | } |
300 | 270 | ||
301 | bool Categories::removeCategory( const QString &appname, int uid ) | 271 | bool Categories::removeCategory( const QString &appname, int uid ) |
302 | { | 272 | { |
303 | QMap< QString, CategoryGroup >::Iterator | 273 | QMap< QString, CategoryGroup >::Iterator |
304 | appIt = mAppCats.find( appname ); | 274 | appIt = mAppCats.find( appname ); |
305 | if ( appIt != mAppCats.end() ) { | 275 | if ( appIt != mAppCats.end() ) { |
306 | CategoryGroup &cats = *appIt; | 276 | CategoryGroup &cats = *appIt; |
307 | if ( cats.remove( uid ) ) { | 277 | if ( cats.remove( uid ) ) { |
308 | emit categoryRemoved( *this, appname, uid ); | 278 | emit categoryRemoved( *this, appname, uid ); |
309 | return TRUE; | 279 | return TRUE; |
310 | } | 280 | } |
311 | } | 281 | } |
312 | return FALSE; | 282 | return FALSE; |
313 | } | 283 | } |
314 | 284 | ||
315 | bool Categories::removeGlobalCategory( const QString &catname ) | 285 | bool Categories::removeGlobalCategory( const QString &catname ) |
316 | { | 286 | { |
317 | int uid = mGlobalCats.id( catname ); | 287 | int uid = mGlobalCats.id( catname ); |
318 | if ( mGlobalCats.remove( uid ) ) { | 288 | if ( mGlobalCats.remove( uid ) ) { |
319 | emit categoryRemoved( *this, QString::null, uid ); | 289 | emit categoryRemoved( *this, QString::null, uid ); |
320 | return TRUE; | 290 | return TRUE; |
321 | } | 291 | } |
322 | return FALSE; | 292 | return FALSE; |
323 | } | 293 | } |
324 | 294 | ||
325 | 295 | ||
326 | bool Categories::removeGlobalCategory( int uid ) | 296 | bool Categories::removeGlobalCategory( int uid ) |
327 | { | 297 | { |
328 | if ( mGlobalCats.remove( uid ) ) { | 298 | if ( mGlobalCats.remove( uid ) ) { |
329 | emit categoryRemoved( *this, QString::null, uid ); | 299 | emit categoryRemoved( *this, QString::null, uid ); |
330 | return TRUE; | 300 | return TRUE; |
331 | } | 301 | } |
332 | return FALSE; | 302 | return FALSE; |
333 | } | 303 | } |
334 | 304 | ||
335 | /** Returns the sorted list of all categories that are associated with | 305 | /** Returns the sorted list of all categories that are associated with |
336 | * the app. If includeGlobal parameter is TRUE then the returned | 306 | * the app. If includeGlobal parameter is TRUE then the returned |
337 | * categories will include the global category items. | 307 | * categories will include the global category items. |
338 | */ | 308 | */ |
339 | QStringList Categories::labels( const QString &app, | 309 | QStringList Categories::labels( const QString &app, |
340 | bool includeGlobal, | 310 | bool includeGlobal, |
341 | ExtraLabels extra ) const | 311 | ExtraLabels extra ) const |
342 | { | 312 | { |
343 | QMap< QString, CategoryGroup >::ConstIterator | 313 | QMap< QString, CategoryGroup >::ConstIterator |
344 | appIt = mAppCats.find( app ); | 314 | appIt = mAppCats.find( app ); |
345 | QStringList cats; | 315 | QStringList cats; |
316 | |||
317 | if ( appIt != mAppCats.end() ) | ||
318 | cats += (*appIt).labels(); | ||
319 | else qDebug("Categories::labels didn't find app %s", app.latin1() ); | ||
320 | if ( includeGlobal ) | ||
321 | cats += mGlobalCats.labels(); | ||
322 | |||
323 | cats.sort(); | ||
346 | switch ( extra ) { | 324 | switch ( extra ) { |
347 | case NoExtra: break; | 325 | case NoExtra: break; |
348 | case AllUnfiled: | 326 | case AllUnfiled: |
349 | cats.append( tr("All") ); | 327 | cats.append( tr("All") ); |
350 | cats.append( tr("Unfiled") ); | 328 | cats.append( tr("Unfiled") ); |
351 | break; | 329 | break; |
352 | case AllLabel: | 330 | case AllLabel: |
353 | cats.append( tr("All") ); | 331 | cats.append( tr("All") ); |
354 | break; | 332 | break; |
355 | case UnfiledLabel: | 333 | case UnfiledLabel: |
356 | cats.append( tr("Unfiled") ); | 334 | cats.append( tr("Unfiled") ); |
357 | break; | 335 | break; |
358 | } | 336 | } |
359 | if ( appIt != mAppCats.end() ) | 337 | |
360 | cats += (*appIt).labels(); | ||
361 | else qDebug("Categories::labels didn't find app %s", app.latin1() ); | ||
362 | if ( includeGlobal ) | ||
363 | cats += mGlobalCats.labels(); | ||
364 | // I don't think a sorted list is useful, the user might find prefer | ||
365 | // it in the original order. | ||
366 | // cats.sort(); | ||
367 | return cats; | 338 | return cats; |
368 | } | 339 | } |
369 | 340 | ||
370 | QString Categories::label( const QString &app, int id ) const | 341 | QString Categories::label( const QString &app, int id ) const |
371 | { | 342 | { |
372 | if ( mGlobalCats.contains( id ) ) | 343 | if ( mGlobalCats.contains( id ) ) |
373 | return mGlobalCats.label( id ); | 344 | return mGlobalCats.label( id ); |
374 | QMap< QString, CategoryGroup >::ConstIterator | 345 | QMap< QString, CategoryGroup >::ConstIterator |
375 | appIt = mAppCats.find( app ); | 346 | appIt = mAppCats.find( app ); |
376 | if ( appIt == mAppCats.end() ) | 347 | if ( appIt == mAppCats.end() ) |
377 | return QString::null; | 348 | return QString::null; |
378 | return (*appIt).label( id ); | 349 | return (*appIt).label( id ); |
379 | } | 350 | } |
380 | 351 | ||
381 | QStringList Categories::labels( const QString & app, | ||
382 | const QArray<int> &catids ) const | ||
383 | { | ||
384 | QStringList strs = mGlobalCats.labels( catids ); | ||
385 | strs += mAppCats[app].labels( catids ); | ||
386 | return strs; | ||
387 | } | ||
388 | |||
389 | /** Returns a single string associated with the cat ids for display in | 352 | /** Returns a single string associated with the cat ids for display in |
390 | * a combobox or any area that requires one string. If catids are empty | 353 | * a combobox or any area that requires one string. If catids are empty |
391 | * then "Unfiled" will be returned. If multiple categories are assigned | 354 | * then "Unfiled" will be returned. If multiple categories are assigned |
392 | * the first cat id is shown with " (multi)" appended to the string. | 355 | * the first cat id is shown with " (multi)" appended to the string. |
393 | */ | 356 | */ |
394 | QString Categories::displaySingle( const QString &app, | 357 | QString Categories::displaySingle( const QString &app, |
395 | const QArray<int> &catids, | 358 | const QArray<int> &catids, |
396 | DisplaySingle display ) const | 359 | DisplaySingle display ) const |
397 | { | 360 | { |
398 | QStringList strs = labels( app, catids ); | 361 | QStringList strs = labels( app, catids ); |
399 | if ( !strs.count() ) | 362 | if ( !strs.count() ) |
400 | return tr("Unfiled"); | 363 | return tr("Unfiled"); |
401 | strs.sort(); | 364 | strs.sort(); |
402 | QString r; | 365 | QString r; |
403 | if ( strs.count() > 1 ) { | 366 | if ( strs.count() > 1 ) { |
404 | switch ( display ) { | 367 | switch ( display ) { |
405 | case ShowFirst: | 368 | case ShowFirst: |
406 | r = strs.first(); | 369 | r = strs.first(); |
407 | break; | 370 | break; |
408 | case ShowMulti: | 371 | case ShowMulti: |
409 | r = strs.first() + tr(" (multi.)"); | 372 | r = strs.first() + tr(" (multi.)"); |
410 | break; | 373 | break; |
411 | case ShowAll: | 374 | case ShowAll: |
412 | r = strs.join(" "); | 375 | r = strs.join(" "); |
413 | break; | 376 | break; |
414 | } | 377 | } |
415 | } | 378 | } |
416 | else r = strs.first(); | 379 | else r = strs.first(); |
417 | return r; | 380 | return r; |
418 | } | 381 | } |
419 | 382 | ||
420 | QArray<int> Categories::ids( const QString &app ) const | 383 | QArray<int> Categories::ids( const QString &app, const QStringList &labels) const |
421 | { | ||
422 | QArray<int> allIds = mGlobalCats.ids(); | ||
423 | QArray<int> appIds = mAppCats[app].ids(); | ||
424 | |||
425 | // we should make the guarentee that the ids are in the | ||
426 | // same order as the labels, (i.e. app cats then global) | ||
427 | // otherwise there is no point in having these two separate functions. | ||
428 | uint appSize = appIds.size(); | ||
429 | appIds.resize( appSize + allIds.size() ); | ||
430 | for ( uint i = appSize; i < appIds.size(); ++i ) | ||
431 | appIds[int(i)] = allIds[int(i - appSize)]; | ||
432 | |||
433 | return appIds; | ||
434 | } | ||
435 | |||
436 | QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const | ||
437 | { | 384 | { |
438 | QArray<int> allIds = mGlobalCats.ids( cats ); | 385 | QArray<int> results; |
439 | QArray<int> appIds = mAppCats[app].ids( cats ); | 386 | QStringList::ConstIterator it; |
440 | 387 | int i; | |
441 | uint appSize = appIds.size(); | 388 | |
442 | appIds.resize( appSize + allIds.size() ); | 389 | for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { |
443 | for ( uint i = appSize; i < appIds.size(); ++i ) | 390 | int value = id( app, *it ); |
444 | appIds[int(i)] = allIds[int(i - appSize)]; | 391 | if ( value != 0 ) { |
445 | 392 | int tmp = results.size(); | |
446 | return appIds; | 393 | results.resize( tmp + 1 ); |
394 | results[ tmp ] = value; | ||
395 | } | ||
396 | } | ||
397 | return results; | ||
447 | } | 398 | } |
448 | 399 | ||
449 | int Categories::id( const QString &app, const QString &cat ) const | 400 | int Categories::id( const QString &app, const QString &cat ) const |
450 | { | 401 | { |
451 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) | 402 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) |
452 | return 0; | 403 | return 0; |
453 | int uid = mGlobalCats.id( cat ); | 404 | int uid = mGlobalCats.id( cat ); |
454 | if ( uid != 0 ) | 405 | if ( uid != 0 ) |
455 | return uid; | 406 | return uid; |
456 | return mAppCats[app].id( cat ); | 407 | return mAppCats[app].id( cat ); |
457 | } | 408 | } |
458 | 409 | ||
459 | 410 | ||
460 | /** Return TRUE if renaming succeeded; FALSE if app name not found, | 411 | /** Return TRUE if renaming succeeded; FALSE if app name not found, |
461 | * or if there was a name conflict | 412 | * or if there was a name conflict |
462 | */ | 413 | */ |
463 | bool Categories::renameCategory( const QString &appname, | 414 | bool Categories::renameCategory( const QString &appname, |
464 | const QString &oldName, | 415 | const QString &oldName, |
465 | const QString &newName ) | 416 | const QString &newName ) |
466 | { | 417 | { |
467 | QMap< QString, CategoryGroup >::Iterator | 418 | QMap< QString, CategoryGroup >::Iterator |
468 | appIt = mAppCats.find( appname ); | 419 | appIt = mAppCats.find( appname ); |
469 | 420 | ||
470 | if ( appIt != mAppCats.end() ) { | 421 | if ( appIt != mAppCats.end() ) { |
471 | CategoryGroup &cats = *appIt; | 422 | CategoryGroup &cats = *appIt; |
472 | int id = cats.id( oldName ); | 423 | int id = cats.id( oldName ); |
473 | if ( id != 0 && cats.rename( id, newName ) ) { | 424 | if ( id != 0 && cats.rename( id, newName ) ) { |
474 | emit categoryRenamed( *this, appname, id ); | 425 | emit categoryRenamed( *this, appname, id ); |
475 | return TRUE; | 426 | return TRUE; |
476 | } | 427 | } |
477 | } | 428 | } |
478 | return renameGlobalCategory( oldName, newName ); | 429 | return renameGlobalCategory( oldName, newName ); |
479 | } | 430 | } |
480 | 431 | ||
481 | bool Categories::renameGlobalCategory( const QString &oldName, | 432 | bool Categories::renameGlobalCategory( const QString &oldName, |
482 | const QString &newName ) | 433 | const QString &newName ) |
483 | { | 434 | { |
484 | int uid = mGlobalCats.id( oldName ); | 435 | int uid = mGlobalCats.id( oldName ); |
485 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { | 436 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { |
486 | emit categoryRenamed( *this, QString::null, uid ); | 437 | emit categoryRenamed( *this, QString::null, uid ); |
487 | return TRUE; | 438 | return TRUE; |
488 | } | 439 | } |
489 | return FALSE; | 440 | return FALSE; |
490 | } | 441 | } |
491 | 442 | ||
492 | void Categories::setGlobal( const QString &appname, | 443 | void Categories::setGlobal( const QString &appname, |
493 | const QString &catname, | 444 | const QString &catname, |
494 | bool global ) | 445 | bool global ) |
495 | { | 446 | { |
496 | // if in global and should be in app; then move it | 447 | // if in global and should be in app; then move it |
497 | if ( mGlobalCats.contains( catname ) && !global ) { | 448 | if ( mGlobalCats.contains( catname ) && !global ) { |
498 | mGlobalCats.remove( catname ); | 449 | mGlobalCats.remove( catname ); |
499 | addCategory( appname, catname ); | 450 | addCategory( appname, catname ); |
500 | return ; | 451 | return ; |
501 | } | 452 | } |
502 | 453 | ||
503 | // if in app and should be in global, then move it | 454 | // if in app and should be in global, then move it |
504 | if ( !global ) | 455 | if ( !global ) |
505 | return; | 456 | return; |
506 | if ( removeCategory( appname, catname, FALSE ) ) | 457 | if ( removeCategory( appname, catname, FALSE ) ) |
507 | addGlobalCategory( catname ); | 458 | addGlobalCategory( catname ); |
508 | } | 459 | } |
509 | 460 | ||
510 | bool Categories::isGlobal( const QString &catname ) const | 461 | bool Categories::isGlobal( const QString &catname ) const |
511 | { | 462 | { |
512 | return mGlobalCats.contains( catname ); | 463 | return mGlobalCats.contains( catname ); |
513 | } | 464 | } |
514 | 465 | ||
515 | 466 | ||
516 | /** Returns true if the catname is associated with any application | 467 | /** Returns true if the catname is associated with any application |
517 | */ | 468 | */ |
518 | bool Categories::exists( const QString &catname ) const | 469 | bool Categories::exists( const QString &catname ) const |
519 | { | 470 | { |
520 | if ( isGlobal(catname) ) | 471 | if ( isGlobal(catname) ) |
521 | return TRUE; | 472 | return TRUE; |
522 | 473 | ||
523 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) | 474 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) |
524 | if ( exists( appsIt.key(), catname ) ) | 475 | if ( exists( appsIt.key(), catname ) ) |
525 | return TRUE; | 476 | return TRUE; |
526 | 477 | ||
527 | return FALSE; | 478 | return FALSE; |
528 | } | 479 | } |
529 | 480 | ||
530 | bool Categories::exists( const QString &appname, | 481 | bool Categories::exists( const QString &appname, |
531 | const QString &catname) const | 482 | const QString &catname) const |
532 | { | 483 | { |
533 | QMap< QString, CategoryGroup >::ConstIterator | 484 | QMap< QString, CategoryGroup >::ConstIterator |
534 | appIt = mAppCats.find( appname ); | 485 | appIt = mAppCats.find( appname ); |
535 | 486 | ||
536 | if ( appIt == mAppCats.end() ) | 487 | if ( appIt == mAppCats.end() ) |
537 | return FALSE; | 488 | return FALSE; |
538 | 489 | ||
539 | return (*appIt).contains( catname ); | 490 | return (*appIt).contains( catname ); |
540 | } | 491 | } |
541 | 492 | ||
493 | |||
542 | bool Categories::save( const QString &fname ) const | 494 | bool Categories::save( const QString &fname ) const |
543 | { | 495 | { |
544 | QFile file( fname ); | 496 | QString strNewFile = fname + ".new"; |
545 | if ( !file.open( IO_WriteOnly ) ) { | 497 | QFile f( strNewFile ); |
498 | QString out; | ||
499 | int total_written; | ||
500 | |||
501 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { | ||
546 | qWarning("Unable to write to %s", fname.latin1()); | 502 | qWarning("Unable to write to %s", fname.latin1()); |
547 | return FALSE; | 503 | return FALSE; |
548 | } | 504 | } |
549 | 505 | ||
550 | QTextStream ts( &file ); | 506 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
551 | ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | 507 | out += "<!DOCTYPE CategoryList>\n"; |
552 | ts << "<!DOCTYPE CategoryList>" << endl; | 508 | |
509 | out += "<Categories>\n"; | ||
553 | 510 | ||
554 | ts << "<Categories>" << endl; | ||
555 | for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); | 511 | for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); |
556 | git != mGlobalCats.idMap().end(); ++git ) | 512 | git != mGlobalCats.idMap().end(); ++git ) |
557 | ts << "<Category id=\"" << git.key() << "\"" | 513 | out += "<Category id=\"" + QString::number(git.key()) + "\"" + |
558 | << " name=\"" << escapeString(*git) << "\" />" << endl; | 514 | " name=\"" + escapeString(*git) + "\" />\n"; |
559 | 515 | ||
560 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); | 516 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); |
561 | appsIt != mAppCats.end(); ++appsIt ) { | 517 | appsIt != mAppCats.end(); ++appsIt ) { |
562 | const QString &app = appsIt.key(); | 518 | const QString &app = appsIt.key(); |
563 | const QMap<int, QString> &appcats = (*appsIt).idMap(); | 519 | const QMap<int, QString> &appcats = (*appsIt).idMap(); |
564 | for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); | 520 | for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); |
565 | appcatit != appcats.end(); ++appcatit ) | 521 | appcatit != appcats.end(); ++appcatit ) |
566 | ts << "<Category id=\"" << appcatit.key() << "\"" | 522 | out += "<Category id=\"" + QString::number(appcatit.key()) + "\"" + |
567 | << " app=\"" << escapeString(app) << "\"" | 523 | " app=\"" + escapeString(app) + "\"" + |
568 | << " name=\"" << escapeString(*appcatit) << "\" />" << endl; | 524 | " name=\"" + escapeString(*appcatit) + "\" />\n"; |
525 | } | ||
526 | out += "</Categories>\n"; | ||
527 | |||
528 | QCString cstr = out.utf8(); | ||
529 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
530 | if ( total_written != int(cstr.length()) ) { | ||
531 | f.close(); | ||
532 | QFile::remove( strNewFile ); | ||
533 | return FALSE; | ||
534 | } | ||
535 | f.close(); | ||
536 | |||
537 | if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { | ||
538 | qWarning( "problem renaming file %s to %s", | ||
539 | strNewFile.latin1(), fname.latin1()); | ||
540 | // remove the tmp file... | ||
541 | QFile::remove( strNewFile ); | ||
569 | } | 542 | } |
570 | ts << "</Categories>" << endl; | ||
571 | 543 | ||
572 | file.close(); | ||
573 | return TRUE; | 544 | return TRUE; |
574 | } | 545 | } |
575 | 546 | ||
576 | bool Categories::load( const QString &fname ) | 547 | bool Categories::load( const QString &fname ) |
577 | { | 548 | { |
578 | QFile file( fname ); | 549 | QFile file( fname ); |
579 | if ( !file.open( IO_ReadOnly ) ) { | 550 | if ( !file.open( IO_ReadOnly ) ) { |
580 | qWarning("Unable to open %s", fname.latin1()); | 551 | qWarning("Unable to open %s", fname.latin1()); |
552 | |||
553 | addGlobalCategory(tr("Business")); | ||
554 | addGlobalCategory(tr("Personal")); | ||
555 | save(fname); | ||
556 | |||
581 | return FALSE; | 557 | return FALSE; |
582 | } | 558 | } |
583 | 559 | ||
584 | clear(); | 560 | clear(); |
585 | QByteArray ba = file.readAll(); | 561 | QByteArray ba = file.readAll(); |
586 | QString data = QString::fromUtf8( ba.data(), ba.size() ); | 562 | QString data = QString::fromUtf8( ba.data(), ba.size() ); |
587 | QChar *uc = (QChar *)data.unicode(); | 563 | QChar *uc = (QChar *)data.unicode(); |
588 | int len = data.length(); | 564 | int len = data.length(); |
589 | 565 | ||
590 | // QTime t; | 566 | // QTime t; |
591 | // t.start(); | 567 | // t.start(); |
592 | QString name; | 568 | QString name; |
593 | QString id; | 569 | QString id; |
594 | QString app; | 570 | QString app; |
595 | int i = 0; | 571 | int i = 0; |
596 | while ( (i = data.find( "<Category ", i)) != -1 ) { | 572 | while ( (i = data.find( "<Category ", i)) != -1 ) { |
597 | 573 | ||
598 | i += 10; | 574 | i += 10; |
599 | name = QString::null; | 575 | name = QString::null; |
600 | app = QString::null; | 576 | app = QString::null; |
601 | while ( 1 ) { | 577 | while ( 1 ) { |
602 | // skip white space | 578 | // skip white space |
603 | while ( i < len && | 579 | while ( i < len && |
604 | (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) | 580 | (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) |
605 | i++; | 581 | i++; |
606 | // if at the end, then done | 582 | // if at the end, then done |
607 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) | 583 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) |
608 | break; | 584 | break; |
609 | // we have another attribute read it. | 585 | // we have another attribute read it. |
610 | int j = i; | 586 | int j = i; |
611 | while ( j < len && uc[j] != '=' ) | 587 | while ( j < len && uc[j] != '=' ) |
612 | j++; | 588 | j++; |
613 | QString attr = QConstString( uc+i, j-i ).string(); | 589 | QString attr = QConstString( uc+i, j-i ).string(); |
614 | i = ++j; // skip = | 590 | i = ++j; // skip = |
615 | while ( i < len && uc[i] != '"' ) | 591 | while ( i < len && uc[i] != '"' ) |
616 | i++; | 592 | i++; |
617 | j = ++i; | 593 | j = ++i; |
618 | while ( j < len && uc[j] != '"' ) | 594 | while ( j < len && uc[j] != '"' ) |
619 | j++; | 595 | j++; |
620 | QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); | 596 | QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); |
621 | i = j + 1; | 597 | i = j + 1; |
622 | 598 | ||
623 | // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); | 599 | // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); |
624 | if ( attr == "id" ) | 600 | if ( attr == "id" ) |
625 | id = value; | 601 | id = value; |
626 | else if ( attr == "app" ) | 602 | else if ( attr == "app" ) |
627 | app = value; | 603 | app = value; |
628 | 604 | ||
629 | else if ( attr == "name" ) | 605 | else if ( attr == "name" ) |
630 | name = value; | 606 | name = value; |
631 | } | 607 | } |
632 | 608 | ||
633 | if ( name.isNull() || id.isNull() ) { | 609 | if ( name.isNull() || id.isNull() ) { |
634 | qWarning("No name or id in the category"); | 610 | qWarning("No name or id in the category"); |
635 | continue; | 611 | continue; |
636 | } | 612 | } |
637 | if ( app.isNull() ) | 613 | if ( app.isNull() ) |
638 | mGlobalCats.add( id.toInt(), name ); | 614 | mGlobalCats.add( id.toInt(), name ); |
639 | else | 615 | else |
640 | mAppCats[ app ].add( id.toInt(), name ); | 616 | mAppCats[ app ].add( id.toInt(), name ); |
641 | } | 617 | } |
642 | 618 | ||
643 | return TRUE; | 619 | return TRUE; |
644 | } | 620 | } |
645 | 621 | ||
646 | void Categories::clear() | 622 | void Categories::clear() |
647 | { | 623 | { |
648 | mGlobalCats.clear(); | 624 | mGlobalCats.clear(); |
649 | mAppCats.clear(); | 625 | mAppCats.clear(); |
650 | } | 626 | } |
651 | 627 | ||
652 | void Categories::dump() const | 628 | void Categories::dump() const |
653 | { | 629 | { |
654 | qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); | 630 | qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); |
655 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { | 631 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { |
656 | const QString &app = appsIt.key(); | 632 | const QString &app = appsIt.key(); |
657 | QStringList appcats = (*appsIt).labels(); | 633 | QStringList appcats = (*appsIt).labels(); |
658 | qDebug("\tapp = %s\tcategories = %s", app.latin1(), | 634 | qDebug("\tapp = %s\tcategories = %s", app.latin1(), |
659 | appcats.join(", ").latin1() ); | 635 | appcats.join(", ").latin1() ); |
660 | 636 | ||
661 | } | 637 | } |
662 | } | 638 | } |
663 | 639 | ||
664 | QStringList CheckedListView::checked() const | 640 | QStringList CheckedListView::checked() const |
665 | { | 641 | { |
666 | QStringList strs; | 642 | QStringList strs; |
667 | for ( QCheckListItem *i = (QCheckListItem *) firstChild(); | 643 | for ( QCheckListItem *i = (QCheckListItem *) firstChild(); |
668 | i; i = (QCheckListItem *)i->nextSibling() ) | 644 | i; i = (QCheckListItem *)i->nextSibling() ) |
669 | if ( i->isOn() ) | 645 | if ( i->isOn() ) |
670 | strs += i->text( 0 ); | 646 | strs += i->text( 0 ); |
671 | return strs; | 647 | return strs; |
672 | } | 648 | } |
673 | 649 | ||
674 | void CheckedListView::addCheckableList( const QStringList &options ) | 650 | void CheckedListView::addCheckableList( const QStringList &options ) |
675 | { | 651 | { |
676 | for ( QStringList::ConstIterator it = options.begin(); | 652 | for ( QStringList::ConstIterator it = options.begin(); |
677 | it != options.end(); ++it ) { | 653 | it != options.end(); ++it ) { |
678 | (void) new QCheckListItem( this, *it, | 654 | (void) new QCheckListItem( this, *it, |
679 | QCheckListItem::CheckBox ); | 655 | QCheckListItem::CheckBox ); |
680 | } | 656 | } |
681 | } | 657 | } |
682 | 658 | ||
683 | void CheckedListView::setChecked( const QStringList &checked ) | 659 | void CheckedListView::setChecked( const QStringList &checked ) |
684 | { | 660 | { |
685 | // iterate over all items | 661 | // iterate over all items |
686 | bool showingChecked = FALSE; | 662 | bool showingChecked = FALSE; |
687 | for ( QCheckListItem *i = (QCheckListItem *) firstChild(); | 663 | for ( QCheckListItem *i = (QCheckListItem *) firstChild(); |
688 | i; i = (QCheckListItem *)i->nextSibling() ) | 664 | i; i = (QCheckListItem *)i->nextSibling() ) |
689 | // see if the item should be checked by searching the | 665 | // see if the item should be checked by searching the |
690 | // checked list | 666 | // checked list |
691 | if ( checked.find( i->text( 0 ) ) != checked.end() ) { | 667 | if ( checked.find( i->text( 0 ) ) != checked.end() ) { |
692 | i->setOn( TRUE ); | 668 | i->setOn( TRUE ); |
693 | // make sure it is showing at least one checked item | 669 | // make sure it is showing at least one checked item |
694 | if ( !showingChecked ) { | 670 | if ( !showingChecked ) { |
695 | ensureItemVisible( i ); | 671 | ensureItemVisible( i ); |
696 | showingChecked = TRUE; | 672 | showingChecked = TRUE; |
697 | } | 673 | } |
698 | } | 674 | } |
699 | else | 675 | else |
700 | i->setOn( FALSE ); | 676 | i->setOn( FALSE ); |
701 | } | 677 | } |
diff --git a/library/backend/categories.h b/library/backend/categories.h index 82d765b..ba65ee3 100644 --- a/library/backend/categories.h +++ b/library/backend/categories.h | |||
@@ -1,232 +1,226 @@ | |||
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 | 7 | ** GNU General Public License version 2 as published by the Free |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Software Foundation and appearing in the file LICENSE.GPL included |
9 | ** in the packaging of this file. | 9 | ** in the packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A |
13 | ** PARTICULAR PURPOSE. | 13 | ** PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef QTPALMTOP_CATEGORIES_H | 22 | #ifndef QTPALMTOP_CATEGORIES_H |
23 | #define QTPALMTOP_CATEGORIES_H | 23 | #define QTPALMTOP_CATEGORIES_H |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qarray.h> | 29 | #include <qarray.h> |
30 | #include "qpcglobal.h" | 30 | #include "qpcglobal.h" |
31 | #include "palmtopuidgen.h" | 31 | #include "palmtopuidgen.h" |
32 | 32 | ||
33 | class CategoryGroup; | 33 | class CategoryGroup; |
34 | 34 | ||
35 | #if defined(QPC_TEMPLATEDLL) | 35 | #if defined(QPC_TEMPLATEDLL) |
36 | // MOC_SKIP_BEGIN | 36 | // MOC_SKIP_BEGIN |
37 | template class QPC_EXPORT QMap<int, QString>; | 37 | template class QPC_EXPORT QMap<int, QString>; |
38 | template class QPC_EXPORT QMap<QString, int>; | 38 | template class QPC_EXPORT QMap<QString, int>; |
39 | template class QPC_EXPORT QMap< QString, CategoryGroup >; | 39 | template class QPC_EXPORT QMap< QString, CategoryGroup >; |
40 | // MOC_SKIP_END | 40 | // MOC_SKIP_END |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | class QPC_EXPORT CategoryGroup | 43 | class QPC_EXPORT CategoryGroup |
44 | { | 44 | { |
45 | friend class Categories; | 45 | friend class Categories; |
46 | public: | 46 | public: |
47 | CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } | 47 | CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } |
48 | CategoryGroup( const CategoryGroup &c ) : | 48 | CategoryGroup( const CategoryGroup &c ) : |
49 | mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } | 49 | mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } |
50 | 50 | ||
51 | void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } | 51 | void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } |
52 | 52 | ||
53 | int add( const QString &label ); | 53 | int add( const QString &label ); |
54 | bool add( int uid, const QString &label ); | 54 | bool add( int uid, const QString &label ); |
55 | 55 | ||
56 | bool remove( const QString &label ); | 56 | bool remove( const QString &label ); |
57 | bool remove( int uid ); | 57 | bool remove( int uid ); |
58 | 58 | ||
59 | bool rename( int uid, const QString &newLabel ); | 59 | bool rename( int uid, const QString &newLabel ); |
60 | bool rename( const QString &oldLabel, const QString &newLabel ); | 60 | bool rename( const QString &oldLabel, const QString &newLabel ); |
61 | 61 | ||
62 | bool contains(int id) const; | 62 | bool contains(int id) const; |
63 | bool contains(const QString &label) const; | 63 | bool contains(const QString &label) const; |
64 | 64 | ||
65 | /** Returns label associated with the uid or QString::null if | 65 | /** Returns label associated with the uid or QString::null if |
66 | * not found | 66 | * not found |
67 | */ | 67 | */ |
68 | const QString &label(int id) const; | 68 | const QString &label(int id) const; |
69 | /** Returns the uid associated with label or 0 if not found */ | 69 | /** Returns the uid associated with label or 0 if not found */ |
70 | int id(const QString &label) const; | 70 | int id(const QString &label) const; |
71 | 71 | ||
72 | /** Returns a sorted list of labels */ | 72 | /** Returns a sorted list of labels */ |
73 | QStringList labels() const; | 73 | QStringList labels() const; |
74 | QArray<int> ids( const QStringList &cats ) const; | 74 | |
75 | QArray<int> ids() const; | ||
76 | QStringList labels( const QArray<int> &catids ) const; | 75 | QStringList labels( const QArray<int> &catids ) const; |
77 | 76 | ||
78 | const QMap<int, QString> &idMap() const { return mIdLabelMap; } | 77 | const QMap<int, QString> &idMap() const { return mIdLabelMap; } |
79 | 78 | ||
80 | private: | 79 | private: |
81 | void insert( int uid, const QString &label ); | 80 | void insert( int uid, const QString &label ); |
82 | QMap<int, QString> mIdLabelMap; | 81 | QMap<int, QString> mIdLabelMap; |
83 | QMap<QString, int> mLabelIdMap; | 82 | QMap<QString, int> mLabelIdMap; |
84 | 83 | ||
85 | static Qtopia::UidGen &uidGen() { return sUidGen; } | 84 | static Qtopia::UidGen &uidGen() { return sUidGen; } |
86 | static Qtopia::UidGen sUidGen; | 85 | static Qtopia::UidGen sUidGen; |
87 | }; | 86 | }; |
88 | 87 | ||
89 | /** Map from application name to categories */ | 88 | /** Map from application name to categories */ |
90 | class QPC_EXPORT Categories : public QObject | 89 | class QPC_EXPORT Categories : public QObject |
91 | { | 90 | { |
92 | Q_OBJECT | 91 | Q_OBJECT |
93 | public: | 92 | public: |
94 | Categories( QObject *parent=0, const char *name = 0 ) | 93 | Categories( QObject *parent=0, const char *name = 0 ) |
95 | : QObject( parent, name ), mGlobalCats(), mAppCats() { } | 94 | : QObject( parent, name ), mGlobalCats(), mAppCats() { } |
96 | Categories( const Categories ©From ) : QObject( copyFrom.parent() ), | 95 | Categories( const Categories ©From ) : QObject( copyFrom.parent() ), |
97 | mGlobalCats( copyFrom.mGlobalCats ), | 96 | mGlobalCats( copyFrom.mGlobalCats ), |
98 | mAppCats( copyFrom.mAppCats ) { } | 97 | mAppCats( copyFrom.mAppCats ) { } |
99 | virtual ~Categories() { } | 98 | virtual ~Categories() { } |
100 | 99 | ||
101 | Categories &operator= ( const Categories &c ) | 100 | Categories &operator= ( const Categories &c ) |
102 | { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } | 101 | { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } |
103 | 102 | ||
104 | void clear(); | 103 | void clear(); |
105 | 104 | ||
106 | /** Add the category name as long as it doesn't already exist | 105 | /** Add the category name as long as it doesn't already exist |
107 | * locally or globally. Return UID if added, 0 if conflicts | 106 | * locally or globally. Return UID if added, 0 if conflicts |
108 | * (error). | 107 | * (error). |
109 | */ | 108 | */ |
110 | int addCategory( const QString &appname, const QString &catname); | 109 | int addCategory( const QString &appname, const QString &catname); |
111 | /** Add the category name as long as it doesn't already exist | 110 | /** Add the category name as long as it doesn't already exist |
112 | * locally or globally. Return UID if added, 0 if conflicts | 111 | * locally or globally. Return UID if added, 0 if conflicts |
113 | * (error). | 112 | * (error). |
114 | */ | 113 | */ |
115 | int addCategory( const QString &appname, const QString &catname, int uid); | 114 | int addCategory( const QString &appname, const QString &catname, int uid); |
116 | /** Add the global category just checking that it doesn't | 115 | /** Add the global category just checking that it doesn't |
117 | * already exist globally. Return UID if added, 0 if conflicts. | 116 | * already exist globally. Return UID if added, 0 if conflicts. |
118 | */ | 117 | */ |
119 | int addGlobalCategory( const QString &catname ); | 118 | int addGlobalCategory( const QString &catname ); |
120 | /** Add the global category just checking that it doesn't | 119 | /** Add the global category just checking that it doesn't |
121 | * already exist globally. Return UID if added, 0 if conflicts. | 120 | * already exist globally. Return UID if added, 0 if conflicts. |
122 | */ | 121 | */ |
123 | int addGlobalCategory( const QString &catname, int uid ); | 122 | int addGlobalCategory( const QString &catname, int uid ); |
124 | /** Removes the category from the application; if it is not found | 123 | /** Removes the category from the application; if it is not found |
125 | * in the application, then it removes it from the global list | 124 | * in the application, then it removes it from the global list |
126 | */ | 125 | */ |
127 | bool removeCategory( const QString &appName, const QString &catName, | 126 | bool removeCategory( const QString &appName, const QString &catName, |
128 | bool checkGlobal = TRUE); | 127 | bool checkGlobal = TRUE); |
129 | bool removeCategory( const QString &appName, int uid ); | 128 | bool removeCategory( const QString &appName, int uid ); |
130 | bool removeGlobalCategory( const QString &catName ); | 129 | bool removeGlobalCategory( const QString &catName ); |
131 | bool removeGlobalCategory( int uid ); | 130 | bool removeGlobalCategory( int uid ); |
132 | 131 | ||
133 | QArray<int> ids( const QString &app ) const; | 132 | QArray<int> ids( const QString &app, const QStringList &labels) const; |
134 | QArray<int> ids( const QString &app, | 133 | |
135 | const QStringList &cats ) const; | ||
136 | /** Returns the id associated with the app */ | 134 | /** Returns the id associated with the app */ |
137 | int id( const QString &app, const QString &cat ) const; | 135 | int id( const QString &app, const QString &cat ) const; |
138 | /** Returns the label associated with the id */ | 136 | /** Returns the label associated with the id */ |
139 | QString label( const QString &app, int id ) const; | 137 | QString label( const QString &app, int id ) const; |
140 | 138 | ||
141 | enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; | 139 | enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; |
142 | /** Returns the sorted list of all categories that are | 140 | /** Returns the sorted list of all categories that are |
143 | * associated with the app. | 141 | * associated with the app. |
144 | * If includeGlobal parameter is TRUE then the returned | 142 | * If includeGlobal parameter is TRUE then the returned |
145 | * categories will include the global category items. | 143 | * categories will include the global category items. |
146 | * If extra = NoExtra, then | 144 | * If extra = NoExtra, then |
147 | * If extra = AllUnfiled, then All and Unfiled will be prepended to | 145 | * If extra = AllUnfiled, then All and Unfiled will be prepended to |
148 | * the list | 146 | * the list |
149 | * If extra = AllLabel, then All is prepended | 147 | * If extra = AllLabel, then All is prepended |
150 | * If extra = UnfiledLabel, then Unfiled is prepended | 148 | * If extra = UnfiledLabel, then Unfiled is prepended |
151 | */ | 149 | */ |
152 | QStringList labels( const QString &app, | 150 | QStringList labels( const QString &app, |
153 | bool includeGlobal = TRUE, | 151 | bool includeGlobal = TRUE, |
154 | ExtraLabels extra = NoExtra ) const; | 152 | ExtraLabels extra = NoExtra ) const; |
155 | 153 | ||
156 | /** Returns the labels of the categories associated with the uids */ | ||
157 | QStringList labels( const QString & app, | ||
158 | const QArray<int> &catids ) const; | ||
159 | |||
160 | enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; | 154 | enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; |
161 | 155 | ||
162 | /** Returns a single string associated with the cat ids for display in | 156 | /** Returns a single string associated with the cat ids for display in |
163 | * a combobox or any area that requires one string. If catids are empty | 157 | * a combobox or any area that requires one string. If catids are empty |
164 | * then "Unfiled" will be returned. If multiple categories are assigned | 158 | * then "Unfiled" will be returned. If multiple categories are assigned |
165 | * then the behavior depends on the DisplaySingle type. | 159 | * then the behavior depends on the DisplaySingle type. |
166 | * If /a display is set to ShowMulti then " (multi)" appended to the | 160 | * If /a display is set to ShowMulti then " (multi)" appended to the |
167 | * first string. If /a display is set to ShowAll, then a space seperated | 161 | * first string. If /a display is set to ShowAll, then a space seperated |
168 | * string is returned with all categories. If ShowFirst is returned, | 162 | * string is returned with all categories. If ShowFirst is returned, |
169 | * the just the first string is returned. | 163 | * the just the first string is returned. |
170 | */ | 164 | */ |
171 | QString displaySingle( const QString &app, | 165 | QString displaySingle( const QString &app, |
172 | const QArray<int> &catids, | 166 | const QArray<int> &catids, |
173 | DisplaySingle display ) const; | 167 | DisplaySingle display ) const; |
174 | 168 | ||
175 | QStringList globalCategories() const { return mGlobalCats.labels();} | 169 | QStringList globalCategories() const { return mGlobalCats.labels();} |
176 | 170 | ||
177 | bool renameCategory( const QString &appname, | 171 | bool renameCategory( const QString &appname, |
178 | const QString &oldName, | 172 | const QString &oldName, |
179 | const QString &newName ); | 173 | const QString &newName ); |
180 | bool renameGlobalCategory( const QString &oldName, | 174 | bool renameGlobalCategory( const QString &oldName, |
181 | const QString &newName ); | 175 | const QString &newName ); |
182 | 176 | ||
183 | void setGlobal( const QString &appname, const QString &catname, | 177 | void setGlobal( const QString &appname, const QString &catname, |
184 | bool value ); | 178 | bool value ); |
185 | bool isGlobal( const QString &catname ) const; | 179 | bool isGlobal( const QString &catname ) const; |
186 | 180 | ||
187 | 181 | ||
188 | /** Returns true if the catname is associated with any application | 182 | /** Returns true if the catname is associated with any application |
189 | */ | 183 | */ |
190 | bool exists( const QString &catname ) const; | 184 | bool exists( const QString &catname ) const; |
191 | bool exists( const QString &appname, const QString &catname) const; | 185 | bool exists( const QString &appname, const QString &catname) const; |
192 | 186 | ||
193 | bool save( const QString &fname ) const; | 187 | bool save( const QString &fname ) const; |
194 | bool load( const QString &fname ); | 188 | bool load( const QString &fname ); |
195 | 189 | ||
196 | // for debugging | 190 | // for debugging |
197 | void dump() const; | 191 | void dump() const; |
198 | 192 | ||
199 | const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } | 193 | const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } |
200 | const CategoryGroup &globalGroup() const { return mGlobalCats; } | 194 | const CategoryGroup &globalGroup() const { return mGlobalCats; } |
201 | 195 | ||
202 | signals: | 196 | signals: |
203 | /** emitted if added a category; | 197 | /** emitted if added a category; |
204 | * the second param is the application the category was added to | 198 | * the second param is the application the category was added to |
205 | * or null if global | 199 | * or null if global |
206 | * the third param is the uid of the newly added category | 200 | * the third param is the uid of the newly added category |
207 | */ | 201 | */ |
208 | void categoryAdded( const Categories &, const QString &, int ); | 202 | void categoryAdded( const Categories &, const QString &, int ); |
209 | /** emitted if removed a category | 203 | /** emitted if removed a category |
210 | * the second param is the application the category was removed from | 204 | * the second param is the application the category was removed from |
211 | * or null if global | 205 | * or null if global |
212 | * the third param is the uid of the removed category | 206 | * the third param is the uid of the removed category |
213 | */ | 207 | */ |
214 | void categoryRemoved( const Categories &, const QString &, int ); | 208 | void categoryRemoved( const Categories &, const QString &, int ); |
215 | /** emitted if a category is renamed; the second param is the uid of | 209 | /** emitted if a category is renamed; the second param is the uid of |
216 | * the removed category */ | 210 | * the removed category */ |
217 | void categoryRenamed( const Categories &, const QString &, int ); | 211 | void categoryRenamed( const Categories &, const QString &, int ); |
218 | 212 | ||
219 | private: | 213 | private: |
220 | CategoryGroup mGlobalCats; | 214 | CategoryGroup mGlobalCats; |
221 | QMap< QString, CategoryGroup > mAppCats; | 215 | QMap< QString, CategoryGroup > mAppCats; |
222 | }; | 216 | }; |
223 | 217 | ||
224 | class QPC_EXPORT CheckedListView : public QListView | 218 | class QPC_EXPORT CheckedListView : public QListView |
225 | { | 219 | { |
226 | public: | 220 | public: |
227 | void addCheckableList( const QStringList &options ); | 221 | void addCheckableList( const QStringList &options ); |
228 | void setChecked( const QStringList &checked ); | 222 | void setChecked( const QStringList &checked ); |
229 | QStringList checked() const; | 223 | QStringList checked() const; |
230 | }; | 224 | }; |
231 | 225 | ||
232 | #endif | 226 | #endif |
diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index a5f10ab..b10b19a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp | |||
@@ -1,909 +1,924 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | #define QTOPIA_INTERNAL_CONTACT_MRE | ||
22 | |||
21 | #include "contact.h" | 23 | #include "contact.h" |
22 | #include "vobject_p.h" | 24 | #include "vobject_p.h" |
23 | #include "qfiledirect_p.h" | 25 | #include "qfiledirect_p.h" |
24 | 26 | ||
25 | #include <qpe/stringutil.h> | 27 | #include <qpe/stringutil.h> |
26 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
27 | 29 | ||
28 | #include <qobject.h> | 30 | #include <qobject.h> |
29 | #include <qregexp.h> | 31 | #include <qregexp.h> |
30 | #include <qstylesheet.h> | 32 | #include <qstylesheet.h> |
31 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
32 | 34 | ||
33 | #include <stdio.h> | 35 | #include <stdio.h> |
34 | 36 | ||
35 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); | 37 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); |
36 | 38 | ||
37 | Contact::Contact() | 39 | Contact::Contact() |
38 | : Record(), mMap(), d( 0 ) | 40 | : Record(), mMap(), d( 0 ) |
39 | { | 41 | { |
40 | } | 42 | } |
41 | 43 | ||
42 | Contact::Contact( const QMap<int, QString> &fromMap ) : | 44 | Contact::Contact( const QMap<int, QString> &fromMap ) : |
43 | Record(), mMap( fromMap ), d( 0 ) | 45 | Record(), mMap( fromMap ), d( 0 ) |
44 | { | 46 | { |
45 | QString cats = mMap[ Qtopia::AddressCategory ]; | 47 | QString cats = mMap[ Qtopia::AddressCategory ]; |
46 | if ( !cats.isEmpty() ) | 48 | if ( !cats.isEmpty() ) |
47 | setCategories( idsFromString( cats ) ); | 49 | setCategories( idsFromString( cats ) ); |
48 | QString uidStr = find( Qtopia::AddressUid ); | 50 | QString uidStr = find( Qtopia::AddressUid ); |
49 | if ( uidStr.isEmpty() ) | 51 | if ( uidStr.isEmpty() ) |
50 | setUid( uidGen().generate() ); | 52 | setUid( uidGen().generate() ); |
51 | else | 53 | else |
52 | setUid( uidStr.toInt() ); | 54 | setUid( uidStr.toInt() ); |
53 | } | 55 | } |
54 | 56 | ||
55 | Contact::~Contact() | 57 | Contact::~Contact() |
56 | { | 58 | { |
57 | } | 59 | } |
58 | 60 | ||
59 | QMap<int, QString> Contact::toMap() const | 61 | QMap<int, QString> Contact::toMap() const |
60 | { | 62 | { |
61 | QMap<int, QString> map = mMap; | 63 | QMap<int, QString> map = mMap; |
62 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); | 64 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); |
63 | return map; | 65 | return map; |
64 | } | 66 | } |
65 | 67 | ||
66 | /*! | 68 | /*! |
67 | Returns a rich text formatted QString of the Contact. | 69 | Returns a rich text formatted QString of the Contact. |
68 | */ | 70 | */ |
69 | QString Contact::toRichText() const | 71 | QString Contact::toRichText() const |
70 | { | 72 | { |
71 | QString text; | 73 | QString text; |
72 | QString value, comp, state; | 74 | QString value, comp, state; |
73 | 75 | ||
74 | // name, jobtitle and company | 76 | // name, jobtitle and company |
75 | if ( !(value = fullName()).isEmpty() ) | 77 | if ( !(value = fullName()).isEmpty() ) |
76 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; | 78 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; |
77 | if ( !(value = jobTitle()).isEmpty() ) | 79 | if ( !(value = jobTitle()).isEmpty() ) |
78 | text += Qtopia::escapeString(value) + "<br>"; | 80 | text += Qtopia::escapeString(value) + "<br>"; |
79 | 81 | ||
80 | comp = company(); | 82 | comp = company(); |
81 | if ( !(value = department()).isEmpty() ) { | 83 | if ( !(value = department()).isEmpty() ) { |
82 | text += Qtopia::escapeString(value); | 84 | text += Qtopia::escapeString(value); |
83 | if ( comp ) | 85 | if ( comp ) |
84 | text += ", "; | 86 | text += ", "; |
85 | else | 87 | else |
86 | text += "<br>"; | 88 | text += "<br>"; |
87 | } | 89 | } |
88 | if ( !comp.isEmpty() ) | 90 | if ( !comp.isEmpty() ) |
89 | text += Qtopia::escapeString(comp) + "<br>"; | 91 | text += Qtopia::escapeString(comp) + "<br>"; |
90 | 92 | ||
91 | // business address | 93 | // business address |
92 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 94 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
93 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 95 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
94 | text += "<br>"; | 96 | text += "<br>"; |
95 | text += QObject::tr( "<b>Work Address:</b>" ); | 97 | text += QObject::tr( "<b>Work Address:</b>" ); |
96 | text += "<br>"; | 98 | text += "<br>"; |
97 | } | 99 | } |
98 | 100 | ||
99 | if ( !(value = businessStreet()).isEmpty() ) | 101 | if ( !(value = businessStreet()).isEmpty() ) |
100 | text += Qtopia::escapeString(value) + "<br>"; | 102 | text += Qtopia::escapeString(value) + "<br>"; |
101 | state = businessState(); | 103 | state = businessState(); |
102 | if ( !(value = businessCity()).isEmpty() ) { | 104 | if ( !(value = businessCity()).isEmpty() ) { |
103 | text += Qtopia::escapeString(value); | 105 | text += Qtopia::escapeString(value); |
104 | if ( state ) | 106 | if ( state ) |
105 | text += ", " + Qtopia::escapeString(state); | 107 | text += ", " + Qtopia::escapeString(state); |
106 | text += "<br>"; | 108 | text += "<br>"; |
107 | } else if ( !state.isEmpty() ) | 109 | } else if ( !state.isEmpty() ) |
108 | text += Qtopia::escapeString(state) + "<br>"; | 110 | text += Qtopia::escapeString(state) + "<br>"; |
109 | if ( !(value = businessZip()).isEmpty() ) | 111 | if ( !(value = businessZip()).isEmpty() ) |
110 | text += Qtopia::escapeString(value) + "<br>"; | 112 | text += Qtopia::escapeString(value) + "<br>"; |
111 | if ( !(value = businessCountry()).isEmpty() ) | 113 | if ( !(value = businessCountry()).isEmpty() ) |
112 | text += Qtopia::escapeString(value) + "<br>"; | 114 | text += Qtopia::escapeString(value) + "<br>"; |
113 | 115 | ||
114 | // home address | 116 | // home address |
115 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 117 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
116 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 118 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
117 | text += "<br>"; | 119 | text += "<br>"; |
118 | text += QObject::tr( "<b>Home Address:</b>" ); | 120 | text += QObject::tr( "<b>Home Address:</b>" ); |
119 | text += "<br>"; | 121 | text += "<br>"; |
120 | } | 122 | } |
121 | 123 | ||
122 | if ( !(value = homeStreet()).isEmpty() ) | 124 | if ( !(value = homeStreet()).isEmpty() ) |
123 | text += Qtopia::escapeString(value) + "<br>"; | 125 | text += Qtopia::escapeString(value) + "<br>"; |
124 | state = homeState(); | 126 | state = homeState(); |
125 | if ( !(value = homeCity()).isEmpty() ) { | 127 | if ( !(value = homeCity()).isEmpty() ) { |
126 | text += Qtopia::escapeString(value); | 128 | text += Qtopia::escapeString(value); |
127 | if ( !state.isEmpty() ) | 129 | if ( !state.isEmpty() ) |
128 | text += ", " + Qtopia::escapeString(state); | 130 | text += ", " + Qtopia::escapeString(state); |
129 | text += "<br>"; | 131 | text += "<br>"; |
130 | } else if (!state.isEmpty()) | 132 | } else if (!state.isEmpty()) |
131 | text += Qtopia::escapeString(state) + "<br>"; | 133 | text += Qtopia::escapeString(state) + "<br>"; |
132 | if ( !(value = homeZip()).isEmpty() ) | 134 | if ( !(value = homeZip()).isEmpty() ) |
133 | text += Qtopia::escapeString(value) + "<br>"; | 135 | text += Qtopia::escapeString(value) + "<br>"; |
134 | if ( !(value = homeCountry()).isEmpty() ) | 136 | if ( !(value = homeCountry()).isEmpty() ) |
135 | text += Qtopia::escapeString(value) + "<br>"; | 137 | text += Qtopia::escapeString(value) + "<br>"; |
136 | 138 | ||
137 | // the others... | 139 | // the others... |
138 | QString str; | 140 | QString str; |
139 | str = emails(); | 141 | str = emails(); |
140 | if ( !str.isEmpty() ) | 142 | if ( !str.isEmpty() ) |
141 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" | 143 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" |
142 | + Qtopia::escapeString(str) + "<br>"; | 144 | + Qtopia::escapeString(str) + "<br>"; |
143 | str = homePhone(); | 145 | str = homePhone(); |
144 | if ( !str.isEmpty() ) | 146 | if ( !str.isEmpty() ) |
145 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 147 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" |
146 | + Qtopia::escapeString(str) + "<br>"; | 148 | + Qtopia::escapeString(str) + "<br>"; |
147 | str = homeFax(); | 149 | str = homeFax(); |
148 | if ( !str.isEmpty() ) | 150 | if ( !str.isEmpty() ) |
149 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 151 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" |
150 | + Qtopia::escapeString(str) + "<br>"; | 152 | + Qtopia::escapeString(str) + "<br>"; |
151 | str = homeMobile(); | 153 | str = homeMobile(); |
152 | if ( !str.isEmpty() ) | 154 | if ( !str.isEmpty() ) |
153 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 155 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" |
154 | + Qtopia::escapeString(str) + "<br>"; | 156 | + Qtopia::escapeString(str) + "<br>"; |
155 | str = homeWebpage(); | 157 | str = homeWebpage(); |
156 | if ( !str.isEmpty() ) | 158 | if ( !str.isEmpty() ) |
157 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 159 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" |
158 | + Qtopia::escapeString(str) + "<br>"; | 160 | + Qtopia::escapeString(str) + "<br>"; |
159 | str = businessWebpage(); | 161 | str = businessWebpage(); |
160 | if ( !str.isEmpty() ) | 162 | if ( !str.isEmpty() ) |
161 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 163 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" |
162 | + Qtopia::escapeString(str) + "<br>"; | 164 | + Qtopia::escapeString(str) + "<br>"; |
163 | str = office(); | 165 | str = office(); |
164 | if ( !str.isEmpty() ) | 166 | if ( !str.isEmpty() ) |
165 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 167 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
166 | + Qtopia::escapeString(str) + "<br>"; | 168 | + Qtopia::escapeString(str) + "<br>"; |
167 | str = businessPhone(); | 169 | str = businessPhone(); |
168 | if ( !str.isEmpty() ) | 170 | if ( !str.isEmpty() ) |
169 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 171 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" |
170 | + Qtopia::escapeString(str) + "<br>"; | 172 | + Qtopia::escapeString(str) + "<br>"; |
171 | str = businessFax(); | 173 | str = businessFax(); |
172 | if ( !str.isEmpty() ) | 174 | if ( !str.isEmpty() ) |
173 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 175 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" |
174 | + Qtopia::escapeString(str) + "<br>"; | 176 | + Qtopia::escapeString(str) + "<br>"; |
175 | str = businessMobile(); | 177 | str = businessMobile(); |
176 | if ( !str.isEmpty() ) | 178 | if ( !str.isEmpty() ) |
177 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 179 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" |
178 | + Qtopia::escapeString(str) + "<br>"; | 180 | + Qtopia::escapeString(str) + "<br>"; |
179 | str = businessPager(); | 181 | str = businessPager(); |
180 | if ( !str.isEmpty() ) | 182 | if ( !str.isEmpty() ) |
181 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 183 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
182 | + Qtopia::escapeString(str) + "<br>"; | 184 | + Qtopia::escapeString(str) + "<br>"; |
183 | str = profession(); | 185 | str = profession(); |
184 | if ( !str.isEmpty() ) | 186 | if ( !str.isEmpty() ) |
185 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 187 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
186 | + Qtopia::escapeString(str) + "<br>"; | 188 | + Qtopia::escapeString(str) + "<br>"; |
187 | str = assistant(); | 189 | str = assistant(); |
188 | if ( !str.isEmpty() ) | 190 | if ( !str.isEmpty() ) |
189 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 191 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
190 | + Qtopia::escapeString(str) + "<br>"; | 192 | + Qtopia::escapeString(str) + "<br>"; |
191 | str = manager(); | 193 | str = manager(); |
192 | if ( !str.isEmpty() ) | 194 | if ( !str.isEmpty() ) |
193 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 195 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
194 | + Qtopia::escapeString(str) + "<br>"; | 196 | + Qtopia::escapeString(str) + "<br>"; |
195 | str = gender(); | 197 | str = gender(); |
196 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 198 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
197 | if ( str.toInt() == 1 ) | 199 | if ( str.toInt() == 1 ) |
198 | str = QObject::tr( "Male" ); | 200 | str = QObject::tr( "Male" ); |
199 | else if ( str.toInt() == 2 ) | 201 | else if ( str.toInt() == 2 ) |
200 | str = QObject::tr( "Female" ); | 202 | str = QObject::tr( "Female" ); |
201 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 203 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
202 | } | 204 | } |
203 | str = spouse(); | 205 | str = spouse(); |
204 | if ( !str.isEmpty() ) | 206 | if ( !str.isEmpty() ) |
205 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 207 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
206 | + Qtopia::escapeString(str) + "<br>"; | 208 | + Qtopia::escapeString(str) + "<br>"; |
207 | str = birthday(); | 209 | str = birthday(); |
208 | if ( !str.isEmpty() ) | 210 | if ( !str.isEmpty() ) |
209 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 211 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
210 | + Qtopia::escapeString(str) + "<br>"; | 212 | + Qtopia::escapeString(str) + "<br>"; |
211 | str = anniversary(); | 213 | str = anniversary(); |
212 | if ( !str.isEmpty() ) | 214 | if ( !str.isEmpty() ) |
213 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 215 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
214 | + Qtopia::escapeString(str) + "<br>"; | 216 | + Qtopia::escapeString(str) + "<br>"; |
215 | str = nickname(); | 217 | str = nickname(); |
216 | if ( !str.isEmpty() ) | 218 | if ( !str.isEmpty() ) |
217 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 219 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
218 | + Qtopia::escapeString(str) + "<br>"; | 220 | + Qtopia::escapeString(str) + "<br>"; |
219 | 221 | ||
220 | // notes last | 222 | // notes last |
221 | if ( (value = notes()) ) { | 223 | if ( (value = notes()) ) { |
222 | QRegExp reg("\n"); | 224 | QRegExp reg("\n"); |
223 | 225 | ||
224 | //QString tmp = Qtopia::escapeString(value); | 226 | //QString tmp = Qtopia::escapeString(value); |
225 | QString tmp = QStyleSheet::convertFromPlainText(value); | 227 | QString tmp = QStyleSheet::convertFromPlainText(value); |
226 | //tmp.replace( reg, "<br>" ); | 228 | //tmp.replace( reg, "<br>" ); |
227 | text += "<br>" + tmp + "<br>"; | 229 | text += "<br>" + tmp + "<br>"; |
228 | } | 230 | } |
229 | return text; | 231 | return text; |
230 | } | 232 | } |
231 | 233 | ||
232 | void Contact::insert( int key, const QString &v ) | 234 | void Contact::insert( int key, const QString &v ) |
233 | { | 235 | { |
234 | QString value = v.stripWhiteSpace(); | 236 | QString value = v.stripWhiteSpace(); |
235 | if ( value.isEmpty() ) | 237 | if ( value.isEmpty() ) |
236 | mMap.remove( key ); | 238 | mMap.remove( key ); |
237 | else | 239 | else |
238 | mMap.insert( key, value ); | 240 | mMap.insert( key, value ); |
239 | } | 241 | } |
240 | 242 | ||
241 | void Contact::replace( int key, const QString & v ) | 243 | void Contact::replace( int key, const QString & v ) |
242 | { | 244 | { |
243 | QString value = v.stripWhiteSpace(); | 245 | QString value = v.stripWhiteSpace(); |
244 | if ( value.isEmpty() ) | 246 | if ( value.isEmpty() ) |
245 | mMap.remove( key ); | 247 | mMap.remove( key ); |
246 | else | 248 | else |
247 | mMap.replace( key, value ); | 249 | mMap.replace( key, value ); |
248 | } | 250 | } |
249 | 251 | ||
250 | QString Contact::find( int key ) const | 252 | QString Contact::find( int key ) const |
251 | { | 253 | { |
252 | return mMap[key]; | 254 | return mMap[key]; |
253 | } | 255 | } |
254 | 256 | ||
255 | QString Contact::displayAddress( const QString &street, | 257 | QString Contact::displayAddress( const QString &street, |
256 | const QString &city, | 258 | const QString &city, |
257 | const QString &state, | 259 | const QString &state, |
258 | const QString &zip, | 260 | const QString &zip, |
259 | const QString &country ) const | 261 | const QString &country ) const |
260 | { | 262 | { |
261 | QString s = street; | 263 | QString s = street; |
262 | if ( !street.isEmpty() ) | 264 | if ( !street.isEmpty() ) |
263 | s+= "\n"; | 265 | s+= "\n"; |
264 | s += city; | 266 | s += city; |
265 | if ( !city.isEmpty() && !state.isEmpty() ) | 267 | if ( !city.isEmpty() && !state.isEmpty() ) |
266 | s += ", "; | 268 | s += ", "; |
267 | s += state; | 269 | s += state; |
268 | if ( !state.isEmpty() && !zip.isEmpty() ) | 270 | if ( !state.isEmpty() && !zip.isEmpty() ) |
269 | s += " "; | 271 | s += " "; |
270 | s += zip; | 272 | s += zip; |
271 | if ( !country.isEmpty() && !s.isEmpty() ) | 273 | if ( !country.isEmpty() && !s.isEmpty() ) |
272 | s += "\n"; | 274 | s += "\n"; |
273 | s += country; | 275 | s += country; |
274 | return s; | 276 | return s; |
275 | } | 277 | } |
276 | 278 | ||
277 | QString Contact::displayBusinessAddress() const | 279 | QString Contact::displayBusinessAddress() const |
278 | { | 280 | { |
279 | return displayAddress( businessStreet(), businessCity(), | 281 | return displayAddress( businessStreet(), businessCity(), |
280 | businessState(), businessZip(), | 282 | businessState(), businessZip(), |
281 | businessCountry() ); | 283 | businessCountry() ); |
282 | } | 284 | } |
283 | 285 | ||
284 | QString Contact::displayHomeAddress() const | 286 | QString Contact::displayHomeAddress() const |
285 | { | 287 | { |
286 | return displayAddress( homeStreet(), homeCity(), | 288 | return displayAddress( homeStreet(), homeCity(), |
287 | homeState(), homeZip(), | 289 | homeState(), homeZip(), |
288 | homeCountry() ); | 290 | homeCountry() ); |
289 | } | 291 | } |
290 | 292 | ||
291 | QString Contact::fullName() const | 293 | QString Contact::fullName() const |
292 | { | 294 | { |
293 | QString title = find( Qtopia::Title ); | 295 | QString title = find( Qtopia::Title ); |
294 | QString firstName = find( Qtopia::FirstName ); | 296 | QString firstName = find( Qtopia::FirstName ); |
295 | QString middleName = find( Qtopia::MiddleName ); | 297 | QString middleName = find( Qtopia::MiddleName ); |
296 | QString lastName = find( Qtopia::LastName ); | 298 | QString lastName = find( Qtopia::LastName ); |
297 | QString suffix = find( Qtopia::Suffix ); | 299 | QString suffix = find( Qtopia::Suffix ); |
298 | 300 | ||
299 | QString name = title; | 301 | QString name = title; |
300 | if ( !firstName.isEmpty() ) { | 302 | if ( !firstName.isEmpty() ) { |
301 | if ( !name.isEmpty() ) | 303 | if ( !name.isEmpty() ) |
302 | name += " "; | 304 | name += " "; |
303 | name += firstName; | 305 | name += firstName; |
304 | } | 306 | } |
305 | if ( !middleName.isEmpty() ) { | 307 | if ( !middleName.isEmpty() ) { |
306 | if ( !name.isEmpty() ) | 308 | if ( !name.isEmpty() ) |
307 | name += " "; | 309 | name += " "; |
308 | name += middleName; | 310 | name += middleName; |
309 | } | 311 | } |
310 | if ( !lastName.isEmpty() ) { | 312 | if ( !lastName.isEmpty() ) { |
311 | if ( !name.isEmpty() ) | 313 | if ( !name.isEmpty() ) |
312 | name += " "; | 314 | name += " "; |
313 | name += lastName; | 315 | name += lastName; |
314 | } | 316 | } |
315 | if ( !suffix.isEmpty() ) { | 317 | if ( !suffix.isEmpty() ) { |
316 | if ( !name.isEmpty() ) | 318 | if ( !name.isEmpty() ) |
317 | name += " "; | 319 | name += " "; |
318 | name += suffix; | 320 | name += suffix; |
319 | } | 321 | } |
320 | return name.simplifyWhiteSpace(); | 322 | return name.simplifyWhiteSpace(); |
321 | } | 323 | } |
322 | 324 | ||
323 | QStringList Contact::childrenList() const | 325 | QStringList Contact::childrenList() const |
324 | { | 326 | { |
325 | return QStringList::split( " ", find( Qtopia::Children ) ); | 327 | return QStringList::split( " ", find( Qtopia::Children ) ); |
326 | } | 328 | } |
327 | 329 | ||
328 | QStringList Contact::emailList() const | 330 | QStringList Contact::emailList() const |
329 | { | 331 | { |
330 | return QStringList::split( ";", find( Qtopia::Emails ) ); | 332 | return QStringList::split( ";", find( Qtopia::Emails ) ); |
331 | } | 333 | } |
332 | 334 | ||
333 | void Contact::setFileAs() | 335 | void Contact::setFileAs() |
334 | { | 336 | { |
335 | QString lastName, firstName, middleName, fileas; | 337 | QString lastName, firstName, middleName, fileas; |
336 | 338 | ||
337 | lastName = find( Qtopia::LastName ); | 339 | lastName = find( Qtopia::LastName ); |
338 | firstName = find( Qtopia::FirstName ); | 340 | firstName = find( Qtopia::FirstName ); |
339 | middleName = find( Qtopia::MiddleName ); | 341 | middleName = find( Qtopia::MiddleName ); |
340 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 342 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
341 | && !middleName.isEmpty() ) | 343 | && !middleName.isEmpty() ) |
342 | fileas = lastName + ", " + firstName + " " + middleName; | 344 | fileas = lastName + ", " + firstName + " " + middleName; |
343 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 345 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
344 | fileas = lastName + ", " + firstName; | 346 | fileas = lastName + ", " + firstName; |
345 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 347 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
346 | !middleName.isEmpty() ) | 348 | !middleName.isEmpty() ) |
347 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 349 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
348 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 350 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
349 | + lastName; | 351 | + lastName; |
350 | 352 | ||
351 | replace( Qtopia::FileAs, fileas ); | 353 | replace( Qtopia::FileAs, fileas ); |
352 | } | 354 | } |
353 | 355 | ||
354 | void Contact::save( QString &buf ) const | 356 | void Contact::save( QString &buf ) const |
355 | { | 357 | { |
356 | static const QStringList SLFIELDS = fields(); | 358 | static const QStringList SLFIELDS = fields(); |
357 | // I'm expecting "<Contact " in front of this... | 359 | // I'm expecting "<Contact " in front of this... |
358 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 360 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
359 | it != mMap.end(); ++it ) { | 361 | it != mMap.end(); ++it ) { |
360 | const QString &value = it.data(); | 362 | const QString &value = it.data(); |
361 | int key = it.key(); | 363 | int key = it.key(); |
362 | if ( !value.isEmpty() ) { | 364 | if ( !value.isEmpty() ) { |
363 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 365 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
364 | continue; | 366 | continue; |
365 | 367 | ||
366 | key -= Qtopia::AddressCategory+1; | 368 | key -= Qtopia::AddressCategory+1; |
367 | buf += SLFIELDS[key]; | 369 | buf += SLFIELDS[key]; |
368 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 370 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
369 | } | 371 | } |
370 | } | 372 | } |
371 | buf += customToXml(); | 373 | buf += customToXml(); |
372 | if ( categories().count() > 0 ) | 374 | if ( categories().count() > 0 ) |
373 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 375 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
374 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 376 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
375 | // You need to close this yourself | 377 | // You need to close this yourself |
376 | } | 378 | } |
377 | 379 | ||
378 | QStringList Contact::fields() | 380 | QStringList Contact::fields() |
379 | { | 381 | { |
380 | QStringList list; | 382 | QStringList list; |
381 | 383 | ||
382 | list.append( "Title" ); // Not Used! | 384 | list.append( "Title" ); // Not Used! |
383 | list.append( "FirstName" ); | 385 | list.append( "FirstName" ); |
384 | list.append( "MiddleName" ); | 386 | list.append( "MiddleName" ); |
385 | list.append( "LastName" ); | 387 | list.append( "LastName" ); |
386 | list.append( "Suffix" ); | 388 | list.append( "Suffix" ); |
387 | list.append( "FileAs" ); | 389 | list.append( "FileAs" ); |
388 | 390 | ||
391 | list.append( "JobTitle" ); | ||
392 | list.append( "Department" ); | ||
393 | list.append( "Company" ); | ||
394 | list.append( "BusinessPhone" ); | ||
395 | list.append( "BusinessFax" ); | ||
396 | list.append( "BusinessMobile" ); | ||
397 | |||
389 | list.append( "DefaultEmail" ); | 398 | list.append( "DefaultEmail" ); |
390 | list.append( "Emails" ); | 399 | list.append( "Emails" ); |
391 | 400 | ||
392 | list.append( "HomeStreet" ); | ||
393 | list.append( "HomeCity" ); | ||
394 | list.append( "HomeState" ); | ||
395 | list.append( "HomeZip" ); | ||
396 | list.append( "HomeCountry" ); | ||
397 | list.append( "HomePhone" ); | 401 | list.append( "HomePhone" ); |
398 | list.append( "HomeFax" ); | 402 | list.append( "HomeFax" ); |
399 | list.append( "HomeMobile" ); | 403 | list.append( "HomeMobile" ); |
400 | list.append( "HomeWebPage" ); | ||
401 | 404 | ||
402 | list.append( "Company" ); | ||
403 | list.append( "BusinessStreet" ); | 405 | list.append( "BusinessStreet" ); |
404 | list.append( "BusinessCity" ); | 406 | list.append( "BusinessCity" ); |
405 | list.append( "BusinessState" ); | 407 | list.append( "BusinessState" ); |
406 | list.append( "BusinessZip" ); | 408 | list.append( "BusinessZip" ); |
407 | list.append( "BusinessCountry" ); | 409 | list.append( "BusinessCountry" ); |
410 | list.append( "BusinessPager" ); | ||
408 | list.append( "BusinessWebPage" ); | 411 | list.append( "BusinessWebPage" ); |
409 | list.append( "JobTitle" ); | 412 | |
410 | list.append( "Department" ); | ||
411 | list.append( "Office" ); | 413 | list.append( "Office" ); |
412 | list.append( "BusinessPhone" ); | ||
413 | list.append( "BusinessFax" ); | ||
414 | list.append( "BusinessMobile" ); | ||
415 | list.append( "BusinessPager" ); | ||
416 | list.append( "Profession" ); | 414 | list.append( "Profession" ); |
417 | list.append( "Assistant" ); | 415 | list.append( "Assistant" ); |
418 | list.append( "Manager" ); | 416 | list.append( "Manager" ); |
419 | 417 | ||
418 | list.append( "HomeStreet" ); | ||
419 | list.append( "HomeCity" ); | ||
420 | list.append( "HomeState" ); | ||
421 | list.append( "HomeZip" ); | ||
422 | list.append( "HomeCountry" ); | ||
423 | list.append( "HomeWebPage" ); | ||
424 | |||
420 | list.append( "Spouse" ); | 425 | list.append( "Spouse" ); |
421 | list.append( "Gender" ); | 426 | list.append( "Gender" ); |
422 | list.append( "Birthday" ); | 427 | list.append( "Birthday" ); |
423 | list.append( "Anniversary" ); | 428 | list.append( "Anniversary" ); |
424 | list.append( "Nickname" ); | 429 | list.append( "Nickname" ); |
425 | |||
426 | list.append( "Children" ); | 430 | list.append( "Children" ); |
431 | |||
427 | list.append( "Notes" ); | 432 | list.append( "Notes" ); |
433 | list.append( "Groups" ); | ||
428 | 434 | ||
429 | return list; | 435 | return list; |
430 | } | 436 | } |
431 | 437 | ||
432 | QStringList Contact::trfields() | 438 | QStringList Contact::trfields() |
433 | { | 439 | { |
434 | QStringList list; | 440 | QStringList list; |
435 | 441 | ||
436 | list.append( QObject::tr( "Name Title") ); | 442 | list.append( QObject::tr( "Name Title") ); |
437 | list.append( QObject::tr( "First Name" ) ); | 443 | list.append( QObject::tr( "First Name" ) ); |
438 | list.append( QObject::tr( "Middle Name" ) ); | 444 | list.append( QObject::tr( "Middle Name" ) ); |
439 | list.append( QObject::tr( "Last Name" ) ); | 445 | list.append( QObject::tr( "Last Name" ) ); |
440 | list.append( QObject::tr( "Suffix" ) ); | 446 | list.append( QObject::tr( "Suffix" ) ); |
441 | list.append( QObject::tr( "File As" ) ); | 447 | list.append( QObject::tr( "File As" ) ); |
442 | 448 | ||
449 | list.append( QObject::tr( "Job Title" ) ); | ||
450 | list.append( QObject::tr( "Department" ) ); | ||
451 | list.append( QObject::tr( "Company" ) ); | ||
452 | list.append( QObject::tr( "Business Phone" ) ); | ||
453 | list.append( QObject::tr( "Business Fax" ) ); | ||
454 | list.append( QObject::tr( "Business Mobile" ) ); | ||
455 | |||
443 | list.append( QObject::tr( "Default Email" ) ); | 456 | list.append( QObject::tr( "Default Email" ) ); |
444 | list.append( QObject::tr( "Emails" ) ); | 457 | list.append( QObject::tr( "Emails" ) ); |
445 | 458 | ||
446 | list.append( QObject::tr( "Home Street" ) ); | ||
447 | list.append( QObject::tr( "Home City" ) ); | ||
448 | list.append( QObject::tr( "Home State" ) ); | ||
449 | list.append( QObject::tr( "Home Zip" ) ); | ||
450 | list.append( QObject::tr( "Home Country" ) ); | ||
451 | list.append( QObject::tr( "Home Phone" ) ); | 459 | list.append( QObject::tr( "Home Phone" ) ); |
452 | list.append( QObject::tr( "Home Fax" ) ); | 460 | list.append( QObject::tr( "Home Fax" ) ); |
453 | list.append( QObject::tr( "Home Mobile" ) ); | 461 | list.append( QObject::tr( "Home Mobile" ) ); |
454 | list.append( QObject::tr( "Home Web Page" ) ); | ||
455 | 462 | ||
456 | list.append( QObject::tr( "Company" ) ); | ||
457 | list.append( QObject::tr( "Business Street" ) ); | 463 | list.append( QObject::tr( "Business Street" ) ); |
458 | list.append( QObject::tr( "Business City" ) ); | 464 | list.append( QObject::tr( "Business City" ) ); |
459 | list.append( QObject::tr( "Business State" ) ); | 465 | list.append( QObject::tr( "Business State" ) ); |
460 | list.append( QObject::tr( "Business Zip" ) ); | 466 | list.append( QObject::tr( "Business Zip" ) ); |
461 | list.append( QObject::tr( "Business Country" ) ); | 467 | list.append( QObject::tr( "Business Country" ) ); |
468 | list.append( QObject::tr( "Business Pager" ) ); | ||
462 | list.append( QObject::tr( "Business WebPage" ) ); | 469 | list.append( QObject::tr( "Business WebPage" ) ); |
463 | list.append( QObject::tr( "Job Title" ) ); | 470 | |
464 | list.append( QObject::tr( "Department" ) ); | ||
465 | list.append( QObject::tr( "Office" ) ); | 471 | list.append( QObject::tr( "Office" ) ); |
466 | list.append( QObject::tr( "Business Phone" ) ); | ||
467 | list.append( QObject::tr( "Business Fax" ) ); | ||
468 | list.append( QObject::tr( "Business Mobile" ) ); | ||
469 | list.append( QObject::tr( "Business Pager" ) ); | ||
470 | list.append( QObject::tr( "Profession" ) ); | 472 | list.append( QObject::tr( "Profession" ) ); |
471 | list.append( QObject::tr( "Assistant" ) ); | 473 | list.append( QObject::tr( "Assistant" ) ); |
472 | list.append( QObject::tr( "Manager" ) ); | 474 | list.append( QObject::tr( "Manager" ) ); |
473 | 475 | ||
476 | list.append( QObject::tr( "Home Street" ) ); | ||
477 | list.append( QObject::tr( "Home City" ) ); | ||
478 | list.append( QObject::tr( "Home State" ) ); | ||
479 | list.append( QObject::tr( "Home Zip" ) ); | ||
480 | list.append( QObject::tr( "Home Country" ) ); | ||
481 | list.append( QObject::tr( "Home Web Page" ) ); | ||
482 | |||
474 | list.append( QObject::tr( "Spouse" ) ); | 483 | list.append( QObject::tr( "Spouse" ) ); |
475 | list.append( QObject::tr( "Gender" ) ); | 484 | list.append( QObject::tr( "Gender" ) ); |
476 | list.append( QObject::tr( "Birthday" ) ); | 485 | list.append( QObject::tr( "Birthday" ) ); |
477 | list.append( QObject::tr( "Anniversary" ) ); | 486 | list.append( QObject::tr( "Anniversary" ) ); |
478 | list.append( QObject::tr( "Nickname" ) ); | 487 | list.append( QObject::tr( "Nickname" ) ); |
479 | |||
480 | list.append( QObject::tr( "Children" ) ); | 488 | list.append( QObject::tr( "Children" ) ); |
489 | |||
481 | list.append( QObject::tr( "Notes" ) ); | 490 | list.append( QObject::tr( "Notes" ) ); |
491 | list.append( QObject::tr( "Groups" ) ); | ||
482 | 492 | ||
483 | return list; | 493 | return list; |
484 | } | 494 | } |
485 | 495 | ||
486 | void Contact::setEmails( const QString &v ) | 496 | void Contact::setEmails( const QString &v ) |
487 | { | 497 | { |
488 | replace( Qtopia::Emails, v ); | 498 | replace( Qtopia::Emails, v ); |
489 | if ( v.isEmpty() ) | 499 | if ( v.isEmpty() ) |
490 | setDefaultEmail( QString::null ); | 500 | setDefaultEmail( QString::null ); |
491 | } | 501 | } |
492 | 502 | ||
493 | void Contact::setChildren( const QString &v ) | 503 | void Contact::setChildren( const QString &v ) |
494 | { | 504 | { |
495 | replace( Qtopia::Children, v ); | 505 | replace( Qtopia::Children, v ); |
496 | } | 506 | } |
497 | 507 | ||
498 | // vcard conversion code | 508 | // vcard conversion code |
499 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 509 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
500 | { | 510 | { |
501 | VObject *ret = 0; | 511 | VObject *ret = 0; |
502 | if ( o && !value.isEmpty() ) | 512 | if ( o && !value.isEmpty() ) |
503 | ret = addPropValue( o, prop, value.latin1() ); | 513 | ret = addPropValue( o, prop, value.latin1() ); |
504 | return ret; | 514 | return ret; |
505 | } | 515 | } |
506 | 516 | ||
507 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 517 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
508 | { | 518 | { |
509 | VObject *ret = 0; | 519 | VObject *ret = 0; |
510 | if ( o ) | 520 | if ( o ) |
511 | ret = addProp( o, prop ); | 521 | ret = addProp( o, prop ); |
512 | return ret; | 522 | return ret; |
513 | } | 523 | } |
514 | 524 | ||
515 | static VObject *createVObject( const Contact &c ) | 525 | static VObject *createVObject( const Contact &c ) |
516 | { | 526 | { |
517 | VObject *vcard = newVObject( VCCardProp ); | 527 | VObject *vcard = newVObject( VCCardProp ); |
518 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 528 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
519 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 529 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
520 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 530 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
521 | 531 | ||
522 | // full name | 532 | // full name |
523 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 533 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
524 | 534 | ||
525 | // name properties | 535 | // name properties |
526 | VObject *name = safeAddProp( vcard, VCNameProp ); | 536 | VObject *name = safeAddProp( vcard, VCNameProp ); |
527 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 537 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
528 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 538 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
529 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 539 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
530 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 540 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
531 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 541 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
532 | 542 | ||
533 | // home properties | 543 | // home properties |
534 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 544 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
535 | safeAddProp( home_adr, VCHomeProp ); | 545 | safeAddProp( home_adr, VCHomeProp ); |
536 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 546 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
537 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 547 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
538 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 548 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
539 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 549 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
540 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 550 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
541 | 551 | ||
542 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 552 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
543 | safeAddProp( home_phone, VCHomeProp ); | 553 | safeAddProp( home_phone, VCHomeProp ); |
544 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 554 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
545 | safeAddProp( home_phone, VCHomeProp ); | 555 | safeAddProp( home_phone, VCHomeProp ); |
546 | safeAddProp( home_phone, VCCellularProp ); | 556 | safeAddProp( home_phone, VCCellularProp ); |
547 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 557 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
548 | safeAddProp( home_phone, VCHomeProp ); | 558 | safeAddProp( home_phone, VCHomeProp ); |
549 | safeAddProp( home_phone, VCFaxProp ); | 559 | safeAddProp( home_phone, VCFaxProp ); |
550 | 560 | ||
551 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 561 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
552 | safeAddProp( url, VCHomeProp ); | 562 | safeAddProp( url, VCHomeProp ); |
553 | 563 | ||
554 | // work properties | 564 | // work properties |
555 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 565 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
556 | safeAddProp( work_adr, VCWorkProp ); | 566 | safeAddProp( work_adr, VCWorkProp ); |
557 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 567 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
558 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 568 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
559 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 569 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
560 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 570 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
561 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 571 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
562 | 572 | ||
563 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 573 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
564 | safeAddProp( work_phone, VCWorkProp ); | 574 | safeAddProp( work_phone, VCWorkProp ); |
565 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 575 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
566 | safeAddProp( work_phone, VCWorkProp ); | 576 | safeAddProp( work_phone, VCWorkProp ); |
567 | safeAddProp( work_phone, VCCellularProp ); | 577 | safeAddProp( work_phone, VCCellularProp ); |
568 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 578 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
569 | safeAddProp( work_phone, VCWorkProp ); | 579 | safeAddProp( work_phone, VCWorkProp ); |
570 | safeAddProp( work_phone, VCFaxProp ); | 580 | safeAddProp( work_phone, VCFaxProp ); |
571 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 581 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
572 | safeAddProp( work_phone, VCWorkProp ); | 582 | safeAddProp( work_phone, VCWorkProp ); |
573 | safeAddProp( work_phone, VCPagerProp ); | 583 | safeAddProp( work_phone, VCPagerProp ); |
574 | 584 | ||
575 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 585 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
576 | safeAddProp( url, VCWorkProp ); | 586 | safeAddProp( url, VCWorkProp ); |
577 | 587 | ||
578 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 588 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
579 | safeAddProp( title, VCWorkProp ); | 589 | safeAddProp( title, VCWorkProp ); |
580 | 590 | ||
581 | 591 | ||
582 | QStringList emails = c.emailList(); | 592 | QStringList emails = c.emailList(); |
583 | emails.prepend( c.defaultEmail() ); | 593 | emails.prepend( c.defaultEmail() ); |
584 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 594 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
585 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 595 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
586 | safeAddProp( email, VCInternetProp ); | 596 | safeAddProp( email, VCInternetProp ); |
587 | } | 597 | } |
588 | 598 | ||
589 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 599 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
590 | 600 | ||
591 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); | 601 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); |
592 | 602 | ||
593 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 603 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
594 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 604 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
595 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 605 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
596 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 606 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
597 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 607 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
598 | } | 608 | } |
599 | 609 | ||
600 | // some values we have to export as custom fields | 610 | // some values we have to export as custom fields |
601 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 611 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
602 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 612 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
603 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 613 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
604 | 614 | ||
605 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 615 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
606 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 616 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
607 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); | 617 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); |
608 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 618 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
609 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 619 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
610 | 620 | ||
611 | return vcard; | 621 | return vcard; |
612 | } | 622 | } |
613 | 623 | ||
614 | 624 | ||
615 | static Contact parseVObject( VObject *obj ) | 625 | static Contact parseVObject( VObject *obj ) |
616 | { | 626 | { |
617 | Contact c; | 627 | Contact c; |
618 | 628 | ||
619 | bool haveDefaultEmail = FALSE; | 629 | bool haveDefaultEmail = FALSE; |
620 | 630 | ||
621 | VObjectIterator it; | 631 | VObjectIterator it; |
622 | initPropIterator( &it, obj ); | 632 | initPropIterator( &it, obj ); |
623 | while( moreIteration( &it ) ) { | 633 | while( moreIteration( &it ) ) { |
624 | VObject *o = nextVObject( &it ); | 634 | VObject *o = nextVObject( &it ); |
625 | QCString name = vObjectName( o ); | 635 | QCString name = vObjectName( o ); |
626 | QCString value = vObjectStringZValue( o ); | 636 | QCString value = vObjectStringZValue( o ); |
627 | if ( name == VCNameProp ) { | 637 | if ( name == VCNameProp ) { |
628 | VObjectIterator nit; | 638 | VObjectIterator nit; |
629 | initPropIterator( &nit, o ); | 639 | initPropIterator( &nit, o ); |
630 | while( moreIteration( &nit ) ) { | 640 | while( moreIteration( &nit ) ) { |
631 | VObject *o = nextVObject( &nit ); | 641 | VObject *o = nextVObject( &nit ); |
632 | QCString name = vObjectName( o ); | 642 | QCString name = vObjectTypeInfo( o ); |
633 | QString value = vObjectStringZValue( o ); | 643 | QString value = vObjectStringZValue( o ); |
634 | if ( name == VCNamePrefixesProp ) | 644 | if ( name == VCNamePrefixesProp ) |
635 | c.setTitle( value ); | 645 | c.setTitle( value ); |
636 | else if ( name == VCNameSuffixesProp ) | 646 | else if ( name == VCNameSuffixesProp ) |
637 | c.setSuffix( value ); | 647 | c.setSuffix( value ); |
638 | else if ( name == VCFamilyNameProp ) | 648 | else if ( name == VCFamilyNameProp ) |
639 | c.setLastName( value ); | 649 | c.setLastName( value ); |
640 | else if ( name == VCGivenNameProp ) | 650 | else if ( name == VCGivenNameProp ) |
641 | c.setFirstName( value ); | 651 | c.setFirstName( value ); |
642 | else if ( name == VCAdditionalNamesProp ) | 652 | else if ( name == VCAdditionalNamesProp ) |
643 | c.setMiddleName( value ); | 653 | c.setMiddleName( value ); |
644 | } | 654 | } |
645 | } | 655 | } |
646 | else if ( name == VCAdrProp ) { | 656 | else if ( name == VCAdrProp ) { |
647 | bool work = TRUE; // default address is work address | 657 | bool work = TRUE; // default address is work address |
648 | QString street; | 658 | QString street; |
649 | QString city; | 659 | QString city; |
650 | QString region; | 660 | QString region; |
651 | QString postal; | 661 | QString postal; |
652 | QString country; | 662 | QString country; |
653 | 663 | ||
654 | VObjectIterator nit; | 664 | VObjectIterator nit; |
655 | initPropIterator( &nit, o ); | 665 | initPropIterator( &nit, o ); |
656 | while( moreIteration( &nit ) ) { | 666 | while( moreIteration( &nit ) ) { |
657 | VObject *o = nextVObject( &nit ); | 667 | VObject *o = nextVObject( &nit ); |
658 | QCString name = vObjectName( o ); | 668 | QCString name = vObjectName( o ); |
659 | QString value = vObjectStringZValue( o ); | 669 | QString value = vObjectStringZValue( o ); |
660 | if ( name == VCHomeProp ) | 670 | if ( name == VCHomeProp ) |
661 | work = FALSE; | 671 | work = FALSE; |
662 | else if ( name == VCWorkProp ) | 672 | else if ( name == VCWorkProp ) |
663 | work = TRUE; | 673 | work = TRUE; |
664 | else if ( name == VCStreetAddressProp ) | 674 | else if ( name == VCStreetAddressProp ) |
665 | street = value; | 675 | street = value; |
666 | else if ( name == VCCityProp ) | 676 | else if ( name == VCCityProp ) |
667 | city = value; | 677 | city = value; |
668 | else if ( name == VCRegionProp ) | 678 | else if ( name == VCRegionProp ) |
669 | region = value; | 679 | region = value; |
670 | else if ( name == VCPostalCodeProp ) | 680 | else if ( name == VCPostalCodeProp ) |
671 | postal = value; | 681 | postal = value; |
672 | else if ( name == VCCountryNameProp ) | 682 | else if ( name == VCCountryNameProp ) |
673 | country = value; | 683 | country = value; |
674 | } | 684 | } |
675 | if ( work ) { | 685 | if ( work ) { |
676 | c.setBusinessStreet( street ); | 686 | c.setBusinessStreet( street ); |
677 | c.setBusinessCity( city ); | 687 | c.setBusinessCity( city ); |
678 | c.setBusinessCountry( country ); | 688 | c.setBusinessCountry( country ); |
679 | c.setBusinessZip( postal ); | 689 | c.setBusinessZip( postal ); |
680 | c.setBusinessState( region ); | 690 | c.setBusinessState( region ); |
681 | } else { | 691 | } else { |
682 | c.setHomeStreet( street ); | 692 | c.setHomeStreet( street ); |
683 | c.setHomeCity( city ); | 693 | c.setHomeCity( city ); |
684 | c.setHomeCountry( country ); | 694 | c.setHomeCountry( country ); |
685 | c.setHomeZip( postal ); | 695 | c.setHomeZip( postal ); |
686 | c.setHomeState( region ); | 696 | c.setHomeState( region ); |
687 | } | 697 | } |
688 | } | 698 | } |
689 | else if ( name == VCTelephoneProp ) { | 699 | else if ( name == VCTelephoneProp ) { |
690 | enum { | 700 | enum { |
691 | HOME = 0x01, | 701 | HOME = 0x01, |
692 | WORK = 0x02, | 702 | WORK = 0x02, |
693 | VOICE = 0x04, | 703 | VOICE = 0x04, |
694 | CELL = 0x08, | 704 | CELL = 0x08, |
695 | FAX = 0x10, | 705 | FAX = 0x10, |
696 | PAGER = 0x20, | 706 | PAGER = 0x20, |
697 | UNKNOWN = 0x80 | 707 | UNKNOWN = 0x80 |
698 | }; | 708 | }; |
699 | int type = 0; | 709 | int type = 0; |
700 | 710 | ||
701 | VObjectIterator nit; | 711 | VObjectIterator nit; |
702 | initPropIterator( &nit, o ); | 712 | initPropIterator( &nit, o ); |
703 | while( moreIteration( &nit ) ) { | 713 | while( moreIteration( &nit ) ) { |
704 | VObject *o = nextVObject( &nit ); | 714 | VObject *o = nextVObject( &nit ); |
705 | QCString name = vObjectName( o ); | 715 | QCString name = vObjectTypeInfo( o ); |
706 | if ( name == VCHomeProp ) | 716 | if ( name == VCHomeProp ) |
707 | type |= HOME; | 717 | type |= HOME; |
708 | else if ( name == VCWorkProp ) | 718 | else if ( name == VCWorkProp ) |
709 | type |= WORK; | 719 | type |= WORK; |
710 | else if ( name == VCVoiceProp ) | 720 | else if ( name == VCVoiceProp ) |
711 | type |= VOICE; | 721 | type |= VOICE; |
712 | else if ( name == VCCellularProp ) | 722 | else if ( name == VCCellularProp ) |
713 | type |= CELL; | 723 | type |= CELL; |
714 | else if ( name == VCFaxProp ) | 724 | else if ( name == VCFaxProp ) |
715 | type |= FAX; | 725 | type |= FAX; |
716 | else if ( name == VCPagerProp ) | 726 | else if ( name == VCPagerProp ) |
717 | type |= PAGER; | 727 | type |= PAGER; |
718 | else if ( name == VCPreferredProp ) | 728 | else if ( name == VCPreferredProp ) |
719 | ; | 729 | ; |
720 | else | 730 | else |
721 | type |= UNKNOWN; | 731 | type |= UNKNOWN; |
722 | } | 732 | } |
723 | if ( (type & UNKNOWN) != UNKNOWN ) { | 733 | if ( (type & UNKNOWN) != UNKNOWN ) { |
724 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 734 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
725 | type |= HOME; | 735 | type |= HOME; |
726 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 736 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
727 | type |= VOICE; | 737 | type |= VOICE; |
728 | 738 | ||
729 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 739 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
730 | c.setHomePhone( value ); | 740 | c.setHomePhone( value ); |
731 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 741 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
732 | c.setHomeFax( value ); | 742 | c.setHomeFax( value ); |
733 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 743 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
734 | c.setHomeMobile( value ); | 744 | c.setHomeMobile( value ); |
735 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 745 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
736 | c.setBusinessPhone( value ); | 746 | c.setBusinessPhone( value ); |
737 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 747 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
738 | c.setBusinessFax( value ); | 748 | c.setBusinessFax( value ); |
739 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 749 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
740 | c.setBusinessMobile( value ); | 750 | c.setBusinessMobile( value ); |
741 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 751 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
742 | c.setBusinessPager( value ); | 752 | c.setBusinessPager( value ); |
743 | } | 753 | } |
744 | } | 754 | } |
745 | else if ( name == VCEmailAddressProp ) { | 755 | else if ( name == VCEmailAddressProp ) { |
746 | QString email = vObjectStringZValue( o ); | 756 | QString email = vObjectStringZValue( o ); |
747 | bool valid = TRUE; | 757 | bool valid = TRUE; |
748 | VObjectIterator nit; | 758 | VObjectIterator nit; |
749 | initPropIterator( &nit, o ); | 759 | initPropIterator( &nit, o ); |
750 | while( moreIteration( &nit ) ) { | 760 | while( moreIteration( &nit ) ) { |
751 | VObject *o = nextVObject( &nit ); | 761 | VObject *o = nextVObject( &nit ); |
752 | QCString name = vObjectName( o ); | 762 | QCString name = vObjectTypeInfo( o ); |
753 | if ( name != VCInternetProp && name != VCHomeProp && | 763 | if ( name != VCInternetProp && name != VCHomeProp && |
754 | name != VCWorkProp && | 764 | name != VCWorkProp && |
755 | name != VCPreferredProp ) | 765 | name != VCPreferredProp ) |
756 | // ### preffered should map to default email | 766 | // ### preffered should map to default email |
757 | valid = FALSE; | 767 | valid = FALSE; |
758 | } | 768 | } |
759 | if ( valid ) { | 769 | if ( valid ) { |
760 | if ( haveDefaultEmail ) { | 770 | if ( haveDefaultEmail ) { |
761 | QString str = c.emails(); | 771 | QString str = c.emails(); |
762 | if ( !str.isEmpty() ) | 772 | if ( !str.isEmpty() ) |
763 | str += ","+email; | 773 | str += ","+email; |
764 | c.setEmails( str ); | 774 | c.setEmails( str ); |
765 | } else { | 775 | } else { |
766 | c.setDefaultEmail( email ); | 776 | c.setDefaultEmail( email ); |
767 | } | 777 | } |
768 | } | 778 | } |
769 | } | 779 | } |
770 | else if ( name == VCURLProp ) { | 780 | else if ( name == VCURLProp ) { |
771 | VObjectIterator nit; | 781 | VObjectIterator nit; |
772 | initPropIterator( &nit, o ); | 782 | initPropIterator( &nit, o ); |
773 | while( moreIteration( &nit ) ) { | 783 | while( moreIteration( &nit ) ) { |
774 | VObject *o = nextVObject( &nit ); | 784 | VObject *o = nextVObject( &nit ); |
775 | QCString name = vObjectName( o ); | 785 | QCString name = vObjectTypeInfo( o ); |
776 | if ( name == VCHomeProp ) | 786 | if ( name == VCHomeProp ) |
777 | c.setHomeWebpage( value ); | 787 | c.setHomeWebpage( value ); |
778 | else if ( name == VCWorkProp ) | 788 | else if ( name == VCWorkProp ) |
779 | c.setBusinessWebpage( value ); | 789 | c.setBusinessWebpage( value ); |
780 | } | 790 | } |
781 | } | 791 | } |
782 | else if ( name == VCOrgProp ) { | 792 | else if ( name == VCOrgProp ) { |
783 | VObjectIterator nit; | 793 | VObjectIterator nit; |
784 | initPropIterator( &nit, o ); | 794 | initPropIterator( &nit, o ); |
785 | while( moreIteration( &nit ) ) { | 795 | while( moreIteration( &nit ) ) { |
786 | VObject *o = nextVObject( &nit ); | 796 | VObject *o = nextVObject( &nit ); |
787 | QCString name = vObjectName( o ); | 797 | QCString name = vObjectName( o ); |
788 | QString value = vObjectStringZValue( o ); | 798 | QString value = vObjectStringZValue( o ); |
789 | if ( name == VCOrgNameProp ) | 799 | if ( name == VCOrgNameProp ) |
790 | c.setCompany( value ); | 800 | c.setCompany( value ); |
791 | else if ( name == VCOrgUnitProp ) | 801 | else if ( name == VCOrgUnitProp ) |
792 | c.setDepartment( value ); | 802 | c.setDepartment( value ); |
793 | else if ( name == VCOrgUnit2Prop ) | 803 | else if ( name == VCOrgUnit2Prop ) |
794 | c.setOffice( value ); | 804 | c.setOffice( value ); |
795 | } | 805 | } |
796 | } | 806 | } |
797 | else if ( name == VCTitleProp ) { | 807 | else if ( name == VCTitleProp ) { |
798 | c.setJobTitle( value ); | 808 | c.setJobTitle( value ); |
799 | } | 809 | } |
800 | else if ( name == "X-Qtopia-Profession" ) { | 810 | else if ( name == "X-Qtopia-Profession" ) { |
801 | c.setProfession( value ); | 811 | c.setProfession( value ); |
802 | } | 812 | } |
803 | else if ( name == "X-Qtopia-Manager" ) { | 813 | else if ( name == "X-Qtopia-Manager" ) { |
804 | c.setManager( value ); | 814 | c.setManager( value ); |
805 | } | 815 | } |
806 | else if ( name == "X-Qtopia-Assistant" ) { | 816 | else if ( name == "X-Qtopia-Assistant" ) { |
807 | c.setAssistant( value ); | 817 | c.setAssistant( value ); |
808 | } | 818 | } |
809 | else if ( name == "X-Qtopia-Spouse" ) { | 819 | else if ( name == "X-Qtopia-Spouse" ) { |
810 | c.setSpouse( value ); | 820 | c.setSpouse( value ); |
811 | } | 821 | } |
812 | else if ( name == "X-Qtopia-Gender" ) { | 822 | else if ( name == "X-Qtopia-Gender" ) { |
813 | c.setGender( value ); | 823 | c.setGender( value ); |
814 | } | 824 | } |
815 | else if ( name == "X-Qtopia-Anniversary" ) { | 825 | else if ( name == "X-Qtopia-Anniversary" ) { |
816 | c.setAnniversary( value ); | 826 | c.setAnniversary( value ); |
817 | } | 827 | } |
818 | else if ( name == "X-Qtopia-Nickname" ) { | 828 | else if ( name == "X-Qtopia-Nickname" ) { |
819 | c.setNickname( value ); | 829 | c.setNickname( value ); |
820 | } | 830 | } |
821 | else if ( name == "X-Qtopia-Children" ) { | 831 | else if ( name == "X-Qtopia-Children" ) { |
822 | c.setChildren( value ); | 832 | c.setChildren( value ); |
823 | } | 833 | } |
824 | 834 | ||
825 | 835 | ||
826 | #if 0 | 836 | #if 0 |
827 | else { | 837 | else { |
828 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 838 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
829 | VObjectIterator nit; | 839 | VObjectIterator nit; |
830 | initPropIterator( &nit, o ); | 840 | initPropIterator( &nit, o ); |
831 | while( moreIteration( &nit ) ) { | 841 | while( moreIteration( &nit ) ) { |
832 | VObject *o = nextVObject( &nit ); | 842 | VObject *o = nextVObject( &nit ); |
833 | QCString name = vObjectName( o ); | 843 | QCString name = vObjectName( o ); |
834 | QString value = vObjectStringZValue( o ); | 844 | QString value = vObjectStringZValue( o ); |
835 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 845 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
836 | } | 846 | } |
837 | } | 847 | } |
838 | #endif | 848 | #endif |
839 | } | 849 | } |
840 | c.setFileAs(); | 850 | c.setFileAs(); |
841 | return c; | 851 | return c; |
842 | } | 852 | } |
843 | 853 | ||
844 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) | 854 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) |
845 | { | 855 | { |
846 | QFileDirect f( filename.utf8().data() ); | 856 | QFileDirect f( filename.utf8().data() ); |
847 | if ( !f.open( IO_WriteOnly ) ) { | 857 | if ( !f.open( IO_WriteOnly ) ) { |
848 | qWarning("Unable to open vcard write"); | 858 | qWarning("Unable to open vcard write"); |
849 | return; | 859 | return; |
850 | } | 860 | } |
851 | 861 | ||
852 | QValueList<Contact>::ConstIterator it; | 862 | QValueList<Contact>::ConstIterator it; |
853 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 863 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
854 | VObject *obj = createVObject( *it ); | 864 | VObject *obj = createVObject( *it ); |
855 | writeVObject(f.directHandle() , obj ); | 865 | writeVObject(f.directHandle() , obj ); |
856 | cleanVObject( obj ); | 866 | cleanVObject( obj ); |
857 | } | 867 | } |
858 | cleanStrTbl(); | 868 | cleanStrTbl(); |
859 | } | 869 | } |
860 | 870 | ||
861 | void Contact::writeVCard( const QString &filename, const Contact &contact) | 871 | void Contact::writeVCard( const QString &filename, const Contact &contact) |
862 | { | 872 | { |
863 | QFileDirect f( filename.utf8().data() ); | 873 | QFileDirect f( filename.utf8().data() ); |
864 | if ( !f.open( IO_WriteOnly ) ) { | 874 | if ( !f.open( IO_WriteOnly ) ) { |
865 | qWarning("Unable to open vcard write"); | 875 | qWarning("Unable to open vcard write"); |
866 | return; | 876 | return; |
867 | } | 877 | } |
868 | 878 | ||
869 | VObject *obj = createVObject( contact ); | 879 | VObject *obj = createVObject( contact ); |
870 | writeVObject( f.directHandle() , obj ); | 880 | writeVObject( f.directHandle() , obj ); |
871 | cleanVObject( obj ); | 881 | cleanVObject( obj ); |
872 | 882 | ||
873 | cleanStrTbl(); | 883 | cleanStrTbl(); |
874 | } | 884 | } |
875 | 885 | ||
876 | 886 | ||
877 | QValueList<Contact> Contact::readVCard( const QString &filename ) | 887 | QValueList<Contact> Contact::readVCard( const QString &filename ) |
878 | { | 888 | { |
879 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 889 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
880 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 890 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
881 | 891 | ||
882 | qDebug("vobject = %p", obj ); | 892 | qDebug("vobject = %p", obj ); |
883 | 893 | ||
884 | QValueList<Contact> contacts; | 894 | QValueList<Contact> contacts; |
885 | 895 | ||
886 | while ( obj ) { | 896 | while ( obj ) { |
887 | contacts.append( parseVObject( obj ) ); | 897 | contacts.append( parseVObject( obj ) ); |
888 | 898 | ||
889 | VObject *t = obj; | 899 | VObject *t = obj; |
890 | obj = nextVObjectInList(obj); | 900 | obj = nextVObjectInList(obj); |
891 | cleanVObject( t ); | 901 | cleanVObject( t ); |
892 | } | 902 | } |
893 | 903 | ||
894 | return contacts; | 904 | return contacts; |
895 | } | 905 | } |
896 | 906 | ||
907 | bool Contact::match( const QString ®exp ) const | ||
908 | { | ||
909 | return match(QRegExp(regexp)); | ||
910 | } | ||
911 | |||
897 | bool Contact::match( const QRegExp &r ) const | 912 | bool Contact::match( const QRegExp &r ) const |
898 | { | 913 | { |
899 | bool match; | 914 | bool match; |
900 | match = false; | 915 | match = false; |
901 | QMap<int, QString>::ConstIterator it; | 916 | QMap<int, QString>::ConstIterator it; |
902 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 917 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
903 | if ( (*it).find( r ) > -1 ) { | 918 | if ( (*it).find( r ) > -1 ) { |
904 | match = true; | 919 | match = true; |
905 | break; | 920 | break; |
906 | } | 921 | } |
907 | } | 922 | } |
908 | return match; | 923 | return match; |
909 | } | 924 | } |
diff --git a/library/backend/contact.h b/library/backend/contact.h index 6abdab6..a74cbbe 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h | |||
@@ -1,217 +1,222 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | #ifndef __CONTACT_H__ | 21 | #ifndef __CONTACT_H__ |
22 | #define __CONTACT_H__ | 22 | #define __CONTACT_H__ |
23 | 23 | ||
24 | #include <qpe/palmtoprecord.h> | 24 | #include <qpe/palmtoprecord.h> |
25 | #include <qpe/recordfields.h> | 25 | #include <qpe/recordfields.h> |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | template class QPC_EXPORT QMap<int, QString>; | 31 | template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class ContactPrivate; |
36 | class QPC_EXPORT Contact : public Qtopia::Record | 36 | class QPC_EXPORT Contact : public Qtopia::Record |
37 | { | 37 | { |
38 | friend class DataSet; | 38 | friend class DataSet; |
39 | public: | 39 | public: |
40 | Contact(); | 40 | Contact(); |
41 | Contact( const QMap<int, QString> &fromMap ); | 41 | Contact( const QMap<int, QString> &fromMap ); |
42 | virtual ~Contact(); | 42 | virtual ~Contact(); |
43 | 43 | ||
44 | static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); | 44 | static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); |
45 | static void writeVCard( const QString &filename, const Contact &c ); | 45 | static void writeVCard( const QString &filename, const Contact &c ); |
46 | static QValueList<Contact> readVCard( const QString &filename ); | 46 | static QValueList<Contact> readVCard( const QString &filename ); |
47 | 47 | ||
48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
49 | 49 | ||
50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
56 | void setFileAs(); | 56 | void setFileAs(); |
57 | 57 | ||
58 | // default email address | 58 | // default email address |
59 | void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } | 59 | void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } |
60 | // the emails should be seperated by a semicolon | 60 | // the emails should be seperated by a semicolon |
61 | void setEmails( const QString &v ); | 61 | void setEmails( const QString &v ); |
62 | 62 | ||
63 | // home | 63 | // home |
64 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 64 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
65 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 65 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
66 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 66 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
67 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 67 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
68 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 68 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
69 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 69 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
70 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 70 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
71 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 71 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
72 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 72 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
73 | 73 | ||
74 | // business | 74 | // business |
75 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 75 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
76 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 76 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
77 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 77 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
78 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 78 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
79 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 79 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
80 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 80 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
81 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 81 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
82 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 82 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
83 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 83 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
84 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 84 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
85 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 85 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
86 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 86 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
87 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 87 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
88 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 88 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
89 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 89 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
90 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 90 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
91 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 91 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
92 | 92 | ||
93 | // personal | 93 | // personal |
94 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 94 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
95 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 95 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
96 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } | 96 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } |
97 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } | 97 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } |
98 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 98 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
99 | void setChildren( const QString &v ); | 99 | void setChildren( const QString &v ); |
100 | 100 | ||
101 | // other | 101 | // other |
102 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 102 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
103 | 103 | ||
104 | bool match( const QRegExp &r ) const; | 104 | bool match( const QString ®exp ) const; |
105 | |||
106 | // DON'T ATTEMPT TO USE THIS | ||
107 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | ||
108 | bool match( const QRegExp ®exp ) const; | ||
109 | #endif | ||
105 | 110 | ||
106 | // // custom | 111 | // // custom |
107 | // void setCustomField( const QString &key, const QString &v ) | 112 | // void setCustomField( const QString &key, const QString &v ) |
108 | // { replace(Custom- + key, v ); } | 113 | // { replace(Custom- + key, v ); } |
109 | 114 | ||
110 | // name | 115 | // name |
111 | QString fullName() const; | 116 | QString fullName() const; |
112 | QString title() const { return find( Qtopia::Title ); } | 117 | QString title() const { return find( Qtopia::Title ); } |
113 | QString firstName() const { return find( Qtopia::FirstName ); } | 118 | QString firstName() const { return find( Qtopia::FirstName ); } |
114 | QString middleName() const { return find( Qtopia::MiddleName ); } | 119 | QString middleName() const { return find( Qtopia::MiddleName ); } |
115 | QString lastName() const { return find( Qtopia::LastName ); } | 120 | QString lastName() const { return find( Qtopia::LastName ); } |
116 | QString suffix() const { return find( Qtopia::Suffix ); } | 121 | QString suffix() const { return find( Qtopia::Suffix ); } |
117 | QString fileAs() const { return find( Qtopia::FileAs ); } | 122 | QString fileAs() const { return find( Qtopia::FileAs ); } |
118 | 123 | ||
119 | 124 | ||
120 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 125 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
121 | QString emails() const { return find( Qtopia::Emails ); } | 126 | QString emails() const { return find( Qtopia::Emails ); } |
122 | QStringList emailList() const; | 127 | QStringList emailList() const; |
123 | 128 | ||
124 | // home | 129 | // home |
125 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
126 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 131 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
127 | QString homeState() const { return find( Qtopia::HomeState ); } | 132 | QString homeState() const { return find( Qtopia::HomeState ); } |
128 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 133 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
129 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
130 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 135 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
131 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 136 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
132 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
133 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
134 | /** Multi line string containing all non-empty address info in the form | 139 | /** Multi line string containing all non-empty address info in the form |
135 | * Street | 140 | * Street |
136 | * City, State Zip | 141 | * City, State Zip |
137 | * Country | 142 | * Country |
138 | */ | 143 | */ |
139 | QString displayHomeAddress() const; | 144 | QString displayHomeAddress() const; |
140 | 145 | ||
141 | // business | 146 | // business |
142 | QString company() const { return find( Qtopia::Company ); } | 147 | QString company() const { return find( Qtopia::Company ); } |
143 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
144 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
145 | QString businessState() const { return find( Qtopia::BusinessState ); } | 150 | QString businessState() const { return find( Qtopia::BusinessState ); } |
146 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
147 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
148 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
149 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
150 | QString department() const { return find( Qtopia::Department ); } | 155 | QString department() const { return find( Qtopia::Department ); } |
151 | QString office() const { return find( Qtopia::Office ); } | 156 | QString office() const { return find( Qtopia::Office ); } |
152 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
153 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
154 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
155 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
156 | QString profession() const { return find( Qtopia::Profession ); } | 161 | QString profession() const { return find( Qtopia::Profession ); } |
157 | QString assistant() const { return find( Qtopia::Assistant ); } | 162 | QString assistant() const { return find( Qtopia::Assistant ); } |
158 | QString manager() const { return find( Qtopia::Manager ); } | 163 | QString manager() const { return find( Qtopia::Manager ); } |
159 | /** Multi line string containing all non-empty address info in the form | 164 | /** Multi line string containing all non-empty address info in the form |
160 | * Street | 165 | * Street |
161 | * City, State Zip | 166 | * City, State Zip |
162 | * Country | 167 | * Country |
163 | */ | 168 | */ |
164 | QString displayBusinessAddress() const; | 169 | QString displayBusinessAddress() const; |
165 | 170 | ||
166 | //personal | 171 | //personal |
167 | QString spouse() const { return find( Qtopia::Spouse ); } | 172 | QString spouse() const { return find( Qtopia::Spouse ); } |
168 | QString gender() const { return find( Qtopia::Gender ); } | 173 | QString gender() const { return find( Qtopia::Gender ); } |
169 | QString birthday() const { return find( Qtopia::Birthday ); } | 174 | QString birthday() const { return find( Qtopia::Birthday ); } |
170 | QString anniversary() const { return find( Qtopia::Anniversary ); } | 175 | QString anniversary() const { return find( Qtopia::Anniversary ); } |
171 | QString nickname() const { return find( Qtopia::Nickname ); } | 176 | QString nickname() const { return find( Qtopia::Nickname ); } |
172 | QString children() const { return find( Qtopia::Children ); } | 177 | QString children() const { return find( Qtopia::Children ); } |
173 | QStringList childrenList() const; | 178 | QStringList childrenList() const; |
174 | 179 | ||
175 | // other | 180 | // other |
176 | QString notes() const { return find( Qtopia::Notes ); } | 181 | QString notes() const { return find( Qtopia::Notes ); } |
177 | QString groups() const { return find( Qtopia::Groups ); } | 182 | QString groups() const { return find( Qtopia::Groups ); } |
178 | QStringList groupList() const; | 183 | QStringList groupList() const; |
179 | 184 | ||
180 | // // custom | 185 | // // custom |
181 | // const QString &customField( const QString &key ) | 186 | // const QString &customField( const QString &key ) |
182 | // { return find( Custom- + key ); } | 187 | // { return find( Custom- + key ); } |
183 | 188 | ||
184 | static QStringList fields(); | 189 | static QStringList fields(); |
185 | static QStringList trfields(); | 190 | static QStringList trfields(); |
186 | 191 | ||
187 | QString toRichText() const; | 192 | QString toRichText() const; |
188 | QMap<int, QString> toMap() const; | 193 | QMap<int, QString> toMap() const; |
189 | QString field( int key ) const { return find( key ); } | 194 | QString field( int key ) const { return find( key ); } |
190 | 195 | ||
191 | 196 | ||
192 | // journaling... | 197 | // journaling... |
193 | void saveJournal( journal_action action, const QString &key = QString::null ); | 198 | void saveJournal( journal_action action, const QString &key = QString::null ); |
194 | void save( QString &buf ) const; | 199 | void save( QString &buf ) const; |
195 | 200 | ||
196 | void setUid( int i ) | 201 | void setUid( int i ) |
197 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 202 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
198 | 203 | ||
199 | private: | 204 | private: |
200 | friend class AbTable; | 205 | friend class AbTable; |
201 | void insert( int key, const QString &value ); | 206 | void insert( int key, const QString &value ); |
202 | void replace( int key, const QString &value ); | 207 | void replace( int key, const QString &value ); |
203 | QString find( int key ) const; | 208 | QString find( int key ) const; |
204 | 209 | ||
205 | QString displayAddress( const QString &street, | 210 | QString displayAddress( const QString &street, |
206 | const QString &city, | 211 | const QString &city, |
207 | const QString &state, | 212 | const QString &state, |
208 | const QString &zip, | 213 | const QString &zip, |
209 | const QString &country ) const; | 214 | const QString &country ) const; |
210 | 215 | ||
211 | Qtopia::UidGen &uidGen() { return sUidGen; } | 216 | Qtopia::UidGen &uidGen() { return sUidGen; } |
212 | static Qtopia::UidGen sUidGen; | 217 | static Qtopia::UidGen sUidGen; |
213 | QMap<int, QString> mMap; | 218 | QMap<int, QString> mMap; |
214 | ContactPrivate *d; | 219 | ContactPrivate *d; |
215 | }; | 220 | }; |
216 | 221 | ||
217 | #endif | 222 | #endif |
diff --git a/library/backend/event.h b/library/backend/event.h index 0ebe9ea..277aadd 100644 --- a/library/backend/event.h +++ b/library/backend/event.h | |||
@@ -1,229 +1,234 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | #ifndef __EVENT_H__ | 21 | #ifndef __EVENT_H__ |
22 | #define __EVENT_H__ | 22 | #define __EVENT_H__ |
23 | 23 | ||
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | #include <qvaluelist.h> | 25 | #include <qvaluelist.h> |
26 | 26 | ||
27 | #ifdef PALMTOPCENTER | 27 | #ifdef PALMTOPCENTER |
28 | #include <qpc/qsorter.h> | 28 | #include <qpc/qsorter.h> |
29 | #endif | 29 | #endif |
30 | #include <qpe/palmtoprecord.h> | 30 | #include <qpe/palmtoprecord.h> |
31 | 31 | ||
32 | #include <qpe/timeconversion.h> | 32 | #include <qpe/timeconversion.h> |
33 | 33 | ||
34 | class EventPrivate; | 34 | class EventPrivate; |
35 | class QPC_EXPORT Event : public Qtopia::Record | 35 | class QPC_EXPORT Event : public Qtopia::Record |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, | 38 | enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, |
39 | MonthlyDate, Yearly }; | 39 | MonthlyDate, Yearly }; |
40 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, | 40 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, |
41 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; | 41 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; |
42 | struct QPC_EXPORT RepeatPattern | 42 | struct QPC_EXPORT RepeatPattern |
43 | { | 43 | { |
44 | RepeatPattern() { | 44 | RepeatPattern() { |
45 | type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1; | 45 | type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1; |
46 | hasEndDate = FALSE; endDateUTC = 0; } | 46 | hasEndDate = FALSE; endDateUTC = 0; } |
47 | bool operator ==( const RepeatPattern &right ) const; | 47 | bool operator ==( const RepeatPattern &right ) const; |
48 | 48 | ||
49 | RepeatType type; | 49 | RepeatType type; |
50 | int frequency; | 50 | int frequency; |
51 | int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end... | 51 | int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end... |
52 | char days; // a mask for days OR in your days! | 52 | char days; // a mask for days OR in your days! |
53 | bool hasEndDate; | 53 | bool hasEndDate; |
54 | QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); } | 54 | QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); } |
55 | void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); } | 55 | void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); } |
56 | time_t endDateUTC; | 56 | time_t endDateUTC; |
57 | time_t createTime; | 57 | time_t createTime; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | Event(); | 60 | Event(); |
61 | Event( const QMap<int, QString > & map ); | 61 | Event( const QMap<int, QString > & map ); |
62 | virtual ~Event(); | 62 | virtual ~Event(); |
63 | 63 | ||
64 | QMap<int, QString> toMap() const; | 64 | QMap<int, QString> toMap() const; |
65 | 65 | ||
66 | static void writeVCalendar( const QString &filename, const QValueList<Event> &events); | 66 | static void writeVCalendar( const QString &filename, const QValueList<Event> &events); |
67 | static void writeVCalendar( const QString &filename, const Event &event); | 67 | static void writeVCalendar( const QString &filename, const Event &event); |
68 | static QValueList<Event> readVCalendar( const QString &filename ); | 68 | static QValueList<Event> readVCalendar( const QString &filename ); |
69 | 69 | ||
70 | enum Type { Normal, AllDay }; | 70 | enum Type { Normal, AllDay }; |
71 | enum SoundTypeChoice { Silent, Loud }; | 71 | enum SoundTypeChoice { Silent, Loud }; |
72 | 72 | ||
73 | bool operator<( const Event &e1) const { return start() < e1.start(); }; | 73 | bool operator<( const Event &e1) const { return start() < e1.start(); }; |
74 | bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; | 74 | bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; |
75 | bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; | 75 | bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; |
76 | bool operator>( const Event &e1 ) const { return start() > e1.start(); }; | 76 | bool operator>( const Event &e1 ) const { return start() > e1.start(); }; |
77 | bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; | 77 | bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; |
78 | bool operator==( const Event &e ) const; | 78 | bool operator==( const Event &e ) const; |
79 | 79 | ||
80 | void setDescription( const QString &s ); | 80 | void setDescription( const QString &s ); |
81 | const QString &description() const; | 81 | const QString &description() const; |
82 | 82 | ||
83 | void setLocation( const QString &s ); | 83 | void setLocation( const QString &s ); |
84 | const QString &location() const; | 84 | const QString &location() const; |
85 | 85 | ||
86 | void setType( Type t ); | 86 | void setType( Type t ); |
87 | Type type() const; | 87 | Type type() const; |
88 | void setStart( const QDateTime &d ); | 88 | void setStart( const QDateTime &d ); |
89 | void setStart( time_t time ); | 89 | void setStart( time_t time ); |
90 | QDateTime start( bool actual = FALSE ) const; | 90 | QDateTime start( bool actual = FALSE ) const; |
91 | time_t startTime() const { return startUTC; } | 91 | time_t startTime() const { return startUTC; } |
92 | void setEnd( const QDateTime &e ); | 92 | void setEnd( const QDateTime &e ); |
93 | void setEnd( time_t time ); | 93 | void setEnd( time_t time ); |
94 | QDateTime end( bool actual = FALSE ) const; | 94 | QDateTime end( bool actual = FALSE ) const; |
95 | time_t endTime() const { return endUTC; } | 95 | time_t endTime() const { return endUTC; } |
96 | void setTimeZone( const QString & ); | 96 | void setTimeZone( const QString & ); |
97 | const QString &timeZone() const; | 97 | const QString &timeZone() const; |
98 | void setAlarm( bool b, int minutes, SoundTypeChoice ); | 98 | void setAlarm( bool b, int minutes, SoundTypeChoice ); |
99 | bool hasAlarm() const; | 99 | bool hasAlarm() const; |
100 | int alarmTime() const; | 100 | int alarmTime() const; |
101 | SoundTypeChoice alarmSound() const; | 101 | SoundTypeChoice alarmSound() const; |
102 | void setRepeat( bool b, const RepeatPattern &p ); | 102 | void setRepeat( bool b, const RepeatPattern &p ); |
103 | void setRepeat( const RepeatPattern &p ); | 103 | void setRepeat( const RepeatPattern &p ); |
104 | bool hasRepeat() const; | 104 | bool hasRepeat() const; |
105 | const RepeatPattern &repeatPattern() const; | 105 | const RepeatPattern &repeatPattern() const; |
106 | RepeatPattern &repeatPattern(); | 106 | RepeatPattern &repeatPattern(); |
107 | void setNotes( const QString &n ); | 107 | void setNotes( const QString &n ); |
108 | const QString ¬es() const; | 108 | const QString ¬es() const; |
109 | bool doRepeat() const { return pattern.type != NoRepeat; } | 109 | bool doRepeat() const { return pattern.type != NoRepeat; } |
110 | 110 | ||
111 | void save( QString& buf ); | 111 | void save( QString& buf ); |
112 | //void load( Node *n ); | 112 | //void load( Node *n ); |
113 | 113 | ||
114 | // helper function to calculate the week of the given date | 114 | // helper function to calculate the week of the given date |
115 | static int week( const QDate& date ); | 115 | static int week( const QDate& date ); |
116 | // calculates the number of occurrences of the week day of | 116 | // calculates the number of occurrences of the week day of |
117 | // the given date from the start of the month | 117 | // the given date from the start of the month |
118 | static int occurrence( const QDate& date ); | 118 | static int occurrence( const QDate& date ); |
119 | // returns a proper days-char for a given dayOfWeek() | 119 | // returns a proper days-char for a given dayOfWeek() |
120 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } | 120 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } |
121 | // returns the dayOfWeek for the *first* day it finds (ignores | 121 | // returns the dayOfWeek for the *first* day it finds (ignores |
122 | // any further days!). Returns 1 (Monday) if there isn't any day found | 122 | // any further days!). Returns 1 (Monday) if there isn't any day found |
123 | static int dayOfWeek( char day ); | 123 | static int dayOfWeek( char day ); |
124 | // returns the difference of months from first to second. | 124 | // returns the difference of months from first to second. |
125 | static int monthDiff( const QDate& first, const QDate& second ); | 125 | static int monthDiff( const QDate& first, const QDate& second ); |
126 | bool match( const QRegExp &r ) const; | 126 | bool match( const QRegExp &r ) const; |
127 | 127 | ||
128 | private: | 128 | private: |
129 | Qtopia::UidGen &uidGen() { return sUidGen; } | 129 | Qtopia::UidGen &uidGen() { return sUidGen; } |
130 | static Qtopia::UidGen sUidGen; | 130 | static Qtopia::UidGen sUidGen; |
131 | 131 | ||
132 | QString descript, locat, categ; | 132 | QString descript, locat, categ; |
133 | Type typ : 4; | 133 | Type typ : 4; |
134 | bool startTimeDirty : 1; | 134 | bool startTimeDirty : 1; |
135 | bool endTimeDirty : 1; | 135 | bool endTimeDirty : 1; |
136 | time_t startUTC, endUTC; | 136 | time_t startUTC, endUTC; |
137 | QString tz; | 137 | QString tz; |
138 | bool hAlarm, hRepeat; | 138 | bool hAlarm, hRepeat; |
139 | int aMinutes; | 139 | int aMinutes; |
140 | SoundTypeChoice aSound; | 140 | SoundTypeChoice aSound; |
141 | RepeatPattern pattern; | 141 | RepeatPattern pattern; |
142 | QString note; | 142 | QString note; |
143 | // ADDITION | ||
144 | int mRid;// Recode ID | ||
145 | int mRinfo;// Recode Info | ||
146 | // | ||
143 | EventPrivate *d; | 147 | EventPrivate *d; |
148 | |||
144 | }; | 149 | }; |
145 | 150 | ||
146 | // Since an event spans multiple day, it is better to have this | 151 | // Since an event spans multiple day, it is better to have this |
147 | // class to represent a day instead of creating many | 152 | // class to represent a day instead of creating many |
148 | // dummy events... | 153 | // dummy events... |
149 | 154 | ||
150 | class EffectiveEventPrivate; | 155 | class EffectiveEventPrivate; |
151 | class QPC_EXPORT EffectiveEvent | 156 | class QPC_EXPORT EffectiveEvent |
152 | { | 157 | { |
153 | public: | 158 | public: |
154 | // If we calculate the effective event of a multi-day event | 159 | // If we calculate the effective event of a multi-day event |
155 | // we have to figure out whether we are at the first day, | 160 | // we have to figure out whether we are at the first day, |
156 | // at the end, or anywhere else ("middle"). This is important | 161 | // at the end, or anywhere else ("middle"). This is important |
157 | // for the start/end times (00:00/23:59) | 162 | // for the start/end times (00:00/23:59) |
158 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 163 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
159 | // day event | 164 | // day event |
160 | // Start: start time -> 23:59 | 165 | // Start: start time -> 23:59 |
161 | // End: 00:00 -> end time | 166 | // End: 00:00 -> end time |
162 | // Start | End == StartEnd: for single-day events (default) | 167 | // Start | End == StartEnd: for single-day events (default) |
163 | // here we draw start time -> end time | 168 | // here we draw start time -> end time |
164 | enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; | 169 | enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; |
165 | 170 | ||
166 | EffectiveEvent(); | 171 | EffectiveEvent(); |
167 | EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); | 172 | EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); |
168 | EffectiveEvent( const EffectiveEvent & ); | 173 | EffectiveEvent( const EffectiveEvent & ); |
169 | EffectiveEvent& operator=( const EffectiveEvent & ); | 174 | EffectiveEvent& operator=( const EffectiveEvent & ); |
170 | ~EffectiveEvent(); | 175 | ~EffectiveEvent(); |
171 | 176 | ||
172 | 177 | ||
173 | bool operator<( const EffectiveEvent &e ) const; | 178 | bool operator<( const EffectiveEvent &e ) const; |
174 | bool operator<=( const EffectiveEvent &e ) const; | 179 | bool operator<=( const EffectiveEvent &e ) const; |
175 | bool operator==( const EffectiveEvent &e ) const; | 180 | bool operator==( const EffectiveEvent &e ) const; |
176 | bool operator!=( const EffectiveEvent &e ) const; | 181 | bool operator!=( const EffectiveEvent &e ) const; |
177 | bool operator>( const EffectiveEvent &e ) const; | 182 | bool operator>( const EffectiveEvent &e ) const; |
178 | bool operator>= ( const EffectiveEvent &e ) const; | 183 | bool operator>= ( const EffectiveEvent &e ) const; |
179 | 184 | ||
180 | void setStart( const QTime &start ); | 185 | void setStart( const QTime &start ); |
181 | void setEnd( const QTime &end ); | 186 | void setEnd( const QTime &end ); |
182 | void setEvent( Event e ); | 187 | void setEvent( Event e ); |
183 | void setDate( const QDate &date ); | 188 | void setDate( const QDate &date ); |
184 | void setEffectiveDates( const QDate &from, const QDate &to ); | 189 | void setEffectiveDates( const QDate &from, const QDate &to ); |
185 | 190 | ||
186 | // QString category() const; | 191 | // QString category() const; |
187 | const QString &description() const; | 192 | const QString &description() const; |
188 | const QString &location() const; | 193 | const QString &location() const; |
189 | const QString ¬es() const; | 194 | const QString ¬es() const; |
190 | const Event &event() const; | 195 | const Event &event() const; |
191 | const QTime &start() const; | 196 | const QTime &start() const; |
192 | const QTime &end() const; | 197 | const QTime &end() const; |
193 | const QDate &date() const; | 198 | const QDate &date() const; |
194 | int length() const; | 199 | int length() const; |
195 | int size() const; | 200 | int size() const; |
196 | 201 | ||
197 | QDate startDate() const; | 202 | QDate startDate() const; |
198 | QDate endDate() const; | 203 | QDate endDate() const; |
199 | 204 | ||
200 | private: | 205 | private: |
201 | class EffectiveEventPrivate *d; | 206 | class EffectiveEventPrivate *d; |
202 | Event mEvent; | 207 | Event mEvent; |
203 | QDate mDate; | 208 | QDate mDate; |
204 | QTime mStart, | 209 | QTime mStart, |
205 | mEnd; | 210 | mEnd; |
206 | 211 | ||
207 | }; | 212 | }; |
208 | 213 | ||
209 | #ifdef PALMTOPCENTER | 214 | #ifdef PALMTOPCENTER |
210 | class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> | 215 | class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> |
211 | { | 216 | { |
212 | public: | 217 | public: |
213 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const | 218 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const |
214 | { | 219 | { |
215 | return a.size() - b.size(); | 220 | return a.size() - b.size(); |
216 | } | 221 | } |
217 | }; | 222 | }; |
218 | 223 | ||
219 | class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent> | 224 | class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent> |
220 | { | 225 | { |
221 | public: | 226 | public: |
222 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const | 227 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const |
223 | { | 228 | { |
224 | return a.start().secsTo( b.start() ); | 229 | return a.start().secsTo( b.start() ); |
225 | } | 230 | } |
226 | }; | 231 | }; |
227 | #endif | 232 | #endif |
228 | 233 | ||
229 | #endif | 234 | #endif |
diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h index 3cddde2..4196c8b 100644 --- a/library/backend/recordfields.h +++ b/library/backend/recordfields.h | |||
@@ -1,135 +1,149 @@ | |||
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 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** email sales@trolltech.com for information about Qtopia License |
15 | ** Agreements. | 15 | ** Agreements. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | #ifndef QPC_RECORD_FIELDS_H | 21 | #ifndef QPC_RECORD_FIELDS_H |
22 | #define QPC_RECORD_FIELDS_H | 22 | #define QPC_RECORD_FIELDS_H |
23 | #include "qpcglobal.h" | 23 | #include "qpcglobal.h" |
24 | 24 | ||
25 | // dataset = "addressbook" | 25 | // dataset = "addressbook" |
26 | namespace Qtopia | 26 | namespace Qtopia |
27 | { | 27 | { |
28 | static const int UID_ID = 0; | 28 | static const int UID_ID = 0; |
29 | static const int CATEGORY_ID = 1; | 29 | static const int CATEGORY_ID = 1; |
30 | 30 | ||
31 | enum AddressBookFields { | 31 | enum AddressBookFields { |
32 | AddressUid = UID_ID, | 32 | AddressUid = UID_ID, |
33 | AddressCategory = CATEGORY_ID, | 33 | AddressCategory = CATEGORY_ID, |
34 | 34 | ||
35 | // NOTE: Order of fields dependency in backend/contact.cpp | ||
36 | |||
35 | Title, | 37 | Title, |
36 | FirstName, | 38 | FirstName, |
37 | MiddleName, | 39 | MiddleName, |
38 | LastName, | 40 | LastName, |
39 | Suffix, | 41 | Suffix, |
40 | FileAs, | 42 | FileAs, |
41 | 43 | ||
44 | JobTitle, | ||
45 | Department, | ||
46 | Company, | ||
47 | BusinessPhone, | ||
48 | BusinessFax, | ||
49 | BusinessMobile, | ||
50 | |||
42 | 51 | ||
43 | DefaultEmail, | 52 | DefaultEmail, |
44 | Emails, | 53 | Emails, |
45 | 54 | ||
46 | // home | ||
47 | HomeStreet, | ||
48 | HomeCity, | ||
49 | HomeState, | ||
50 | HomeZip, | ||
51 | HomeCountry, | ||
52 | HomePhone, | 55 | HomePhone, |
53 | HomeFax, | 56 | HomeFax, |
54 | HomeMobile, | 57 | HomeMobile, |
55 | HomeWebPage, | ||
56 | 58 | ||
57 | // business | 59 | // business |
58 | Company, | ||
59 | BusinessStreet, | 60 | BusinessStreet, |
60 | BusinessCity, | 61 | BusinessCity, |
61 | BusinessState, | 62 | BusinessState, |
62 | BusinessZip, | 63 | BusinessZip, |
63 | BusinessCountry, | 64 | BusinessCountry, |
65 | BusinessPager, | ||
64 | BusinessWebPage, | 66 | BusinessWebPage, |
65 | JobTitle, | 67 | |
66 | Department, | ||
67 | Office, | 68 | Office, |
68 | BusinessPhone, | ||
69 | BusinessFax, | ||
70 | BusinessMobile, | ||
71 | BusinessPager, | ||
72 | Profession, | 69 | Profession, |
73 | Assistant, | 70 | Assistant, |
74 | Manager, | 71 | Manager, |
75 | 72 | ||
73 | // home | ||
74 | HomeStreet, | ||
75 | HomeCity, | ||
76 | HomeState, | ||
77 | HomeZip, | ||
78 | HomeCountry, | ||
79 | HomeWebPage, | ||
80 | |||
76 | //personal | 81 | //personal |
77 | Spouse, | 82 | Spouse, |
78 | Gender, | 83 | Gender, |
79 | Birthday, | 84 | Birthday, |
80 | Anniversary, | 85 | Anniversary, |
81 | Nickname, | 86 | Nickname, |
82 | Children, | 87 | Children, |
83 | 88 | ||
84 | // other | 89 | // other |
85 | Notes, | 90 | Notes, |
86 | Groups | 91 | Groups |
92 | |||
93 | ,rid, | ||
94 | rinfo | ||
87 | }; | 95 | }; |
88 | 96 | ||
89 | // dataset = "todolist" | 97 | // dataset = "todolist" |
90 | enum TaskFields { | 98 | enum TaskFields { |
91 | TaskUid = UID_ID, | 99 | TaskUid = UID_ID, |
92 | TaskCategory = CATEGORY_ID, | 100 | TaskCategory = CATEGORY_ID, |
93 | 101 | ||
94 | HasDate, | 102 | HasDate, |
95 | Completed, | 103 | Completed, |
96 | TaskDescription, | 104 | TaskDescription, |
97 | Priority, | 105 | Priority, |
98 | Date | 106 | Date, |
107 | |||
108 | TaskRid, | ||
109 | TaskRinfo | ||
99 | }; | 110 | }; |
100 | 111 | ||
101 | // dataset = "categories" for todos | 112 | // dataset = "categories" for todos |
102 | enum CategoryFields { | 113 | enum CategoryFields { |
103 | CatUid = UID_ID, | 114 | CatUid = UID_ID, |
104 | CatName, | 115 | CatName, |
105 | CatAppGroup | 116 | CatAppGroup |
106 | }; | 117 | }; |
107 | 118 | ||
108 | 119 | ||
109 | // dataset = "datebook" | 120 | // dataset = "datebook" |
110 | enum DatebookFields { | 121 | enum DatebookFields { |
111 | DatebookUid = UID_ID, | 122 | DatebookUid = UID_ID, |
112 | DatebookCategory = CATEGORY_ID, | 123 | DatebookCategory = CATEGORY_ID, |
113 | 124 | ||
114 | DatebookDescription, | 125 | DatebookDescription, |
115 | Location, | 126 | Location, |
116 | TimeZone, | 127 | TimeZone, |
117 | Note, | 128 | Note, |
118 | StartDateTime, | 129 | StartDateTime, |
119 | EndDateTime, | 130 | EndDateTime, |
120 | DatebookType, | 131 | DatebookType, |
121 | HasAlarm, | 132 | HasAlarm, |
122 | SoundType, | 133 | SoundType, |
123 | AlarmTime, | 134 | AlarmTime, |
124 | 135 | ||
125 | RepeatPatternType, | 136 | RepeatPatternType, |
126 | RepeatPatternFrequency, | 137 | RepeatPatternFrequency, |
127 | RepeatPatternPosition, | 138 | RepeatPatternPosition, |
128 | RepeatPatternDays, | 139 | RepeatPatternDays, |
129 | RepeatPatternHasEndDate, | 140 | RepeatPatternHasEndDate, |
130 | RepeatPatternEndDate, | 141 | RepeatPatternEndDate, |
142 | |||
143 | DateBookRid, | ||
144 | DateBookRinfo | ||
131 | }; | 145 | }; |
132 | }; | 146 | }; |
133 | 147 | ||
134 | 148 | ||
135 | #endif | 149 | #endif |
diff --git a/library/backend/task.h b/library/backend/task.h index ffe26b0..6f383b8 100644 --- a/library/backend/task.h +++ b/library/backend/task.h | |||
@@ -1,77 +1,81 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | #ifndef __TASK_H__ | 20 | #ifndef __TASK_H__ |
21 | #define __TASK_H__ | 21 | #define __TASK_H__ |
22 | 22 | ||
23 | #include <qpe/palmtoprecord.h> | 23 | #include <qpe/palmtoprecord.h> |
24 | #include <qpe/stringutil.h> | 24 | #include <qpe/stringutil.h> |
25 | 25 | ||
26 | #include <qvaluelist.h> | 26 | #include <qvaluelist.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | 28 | ||
29 | class TaskPrivate; | 29 | class TaskPrivate; |
30 | class QPC_EXPORT Task : public Qtopia::Record | 30 | class QPC_EXPORT Task : public Qtopia::Record |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | Task(); | 33 | Task(); |
34 | Task( const QMap<int, QString> &fromMap ); | 34 | Task( const QMap<int, QString> &fromMap ); |
35 | ~Task(); | 35 | ~Task(); |
36 | 36 | ||
37 | QMap<int, QString> toMap() const; | 37 | QMap<int, QString> toMap() const; |
38 | 38 | ||
39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); | 39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); |
40 | static void writeVCalendar( const QString &filename, const Task &task); | 40 | static void writeVCalendar( const QString &filename, const Task &task); |
41 | static QValueList<Task> readVCalendar( const QString &filename ); | 41 | static QValueList<Task> readVCalendar( const QString &filename ); |
42 | 42 | ||
43 | void setPriority( int priority ) { mPriority = priority; } | 43 | void setPriority( int priority ) { mPriority = priority; } |
44 | int priority() const { return mPriority; } | 44 | int priority() const { return mPriority; } |
45 | 45 | ||
46 | // void setCategory( const QString& category ) | 46 | // void setCategory( const QString& category ) |
47 | // { mCategory = category.stripWhiteSpace(); } | 47 | // { mCategory = category.stripWhiteSpace(); } |
48 | // const QString &category() const { return mCategory; } | 48 | // const QString &category() const { return mCategory; } |
49 | 49 | ||
50 | void setDescription( const QString& description ) | 50 | void setDescription( const QString& description ) |
51 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } | 51 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } |
52 | const QString &description() const { return mDesc; } | 52 | const QString &description() const { return mDesc; } |
53 | 53 | ||
54 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } | 54 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } |
55 | const QDate &dueDate() const { return mDueDate; } | 55 | const QDate &dueDate() const { return mDueDate; } |
56 | bool hasDueDate() const { return mDue; } | 56 | bool hasDueDate() const { return mDue; } |
57 | void setHasDueDate( bool b ) { mDue = b; } | 57 | void setHasDueDate( bool b ) { mDue = b; } |
58 | 58 | ||
59 | void setCompleted( bool b ) { mCompleted = b; } | 59 | void setCompleted( bool b ) { mCompleted = b; } |
60 | bool isCompleted() const { return mCompleted; } | 60 | bool isCompleted() const { return mCompleted; } |
61 | 61 | ||
62 | void save( QString& buf ) const; | 62 | void save( QString& buf ) const; |
63 | bool match( const QRegExp &r ) const; | 63 | bool match( const QRegExp &r ) const; |
64 | 64 | ||
65 | private: | 65 | private: |
66 | Qtopia::UidGen &uidGen() { return sUidGen; } | 66 | Qtopia::UidGen &uidGen() { return sUidGen; } |
67 | static Qtopia::UidGen sUidGen; | 67 | static Qtopia::UidGen sUidGen; |
68 | 68 | ||
69 | bool mDue; | 69 | bool mDue; |
70 | QDate mDueDate; | 70 | QDate mDueDate; |
71 | bool mCompleted; | 71 | bool mCompleted; |
72 | int mPriority; | 72 | int mPriority; |
73 | QString mDesc; | 73 | QString mDesc; |
74 | TaskPrivate *d; | 74 | TaskPrivate *d; |
75 | // ADDITION | ||
76 | int recordId; | ||
77 | int recordInfo; | ||
78 | // | ||
75 | }; | 79 | }; |
76 | 80 | ||
77 | #endif | 81 | #endif |
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index af112a7..9c2ba3b 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -186,1025 +186,1034 @@ DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s) | |||
186 | } | 186 | } |
187 | 187 | ||
188 | DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s) | 188 | DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s) |
189 | { | 189 | { |
190 | STRINGZ_VALUE_OF(o) = s; | 190 | STRINGZ_VALUE_OF(o) = s; |
191 | VALUE_TYPE(o) = VCVT_STRINGZ; | 191 | VALUE_TYPE(o) = VCVT_STRINGZ; |
192 | } | 192 | } |
193 | 193 | ||
194 | DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o) | 194 | DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o) |
195 | { | 195 | { |
196 | return INTEGER_VALUE_OF(o); | 196 | return INTEGER_VALUE_OF(o); |
197 | } | 197 | } |
198 | 198 | ||
199 | DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i) | 199 | DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i) |
200 | { | 200 | { |
201 | INTEGER_VALUE_OF(o) = i; | 201 | INTEGER_VALUE_OF(o) = i; |
202 | VALUE_TYPE(o) = VCVT_UINT; | 202 | VALUE_TYPE(o) = VCVT_UINT; |
203 | } | 203 | } |
204 | 204 | ||
205 | DLLEXPORT(unsigned long) vObjectLongValue(VObject *o) | 205 | DLLEXPORT(unsigned long) vObjectLongValue(VObject *o) |
206 | { | 206 | { |
207 | return LONG_VALUE_OF(o); | 207 | return LONG_VALUE_OF(o); |
208 | } | 208 | } |
209 | 209 | ||
210 | DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l) | 210 | DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l) |
211 | { | 211 | { |
212 | LONG_VALUE_OF(o) = l; | 212 | LONG_VALUE_OF(o) = l; |
213 | VALUE_TYPE(o) = VCVT_ULONG; | 213 | VALUE_TYPE(o) = VCVT_ULONG; |
214 | } | 214 | } |
215 | 215 | ||
216 | DLLEXPORT(void*) vObjectAnyValue(VObject *o) | 216 | DLLEXPORT(void*) vObjectAnyValue(VObject *o) |
217 | { | 217 | { |
218 | return ANY_VALUE_OF(o); | 218 | return ANY_VALUE_OF(o); |
219 | } | 219 | } |
220 | 220 | ||
221 | DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t) | 221 | DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t) |
222 | { | 222 | { |
223 | ANY_VALUE_OF(o) = t; | 223 | ANY_VALUE_OF(o) = t; |
224 | VALUE_TYPE(o) = VCVT_RAW; | 224 | VALUE_TYPE(o) = VCVT_RAW; |
225 | } | 225 | } |
226 | 226 | ||
227 | DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o) | 227 | DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o) |
228 | { | 228 | { |
229 | return VOBJECT_VALUE_OF(o); | 229 | return VOBJECT_VALUE_OF(o); |
230 | } | 230 | } |
231 | 231 | ||
232 | DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p) | 232 | DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p) |
233 | { | 233 | { |
234 | VOBJECT_VALUE_OF(o) = p; | 234 | VOBJECT_VALUE_OF(o) = p; |
235 | VALUE_TYPE(o) = VCVT_VOBJECT; | 235 | VALUE_TYPE(o) = VCVT_VOBJECT; |
236 | } | 236 | } |
237 | 237 | ||
238 | DLLEXPORT(int) vObjectValueType(VObject *o) | 238 | DLLEXPORT(int) vObjectValueType(VObject *o) |
239 | { | 239 | { |
240 | return VALUE_TYPE(o); | 240 | return VALUE_TYPE(o); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | /*---------------------------------------------------------------------- | 244 | /*---------------------------------------------------------------------- |
245 | The following functions can be used to build VObject. | 245 | The following functions can be used to build VObject. |
246 | ----------------------------------------------------------------------*/ | 246 | ----------------------------------------------------------------------*/ |
247 | 247 | ||
248 | DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p) | 248 | DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p) |
249 | { | 249 | { |
250 | /* circular link list pointed to tail */ | 250 | /* circular link list pointed to tail */ |
251 | /* | 251 | /* |
252 | o {next,id,prop,val} | 252 | o {next,id,prop,val} |
253 | V | 253 | V |
254 | pn {next,id,prop,val} | 254 | pn {next,id,prop,val} |
255 | V | 255 | V |
256 | ... | 256 | ... |
257 | p1 {next,id,prop,val} | 257 | p1 {next,id,prop,val} |
258 | V | 258 | V |
259 | pn | 259 | pn |
260 | --> | 260 | --> |
261 | o {next,id,prop,val} | 261 | o {next,id,prop,val} |
262 | V | 262 | V |
263 | pn {next,id,prop,val} | 263 | pn {next,id,prop,val} |
264 | V | 264 | V |
265 | p {next,id,prop,val} | 265 | p {next,id,prop,val} |
266 | ... | 266 | ... |
267 | p1 {next,id,prop,val} | 267 | p1 {next,id,prop,val} |
268 | V | 268 | V |
269 | pn | 269 | pn |
270 | */ | 270 | */ |
271 | 271 | ||
272 | VObject *tail = o->prop; | 272 | VObject *tail = o->prop; |
273 | if (tail) { | 273 | if (tail) { |
274 | p->next = tail->next; | 274 | p->next = tail->next; |
275 | o->prop = tail->next = p; | 275 | o->prop = tail->next = p; |
276 | } | 276 | } |
277 | else { | 277 | else { |
278 | o->prop = p->next = p; | 278 | o->prop = p->next = p; |
279 | } | 279 | } |
280 | return p; | 280 | return p; |
281 | } | 281 | } |
282 | 282 | ||
283 | DLLEXPORT(VObject*) addProp(VObject *o, const char *id) | 283 | DLLEXPORT(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 | ||
288 | DLLEXPORT(VObject*) addProp_(VObject *o, const char *id) | 288 | DLLEXPORT(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 | ||
293 | DLLEXPORT(void) addList(VObject **o, VObject *p) | 293 | DLLEXPORT(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 | ||
308 | DLLEXPORT(VObject*) nextVObjectInList(VObject *o) | 308 | DLLEXPORT(VObject*) nextVObjectInList(VObject *o) |
309 | { | 309 | { |
310 | return o->next; | 310 | return o->next; |
311 | } | 311 | } |
312 | 312 | ||
313 | DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size) | 313 | DLLEXPORT(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 | ||
322 | DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size) | 322 | DLLEXPORT(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 | ||
328 | DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) | 328 | DLLEXPORT(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 | ||
334 | DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) | 334 | DLLEXPORT(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 | ||
340 | DLLEXPORT(int) moreIteration(VObjectIterator *i) | 340 | DLLEXPORT(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 | ||
345 | DLLEXPORT(VObject*) nextVObject(VObjectIterator *i) | 345 | DLLEXPORT(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 | ||
360 | DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id) | 360 | DLLEXPORT(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 | ||
372 | DLLEXPORT(VObject*) addGroup(VObject *o, const char *g) | 372 | DLLEXPORT(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 | ||
413 | DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v) | 413 | DLLEXPORT(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 | ||
421 | DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, | 421 | DLLEXPORT(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 | ||
430 | DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, | 430 | DLLEXPORT(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 | ||
437 | DLLEXPORT(void) cleanVObject(VObject *o) | 437 | DLLEXPORT(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; |
455 | } while (p); | 455 | } while (p); |
456 | } | 456 | } |
457 | switch (VALUE_TYPE(o)) { | 457 | switch (VALUE_TYPE(o)) { |
458 | case VCVT_STRINGZ: | 458 | case VCVT_STRINGZ: |
459 | case VCVT_RAW: | 459 | case VCVT_RAW: |
460 | // assume they are all allocated by malloc. | 460 | // assume they are all allocated by malloc. |
461 | free((char*)STRINGZ_VALUE_OF(o)); | 461 | free((char*)STRINGZ_VALUE_OF(o)); |
462 | break; | 462 | break; |
463 | case VCVT_VOBJECT: | 463 | case VCVT_VOBJECT: |
464 | cleanVObject(VOBJECT_VALUE_OF(o)); | 464 | cleanVObject(VOBJECT_VALUE_OF(o)); |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | deleteVObject(o); | 467 | deleteVObject(o); |
468 | } | 468 | } |
469 | 469 | ||
470 | DLLEXPORT(void) cleanVObjects(VObject *list) | 470 | DLLEXPORT(void) cleanVObjects(VObject *list) |
471 | { | 471 | { |
472 | while (list) { | 472 | while (list) { |
473 | VObject *t = list; | 473 | VObject *t = list; |
474 | list = nextVObjectInList(list); | 474 | list = nextVObjectInList(list); |
475 | cleanVObject(t); | 475 | cleanVObject(t); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | /*---------------------------------------------------------------------- | 479 | /*---------------------------------------------------------------------- |
480 | The following is a String Table Facilities. | 480 | The following is a String Table Facilities. |
481 | ----------------------------------------------------------------------*/ | 481 | ----------------------------------------------------------------------*/ |
482 | 482 | ||
483 | #define STRTBLSIZE 255 | 483 | #define STRTBLSIZE 255 |
484 | 484 | ||
485 | static StrItem *strTbl[STRTBLSIZE]; | 485 | static StrItem *strTbl[STRTBLSIZE]; |
486 | 486 | ||
487 | static unsigned int hashStr(const char *s) | 487 | static unsigned int hashStr(const char *s) |
488 | { | 488 | { |
489 | unsigned int h = 0; | 489 | unsigned int h = 0; |
490 | int i; | 490 | int i; |
491 | for (i=0;s[i];i++) { | 491 | for (i=0;s[i];i++) { |
492 | h += s[i]*i; | 492 | h += s[i]*i; |
493 | } | 493 | } |
494 | return h % STRTBLSIZE; | 494 | return h % STRTBLSIZE; |
495 | } | 495 | } |
496 | 496 | ||
497 | DLLEXPORT(const char*) lookupStr(const char *s) | 497 | DLLEXPORT(const char*) lookupStr(const char *s) |
498 | { | 498 | { |
499 | StrItem *t; | 499 | StrItem *t; |
500 | unsigned int h = hashStr(s); | 500 | unsigned int h = hashStr(s); |
501 | if ((t = strTbl[h]) != 0) { | 501 | if ((t = strTbl[h]) != 0) { |
502 | do { | 502 | do { |
503 | if (qstricmp(t->s,s) == 0) { | 503 | if (qstricmp(t->s,s) == 0) { |
504 | t->refCnt++; | 504 | t->refCnt++; |
505 | return t->s; | 505 | return t->s; |
506 | } | 506 | } |
507 | t = t->next; | 507 | t = t->next; |
508 | } while (t); | 508 | } while (t); |
509 | } | 509 | } |
510 | s = dupStr(s,0); | 510 | s = dupStr(s,0); |
511 | strTbl[h] = newStrItem(s,strTbl[h]); | 511 | strTbl[h] = newStrItem(s,strTbl[h]); |
512 | return s; | 512 | return s; |
513 | } | 513 | } |
514 | 514 | ||
515 | DLLEXPORT(void) unUseStr(const char *s) | 515 | DLLEXPORT(void) unUseStr(const char *s) |
516 | { | 516 | { |
517 | StrItem *t, *p; | 517 | StrItem *t, *p; |
518 | unsigned int h = hashStr(s); | 518 | unsigned int h = hashStr(s); |
519 | if ((t = strTbl[h]) != 0) { | 519 | if ((t = strTbl[h]) != 0) { |
520 | p = t; | 520 | p = t; |
521 | do { | 521 | do { |
522 | if (qstricmp(t->s,s) == 0) { | 522 | if (qstricmp(t->s,s) == 0) { |
523 | t->refCnt--; | 523 | t->refCnt--; |
524 | if (t->refCnt == 0) { | 524 | if (t->refCnt == 0) { |
525 | if (p == strTbl[h]) { | 525 | if (p == strTbl[h]) { |
526 | strTbl[h] = t->next; | 526 | strTbl[h] = t->next; |
527 | } | 527 | } |
528 | else { | 528 | else { |
529 | p->next = t->next; | 529 | p->next = t->next; |
530 | } | 530 | } |
531 | deleteStr(t->s); | 531 | deleteStr(t->s); |
532 | deleteStrItem(t); | 532 | deleteStrItem(t); |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | p = t; | 536 | p = t; |
537 | t = t->next; | 537 | t = t->next; |
538 | } while (t); | 538 | } while (t); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | DLLEXPORT(void) cleanStrTbl() | 542 | DLLEXPORT(void) cleanStrTbl() |
543 | { | 543 | { |
544 | int i; | 544 | int i; |
545 | for (i=0; i<STRTBLSIZE;i++) { | 545 | for (i=0; i<STRTBLSIZE;i++) { |
546 | StrItem *t = strTbl[i]; | 546 | StrItem *t = strTbl[i]; |
547 | while (t) { | 547 | while (t) { |
548 | StrItem *p; | 548 | StrItem *p; |
549 | deleteStr(t->s); | 549 | deleteStr(t->s); |
550 | p = t; | 550 | p = t; |
551 | t = t->next; | 551 | t = t->next; |
552 | deleteStrItem(p); | 552 | deleteStrItem(p); |
553 | } while (t); | 553 | } while (t); |
554 | strTbl[i] = 0; | 554 | strTbl[i] = 0; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | struct PreDefProp { | 559 | struct PreDefProp { |
560 | const char *name; | 560 | const char *name; |
561 | const char *alias; | 561 | const char *alias; |
562 | const char** fields; | 562 | const char** fields; |
563 | unsigned int flags; | 563 | unsigned int flags; |
564 | }; | 564 | }; |
565 | 565 | ||
566 | /* flags in PreDefProp */ | 566 | /* flags in PreDefProp */ |
567 | #define PD_BEGIN0x1 | 567 | #define PD_BEGIN0x1 |
568 | #define PD_INTERNAL0x2 | 568 | #define PD_INTERNAL0x2 |
569 | 569 | ||
570 | static const char *adrFields[] = { | 570 | static const char *adrFields[] = { |
571 | VCPostalBoxProp, | 571 | VCPostalBoxProp, |
572 | VCExtAddressProp, | 572 | VCExtAddressProp, |
573 | VCStreetAddressProp, | 573 | VCStreetAddressProp, |
574 | VCCityProp, | 574 | VCCityProp, |
575 | VCRegionProp, | 575 | VCRegionProp, |
576 | VCPostalCodeProp, | 576 | VCPostalCodeProp, |
577 | VCCountryNameProp, | 577 | VCCountryNameProp, |
578 | 0 | 578 | 0 |
579 | }; | 579 | }; |
580 | 580 | ||
581 | static const char *nameFields[] = { | 581 | static const char *nameFields[] = { |
582 | VCFamilyNameProp, | 582 | VCFamilyNameProp, |
583 | VCGivenNameProp, | 583 | VCGivenNameProp, |
584 | VCAdditionalNamesProp, | 584 | VCAdditionalNamesProp, |
585 | VCNamePrefixesProp, | 585 | VCNamePrefixesProp, |
586 | VCNameSuffixesProp, | 586 | VCNameSuffixesProp, |
587 | NULL | 587 | NULL |
588 | }; | 588 | }; |
589 | 589 | ||
590 | static const char *orgFields[] = { | 590 | static const char *orgFields[] = { |
591 | VCOrgNameProp, | 591 | VCOrgNameProp, |
592 | VCOrgUnitProp, | 592 | VCOrgUnitProp, |
593 | VCOrgUnit2Prop, | 593 | VCOrgUnit2Prop, |
594 | VCOrgUnit3Prop, | 594 | VCOrgUnit3Prop, |
595 | VCOrgUnit4Prop, | 595 | VCOrgUnit4Prop, |
596 | NULL | 596 | NULL |
597 | }; | 597 | }; |
598 | 598 | ||
599 | static const char *AAlarmFields[] = { | 599 | static const char *AAlarmFields[] = { |
600 | VCRunTimeProp, | 600 | VCRunTimeProp, |
601 | VCSnoozeTimeProp, | 601 | VCSnoozeTimeProp, |
602 | VCRepeatCountProp, | 602 | VCRepeatCountProp, |
603 | VCAudioContentProp, | 603 | VCAudioContentProp, |
604 | 0 | 604 | 0 |
605 | }; | 605 | }; |
606 | 606 | ||
607 | /* ExDate -- has unamed fields */ | 607 | /* ExDate -- has unamed fields */ |
608 | /* RDate -- has unamed fields */ | 608 | /* RDate -- has unamed fields */ |
609 | 609 | ||
610 | static const char *DAlarmFields[] = { | 610 | static const char *DAlarmFields[] = { |
611 | VCRunTimeProp, | 611 | VCRunTimeProp, |
612 | VCSnoozeTimeProp, | 612 | VCSnoozeTimeProp, |
613 | VCRepeatCountProp, | 613 | VCRepeatCountProp, |
614 | VCDisplayStringProp, | 614 | VCDisplayStringProp, |
615 | 0 | 615 | 0 |
616 | }; | 616 | }; |
617 | 617 | ||
618 | static const char *MAlarmFields[] = { | 618 | static const char *MAlarmFields[] = { |
619 | VCRunTimeProp, | 619 | VCRunTimeProp, |
620 | VCSnoozeTimeProp, | 620 | VCSnoozeTimeProp, |
621 | VCRepeatCountProp, | 621 | VCRepeatCountProp, |
622 | VCEmailAddressProp, | 622 | VCEmailAddressProp, |
623 | VCNoteProp, | 623 | VCNoteProp, |
624 | 0 | 624 | 0 |
625 | }; | 625 | }; |
626 | 626 | ||
627 | static const char *PAlarmFields[] = { | 627 | static const char *PAlarmFields[] = { |
628 | VCRunTimeProp, | 628 | VCRunTimeProp, |
629 | VCSnoozeTimeProp, | 629 | VCSnoozeTimeProp, |
630 | VCRepeatCountProp, | 630 | VCRepeatCountProp, |
631 | VCProcedureNameProp, | 631 | VCProcedureNameProp, |
632 | 0 | 632 | 0 |
633 | }; | 633 | }; |
634 | 634 | ||
635 | static struct PreDefProp propNames[] = { | 635 | static struct PreDefProp propNames[] = { |
636 | { VC7bitProp, 0, 0, 0 }, | 636 | { VC7bitProp, 0, 0, 0 }, |
637 | { VC8bitProp, 0, 0, 0 }, | 637 | { VC8bitProp, 0, 0, 0 }, |
638 | { VCAAlarmProp, 0, AAlarmFields, 0 }, | 638 | { VCAAlarmProp, 0, AAlarmFields, 0 }, |
639 | { VCAdditionalNamesProp, 0, 0, 0 }, | 639 | { VCAdditionalNamesProp, 0, 0, 0 }, |
640 | { VCAdrProp, 0, adrFields, 0 }, | 640 | { VCAdrProp, 0, adrFields, 0 }, |
641 | { VCAgentProp, 0, 0, 0 }, | 641 | { VCAgentProp, 0, 0, 0 }, |
642 | { VCAIFFProp, 0, 0, 0 }, | 642 | { VCAIFFProp, 0, 0, 0 }, |
643 | { VCAOLProp, 0, 0, 0 }, | 643 | { VCAOLProp, 0, 0, 0 }, |
644 | { VCAppleLinkProp, 0, 0, 0 }, | 644 | { VCAppleLinkProp, 0, 0, 0 }, |
645 | { VCAttachProp, 0, 0, 0 }, | 645 | { VCAttachProp, 0, 0, 0 }, |
646 | { VCAttendeeProp, 0, 0, 0 }, | 646 | { VCAttendeeProp, 0, 0, 0 }, |
647 | { VCATTMailProp, 0, 0, 0 }, | 647 | { VCATTMailProp, 0, 0, 0 }, |
648 | { VCAudioContentProp, 0, 0, 0 }, | 648 | { VCAudioContentProp, 0, 0, 0 }, |
649 | { VCAVIProp, 0, 0, 0 }, | 649 | { VCAVIProp, 0, 0, 0 }, |
650 | { VCBase64Prop, 0, 0, 0 }, | 650 | { VCBase64Prop, 0, 0, 0 }, |
651 | { VCBBSProp, 0, 0, 0 }, | 651 | { VCBBSProp, 0, 0, 0 }, |
652 | { VCBirthDateProp, 0, 0, 0 }, | 652 | { VCBirthDateProp, 0, 0, 0 }, |
653 | { VCBMPProp, 0, 0, 0 }, | 653 | { VCBMPProp, 0, 0, 0 }, |
654 | { VCBodyProp, 0, 0, 0 }, | 654 | { VCBodyProp, 0, 0, 0 }, |
655 | { VCBusinessRoleProp, 0, 0, 0 }, | 655 | { VCBusinessRoleProp, 0, 0, 0 }, |
656 | { VCCalProp, 0, 0, PD_BEGIN }, | 656 | { VCCalProp, 0, 0, PD_BEGIN }, |
657 | { VCCaptionProp, 0, 0, 0 }, | 657 | { VCCaptionProp, 0, 0, 0 }, |
658 | { VCCardProp, 0, 0, PD_BEGIN }, | 658 | { VCCardProp, 0, 0, PD_BEGIN }, |
659 | { VCCarProp, 0, 0, 0 }, | 659 | { VCCarProp, 0, 0, 0 }, |
660 | { VCCategoriesProp, 0, 0, 0 }, | 660 | { VCCategoriesProp, 0, 0, 0 }, |
661 | { VCCellularProp, 0, 0, 0 }, | 661 | { VCCellularProp, 0, 0, 0 }, |
662 | { VCCGMProp, 0, 0, 0 }, | 662 | { VCCGMProp, 0, 0, 0 }, |
663 | { VCCharSetProp, 0, 0, 0 }, | 663 | { VCCharSetProp, 0, 0, 0 }, |
664 | { VCCIDProp, VCContentIDProp, 0, 0 }, | 664 | { VCCIDProp, VCContentIDProp, 0, 0 }, |
665 | { VCCISProp, 0, 0, 0 }, | 665 | { VCCISProp, 0, 0, 0 }, |
666 | { VCCityProp, 0, 0, 0 }, | 666 | { VCCityProp, 0, 0, 0 }, |
667 | { VCClassProp, 0, 0, 0 }, | 667 | { VCClassProp, 0, 0, 0 }, |
668 | { VCCommentProp, 0, 0, 0 }, | 668 | { VCCommentProp, 0, 0, 0 }, |
669 | { VCCompletedProp, 0, 0, 0 }, | 669 | { VCCompletedProp, 0, 0, 0 }, |
670 | { VCContentIDProp, 0, 0, 0 }, | 670 | { VCContentIDProp, 0, 0, 0 }, |
671 | { VCCountryNameProp, 0, 0, 0 }, | 671 | { VCCountryNameProp, 0, 0, 0 }, |
672 | { VCDAlarmProp, 0, DAlarmFields, 0 }, | 672 | { VCDAlarmProp, 0, DAlarmFields, 0 }, |
673 | { VCDataSizeProp, 0, 0, PD_INTERNAL }, | 673 | { VCDataSizeProp, 0, 0, PD_INTERNAL }, |
674 | { VCDayLightProp, 0, 0, 0 }, | 674 | { VCDayLightProp, 0, 0, 0 }, |
675 | { VCDCreatedProp, 0, 0, 0 }, | 675 | { VCDCreatedProp, 0, 0, 0 }, |
676 | { VCDeliveryLabelProp, 0, 0, 0 }, | 676 | { VCDeliveryLabelProp, 0, 0, 0 }, |
677 | { VCDescriptionProp, 0, 0, 0 }, | 677 | { VCDescriptionProp, 0, 0, 0 }, |
678 | { VCDIBProp, 0, 0, 0 }, | 678 | { VCDIBProp, 0, 0, 0 }, |
679 | { VCDisplayStringProp, 0, 0, 0 }, | 679 | { VCDisplayStringProp, 0, 0, 0 }, |
680 | { VCDomesticProp, 0, 0, 0 }, | 680 | { VCDomesticProp, 0, 0, 0 }, |
681 | { VCDTendProp, 0, 0, 0 }, | 681 | { VCDTendProp, 0, 0, 0 }, |
682 | { VCDTstartProp, 0, 0, 0 }, | 682 | { VCDTstartProp, 0, 0, 0 }, |
683 | { VCDueProp, 0, 0, 0 }, | 683 | { VCDueProp, 0, 0, 0 }, |
684 | { VCEmailAddressProp, 0, 0, 0 }, | 684 | { VCEmailAddressProp, 0, 0, 0 }, |
685 | { VCEncodingProp, 0, 0, 0 }, | 685 | { VCEncodingProp, 0, 0, 0 }, |
686 | { VCEndProp, 0, 0, 0 }, | 686 | { VCEndProp, 0, 0, 0 }, |
687 | { VCEventProp, 0, 0, PD_BEGIN }, | 687 | { VCEventProp, 0, 0, PD_BEGIN }, |
688 | { VCEWorldProp, 0, 0, 0 }, | 688 | { VCEWorldProp, 0, 0, 0 }, |
689 | { VCExNumProp, 0, 0, 0 }, | 689 | { VCExNumProp, 0, 0, 0 }, |
690 | { VCExpDateProp, 0, 0, 0 }, | 690 | { VCExpDateProp, 0, 0, 0 }, |
691 | { VCExpectProp, 0, 0, 0 }, | 691 | { VCExpectProp, 0, 0, 0 }, |
692 | { VCExtAddressProp, 0, 0, 0 }, | 692 | { VCExtAddressProp, 0, 0, 0 }, |
693 | { VCFamilyNameProp, 0, 0, 0 }, | 693 | { VCFamilyNameProp, 0, 0, 0 }, |
694 | { VCFaxProp, 0, 0, 0 }, | 694 | { VCFaxProp, 0, 0, 0 }, |
695 | { VCFullNameProp, 0, 0, 0 }, | 695 | { VCFullNameProp, 0, 0, 0 }, |
696 | { VCGeoLocationProp, 0, 0, 0 }, | 696 | { VCGeoLocationProp, 0, 0, 0 }, |
697 | { VCGeoProp, 0, 0, 0 }, | 697 | { VCGeoProp, 0, 0, 0 }, |
698 | { VCGIFProp, 0, 0, 0 }, | 698 | { VCGIFProp, 0, 0, 0 }, |
699 | { VCGivenNameProp, 0, 0, 0 }, | 699 | { VCGivenNameProp, 0, 0, 0 }, |
700 | { VCGroupingProp, 0, 0, 0 }, | 700 | { VCGroupingProp, 0, 0, 0 }, |
701 | { VCHomeProp, 0, 0, 0 }, | 701 | { VCHomeProp, 0, 0, 0 }, |
702 | { VCIBMMailProp, 0, 0, 0 }, | 702 | { VCIBMMailProp, 0, 0, 0 }, |
703 | { VCInlineProp, 0, 0, 0 }, | 703 | { VCInlineProp, 0, 0, 0 }, |
704 | { VCInternationalProp, 0, 0, 0 }, | 704 | { VCInternationalProp, 0, 0, 0 }, |
705 | { VCInternetProp, 0, 0, 0 }, | 705 | { VCInternetProp, 0, 0, 0 }, |
706 | { VCISDNProp, 0, 0, 0 }, | 706 | { VCISDNProp, 0, 0, 0 }, |
707 | { VCJPEGProp, 0, 0, 0 }, | 707 | { VCJPEGProp, 0, 0, 0 }, |
708 | { VCLanguageProp, 0, 0, 0 }, | 708 | { VCLanguageProp, 0, 0, 0 }, |
709 | { VCLastModifiedProp, 0, 0, 0 }, | 709 | { VCLastModifiedProp, 0, 0, 0 }, |
710 | { VCLastRevisedProp, 0, 0, 0 }, | 710 | { VCLastRevisedProp, 0, 0, 0 }, |
711 | { VCLocationProp, 0, 0, 0 }, | 711 | { VCLocationProp, 0, 0, 0 }, |
712 | { VCLogoProp, 0, 0, 0 }, | 712 | { VCLogoProp, 0, 0, 0 }, |
713 | { VCMailerProp, 0, 0, 0 }, | 713 | { VCMailerProp, 0, 0, 0 }, |
714 | { VCMAlarmProp, 0, MAlarmFields, 0 }, | 714 | { VCMAlarmProp, 0, MAlarmFields, 0 }, |
715 | { VCMCIMailProp, 0, 0, 0 }, | 715 | { VCMCIMailProp, 0, 0, 0 }, |
716 | { VCMessageProp, 0, 0, 0 }, | 716 | { VCMessageProp, 0, 0, 0 }, |
717 | { VCMETProp, 0, 0, 0 }, | 717 | { VCMETProp, 0, 0, 0 }, |
718 | { VCModemProp, 0, 0, 0 }, | 718 | { VCModemProp, 0, 0, 0 }, |
719 | { VCMPEG2Prop, 0, 0, 0 }, | 719 | { VCMPEG2Prop, 0, 0, 0 }, |
720 | { VCMPEGProp, 0, 0, 0 }, | 720 | { VCMPEGProp, 0, 0, 0 }, |
721 | { VCMSNProp, 0, 0, 0 }, | 721 | { VCMSNProp, 0, 0, 0 }, |
722 | { VCNamePrefixesProp, 0, 0, 0 }, | 722 | { VCNamePrefixesProp, 0, 0, 0 }, |
723 | { VCNameProp, 0, nameFields, 0 }, | 723 | { VCNameProp, 0, nameFields, 0 }, |
724 | { VCNameSuffixesProp, 0, 0, 0 }, | 724 | { VCNameSuffixesProp, 0, 0, 0 }, |
725 | { VCNoteProp, 0, 0, 0 }, | 725 | { VCNoteProp, 0, 0, 0 }, |
726 | { VCOrgNameProp, 0, 0, 0 }, | 726 | { VCOrgNameProp, 0, 0, 0 }, |
727 | { VCOrgProp, 0, orgFields, 0 }, | 727 | { VCOrgProp, 0, orgFields, 0 }, |
728 | { VCOrgUnit2Prop, 0, 0, 0 }, | 728 | { VCOrgUnit2Prop, 0, 0, 0 }, |
729 | { VCOrgUnit3Prop, 0, 0, 0 }, | 729 | { VCOrgUnit3Prop, 0, 0, 0 }, |
730 | { VCOrgUnit4Prop, 0, 0, 0 }, | 730 | { VCOrgUnit4Prop, 0, 0, 0 }, |
731 | { VCOrgUnitProp, 0, 0, 0 }, | 731 | { VCOrgUnitProp, 0, 0, 0 }, |
732 | { VCPagerProp, 0, 0, 0 }, | 732 | { VCPagerProp, 0, 0, 0 }, |
733 | { VCPAlarmProp, 0, PAlarmFields, 0 }, | 733 | { VCPAlarmProp, 0, PAlarmFields, 0 }, |
734 | { VCParcelProp, 0, 0, 0 }, | 734 | { VCParcelProp, 0, 0, 0 }, |
735 | { VCPartProp, 0, 0, 0 }, | 735 | { VCPartProp, 0, 0, 0 }, |
736 | { VCPCMProp, 0, 0, 0 }, | 736 | { VCPCMProp, 0, 0, 0 }, |
737 | { VCPDFProp, 0, 0, 0 }, | 737 | { VCPDFProp, 0, 0, 0 }, |
738 | { VCPGPProp, 0, 0, 0 }, | 738 | { VCPGPProp, 0, 0, 0 }, |
739 | { VCPhotoProp, 0, 0, 0 }, | 739 | { VCPhotoProp, 0, 0, 0 }, |
740 | { VCPICTProp, 0, 0, 0 }, | 740 | { VCPICTProp, 0, 0, 0 }, |
741 | { VCPMBProp, 0, 0, 0 }, | 741 | { VCPMBProp, 0, 0, 0 }, |
742 | { VCPostalBoxProp, 0, 0, 0 }, | 742 | { VCPostalBoxProp, 0, 0, 0 }, |
743 | { VCPostalCodeProp, 0, 0, 0 }, | 743 | { VCPostalCodeProp, 0, 0, 0 }, |
744 | { VCPostalProp, 0, 0, 0 }, | 744 | { VCPostalProp, 0, 0, 0 }, |
745 | { VCPowerShareProp, 0, 0, 0 }, | 745 | { VCPowerShareProp, 0, 0, 0 }, |
746 | { VCPreferredProp, 0, 0, 0 }, | 746 | { VCPreferredProp, 0, 0, 0 }, |
747 | { VCPriorityProp, 0, 0, 0 }, | 747 | { VCPriorityProp, 0, 0, 0 }, |
748 | { VCProcedureNameProp, 0, 0, 0 }, | 748 | { VCProcedureNameProp, 0, 0, 0 }, |
749 | { VCProdIdProp, 0, 0, 0 }, | 749 | { VCProdIdProp, 0, 0, 0 }, |
750 | { VCProdigyProp, 0, 0, 0 }, | 750 | { VCProdigyProp, 0, 0, 0 }, |
751 | { VCPronunciationProp, 0, 0, 0 }, | 751 | { VCPronunciationProp, 0, 0, 0 }, |
752 | { VCPSProp, 0, 0, 0 }, | 752 | { VCPSProp, 0, 0, 0 }, |
753 | { VCPublicKeyProp, 0, 0, 0 }, | 753 | { VCPublicKeyProp, 0, 0, 0 }, |
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 | ||
798 | static struct PreDefProp* lookupPropInfo(const char* str) | 798 | static 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 | ||
812 | DLLEXPORT(const char*) lookupProp_(const char* str) | 812 | DLLEXPORT(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 | ||
826 | DLLEXPORT(const char*) lookupProp(const char* str) | 826 | DLLEXPORT(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 |
846 | typedef struct OFile { | 846 | typedef 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 |
856 | static void appendsOFile(OFile *fp, const char *s) | 856 | static 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 { |
865 | stuff: | 865 | stuff: |
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) |
878 | free(fp->s); | 878 | free(fp->s); |
879 | fp->s = 0; | 879 | fp->s = 0; |
880 | fp->fail = 1; | 880 | fp->fail = 1; |
881 | } | 881 | } |
882 | } | 882 | } |
883 | 883 | ||
884 | static void appendcOFile(OFile *fp, char c) | 884 | static void appendcOFile(OFile *fp, char c) |
885 | { | 885 | { |
886 | if (fp->fail) return; | 886 | if (fp->fail) return; |
887 | if (fp->fp) { | 887 | if (fp->fp) { |
888 | fputc(c,fp->fp); | 888 | fputc(c,fp->fp); |
889 | } | 889 | } |
890 | else { | 890 | else { |
891 | stuff: | 891 | stuff: |
892 | if (fp->len+1 < fp->limit) { | 892 | if (fp->len+1 < fp->limit) { |
893 | fp->s[fp->len] = c; | 893 | fp->s[fp->len] = c; |
894 | fp->len++; | 894 | fp->len++; |
895 | return; | 895 | return; |
896 | } | 896 | } |
897 | else if (fp->alloc) { | 897 | else if (fp->alloc) { |
898 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; | 898 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; |
899 | fp->s = (char *) realloc(fp->s,fp->limit); | 899 | fp->s = (char *) realloc(fp->s,fp->limit); |
900 | if (fp->s) goto stuff; | 900 | if (fp->s) goto stuff; |
901 | } | 901 | } |
902 | if (fp->alloc) | 902 | if (fp->alloc) |
903 | free(fp->s); | 903 | free(fp->s); |
904 | fp->s = 0; | 904 | fp->s = 0; |
905 | fp->fail = 1; | 905 | fp->fail = 1; |
906 | } | 906 | } |
907 | } | 907 | } |
908 | #else | 908 | #else |
909 | static void appendcOFile_(OFile *fp, char c) | 909 | static void appendcOFile_(OFile *fp, char c) |
910 | { | 910 | { |
911 | if (fp->fail) return; | 911 | if (fp->fail) return; |
912 | if (fp->fp) { | 912 | if (fp->fp) { |
913 | fputc(c,fp->fp); | 913 | fputc(c,fp->fp); |
914 | } | 914 | } |
915 | else { | 915 | else { |
916 | stuff: | 916 | stuff: |
917 | if (fp->len+1 < fp->limit) { | 917 | if (fp->len+1 < fp->limit) { |
918 | fp->s[fp->len] = c; | 918 | fp->s[fp->len] = c; |
919 | fp->len++; | 919 | fp->len++; |
920 | return; | 920 | return; |
921 | } | 921 | } |
922 | else if (fp->alloc) { | 922 | else if (fp->alloc) { |
923 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; | 923 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; |
924 | fp->s = (char *)realloc(fp->s,fp->limit); | 924 | fp->s = (char *)realloc(fp->s,fp->limit); |
925 | if (fp->s) goto stuff; | 925 | if (fp->s) goto stuff; |
926 | } | 926 | } |
927 | if (fp->alloc) | 927 | if (fp->alloc) |
928 | free(fp->s); | 928 | free(fp->s); |
929 | fp->s = 0; | 929 | fp->s = 0; |
930 | fp->fail = 1; | 930 | fp->fail = 1; |
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | static void appendcOFile(OFile *fp, char c) | 934 | static void appendcOFile(OFile *fp, char c) |
935 | { | 935 | { |
936 | if (c == '\n') { | 936 | if (c == '\n') { |
937 | /* write out as <CR><LF> */ | 937 | /* write out as <CR><LF> */ |
938 | appendcOFile_(fp,0xd); | 938 | appendcOFile_(fp,0xd); |
939 | appendcOFile_(fp,0xa); | 939 | appendcOFile_(fp,0xa); |
940 | } | 940 | } |
941 | else | 941 | else |
942 | appendcOFile_(fp,c); | 942 | appendcOFile_(fp,c); |
943 | } | 943 | } |
944 | 944 | ||
945 | static void appendsOFile(OFile *fp, const char *s) | 945 | static void appendsOFile(OFile *fp, const char *s) |
946 | { | 946 | { |
947 | int i, slen; | 947 | int i, slen; |
948 | slen = strlen(s); | 948 | slen = strlen(s); |
949 | for (i=0; i<slen; i++) { | 949 | for (i=0; i<slen; i++) { |
950 | appendcOFile(fp,s[i]); | 950 | appendcOFile(fp,s[i]); |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | #endif | 954 | #endif |
955 | 955 | ||
956 | static void initOFile(OFile *fp, FILE *ofp) | 956 | static void initOFile(OFile *fp, FILE *ofp) |
957 | { | 957 | { |
958 | fp->fp = ofp; | 958 | fp->fp = ofp; |
959 | fp->s = 0; | 959 | fp->s = 0; |
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 | ||
966 | static int writeBase64(OFile *fp, unsigned char *s, long len) | 966 | static 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 | ||
1008 | static void writeQPString(OFile *fp, const char *s) | 1008 | static void writeQPString(OFile *fp, const char *s) |
1009 | { | 1009 | { |
1010 | const char *p = s; | 1010 | const char *p = s; |
1011 | while (*p) { | 1011 | while (*p) { |
1012 | if (*p == '\n') { | 1012 | if (*p == '\n') { |
1013 | if (p[1]) appendsOFile(fp,"=0A="); | 1013 | if (p[1]) appendsOFile(fp,"=0A="); |
1014 | } | 1014 | } |
1015 | appendcOFile(fp,*p); | 1015 | appendcOFile(fp,*p); |
1016 | p++; | 1016 | p++; |
1017 | } | 1017 | } |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | 1020 | ||
1021 | 1021 | ||
1022 | static void writeVObject_(OFile *fp, VObject *o); | 1022 | static void writeVObject_(OFile *fp, VObject *o); |
1023 | 1023 | ||
1024 | static void writeValue(OFile *fp, VObject *o, unsigned long size) | 1024 | static void writeValue(OFile *fp, VObject *o, unsigned long size) |
1025 | { | 1025 | { |
1026 | if (o == 0) return; | 1026 | if (o == 0) return; |
1027 | switch (VALUE_TYPE(o)) { | 1027 | switch (VALUE_TYPE(o)) { |
1028 | case VCVT_STRINGZ: { | 1028 | case VCVT_STRINGZ: { |
1029 | writeQPString(fp, STRINGZ_VALUE_OF(o)); | 1029 | writeQPString(fp, STRINGZ_VALUE_OF(o)); |
1030 | break; | 1030 | break; |
1031 | } | 1031 | } |
1032 | case VCVT_UINT: { | 1032 | case VCVT_UINT: { |
1033 | char buf[16]; | 1033 | char buf[16]; |
1034 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); | 1034 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); |
1035 | appendsOFile(fp,buf); | 1035 | appendsOFile(fp,buf); |
1036 | break; | 1036 | break; |
1037 | } | 1037 | } |
1038 | case VCVT_ULONG: { | 1038 | case VCVT_ULONG: { |
1039 | char buf[16]; | 1039 | char buf[16]; |
1040 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); | 1040 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); |
1041 | appendsOFile(fp,buf); | 1041 | appendsOFile(fp,buf); |
1042 | break; | 1042 | break; |
1043 | } | 1043 | } |
1044 | case VCVT_RAW: { | 1044 | case VCVT_RAW: { |
1045 | appendcOFile(fp,'\n'); | 1045 | appendcOFile(fp,'\n'); |
1046 | writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); | 1046 | writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); |
1047 | break; | 1047 | break; |
1048 | } | 1048 | } |
1049 | case VCVT_VOBJECT: | 1049 | case VCVT_VOBJECT: |
1050 | appendcOFile(fp,'\n'); | 1050 | appendcOFile(fp,'\n'); |
1051 | writeVObject_(fp,VOBJECT_VALUE_OF(o)); | 1051 | writeVObject_(fp,VOBJECT_VALUE_OF(o)); |
1052 | break; | 1052 | break; |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | static void writeAttrValue(OFile *fp, VObject *o) | 1056 | static void writeAttrValue(OFile *fp, VObject *o) |
1057 | { | 1057 | { |
1058 | if (NAME_OF(o)) { | 1058 | if (NAME_OF(o)) { |
1059 | struct PreDefProp *pi; | 1059 | struct PreDefProp *pi; |
1060 | pi = lookupPropInfo(NAME_OF(o)); | 1060 | pi = lookupPropInfo(NAME_OF(o)); |
1061 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; | 1061 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; |
1062 | appendcOFile(fp,';'); | 1062 | appendcOFile(fp,';'); |
1063 | appendsOFile(fp,NAME_OF(o)); | 1063 | appendsOFile(fp,NAME_OF(o)); |
1064 | } | 1064 | } |
1065 | else | 1065 | else |
1066 | appendcOFile(fp,';'); | 1066 | appendcOFile(fp,';'); |
1067 | if (VALUE_TYPE(o)) { | 1067 | if (VALUE_TYPE(o)) { |
1068 | appendcOFile(fp,'='); | 1068 | appendcOFile(fp,'='); |
1069 | writeValue(fp,o,0); | 1069 | writeValue(fp,o,0); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static void writeGroup(OFile *fp, VObject *o) | 1073 | static void writeGroup(OFile *fp, VObject *o) |
1074 | { | 1074 | { |
1075 | char buf1[256]; | 1075 | char buf1[256]; |
1076 | char buf2[256]; | 1076 | char buf2[256]; |
1077 | strcpy(buf1,NAME_OF(o)); | 1077 | strcpy(buf1,NAME_OF(o)); |
1078 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { | 1078 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { |
1079 | strcpy(buf2,STRINGZ_VALUE_OF(o)); | 1079 | strcpy(buf2,STRINGZ_VALUE_OF(o)); |
1080 | strcat(buf2,"."); | 1080 | strcat(buf2,"."); |
1081 | strcat(buf2,buf1); | 1081 | strcat(buf2,buf1); |
1082 | strcpy(buf1,buf2); | 1082 | strcpy(buf1,buf2); |
1083 | } | 1083 | } |
1084 | appendsOFile(fp,buf1); | 1084 | appendsOFile(fp,buf1); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | static int inList(const char **list, const char *s) | 1087 | static int inList(const char **list, const char *s) |
1088 | { | 1088 | { |
1089 | if (list == 0) return 0; | 1089 | if (list == 0) return 0; |
1090 | while (*list) { | 1090 | while (*list) { |
1091 | if (qstricmp(*list,s) == 0) return 1; | 1091 | if (qstricmp(*list,s) == 0) return 1; |
1092 | list++; | 1092 | list++; |
1093 | } | 1093 | } |
1094 | return 0; | 1094 | return 0; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | static void writeProp(OFile *fp, VObject *o) | 1097 | static void writeProp(OFile *fp, VObject *o) |
1098 | { | 1098 | { |
1099 | if (NAME_OF(o)) { | 1099 | if (NAME_OF(o)) { |
1100 | struct PreDefProp *pi; | 1100 | struct PreDefProp *pi; |
1101 | VObjectIterator t; | 1101 | VObjectIterator t; |
1102 | const char **fields_ = 0; | 1102 | const char **fields_ = 0; |
1103 | pi = lookupPropInfo(NAME_OF(o)); | 1103 | pi = lookupPropInfo(NAME_OF(o)); |
1104 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1104 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1105 | writeVObject_(fp,o); | 1105 | writeVObject_(fp,o); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | if (isAPropertyOf(o,VCGroupingProp)) | 1108 | if (isAPropertyOf(o,VCGroupingProp)) |
1109 | writeGroup(fp,o); | 1109 | writeGroup(fp,o); |
1110 | else | 1110 | else |
1111 | appendsOFile(fp,NAME_OF(o)); | 1111 | appendsOFile(fp,NAME_OF(o)); |
1112 | if (pi) fields_ = pi->fields; | 1112 | if (pi) fields_ = pi->fields; |
1113 | initPropIterator(&t,o); | 1113 | initPropIterator(&t,o); |
1114 | while (moreIteration(&t)) { | 1114 | while (moreIteration(&t)) { |
1115 | const char *s; | 1115 | const char *s; |
1116 | VObject *eachProp = nextVObject(&t); | 1116 | VObject *eachProp = nextVObject(&t); |
1117 | s = NAME_OF(eachProp); | 1117 | s = NAME_OF(eachProp); |
1118 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) | 1118 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) |
1119 | writeAttrValue(fp,eachProp); | 1119 | writeAttrValue(fp,eachProp); |
1120 | } | 1120 | } |
1121 | if (fields_) { | 1121 | if (fields_) { |
1122 | int i = 0, n = 0; | 1122 | int i = 0, n = 0; |
1123 | const char** fields = fields_; | 1123 | const char** fields = fields_; |
1124 | /* output prop as fields */ | 1124 | /* output prop as fields */ |
1125 | appendcOFile(fp,':'); | 1125 | appendcOFile(fp,':'); |
1126 | while (*fields) { | 1126 | while (*fields) { |
1127 | VObject *t = isAPropertyOf(o,*fields); | 1127 | VObject *t = isAPropertyOf(o,*fields); |
1128 | i++; | 1128 | i++; |
1129 | if (t) n = i; | 1129 | if (t) n = i; |
1130 | fields++; | 1130 | fields++; |
1131 | } | 1131 | } |
1132 | fields = fields_; | 1132 | fields = fields_; |
1133 | for (i=0;i<n;i++) { | 1133 | for (i=0;i<n;i++) { |
1134 | writeValue(fp,isAPropertyOf(o,*fields),0); | 1134 | writeValue(fp,isAPropertyOf(o,*fields),0); |
1135 | fields++; | 1135 | fields++; |
1136 | if (i<(n-1)) appendcOFile(fp,';'); | 1136 | if (i<(n-1)) appendcOFile(fp,';'); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | if (VALUE_TYPE(o)) { | 1141 | if (VALUE_TYPE(o)) { |
1142 | unsigned long size = 0; | 1142 | unsigned long size = 0; |
1143 | VObject *p = isAPropertyOf(o,VCDataSizeProp); | 1143 | VObject *p = isAPropertyOf(o,VCDataSizeProp); |
1144 | if (p) size = LONG_VALUE_OF(p); | 1144 | if (p) size = LONG_VALUE_OF(p); |
1145 | appendcOFile(fp,':'); | 1145 | appendcOFile(fp,':'); |
1146 | writeValue(fp,o,size); | 1146 | writeValue(fp,o,size); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | appendcOFile(fp,'\n'); | 1149 | appendcOFile(fp,'\n'); |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | static void writeVObject_(OFile *fp, VObject *o) | 1152 | static void writeVObject_(OFile *fp, VObject *o) |
1153 | { | 1153 | { |
1154 | if (NAME_OF(o)) { | 1154 | if (NAME_OF(o)) { |
1155 | struct PreDefProp *pi; | 1155 | struct PreDefProp *pi; |
1156 | pi = lookupPropInfo(NAME_OF(o)); | 1156 | pi = lookupPropInfo(NAME_OF(o)); |
1157 | 1157 | ||
1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1159 | VObjectIterator t; | 1159 | VObjectIterator t; |
1160 | const char *begin = NAME_OF(o); | 1160 | const char *begin = NAME_OF(o); |
1161 | appendsOFile(fp,"BEGIN:"); | 1161 | appendsOFile(fp,"BEGIN:"); |
1162 | appendsOFile(fp,begin); | 1162 | appendsOFile(fp,begin); |
1163 | appendcOFile(fp,'\n'); | 1163 | appendcOFile(fp,'\n'); |
1164 | initPropIterator(&t,o); | 1164 | initPropIterator(&t,o); |
1165 | while (moreIteration(&t)) { | 1165 | while (moreIteration(&t)) { |
1166 | VObject *eachProp = nextVObject(&t); | 1166 | VObject *eachProp = nextVObject(&t); |
1167 | writeProp(fp, eachProp); | 1167 | writeProp(fp, eachProp); |
1168 | } | 1168 | } |
1169 | appendsOFile(fp,"END:"); | 1169 | appendsOFile(fp,"END:"); |
1170 | appendsOFile(fp,begin); | 1170 | appendsOFile(fp,begin); |
1171 | appendsOFile(fp,"\n\n"); | 1171 | appendsOFile(fp,"\n\n"); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | void writeVObject(FILE *fp, VObject *o) | 1176 | void writeVObject(FILE *fp, VObject *o) |
1177 | { | 1177 | { |
1178 | OFile ofp; | 1178 | OFile ofp; |
1179 | // ##### | 1179 | // ##### |
1180 | //_setmode(_fileno(fp), _O_BINARY); | 1180 | //_setmode(_fileno(fp), _O_BINARY); |
1181 | initOFile(&ofp,fp); | 1181 | initOFile(&ofp,fp); |
1182 | writeVObject_(&ofp,o); | 1182 | writeVObject_(&ofp,o); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) | 1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) |
1186 | { | 1186 | { |
1187 | QFileDirect f( fname); | 1187 | QFileDirect f( fname); |
1188 | if ( !f.open( IO_WriteOnly ) ) { | 1188 | if ( !f.open( IO_WriteOnly ) ) { |
1189 | qWarning("Unable to open vobject write %s", fname); | 1189 | qWarning("Unable to open vobject write %s", fname); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | writeVObject( f.directHandle(),o ); | 1193 | writeVObject( f.directHandle(),o ); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | 1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) |
1197 | { | 1197 | { |
1198 | QFileDirect f( fname); | 1198 | QFileDirect f( fname); |
1199 | if ( !f.open( IO_WriteOnly ) ) { | 1199 | if ( !f.open( IO_WriteOnly ) ) { |
1200 | qWarning("Unable to open vobject write %s", fname); | 1200 | qWarning("Unable to open vobject write %s", fname); |
1201 | return; | 1201 | return; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | while (list) { | 1204 | while (list) { |
1205 | writeVObject(f.directHandle(),list); | 1205 | writeVObject(f.directHandle(),list); |
1206 | list = nextVObjectInList(list); | 1206 | list = nextVObjectInList(list); |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | ||
1211 | { | ||
1212 | const char *type = vObjectName( o ); | ||
1213 | if ( strcmp( type, "TYPE" ) == 0 ) | ||
1214 | type = vObjectStringZValue( o ); | ||
1215 | return type; | ||
1216 | } | ||
1217 | |||
1218 | |||
1210 | // end of source file vobject.c | 1219 | // end of source file vobject.c |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index b6a2c0a..a0d921e 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -1,401 +1,404 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | 2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International |
3 | Business Machines Corporation and Siemens Rolm Communications Inc. | 3 | Business Machines Corporation and Siemens Rolm Communications Inc. |
4 | 4 | ||
5 | For purposes of this license notice, the term Licensors shall mean, | 5 | For purposes of this license notice, the term Licensors shall mean, |
6 | collectively, Apple Computer, Inc., AT&T Corp., International | 6 | collectively, Apple Computer, Inc., AT&T Corp., International |
7 | Business Machines Corporation and Siemens Rolm Communications Inc. | 7 | Business Machines Corporation and Siemens Rolm Communications Inc. |
8 | The term Licensor shall mean any of the Licensors. | 8 | The term Licensor shall mean any of the Licensors. |
9 | 9 | ||
10 | Subject to acceptance of the following conditions, permission is hereby | 10 | Subject to acceptance of the following conditions, permission is hereby |
11 | granted by Licensors without the need for written agreement and without | 11 | granted by Licensors without the need for written agreement and without |
12 | license or royalty fees, to use, copy, modify and distribute this | 12 | license or royalty fees, to use, copy, modify and distribute this |
13 | software for any purpose. | 13 | software for any purpose. |
14 | 14 | ||
15 | The above copyright notice and the following four paragraphs must be | 15 | The above copyright notice and the following four paragraphs must be |
16 | reproduced in all copies of this software and any software including | 16 | reproduced in all copies of this software and any software including |
17 | this software. | 17 | this software. |
18 | 18 | ||
19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE | 19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE |
20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR | 20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR |
21 | MODIFICATIONS. | 21 | MODIFICATIONS. |
22 | 22 | ||
23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, | 23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, |
24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT | 24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT |
25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
26 | DAMAGE. | 26 | DAMAGE. |
27 | 27 | ||
28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, | 28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, |
29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE | 29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE |
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
31 | PURPOSE. | 31 | PURPOSE. |
32 | 32 | ||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | 33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or |
34 | disclosure by the government are subject to restrictions set forth in | 34 | disclosure by the government are subject to restrictions set forth in |
35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | 35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. |
36 | 36 | ||
37 | ***************************************************************************/ | 37 | ***************************************************************************/ |
38 | 38 | ||
39 | /* | 39 | /* |
40 | 40 | ||
41 | The vCard/vCalendar C interface is implemented in the set | 41 | The vCard/vCalendar C interface is implemented in the set |
42 | of files as follows: | 42 | of files as follows: |
43 | 43 | ||
44 | vcc.y, yacc source, and vcc.c, the yacc output you will use | 44 | vcc.y, yacc source, and vcc.c, the yacc output you will use |
45 | implements the core parser | 45 | implements the core parser |
46 | 46 | ||
47 | vobject.c implements an API that insulates the caller from | 47 | vobject.c implements an API that insulates the caller from |
48 | the parser and changes in the vCard/vCalendar BNF | 48 | the parser and changes in the vCard/vCalendar BNF |
49 | 49 | ||
50 | port.h defines compilation environment dependent stuff | 50 | port.h defines compilation environment dependent stuff |
51 | 51 | ||
52 | vcc.h and vobject.h are header files for their .c counterparts | 52 | vcc.h and vobject.h are header files for their .c counterparts |
53 | 53 | ||
54 | vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions | 54 | vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions |
55 | which you may find useful. | 55 | which you may find useful. |
56 | 56 | ||
57 | test.c is a standalone test driver that exercises some of | 57 | test.c is a standalone test driver that exercises some of |
58 | the features of the APIs provided. Invoke test.exe on a | 58 | the features of the APIs provided. Invoke test.exe on a |
59 | VCARD/VCALENDAR input text file and you will see the pretty | 59 | VCARD/VCALENDAR input text file and you will see the pretty |
60 | print output of the internal representation (this pretty print | 60 | print output of the internal representation (this pretty print |
61 | output should give you a good idea of how the internal | 61 | output should give you a good idea of how the internal |
62 | representation looks like -- there is one such output in the | 62 | representation looks like -- there is one such output in the |
63 | following too). Also, a file with the .out suffix is generated | 63 | following too). Also, a file with the .out suffix is generated |
64 | to show that the internal representation can be written back | 64 | to show that the internal representation can be written back |
65 | in the original text format. | 65 | in the original text format. |
66 | 66 | ||
67 | For more information on this API see the readme.txt file | 67 | For more information on this API see the readme.txt file |
68 | which accompanied this distribution. | 68 | which accompanied this distribution. |
69 | 69 | ||
70 | Also visit: | 70 | Also visit: |
71 | 71 | ||
72 | http://www.versit.com | 72 | http://www.versit.com |
73 | http://www.ralden.com | 73 | http://www.ralden.com |
74 | 74 | ||
75 | */ | 75 | */ |
76 | 76 | ||
77 | 77 | ||
78 | #ifndef __VOBJECT_H__ | 78 | #ifndef __VOBJECT_H__ |
79 | #define __VOBJECT_H__ 1 | 79 | #define __VOBJECT_H__ 1 |
80 | 80 | ||
81 | #include <qstring.h> | 81 | #include <qstring.h> |
82 | 82 | ||
83 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" | 83 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" |
84 | #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar" | 84 | #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar" |
85 | 85 | ||
86 | /* The above strings vCardClipboardFormat and vCalendarClipboardFormat | 86 | /* The above strings vCardClipboardFormat and vCalendarClipboardFormat |
87 | are globally unique IDs which can be used to generate clipboard format | 87 | are globally unique IDs which can be used to generate clipboard format |
88 | ID's as per the requirements of a specific platform. For example, in | 88 | ID's as per the requirements of a specific platform. For example, in |
89 | Windows they are used as the parameter in a call to RegisterClipboardFormat. | 89 | Windows they are used as the parameter in a call to RegisterClipboardFormat. |
90 | For example: | 90 | For example: |
91 | 91 | ||
92 | CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); | 92 | CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); |
93 | 93 | ||
94 | */ | 94 | */ |
95 | 95 | ||
96 | #define vCardMimeType "text/x-vCard" | 96 | #define vCardMimeType "text/x-vCard" |
97 | #define vCalendarMimeType"text/x-vCalendar" | 97 | #define vCalendarMimeType"text/x-vCalendar" |
98 | 98 | ||
99 | #undef DLLEXPORT | 99 | #undef DLLEXPORT |
100 | #include <qglobal.h> | 100 | #include <qglobal.h> |
101 | #if defined(Q_WS_WIN) | 101 | #if defined(Q_WS_WIN) |
102 | #define DLLEXPORT(t) __declspec(dllexport) t | 102 | #define DLLEXPORT(t) __declspec(dllexport) t |
103 | #else | 103 | #else |
104 | #define DLLEXPORT(t) t | 104 | #define DLLEXPORT(t) t |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | #ifndef FALSE | 107 | #ifndef FALSE |
108 | #define FALSE0 | 108 | #define FALSE0 |
109 | #endif | 109 | #endif |
110 | #ifndef TRUE | 110 | #ifndef TRUE |
111 | #define TRUE1 | 111 | #define TRUE1 |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #include <stdlib.h> | 114 | #include <stdlib.h> |
115 | #include <stdio.h> | 115 | #include <stdio.h> |
116 | 116 | ||
117 | 117 | ||
118 | #define VC7bitProp "7BIT" | 118 | #define VC7bitProp "7BIT" |
119 | #define VC8bitProp "8BIT" | 119 | #define VC8bitProp "8BIT" |
120 | #define VCAAlarmProp "AALARM" | 120 | #define VCAAlarmProp "AALARM" |
121 | #define VCAdditionalNamesProp"ADDN" | 121 | #define VCAdditionalNamesProp"ADDN" |
122 | #define VCAdrProp "ADR" | 122 | #define VCAdrProp "ADR" |
123 | #define VCAgentProp "AGENT" | 123 | #define VCAgentProp "AGENT" |
124 | #define VCAIFFProp "AIFF" | 124 | #define VCAIFFProp "AIFF" |
125 | #define VCAOLProp "AOL" | 125 | #define VCAOLProp "AOL" |
126 | #define VCAppleLinkProp "APPLELINK" | 126 | #define VCAppleLinkProp "APPLELINK" |
127 | #define VCAttachProp "ATTACH" | 127 | #define VCAttachProp "ATTACH" |
128 | #define VCAttendeeProp "ATTENDEE" | 128 | #define VCAttendeeProp "ATTENDEE" |
129 | #define VCATTMailProp "ATTMAIL" | 129 | #define VCATTMailProp "ATTMAIL" |
130 | #define VCAudioContentProp "AUDIOCONTENT" | 130 | #define VCAudioContentProp "AUDIOCONTENT" |
131 | #define VCAVIProp "AVI" | 131 | #define VCAVIProp "AVI" |
132 | #define VCBase64Prop "BASE64" | 132 | #define VCBase64Prop "BASE64" |
133 | #define VCBBSProp "BBS" | 133 | #define VCBBSProp "BBS" |
134 | #define VCBirthDateProp "BDAY" | 134 | #define VCBirthDateProp "BDAY" |
135 | #define VCBMPProp "BMP" | 135 | #define VCBMPProp "BMP" |
136 | #define VCBodyProp "BODY" | 136 | #define VCBodyProp "BODY" |
137 | #define VCBusinessRoleProp "ROLE" | 137 | #define VCBusinessRoleProp "ROLE" |
138 | #define VCCalProp "VCALENDAR" | 138 | #define VCCalProp "VCALENDAR" |
139 | #define VCCaptionProp "CAP" | 139 | #define VCCaptionProp "CAP" |
140 | #define VCCardProp "VCARD" | 140 | #define VCCardProp "VCARD" |
141 | #define VCCarProp "CAR" | 141 | #define VCCarProp "CAR" |
142 | #define VCCategoriesProp "CATEGORIES" | 142 | #define VCCategoriesProp "CATEGORIES" |
143 | #define VCCellularProp "CELL" | 143 | #define VCCellularProp "CELL" |
144 | #define VCCGMProp "CGM" | 144 | #define VCCGMProp "CGM" |
145 | #define VCCharSetProp "CS" | 145 | #define VCCharSetProp "CS" |
146 | #define VCCIDProp "CID" | 146 | #define VCCIDProp "CID" |
147 | #define VCCISProp "CIS" | 147 | #define VCCISProp "CIS" |
148 | #define VCCityProp "L" | 148 | #define VCCityProp "L" |
149 | #define VCClassProp "CLASS" | 149 | #define VCClassProp "CLASS" |
150 | #define VCCommentProp "NOTE" | 150 | #define VCCommentProp "NOTE" |
151 | #define VCCompletedProp "COMPLETED" | 151 | #define VCCompletedProp "COMPLETED" |
152 | #define VCContentIDProp "CONTENT-ID" | 152 | #define VCContentIDProp "CONTENT-ID" |
153 | #define VCCountryNameProp "C" | 153 | #define VCCountryNameProp "C" |
154 | #define VCDAlarmProp "DALARM" | 154 | #define VCDAlarmProp "DALARM" |
155 | #define VCDataSizeProp "DATASIZE" | 155 | #define VCDataSizeProp "DATASIZE" |
156 | #define VCDayLightProp "DAYLIGHT" | 156 | #define VCDayLightProp "DAYLIGHT" |
157 | #define VCDCreatedProp "DCREATED" | 157 | #define VCDCreatedProp "DCREATED" |
158 | #define VCDeliveryLabelProp "LABEL" | 158 | #define VCDeliveryLabelProp "LABEL" |
159 | #define VCDescriptionProp "DESCRIPTION" | 159 | #define VCDescriptionProp "DESCRIPTION" |
160 | #define VCDIBProp "DIB" | 160 | #define VCDIBProp "DIB" |
161 | #define VCDisplayStringProp "DISPLAYSTRING" | 161 | #define VCDisplayStringProp "DISPLAYSTRING" |
162 | #define VCDomesticProp "DOM" | 162 | #define VCDomesticProp "DOM" |
163 | #define VCDTendProp "DTEND" | 163 | #define VCDTendProp "DTEND" |
164 | #define VCDTstartProp "DTSTART" | 164 | #define VCDTstartProp "DTSTART" |
165 | #define VCDueProp "DUE" | 165 | #define VCDueProp "DUE" |
166 | #define VCEmailAddressProp "EMAIL" | 166 | #define VCEmailAddressProp "EMAIL" |
167 | #define VCEncodingProp "ENCODING" | 167 | #define VCEncodingProp "ENCODING" |
168 | #define VCEndProp "END" | 168 | #define VCEndProp "END" |
169 | #define VCEventProp "VEVENT" | 169 | #define VCEventProp "VEVENT" |
170 | #define VCEWorldProp "EWORLD" | 170 | #define VCEWorldProp "EWORLD" |
171 | #define VCExNumProp "EXNUM" | 171 | #define VCExNumProp "EXNUM" |
172 | #define VCExpDateProp "EXDATE" | 172 | #define VCExpDateProp "EXDATE" |
173 | #define VCExpectProp "EXPECT" | 173 | #define VCExpectProp "EXPECT" |
174 | #define VCExtAddressProp "EXT ADD" | 174 | #define VCExtAddressProp "EXT ADD" |
175 | #define VCFamilyNameProp "F" | 175 | #define VCFamilyNameProp "F" |
176 | #define VCFaxProp "FAX" | 176 | #define VCFaxProp "FAX" |
177 | #define VCFullNameProp "FN" | 177 | #define VCFullNameProp "FN" |
178 | #define VCGeoProp "GEO" | 178 | #define VCGeoProp "GEO" |
179 | #define VCGeoLocationProp "GEO" | 179 | #define VCGeoLocationProp "GEO" |
180 | #define VCGIFProp "GIF" | 180 | #define VCGIFProp "GIF" |
181 | #define VCGivenNameProp "G" | 181 | #define VCGivenNameProp "G" |
182 | #define VCGroupingProp "Grouping" | 182 | #define VCGroupingProp "Grouping" |
183 | #define VCHomeProp "HOME" | 183 | #define VCHomeProp "HOME" |
184 | #define VCIBMMailProp "IBMMail" | 184 | #define VCIBMMailProp "IBMMail" |
185 | #define VCInlineProp "INLINE" | 185 | #define VCInlineProp "INLINE" |
186 | #define VCInternationalProp "INTL" | 186 | #define VCInternationalProp "INTL" |
187 | #define VCInternetProp "INTERNET" | 187 | #define VCInternetProp "INTERNET" |
188 | #define VCISDNProp "ISDN" | 188 | #define VCISDNProp "ISDN" |
189 | #define VCJPEGProp "JPEG" | 189 | #define VCJPEGProp "JPEG" |
190 | #define VCLanguageProp "LANG" | 190 | #define VCLanguageProp "LANG" |
191 | #define VCLastModifiedProp "LAST-MODIFIED" | 191 | #define VCLastModifiedProp "LAST-MODIFIED" |
192 | #define VCLastRevisedProp "REV" | 192 | #define VCLastRevisedProp "REV" |
193 | #define VCLocationProp "LOCATION" | 193 | #define VCLocationProp "LOCATION" |
194 | #define VCLogoProp "LOGO" | 194 | #define VCLogoProp "LOGO" |
195 | #define VCMailerProp "MAILER" | 195 | #define VCMailerProp "MAILER" |
196 | #define VCMAlarmProp "MALARM" | 196 | #define VCMAlarmProp "MALARM" |
197 | #define VCMCIMailProp "MCIMAIL" | 197 | #define VCMCIMailProp "MCIMAIL" |
198 | #define VCMessageProp "MSG" | 198 | #define VCMessageProp "MSG" |
199 | #define VCMETProp "MET" | 199 | #define VCMETProp "MET" |
200 | #define VCModemProp "MODEM" | 200 | #define VCModemProp "MODEM" |
201 | #define VCMPEG2Prop "MPEG2" | 201 | #define VCMPEG2Prop "MPEG2" |
202 | #define VCMPEGProp "MPEG" | 202 | #define VCMPEGProp "MPEG" |
203 | #define VCMSNProp "MSN" | 203 | #define VCMSNProp "MSN" |
204 | #define VCNamePrefixesProp "NPRE" | 204 | #define VCNamePrefixesProp "NPRE" |
205 | #define VCNameProp "N" | 205 | #define VCNameProp "N" |
206 | #define VCNameSuffixesProp "NSUF" | 206 | #define VCNameSuffixesProp "NSUF" |
207 | #define VCNoteProp "NOTE" | 207 | #define VCNoteProp "NOTE" |
208 | #define VCOrgNameProp "ORGNAME" | 208 | #define VCOrgNameProp "ORGNAME" |
209 | #define VCOrgProp "ORG" | 209 | #define VCOrgProp "ORG" |
210 | #define VCOrgUnit2Prop "OUN2" | 210 | #define VCOrgUnit2Prop "OUN2" |
211 | #define VCOrgUnit3Prop "OUN3" | 211 | #define VCOrgUnit3Prop "OUN3" |
212 | #define VCOrgUnit4Prop "OUN4" | 212 | #define VCOrgUnit4Prop "OUN4" |
213 | #define VCOrgUnitProp "OUN" | 213 | #define VCOrgUnitProp "OUN" |
214 | #define VCPagerProp "PAGER" | 214 | #define VCPagerProp "PAGER" |
215 | #define VCPAlarmProp "PALARM" | 215 | #define VCPAlarmProp "PALARM" |
216 | #define VCParcelProp "PARCEL" | 216 | #define VCParcelProp "PARCEL" |
217 | #define VCPartProp "PART" | 217 | #define VCPartProp "PART" |
218 | #define VCPCMProp "PCM" | 218 | #define VCPCMProp "PCM" |
219 | #define VCPDFProp "PDF" | 219 | #define VCPDFProp "PDF" |
220 | #define VCPGPProp "PGP" | 220 | #define VCPGPProp "PGP" |
221 | #define VCPhotoProp "PHOTO" | 221 | #define VCPhotoProp "PHOTO" |
222 | #define VCPICTProp "PICT" | 222 | #define VCPICTProp "PICT" |
223 | #define VCPMBProp "PMB" | 223 | #define VCPMBProp "PMB" |
224 | #define VCPostalBoxProp "BOX" | 224 | #define VCPostalBoxProp "BOX" |
225 | #define VCPostalCodeProp "PC" | 225 | #define VCPostalCodeProp "PC" |
226 | #define VCPostalProp "POSTAL" | 226 | #define VCPostalProp "POSTAL" |
227 | #define VCPowerShareProp "POWERSHARE" | 227 | #define VCPowerShareProp "POWERSHARE" |
228 | #define VCPreferredProp "PREF" | 228 | #define VCPreferredProp "PREF" |
229 | #define VCPriorityProp "PRIORITY" | 229 | #define VCPriorityProp "PRIORITY" |
230 | #define VCProcedureNameProp "PROCEDURENAME" | 230 | #define VCProcedureNameProp "PROCEDURENAME" |
231 | #define VCProdIdProp "PRODID" | 231 | #define VCProdIdProp "PRODID" |
232 | #define VCProdigyProp "PRODIGY" | 232 | #define VCProdigyProp "PRODIGY" |
233 | #define VCPronunciationProp "SOUND" | 233 | #define VCPronunciationProp "SOUND" |
234 | #define VCPSProp "PS" | 234 | #define VCPSProp "PS" |
235 | #define VCPublicKeyProp "KEY" | 235 | #define VCPublicKeyProp "KEY" |
236 | #define VCQPProp "QP" | 236 | #define VCQPProp "QP" |
237 | #define VCQuickTimeProp "QTIME" | 237 | #define VCQuickTimeProp "QTIME" |
238 | #define VCQuotedPrintableProp"QUOTED-PRINTABLE" | 238 | #define VCQuotedPrintableProp"QUOTED-PRINTABLE" |
239 | #define VCRDateProp "RDATE" | 239 | #define VCRDateProp "RDATE" |
240 | #define VCRegionProp "R" | 240 | #define VCRegionProp "R" |
241 | #define VCRelatedToProp "RELATED-TO" | 241 | #define VCRelatedToProp "RELATED-TO" |
242 | #define VCRepeatCountProp "REPEATCOUNT" | 242 | #define VCRepeatCountProp "REPEATCOUNT" |
243 | #define VCResourcesProp "RESOURCES" | 243 | #define VCResourcesProp "RESOURCES" |
244 | #define VCRNumProp "RNUM" | 244 | #define VCRNumProp "RNUM" |
245 | #define VCRoleProp "ROLE" | 245 | #define VCRoleProp "ROLE" |
246 | #define VCRRuleProp "RRULE" | 246 | #define VCRRuleProp "RRULE" |
247 | #define VCRSVPProp "RSVP" | 247 | #define VCRSVPProp "RSVP" |
248 | #define VCRunTimeProp "RUNTIME" | 248 | #define VCRunTimeProp "RUNTIME" |
249 | #define VCSequenceProp "SEQUENCE" | 249 | #define VCSequenceProp "SEQUENCE" |
250 | #define VCSnoozeTimeProp "SNOOZETIME" | 250 | #define VCSnoozeTimeProp "SNOOZETIME" |
251 | #define VCStartProp "START" | 251 | #define VCStartProp "START" |
252 | #define VCStatusProp "STATUS" | 252 | #define VCStatusProp "STATUS" |
253 | #define VCStreetAddressProp "STREET" | 253 | #define VCStreetAddressProp "STREET" |
254 | #define VCSubTypeProp "SUBTYPE" | 254 | #define VCSubTypeProp "SUBTYPE" |
255 | #define VCSummaryProp "SUMMARY" | 255 | #define VCSummaryProp "SUMMARY" |
256 | #define VCTelephoneProp "TEL" | 256 | #define VCTelephoneProp "TEL" |
257 | #define VCTIFFProp "TIFF" | 257 | #define VCTIFFProp "TIFF" |
258 | #define VCTimeZoneProp "TZ" | 258 | #define VCTimeZoneProp "TZ" |
259 | #define VCTitleProp "TITLE" | 259 | #define VCTitleProp "TITLE" |
260 | #define VCTLXProp "TLX" | 260 | #define VCTLXProp "TLX" |
261 | #define VCTodoProp "VTODO" | 261 | #define VCTodoProp "VTODO" |
262 | #define VCTranspProp "TRANSP" | 262 | #define VCTranspProp "TRANSP" |
263 | #define VCUniqueStringProp "UID" | 263 | #define VCUniqueStringProp "UID" |
264 | #define VCURLProp "URL" | 264 | #define VCURLProp "URL" |
265 | #define VCURLValueProp "URLVAL" | 265 | #define VCURLValueProp "URLVAL" |
266 | #define VCValueProp "VALUE" | 266 | #define VCValueProp "VALUE" |
267 | #define VCVersionProp "VERSION" | 267 | #define VCVersionProp "VERSION" |
268 | #define VCVideoProp "VIDEO" | 268 | #define VCVideoProp "VIDEO" |
269 | #define VCVoiceProp "VOICE" | 269 | #define VCVoiceProp "VOICE" |
270 | #define VCWAVEProp "WAVE" | 270 | #define VCWAVEProp "WAVE" |
271 | #define VCWMFProp "WMF" | 271 | #define VCWMFProp "WMF" |
272 | #define VCWorkProp "WORK" | 272 | #define VCWorkProp "WORK" |
273 | #define VCX400Prop "X400" | 273 | #define VCX400Prop "X400" |
274 | #define VCX509Prop "X509" | 274 | #define VCX509Prop "X509" |
275 | #define VCXRuleProp "XRULE" | 275 | #define VCXRuleProp "XRULE" |
276 | 276 | ||
277 | 277 | ||
278 | typedef struct VObject VObject; | 278 | typedef struct VObject VObject; |
279 | 279 | ||
280 | typedef struct VObjectIterator { | 280 | typedef struct VObjectIterator { |
281 | VObject* start; | 281 | VObject* start; |
282 | VObject* next; | 282 | VObject* next; |
283 | } VObjectIterator; | 283 | } VObjectIterator; |
284 | 284 | ||
285 | extern DLLEXPORT(VObject*) newVObject(const char *id); | 285 | extern DLLEXPORT(VObject*) newVObject(const char *id); |
286 | extern DLLEXPORT(void) deleteVObject(VObject *p); | 286 | extern DLLEXPORT(void) deleteVObject(VObject *p); |
287 | extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); | 287 | extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); |
288 | extern DLLEXPORT(void) deleteStr(const char *p); | 288 | extern DLLEXPORT(void) deleteStr(const char *p); |
289 | extern DLLEXPORT(void) unUseStr(const char *s); | 289 | extern DLLEXPORT(void) unUseStr(const char *s); |
290 | 290 | ||
291 | extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); | 291 | extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); |
292 | extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); | 292 | extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); |
293 | extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); | 293 | extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); |
294 | extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); | 294 | extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); |
295 | extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); | 295 | extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); |
296 | extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); | 296 | extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); |
297 | extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); | 297 | extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); |
298 | extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); | 298 | extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); |
299 | 299 | ||
300 | extern DLLEXPORT(const char*) vObjectName(VObject *o); | 300 | extern DLLEXPORT(const char*) vObjectName(VObject *o); |
301 | extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); | 301 | extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); |
302 | extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); | 302 | extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); |
303 | extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); | 303 | extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); |
304 | extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); | 304 | extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); |
305 | extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); | 305 | extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); |
306 | extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); | 306 | extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); |
307 | 307 | ||
308 | extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); | 308 | extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); |
309 | extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); | 309 | extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); |
310 | extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); | 310 | extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); |
311 | extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); | 311 | extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); |
312 | extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); | 312 | extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); |
313 | extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); | 313 | extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); |
314 | extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); | 314 | extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); |
315 | extern DLLEXPORT(void) addList(VObject **o, VObject *p); | 315 | extern DLLEXPORT(void) addList(VObject **o, VObject *p); |
316 | 316 | ||
317 | extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); | 317 | extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); |
318 | 318 | ||
319 | extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); | 319 | extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); |
320 | extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); | 320 | extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); |
321 | extern DLLEXPORT(int) moreIteration(VObjectIterator *i); | 321 | extern DLLEXPORT(int) moreIteration(VObjectIterator *i); |
322 | extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); | 322 | extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); |
323 | 323 | ||
324 | extern DLLEXPORT(const char*) lookupStr(const char *s); | 324 | extern DLLEXPORT(const char*) lookupStr(const char *s); |
325 | extern DLLEXPORT(void) cleanStrTbl(); | 325 | extern DLLEXPORT(void) cleanStrTbl(); |
326 | 326 | ||
327 | extern DLLEXPORT(void) cleanVObject(VObject *o); | 327 | extern DLLEXPORT(void) cleanVObject(VObject *o); |
328 | extern DLLEXPORT(void) cleanVObjects(VObject *list); | 328 | extern DLLEXPORT(void) cleanVObjects(VObject *list); |
329 | 329 | ||
330 | extern DLLEXPORT(const char*) lookupProp(const char* str); | 330 | extern DLLEXPORT(const char*) lookupProp(const char* str); |
331 | extern DLLEXPORT(const char*) lookupProp_(const char* str); | 331 | extern DLLEXPORT(const char*) lookupProp_(const char* str); |
332 | 332 | ||
333 | extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); | 333 | extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); |
334 | extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); | 334 | extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); |
335 | 335 | ||
336 | extern DLLEXPORT(int) vObjectValueType(VObject *o); | 336 | extern DLLEXPORT(int) vObjectValueType(VObject *o); |
337 | 337 | ||
338 | /* return type of vObjectValueType: */ | 338 | /* return type of vObjectValueType: */ |
339 | #define VCVT_NOVALUE0 | 339 | #define VCVT_NOVALUE0 |
340 | /* if the VObject has no value associated with it. */ | 340 | /* if the VObject has no value associated with it. */ |
341 | #define VCVT_STRINGZ1 | 341 | #define VCVT_STRINGZ1 |
342 | /* if the VObject has value set by setVObjectStringZValue. */ | 342 | /* if the VObject has value set by setVObjectStringZValue. */ |
343 | #define VCVT_UINT 2 | 343 | #define VCVT_UINT 2 |
344 | /* if the VObject has value set by setVObjectIntegerValue. */ | 344 | /* if the VObject has value set by setVObjectIntegerValue. */ |
345 | #define VCVT_ULONG 3 | 345 | #define VCVT_ULONG 3 |
346 | /* if the VObject has value set by setVObjectLongValue. */ | 346 | /* if the VObject has value set by setVObjectLongValue. */ |
347 | #define VCVT_RAW 4 | 347 | #define VCVT_RAW 4 |
348 | /* if the VObject has value set by setVObjectAnyValue. */ | 348 | /* if the VObject has value set by setVObjectAnyValue. */ |
349 | #define VCVT_VOBJECT5 | 349 | #define VCVT_VOBJECT5 |
350 | /* if the VObject has value set by setVObjectVObjectValue. */ | 350 | /* if the VObject has value set by setVObjectVObjectValue. */ |
351 | 351 | ||
352 | extern const char** fieldedProp; | 352 | extern const char** fieldedProp; |
353 | 353 | ||
354 | /*************************************************** | 354 | /*************************************************** |
355 | * The methods below are implemented in vcc.c (generated from vcc.y ) | 355 | * The methods below are implemented in vcc.c (generated from vcc.y ) |
356 | ***************************************************/ | 356 | ***************************************************/ |
357 | 357 | ||
358 | /* NOTE regarding printVObject and writeVObject | 358 | /* NOTE regarding printVObject and writeVObject |
359 | 359 | ||
360 | The functions below are not exported from the DLL because they | 360 | The functions below are not exported from the DLL because they |
361 | take a FILE* as a parameter, which cannot be passed across a DLL | 361 | take a FILE* as a parameter, which cannot be passed across a DLL |
362 | interface (at least that is my experience). Instead you can use | 362 | interface (at least that is my experience). Instead you can use |
363 | their companion functions which take file names or pointers | 363 | their companion functions which take file names or pointers |
364 | to memory. However, if you are linking this code into | 364 | to memory. However, if you are linking this code into |
365 | your build directly then you may find them a more convenient API | 365 | your build directly then you may find them a more convenient API |
366 | and you can go ahead and use them. If you try to use them with | 366 | and you can go ahead and use them. If you try to use them with |
367 | the DLL LIB you will get a link error. | 367 | the DLL LIB you will get a link error. |
368 | */ | 368 | */ |
369 | extern void writeVObject(FILE *fp, VObject *o); | 369 | extern void writeVObject(FILE *fp, VObject *o); |
370 | 370 | ||
371 | 371 | ||
372 | 372 | ||
373 | typedef void (*MimeErrorHandler)(char *); | 373 | typedef void (*MimeErrorHandler)(char *); |
374 | 374 | ||
375 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); | 375 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); |
376 | 376 | ||
377 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); | 377 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); |
378 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); | 378 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); |
379 | 379 | ||
380 | 380 | ||
381 | /* NOTE regarding Parse_MIME_FromFile | 381 | /* NOTE regarding Parse_MIME_FromFile |
382 | The function above, Parse_MIME_FromFile, comes in two flavors, | 382 | The function above, Parse_MIME_FromFile, comes in two flavors, |
383 | neither of which is exported from the DLL. Each version takes | 383 | neither of which is exported from the DLL. Each version takes |
384 | a CFile or FILE* as a parameter, neither of which can be | 384 | a CFile or FILE* as a parameter, neither of which can be |
385 | passed across a DLL interface (at least that is my experience). | 385 | passed across a DLL interface (at least that is my experience). |
386 | If you are linking this code into your build directly then | 386 | If you are linking this code into your build directly then |
387 | you may find them a more convenient API that the other flavors | 387 | you may find them a more convenient API that the other flavors |
388 | that take a file name. If you use them with the DLL LIB you | 388 | that take a file name. If you use them with the DLL LIB you |
389 | will get a link error. | 389 | will get a link error. |
390 | */ | 390 | */ |
391 | 391 | ||
392 | 392 | ||
393 | #if INCLUDEMFC | 393 | #if INCLUDEMFC |
394 | extern VObject* Parse_MIME_FromFile(CFile *file); | 394 | extern VObject* Parse_MIME_FromFile(CFile *file); |
395 | #else | 395 | #else |
396 | extern VObject* Parse_MIME_FromFile(FILE *file); | 396 | extern VObject* Parse_MIME_FromFile(FILE *file); |
397 | #endif | 397 | #endif |
398 | 398 | ||
399 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); | ||
400 | |||
401 | |||
399 | #endif /* __VOBJECT_H__ */ | 402 | #endif /* __VOBJECT_H__ */ |
400 | 403 | ||
401 | 404 | ||
diff --git a/library/categoryedit_p.cpp b/library/categoryedit_p.cpp index 06e5fec..07e707e 100644 --- a/library/categoryedit_p.cpp +++ b/library/categoryedit_p.cpp | |||
@@ -1,227 +1,229 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 "categoryedit_p.h" | 21 | #include "categoryedit_p.h" |
22 | 22 | ||
23 | #include <qpe/categories.h> | 23 | #include <qpe/categories.h> |
24 | 24 | ||
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | 31 | ||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | 37 | ||
38 | using namespace Qtopia; | 38 | using namespace Qtopia; |
39 | 39 | ||
40 | class CategoryEditPrivate | 40 | class CategoryEditPrivate |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | CategoryEditPrivate( QWidget *parent, const QString &appName ) | 43 | CategoryEditPrivate( QWidget *parent, const QString &appName ) |
44 | : mCategories( parent, "" ), | 44 | : mCategories( parent, "" ), |
45 | mStrApp( appName ) | 45 | mStrApp( appName ) |
46 | { | 46 | { |
47 | editItem = 0; | 47 | editItem = 0; |
48 | mCategories.load( categoryFileName() ); | 48 | mCategories.load( categoryFileName() ); |
49 | } | 49 | } |
50 | Categories mCategories; | 50 | Categories mCategories; |
51 | QListViewItem *editItem; | 51 | QListViewItem *editItem; |
52 | QString mStrApp; | 52 | QString mStrApp; |
53 | QString mVisible; | 53 | QString mVisible; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | CategoryEdit::CategoryEdit( QWidget *parent, const char *name ) | 56 | CategoryEdit::CategoryEdit( QWidget *parent, const char *name ) |
57 | : CategoryEditBase( parent, name ) | 57 | : CategoryEditBase( parent, name ) |
58 | { | 58 | { |
59 | d = 0; | 59 | d = 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | CategoryEdit::CategoryEdit( const QArray<int> &recCats, | 62 | CategoryEdit::CategoryEdit( const QArray<int> &recCats, |
63 | const QString &appName, const QString &visibleName, | 63 | const QString &appName, const QString &visibleName, |
64 | QWidget *parent, const char *name ) | 64 | QWidget *parent, const char *name ) |
65 | : CategoryEditBase( parent, name ) | 65 | : CategoryEditBase( parent, name ) |
66 | { | 66 | { |
67 | d = 0; | 67 | d = 0; |
68 | setCategories( recCats, appName, visibleName ); | 68 | setCategories( recCats, appName, visibleName ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void CategoryEdit::setCategories( const QArray<int> &recCats, | 71 | void CategoryEdit::setCategories( const QArray<int> &recCats, |
72 | const QString &appName, const QString &visibleName ) | 72 | const QString &appName, const QString &visibleName ) |
73 | { | 73 | { |
74 | if ( !d ) | 74 | if ( !d ) |
75 | d = new CategoryEditPrivate( (QWidget*)parent(), name() ); | 75 | d = new CategoryEditPrivate( (QWidget*)parent(), name() ); |
76 | d->mStrApp = appName; | 76 | d->mStrApp = appName; |
77 | d->mVisible = visibleName; | 77 | d->mVisible = visibleName; |
78 | QArray<int> cats = d->mCategories.ids( d->mStrApp ); | 78 | |
79 | lvView->clear(); | ||
80 | QStringList appCats = d->mCategories.labels( d->mStrApp ); | 79 | QStringList appCats = d->mCategories.labels( d->mStrApp ); |
80 | QArray<int> cats = d->mCategories.ids(d->mStrApp, appCats); | ||
81 | lvView->clear(); | ||
82 | |||
81 | QStringList::ConstIterator it; | 83 | QStringList::ConstIterator it; |
82 | int i, j; | 84 | int i, j; |
83 | for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) { | 85 | for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) { |
84 | QCheckListItem *chk; | 86 | QCheckListItem *chk; |
85 | chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox ); | 87 | chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox ); |
86 | if ( !d->mCategories.isGlobal((*it)) ) | 88 | if ( !d->mCategories.isGlobal((*it)) ) |
87 | chk->setText( 1, tr(d->mVisible) ); | 89 | chk->setText( 1, tr(d->mVisible) ); |
88 | else | 90 | else |
89 | chk->setText( 1, tr("All") ); | 91 | chk->setText( 1, tr("All") ); |
90 | // Is this record using this category, then we should check it | 92 | // Is this record using this category, then we should check it |
91 | for ( j = 0; j < int(recCats.count()); j++ ) { | 93 | for ( j = 0; j < int(recCats.count()); j++ ) { |
92 | if ( cats[i] == recCats[j] ) { | 94 | if ( cats[i] == recCats[j] ) { |
93 | chk->setOn( true ); | 95 | chk->setOn( true ); |
94 | break; | 96 | break; |
95 | } | 97 | } |
96 | } | 98 | } |
97 | } | 99 | } |
98 | lvView->setSorting( 0, TRUE ); | 100 | lvView->setSorting( 0, TRUE ); |
99 | lvView->sort(); | 101 | lvView->sort(); |
100 | if ( lvView->childCount() < 1 ) | 102 | if ( lvView->childCount() < 1 ) |
101 | txtCat->setEnabled( FALSE ); | 103 | txtCat->setEnabled( FALSE ); |
102 | else { | 104 | else { |
103 | lvView->setSelected( lvView->firstChild(), true ); | 105 | lvView->setSelected( lvView->firstChild(), true ); |
104 | } | 106 | } |
105 | } | 107 | } |
106 | 108 | ||
107 | CategoryEdit::~CategoryEdit() | 109 | CategoryEdit::~CategoryEdit() |
108 | { | 110 | { |
109 | if ( d ) | 111 | if ( d ) |
110 | delete d; | 112 | delete d; |
111 | } | 113 | } |
112 | 114 | ||
113 | void CategoryEdit::slotSetText( QListViewItem *selected ) | 115 | void CategoryEdit::slotSetText( QListViewItem *selected ) |
114 | { | 116 | { |
115 | d->editItem = selected; | 117 | d->editItem = selected; |
116 | if ( !d->editItem ) | 118 | if ( !d->editItem ) |
117 | return; | 119 | return; |
118 | txtCat->setText( d->editItem->text(0) ); | 120 | txtCat->setText( d->editItem->text(0) ); |
119 | txtCat->setEnabled( true ); | 121 | txtCat->setEnabled( true ); |
120 | if ( d->editItem->text(1) == tr("All") ) | 122 | if ( d->editItem->text(1) == tr("All") ) |
121 | chkGlobal->setChecked( true ); | 123 | chkGlobal->setChecked( true ); |
122 | else | 124 | else |
123 | chkGlobal->setChecked( false ); | 125 | chkGlobal->setChecked( false ); |
124 | } | 126 | } |
125 | 127 | ||
126 | void CategoryEdit::slotAdd() | 128 | void CategoryEdit::slotAdd() |
127 | { | 129 | { |
128 | QString name = tr( "New Category" ); | 130 | QString name = tr( "New Category" ); |
129 | bool insertOk = FALSE; | 131 | bool insertOk = FALSE; |
130 | int num = 0; | 132 | int num = 0; |
131 | while ( !insertOk ) { | 133 | while ( !insertOk ) { |
132 | if ( num++ > 0 ) | 134 | if ( num++ > 0 ) |
133 | name = tr("New Category ") + QString::number(num); | 135 | name = tr("New Category ") + QString::number(num); |
134 | insertOk = d->mCategories.addCategory( d->mStrApp, name ); | 136 | insertOk = d->mCategories.addCategory( d->mStrApp, name ); |
135 | } | 137 | } |
136 | QCheckListItem *chk; | 138 | QCheckListItem *chk; |
137 | chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox ); | 139 | chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox ); |
138 | if ( !chkGlobal->isChecked() ) | 140 | if ( !chkGlobal->isChecked() ) |
139 | chk->setText( 1, tr(d->mVisible) ); | 141 | chk->setText( 1, tr(d->mVisible) ); |
140 | else | 142 | else |
141 | chk->setText( 1, tr("All") ); | 143 | chk->setText( 1, tr("All") ); |
142 | 144 | ||
143 | lvView->setSelected( chk, TRUE ); | 145 | lvView->setSelected( chk, TRUE ); |
144 | txtCat->selectAll(); | 146 | txtCat->selectAll(); |
145 | } | 147 | } |
146 | 148 | ||
147 | void CategoryEdit::slotRemove() | 149 | void CategoryEdit::slotRemove() |
148 | { | 150 | { |
149 | d->editItem = lvView->selectedItem(); | 151 | d->editItem = lvView->selectedItem(); |
150 | if ( d->editItem ) { | 152 | if ( d->editItem ) { |
151 | QListViewItem *sibling = d->editItem->nextSibling(); | 153 | QListViewItem *sibling = d->editItem->nextSibling(); |
152 | 154 | ||
153 | d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) ); | 155 | d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) ); |
154 | 156 | ||
155 | delete d->editItem; | 157 | delete d->editItem; |
156 | d->editItem = 0; | 158 | d->editItem = 0; |
157 | 159 | ||
158 | if ( sibling ) | 160 | if ( sibling ) |
159 | lvView->setSelected( sibling, TRUE ); | 161 | lvView->setSelected( sibling, TRUE ); |
160 | } | 162 | } |
161 | if ( lvView->childCount() < 1 ) { | 163 | if ( lvView->childCount() < 1 ) { |
162 | txtCat->clear(); | 164 | txtCat->clear(); |
163 | txtCat->setEnabled( FALSE ); | 165 | txtCat->setEnabled( FALSE ); |
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | void CategoryEdit::slotSetGlobal( bool isChecked ) | 169 | void CategoryEdit::slotSetGlobal( bool isChecked ) |
168 | { | 170 | { |
169 | if ( d->editItem ) { | 171 | if ( d->editItem ) { |
170 | if ( isChecked ) | 172 | if ( isChecked ) |
171 | d->editItem->setText( 1, tr("All") ); | 173 | d->editItem->setText( 1, tr("All") ); |
172 | else | 174 | else |
173 | d->editItem->setText( 1, tr(d->mVisible) ); | 175 | d->editItem->setText( 1, tr(d->mVisible) ); |
174 | 176 | ||
175 | d->mCategories.setGlobal( d->mStrApp, d->editItem->text( 0 ), isChecked ); | 177 | d->mCategories.setGlobal( d->mStrApp, d->editItem->text( 0 ), isChecked ); |
176 | } | 178 | } |
177 | } | 179 | } |
178 | 180 | ||
179 | void CategoryEdit::slotTextChanged( const QString &strNew ) | 181 | void CategoryEdit::slotTextChanged( const QString &strNew ) |
180 | { | 182 | { |
181 | if ( d->editItem ) { | 183 | if ( d->editItem ) { |
182 | if ( chkGlobal->isChecked() ) | 184 | if ( chkGlobal->isChecked() ) |
183 | d->mCategories.renameGlobalCategory( d->editItem->text(0), strNew ); | 185 | d->mCategories.renameGlobalCategory( d->editItem->text(0), strNew ); |
184 | else | 186 | else |
185 | d->mCategories.renameCategory( d->mStrApp, d->editItem->text(0), strNew ); | 187 | d->mCategories.renameCategory( d->mStrApp, d->editItem->text(0), strNew ); |
186 | d->editItem->setText( 0, strNew ); | 188 | d->editItem->setText( 0, strNew ); |
187 | } | 189 | } |
188 | } | 190 | } |
189 | 191 | ||
190 | QArray<int> CategoryEdit::newCategories() | 192 | QArray<int> CategoryEdit::newCategories() |
191 | { | 193 | { |
192 | QArray<int> a; | 194 | QArray<int> a; |
193 | if ( d ) { | 195 | if ( d ) { |
194 | d->mCategories.save( categoryFileName() ); | 196 | d->mCategories.save( categoryFileName() ); |
195 | QListViewItemIterator it( lvView ); | 197 | QListViewItemIterator it( lvView ); |
196 | QValueList<int> l; | 198 | QValueList<int> l; |
197 | for ( ; it.current(); ++it ) { | 199 | for ( ; it.current(); ++it ) { |
198 | if ( reinterpret_cast<QCheckListItem*>(it.current())->isOn() ) | 200 | if ( reinterpret_cast<QCheckListItem*>(it.current())->isOn() ) |
199 | l.append( d->mCategories.id( d->mStrApp, it.current()->text(0) ) ); | 201 | l.append( d->mCategories.id( d->mStrApp, it.current()->text(0) ) ); |
200 | } | 202 | } |
201 | uint i = 0; | 203 | uint i = 0; |
202 | a.resize( l.count() ); | 204 | a.resize( l.count() ); |
203 | for ( QValueList<int>::Iterator lit = l.begin(); lit != l.end(); ++lit ) | 205 | for ( QValueList<int>::Iterator lit = l.begin(); lit != l.end(); ++lit ) |
204 | a[i++] = *lit; | 206 | a[i++] = *lit; |
205 | } | 207 | } |
206 | return a; | 208 | return a; |
207 | } | 209 | } |
208 | 210 | ||
209 | void CategoryEdit::accept() | 211 | void CategoryEdit::accept() |
210 | { | 212 | { |
211 | // write our categories out... | 213 | // write our categories out... |
212 | d->mCategories.save( categoryFileName() ); | 214 | d->mCategories.save( categoryFileName() ); |
213 | // QDialog::accept(); | 215 | // QDialog::accept(); |
214 | } | 216 | } |
215 | 217 | ||
216 | QString categoryFileName() | 218 | QString categoryFileName() |
217 | { | 219 | { |
218 | QDir dir = (QString(getenv("HOME")) + "/Settings"); | 220 | QDir dir = (QString(getenv("HOME")) + "/Settings"); |
219 | if ( !dir.exists() ) | 221 | if ( !dir.exists() ) |
220 | mkdir( dir.path().local8Bit(), 0700 ); | 222 | mkdir( dir.path().local8Bit(), 0700 ); |
221 | return dir.path() + "/" + "Categories" + ".xml"; | 223 | return dir.path() + "/" + "Categories" + ".xml"; |
222 | } | 224 | } |
223 | 225 | ||
224 | void CategoryEdit::kludge() | 226 | void CategoryEdit::kludge() |
225 | { | 227 | { |
226 | lvView->setMaximumHeight( 130 ); | 228 | lvView->setMaximumHeight( 130 ); |
227 | } | 229 | } |
diff --git a/library/categoryselect.cpp b/library/categoryselect.cpp index dc5d1fa..21b3f91 100644 --- a/library/categoryselect.cpp +++ b/library/categoryselect.cpp | |||
@@ -1,315 +1,452 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 <qpe/categories.h> | 21 | #include <qpe/categories.h> |
22 | #include <qpe/palmtoprecord.h> | ||
22 | 23 | ||
23 | #include <qdialog.h> | 24 | #include <qmessagebox.h> |
24 | #include <qlayout.h> | 25 | #include <qlayout.h> |
25 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | #include <qfile.h> | ||
26 | 28 | ||
27 | #include "categorywidget.h" | 29 | #include "categorywidget.h" |
28 | #include "categoryselect.h" | 30 | #include "categoryselect.h" |
29 | 31 | ||
32 | #include <stdlib.h> | ||
33 | |||
34 | static QString categoryEdittingFileName() | ||
35 | { | ||
36 | QString str = getenv("HOME"); | ||
37 | str +="/.cateditting"; | ||
38 | return str; | ||
39 | } | ||
30 | 40 | ||
31 | class CategoryComboPrivate | 41 | class CategoryComboPrivate |
32 | { | 42 | { |
33 | public: | 43 | public: |
34 | CategoryComboPrivate(QObject *o) | 44 | CategoryComboPrivate(QObject *o) |
35 | : mCat( o ) | 45 | : mCat( o ) |
36 | { | 46 | { |
37 | } | 47 | } |
38 | QArray<int> mAppCats; | 48 | QArray<int> mAppCats; |
39 | QString mStrAppName; | 49 | QString mStrAppName; |
40 | QString mStrVisibleName; | 50 | QString mStrVisibleName; |
41 | Categories mCat; | 51 | Categories mCat; |
42 | }; | 52 | }; |
43 | 53 | ||
44 | class CategorySelectPrivate | 54 | class CategorySelectPrivate |
45 | { | 55 | { |
46 | public: | 56 | public: |
47 | CategorySelectPrivate( const QArray<int> &cats) | 57 | CategorySelectPrivate( const QArray<int> &cats) |
48 | : mRec( cats ), | 58 | : mRec( cats ), |
49 | usingAll( false ) | 59 | usingAll( false ) |
50 | { | 60 | { |
51 | } | 61 | } |
52 | CategorySelectPrivate() | 62 | CategorySelectPrivate() |
53 | { | 63 | { |
54 | } | 64 | } |
55 | QArray<int> mRec; | 65 | QArray<int> mRec; |
56 | bool usingAll; | 66 | bool usingAll; |
57 | QString mVisibleName; | 67 | QString mVisibleName; |
58 | }; | 68 | }; |
59 | 69 | ||
60 | CategoryCombo::CategoryCombo( QWidget *parent, const char *name ) | 70 | CategoryCombo::CategoryCombo( QWidget *parent, const char *name , int width) |
61 | : QComboBox( parent, name ) | 71 | : QComboBox( parent, name ) |
62 | { | 72 | { |
63 | d = new CategoryComboPrivate(this); | 73 | d = new CategoryComboPrivate(this); |
74 | if (width) | ||
75 | setFixedWidth(width); | ||
64 | } | 76 | } |
65 | 77 | ||
66 | void CategoryCombo::initCombo( const QArray<int> &recCats, | 78 | void CategoryCombo::initCombo( const QArray<int> &recCats, |
67 | const QString &appName ) | 79 | const QString &appName ) |
68 | { | 80 | { |
69 | initCombo( recCats, appName, appName ); | 81 | initCombo( recCats, appName, appName ); |
70 | } | 82 | } |
71 | 83 | ||
72 | void CategoryCombo::initCombo( const QArray<int> &recCats, | 84 | void CategoryCombo::initCombo( const QArray<int> &recCats, |
73 | const QString &appName, | 85 | const QString &appName, |
74 | const QString &visibleName ) | 86 | const QString &visibleName ) |
75 | { | 87 | { |
76 | d->mStrAppName = appName; | 88 | d->mStrAppName = appName; |
77 | d->mStrVisibleName = visibleName; | 89 | d->mStrVisibleName = visibleName; |
78 | clear(); | 90 | clear(); |
79 | QStringList slApp; | 91 | QStringList slApp; |
80 | 92 | ||
93 | QObject::disconnect( this, SIGNAL(activated(int)), | ||
94 | this, SLOT(slotValueChanged(int)) ); | ||
95 | |||
81 | QObject::connect( this, SIGNAL(activated(int)), | 96 | QObject::connect( this, SIGNAL(activated(int)), |
82 | this, SLOT(slotValueChanged(int)) ); | 97 | this, SLOT(slotValueChanged(int)) ); |
83 | bool loadOk = d->mCat.load( categoryFileName() ); | 98 | bool loadOk = d->mCat.load( categoryFileName() ); |
84 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); | 99 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); |
85 | d->mAppCats = d->mCat.ids( d->mStrAppName ); | 100 | |
101 | d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); | ||
86 | 102 | ||
87 | int i, | 103 | int i, |
88 | j, | 104 | j, |
89 | saveMe, | 105 | saveMe, |
90 | recCount; | 106 | recCount; |
91 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
92 | // now add in all the items... | 108 | // now add in all the items... |
93 | recCount = recCats.count(); | 109 | recCount = recCats.count(); |
94 | saveMe = -1; | 110 | saveMe = -1; |
95 | if ( recCount > 1 && loadOk ) { | 111 | if ( recCount > 1 && loadOk ) { |
96 | it = slApp.begin(); | 112 | it = slApp.begin(); |
97 | insertItem( *it ); | 113 | for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { |
98 | ++it; | ||
99 | for ( j = 0; it != slApp.end(); ++it, j++ ) { | ||
100 | // grr... we have to go through and compare... | 114 | // grr... we have to go through and compare... |
101 | if ( j < int(d->mAppCats.size()) ) { | 115 | if ( j < int(d->mAppCats.size()) ) { |
102 | for ( i = 0; i < recCount; i++ ) { | 116 | for ( i = 0; i < recCount; i++ ) { |
103 | if ( recCats[i] == d->mAppCats[j] ) { | 117 | if ( recCats[i] == d->mAppCats[j] ) { |
104 | (*it).append( tr(" (Multi.)") ); | 118 | (*it).append( tr(" (Multi.)") ); |
105 | if ( saveMe < 0 ) | 119 | if ( saveMe < 0 ) |
106 | saveMe = j; | 120 | saveMe = j; |
107 | // no need to continue through the list. | 121 | // no need to continue through the list. |
108 | break; | 122 | break; |
109 | } | 123 | } |
110 | } | 124 | } |
111 | } | 125 | } |
112 | insertItem( *it ); | 126 | insertItem( *it ); |
113 | } | 127 | } |
128 | insertItem( *it ); | ||
114 | } else | 129 | } else |
115 | insertStringList( slApp ); | 130 | insertStringList( slApp ); |
116 | 131 | ||
117 | if ( recCount > 0 && loadOk ) { | 132 | if ( recCount > 0 && loadOk ) { |
118 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | 133 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { |
119 | if ( d->mAppCats[i] == recCats[0] ) { | 134 | if ( d->mAppCats[i] == recCats[0] ) { |
120 | setCurrentItem( i + 1 ); | 135 | setCurrentItem( i ); |
136 | break; | ||
137 | } | ||
138 | } | ||
139 | } else | ||
140 | { | ||
141 | setCurrentItem( slApp.count()-1 ); // unfiled | ||
142 | } | ||
143 | } | ||
144 | |||
145 | // this is a new function by SHARP instead of initCombo() | ||
146 | QArray<int> CategoryCombo::initComboWithRefind( const QArray<int> &recCats, | ||
147 | const QString &appName) | ||
148 | { | ||
149 | QString visibleName = appName; | ||
150 | d->mStrAppName = appName; | ||
151 | d->mStrVisibleName = visibleName; | ||
152 | clear(); | ||
153 | QStringList slApp; | ||
154 | QArray<int> results; | ||
155 | |||
156 | QObject::disconnect( this, SIGNAL(activated(int)), | ||
157 | this, SLOT(slotValueChanged(int)) ); | ||
158 | |||
159 | QObject::connect( this, SIGNAL(activated(int)), | ||
160 | this, SLOT(slotValueChanged(int)) ); | ||
161 | bool loadOk = d->mCat.load( categoryFileName() ); | ||
162 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); | ||
163 | |||
164 | d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); | ||
165 | |||
166 | // addition part | ||
167 | // make new recCats | ||
168 | if (loadOk){ | ||
169 | int i,j; | ||
170 | int value; | ||
171 | int rCount = recCats.count(); | ||
172 | int mCount = d->mAppCats.count(); | ||
173 | |||
174 | for (i=0; i<rCount; i++){ | ||
175 | value = 0; | ||
176 | for (j=0; j<mCount; j++){ | ||
177 | if (recCats[i] == d->mAppCats[j]){ | ||
178 | value = recCats[i]; | ||
179 | break; | ||
180 | } | ||
181 | } | ||
182 | if (value != 0){ | ||
183 | int tmp = results.size(); | ||
184 | results.resize( tmp + 1 ); | ||
185 | results[ tmp ] = value; | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | else{ | ||
190 | results = recCats; | ||
191 | } | ||
192 | // addition end | ||
193 | |||
194 | int i, | ||
195 | j, | ||
196 | saveMe, | ||
197 | recCount; | ||
198 | QStringList::Iterator it; | ||
199 | // now add in all the items... | ||
200 | recCount = results.count(); | ||
201 | saveMe = -1; | ||
202 | if ( recCount > 1 && loadOk ) { | ||
203 | it = slApp.begin(); | ||
204 | for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { | ||
205 | |||
206 | // grr... we have to go through and compare... | ||
207 | if ( j < int(d->mAppCats.size()) ) { | ||
208 | for ( i = 0; i < recCount; i++ ) { | ||
209 | if ( results[i] == d->mAppCats[j] ) { | ||
210 | (*it).append( tr(" (Multi.)") ); | ||
211 | if ( saveMe < 0 ) | ||
212 | saveMe = j; | ||
213 | // no need to continue through the list. | ||
214 | break; | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | insertItem( *it ); | ||
219 | } | ||
220 | insertItem( *it ); | ||
221 | } else | ||
222 | insertStringList( slApp ); | ||
223 | |||
224 | if ( recCount > 0 && loadOk ) { | ||
225 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | ||
226 | if ( d->mAppCats[i] == results[0] ) { | ||
227 | setCurrentItem( i ); | ||
121 | break; | 228 | break; |
122 | } | 229 | } |
123 | } | 230 | } |
124 | } else | 231 | } else |
125 | setCurrentItem( 0 ); // unfiled | 232 | { |
233 | setCurrentItem( slApp.count()-1 ); // unfiled | ||
234 | } | ||
235 | /* | ||
126 | QObject::connect( this, SIGNAL(activated(int)), | 236 | QObject::connect( this, SIGNAL(activated(int)), |
127 | this, SLOT(slotValueChanged(int)) ); | 237 | this, SLOT(slotValueChanged(int)) ); |
238 | */ | ||
239 | return results; | ||
128 | } | 240 | } |
129 | 241 | ||
242 | |||
130 | CategoryCombo::~CategoryCombo() | 243 | CategoryCombo::~CategoryCombo() |
131 | { | 244 | { |
132 | delete d; | 245 | delete d; |
133 | } | 246 | } |
134 | 247 | ||
135 | int CategoryCombo::currentCategory() const | 248 | int CategoryCombo::currentCategory() const |
136 | { | 249 | { |
137 | int returnMe; | 250 | int returnMe; |
138 | returnMe = currentItem(); | 251 | returnMe = currentItem(); |
139 | // unfiled is now 0... | 252 | |
140 | if ( returnMe == 0 ) | 253 | if ( returnMe == (int)d->mAppCats.count() ) |
141 | returnMe = -1; | 254 | returnMe = -1; |
142 | else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" | 255 | else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" |
143 | returnMe = -2; | 256 | returnMe = -2; |
144 | else | 257 | else |
145 | returnMe = d->mAppCats[returnMe - 1]; | 258 | returnMe = d->mAppCats[returnMe]; |
146 | return returnMe; | 259 | return returnMe; |
147 | } | 260 | } |
148 | 261 | ||
149 | void CategoryCombo::setCurrentCategory( int newCatUid ) | 262 | void CategoryCombo::setCurrentCategory( int newCatUid ) |
150 | { | 263 | { |
151 | int i; | 264 | int i; |
152 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | 265 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { |
153 | if ( d->mAppCats[i] == newCatUid ) | 266 | if ( d->mAppCats[i] == newCatUid ) |
154 | setCurrentItem( i ); | 267 | setCurrentItem( i ); |
155 | } | 268 | } |
156 | } | 269 | } |
157 | 270 | ||
158 | void CategoryCombo::setCurrentText( const QString &str ) | 271 | void CategoryCombo::setCurrentText( const QString &str ) |
159 | { | 272 | { |
160 | int i; | 273 | int i; |
161 | int stop; | 274 | int stop; |
162 | stop = count(); | 275 | stop = count(); |
163 | for ( i = 0; i < stop; i++ ) { | 276 | for ( i = 0; i < stop; i++ ) { |
164 | if ( text( i ) == str ) { | 277 | if ( text( i ) == str ) { |
165 | setCurrentItem( i ); | 278 | setCurrentItem( i ); |
166 | break; | 279 | break; |
167 | } | 280 | } |
168 | } | 281 | } |
169 | } | 282 | } |
170 | 283 | ||
171 | void CategoryCombo::slotValueChanged( int ) | 284 | void CategoryCombo::slotValueChanged( int ) |
172 | { | 285 | { |
173 | emit sigCatChanged( currentCategory() ); | 286 | emit sigCatChanged( currentCategory() ); |
174 | } | 287 | } |
175 | 288 | ||
176 | CategorySelect::CategorySelect( QWidget *parent, const char *name ) | 289 | CategorySelect::CategorySelect( QWidget *parent, const char *name,int width) |
177 | : QHBox( parent, name ), | 290 | : QHBox( parent, name ), |
178 | cmbCat( 0 ), | 291 | cmbCat( 0 ), |
179 | cmdCat( 0 ), | 292 | cmdCat( 0 ), |
180 | d( 0 ) | 293 | d( 0 ) |
181 | { | 294 | { |
182 | d = new CategorySelectPrivate(); | 295 | d = new CategorySelectPrivate(); |
183 | init(); | 296 | init(width); |
184 | } | 297 | } |
185 | 298 | ||
186 | CategorySelect::CategorySelect( const QArray<int> &vl, | 299 | CategorySelect::CategorySelect( const QArray<int> &vl, |
187 | const QString &appName, QWidget *parent, | 300 | const QString &appName, QWidget *parent, |
188 | const char *name ) | 301 | const char *name ,int width) |
189 | : QHBox( parent, name ) | 302 | : QHBox( parent, name ) |
190 | { | 303 | { |
191 | d = new CategorySelectPrivate( vl ); | 304 | d = new CategorySelectPrivate( vl ); |
192 | init(); | 305 | |
306 | init(width); | ||
307 | |||
193 | setCategories( vl, appName, appName ); | 308 | setCategories( vl, appName, appName ); |
194 | } | 309 | } |
195 | 310 | ||
196 | CategorySelect::CategorySelect( const QArray<int> &vl, | 311 | CategorySelect::CategorySelect( const QArray<int> &vl, |
197 | const QString &appName, | 312 | const QString &appName, |
198 | const QString &visibleName, | 313 | const QString &visibleName, |
199 | QWidget *parent, const char *name ) | 314 | QWidget *parent, const char *name , int width) |
200 | : QHBox( parent, name ) | 315 | : QHBox( parent, name ) |
201 | { | 316 | { |
202 | d = new CategorySelectPrivate( vl ); | 317 | d = new CategorySelectPrivate( vl ); |
203 | init(); | 318 | init(width); |
204 | setCategories( vl, appName, visibleName ); | 319 | setCategories( vl, appName, visibleName ); |
205 | } | 320 | } |
206 | 321 | ||
207 | CategorySelect::~CategorySelect() | 322 | CategorySelect::~CategorySelect() |
208 | { | 323 | { |
209 | delete d; | 324 | delete d; |
210 | } | 325 | } |
211 | 326 | ||
212 | void CategorySelect::slotDialog() | 327 | void CategorySelect::slotDialog() |
213 | { | 328 | { |
329 | if (QFile::exists( categoryEdittingFileName() )){ | ||
330 | QMessageBox::warning(this,tr("Error"), | ||
331 | tr("Sorry, another application is\nediting categories.") ); | ||
332 | return; | ||
333 | } | ||
334 | |||
335 | QFile f( categoryEdittingFileName() ); | ||
336 | if ( !f.open( IO_WriteOnly) ){ | ||
337 | return; | ||
338 | } | ||
339 | |||
214 | QDialog editDlg( this, 0, TRUE ); | 340 | QDialog editDlg( this, 0, TRUE ); |
215 | editDlg.setCaption( tr("Edit Categories") ); | 341 | editDlg.setCaption( tr("Edit Categories") ); |
216 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 342 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
217 | QScrollView *sv = new QScrollView( &editDlg ); | 343 | QScrollView *sv = new QScrollView( &editDlg ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 344 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 345 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
220 | vb->addWidget( sv ); | 346 | vb->addWidget( sv ); |
221 | CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); | 347 | CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); |
222 | sv->addChild( &ce ); | 348 | sv->addChild( &ce ); |
223 | editDlg.showMaximized(); | 349 | editDlg.showMaximized(); |
224 | 350 | ||
225 | if ( editDlg.exec() ) { | 351 | if ( editDlg.exec() ) { |
226 | d->mRec = ce.newCategories(); | 352 | d->mRec = ce.newCategories(); |
227 | cmbCat->initCombo( d->mRec, mStrAppName ); | 353 | cmbCat->initCombo( d->mRec, mStrAppName ); |
228 | } | 354 | } |
355 | |||
356 | f.close(); | ||
357 | QFile::remove( categoryEdittingFileName() ); | ||
229 | } | 358 | } |
230 | 359 | ||
231 | void CategorySelect::slotNewCat( int newUid ) | 360 | void CategorySelect::slotNewCat( int newUid ) |
232 | { | 361 | { |
233 | if ( newUid != -1 ) { | 362 | if ( newUid != -1 ) { |
234 | bool alreadyIn = false; | 363 | bool alreadyIn = false; |
235 | for ( uint it = 0; it < d->mRec.count(); ++it ) { | 364 | for ( uint it = 0; it < d->mRec.count(); ++it ) { |
236 | if ( d->mRec[it] == newUid ) { | 365 | if ( d->mRec[it] == newUid ) { |
237 | alreadyIn = true; | 366 | alreadyIn = true; |
238 | break; | 367 | break; |
239 | } | 368 | } |
240 | } | 369 | } |
241 | if ( !alreadyIn ) { | 370 | if ( !alreadyIn ) { |
242 | d->mRec.resize( 1 ); | 371 | d->mRec.resize( 1 ); |
243 | d->mRec[ 0 ] = newUid; | 372 | d->mRec[ 0 ] = newUid; |
244 | } | 373 | } |
245 | } else | 374 | } else |
246 | d->mRec.resize(0); // now Unfiled. | 375 | d->mRec.resize(0); // now Unfiled. |
247 | emit signalSelected( currentCategory() ); | 376 | emit signalSelected( currentCategory() ); |
248 | } | 377 | } |
249 | 378 | ||
250 | void CategorySelect::setCategories( const QArray<int> &rec, | 379 | QString CategorySelect::setCategories( const QArray<int> &rec, |
251 | const QString &appName ) | 380 | const QString &appName ) |
252 | { | 381 | { |
253 | setCategories( rec, appName, appName ); | 382 | return setCategories( rec, appName, appName ); |
254 | } | 383 | } |
255 | 384 | ||
256 | void CategorySelect::setCategories( const QArray<int> &rec, | 385 | QString CategorySelect::setCategories( const QArray<int> &rec, |
257 | const QString &appName, | 386 | const QString &appName, |
258 | const QString &visibleName ) | 387 | const QString &visibleName ) |
259 | { | 388 | { |
260 | d->mRec = rec; | ||
261 | d->mVisibleName = visibleName; | 389 | d->mVisibleName = visibleName; |
262 | mStrAppName = appName; | 390 | mStrAppName = appName; |
263 | cmbCat->initCombo( rec, appName ); | 391 | d->mRec = cmbCat->initComboWithRefind( rec, appName ); |
392 | return Qtopia::Record::idsToString(d->mRec); | ||
264 | } | 393 | } |
265 | 394 | ||
266 | void CategorySelect::init() | 395 | void CategorySelect::init(int width) |
267 | { | 396 | { |
268 | cmbCat = new CategoryCombo( this ); | 397 | cmbCat = new CategoryCombo( this, 0, width); |
398 | |||
269 | QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), | 399 | QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), |
270 | this, SLOT(slotNewCat(int)) ); | 400 | this, SLOT(slotNewCat(int)) ); |
271 | cmdCat = new QToolButton( this ); | 401 | cmdCat = new QToolButton( this ); |
272 | QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); | 402 | QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); |
273 | cmdCat->setTextLabel( "...", FALSE ); | 403 | cmdCat->setTextLabel( "...", FALSE ); |
274 | cmdCat->setUsesTextLabel( true ); | 404 | cmdCat->setUsesTextLabel( true ); |
275 | cmdCat->setMaximumSize( cmdCat->sizeHint() ); | 405 | cmdCat->setMaximumSize( cmdCat->sizeHint() ); |
276 | cmdCat->setFocusPolicy( TabFocus ); | 406 | cmdCat->setFocusPolicy( TabFocus ); |
277 | } | 407 | } |
278 | 408 | ||
279 | 409 | ||
280 | int CategorySelect::currentCategory() const | 410 | int CategorySelect::currentCategory() const |
281 | { | 411 | { |
282 | return cmbCat->currentCategory(); | 412 | return cmbCat->currentCategory(); |
283 | } | 413 | } |
284 | 414 | ||
285 | void CategorySelect::setCurrentCategory( int newCatUid ) | 415 | void CategorySelect::setCurrentCategory( int newCatUid ) |
286 | { | 416 | { |
287 | cmbCat->setCurrentCategory( newCatUid ); | 417 | cmbCat->setCurrentCategory( newCatUid ); |
288 | } | 418 | } |
289 | 419 | ||
290 | 420 | ||
291 | const QArray<int> &CategorySelect::currentCategories() const | 421 | const QArray<int> &CategorySelect::currentCategories() const |
292 | { | 422 | { |
293 | return d->mRec; | 423 | return d->mRec; |
294 | } | 424 | } |
295 | 425 | ||
296 | void CategorySelect::setRemoveCategoryEdit( bool remove ) | 426 | void CategorySelect::setRemoveCategoryEdit( bool remove ) |
297 | { | 427 | { |
298 | if ( remove ) { | 428 | if ( remove ) { |
299 | cmdCat->setEnabled( FALSE ); | 429 | cmdCat->setEnabled( FALSE ); |
300 | cmdCat->hide(); | 430 | cmdCat->hide(); |
301 | } else { | 431 | } else { |
302 | cmdCat->setEnabled( TRUE ); | 432 | cmdCat->setEnabled( TRUE ); |
303 | cmdCat->show(); | 433 | cmdCat->show(); |
304 | } | 434 | } |
305 | } | 435 | } |
306 | 436 | ||
307 | void CategorySelect::setAllCategories( bool add ) | 437 | void CategorySelect::setAllCategories( bool add ) |
308 | { | 438 | { |
309 | d->usingAll = add; | 439 | d->usingAll = add; |
310 | if ( add ) { | 440 | if ( add ) { |
311 | cmbCat->insertItem( tr( "All" ), cmbCat->count() ); | 441 | cmbCat->insertItem( tr( "All" ), cmbCat->count() ); |
312 | cmbCat->setCurrentItem( cmbCat->count() - 1 ); | 442 | cmbCat->setCurrentItem( cmbCat->count() - 1 ); |
313 | } else | 443 | } else |
314 | cmbCat->removeItem( cmbCat->count() - 1 ); | 444 | cmbCat->removeItem( cmbCat->count() - 1 ); |
315 | } | 445 | } |
446 | |||
447 | // 01.12.21 added | ||
448 | void CategorySelect::setFixedWidth(int width) | ||
449 | { | ||
450 | width -= cmdCat->width(); | ||
451 | cmbCat->setFixedWidth(width); | ||
452 | } | ||
diff --git a/library/categoryselect.h b/library/categoryselect.h index 5c6b565..7a8e491 100644 --- a/library/categoryselect.h +++ b/library/categoryselect.h | |||
@@ -1,105 +1,113 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | #ifndef __CATEGORYCOMBO_H__ | 21 | #ifndef __CATEGORYCOMBO_H__ |
22 | #define __CATEGORYCOMBO_H__ | 22 | #define __CATEGORYCOMBO_H__ |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qhbox.h> | 25 | #include <qhbox.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qarray.h> | 27 | #include <qarray.h> |
28 | 28 | ||
29 | extern QString categoryFileName(); | 29 | extern QString categoryFileName(); |
30 | 30 | ||
31 | class QToolButton; | 31 | class QToolButton; |
32 | 32 | ||
33 | class CategoryComboPrivate; | 33 | class CategoryComboPrivate; |
34 | class CategoryCombo : public QComboBox | 34 | class CategoryCombo : public QComboBox |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | CategoryCombo( QWidget *parent, const char* name = 0 ); | 39 | CategoryCombo( QWidget *parent, const char* name = 0, int width=0); |
40 | |||
40 | ~CategoryCombo(); | 41 | ~CategoryCombo(); |
41 | 42 | ||
42 | int currentCategory() const; | 43 | int currentCategory() const; |
43 | void setCurrentCategory( int id ); | 44 | void setCurrentCategory( int id ); |
44 | // depreciated. | 45 | // depreciated. |
45 | void initCombo( const QArray<int> &recCats, const QString &appName ); | 46 | void initCombo( const QArray<int> &recCats, const QString &appName ); |
46 | void initCombo( const QArray<int> &recCats, const QString &appName, | 47 | void initCombo( const QArray<int> &recCats, const QString &appName, |
47 | const QString &visibleName /* = appName */ ); | 48 | const QString &visibleName /* = appName */ ); |
48 | 49 | ||
50 | QArray<int> initComboWithRefind( const QArray<int> &recCats, const QString &appName ); | ||
51 | |||
49 | signals: | 52 | signals: |
50 | void sigCatChanged( int newUid ); | 53 | void sigCatChanged( int newUid ); |
51 | 54 | ||
52 | private slots: | 55 | private slots: |
53 | void slotValueChanged( int ); | 56 | void slotValueChanged( int ); |
54 | 57 | ||
55 | private: | 58 | private: |
56 | void setCurrentText( const QString &str ); | 59 | void setCurrentText( const QString &str ); |
57 | CategoryComboPrivate *d; | 60 | CategoryComboPrivate *d; |
58 | }; | 61 | }; |
59 | 62 | ||
60 | #endif | 63 | #endif |
61 | 64 | ||
62 | class CategorySelectPrivate; | 65 | class CategorySelectPrivate; |
63 | class CategorySelect : public QHBox | 66 | class CategorySelect : public QHBox |
64 | { | 67 | { |
65 | Q_OBJECT | 68 | Q_OBJECT |
66 | public: | 69 | public: |
67 | // we need two constructors, the first gets around designer limitations | 70 | // we need two constructors, the first gets around designer limitations |
68 | CategorySelect( QWidget *parent = 0, const char *name = 0 ); | 71 | |
72 | CategorySelect( QWidget *parent = 0, const char *name = 0, int width = 0 ); | ||
69 | 73 | ||
70 | CategorySelect( const QArray<int> &vlCats, const QString &appName, | 74 | CategorySelect( const QArray<int> &vlCats, const QString &appName, |
71 | QWidget *parent = 0, const char *name = 0 ); | 75 | QWidget *parent = 0, const char *name = 0, |
76 | int width = 0); | ||
72 | CategorySelect( const QArray<int> &vlCats, const QString &appName, | 77 | CategorySelect( const QArray<int> &vlCats, const QString &appName, |
73 | const QString &visibleName, QWidget *parent = 0, | 78 | const QString &visibleName, QWidget *parent = 0, |
74 | const char *name = 0 ); | 79 | const char *name = 0 , int width = 0); |
80 | |||
75 | ~CategorySelect(); | 81 | ~CategorySelect(); |
76 | 82 | ||
77 | const QArray<int> ¤tCategories() const; | 83 | const QArray<int> ¤tCategories() const; |
78 | int currentCategory() const; | 84 | int currentCategory() const; |
79 | void setCurrentCategory( int newCatUid ); | 85 | void setCurrentCategory( int newCatUid ); |
80 | // pretty much if you don't set it the constructor, you need to | 86 | // pretty much if you don't set it the constructor, you need to |
81 | // call it here ASAP! | 87 | // call it here ASAP! |
82 | // however this call is depreciated... | 88 | // however this call is depreciated... |
83 | void setCategories( const QArray<int> &vlCats, const QString &appName ); | ||
84 | // use this one instead (for translating ) | ||
85 | void setCategories( const QArray<int> &vlCats, const QString &appName, | ||
86 | const QString &visibleName ); | ||
87 | 89 | ||
90 | QString setCategories( const QArray<int> &vlCats, const QString &appName ); | ||
91 | QString setCategories( const QArray<int> &vlCats, const QString &appName, | ||
92 | const QString &visibleName ); | ||
88 | // these were added for find dialog. | 93 | // these were added for find dialog. |
89 | void setRemoveCategoryEdit( bool remove ); | 94 | void setRemoveCategoryEdit( bool remove ); |
90 | void setAllCategories( bool add ); | 95 | void setAllCategories( bool add ); |
91 | 96 | ||
97 | void setFixedWidth(int width); | ||
92 | signals: | 98 | signals: |
93 | void signalSelected( int ); | 99 | void signalSelected( int ); |
94 | 100 | ||
95 | private slots: | 101 | private slots: |
96 | void slotDialog(); | 102 | void slotDialog(); |
103 | |||
104 | public slots: | ||
97 | void slotNewCat( int id ); | 105 | void slotNewCat( int id ); |
98 | 106 | ||
99 | private: | 107 | private: |
100 | void init(); | 108 | void init(int width=0); |
101 | QString mStrAppName; | 109 | QString mStrAppName; |
102 | CategoryCombo *cmbCat; | 110 | CategoryCombo *cmbCat; |
103 | QToolButton *cmdCat; | 111 | QToolButton *cmdCat; |
104 | CategorySelectPrivate *d; | 112 | CategorySelectPrivate *d; |
105 | }; | 113 | }; |
diff --git a/library/config.cpp b/library/config.cpp index 9634571..e07eecb 100644 --- a/library/config.cpp +++ b/library/config.cpp | |||
@@ -1,557 +1,554 @@ | |||
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 <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 25 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
26 | #include <qtextcodec.h> | 26 | #include <qtextcodec.h> |
27 | #endif | 27 | #endif |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | 29 | ||
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | 35 | ||
36 | #define QTOPIA_INTERNAL_LANGLIST | ||
36 | #include "config.h" | 37 | #include "config.h" |
38 | #include "global.h" | ||
37 | 39 | ||
38 | 40 | ||
39 | /*! | 41 | /*! |
40 | \internal | 42 | \internal |
41 | */ | 43 | */ |
42 | QString Config::configFilename(const QString& name, Domain d) | 44 | QString Config::configFilename(const QString& name, Domain d) |
43 | { | 45 | { |
44 | switch (d) { | 46 | switch (d) { |
45 | case File: | 47 | case File: |
46 | return name; | 48 | return name; |
47 | case User: { | 49 | case User: { |
48 | QDir dir = (QString(getenv("HOME")) + "/Settings"); | 50 | QDir dir = (QString(getenv("HOME")) + "/Settings"); |
49 | if ( !dir.exists() ) | 51 | if ( !dir.exists() ) |
50 | mkdir(dir.path().local8Bit(),0700); | 52 | mkdir(dir.path().local8Bit(),0700); |
51 | return dir.path() + "/" + name + ".conf"; | 53 | return dir.path() + "/" + name + ".conf"; |
52 | } | 54 | } |
53 | } | 55 | } |
54 | return name; | 56 | return name; |
55 | } | 57 | } |
56 | 58 | ||
57 | /*! | 59 | /*! |
58 | \class Config config.h | 60 | \class Config config.h |
59 | \brief The Config class provides for saving application cofniguration state. | 61 | \brief The Config class provides for saving application cofniguration state. |
60 | 62 | ||
61 | You should keep a Config in existence only while you do not want others | 63 | You should keep a Config in existence only while you do not want others |
62 | to be able to change the state. There is no locking currently, but there | 64 | to be able to change the state. There is no locking currently, but there |
63 | may be in the future. | 65 | may be in the future. |
64 | */ | 66 | */ |
65 | 67 | ||
66 | /*! | 68 | /*! |
67 | \enum Config::ConfigGroup | 69 | \enum Config::ConfigGroup |
68 | \internal | 70 | \internal |
69 | */ | 71 | */ |
70 | 72 | ||
71 | /*! | 73 | /*! |
72 | \enum Config::Domain | 74 | \enum Config::Domain |
73 | 75 | ||
74 | \value File | 76 | \value File |
75 | \value User | 77 | \value User |
76 | 78 | ||
77 | See Config for details. | 79 | See Config for details. |
78 | */ | 80 | */ |
79 | 81 | ||
80 | /*! | 82 | /*! |
81 | Constructs a config that will load or create a configuration with the | 83 | Constructs a config that will load or create a configuration with the |
82 | given \a name in the given \a domain. | 84 | given \a name in the given \a domain. |
83 | 85 | ||
84 | You must call setGroup() before doing much else with the Config. | 86 | You must call setGroup() before doing much else with the Config. |
85 | 87 | ||
86 | In the default Domain, \e User, | 88 | In the default Domain, \e User, |
87 | the configuration is user-specific. \a name should not contain "/" in | 89 | the configuration is user-specific. \a name should not contain "/" in |
88 | this case, and in general should be the name of the C++ class that is | 90 | this case, and in general should be the name of the C++ class that is |
89 | primarily responsible for maintaining the configuration. | 91 | primarily responsible for maintaining the configuration. |
90 | 92 | ||
91 | In the File Domain, \a name is an absolute filename. | 93 | In the File Domain, \a name is an absolute filename. |
92 | */ | 94 | */ |
93 | Config::Config( const QString &name, Domain domain ) | 95 | Config::Config( const QString &name, Domain domain ) |
94 | : filename( configFilename(name,domain) ) | 96 | : filename( configFilename(name,domain) ) |
95 | { | 97 | { |
96 | git = groups.end(); | 98 | git = groups.end(); |
97 | read(); | 99 | read(); |
98 | 100 | QStringList l = Global::languageList(); | |
99 | lang = getenv("LANG"); | 101 | lang = l[0]; |
100 | int i = lang.find("."); | 102 | glang = l[1]; |
101 | if ( i > 0 ) | ||
102 | lang = lang.left( i ); | ||
103 | i = lang.find( "_" ); | ||
104 | if ( i > 0 ) | ||
105 | glang = lang.left(i); | ||
106 | } | 103 | } |
107 | 104 | ||
108 | /*! | 105 | /*! |
109 | Writes any changes to disk and destroys the in-memory object. | 106 | Writes any changes to disk and destroys the in-memory object. |
110 | */ | 107 | */ |
111 | Config::~Config() | 108 | Config::~Config() |
112 | { | 109 | { |
113 | if ( changed ) | 110 | if ( changed ) |
114 | write(); | 111 | write(); |
115 | } | 112 | } |
116 | 113 | ||
117 | /*! | 114 | /*! |
118 | Returns whether the current group has an entry called \a key. | 115 | Returns whether the current group has an entry called \a key. |
119 | */ | 116 | */ |
120 | bool Config::hasKey( const QString &key ) const | 117 | bool Config::hasKey( const QString &key ) const |
121 | { | 118 | { |
122 | if ( groups.end() == git ) | 119 | if ( groups.end() == git ) |
123 | return FALSE; | 120 | return FALSE; |
124 | ConfigGroup::ConstIterator it = ( *git ).find( key ); | 121 | ConfigGroup::ConstIterator it = ( *git ).find( key ); |
125 | return it != ( *git ).end(); | 122 | return it != ( *git ).end(); |
126 | } | 123 | } |
127 | 124 | ||
128 | /*! | 125 | /*! |
129 | Sets the current group for subsequent reading and writing of | 126 | Sets the current group for subsequent reading and writing of |
130 | entries to \a gname. Grouping allows the application to partition the namespace. | 127 | entries to \a gname. Grouping allows the application to partition the namespace. |
131 | 128 | ||
132 | This function must be called prior to any reading or writing | 129 | This function must be called prior to any reading or writing |
133 | of entries. | 130 | of entries. |
134 | 131 | ||
135 | The \a gname must not be empty. | 132 | The \a gname must not be empty. |
136 | */ | 133 | */ |
137 | void Config::setGroup( const QString &gname ) | 134 | void Config::setGroup( const QString &gname ) |
138 | { | 135 | { |
139 | QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); | 136 | QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); |
140 | if ( it == groups.end() ) { | 137 | if ( it == groups.end() ) { |
141 | git = groups.insert( gname, ConfigGroup() ); | 138 | git = groups.insert( gname, ConfigGroup() ); |
142 | changed = TRUE; | 139 | changed = TRUE; |
143 | return; | 140 | return; |
144 | } | 141 | } |
145 | git = it; | 142 | git = it; |
146 | } | 143 | } |
147 | 144 | ||
148 | /*! | 145 | /*! |
149 | Writes a (\a key, \a value) entry to the current group. | 146 | Writes a (\a key, \a value) entry to the current group. |
150 | 147 | ||
151 | \sa readEntry() | 148 | \sa readEntry() |
152 | */ | 149 | */ |
153 | void Config::writeEntry( const QString &key, const char* value ) | 150 | void Config::writeEntry( const QString &key, const char* value ) |
154 | { | 151 | { |
155 | writeEntry(key,QString(value)); | 152 | writeEntry(key,QString(value)); |
156 | } | 153 | } |
157 | 154 | ||
158 | /*! | 155 | /*! |
159 | Writes a (\a key, \a value) entry to the current group. | 156 | Writes a (\a key, \a value) entry to the current group. |
160 | 157 | ||
161 | \sa readEntry() | 158 | \sa readEntry() |
162 | */ | 159 | */ |
163 | void Config::writeEntry( const QString &key, const QString &value ) | 160 | void Config::writeEntry( const QString &key, const QString &value ) |
164 | { | 161 | { |
165 | if ( git == groups.end() ) { | 162 | if ( git == groups.end() ) { |
166 | qWarning( "no group set" ); | 163 | qWarning( "no group set" ); |
167 | return; | 164 | return; |
168 | } | 165 | } |
169 | if ( (*git)[key] != value ) { | 166 | if ( (*git)[key] != value ) { |
170 | ( *git ).insert( key, value ); | 167 | ( *git ).insert( key, value ); |
171 | changed = TRUE; | 168 | changed = TRUE; |
172 | } | 169 | } |
173 | } | 170 | } |
174 | 171 | ||
175 | /* | 172 | /* |
176 | Note that the degree of protection offered by the encryption here is | 173 | Note that the degree of protection offered by the encryption here is |
177 | only sufficient to avoid the most casual observation of the configuration | 174 | only sufficient to avoid the most casual observation of the configuration |
178 | files. People with access to the files can write down the contents and | 175 | files. People with access to the files can write down the contents and |
179 | decrypt it using this source code. | 176 | decrypt it using this source code. |
180 | 177 | ||
181 | Conceivably, and at some burden to the user, this encryption could | 178 | Conceivably, and at some burden to the user, this encryption could |
182 | be improved. | 179 | be improved. |
183 | */ | 180 | */ |
184 | static QString encipher(const QString& plain) | 181 | static QString encipher(const QString& plain) |
185 | { | 182 | { |
186 | // mainly, we make it long | 183 | // mainly, we make it long |
187 | QString cipher; | 184 | QString cipher; |
188 | int mix=28730492; | 185 | int mix=28730492; |
189 | for (int i=0; i<(int)plain.length(); i++) { | 186 | for (int i=0; i<(int)plain.length(); i++) { |
190 | int u = plain[i].unicode(); | 187 | int u = plain[i].unicode(); |
191 | int c = u ^ mix; | 188 | int c = u ^ mix; |
192 | QString x = QString::number(c,36); | 189 | QString x = QString::number(c,36); |
193 | cipher.append(QChar('a'+x.length())); | 190 | cipher.append(QChar('a'+x.length())); |
194 | cipher.append(x); | 191 | cipher.append(x); |
195 | mix *= u; | 192 | mix *= u; |
196 | } | 193 | } |
197 | return cipher; | 194 | return cipher; |
198 | } | 195 | } |
199 | 196 | ||
200 | static QString decipher(const QString& cipher) | 197 | static QString decipher(const QString& cipher) |
201 | { | 198 | { |
202 | QString plain; | 199 | QString plain; |
203 | int mix=28730492; | 200 | int mix=28730492; |
204 | for (int i=0; i<(int)cipher.length();) { | 201 | for (int i=0; i<(int)cipher.length();) { |
205 | int l = cipher[i].unicode()-'a'; | 202 | int l = cipher[i].unicode()-'a'; |
206 | QString x = cipher.mid(i+1,l); i+=l+1; | 203 | QString x = cipher.mid(i+1,l); i+=l+1; |
207 | int u = x.toInt(0,36) ^ mix; | 204 | int u = x.toInt(0,36) ^ mix; |
208 | plain.append(QChar(u)); | 205 | plain.append(QChar(u)); |
209 | mix *= u; | 206 | mix *= u; |
210 | } | 207 | } |
211 | return plain; | 208 | return plain; |
212 | } | 209 | } |
213 | 210 | ||
214 | /*! | 211 | /*! |
215 | Writes an encrypted (\a key, \a value) entry to the current group. | 212 | Writes an encrypted (\a key, \a value) entry to the current group. |
216 | 213 | ||
217 | Note that the degree of protection offered by the encryption is | 214 | Note that the degree of protection offered by the encryption is |
218 | only sufficient to avoid the most casual observation of the configuration | 215 | only sufficient to avoid the most casual observation of the configuration |
219 | files. | 216 | files. |
220 | 217 | ||
221 | \sa readEntry() | 218 | \sa readEntry() |
222 | */ | 219 | */ |
223 | void Config::writeEntryCrypt( const QString &key, const QString &value ) | 220 | void Config::writeEntryCrypt( const QString &key, const QString &value ) |
224 | { | 221 | { |
225 | if ( git == groups.end() ) { | 222 | if ( git == groups.end() ) { |
226 | qWarning( "no group set" ); | 223 | qWarning( "no group set" ); |
227 | return; | 224 | return; |
228 | } | 225 | } |
229 | QString evalue = encipher(value); | 226 | QString evalue = encipher(value); |
230 | if ( (*git)[key] != evalue ) { | 227 | if ( (*git)[key] != evalue ) { |
231 | ( *git ).insert( key, evalue ); | 228 | ( *git ).insert( key, evalue ); |
232 | changed = TRUE; | 229 | changed = TRUE; |
233 | } | 230 | } |
234 | } | 231 | } |
235 | 232 | ||
236 | /*! | 233 | /*! |
237 | Writes a (\a key, \a num) entry to the current group. | 234 | Writes a (\a key, \a num) entry to the current group. |
238 | 235 | ||
239 | \sa readNumEntry() | 236 | \sa readNumEntry() |
240 | */ | 237 | */ |
241 | void Config::writeEntry( const QString &key, int num ) | 238 | void Config::writeEntry( const QString &key, int num ) |
242 | { | 239 | { |
243 | QString s; | 240 | QString s; |
244 | s.setNum( num ); | 241 | s.setNum( num ); |
245 | writeEntry( key, s ); | 242 | writeEntry( key, s ); |
246 | } | 243 | } |
247 | 244 | ||
248 | #ifdef Q_HAS_BOOL_TYPE | 245 | #ifdef Q_HAS_BOOL_TYPE |
249 | /*! | 246 | /*! |
250 | Writes a (\a key, \a b) entry to the current group. This is equivalent | 247 | Writes a (\a key, \a b) entry to the current group. This is equivalent |
251 | to writing a 0 or 1 as an integer entry. | 248 | to writing a 0 or 1 as an integer entry. |
252 | 249 | ||
253 | \sa readBoolEntry() | 250 | \sa readBoolEntry() |
254 | */ | 251 | */ |
255 | void Config::writeEntry( const QString &key, bool b ) | 252 | void Config::writeEntry( const QString &key, bool b ) |
256 | { | 253 | { |
257 | QString s; | 254 | QString s; |
258 | s.setNum( ( int )b ); | 255 | s.setNum( ( int )b ); |
259 | writeEntry( key, s ); | 256 | writeEntry( key, s ); |
260 | } | 257 | } |
261 | #endif | 258 | #endif |
262 | 259 | ||
263 | /*! | 260 | /*! |
264 | Writes a (\a key, \a lst) entry to the current group. The list | 261 | Writes a (\a key, \a lst) entry to the current group. The list |
265 | is separated by \a sep, so the strings must not contain that character. | 262 | is separated by \a sep, so the strings must not contain that character. |
266 | 263 | ||
267 | \sa readListEntry() | 264 | \sa readListEntry() |
268 | */ | 265 | */ |
269 | void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) | 266 | void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) |
270 | { | 267 | { |
271 | QString s; | 268 | QString s; |
272 | QStringList::ConstIterator it = lst.begin(); | 269 | QStringList::ConstIterator it = lst.begin(); |
273 | for ( ; it != lst.end(); ++it ) | 270 | for ( ; it != lst.end(); ++it ) |
274 | s += *it + sep; | 271 | s += *it + sep; |
275 | writeEntry( key, s ); | 272 | writeEntry( key, s ); |
276 | } | 273 | } |
277 | 274 | ||
278 | /*! | 275 | /*! |
279 | Removes the \a key entry from the current group. Does nothing if | 276 | Removes the \a key entry from the current group. Does nothing if |
280 | there is no such entry. | 277 | there is no such entry. |
281 | */ | 278 | */ |
282 | 279 | ||
283 | void Config::removeEntry( const QString &key ) | 280 | void Config::removeEntry( const QString &key ) |
284 | { | 281 | { |
285 | if ( git == groups.end() ) { | 282 | if ( git == groups.end() ) { |
286 | qWarning( "no group set" ); | 283 | qWarning( "no group set" ); |
287 | return; | 284 | return; |
288 | } | 285 | } |
289 | ( *git ).remove( key ); | 286 | ( *git ).remove( key ); |
290 | changed = TRUE; | 287 | changed = TRUE; |
291 | } | 288 | } |
292 | 289 | ||
293 | /*! | 290 | /*! |
294 | \fn bool Config::operator == ( const Config & other ) const | 291 | \fn bool Config::operator == ( const Config & other ) const |
295 | 292 | ||
296 | Tests for equality with \a other. Config objects are equal if they refer to the same filename. | 293 | Tests for equality with \a other. Config objects are equal if they refer to the same filename. |
297 | */ | 294 | */ |
298 | 295 | ||
299 | /*! | 296 | /*! |
300 | \fn bool Config::operator != ( const Config & other ) const | 297 | \fn bool Config::operator != ( const Config & other ) const |
301 | 298 | ||
302 | Tests for inequality with \a other. Config objects are equal if they refer to the same filename. | 299 | Tests for inequality with \a other. Config objects are equal if they refer to the same filename. |
303 | */ | 300 | */ |
304 | 301 | ||
305 | /*! | 302 | /*! |
306 | \fn QString Config::readEntry( const QString &key, const QString &deflt ) const | 303 | \fn QString Config::readEntry( const QString &key, const QString &deflt ) const |
307 | 304 | ||
308 | Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. | 305 | Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. |
309 | */ | 306 | */ |
310 | 307 | ||
311 | /*! | 308 | /*! |
312 | \internal | 309 | \internal |
313 | For compatibility, non-const version. | 310 | For compatibility, non-const version. |
314 | */ | 311 | */ |
315 | QString Config::readEntry( const QString &key, const QString &deflt ) | 312 | QString Config::readEntry( const QString &key, const QString &deflt ) |
316 | { | 313 | { |
317 | QString res = readEntryDirect( key+"["+lang+"]" ); | 314 | QString res = readEntryDirect( key+"["+lang+"]" ); |
318 | if ( !res.isNull() ) | 315 | if ( !res.isNull() ) |
319 | return res; | 316 | return res; |
320 | if ( !glang.isEmpty() ) { | 317 | if ( !glang.isEmpty() ) { |
321 | res = readEntryDirect( key+"["+glang+"]" ); | 318 | res = readEntryDirect( key+"["+glang+"]" ); |
322 | if ( !res.isNull() ) | 319 | if ( !res.isNull() ) |
323 | return res; | 320 | return res; |
324 | } | 321 | } |
325 | return readEntryDirect( key, deflt ); | 322 | return readEntryDirect( key, deflt ); |
326 | } | 323 | } |
327 | 324 | ||
328 | /*! | 325 | /*! |
329 | \fn QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const | 326 | \fn QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const |
330 | 327 | ||
331 | Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry. | 328 | Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry. |
332 | */ | 329 | */ |
333 | 330 | ||
334 | /*! | 331 | /*! |
335 | \internal | 332 | \internal |
336 | For compatibility, non-const version. | 333 | For compatibility, non-const version. |
337 | */ | 334 | */ |
338 | QString Config::readEntryCrypt( const QString &key, const QString &deflt ) | 335 | QString Config::readEntryCrypt( const QString &key, const QString &deflt ) |
339 | { | 336 | { |
340 | QString res = readEntryDirect( key+"["+lang+"]" ); | 337 | QString res = readEntryDirect( key+"["+lang+"]" ); |
341 | if ( res.isNull() && glang.isEmpty() ) | 338 | if ( res.isNull() && glang.isEmpty() ) |
342 | res = readEntryDirect( key+"["+glang+"]" ); | 339 | res = readEntryDirect( key+"["+glang+"]" ); |
343 | if ( res.isNull() ) | 340 | if ( res.isNull() ) |
344 | res = readEntryDirect( key, QString::null ); | 341 | res = readEntryDirect( key, QString::null ); |
345 | if ( res.isNull() ) | 342 | if ( res.isNull() ) |
346 | return deflt; | 343 | return deflt; |
347 | return decipher(res); | 344 | return decipher(res); |
348 | } | 345 | } |
349 | 346 | ||
350 | /*! | 347 | /*! |
351 | \fn QString Config::readEntryDirect( const QString &key, const QString &deflt ) const | 348 | \fn QString Config::readEntryDirect( const QString &key, const QString &deflt ) const |
352 | \internal | 349 | \internal |
353 | */ | 350 | */ |
354 | 351 | ||
355 | /*! | 352 | /*! |
356 | \internal | 353 | \internal |
357 | For compatibility, non-const version. | 354 | For compatibility, non-const version. |
358 | */ | 355 | */ |
359 | QString Config::readEntryDirect( const QString &key, const QString &deflt ) | 356 | QString Config::readEntryDirect( const QString &key, const QString &deflt ) |
360 | { | 357 | { |
361 | if ( git == groups.end() ) { | 358 | if ( git == groups.end() ) { |
362 | //qWarning( "no group set" ); | 359 | //qWarning( "no group set" ); |
363 | return deflt; | 360 | return deflt; |
364 | } | 361 | } |
365 | ConfigGroup::ConstIterator it = ( *git ).find( key ); | 362 | ConfigGroup::ConstIterator it = ( *git ).find( key ); |
366 | if ( it != ( *git ).end() ) | 363 | if ( it != ( *git ).end() ) |
367 | return *it; | 364 | return *it; |
368 | else | 365 | else |
369 | return deflt; | 366 | return deflt; |
370 | } | 367 | } |
371 | 368 | ||
372 | /*! | 369 | /*! |
373 | \fn int Config::readNumEntry( const QString &key, int deflt ) const | 370 | \fn int Config::readNumEntry( const QString &key, int deflt ) const |
374 | Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. | 371 | Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. |
375 | */ | 372 | */ |
376 | 373 | ||
377 | /*! | 374 | /*! |
378 | \internal | 375 | \internal |
379 | For compatibility, non-const version. | 376 | For compatibility, non-const version. |
380 | */ | 377 | */ |
381 | int Config::readNumEntry( const QString &key, int deflt ) | 378 | int Config::readNumEntry( const QString &key, int deflt ) |
382 | { | 379 | { |
383 | QString s = readEntry( key ); | 380 | QString s = readEntry( key ); |
384 | if ( s.isEmpty() ) | 381 | if ( s.isEmpty() ) |
385 | return deflt; | 382 | return deflt; |
386 | else | 383 | else |
387 | return s.toInt(); | 384 | return s.toInt(); |
388 | } | 385 | } |
389 | 386 | ||
390 | /*! | 387 | /*! |
391 | \fn bool Config::readBoolEntry( const QString &key, bool deflt ) const | 388 | \fn bool Config::readBoolEntry( const QString &key, bool deflt ) const |
392 | Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. | 389 | Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. |
393 | */ | 390 | */ |
394 | 391 | ||
395 | /*! | 392 | /*! |
396 | \internal | 393 | \internal |
397 | For compatibility, non-const version. | 394 | For compatibility, non-const version. |
398 | */ | 395 | */ |
399 | bool Config::readBoolEntry( const QString &key, bool deflt ) | 396 | bool Config::readBoolEntry( const QString &key, bool deflt ) |
400 | { | 397 | { |
401 | QString s = readEntry( key ); | 398 | QString s = readEntry( key ); |
402 | if ( s.isEmpty() ) | 399 | if ( s.isEmpty() ) |
403 | return deflt; | 400 | return deflt; |
404 | else | 401 | else |
405 | return (bool)s.toInt(); | 402 | return (bool)s.toInt(); |
406 | } | 403 | } |
407 | 404 | ||
408 | /*! | 405 | /*! |
409 | \fn QStringList Config::readListEntry( const QString &key, const QChar &sep ) const | 406 | \fn QStringList Config::readListEntry( const QString &key, const QChar &sep ) const |
410 | Reads a string list entry stored with \a key, and with \a sep as the separator. | 407 | Reads a string list entry stored with \a key, and with \a sep as the separator. |
411 | */ | 408 | */ |
412 | 409 | ||
413 | /*! | 410 | /*! |
414 | \internal | 411 | \internal |
415 | For compatibility, non-const version. | 412 | For compatibility, non-const version. |
416 | */ | 413 | */ |
417 | QStringList Config::readListEntry( const QString &key, const QChar &sep ) | 414 | QStringList Config::readListEntry( const QString &key, const QChar &sep ) |
418 | { | 415 | { |
419 | QString s = readEntry( key ); | 416 | QString s = readEntry( key ); |
420 | if ( s.isEmpty() ) | 417 | if ( s.isEmpty() ) |
421 | return QStringList(); | 418 | return QStringList(); |
422 | else | 419 | else |
423 | return QStringList::split( sep, s ); | 420 | return QStringList::split( sep, s ); |
424 | } | 421 | } |
425 | 422 | ||
426 | /*! | 423 | /*! |
427 | Removes all entries from the current group. | 424 | Removes all entries from the current group. |
428 | */ | 425 | */ |
429 | void Config::clearGroup() | 426 | void Config::clearGroup() |
430 | { | 427 | { |
431 | if ( git == groups.end() ) { | 428 | if ( git == groups.end() ) { |
432 | qWarning( "no group set" ); | 429 | qWarning( "no group set" ); |
433 | return; | 430 | return; |
434 | } | 431 | } |
435 | if ( !(*git).isEmpty() ) { | 432 | if ( !(*git).isEmpty() ) { |
436 | ( *git ).clear(); | 433 | ( *git ).clear(); |
437 | changed = TRUE; | 434 | changed = TRUE; |
438 | } | 435 | } |
439 | } | 436 | } |
440 | 437 | ||
441 | /*! | 438 | /*! |
442 | \internal | 439 | \internal |
443 | */ | 440 | */ |
444 | void Config::write( const QString &fn ) | 441 | void Config::write( const QString &fn ) |
445 | { | 442 | { |
446 | QString strNewFile; | 443 | QString strNewFile; |
447 | if ( !fn.isEmpty() ) | 444 | if ( !fn.isEmpty() ) |
448 | filename = fn; | 445 | filename = fn; |
449 | strNewFile = filename + ".new"; | 446 | strNewFile = filename + ".new"; |
450 | 447 | ||
451 | QFile f( strNewFile ); | 448 | QFile f( strNewFile ); |
452 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { | 449 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { |
453 | qWarning( "could not open for writing `%s'", strNewFile.latin1() ); | 450 | qWarning( "could not open for writing `%s'", strNewFile.latin1() ); |
454 | git = groups.end(); | 451 | git = groups.end(); |
455 | return; | 452 | return; |
456 | } | 453 | } |
457 | 454 | ||
458 | QString str; | 455 | QString str; |
459 | QCString cstr; | 456 | QCString cstr; |
460 | QMap< QString, ConfigGroup >::Iterator g_it = groups.begin(); | 457 | QMap< QString, ConfigGroup >::Iterator g_it = groups.begin(); |
461 | 458 | ||
462 | for ( ; g_it != groups.end(); ++g_it ) { | 459 | for ( ; g_it != groups.end(); ++g_it ) { |
463 | str += "[" + g_it.key() + "]\n"; | 460 | str += "[" + g_it.key() + "]\n"; |
464 | ConfigGroup::Iterator e_it = ( *g_it ).begin(); | 461 | ConfigGroup::Iterator e_it = ( *g_it ).begin(); |
465 | for ( ; e_it != ( *g_it ).end(); ++e_it ) | 462 | for ( ; e_it != ( *g_it ).end(); ++e_it ) |
466 | str += e_it.key() + " = " + *e_it + "\n"; | 463 | str += e_it.key() + " = " + *e_it + "\n"; |
467 | } | 464 | } |
468 | cstr = str.utf8(); | 465 | cstr = str.utf8(); |
469 | 466 | ||
470 | int total_length; | 467 | int total_length; |
471 | total_length = f.writeBlock( cstr.data(), cstr.length() ); | 468 | total_length = f.writeBlock( cstr.data(), cstr.length() ); |
472 | if ( total_length != int(cstr.length()) ) { | 469 | if ( total_length != int(cstr.length()) ) { |
473 | QMessageBox::critical( 0, QObject::tr("Out of Space"), | 470 | QMessageBox::critical( 0, QObject::tr("Out of Space"), |
474 | QObject::tr("There was a problem creating\nConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); | 471 | QObject::tr("There was a problem creating\nConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); |
475 | f.close(); | 472 | f.close(); |
476 | QFile::remove( strNewFile ); | 473 | QFile::remove( strNewFile ); |
477 | return; | 474 | return; |
478 | } | 475 | } |
479 | 476 | ||
480 | f.close(); | 477 | f.close(); |
481 | // now rename the file... | 478 | // now rename the file... |
482 | if ( rename( strNewFile, filename ) < 0 ) { | 479 | if ( rename( strNewFile, filename ) < 0 ) { |
483 | qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), | 480 | qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), |
484 | filename.latin1() ); | 481 | filename.latin1() ); |
485 | QFile::remove( strNewFile ); | 482 | QFile::remove( strNewFile ); |
486 | } | 483 | } |
487 | } | 484 | } |
488 | 485 | ||
489 | /*! | 486 | /*! |
490 | Returns whether the Config is in a valid state. | 487 | Returns whether the Config is in a valid state. |
491 | */ | 488 | */ |
492 | bool Config::isValid() const | 489 | bool Config::isValid() const |
493 | { | 490 | { |
494 | return groups.end() != git; | 491 | return groups.end() != git; |
495 | } | 492 | } |
496 | 493 | ||
497 | /*! | 494 | /*! |
498 | \internal | 495 | \internal |
499 | */ | 496 | */ |
500 | void Config::read() | 497 | void Config::read() |
501 | { | 498 | { |
502 | changed = FALSE; | 499 | changed = FALSE; |
503 | 500 | ||
504 | if ( !QFileInfo( filename ).exists() ) { | 501 | if ( !QFileInfo( filename ).exists() ) { |
505 | git = groups.end(); | 502 | git = groups.end(); |
506 | return; | 503 | return; |
507 | } | 504 | } |
508 | 505 | ||
509 | QFile f( filename ); | 506 | QFile f( filename ); |
510 | if ( !f.open( IO_ReadOnly ) ) { | 507 | if ( !f.open( IO_ReadOnly ) ) { |
511 | git = groups.end(); | 508 | git = groups.end(); |
512 | return; | 509 | return; |
513 | } | 510 | } |
514 | 511 | ||
515 | QTextStream s( &f ); | 512 | QTextStream s( &f ); |
516 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 513 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
517 | // The below should work, but doesn't in Qt 2.3.0 | 514 | // The below should work, but doesn't in Qt 2.3.0 |
518 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | 515 | s.setCodec( QTextCodec::codecForMib( 106 ) ); |
519 | #else | 516 | #else |
520 | s.setEncoding( QTextStream::UnicodeUTF8 ); | 517 | s.setEncoding( QTextStream::UnicodeUTF8 ); |
521 | #endif | 518 | #endif |
522 | 519 | ||
523 | QStringList list = QStringList::split('\n', s.read() ); | 520 | QStringList list = QStringList::split('\n', s.read() ); |
524 | f.close(); | 521 | f.close(); |
525 | 522 | ||
526 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 523 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
527 | if ( !parse( *it ) ) { | 524 | if ( !parse( *it ) ) { |
528 | git = groups.end(); | 525 | git = groups.end(); |
529 | return; | 526 | return; |
530 | } | 527 | } |
531 | } | 528 | } |
532 | } | 529 | } |
533 | 530 | ||
534 | /*! | 531 | /*! |
535 | \internal | 532 | \internal |
536 | */ | 533 | */ |
537 | bool Config::parse( const QString &l ) | 534 | bool Config::parse( const QString &l ) |
538 | { | 535 | { |
539 | QString line = l.stripWhiteSpace(); | 536 | QString line = l.stripWhiteSpace(); |
540 | if ( line[ 0 ] == QChar( '[' ) ) { | 537 | if ( line[ 0 ] == QChar( '[' ) ) { |
541 | QString gname = line; | 538 | QString gname = line; |
542 | gname = gname.remove( 0, 1 ); | 539 | gname = gname.remove( 0, 1 ); |
543 | if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) | 540 | if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) |
544 | gname = gname.remove( gname.length() - 1, 1 ); | 541 | gname = gname.remove( gname.length() - 1, 1 ); |
545 | git = groups.insert( gname, ConfigGroup() ); | 542 | git = groups.insert( gname, ConfigGroup() ); |
546 | } else if ( !line.isEmpty() ) { | 543 | } else if ( !line.isEmpty() ) { |
547 | if ( git == groups.end() ) | 544 | if ( git == groups.end() ) |
548 | return FALSE; | 545 | return FALSE; |
549 | int eq = line.find( '=' ); | 546 | int eq = line.find( '=' ); |
550 | if ( eq == -1 ) | 547 | if ( eq == -1 ) |
551 | return FALSE; | 548 | return FALSE; |
552 | QString key = line.left(eq).stripWhiteSpace(); | 549 | QString key = line.left(eq).stripWhiteSpace(); |
553 | QString value = line.mid(eq+1).stripWhiteSpace(); | 550 | QString value = line.mid(eq+1).stripWhiteSpace(); |
554 | ( *git ).insert( key, value ); | 551 | ( *git ).insert( key, value ); |
555 | } | 552 | } |
556 | return TRUE; | 553 | return TRUE; |
557 | } | 554 | } |
diff --git a/library/custom-linux-sharp-g++.h b/library/custom-linux-sharp-g++.h deleted file mode 100644 index f65d474..0000000 --- a/library/custom-linux-sharp-g++.h +++ b/dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #define QPE_OWNAPM | ||
22 | #define QPE_HAVE_TOGGLELIGHT | ||
23 | #define QPE_NOCIBAUD | ||
24 | #define QPE_STARTMENU | ||
25 | #include <asm/sharp_apm.h> | ||
26 | #ifndef APM_IOC_BATTERY_BACK_CHK | ||
27 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) | ||
28 | #endif | ||
29 | #ifndef APM_IOC_BATTERY_MAIN_CHK | ||
30 | #define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) | ||
31 | #endif | ||
32 | |||
33 | #include <unistd.h> | ||
34 | #include <stdio.h> | ||
35 | #include <signal.h> | ||
36 | #include <fcntl.h> | ||
37 | #include <sys/ioctl.h> | ||
38 | |||
39 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | ||
40 | |||
41 | /* --- for SHARP_BUZZER device --- */ | ||
42 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
43 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | ||
44 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | ||
45 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | ||
46 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | ||
47 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | ||
48 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | ||
49 | |||
50 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | ||
51 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | ||
52 | #define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | ||
53 | #define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | ||
54 | #define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | ||
55 | #define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | ||
56 | #define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | ||
57 | #define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | ||
58 | #define SHARP_PDA_APPSTART 9 /* application start */ | ||
59 | #define SHARP_PDA_APPQUIT 10 /* application ends */ | ||
60 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | ||
61 | #define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | ||
62 | #define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | ||
63 | #define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | ||
64 | |||
65 | |||
66 | #define CUSTOM_BUZZER( sound ) \ | ||
67 | { \ | ||
68 | static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \ | ||
69 | ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \ | ||
70 | } | ||
71 | |||
72 | #define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM ) | ||
73 | |||
74 | #include <sys/ioctl.h> | ||
75 | #include <asm/sharp_char.h> | ||
76 | |||
77 | // a bit awkward, as this value is defined in emailclient.cpp aswell... | ||
78 | #define LED_MAIL 0 | ||
79 | #define SHARP_LED_MAIL 9 | ||
80 | |||
81 | #define CUSTOM_LEDS( led, status ) \ | ||
82 | { \ | ||
83 | if ( led == LED_MAIL ) \ | ||
84 | led = SHARP_LED_MAIL; \ | ||
85 | static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \ | ||
86 | sharp_led_status leds; \ | ||
87 | memset(&leds, 0, sizeof(leds)); \ | ||
88 | leds.which = led; \ | ||
89 | leds.status = status; \ | ||
90 | ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \ | ||
91 | } | ||
92 | |||
93 | #define QPE_HAVE_MEMALERTER | ||
94 | |||
95 | #define QPE_MEMALERTER_IMPL \ | ||
96 | static void sig_handler(int sig) \ | ||
97 | { \ | ||
98 | switch (sig) { \ | ||
99 | case SIGHUP: \ | ||
100 | memstate = VeryLow; \ | ||
101 | break; \ | ||
102 | case SIGUSR1: \ | ||
103 | memstate = Normal; \ | ||
104 | break; \ | ||
105 | case SIGUSR2: \ | ||
106 | memstate = Low; \ | ||
107 | break; \ | ||
108 | } \ | ||
109 | } \ | ||
110 | static void initMemalerter() \ | ||
111 | { \ | ||
112 | struct sigaction sa; \ | ||
113 | memset(&sa, '\0', sizeof sa); \ | ||
114 | sa.sa_handler = sig_handler; \ | ||
115 | sa.sa_flags = SA_RESTART; \ | ||
116 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ | ||
117 | return; \ | ||
118 | } \ | ||
119 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ | ||
120 | return; \ | ||
121 | } \ | ||
122 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ | ||
123 | return; \ | ||
124 | } \ | ||
125 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ | ||
126 | \ | ||
127 | if (!fo) \ | ||
128 | return; \ | ||
129 | fprintf(fo, "qpe\n"); \ | ||
130 | fclose(fo); \ | ||
131 | } | ||
132 | |||
133 | #define QPE_INITIAL_NUMLOCK_STATE \ | ||
134 | { \ | ||
135 | bool numLock = FALSE; \ | ||
136 | sharp_kbdctl_modifstat st; \ | ||
137 | int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ | ||
138 | if( dev >= 0 ) { \ | ||
139 | memset(&st, 0, sizeof(st)); \ | ||
140 | st.which = 3; \ | ||
141 | int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ | ||
142 | if( !ret ) \ | ||
143 | numLock = (bool)st.stat; \ | ||
144 | ::close(dev); \ | ||
145 | } \ | ||
146 | return numLock; \ | ||
147 | } | ||
diff --git a/library/datebookmonth.h b/library/datebookmonth.h index 6cd1ac5..a7647ae 100644 --- a/library/datebookmonth.h +++ b/library/datebookmonth.h | |||
@@ -1,210 +1,211 @@ | |||
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 | #ifndef DATEBOOKMONTH | 20 | #ifndef DATEBOOKMONTH |
21 | #define DATEBOOKMONTH | 21 | #define DATEBOOKMONTH |
22 | 22 | ||
23 | #include <qpe/event.h> | 23 | #include <qpe/event.h> |
24 | 24 | ||
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | #include <qtable.h> | 29 | #include <qtable.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | 34 | ||
35 | class QToolButton; | 35 | class QToolButton; |
36 | class QComboBox; | 36 | class QComboBox; |
37 | class QSpinBox; | 37 | class QSpinBox; |
38 | class Event; | 38 | class Event; |
39 | class DateBookDB; | 39 | class DateBookDB; |
40 | 40 | ||
41 | class DateBookMonthHeaderPrivate; | 41 | class DateBookMonthHeaderPrivate; |
42 | class DateBookMonthHeader : public QHBox | 42 | class DateBookMonthHeader : public QHBox |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 ); | 47 | DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 ); |
48 | ~DateBookMonthHeader(); | 48 | ~DateBookMonthHeader(); |
49 | void setDate( int year, int month ); | 49 | void setDate( int year, int month ); |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void dateChanged( int year, int month ); | 52 | void dateChanged( int year, int month ); |
53 | 53 | ||
54 | protected slots: | 54 | protected slots: |
55 | void keyPressEvent(QKeyEvent *e ) { | 55 | void keyPressEvent(QKeyEvent *e ) { |
56 | e->ignore(); | 56 | e->ignore(); |
57 | } | 57 | } |
58 | 58 | ||
59 | private slots: | 59 | private slots: |
60 | void updateDate(); | 60 | void updateDate(); |
61 | void firstMonth(); | 61 | void firstMonth(); |
62 | void lastMonth(); | 62 | void lastMonth(); |
63 | void monthBack(); | 63 | void monthBack(); |
64 | void monthForward(); | 64 | void monthForward(); |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QToolButton *begin, *back, *next, *end; | 67 | QToolButton *begin, *back, *next, *end; |
68 | QComboBox *month; | 68 | QComboBox *month; |
69 | QSpinBox *year; | 69 | QSpinBox *year; |
70 | DateBookMonthHeaderPrivate *d; | 70 | DateBookMonthHeaderPrivate *d; |
71 | int focus; | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | class DayItemMonthPrivate; | 74 | class DayItemMonthPrivate; |
74 | class DayItemMonth : public QTableItem | 75 | class DayItemMonth : public QTableItem |
75 | { | 76 | { |
76 | public: | 77 | public: |
77 | DayItemMonth( QTable *table, EditType et, const QString &t ); | 78 | DayItemMonth( QTable *table, EditType et, const QString &t ); |
78 | ~DayItemMonth(); | 79 | ~DayItemMonth(); |
79 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 80 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
80 | void setDay( int d ) { dy = d; } | 81 | void setDay( int d ) { dy = d; } |
81 | void setEvents( const QValueList<Event> &events ) { daysEvents = events; }; | 82 | void setEvents( const QValueList<Event> &events ) { daysEvents = events; }; |
82 | void setEvents( const QValueList<EffectiveEvent> &effEvents ); | 83 | void setEvents( const QValueList<EffectiveEvent> &effEvents ); |
83 | void clearEvents() { daysEvents.clear(); }; | 84 | void clearEvents() { daysEvents.clear(); }; |
84 | void clearEffEvents(); | 85 | void clearEffEvents(); |
85 | int day() const { return dy; } | 86 | int day() const { return dy; } |
86 | void setType( Calendar::Day::Type t ); | 87 | void setType( Calendar::Day::Type t ); |
87 | Calendar::Day::Type type() const { return typ; } | 88 | Calendar::Day::Type type() const { return typ; } |
88 | 89 | ||
89 | private: | 90 | private: |
90 | QBrush back; | 91 | QBrush back; |
91 | QColor forg; | 92 | QColor forg; |
92 | int dy; | 93 | int dy; |
93 | Calendar::Day::Type typ; | 94 | Calendar::Day::Type typ; |
94 | QValueList<Event> daysEvents; // not used anymore... | 95 | QValueList<Event> daysEvents; // not used anymore... |
95 | DayItemMonthPrivate *d; | 96 | DayItemMonthPrivate *d; |
96 | }; | 97 | }; |
97 | 98 | ||
98 | class DateBookMonthTablePrivate; | 99 | class DateBookMonthTablePrivate; |
99 | class DateBookMonthTable : public QTable | 100 | class DateBookMonthTable : public QTable |
100 | { | 101 | { |
101 | Q_OBJECT | 102 | Q_OBJECT |
102 | 103 | ||
103 | public: | 104 | public: |
104 | DateBookMonthTable( QWidget *parent = 0, const char *name = 0, | 105 | DateBookMonthTable( QWidget *parent = 0, const char *name = 0, |
105 | DateBookDB *newDb = 0 ); | 106 | DateBookDB *newDb = 0 ); |
106 | ~DateBookMonthTable(); | 107 | ~DateBookMonthTable(); |
107 | void setDate( int y, int m, int d ); | 108 | void setDate( int y, int m, int d ); |
108 | void redraw(); | 109 | void redraw(); |
109 | 110 | ||
110 | QSize minimumSizeHint() const { return sizeHint(); } | 111 | QSize minimumSizeHint() const { return sizeHint(); } |
111 | QSize minimumSize() const { return sizeHint(); } | 112 | QSize minimumSize() const { return sizeHint(); } |
112 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} | 113 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} |
113 | void setWeekStart( bool onMonday ); | 114 | void setWeekStart( bool onMonday ); |
114 | signals: | 115 | signals: |
115 | void dateClicked( int year, int month, int day ); | 116 | void dateClicked( int year, int month, int day ); |
116 | 117 | ||
117 | protected: | 118 | protected: |
118 | void viewportMouseReleaseEvent( QMouseEvent * ); | 119 | void viewportMouseReleaseEvent( QMouseEvent * ); |
119 | 120 | ||
120 | protected slots: | 121 | protected slots: |
121 | 122 | ||
122 | void keyPressEvent(QKeyEvent *e ) { | 123 | void keyPressEvent(QKeyEvent *e ) { |
123 | e->ignore(); | 124 | e->ignore(); |
124 | } | 125 | } |
125 | 126 | ||
126 | private slots: | 127 | private slots: |
127 | void dayClicked( int row, int col ); | 128 | void dayClicked( int row, int col ); |
128 | void dragDay( int row, int col ); | 129 | void dragDay( int row, int col ); |
129 | 130 | ||
130 | private: | 131 | private: |
131 | void setupTable(); | 132 | void setupTable(); |
132 | void setupLabels(); | 133 | void setupLabels(); |
133 | 134 | ||
134 | void findDay( int day, int &row, int &col ); | 135 | void findDay( int day, int &row, int &col ); |
135 | void getEvents(); | 136 | void getEvents(); |
136 | void changeDaySelection( int row, int col ); | 137 | void changeDaySelection( int row, int col ); |
137 | 138 | ||
138 | int year, month, day; | 139 | int year, month, day; |
139 | int selYear, selMonth, selDay; | 140 | int selYear, selMonth, selDay; |
140 | QValueList<Event> monthsEvents; // not used anymore... | 141 | QValueList<Event> monthsEvents; // not used anymore... |
141 | DateBookDB *db; | 142 | DateBookDB *db; |
142 | DateBookMonthTablePrivate *d; | 143 | DateBookMonthTablePrivate *d; |
143 | }; | 144 | }; |
144 | 145 | ||
145 | class DateBookMonthPrivate; | 146 | class DateBookMonthPrivate; |
146 | class DateBookMonth : public QVBox | 147 | class DateBookMonth : public QVBox |
147 | { | 148 | { |
148 | Q_OBJECT | 149 | Q_OBJECT |
149 | 150 | ||
150 | public: | 151 | public: |
151 | DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, | 152 | DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, |
152 | DateBookDB *data = 0 ); | 153 | DateBookDB *data = 0 ); |
153 | ~DateBookMonth(); | 154 | ~DateBookMonth(); |
154 | QDate selectedDate() const; | 155 | QDate selectedDate() const; |
155 | 156 | ||
156 | signals: | 157 | signals: |
157 | void dateClicked( int year, int month, int day ); | 158 | void dateClicked( int year, int month, int day ); |
158 | 159 | ||
159 | public slots: | 160 | public slots: |
160 | void setDate( int y, int m ); | 161 | void setDate( int y, int m ); |
161 | void setDate( int y, int m, int d ); | 162 | void setDate( int y, int m, int d ); |
162 | void setDate( QDate ); | 163 | void setDate( QDate ); |
163 | void redraw(); | 164 | void redraw(); |
164 | void slotWeekChange( bool ); | 165 | void slotWeekChange( bool ); |
165 | 166 | ||
166 | protected slots: | 167 | protected slots: |
167 | virtual void keyPressEvent(QKeyEvent *e); | 168 | virtual void keyPressEvent(QKeyEvent *e); |
168 | 169 | ||
169 | private slots: | 170 | private slots: |
170 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } | 171 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } |
171 | void finalDate(int, int, int); | 172 | void finalDate(int, int, int); |
172 | 173 | ||
173 | private: | 174 | private: |
174 | DateBookMonthHeader *header; | 175 | DateBookMonthHeader *header; |
175 | DateBookMonthTable *table; | 176 | DateBookMonthTable *table; |
176 | int year, month, day; | 177 | int year, month, day; |
177 | bool autoClose; | 178 | bool autoClose; |
178 | class DateBookMonthPrivate *d; | 179 | class DateBookMonthPrivate *d; |
179 | }; | 180 | }; |
180 | 181 | ||
181 | class DateButton : public QPushButton | 182 | class DateButton : public QPushButton |
182 | { | 183 | { |
183 | Q_OBJECT | 184 | Q_OBJECT |
184 | 185 | ||
185 | public: | 186 | public: |
186 | DateButton( bool longDate, QWidget *parent, const char * name = 0 ); | 187 | DateButton( bool longDate, QWidget *parent, const char * name = 0 ); |
187 | QDate date() const { return currDate; } | 188 | QDate date() const { return currDate; } |
188 | 189 | ||
189 | signals: | 190 | signals: |
190 | void dateSelected( int year, int month, int day ); | 191 | void dateSelected( int year, int month, int day ); |
191 | 192 | ||
192 | public slots: | 193 | public slots: |
193 | void setDate( int y, int m, int d ); | 194 | void setDate( int y, int m, int d ); |
194 | void setDate( QDate ); | 195 | void setDate( QDate ); |
195 | void setWeekStartsMonday( int ); | 196 | void setWeekStartsMonday( int ); |
196 | void setDateFormat( DateFormat ); | 197 | void setDateFormat( DateFormat ); |
197 | 198 | ||
198 | private slots: | 199 | private slots: |
199 | void pickDate(); | 200 | void pickDate(); |
200 | void gotHide(); | 201 | void gotHide(); |
201 | 202 | ||
202 | private: | 203 | private: |
203 | bool longFormat; | 204 | bool longFormat; |
204 | bool weekStartsMonday; | 205 | bool weekStartsMonday; |
205 | QDate currDate; | 206 | QDate currDate; |
206 | DateFormat df; | 207 | DateFormat df; |
207 | }; | 208 | }; |
208 | 209 | ||
209 | 210 | ||
210 | #endif | 211 | #endif |
diff --git a/library/fileselector.h b/library/fileselector.h index ef8efea..8cfdf13 100644 --- a/library/fileselector.h +++ b/library/fileselector.h | |||
@@ -1,108 +1,80 @@ | |||
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 | #ifndef FILESELECTOR_H | 20 | #ifndef FILESELECTOR_H |
21 | #define FILESELECTOR_H | 21 | #define FILESELECTOR_H |
22 | 22 | ||
23 | #include <qhbox.h> | 23 | #include <qhbox.h> |
24 | #include <qvbox.h> | 24 | #include <qvbox.h> |
25 | #include <qlistview.h> | ||
26 | #include <qtoolbutton.h> | 25 | #include <qtoolbutton.h> |
26 | #include <qlistview.h> | ||
27 | 27 | ||
28 | #include "filemanager.h" | 28 | #include "filemanager.h" |
29 | #include "applnk.h" | 29 | #include "applnk.h" |
30 | 30 | ||
31 | class QPopupMenu; | 31 | class QPopupMenu; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class FileSelectorView; | ||
33 | 34 | ||
34 | class FileSelectorItem : public QListViewItem | 35 | class FileSelectorItem : public QListViewItem |
35 | { | 36 | { |
36 | public: | 37 | public: |
37 | FileSelectorItem( QListView *parent, const DocLnk& f ); | 38 | FileSelectorItem( QListView *parent, const DocLnk& f ); |
38 | ~FileSelectorItem(); | 39 | ~FileSelectorItem(); |
39 | 40 | ||
40 | DocLnk file() const { return fl; } | 41 | DocLnk file() const { return fl; } |
41 | 42 | ||
42 | private: | 43 | private: |
43 | DocLnk fl; | 44 | DocLnk fl; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | class CategoryMenu; | ||
47 | class FileSelectorViewPrivate; | ||
48 | class FileSelectorView : public QListView | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | |||
52 | public: | ||
53 | FileSelectorView( const QString &mimefilter, QWidget *parent, const char *name ); | ||
54 | ~FileSelectorView(); | ||
55 | void reread(); | ||
56 | int fileCount() { return count; } | ||
57 | |||
58 | void setCategoryFilter(CategoryMenu *); | ||
59 | protected: | ||
60 | void keyPressEvent( QKeyEvent *e ); | ||
61 | |||
62 | protected slots: | ||
63 | void cardMessage( const QCString &, const QByteArray &); | ||
64 | |||
65 | void categoryChanged(); | ||
66 | |||
67 | private: | ||
68 | QString filter; | ||
69 | FileManager *fileManager; | ||
70 | int count; | ||
71 | FileSelectorViewPrivate *d; | ||
72 | }; | ||
73 | |||
74 | class FileSelectorPrivate; | 47 | class FileSelectorPrivate; |
75 | class FileSelector : public QVBox | 48 | class FileSelector : public QVBox |
76 | { | 49 | { |
77 | Q_OBJECT | 50 | Q_OBJECT |
78 | 51 | ||
79 | public: | 52 | public: |
80 | FileSelector( const QString &mimefilter, QWidget *parent, const char *name, bool newVisible = TRUE, bool closeVisible = TRUE ); | 53 | FileSelector( const QString &mimefilter, QWidget *parent, const char *name, bool newVisible = TRUE, bool closeVisible = TRUE ); |
81 | ~FileSelector(); | 54 | ~FileSelector(); |
82 | void setNewVisible( bool b ); | 55 | void setNewVisible( bool b ); |
83 | void setCloseVisible( bool b ); | 56 | void setCloseVisible( bool b ); |
84 | void setCategoriesVisible( bool b ); | ||
85 | void reread(); | 57 | void reread(); |
86 | int fileCount(); | 58 | int fileCount(); |
87 | const DocLnk *selected(); | 59 | const DocLnk *selected(); |
88 | 60 | ||
89 | signals: | 61 | signals: |
90 | void fileSelected( const DocLnk & ); | 62 | void fileSelected( const DocLnk & ); |
91 | void newSelected( const DocLnk & ); | 63 | void newSelected( const DocLnk & ); |
92 | void closeMe(); | 64 | void closeMe(); |
93 | 65 | ||
94 | private slots: | 66 | private slots: |
95 | void createNew(); | 67 | void createNew(); |
96 | void fileClicked( int, QListViewItem *, const QPoint &, int ); | 68 | void fileClicked( int, QListViewItem *, const QPoint &, int ); |
97 | // pressed to get 'right down' | 69 | // pressed to get 'right down' |
98 | void filePressed( int, QListViewItem *, const QPoint &, int ); | 70 | void filePressed( int, QListViewItem *, const QPoint &, int ); |
99 | void fileClicked( QListViewItem *); | 71 | void fileClicked( QListViewItem *); |
100 | 72 | ||
101 | private: | 73 | private: |
102 | FileSelectorView *view; | 74 | FileSelectorView *view; |
103 | QString filter; | 75 | QString filter; |
104 | QToolButton *buttonNew, *buttonClose; | 76 | QToolButton *buttonNew, *buttonClose; |
105 | FileSelectorPrivate *d; | 77 | FileSelectorPrivate *d; |
106 | }; | 78 | }; |
107 | 79 | ||
108 | #endif | 80 | #endif |
diff --git a/library/finddialog.cpp b/library/finddialog.cpp index 7a9367b..904e952 100644 --- a/library/finddialog.cpp +++ b/library/finddialog.cpp | |||
@@ -1,73 +1,77 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | ||
22 | // have this class. | ||
23 | #define QTOPIA_INTERNAL_FD | ||
24 | |||
21 | #include "finddialog.h" | 25 | #include "finddialog.h" |
22 | #include "findwidget_p.h" | 26 | #include "findwidget_p.h" |
23 | 27 | ||
24 | #include <qlayout.h> | 28 | #include <qlayout.h> |
25 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
26 | 30 | ||
27 | FindDialog::FindDialog( const QString &appName, QWidget *parent, | 31 | FindDialog::FindDialog( const QString &appName, QWidget *parent, |
28 | const char *name, bool modal ) | 32 | const char *name, bool modal ) |
29 | : QDialog( parent, name, modal ) | 33 | : QDialog( parent, name, modal ) |
30 | { | 34 | { |
31 | QVBoxLayout *vb; | 35 | QVBoxLayout *vb; |
32 | vb = new QVBoxLayout( this ); | 36 | vb = new QVBoxLayout( this ); |
33 | fw = new FindWidget( appName, this, "Find Widget" ); | 37 | fw = new FindWidget( appName, this, "Find Widget" ); |
34 | vb->addWidget( fw ); | 38 | vb->addWidget( fw ); |
35 | QObject::connect( fw, SIGNAL(signalFindClicked(const QString&, | 39 | QObject::connect( fw, SIGNAL(signalFindClicked(const QString&, |
36 | bool,bool,int)), | 40 | bool,bool,int)), |
37 | this, SIGNAL(signalFindClicked(const QString&, | 41 | this, SIGNAL(signalFindClicked(const QString&, |
38 | bool,bool,int)) ); | 42 | bool,bool,int)) ); |
39 | QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&, | 43 | QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&, |
40 | bool,bool,int)), | 44 | bool,bool,int)), |
41 | this, SIGNAL(signalFindClicked(const QString&, | 45 | this, SIGNAL(signalFindClicked(const QString&, |
42 | const QDate&,bool,bool,int)) ); | 46 | const QDate&,bool,bool,int)) ); |
43 | d = 0; | 47 | d = 0; |
44 | } | 48 | } |
45 | 49 | ||
46 | FindDialog::~FindDialog() | 50 | FindDialog::~FindDialog() |
47 | { | 51 | { |
48 | } | 52 | } |
49 | 53 | ||
50 | QString FindDialog::findText() const | 54 | QString FindDialog::findText() const |
51 | { | 55 | { |
52 | return fw->findText(); | 56 | return fw->findText(); |
53 | } | 57 | } |
54 | 58 | ||
55 | void FindDialog::setUseDate( bool show ) | 59 | void FindDialog::setUseDate( bool show ) |
56 | { | 60 | { |
57 | fw->setUseDate( show ); | 61 | fw->setUseDate( show ); |
58 | } | 62 | } |
59 | 63 | ||
60 | void FindDialog::setDate( const QDate &dt ) | 64 | void FindDialog::setDate( const QDate &dt ) |
61 | { | 65 | { |
62 | fw->setDate( dt ); | 66 | fw->setDate( dt ); |
63 | } | 67 | } |
64 | 68 | ||
65 | void FindDialog::slotNotFound() | 69 | void FindDialog::slotNotFound() |
66 | { | 70 | { |
67 | fw->slotNotFound(); | 71 | fw->slotNotFound(); |
68 | } | 72 | } |
69 | 73 | ||
70 | void FindDialog::slotWrapAround() | 74 | void FindDialog::slotWrapAround() |
71 | { | 75 | { |
72 | fw->slotWrapAround(); | 76 | fw->slotWrapAround(); |
73 | } | 77 | } |
diff --git a/library/finddialog.h b/library/finddialog.h index 265b5ae..00c7b45 100644 --- a/library/finddialog.h +++ b/library/finddialog.h | |||
@@ -1,57 +1,68 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 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 | |||
22 | // | ||
23 | // DO NOT ATTEMPT TO USE THIS CLASS | ||
24 | // | ||
25 | |||
21 | #ifndef __FINDDIALOG_H__ | 26 | #ifndef __FINDDIALOG_H__ |
22 | #define __FINDDIALOG_H__ | 27 | #define __FINDDIALOG_H__ |
23 | 28 | ||
24 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
25 | #include <qdialog.h> | 30 | #include <qdialog.h> |
26 | 31 | ||
27 | class FindWidget; | 32 | class FindWidget; |
28 | 33 | ||
29 | class FindDialogPrivate; | 34 | class FindDialogPrivate; |
30 | class FindDialog : public QDialog | 35 | class FindDialog : public QDialog |
31 | { | 36 | { |
32 | Q_OBJECT | 37 | Q_OBJECT |
33 | public: | 38 | public: |
39 | |||
40 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | ||
41 | // have this class. | ||
42 | #ifdef QTOPIA_INTERNAL_FD | ||
43 | |||
34 | FindDialog( const QString &appName, | 44 | FindDialog( const QString &appName, |
35 | QWidget *parent = 0, const char *name = 0, bool modal = TRUE ); | 45 | QWidget *parent = 0, const char *name = 0, bool modal = TRUE ); |
36 | ~FindDialog(); | 46 | ~FindDialog(); |
47 | #endif | ||
37 | 48 | ||
38 | QString findText() const; | 49 | QString findText() const; |
39 | void setUseDate( bool show ); | 50 | void setUseDate( bool show ); |
40 | void setDate( const QDate &dt ); | 51 | void setDate( const QDate &dt ); |
41 | 52 | ||
42 | public slots: | 53 | public slots: |
43 | void slotNotFound(); | 54 | void slotNotFound(); |
44 | void slotWrapAround(); | 55 | void slotWrapAround(); |
45 | 56 | ||
46 | signals: | 57 | signals: |
47 | void signalFindClicked( const QString &txt, bool caseSensitive, | 58 | void signalFindClicked( const QString &txt, bool caseSensitive, |
48 | bool backwards, int category ); | 59 | bool backwards, int category ); |
49 | void signalFindClicked( const QString &txt, const QDate &dt, | 60 | void signalFindClicked( const QString &txt, const QDate &dt, |
50 | bool caseSensitive, bool backwards, int category ); | 61 | bool caseSensitive, bool backwards, int category ); |
51 | 62 | ||
52 | private: | 63 | private: |
53 | FindWidget *fw; | 64 | FindWidget *fw; |
54 | FindDialogPrivate *d; | 65 | FindDialogPrivate *d; |
55 | }; | 66 | }; |
56 | 67 | ||
57 | #endif | 68 | #endif |
diff --git a/library/mimetype.cpp b/library/mimetype.cpp index c6a4453..9fab160 100644 --- a/library/mimetype.cpp +++ b/library/mimetype.cpp | |||
@@ -1,204 +1,217 @@ | |||
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 | #define QTOPIA_INTERNAL_MIMEEXT | ||
21 | #include "mimetype.h" | 22 | #include "mimetype.h" |
22 | #include "applnk.h" | 23 | #include "applnk.h" |
23 | #include "resource.h" | 24 | #include "resource.h" |
24 | #include "qpeapplication.h" | 25 | #include "qpeapplication.h" |
25 | #include <qfile.h> | 26 | #include <qfile.h> |
26 | #include <qdict.h> | 27 | #include <qdict.h> |
27 | #include <qregexp.h> | 28 | #include <qregexp.h> |
28 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
29 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
30 | #include <qmap.h> | 31 | #include <qmap.h> |
31 | 32 | ||
32 | class MimeTypeData { | 33 | class MimeTypeData { |
33 | public: | 34 | public: |
34 | MimeTypeData(const QString& i, const AppLnk& lnk, const QString& icon ) : | 35 | MimeTypeData(const QString& i, const AppLnk& lnk, const QString& icon ) : |
35 | id(i), | 36 | id(i), |
36 | desc(lnk.name()+" document"), | 37 | desc(lnk.name()+" document"), |
37 | app(lnk) | 38 | app(lnk) |
38 | { | 39 | { |
39 | if ( icon.isEmpty() ) { | 40 | if ( icon.isEmpty() ) { |
40 | regIcon = lnk.pixmap(); | 41 | regIcon = lnk.pixmap(); |
41 | bigIcon = lnk.bigPixmap(); | 42 | bigIcon = lnk.bigPixmap(); |
42 | } else { | 43 | } else { |
43 | QImage unscaledIcon = Resource::loadImage( icon ); | 44 | QImage unscaledIcon = Resource::loadImage( icon ); |
44 | regIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 45 | regIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
45 | bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) ); | 46 | bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) ); |
46 | } | 47 | } |
47 | } | 48 | } |
48 | QString id; | 49 | QString id; |
50 | QString extension; | ||
49 | QString desc; | 51 | QString desc; |
50 | QPixmap regIcon; | 52 | QPixmap regIcon; |
51 | QPixmap bigIcon; | 53 | QPixmap bigIcon; |
52 | AppLnk app; | 54 | AppLnk app; |
53 | }; | 55 | }; |
54 | 56 | ||
55 | class MimeType::Dict : public QDict<MimeTypeData> { | 57 | class MimeType::Dict : public QDict<MimeTypeData> { |
56 | public: | 58 | public: |
57 | Dict() {} | 59 | Dict() {} |
58 | }; | 60 | }; |
59 | 61 | ||
60 | MimeType::Dict* MimeType::d=0; | 62 | MimeType::Dict* MimeType::d=0; |
61 | static QMap<QString,QString> *typeFor = 0; | 63 | static QMap<QString,QString> *typeFor = 0; |
64 | static QMap<QString,QString> *extFor = 0; | ||
62 | 65 | ||
63 | MimeType::Dict& MimeType::dict() | 66 | MimeType::Dict& MimeType::dict() |
64 | { | 67 | { |
65 | if ( !d ) { | 68 | if ( !d ) { |
66 | d = new Dict; | 69 | d = new Dict; |
67 | d->setAutoDelete(TRUE); | 70 | d->setAutoDelete(TRUE); |
68 | } | 71 | } |
69 | return *d; | 72 | return *d; |
70 | } | 73 | } |
71 | 74 | ||
72 | MimeType::MimeType( const QString& ext_or_id ) | 75 | MimeType::MimeType( const QString& ext_or_id ) |
73 | { | 76 | { |
74 | init(ext_or_id); | 77 | init(ext_or_id); |
75 | } | 78 | } |
76 | 79 | ||
77 | MimeType::MimeType( const DocLnk& lnk ) | 80 | MimeType::MimeType( const DocLnk& lnk ) |
78 | { | 81 | { |
79 | init(lnk.type()); | 82 | init(lnk.type()); |
80 | } | 83 | } |
81 | 84 | ||
82 | QString MimeType::id() const | 85 | QString MimeType::id() const |
83 | { | 86 | { |
84 | return i; | 87 | return i; |
85 | } | 88 | } |
86 | 89 | ||
87 | QString MimeType::description() const | 90 | QString MimeType::description() const |
88 | { | 91 | { |
89 | MimeTypeData* d = data(i); | 92 | MimeTypeData* d = data(i); |
90 | return d ? d->desc : QString::null; | 93 | return d ? d->desc : QString::null; |
91 | } | 94 | } |
92 | 95 | ||
93 | QPixmap MimeType::pixmap() const | 96 | QPixmap MimeType::pixmap() const |
94 | { | 97 | { |
95 | MimeTypeData* d = data(i); | 98 | MimeTypeData* d = data(i); |
96 | return d ? d->regIcon : QPixmap(); | 99 | return d ? d->regIcon : QPixmap(); |
97 | } | 100 | } |
98 | 101 | ||
102 | QString MimeType::extension() const | ||
103 | { | ||
104 | loadExtensions(); | ||
105 | return *(*extFor).find(i); | ||
106 | } | ||
107 | |||
99 | QPixmap MimeType::bigPixmap() const | 108 | QPixmap MimeType::bigPixmap() const |
100 | { | 109 | { |
101 | MimeTypeData* d = data(i); | 110 | MimeTypeData* d = data(i); |
102 | return d ? d->bigIcon : QPixmap(); | 111 | return d ? d->bigIcon : QPixmap(); |
103 | } | 112 | } |
104 | 113 | ||
105 | const AppLnk* MimeType::application() const | 114 | const AppLnk* MimeType::application() const |
106 | { | 115 | { |
107 | MimeTypeData* d = data(i); | 116 | MimeTypeData* d = data(i); |
108 | return d ? &d->app : 0; | 117 | return d ? &d->app : 0; |
109 | } | 118 | } |
110 | 119 | ||
111 | void MimeType::registerApp( const AppLnk& lnk ) | 120 | void MimeType::registerApp( const AppLnk& lnk ) |
112 | { | 121 | { |
113 | QStringList list = lnk.mimeTypes(); | 122 | QStringList list = lnk.mimeTypes(); |
114 | QStringList icons = lnk.mimeTypeIcons(); | 123 | QStringList icons = lnk.mimeTypeIcons(); |
115 | QStringList::ConstIterator icon = icons.begin(); | 124 | QStringList::ConstIterator icon = icons.begin(); |
116 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it, ++icon) { | 125 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it, ++icon) { |
117 | MimeTypeData *item = new MimeTypeData( *it, lnk, *icon ); | 126 | MimeTypeData *item = new MimeTypeData( *it, lnk, *icon ); |
118 | dict().replace( *it, item ); | 127 | dict().replace( *it, item ); |
119 | } | 128 | } |
120 | } | 129 | } |
121 | 130 | ||
122 | void MimeType::clear() | 131 | void MimeType::clear() |
123 | { | 132 | { |
124 | delete d; | 133 | delete d; |
125 | d = 0; | 134 | d = 0; |
126 | } | 135 | } |
127 | 136 | ||
128 | void MimeType::loadExtensions() | 137 | void MimeType::loadExtensions() |
129 | { | 138 | { |
130 | if ( !typeFor ) { | 139 | if ( !typeFor ) { |
140 | extFor = new QMap<QString,QString>; | ||
131 | typeFor = new QMap<QString,QString>; | 141 | typeFor = new QMap<QString,QString>; |
132 | loadExtensions("/etc/mime.types"); | 142 | loadExtensions("/etc/mime.types"); |
133 | loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); | 143 | loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); |
134 | } | 144 | } |
135 | } | 145 | } |
136 | 146 | ||
137 | void MimeType::loadExtensions(const QString& filename) | 147 | void MimeType::loadExtensions(const QString& filename) |
138 | { | 148 | { |
139 | QFile file(filename); | 149 | QFile file(filename); |
140 | if ( file.open(IO_ReadOnly) ) { | 150 | if ( file.open(IO_ReadOnly) ) { |
141 | QTextStream in(&file); | 151 | QTextStream in(&file); |
142 | QRegExp space("[ \t]+"); | 152 | QRegExp space("[ \t]+"); |
143 | while (!in.atEnd()) { | 153 | while (!in.atEnd()) { |
144 | QStringList tokens = QStringList::split(space, in.readLine()); | 154 | QStringList tokens = QStringList::split(space, in.readLine()); |
145 | QStringList::ConstIterator it = tokens.begin(); | 155 | QStringList::ConstIterator it = tokens.begin(); |
146 | if ( it != tokens.end() ) { | 156 | if ( it != tokens.end() ) { |
147 | QString id = *it; ++it; | 157 | QString id = *it; ++it; |
148 | while (it != tokens.end()) { | 158 | if ( it != tokens.end() ) { |
149 | (*typeFor)[*it] = id; | 159 | (*extFor)[id] = *it; |
150 | ++it; | 160 | while (it != tokens.end()) { |
161 | (*typeFor)[*it] = id; | ||
162 | ++it; | ||
163 | } | ||
151 | } | 164 | } |
152 | } | 165 | } |
153 | } | 166 | } |
154 | } | 167 | } |
155 | } | 168 | } |
156 | 169 | ||
157 | void MimeType::init( const QString& ext_or_id ) | 170 | void MimeType::init( const QString& ext_or_id ) |
158 | { | 171 | { |
159 | if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { | 172 | if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { |
160 | i = ext_or_id.lower(); | 173 | i = ext_or_id.lower(); |
161 | } else { | 174 | } else { |
162 | loadExtensions(); | 175 | loadExtensions(); |
163 | int dot = ext_or_id.findRev('.'); | 176 | int dot = ext_or_id.findRev('.'); |
164 | QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; | 177 | QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; |
165 | i = (*typeFor)[ext.lower()]; | 178 | i = (*typeFor)[ext.lower()]; |
166 | if ( i.isNull() ) | 179 | if ( i.isNull() ) |
167 | i = "application/octet-stream"; | 180 | i = "application/octet-stream"; |
168 | } | 181 | } |
169 | static bool appsUpdated = FALSE; | 182 | static bool appsUpdated = FALSE; |
170 | if ( !appsUpdated ) { | 183 | if ( !appsUpdated ) { |
171 | appsUpdated = TRUE; | 184 | appsUpdated = TRUE; |
172 | updateApplications(); | 185 | updateApplications(); |
173 | } | 186 | } |
174 | } | 187 | } |
175 | 188 | ||
176 | MimeTypeData* MimeType::data(const QString& id) | 189 | MimeTypeData* MimeType::data(const QString& id) |
177 | { | 190 | { |
178 | MimeTypeData* d = dict()[id]; | 191 | MimeTypeData* d = dict()[id]; |
179 | if ( !d ) { | 192 | if ( !d ) { |
180 | int s = id.find('/'); | 193 | int s = id.find('/'); |
181 | QString idw = id.left(s)+"/*"; | 194 | QString idw = id.left(s)+"/*"; |
182 | d = dict()[idw]; | 195 | d = dict()[idw]; |
183 | } | 196 | } |
184 | return d; | 197 | return d; |
185 | } | 198 | } |
186 | 199 | ||
187 | QString MimeType::appsFolderName() | 200 | QString MimeType::appsFolderName() |
188 | { | 201 | { |
189 | return QPEApplication::qpeDir() + "apps"; | 202 | return QPEApplication::qpeDir() + "apps"; |
190 | } | 203 | } |
191 | 204 | ||
192 | void MimeType::updateApplications() | 205 | void MimeType::updateApplications() |
193 | { | 206 | { |
194 | clear(); | 207 | clear(); |
195 | AppLnkSet apps( appsFolderName() ); | 208 | AppLnkSet apps( appsFolderName() ); |
196 | updateApplications(&apps); | 209 | updateApplications(&apps); |
197 | } | 210 | } |
198 | 211 | ||
199 | void MimeType::updateApplications(AppLnkSet* folder) | 212 | void MimeType::updateApplications(AppLnkSet* folder) |
200 | { | 213 | { |
201 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 214 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
202 | registerApp(*it.current()); | 215 | registerApp(*it.current()); |
203 | } | 216 | } |
204 | } | 217 | } |
diff --git a/library/mimetype.h b/library/mimetype.h index 58725d7..b6cca95 100644 --- a/library/mimetype.h +++ b/library/mimetype.h | |||
@@ -1,64 +1,69 @@ | |||
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 | #ifndef MIMETYPE_H | 20 | #ifndef MIMETYPE_H |
21 | #define MIMETYPE_H | 21 | #define MIMETYPE_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | 25 | ||
26 | class AppLnk; | 26 | class AppLnk; |
27 | class DocLnk; | 27 | class DocLnk; |
28 | class QStringList; | 28 | class QStringList; |
29 | class MimeTypeData; | 29 | class MimeTypeData; |
30 | class AppLnkSet; | 30 | class AppLnkSet; |
31 | 31 | ||
32 | class MimeType | 32 | class MimeType |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | MimeType( const QString& ext_or_id ); | 35 | MimeType( const QString& ext_or_id ); |
36 | MimeType( const DocLnk& ); | 36 | MimeType( const DocLnk& ); |
37 | 37 | ||
38 | QString id() const; | 38 | QString id() const; |
39 | QString description() const; | 39 | QString description() const; |
40 | QPixmap pixmap() const; | 40 | QPixmap pixmap() const; |
41 | QPixmap bigPixmap() const; | 41 | QPixmap bigPixmap() const; |
42 | 42 | ||
43 | // DON'T define this yourself! | ||
44 | #ifdef QTOPIA_INTERNAL_MIMEEXT | ||
45 | QString extension() const; | ||
46 | #endif | ||
47 | |||
43 | const AppLnk* application() const; | 48 | const AppLnk* application() const; |
44 | 49 | ||
45 | static QString appsFolderName(); | 50 | static QString appsFolderName(); |
46 | static void updateApplications(); | 51 | static void updateApplications(); |
47 | 52 | ||
48 | // These shouldn't be needed | 53 | // These shouldn't be needed |
49 | static void clear(); | 54 | static void clear(); |
50 | static void registerApp( const AppLnk& ); | 55 | static void registerApp( const AppLnk& ); |
51 | 56 | ||
52 | private: | 57 | private: |
53 | static void updateApplications(AppLnkSet* folder); | 58 | static void updateApplications(AppLnkSet* folder); |
54 | static void loadExtensions(); | 59 | static void loadExtensions(); |
55 | static void loadExtensions(const QString&); | 60 | static void loadExtensions(const QString&); |
56 | void init( const QString& ext_or_id ); | 61 | void init( const QString& ext_or_id ); |
57 | class Dict; | 62 | class Dict; |
58 | static Dict* d; | 63 | static Dict* d; |
59 | static Dict& dict(); | 64 | static Dict& dict(); |
60 | static MimeTypeData* data(const QString& id); | 65 | static MimeTypeData* data(const QString& id); |
61 | QString i; | 66 | QString i; |
62 | }; | 67 | }; |
63 | 68 | ||
64 | #endif | 69 | #endif |
diff --git a/library/network.cpp b/library/network.cpp index 7d51016..e6d2781 100644 --- a/library/network.cpp +++ b/library/network.cpp | |||
@@ -1,436 +1,439 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | ||
21 | #include "qpe/network.h" | 22 | #include "qpe/network.h" |
22 | #include "qpe/networkinterface.h" | 23 | #include "qpe/networkinterface.h" |
23 | #include "qpe/global.h" | 24 | #include "qpe/global.h" |
24 | #include "qpe/config.h" | 25 | #include "qpe/config.h" |
25 | #include "qpe/resource.h" | 26 | #include "qpe/resource.h" |
26 | #include "qpe/qpeapplication.h" | 27 | #include "qpe/qpeapplication.h" |
27 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/qlibrary.h> | 29 | #include <qpe/qlibrary.h> |
29 | 30 | ||
30 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <qlayout.h> | 33 | #include <qlayout.h> |
33 | #include <qdict.h> | 34 | #include <qdict.h> |
34 | #include <qtranslator.h> | 35 | #include <qtranslator.h> |
35 | 36 | ||
36 | #include <stdlib.h> | 37 | #include <stdlib.h> |
37 | 38 | ||
38 | class NetworkEmitter : public QCopChannel { | 39 | class NetworkEmitter : public QCopChannel { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | public: | 41 | public: |
41 | NetworkEmitter() : QCopChannel("QPE/Network",qApp) | 42 | NetworkEmitter() : QCopChannel("QPE/Network",qApp) |
42 | { | 43 | { |
43 | } | 44 | } |
44 | 45 | ||
45 | void receive(const QCString &msg, const QByteArray&) | 46 | void receive(const QCString &msg, const QByteArray&) |
46 | { | 47 | { |
47 | if ( msg == "choicesChanged()" ) | 48 | if ( msg == "choicesChanged()" ) |
48 | emit changed(); | 49 | emit changed(); |
49 | } | 50 | } |
50 | 51 | ||
51 | signals: | 52 | signals: |
52 | void changed(); | 53 | void changed(); |
53 | }; | 54 | }; |
54 | 55 | ||
55 | /*! | 56 | /*! |
56 | \internal | 57 | \internal |
57 | 58 | ||
58 | Requests that the service \a choice be started. The \a password is | 59 | Requests that the service \a choice be started. The \a password is |
59 | the password to use if required. | 60 | the password to use if required. |
60 | */ | 61 | */ |
61 | void Network::start(const QString& choice, const QString& password) | 62 | void Network::start(const QString& choice, const QString& password) |
62 | { | 63 | { |
63 | QCopEnvelope e("QPE/Network", "start(QString,QString)"); | 64 | QCopEnvelope e("QPE/Network", "start(QString,QString)"); |
64 | e << choice << password; | 65 | e << choice << password; |
65 | } | 66 | } |
66 | 67 | ||
67 | /*! | 68 | /*! |
68 | \class Network network.h | 69 | \class Network network.h |
69 | \brief The Network class provides network access functionality. | 70 | \brief The Network class provides network access functionality. |
70 | */ | 71 | */ |
71 | 72 | ||
72 | // copy the proxy settings of the active config over to the Proxies.conf file | 73 | // copy the proxy settings of the active config over to the Proxies.conf file |
73 | /*! | 74 | /*! |
74 | \internal | 75 | \internal |
75 | */ | 76 | */ |
76 | void Network::writeProxySettings( Config &cfg ) | 77 | void Network::writeProxySettings( Config &cfg ) |
77 | { | 78 | { |
78 | Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); | 79 | Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); |
79 | proxy.setGroup("Properties"); | 80 | proxy.setGroup("Properties"); |
80 | cfg.setGroup("Proxy"); | 81 | cfg.setGroup("Proxy"); |
81 | proxy.writeEntry("type", cfg.readEntry("type") ); | 82 | proxy.writeEntry("type", cfg.readEntry("type") ); |
82 | proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); | 83 | proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); |
83 | proxy.writeEntry("httphost", cfg.readEntry("httphost") ); | 84 | proxy.writeEntry("httphost", cfg.readEntry("httphost") ); |
84 | proxy.writeEntry("httpport", cfg.readEntry("httpport") ); | 85 | proxy.writeEntry("httpport", cfg.readEntry("httpport") ); |
85 | proxy.writeEntry("ftphost", cfg.readEntry("ftphost") ); | 86 | proxy.writeEntry("ftphost", cfg.readEntry("ftphost") ); |
86 | proxy.writeEntry("ftpport", cfg.readEntry("ftpport") ); | 87 | proxy.writeEntry("ftpport", cfg.readEntry("ftpport") ); |
87 | proxy.writeEntry("noproxies", cfg.readEntry("noproxies") ); | 88 | proxy.writeEntry("noproxies", cfg.readEntry("noproxies") ); |
88 | cfg.setGroup("Properties"); | 89 | cfg.setGroup("Properties"); |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | 93 | ||
93 | /*! | 94 | /*! |
94 | \internal | 95 | \internal |
95 | 96 | ||
96 | Stops the current network service. | 97 | Stops the current network service. |
97 | */ | 98 | */ |
98 | void Network::stop() | 99 | void Network::stop() |
99 | { | 100 | { |
100 | QCopEnvelope e("QPE/Network", "stop()"); | 101 | QCopEnvelope e("QPE/Network", "stop()"); |
101 | } | 102 | } |
102 | 103 | ||
103 | static NetworkEmitter *emitter = 0; | 104 | static NetworkEmitter *emitter = 0; |
104 | 105 | ||
105 | /*! | 106 | /*! |
106 | \internal | 107 | \internal |
107 | */ | 108 | */ |
108 | void Network::connectChoiceChange(QObject* receiver, const char* slot) | 109 | void Network::connectChoiceChange(QObject* receiver, const char* slot) |
109 | { | 110 | { |
110 | if ( !emitter ) | 111 | if ( !emitter ) |
111 | emitter = new NetworkEmitter; | 112 | emitter = new NetworkEmitter; |
112 | QObject::connect(emitter,SIGNAL(changed()),receiver,slot); | 113 | QObject::connect(emitter,SIGNAL(changed()),receiver,slot); |
113 | } | 114 | } |
114 | 115 | ||
115 | /*! | 116 | /*! |
116 | \internal | 117 | \internal |
117 | */ | 118 | */ |
118 | QString Network::settingsDir() | 119 | QString Network::settingsDir() |
119 | { | 120 | { |
120 | return Global::applicationFileName("Network", "modules"); | 121 | return Global::applicationFileName("Network", "modules"); |
121 | } | 122 | } |
122 | 123 | ||
123 | /*! | 124 | /*! |
124 | \internal | 125 | \internal |
125 | */ | 126 | */ |
126 | QStringList Network::choices(QListBox* lb, const QString& dir) | 127 | QStringList Network::choices(QListBox* lb, const QString& dir) |
127 | { | 128 | { |
128 | QStringList list; | 129 | QStringList list; |
129 | 130 | ||
130 | if ( lb ) | 131 | if ( lb ) |
131 | lb->clear(); | 132 | lb->clear(); |
132 | 133 | ||
133 | QString adir = dir.isEmpty() ? settingsDir() : dir; | 134 | QString adir = dir.isEmpty() ? settingsDir() : dir; |
134 | QDir settingsdir(adir); | 135 | QDir settingsdir(adir); |
135 | settingsdir.mkdir(adir); | 136 | settingsdir.mkdir(adir); |
136 | 137 | ||
137 | QStringList files = settingsdir.entryList("*.conf"); | 138 | QStringList files = settingsdir.entryList("*.conf"); |
138 | for (QStringList::ConstIterator it=files.begin(); it!=files.end(); ++it ) { | 139 | for (QStringList::ConstIterator it=files.begin(); it!=files.end(); ++it ) { |
139 | QString filename = settingsdir.filePath(*it); | 140 | QString filename = settingsdir.filePath(*it); |
140 | Config cfg(filename, Config::File); | 141 | Config cfg(filename, Config::File); |
141 | cfg.setGroup("Info"); | 142 | cfg.setGroup("Info"); |
142 | if ( lb ) | 143 | if ( lb ) |
143 | lb->insertItem(Resource::loadPixmap("Network/" + cfg.readEntry("Type")), | 144 | lb->insertItem(Resource::loadPixmap("Network/" + cfg.readEntry("Type")), |
144 | cfg.readEntry("Name")); | 145 | cfg.readEntry("Name")); |
145 | list.append(filename); | 146 | list.append(filename); |
146 | } | 147 | } |
147 | 148 | ||
148 | return list; | 149 | return list; |
149 | } | 150 | } |
150 | 151 | ||
151 | class NetworkServer : public QCopChannel { | 152 | class NetworkServer : public QCopChannel { |
152 | Q_OBJECT | 153 | Q_OBJECT |
153 | public: | 154 | public: |
154 | NetworkServer(QObject* parent) : QCopChannel("QPE/Network",parent) | 155 | NetworkServer(QObject* parent) : QCopChannel("QPE/Network",parent) |
155 | { | 156 | { |
156 | up = FALSE; | 157 | up = FALSE; |
157 | examineNetworks( TRUE ); | 158 | examineNetworks( TRUE ); |
158 | QCopChannel* card = new QCopChannel("QPE/Card",parent); | 159 | QCopChannel* card = new QCopChannel("QPE/Card",parent); |
159 | connect(card,SIGNAL(received(const QCString &, const QByteArray&)), | 160 | connect(card,SIGNAL(received(const QCString &, const QByteArray&)), |
160 | this,SLOT(cardMessage(const QCString &, const QByteArray&))); | 161 | this,SLOT(cardMessage(const QCString &, const QByteArray&))); |
161 | } | 162 | } |
162 | 163 | ||
163 | ~NetworkServer() | 164 | ~NetworkServer() |
164 | { | 165 | { |
165 | stop(); | 166 | stop(); |
166 | } | 167 | } |
167 | 168 | ||
168 | bool networkOnline() const | 169 | bool networkOnline() const |
169 | { | 170 | { |
170 | return up; | 171 | return up; |
171 | } | 172 | } |
172 | 173 | ||
173 | private: | 174 | private: |
174 | void receive(const QCString &msg, const QByteArray& data) | 175 | void receive(const QCString &msg, const QByteArray& data) |
175 | { | 176 | { |
176 | if ( msg == "start(QString,QString)" ) { | 177 | if ( msg == "start(QString,QString)" ) { |
177 | QDataStream stream(data,IO_ReadOnly); | 178 | QDataStream stream(data,IO_ReadOnly); |
178 | QString file,password; | 179 | QString file,password; |
179 | stream >> file >> password; | 180 | stream >> file >> password; |
180 | if ( file.isEmpty() ) { | 181 | if ( file.isEmpty() ) { |
181 | QStringList l = Network::choices(); | 182 | QStringList l = Network::choices(); |
182 | for (QStringList::ConstIterator i=l.begin(); i!=l.end(); ++i) { | 183 | for (QStringList::ConstIterator i=l.begin(); i!=l.end(); ++i) { |
183 | Config cfg(*i,Config::File); | 184 | Config cfg(*i,Config::File); |
184 | cfg.setGroup("Info"); | 185 | cfg.setGroup("Info"); |
185 | QString type = cfg.readEntry("Type"); | 186 | QString type = cfg.readEntry("Type"); |
186 | NetworkInterface* plugin = Network::loadPlugin(type); | 187 | NetworkInterface* plugin = Network::loadPlugin(type); |
187 | cfg.setGroup("Properties"); | 188 | cfg.setGroup("Properties"); |
188 | if ( plugin && plugin->isAvailable(cfg) ) { | 189 | if ( plugin && plugin->isAvailable(cfg) ) { |
189 | file = *i; | 190 | file = *i; |
190 | break; | 191 | break; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | if ( file.isEmpty() ) { | 194 | if ( file.isEmpty() ) { |
194 | QCopEnvelope("QPE/Network", "failed()"); | 195 | QCopEnvelope("QPE/Network", "failed()"); |
195 | return; | 196 | return; |
196 | } | 197 | } |
197 | } | 198 | } |
198 | start(file,password); | 199 | start(file,password); |
199 | } else if ( msg == "stop()" ) { | 200 | } else if ( msg == "stop()" ) { |
200 | stop(); | 201 | stop(); |
201 | } else if ( msg == "choicesChanged()" ) { | 202 | } else if ( msg == "choicesChanged()" ) { |
202 | examineNetworks(); | 203 | examineNetworks(); |
203 | } | 204 | } |
204 | } | 205 | } |
205 | 206 | ||
206 | private slots: | 207 | private slots: |
207 | void cardMessage(const QCString &msg, const QByteArray&) | 208 | void cardMessage(const QCString &msg, const QByteArray&) |
208 | { | 209 | { |
209 | if ( msg == "stabChanged()" ) | 210 | if ( msg == "stabChanged()" ) |
210 | examineNetworks(); | 211 | examineNetworks(); |
211 | } | 212 | } |
212 | 213 | ||
213 | private: | 214 | private: |
214 | void examineNetworks( bool firstStart = FALSE ) | 215 | void examineNetworks( bool firstStart = FALSE ) |
215 | { | 216 | { |
216 | QStringList l = Network::choices(); | 217 | QStringList l = Network::choices(); |
217 | bool wasup = up; up=FALSE; | 218 | bool wasup = up; up=FALSE; |
218 | QStringList pavailable = available; | 219 | QStringList pavailable = available; |
219 | available.clear(); | 220 | available.clear(); |
220 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 221 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
221 | Config cfg(*it,Config::File); | 222 | Config cfg(*it,Config::File); |
222 | cfg.setGroup("Info"); | 223 | cfg.setGroup("Info"); |
223 | QString type = cfg.readEntry("Type"); | 224 | QString type = cfg.readEntry("Type"); |
224 | NetworkInterface* plugin = Network::loadPlugin(type); | 225 | NetworkInterface* plugin = Network::loadPlugin(type); |
225 | cfg.setGroup("Properties"); | 226 | cfg.setGroup("Properties"); |
226 | if ( plugin ) { | 227 | if ( plugin ) { |
227 | if ( plugin->isActive(cfg) ) { | 228 | if ( plugin->isActive(cfg) ) { |
228 | up = TRUE; | 229 | up = TRUE; |
229 | if ( firstStart ) | 230 | if ( firstStart ) |
230 | plugin->start( cfg ); | 231 | plugin->start( cfg ); |
231 | } | 232 | } |
232 | if ( plugin->isAvailable(cfg) ) | 233 | if ( plugin->isAvailable(cfg) ) |
233 | available.append(*it); | 234 | available.append(*it); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | // Try to work around unreproducible bug whereby | 238 | // Try to work around unreproducible bug whereby |
238 | // the netmon applet shows wrong state. | 239 | // the netmon applet shows wrong state. |
239 | bool reannounce = wait<0; | 240 | bool reannounce = wait<0; |
240 | 241 | ||
241 | if ( available != pavailable || reannounce ) { | 242 | if ( available != pavailable || reannounce ) { |
242 | QCopEnvelope e("QPE/Network", "available(QStringList)"); | 243 | QCopEnvelope e("QPE/Network", "available(QStringList)"); |
243 | e << available; | 244 | e << available; |
244 | } | 245 | } |
245 | if ( up != wasup || reannounce ) { | 246 | if ( up != wasup || reannounce ) { |
246 | QCopEnvelope("QPE/Network", up ? "up()" : "down()"); | 247 | QCopEnvelope("QPE/Network", up ? "up()" : "down()"); |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | void start( const QString& file, const QString& password ) | 251 | void start( const QString& file, const QString& password ) |
251 | { | 252 | { |
252 | if ( !current.isEmpty() ) | 253 | if ( !current.isEmpty() ) |
253 | stop(); | 254 | stop(); |
254 | current = QString::null; | 255 | current = QString::null; |
255 | Config cfg(file, Config::File); | 256 | Config cfg(file, Config::File); |
256 | cfg.setGroup("Info"); | 257 | cfg.setGroup("Info"); |
257 | QString type = cfg.readEntry("Type"); | 258 | QString type = cfg.readEntry("Type"); |
258 | NetworkInterface* plugin = Network::loadPlugin(type); | 259 | NetworkInterface* plugin = Network::loadPlugin(type); |
259 | bool started = FALSE; | 260 | bool started = FALSE; |
260 | if ( plugin ) { | 261 | if ( plugin ) { |
261 | cfg.setGroup("Properties"); | 262 | cfg.setGroup("Properties"); |
262 | if ( plugin->start(cfg,password) ) { | 263 | if ( plugin->start(cfg,password) ) { |
263 | Network::writeProxySettings( cfg ); | 264 | Network::writeProxySettings( cfg ); |
264 | current = file; | 265 | current = file; |
265 | wait=0; | 266 | wait=0; |
266 | startTimer(400); | 267 | startTimer(400); |
267 | started = TRUE; | 268 | started = TRUE; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | if ( !started ) { | 271 | if ( !started ) { |
271 | QCopEnvelope("QPE/Network", "failed()"); | 272 | QCopEnvelope("QPE/Network", "failed()"); |
272 | } | 273 | } |
273 | } | 274 | } |
274 | 275 | ||
275 | void stop() | 276 | void stop() |
276 | { | 277 | { |
277 | bool stopped = FALSE; | 278 | bool stopped = FALSE; |
278 | if ( !current.isEmpty() ) { | 279 | if ( !current.isEmpty() ) { |
279 | Config cfg(current, Config::File); | 280 | Config cfg(current, Config::File); |
280 | cfg.setGroup("Info"); | 281 | cfg.setGroup("Info"); |
281 | QString type = cfg.readEntry("Type"); | 282 | QString type = cfg.readEntry("Type"); |
282 | NetworkInterface* plugin = Network::loadPlugin(type); | 283 | NetworkInterface* plugin = Network::loadPlugin(type); |
283 | if ( plugin ) { | 284 | if ( plugin ) { |
284 | cfg.setGroup("Properties"); | 285 | cfg.setGroup("Properties"); |
285 | if ( plugin->stop(cfg) ) { | 286 | if ( plugin->stop(cfg) ) { |
286 | current = QString::null; | 287 | current = QString::null; |
287 | wait=0; | 288 | wait=0; |
288 | startTimer(400); | 289 | startTimer(400); |
289 | stopped = TRUE; | 290 | stopped = TRUE; |
290 | } | 291 | } |
291 | } | 292 | } |
292 | } | 293 | } |
293 | if ( !stopped ) { | 294 | if ( !stopped ) { |
294 | QCopEnvelope("QPE/Network", "failed()"); | 295 | QCopEnvelope("QPE/Network", "failed()"); |
295 | } | 296 | } |
296 | } | 297 | } |
297 | 298 | ||
298 | void timerEvent(QTimerEvent*) | 299 | void timerEvent(QTimerEvent*) |
299 | { | 300 | { |
300 | examineNetworks(); | 301 | examineNetworks(); |
301 | if ( wait >= 0 ) { | 302 | if ( wait >= 0 ) { |
302 | if ( up == !current.isNull() ) { | 303 | if ( up == !current.isNull() ) { |
303 | // done | 304 | // done |
304 | killTimers(); | 305 | killTimers(); |
305 | if ( up ) { | 306 | if ( up ) { |
306 | startTimer(3000); // monitor link | 307 | startTimer(3000); // monitor link |
307 | wait = -1; | 308 | wait = -1; |
308 | } | 309 | } |
309 | } else { | 310 | } else { |
310 | wait++; | 311 | wait++; |
311 | if ( wait == 600 ) { | 312 | if ( wait == 600 ) { |
312 | killTimers(); // forget about it after 240 s | 313 | killTimers(); // forget about it after 240 s |
313 | QCopEnvelope("QPE/Network", "failed()"); | 314 | QCopEnvelope("QPE/Network", "failed()"); |
314 | up = !current.isNull(); | 315 | up = !current.isNull(); |
315 | } | 316 | } |
316 | } | 317 | } |
317 | } else if ( !up ) { | 318 | } else if ( !up ) { |
318 | killTimers(); | 319 | killTimers(); |
319 | } | 320 | } |
320 | } | 321 | } |
321 | 322 | ||
322 | private: | 323 | private: |
323 | QStringList available; | 324 | QStringList available; |
324 | QString current; | 325 | QString current; |
325 | bool up; | 326 | bool up; |
326 | int wait; | 327 | int wait; |
327 | }; | 328 | }; |
328 | 329 | ||
329 | static NetworkServer* ns=0; | 330 | static NetworkServer* ns=0; |
330 | 331 | ||
331 | /*! | 332 | /*! |
332 | \internal | 333 | \internal |
333 | */ | 334 | */ |
334 | QString Network::serviceName(const QString& service) | 335 | QString Network::serviceName(const QString& service) |
335 | { | 336 | { |
336 | Config cfg(service, Config::File); | 337 | Config cfg(service, Config::File); |
337 | cfg.setGroup("Info"); | 338 | cfg.setGroup("Info"); |
338 | return cfg.readEntry("Name"); | 339 | return cfg.readEntry("Name"); |
339 | } | 340 | } |
340 | 341 | ||
341 | /*! | 342 | /*! |
342 | \internal | 343 | \internal |
343 | */ | 344 | */ |
344 | QString Network::serviceType(const QString& service) | 345 | QString Network::serviceType(const QString& service) |
345 | { | 346 | { |
346 | Config cfg(service, Config::File); | 347 | Config cfg(service, Config::File); |
347 | cfg.setGroup("Info"); | 348 | cfg.setGroup("Info"); |
348 | return cfg.readEntry("Type"); | 349 | return cfg.readEntry("Type"); |
349 | } | 350 | } |
350 | 351 | ||
351 | /*! | 352 | /*! |
352 | \internal | 353 | \internal |
353 | */ | 354 | */ |
354 | bool Network::serviceNeedsPassword(const QString& service) | 355 | bool Network::serviceNeedsPassword(const QString& service) |
355 | { | 356 | { |
356 | Config cfg(service,Config::File); | 357 | Config cfg(service,Config::File); |
357 | cfg.setGroup("Info"); | 358 | cfg.setGroup("Info"); |
358 | QString type = cfg.readEntry("Type"); | 359 | QString type = cfg.readEntry("Type"); |
359 | NetworkInterface* plugin = Network::loadPlugin(type); | 360 | NetworkInterface* plugin = Network::loadPlugin(type); |
360 | cfg.setGroup("Properties"); | 361 | cfg.setGroup("Properties"); |
361 | return plugin ? plugin->needPassword(cfg) : FALSE; | 362 | return plugin ? plugin->needPassword(cfg) : FALSE; |
362 | } | 363 | } |
363 | 364 | ||
364 | /*! | 365 | /*! |
365 | \internal | 366 | \internal |
366 | */ | 367 | */ |
367 | bool Network::networkOnline() | 368 | bool Network::networkOnline() |
368 | { | 369 | { |
369 | return ns && ns->networkOnline(); | 370 | return ns && ns->networkOnline(); |
370 | } | 371 | } |
371 | 372 | ||
372 | /*! | 373 | /*! |
373 | \internal | 374 | \internal |
374 | */ | 375 | */ |
375 | void Network::createServer(QObject* parent) | 376 | void Network::createServer(QObject* parent) |
376 | { | 377 | { |
377 | ns = new NetworkServer(parent); | 378 | ns = new NetworkServer(parent); |
378 | } | 379 | } |
379 | 380 | ||
380 | /*! | 381 | /*! |
381 | \internal | 382 | \internal |
382 | */ | 383 | */ |
383 | int Network::addStateWidgets(QWidget* parent) | 384 | int Network::addStateWidgets(QWidget* parent) |
384 | { | 385 | { |
385 | int n=0; | 386 | int n=0; |
386 | QStringList l = Network::choices(); | 387 | QStringList l = Network::choices(); |
387 | QVBoxLayout* vb = new QVBoxLayout(parent); | 388 | QVBoxLayout* vb = new QVBoxLayout(parent); |
388 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 389 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
389 | Config cfg(*it,Config::File); | 390 | Config cfg(*it,Config::File); |
390 | cfg.setGroup("Info"); | 391 | cfg.setGroup("Info"); |
391 | QString type = cfg.readEntry("Type"); | 392 | QString type = cfg.readEntry("Type"); |
392 | NetworkInterface* plugin = Network::loadPlugin(type); | 393 | NetworkInterface* plugin = Network::loadPlugin(type); |
393 | cfg.setGroup("Properties"); | 394 | cfg.setGroup("Properties"); |
394 | if ( plugin ) { | 395 | if ( plugin ) { |
395 | QWidget* w; | 396 | QWidget* w; |
396 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { | 397 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { |
397 | n++; | 398 | n++; |
398 | vb->addWidget(w); | 399 | vb->addWidget(w); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | } | 402 | } |
402 | return n; | 403 | return n; |
403 | } | 404 | } |
404 | 405 | ||
405 | static QDict<NetworkInterface> *ifaces; | 406 | static QDict<NetworkInterface> *ifaces; |
406 | 407 | ||
407 | /*! | 408 | /*! |
408 | \internal | 409 | \internal |
409 | */ | 410 | */ |
410 | NetworkInterface* Network::loadPlugin(const QString& type) | 411 | NetworkInterface* Network::loadPlugin(const QString& type) |
411 | { | 412 | { |
412 | #ifndef QT_NO_COMPONENT | 413 | #ifndef QT_NO_COMPONENT |
413 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; | 414 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; |
414 | NetworkInterface *iface = ifaces->find(type); | 415 | NetworkInterface *iface = ifaces->find(type); |
415 | if ( !iface ) { | 416 | if ( !iface ) { |
416 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; | 417 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; |
417 | QLibrary lib(libfile); | 418 | QLibrary lib(libfile); |
418 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) | 419 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) |
419 | return 0; | 420 | return 0; |
420 | ifaces->insert(type,iface); | 421 | ifaces->insert(type,iface); |
421 | QString lang = getenv( "LANG" ); | 422 | QStringList langs = Global::languageList(); |
422 | QTranslator * trans = new QTranslator(qApp); | 423 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
423 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; | 424 | QString lang = *it; |
424 | if ( trans->load( tfn )) | 425 | QTranslator * trans = new QTranslator(qApp); |
425 | qApp->installTranslator( trans ); | 426 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; |
426 | else | 427 | if ( trans->load( tfn )) |
427 | delete trans; | 428 | qApp->installTranslator( trans ); |
428 | 429 | else | |
430 | delete trans; | ||
431 | } | ||
429 | } | 432 | } |
430 | return iface; | 433 | return iface; |
431 | #else | 434 | #else |
432 | return 0; | 435 | return 0; |
433 | #endif | 436 | #endif |
434 | } | 437 | } |
435 | 438 | ||
436 | #include "network.moc" | 439 | #include "network.moc" |
diff --git a/library/power.cpp b/library/power.cpp index 990ff62..12b52ed 100644 --- a/library/power.cpp +++ b/library/power.cpp | |||
@@ -1,226 +1,228 @@ | |||
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 "power.h" | 21 | #include "power.h" |
22 | 22 | ||
23 | #ifdef QT_QWS_CUSTOM | 23 | #ifdef QT_QWS_CUSTOM |
24 | #include "custom.h" | 24 | #include "custom.h" |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | #include <fcntl.h> | 30 | #include <fcntl.h> |
31 | #include <sys/ioctl.h> | 31 | #include <sys/ioctl.h> |
32 | 32 | ||
33 | #ifdef QT_QWS_IPAQ_NO_APM | 33 | #ifdef QT_QWS_IPAQ_NO_APM |
34 | #include <linux/h3600_ts.h> | 34 | #include <linux/h3600_ts.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | PowerStatusManager *PowerStatusManager::powerManager = 0; | 37 | PowerStatusManager *PowerStatusManager::powerManager = 0; |
38 | PowerStatus *PowerStatusManager::ps = 0; | 38 | PowerStatus *PowerStatusManager::ps = 0; |
39 | 39 | ||
40 | static bool haveProcApm = false; | 40 | static bool haveProcApm = false; |
41 | 41 | ||
42 | PowerStatusManager::PowerStatusManager() | 42 | PowerStatusManager::PowerStatusManager() |
43 | { | 43 | { |
44 | powerManager = this; | 44 | powerManager = this; |
45 | ps = new PowerStatus; | 45 | ps = new PowerStatus; |
46 | FILE *f = fopen("/proc/apm", "r"); | 46 | FILE *f = fopen("/proc/apm", "r"); |
47 | if ( f ) { | 47 | if ( f ) { |
48 | fclose(f); | 48 | fclose(f); |
49 | haveProcApm = TRUE; | 49 | haveProcApm = TRUE; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | const PowerStatus &PowerStatusManager::readStatus() | 53 | const PowerStatus &PowerStatusManager::readStatus() |
54 | { | 54 | { |
55 | if ( !powerManager ) | 55 | if ( !powerManager ) |
56 | (void)new PowerStatusManager; | 56 | (void)new PowerStatusManager; |
57 | 57 | ||
58 | powerManager->getStatus(); | 58 | powerManager->getStatus(); |
59 | 59 | ||
60 | return *ps; | 60 | return *ps; |
61 | } | 61 | } |
62 | 62 | ||
63 | // Standard /proc/apm reader | 63 | // Standard /proc/apm reader |
64 | bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) | 64 | bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) |
65 | { | 65 | { |
66 | bool ok = false; | 66 | bool ok = false; |
67 | 67 | ||
68 | ac = 0xff; | 68 | ac = 0xff; |
69 | bs = 0xff; | 69 | bs = 0xff; |
70 | bf = 0xff; | 70 | bf = 0xff; |
71 | pc = -1; | 71 | pc = -1; |
72 | sec = -1; | 72 | sec = -1; |
73 | 73 | ||
74 | FILE *f = fopen("/proc/apm", "r"); | 74 | FILE *f = fopen("/proc/apm", "r"); |
75 | if ( f ) { | 75 | if ( f ) { |
76 | //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec | 76 | //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec |
77 | char u; | 77 | char u; |
78 | fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", | 78 | fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", |
79 | &ac, &bs, &bf, &pc, &sec, &u); | 79 | &ac, &bs, &bf, &pc, &sec, &u); |
80 | fclose(f); | 80 | fclose(f); |
81 | switch ( u ) { | 81 | switch ( u ) { |
82 | case 'm': sec *= 60; | 82 | case 'm': sec *= 60; |
83 | case 's': break; // ok | 83 | case 's': break; // ok |
84 | default: sec = -1; // unknown | 84 | default: sec = -1; // unknown |
85 | } | 85 | } |
86 | 86 | ||
87 | // extract data | 87 | // extract data |
88 | switch ( bs ) { | 88 | switch ( bs ) { |
89 | case 0x00: | 89 | case 0x00: |
90 | ps->bs = PowerStatus::High; | 90 | ps->bs = PowerStatus::High; |
91 | break; | 91 | break; |
92 | case 0x01: | 92 | case 0x01: |
93 | ps->bs = PowerStatus::Low; | 93 | ps->bs = PowerStatus::Low; |
94 | break; | 94 | break; |
95 | case 0x7f: | 95 | case 0x7f: |
96 | ps->bs = PowerStatus::VeryLow; | 96 | ps->bs = PowerStatus::VeryLow; |
97 | break; | 97 | break; |
98 | case 0x02: | 98 | case 0x02: |
99 | ps->bs = PowerStatus::Critical; | 99 | ps->bs = PowerStatus::Critical; |
100 | break; | 100 | break; |
101 | case 0x03: | 101 | case 0x03: |
102 | ps->bs = PowerStatus::Charging; | 102 | ps->bs = PowerStatus::Charging; |
103 | break; | 103 | break; |
104 | case 0x04: | 104 | case 0x04: |
105 | case 0xff: // 0xff is Unknown but we map to NotPresent | ||
106 | default: | ||
105 | ps->bs = PowerStatus::NotPresent; | 107 | ps->bs = PowerStatus::NotPresent; |
106 | break; | 108 | break; |
107 | } | 109 | } |
108 | 110 | ||
109 | switch ( ac ) { | 111 | switch ( ac ) { |
110 | case 0x00: | 112 | case 0x00: |
111 | ps->ac = PowerStatus::Offline; | 113 | ps->ac = PowerStatus::Offline; |
112 | break; | 114 | break; |
113 | case 0x01: | 115 | case 0x01: |
114 | ps->ac = PowerStatus::Online; | 116 | ps->ac = PowerStatus::Online; |
115 | break; | 117 | break; |
116 | case 0x02: | 118 | case 0x02: |
117 | ps->ac = PowerStatus::Backup; | 119 | ps->ac = PowerStatus::Backup; |
118 | break; | 120 | break; |
119 | } | 121 | } |
120 | 122 | ||
121 | if ( pc > 100 ) | 123 | if ( pc > 100 ) |
122 | pc = -1; | 124 | pc = -1; |
123 | 125 | ||
124 | ps->percentRemain = pc; | 126 | ps->percentRemain = pc; |
125 | ps->secsRemain = sec; | 127 | ps->secsRemain = sec; |
126 | 128 | ||
127 | ok = true; | 129 | ok = true; |
128 | } | 130 | } |
129 | 131 | ||
130 | return ok; | 132 | return ok; |
131 | } | 133 | } |
132 | 134 | ||
133 | #ifdef QT_QWS_CUSTOM | 135 | #ifdef QT_QWS_CUSTOM |
134 | 136 | ||
135 | void PowerStatusManager::getStatus() | 137 | void PowerStatusManager::getStatus() |
136 | { | 138 | { |
137 | int ac, bs, bf, pc, sec; | 139 | int ac, bs, bf, pc, sec; |
138 | ps->percentAccurate = TRUE; // not for long... | 140 | ps->percentAccurate = TRUE; // not for long... |
139 | 141 | ||
140 | if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { | 142 | if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { |
141 | // special case | 143 | // special case |
142 | if ( bs == 0x7f ) | 144 | if ( bs == 0x7f ) |
143 | ps->bs = PowerStatus::VeryLow; | 145 | ps->bs = PowerStatus::VeryLow; |
144 | pc = -1; // fake percentage | 146 | pc = -1; // fake percentage |
145 | if ( pc < 0 ) { | 147 | if ( pc < 0 ) { |
146 | switch ( bs ) { | 148 | switch ( bs ) { |
147 | case 0x00: ps->percentRemain = 100; break; // High | 149 | case 0x00: ps->percentRemain = 100; break; // High |
148 | case 0x01: ps->percentRemain = 30; break; // Low | 150 | case 0x01: ps->percentRemain = 30; break; // Low |
149 | case 0x7f: ps->percentRemain = 10; break; // Very Low | 151 | case 0x7f: ps->percentRemain = 10; break; // Very Low |
150 | case 0x02: ps->percentRemain = 5; break; // Critical | 152 | case 0x02: ps->percentRemain = 5; break; // Critical |
151 | case 0x03: ps->percentRemain = -1; break; // Charging | 153 | case 0x03: ps->percentRemain = -1; break; // Charging |
152 | } | 154 | } |
153 | ps->percentAccurate = FALSE; | 155 | ps->percentAccurate = FALSE; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | char *device = "/dev/apm_bios"; | 159 | char *device = "/dev/apm_bios"; |
158 | int fd = ::open (device, O_WRONLY); | 160 | int fd = ::open (device, O_WRONLY); |
159 | if ( fd >= 0 ) { | 161 | if ( fd >= 0 ) { |
160 | int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); | 162 | int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); |
161 | switch ( bbat_status ) { | 163 | switch ( bbat_status ) { |
162 | case 0x00: | 164 | case 0x00: |
163 | ps->bbs = PowerStatus::High; | 165 | ps->bbs = PowerStatus::High; |
164 | break; | 166 | break; |
165 | case 0x01: | 167 | case 0x01: |
166 | ps->bbs = PowerStatus::Low; | 168 | ps->bbs = PowerStatus::Low; |
167 | break; | 169 | break; |
168 | case 0x7f: | 170 | case 0x7f: |
169 | ps->bbs = PowerStatus::VeryLow; | 171 | ps->bbs = PowerStatus::VeryLow; |
170 | break; | 172 | break; |
171 | case 0x02: | 173 | case 0x02: |
172 | ps->bbs = PowerStatus::Critical; | 174 | ps->bbs = PowerStatus::Critical; |
173 | break; | 175 | break; |
174 | case 0x03: | 176 | case 0x03: |
175 | ps->bbs = PowerStatus::Charging; | 177 | ps->bbs = PowerStatus::Charging; |
176 | break; | 178 | break; |
177 | case 0x04: | 179 | case 0x04: |
178 | ps->bbs = PowerStatus::NotPresent; | 180 | ps->bbs = PowerStatus::NotPresent; |
179 | break; | 181 | break; |
180 | } | 182 | } |
181 | ::close(fd); | 183 | ::close(fd); |
182 | } | 184 | } |
183 | } | 185 | } |
184 | 186 | ||
185 | #else | 187 | #else |
186 | 188 | ||
187 | void PowerStatusManager::getStatus() | 189 | void PowerStatusManager::getStatus() |
188 | { | 190 | { |
189 | bool usedApm = FALSE; | 191 | bool usedApm = FALSE; |
190 | 192 | ||
191 | ps->percentAccurate = TRUE; | 193 | ps->percentAccurate = TRUE; |
192 | 194 | ||
193 | // Some iPAQ kernel builds don't have APM. If this is not the case we | 195 | // Some iPAQ kernel builds don't have APM. If this is not the case we |
194 | // save ourselves an ioctl by testing if /proc/apm exists in the | 196 | // save ourselves an ioctl by testing if /proc/apm exists in the |
195 | // constructor and we use /proc/apm instead | 197 | // constructor and we use /proc/apm instead |
196 | int ac, bs, bf, pc, sec; | 198 | int ac, bs, bf, pc, sec; |
197 | if ( haveProcApm ) | 199 | if ( haveProcApm ) |
198 | usedApm = getProcApmStatus( ac, bs, bf, pc, sec ); | 200 | usedApm = getProcApmStatus( ac, bs, bf, pc, sec ); |
199 | 201 | ||
200 | if ( !usedApm ) { | 202 | if ( !usedApm ) { |
201 | #ifdef QT_QWS_IPAQ_NO_APM | 203 | #ifdef QT_QWS_IPAQ_NO_APM |
202 | int fd; | 204 | int fd; |
203 | int err; | 205 | int err; |
204 | struct bat_dev batt_info; | 206 | struct bat_dev batt_info; |
205 | 207 | ||
206 | memset(&batt_info, 0, sizeof(batt_info)); | 208 | memset(&batt_info, 0, sizeof(batt_info)); |
207 | 209 | ||
208 | fd = ::open("/dev/ts",O_RDONLY); | 210 | fd = ::open("/dev/ts",O_RDONLY); |
209 | if( fd < 0 ) | 211 | if( fd < 0 ) |
210 | return; | 212 | return; |
211 | 213 | ||
212 | ioctl(fd, GET_BATTERY_STATUS, &batt_info); | 214 | ioctl(fd, GET_BATTERY_STATUS, &batt_info); |
213 | ac_status = batt_info.ac_status; | 215 | ac_status = batt_info.ac_status; |
214 | ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c | 216 | ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c |
215 | ps->secsRemain = -1; // seconds is bogus on iPAQ | 217 | ps->secsRemain = -1; // seconds is bogus on iPAQ |
216 | ::close (fd); | 218 | ::close (fd); |
217 | #else | 219 | #else |
218 | ps->percentRemain = 100; | 220 | ps->percentRemain = 100; |
219 | ps->secsRemain = -1; | 221 | ps->secsRemain = -1; |
220 | ps->percentAccurate = FALSE; | 222 | ps->percentAccurate = FALSE; |
221 | #endif | 223 | #endif |
222 | } | 224 | } |
223 | } | 225 | } |
224 | 226 | ||
225 | #endif | 227 | #endif |
226 | 228 | ||
diff --git a/library/qcopmessage_qws.h b/library/qcopmessage_qws.h deleted file mode 100644 index c19f57d..0000000 --- a/library/qcopmessage_qws.h +++ b/dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef QCOP_MESSAGE_H | ||
22 | #define QCOP_MESSAGE_H | ||
23 | |||
24 | #include <qdatastream.h> | ||
25 | #include <qbuffer.h> | ||
26 | |||
27 | class QCopMessage : public QDataStream { | ||
28 | public: | ||
29 | QCopMessage(); | ||
30 | QCopMessage(const QCString& channel, const QCString& message); | ||
31 | QCopMessage(const QCopMessage& orig); | ||
32 | ~QCopMessage(); | ||
33 | |||
34 | void setChannel(QCString& channel) { m_Channel = channel; } | ||
35 | QCString channel() const { return m_Channel; } | ||
36 | void setMessage(QCString& message) { m_Message = message; } | ||
37 | QCString message() const { return m_Message; } | ||
38 | const QByteArray data() const; | ||
39 | |||
40 | QCopMessage& operator=(const QCopMessage& orig); | ||
41 | |||
42 | private: | ||
43 | QCString m_Channel; | ||
44 | QCString m_Message; | ||
45 | }; | ||
46 | |||
47 | // ### No need to inline, just maintaining binary compatability | ||
48 | inline QCopMessage::QCopMessage() : QDataStream(new QBuffer()) { | ||
49 | device()->open(IO_WriteOnly); | ||
50 | } | ||
51 | |||
52 | inline QCopMessage::QCopMessage(const QCString& channel, const QCString& message) | ||
53 | : QDataStream(new QBuffer()), m_Channel(channel), m_Message(message) { | ||
54 | device()->open(IO_WriteOnly); | ||
55 | } | ||
56 | |||
57 | inline QCopMessage::QCopMessage(const QCopMessage& orig) : QDataStream() { | ||
58 | // The QBuffer is going to share the byte array, so it will keep the | ||
59 | // data pointer even when this one goes out of scope. | ||
60 | QByteArray array(((QBuffer*)orig.device())->buffer()); | ||
61 | array.detach(); | ||
62 | setDevice(new QBuffer(array)); | ||
63 | device()->open(IO_Append); | ||
64 | |||
65 | m_Channel = orig.channel(); | ||
66 | m_Message = orig.message(); | ||
67 | } | ||
68 | |||
69 | inline QCopMessage& QCopMessage::operator=(const QCopMessage& orig) { | ||
70 | if (device()) { | ||
71 | delete device(); | ||
72 | unsetDevice(); | ||
73 | } | ||
74 | |||
75 | // The QBuffer is going to share the byte array, so it will keep the | ||
76 | // data pointer even when this one goes out of scope. | ||
77 | QByteArray array(((QBuffer*)orig.device())->buffer()); | ||
78 | array.detach(); | ||
79 | setDevice(new QBuffer(array)); | ||
80 | device()->open(IO_Append); | ||
81 | |||
82 | m_Channel = orig.channel(); | ||
83 | m_Message = orig.message(); | ||
84 | |||
85 | return *this; | ||
86 | } | ||
87 | |||
88 | inline const QByteArray QCopMessage::data() const { | ||
89 | return ((QBuffer*)device())->buffer(); | ||
90 | } | ||
91 | |||
92 | inline QCopMessage::~QCopMessage() { | ||
93 | // If we still have our QBuffer, clean it up... | ||
94 | if (device()) | ||
95 | delete device(); | ||
96 | unsetDevice(); | ||
97 | } | ||
98 | |||
99 | #endif | ||
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index b6085ef..e041945 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -1,639 +1,640 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | ||
20 | #include <qapplication.h> | 21 | #include <qapplication.h> |
21 | #include <qstyle.h> | 22 | #include <qstyle.h> |
22 | #include <qwidget.h> | 23 | #include <qwidget.h> |
23 | #include <qpainter.h> | 24 | #include <qpainter.h> |
24 | #include <qtimer.h> | 25 | #include <qtimer.h> |
25 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
26 | #include "qcopenvelope_qws.h" | 27 | #include "qcopenvelope_qws.h" |
27 | #include "qpedecoration_qws.h" | 28 | #include "qpedecoration_qws.h" |
28 | #include <qdialog.h> | 29 | #include <qdialog.h> |
29 | #include <qdrawutil.h> | 30 | #include <qdrawutil.h> |
30 | #include <qgfx_qws.h> | 31 | #include <qgfx_qws.h> |
31 | #include "qpeapplication.h" | 32 | #include "qpeapplication.h" |
32 | #include "resource.h" | 33 | #include "resource.h" |
33 | #include "global.h" | 34 | #include "global.h" |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qsignal.h> | 36 | #include <qsignal.h> |
36 | 37 | ||
37 | #include <stdlib.h> | 38 | #include <stdlib.h> |
38 | 39 | ||
39 | extern QRect qt_maxWindowRect; | 40 | extern QRect qt_maxWindowRect; |
40 | 41 | ||
41 | //#define MINIMIZE_HELP_HACK // use minimize button when not a dialog | 42 | //#define MINIMIZE_HELP_HACK // use minimize button when not a dialog |
42 | 43 | ||
43 | //#define WHATSTHIS_MODE | 44 | //#define WHATSTHIS_MODE |
44 | 45 | ||
45 | #ifndef QT_NO_QWS_QPE_WM_STYLE | 46 | #ifndef QT_NO_QWS_QPE_WM_STYLE |
46 | 47 | ||
47 | #ifndef QT_NO_IMAGEIO_XPM | 48 | #ifndef QT_NO_IMAGEIO_XPM |
48 | 49 | ||
49 | /* XPM */ | 50 | /* XPM */ |
50 | static const char * const qpe_close_xpm[] = { | 51 | static const char * const qpe_close_xpm[] = { |
51 | "16 16 3 1", | 52 | "16 16 3 1", |
52 | " c None", | 53 | " c None", |
53 | ". c #FFFFFF", | 54 | ". c #FFFFFF", |
54 | "+ c #000000", | 55 | "+ c #000000", |
55 | " ", | 56 | " ", |
56 | " ", | 57 | " ", |
57 | " ..... ", | 58 | " ..... ", |
58 | " ..+++++.. ", | 59 | " ..+++++.. ", |
59 | " .+++++++++. ", | 60 | " .+++++++++. ", |
60 | " .+..+++..+. ", | 61 | " .+..+++..+. ", |
61 | " .++...+...++. ", | 62 | " .++...+...++. ", |
62 | " .+++.....+++. ", | 63 | " .+++.....+++. ", |
63 | " .++++...++++. ", | 64 | " .++++...++++. ", |
64 | " .+++.....+++. ", | 65 | " .+++.....+++. ", |
65 | " .++...+...++. ", | 66 | " .++...+...++. ", |
66 | " .+..+++..+. ", | 67 | " .+..+++..+. ", |
67 | " .+++++++++. ", | 68 | " .+++++++++. ", |
68 | " ..+++++.. ", | 69 | " ..+++++.. ", |
69 | " ..... ", | 70 | " ..... ", |
70 | " "}; | 71 | " "}; |
71 | 72 | ||
72 | /* XPM */ | 73 | /* XPM */ |
73 | static const char * const qpe_accept_xpm[] = { | 74 | static const char * const qpe_accept_xpm[] = { |
74 | "16 16 3 1", | 75 | "16 16 3 1", |
75 | " c None", | 76 | " c None", |
76 | ". c #FFFFFF", | 77 | ". c #FFFFFF", |
77 | "+ c #000000", | 78 | "+ c #000000", |
78 | " ", | 79 | " ", |
79 | " ", | 80 | " ", |
80 | " ..... ", | 81 | " ..... ", |
81 | " ..+++++.. ", | 82 | " ..+++++.. ", |
82 | " .+++++++++. ", | 83 | " .+++++++++. ", |
83 | " .+++++++++. ", | 84 | " .+++++++++. ", |
84 | " .+++++++..++. ", | 85 | " .+++++++..++. ", |
85 | " .++.+++...++. ", | 86 | " .++.+++...++. ", |
86 | " .+...+...+++. ", | 87 | " .+...+...+++. ", |
87 | " .+......++++. ", | 88 | " .+......++++. ", |
88 | " .++....+++++. ", | 89 | " .++....+++++. ", |
89 | " .++..+++++. ", | 90 | " .++..+++++. ", |
90 | " .+++++++++. ", | 91 | " .+++++++++. ", |
91 | " ..+++++.. ", | 92 | " ..+++++.. ", |
92 | " ..... ", | 93 | " ..... ", |
93 | " "}; | 94 | " "}; |
94 | 95 | ||
95 | #endif // QT_NO_IMAGEIO_XPM | 96 | #endif // QT_NO_IMAGEIO_XPM |
96 | 97 | ||
97 | class TLWidget : public QWidget | 98 | class TLWidget : public QWidget |
98 | { | 99 | { |
99 | public: | 100 | public: |
100 | QWSManager *manager() | 101 | QWSManager *manager() |
101 | { | 102 | { |
102 | return topData()->qwsManager; | 103 | return topData()->qwsManager; |
103 | } | 104 | } |
104 | 105 | ||
105 | QTLWExtra *topExtra() | 106 | QTLWExtra *topExtra() |
106 | { | 107 | { |
107 | return topData(); | 108 | return topData(); |
108 | } | 109 | } |
109 | }; | 110 | }; |
110 | 111 | ||
111 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) | 112 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) |
112 | : QObject( parent ), decoration( d ), helpState(0) | 113 | : QObject( parent ), decoration( d ), helpState(0) |
113 | { | 114 | { |
114 | wtTimer = new QTimer( this ); | 115 | wtTimer = new QTimer( this ); |
115 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); | 116 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
119 | void QPEManager::updateActive() | 120 | void QPEManager::updateActive() |
120 | { | 121 | { |
121 | QWidget *newActive = qApp->activeWindow(); | 122 | QWidget *newActive = qApp->activeWindow(); |
122 | if ( (QWidget*)active == newActive ) | 123 | if ( (QWidget*)active == newActive ) |
123 | return; | 124 | return; |
124 | 125 | ||
125 | if ( active ) { | 126 | if ( active ) { |
126 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); | 127 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); |
127 | } | 128 | } |
128 | 129 | ||
129 | if ( newActive && ((TLWidget *)newActive)->manager() ) { | 130 | if ( newActive && ((TLWidget *)newActive)->manager() ) { |
130 | active = newActive; | 131 | active = newActive; |
131 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); | 132 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); |
132 | } else { | 133 | } else { |
133 | active = 0; | 134 | active = 0; |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) | 138 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) |
138 | { | 139 | { |
139 | if ( decoration->region( w, w->geometry(), | 140 | if ( decoration->region( w, w->geometry(), |
140 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) { | 141 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) { |
141 | return QPEDecoration::Help; | 142 | return QPEDecoration::Help; |
142 | } | 143 | } |
143 | 144 | ||
144 | return QWSDecoration::None; | 145 | return QWSDecoration::None; |
145 | } | 146 | } |
146 | 147 | ||
147 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) | 148 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) |
148 | { | 149 | { |
149 | QWSManager *mgr = (QWSManager *)o; | 150 | QWSManager *mgr = (QWSManager *)o; |
150 | QWidget *w = mgr->widget(); | 151 | QWidget *w = mgr->widget(); |
151 | switch ( e->type() ) { | 152 | switch ( e->type() ) { |
152 | case QEvent::MouseButtonPress: | 153 | case QEvent::MouseButtonPress: |
153 | { | 154 | { |
154 | if ( QWhatsThis::inWhatsThisMode() ) { | 155 | if ( QWhatsThis::inWhatsThisMode() ) { |
155 | QWhatsThis::leaveWhatsThisMode(); | 156 | QWhatsThis::leaveWhatsThisMode(); |
156 | return true; | 157 | return true; |
157 | } | 158 | } |
158 | pressTime = QTime::currentTime(); | 159 | pressTime = QTime::currentTime(); |
159 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 160 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
160 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 161 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
161 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 162 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
162 | drawButton( w, QPEDecoration::Help, helpState ); | 163 | drawButton( w, QPEDecoration::Help, helpState ); |
163 | return true; | 164 | return true; |
164 | } | 165 | } |
165 | } | 166 | } |
166 | break; | 167 | break; |
167 | case QEvent::MouseButtonRelease: | 168 | case QEvent::MouseButtonRelease: |
168 | if ( helpState & QWSButton::Clicked ) { | 169 | if ( helpState & QWSButton::Clicked ) { |
169 | helpState = 0; | 170 | helpState = 0; |
170 | drawButton( w, QPEDecoration::Help, helpState ); | 171 | drawButton( w, QPEDecoration::Help, helpState ); |
171 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 172 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
172 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 173 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
173 | #ifdef WHATSTHIS_MODE | 174 | #ifdef WHATSTHIS_MODE |
174 | if ( pressTime.msecsTo( QTime::currentTime() ) > 250 ) { | 175 | if ( pressTime.msecsTo( QTime::currentTime() ) > 250 ) { |
175 | decoration->help( w ); | 176 | decoration->help( w ); |
176 | } else { | 177 | } else { |
177 | QWhatsThis::enterWhatsThisMode(); | 178 | QWhatsThis::enterWhatsThisMode(); |
178 | wtTimer->start( 200 ); | 179 | wtTimer->start( 200 ); |
179 | } | 180 | } |
180 | #else | 181 | #else |
181 | decoration->help( w ); | 182 | decoration->help( w ); |
182 | #endif | 183 | #endif |
183 | } | 184 | } |
184 | return true; | 185 | return true; |
185 | } | 186 | } |
186 | break; | 187 | break; |
187 | case QEvent::MouseMove: | 188 | case QEvent::MouseMove: |
188 | if ( helpState & QWSButton::Clicked ) { | 189 | if ( helpState & QWSButton::Clicked ) { |
189 | int oldState = helpState; | 190 | int oldState = helpState; |
190 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 191 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
191 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) | 192 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) |
192 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 193 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
193 | else | 194 | else |
194 | helpState = 0; | 195 | helpState = 0; |
195 | if ( helpState != oldState ) | 196 | if ( helpState != oldState ) |
196 | drawButton( w, QPEDecoration::Help, helpState ); | 197 | drawButton( w, QPEDecoration::Help, helpState ); |
197 | } | 198 | } |
198 | break; | 199 | break; |
199 | default: | 200 | default: |
200 | break; | 201 | break; |
201 | } | 202 | } |
202 | return QObject::eventFilter( o, e ); | 203 | return QObject::eventFilter( o, e ); |
203 | } | 204 | } |
204 | 205 | ||
205 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) | 206 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) |
206 | { | 207 | { |
207 | QPainter painter(w); | 208 | QPainter painter(w); |
208 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 209 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
209 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 210 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
210 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 211 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
211 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); | 212 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); |
212 | } | 213 | } |
213 | 214 | ||
214 | void QPEManager::whatsThisTimeout() | 215 | void QPEManager::whatsThisTimeout() |
215 | { | 216 | { |
216 | if ( !QWhatsThis::inWhatsThisMode() ) { | 217 | if ( !QWhatsThis::inWhatsThisMode() ) { |
217 | wtTimer->stop(); | 218 | wtTimer->stop(); |
218 | if ( active ) | 219 | if ( active ) |
219 | drawButton( active, QPEDecoration::Help, 0 ); | 220 | drawButton( active, QPEDecoration::Help, 0 ); |
220 | } else if ( active ) { | 221 | } else if ( active ) { |
221 | static int state = 0; | 222 | static int state = 0; |
222 | if ( !state ) | 223 | if ( !state ) |
223 | state = QWSButton::Clicked|QWSButton::MouseOver; | 224 | state = QWSButton::Clicked|QWSButton::MouseOver; |
224 | else | 225 | else |
225 | state = 0; | 226 | state = 0; |
226 | drawButton( active, QPEDecoration::Help, state ); | 227 | drawButton( active, QPEDecoration::Help, state ); |
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | //========= | 231 | //========= |
231 | 232 | ||
232 | class HackWidget : public QWidget | 233 | class HackWidget : public QWidget |
233 | { | 234 | { |
234 | public: | 235 | public: |
235 | bool needsOk() { return (getWState() & WState_Reserved1 ); } | 236 | bool needsOk() { return (getWState() & WState_Reserved1 ); } |
236 | }; | 237 | }; |
237 | 238 | ||
238 | //=========================================================================== | 239 | //=========================================================================== |
239 | 240 | ||
240 | QPEDecoration::QPEDecoration() | 241 | QPEDecoration::QPEDecoration() |
241 | : QWSDefaultDecoration() | 242 | : QWSDefaultDecoration() |
242 | { | 243 | { |
243 | imageOk = Resource::loadImage( "OKButton" ); | 244 | imageOk = Resource::loadImage( "OKButton" ); |
244 | imageClose = Resource::loadImage( "CloseButton" ); | 245 | imageClose = Resource::loadImage( "CloseButton" ); |
245 | imageHelp = Resource::loadImage( "HelpButton" ); | 246 | imageHelp = Resource::loadImage( "HelpButton" ); |
246 | helpFile = QString(qApp->argv()[0]) + ".html"; | 247 | helpFile = QString(qApp->argv()[0]) + ".html"; |
247 | QString lang = getenv( "LANG" ); | 248 | QStringList path = Global::helpPath(); |
248 | helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/" + lang + "/html/" + helpFile ); | 249 | helpExists = FALSE; |
249 | if ( !helpExists ) | 250 | for (QStringList::ConstIterator it=path.begin(); it!=path.end() && !helpExists; ++it) |
250 | helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/en/html/" + helpFile ); | 251 | helpExists = QFile::exists( *it + "/" + helpFile ); |
251 | #ifndef MINIMIZE_HELP_HACK | 252 | #ifndef MINIMIZE_HELP_HACK |
252 | qpeManager = new QPEManager( this ); | 253 | qpeManager = new QPEManager( this ); |
253 | #else | 254 | #else |
254 | qpeManager = 0; | 255 | qpeManager = 0; |
255 | #endif | 256 | #endif |
256 | } | 257 | } |
257 | 258 | ||
258 | QPEDecoration::~QPEDecoration() | 259 | QPEDecoration::~QPEDecoration() |
259 | { | 260 | { |
260 | delete qpeManager; | 261 | delete qpeManager; |
261 | } | 262 | } |
262 | 263 | ||
263 | const char **QPEDecoration::menuPixmap() | 264 | const char **QPEDecoration::menuPixmap() |
264 | { | 265 | { |
265 | return (const char **)0; | 266 | return (const char **)0; |
266 | } | 267 | } |
267 | 268 | ||
268 | const char **QPEDecoration::closePixmap() | 269 | const char **QPEDecoration::closePixmap() |
269 | { | 270 | { |
270 | return (const char **)qpe_close_xpm; | 271 | return (const char **)qpe_close_xpm; |
271 | } | 272 | } |
272 | 273 | ||
273 | const char **QPEDecoration::minimizePixmap() | 274 | const char **QPEDecoration::minimizePixmap() |
274 | { | 275 | { |
275 | return (const char **)qpe_accept_xpm; | 276 | return (const char **)qpe_accept_xpm; |
276 | } | 277 | } |
277 | 278 | ||
278 | const char **QPEDecoration::maximizePixmap() | 279 | const char **QPEDecoration::maximizePixmap() |
279 | { | 280 | { |
280 | return (const char **)0; | 281 | return (const char **)0; |
281 | } | 282 | } |
282 | 283 | ||
283 | const char **QPEDecoration::normalizePixmap() | 284 | const char **QPEDecoration::normalizePixmap() |
284 | { | 285 | { |
285 | return (const char **)0; | 286 | return (const char **)0; |
286 | } | 287 | } |
287 | 288 | ||
288 | int QPEDecoration::getTitleHeight(const QWidget *) | 289 | int QPEDecoration::getTitleHeight(const QWidget *) |
289 | { | 290 | { |
290 | return 15; | 291 | return 15; |
291 | } | 292 | } |
292 | 293 | ||
293 | /* | 294 | /* |
294 | If rect is empty, no frame is added. (a hack, really) | 295 | If rect is empty, no frame is added. (a hack, really) |
295 | */ | 296 | */ |
296 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 297 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
297 | { | 298 | { |
298 | int titleHeight = getTitleHeight(widget); | 299 | int titleHeight = getTitleHeight(widget); |
299 | // int titleWidth = getTitleWidth(widget); | 300 | // int titleWidth = getTitleWidth(widget); |
300 | // int bw = rect.isEmpty() ? 0 : BORDER_WIDTH; | 301 | // int bw = rect.isEmpty() ? 0 : BORDER_WIDTH; |
301 | QRegion region; | 302 | QRegion region; |
302 | 303 | ||
303 | #ifndef MINIMIZE_HELP_HACK | 304 | #ifndef MINIMIZE_HELP_HACK |
304 | qpeManager->updateActive(); | 305 | qpeManager->updateActive(); |
305 | #endif | 306 | #endif |
306 | 307 | ||
307 | switch ((int)type) { | 308 | switch ((int)type) { |
308 | case Menu: | 309 | case Menu: |
309 | case Maximize: | 310 | case Maximize: |
310 | break; | 311 | break; |
311 | case Minimize: { | 312 | case Minimize: { |
312 | if ( ((HackWidget *)widget)->needsOk() || | 313 | if ( ((HackWidget *)widget)->needsOk() || |
313 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { | 314 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { |
314 | QRect r(rect.right() - imageOk.width(), | 315 | QRect r(rect.right() - imageOk.width(), |
315 | rect.top() - titleHeight - 2, | 316 | rect.top() - titleHeight - 2, |
316 | imageOk.width(), titleHeight); | 317 | imageOk.width(), titleHeight); |
317 | if (r.left() > rect.left() + titleHeight) | 318 | if (r.left() > rect.left() + titleHeight) |
318 | region = r; | 319 | region = r; |
319 | } | 320 | } |
320 | #ifdef MINIMIZE_HELP_HACK | 321 | #ifdef MINIMIZE_HELP_HACK |
321 | else if ( helpExists ) { | 322 | else if ( helpExists ) { |
322 | QRect r; | 323 | QRect r; |
323 | r = QRect(rect.right() - imageClose.width() - imageHelp.width(), | 324 | r = QRect(rect.right() - imageClose.width() - imageHelp.width(), |
324 | rect.top() - titleHeight - 2, | 325 | rect.top() - titleHeight - 2, |
325 | imageHelp.width(), titleHeight); | 326 | imageHelp.width(), titleHeight); |
326 | if (r.left() > rect.left() + titleHeight) | 327 | if (r.left() > rect.left() + titleHeight) |
327 | region = r; | 328 | region = r; |
328 | } | 329 | } |
329 | #endif | 330 | #endif |
330 | } | 331 | } |
331 | break; | 332 | break; |
332 | case Close: { | 333 | case Close: { |
333 | if ( ((HackWidget *)widget)->needsOk() || | 334 | if ( ((HackWidget *)widget)->needsOk() || |
334 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { | 335 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { |
335 | QRect r; | 336 | QRect r; |
336 | r = QRect(rect.right() - imageOk.width() - imageClose.width(), | 337 | r = QRect(rect.right() - imageOk.width() - imageClose.width(), |
337 | rect.top() - titleHeight - 2, | 338 | rect.top() - titleHeight - 2, |
338 | imageClose.width(), titleHeight); | 339 | imageClose.width(), titleHeight); |
339 | if (r.left() > rect.left() + titleHeight) | 340 | if (r.left() > rect.left() + titleHeight) |
340 | region = r; | 341 | region = r; |
341 | } else { | 342 | } else { |
342 | QRect r(rect.right() - imageClose.width(), | 343 | QRect r(rect.right() - imageClose.width(), |
343 | rect.top() - titleHeight - 2, | 344 | rect.top() - titleHeight - 2, |
344 | imageClose.width(), titleHeight); | 345 | imageClose.width(), titleHeight); |
345 | if (r.left() > rect.left() + titleHeight) | 346 | if (r.left() > rect.left() + titleHeight) |
346 | region = r; | 347 | region = r; |
347 | } | 348 | } |
348 | break; | 349 | break; |
349 | } | 350 | } |
350 | case Title: { | 351 | case Title: { |
351 | if ( widget->isMaximized() ) { | 352 | if ( widget->isMaximized() ) { |
352 | region = QRegion(); | 353 | region = QRegion(); |
353 | } else { | 354 | } else { |
354 | int btnWidth = imageClose.width(); | 355 | int btnWidth = imageClose.width(); |
355 | if ( ((HackWidget *)widget)->needsOk() || | 356 | if ( ((HackWidget *)widget)->needsOk() || |
356 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) | 357 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) |
357 | btnWidth += imageOk.width(); | 358 | btnWidth += imageOk.width(); |
358 | QRect r(rect.left() + 1, rect.top() - titleHeight, | 359 | QRect r(rect.left() + 1, rect.top() - titleHeight, |
359 | rect.width() - btnWidth - 2, titleHeight); | 360 | rect.width() - btnWidth - 2, titleHeight); |
360 | if (r.width() > 0) | 361 | if (r.width() > 0) |
361 | region = r; | 362 | region = r; |
362 | } | 363 | } |
363 | break; | 364 | break; |
364 | } | 365 | } |
365 | case Help: { | 366 | case Help: { |
366 | if ( helpExists ) { | 367 | if ( helpExists ) { |
367 | QRect r; | 368 | QRect r; |
368 | int l = rect.right() - imageClose.width() - imageHelp.width(); | 369 | int l = rect.right() - imageClose.width() - imageHelp.width(); |
369 | if ( ((HackWidget *)widget)->needsOk() || | 370 | if ( ((HackWidget *)widget)->needsOk() || |
370 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) | 371 | (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) |
371 | l -= imageOk.width(); | 372 | l -= imageOk.width(); |
372 | r = QRect(l, rect.top() - titleHeight - 2, | 373 | r = QRect(l, rect.top() - titleHeight - 2, |
373 | imageHelp.width(), titleHeight); | 374 | imageHelp.width(), titleHeight); |
374 | if (r.left() > rect.left() + titleHeight) | 375 | if (r.left() > rect.left() + titleHeight) |
375 | region = r; | 376 | region = r; |
376 | } | 377 | } |
377 | break; | 378 | break; |
378 | } | 379 | } |
379 | case Top: | 380 | case Top: |
380 | case Left: | 381 | case Left: |
381 | case Right: | 382 | case Right: |
382 | case Bottom: | 383 | case Bottom: |
383 | case TopLeft: | 384 | case TopLeft: |
384 | case TopRight: | 385 | case TopRight: |
385 | case BottomLeft: | 386 | case BottomLeft: |
386 | case BottomRight: | 387 | case BottomRight: |
387 | if ( widget->isMaximized() ) { | 388 | if ( widget->isMaximized() ) { |
388 | region = QRegion(); | 389 | region = QRegion(); |
389 | break; | 390 | break; |
390 | } | 391 | } |
391 | //else fallthrough!!! | 392 | //else fallthrough!!! |
392 | case All: | 393 | case All: |
393 | default: | 394 | default: |
394 | region = QWSDefaultDecoration::region(widget, rect, type); | 395 | region = QWSDefaultDecoration::region(widget, rect, type); |
395 | break; | 396 | break; |
396 | } | 397 | } |
397 | 398 | ||
398 | return region; | 399 | return region; |
399 | } | 400 | } |
400 | 401 | ||
401 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) | 402 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) |
402 | { | 403 | { |
403 | #ifndef QT_NO_STYLE | 404 | #ifndef QT_NO_STYLE |
404 | // QStyle &style = QApplication::style(); | 405 | // QStyle &style = QApplication::style(); |
405 | #endif | 406 | #endif |
406 | 407 | ||
407 | int titleWidth = getTitleWidth(widget); | 408 | int titleWidth = getTitleWidth(widget); |
408 | int titleHeight = getTitleHeight(widget); | 409 | int titleHeight = getTitleHeight(widget); |
409 | 410 | ||
410 | QRect rect(widget->rect()); | 411 | QRect rect(widget->rect()); |
411 | 412 | ||
412 | // Border rect | 413 | // Border rect |
413 | QRect br( rect.left() - BORDER_WIDTH, | 414 | QRect br( rect.left() - BORDER_WIDTH, |
414 | rect.top() - BORDER_WIDTH - titleHeight, | 415 | rect.top() - BORDER_WIDTH - titleHeight, |
415 | rect.width() + 2 * BORDER_WIDTH, | 416 | rect.width() + 2 * BORDER_WIDTH, |
416 | rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight ); | 417 | rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight ); |
417 | 418 | ||
418 | // title bar rect | 419 | // title bar rect |
419 | QRect tr; | 420 | QRect tr; |
420 | 421 | ||
421 | tr = QRect( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 422 | tr = QRect( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
422 | 423 | ||
423 | QRegion oldClip = painter->clipRegion(); | 424 | QRegion oldClip = painter->clipRegion(); |
424 | painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker | 425 | painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker |
425 | 426 | ||
426 | #ifndef QT_NO_PALETTE | 427 | #ifndef QT_NO_PALETTE |
427 | // const QColorGroup &cg = QApplication::palette().active(); | 428 | // const QColorGroup &cg = QApplication::palette().active(); |
428 | const QColorGroup &cg = widget->palette().active(); | 429 | const QColorGroup &cg = widget->palette().active(); |
429 | 430 | ||
430 | qDrawWinPanel(painter, br.x(), br.y(), br.width(), | 431 | qDrawWinPanel(painter, br.x(), br.y(), br.width(), |
431 | br.height() - 4, cg, FALSE, | 432 | br.height() - 4, cg, FALSE, |
432 | &cg.brush(QColorGroup::Background)); | 433 | &cg.brush(QColorGroup::Background)); |
433 | 434 | ||
434 | painter->setClipRegion( oldClip ); | 435 | painter->setClipRegion( oldClip ); |
435 | 436 | ||
436 | if (titleWidth > 0) { | 437 | if (titleWidth > 0) { |
437 | QBrush titleBrush; | 438 | QBrush titleBrush; |
438 | QPen titlePen; | 439 | QPen titlePen; |
439 | QPen titleLines; | 440 | QPen titleLines; |
440 | int titleLeft = titleHeight + 4; | 441 | int titleLeft = titleHeight + 4; |
441 | 442 | ||
442 | if (widget == qApp->activeWindow()) { | 443 | if (widget == qApp->activeWindow()) { |
443 | titleBrush = cg.brush(QColorGroup::Highlight); | 444 | titleBrush = cg.brush(QColorGroup::Highlight); |
444 | titlePen = cg.color(QColorGroup::HighlightedText); | 445 | titlePen = cg.color(QColorGroup::HighlightedText); |
445 | } else { | 446 | } else { |
446 | titleBrush = cg.brush(QColorGroup::Background); | 447 | titleBrush = cg.brush(QColorGroup::Background); |
447 | titlePen = cg.color(QColorGroup::Text); | 448 | titlePen = cg.color(QColorGroup::Text); |
448 | } | 449 | } |
449 | 450 | ||
450 | titleLines = titleBrush.color().dark(150); | 451 | titleLines = titleBrush.color().dark(150); |
451 | 452 | ||
452 | #define CLAMP(x, y) ( ((x) > (y)) ? (y) : (x) ) | 453 | #define CLAMP(x, y) ( ((x) > (y)) ? (y) : (x) ) |
453 | 454 | ||
454 | titleLeft = rect.left() + 5; | 455 | titleLeft = rect.left() + 5; |
455 | painter->setPen( cg.midlight() ); | 456 | painter->setPen( cg.midlight() ); |
456 | painter->drawLine( rect.left() - BORDER_WIDTH + 2, | 457 | painter->drawLine( rect.left() - BORDER_WIDTH + 2, |
457 | rect.bottom() + 1, rect.right() + BORDER_WIDTH - 2, | 458 | rect.bottom() + 1, rect.right() + BORDER_WIDTH - 2, |
458 | rect.bottom() + 1 ); | 459 | rect.bottom() + 1 ); |
459 | 460 | ||
460 | fillTitle( painter, widget, rect.left() - 2, | 461 | fillTitle( painter, widget, rect.left() - 2, |
461 | rect.top() - titleHeight - 2, | 462 | rect.top() - titleHeight - 2, |
462 | rect.width() + 3, titleHeight + 2 ); | 463 | rect.width() + 3, titleHeight + 2 ); |
463 | /* | 464 | /* |
464 | painter->fillRect(rect.left() - 2, | 465 | painter->fillRect(rect.left() - 2, |
465 | rect.top() - titleHeight - 2, | 466 | rect.top() - titleHeight - 2, |
466 | rect.width() + 3, titleHeight + 2, | 467 | rect.width() + 3, titleHeight + 2, |
467 | titleBrush); | 468 | titleBrush); |
468 | 469 | ||
469 | painter->setPen( titleLines ); | 470 | painter->setPen( titleLines ); |
470 | for ( int i = rect.top() - titleHeight - 2; i < rect.top(); i += 2 ) | 471 | for ( int i = rect.top() - titleHeight - 2; i < rect.top(); i += 2 ) |
471 | painter->drawLine( rect.left() - 2, i, rect.left() + rect.width() + 2, i ); | 472 | painter->drawLine( rect.left() - 2, i, rect.left() + rect.width() + 2, i ); |
472 | */ | 473 | */ |
473 | painter->setPen(titlePen); | 474 | painter->setPen(titlePen); |
474 | QFont f( QApplication::font() ); | 475 | QFont f( QApplication::font() ); |
475 | f.setWeight( QFont::Bold ); | 476 | f.setWeight( QFont::Bold ); |
476 | painter->setFont(f); | 477 | painter->setFont(f); |
477 | painter->drawText( titleLeft, -titleHeight, | 478 | painter->drawText( titleLeft, -titleHeight, |
478 | rect.width() - titleHeight - 10, titleHeight-1, | 479 | rect.width() - titleHeight - 10, titleHeight-1, |
479 | QPainter::AlignVCenter, widget->caption()); | 480 | QPainter::AlignVCenter, widget->caption()); |
480 | } | 481 | } |
481 | 482 | ||
482 | #endif //QT_NO_PALETTE | 483 | #endif //QT_NO_PALETTE |
483 | 484 | ||
484 | #ifndef MINIMIZE_HELP_HACK | 485 | #ifndef MINIMIZE_HELP_HACK |
485 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); | 486 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); |
486 | #endif | 487 | #endif |
487 | } | 488 | } |
488 | 489 | ||
489 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | 490 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, |
490 | QWSDecoration::Region type, int state) | 491 | QWSDecoration::Region type, int state) |
491 | { | 492 | { |
492 | #ifndef QT_NO_PALETTE | 493 | #ifndef QT_NO_PALETTE |
493 | #ifndef QT_NO_STYLE | 494 | #ifndef QT_NO_STYLE |
494 | // QStyle &style = QApplication::style(); | 495 | // QStyle &style = QApplication::style(); |
495 | #endif | 496 | #endif |
496 | const QColorGroup &cg = w->palette().active(); | 497 | const QColorGroup &cg = w->palette().active(); |
497 | 498 | ||
498 | QRect brect(region(w, w->rect(), type).boundingRect()); | 499 | QRect brect(region(w, w->rect(), type).boundingRect()); |
499 | 500 | ||
500 | // int xoff=2; | 501 | // int xoff=2; |
501 | // int yoff=2; | 502 | // int yoff=2; |
502 | 503 | ||
503 | // const QPixmap *pm=pixmapFor(w,type,state & QWSButton::On, xoff, yoff); | 504 | // const QPixmap *pm=pixmapFor(w,type,state & QWSButton::On, xoff, yoff); |
504 | 505 | ||
505 | const QImage *img = 0; | 506 | const QImage *img = 0; |
506 | 507 | ||
507 | switch ((int)type) { | 508 | switch ((int)type) { |
508 | case Close: | 509 | case Close: |
509 | img = &imageClose; | 510 | img = &imageClose; |
510 | break; | 511 | break; |
511 | case Minimize: | 512 | case Minimize: |
512 | if ( ((HackWidget *)w)->needsOk() || | 513 | if ( ((HackWidget *)w)->needsOk() || |
513 | (w->inherits( "QDialog" ) && !w->inherits( "QMessageBox" ) ) ) | 514 | (w->inherits( "QDialog" ) && !w->inherits( "QMessageBox" ) ) ) |
514 | img = &imageOk; | 515 | img = &imageOk; |
515 | else if ( helpExists ) | 516 | else if ( helpExists ) |
516 | img = &imageHelp; | 517 | img = &imageHelp; |
517 | break; | 518 | break; |
518 | case Help: | 519 | case Help: |
519 | img = &imageHelp; | 520 | img = &imageHelp; |
520 | break; | 521 | break; |
521 | default: | 522 | default: |
522 | return; | 523 | return; |
523 | } | 524 | } |
524 | 525 | ||
525 | QBrush titleBrush; | 526 | QBrush titleBrush; |
526 | 527 | ||
527 | if (w == qApp->activeWindow()) { | 528 | if (w == qApp->activeWindow()) { |
528 | titleBrush = cg.brush(QColorGroup::Highlight); | 529 | titleBrush = cg.brush(QColorGroup::Highlight); |
529 | } else { | 530 | } else { |
530 | titleBrush = cg.brush(QColorGroup::Background); | 531 | titleBrush = cg.brush(QColorGroup::Background); |
531 | } | 532 | } |
532 | 533 | ||
533 | fillTitle( painter, w, brect.x(), brect.y(), brect.width()+1, | 534 | fillTitle( painter, w, brect.x(), brect.y(), brect.width()+1, |
534 | brect.height()+1 ); | 535 | brect.height()+1 ); |
535 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) { | 536 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) { |
536 | if (img) painter->drawImage(brect.x()+1, brect.y()+3, *img); | 537 | if (img) painter->drawImage(brect.x()+1, brect.y()+3, *img); |
537 | } else { | 538 | } else { |
538 | if (img) painter->drawImage(brect.x(), brect.y()+2, *img); | 539 | if (img) painter->drawImage(brect.x(), brect.y()+2, *img); |
539 | } | 540 | } |
540 | 541 | ||
541 | #endif | 542 | #endif |
542 | 543 | ||
543 | } | 544 | } |
544 | 545 | ||
545 | void QPEDecoration::fillTitle( QPainter *p, const QWidget *widget, | 546 | void QPEDecoration::fillTitle( QPainter *p, const QWidget *widget, |
546 | int x, int y, int w, int h ) | 547 | int x, int y, int w, int h ) |
547 | { | 548 | { |
548 | QBrush titleBrush; | 549 | QBrush titleBrush; |
549 | QPen topLine; | 550 | QPen topLine; |
550 | QPen titleLines; | 551 | QPen titleLines; |
551 | 552 | ||
552 | const QColorGroup &cg = widget->palette().active(); | 553 | const QColorGroup &cg = widget->palette().active(); |
553 | 554 | ||
554 | if (widget == qApp->activeWindow()) { | 555 | if (widget == qApp->activeWindow()) { |
555 | titleBrush = cg.brush(QColorGroup::Highlight); | 556 | titleBrush = cg.brush(QColorGroup::Highlight); |
556 | titleLines = titleBrush.color().dark(); | 557 | titleLines = titleBrush.color().dark(); |
557 | topLine = titleBrush.color().light(); | 558 | topLine = titleBrush.color().light(); |
558 | } else { | 559 | } else { |
559 | titleBrush = cg.brush(QColorGroup::Background); | 560 | titleBrush = cg.brush(QColorGroup::Background); |
560 | titleLines = titleBrush.color(); | 561 | titleLines = titleBrush.color(); |
561 | topLine = titleBrush.color(); | 562 | topLine = titleBrush.color(); |
562 | } | 563 | } |
563 | 564 | ||
564 | p->fillRect( x, y, w, h, titleBrush); | 565 | p->fillRect( x, y, w, h, titleBrush); |
565 | 566 | ||
566 | p->setPen( topLine ); | 567 | p->setPen( topLine ); |
567 | p->drawLine( x, y+1, x+w-1, y+1 ); | 568 | p->drawLine( x, y+1, x+w-1, y+1 ); |
568 | p->setPen( titleLines ); | 569 | p->setPen( titleLines ); |
569 | for ( int i = y; i < y+h; i += 2 ) | 570 | for ( int i = y; i < y+h; i += 2 ) |
570 | p->drawLine( x, i, x+w-1, i ); | 571 | p->drawLine( x, i, x+w-1, i ); |
571 | } | 572 | } |
572 | 573 | ||
573 | //#define QPE_DONT_SHOW_TITLEBAR | 574 | //#define QPE_DONT_SHOW_TITLEBAR |
574 | 575 | ||
575 | void QPEDecoration::maximize( QWidget *widget ) | 576 | void QPEDecoration::maximize( QWidget *widget ) |
576 | { | 577 | { |
577 | #ifdef QPE_DONT_SHOW_TITLEBAR | 578 | #ifdef QPE_DONT_SHOW_TITLEBAR |
578 | if ( !widget->inherits( "QDialog" ) ) { | 579 | if ( !widget->inherits( "QDialog" ) ) { |
579 | widget->setGeometry( qt_maxWindowRect ); | 580 | widget->setGeometry( qt_maxWindowRect ); |
580 | } else | 581 | } else |
581 | #endif | 582 | #endif |
582 | { | 583 | { |
583 | QWSDecoration::maximize( widget ); | 584 | QWSDecoration::maximize( widget ); |
584 | } | 585 | } |
585 | } | 586 | } |
586 | 587 | ||
587 | #ifndef QT_NO_DIALOG | 588 | #ifndef QT_NO_DIALOG |
588 | class HackDialog : public QDialog | 589 | class HackDialog : public QDialog |
589 | { | 590 | { |
590 | public: | 591 | public: |
591 | void acceptIt() { | 592 | void acceptIt() { |
592 | if ( isA( "QMessageBox" ) ) | 593 | if ( isA( "QMessageBox" ) ) |
593 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); | 594 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); |
594 | else | 595 | else |
595 | accept(); | 596 | accept(); |
596 | } | 597 | } |
597 | }; | 598 | }; |
598 | #endif | 599 | #endif |
599 | 600 | ||
600 | 601 | ||
601 | void QPEDecoration::minimize( QWidget *widget ) | 602 | void QPEDecoration::minimize( QWidget *widget ) |
602 | { | 603 | { |
603 | #ifndef QT_NO_DIALOG | 604 | #ifndef QT_NO_DIALOG |
604 | // We use the minimize button as an "accept" button. | 605 | // We use the minimize button as an "accept" button. |
605 | if ( widget->inherits( "QDialog" ) ) { | 606 | if ( widget->inherits( "QDialog" ) ) { |
606 | HackDialog *d = (HackDialog *)widget; | 607 | HackDialog *d = (HackDialog *)widget; |
607 | d->acceptIt(); | 608 | d->acceptIt(); |
608 | } | 609 | } |
609 | #endif | 610 | #endif |
610 | else if ( ((HackWidget *)widget)->needsOk() ) { | 611 | else if ( ((HackWidget *)widget)->needsOk() ) { |
611 | QSignal s; | 612 | QSignal s; |
612 | s.connect( widget, SLOT( accept() ) ); | 613 | s.connect( widget, SLOT( accept() ) ); |
613 | s.activate(); | 614 | s.activate(); |
614 | } else { | 615 | } else { |
615 | help( widget ); | 616 | help( widget ); |
616 | } | 617 | } |
617 | } | 618 | } |
618 | 619 | ||
619 | void QPEDecoration::help( QWidget * ) | 620 | void QPEDecoration::help( QWidget * ) |
620 | { | 621 | { |
621 | if ( helpExists ) { | 622 | if ( helpExists ) { |
622 | Global::execute( "helpbrowser", helpFile ); | 623 | Global::execute( "helpbrowser", helpFile ); |
623 | } | 624 | } |
624 | } | 625 | } |
625 | 626 | ||
626 | 627 | ||
627 | /* | 628 | /* |
628 | #ifndef QT_NO_POPUPMENU | 629 | #ifndef QT_NO_POPUPMENU |
629 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) | 630 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) |
630 | { | 631 | { |
631 | return 0; | 632 | return 0; |
632 | } | 633 | } |
633 | #endif | 634 | #endif |
634 | */ | 635 | */ |
635 | 636 | ||
636 | 637 | ||
637 | 638 | ||
638 | 639 | ||
639 | #endif // QT_NO_QWS_QPE_WM_STYLE | 640 | #endif // QT_NO_QWS_QPE_WM_STYLE |