/*! \internal */ void QFormBuilder::createConnections(DomConnections *ui_connections, QWidget *widget) { typedef QList<DomConnection*> DomConnectionList; Q_ASSERT(widget != 0); if (ui_connections == 0) return; const DomConnectionList connections = ui_connections->elementConnection(); if (!connections.empty()) { const DomConnectionList::const_iterator cend = connections.constEnd(); for (DomConnectionList::const_iterator it = connections.constBegin(); it != cend; ++it) { QObject *sender = objectByName(widget, (*it)->elementSender()); QObject *receiver = objectByName(widget, (*it)->elementReceiver()); if (!sender || !receiver) continue; QByteArray sig = (*it)->elementSignal().toUtf8(); sig.prepend("2"); QByteArray sl = (*it)->elementSlot().toUtf8(); sl.prepend("1"); QObject::connect(sender, sig, receiver, sl); } } }
void SignalSlotEditor::fromUi(const DomConnections *connections, QWidget *parent) { if (connections == 0) return; setBackground(parent); clear(); const QList<DomConnection*> list = connections->elementConnection(); foreach (const DomConnection *dom_con, list) { QObject *source = objectByName(parent, dom_con->elementSender()); if (source == 0) { qDebug("SignalSlotEditor::fromUi(): no source widget called \"%s\"", dom_con->elementSender().toUtf8().constData()); continue; } QObject *destination = objectByName(parent, dom_con->elementReceiver()); if (destination == 0) { qDebug("SignalSlotEditor::fromUi(): no destination widget called \"%s\"", dom_con->elementReceiver().toUtf8().constData()); continue; } QPoint sp = QPoint(20, 20), tp = QPoint(20, 20); const DomConnectionHints *dom_hints = dom_con->elementHints(); if (dom_hints != 0) { QList<DomConnectionHint*> list = dom_hints->elementHint(); foreach (DomConnectionHint *hint, list) { QString attr_type = hint->attributeType(); QPoint p = QPoint(hint->elementX(), hint->elementY()); if (attr_type == QLatin1String("sourcelabel")) sp = p; else if (attr_type == QLatin1String("destinationlabel")) tp = p; }
void ConnectionEditor::receiverChanged(const QString& s) { QObject* p_object = objectByName(s); if (!p_object) return; m_receiver = p_object; int n = m_receiver->metaObject()->numSlots(true); slotBox->clear(); for (int i = 0; i < n; ++i) { const QMetaData* md = m_receiver->metaObject()->slot(i, true); if (!isSlotIgnored(md) && !slotBox->findItem(md->name, Qt::ExactMatch)) slotBox->insertItem(md->name); } slotBox->sort(); slotBox->setCurrentItem(slotBox->firstItem()); updateConnectButton(); }
void ConnectionEditor::senderChanged(const QString& s) { QObject* p_object = objectByName(s); if (!p_object) return; m_sender = p_object; QStrList p_sigs = m_sender->metaObject()->signalNames(true); signalBox->clear(); for (QStrListIterator it(p_sigs); it.current(); ++it) if (!isSignalIgnored(it.current()) && !signalBox->findItem(it.current(), Qt::ExactMatch)) signalBox->insertItem(it.current()); if (m_sender == m_formWindow->mainContainer()) signalBox->insertStringList(MetaDataBase::signalList(m_formWindow)); signalBox->sort(); signalBox->setCurrentItem(signalBox->firstItem()); // Update slots - some may (not) have their signal equivalents now. receiverChanged(m_receiver->name()); }