summaryrefslogtreecommitdiff
path: root/library/backend/palmtoprecord.h
Unidiff
Diffstat (limited to 'library/backend/palmtoprecord.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/palmtoprecord.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/library/backend/palmtoprecord.h b/library/backend/palmtoprecord.h
index 0372011..72f7d1c 100644
--- a/library/backend/palmtoprecord.h
+++ b/library/backend/palmtoprecord.h
@@ -1,94 +1,95 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free 7** GNU General Public License version 2 as published by the Free Software
8** Software Foundation and appearing in the file LICENSE.GPL included 8** Foundation and appearing in the file LICENSE.GPL included in the
9** in the packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** PARTICULAR PURPOSE.
14** 13**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 15**
17** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 17** not clear to you.
19** 18**
20**********************************************************************/ 19**********************************************************************/
21
22#ifndef QTPALMTOP_RECORD_H 20#ifndef QTPALMTOP_RECORD_H
23#define QTPALMTOP_RECORD_H 21#define QTPALMTOP_RECORD_H
24
25#include <qglobal.h> 22#include <qglobal.h>
26#include "qpcglobal.h" 23#include "qpcglobal.h"
27#include "palmtopuidgen.h" 24#include "palmtopuidgen.h"
28#include <qarray.h> 25#include <qarray.h>
29#include <qmap.h> 26#include <qmap.h>
30 27
31#if defined(QPC_TEMPLATEDLL) 28#if defined(QPC_TEMPLATEDLL)
32// MOC_SKIP_BEGIN 29// MOC_SKIP_BEGIN
33template class QPC_EXPORT QMap<QString, QString>; 30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>;
34// MOC_SKIP_END 31// MOC_SKIP_END
35#endif 32#endif
36 33
37class QRegExp; 34class QRegExp;
38namespace Qtopia { 35namespace Qtopia {
39 36
40class RecordPrivate; 37class RecordPrivate;
41class QPC_EXPORT Record 38class QPC_EXPORT Record
42{ 39{
43public: 40public:
44 Record() : mUid(0), mCats() { } 41 Record() : mUid(0), mCats() { }
45 Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { } 42 Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { }
46 virtual ~Record() { } 43 virtual ~Record() { }
47 44
48 Record &operator=( const Record &c ); 45 Record &operator=( const Record &c );
49 46
50 virtual bool match( const QRegExp & ) const { return FALSE; } 47 virtual bool match( const QRegExp & ) const { return FALSE; }
51 48
52 void setCategories( const QArray<int> &v ) { mCats = v; } 49 void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); }
53 void setCategories( int single ); 50 void setCategories( int single );
54 const QArray<int> &categories() const { return mCats; } 51 const QArray<int> &categories() const { return mCats; }
55 52
53 void reassignCategoryId( int oldId, int newId )
54 {
55 int index = mCats.find( oldId );
56 if ( index >= 0 )
57 mCats[index] = newId;
58 }
59
56 int uid() const { return mUid; }; 60 int uid() const { return mUid; };
57 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); } 61 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); }
58 bool isValidUid() const { return mUid != 0; } 62 bool isValidUid() const { return mUid != 0; }
59 void assignUid() { setUid( uidGen().generate() ); } 63 void assignUid() { setUid( uidGen().generate() ); }
60 64
61 virtual QString customField(const QString &) const; 65 virtual QString customField(const QString &) const;
62 virtual void setCustomField(const QString &, const QString &); 66 virtual void setCustomField(const QString &, const QString &);
63 virtual void removeCustomField(const QString &); 67 virtual void removeCustomField(const QString &);
64 68
65 virtual bool operator == ( const Record &r ) const 69 virtual bool operator == ( const Record &r ) const
66{ return mUid == r.mUid; } 70{ return mUid == r.mUid; }
67 virtual bool operator != ( const Record &r ) const 71 virtual bool operator != ( const Record &r ) const
68{ return mUid != r.mUid; } 72{ return mUid != r.mUid; }
69 73
70 // convenience methods provided for loading and saving to xml 74 // convenience methods provided for loading and saving to xml
71 static QString idsToString( const QArray<int> &ids ); 75 static QString idsToString( const QArray<int> &ids );
72 // convenience methods provided for loading and saving to xml 76 // convenience methods provided for loading and saving to xml
73 static QArray<int> idsFromString( const QString &str ); 77 static QArray<int> idsFromString( const QString &str );
74 78
75 // for debugging 79 // for debugging
76 static void dump( const QMap<int, QString> &map ); 80 static void dump( const QMap<int, QString> &map );
77 81
78protected: 82protected:
79 virtual UidGen &uidGen() = 0; 83 virtual UidGen &uidGen() = 0;
80
81 virtual QString customToXml() const; 84 virtual QString customToXml() const;
82
83private: 85private:
84 int mUid; 86 int mUid;
85 QArray<int> mCats; 87 QArray<int> mCats;
86
87 QMap<QString, QString> customMap; 88 QMap<QString, QString> customMap;
88
89 RecordPrivate *d; 89 RecordPrivate *d;
90}; 90};
91 91
92} 92}
93 93
94#endif 94#endif
95