1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/***************************************************************************
* qtobject.h
* This file is part of the KDE project
* copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
*
* This program 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 program 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 program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
***************************************************************************/
#ifndef KROSS_API_QTOBJECT_H
#define KROSS_API_QTOBJECT_H
#include "class.h"
#include <qstring.h>
#include <qobject.h>
// Forward-declaration of the builtin Qt QUObject struct.
struct QUObject;
namespace Kross { namespace Api {
// Forward declarations.
class Object;
class Variant;
class ScriptContainer;
class ScriptContrainer;
/**
* Class to wrap \a QObject or inherited instances.
*
* This class publishs all SIGNAL's, SLOT's and Q_PROPERTY's
* the QObject has.
*/
class QtObject : public Kross::Api::Class<QtObject>
{
public:
/**
* Shared pointer to implement reference-counting.
*/
typedef KSharedPtr<QtObject> Ptr;
/**
* Constructor.
*
* \param object The \a QObject instance this
* class wraps.
* \param name The unique name this \a QtObject
* instance has. If not defined then the
* \a QObject::name() will be used.
*/
QtObject(QObject* object, const QString& name = QString::null);
/**
* Destructor.
*/
virtual ~QtObject();
/// \see Kross::Api::Object::getClassName()
virtual const QString getClassName() const;
/**
* Return the \a QObject instance this class wraps.
*
* \return The wrapped QObject.
*/
QObject* getObject();
/**
* Build a Qt QUObject struct out of the Qt signal or
* slot signature and the passed \a List arguments.
*
* \throw RuntimeException If the try to translate \p arguments
* failed.
* \param signature The Qt signal or slot signature.
* \param arguments The optional \a List of arguments.
* \return A QUObject array.
*/
static QUObject* toQUObject(const QString& signature, List::Ptr arguments);
private:
/// The wrapped QObject.
QObject* m_object;
// QProperty's
/// Return a list of property names.
Kross::Api::Object::Ptr propertyNames(Kross::Api::List::Ptr);
/// Return true if the property exists else false.
Kross::Api::Object::Ptr hasProperty(Kross::Api::List::Ptr);
/// Return a property.
Kross::Api::Object::Ptr getProperty(Kross::Api::List::Ptr);
/// Set a property.
Kross::Api::Object::Ptr setProperty(Kross::Api::List::Ptr);
// Slots
/// Return a list of slot names.
Kross::Api::Object::Ptr slotNames(Kross::Api::List::Ptr);
/// Return true if the slot exists else false.
Kross::Api::Object::Ptr hasSlot(Kross::Api::List::Ptr);
/// Call a slot.
Kross::Api::Object::Ptr callSlot(Kross::Api::List::Ptr);
// Signals
/// Return a list of signal names.
Kross::Api::Object::Ptr signalNames(Kross::Api::List::Ptr);
/// Return true if the signal exists else false.
Kross::Api::Object::Ptr hasSignal(Kross::Api::List::Ptr);
/// Emit a signal.
Kross::Api::Object::Ptr emitSignal(Kross::Api::List::Ptr);
/// Connect signal with a QObject slot.
Kross::Api::Object::Ptr connectSignal(Kross::Api::List::Ptr);
/// Disconnect signal from QObject slot.
Kross::Api::Object::Ptr disconnectSignal(Kross::Api::List::Ptr);
};
}}
#endif
|