| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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( false ),
    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     d->managers.setAutoDelete( true );
    00068
    00069 }
    00070
    00071 KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
    00072     : QWidget(parent, instance ? instance->instanceName().data() : 0)
    00073 {
    00074     init();
    00075     d->_instance = instance;
    00076     KGlobal::locale()->insertCatalogue(instance->instanceName());
    00077     d->_hasOwnInstance = false;
    00078     KGlobal::setActiveInstance(this->instance());
    00079 }
    00080
    00081 void KCModule::init()
    00082 {
    00083     d = new KCModulePrivate;
    00084    _btn = Help|Default|Apply;
    00085 }
    00086
    00087 KConfigDialogManager* KCModule::addConfig( KConfigSkeleton *config, QWidget* widget )
    00088 {
    00089     KConfigDialogManager* manager = new KConfigDialogManager( widget, config, name() );
    00090     connect( manager, SIGNAL( widgetModified() ), SLOT( widgetChanged() ));
    00091     d->managers.append( manager );
    00092     return manager;
    00093 }
    00094
    00095 KCModule::~KCModule()
    00096 {
    00097     if (d->_hasOwnInstance)
    00098        delete d->_instance;
    00099     delete d->_about;
    00100     delete d;
    00101 }
    00102
    00103 void KCModule::load()
    00104 {
    00105     KConfigDialogManager* manager;
    00106     for( manager = d->managers.first(); manager; manager = d->managers.next() )
    00107         manager->updateWidgets();
    00108 }
    00109
    00110 void KCModule::save()
    00111 {
    00112     KConfigDialogManager* manager;
    00113     for( manager = d->managers.first(); manager; manager = d->managers.next() )
    00114         manager->updateSettings();
    00115     emit( changed( false ));
    00116 }
    00117
    00118 void KCModule::defaults()
    00119 {
    00120     KConfigDialogManager* manager;
    00121     for( manager = d->managers.first(); manager; manager = d->managers.next() )
    00122         manager->updateWidgetsDefault();
    00123 }
    00124
    00125 void KCModule::widgetChanged()
    00126 {
    00127     bool bChanged = false;
    00128     KConfigDialogManager* manager;
    00129     for( manager = d->managers.first(); manager; manager = d->managers.next() )
    00130         bChanged |= manager->hasChanged();
    00131     emit( changed( bChanged ));
    00132 }
    00133
    00134 const KAboutData *KCModule::aboutData() const
    00135 {
    00136     return d->_about;
    00137 }
    00138
    00139 void KCModule::setAboutData( KAboutData* about )
    00140 {
    00141     delete d->_about;
    00142     d->_about = about;
    00143 }
    00144
    00145 void KCModule::setRootOnlyMsg(const QString& msg)
    00146 {
    00147     d->_rootOnlyMsg = msg;
    00148 }
    00149
    00150 QString KCModule::rootOnlyMsg() const
    00151 {
    00152     return d->_rootOnlyMsg;
    00153 }
    00154
    00155 void KCModule::setUseRootOnlyMsg(bool on)
    00156 {
    00157     d->_useRootOnlyMsg = on;
    00158 }
    00159
    00160 bool KCModule::useRootOnlyMsg() const
    00161 {
    00162     return d->_useRootOnlyMsg;
    00163 }
    00164
    00165 void KCModule::changed()
    00166 {
    00167     emit changed(true);
    00168 }
    00169
    00170 KInstance *KCModule::instance() const
    00171 {
    00172     return d->_instance;
    00173 }
    00174
    00175 void KCModule::setQuickHelp( const QString& help )
    00176 {
    00177     d->_quickHelp = help;
    00178     emit( quickHelpChanged() );
    00179 }
    00180
    00181 QString KCModule::quickHelp() const
    00182 {
    00183     return d->_quickHelp;
    00184 }
    00185
    00186
    00187 const QPtrList<KConfigDialogManager>& KCModule::configs() const
    00188 {
    00189     return d->managers;
    00190 }
    00191
    00192 void KCModule::virtual_hook( int, void* )
    00193 { /*BASE::virtual_hook( id, data );*/ }
    00194
    00195 // vim: sw=4 et sts=4

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:14 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003