~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2005-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the designer application of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include <QtCore/QAbstractItemModel>
 
30
#include <QtCore/QDebug>
 
31
#include <QtGui/QStandardItemModel>
 
32
#include <QtGui/QComboBox>
 
33
#include <QtGui/QApplication>
 
34
#include <QtGui/QItemDelegate>
 
35
#include <QtGui/QItemEditorFactory>
 
36
#include <QtGui/QTreeView>
 
37
#include <QtGui/QVBoxLayout>
 
38
#include <QtGui/QToolButton>
 
39
 
 
40
#include <iconloader_p.h>
 
41
 
 
42
#include <abstractformeditor.h>
 
43
#include <abstractformwindowmanager.h>
 
44
#include "signalsloteditorwindow.h"
 
45
#include "signalsloteditor_p.h"
 
46
#include "signalsloteditor.h"
 
47
 
 
48
namespace qdesigner_internal {
 
49
 
 
50
/*******************************************************************************
 
51
** ConnectionModel
 
52
*/
 
53
 
 
54
ConnectionModel::ConnectionModel(SignalSlotEditor *editor, QObject *parent)
 
55
    : QAbstractItemModel(parent)
 
56
{
 
57
    m_editor = editor;
 
58
 
 
59
    connect(m_editor, SIGNAL(connectionAdded(Connection*)),
 
60
            this, SLOT(connectionAdded(Connection*)));
 
61
    connect(m_editor, SIGNAL(connectionRemoved(int)),
 
62
            this, SLOT(connectionRemoved(int)));
 
63
    connect(m_editor, SIGNAL(aboutToRemoveConnection(Connection*)),
 
64
            this, SLOT(aboutToRemoveConnection(Connection*)));
 
65
    connect(m_editor, SIGNAL(aboutToAddConnection(int)),
 
66
            this, SLOT(aboutToAddConnection(int)));
 
67
    connect(m_editor, SIGNAL(connectionChanged(Connection*)),
 
68
            this, SLOT(connectionChanged(Connection*)));
 
69
}
 
70
 
 
71
QVariant ConnectionModel::headerData(int section, Qt::Orientation orientation,
 
72
                                        int role) const
 
73
{
 
74
    QVariant result;
 
75
 
 
76
    if (orientation == Qt::Vertical)
 
77
        return result;
 
78
    if (role != Qt::DisplayRole)
 
79
        return result;
 
80
 
 
81
    switch (section) {
 
82
        case 0:
 
83
            result = tr("Sender");
 
84
            break;
 
85
        case 1:
 
86
            result = tr("Signal");
 
87
            break;
 
88
        case 2:
 
89
            result = tr("Receiver");
 
90
            break;
 
91
        case 3:
 
92
            result = tr("Slot");
 
93
            break;
 
94
    }
 
95
 
 
96
    return result;
 
97
}
 
98
 
 
99
QModelIndex ConnectionModel::index(int row, int column,
 
100
                                    const QModelIndex &parent) const
 
101
{
 
102
    if (parent.isValid())
 
103
        return QModelIndex();
 
104
    if (row < 0 || row >= m_editor->connectionCount())
 
105
        return QModelIndex();
 
106
    return createIndex(row, column);
 
107
}
 
108
 
 
109
Connection *ConnectionModel::indexToConnection(const QModelIndex &index) const
 
110
{
 
111
    if (!index.isValid())
 
112
        return 0;
 
113
    if (index.row() < 0 || index.row() >= m_editor->connectionCount())
 
114
        return 0;
 
115
    return m_editor->connection(index.row());
 
116
}
 
117
 
 
118
QModelIndex ConnectionModel::connectionToIndex(Connection *con) const
 
119
{
 
120
    return createIndex(m_editor->indexOfConnection(con), 0);
 
121
}
 
122
 
 
123
QModelIndex ConnectionModel::parent(const QModelIndex&) const
 
124
{
 
125
    return QModelIndex();
 
126
}
 
127
 
 
128
int ConnectionModel::rowCount(const QModelIndex &parent) const
 
129
{
 
130
    if (parent.isValid())
 
131
        return 0;
 
132
    return m_editor->connectionCount();
 
133
}
 
134
 
 
135
int ConnectionModel::columnCount(const QModelIndex &parent) const
 
136
{
 
137
    if (parent.isValid())
 
138
        return 0;
 
139
    return 4;
 
140
}
 
141
 
 
142
QVariant ConnectionModel::data(const QModelIndex &index, int role) const
 
143
{
 
144
    if (role != Qt::DisplayRole && role != Qt::EditRole)
 
145
        return QVariant();
 
146
 
 
147
    if (index.row() < 0 || index.row() >= m_editor->connectionCount())
 
148
        return QVariant();
 
149
 
 
150
    SignalSlotConnection *con
 
151
        = static_cast<SignalSlotConnection*>(m_editor->connection(index.row()));
 
152
    Q_ASSERT(con != 0);
 
153
 
 
154
    switch (index.column()) {
 
155
        case 0: {
 
156
            QString sender = con->sender();
 
157
            if (sender.isEmpty())
 
158
                sender = tr("<sender>");
 
159
            return sender;
 
160
        }
 
161
        case 1: {
 
162
            QString signal = con->signal();
 
163
            if (signal.isEmpty())
 
164
                signal = tr("<signal>");
 
165
            return signal;
 
166
        }
 
167
        case 2: {
 
168
            QString receiver = con->receiver();
 
169
            if (receiver.isEmpty())
 
170
                receiver = tr("<receiver>");
 
171
            return receiver;
 
172
        }
 
173
        case 3: {
 
174
            QString slot = con->slot();
 
175
            if (slot.isEmpty())
 
176
                slot = tr("<slot>");
 
177
            return slot;
 
178
        }
 
179
    }
 
180
 
 
181
    return QVariant();
 
182
}
 
183
 
 
184
bool ConnectionModel::setData(const QModelIndex &index, const QVariant &data, int)
 
185
{
 
186
    if (!index.isValid())
 
187
        return false;
 
188
    if (data.type() != QVariant::String)
 
189
        return false;
 
190
 
 
191
    SignalSlotConnection *con = static_cast<SignalSlotConnection*>(m_editor->connection(index.row()));
 
192
    QDesignerFormWindowInterface *form = m_editor->formWindow();
 
193
 
 
194
    QString s = data.toString();
 
195
    switch (index.column()) {
 
196
        case 0: {
 
197
            if (!s.isEmpty() && !objectNameList(form).contains(s))
 
198
                s.clear();
 
199
            m_editor->setSource(con, s);
 
200
            break;
 
201
        }
 
202
        case 1: {
 
203
            if (!memberList(form, con->widget(CETypes::EndPoint::Source), SignalMember).contains(s))
 
204
                s.clear();
 
205
            m_editor->setSignal(con, s);
 
206
            break;
 
207
        }
 
208
        case 2: {
 
209
            if (!s.isEmpty() && !objectNameList(form).contains(s))
 
210
                s.clear();
 
211
            m_editor->setTarget(con, s);
 
212
            break;
 
213
        }
 
214
        case 3: {
 
215
            if (!memberList(form, con->widget(CETypes::EndPoint::Target), SlotMember).contains(s))
 
216
                s.clear();
 
217
            m_editor->setSlot(con, s);
 
218
            break;
 
219
        }
 
220
    }
 
221
 
 
222
    return true;
 
223
}
 
224
 
 
225
void ConnectionModel::connectionAdded(Connection*)
 
226
{
 
227
    endInsertRows();
 
228
}
 
229
 
 
230
void ConnectionModel::connectionRemoved(int)
 
231
{
 
232
    endRemoveRows();
 
233
}
 
234
 
 
235
void ConnectionModel::aboutToRemoveConnection(Connection *con)
 
236
{
 
237
    int idx = m_editor->indexOfConnection(con);
 
238
    beginRemoveRows(QModelIndex(), idx, idx);
 
239
}
 
240
 
 
241
void ConnectionModel::aboutToAddConnection(int idx)
 
242
{
 
243
    beginInsertRows(QModelIndex(), idx, idx);
 
244
}
 
245
 
 
246
Qt::ItemFlags ConnectionModel::flags(const QModelIndex&) const
 
247
{
 
248
    return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
 
249
}
 
250
 
 
251
void ConnectionModel::connectionChanged(Connection *con)
 
252
{
 
253
    int idx = m_editor->indexOfConnection(con);
 
254
    emit dataChanged(createIndex(idx, 0), createIndex(idx, 3));
 
255
}
 
256
 
 
257
/*******************************************************************************
 
258
** InlineEditor
 
259
*/
 
260
 
 
261
#define TITLE_ITEM 1
 
262
 
 
263
class InlineEditorModel : public QStandardItemModel
 
264
{
 
265
    Q_OBJECT
 
266
public:
 
267
    InlineEditorModel(int rows, int cols, QObject *parent = 0);
 
268
 
 
269
    void addTitle(const QString &title);
 
270
    void addTextList(const QStringList &text_list);
 
271
    void addText(const QString &text);
 
272
    bool isTitle(int idx) const;
 
273
 
 
274
    int findText(const QString &text) const;
 
275
 
 
276
    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 
277
};
 
278
 
 
279
class InlineEditor : public QComboBox
 
280
{
 
281
    Q_OBJECT
 
282
    Q_PROPERTY(QString text READ text WRITE setText)
 
283
public:
 
284
    InlineEditor(QWidget *parent = 0);
 
285
    ~InlineEditor();
 
286
 
 
287
    QString text() const;
 
288
    void setText(const QString &text);
 
289
 
 
290
    void addTitle(const QString &title);
 
291
    void addText(const QString &text);
 
292
    void addTextList(const QStringList &text_list);
 
293
 
 
294
private slots:
 
295
    void checkSelection(int idx);
 
296
 
 
297
private:
 
298
    InlineEditorModel *m_model;
 
299
    int m_idx;
 
300
};
 
301
 
 
302
InlineEditorModel::InlineEditorModel(int rows, int cols, QObject *parent)
 
303
    : QStandardItemModel(rows, cols, parent)
 
304
{
 
305
}
 
306
 
 
307
void InlineEditorModel::addTitle(const QString &title)
 
308
{
 
309
    int cnt = rowCount();
 
310
    insertRows(cnt, 1);
 
311
    QModelIndex cat_idx = index(cnt, 0);
 
312
    setData(cat_idx, title + QLatin1Char(':'), Qt::DisplayRole);
 
313
    setData(cat_idx, TITLE_ITEM, Qt::UserRole);
 
314
    QFont font = QApplication::font();
 
315
    font.setBold(true);
 
316
    setData(cat_idx, font, Qt::FontRole);
 
317
}
 
318
 
 
319
bool InlineEditorModel::isTitle(int idx) const
 
320
{
 
321
    if (idx == -1)
 
322
        return false;
 
323
 
 
324
    return data(index(idx, 0), Qt::UserRole).toInt() == TITLE_ITEM;
 
325
}
 
326
 
 
327
void InlineEditorModel::addText(const QString &text)
 
328
{
 
329
    int cnt = rowCount();
 
330
    insertRows(cnt, 1);
 
331
    setData(index(cnt, 0), text, Qt::DisplayRole);
 
332
}
 
333
 
 
334
void InlineEditorModel::addTextList(const QStringList &text_list)
 
335
{
 
336
    int cnt = rowCount();
 
337
    insertRows(cnt, text_list.size());
 
338
    foreach (QString text, text_list) {
 
339
        QModelIndex text_idx = index(cnt++, 0);
 
340
        setData(text_idx, text, Qt::DisplayRole);
 
341
    }
 
342
}
 
343
 
 
344
Qt::ItemFlags InlineEditorModel::flags(const QModelIndex &index) const
 
345
{
 
346
    if (isTitle(index.row()))
 
347
        return Qt::ItemIsEnabled;
 
348
    else
 
349
        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
 
350
}
 
351
 
 
352
int InlineEditorModel::findText(const QString &text) const
 
353
{
 
354
    int cnt = rowCount();
 
355
    for (int i = 0; i < cnt; ++i) {
 
356
        QModelIndex idx = index(i, 0);
 
357
        if (data(idx, Qt::UserRole).toInt() == TITLE_ITEM)
 
358
            continue;
 
359
        if (data(idx, Qt::DisplayRole).toString() == text)
 
360
            return i;
 
361
    }
 
362
    return -1;
 
363
}
 
364
 
 
365
InlineEditor::InlineEditor(QWidget *parent)
 
366
    : QComboBox(parent)
 
367
{
 
368
    setModel(m_model = new InlineEditorModel(0, 4, this));
 
369
    setFrame(false);
 
370
    m_idx = -1;
 
371
    connect(this, SIGNAL(activated(int)), this, SLOT(checkSelection(int)));
 
372
}
 
373
 
 
374
InlineEditor::~InlineEditor()
 
375
{
 
376
}
 
377
 
 
378
void InlineEditor::checkSelection(int idx)
 
379
{
 
380
    if (idx == m_idx)
 
381
        return;
 
382
    if (m_model->isTitle(idx))
 
383
        setCurrentIndex(m_idx);
 
384
    else
 
385
        m_idx = idx;
 
386
}
 
387
 
 
388
void InlineEditor::addTitle(const QString &title)
 
389
{
 
390
    m_model->addTitle(title);
 
391
}
 
392
 
 
393
void InlineEditor::addTextList(const QStringList &text_list)
 
394
{
 
395
    m_model->addTextList(text_list);
 
396
}
 
397
 
 
398
void InlineEditor::addText(const QString &text)
 
399
{
 
400
    m_model->addText(text);
 
401
}
 
402
 
 
403
QString InlineEditor::text() const
 
404
{
 
405
    return currentText();
 
406
}
 
407
 
 
408
void InlineEditor::setText(const QString &text)
 
409
{
 
410
    m_idx = m_model->findText(text);
 
411
    if (m_idx == -1)
 
412
        m_idx = 0;
 
413
    setCurrentIndex(m_idx);
 
414
}
 
415
 
 
416
/*******************************************************************************
 
417
** ConnectionDelegate
 
418
*/
 
419
 
 
420
class ConnectionDelegate : public QItemDelegate
 
421
{
 
422
    Q_OBJECT
 
423
public:
 
424
    ConnectionDelegate(QWidget *parent = 0);
 
425
 
 
426
    void setForm(QDesignerFormWindowInterface *form);
 
427
 
 
428
    virtual QWidget *createEditor(QWidget *parent,
 
429
                                    const QStyleOptionViewItem &option,
 
430
                                    const QModelIndex &index) const;
 
431
 
 
432
private slots:
 
433
    void emitCommitData();
 
434
 
 
435
private:
 
436
    QDesignerFormWindowInterface *m_form;
 
437
};
 
438
 
 
439
ConnectionDelegate::ConnectionDelegate(QWidget *parent)
 
440
    : QItemDelegate(parent)
 
441
{
 
442
    m_form = 0;
 
443
 
 
444
    static QItemEditorFactory *factory = 0;
 
445
    if (factory == 0) {
 
446
        factory = new QItemEditorFactory;
 
447
        QItemEditorCreatorBase *creator
 
448
            = new QItemEditorCreator<InlineEditor>("text");
 
449
        factory->registerEditor(QVariant::String, creator);
 
450
    }
 
451
 
 
452
    setItemEditorFactory(factory);
 
453
}
 
454
 
 
455
void ConnectionDelegate::setForm(QDesignerFormWindowInterface *form)
 
456
{
 
457
    m_form = form;
 
458
}
 
459
 
 
460
QWidget *ConnectionDelegate::createEditor(QWidget *parent,
 
461
                                                const QStyleOptionViewItem &option,
 
462
                                                const QModelIndex &index) const
 
463
{
 
464
    if (m_form == 0)
 
465
        return 0;
 
466
 
 
467
    QWidget *w = QItemDelegate::createEditor(parent, option, index);
 
468
    InlineEditor *inline_editor = qobject_cast<InlineEditor*>(w);
 
469
    Q_ASSERT(inline_editor != 0);
 
470
    const QAbstractItemModel *model = index.model();
 
471
 
 
472
    QModelIndex obj_name_idx = model->index(index.row(), index.column() <= 1 ? 0 : 2);
 
473
    QString obj_name = model->data(obj_name_idx, Qt::DisplayRole).toString();
 
474
 
 
475
    if (index.column() == 0 || index.column() == 2) { // object names
 
476
        QStringList obj_name_list = objectNameList(m_form);
 
477
        obj_name_list.prepend(tr("<object>"));
 
478
        inline_editor->addTextList(obj_name_list);
 
479
    } else { // signals, slots
 
480
        MemberType type = index.column() == 1 ? SignalMember : SlotMember;
 
481
        QModelIndex peer_index = model->index(index.row(), type == SignalMember ? 3 : 1);
 
482
        QString peer = model->data(peer_index, Qt::DisplayRole).toString();
 
483
        ClassList class_list = classList(obj_name, type, peer, m_form);
 
484
 
 
485
        inline_editor->addText(type == SignalMember ? tr("<signal>") : tr("<slot>"));
 
486
        foreach (const ClassInfo &class_info, class_list) {
 
487
            if (class_info.class_name.isEmpty() || class_info.member_list.isEmpty())
 
488
                continue;
 
489
            inline_editor->addTitle(class_info.class_name);
 
490
            inline_editor->addTextList(class_info.member_list);
 
491
        }
 
492
    }
 
493
 
 
494
    connect(inline_editor, SIGNAL(activated(int)), this, SLOT(emitCommitData()));
 
495
 
 
496
    return inline_editor;
 
497
}
 
498
 
 
499
void ConnectionDelegate::emitCommitData()
 
500
{
 
501
    InlineEditor *editor = qobject_cast<InlineEditor*>(sender());
 
502
    emit commitData(editor);
 
503
}
 
504
 
 
505
/*******************************************************************************
 
506
** SignalSlotEditorWindow
 
507
*/
 
508
 
 
509
SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *core,
 
510
                                                QWidget *parent)
 
