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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt 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 QObject
00057 {
00058   Q_OBJECT
00059 
00060   public:
00061     ExtensionManager( TQWidget *extensionBar, TQWidgetStack *detailsStack, KAB::Core *core, TQObject *parent, const char *name = 0 );
00062     ~ExtensionManager();
00063 
00067     void restoreSettings();
00068 
00072     void saveSettings();
00073 
00078     void reconfigure();
00079 
00083     bool isQuickEditVisible() const;
00084 
00085     TQWidget *activeDetailsWidget() const;
00086  
00087   public slots:
00088     void setSelectionChanged();
00089     void createActions();
00090 
00091   signals:
00092 
00093     void detailsWidgetActivated( TQWidget* widget );
00094     void detailsWidgetDeactivated( TQWidget* widget );
00095     void modified( const KABC::Addressee::List& );
00096     void deleted( const TQStringList& );
00097 
00098   private slots:
00099     void activationToggled( const TQString &extid );
00100 
00101   private:
00102     void createExtensionWidgets();
00103     void setExtensionActive( const TQString &extid, bool active ); 
00104 
00105   private:
00106     TQWidget *mExtensionBar;
00107     KAB::Core *mCore;
00108     TQMap<TQString, ExtensionData> mExtensionMap;
00109     TQStringList mActiveExtensions;
00110     TQSignalMapper *mMapper;
00111     TQPtrList<KAction> mActionList;
00112     KActionCollection *mActionCollection;
00113     TQSplitter *mSplitter;
00114     TQWidgetStack *mDetailsStack; 
00115     TQWidget *mActiveDetailsWidget;
00116 };
00117 
00118 #endif