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