本文整理汇总了C++中QAbstractItemModel::match方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::match方法的具体用法?C++ QAbstractItemModel::match怎么用?C++ QAbstractItemModel::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCurrentShapeType
void ShapeSelector::setCurrentShapeType( int type )
{
QAbstractItemModel *model = shapeType->model();
QModelIndexList indexes = model->match ( model->index(0,1), Qt::DisplayRole, type );
QModelIndex index = indexes.value(0);
shapeType->setCurrentIndex( index.row() );
}
示例2: setItemIconId
void TreeItemEditDialog::setItemIconId(QString iconId){
QAbstractItemModel * iconsModel = _iconCombo->model();
QModelIndex startIndex = iconsModel->index(0, 0);
QString toFind = iconId.isEmpty() ? _defaultIconId : iconId;
QModelIndexList res = iconsModel->match(startIndex, Qt::EditRole, toFind);
if(!res.isEmpty()){
_iconCombo->setCurrentIndex(res.first().row());
}
}
示例3: resetColor
void AutocompletingComboBox::resetColor(void) {
QAbstractItemModel* m = completer()->model();
if (QPalette::Base, (m->match(m->index(0, 0), Qt::DisplayRole, currentText(), 1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap) ).isEmpty())) {
QPalette pal = palette();
pal.setColor(QPalette::Base, QColor(233,150,122));
setPalette(pal);
}
else
setPalette(QApplication::palette(this));
}
示例4: on_tbReload_clicked
void pTranslationDialog::on_tbReload_clicked()
{
// reload translations if needed
if ( mTranslationManager && mTranslationManager->availableLocales().isEmpty() ) {
mTranslationManager->reloadTranslations();
}
// keep current locale
const QString currentLocale = selectedLocale();
// clear items
ui->twLocales->clear();
mRootItems.clear();
// create new ones
if ( mTranslationManager ) {
foreach ( const QLocale& _locale, mTranslationManager->availableQLocales() ) {
const QLocale locale = _locale.language() == QLocale::C ? QLocale( QLocale::English ) : _locale;
QTreeWidgetItem* rootItem = this->rootItem( QLocale( locale.language() ) );
if ( rootItem->data( 0, Qt::UserRole ).toString() == locale.name() ) {
continue;
}
rootItem->addChild( newItem( locale ) );
}
}
// sort items
ui->twLocales->sortByColumn( 0, Qt::AscendingOrder );
// restore locale
QAbstractItemModel* model = ui->twLocales->model();
QModelIndex index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchFixedString | Qt::MatchWrap ).value( 0 );
if ( !index.isValid() ) {
index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchStartsWith | Qt::MatchWrap ).value( 0 );
}
ui->twLocales->setCurrentIndex( index );
}
示例5: on_lineEdit_textChanged
void MainWindow::on_lineEdit_textChanged(const QString &arg1)
{
QAbstractItemModel *model = ui->tableView->model();
QList<QModelIndex> list = model->match(model->index(0,0), Qt::DisplayRole, arg1, -1, Qt::MatchContains | Qt::MatchRecursive );
if (!list.empty())
{
ui->tableView->setCurrentIndex(list.at(0));
}
}
示例6: refreshSettings
void PreferencesLanguage::refreshSettings()
{
ui->languageSystemDefault->setChecked(prefs.locale.use_system_language);
ui->timeFormatSystemDefault->setChecked(!prefs.time_format_override);
ui->dateFormatSystemDefault->setChecked(!prefs.date_format_override);
ui->timeFormatEntry->setText(prefs.time_format);
ui->dateFormatEntry->setText(prefs.date_format);
ui->shortDateFormatEntry->setText(prefs.date_format_short);
QAbstractItemModel *m = ui->languageDropdown->model();
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, QString(prefs.locale.lang_locale).replace("-", "_"));
if (languages.count())
ui->languageDropdown->setCurrentIndex(languages.first().row());
}
示例7: logSourceChange
void MainWindow::logSourceChange( QWidget* pWidget )
{
QCheckBox* checkbox = qobject_cast<QCheckBox*>( pWidget );
QAbstractItemModel* model = mUI.logListWidget->model();
QModelIndexList list = model->match( model->index( 0, 0 ), Qt::UserRole + 1,
checkbox->text(), -1 );
for( QModelIndexList::iterator i = list.begin();i != list.end(); ++i )
{
model->setData( *i, checkbox->isChecked(), Qt::UserRole + 3 );
MainWindow::checkLogItem( *i );
}
if( !list.empty() ) mUI.logListWidget->scrollToBottom();
}
示例8: expandAllGroups
void PropertyBrowser::expandAllGroups()
{
QAbstractItemModel * model = this->model();
QModelIndexList indexes = model->match(model->index(0,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive);
for (QModelIndex index : indexes)
{
if (!index.isValid())
continue;
AbstractProperty * property = retrieveProperty(index);
if (property->isGroup() && model->hasChildren(index))
expand(index);
}
}
示例9: buttonAssign
void GameControllerMappingDialog::buttonAssign(int buttonindex)
{
if (ui->buttonMappingTableWidget->currentRow() > -1 && buttonGrabs == 0)
{
QTableWidgetItem* item = ui->buttonMappingTableWidget->currentItem();
int column = ui->buttonMappingTableWidget->currentColumn();
int row = ui->buttonMappingTableWidget->currentRow();
if (row < 17)
{
if (!item)
{
item = new QTableWidgetItem(QString("Button %1").arg(buttonindex+1));
ui->buttonMappingTableWidget->setItem(row, column, item);
}
QList<QVariant> templist;
templist.append(QVariant(0));
templist.append(QVariant(buttonindex));
QAbstractItemModel *model = ui->buttonMappingTableWidget->model();
QModelIndexList matchlist = model->match(model->index(0,0), Qt::UserRole, templist, 1, Qt::MatchExactly);
foreach (const QModelIndex &index, matchlist) {
QTableWidgetItem *existingItem = ui->buttonMappingTableWidget->item(index.row(), index.column());
if (existingItem)
{
existingItem->setText("");
existingItem->setData(Qt::UserRole, QVariant());
}
}
QList<QVariant> tempvalue;
tempvalue.append(QVariant(0));
tempvalue.append(QVariant(buttonindex));
item->setData(Qt::UserRole, tempvalue);
item->setText(QString("Button %1").arg(buttonindex+1));
if (row < ui->buttonMappingTableWidget->rowCount()-1)
{
ui->buttonMappingTableWidget->setCurrentCell(row+1, column);
}
ui->mappingStringPlainTextEdit->document()->setPlainText(generateSDLMappingString());
}
示例10: selectItem
bool ThemeManager::selectItem(const QString& id, bool is_default)
{
QListWidget* view = m_themes;
QListWidget* other_view = m_default_themes;
if (is_default) {
std::swap(view, other_view);
}
QAbstractItemModel* model = view->model();
QModelIndexList items = model->match(model->index(0, 0, QModelIndex()),
Qt::UserRole, id, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive);
if (!items.isEmpty()) {
view->setCurrentRow(items.first().row());
other_view->setCurrentIndex(other_view->rootIndex());
m_tabs->setCurrentIndex(!is_default);
return true;
} else {
return false;
}
}
示例11: widgetSelected
void WidgetInspector::widgetSelected(QWidget *widget)
{
QAbstractItemModel *model = ui->widgetTreeView->model();
const QModelIndexList indexList =
model->match(model->index(0, 0),
ObjectModel::ObjectRole,
QVariant::fromValue<QObject*>(widget), 1,
Qt::MatchExactly | Qt::MatchRecursive);
if (indexList.isEmpty()) {
return;
}
const QModelIndex index = indexList.first();
ui->widgetTreeView->selectionModel()->select(
index,
QItemSelectionModel::Select | QItemSelectionModel::Clear |
QItemSelectionModel::Rows | QItemSelectionModel::Current);
ui->widgetTreeView->scrollTo(index);
widgetSelected(index);
}
示例12: mapToGlobal
int
KexiRelationsTableFieldList::globalY(const QString &item)
{
QAbstractItemModel *themodel = model();
QModelIndex idx;
for (int i = 0; i < themodel->rowCount(); ++i) {
idx = themodel->index(i, 0);
QVariant data = themodel->data(idx);
if (data.toString() == item) {
break;
}
}
if (idx.isValid()) {
QRect r = this->rectForIndex(idx);
int y = r.y() + r.height()/2;
//Not sure what this line is supposed to do...is it to check if the item is visible?
if (visualRect(idx).y() > viewport()->height()) {
y = 0;
} else if (y == 0) {
y = height();
}
return mapToGlobal(QPoint(0, y)).y();
}
return -1;
#if 0
QModelIndexList list = themodel->match()
Q3ListViewItem *i = findItem(item, 0);
if (!i)
return -1;
int y = itemRect(i).y() + (itemRect(i).height() / 2);
if (contentsY() > itemPos(i))
y = 0;
else if (y == 0)
y = height();
return mapToGlobal(QPoint(0, y)).y();
#endif
}
示例13: updateApplyEnabledState
void
SelectLocalesDialog::showLocaleComboBox( const QModelIndex& index )
{
if ( index.isValid() )
{
/* Select locale with UTF-8 encoding by default */
QAbstractItemModel* model = ui->localeComboBox->model();
QModelIndexList localeIndexList = model->match( model->index( 0,0 ),
SupportedLocalesModel::ValueRole,
"UTF-8",
-1,
Qt::MatchContains );
if ( localeIndexList.size() > 0 )
{
QModelIndex modelIndex = localeIndexList.first();
ui->localeComboBox->setCurrentIndex( modelIndex.row() );
}
ui->localeComboBox->show();
updateApplyEnabledState();
}
}
示例14: syncSettings
void PreferencesLanguage::syncSettings()
{
bool useSystemLang = prefs.locale.use_system_language;
QString currentText = ui->languageDropdown->currentText();
if (useSystemLang != ui->languageSystemDefault->isChecked() ||
(!useSystemLang && currentText != prefs.locale.language)) {
QMessageBox::warning(this, tr("Restart required"),
tr("To correctly load a new language you must restart Subsurface."));
}
QAbstractItemModel *m = ui->languageDropdown->model();
QModelIndexList languages = m->match(m->index(0, 0), Qt::DisplayRole, currentText);
QString currentLocale;
if (languages.count())
currentLocale = m->data(languages.first(),Qt::UserRole).toString();
auto lang = SettingsObjectWrapper::instance()->language_settings;
lang->setLanguage(currentText);
lang->setLangLocale(currentLocale);
lang->setUseSystemLanguage(ui->languageSystemDefault->isChecked());
lang->setTimeFormatOverride(!ui->timeFormatSystemDefault->isChecked());
lang->setDateFormatOverride(!ui->dateFormatSystemDefault->isChecked());
lang->setTimeFormat(ui->timeFormatEntry->text());
lang->setDateFormat(ui->dateFormatEntry->text());
lang->setDateFormatShort(ui->shortDateFormatEntry->text());
uiLanguage(NULL);
QRegExp tfillegalchars("[^hHmszaApPt\\s:;\\.,]");
if (tfillegalchars.indexIn(ui->timeFormatEntry->text()) >= 0)
QMessageBox::warning(this, tr("Literal characters"),
tr("Non-special character(s) in time format.\nThese will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString"));
QRegExp dfillegalchars("[^dMy/\\s:;\\.,]");
if (dfillegalchars.indexIn(ui->dateFormatEntry->text()) >= 0 ||
dfillegalchars.indexIn(ui->shortDateFormatEntry->text()) >= 0)
QMessageBox::warning(this, tr("Literal characters"),
tr("Non-special character(s) in time format.\nThese will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString"));
}
示例15: setUiFromPrefs
void PreferencesDialog::setUiFromPrefs()
{
// graphs
ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
ui.maxppo2->setValue(prefs.mod_ppO2);
ui.red_ceiling->setChecked(prefs.profile_red_ceiling);
ui.units_group->setEnabled(ui.personalize->isChecked());
ui.gflow->setValue(prefs.gflow);
ui.gfhigh->setValue(prefs.gfhigh);
ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
// units
if (prefs.unit_system == METRIC)
ui.metric->setChecked(true);
else if (prefs.unit_system == IMPERIAL)
ui.imperial->setChecked(true);
else
ui.personalize->setChecked(true);
ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS);
ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
ui.meter->setChecked(prefs.units.length == units::METERS);
ui.feet->setChecked(prefs.units.length == units::FEET);
ui.bar->setChecked(prefs.units.pressure == units::BAR);
ui.psi->setChecked(prefs.units.pressure == units::PSI);
ui.liter->setChecked(prefs.units.volume == units::LITER);
ui.cuft->setChecked(prefs.units.volume == units::CUFT);
ui.kg->setChecked(prefs.units.weight == units::KG);
ui.lbs->setChecked(prefs.units.weight == units::LBS);
ui.font->setCurrentFont(QString(prefs.divelist_font));
ui.fontsize->setValue(prefs.font_size);
ui.defaultfilename->setText(prefs.default_filename);
ui.default_cylinder->clear();
for (int i = 0; tank_info[i].name != NULL; i++) {
ui.default_cylinder->addItem(tank_info[i].name);
if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0)
ui.default_cylinder->setCurrentIndex(i);
}
ui.displayinvalid->setChecked(prefs.display_invalid_dives);
ui.display_unused_tanks->setChecked(prefs.display_unused_tanks);
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
filterModel->setSourceModel(LanguageModel::instance());
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui.languageView->setModel(filterModel);
filterModel->sort(0);
connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString)));
QSettings s;
s.beginGroup("Language");
ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
QAbstractItemModel *m = ui.languageView->model();
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
if (languages.count())
ui.languageView->setCurrentIndex(languages.first());
}