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 <tqvaluelist.h> 00024 #include <tqstring.h> 00025 #include <tqstringlist.h> 00026 00027 #include <kcmodule.h> 00028 #include <kcmoduleloader.h> 00029 00030 class TQTabWidget; 00031 class TQWidget; 00032 class TQVBoxLayout; 00033 00034 class KCModuleProxy; 00035 00053 class KUTILS_EXPORT KCModuleContainer : public KCModule 00054 { 00055 Q_OBJECT 00056 public: 00068 KCModuleContainer( TQWidget* parent, const char* name, const TQStringList& mods ); 00069 00087 KCModuleContainer( TQWidget *parent, const char* name, const TQString& mods = TQString() ); 00088 00096 void addModule( const TQString& module ); 00097 00101 virtual ~KCModuleContainer(); 00102 00107 void save(); 00108 00113 void load(); 00114 00119 void defaults(); 00120 00121 protected: 00122 00129 void finalize(); 00130 00131 typedef TQValueList<KCModuleProxy*> ModuleList; 00132 00137 ModuleList changedModules; 00138 00142 ModuleList allModules; // KDE 4 put in the Private class and abstract with getter 00143 00144 private slots: 00145 00149 void tabSwitched( TQWidget * module ); 00150 00151 void moduleChanged(KCModuleProxy *proxy); 00152 00156 void runAsRoot(); 00157 00161 void rootExited(); 00162 00163 private: 00164 00165 void init(); 00166 00167 class KCModuleContainerPrivate; 00168 KCModuleContainerPrivate *d; 00169 00170 }; 00171 00188 #define KCMODULECONTAINER( modules, factoryName ) \ 00189 extern "C" \ 00190 { \ 00191 KCModule *create_## factoryName(TQWidget *parent, const char *name) \ 00192 { \ 00193 return new KCModuleContainer( parent, name, TQString( modules ) ); \ 00194 } \ 00195 \ 00196 bool test_## factoryName() \ 00197 { \ 00198 TQStringList modList = TQStringList::split( ",", TQString(modules).remove( " " )); \ 00199 for ( TQStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) \ 00200 if ( KCModuleLoader::testModule( *it ) ) \ 00201 return true; \ 00202 return false; \ 00203 } \ 00204 } 00205 00206 #endif // KCMODULECONTAINER_H 00207