summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp2
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 9510357..0c9734d 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,174 +1,176 @@
1#include <qarray.h> 1#include <qarray.h>
2 2
3#include <qpe/categories.h> 3#include <qpe/categories.h>
4#include <qpe/categoryselect.h> 4#include <qpe/categoryselect.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
9 9
10 10
11OPimRecord::OPimRecord( int uid ) 11OPimRecord::OPimRecord( int uid )
12 : Qtopia::Record() { 12 : Qtopia::Record() {
13 13
14 m_lastHit = -1; 14 m_lastHit = -1;
15 setUid( uid ); 15 setUid( uid );
16} 16}
17OPimRecord::~OPimRecord() { 17OPimRecord::~OPimRecord() {
18} 18}
19OPimRecord::OPimRecord( const OPimRecord& rec ) 19OPimRecord::OPimRecord( const OPimRecord& rec )
20 : Qtopia::Record( rec ) 20 : Qtopia::Record( rec )
21{ 21{
22 (*this) = rec; 22 (*this) = rec;
23} 23}
24 24
25OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 25OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
26 if ( this == &rec ) return *this;
27
26 Qtopia::Record::operator=( rec ); 28 Qtopia::Record::operator=( rec );
27 m_xrefman = rec.m_xrefman; 29 m_xrefman = rec.m_xrefman;
28 m_lastHit = rec.m_lastHit; 30 m_lastHit = rec.m_lastHit;
29 31
30 return *this; 32 return *this;
31} 33}
32/* 34/*
33 * category names 35 * category names
34 */ 36 */
35QStringList OPimRecord::categoryNames( const QString& appname ) const { 37QStringList OPimRecord::categoryNames( const QString& appname ) const {
36 QStringList list; 38 QStringList list;
37 QArray<int> cats = categories(); 39 QArray<int> cats = categories();
38 Categories catDB; 40 Categories catDB;
39 catDB.load( categoryFileName() ); 41 catDB.load( categoryFileName() );
40 42
41 for (uint i = 0; i < cats.count(); i++ ) { 43 for (uint i = 0; i < cats.count(); i++ ) {
42 list << catDB.label( appname, cats[i] ); 44 list << catDB.label( appname, cats[i] );
43 } 45 }
44 46
45 return list; 47 return list;
46} 48}
47void OPimRecord::setCategoryNames( const QStringList& ) { 49void OPimRecord::setCategoryNames( const QStringList& ) {
48 50
49} 51}
50void OPimRecord::addCategoryName( const QString& ) { 52void OPimRecord::addCategoryName( const QString& ) {
51 Categories catDB; 53 Categories catDB;
52 catDB.load( categoryFileName() ); 54 catDB.load( categoryFileName() );
53 55
54 56
55} 57}
56bool OPimRecord::isEmpty()const { 58bool OPimRecord::isEmpty()const {
57 return ( uid() == 0 ); 59 return ( uid() == 0 );
58} 60}
59/*QString OPimRecord::crossToString()const { 61/*QString OPimRecord::crossToString()const {
60 QString str; 62 QString str;
61 QMap<QString, QArray<int> >::ConstIterator it; 63 QMap<QString, QArray<int> >::ConstIterator it;
62 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 64 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
63 QArray<int> id = it.data(); 65 QArray<int> id = it.data();
64 for ( uint i = 0; i < id.size(); ++i ) { 66 for ( uint i = 0; i < id.size(); ++i ) {
65 str += it.key() + "," + QString::number( i ) + ";"; 67 str += it.key() + "," + QString::number( i ) + ";";
66 } 68 }
67 } 69 }
68 str = str.remove( str.length()-1, 1); // strip the ; 70 str = str.remove( str.length()-1, 1); // strip the ;
69 //qWarning("IDS " + str ); 71 //qWarning("IDS " + str );
70 72
71 return str; 73 return str;
72 }*/ 74 }*/
73/* if uid = 1 assign a new one */ 75/* if uid = 1 assign a new one */
74void OPimRecord::setUid( int uid ) { 76void OPimRecord::setUid( int uid ) {
75 if ( uid == 1) 77 if ( uid == 1)
76 uid = uidGen().generate(); 78 uid = uidGen().generate();
77 79
78 Qtopia::Record::setUid( uid ); 80 Qtopia::Record::setUid( uid );
79}; 81};
80Qtopia::UidGen &OPimRecord::uidGen() { 82Qtopia::UidGen &OPimRecord::uidGen() {
81 return m_uidGen; 83 return m_uidGen;
82} 84}
83OPimXRefManager &OPimRecord::xrefmanager() { 85OPimXRefManager &OPimRecord::xrefmanager() {
84 return m_xrefman; 86 return m_xrefman;
85} 87}
86int OPimRecord::rtti(){ 88int OPimRecord::rtti(){
87 return 0; 89 return 0;
88} 90}
89 91
90/** 92/**
91 * now let's put our data into the stream 93 * now let's put our data into the stream
92 */ 94 */
93/* 95/*
94 * First read UID 96 * First read UID
95 * Categories 97 * Categories
96 * XRef 98 * XRef
97 */ 99 */
98bool OPimRecord::loadFromStream( QDataStream& stream ) { 100bool OPimRecord::loadFromStream( QDataStream& stream ) {
99 int Int; 101 int Int;
100 uint UInt; 102 uint UInt;
101 stream >> Int; 103 stream >> Int;
102 setUid(Int); 104 setUid(Int);
103 105
104 /** Categories */ 106 /** Categories */
105 stream >> UInt; 107 stream >> UInt;
106 QArray<int> array(UInt); 108 QArray<int> array(UInt);
107 for (uint i = 0; i < UInt; i++ ) { 109 for (uint i = 0; i < UInt; i++ ) {
108 stream >> array[i]; 110 stream >> array[i];
109 } 111 }
110 setCategories( array ); 112 setCategories( array );
111 113
112 /* 114 /*
113 * now we do the X-Ref stuff 115 * now we do the X-Ref stuff
114 */ 116 */
115 OPimXRef xref; 117 OPimXRef xref;
116 stream >> UInt; 118 stream >> UInt;
117 for ( uint i = 0; i < UInt; i++ ) { 119 for ( uint i = 0; i < UInt; i++ ) {
118 xref.setPartner( OPimXRef::One, partner( stream ) ); 120 xref.setPartner( OPimXRef::One, partner( stream ) );
119 xref.setPartner( OPimXRef::Two, partner( stream ) ); 121 xref.setPartner( OPimXRef::Two, partner( stream ) );
120 m_xrefman.add( xref ); 122 m_xrefman.add( xref );
121 } 123 }
122 124
123 return true; 125 return true;
124} 126}
125bool OPimRecord::saveToStream( QDataStream& stream )const { 127bool OPimRecord::saveToStream( QDataStream& stream )const {
126 /** UIDs */ 128 /** UIDs */
127 129
128 stream << uid(); 130 stream << uid();
129 131
130 /** Categories */ 132 /** Categories */
131 stream << categories().count(); 133 stream << categories().count();
132 for ( uint i = 0; i < categories().count(); i++ ) { 134 for ( uint i = 0; i < categories().count(); i++ ) {
133 stream << categories()[i]; 135 stream << categories()[i];
134 } 136 }
135 137
136 /* 138 /*
137 * first the XRef count 139 * first the XRef count
138 * then the xrefs 140 * then the xrefs
139 */ 141 */
140 stream << m_xrefman.list().count(); 142 stream << m_xrefman.list().count();
141 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 143 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
142 it != m_xrefman.list().end(); ++it ) { 144 it != m_xrefman.list().end(); ++it ) {
143 flush( (*it).partner( OPimXRef::One), stream ); 145 flush( (*it).partner( OPimXRef::One), stream );
144 flush( (*it).partner( OPimXRef::Two), stream ); 146 flush( (*it).partner( OPimXRef::Two), stream );
145 } 147 }
146 return true; 148 return true;
147} 149}
148void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 150void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
149 str << par.service(); 151 str << par.service();
150 str << par.uid(); 152 str << par.uid();
151 str << par.field(); 153 str << par.field();
152} 154}
153OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 155OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
154 OPimXRefPartner par; 156 OPimXRefPartner par;
155 QString str; 157 QString str;
156 int i; 158 int i;
157 159
158 stream >> str; 160 stream >> str;
159 par.setService( str ); 161 par.setService( str );
160 162
161 stream >> i; 163 stream >> i;
162 par.setUid( i ); 164 par.setUid( i );
163 165
164 stream >> i ; 166 stream >> i ;
165 par.setField( i ); 167 par.setField( i );
166 168
167 return par; 169 return par;
168} 170}
169void OPimRecord::setLastHitField( int lastHit )const { 171void OPimRecord::setLastHitField( int lastHit )const {
170 m_lastHit = lastHit; 172 m_lastHit = lastHit;
171} 173}
172int OPimRecord::lastHitField()const{ 174int OPimRecord::lastHitField()const{
173 return m_lastHit; 175 return m_lastHit;
174} 176}
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 9510357..0c9734d 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,174 +1,176 @@
1#include <qarray.h> 1#include <qarray.h>
2 2
3#include <qpe/categories.h> 3#include <qpe/categories.h>
4#include <qpe/categoryselect.h> 4#include <qpe/categoryselect.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
9 9
10 10
11OPimRecord::OPimRecord( int uid ) 11OPimRecord::OPimRecord( int uid )
12 : Qtopia::Record() { 12 : Qtopia::Record() {
13 13
14 m_lastHit = -1; 14 m_lastHit = -1;
15 setUid( uid ); 15 setUid( uid );
16} 16}
17OPimRecord::~OPimRecord() { 17OPimRecord::~OPimRecord() {
18} 18}
19OPimRecord::OPimRecord( const OPimRecord& rec ) 19OPimRecord::OPimRecord( const OPimRecord& rec )
20 : Qtopia::Record( rec ) 20 : Qtopia::Record( rec )
21{ 21{
22 (*this) = rec; 22 (*this) = rec;
23} 23}
24 24
25OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 25OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
26 if ( this == &rec ) return *this;
27
26 Qtopia::Record::operator=( rec ); 28 Qtopia::Record::operator=( rec );
27 m_xrefman = rec.m_xrefman; 29 m_xrefman = rec.m_xrefman;
28 m_lastHit = rec.m_lastHit; 30 m_lastHit = rec.m_lastHit;
29 31
30 return *this; 32 return *this;
31} 33}
32/* 34/*
33 * category names 35 * category names
34 */ 36 */
35QStringList OPimRecord::categoryNames( const QString& appname ) const { 37QStringList OPimRecord::categoryNames( const QString& appname ) const {
36 QStringList list; 38 QStringList list;
37 QArray<int> cats = categories(); 39 QArray<int> cats = categories();
38 Categories catDB; 40 Categories catDB;
39 catDB.load( categoryFileName() ); 41 catDB.load( categoryFileName() );
40 42
41 for (uint i = 0; i < cats.count(); i++ ) { 43 for (uint i = 0; i < cats.count(); i++ ) {
42 list << catDB.label( appname, cats[i] ); 44 list << catDB.label( appname, cats[i] );
43 } 45 }
44 46
45 return list; 47 return list;
46} 48}
47void OPimRecord::setCategoryNames( const QStringList& ) { 49void OPimRecord::setCategoryNames( const QStringList& ) {
48 50
49} 51}
50void OPimRecord::addCategoryName( const QString& ) { 52void OPimRecord::addCategoryName( const QString& ) {
51 Categories catDB; 53 Categories catDB;
52 catDB.load( categoryFileName() ); 54 catDB.load( categoryFileName() );
53 55
54 56
55} 57}
56bool OPimRecord::isEmpty()const { 58bool OPimRecord::isEmpty()const {
57 return ( uid() == 0 ); 59 return ( uid() == 0 );
58} 60}
59/*QString OPimRecord::crossToString()const { 61/*QString OPimRecord::crossToString()const {
60 QString str; 62 QString str;
61 QMap<QString, QArray<int> >::ConstIterator it; 63 QMap<QString, QArray<int> >::ConstIterator it;
62 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 64 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
63 QArray<int> id = it.data(); 65 QArray<int> id = it.data();
64 for ( uint i = 0; i < id.size(); ++i ) { 66 for ( uint i = 0; i < id.size(); ++i ) {
65 str += it.key() + "," + QString::number( i ) + ";"; 67 str += it.key() + "," + QString::number( i ) + ";";
66 } 68 }
67 } 69 }
68 str = str.remove( str.length()-1, 1); // strip the ; 70 str = str.remove( str.length()-1, 1); // strip the ;
69 //qWarning("IDS " + str ); 71 //qWarning("IDS " + str );
70 72
71 return str; 73 return str;
72 }*/ 74 }*/
73/* if uid = 1 assign a new one */ 75/* if uid = 1 assign a new one */
74void OPimRecord::setUid( int uid ) { 76void OPimRecord::setUid( int uid ) {
75 if ( uid == 1) 77 if ( uid == 1)
76 uid = uidGen().generate(); 78 uid = uidGen().generate();
77 79
78 Qtopia::Record::setUid( uid ); 80 Qtopia::Record::setUid( uid );
79}; 81};
80Qtopia::UidGen &OPimRecord::uidGen() { 82Qtopia::UidGen &OPimRecord::uidGen() {
81 return m_uidGen; 83 return m_uidGen;
82} 84}
83OPimXRefManager &OPimRecord::xrefmanager() { 85OPimXRefManager &OPimRecord::xrefmanager() {
84 return m_xrefman; 86 return m_xrefman;
85} 87}
86int OPimRecord::rtti(){ 88int OPimRecord::rtti(){
87 return 0; 89 return 0;
88} 90}
89 91
90/** 92/**
91 * now let's put our data into the stream 93 * now let's put our data into the stream
92 */ 94 */
93/* 95/*
94 * First read UID 96 * First read UID
95 * Categories 97 * Categories
96 * XRef 98 * XRef
97 */ 99 */
98bool OPimRecord::loadFromStream( QDataStream& stream ) { 100bool OPimRecord::loadFromStream( QDataStream& stream ) {
99 int Int; 101 int Int;
100 uint UInt; 102 uint UInt;
101 stream >> Int; 103 stream >> Int;
102 setUid(Int); 104 setUid(Int);
103 105
104 /** Categories */ 106 /** Categories */
105 stream >> UInt; 107 stream >> UInt;
106 QArray<int> array(UInt); 108 QArray<int> array(UInt);
107 for (uint i = 0; i < UInt; i++ ) { 109 for (uint i = 0; i < UInt; i++ ) {
108 stream >> array[i]; 110 stream >> array[i];
109 } 111 }
110 setCategories( array ); 112 setCategories( array );
111 113
112 /* 114 /*
113 * now we do the X-Ref stuff 115 * now we do the X-Ref stuff
114 */ 116 */
115 OPimXRef xref; 117 OPimXRef xref;
116 stream >> UInt; 118 stream >> UInt;
117 for ( uint i = 0; i < UInt; i++ ) { 119 for ( uint i = 0; i < UInt; i++ ) {
118 xref.setPartner( OPimXRef::One, partner( stream ) ); 120 xref.setPartner( OPimXRef::One, partner( stream ) );
119 xref.setPartner( OPimXRef::Two, partner( stream ) ); 121 xref.setPartner( OPimXRef::Two, partner( stream ) );
120 m_xrefman.add( xref ); 122 m_xrefman.add( xref );
121 } 123 }
122 124
123 return true; 125 return true;
124} 126}
125bool OPimRecord::saveToStream( QDataStream& stream )const { 127bool OPimRecord::saveToStream( QDataStream& stream )const {
126 /** UIDs */ 128 /** UIDs */
127 129
128 stream << uid(); 130 stream << uid();
129 131
130 /** Categories */ 132 /** Categories */
131 stream << categories().count(); 133 stream << categories().count();
132 for ( uint i = 0; i < categories().count(); i++ ) { 134 for ( uint i = 0; i < categories().count(); i++ ) {
133 stream << categories()[i]; 135 stream << categories()[i];
134 } 136 }
135 137
136 /* 138 /*
137 * first the XRef count 139 * first the XRef count
138 * then the xrefs 140 * then the xrefs
139 */ 141 */
140 stream << m_xrefman.list().count(); 142 stream << m_xrefman.list().count();
141 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 143 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
142 it != m_xrefman.list().end(); ++it ) { 144 it != m_xrefman.list().end(); ++it ) {
143 flush( (*it).partner( OPimXRef::One), stream ); 145 flush( (*it).partner( OPimXRef::One), stream );
144 flush( (*it).partner( OPimXRef::Two), stream ); 146 flush( (*it).partner( OPimXRef::Two), stream );
145 } 147 }
146 return true; 148 return true;
147} 149}
148void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 150void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
149 str << par.service(); 151 str << par.service();
150 str << par.uid(); 152 str << par.uid();
151 str << par.field(); 153 str << par.field();
152} 154}
153OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 155OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
154 OPimXRefPartner par; 156 OPimXRefPartner par;
155 QString str; 157 QString str;
156 int i; 158 int i;
157 159
158 stream >> str; 160 stream >> str;
159 par.setService( str ); 161 par.setService( str );
160 162
161 stream >> i; 163 stream >> i;
162 par.setUid( i ); 164 par.setUid( i );
163 165
164 stream >> i ; 166 stream >> i ;
165 par.setField( i ); 167 par.setField( i );
166 168
167 return par; 169 return par;
168} 170}
169void OPimRecord::setLastHitField( int lastHit )const { 171void OPimRecord::setLastHitField( int lastHit )const {
170 m_lastHit = lastHit; 172 m_lastHit = lastHit;
171} 173}
172int OPimRecord::lastHitField()const{ 174int OPimRecord::lastHitField()const{
173 return m_lastHit; 175 return m_lastHit;
174} 176}