• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kcmodule.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, 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         _unmanagedWidgetChangeState( false )
00045         { }
00046 
00047     KInstance *_instance;
00048     KAboutData *_about;
00049     QString _rootOnlyMsg;
00050     bool _useRootOnlyMsg;
00051     bool _hasOwnInstance;
00052     QPtrList<KConfigDialogManager> managers;
00053     QString _quickHelp;
00054 
00055     // this member is used to record the state on non-automatically
00056     // managed widgets, allowing for mixed KConfigXT-drive and manual
00057     // widgets to coexist peacefully and do the correct thing with
00058     // the changed(bool) signal
00059     bool _unmanagedWidgetChangeState;
00060 };
00061 
00062 KCModule::KCModule(QWidget *parent, const char *name, const QStringList &)
00063     : QWidget(parent, name)
00064 {
00065     init();
00066     if (name && strlen(name)) {
00067         d->_instance = new KInstance(name);
00068         KGlobal::locale()->insertCatalogue(name);
00069     } else
00070         d->_instance = new KInstance("kcmunnamed");
00071     KGlobal::setActiveInstance(this->instance());
00072 
00073     d->managers.setAutoDelete( true );
00074 
00075 }
00076 
00077 KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
00078     : QWidget(parent, instance ? instance->instanceName().data() : 0)
00079 {
00080     init();
00081     d->_instance = instance;
00082 
00083     if (instance)
00084     {
00085         KGlobal::locale()->insertCatalogue(instance->instanceName());
00086     }
00087 
00088     d->_hasOwnInstance = false;
00089     KGlobal::setActiveInstance(this->instance());
00090 }
00091 
00092 void KCModule::init()
00093 {
00094     d = new KCModulePrivate;
00095    _btn = Help|Default|Apply;
00096 }
00097 
00098 KConfigDialogManager* KCModule::addConfig( KConfigSkeleton *config, QWidget* widget )
00099 {
00100     KConfigDialogManager* manager = new KConfigDialogManager( widget, config, name() );
00101     connect( manager, SIGNAL( widgetModified() ), SLOT( widgetChanged() ));
00102     d->managers.append( manager );
00103     return manager;
00104 }
00105 
00106 KCModule::~KCModule()
00107 {
00108     if (d->_hasOwnInstance)
00109        delete d->_instance;
00110     delete d->_about;
00111     delete d;
00112 }
00113 
00114 void KCModule::load()
00115 {
00116     KConfigDialogManager* manager;
00117     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00118         manager->updateWidgets();
00119 }
00120 
00121 void KCModule::save()
00122 {
00123     KConfigDialogManager* manager;
00124     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00125         manager->updateSettings();
00126     emit( changed( false ));
00127 }
00128 
00129 void KCModule::defaults()
00130 {
00131     KConfigDialogManager* manager;
00132     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00133         manager->updateWidgetsDefault();
00134 }
00135 
00136 void KCModule::widgetChanged()
00137 {
00138     emit changed(d->_unmanagedWidgetChangeState || managedWidgetChangeState());
00139 }
00140 
00141 bool KCModule::managedWidgetChangeState() const
00142 {
00143     KConfigDialogManager* manager;
00144     for( manager = d->managers.first(); manager; manager = d->managers.next() )
00145     {
00146         if ( manager->hasChanged() )
00147             return true;
00148     }
00149 
00150     return false;
00151 }
00152 
00153 void KCModule::unmanagedWidgetChangeState(bool changed)
00154 {
00155     d->_unmanagedWidgetChangeState = changed;
00156     widgetChanged();
00157 }
00158 
00159 const KAboutData *KCModule::aboutData() const
00160 {
00161     return d->_about;
00162 }
00163 
00164 void KCModule::setAboutData( KAboutData* about )
00165 {
00166     delete d->_about;
00167     d->_about = about;
00168 }
00169 
00170 void KCModule::setRootOnlyMsg(const QString& msg)
00171 {
00172     d->_rootOnlyMsg = msg;
00173 }
00174 
00175 QString KCModule::rootOnlyMsg() const
00176 {
00177     return d->_rootOnlyMsg;
00178 }
00179 
00180 void KCModule::setUseRootOnlyMsg(bool on)
00181 {
00182     d->_useRootOnlyMsg = on;
00183 }
00184 
00185 bool KCModule::useRootOnlyMsg() const
00186 {
00187     return d->_useRootOnlyMsg;
00188 }
00189 
00190 void KCModule::changed()
00191 {
00192     emit changed(true);
00193 }
00194 
00195 KInstance *KCModule::instance() const
00196 {
00197     return d->_instance;
00198 }
00199 
00200 void KCModule::setQuickHelp( const QString& help )
00201 {
00202     d->_quickHelp = help;
00203     emit( quickHelpChanged() );
00204 }
00205 
00206 QString KCModule::quickHelp() const
00207 {
00208     return d->_quickHelp;
00209 }
00210 
00211 
00212 const QPtrList<KConfigDialogManager>& KCModule::configs() const
00213 {
00214     return d->managers;
00215 }
00216 
00217 void KCModule::virtual_hook( int, void* )
00218 { /*BASE::virtual_hook( id, data );*/ }
00219 
00220 // vim: sw=4 et sts=4

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal