Diffstat (limited to 'noncore/unsupported/libopie/pim/opimrecord.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/libopie/pim/opimrecord.h | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/opimrecord.h b/noncore/unsupported/libopie/pim/opimrecord.h new file mode 100644 index 0000000..3d774e2 --- a/dev/null +++ b/noncore/unsupported/libopie/pim/opimrecord.h | |||
@@ -0,0 +1,158 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | ||
2 | #define OPIE_PIM_RECORD_H | ||
3 | |||
4 | #include <qdatastream.h> | ||
5 | #include <qmap.h> | ||
6 | #include <qstring.h> | ||
7 | #include <qstringlist.h> | ||
8 | |||
9 | /* | ||
10 | * we need to get customMap which is private... | ||
11 | */ | ||
12 | #define private protected | ||
13 | #include <qpe/palmtoprecord.h> | ||
14 | #undef private | ||
15 | |||
16 | #include <opie/opimxrefmanager.h> | ||
17 | |||
18 | /** | ||
19 | * This is the base class for | ||
20 | * all PIM Records | ||
21 | * | ||
22 | */ | ||
23 | class OPimRecord : public Qtopia::Record { | ||
24 | public: | ||
25 | /** | ||
26 | * c'tor | ||
27 | * uid of 0 isEmpty | ||
28 | * uid of 1 will be assigned a new one | ||
29 | */ | ||
30 | OPimRecord(int uid = 0); | ||
31 | ~OPimRecord(); | ||
32 | |||
33 | /** | ||
34 | * copy c'tor | ||
35 | */ | ||
36 | OPimRecord( const OPimRecord& rec ); | ||
37 | |||
38 | /** | ||
39 | * copy operator | ||
40 | */ | ||
41 | OPimRecord &operator=( const OPimRecord& ); | ||
42 | |||
43 | /** | ||
44 | * category names resolved | ||
45 | */ | ||
46 | QStringList categoryNames( const QString& appname )const; | ||
47 | |||
48 | /** | ||
49 | * set category names they will be resolved | ||
50 | */ | ||
51 | void setCategoryNames( const QStringList& ); | ||
52 | |||
53 | /** | ||
54 | * addCategoryName adds a name | ||
55 | * to the internal category list | ||
56 | */ | ||
57 | void addCategoryName( const QString& ); | ||
58 | |||
59 | /** | ||
60 | * if a Record isEmpty | ||
61 | * it's empty if it's 0 | ||
62 | */ | ||
63 | virtual bool isEmpty()const; | ||
64 | |||
65 | /** | ||
66 | * toRichText summary | ||
67 | */ | ||
68 | virtual QString toRichText()const = 0; | ||
69 | |||
70 | /** | ||
71 | * a small one line summary | ||
72 | */ | ||
73 | virtual QString toShortText()const = 0; | ||
74 | |||
75 | /** | ||
76 | * the name of the Record | ||
77 | */ | ||
78 | virtual QString type()const = 0; | ||
79 | |||
80 | /** | ||
81 | * matches the Records the regular expression? | ||
82 | */ | ||
83 | virtual bool match( const QString ®exp ) const | ||
84 | {setLastHitField( -1 ); | ||
85 | return Qtopia::Record::match(QRegExp(regexp));}; | ||
86 | |||
87 | /** | ||
88 | * if implemented this function returns which item has been | ||
89 | * last hit by the match() function. | ||
90 | * or -1 if not implemented or no hit has occured | ||
91 | */ | ||
92 | int lastHitField()const; | ||
93 | |||
94 | /** | ||
95 | * converts the internal structure to a map | ||
96 | */ | ||
97 | virtual QMap<int, QString> toMap()const = 0; | ||
98 | // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) | ||
99 | |||
100 | /** | ||
101 | * key value representation of extra items | ||
102 | */ | ||
103 | QMap<QString, QString> toExtraMap()const; | ||
104 | void setExtraMap( const QMap<QString, QString>& ); | ||
105 | |||
106 | /** | ||
107 | * the name for a recordField | ||
108 | */ | ||
109 | virtual QString recordField(int)const = 0; | ||
110 | |||
111 | /** | ||
112 | * returns a reference of the | ||
113 | * Cross Reference Manager | ||
114 | * Partner 'One' is THIS PIM RECORD! | ||
115 | * 'Two' is the Partner where we link to | ||
116 | */ | ||
117 | OPimXRefManager& xrefmanager(); | ||
118 | |||
119 | /** | ||
120 | * set the uid | ||
121 | */ | ||
122 | virtual void setUid( int uid ); | ||
123 | |||
124 | /* | ||
125 | * used inside the Templates for casting | ||
126 | * REIMPLEMENT in your .... | ||
127 | */ | ||
128 | static int rtti(); | ||
129 | |||
130 | /** | ||
131 | * some marshalling and de marshalling code | ||
132 | * saves the OPimRecord | ||
133 | * to and from a DataStream | ||
134 | */ | ||
135 | virtual bool loadFromStream(QDataStream& ); | ||
136 | virtual bool saveToStream( QDataStream& stream )const; | ||
137 | |||
138 | protected: | ||
139 | // need to be const cause it is called from const methods | ||
140 | mutable int m_lastHit; | ||
141 | void setLastHitField( int lastHit )const; | ||
142 | Qtopia::UidGen &uidGen(); | ||
143 | // QString crossToString()const; | ||
144 | |||
145 | private: | ||
146 | class OPimRecordPrivate; | ||
147 | OPimRecordPrivate *d; | ||
148 | OPimXRefManager m_xrefman; | ||
149 | static Qtopia::UidGen m_uidGen; | ||
150 | |||
151 | private: | ||
152 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | ||
153 | OPimXRefPartner partner( QDataStream& ); | ||
154 | }; | ||
155 | |||
156 | |||
157 | |||
158 | #endif | ||