511
    : QWidget(parent)
 
512
{
 
513
    m_handling_selection_change = false;
 
514
 
 
515
    m_editor = 0;
 
516
    m_view = new QTreeView(this);
 
517
    m_view->setItemDelegate(new ConnectionDelegate(this));
 
518
    m_view->setEditTriggers(QAbstractItemView::SelectedClicked
 
519
                                | QAbstractItemView::EditKeyPressed);
 
520
    m_view->setRootIsDecorated(false);
 
521
    connect(m_view, SIGNAL(activated(const QModelIndex&)), this, SLOT(updateUi()));
 
522
 
 
523
    QVBoxLayout *layout = new QVBoxLayout(this);
 
524
    layout->setMargin(0);
 
525
    layout->addWidget(m_view);
 
526
 
 
527
    QHBoxLayout *layout2 = new QHBoxLayout;
 
528
    layout2->setMargin(3);
 
529
    layout->addLayout(layout2);
 
530
    layout2->addStretch();
 
531
 
 
532
    m_remove_button = new QToolButton(this);
 
533
    m_remove_button->setIcon(createIconSet(QLatin1String("minus.png")));
 
534
    connect(m_remove_button, SIGNAL(clicked()), this, SLOT(removeConnection()));
 
535
    layout2->addWidget(m_remove_button);
 
536
 
 
537
    m_add_button = new QToolButton(this);
 
538
    m_add_button->setIcon(createIconSet(QLatin1String("plus.png")));
 
539
    connect(m_add_button, SIGNAL(clicked()), this, SLOT(addConnection()));
 
540
    layout2->addWidget(m_add_button);
 
541
 
 
542
    connect(core->formWindowManager(),
 
543
            SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
 
544
                this, SLOT(setActiveFormWindow(QDesignerFormWindowInterface*)));
 
545
 
 
546
    updateUi();
 
547
}
 
