inline void KNPreferencePanelData::addComboItem(PreferencePanelBlock &block, const QString &title, const QString &path, const QVariant &defaultValue, const QString &explain, const QStringList &candidates, bool allowEdit, bool isAdvanced) { //Generate an item. PreferencePanelOption option; //Update the item data. setItemData(option, title, path, defaultValue, explain, TypeCombo, isAdvanced); //Set the preference. QJsonObject config; config.insert("edit", allowEdit); //Translate the string list to json array. QJsonArray candidateList; for(auto i : candidates) { //Add the item to the candidate json array. candidateList.append(i); } config.insert("candidates", candidateList); option.configure=config; //Add data to item. block.options.append(option); }
QgsAuthCertTrustPolicyComboBox::QgsAuthCertTrustPolicyComboBox( QWidget *parent, QgsAuthCertUtils::CertTrustPolicy policy, QgsAuthCertUtils::CertTrustPolicy defaultpolicy ) : QComboBox( parent ) { QList < QPair<QgsAuthCertUtils::CertTrustPolicy, QString> > policies; policies << qMakePair( QgsAuthCertUtils::DefaultTrust, defaultTrustText( defaultpolicy ) ) << qMakePair( QgsAuthCertUtils::Trusted, QgsAuthCertUtils::getCertTrustName( QgsAuthCertUtils::Trusted ) ) << qMakePair( QgsAuthCertUtils::Untrusted, QgsAuthCertUtils::getCertTrustName( QgsAuthCertUtils::Untrusted ) ); for ( int i = 0; i < policies.size(); i++ ) { QgsAuthCertUtils::CertTrustPolicy polcy = policies.at( i ).first; QString name = policies.at( i ).second; addItem( name, QVariant(( int )polcy ) ); } setItemData(1, QgsAuthCertUtils::greenColor(), Qt::TextColorRole); setItemData(2, QgsAuthCertUtils::redColor(), Qt::TextColorRole); // for styling closed state of combobox // setEditable( true ); // lineEdit()->setReadOnly( true ); connect( this, SIGNAL( currentIndexChanged( int ) ), this, SLOT( highlightCurrentIndex( int ) ) ); setTrustPolicy( policy ); setDefaultTrustPolicy( defaultpolicy ); }
void NumberGenComboBox::append(NumberGenComboBox::GenMethod id, QString text, QString code) { int index = count(); insertItem(index, text); setItemData(index, id, Xt::IdRole); setItemData(index, code.isEmpty() ? text : code, Xt::RawRole); }
void ApplicationComboBoxWidget::changeEvent(QEvent *event) { QComboBox::changeEvent(event); if (event->type() == QEvent::LanguageChange) { setItemData(0, tr("Default Application"), Qt::DisplayRole); setItemData((count() - 1), tr("Other…"), Qt::DisplayRole); } }
void ShaderComboBox::currentChanged(int index) { if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { QString newShader = HordeFileDialog::getResourceFile( H3DResTypes::Shader, m_resourcePath, this, tr("Select shader to import")); if (!newShader.isEmpty()) { int index2 = findText(newShader); if (index2 == -1) { blockSignals(true); removeItem(index); addItem(newShader); addItem(tr("Import from Repository"), QVariant(QVariant::UserType)); blockSignals(false); QHordeSceneEditorSettings settings; setItemData( count() - 1, settings.value( "ImportEntryColor", QColor( 132, 255, 136 ) ), Qt::BackgroundColorRole ); index2 = findText(newShader); } setCurrentIndex(index2); return; } else setCurrentIndex(findText(m_init)); return; } if (m_init != currentText()) { emit shaderChanged(); emit editFinished(); } }
void ListBox::insertString(int index, const TCHAR *str, LPARAM data) { LRESULT lresult = SendMessage(m_hwnd, LB_INSERTSTRING, index, (LPARAM)str); int i = (int)lresult; _ASSERT(i == lresult); setItemData(i, data); }
void ListBox::addString(const TCHAR *str, void *tag) { LRESULT lresult = SendMessage(m_hwnd, LB_ADDSTRING, 0, (LPARAM)str); int i = (int)lresult; _ASSERT(i == lresult); setItemData(i, (LPARAM)tag); }
void ColorDropDown::updateColor(const MapColor* color) { if (!spot_colors_only || color->getSpotColorMethod() == MapColor::SpotColor) { int pos = 0; for (; pos < count(); ++pos) { if (itemData(pos).value<const MapColor*>() == color) break; } if (pos < count()) { int icon_size = style()->pixelMetric(QStyle::PM_SmallIconSize); QPixmap pixmap(icon_size, icon_size); pixmap.fill(*color); setItemText(pos, color->getName()); setItemData(pos, pixmap, Qt::DecorationRole); } else { addColor(color); } } else { removeColor(color); } }
void RecordContentWidget::addField(types::rfield_id fieldId, types::tfield_id fieldTypeId, const QString &fieldData) { auto comboBox = new QComboBox(this->scrollArea_); auto lineEdit = new LineEditConfirm(fieldData, this); // Color for comboBox // auto palette = this->palette(); // palette.setColor(QPalette::Foreground, Qt::gray); // comboBox->setPalette(palette); // comboBox->setMinimumHeight(lineEdit->height()); // Filling combo box int i = 0; for (auto typeFieldId: this->typeFieldsOrder_) { comboBox->addItem(this->typeFieldNames_[typeFieldId]); if (typeFieldId == fieldTypeId) comboBox->setCurrentIndex(i); comboBox->setItemData(i, Qt::AlignRight, Qt::TextAlignmentRole); ++i; } comboBox->setFrame(false); // Connections this->connect(comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this, fieldId](int typeFieldIndex) { this->onFieldTypeChanged(fieldId, typeFieldIndex); }); this->connect(lineEdit, &LineEditConfirm::accepted, [this, fieldId](QString newText) { this->onFieldChanged(fieldId, newText); }); this->fields_[fieldId] = qMakePair(comboBox, lineEdit); this->formLayout_->addRow(comboBox, lineEdit); }
void ListBox::appendString(const TCHAR *str, LPARAM data) { LRESULT lresult = SendMessage(m_hwnd, LB_ADDSTRING, 0, (LPARAM)str); int index = (int)lresult; _ASSERT(index == lresult); setItemData(index, data); }
void ServersComboBox::resetContents(const Host ¤t_host, bool caption, bool connection) { setUpdatesEnabled(false); clear(); int sel = -1; if (caption) { addItem(tr("MPD Servers")); } std::vector<ServerItem> servers; loadPresetServers(&servers); for (int i = 0; i < (int)servers.size(); i++) { int row = count(); QString text = servers[i].name; addItem(text); setItemData(row, text); if (current_host == servers[i].host) { sel = i; } } if (sel < 0 && current_host.isValid()) { QString text = makeServerText(current_host); if (!text.isEmpty()) { sel = count(); addItem(text); } } if (connection) { addItem(trConnect()); } setCurrentIndex(sel); setUpdatesEnabled(true); }
bool BranchSelectionComboBox::populate() // ---------------------------------------------------------------------------- // Read branches from repository, fill the combo box // ---------------------------------------------------------------------------- { clear(); int i = 0; if (repo->branch() == "") { addItem(tr("<No branch>"), CIK_None); i++; } QStringList branches = repo->branches(); foreach (QString branch, branches) { bool match = (filter == BSF_AllBranches); if (!match) { bool remote = repo->isRemoteBranch(+branch); if (remote) match = (filter & BSF_RemoteBranches); else match = (filter & BSF_LocalBranches); if (!match) continue; } addItem(branch); setItemData(i++, CIK_Name); }
void IntPropChioce::init( int numSet , int const valueSet[] , char const* strSet[] ) { for( int i = 0 ; i < numSet ; ++i ) { unsigned pos = appendItem( strSet[i] ); setItemData( pos , (void*)valueSet[i] ); } }
/** * Adds the string to the listbox */ void CListBox::addString(const wchar_t* _text) { int idx = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM)_text); if(drawer) { setItemData(idx, (void*)_text); } }
bool CommitSelectionComboBox::populate() // ---------------------------------------------------------------------------- // Read branches from repository, fill the combo box // ---------------------------------------------------------------------------- { if (!repo || branch.isEmpty()) return false; int i = 0; clear(); prevSelected = -1; if (mode & CSM_HeadEntry) { Repository::Commit head = Repository::HeadCommit; addItem(head.toString()); setItemData(i++, QVariant::fromValue(head)); } QList<Repository::Commit> commits = repo->history(branch); // Commit list is in chronological order, we want latest first for (int n = commits.size() - 1; n >= 0; n--) { Repository::Commit commit = commits[n]; QString txt; if (mode & CSM_CommitId) { txt += commit.id; } if (mode & CSM_CommitMsg) { if (!txt.isEmpty()) txt += " "; txt += commit.msg; } if (!txt.isEmpty()) { addItem(txt); setItemData(i++, QVariant::fromValue(commit)); } } on_activated(currentIndex()); return true; }
void QxtCheckComboBox::toggleCheckState(int index) { QVariant value = itemData(index, Qt::CheckStateRole); if (value.isValid()) { Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt()); setItemData(index, (state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole); } }
void ColorListEditor::populateList() { QStringList colorNames = QColor::colorNames(); for (int i = 0; i < colorNames.size(); ++i) { QColor color(colorNames[i]); insertItem(i, colorNames[i]); setItemData(i, color, Qt::DecorationRole); } }
void WSimpleManufacturerItem::manufacturerUpdated() { QSqlQuery q = HACC_DB->query("select name, icon_id from manufacturers where id=?", QVariantList() << itemID()); if(HACC_QUERY_DATA_AVIALABLE(q)) { //! \todo Добавить действие, если запрос не вернет данных setItemData(HACC_DB_2_DBID(q, 1), HACC_DB_2_STRG(q, 0)); } }
void ColorCombo::setColor(QColor color) { m_init = color; setCurrentIndex(findData(color, int(Qt::DecorationRole))); if (currentIndex() == -1) { addItem(color.name()); setItemData(count()-1, color, Qt::DecorationRole); setCurrentIndex(count()-1); } }
void ShaderComboBox::addShader(const QString dir) { QDir base(m_resourcePath); QList<QFileInfo> shaders = QDir(dir).entryInfoList(QStringList("*.shader"), QDir::Files | QDir::Readable); foreach(QFileInfo shader, shaders) { QString text(base.relativeFilePath(shader.absoluteFilePath())); addItem(text); #ifdef Q_WS_WIN setItemData(count()-1, text, Qt::ToolTipRole); #endif }
void AbstractItemEditor::resetProperty(QtProperty *property) { if (m_propertyManager->resetFontSubProperty(property)) return; if (m_propertyManager->resetIconSubProperty(property)) return; BoolBlocker block(m_updatingBrowser); QtVariantProperty *prop = m_propertyManager->variantProperty(property); int role = m_propertyToRole.value(prop); if (role == ItemFlagsShadowRole) prop->setValue(qVariantFromValue((int)QListWidgetItem().flags())); else prop->setValue(QVariant(prop->valueType(), (void *)0)); prop->setModified(false); setItemData(role, QVariant()); if (role == Qt::DecorationPropertyRole) setItemData(Qt::DecorationRole, qVariantFromValue(QIcon())); if (role == Qt::DisplayPropertyRole) setItemData(Qt::EditRole, qVariantFromValue(QString())); if (role == Qt::ToolTipPropertyRole) setItemData(Qt::ToolTipRole, qVariantFromValue(QString())); if (role == Qt::StatusTipPropertyRole) setItemData(Qt::StatusTipRole, qVariantFromValue(QString())); if (role == Qt::WhatsThisPropertyRole) setItemData(Qt::WhatsThisRole, qVariantFromValue(QString())); }
ColorCombo::ColorCombo(QWidget* parent /*= 0*/) : QComboBox(parent) { QStringList colorNames = QColor::colorNames(); for (int i = 0; i < colorNames.size(); ++i) { QColor color(colorNames[i]); insertItem(i, colorNames[i]); setItemData(i, color, Qt::DecorationRole); } addItem(tr("Custom"), QVariant((int)QVariant::UserType)); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(currentChanged(int))); }
void KonqCombo::updateItem( const QPixmap& pix, const QString& t, int index, const QString& title ) { // No need to flicker if (itemText( index ) == t && (!itemIcon(index).isNull() && itemIcon(index).pixmap(iconSize()).serialNumber() == pix.serialNumber())) return; // kDebug() << "item=" << t << "index=" << index; setItemText( index, t ); setItemIcon( index, pix ); setItemData( index, title ); update(); }
void WSimpleEnumeratedThingTypeItem::enumeratedThingTypeUpdated() { QSqlQuery q = HACC_DB->query("select " "thing_enumerated_types.precision, " "thing_enumerated_types.name " "from thing_enumerated_types " "where thing_enumerated_types.id=?", QVariantList() << itemID()); if(HACC_QUERY_DATA_AVIALABLE(q)) { //! \todo Добавить действие, если запрос не вернет данных setItemData(HACC_DB_2_STRG(q, 1), HACC_DB_2_PREC(q, 0)); } }
inline void KNPreferencePanelData::addItem(PreferencePanelBlock &block, const QString &title, const QString &path, const QVariant &defaultValue, PreferencePanelOptionType type, const QString &explain, bool isAdvanced) { //Generate an item. PreferencePanelOption option; //Update the item data. setItemData(option, title, path, defaultValue, explain, type, isAdvanced); //No preference will be added. //Add data to item. block.options.append(option); }
void ColorDropDown::addColor(const MapColor* color) { if (!spot_colors_only || color->getSpotColorMethod() == MapColor::SpotColor) { int pos = 0; for (; pos < count(); ++pos) { const MapColor* c = itemData(pos).value<const MapColor*>(); if (c && c->getPriority() > color->getPriority()) break; } int icon_size = style()->pixelMetric(QStyle::PM_SmallIconSize); QPixmap pixmap(icon_size, icon_size); pixmap.fill(*color); insertItem(pos, color->getName(), QVariant::fromValue(color)); setItemData(pos, pixmap, Qt::DecorationRole); } }
void AbstractItemEditor::propertyChanged(QtProperty *property) { if (m_updatingBrowser) return; BoolBlocker block(m_updatingBrowser); QtVariantProperty *prop = m_propertyManager->variantProperty(property); int role; if ((role = m_propertyToRole.value(prop, -1)) == -1) // Subproperty return; if ((role == ItemFlagsShadowRole && prop->value().toInt() == (int)QListWidgetItem().flags()) || (role == Qt::DecorationPropertyRole && !qVariantValue<PropertySheetIconValue>(prop->value()).mask()) || (role == Qt::FontRole && !qVariantValue<QFont>(prop->value()).resolve())) { prop->setModified(false); setItemData(role, QVariant()); } else { prop->setModified(true); setItemData(role, prop->value()); } switch (role) { case Qt::DecorationPropertyRole: setItemData(Qt::DecorationRole, qVariantFromValue(iconCache()->icon(qVariantValue<PropertySheetIconValue>(prop->value())))); break; case Qt::DisplayPropertyRole: setItemData(Qt::EditRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::ToolTipPropertyRole: setItemData(Qt::ToolTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::StatusTipPropertyRole: setItemData(Qt::StatusTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::WhatsThisPropertyRole: setItemData(Qt::WhatsThisRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; default: break; } prop->setValue(getItemData(role)); }
void ColorCombo::currentChanged(int index) { if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { QColor color = QColorDialog::getColor(m_init, this); if (color.isValid()) { if (findData(color, int(Qt::DecorationRole)) == -1) { addItem(color.name()); setItemData(count()-1, color, Qt::DecorationRole); } setCurrentIndex(findData(color, int(Qt::DecorationRole))); } else { setCurrentIndex(findData(m_init)); } } }
inline void KNPreferencePanelData::addIntItem(PreferencePanelBlock &block, const QString &title, const QString &path, const QVariant &defaultValue, const QString &explain, int min, int max, bool isAdvanced) { //Generate an item. PreferencePanelOption option; //Update the item data. setItemData(option, title, path, defaultValue, explain, TypeInt, isAdvanced); //Set the preference. QJsonObject config; config.insert("min", min); config.insert("max", max); option.configure=config; //Add data to item. block.options.append(option); }
inline void KNPreferencePanelData::addFontItem(PreferencePanelBlock &block, const QString &title, const QString &path, const QVariant &defaultValue, const QString &explain, bool showSize, bool showAttribute, bool isAdvanced) { //Generate an item. PreferencePanelOption option; //Update the item data. setItemData(option, title, path, defaultValue, explain, TypeFont, isAdvanced); //Set the preference. QJsonObject config; config.insert("size", showSize); config.insert("attribute", showAttribute); option.configure=config; //Add data to item. block.options.append(option); }