summaryrefslogtreecommitdiff
path: root/libopie/pim/opimrecord.cpp
authorzecke <zecke>2002-09-20 12:59:29 (UTC)
committer zecke <zecke>2002-09-20 12:59:29 (UTC)
commita05c10c9744020be31c3038b2de3401b5cc673fb (patch) (side-by-side diff)
tree20d059bf00fc1199c34a60a8be4cb842ebfe4d14 /libopie/pim/opimrecord.cpp
parent7099778ab711f78cfd86dadad1b8af993e008f38 (diff)
downloadopie-a05c10c9744020be31c3038b2de3401b5cc673fb.zip
opie-a05c10c9744020be31c3038b2de3401b5cc673fb.tar.gz
opie-a05c10c9744020be31c3038b2de3401b5cc673fb.tar.bz2
Our new common template based start for Accessing and Manipulating
the Records The CROSS_REFERENCE branch will get ported to it. We use templates for several reasons They allow us to share code and to be easily extended I've to make them not inline to save memory... I've to port all DBs and Record related classes
Diffstat (limited to 'libopie/pim/opimrecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
new file mode 100644
index 0000000..95de1df
--- a/dev/null
+++ b/libopie/pim/opimrecord.cpp
@@ -0,0 +1,90 @@
+#include "opimrecord.h"
+
+OPimRecord::OPimRecord( int uid )
+ : Qtopia::Record() {
+ setUid( uid );
+ if ( uid == 1 )
+ assignUid();
+}
+OPimRecord::~OPimRecord() {
+}
+OPimRecord::OPimRecord( OPimRecord& rec )
+ : Qtopia::Record( rec )
+{
+ (*this) = rec;
+}
+
+OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
+ /* how do I call the parent copy operator ? */
+ setUid( rec.uid() );
+ setCategories( rec.categories() );
+ return *this;
+}
+QStringList OPimRecord::categoryNames()const {
+ QStringList list;
+
+ return list;
+}
+void OPimRecord::setCategoryName( const QStringList& ) {
+
+}
+void OPimRecord::addCategoryName( const QString& ) {
+
+}
+bool OPimRecord::isEmpty()const {
+ return ( uid() == 0 );
+}
+QStringList OPimRecord::relatedApps()const{
+ QStringList list;
+ QMap<QString, QArray<int> >::ConstIterator it;
+ for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
+ list << it.key();
+ }
+ return list;
+}
+QArray<int> OPimRecord::relations(const QString& app )const {
+ QArray<int> tmp;
+ QMap<QString, QArray<int> >::ConstIterator it;
+ it = m_relations.find( app);
+ if ( it != m_relations.end() )
+ tmp = it.data();
+ return tmp;
+}
+void OPimRecord::clearRelation( const QString& app ) {
+ m_relations.remove( app );
+}
+void OPimRecord::addRelation( const QString& app, int id ) {
+
+ QMap<QString, QArray<int> >::Iterator it;
+ QArray<int> tmp;
+
+ it = m_relations.find( app );
+ if ( it == m_relations.end() ) {
+ tmp.resize(1 );
+ tmp[0] = id;
+ }else{
+ tmp = it.data();
+ tmp.resize( tmp.size() + 1 );
+ tmp[tmp.size() - 1] = id;
+ }
+ m_relations.replace( app, tmp );
+}
+void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
+
+ QMap<QString, QArray<int> >::Iterator it;
+ QArray<int> tmp;
+
+ it = m_relations.find( app);
+ if ( it == m_relations.end() ) {
+ tmp = ids;
+ }else{
+ tmp = it.data();
+ int offset = tmp.size()-1;
+ tmp.resize( tmp.size() + ids.size() );
+ for (uint i = 0; i < ids.size(); i++ ) {
+ tmp[offset+i] = ids[i];
+ }
+
+ }
+ m_relations.replace( app, tmp );
+}