viewmanager.h
00001 #ifndef VIEWMANAGER_H 00002 #define VIEWMANAGER_H 00003 00004 /* 00005 This file is part of KAddressBook. 00006 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 00022 As a special exception, permission is given to link this program 00023 with any edition of Qt, and distribute the resulting executable, 00024 without including the source code for Qt in the source distribution. 00025 */ 00026 00027 #include <qwidget.h> 00028 #include <qdict.h> 00029 #include <qstringlist.h> 00030 00031 #include <kabc/field.h> 00032 00033 #include "filter.h" 00034 00035 class QComboBox; 00036 class QLineEdit; 00037 class QWidgetStack; 00038 class QResizeEvent; 00039 class QDropEvent; 00040 class QSplitter; 00041 class QTabWidget; 00042 class QHBox; 00043 class KConfig; 00044 namespace KABC { class AddressBook; } 00045 00046 class ViewWrapper; 00047 class ViewContainer; 00048 class KAddressBookView; 00049 class JumpButtonBar; 00050 class AddresseeEditorWidget; 00051 class FeatureDistributionList; 00052 00060 class ViewManager : public QWidget 00061 { 00062 Q_OBJECT 00063 00064 public: 00065 ViewManager(KABC::AddressBook *doc, KConfig *config, 00066 QWidget *parent = 0, const char *name = 0); 00067 ~ViewManager(); 00068 00073 void setActiveView(const QString &name); 00074 00080 void unloadViews(); 00081 00087 const QStringList &viewNames() { return mViewNameList; } 00088 00089 /* Return a list of all the uids of selected contacts. 00090 */ 00091 QStringList selectedUids(); 00092 00097 void setJumpButtonBarVisible(bool visible); 00098 00101 void setDetailsVisible(bool visible); 00102 00106 bool isQuickEditVisible(); 00107 00110 const Filter::List &filters() const { return mFilterList; } 00111 00112 public slots: 00115 void readConfig(); 00116 00119 void writeConfig(); 00120 00125 virtual void sendMail(); 00126 00128 void sendMail(const QString& addressee); 00129 00131 void browse(const QString& url); 00132 00137 void deleteAddressee(); 00138 00141 void paste(); 00142 00146 void copy(); 00147 00151 void cut(); 00152 00155 void setSelected(QString uid = QString::null, bool selected = true); 00156 00162 void refresh(QString uid = QString::null); 00163 00166 void modifyView(); 00167 00170 void deleteView(); 00171 00175 void addView(); 00176 00179 void filtersChanged(const Filter::List &list); 00180 00183 void filterActivated(int index); 00184 00186 void slotModified(); 00187 00194 void showFeatures( int id ); 00195 00196 protected slots: 00198 void incSearch(const QString& text, int field); 00199 00202 void jumpToLetter(const QChar &ch); 00203 00208 void dropped(QDropEvent *e); 00209 00214 void startDrag(); 00215 00220 void addresseeSelected(const QString &uid); 00221 00227 void addresseeModified(); 00228 00229 signals: 00232 void selected(const QString &uid); 00233 00236 void executed(const QString &uid); 00237 00240 void modified(); 00241 00248 void viewConfigChanged(const QString &newActive); 00249 00252 void setIncSearchFields(const QStringList&); 00253 00255 void setFilterNames(const QStringList&); 00256 00258 void setCurrentFilterName(const QString&); 00259 00261 void setCurrentFilter(int index); 00262 00264 void importVCard(const QString &, bool); 00265 00266 private: 00269 void createViewWrappers(); 00270 00273 void initGUI(); 00274 00277 void refreshIncrementalSearchCombo(); 00278 00279 QStringList mViewNameList; 00280 QDict<ViewWrapper> mViewWrapperDict; 00281 QDict<KAddressBookView> mViewDict; 00282 KABC::AddressBook *mDocument; 00283 KConfig *mConfig; 00284 QWidgetStack *mViewWidgetStack; 00285 KABC::Field::List mIncrementalSearchFields; 00286 KABC::Field *mCurrentIncSearchField; 00287 Filter::List mFilterList; 00288 Filter mCurrentFilter; 00289 // ----- GUI widgets: 00290 KAddressBookView *mActiveView; 00291 ViewContainer *mDetails; 00292 JumpButtonBar *mJumpButtonBar; 00293 AddresseeEditorWidget *mQuickEdit; 00294 QSplitter *mQSpltDetails; 00295 QSplitter *mQSpltFeatures; 00296 QHBox *mFeatureBar; 00297 FeatureDistributionList *mFeatDistList; 00298 }; 00299 00300 #endif