kdeui Library API Documentation

kcmodule.cpp

00001 /*
00002    This file is part of the KDE libraries
00003 
00004 <<<Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00005    Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.
00021 
00022 */
00023 
00024 #include <qlayout.h>
00025 
00026 #include <kaboutdata.h>
00027 #include <kconfigskeleton.h> 
00028 #include <kconfigdialogmanager.h>
00029 #include <kdebug.h>
00030 #include <kglobal.h>
00031 #include <kinstance.h>
00032 #include <klocale.h>
00033 
00034 #include "kcmodule.h"
00035 #include "kcmodule.moc"
00036 
00037 class KCModulePrivate
00038 {
00039 public:
00040     KCModulePrivate():
00041         _about( 0 ),
00042         _useRootOnlyMsg( true ),
00043         _hasOwnInstance( true )
00044         { }
00045 
00046     KInstance *_instance;
00047     KAboutData *_about;
00048     QString _rootOnlyMsg;
00049     bool _useRootOnlyMsg;
00050     bool _hasOwnInstance;
00051     QPtrList<KConfigDialogManager> managers;
00052     QString _quickHelp;
00053 
00054 };
00055 
00056 KCModule::KCModule(QWidget *parent, const char *name, const QStringList &)
00057     : QWidget(parent, name)
00058 {
00059     init();
00060     if (name && strlen(name)) {
00061         d->_instance = new KInstance(name);
00062         KGlobal::locale()->insertCatalogue(name);
00063     } else
00064         d->_instance = new KInstance("kcmunnamed");
00065     KGlobal::setActiveInstance(this->instance());
00066 }
00067 
00068 KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
00069     : QWidget(parent, instance ? instance->instanceName().data() : 0)
00070 {
00071     init();
00072     d->_instance = instance;
00073     KGlobal::locale()->insertCatalogue(instance->instanceName());
00074     d->_hasOwnInstance = false;
00075     KGlobal::setActiveInstance(this->instance());
00076 }
00077 
00078 void KCModule::init()
00079 { 
00080     d = new KCModulePrivate;
00081    _btn = Help|Default|Apply;
00082 }
00083 
00084 KConfigDialogManager* KCModule::addConfig( KConfigSkeleton *config, QWidget* widget )
00085 {
00086     KConfigDialogManager* manager = new KConfigDialogManager( widget, config, name() );
00087     connect( manager, SIGNAL( settingsChanged() ), SLOT( changed() ));
00088     connect( manager, SIGNAL( widgetModified() ), SLOT( changed() ));
00089     d->managers.append( manager );
00090     return manager;
00091 }
00092 
00093 KCModule::~KCModule()
00094 {
00095     if (d->_hasOwnInstance)
00096        delete d->_instance;
00097     delete d->_about;
00098     delete d;
00099 }
00100 
00101 void KCModule::load()
00102 {
00103     KConfigDialogManager* manager;
00104     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00105         manager->updateWidgets();
00106 }
00107 
00108 void KCModule::save()
00109 {
00110     KConfigDialogManager* manager;
00111     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00112         manager->updateSettings();
00113 }
00114 
00115 void KCModule::defaults()
00116 {
00117     KConfigDialogManager* manager;
00118     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00119         manager->updateWidgetsDefault();
00120 }
00121 
00122 const KAboutData *KCModule::aboutData() const
00123 {
00124     return d->_about;
00125 }
00126 
00127 void KCModule::setAboutData( KAboutData* about )
00128 {
00129     delete d->_about;
00130     d->_about = about;
00131 }
00132 
00133 void KCModule::setRootOnlyMsg(const QString& msg)
00134 {
00135     d->_rootOnlyMsg = msg;
00136 }
00137 
00138 QString KCModule::rootOnlyMsg() const
00139 {
00140     return d->_rootOnlyMsg;
00141 }
00142 
00143 void KCModule::setUseRootOnlyMsg(bool on)
00144 {
00145     d->_useRootOnlyMsg = on;
00146 }
00147 
00148 bool KCModule::useRootOnlyMsg() const
00149 {
00150     return d->_useRootOnlyMsg;
00151 }
00152 
00153 void KCModule::changed()
00154 {
00155     emit changed(true);
00156 }
00157 
00158 KInstance *KCModule::instance() const
00159 {
00160     return d->_instance;
00161 }
00162 
00163 void KCModule::setQuickHelp( const QString& help )
00164 {
00165     d->_quickHelp = help;
00166     emit( quickHelpChanged() );
00167 }
00168 
00169 QString KCModule::quickHelp() const
00170 {
00171     return d->_quickHelp;
00172 }
00173 
00174 
00175 void KCModule::virtual_hook( int, void* )
00176 { /*BASE::virtual_hook( id, data );*/ }
00177 
00178 // vim: sw=4 et sts=4
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:11:59 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003