kaddressbook

viewmanager.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 VIEWMANAGER_H
00025 #define VIEWMANAGER_H
00026 
00027 #include <qdict.h>
00028 #include <qwidget.h>
00029 #include <kaddressbookview.h>
00030 
00031 class QDropEvent;
00032 class QWidgetStack;
00033 
00034 class KAction;
00035 class KSelectAction;
00036 
00037 class FilterSelectionWidget;
00038 
00039 namespace KAB { class Core; }
00040 namespace KABC { class AddressBook; }
00041 
00050 class ViewManager : public QWidget
00051 {
00052   Q_OBJECT
00053 
00054   public:
00055     ViewManager( KAB::Core *core, QWidget *parent, const char *name = 0 );
00056     ~ViewManager();
00057 
00058     void restoreSettings();
00059     void saveSettings();
00060 
00061     void unloadViews();
00062 
00063     QStringList selectedUids() const;
00064     QStringList selectedEmails() const;
00065     KABC::Addressee::List selectedAddressees() const;
00066 
00067     void setFilterSelectionWidget( FilterSelectionWidget *wdg );
00068 
00069     KABC::Field *currentSortField() const;
00070     KABC::Field::List viewFields() const;
00071 
00072   public slots:
00073     void setSelected( const QString &uid = QString::null, bool selected = true );
00074     void setFirstSelected( bool selected = true );
00075 
00076     void refreshView( const QString &uid = QString::null );
00077     void editView();
00078     void deleteView();
00079     void addView();
00080 
00081     void scrollUp();
00082     void scrollDown();
00083 
00084   protected slots:
00090     void dropped( QDropEvent* );
00091 
00097     void startDrag();
00098 
00099   signals:
00103     void selected( const QString &uid );
00104 
00108     void executed( const QString &uid );
00109 
00113     void modified();
00114 
00118     void urlDropped( const KURL& );
00119 
00123     void sortFieldChanged();
00124 
00128     void viewFieldsChanged();
00129 
00130   private slots:
00131     void setActiveView( const QString &name );
00132     void setActiveFilter( int index );
00133     void configureFilters();
00134 
00135   private:
00136     void createViewFactories();
00137     QStringList filterNames() const;
00138     int filterPosition( const QString &name ) const;
00139     QStringList viewNames() const;
00140     int viewPosition( const QString &name ) const;
00141     void initActions();
00142     void initGUI();
00143 
00144     KAB::Core *mCore;
00145 
00146     Filter mCurrentFilter;
00147     Filter::List mFilterList;
00148 
00149     QDict<KAddressBookView> mViewDict;
00150     QDict<ViewFactory> mViewFactoryDict;
00151     QStringList mViewNameList;
00152 
00153     QWidgetStack *mViewWidgetStack;
00154     KAddressBookView *mActiveView;
00155 
00156     KAction *mActionDeleteView;
00157     KSelectAction *mActionSelectView;
00158 
00159     FilterSelectionWidget *mFilterSelectionWidget;
00160 };
00161 
00162 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys