tdecmodulecontainer.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 TDECMODULECONTAINER_H 00021 #define TDECMODULECONTAINER_H 00022 00023 #include <tqvaluelist.h> 00024 #include <tqstring.h> 00025 #include <tqstringlist.h> 00026 00027 #include <tdecmodule.h> 00028 #include <tdecmoduleloader.h> 00029 00030 class TQTabWidget; 00031 class TQWidget; 00032 class TQVBoxLayout; 00033 00034 class TDECModuleProxy; 00035 00053 class TDEUTILS_EXPORT TDECModuleContainer : public TDECModule 00054 { 00055 Q_OBJECT 00056 public: 00068 TDECModuleContainer( TQWidget* parent, const char* name, const TQStringList& mods ); 00069 00087 TDECModuleContainer( TQWidget *parent, const char* name, const TQString& mods = TQString() ); 00088 00096 void addModule( const TQString& module ); 00097 00101 virtual ~TDECModuleContainer(); 00102 00107 void save(); 00108 00113 void load(); 00114 00119 void defaults(); 00120 00125 virtual TQString handbookSection() const; 00126 00127 protected: 00128 00135 void finalize(); 00136 00137 typedef TQValueList<TDECModuleProxy*> ModuleList; 00138 00143 ModuleList changedModules; 00144 00148 ModuleList allModules; // KDE 4 put in the Private class and abstract with getter 00149 00150 private slots: 00151 00155 void tabSwitched( TQWidget * module ); 00156 00157 void moduleChanged(TDECModuleProxy *proxy); 00158 00162 void runAsRoot(); 00163 00167 void rootExited(); 00168 00169 private: 00170 00171 void init(); 00172 00173 class TDECModuleContainerPrivate; 00174 TDECModuleContainerPrivate *d; 00175 00176 }; 00177 00194 #define KCMODULECONTAINER( modules, factoryName ) \ 00195 extern "C" \ 00196 { \ 00197 TDECModule *create_## factoryName(TQWidget *parent, const char *name) \ 00198 { \ 00199 return new TDECModuleContainer( parent, name, TQString( modules ) ); \ 00200 } \ 00201 \ 00202 bool test_## factoryName() \ 00203 { \ 00204 TQStringList modList = TQStringList::split( ",", TQString(modules).remove( " " )); \ 00205 for ( TQStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) \ 00206 if ( TDECModuleLoader::testModule( *it ) ) \ 00207 return true; \ 00208 return false; \ 00209 } \ 00210 } 00211 00212 #endif // TDECMODULECONTAINER_H 00213