summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimrecord.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimrecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp141
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
@@ -27,31 +27,42 @@
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
36namespace Opie { 39namespace Opie
40{
37Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 41Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
38 42
39 43
40OPimRecord::OPimRecord( int uid ) 44OPimRecord::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}
46OPimRecord::~OPimRecord() { 51
47} 52
53OPimRecord::~OPimRecord()
54{}
55
56
48OPimRecord::OPimRecord( const OPimRecord& rec ) 57OPimRecord::OPimRecord( const OPimRecord& rec )
49 : Qtopia::Record( rec ) 58 : Qtopia::Record( rec )
50{ 59{
51 (*this) = rec; 60 ( *this ) = rec;
52} 61}
53 62
54OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 63
55 if ( this == &rec ) return *this; 64OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
65{
66 if ( this == &rec ) return * this;
56 67
57 Qtopia::Record::operator=( rec ); 68 Qtopia::Record::operator=( rec );
@@ -59,10 +70,13 @@ OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
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 */
66QStringList OPimRecord::categoryNames( const QString& appname ) const { 79QStringList OPimRecord::categoryNames( const QString& appname ) const
80{
67 QStringList list; 81 QStringList list;
68 QArray<int> cats = categories(); 82 QArray<int> cats = categories();
@@ -70,14 +84,20 @@ QStringList OPimRecord::categoryNames( const QString& appname ) const {
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}
78void OPimRecord::setCategoryNames( const QStringList& ) {
79 93
94
95void OPimRecord::setCategoryNames( const QStringList& )
96{
80} 97}
81void OPimRecord::addCategoryName( const QString& ) { 98
99
100void OPimRecord::addCategoryName( const QString& )
101{
82 Categories catDB; 102 Categories catDB;
83 catDB.load( categoryFileName() ); 103 catDB.load( categoryFileName() );
@@ -85,7 +105,12 @@ void OPimRecord::addCategoryName( const QString& ) {
85 105
86} 106}
87bool OPimRecord::isEmpty()const { 107
108
109bool 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;
@@ -103,17 +128,27 @@ bool OPimRecord::isEmpty()const {
103 }*/ 128 }*/
104/* if uid = 1 assign a new one */ 129/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) { 130void 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};
111Qtopia::UidGen &OPimRecord::uidGen() { 137
138
139Qtopia::UidGen &OPimRecord::uidGen()
140{
112 return m_uidGen; 141 return m_uidGen;
113} 142}
114OPimXRefManager &OPimRecord::xrefmanager() { 143
144
145OPimXRefManager &OPimRecord::xrefmanager()
146{
115 return m_xrefman; 147 return m_xrefman;
116} 148}
117int OPimRecord::rtti(){ 149
150
151int OPimRecord::rtti()
152{
118 return 0; 153 return 0;
119} 154}
@@ -127,15 +162,17 @@ int OPimRecord::rtti(){
127 * XRef 162 * XRef
128 */ 163 */
129bool OPimRecord::loadFromStream( QDataStream& stream ) { 164bool 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 );
@@ -146,5 +183,6 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
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 ) );
@@ -154,5 +192,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
154 return true; 192 return true;
155} 193}
156bool OPimRecord::saveToStream( QDataStream& stream )const { 194
195
196bool OPimRecord::saveToStream( QDataStream& stream ) const
197{
157 /** UIDs */ 198 /** UIDs */
158 199
@@ -161,6 +202,7 @@ bool OPimRecord::saveToStream( QDataStream& stream )const {
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
@@ -171,16 +213,23 @@ bool OPimRecord::saveToStream( QDataStream& stream )const {
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}
179void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 222
223
224void 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}
184OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 230
231
232OPimXRefPartner OPimRecord::partner( QDataStream& stream )
233{
185 OPimXRefPartner par; 234 OPimXRefPartner par;
186 QString str; 235 QString str;
@@ -198,14 +247,26 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
198 return par; 247 return par;
199} 248}
200void OPimRecord::setLastHitField( int lastHit )const { 249
250
251void OPimRecord::setLastHitField( int lastHit ) const
252{
201 m_lastHit = lastHit; 253 m_lastHit = lastHit;
202} 254}
203int OPimRecord::lastHitField()const{ 255
256
257int OPimRecord::lastHitField() const
258{
204 return m_lastHit; 259 return m_lastHit;
205} 260}
206QMap<QString, QString> OPimRecord::toExtraMap()const { 261
262
263QMap<QString, QString> OPimRecord::toExtraMap() const
264{
207 return customMap; 265 return customMap;
208} 266}
209void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { 267
268
269void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
270{
210 customMap = map; 271 customMap = map;
211} 272}