kaddressbook

kaddressbookview.h

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program 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
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of TQt, and distribute the resulting executable,
00021     without including the source code for TQt in the source distribution.
00022 */
00023 
00024 #ifndef KADDRESSBOOKVIEW_H
00025 #define KADDRESSBOOKVIEW_H
00026 
00027 #define KAB_VIEW_PLUGIN_VERSION 1
00028 
00029 #include <tqstringlist.h>
00030 #include <tqwidget.h>
00031 
00032 #include <tdeabc/field.h>
00033 #include <klibloader.h>
00034 #include <tdepimmacros.h>
00035 
00036 #include "filter.h"
00037 #include "viewconfigurewidget.h"
00038 
00039 class TDEConfig;
00040 class KXMLGUIClient;
00041 
00042 class TQDropEvent;
00043 
00044 namespace KAB { class Core; }
00045 namespace TDEABC { class AddressBook; }
00046 
00056 class KDE_EXPORT KAddressBookView : public TQWidget
00057 {
00058   Q_OBJECT
00059   
00060 
00061   public:
00062     enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
00063 
00064     KAddressBookView( KAB::Core *core, TQWidget *parent, const char *name );
00065     virtual ~KAddressBookView();
00066 
00071     virtual TQStringList selectedUids() = 0;
00072 
00086     virtual void readConfig( TDEConfig *config );
00087 
00097     // The TDEConfig object is unused so we do not document it
00098     // else doxygen will complain.
00099     virtual void writeConfig( TDEConfig * );
00100 
00105     virtual TQString selectedEmails();
00106 
00112     virtual TQString type() const = 0;
00113 
00124     TDEABC::Field::List fields() const;
00125 
00132     void setFilter( const Filter& );
00133 
00139     DefaultFilterType defaultFilterType() const;
00140 
00145     const TQString &defaultFilterName() const;
00146 
00150     KAB::Core *core() const;
00151 
00155     virtual TDEABC::Field *sortField() const = 0;
00156 
00157     virtual void scrollUp() = 0;
00158     virtual void scrollDown() = 0;
00159 
00160   public slots:
00168     virtual void refresh( const TQString &uid = TQString() ) = 0;
00169 
00175     virtual void setSelected( const TQString &uid = TQString(), bool selected = true ) = 0;
00176 
00180     virtual void setFirstSelected( bool selected = true ) = 0;
00181 
00187     void popup( const TQPoint &point );
00188 
00189   signals:
00194     void modified();
00195 
00207     void selected( const TQString &uid );
00208 
00218     void executed( const TQString &uid );
00219 
00225     void startDrag();
00226 
00232     void dropped( TQDropEvent* );
00233 
00237     void sortFieldChanged();
00238 
00242     void viewFieldsChanged();
00243 
00244   protected:
00251     TDEABC::Addressee::List addressees();
00252 
00259     TQWidget *viewWidget();
00260 
00261   private slots:
00262     void updateView();
00263 
00264   private:
00265     void initGUI();
00266 
00267     DefaultFilterType mDefaultFilterType;
00268     Filter mFilter;
00269     TQString mDefaultFilterName;
00270     KAB::Core *mCore;
00271     TDEABC::Field::List mFieldList;
00272 
00273     TQWidget *mViewWidget;
00274 };
00275 
00276 class KDE_EXPORT ViewFactory : public KLibFactory
00277 {
00278   public:
00279     virtual KAddressBookView *view( KAB::Core *core, TQWidget *parent,
00280                                     const char *name = 0 ) = 0;
00285     virtual TQString type() const = 0;
00286 
00292     virtual TQString description() const = 0;
00293 
00303     virtual ViewConfigureWidget *configureWidget( TDEABC::AddressBook *ab,
00304                                                   TQWidget *parent,
00305                                                   const char *name = 0 );
00306 
00307   protected:
00308     virtual TQObject* createObject( TQObject*, const char*, const char*,
00309                                    const TQStringList & )
00310     {
00311       return 0;
00312     }
00313 };
00314 
00315 #endif