summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-09-21 15:16:59 (UTC)
committer zecke <zecke>2002-09-21 15:16:59 (UTC)
commit978dcbe44df66d4efbbc12bdacdcb293358581fd (patch) (unidiff)
tree83c4eb4ccaf4eefbfc871666379d4e79a6a4b3ef /libopie
parente6c53c4d7317e766235449535b22d0d2fe709214 (diff)
downloadopie-978dcbe44df66d4efbbc12bdacdcb293358581fd.zip
opie-978dcbe44df66d4efbbc12bdacdcb293358581fd.tar.gz
opie-978dcbe44df66d4efbbc12bdacdcb293358581fd.tar.bz2
additions
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index e510f4e..88b6fde 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,111 +1,127 @@
1#include <qpe/categories.h>
2#include <qpe/categoryselect.h>
3
1#include "opimrecord.h" 4#include "opimrecord.h"
2 5
3OPimRecord::OPimRecord( int uid ) 6OPimRecord::OPimRecord( int uid )
4 : Qtopia::Record() { 7 : Qtopia::Record() {
5 8
6 setUid( uid ); 9 setUid( uid );
7} 10}
8OPimRecord::~OPimRecord() { 11OPimRecord::~OPimRecord() {
9} 12}
10OPimRecord::OPimRecord( const OPimRecord& rec ) 13OPimRecord::OPimRecord( const OPimRecord& rec )
11 : Qtopia::Record( rec ) 14 : Qtopia::Record( rec )
12{ 15{
13 (*this) = rec; 16 (*this) = rec;
14} 17}
15 18
16OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 19OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
17 Qtopia::Record::operator=( rec ); 20 Qtopia::Record::operator=( rec );
18 m_relations = rec.m_relations; 21 m_relations = rec.m_relations;
19 22
20 return *this; 23 return *this;
21} 24}
25/*
26 * category names
27 */
22QStringList OPimRecord::categoryNames()const { 28QStringList OPimRecord::categoryNames()const {
23 QStringList list; 29 QStringList list;
30 QArray<int> cats = categories();
31 Categories catDB;
32 catDB.load( categoryFileName() );
33
34 for (uint i = 0; i < cats.count(); i++ ) {
35 list << catDB.label("Todo List", cats[i] );
36 }
24 37
25 return list; 38 return list;
26} 39}
27void OPimRecord::setCategoryNames( const QStringList& ) { 40void OPimRecord::setCategoryNames( const QStringList& ) {
28 41
29} 42}
30void OPimRecord::addCategoryName( const QString& ) { 43void OPimRecord::addCategoryName( const QString& ) {
44 Categories catDB;
45 catDB.load( categoryFileName() );
46
31 47
32} 48}
33bool OPimRecord::isEmpty()const { 49bool OPimRecord::isEmpty()const {
34 return ( uid() == 0 ); 50 return ( uid() == 0 );
35} 51}
36QStringList OPimRecord::relatedApps()const{ 52QStringList OPimRecord::relatedApps()const{
37 QStringList list; 53 QStringList list;
38 QMap<QString, QArray<int> >::ConstIterator it; 54 QMap<QString, QArray<int> >::ConstIterator it;
39 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 55 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
40 list << it.key(); 56 list << it.key();
41 } 57 }
42 return list; 58 return list;
43} 59}
44QArray<int> OPimRecord::relations(const QString& app )const { 60QArray<int> OPimRecord::relations(const QString& app )const {
45 QArray<int> tmp; 61 QArray<int> tmp;
46 QMap<QString, QArray<int> >::ConstIterator it; 62 QMap<QString, QArray<int> >::ConstIterator it;
47 it = m_relations.find( app); 63 it = m_relations.find( app);
48 if ( it != m_relations.end() ) 64 if ( it != m_relations.end() )
49 tmp = it.data(); 65 tmp = it.data();
50 return tmp; 66 return tmp;
51} 67}
52void OPimRecord::clearRelation( const QString& app ) { 68void OPimRecord::clearRelation( const QString& app ) {
53 m_relations.remove( app ); 69 m_relations.remove( app );
54} 70}
55void OPimRecord::addRelation( const QString& app, int id ) { 71void OPimRecord::addRelation( const QString& app, int id ) {
56 72
57 QMap<QString, QArray<int> >::Iterator it; 73 QMap<QString, QArray<int> >::Iterator it;
58 QArray<int> tmp; 74 QArray<int> tmp;
59 75
60 it = m_relations.find( app ); 76 it = m_relations.find( app );
61 if ( it == m_relations.end() ) { 77 if ( it == m_relations.end() ) {
62 tmp.resize(1 ); 78 tmp.resize(1 );
63 tmp[0] = id; 79 tmp[0] = id;
64 }else{ 80 }else{
65 tmp = it.data(); 81 tmp = it.data();
66 tmp.resize( tmp.size() + 1 ); 82 tmp.resize( tmp.size() + 1 );
67 tmp[tmp.size() - 1] = id; 83 tmp[tmp.size() - 1] = id;
68 } 84 }
69 m_relations.replace( app, tmp ); 85 m_relations.replace( app, tmp );
70} 86}
71void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 87void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
72 88
73 QMap<QString, QArray<int> >::Iterator it; 89 QMap<QString, QArray<int> >::Iterator it;
74 QArray<int> tmp; 90 QArray<int> tmp;
75 91
76 it = m_relations.find( app); 92 it = m_relations.find( app);
77 if ( it == m_relations.end() ) { 93 if ( it == m_relations.end() ) {
78 tmp = ids; 94 tmp = ids;
79 }else{ 95 }else{
80 tmp = it.data(); 96 tmp = it.data();
81 int offset = tmp.size()-1; 97 int offset = tmp.size()-1;
82 tmp.resize( tmp.size() + ids.size() ); 98 tmp.resize( tmp.size() + ids.size() );
83 for (uint i = 0; i < ids.size(); i++ ) { 99 for (uint i = 0; i < ids.size(); i++ ) {
84 tmp[offset+i] = ids[i]; 100 tmp[offset+i] = ids[i];
85 } 101 }
86 102
87 } 103 }
88 m_relations.replace( app, tmp ); 104 m_relations.replace( app, tmp );
89} 105}
90QString OPimRecord::crossToString()const { 106QString OPimRecord::crossToString()const {
91 QString str; 107 QString str;
92 QMap<QString, QArray<int> >::ConstIterator it; 108 QMap<QString, QArray<int> >::ConstIterator it;
93 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 109 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
94 QArray<int> id = it.data(); 110 QArray<int> id = it.data();
95 for ( uint i = 0; i < id.size(); ++i ) { 111 for ( uint i = 0; i < id.size(); ++i ) {
96 str += it.key() + "," + QString::number( i ) + ";"; 112 str += it.key() + "," + QString::number( i ) + ";";
97 } 113 }
98 } 114 }
99 str = str.remove( str.length()-1, 1); // strip the ; 115 str = str.remove( str.length()-1, 1); // strip the ;
100 //qWarning("IDS " + str ); 116 //qWarning("IDS " + str );
101 117
102 return str; 118 return str;
103} 119}
104/* if uid = 1 assign a new one */ 120/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) { 121void OPimRecord::setUid( int uid ) {
106 122
107 if ( uid == 1) 123 if ( uid == 1)
108 uid = uidGen().generate(); 124 uid = uidGen().generate();
109 125
110 Qtopia::Record::setUid( uid ); 126 Qtopia::Record::setUid( uid );
111}; 127};