kaddressbook Library API Documentation

imeditorwidget.h

00001 /*
00002     imeditorwidget.h
00003 
00004     IM addresses editor widget for KAddressbook
00005 
00006     Copyright (c) 2004 Will Stephenson   <lists@stevello.free-online.co.uk>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 
00022     As a special exception, permission is given to link this program
00023     with any edition of Qt, and distribute the resulting executable,
00024     without including the source code for Qt in the source distribution.
00025 */
00026 
00027 #ifndef IMEDITORWIDGET_H
00028 #define IMEDITORWIDGET_H
00029 
00030 #include <qvaluelist.h>
00031 #include <klistview.h>
00032 
00033 #include "contacteditorwidget.h"
00034 #include "imeditorbase.h"
00035 
00036 class AddressWidget;
00037 class KPluginInfo;
00038 
00039 enum IMContext { Any, Home, Work };
00040 
00041 /* Note regarding Context:
00042  * It wasn not possible to get an idea of Context into Kopete in time for KDE 3.3,
00043  * so it has been removed from the UI and functionally disabled in the code.
00044  */
00045 
00049 class IMEditorWidget : public KAB::ContactEditorWidget
00050 {
00051     Q_OBJECT
00052 
00053     public:
00054         IMEditorWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
00055         ~IMEditorWidget() {};
00056 
00060         void loadContact( KABC::Addressee *addr );
00061         void storeContact( KABC::Addressee *addr );
00062         void setReadOnly( bool readOnly );
00063         QValueList<KPluginInfo *> availableProtocols() const;
00064     protected slots:
00065         void slotUpdateButtons();
00066         void slotAdd();
00067         void slotEdit();
00068         void slotDelete();
00069     protected:
00073         static void splitField( const QString &str, QString &app, QString &name, QString &value );
00077         KPluginInfo * protocolFromString( const QString fieldValue );
00078     private:
00079         bool mReadOnly;
00080         IMEditorBase *mWidget;
00081         // Used to track changed protocols to reduce KABC writes
00082         QValueList<KPluginInfo *> mChangedProtocols;
00083         QValueList<KPluginInfo *> mProtocols;
00084 };
00085 
00090 // VCard has been disabled as there is no standard VCard location to store IM addresses yet.
00091 class IMAddressLVI : public KListViewItem
00092 {
00093     public:
00094         IMAddressLVI( KListView *parent, KPluginInfo * protocol, QString address, IMContext context = Any );
00095         void setAddress( const QString &address );
00096         void setProtocol( KPluginInfo * protocol );
00097         void setContext( IMContext context );
00098         void activate();
00099         KPluginInfo * protocol() const;
00100         QString address() const;
00101         IMContext context() const;
00102     private:
00103         KPluginInfo * mProtocol;
00104         IMContext mContext;
00105         
00106 };
00107 
00111 class IMEditorWidgetFactory : public KAB::ContactEditorWidgetFactory
00112 {
00113     public:
00114         IMEditorWidgetFactory() {};
00115         KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
00116         {
00117             return new IMEditorWidget( ab, parent, name );
00118         }
00119 
00120         QString pageTitle() const;
00121         QString pageIdentifier() const;
00122 };
00123 
00124 
00125 #endif
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu May 3 20:21:50 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003