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 TQt, and distribute the resulting executable,
00021     without including the source code for TQt in the source distribution.
00022 */
00023 
00024 #ifndef VIEWMANAGER_H
00025 #define VIEWMANAGER_H
00026 
00027 #include <tqdict.h>
00028 #include <tqwidget.h>
00029 #include <kaddressbookview.h>
00030 
00031 class TQDropEvent;
00032 class TQWidgetStack;
00033 
00034 class TDEAction;
00035 class TDESelectAction;
00036 
00037 class FilterSelectionWidget;
00038 
00039 namespace KAB { class Core; }
00040 namespace TDEABC { class AddressBook; }
00041 
00050 class ViewManager : public TQWidget
00051 {
00052   Q_OBJECT
00053   
00054 
00055   public:
00056     ViewManager( KAB::Core *core, TQWidget *parent, const char *name = 0 );
00057     ~ViewManager();
00058 
00059     void restoreSettings();
00060     void saveSettings();
00061 
00062     void unloadViews();
00063 
00064     TQStringList selectedUids() const;
00065     TQStringList selectedEmails() const;
00066     TDEABC::Addressee::List selectedAddressees() const;
00067 
00068     void setFilterSelectionWidget( FilterSelectionWidget *wdg );
00069 
00070     TDEABC::Field *currentSortField() const;
00071     TDEABC::Field::List viewFields() const;
00072 
00073   public slots:
00074     void setSelected( const TQString &uid = TQString(), bool selected = true );
00075     void setFirstSelected( bool selected = true );
00076 
00077     void refreshView( const TQString &uid = TQString() );
00078     void editView();
00079     void deleteView();
00080     void addView();
00081 
00082     void scrollUp();
00083     void scrollDown();
00084 
00085   protected slots:
00091     void dropped( TQDropEvent* );
00092 
00098     void startDrag();
00099 
00100   signals:
00104     void selected( const TQString &uid );
00105 
00109     void executed( const TQString &uid );
00110 
00114     void modified();
00115 
00119     void urlDropped( const KURL& );
00120 
00124     void sortFieldChanged();
00125 
00129     void viewFieldsChanged();
00130 
00131   private slots:
00132     void setActiveView( const TQString &name );
00133     void setActiveFilter( int index );
00134     void configureFilters();
00135 
00136   private:
00137     void createViewFactories();
00138     TQStringList filterNames() const;
00139     int filterPosition( const TQString &name ) const;
00140     TQStringList viewNames() const;
00141     int viewPosition( const TQString &name ) const;
00142     void initActions();
00143     void initGUI();
00144 
00145     KAB::Core *mCore;
00146 
00147     Filter mCurrentFilter;
00148     Filter::List mFilterList;
00149 
00150     TQDict<KAddressBookView> mViewDict;
00151     TQDict<ViewFactory> mViewFactoryDict;
00152     TQStringList mViewNameList;
00153 
00154     TQWidgetStack *mViewWidgetStack;
00155     KAddressBookView *mActiveView;
00156 
00157     TDEAction *mActionDeleteView;
00158     TDESelectAction *mActionSelectView;
00159 
00160     FilterSelectionWidget *mFilterSelectionWidget;
00161 };
00162 
00163 #endif