void NodeComboBox::Update(const QString &indexAtText) { this->disconnect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SlotSelectionChanged(QString)) ); this->clear(); this->addItem(NONE_VALUE); int i=0; for(i=0; i < m_Values->size(); ++i) { this->addItem(m_Values->at(i)); } for(i=0; i < m_DefaultValues.size(); ++i) { this->addItem(m_DefaultValues.at(i)); } this->SetCurrentIndex(indexAtText); this->connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SlotSelectionChanged(QString)) ); if(this->IsSelectedEntryNode(this->currentText())) m_LastSelectedNode = this->currentText(); }
void NodeComboBox::SetCurrentIndex(const QString& text) { this->disconnect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SlotSelectionChanged(QString)) ); int textIDX = this->findText(text); if(textIDX != -1) this->setCurrentIndex(textIDX); else this->setCurrentIndex(0); this->connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SlotSelectionChanged(QString)) ); }
NodeComboBox::NodeComboBox(const QString& description, QList<QString>* values, QWidget *parent) : QComboBox(parent) ,m_StringCreate("Create new ") ,m_StringRename("Rename current ") ,m_StringDelete("Delete current ") ,m_StringSeparator("_________________________ ") { m_Description = description; m_Values = values; m_DefaultValues.append(m_StringSeparator); m_StringRename = m_StringRename + m_Description + " "; m_DefaultValues.append(m_StringRename); m_StringCreate = m_StringCreate + m_Description + " "; m_DefaultValues.append(m_StringCreate); m_StringDelete = m_StringDelete + m_Description + " "; m_DefaultValues.append(m_StringDelete); this->connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SlotSelectionChanged(QString)) ); this->Update(); }
ezQtShortcutEditorDlg::ezQtShortcutEditorDlg(QWidget* parent) : QDialog(parent) { setupUi(this); EZ_VERIFY(connect(Shortcuts, SIGNAL(itemSelectionChanged()), this, SLOT(SlotSelectionChanged())) != nullptr, "signal/slot connection failed"); m_iSelectedAction = -1; KeyEditor->setEnabled(false); ezMap<ezString, ezMap<ezString, ezInt32>> SortedItems; { auto itActions = ezActionManager::GetActionIterator(); while (itActions.IsValid()) { if (itActions.Value()->m_Type == ezActionType::Action) { SortedItems[itActions.Value()->m_sCategoryPath][itActions.Value()->m_sActionName] = m_ActionDescs.GetCount(); m_ActionDescs.PushBack(itActions.Value()); } itActions.Next(); } } { ezQtScopedBlockSignals bs(Shortcuts); ezQtScopedUpdatesDisabled ud(Shortcuts); Shortcuts->setAlternatingRowColors(true); Shortcuts->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers); Shortcuts->setExpandsOnDoubleClick(true); ezStringBuilder sTemp; for (auto it = SortedItems.GetIterator(); it.IsValid(); ++it) { auto pParent = new QTreeWidgetItem(); pParent->setData(0, Qt::DisplayRole, it.Key().GetData()); Shortcuts->addTopLevelItem(pParent); pParent->setExpanded(true); pParent->setFirstColumnSpanned(true); pParent->setFlags(Qt::ItemFlag::ItemIsEnabled); QFont font = pParent->font(0); font.setBold(true); pParent->setFont(0, font); for (auto it2 : it.Value()) { const auto& item = m_ActionDescs[it2.Value()]; auto pItem = new QTreeWidgetItem(pParent); /// \todo Instead of removing &, replace it by underlined text (requires formatted text output) sTemp = ezTranslate(item->m_sActionName); sTemp.ReplaceAll("&", ""); pItem->setData(0, Qt::UserRole, it2.Value()); pItem->setData(0, Qt::DisplayRole, item->m_sActionName.GetData()); pItem->setData(1, Qt::DisplayRole, sTemp.GetData()); pItem->setData(2, Qt::DisplayRole, item->m_sShortcut.GetData()); pItem->setData(3, Qt::DisplayRole, ezTranslateTooltip(item->m_sActionName)); if (item->m_sShortcut == item->m_sDefaultShortcut) pItem->setBackground(2, QBrush()); else pItem->setBackgroundColor(2, Qt::darkYellow); sTemp.Set("Default: ", item->m_sDefaultShortcut.IsEmpty() ? "<none>" : item->m_sDefaultShortcut); pItem->setToolTip(2, QString::fromUtf8(sTemp.GetData())); } } Shortcuts->resizeColumnToContents(0); Shortcuts->resizeColumnToContents(2); } ButtonAssign->setEnabled(false); ButtonRemove->setEnabled(false); ButtonReset->setEnabled(false); }