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 TQt, and distribute the resulting executable,
00021     without including the source code for TQt in the source distribution.
00022 */
00023 
00024 #ifndef KABCORE_H
00025 #define KABCORE_H
00026 
00027 #include <config.h> // FOR TDEPIM_NEW_DISTRLISTS
00028 
00029 #include <tdeabc/field.h>
00030 
00031 #include <tqdict.h>
00032 #include <tqlabel.h>
00033 #include <tqwidget.h>
00034 
00035 #include "core.h"
00036 #include <tdepimmacros.h>
00037 
00038 namespace TDEABC {
00039 class AddressBook;
00040 class Ticket;
00041 }
00042 
00043 namespace KPIM {
00044 class AddresseeView;
00045 class CategoryEditDialog;
00046 class CategorySelectDialog;
00047 }
00048 
00049 class TDEAboutData;
00050 class TDEAction;
00051 class TDEActionCollection;
00052 class TDEConfig;
00053 class KPushButton;
00054 class KStatusBar;
00055 class TDEToggleAction;
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   TDEABC::Ticket *ticket;
00080   int counter;
00081 } ResourceMapEntry;
00082 
00083 class KDE_EXPORT KABCore : public KAB::Core
00084 {
00085   Q_OBJECT
00086   
00087 
00088   public:
00089     KABCore( KXMLGUIClient *client, bool readWrite, TQWidget *parent,
00090              const TQString &file = TQString(), const char *name = 0 );
00091     ~KABCore();
00092 
00096     void restoreSettings();
00097 
00101     void saveSettings();
00102 
00106     TDEABC::AddressBook *addressBook() const;
00107 
00111     TDEConfig *config() const;
00112 
00117     TDEActionCollection *actionCollection() const;
00118 
00122     TDEABC::Field *currentSortField() const;
00123 
00127     TQStringList selectedUIDs() const;
00128 
00134     TDEABC::Resource *requestResource( TQWidget *parent );
00135 
00139     TQWidget *widget() const;
00140 
00141     static TDEAboutData *createAboutData();
00142 
00143     void setStatusBar( KStatusBar *statusBar );
00144 
00145     KStatusBar *statusBar() const;
00146 
00147     KAB::SearchManager *searchManager() const { return mSearchManager; }
00148 
00149     KCommandHistory *commandHistory() const { return mCommandHistory; }
00150 
00151 #ifdef TDEPIM_NEW_DISTRLISTS
00152 
00155     virtual KPIM::DistributionList::List distributionLists() const;
00156 
00160     virtual TQStringList distributionListNames() const;
00161 
00166     virtual void setSelectedDistributionList( const TQString &name );
00167 #endif
00168 
00169   public slots:
00173     void setContactSelected( const TQString &uid );
00174 
00179     void sendMail();
00180 
00185     void sendMail( const TQString& email );
00186 
00187 
00188     void mailVCard();
00189     void mailVCard(const TQStringList& uids);
00190 
00194     void startChat();
00195 
00199     void browse( const TQString& url );
00200 
00204     void selectAllContacts();
00205 
00209     void deleteContacts();
00210 
00216     void deleteContacts( const TQStringList &uids );
00217 
00223     void deleteDistributionLists( const TQStringList &names );
00224 
00225 
00229     void copyContacts();
00230 
00234     void cutContacts();
00235 
00239     void pasteContacts();
00240 
00246     void pasteContacts( TDEABC::Addressee::List &list );
00247 
00248 
00252     void mergeContacts();
00253 
00258     void setWhoAmI();
00259 
00264     void setCategories();
00265 
00270     void incrementalTextSearch( const TQString& text );
00271 
00272     void incrementalJumpButtonSearch( const TQString& characters );
00273 
00277     void setModified();
00278 
00282     void setModified( bool modified );
00283 
00287     bool modified() const;
00288 
00293     void contactModified( const TDEABC::Addressee &addr );
00294 
00298     virtual void addEmail( const TQString& addr );
00299 
00303     virtual void importVCard( const KURL& url );
00304 
00308     virtual void importVCardFromData( const TQString& vCard );
00309 
00313     virtual void newContact();
00314 
00318     virtual void newDistributionList();
00319 
00324     virtual TQString getNameByPhone( const TQString& phone );
00325 
00330     bool handleCommandLine( KAddressBookIface* iface );
00331 
00332 
00336     void save();
00337 
00341     void load();
00342 
00347     void editContact( const TQString &uid = TQString() );
00348 
00353     void storeContactIn( const TQString &uid = TQString(), bool copy = false );
00354 
00359     void copySelectedContactToResource();
00360 
00365     void moveSelectedContactToResource();
00366 
00370     void openLDAPDialog();
00371 
00375     void configure();
00376 
00381     void print();
00382 
00383     void detailsHighlighted( const TQString& );
00384 
00385     void showContactsAddress( const TQString &uid );
00386 
00387     void configurationChanged();
00388 
00389     bool queryClose();
00390 
00394     void reinitXMLGUI();
00395 
00396   private:
00397 
00398 #ifdef TDEPIM_NEW_DISTRLISTS
00399     void editDistributionList( const KPIM::DistributionList &list );
00400     void showDistributionListEntry( const TQString &uid );
00401 #endif
00402 
00403   private slots:
00404     void setJumpButtonBarVisible( bool visible );
00405     void setDetailsVisible( bool visible );
00406 
00407     void extensionModified( const TDEABC::Addressee::List &list );
00408     void extensionDeleted( const TQStringList &uidList );
00409     void clipboardDataChanged();
00410     void updateIncSearchWidget();
00411 
00412     void slotEditorDestroyed( const TQString &uid );
00413     void delayedAddressBookChanged();
00414     void addressBookChanged();
00415 
00416     void categoriesSelected( const TQStringList& );
00417     void editCategories();
00418     void slotClearSearchBar();
00419     void slotContactsUpdated();
00420 
00421     void activateDetailsWidget( TQWidget *widget );
00422     void deactivateDetailsWidget( TQWidget *widget );
00423 
00424     void editDistributionList( const TQString &name );
00425 
00426     void removeSelectedContactsFromDistList();
00427     void editSelectedDistributionList();
00428     void sendMailToDistributionList( const TQString &id );
00429 
00430   private:
00431     void initGUI();
00432     void createJumpButtonBar();
00433     void initActions();
00434 
00435     void updateCategories();
00436     TQStringList allCategories() const;
00437 
00438     AddresseeEditorDialog *createAddresseeEditorDialog( TQWidget *parent,
00439                                                         const char *name = 0 );
00440 
00441     TQWidget *mWidget;
00442     TDEABC::AddressBook *mAddressBook;
00443     KStatusBar *mStatusBar;
00444 
00445     ViewManager *mViewManager;
00446     TQLabel *mViewHeaderLabel;
00447 
00448 #ifdef TDEPIM_NEW_DISTRLISTS
00449     TQString mSelectedDistributionList;
00450     KPushButton *mAddDistListButton;
00451     KPushButton *mRemoveDistListButton;
00452     TQWidget *mDistListButtonWidget;
00453 #endif
00454 
00455     ExtensionManager *mExtensionManager;
00456     XXPortManager *mXXPortManager;
00457 
00458     JumpButtonBar *mJumpButtonBar;
00459     FilterSelectionWidget *mFilterSelectionWidget;
00460     IncSearchWidget *mIncSearchWidget;
00461     KAB::DistributionListEntryView* mDistListEntryView;
00462     KPIM::AddresseeView *mDetailsViewer;
00463     KPIM::CategorySelectDialog *mCategorySelectDialog;
00464     KPIM::CategoryEditDialog *mCategoryEditDialog;
00465     TQWidget *mDetailsPage;
00466     TQWidget *mDetailsWidget;
00467     TQHBoxLayout *mDetailsLayout;
00468     TQSplitter *mDetailsSplitter;
00469     TQSplitter *mLeftSplitter;
00470     TQWidgetStack *mDetailsStack;
00471     LDAPSearchDialog *mLdapSearchDialog;
00472     TQDict<AddresseeEditorDialog> mEditorDict;
00473 
00474     bool mReadWrite;
00475     bool mModified;
00476     bool mIsPart;
00477 
00478     TQTimer *mAddressBookChangedTimer;
00479 
00480     TDEAction *mActionPaste;
00481     TDEAction *mActionCut;
00482     TDEAction *mActionDelete;
00483     TDEAction *mActionCopy;
00484     TDEAction *mActionEditAddressee;
00485     TDEAction *mActionMoveAddresseeTo;
00486     TDEAction *mActionCopyAddresseeTo;
00487     TDEAction *mActionMerge;
00488     TDEAction *mActionMail;
00489     TDEAction *mActionMailVCard;
00490     TDEAction *mActionChat;
00491     TDEAction *mActionSave;
00492     TDEAction *mActionDeleteView;
00493     TDEAction *mActionWhoAmI;
00494     TDEAction *mActionCategories;
00495     TDEToggleAction *mActionJumpBar;
00496     TDEToggleAction *mActionDetails;
00497     KCommandHistory *mCommandHistory;
00498 
00499     KAddressBookService *mAddressBookService;
00500 
00501     KAB::SearchManager *mSearchManager;
00502     // KIMProxy provides access to up to date instant messaging presence data
00503     ::KIMProxy *mKIMProxy;
00504     class KABCorePrivate;
00505     KABCorePrivate *d;
00506 };
00507 
00508 #endif