void MSCalibrationForm::OnMSReferencesUpdated( const QModelIndex& index ) { QStandardItemModel& model = *pModel_; QStandardItem * item = model.itemFromIndex( index ); const adcontrols::MSReferences& refs = pMethod_->references(); if ( item->rowCount() ) item->removeRows( 0, item->rowCount() ); size_t row(0); for ( adcontrols::MSReferences::vector_type::const_iterator it = refs.begin(); it != refs.end(); ++it, ++row ) { int col = 0; std::wstring formula = it->formula(); if ( ! it->adduct_or_loss().empty() ) formula += std::wstring( it->polarityPositive() ? L" + " : L" - ") + it->adduct_or_loss(); StandardItemHelper::appendRow( item, formula, true ); col++; if ( item->columnCount() < col + 1 ) model.insertColumn( item->columnCount(), item->index() ); model.setData( model.index( row, col, index ), it->exactMass() ); col++; if ( item->columnCount() < col + 1 ) model.insertColumn( item->columnCount(), item->index() ); model.setData( model.index( row, col, index ), it->enable() ); } }
QJsonDocument q2d::json::exportComponentHierarchy(QStandardItemModel* componentHierarchy) { QJsonDocument result = QJsonDocument(); QJsonArray hierarchy = QJsonArray(); QStandardItem* rootItem = componentHierarchy->invisibleRootItem(); for (int rIndex = 0; rIndex < rootItem->rowCount(); ++rIndex) { for (int cIndex = 0; cIndex < rootItem->columnCount(); ++cIndex) { hierarchy.append(QJsonValue(fromHierarchyEntry(rootItem->child(rIndex, cIndex)))); } } result.setArray(hierarchy); return result; }
void InstrumentTree::patchDoubleClicked(QModelIndex index)/*{{{*/ { if(!m_instrument) return; QStandardItem* nItem = _patchModel->itemFromIndex(index); if(nItem->hasChildren()) //Its a folder perform expand collapse { setExpanded(index, !isExpanded(index)); } else { int row = nItem->row(); QStandardItem* p = nItem->parent(); QStandardItem *idItem; QString pg = ""; if(p && p != _patchModel->invisibleRootItem() && p->columnCount() == 2) { //We are in group mode idItem = p->child(row, 1); pg = p->text(); } else { idItem = _patchModel->item(row, 1); } int id = idItem->text().toInt(); QString name = nItem->text(); //printf("Found patch Name: %s - ID: %d\n",name.toUtf8().constData(), id); if (!name.isEmpty() && id >= 0) { emit patchSelected(id, name); if(m_popup) { hide(); } } } }/*}}}*/
void tst_QStandardItem::getSetRowAndColumnCount() { QStandardItem item; item.setRowCount(-1); QCOMPARE(item.rowCount(), 0); item.setColumnCount(-1); QCOMPARE(item.columnCount(), 0); item.setRowCount(1); QCOMPARE(item.rowCount(), 1); QCOMPARE(item.columnCount(), 0); item.setColumnCount(1); QCOMPARE(item.columnCount(), 1); QCOMPARE(item.rowCount(), 1); item.setColumnCount(10); QCOMPARE(item.columnCount(), 10); QCOMPARE(item.rowCount(), 1); item.setRowCount(20); QCOMPARE(item.rowCount(), 20); QCOMPARE(item.columnCount(), 10); item.setRowCount(-1); QCOMPARE(item.rowCount(), 20); item.setColumnCount(-1); QCOMPARE(item.columnCount(), 10); item.setColumnCount(0); QCOMPARE(item.columnCount(), 0); QCOMPARE(item.rowCount(), 20); item.setRowCount(0); QCOMPARE(item.rowCount(), 0); }
void MSCalibrationForm::OnInitialUpdate() { QStandardItemModel& model = *pModel_; adcontrols::MSCalibrateMethod& method = *pMethod_; QStandardItem * rootNode = model.invisibleRootItem(); ui->treeView->setItemDelegate( pDelegate_.get() ); rootNode->setColumnCount(4); model.setHeaderData( 0, Qt::Horizontal, "MSCaribrate" ); for ( int i = 1; i < rootNode->columnCount(); ++i ) model.setHeaderData( 1, Qt::Horizontal, "" ); //---- StandardItemHelper::appendRow( rootNode, "Polynomial[degree]", method.polynomialDegree() ); StandardItemHelper::appendRow( rootNode, "Mass Tolerance[Da]", method.massToleranceDa() ); StandardItemHelper::appendRow( rootNode, "Minimum RA[%]", method.minimumRAPercent() ); StandardItemHelper::appendRow( rootNode, "Low Mass[Da]", method.lowMass() ); StandardItemHelper::appendRow( rootNode, "High Mass[Da]", method.highMass() ); //------ create Xe reference ------- adcontrols::MSReferences Xe; Xe.name( L"Xe-EI-Positive" ); #if 0 // adcontrols::MSReferenceDefns Xe; do { adcontrols::MSReferences& ref = Xe; ref << adcontrols::MSReference( L"126Xe", true, L"", false ); ref << adcontrols::MSReference( L"128Xe", true, L"", false ); ref << adcontrols::MSReference( L"129Xe", true, L"", true ); ref << adcontrols::MSReference( L"130Xe", true, L"", false ); ref << adcontrols::MSReference( L"131Xe", true, L"", false ); ref << adcontrols::MSReference( L"132Xe", true, L"", false ); ref << adcontrols::MSReference( L"134Xe", true, L"", false ); ref << adcontrols::MSReference( L"136Xe", true, L"", true ); } while(0); #endif // --------------------------------- //------ create PFTBA < tris(Perfluorobutyl)amine > reference ------- adcontrols::MSReferences PFTBA; PFTBA.name( L"PFTBA-EI-Positive" ); do { adcontrols::MSReferences& ref = PFTBA; ref << adcontrols::MSReference( L"CF3", true, L"", true ); ref << adcontrols::MSReference( L"C2F4", true, L"", false ); ref << adcontrols::MSReference( L"C2F5", true, L"", false ); ref << adcontrols::MSReference( L"C3F5", true, L"", true ); ref << adcontrols::MSReference( L"C4F9", true, L"", true ); ref << adcontrols::MSReference( L"C5F10N", true, L"", true ); ref << adcontrols::MSReference( L"C6F12N", true, L"", false ); ref << adcontrols::MSReference( L"C7F12N", true, L"", false ); ref << adcontrols::MSReference( L"C8F14N", true, L"", false ); ref << adcontrols::MSReference( L"C8F16N", true, L"", false ); ref << adcontrols::MSReference( L"C9F16N", true, L"", false ); ref << adcontrols::MSReference( L"C9F18N", true, L"", false ); ref << adcontrols::MSReference( L"C9F20N", true, L"", true ); ref << adcontrols::MSReference( L"C12F22N", true, L"", false ); ref << adcontrols::MSReference( L"C12F24N", true, L"", false ); } while(0); // --------------------------------- pDelegate_->refs_[ Xe.name() ] = Xe; pDelegate_->refs_[ PFTBA.name() ] = PFTBA; pMethod_->references( PFTBA ); // set as default calibration reference QStandardItem * refItem = StandardItemHelper::appendRow( rootNode, "Mass References", qVariantFromValue( MSCalibrateDelegate::MSReferences( pMethod_->references().name() ) ) ); OnMSReferencesUpdated( refItem->index() ); ui->treeView->expand( refItem->index() ); ui->treeView->setColumnWidth( 0, 200 ); }