author | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
commit | 6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff) | |
tree | 6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/backend/palmtoprecord.cpp | |
parent | d10cddb3c9ce75bc90b14add14bc133737fe35aa (diff) | |
download | opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2 |
Qtopia1-6 merge
still to test
bic changes to be resolved
more changes to be made?
Diffstat (limited to 'library/backend/palmtoprecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | library/backend/palmtoprecord.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/library/backend/palmtoprecord.cpp b/library/backend/palmtoprecord.cpp index 0d57699..3cfa874 100644 --- a/library/backend/palmtoprecord.cpp +++ b/library/backend/palmtoprecord.cpp | |||
@@ -1,127 +1,141 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** in the 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 | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | 13 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | #include "palmtoprecord.h" | 20 | #include <qtopia/private/palmtoprecord.h> |
22 | #include "stringutil.h" | 21 | #include <qtopia/stringutil.h> |
23 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
24 | 23 | ||
24 | /*! \class Qtopia::PalmtopRecord palmtoprecord.h | ||
25 | \brief The Qtopia::PalmtopRecord class is the base class for all PIM records. | ||
26 | |||
27 | Provides unique id and category support for all PIM records. | ||
28 | |||
29 | \ingroup qtopiaemb | ||
30 | \ingroup qtopiadesktop | ||
31 | */ | ||
32 | |||
33 | |||
25 | namespace Qtopia { | 34 | namespace Qtopia { |
26 | 35 | ||
36 | |||
37 | |||
27 | Record &Record::operator=( const Record &c ) | 38 | Record &Record::operator=( const Record &c ) |
28 | { | 39 | { |
29 | mUid = c.mUid; | 40 | mUid = c.mUid; |
30 | mCats = c.mCats; | 41 | mCats = c.mCats; |
31 | customMap = c.customMap; | 42 | customMap = c.customMap; |
32 | return *this; | 43 | return *this; |
33 | } | 44 | } |
34 | 45 | ||
35 | void Record::setCategories( int single ) | 46 | void Record::setCategories( int single ) |
36 | { | 47 | { |
37 | if ( single == 0 ) | 48 | if ( single == 0 ) |
38 | return; | 49 | return; |
39 | mCats.resize(1); | 50 | mCats.resize(1); |
40 | mCats[0] = single; | 51 | mCats[0] = single; |
41 | } | 52 | } |
42 | 53 | ||
43 | // convenience methods provided for loading and saving to xml | 54 | // convenience methods provided for loading and saving to xml |
44 | QString Record::idsToString( const QArray<int> &cats ) | 55 | QString Record::idsToString( const QArray<int> &catsUnsorted ) |
45 | { | 56 | { |
57 | QArray<int> cats = catsUnsorted; | ||
58 | cats.sort(); | ||
59 | |||
46 | QString str; | 60 | QString str; |
47 | for ( uint i = 0; i < cats.size(); i++ ) | 61 | for ( uint i = 0; i < cats.size(); i++ ) |
48 | if ( i == 0 ) | 62 | if ( i == 0 ) |
49 | str = QString::number( cats[int(i)] ); | 63 | str = QString::number( cats[int(i)] ); |
50 | else | 64 | else |
51 | str += ";" + QString::number( cats[int(i)] ); | 65 | str += ";" + QString::number( cats[int(i)] ); |
52 | 66 | ||
53 | return str; | 67 | return str; |
54 | } | 68 | } |
55 | 69 | ||
56 | // convenience methods provided for loading and saving to xml | 70 | // convenience methods provided for loading and saving to xml |
57 | QArray<int> Record::idsFromString( const QString &str ) | 71 | QArray<int> Record::idsFromString( const QString &str ) |
58 | { | 72 | { |
59 | QStringList catStrs = QStringList::split( ";", str ); | 73 | QStringList catStrs = QStringList::split( ";", str ); |
60 | QArray<int> cats( catStrs.count() ); | 74 | QArray<int> cats( catStrs.count() ); |
61 | uint i = 0; | 75 | uint i = 0; |
62 | for ( QStringList::ConstIterator it = catStrs.begin(); | 76 | for ( QStringList::ConstIterator it = catStrs.begin(); |
63 | it != catStrs.end(); ++it ) { | 77 | it != catStrs.end(); ++it ) { |
64 | cats[int(i)] = (*it).toInt(); | 78 | cats[int(i)] = (*it).toInt(); |
65 | i++; | 79 | i++; |
66 | } | 80 | } |
67 | return cats; | 81 | return cats; |
68 | } | 82 | } |
69 | 83 | ||
70 | /*! | 84 | /*! |
71 | Returns the string stored for the custom field \a key. | 85 | Returns the string stored for the custom field \a key. |
72 | Returns a null string if the field does not exist. | 86 | Returns a null string if the field does not exist. |
73 | */ | 87 | */ |
74 | QString Record::customField( const QString &key) const | 88 | QString Record::customField( const QString &key) const |
75 | { | 89 | { |
76 | if (customMap.contains(key)) | 90 | if (customMap.contains(key)) |
77 | return customMap[key]; | 91 | return customMap[key]; |
78 | 92 | ||
79 | return QString::null; | 93 | return QString::null; |
80 | } | 94 | } |
81 | 95 | ||
82 | /*! | 96 | /*! |
83 | Sets the string stored for the custom field \a key to \a value. | 97 | Sets the string stored for the custom field \a key to \a value. |
84 | */ | 98 | */ |
85 | void Record::setCustomField( const QString &key, const QString &value) | 99 | void Record::setCustomField( const QString &key, const QString &value) |
86 | { | 100 | { |
87 | qWarning("setting custom " + key + " to " + value); | 101 | // qWarning("setting custom " + key + " to " + value); |
88 | if (customMap.contains(key)) | 102 | if (customMap.contains(key)) |
89 | customMap.replace(key, value); | 103 | customMap.replace(key, value); |
90 | else | 104 | else |
91 | customMap.insert(key, value); | 105 | customMap.insert(key, value); |
92 | 106 | ||
93 | qWarning(QString("custom size %1").arg(customMap.count())); | 107 | // qWarning(QString("custom size %1").arg(customMap.count())); |
94 | } | 108 | } |
95 | 109 | ||
96 | /*! | 110 | /*! |
97 | Removes the custom field \a key. | 111 | Removes the custom field \a key. |
98 | */ | 112 | */ |
99 | void Record::removeCustomField(const QString &key) | 113 | void Record::removeCustomField(const QString &key) |
100 | { | 114 | { |
101 | customMap.remove(key); | 115 | customMap.remove(key); |
102 | } | 116 | } |
103 | 117 | ||
104 | QString Record::customToXml() const | 118 | QString Record::customToXml() const |
105 | { | 119 | { |
106 | //qWarning(QString("writing custom %1").arg(customMap.count())); | 120 | //qWarning(QString("writing custom %1").arg(customMap.count())); |
107 | QString buf(" "); | 121 | QString buf(" "); |
108 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); | 122 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); |
109 | cit != customMap.end(); ++cit) { | 123 | cit != customMap.end(); ++cit) { |
110 | qWarning(".ITEM."); | 124 | // qWarning(".ITEM."); |
111 | buf += cit.key(); | 125 | buf += cit.key(); |
112 | buf += "=\""; | 126 | buf += "=\""; |
113 | buf += escapeString(cit.data()); | 127 | buf += escapeString(cit.data()); |
114 | buf += "\" "; | 128 | buf += "\" "; |
115 | } | 129 | } |
116 | return buf; | 130 | return buf; |
117 | } | 131 | } |
118 | 132 | ||
119 | void Record::dump( const QMap<int, QString> &map ) | 133 | void Record::dump( const QMap<int, QString> &map ) |
120 | { | 134 | { |
121 | QMap<int, QString>::ConstIterator it; | 135 | QMap<int, QString>::ConstIterator it; |
122 | for( it = map.begin(); it != map.end(); ++it ) | 136 | for( it = map.begin(); it != map.end(); ++it ) |
123 | qDebug("%d : %s", it.key(), it.data().local8Bit().data() ); | 137 | qDebug("%d : %s", it.key(), it.data().local8Bit().data() ); |
124 | } | 138 | } |
125 | 139 | ||
126 | } | 140 | } |
127 | 141 | ||