kcmodulecontainer.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KCMODULECONTAINER_H
00021 #define KCMODULECONTAINER_H
00022 
00023 #include <qvaluelist.h>
00024 #include <qstring.h>
00025 #include <qstringlist.h>
00026 
00027 #include <kcmodule.h>
00028 #include <kcmoduleloader.h>
00029 
00030 class QTabWidget;
00031 class QWidget;
00032 class QVBoxLayout;
00033 
00034 class KCModuleProxy;
00035 
00052 class KUTILS_EXPORT KCModuleContainer : public KCModule
00053 {
00054     Q_OBJECT
00055     public:
00067         KCModuleContainer( QWidget* parent, const char* name, const QStringList& mods );
00068 
00086         KCModuleContainer( QWidget *parent, const char* name, const QString& mods = QString() );
00087 
00095         void addModule( const QString& module );
00096 
00100         virtual ~KCModuleContainer();
00101 
00106         void save();
00107 
00112         void load();
00113 
00118         void defaults();
00119 
00120     protected:
00121 
00128         void finalize();
00129 
00130         typedef QValueList<KCModuleProxy*> ModuleList;
00131 
00136         ModuleList changedModules;
00137 
00141         ModuleList allModules; // KDE 4 put in the Private class and abstract with getter
00142 
00143     private slots:
00144 
00148         void tabSwitched( QWidget * module );
00149 
00150         void moduleChanged(KCModuleProxy *proxy);
00151 
00155         void runAsRoot();
00156 
00160         void rootExited();
00161 
00162     private:
00163 
00164         void init();
00165 
00166         class KCModuleContainerPrivate;
00167         KCModuleContainerPrivate *d;
00168 
00169 };
00170 
00186 #define KCMODULECONTAINER( modules, factoryName ) \
00187 extern "C" \
00188 { \
00189     KCModule *create_## factoryName(QWidget *parent, const char *name) \
00190     { \
00191         return new KCModuleContainer( parent, name, QString( modules ) ); \
00192     } \
00193     \
00194     bool test_## factoryName() \
00195     { \
00196         QStringList modList = QStringList::split( ",", QString(modules).remove( " " )); \
00197         for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) \
00198             if ( KCModuleLoader::testModule( *it ) ) \
00199                 return true; \
00200         return false; \
00201     } \
00202 }
00203 
00204 #endif // KCMODULECONTAINER_H
00205 
KDE Home | KDE Accessibility Home | Description of Access Keys