Need to store config when changing units, if not very bad things happen
[kdepim.git] / kaddressbook / viewmanager.h
blobb74f025eee9bbb67e7e6b8dbdaadde6e5c78407d
1 /*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
24 #ifndef VIEWMANAGER_H
25 #define VIEWMANAGER_H
27 #include <qdict.h>
28 #include <qwidget.h>
29 #include <kaddressbookview.h>
31 class QDropEvent;
32 class QWidgetStack;
34 class KAction;
35 class KSelectAction;
37 class FilterSelectionWidget;
39 namespace KAB { class Core; }
40 namespace KABC { class AddressBook; }
42 /**
43 The view manager manages the views and everything related to them. The
44 manager will load the views at startup and display a view when told to
45 make one active.
47 The view manager will also create and manage all dialogs directly related to
48 views (ie: AddView, ConfigureView, DeleteView, etc).
50 class ViewManager : public QWidget
52 Q_OBJECT
54 public:
55 ViewManager( KAB::Core *core, QWidget *parent, const char *name = 0 );
56 ~ViewManager();
58 void restoreSettings();
59 void saveSettings();
61 void unloadViews();
63 QStringList selectedUids() const;
64 QStringList selectedEmails() const;
65 KABC::Addressee::List selectedAddressees() const;
67 void setFilterSelectionWidget( FilterSelectionWidget *wdg );
69 KABC::Field *currentSortField() const;
70 KABC::Field::List viewFields() const;
72 public slots:
73 void setSelected( const QString &uid = QString::null, bool selected = true );
74 void setFirstSelected( bool selected = true );
76 void refreshView( const QString &uid = QString::null );
77 void editView();
78 void deleteView();
79 void addView();
81 void scrollUp();
82 void scrollDown();
84 protected slots:
85 /**
86 Called whenever the user drops something in the active view.
87 This method will try to decode what was dropped, and if it was
88 a valid addressee, add it to the addressbook.
90 void dropped( QDropEvent* );
92 /**
93 Called whenever the user attempts to start a drag in the view.
94 This method will convert all the selected addressees into text (vcard)
95 and create a drag object.
97 void startDrag();
99 signals:
101 Emitted whenever the user selects an entry in the view.
103 void selected( const QString &uid );
106 Emitted whenever the user activates an entry in the view.
108 void executed( const QString &uid );
111 Emitted whenever the address book is modified in some way.
113 void modified();
116 Emitted whenever a url is dragged on a view.
118 void urlDropped( const KURL& );
121 Emitted whenever the sort field of a view has changed.
123 void sortFieldChanged();
126 Emitted whenever the view fields changed.
128 void viewFieldsChanged();
130 private slots:
131 void setActiveView( const QString &name );
132 void setActiveFilter( int index );
133 void configureFilters();
135 private:
136 void createViewFactories();
137 QStringList filterNames() const;
138 int filterPosition( const QString &name ) const;
139 QStringList viewNames() const;
140 int viewPosition( const QString &name ) const;
141 void initActions();
142 void initGUI();
144 KAB::Core *mCore;
146 Filter mCurrentFilter;
147 Filter::List mFilterList;
149 QDict<KAddressBookView> mViewDict;
150 QDict<ViewFactory> mViewFactoryDict;
151 QStringList mViewNameList;
153 QWidgetStack *mViewWidgetStack;
154 KAddressBookView *mActiveView;
156 KAction *mActionDeleteView;
157 KSelectAction *mActionSelectView;
159 FilterSelectionWidget *mFilterSelectionWidget;
162 #endif