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.
101 lines
3.8 KiB
101 lines
3.8 KiB
/* This file is part of the KDE project
|
|
Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
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 KFORMDESIGNEREVENTS_H
|
|
#define KFORMDESIGNEREVENTS_H
|
|
|
|
#include <tqvaluelist.h>
|
|
#include <tqguardedptr.h>
|
|
|
|
class TQDomNode;
|
|
class TQObject;
|
|
|
|
//! A simple class to store events
|
|
/*! There are three different types of events (an maybe more in the future):
|
|
* signal to slot: sender and receiver are both widgets.
|
|
* signal to user function: whenever the signal is emitted, a function in the form script is called.
|
|
* signal to action: the signal activates an application action (eg addNewRecord in Kexi)
|
|
(other :* global signal to user function: an application global signal (new window opened, etc.) calls a user script function)
|
|
|
|
\todo add aliases for slot()?? (eg actionName())
|
|
*/
|
|
class KEXICORE_EXPORT Event
|
|
{
|
|
public:
|
|
Event(TQObject *sender, const TQCString &signal,
|
|
TQObject *receiver, const TQCString &slot);
|
|
Event(TQObject *sender, const TQCString &signal,
|
|
const TQCString &functionName);
|
|
Event() : m_type(Slot) {;}
|
|
~Event() {;}
|
|
|
|
enum { Slot=1000, UserFunction, Action }; //! Event types
|
|
int type() {return m_type; }
|
|
void setType(int type) { m_type = type; }
|
|
|
|
TQObject* sender() const { return m_sender; }
|
|
TQObject* receiver() const { return m_receiver; }
|
|
TQCString signal() const { return m_signal; }
|
|
TQCString slot() const { return m_slot; }
|
|
|
|
void setSender(TQObject *o) { m_sender = o; }
|
|
void setReceiver(TQObject *o) { m_receiver = o; }
|
|
void setSignal(const TQCString &s) { m_signal = s; }
|
|
void setSlot(const TQCString &s) { m_slot = s; }
|
|
|
|
protected:
|
|
TQGuardedPtr<TQObject> m_sender;
|
|
TQCString m_signal;
|
|
TQGuardedPtr<TQObject> m_receiver;
|
|
TQCString m_slot;
|
|
int m_type;
|
|
};
|
|
|
|
class KEXICORE_EXPORT EventList : protected TQValueList<Event*>
|
|
{
|
|
public:
|
|
EventList() {;}
|
|
~EventList() {;}
|
|
|
|
/*! Adds an event in list. Other overload are available, so that
|
|
other classes don't have to use Event class in simple cases. */
|
|
void addEvent(Event *event);
|
|
void addEvent(TQObject *sender, const TQCString &signal, TQObject *receiver, const TQCString &slot);
|
|
void addEvent(TQObject *sender, const TQCString &signal, const TQCString &action);
|
|
/*! Removes the Event \a event from the FormScript's list. */
|
|
void removeEvent(Event *event);
|
|
|
|
/*! \return A list of events related to widget \a name (ie where Event::sender()
|
|
or Event::receiver() == name). */
|
|
EventList* allEventsForObject(TQObject *object);
|
|
/*! Replace all ocurrences of \a oldname with \a newName inside the list. */
|
|
//void renameWidget(const TQCString &oldName, const TQCString &newName);
|
|
/*! Removes all events related to widget \a name. Called eg when widget is destroyed. */
|
|
void removeAllEventsForObject(TQObject *object);
|
|
|
|
// make some TQValueList function accessible by other classes
|
|
TQValueListConstIterator<Event*> constBegin() const { return TQValueList<Event*>::constBegin(); }
|
|
TQValueListConstIterator<Event*> constEnd() const { return TQValueList<Event*>::constEnd(); }
|
|
bool isEmpty() const { return TQValueList<Event*>::isEmpty(); }
|
|
};
|
|
|
|
|
|
#endif
|
|
|