Diffstat (limited to 'libopie2/opiepim/core/opimrecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 2365748..72bb372 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,55 +1,84 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <qarray.h> | 29 | #include <qarray.h> |
2 | 30 | ||
3 | #include <qpe/categories.h> | 31 | #include <qpe/categories.h> |
4 | #include <qpe/categoryselect.h> | 32 | #include <qpe/categoryselect.h> |
5 | 33 | ||
6 | #include "opimrecord.h" | 34 | #include <opie2/opimrecord.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 37 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
9 | 38 | ||
10 | 39 | ||
11 | OPimRecord::OPimRecord( int uid ) | 40 | OPimRecord::OPimRecord( int uid ) |
12 | : Qtopia::Record() { | 41 | : Qtopia::Record() { |
13 | 42 | ||
14 | m_lastHit = -1; | 43 | m_lastHit = -1; |
15 | setUid( uid ); | 44 | setUid( uid ); |
16 | } | 45 | } |
17 | OPimRecord::~OPimRecord() { | 46 | OPimRecord::~OPimRecord() { |
18 | } | 47 | } |
19 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 48 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
20 | : Qtopia::Record( rec ) | 49 | : Qtopia::Record( rec ) |
21 | { | 50 | { |
22 | (*this) = rec; | 51 | (*this) = rec; |
23 | } | 52 | } |
24 | 53 | ||
25 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 54 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
26 | if ( this == &rec ) return *this; | 55 | if ( this == &rec ) return *this; |
27 | 56 | ||
28 | Qtopia::Record::operator=( rec ); | 57 | Qtopia::Record::operator=( rec ); |
29 | m_xrefman = rec.m_xrefman; | 58 | m_xrefman = rec.m_xrefman; |
30 | m_lastHit = rec.m_lastHit; | 59 | m_lastHit = rec.m_lastHit; |
31 | 60 | ||
32 | return *this; | 61 | return *this; |
33 | } | 62 | } |
34 | /* | 63 | /* |
35 | * category names | 64 | * category names |
36 | */ | 65 | */ |
37 | QStringList OPimRecord::categoryNames( const QString& appname ) const { | 66 | QStringList OPimRecord::categoryNames( const QString& appname ) const { |
38 | QStringList list; | 67 | QStringList list; |
39 | QArray<int> cats = categories(); | 68 | QArray<int> cats = categories(); |
40 | Categories catDB; | 69 | Categories catDB; |
41 | catDB.load( categoryFileName() ); | 70 | catDB.load( categoryFileName() ); |
42 | 71 | ||
43 | for (uint i = 0; i < cats.count(); i++ ) { | 72 | for (uint i = 0; i < cats.count(); i++ ) { |
44 | list << catDB.label( appname, cats[i] ); | 73 | list << catDB.label( appname, cats[i] ); |
45 | } | 74 | } |
46 | 75 | ||
47 | return list; | 76 | return list; |
48 | } | 77 | } |
49 | void OPimRecord::setCategoryNames( const QStringList& ) { | 78 | void OPimRecord::setCategoryNames( const QStringList& ) { |
50 | 79 | ||
51 | } | 80 | } |
52 | void OPimRecord::addCategoryName( const QString& ) { | 81 | void OPimRecord::addCategoryName( const QString& ) { |
53 | Categories catDB; | 82 | Categories catDB; |
54 | catDB.load( categoryFileName() ); | 83 | catDB.load( categoryFileName() ); |
55 | 84 | ||
@@ -135,48 +164,50 @@ bool OPimRecord::saveToStream( QDataStream& stream )const { | |||
135 | stream << categories()[i]; | 164 | stream << categories()[i]; |
136 | } | 165 | } |
137 | 166 | ||
138 | /* | 167 | /* |
139 | * first the XRef count | 168 | * first the XRef count |
140 | * then the xrefs | 169 | * then the xrefs |
141 | */ | 170 | */ |
142 | stream << m_xrefman.list().count(); | 171 | stream << m_xrefman.list().count(); |
143 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 172 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
144 | it != m_xrefman.list().end(); ++it ) { | 173 | it != m_xrefman.list().end(); ++it ) { |
145 | flush( (*it).partner( OPimXRef::One), stream ); | 174 | flush( (*it).partner( OPimXRef::One), stream ); |
146 | flush( (*it).partner( OPimXRef::Two), stream ); | 175 | flush( (*it).partner( OPimXRef::Two), stream ); |
147 | } | 176 | } |
148 | return true; | 177 | return true; |
149 | } | 178 | } |
150 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ | 179 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ |
151 | str << par.service(); | 180 | str << par.service(); |
152 | str << par.uid(); | 181 | str << par.uid(); |
153 | str << par.field(); | 182 | str << par.field(); |
154 | } | 183 | } |
155 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | 184 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { |
156 | OPimXRefPartner par; | 185 | OPimXRefPartner par; |
157 | QString str; | 186 | QString str; |
158 | int i; | 187 | int i; |
159 | 188 | ||
160 | stream >> str; | 189 | stream >> str; |
161 | par.setService( str ); | 190 | par.setService( str ); |
162 | 191 | ||
163 | stream >> i; | 192 | stream >> i; |
164 | par.setUid( i ); | 193 | par.setUid( i ); |
165 | 194 | ||
166 | stream >> i ; | 195 | stream >> i ; |
167 | par.setField( i ); | 196 | par.setField( i ); |
168 | 197 | ||
169 | return par; | 198 | return par; |
170 | } | 199 | } |
171 | void OPimRecord::setLastHitField( int lastHit )const { | 200 | void OPimRecord::setLastHitField( int lastHit )const { |
172 | m_lastHit = lastHit; | 201 | m_lastHit = lastHit; |
173 | } | 202 | } |
174 | int OPimRecord::lastHitField()const{ | 203 | int OPimRecord::lastHitField()const{ |
175 | return m_lastHit; | 204 | return m_lastHit; |
176 | } | 205 | } |
177 | QMap<QString, QString> OPimRecord::toExtraMap()const { | 206 | QMap<QString, QString> OPimRecord::toExtraMap()const { |
178 | return customMap; | 207 | return customMap; |
179 | } | 208 | } |
180 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { | 209 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { |
181 | customMap = map; | 210 | customMap = map; |
182 | } | 211 | } |
212 | |||
213 | } | ||