imeditorwidget.h
00001 /* 00002 IM addresses editor widget for KAddressbook 00003 00004 Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #ifndef IMEDITORWIDGET_H 00026 #define IMEDITORWIDGET_H 00027 00028 #include <tqvaluelist.h> 00029 #include <klistview.h> 00030 #include <kdialogbase.h> 00031 00032 #include "contacteditorwidget.h" 00033 00034 00035 class AddressWidget; 00036 class KPluginInfo; 00037 class IMEditorBase; 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 KDialogBase 00050 { 00051 Q_OBJECT 00052 TQ_OBJECT 00053 00054 public: 00055 IMEditorWidget( TQWidget *parent, const TQString &preferredIM, const char *name = 0 ); 00056 ~IMEditorWidget() {}; 00057 00058 void loadContact( KABC::Addressee *addr ); 00059 void storeContact( KABC::Addressee *addr ); 00060 void setReadOnly( bool readOnly ); 00061 TQValueList<KPluginInfo *> availableProtocols() const; 00062 bool isModified() const; 00063 TQString preferred() const; 00064 00065 protected slots: 00066 void slotUpdateButtons(); 00067 void slotAdd(); 00068 void slotEdit(); 00069 void slotDelete(); 00070 void slotSetStandard(); 00071 00072 protected: 00076 static void splitField( const TQString &str, TQString &app, TQString &name, TQString &value ); 00077 00081 KPluginInfo * protocolFromString( const TQString &fieldValue ) const; 00082 00083 private: 00084 bool mReadOnly; 00085 bool mModified; 00086 TQString mPreferred; 00087 IMEditorBase *mWidget; 00088 void setModified( bool modified ); 00089 00090 // Used to track changed protocols to reduce KABC writes 00091 TQValueList<KPluginInfo *> mChangedProtocols; 00092 TQValueList<KPluginInfo *> mProtocols; 00093 }; 00094 00099 // VCard has been disabled as there is no standard VCard location to store IM addresses yet. 00100 class IMAddressLVI : public KListViewItem 00101 { 00102 public: 00103 IMAddressLVI( KListView *parent, KPluginInfo * protocol, 00104 const TQString &address, const IMContext &context = Any ); 00105 00106 void setAddress( const TQString &address ); 00107 void setProtocol( KPluginInfo * protocol ); 00108 void setContext( const IMContext &context ); 00109 void activate(); 00110 00111 KPluginInfo * protocol() const; 00112 TQString address() const; 00113 IMContext context() const; 00114 00115 void setPreferred( bool preferred ); 00116 bool preferred() const; 00117 00118 protected: 00119 virtual void paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment ); 00120 00121 private: 00122 KPluginInfo * mProtocol; 00123 bool mPreferred; 00124 IMContext mContext; 00125 TQString mAddress; 00126 }; 00127 00128 #endif 00129