summaryrefslogtreecommitdiffabout
path: root/kabc/field.h
Unidiff
Diffstat (limited to 'kabc/field.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.h178
1 files changed, 178 insertions, 0 deletions
diff --git a/kabc/field.h b/kabc/field.h
new file mode 100644
index 0000000..9e06597
--- a/dev/null
+++ b/kabc/field.h
@@ -0,0 +1,178 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk
24
25$Id$
26*/
27
28#ifndef KABC_FIELD_H
29#define KABC_FIELD_H
30
31#include <qstring.h>
32#include <qvaluelist.h>
33
34#include "addressee.h"
35
36class KConfig;
37
38namespace KABC {
39
40class Field
41{
42 class FieldImpl;
43 friend class FieldImpl;
44
45public:
46 typedef QValueList<Field *> List;
47
48 /**
49 * @li @p All -
50 * @li @p Frequent -
51 * @li @p Address -
52 * @li @p Email -
53 * @li @p Personal -
54 * @li @p Organization -
55 * @li @p CustomCategory -
56 */
57 enum FieldCategory
58 {
59 All = 0x0,
60 Frequent = 0x01,
61 Address = 0x02,
62 Email = 0x04,
63 Personal = 0x08,
64 Organization = 0x10,
65 CustomCategory = 0x20
66 };
67
68 /**
69 * Returns the translated label for this field.
70 */
71 virtual QString label();
72
73 /**
74 * Returns the ored categories the field belongs to.
75 */
76 virtual int category();
77
78 /**
79 * Returns the translated label for field category.
80 */
81 static QString categoryLabel( int category );
82
83 /**
84 * Returns a string representation of the value the field has in the given
85 * Addressee. Returns QString::null, if it is not possible to convert the
86 * value to a string.
87 */
88 virtual QString value( const KABC::Addressee & );
89
90 /**
91 * Sets the value of the field in the given Addressee. Returns true on success
92 * or false, if the given string couldn't be converted to a valid value.
93 */
94 virtual bool setValue( KABC::Addressee &, const QString & );
95
96 /**
97 * Returns, if the field is a user-defined field.
98 */
99 virtual bool isCustom();
100
101 /**
102 * Returns, if the field is equal with @param field.
103 */
104 virtual bool equals( Field *field );
105
106 /**
107 * Returns a list of all fields.
108 */
109 static Field::List allFields();
110
111 /**
112 * Returns a list of the default fields.
113 */
114 static Field::List defaultFields();
115
116 /**
117 * Creates a custom field.
118 *
119 * @param label The label for this field
120 * @param category The category of this field
121 * @param key Unique key for this field
122 * @param app Unique app name for this field
123 */
124 static Field *createCustomField( const QString &label, int category,
125 const QString &key, const QString &app );
126
127 /**
128 * Delete all fields from list.
129 */
130 static void deleteFields();
131
132 /**
133 * Save the field settings to a config file.
134 *
135 * @param cfg The config file object
136 * @param identifier The unique identifier
137 * @param fields The list of the fields
138 */
139 static void saveFields( KConfig *cfg, const QString &identifier,
140 const Field::List &fields );
141 /**
142 * This is the same as above, with the difference, that
143 * the list is stored in KGlobal::config() in group "KABCFields".
144 */
145 static void saveFields( const QString &identifier,
146 const Field::List &fields );
147
148 /**
149 * Load the field settings from a config file.
150 *
151 * @param cfg The config file object
152 * @param identifier The unique identifier
153 */
154 static Field::List restoreFields( KConfig *cfg, const QString &identifier );
155
156 /**
157 * This is the same as above, with the difference, that
158 * the list is loaded from KGlobal::config() from group "KABCFields".
159 */
160 static Field::List restoreFields( const QString &identifier );
161
162protected:
163 static void createField( int id, int category = 0 );
164 static void createDefaultField( int id, int category = 0 );
165
166private:
167 Field( FieldImpl * );
168 virtual ~Field();
169
170 FieldImpl *mImpl;
171
172 static Field::List mAllFields;
173 static Field::List mDefaultFields;
174 static Field::List mCustomFields;
175};
176
177}
178#endif