~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to kdevdesigner/designer/connectionitems.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
** Copyright (C) 2002 Trolltech AS.  All rights reserved.
3
 
**
4
 
** This file is part of Qt Designer.
5
 
**
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.
10
 
**
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.
14
 
**
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.
17
 
**
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.
21
 
**
22
 
** Contact info@trolltech.com if any conditions of this licensing are
23
 
** not clear to you.
24
 
**
25
 
**********************************************************************/
26
 
 
27
 
#ifndef CONNECTIONITEMS_H
28
 
#define CONNECTIONITEMS_H
29
 
 
30
 
class FormWindow;
31
 
 
32
 
#include <qtable.h>
33
 
 
34
 
class SenderItem;
35
 
class ReceiverItem;
36
 
class SignalItem;
37
 
class SlotItem;
38
 
class ConnectionContainer;
39
 
 
40
 
 
41
 
class ConnectionItem : public QObject,
42
 
                       public QComboTableItem
43
 
{
44
 
    Q_OBJECT
45
 
 
46
 
public:
47
 
    ConnectionItem( QTable *table, FormWindow *fw );
48
 
 
49
 
    void paint( QPainter *p, const QColorGroup &cg,
50
 
                const QRect &cr, bool selected );
51
 
 
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 );
57
 
 
58
 
public slots:
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 );
63
 
 
64
 
signals:
65
 
    void changed();
66
 
 
67
 
protected:
68
 
    FormWindow *formWindow;
69
 
 
70
 
private:
71
 
    ConnectionContainer *conn;
72
 
 
73
 
};
74
 
 
75
 
// ------------------------------------------------------------------
76
 
 
77
 
class SenderItem : public ConnectionItem
78
 
{
79
 
    Q_OBJECT
80
 
 
81
 
public:
82
 
    SenderItem( QTable *table, FormWindow *fw );
83
 
    QWidget *createEditor() const;
84
 
    void setSenderEx( QObject *sender );
85
 
 
86
 
signals:
87
 
    void currentSenderChanged( QObject *sender );
88
 
 
89
 
private slots:
90
 
    void senderChanged( const QString &sender );
91
 
 
92
 
};
93
 
 
94
 
// ------------------------------------------------------------------
95
 
 
96
 
class ReceiverItem : public ConnectionItem
97
 
{
98
 
    Q_OBJECT
99
 
 
100
 
public:
101
 
    ReceiverItem( QTable *table, FormWindow *fw );
102
 
    QWidget *createEditor() const;
103
 
    void setReceiverEx( QObject *receiver );
104
 
 
105
 
signals:
106
 
    void currentReceiverChanged( QObject *receiver );
107
 
 
108
 
private slots:
109
 
    void receiverChanged( const QString &receiver );
110
 
 
111
 
};
112
 
 
113
 
// ------------------------------------------------------------------
114
 
 
115
 
class SignalItem : public ConnectionItem
116
 
{
117
 
    Q_OBJECT
118
 
 
119
 
public:
120
 
    SignalItem( QTable *table, FormWindow *fw );
121
 
 
122
 
    void senderChanged( QObject *sender );
123
 
    QWidget *createEditor() const;
124
 
 
125
 
signals:
126
 
    void currentSignalChanged( const QString & );
127
 
 
128
 
};
129
 
 
130
 
// ------------------------------------------------------------------
131
 
 
132
 
class SlotItem : public ConnectionItem
133
 
{
134
 
    Q_OBJECT
135
 
 
136
 
public:
137
 
    SlotItem( QTable *table, FormWindow *fw );
138
 
 
139
 
    void receiverChanged( QObject *receiver );
140
 
    void signalChanged( const QString &signal );
141
 
    QWidget *createEditor() const;
142
 
 
143
 
    void customSlotsChanged();
144
 
 
145
 
signals:
146
 
    void currentSlotChanged( const QString & );
147
 
 
148
 
private:
149
 
    void updateSlotList();
150
 
    bool ignoreSlot( const char* slot ) const;
151
 
 
152
 
private:
153
 
    QObject *lastReceiver;
154
 
    QString lastSignal;
155
 
 
156
 
};
157
 
 
158
 
// ------------------------------------------------------------------
159
 
 
160
 
class ConnectionContainer : public QObject
161
 
{
162
 
    Q_OBJECT
163
 
 
164
 
public:
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() ) );
177
 
    }
178
 
 
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] != '<';
186
 
    }
187
 
 
188
 
    void repaint() {
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() );
193
 
    }
194
 
 
195
 
    int row() const { return rw; }
196
 
    void setRow( int r ) { rw = r; }
197
 
 
198
 
    SenderItem *senderItem() const { return se; }
199
 
    SignalItem *signalItem() const { return si; }
200
 
    ReceiverItem *receiverItem() const { return re; }
201
 
    SlotItem *slotItem() const { return sl; }
202
 
 
203
 
public slots:
204
 
    void somethingChanged() { mod = TRUE; emit changed( this ); }
205
 
 
206
 
signals:
207
 
    void changed( ConnectionContainer *c );
208
 
 
209
 
private:
210
 
    bool mod;
211
 
    SenderItem *se;
212
 
    SignalItem *si;
213
 
    ReceiverItem *re;
214
 
    SlotItem *sl;
215
 
    int rw;
216
 
 
217
 
};
218
 
 
219
 
 
220
 
#endif