void VegetationWidget::getSelectedTypes(std::vector<std::string>& returnTypeList) { returnTypeList.clear(); QWidget* curWidget = _tabWidget->currentWidget(); if (curWidget == _treeListView) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_treeListView->model()); for (int j = 0; j < model->rowCount(); ++j) { QStandardItem* item = model->item(j); if (item->checkState() == Qt::Checked) { returnTypeList.push_back(chineseTextToUTF8String(item->text())); } } } else { QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_grassListView->model()); for (int j = 0; j < model->rowCount(); ++j) { QStandardItem* item = model->item(j); if (item->checkState() == Qt::Checked) { returnTypeList.push_back(chineseTextToUTF8String(item->text())); } } } }
void tst_QStandardItem::clone() { QStandardItem item; item.setText(QLatin1String("text")); item.setToolTip(QLatin1String("toolTip")); item.setStatusTip(QLatin1String("statusTip")); item.setWhatsThis(QLatin1String("whatsThis")); item.setSizeHint(QSize(64, 48)); item.setFont(QFont()); item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter); item.setBackground(QColor(Qt::blue)); item.setForeground(QColor(Qt::green)); item.setCheckState(Qt::PartiallyChecked); item.setAccessibleText(QLatin1String("accessibleText")); item.setAccessibleDescription(QLatin1String("accessibleDescription")); item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); QStandardItem *clone = item.clone(); QCOMPARE(clone->text(), item.text()); QCOMPARE(clone->toolTip(), item.toolTip()); QCOMPARE(clone->statusTip(), item.statusTip()); QCOMPARE(clone->whatsThis(), item.whatsThis()); QCOMPARE(clone->sizeHint(), item.sizeHint()); QCOMPARE(clone->font(), item.font()); QCOMPARE(clone->textAlignment(), item.textAlignment()); QCOMPARE(clone->background(), item.background()); QCOMPARE(clone->foreground(), item.foreground()); QCOMPARE(clone->checkState(), item.checkState()); QCOMPARE(clone->accessibleText(), item.accessibleText()); QCOMPARE(clone->accessibleDescription(), item.accessibleDescription()); QCOMPARE(clone->flags(), item.flags()); QVERIFY(!(*clone < item)); delete clone; }
void FilterLvl::onClicked (QModelIndex idx) { if (!idx.isValid()) return; QStandardItem * item = m_model->itemFromIndex(idx); Q_ASSERT(item); if (idx.column() == 1) { QString const & filter_item = m_model->data(m_model->index(idx.row(), 0, QModelIndex()), Qt::DisplayRole).toString(); QString const & mod = m_model->data(idx, Qt::DisplayRole).toString(); E_LevelMode const curr = stringToLvlMod(mod.toStdString().c_str()[0]); size_t const i = (curr + 1) % e_max_lvlmod_enum_value; E_LevelMode const new_mode = static_cast<E_LevelMode>(i); m_model->setData(idx, QString(lvlModToString(new_mode))); bool const checked = (item->checkState() == Qt::Checked); setMode(filter_item, !checked, new_mode); emitFilterChangedSignal(); } else { QString const & filter_item = m_model->data(idx, Qt::DisplayRole).toString(); bool const orig_checked = (item->checkState() == Qt::Checked); if (orig_checked) append(filter_item); else remove(filter_item); emitFilterChangedSignal(); } }
void PreferencesDialog::saveWaveInfo() { // Change focus to force save of any open editors.. ui->waveSearch->setFocus(); int toprows = waveModel->rowCount(); bool ok; for (int i=0; i < toprows; i++) { QStandardItem * topitem = waveModel->item(i,0); if (!topitem) continue; int rows = topitem->rowCount(); for (int j=0; j< rows; ++j) { QStandardItem * item = topitem->child(j, 0); if (!item) continue; ChannelID id = item->data(Qt::UserRole).toUInt(&ok); schema::Channel & chan = schema::channel[id]; if (chan.isNull()) continue; chan.setEnabled(item->checkState() == Qt::Checked ? true : false); chan.setFullname(item->text()); chan.setDefaultColor(QColor(topitem->child(j,1)->data(Qt::UserRole).toUInt())); chan.setShowInOverview(topitem->child(j,2)->checkState() == Qt::Checked); chan.setLowerThreshold(topitem->child(j,3)->text().toDouble()); chan.setUpperThreshold(topitem->child(j,4)->text().toDouble()); chan.setLabel(topitem->child(j,5)->text()); chan.setDescription(topitem->child(j,6)->text()); } } }
bool FilterModel::setData(const QModelIndex & index, const QVariant& value, int role) { bool res = QStandardItemModel::setData(index, value, role); if (role == Qt::CheckStateRole) { if (!index.parent().isValid()) { QStandardItem * item = itemFromIndex(index); Qt::CheckState st = item->checkState(); if (st != Qt::PartiallyChecked) { for (int i = 0; i < item->rowCount(); i++) { item->child(i)->setCheckState(st); } } } emit filterChanged(); } return res; }
void PluginChoooserWidget::onItemClicked(QModelIndex index) { QStandardItem *item = m_model->itemFromIndex(index); if (item) { item->setCheckState(item->checkState() == Qt::Unchecked ? Qt::Checked : Qt::Unchecked); } }
void CSatelliteDlg::on_pushButton_5_clicked() { QStandardItemModel *model = (QStandardItemModel *)ui->listView->model(); for (int i = 0; i < model->rowCount(); i++) { QStandardItem *item = model->item(i); sgp4.tleItem(i)->used = item->checkState() == Qt::Checked ? true : false; } if (sgp4.count() != 0) { if (msgBoxQuest(this, m_cSaveQuest) == QMessageBox::Yes) { if (!save(curSatelliteCatName)) { return; } } } deleteTracking(MO_SATELLITE); releaseHoldObject(MO_SATELLITE); pcMainWnd->removeQuickInfo(MO_SATELLITE); curSatelliteCatName.clear(); sgp4.removeAll(); fillList(); }
void Hdd::configAccepted() { KConfigGroup cg = config(); KConfigGroup cgGlobal = globalConfig(); QStandardItem *parentItem = m_hddModel.invisibleRootItem(); clear(); for (int i = 0; i < parentItem->rowCount(); ++i) { QStandardItem *item = parentItem->child(i, 0); if (item) { QStandardItem *child = parentItem->child(i, 1); if (child->text() != child->data().toString()) { cgGlobal.writeEntry(item->data().toString(), child->text()); } if (item->checkState() == Qt::Checked) { appendSource(item->data().toString()); } } } cg.writeEntry("uuids", sources()); uint interval = ui.intervalSpinBox->value(); cg.writeEntry("interval", interval); emit configNeedsSaving(); }
void NotifyOptionsWidget::apply() { Options::node(OPV_NOTIFICATIONS_POPUPTIMEOUT).setValue(ui.spbPopupTimeout->value()); for(QMap<QString, QStandardItem *>::const_iterator it=FTypeItems.constBegin(); it!=FTypeItems.constEnd(); ++it) { QStandardItem *typeNameItem = it.value(); ushort kinds = !it.key().isEmpty() ? FNotifications->typeNotificationKinds(it.key()) : 0; for (int row=0; row<typeNameItem->rowCount(); row++) { QStandardItem *kindEnableItem = typeNameItem->child(row, COL_ENABLE); if (kindEnableItem->checkState() == Qt::Checked) kinds |= (ushort)kindEnableItem->data(MDR_KIND).toInt(); else kinds &= ~((ushort)kindEnableItem->data(MDR_KIND).toInt()); } if (!it.key().isEmpty()) FNotifications->setTypeNotificationKinds(it.key(),kinds); else FNotifications->setEnabledNotificationKinds(kinds); } emit childApply(); }
void QToDoContent::tree_clicked(const QModelIndex &index) { int r = index.row(); QStandardItem *item = m_model->item(r,1); QStandardItem *item2 = m_model->item(r,0); QString data = QToDoData::ref().getData("127.0.0.1","fasp_yz","postgres","postgres"); qDebug()<<data; m_edit->setText(data); if ( item->checkState() == Qt::Checked ) { qDebug()<<"Checked:"; QString data = m_model->data( m_model->index(r,0)).toString(); if ( m_type == ToDo ) { QToDoData::ref().getToDo().removeAll(data); } qDebug()<<data; m_taskList.append(data); m_taskList.removeDuplicates(); }else { qDebug()<<"UnChecked"; } }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void tCZoneModesModel::OnDataChanged() { bool modeChanged = false; for ( int row=0; row < rowCount(); ++row ) { QStandardItem* pItem = item( row ); if (pItem != 0) { bool ok; int index = pItem->data( INDEX_ROLE ).toInt( &ok ); if ( ok ) { tDigitalData state( tDataId( DATA_TYPE_SWITCH_STATE, index, DATA_ENGINE_CZONE_SELECTION ) ); Qt::CheckState checkState = Qt::Unchecked; if ( state.Value() > 0 ) { checkState = Qt::Checked; } Qt::CheckState oldCheckState = pItem->checkState(); pItem->setCheckState( checkState ); if ( oldCheckState != checkState ) { modeChanged = true; } } } } if ( modeChanged ) { emit ModeChanged(); } }
void QgsOSMExportDialog::onOK() { if ( !openDatabase() ) return; QgsOSMDatabase::ExportType type; if ( radPoints->isChecked() ) type = QgsOSMDatabase::Point; else if ( radPolylines->isChecked() ) type = QgsOSMDatabase::Polyline; else type = QgsOSMDatabase::Polygon; buttonBox->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList tagKeys; QStringList notNullTagKeys; for ( int i = 0; i < mTagsModel->rowCount(); ++i ) { QStandardItem* item = mTagsModel->item( i, 0 ); if ( item->checkState() == Qt::Checked ) tagKeys << item->text(); QStandardItem* item2 = mTagsModel->item( i, 2 ); if ( item2->checkState() == Qt::Checked ) notNullTagKeys << item->text(); } bool res = mDatabase->exportSpatiaLite( type, editLayerName->text(), tagKeys, notNullTagKeys ); // load the layer into canvas if that was requested if ( chkLoadWhenFinished->isChecked() ) { QgsDataSourceUri uri; uri.setDatabase( editDbFileName->text() ); uri.setDataSource( QString(), editLayerName->text(), "geometry" ); QgsVectorLayer* vlayer = new QgsVectorLayer( uri.uri(), editLayerName->text(), "spatialite" ); if ( vlayer->isValid() ) QgsMapLayerRegistry::instance()->addMapLayer( vlayer ); } QApplication::restoreOverrideCursor(); buttonBox->setEnabled( true ); if ( res ) { QMessageBox::information( this, tr( "OpenStreetMap export" ), tr( "Export has been successful." ) ); } else { QMessageBox::critical( this, tr( "OpenStreetMap export" ), tr( "Failed to export OSM data:\n%1" ).arg( mDatabase->errorString() ) ); } mDatabase->close(); }
// check QStandardItem and its decendants void AbstractCameraManager::cameraTree_recursiveCheck(QStandardItem* parent, Qt::CheckState checked) { qDebug() << "recursivecheck(" << checked << ") on " << parent->text(); for(int i=0; i<parent->rowCount(); ++i) { QStandardItem* currItem = parent->child(i); if(currItem->checkState() != checked) currItem->setCheckState(checked); else cameraTree_recursiveCheck(currItem, checked); } }
void ColorizerRow::onClickedAt (QModelIndex idx) { QStandardItem * item = m_model->itemFromIndex(idx); Q_ASSERT(item); QString const & str = m_model->data(idx, Qt::DisplayRole).toString(); bool const checked = (item->checkState() == Qt::Checked); ColorizedRow & ct = findOrCreateColorizedRow(item->text()); if (checked) { append(str); recompileColorRow(ct); updateColorRow(ct); } else { recompileColorRow(ct); updateColorRow(ct); remove(str); } emitFilterChangedSignal(); /* if (!idx.isValid()) return; QStandardItemModel * model = static_cast<QStandardItemModel *>(m_config_ui.ui()->viewColorRow->model()); QStandardItem * item = model->itemFromIndex(idx); Q_ASSERT(item); QString const & val = model->data(idx, Qt::DisplayRole).toString(); bool const checked = (item->checkState() == Qt::Checked); // @TODO: if state really changed for (int i = 0, ie = m_filter_state.m_colorized_texts.size(); i < ie; ++i) { ColorizedRow & ct = m_filter_state.m_colorized_texts[i]; if (ct.m_row_str == val) { if (checked) { m_filter_state.setColorRowChecked(val, checked); recompileColorRow(ct); updateColorRow(ct); } else { uncolorRow(ct); m_filter_state.setColorRowChecked(val, checked); recompileColorRow(ct); } break; } } */ }
QList<QSharedPointer<Shader> > ShaderListView::getCheckedShaders(){ QList<QSharedPointer<Shader> > list; for(int i = 0; i < itemModel->rowCount();i++){ QStandardItem* item = itemModel->item(i); if(item->checkState()){ int key = item->data().value<int>(); list.append(shaderMap.value(key)); } } return list; }
void tst_QStandardItem::streamItem() { QStandardItem item; item.setText(QLatin1String("text")); item.setToolTip(QLatin1String("toolTip")); item.setStatusTip(QLatin1String("statusTip")); item.setWhatsThis(QLatin1String("whatsThis")); item.setSizeHint(QSize(64, 48)); item.setFont(QFont()); item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter); item.setBackground(QColor(Qt::blue)); item.setForeground(QColor(Qt::green)); item.setCheckState(Qt::PartiallyChecked); item.setAccessibleText(QLatin1String("accessibleText")); item.setAccessibleDescription(QLatin1String("accessibleDescription")); QByteArray ba; { QDataStream ds(&ba, QIODevice::WriteOnly); ds << item; } { QStandardItem streamedItem; QDataStream ds(&ba, QIODevice::ReadOnly); ds >> streamedItem; QCOMPARE(streamedItem.text(), item.text()); QCOMPARE(streamedItem.toolTip(), item.toolTip()); QCOMPARE(streamedItem.statusTip(), item.statusTip()); QCOMPARE(streamedItem.whatsThis(), item.whatsThis()); QCOMPARE(streamedItem.sizeHint(), item.sizeHint()); QCOMPARE(streamedItem.font(), item.font()); QCOMPARE(streamedItem.textAlignment(), item.textAlignment()); QCOMPARE(streamedItem.background(), item.background()); QCOMPARE(streamedItem.foreground(), item.foreground()); QCOMPARE(streamedItem.checkState(), item.checkState()); QCOMPARE(streamedItem.accessibleText(), item.accessibleText()); QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription()); QCOMPARE(streamedItem.flags(), item.flags()); } }
bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int role) { QStandardItem *item = QStandardItemModel::itemFromIndex(index); if(!item) return false; // do not warn when the item is checked if ( value == QVariant(Qt::Unchecked) && role == Qt::CheckStateRole) warn(); if (item->parent()) { QStandardItem *tmpItem = item; while (tmpItem->parent()) { QStandardItemModel::setData(item->index(), value, role); // we are a child, and we have to update parent's status // so find out how many of us are selected and how many are // partially selected int selected = 0; int partSelected = 0; for(int i=0; i< tmpItem->parent()->rowCount(); i++) { QStandardItem *childItem = tmpItem->parent()->child(i); if (childItem->checkState() == Qt::Checked) { selected++; } if (childItem->checkState() == Qt::PartiallyChecked) { partSelected++; } } if (selected == tmpItem->parent()->rowCount()) { tmpItem->parent()->setCheckState(Qt::Checked); } else if (selected == 0 && partSelected == 0) { tmpItem->parent()->setCheckState(Qt::Unchecked); } else { tmpItem->parent()->setCheckState(Qt::PartiallyChecked); } tmpItem = tmpItem->parent(); } } changeAllChildren(item, value, role); return QStandardItemModel::setData(index, value, role); }
bool TreeModel::allInStatus(Qt::CheckState wanted_status) { for (int i=0; i< rowCount(); i++) { QStandardItem *item = this->item(i, 0); if (!item) continue; if (item->checkState() != wanted_status) { return false; } } return true; }
QStringList SpellCheckWidget::EnabledDictionaries() { QStringList enabled_dicts; for (int row = 0; row < m_Model.rowCount(); ++row) { QStandardItem *item = m_Model.itemFromIndex(m_Model.index(row, 0)); if (item->checkState() == Qt::Checked) { QStandardItem *name_item = m_Model.itemFromIndex(m_Model.index(row, 1)); enabled_dicts.append(name_item->text()); } } return enabled_dicts; }
QVariantHash OriginModel::changes() const { QVariantHash ret; for (int i = 0; i < rowCount(); ++i) { QStandardItem *repo = item(i); bool currentState = repo->checkState(); if (currentState != repo->data(RepoInitialState).toBool()) { ret[repo->data(RepoId).toString()] = currentState; } } return ret; }
QList<KUrl> VcsFileChangesModel::checkedUrls(QStandardItem *parent) const { QList<KUrl> ret; for(int i = 0; i < parent->rowCount(); i++) { QStandardItem* item = parent->child(i); if(!d->allowSelection || item->checkState() == Qt::Checked) { ret << statusInfo(item).url(); } } return ret; }
void ServiceChoooserWidget::onItemClicked(QModelIndex index) { if (ui->treeView->isExpanded(index)) ui->treeView->collapse(index); else ui->treeView->expand(index); #ifdef QUTIM_MOBILE_UI QStandardItem *item = m_model->itemFromIndex(index); if (item) { item->setCheckState(item->checkState() == Qt::Unchecked ? Qt::Checked : Qt::Unchecked); } #endif }
void CTrackList::on_pushButton_clicked() //////////////////////////////////////// { QStandardItemModel *model = (QStandardItemModel *)ui->treeView->model(); for (int i = 0; i < model->rowCount(); i++) { QStandardItem *item = model->item(i); tTracking[i].show = item->checkState() == Qt::Checked ? true : false; } done(DL_OK); }
void Dialog_save::slot_changed(const QModelIndex & topLeft, const QModelIndex & bottomRight){ bool value; int index = topLeft.row(); QStandardItem* item = this->Items_Views[index]; if(item->checkState() == Qt::Unchecked){ value = false; } else if(item->checkState() == Qt::Checked){ value = true; } switch (index) { case 0: gAcquisition->save_left_view = value; break; case 1: gAcquisition->save_right_view = value; break; case 2: gAcquisition->save_combo_view = value; break; } }
QStandardItem* updateProxyItem(QStandardItem* parent, QString name, T& proxy) { QStandardItem* item = NULL; if(NULL == parent) { return item; } QList<QStandardItem*> items = findChildItems(parent, name); if (items.count() == 1) { item = items.at(0); // qDebug() << parent->text() << " | " << item->text() << " ::" << proxy.flag << " (Going to Change to) " << item->checkState(); proxy.flag = item->checkState(); } return item; }
void DkFileAssociationsPreference::writeSettings() const { DkFileFilterHandling fh; Settings::param().app().browseFilters.clear(); Settings::param().app().registerFilters.clear(); for (int idx = 0; idx < mModel->rowCount(); idx++) { QStandardItem* item = mModel->item(idx, 0); if (!item) continue; QStandardItem* browseItem = mModel->item(idx, 1); QStandardItem* regItem = mModel->item(idx, 2); if (browseItem && browseItem->checkState() == Qt::Checked) { QString cFilter = item->text(); cFilter = cFilter.section(QRegExp("(\\(|\\))"), 1); cFilter = cFilter.replace(")", ""); Settings::param().app().browseFilters += cFilter.split(" "); } fh.registerFileType(item->text(), tr("Image"), regItem->checkState() == Qt::Checked); if (regItem->checkState() == Qt::Checked) { Settings::param().app().registerFilters.append(item->text()); qDebug() << item->text() << " registered"; } else qDebug() << item->text() << " unregistered"; } fh.registerNomacs(); // register nomacs again - to be save }
// slots void FilterTid::onClicked (QModelIndex idx) { if (!idx.isValid()) return; QStandardItem * item = m_model->itemFromIndex(idx); Q_ASSERT(item); QString const & filter_item = m_model->data(idx, Qt::DisplayRole).toString(); bool const orig_checked = (item->checkState() == Qt::Checked); if (orig_checked) append(filter_item); else remove(filter_item); emitFilterChangedSignal(); }
QList<QString>* AjoutPrecedence::testChecked(QStandardItem* element, QList<QString>* liste){ QStandardItem* temp; for(int nb=0; nb<element->rowCount(); nb++){ temp=element->child(nb); if(temp->checkState()==Qt::Checked){ liste->append(temp->text()); } else{ if (temp->child(0)!=0){ testChecked(temp, liste); } } } return liste; }
std::vector<openstudio::path> FileSystemSearch::selectedFiles() { std::vector<openstudio::path> results; int rowCount = m_model.rowCount(); for (int i = 0; i < rowCount; ++i) { QStandardItem *qsi = m_model.item(i); if (qsi->checkState() == Qt::Checked) { results.push_back(m_rootPath / toPath(qsi->text())); } } return results; }
void CDrawingList::on_pushButton_clicked() { QStandardItemModel *model = (QStandardItemModel *)ui->treeView->model(); for (int i = 0; i < model->rowCount(); i++) { QStandardItem *item = model->item(i); QStandardItem *item2 = model->item(i, 1); drawing_t *draw = (drawing_t *)item->data(Qt::UserRole + 1).toLongLong(); draw->show = item->checkState() == Qt::Checked ? true : false; draw->telescopeLink = item2->checkState() == Qt::Checked ? true : false; } done(DL_CANCEL); }