548
 
 
549
void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *form)
 
550
{
 
551
    m_view->setModel(0);
 
552
 
 
553
    if (!m_editor.isNull()) {
 
554
        disconnect(m_view->selectionModel(),
 
555
                    SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
 
556
                    this, SLOT(updateEditorSelection(const QModelIndex&)));
 
557
        disconnect(m_editor, SIGNAL(connectionSelected(Connection*)),
 
558
                    this, SLOT(updateDialogSelection(Connection*)));
 
559
    }
 
560
 
 
561
    m_editor = qFindChild<SignalSlotEditor*>(form);
 
562
 
 
563
    if (!m_editor.isNull()) {
 
564
        m_view->setModel(m_editor->model());
 
565
        ConnectionDelegate *delegate
 
566
            = qobject_cast<ConnectionDelegate*>(m_view->itemDelegate());
 
567
        if (delegate != 0)
 
568
            delegate->setForm(form);
 
569
 
 
570
        connect(m_view->selectionModel(),
 
571
                SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
 
572
                this, SLOT(updateEditorSelection(const QModelIndex&)));
 
573
        connect(m_editor, SIGNAL(connectionSelected(Connection*)),
 
574
                this, SLOT(updateDialogSelection(Connection*)));
 
575
    }
 
576
 
 
577
    updateUi();
 
578
}
 
