New lua versions
[ryzomcore.git] / studio / src / plugins / gui_editor / expression_node.h
blobb1565a277e10db5ecc84dcd7ad0c21e906c0118e
1 // Ryzom Core Studio - GUI Editor Plugin
2 //
3 // Copyright (C) 2010-2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Affero General Public License as
7 // published by the Free Software Foundation, either version 3 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Affero General Public License for more details.
15 // You should have received a copy of the GNU Affero General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef EXPRESSION_NODE
20 #define EXPRESSION_NODE
22 #include <QGraphicsItem>
23 #include <QList>
24 #include "expr_slot_info.h"
26 class ExpressionLink;
27 class NodeSlot;
29 class ExpressionNode : public QGraphicsItem
31 public:
32 ExpressionNode( const QString &name, int slotCount = 3, QGraphicsItem *parent = NULL );
33 ~ExpressionNode();
35 QRectF boundingRect() const;
36 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget );
38 void setLink( ExpressionLink *link, int slot );
39 ExpressionLink* link( int slot ) const;
41 QPointF slotPos( int slot ) const;
43 int slotCount() const{ return m_slots.count(); }
44 void changeSlotCount( int count );
45 void clearSlots();
47 bool slotEmpty( int slot ) const;
49 void getSlots( QList< SlotInfo > &l );
51 void clearLinks();
53 QString name() const{ return m_name; }
55 void setSlotNames( const QList< QString > &l );
57 void setVariable( bool b ){ m_variable = b; }
58 bool variable() const{ return m_variable; }
60 void setValue( const QString &value );
61 QString getValue() const{ return m_value; }
63 bool isValue() const{ return m_isValue; }
64 void setIsValue( bool b ){ m_isValue = b; }
65 void setRoot( bool b );
67 QString build() const;
69 protected:
70 QVariant itemChange( GraphicsItemChange change, const QVariant &value );
72 private:
73 void onNodeMove();
74 void createSlots( int count = 3 );
75 void paintSlots( QPainter *painter );
77 qreal m_w; // node width
78 qreal m_h; // node height
79 qreal m_hh; // header height
81 QList< NodeSlot* > m_slots;
82 QList< ExpressionLink* > m_links;
84 QString m_name;
86 bool m_variable;
88 QString m_value;
89 bool m_isValue;
90 bool m_isRoot;
93 #endif