kabc
field.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KABC_FIELD_H 00022 #define KABC_FIELD_H 00023 00024 #include "addressee.h" 00025 #include <QtCore/QString> 00026 00027 class KConfigGroup; 00028 00029 namespace KABC { 00030 00046 class KABC_EXPORT Field 00047 { 00048 public: 00052 typedef QList<Field *> List; 00053 00057 enum FieldCategory { 00061 All = 0x0, 00065 Frequent = 0x01, 00069 Address = 0x02, 00074 Email = 0x04, 00078 Personal = 0x08, 00083 Organization = 0x10, 00087 CustomCategory = 0x20 00088 }; 00089 00093 virtual QString label(); 00094 00098 virtual int category(); 00099 00106 static QString categoryLabel( int category ); 00107 00115 virtual QString value( const KABC::Addressee & ); 00116 00123 virtual bool setValue( KABC::Addressee &, const QString & ); 00124 00128 QString sortKey( const KABC::Addressee & ); 00129 00135 virtual bool isCustom(); 00136 00143 virtual bool equals( Field *field ); 00144 00148 static Field::List allFields(); 00149 00153 static Field::List defaultFields(); 00154 00163 static Field *createCustomField( const QString &label, int category, 00164 const QString &key, const QString &app ); 00165 00169 static void deleteFields(); 00170 00178 static void saveFields( KConfigGroup &cfg, const QString &identifier, 00179 const Field::List &fields ); 00188 static void saveFields( const QString &identifier, 00189 const Field::List &fields ); 00190 00197 static Field::List restoreFields( const KConfigGroup &cfg, const QString &identifier ); 00198 00206 static Field::List restoreFields( const QString &identifier ); 00207 00208 protected: 00217 static void createField( int id, int category = 0 ); 00218 00227 static void createDefaultField( int id, int category = 0 ); 00228 00229 private: 00230 class Private; 00231 00232 Field( Private * ); 00233 virtual ~Field(); 00234 00235 Private *const d; 00236 }; 00237 00238 } 00239 #endif