kaddressbook

kabcore.h

00001 /*
00002     This file is part of KAddressbook.
00003     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
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 KABCORE_H
00025 #define KABCORE_H
00026 
00027 #include <config.h> // FOR KDEPIM_NEW_DISTRLISTS
00028 
00029 #include <kabc/field.h>
00030 
00031 #include <tqdict.h>
00032 #include <tqlabel.h>
00033 #include <tqwidget.h>
00034 
00035 #include "core.h"
00036 #include <kdepimmacros.h>
00037 
00038 namespace KABC {
00039 class AddressBook;
00040 class Ticket;
00041 }
00042 
00043 namespace KPIM {
00044 class AddresseeView;
00045 class CategoryEditDialog;
00046 class CategorySelectDialog;
00047 }
00048 
00049 class KAboutData;
00050 class KAction;
00051 class KActionCollection;
00052 class KConfig;
00053 class KPushButton;
00054 class KStatusBar;
00055 class KToggleAction;
00056 class KXMLGUIClient;
00057 
00058 class TQSplitter;
00059 class TQHBoxLayout;
00060 class TQWidgetStack;
00061 
00062 class AddresseeEditorDialog;
00063 class ExtensionManager;
00064 class FilterSelectionWidget;
00065 class IncSearchWidget;
00066 class JumpButtonBar;
00067 class KAddressBookIface;
00068 class KAddressBookService;
00069 class KIMProxy;
00070 class LDAPSearchDialog;
00071 class ViewManager;
00072 class XXPortManager;
00073 
00074 namespace KAB {
00075     class DistributionListEntryView;
00076 }
00077 
00078 typedef struct {
00079   KABC::Ticket *ticket;
00080   int counter;
00081 } ResourceMapEntry;
00082 
00083 class KDE_EXPORT KABCore : public KAB::Core
00084 {
00085   Q_OBJECT
00086 
00087   public:
00088     KABCore( KXMLGUIClient *client, bool readWrite, TQWidget *parent,
00089              const TQString &file = TQString::null, const char *name = 0 );
00090     ~KABCore();
00091 
00095     void restoreSettings();
00096 
00100     void saveSettings();
00101 
00105     KABC::AddressBook *addressBook() const;
00106 
00110     KConfig *config() const;
00111 
00116     KActionCollection *actionCollection() const;
00117 
00121     KABC::Field *currentSortField() const;
00122 
00126     TQStringList selectedUIDs() const;
00127 
00133     KABC::Resource *requestResource( TQWidget *parent );
00134 
00138     TQWidget *widget() const;
00139 
00140     static KAboutData *createAboutData();
00141 
00142     void setStatusBar( KStatusBar *statusBar );
00143 
00144     KStatusBar *statusBar() const;
00145 
00146     KAB::SearchManager *searchManager() const { return mSearchManager; }
00147 
00148     KCommandHistory *commandHistory() const { return mCommandHistory; }
00149 
00150 #ifdef KDEPIM_NEW_DISTRLISTS
00151 
00154     virtual KPIM::DistributionList::List distributionLists() const;
00155 
00159     virtual TQStringList distributionListNames() const;
00160 
00165     virtual void setSelectedDistributionList( const TQString &name );
00166 #endif
00167 
00168   public slots:
00172     void setContactSelected( const TQString &uid );
00173 
00178     void sendMail();
00179 
00184     void sendMail( const TQString& email );
00185 
00186 
00187     void mailVCard();
00188     void mailVCard(const TQStringList& uids);
00189 
00193     void startChat();
00194 
00198     void browse( const TQString& url );
00199 
00203     void selectAllContacts();
00204 
00208     void deleteContacts();
00209 
00215     void deleteContacts( const TQStringList &uids );
00216 
00222     void deleteDistributionLists( const TQStringList &names );
00223 
00224 
00228     void copyContacts();
00229 
00233     void cutContacts();
00234 
00238     void pasteContacts();
00239 
00245     void pasteContacts( KABC::Addressee::List &list );
00246 
00247 
00251     void mergeContacts();
00252 
00257     void setWhoAmI();
00258 
00263     void setCategories();
00264 
00269     void incrementalTextSearch( const TQString& text );
00270 
00271     void incrementalJumpButtonSearch( const TQString& characters );
00272 
00276     void setModified();
00277 
00281     void setModified( bool modified );
00282 
00286     bool modified() const;
00287 
00292     void contactModified( const KABC::Addressee &addr );
00293 
00297     virtual void addEmail( const TQString& addr );
00298 
00302     virtual void importVCard( const KURL& url );
00303 
00307     virtual void importVCardFromData( const TQString& vCard );
00308 
00312     virtual void newContact();
00313 
00317     virtual void newDistributionList();
00318 
00323     virtual TQString getNameByPhone( const TQString& phone );
00324 
00329     bool handleCommandLine( KAddressBookIface* iface );
00330 
00331 
00335     void save();
00336 
00340     void load();
00341 
00346     void editContact( const TQString &uid = TQString::null );
00347 
00352     void storeContactIn( const TQString &uid = TQString::null, bool copy = false );
00353 
00358     void copySelectedContactToResource();
00359 
00364     void moveSelectedContactToResource();
00365 
00369     void openLDAPDialog();
00370 
00374     void configure();
00375 
00380     void print();
00381 
00382     void detailsHighlighted( const TQString& );
00383 
00384     void showContactsAddress( const TQString &uid );
00385 
00386     void configurationChanged();
00387 
00388     bool queryClose();
00389 
00393     void reinitXMLGUI();
00394 
00395   private:
00396 
00397 #ifdef KDEPIM_NEW_DISTRLISTS
00398     void editDistributionList( const KPIM::DistributionList &list );
00399     void showDistributionListEntry( const TQString &uid );
00400 #endif
00401 
00402   private slots:
00403     void setJumpButtonBarVisible( bool visible );
00404     void setDetailsVisible( bool visible );
00405 
00406     void extensionModified( const KABC::Addressee::List &list );
00407     void extensionDeleted( const TQStringList &uidList );
00408     void clipboardDataChanged();
00409     void updateIncSearchWidget();
00410 
00411     void slotEditorDestroyed( const TQString &uid );
00412     void delayedAddressBookChanged();
00413     void addressBookChanged();
00414 
00415     void categoriesSelected( const TQStringList& );
00416     void editCategories();
00417     void slotClearSearchBar();
00418     void slotContactsUpdated();
00419 
00420     void activateDetailsWidget( TQWidget *widget );
00421     void deactivateDetailsWidget( TQWidget *widget );
00422 
00423     void editDistributionList( const TQString &name );
00424 
00425     void removeSelectedContactsFromDistList();
00426     void editSelectedDistributionList();
00427     void sendMailToDistributionList( const TQString &id );
00428 
00429   private:
00430     void initGUI();
00431     void createJumpButtonBar();
00432     void initActions();
00433 
00434     void updateCategories();
00435     TQStringList allCategories() const;
00436 
00437     AddresseeEditorDialog *createAddresseeEditorDialog( TQWidget *parent,
00438                                                         const char *name = 0 );
00439 
00440     TQWidget *mWidget;
00441     KABC::AddressBook *mAddressBook;
00442     KStatusBar *mStatusBar;
00443 
00444     ViewManager *mViewManager;
00445     TQLabel *mViewHeaderLabel;
00446 
00447 #ifdef KDEPIM_NEW_DISTRLISTS
00448     TQString mSelectedDistributionList;
00449     KPushButton *mAddDistListButton;
00450     KPushButton *mRemoveDistListButton;
00451     TQWidget *mDistListButtonWidget;
00452 #endif
00453 
00454     ExtensionManager *mExtensionManager;
00455     XXPortManager *mXXPortManager;
00456 
00457     JumpButtonBar *mJumpButtonBar;
00458     FilterSelectionWidget *mFilterSelectionWidget;
00459     IncSearchWidget *mIncSearchWidget;
00460     KAB::DistributionListEntryView* mDistListEntryView;
00461     KPIM::AddresseeView *mDetailsViewer;
00462     KPIM::CategorySelectDialog *mCategorySelectDialog;
00463     KPIM::CategoryEditDialog *mCategoryEditDialog;
00464     TQWidget *mDetailsPage;
00465     TQWidget *mDetailsWidget;
00466     TQHBoxLayout *mDetailsLayout;
00467     TQSplitter *mDetailsSplitter;
00468     TQSplitter *mLeftSplitter;
00469     TQWidgetStack *mDetailsStack;
00470     LDAPSearchDialog *mLdapSearchDialog;
00471     TQDict<AddresseeEditorDialog> mEditorDict;
00472 
00473     bool mReadWrite;
00474     bool mModified;
00475     bool mIsPart;
00476 
00477     TQTimer *mAddressBookChangedTimer;
00478 
00479     KAction *mActionPaste;
00480     KAction *mActionCut;
00481     KAction *mActionDelete;
00482     KAction *mActionCopy;
00483     KAction *mActionEditAddressee;
00484     KAction *mActionMoveAddresseeTo;
00485     KAction *mActionCopyAddresseeTo;
00486     KAction *mActionMerge;
00487     KAction *mActionMail;
00488     KAction *mActionMailVCard;
00489     KAction *mActionChat;
00490     KAction *mActionSave;
00491     KAction *mActionDeleteView;
00492     KAction *mActionWhoAmI;
00493     KAction *mActionCategories;
00494     KToggleAction *mActionJumpBar;
00495     KToggleAction *mActionDetails;
00496     KCommandHistory *mCommandHistory;
00497 
00498     KAddressBookService *mAddressBookService;
00499 
00500     KAB::SearchManager *mSearchManager;
00501     // KIMProxy provides access to up to date instant messaging presence data
00502     ::KIMProxy *mKIMProxy;
00503     class KABCorePrivate;
00504     KABCorePrivate *d;
00505 };
00506 
00507 #endif