author | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
commit | f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (unidiff) | |
tree | 4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/core/opimrecord.cpp | |
parent | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff) | |
download | opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2 |
cosmetics
Diffstat (limited to 'libopie2/opiepim/core/opimrecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 141 |
1 files changed, 101 insertions, 40 deletions
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 72bb372..c603f44 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -26,67 +26,92 @@ | |||
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qarray.h> | ||
30 | 29 | ||
30 | #include "opimrecord.h" | ||
31 | |||
32 | /* OPIE */ | ||
31 | #include <qpe/categories.h> | 33 | #include <qpe/categories.h> |
32 | #include <qpe/categoryselect.h> | 34 | #include <qpe/categoryselect.h> |
33 | 35 | ||
34 | #include <opie2/opimrecord.h> | 36 | /* QT */ |
37 | #include <qarray.h> | ||
35 | 38 | ||
36 | namespace Opie { | 39 | namespace Opie |
40 | { | ||
37 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 41 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
38 | 42 | ||
39 | 43 | ||
40 | OPimRecord::OPimRecord( int uid ) | 44 | OPimRecord::OPimRecord( int uid ) |
41 | : Qtopia::Record() { | 45 | : Qtopia::Record() |
46 | { | ||
42 | 47 | ||
43 | m_lastHit = -1; | 48 | m_lastHit = -1; |
44 | setUid( uid ); | 49 | setUid( uid ); |
45 | } | 50 | } |
46 | OPimRecord::~OPimRecord() { | 51 | |
47 | } | 52 | |
53 | OPimRecord::~OPimRecord() | ||
54 | {} | ||
55 | |||
56 | |||
48 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 57 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
49 | : Qtopia::Record( rec ) | 58 | : Qtopia::Record( rec ) |
50 | { | 59 | { |
51 | (*this) = rec; | 60 | ( *this ) = rec; |
52 | } | 61 | } |
53 | 62 | ||
54 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 63 | |
55 | if ( this == &rec ) return *this; | 64 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) |
65 | { | ||
66 | if ( this == &rec ) return * this; | ||
56 | 67 | ||
57 | Qtopia::Record::operator=( rec ); | 68 | Qtopia::Record::operator=( rec ); |
58 | m_xrefman = rec.m_xrefman; | 69 | m_xrefman = rec.m_xrefman; |
59 | m_lastHit = rec.m_lastHit; | 70 | m_lastHit = rec.m_lastHit; |
60 | 71 | ||
61 | return *this; | 72 | return *this; |
62 | } | 73 | } |
74 | |||
75 | |||
63 | /* | 76 | /* |
64 | * category names | 77 | * category names |
65 | */ | 78 | */ |
66 | QStringList OPimRecord::categoryNames( const QString& appname ) const { | 79 | QStringList OPimRecord::categoryNames( const QString& appname ) const |
80 | { | ||
67 | QStringList list; | 81 | QStringList list; |
68 | QArray<int> cats = categories(); | 82 | QArray<int> cats = categories(); |
69 | Categories catDB; | 83 | Categories catDB; |
70 | catDB.load( categoryFileName() ); | 84 | catDB.load( categoryFileName() ); |
71 | 85 | ||
72 | for (uint i = 0; i < cats.count(); i++ ) { | 86 | for ( uint i = 0; i < cats.count(); i++ ) |
73 | list << catDB.label( appname, cats[i] ); | 87 | { |
88 | list << catDB.label( appname, cats[ i ] ); | ||
74 | } | 89 | } |
75 | 90 | ||
76 | return list; | 91 | return list; |
77 | } | 92 | } |
78 | void OPimRecord::setCategoryNames( const QStringList& ) { | ||
79 | 93 | ||
94 | |||
95 | void OPimRecord::setCategoryNames( const QStringList& ) | ||
96 | { | ||
80 | } | 97 | } |
81 | void OPimRecord::addCategoryName( const QString& ) { | 98 | |
99 | |||
100 | void OPimRecord::addCategoryName( const QString& ) | ||
101 | { | ||
82 | Categories catDB; | 102 | Categories catDB; |
83 | catDB.load( categoryFileName() ); | 103 | catDB.load( categoryFileName() ); |
84 | 104 | ||
85 | 105 | ||
86 | } | 106 | } |
87 | bool OPimRecord::isEmpty()const { | 107 | |
108 | |||
109 | bool OPimRecord::isEmpty() const | ||
110 | { | ||
88 | return ( uid() == 0 ); | 111 | return ( uid() == 0 ); |
89 | } | 112 | } |
113 | |||
114 | |||
90 | /*QString OPimRecord::crossToString()const { | 115 | /*QString OPimRecord::crossToString()const { |
91 | QString str; | 116 | QString str; |
92 | QMap<QString, QArray<int> >::ConstIterator it; | 117 | QMap<QString, QArray<int> >::ConstIterator it; |
@@ -102,19 +127,29 @@ bool OPimRecord::isEmpty()const { | |||
102 | return str; | 127 | return str; |
103 | }*/ | 128 | }*/ |
104 | /* if uid = 1 assign a new one */ | 129 | /* if uid = 1 assign a new one */ |
105 | void OPimRecord::setUid( int uid ) { | 130 | void OPimRecord::setUid( int uid ) |
106 | if ( uid == 1) | 131 | { |
132 | if ( uid == 1 ) | ||
107 | uid = uidGen().generate(); | 133 | uid = uidGen().generate(); |
108 | 134 | ||
109 | Qtopia::Record::setUid( uid ); | 135 | Qtopia::Record::setUid( uid ); |
110 | }; | 136 | }; |
111 | Qtopia::UidGen &OPimRecord::uidGen() { | 137 | |
138 | |||
139 | Qtopia::UidGen &OPimRecord::uidGen() | ||
140 | { | ||
112 | return m_uidGen; | 141 | return m_uidGen; |
113 | } | 142 | } |
114 | OPimXRefManager &OPimRecord::xrefmanager() { | 143 | |
144 | |||
145 | OPimXRefManager &OPimRecord::xrefmanager() | ||
146 | { | ||
115 | return m_xrefman; | 147 | return m_xrefman; |
116 | } | 148 | } |
117 | int OPimRecord::rtti(){ | 149 | |
150 | |||
151 | int OPimRecord::rtti() | ||
152 | { | ||
118 | return 0; | 153 | return 0; |
119 | } | 154 | } |
120 | 155 | ||
@@ -126,17 +161,19 @@ int OPimRecord::rtti(){ | |||
126 | * Categories | 161 | * Categories |
127 | * XRef | 162 | * XRef |
128 | */ | 163 | */ |
129 | bool OPimRecord::loadFromStream( QDataStream& stream ) { | 164 | bool OPimRecord::loadFromStream( QDataStream& stream ) |
165 | { | ||
130 | int Int; | 166 | int Int; |
131 | uint UInt; | 167 | uint UInt; |
132 | stream >> Int; | 168 | stream >> Int; |
133 | setUid(Int); | 169 | setUid( Int ); |
134 | 170 | ||
135 | /** Categories */ | 171 | /** Categories */ |
136 | stream >> UInt; | 172 | stream >> UInt; |
137 | QArray<int> array(UInt); | 173 | QArray<int> array( UInt ); |
138 | for (uint i = 0; i < UInt; i++ ) { | 174 | for ( uint i = 0; i < UInt; i++ ) |
139 | stream >> array[i]; | 175 | { |
176 | stream >> array[ i ]; | ||
140 | } | 177 | } |
141 | setCategories( array ); | 178 | setCategories( array ); |
142 | 179 | ||
@@ -145,7 +182,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) { | |||
145 | */ | 182 | */ |
146 | OPimXRef xref; | 183 | OPimXRef xref; |
147 | stream >> UInt; | 184 | stream >> UInt; |
148 | for ( uint i = 0; i < UInt; i++ ) { | 185 | for ( uint i = 0; i < UInt; i++ ) |
186 | { | ||
149 | xref.setPartner( OPimXRef::One, partner( stream ) ); | 187 | xref.setPartner( OPimXRef::One, partner( stream ) ); |
150 | xref.setPartner( OPimXRef::Two, partner( stream ) ); | 188 | xref.setPartner( OPimXRef::Two, partner( stream ) ); |
151 | m_xrefman.add( xref ); | 189 | m_xrefman.add( xref ); |
@@ -153,15 +191,19 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) { | |||
153 | 191 | ||
154 | return true; | 192 | return true; |
155 | } | 193 | } |
156 | bool OPimRecord::saveToStream( QDataStream& stream )const { | 194 | |
195 | |||
196 | bool OPimRecord::saveToStream( QDataStream& stream ) const | ||
197 | { | ||
157 | /** UIDs */ | 198 | /** UIDs */ |
158 | 199 | ||
159 | stream << uid(); | 200 | stream << uid(); |
160 | 201 | ||
161 | /** Categories */ | 202 | /** Categories */ |
162 | stream << categories().count(); | 203 | stream << categories().count(); |
163 | for ( uint i = 0; i < categories().count(); i++ ) { | 204 | for ( uint i = 0; i < categories().count(); i++ ) |
164 | stream << categories()[i]; | 205 | { |
206 | stream << categories() [ i ]; | ||
165 | } | 207 | } |
166 | 208 | ||
167 | /* | 209 | /* |
@@ -170,18 +212,25 @@ bool OPimRecord::saveToStream( QDataStream& stream )const { | |||
170 | */ | 212 | */ |
171 | stream << m_xrefman.list().count(); | 213 | stream << m_xrefman.list().count(); |
172 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 214 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
173 | it != m_xrefman.list().end(); ++it ) { | 215 | it != m_xrefman.list().end(); ++it ) |
174 | flush( (*it).partner( OPimXRef::One), stream ); | 216 | { |
175 | flush( (*it).partner( OPimXRef::Two), stream ); | 217 | flush( ( *it ).partner( OPimXRef::One ), stream ); |
218 | flush( ( *it ).partner( OPimXRef::Two ), stream ); | ||
176 | } | 219 | } |
177 | return true; | 220 | return true; |
178 | } | 221 | } |
179 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ | 222 | |
223 | |||
224 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const | ||
225 | { | ||
180 | str << par.service(); | 226 | str << par.service(); |
181 | str << par.uid(); | 227 | str << par.uid(); |
182 | str << par.field(); | 228 | str << par.field(); |
183 | } | 229 | } |
184 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | 230 | |
231 | |||
232 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) | ||
233 | { | ||
185 | OPimXRefPartner par; | 234 | OPimXRefPartner par; |
186 | QString str; | 235 | QString str; |
187 | int i; | 236 | int i; |
@@ -197,16 +246,28 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | |||
197 | 246 | ||
198 | return par; | 247 | return par; |
199 | } | 248 | } |
200 | void OPimRecord::setLastHitField( int lastHit )const { | 249 | |
250 | |||
251 | void OPimRecord::setLastHitField( int lastHit ) const | ||
252 | { | ||
201 | m_lastHit = lastHit; | 253 | m_lastHit = lastHit; |
202 | } | 254 | } |
203 | int OPimRecord::lastHitField()const{ | 255 | |
256 | |||
257 | int OPimRecord::lastHitField() const | ||
258 | { | ||
204 | return m_lastHit; | 259 | return m_lastHit; |
205 | } | 260 | } |
206 | QMap<QString, QString> OPimRecord::toExtraMap()const { | 261 | |
262 | |||
263 | QMap<QString, QString> OPimRecord::toExtraMap() const | ||
264 | { | ||
207 | return customMap; | 265 | return customMap; |
208 | } | 266 | } |
209 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { | 267 | |
268 | |||
269 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) | ||
270 | { | ||
210 | customMap = map; | 271 | customMap = map; |
211 | } | 272 | } |
212 | 273 | ||