1
/**********************************************************************
2
** Copyright (C) 2002 Trolltech AS. All rights reserved.
4
** This file is part of Qt Designer.
6
** This file may be distributed and/or modified under the terms of the
7
** GNU General Public License version 2 as published by the Free Software
8
** Foundation and appearing in the file LICENSE.GPL included in the
9
** packaging of this file.
11
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12
** licenses may use this file in accordance with the Qt Commercial License
13
** Agreement provided with the Software.
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
** See http://www.trolltech.com/gpl/ for GPL licensing information.
19
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20
** information about Qt Commercial License Agreements.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
**********************************************************************/
27
#ifndef CONNECTIONITEMS_H
28
#define CONNECTIONITEMS_H
38
class ConnectionContainer;
41
class ConnectionItem : public QObject,
42
public QComboTableItem
47
ConnectionItem( QTable *table, FormWindow *fw );
49
void paint( QPainter *p, const QColorGroup &cg,
50
const QRect &cr, bool selected );
52
void setSender( SenderItem *i );
53
void setReceiver( ReceiverItem *i );
54
void setSignal( SignalItem *i );
55
void setSlot( SlotItem *i );
56
void setConnection( ConnectionContainer *c );
59
virtual void senderChanged( QObject *sender );
60
virtual void receiverChanged( QObject *receiver );
61
virtual void signalChanged( const QString &sig );
62
virtual void slotChanged( const QString &slot );
68
FormWindow *formWindow;
71
ConnectionContainer *conn;
75
// ------------------------------------------------------------------
77
class SenderItem : public ConnectionItem
82
SenderItem( QTable *table, FormWindow *fw );
83
QWidget *createEditor() const;
84
void setSenderEx( QObject *sender );
87
void currentSenderChanged( QObject *sender );
90
void senderChanged( const QString &sender );
94
// ------------------------------------------------------------------
96
class ReceiverItem : public ConnectionItem
101
ReceiverItem( QTable *table, FormWindow *fw );
102
QWidget *createEditor() const;
103
void setReceiverEx( QObject *receiver );
106
void currentReceiverChanged( QObject *receiver );
109
void receiverChanged( const QString &receiver );
113
// ------------------------------------------------------------------
115
class SignalItem : public ConnectionItem
120
SignalItem( QTable *table, FormWindow *fw );
122
void senderChanged( QObject *sender );
123
QWidget *createEditor() const;
126
void currentSignalChanged( const QString & );
130
// ------------------------------------------------------------------
132
class SlotItem : public ConnectionItem
137
SlotItem( QTable *table, FormWindow *fw );
139
void receiverChanged( QObject *receiver );
140
void signalChanged( const QString &signal );
141
QWidget *createEditor() const;
143
void customSlotsChanged();
146
void currentSlotChanged( const QString & );
149
void updateSlotList();
150
bool ignoreSlot( const char* slot ) const;
153
QObject *lastReceiver;
158
// ------------------------------------------------------------------
160
class ConnectionContainer : public QObject
165
ConnectionContainer( QObject *parent, SenderItem *i1, SignalItem *i2,
166
ReceiverItem *i3, SlotItem *i4, int r )
167
: QObject( parent ), mod( FALSE ), se( i1 ), si( i2 ),
168
re( i3 ), sl( i4 ), rw ( r ) {
169
i1->setConnection( this );
170
i2->setConnection( this );
171
i3->setConnection( this );
172
i4->setConnection( this );
173
connect( i1, SIGNAL( changed() ), this, SLOT( somethingChanged() ) );
174
connect( i2, SIGNAL( changed() ), this, SLOT( somethingChanged() ) );
175
connect( i3, SIGNAL( changed() ), this, SLOT( somethingChanged() ) );
176
connect( i4, SIGNAL( changed() ), this, SLOT( somethingChanged() ) );
179
bool isModified() const { return mod; }
180
void setModified( bool b ) { mod = b; repaint(); }
181
bool isValid() const {
182
return se->currentText()[0] != '<' &&
183
si->currentText()[0] != '<' &&
184
re->currentText()[0] != '<' &&
185
sl->currentText()[0] != '<';
189
se->table()->updateCell( se->row(), se->col() );
190
si->table()->updateCell( si->row(), si->col() );
191
re->table()->updateCell( re->row(), re->col() );
192
sl->table()->updateCell( sl->row(), sl->col() );
195
int row() const { return rw; }
196
void setRow( int r ) { rw = r; }
198
SenderItem *senderItem() const { return se; }
199
SignalItem *signalItem() const { return si; }
200
ReceiverItem *receiverItem() const { return re; }
201
SlotItem *slotItem() const { return sl; }
204
void somethingChanged() { mod = TRUE; emit changed( this ); }
207
void changed( ConnectionContainer *c );