579
 
 
580
void SignalSlotEditorWindow::updateDialogSelection(Connection *con)
 
581
{
 
582
    if (m_handling_selection_change || m_editor == 0)
 
583
        return;
 
584
 
 
585
    ConnectionModel *model = qobject_cast<ConnectionModel*>(m_editor->model());
 
586
    Q_ASSERT(model != 0);
 
587
    QModelIndex index = model->connectionToIndex(con);
 
588
    if (index == m_view->currentIndex())
 
589
        return;
 
590
    m_handling_selection_change = true;
 
591
    m_view->setCurrentIndex(index);
 
592
    m_handling_selection_change = false;
 
593
 
 
594
    updateUi();
 
595
}
 
596
 
 
597
void SignalSlotEditorWindow::updateEditorSelection(const QModelIndex &index)
 
598
{
 
599
    if (m_handling_selection_change || m_editor == 0)
 
600
        return;
 
601
 
 
602
    if (m_editor == 0)
 
603
        return;
 
604
 
 
605
    ConnectionModel *model = qobject_cast<ConnectionModel*>(m_editor->model());
 
606
    Q_ASSERT(model != 0);
 
607
    Connection *con = model->indexToConnection(index);
 
608
    if (m_editor->selected(con))
 
609
        return;
 
610
    m_handling_selection_change = true;
 
611
    m_editor->selectNone();
 
612
    m_editor->setSelected(con, true);
 
613
    m_handling_selection_change = false;
 
614
 
 
615
    updateUi();
 
616
}
 
617
 
 
618
void SignalSlotEditorWindow::addConnection()
 
619
{
 
620
    if (m_editor.isNull())
 
621
        return;
 
622
 
 
623
    m_editor->addEmptyConnection();
 
624
    updateUi();
 
625
}
 
626
 
 
627
void SignalSlotEditorWindow::removeConnection()
 
628
{
 
629
    if (m_editor.isNull())
 
630
        return;
 
631
 
 
632
    m_editor->deleteSelected();
 
633
    updateUi();
 
634
}
 
635
 
 
636
void SignalSlotEditorWindow::updateUi()
 
637
{
 
638
    m_add_button->setEnabled(!m_editor.isNull());
 
639
    m_remove_button->setEnabled(!m_editor.isNull() && m_view->currentIndex().isValid());
 
640
}
 
641
 
 
642
} // namespace qdesigner_internal
 
643
 
 
644
#include "signalsloteditorwindow.moc"