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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt 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 <qstringlist.h>
00030 #include <qwidget.h>
00031 
00032 #include <kabc/field.h>
00033 #include <klibloader.h>
00034 #include <kdepimmacros.h>
00035 
00036 #include "filter.h"
00037 #include "viewconfigurewidget.h"
00038 
00039 class KConfig;
00040 class KXMLGUIClient;
00041 
00042 class QDropEvent;
00043 
00044 namespace KAB { class Core; }
00045 namespace KABC { class AddressBook; }
00046 
00056 class KDE_EXPORT KAddressBookView : public QWidget
00057 {
00058   Q_OBJECT
00059 
00060   public:
00061     enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
00062 
00063     KAddressBookView( KAB::Core *core, QWidget *parent, const char *name );
00064     virtual ~KAddressBookView();
00065 
00070     virtual QStringList selectedUids() = 0;
00071 
00085     virtual void readConfig( KConfig *config );
00086 
00096     // The KConfig object is unused so we do not document it
00097     // else doxygen will complain.
00098     virtual void writeConfig( KConfig * );
00099 
00104     virtual QString selectedEmails();
00105 
00111     virtual QString type() const = 0;
00112 
00123     KABC::Field::List fields() const;
00124 
00131     void setFilter( const Filter& );
00132 
00138     DefaultFilterType defaultFilterType() const;
00139 
00144     const QString &defaultFilterName() const;
00145 
00149     KAB::Core *core() const;
00150 
00154     virtual KABC::Field *sortField() const = 0;
00155 
00156     virtual void scrollUp() = 0;
00157     virtual void scrollDown() = 0;
00158 
00159   public slots:
00167     virtual void refresh( const QString &uid = QString() ) = 0;
00168 
00174     virtual void setSelected( const QString &uid = QString(), bool selected = true ) = 0;
00175 
00179     virtual void setFirstSelected( bool selected = true ) = 0;
00180 
00186     void popup( const QPoint &point );
00187 
00188   signals:
00193     void modified();
00194 
00206     void selected( const QString &uid );
00207 
00217     void executed( const QString &uid );
00218 
00224     void startDrag();
00225 
00231     void dropped( QDropEvent* );
00232 
00236     void sortFieldChanged();
00237 
00241     void viewFieldsChanged();
00242 
00243   protected:
00250     KABC::Addressee::List addressees();
00251 
00258     QWidget *viewWidget();
00259 
00260   private slots:
00261     void updateView();
00262 
00263   private:
00264     void initGUI();
00265 
00266     DefaultFilterType mDefaultFilterType;
00267     Filter mFilter;
00268     QString mDefaultFilterName;
00269     KAB::Core *mCore;
00270     KABC::Field::List mFieldList;
00271 
00272     QWidget *mViewWidget;
00273 };
00274 
00275 class KDE_EXPORT ViewFactory : public KLibFactory
00276 {
00277   public:
00278     virtual KAddressBookView *view( KAB::Core *core, QWidget *parent,
00279                                     const char *name = 0 ) = 0;
00284     virtual QString type() const = 0;
00285 
00291     virtual QString description() const = 0;
00292 
00302     virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
00303                                                   QWidget *parent,
00304                                                   const char *name = 0 );
00305 
00306   protected:
00307     virtual QObject* createObject( QObject*, const char*, const char*,
00308                                    const QStringList & )
00309     {
00310       return 0;
00311     }
00312 };
00313 
00314 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys