-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 18 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 63 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 33 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxref.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxref.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefmanager.cpp | 69 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefmanager.h | 5 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimxrefpartner.cpp | 43 |
8 files changed, 184 insertions, 101 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 591e467..c1682c6 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -333,3 +333,3 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
333 | if ( pos > -1 ) | 333 | if ( pos > -1 ) |
334 | ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 334 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
335 | 335 | ||
@@ -384,18 +384,2 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
384 | // cross refernce | 384 | // cross refernce |
385 | QStringList list = ev.relatedApps(); | ||
386 | QStringList::Iterator listIt; | ||
387 | QString refs; | ||
388 | str += "CrossReference=\""; | ||
389 | bool added = false; | ||
390 | for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { | ||
391 | added = true; | ||
392 | QArray<int> ints = ev.relations( (*listIt) ); | ||
393 | for ( uint i = 0; i< ints.count(); i++ ) { | ||
394 | str += (*listIt) + "," + QString::number( i ) + ";"; | ||
395 | } | ||
396 | } | ||
397 | if ( added ) | ||
398 | str = str.remove( str.length()-1, 1 ); | ||
399 | |||
400 | str += "\" "; | ||
401 | 385 | ||
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 21cf131..0e3be9d 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -23,3 +23,3 @@ OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | |||
23 | Qtopia::Record::operator=( rec ); | 23 | Qtopia::Record::operator=( rec ); |
24 | m_relations = rec.m_relations; | 24 | m_xrefman = rec.m_xrefman; |
25 | 25 | ||
@@ -54,57 +54,3 @@ bool OPimRecord::isEmpty()const { | |||
54 | } | 54 | } |
55 | QStringList OPimRecord::relatedApps()const{ | 55 | /*QString OPimRecord::crossToString()const { |
56 | QStringList list; | ||
57 | QMap<QString, QArray<int> >::ConstIterator it; | ||
58 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | ||
59 | list << it.key(); | ||
60 | } | ||
61 | return list; | ||
62 | } | ||
63 | QArray<int> OPimRecord::relations(const QString& app )const { | ||
64 | QArray<int> tmp; | ||
65 | QMap<QString, QArray<int> >::ConstIterator it; | ||
66 | it = m_relations.find( app); | ||
67 | if ( it != m_relations.end() ) | ||
68 | tmp = it.data(); | ||
69 | return tmp; | ||
70 | } | ||
71 | void OPimRecord::clearRelation( const QString& app ) { | ||
72 | m_relations.remove( app ); | ||
73 | } | ||
74 | void OPimRecord::addRelation( const QString& app, int id ) { | ||
75 | |||
76 | QMap<QString, QArray<int> >::Iterator it; | ||
77 | QArray<int> tmp; | ||
78 | |||
79 | it = m_relations.find( app ); | ||
80 | if ( it == m_relations.end() ) { | ||
81 | tmp.resize(1 ); | ||
82 | tmp[0] = id; | ||
83 | }else{ | ||
84 | tmp = it.data(); | ||
85 | tmp.resize( tmp.size() + 1 ); | ||
86 | tmp[tmp.size() - 1] = id; | ||
87 | } | ||
88 | m_relations.replace( app, tmp ); | ||
89 | } | ||
90 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | ||
91 | |||
92 | QMap<QString, QArray<int> >::Iterator it; | ||
93 | QArray<int> tmp; | ||
94 | |||
95 | it = m_relations.find( app); | ||
96 | if ( it == m_relations.end() ) { | ||
97 | tmp = ids; | ||
98 | }else{ | ||
99 | tmp = it.data(); | ||
100 | int offset = tmp.size()-1; | ||
101 | tmp.resize( tmp.size() + ids.size() ); | ||
102 | for (uint i = 0; i < ids.size(); i++ ) { | ||
103 | tmp[offset+i] = ids[i]; | ||
104 | } | ||
105 | |||
106 | } | ||
107 | m_relations.replace( app, tmp ); | ||
108 | } | ||
109 | QString OPimRecord::crossToString()const { | ||
110 | QString str; | 56 | QString str; |
@@ -121,3 +67,3 @@ QString OPimRecord::crossToString()const { | |||
121 | return str; | 67 | return str; |
122 | } | 68 | }*/ |
123 | /* if uid = 1 assign a new one */ | 69 | /* if uid = 1 assign a new one */ |
@@ -132 +78,4 @@ Qtopia::UidGen &OPimRecord::uidGen() { | |||
132 | } | 78 | } |
79 | OPimXRefManager &OPimRecord::xrefmanager() { | ||
80 | return m_xrefman; | ||
81 | } | ||
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index d9ccad4..1642a5e 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -9,2 +9,3 @@ | |||
9 | 9 | ||
10 | #include <opie/opimxrefmanager.h> | ||
10 | 11 | ||
@@ -88,26 +89,8 @@ public: | |||
88 | /** | 89 | /** |
89 | * the related apps names | 90 | * returns a reference of the |
91 | * Cross Reference Manager | ||
92 | * Partner One is THIS PIM RECORD! | ||
93 | * Two is the Partner where we link to | ||
90 | */ | 94 | */ |
91 | QStringList relatedApps()const; | 95 | OPimXRefManager& xrefmanager(); |
92 | |||
93 | /** | ||
94 | * the realtions between an app | ||
95 | */ | ||
96 | QArray<int> relations( const QString& app )const; | ||
97 | |||
98 | /** | ||
99 | * clear the relations for all relations | ||
100 | * with app | ||
101 | */ | ||
102 | void clearRelation( const QString& app ); | ||
103 | |||
104 | /** | ||
105 | * add a relation | ||
106 | */ | ||
107 | void addRelation( const QString& app, int id ); | ||
108 | |||
109 | /** | ||
110 | * set the relations for an app | ||
111 | */ | ||
112 | void setRelations( const QString&, QArray<int> ids ); | ||
113 | 96 | ||
@@ -120,3 +103,3 @@ protected: | |||
120 | Qtopia::UidGen &uidGen(); | 103 | Qtopia::UidGen &uidGen(); |
121 | QString crossToString()const; | 104 | // QString crossToString()const; |
122 | 105 | ||
@@ -125,3 +108,3 @@ private: | |||
125 | OPimRecordPrivate *d; | 108 | OPimRecordPrivate *d; |
126 | QMap<QString, QArray<int> > m_relations; | 109 | OPimXRefManager m_xrefman; |
127 | static Qtopia::UidGen m_uidGen; | 110 | static Qtopia::UidGen m_uidGen; |
diff --git a/libopie2/opiepim/core/opimxref.cpp b/libopie2/opiepim/core/opimxref.cpp new file mode 100644 index 0000000..5cae871 --- a/dev/null +++ b/libopie2/opiepim/core/opimxref.cpp | |||
@@ -0,0 +1,47 @@ | |||
1 | #include "opimxref.h" | ||
2 | |||
3 | OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) | ||
4 | : m_partners(2) | ||
5 | { | ||
6 | m_partners[0] = one; | ||
7 | m_partners[1] = two; | ||
8 | } | ||
9 | OPimXRef::OPimXRef() | ||
10 | : m_partners(2) | ||
11 | { | ||
12 | |||
13 | } | ||
14 | OPimXRef::OPimXRef( const OPimXRef& ref) { | ||
15 | *this = ref; | ||
16 | } | ||
17 | OPimXRef::~OPimXRef() { | ||
18 | } | ||
19 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { | ||
20 | m_partners = ref.m_partners; | ||
21 | m_partners.detach(); | ||
22 | |||
23 | return* this; | ||
24 | } | ||
25 | bool OPimXRef::operator==( const OPimXRef& oper ) { | ||
26 | if ( m_partners == oper.m_partners ) return true; | ||
27 | |||
28 | return false; | ||
29 | } | ||
30 | OPimXRefPartner OPimXRef::partner( enum Partners par) const{ | ||
31 | return m_partners[par]; | ||
32 | } | ||
33 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { | ||
34 | m_partners[par] = part; | ||
35 | } | ||
36 | bool OPimXRef::containsString( const QString& string ) const{ | ||
37 | if ( m_partners[One].appName() == string || | ||
38 | m_partners[Two].appName() == string ) return true; | ||
39 | |||
40 | return false; | ||
41 | } | ||
42 | bool OPimXRef::containsUid( int uid ) const{ | ||
43 | if ( m_partners[One].uid() == uid || | ||
44 | m_partners[Two].uid() == uid ) return true; | ||
45 | |||
46 | return false; | ||
47 | } | ||
diff --git a/libopie2/opiepim/core/opimxref.h b/libopie2/opiepim/core/opimxref.h index 72154ac..354739a 100644 --- a/libopie2/opiepim/core/opimxref.h +++ b/libopie2/opiepim/core/opimxref.h | |||
@@ -22,5 +22,5 @@ public: | |||
22 | OPimXRef &operator=( const OPimXRef& ); | 22 | OPimXRef &operator=( const OPimXRef& ); |
23 | bool operator==( const OPimXRef ); | 23 | bool operator==( const OPimXRef& ); |
24 | 24 | ||
25 | OPimXRefPartner partner( enum Partners ); | 25 | OPimXRefPartner partner( enum Partners )const; |
26 | 26 | ||
@@ -28,2 +28,5 @@ public: | |||
28 | 28 | ||
29 | bool containsString( const QString& appName)const; | ||
30 | bool containsUid( int uid )const; | ||
31 | |||
29 | private: | 32 | private: |
diff --git a/libopie2/opiepim/core/opimxrefmanager.cpp b/libopie2/opiepim/core/opimxrefmanager.cpp new file mode 100644 index 0000000..d49f5f5 --- a/dev/null +++ b/libopie2/opiepim/core/opimxrefmanager.cpp | |||
@@ -0,0 +1,69 @@ | |||
1 | #include "opimxrefmanager.h" | ||
2 | |||
3 | |||
4 | OPimXRefManager::OPimXRefManager() { | ||
5 | } | ||
6 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { | ||
7 | m_list = ref.m_list; | ||
8 | } | ||
9 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { | ||
10 | m_list = ref.m_list; | ||
11 | return *this; | ||
12 | } | ||
13 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { | ||
14 | // if ( m_list == ref.m_list ) return true; | ||
15 | |||
16 | return false; | ||
17 | } | ||
18 | void OPimXRefManager::add( const OPimXRef& ref) { | ||
19 | m_list.append( ref ); | ||
20 | } | ||
21 | void OPimXRefManager::remove( const OPimXRef& ref) { | ||
22 | m_list.remove( ref ); | ||
23 | } | ||
24 | void OPimXRefManager::replace( const OPimXRef& ref) { | ||
25 | m_list.remove( ref ); | ||
26 | m_list.append( ref ); | ||
27 | } | ||
28 | void OPimXRefManager::clear() { | ||
29 | m_list.clear(); | ||
30 | } | ||
31 | QStringList OPimXRefManager::apps()const { | ||
32 | OPimXRef::ValueList::ConstIterator it; | ||
33 | QStringList list; | ||
34 | |||
35 | QString str; | ||
36 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | ||
37 | str = (*it).partner( OPimXRef::One ).appName(); | ||
38 | if ( !list.contains( str ) ) list << str; | ||
39 | |||
40 | str = (*it).partner( OPimXRef::Two ).appName(); | ||
41 | if ( !list.contains( str ) ) list << str; | ||
42 | } | ||
43 | return list; | ||
44 | } | ||
45 | OPimXRef::ValueList OPimXRefManager::list()const { | ||
46 | return m_list; | ||
47 | } | ||
48 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ | ||
49 | OPimXRef::ValueList list; | ||
50 | OPimXRef::ValueList::ConstIterator it; | ||
51 | |||
52 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | ||
53 | if ( (*it).containsString( appName ) ) | ||
54 | list.append( (*it) ); | ||
55 | } | ||
56 | |||
57 | return list; | ||
58 | } | ||
59 | OPimXRef::ValueList OPimXRefManager::list( int uid )const { | ||
60 | OPimXRef::ValueList list; | ||
61 | OPimXRef::ValueList::ConstIterator it; | ||
62 | |||
63 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | ||
64 | if ( (*it).containsUid( uid ) ) | ||
65 | list.append( (*it) ); | ||
66 | } | ||
67 | |||
68 | return list; | ||
69 | } | ||
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h index 147895d..9b003a3 100644 --- a/libopie2/opiepim/core/opimxrefmanager.h +++ b/libopie2/opiepim/core/opimxrefmanager.h | |||
@@ -3,2 +3,4 @@ | |||
3 | 3 | ||
4 | #include <qstringlist.h> | ||
5 | |||
4 | #include <opie/opimxref.h> | 6 | #include <opie/opimxref.h> |
@@ -33,2 +35,5 @@ public: | |||
33 | OPimXRef::ValueList list( int uid )const; | 35 | OPimXRef::ValueList list( int uid )const; |
36 | |||
37 | private: | ||
38 | OPimXRef::ValueList m_list; | ||
34 | }; | 39 | }; |
diff --git a/libopie2/opiepim/core/opimxrefpartner.cpp b/libopie2/opiepim/core/opimxrefpartner.cpp new file mode 100644 index 0000000..028f4e6 --- a/dev/null +++ b/libopie2/opiepim/core/opimxrefpartner.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include "opimxrefpartner.h" | ||
2 | |||
3 | OPimXRefPartner::OPimXRefPartner( const QString& appName, | ||
4 | int uid, int field ) | ||
5 | : m_app(appName), m_uid(uid), m_field( field ) { | ||
6 | } | ||
7 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { | ||
8 | *this = ref; | ||
9 | } | ||
10 | OPimXRefPartner::~OPimXRefPartner() { | ||
11 | } | ||
12 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { | ||
13 | m_app = par.m_app; | ||
14 | m_uid = par.m_uid; | ||
15 | m_field = par.m_field; | ||
16 | |||
17 | return *this; | ||
18 | } | ||
19 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { | ||
20 | if ( m_app != par.m_app ) return false; | ||
21 | if ( m_uid != par.m_uid ) return false; | ||
22 | if ( m_field != par.m_field ) return false; | ||
23 | |||
24 | return true; | ||
25 | } | ||
26 | QString OPimXRefPartner::appName()const { | ||
27 | return m_app; | ||
28 | } | ||
29 | int OPimXRefPartner::uid()const { | ||
30 | return m_uid; | ||
31 | } | ||
32 | int OPimXRefPartner::field()const { | ||
33 | return m_field; | ||
34 | } | ||
35 | void OPimXRefPartner::setAppName( const QString& appName ) { | ||
36 | m_app = appName; | ||
37 | } | ||
38 | void OPimXRefPartner::setUid( int uid ) { | ||
39 | m_uid = uid; | ||
40 | } | ||
41 | void OPimXRefPartner::setField( int field ) { | ||
42 | m_field = field; | ||
43 | } | ||