43 DomConnection *result =
new DomConnection;
45 result->setElementSender(sender());
46 result->setElementSignal(signal());
47 result->setElementReceiver(receiver());
48 result->setElementSlot(slot());
50 DomConnectionHints *hints =
new DomConnectionHints;
51 QList<DomConnectionHint *> list;
53 QPoint sp = endPointPos(EndPoint::Source);
54 QPoint tp = endPointPos(EndPoint::Target);
56 DomConnectionHint *hint =
new DomConnectionHint;
57 hint->setAttributeType(u"sourcelabel"_s);
58 hint->setElementX(sp.x());
59 hint->setElementY(sp.y());
62 hint =
new DomConnectionHint;
63 hint->setAttributeType(u"destinationlabel"_s);
64 hint->setElementX(tp.x());
65 hint->setElementY(tp.y());
68 hints->setElementHint(list);
69 result->setElementHints(hints);
124 const QObject *source = object(EndPoint::Source);
128 const QObject *target = object(EndPoint::Target);
132 if (m_slot.isEmpty() || m_signal.isEmpty())
135 if (
const QWidget *sourceWidget = qobject_cast<
const QWidget*>(source))
136 if (!background->isAncestorOf(sourceWidget))
139 if (
const QWidget *targetWidget = qobject_cast<
const QWidget*>(target))
140 if (!background->isAncestorOf(targetWidget))
260 sigslot_con->widget(EndPoint::Source),
261 sigslot_con->widget(EndPoint::Target),
262 m_form_window->core()->topLevel());
264 dialog.setSignalSlot(sigslot_con->signal(), sigslot_con->slot());
267 if (dialog.exec() == QDialog::Accepted) {
268 const QString newSignal = dialog.signal();
269 const QString newSlot = dialog.slot();
270 if (sigslot_con->signal() != newSignal || sigslot_con->slot() != newSlot) {
272 m_form_window->commandHistory()->push(cmd);
283 Q_ASSERT(source !=
nullptr);
284 Q_ASSERT(destination !=
nullptr);
286 ConnectDialog dialog(m_form_window, source, destination, m_form_window->core()->topLevel());
289 if (dialog.exec() == QDialog::Accepted) {
291 con->setSignal(dialog.signal());
292 con->setSlot(dialog.slot());
351 if (connections ==
nullptr)
362 QStringList existingSlots, existingSignals;
363 SignalSlotDialog::existingMethodsFromMemberSheet(m_form_window->core(), parent,
364 existingSlots, existingSignals);
365 QStringList fakeSlots, fakeSignals;
366 SignalSlotDialog::fakeMethodsFromMetaDataBase(m_form_window->core(), parent,
367 fakeSlots, fakeSignals);
369 setBackground(parent);
371 const auto &list = connections->elementConnection();
372 for (
const DomConnection *dom_con : list) {
373 QObject *source = objectByName(parent, dom_con->elementSender());
374 if (source ==
nullptr) {
375 qDebug(
"SignalSlotEditor::fromUi(): no source widget called \"%s\"",
376 dom_con->elementSender().toUtf8().constData());
379 QObject *destination = objectByName(parent, dom_con->elementReceiver());
380 if (destination ==
nullptr) {
381 qDebug(
"SignalSlotEditor::fromUi(): no destination widget called \"%s\"",
382 dom_con->elementReceiver().toUtf8().constData());
386 QPoint sp = QPoint(20, 20), tp = QPoint(20, 20);
387 const DomConnectionHints *dom_hints = dom_con->elementHints();
388 if (dom_hints !=
nullptr) {
389 const auto &hints = dom_hints->elementHint();
390 for (DomConnectionHint *hint : hints) {
391 QString attr_type = hint->attributeType();
392 QPoint p = QPoint(hint->elementX(), hint->elementY());
393 if (attr_type ==
"sourcelabel"_L1)
395 else if (attr_type ==
"destinationlabel"_L1)
400 const QString sourceSignal = dom_con->elementSignal();
401 if (source == parent && !existingSignals.contains(sourceSignal)
402 && !fakeSignals.contains(sourceSignal)) {
403 fakeSignals.append(sourceSignal);
406 const QString destSlot = dom_con->elementSlot();
407 if (destination == parent && !existingSlots.contains(destSlot)
408 && !fakeSlots.contains(destSlot)) {
409 fakeSlots.append(destSlot);
413 SignalSlotConnection *con =
new SignalSlotConnection(
this);
415 con->setEndPoint(EndPoint::Source, source, sp);
416 con->setEndPoint(EndPoint::Target, destination, tp);
417 con->setSignal(sourceSignal);
418 con->setSlot(destSlot);
421 SignalSlotDialog::fakeMethodsToMetaDataBase(m_form_window->core(), parent,
422 fakeSlots, fakeSignals);
460 if (member == con->signal())
463 m_form_window->beginCommand(QApplication::translate(
"Command",
"Change signal"));
464 undoStack()->push(
new SetMemberCommand(con, EndPoint::Source, member,
this));
465 if (!signalMatchesSlot(m_form_window->core(), member, con->slot()))
466 undoStack()->push(
new SetMemberCommand(con, EndPoint::Target, QString(),
this));
467 m_form_window->endCommand();
472 if (member == con->slot())
475 m_form_window->beginCommand(QApplication::translate(
"Command",
"Change slot"));
476 undoStack()->push(
new SetMemberCommand(con, EndPoint::Target, member,
this));
477 if (!signalMatchesSlot(m_form_window->core(), con->signal(), member))
478 undoStack()->push(
new SetMemberCommand(con, EndPoint::Source, QString(),
this));
479 m_form_window->endCommand();
486 if (con->sender() == obj_name)
489 m_form_window->beginCommand(QApplication::translate(
"Command",
"Change sender"));
490 ConnectionEdit::setSource(con, obj_name);
492 QObject *sourceObject = con->object(EndPoint::Source);
494 if (!memberFunctionListContains(m_form_window->core(), sourceObject, SignalMember, con->signal()))
495 undoStack()->push(
new SetMemberCommand(con, EndPoint::Source, QString(),
this));
497 m_form_window->endCommand();
504 if (con->receiver() == obj_name)
507 m_form_window->beginCommand(QApplication::translate(
"Command",
"Change receiver"));
508 ConnectionEdit::setTarget(con, obj_name);
510 QObject *targetObject = con->object(EndPoint::Target);
511 if (!memberFunctionListContains(m_form_window->core(), targetObject, SlotMember, con->slot()))
512 undoStack()->push(
new SetMemberCommand(con, EndPoint::Target, QString(),
this));
514 m_form_window->endCommand();