kdeui Library API Documentation

kcmodule.cpp

00001 /*
00002    This file is part of the KDE libraries
00003 
00004    Copyright (c) 2001 Michael Goffioul <goffioul@imec.be>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 
00021 */
00022 
00023 #include "kcmodule.h"
00024 #include <kinstance.h>
00025 #include <kglobal.h>
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 
00029 class KCModulePrivate
00030 {
00031 public:
00032         KInstance *_instance;
00033         QString _rootOnlyMsg;
00034         bool _useRootOnlyMsg;
00035         bool _hasOwnInstance;
00036 };
00037 
00038 KCModule::KCModule(QWidget *parent, const char *name, const QStringList &)
00039         : QWidget(parent, name), _btn(Help|Default|Apply)
00040 {
00041     kdDebug() << "KCModule " << name << endl;
00042     d = new KCModulePrivate;
00043     d->_useRootOnlyMsg = true;
00044     d->_instance = new KInstance(name);
00045         if (name && strlen(name)) {
00046                 d->_instance = new KInstance(name);
00047                 KGlobal::locale()->insertCatalogue(name);
00048         } else
00049                 d->_instance = new KInstance("kcmunnamed");
00050     d->_hasOwnInstance = true;
00051     KGlobal::setActiveInstance(this->instance());
00052 }
00053 
00054 KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
00055     : QWidget(parent, instance ? instance->instanceName().data() : 0), _btn(Help|Default|Apply)
00056 {
00057     kdDebug() << "KCModule instance " << (instance ? instance->instanceName().data() : "none") << endl;
00058     d = new KCModulePrivate;
00059     d->_useRootOnlyMsg = true;
00060     d->_instance = instance;
00061     KGlobal::locale()->insertCatalogue(instance->instanceName());
00062     d->_hasOwnInstance = false;
00063     KGlobal::setActiveInstance(this->instance());
00064 }
00065 
00066 KCModule::~KCModule()
00067 {
00068     if (d->_hasOwnInstance)
00069        delete d->_instance;
00070         delete d;
00071 }
00072 
00073 void KCModule::setRootOnlyMsg(const QString& msg)
00074 {
00075         d->_rootOnlyMsg = msg;
00076 }
00077 
00078 QString KCModule::rootOnlyMsg() const
00079 {
00080         return d->_rootOnlyMsg;
00081 }
00082 
00083 void KCModule::setUseRootOnlyMsg(bool on)
00084 {
00085         d->_useRootOnlyMsg = on;
00086 }
00087 
00088 bool KCModule::useRootOnlyMsg() const
00089 {
00090         return d->_useRootOnlyMsg;
00091 }
00092 
00093 KInstance *KCModule::instance() const
00094 {
00095     return d->_instance;
00096 }
00097 
00098 void KCModule::virtual_hook( int, void* )
00099 { /*BASE::virtual_hook( id, data );*/ }
00100 
00101 #include "kcmodule.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:15 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001