You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.3 KiB
134 lines
4.3 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
*/
|
||
|
|
||
|
#ifndef KSETTINGS_DISPATCHER_H
|
||
|
#define KSETTINGS_DISPATCHER_H
|
||
|
|
||
15 years ago
|
#include <tqobject.h>
|
||
|
#include <tqmap.h>
|
||
13 years ago
|
#include <tdelibs_export.h>
|
||
15 years ago
|
|
||
15 years ago
|
class TQCString;
|
||
|
class TQSignal;
|
||
|
class TQStrList;
|
||
15 years ago
|
template<class T> class KStaticDeleter;
|
||
12 years ago
|
class TDEInstance;
|
||
12 years ago
|
class TDEConfig;
|
||
15 years ago
|
|
||
|
namespace KSettings
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* @ingroup settings
|
||
|
* @short Dispatch change notifications from the KCMs to the program.
|
||
|
*
|
||
|
* Since your program does not have direct control over the KCMs that get loaded
|
||
12 years ago
|
* into the TDEConfigureDialog you need a way to get notified. This is what you
|
||
15 years ago
|
* do:
|
||
|
* \code
|
||
15 years ago
|
* Dispatcher::self()->registerInstance( instance(), this, TQT_SLOT( loadSettings() ) );
|
||
15 years ago
|
* \endcode
|
||
|
*
|
||
|
* @author Matthias Kretz <kretz@kde.org>
|
||
|
* @since 3.2
|
||
|
*/
|
||
14 years ago
|
class KUTILS_EXPORT Dispatcher : public TQObject
|
||
15 years ago
|
{
|
||
|
friend class KStaticDeleter<Dispatcher>;
|
||
|
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
/**
|
||
|
* Get a reference the the Dispatcher object.
|
||
|
*/
|
||
|
static Dispatcher * self();
|
||
|
|
||
|
/**
|
||
|
* Register a slot to be called when the configuration for the instance
|
||
12 years ago
|
* has changed. @p instance is the TDEInstance object
|
||
15 years ago
|
* that is passed to KGenericFactory (if it is used). You can query
|
||
|
* it with KGenericFactory<YourClassName>::instance().
|
||
|
* instance->instanceName() is also the same name that is put into the
|
||
13 years ago
|
* .desktop file of the KCMs for the X-TDE-ParentComponents.
|
||
15 years ago
|
*
|
||
12 years ago
|
* @param instance The TDEInstance object
|
||
15 years ago
|
* @param recv The object that should receive the signal
|
||
15 years ago
|
* @param slot The slot to be called: TQT_SLOT( slotName() )
|
||
15 years ago
|
*/
|
||
12 years ago
|
void registerInstance( TDEInstance * instance, TQObject * recv, const char * slot );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @return the TDEConfig object that belongs to the instanceName
|
||
15 years ago
|
*/
|
||
12 years ago
|
TDEConfig * configForInstanceName( const TQCString & instanceName );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return a list of all the instance names that are currently
|
||
|
* registered
|
||
|
*/
|
||
15 years ago
|
TQStrList instanceNames() const;
|
||
15 years ago
|
|
||
|
//X /**
|
||
12 years ago
|
//X * @return The TDEInstance object belonging to the instance name you pass
|
||
15 years ago
|
//X * (only works for registered instances of course).
|
||
|
//X */
|
||
12 years ago
|
//X TDEInstance * instanceForName( const TQCString & instanceName );
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
/**
|
||
|
* Call this slot when the configuration belonging to the associated
|
||
|
* instance name has changed. The registered slot will be called.
|
||
|
*
|
||
13 years ago
|
* @param instanceName The value of X-TDE-ParentComponents.
|
||
15 years ago
|
*/
|
||
15 years ago
|
void reparseConfiguration( const TQCString & instanceName );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* When this slot is called the TDEConfig objects of all the registered
|
||
|
* instances are sync()ed. This is usefull when some other TDEConfig
|
||
15 years ago
|
* objects will read/write from/to the same config file, so that you
|
||
12 years ago
|
* can first write out the current state of the TDEConfig objects.
|
||
15 years ago
|
*/
|
||
|
void syncConfiguration();
|
||
|
|
||
|
private slots:
|
||
15 years ago
|
void unregisterInstance( TQObject * );
|
||
15 years ago
|
|
||
|
private:
|
||
15 years ago
|
Dispatcher( TQObject * parent = 0, const char * name = 0 );
|
||
15 years ago
|
~Dispatcher();
|
||
|
static Dispatcher * m_self;
|
||
|
|
||
|
struct InstanceInfo {
|
||
12 years ago
|
TDEInstance * instance;
|
||
15 years ago
|
TQSignal * signal;
|
||
15 years ago
|
int count;
|
||
|
};
|
||
15 years ago
|
TQMap<TQCString, InstanceInfo> m_instanceInfo;
|
||
|
TQMap<TQObject *, TQCString> m_instanceName;
|
||
15 years ago
|
|
||
|
class DispatcherPrivate;
|
||
|
DispatcherPrivate * d;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
// vim: sw=4 sts=4 et
|
||
|
#endif // KSETTINGS_DISPATCHER_H
|