void ConnectDialog::selectSignal(QListWidgetItem *item) { if (item) { m_ui.signalList->setCurrentItem(item); populateSlotList(item->text()); m_ui.slotList->setEnabled(true); setOkButtonEnabled(!m_ui.slotList->selectedItems().isEmpty()); } else { m_ui.signalList->clearSelection(); populateSlotList(); m_ui.slotList->setEnabled(false); setOkButtonEnabled(false); } }
void ConnectDialog::populateSignalList() { enum { deprecatedSignal = 0 }; QString selectedName; if (const QListWidgetItem *item = m_ui.signalList->currentItem()) selectedName = item->text(); m_ui.signalList->clear(); QMap<QString, QString> memberToClassName = getSignals(m_formWindow->core(), m_source, showAllSignalsSlots()); QFont font = QApplication::font(); font.setItalic(true); QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap<QString, QString>::ConstIterator itMember = memberToClassName.constBegin(); const QMap<QString, QString>::ConstIterator itMemberEnd = memberToClassName.constEnd(); while (itMember != itMemberEnd) { const QString member = itMember.key(); QListWidgetItem *item = new QListWidgetItem(m_ui.signalList); item->setText(member); if (!selectedName.isEmpty() && member == selectedName) curr = item; // Mark deprecated signals red. Not currently in use (historically for Qt 3 slots in Qt 4), // but may be used again in the future. if (deprecatedSignal) { item->setData(Qt::FontRole, variantFont); item->setData(Qt::ForegroundRole, QColor(Qt::red)); } ++itMember; } if (curr) { m_ui.signalList->setCurrentItem(curr); } else { selectedName.clear(); } populateSlotList(selectedName); if (!curr) m_ui.slotList->setEnabled(false); }
void ConnectDialog::populateSignalList() { QString selectedName; if (const QListWidgetItem *item = m_ui.signalList->currentItem()) selectedName = item->text(); m_ui.signalList->clear(); QMap<QString, QString> memberToClassName = getSignals(m_formWindow->core(), m_source, showAllSignalsSlots()); QFont font = QApplication::font(); font.setItalic(true); QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap<QString, QString>::ConstIterator itMember = memberToClassName.constBegin(); const QMap<QString, QString>::ConstIterator itMemberEnd = memberToClassName.constEnd(); while (itMember != itMemberEnd) { const QString member = itMember.key(); const bool qt3Signal = isQt3Signal(m_formWindow->core(), m_source, member); QListWidgetItem *item = new QListWidgetItem(m_ui.signalList); item->setText(member); if (!selectedName.isEmpty() && member == selectedName) curr = item; if (qt3Signal) { item->setData(Qt::FontRole, variantFont); item->setData(Qt::ForegroundRole, Qt::red); } ++itMember; } if (curr) { m_ui.signalList->setCurrentItem(curr); } else { selectedName.clear(); } populateSlotList(selectedName); if (!curr) m_ui.slotList->setEnabled(false); }