kaddressbook

extensionmanager.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 EXTENSIONMANAGER_H
00025 #define EXTENSIONMANAGER_H
00026 
00027 #include "extensionwidget.h"
00028 
00029 #include <tqwidget.h>
00030 #include <tqmap.h>
00031 #include <tqptrlist.h>
00032 #include <tqstringlist.h>
00033 
00034 class TQSignalMapper;
00035 class TQWidgetStack;
00036 class KActionCollection;
00037 
00038 namespace KAB {
00039 class Core;
00040 }
00041 
00042 class ExtensionData
00043 {
00044   public:
00045     ExtensionData();
00046     typedef TQValueList<ExtensionData> List;
00047 
00048     KToggleAction* action;
00049     KAB::ExtensionWidget *widget;
00050     TQString identifier;
00051     TQString title;
00052     int weight;
00053     bool isDetailsExtension;
00054 };
00055 
00056 class ExtensionManager : public TQObject
00057 {
00058   Q_OBJECT
00059   TQ_OBJECT
00060 
00061   public:
00062     ExtensionManager( TQWidget *extensionBar, TQWidgetStack *detailsStack, KAB::Core *core, TQObject *parent, const char *name = 0 );
00063     ~ExtensionManager();
00064 
00068     void restoreSettings();
00069 
00073     void saveSettings();
00074 
00079     void reconfigure();
00080 
00084     bool isQuickEditVisible() const;
00085 
00086     TQWidget *activeDetailsWidget() const;
00087  
00088   public slots:
00089     void setSelectionChanged();
00090     void createActions();
00091 
00092   signals:
00093 
00094     void detailsWidgetActivated( TQWidget* widget );
00095     void detailsWidgetDeactivated( TQWidget* widget );
00096     void modified( const KABC::Addressee::List& );
00097     void deleted( const TQStringList& );
00098 
00099   private slots:
00100     void activationToggled( const TQString &extid );
00101 
00102   private:
00103     void createExtensionWidgets();
00104     void setExtensionActive( const TQString &extid, bool active ); 
00105 
00106   private:
00107     TQWidget *mExtensionBar;
00108     KAB::Core *mCore;
00109     TQMap<TQString, ExtensionData> mExtensionMap;
00110     TQStringList mActiveExtensions;
00111     TQSignalMapper *mMapper;
00112     TQPtrList<KAction> mActionList;
00113     KActionCollection *mActionCollection;
00114     TQSplitter *mSplitter;
00115     TQWidgetStack *mDetailsStack; 
00116     TQWidget *mActiveDetailsWidget;
00117 };
00118 
00119 #endif