bump version to 3.5beta1
[supercollider.git] / QtCollider / Slot.h
blob6b3aa034560f602929106ef4b498f2655f5f968e
1 /************************************************************************
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef _SLOT_H
23 #define _SLOT_H
25 #include <QString>
26 #include <QRect>
27 #include <QFont>
28 #include <QColor>
29 #include <QList>
30 #include <QVariant>
31 #include <QPalette>
33 #include <PyrSlot.h>
35 #include "Common.h"
36 #include "widgets/QcTreeWidget.h"
38 class QObjectProxy;
40 namespace QtCollider {
42 namespace Slot
44 bool toBool( PyrSlot * );
45 int toInt( PyrSlot * );
46 float toFloat( PyrSlot * );
47 double toDouble( PyrSlot * );
48 QString toString( PyrSlot * );
49 QPointF toPoint( PyrSlot * );
50 QRectF toRect( PyrSlot * );
51 QSizeF toSize( PyrSlot * );
52 QColor toColor( PyrSlot * );
53 QFont toFont( PyrSlot * );
54 QPalette toPalette( PyrSlot * );
55 VariantList toVariantList( PyrSlot * );
56 QObjectProxy * toObjectProxy( PyrSlot * );
57 QcTreeWidget::ItemPtr toTreeWidgetItem( PyrSlot * );
58 QVariant toVariant( PyrSlot * );
60 void setRect( PyrSlot *, const QRectF & );
61 void setPoint( PyrSlot *, const QPointF & );
62 void setSize( PyrSlot *, const QSizeF & );
63 void setString( PyrSlot *, const QString & );
64 void setColor( PyrSlot *, const QColor & );
65 void setPalette( PyrSlot *, const QPalette & );
66 void setQObject( PyrSlot *, QObject * );
67 void setTreeWidgetItem( PyrSlot *, const QcTreeWidget::ItemPtr & );
68 void setVariantList( PyrSlot *, const VariantList& );
69 bool setVariant( PyrSlot *, const QVariant & );
72 class Variant
74 public:
76 Variant() :
77 _type( QMetaType::Void ),
78 _ptr(0)
81 Variant( PyrSlot *slot )
82 { setData( slot ); }
84 ~Variant() {
85 if( _ptr ) {
86 QMetaType::destroy( _type, _ptr );
90 void setData( PyrSlot * );
92 QGenericArgument asGenericArgument() {
93 if( _type != QMetaType::Void )
94 return QGenericArgument( QMetaType::typeName(_type), _ptr );
95 else
96 return QGenericArgument();
99 int type() { return _type; }
101 template<typename T> T value() {
102 if( qMetaTypeId<T>() == _type )
103 return *reinterpret_cast<T*>(_ptr);
104 else
105 return T();
108 private:
110 int _type;
111 void *_ptr;
114 } // namespace QtCollider
116 #endif