ConnectionEditor::ConnectionEditor(QWidget* parent, QObject* sndr, QObject* rcvr, FormWindow* fw) : ConnectionEditorBase(parent, 0, true), m_formWindow(fw) { if (!rcvr || rcvr == m_formWindow) rcvr = m_formWindow->mainContainer(); if (!sndr || sndr == m_formWindow) sndr = m_formWindow->mainContainer(); m_sender = sndr; m_receiver = rcvr; /* Create widget list */ QStringList lst; lst << m_formWindow->name(); for (QPtrDictIterator<QWidget> it(*m_formWindow->widgets()); it.current(); ++it) { if (it.current()->isVisibleTo(this) && !it.current()->inherits("QLayoutWidget") && !it.current()->inherits("Spacer") && qstrcmp(it.current()->name(), "central widget") && !m_formWindow->isMainContainer(it.current()) && !lst.contains(it.current()->name())) lst << it.current()->name(); } // Fill receiver combos with widget list // fillWidgetList(comboReceiver, lst, m_receiver->name()); // Fill receiver combos with widget and action list for (QPtrListIterator<QAction> it(m_formWindow->actionList()); it.current(); ++it) lst << it.current()->name(); lst.sort(); fillWidgetList(comboReceiver, lst, m_receiver->name()); fillWidgetList(comboSender, lst, m_sender->name()); senderChanged(m_sender->name()); fillConnectionsList(); updateConnectButton(); updateDisconnectButton(); // Connections connect(comboSender, SIGNAL(activated(const QString&)), SLOT(senderChanged(const QString&))); connect(comboReceiver, SIGNAL(activated(const QString&)), SLOT(receiverChanged(const QString&))); connect(signalBox, SIGNAL(selectionChanged()), SLOT(updateConnectButton())); connect(slotBox, SIGNAL(selectionChanged()), SLOT(updateConnectButton())); connect(connectButton, SIGNAL(clicked()), SLOT(connectClicked())); connect(disconnectButton, SIGNAL(clicked()), SLOT(disconnectClicked())); connect(okButton, SIGNAL(clicked()), SLOT(okClicked())); connect(cancelButton, SIGNAL(clicked()), SLOT(cancelClicked())); connect(signalBox, SIGNAL(doubleClicked(QListBoxItem*)), SLOT(connectClicked())); connect(slotBox, SIGNAL(doubleClicked(QListBoxItem*)), SLOT(connectClicked())); }
void ConnectionEditor::disconnectClicked() { QListViewItem *p_item = connectionView->currentItem(); if (!p_item) return; QMap <QListViewItem*, MetaDataBase::Connection>::Iterator it = m_connections.find(p_item); if (it != m_connections.end()) m_connections.remove(it); delete p_item; if (connectionView->currentItem()) connectionView->setSelected(connectionView->currentItem(), true); updateConnectButton(); updateDisconnectButton(); }
void ConnectionEditor::connectClicked() { if (signalBox->currentItem() == -1 || slotBox->currentItem() == -1) return; if (hasConnection(m_sender->name(), signalBox->currentText(), m_receiver->name(), slotBox->currentText())) return; MetaDataBase::Connection conn; conn.sender = m_sender; conn.signal = signalBox->currentText(); conn.slot = slotBox->currentText(); conn.receiver = m_receiver; KListViewItem *i = new KListViewItem(connectionView, m_sender->name(), conn.signal, m_receiver->name(), conn.slot); i->setPixmap(0, PixmapChooser::loadPixmap("connecttool.xpm")); connectionView->setCurrentItem(i); connectionView->setSelected(i, true); m_connections.insert(i, conn); connectButton->setEnabled(false); updateDisconnectButton(); }