void MainWindow::loadFonts() { QGridLayout *grlt; FontPixel *fpx; unsigned char data; // Load big font for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { grlt = dynamic_cast<QGridLayout*>(digBig[i]->layout()); data = eep[EEPROM_BIG_NUM_FONT + i * 5 + j]; for (int k = 0; k < 8; k++) { fpx = dynamic_cast<FontPixel*>(grlt->itemAtPosition(k, j)->widget()); fpx->setChecked(data & 1<<k); } } } // Load extra font for (int i = 0; i < 10; i++) { for (int j = 0; j < 6; j++) { grlt = dynamic_cast<QGridLayout*>(digExtra[i]->layout()); data = eep[EEPROM_EXTRA_NUM_FONT + i * 6 + j]; for (int k = 0; k < 8; k++) { fpx = dynamic_cast<FontPixel*>(grlt->itemAtPosition(k, j)->widget()); fpx->setChecked(data & 1<<k); } } } }
/* * Update the QtHtmSublayer grid display after running the CLA. */ void QtFront::UpdateHtmDisplay() { QGridLayout *currGrid = (QGridLayout *)smiLayerGroup->layout(); QGridLayout *newHtmGrid = HtmDisplay->UnitGrid(objHtm); HtmSublayer **sublayers = htm->GetSublayers(); unsigned int h = sublayers[0]->GetHeight(); unsigned int w = sublayers[0]->GetWidth(); unsigned int d = sublayers[0]->GetDepth(); QtUnit *colUnit = NULL; QList<QtCell *> qtCells; //QGridLayout *cellGrid = NULL; QColor rgb[d+1]; int r[d+1], g[d+1], b[d+1]; for (unsigned int i=0; i<h; i++) { for (unsigned int j=0; j<w; j++) { colUnit = (QtUnit *)newHtmGrid->itemAtPosition(i, j)->widget(); //cellGrid = colUnit->GetCellGrid(); rgb[0] = colUnit->getBrushColor(); rgb[0].getRgb(&r[0], &g[0], &b[0]); qtCells = colUnit->findChildren<QtCell *>(); for (unsigned int c=1; c<=d; c++) { rgb[c] = qtCells.at(c-1)->getBrushColor(); rgb[c].getRgb(&r[c], &g[c], &b[c]); } colUnit = (QtUnit *)currGrid->itemAtPosition(i, j)->widget(); colUnit->setBrushColor(QColor(r[0], g[0], b[0])); qtCells = colUnit->findChildren<QtCell *>(); for (unsigned int c=1; c<=d; c++) qtCells.at(c-1)->setBrushColor( QColor(r[c], g[c], b[c]) ); } } QGridLayout *currPoolingGrid = (QGridLayout *)poolGroup->layout(); QGridLayout *newPoolingGrid = HtmDisplay->PoolUnitGrid(objHtm); PoolingLayer *p = htm->GetPoolingLayer(); h = p->GetHeight(); w = p->GetWidth(); QColor rgbPool; int rP, gP, bP; for (unsigned int i=0; i<h; i++) { for (unsigned int j=0; j<w; j++) { colUnit = (QtUnit *)newPoolingGrid->itemAtPosition(i, j)->widget(); rgbPool = colUnit->getBrushColor(); rgbPool.getRgb(&rP, &gP, &bP); colUnit = (QtUnit *)currPoolingGrid->itemAtPosition(i, j)->widget(); colUnit->setBrushColor( QColor(rP, gP, bP)); } } }
void TreeModel::saveNewData(QWidget *widgetContainer, const QModelIndex &parentIndex) { TreeItem *m_parent = itemFromIndex(parentIndex); if (m_parent != NULL) { int totalChilds = m_parent->childCount(); QGridLayout *gridLayout = dynamic_cast<QGridLayout*>(widgetContainer->layout()); for (int i = 0; i < gridLayout->rowCount(); i++) { QWidgetItem *widgetItem = dynamic_cast<QWidgetItem*>(gridLayout->itemAtPosition(i,3)); if (widgetItem) { QLabel *label = dynamic_cast<QLabel*>(widgetItem->widget()); QWidgetItem *widgetItem2 = dynamic_cast<QWidgetItem*>(gridLayout->itemAtPosition(i,1)); if (label and widgetItem2) { for (int j = 0; j < totalChilds; j++) { if (label->text() == m_parent->child(j)->getUID()) { QLineEdit *lineEdit = qobject_cast<QLineEdit*>(widgetItem2->widget()); QComboBox *comboBox = qobject_cast<QComboBox*>(widgetItem2->widget()); if (lineEdit) m_parent->child(j)->setValue(lineEdit->text()); else if (comboBox) { QString valAux = ""; if (comboBox->currentText() == "TRUE") valAux = "1"; else if (comboBox->currentText() == "FALSE") valAux = "0"; m_parent->child(j)->setValue(valAux); } TreeItem *item = new TreeItem(m_parent->child(j)); m_parent->removeRow(j); m_parent->insertRow(j, item); } } } } } emit modelModified(); } }
QLayoutItem *QGridLayoutProto::itemAtPosition(int row, int column) const { QGridLayout *item = qscriptvalue_cast<QGridLayout*>(thisObject()); if (item) return item->itemAtPosition(row, column); return 0; }
void SettingsBottomView::dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight) { QModelIndex parent = topLeft.parent(); // If modifying data for a group, don't do anything if (!parent.isValid()) return; // Don't allow modifying more than one data element if (topLeft != bottomRight) { qDebug() << "Warning: the settings view does not allow batch modification"; return; } QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(parent.row())); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QWidget* widget; QLayoutItem* item; // Setting description item = layout->itemAtPosition(topLeft.row(), 0); QString description = getSettingDescription(topLeft); if (!item) { widget = new QLabel(description, NULL); layout->addWidget(widget, topLeft.row(), 0); } else { widget = item->widget(); qobject_cast<QLabel*>(widget)->setText(description); } // Setting value item = layout->itemAtPosition(topLeft.row(), 1); if (!item) { widget = createEditorForIndex(topLeft); layout->addWidget(widget, topLeft.row(), 1); widget->show(); } else { widget = item->widget(); } QAbstractItemDelegate* delegate = itemDelegate(topLeft); delegate->setEditorData(widget, topLeft); }
void DialogEditSIMDRegister::hideRows(EntriesRows rowToHide) { QGridLayout* layout = dynamic_cast<QGridLayout*>(this->layout()); for(int col=0;col<TOTAL_COLS;++col) { const auto item=layout->itemAtPosition(rowToHide,col); if(item && item->widget()) item->widget()->hide(); } }
/** Slot checks whether entered scores are valid and * enables or disables okButton */ void MatchResDialog::textChanged( ) { QList< Game > res; QGridLayout* l = qobject_cast< QGridLayout* >( layout () ); for ( unsigned int i = 0; i < _match.maxGames(); i ++ ) { QWidget* w = l->itemAtPosition( i + 1, 0 )->widget(); QLineEdit* leA = qobject_cast< QLineEdit* >( w ); w = l->itemAtPosition( i + 1, 1 )->widget(); QLineEdit* leB = qobject_cast< QLineEdit* >( w ); if ( leB->text().isEmpty() || leA->text().isEmpty() ) { continue; } Game game; game.a = _match.playerA(); game.b = _match.playerB(); game.aBalls = leA->text().toInt(); game.bBalls = leB->text().toInt(); if ( !game.validate() ) { _okButton->setEnabled( false ); return; } res << game; } // all games are correct at this time. _match = Match( _match.playerA(), _match.playerB() ); _match.games() << res; _okButton->setEnabled( _match.validate() ); }
void ParameterWidget::storeFilterValue(QDate date) { QObject *filter = (QObject *)sender(); QLayoutItem *test; QLayoutItem *test2; QLayoutItem *child; QLayoutItem *child2; QGridLayout *layout; QHBoxLayout *layout2; QWidget *found; XComboBox *mybox; int foundRow = 0; for (int i = 1; i < _filtersLayout->rowCount(); i++) { test = _filtersLayout->itemAtPosition(i, 1); if (test) { layout = (QGridLayout *)test->layout(); child =layout->itemAtPosition(0, 0); layout2 = (QHBoxLayout *)child->layout()->itemAt(0); child2 = layout2->itemAt(0); found = child2->widget(); if (found == filter ) foundRow = i; } } test2 = _filtersLayout->itemAtPosition(foundRow, 0)->layout()->itemAt(0); mybox = (XComboBox*)test2->widget(); QString currText = mybox->currentText(); QPair<QString, ParameterWidgetTypes> tempPair = _types[currText]; _filterValues[foundRow] = qMakePair(tempPair.first, QVariant(date)); //if (!mybox->currentText().isEmpty()) //{ //_usedTypes->removeAll(mybox->currentText()); if (!_usedTypes.isEmpty()) _usedTypes.remove(foundRow); _usedTypes[foundRow] = mybox->currentText(); _addFilterRow->setDisabled(false); repopulateComboboxes(); emit updated(); }
QWidget * GraphicalArrayTest::findWidget(const GraphicalArray* value, int row, int col) { // /!\ WARNING /!\ // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION // OF THE GRAPHICAL LOOK OF GraphicalArray QGridLayout * layout = dynamic_cast<QGridLayout*>(value->layout()->itemAt(0)->widget()->layout()); QWidget * widget = nullptr; if( is_not_null(layout) ) widget = layout->itemAtPosition(row, col)->widget(); else QWARN("Failed to find the layout or cast it to QGridLayout."); return widget; }
void SettingsBottomView::commit() { int pages = stack->count(); for (int p = 0; p < pages; ++p) { QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(p)); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QModelIndex pageIndex = model()->index(p, 0); for (int i = 0; i < layout->rowCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(i, 1); if (!item) continue; // Prevent segfault for empty layout QWidget* editor = item->widget(); QModelIndex dataIndex = model()->index(i, 0, pageIndex); itemDelegate()->setModelData(editor, model(), dataIndex); } } }
void MetaEditDialog::accept() { if (dirty) { QGridLayout* grid = static_cast<QGridLayout*>(scrollWidget->layout()); int idx = grid->rowCount(); QMap<QString, QString> m; for (int i = 0; i < idx; ++i) { QLayoutItem* labelItem = grid->itemAtPosition(i, 0); QLayoutItem* dataItem = grid->itemAtPosition(i, 1); if (labelItem && dataItem) { QLabel* label = static_cast<QLabel*>(labelItem->widget()); QLineEdit* le = static_cast<QLineEdit*>(dataItem->widget()); m.insert(label->text(), le->text()); } } score->undo(new ChangeMetaTags(score, m)); } QDialog::accept(); }
PreviewFileDialog::PreviewFileDialog( QWidget* parent ) : QFileDialog( parent ) { QGridLayout* gridLayout = dynamic_cast<QGridLayout*>( this->layout() ); if ( gridLayout ) { QLayoutItem* layoutItem = gridLayout->itemAtPosition( 1,0 ); QSplitter* splitter; splitter = dynamic_cast<QSplitter*>( layoutItem->widget() ); if ( splitter ) { QFrame* framePreview = new QFrame( splitter ); splitter->addWidget( framePreview ); QVBoxLayout* vboxPreviewLayout = new QVBoxLayout( framePreview ); QGridLayout* gridPreviewLayout = new QGridLayout(); m_labelPreview.setFrameShape( QFrame::NoFrame ); m_labelPreview.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); m_labelPreview.setMinimumSize( 100,100 ); gridPreviewLayout->addWidget( &m_labelPreviewWidthText, 0, 0, 1, 1, Qt::AlignLeft ); gridPreviewLayout->addWidget( &m_labelPreviewWidth, 0, 1, 1, 1, Qt::AlignLeft ); gridPreviewLayout->addWidget( &m_labelPreviewHeightText, 1, 0, 1, 1, Qt::AlignLeft ); gridPreviewLayout->addWidget( &m_labelPreviewHeight, 1, 1, 1, 1, Qt::AlignLeft ); gridPreviewLayout->addWidget( &m_labelPreviewRatioText, 2, 0, 1, 1, Qt::AlignLeft ); gridPreviewLayout->addWidget( &m_labelPreviewRatio, 2, 1, 1, 1, Qt::AlignLeft ); gridPreviewLayout->setColumnStretch( 1,1 ); vboxPreviewLayout->addWidget( &m_labelPreview, 1, Qt::AlignHCenter ); vboxPreviewLayout->addLayout( gridPreviewLayout ); vboxPreviewLayout->addStretch( 1 ); framePreview->setLayout( vboxPreviewLayout ); connect( this, SIGNAL( currentChanged( QString ) ), this, SLOT( setPreviewPicture( QString ) ) ); } } }
void DialogEditSIMDRegister::resetLayout() { QGridLayout* layout = dynamic_cast<QGridLayout*>(this->layout()); for(int col=ENTRIES_FIRST_COL;col<TOTAL_COLS;++col) { int i=numBytes-1-(col-ENTRIES_FIRST_COL); columnLabels[i]->show(); const auto& byte=bytes[i]; layout->addWidget(byte,BYTES_ROW,byte->column(),1,byte->colSpan()); byte->show(); const auto& word=words[i/2]; layout->addWidget(word,WORDS_ROW,word->column(),1,word->colSpan()); word->show(); const auto& dword=dwords[i/4]; layout->addWidget(dword,DWORDS_ROW,dword->column(),1,dword->colSpan()); dword->show(); const auto& qword=qwords[i/8]; layout->addWidget(qword,QWORDS_ROW,qword->column(),1,qword->colSpan()); qword->show(); const auto& float32=floats32[i/4]; layout->addWidget(float32,FLOATS32_ROW,float32->column(),1,float32->colSpan()); float32->show(); const auto& float64=floats64[i/8]; layout->addWidget(float64,FLOATS64_ROW,float64->column(),1,float64->colSpan()); float64->show(); } for(int row=ENTRIES_FIRST_ROW;row<ROW_AFTER_ENTRIES;++row) layout->itemAtPosition(row,LABELS_COL)->widget()->show(); layout->removeItem(hexSignOKCancelLayout); hexSignOKCancelLayout->setParent(nullptr); layout->addLayout(hexSignOKCancelLayout, ROW_AFTER_ENTRIES, ENTRIES_FIRST_COL, 1, numBytes); }
int KnobGui::getActualIndexInLayout() const { QWidget* parent = _imp->field->parentWidget(); if (!parent) { return -1; } QGridLayout* layout = dynamic_cast<QGridLayout*>( parent->layout() ); if (!layout) { return -1; } for (int i = 0; i < layout->rowCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(i, 1); if ( item && (item->widget() == _imp->field) ) { return i; } } return -1; }
bool SettingsBottomView::editorValuesChanged() { QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->currentWidget()); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QModelIndex pageIndex = model()->index(stack->currentIndex(), 0); for (int i = 0; i < layout->rowCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(i, 1); if (!item) continue; // Prevent segfault for empty layout QWidget* editor = item->widget(); QByteArray propertyName = editor->metaObject()->userProperty().name(); QVariant editorData = editor->property(propertyName); QModelIndex dataIndex = model()->index(i, 0, pageIndex); QVariant modelData = model()->data(dataIndex, Qt::EditRole); if (!variantsEqual(editorData, modelData)) return true; } return false; }
void MainWindow::updateFontExtra() { QGridLayout *grlt; FontPixel *fpx; unsigned char data; for (int i = 0; i < 10; i++) { for (int j = 0; j < 6; j++) { grlt = dynamic_cast<QGridLayout*>(digExtra[i]->layout()); data = 0; for (int k = 0; k < 8; k++) { fpx = dynamic_cast<FontPixel*>(grlt->itemAtPosition(k, j)->widget()); if (fpx->isChecked()) data |= (1<<k); else data &= ~(1<<k); } eep[EEPROM_EXTRA_NUM_FONT + i * 6 + j] = data; } } updateHexTable(); }
void MainWindow::setupBlockArray(QVBoxLayout *in) { ui->label_selectedTitle->setText("Select a value"); ui->label_selectedSub->clear(); ui->label_selectedLong->clear(); ui->label_selectedValue->clear(); ui->label_selectedUnits->clear(); ui->label_selectedBinary->clear(); ui->label_selectedSub->hide(); ui->label_selectedLong->hide(); ui->label_selectedValue->hide(); ui->label_selectedUnits->hide(); ui->label_selectedBinary->hide(); connect(&mapButtons, SIGNAL(mapped(int)), this, SLOT(openCloseBlock(int))); connect(&mapValueClick, SIGNAL(mapped(int)), this, SLOT(displayInfo(int))); for (int i = 0; i < 4; i++) { QGridLayout* row = static_cast<QGridLayout*>(in->itemAt(i)->layout()); blockDisplays[i].pushButton = static_cast<QPushButton*>(row->itemAtPosition(3,0)->widget()); mapButtons.setMapping(blockDisplays[i].pushButton, i); connect(blockDisplays[i].pushButton, SIGNAL(clicked()), &mapButtons, SLOT(map())); blockDisplays[i].spinBox = static_cast<QSpinBox*>(row->itemAtPosition(3,1)->widget()); connect(blockDisplays[i].spinBox, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int))); blockDisplays[i].blockTitle = static_cast<QLabel*>(row->itemAtPosition(1,0)->widget()); for (int j = 0; j < 4; j++) { blockDisplays[i].desc[j] = static_cast<QLabel*>(row->itemAtPosition(1,j+2)->widget()); blockDisplays[i].subDesc[j] = static_cast<QLabel*>(row->itemAtPosition(2,j+2)->widget()); blockDisplays[i].lineEdit[j] = static_cast<clickLineEdit*>(row->itemAtPosition(3,j+2)->widget()); mapValueClick.setMapping(blockDisplays[i].lineEdit[j], i*4+j); connect(blockDisplays[i].lineEdit[j], SIGNAL(clicked()), &mapValueClick, SLOT(map())); blockDisplays[i].desc[j]->setText("Value " + QString::number(j+1)); //blockDisplays[i].subDesc[j]->setText(""); } blockDisplays[i].blockNum = -1; } }
void PhotoDrop::moveRight() { std::cerr << "PhotoDrop::moveRight()"; std::cerr << std::endl; QLayout *alayout = layout(); if (!alayout) { std::cerr << "PhotoDrop::moveRight() No Layout"; std::cerr << std::endl; return; } QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout); if (!glayout) { std::cerr << "PhotoDrop::moveRight() not GridLayout... not much we can do!"; std::cerr << std::endl; return; } int count = alayout->count(); if ((!mSelected) || (count < 2)) { std::cerr << "PhotoDrop::moveRight() Not enough items"; std::cerr << std::endl; return; } int index = alayout->indexOf(mSelected); int selectedRow; int selectedColumn; int rowSpan; int colSpan; glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan); int maxRow = (count - 1) / mColumns; int maxCol = (count - 1) % mColumns; if ((selectedRow == maxRow) && (selectedColumn == maxCol)) { std::cerr << "PhotoDrop::moveRight() Selected is last item"; std::cerr << std::endl; return; } int swapRow = selectedRow; int swapColumn = selectedColumn + 1; if (swapColumn == mColumns) { swapRow++; swapColumn = 0; } std::cerr << "PhotoDrop::moveRight() Trying to swap (" << selectedRow << ","; std::cerr << selectedColumn << ") <-> (" << swapRow; std::cerr << "," << swapColumn << ")"; std::cerr << std::endl; QLayoutItem *litem = glayout->itemAtPosition(swapRow, swapColumn); if (!litem) { std::cerr << "PhotoDrop::moveRight() No layout item to the right"; std::cerr << std::endl; return; } QWidget *widget = litem->widget(); if (!widget) { std::cerr << "PhotoDrop::moveRight() No item to the right"; std::cerr << std::endl; return; } /* grab both items, and switch */ std::cerr << "PhotoDrop::moveRight() could move index: " << index; std::cerr << std::endl; glayout->removeWidget(widget); glayout->removeWidget(mSelected); glayout->addWidget(widget, selectedRow, selectedColumn, Qt::AlignCenter); glayout->addWidget(mSelected, swapRow, swapColumn, Qt::AlignCenter); checkMoveButtons(); }
/* * Sets up the GUI. It's a bit messy. These are the important things to remember: * 1. The parameter/state block created by DefaultGUIModel is HIDDEN. * 2. The Unload button is hidden, Pause is renamed 'Auto', and Modify is renamed 'Set DAQ' * 3. All GUI changes are connected to their respective text boxes in the hidden block * 4. 'Set DAQ' updates the values of inner variables with GUI choices linked to the text boxes * * Okay, here we go! */ void AMAmp::customizeGUI(void) { QGridLayout *customLayout = DefaultGUIModel::getLayout(); customLayout->itemAtPosition(1,0)->widget()->setVisible(false); DefaultGUIModel::pauseButton->setVisible(false); DefaultGUIModel::modifyButton->setText("Set DAQ"); DefaultGUIModel::unloadButton->setVisible(false); // create input spinboxes QGroupBox *ioGroupBox = new QGroupBox("Channels"); QGridLayout *ioGroupLayout = new QGridLayout; ioGroupBox->setLayout(ioGroupLayout); QLabel *inputBoxLabel = new QLabel("Input"); inputBox = new AMAmpSpinBox; // this is the QSpinBox wrapper made earlier inputBox->setRange(0,100); ioGroupLayout->addWidget(inputBoxLabel, 0, 0); ioGroupLayout->addWidget(inputBox, 0, 1); QLabel *outputBoxLabel = new QLabel("Output"); outputBox = new AMAmpSpinBox; outputBox->setRange(0,100); ioGroupLayout->addWidget(outputBoxLabel, 1, 0); ioGroupLayout->addWidget(outputBox, 1, 1); // create amp mode groupbox QGroupBox *ampModeGroupBox = new QGroupBox("Amp Mode"); QGridLayout *ampModeGroupLayout = new QGridLayout; ampModeGroupBox->setLayout(ampModeGroupLayout); QGridLayout *offsetLayout = new QGridLayout; offsetLayout->setColumnStretch(0, 1); QLabel *aiOffsetLabel = new QLabel("AI Offset:"); offsetLayout->addWidget(aiOffsetLabel, 0, 0); aiOffsetEdit = new AMAmpLineEdit(); aiOffsetEdit->setMaximumWidth(aiOffsetEdit->minimumSizeHint().width()*3); aiOffsetEdit->setValidator( new QDoubleValidator(aiOffsetEdit) ); offsetLayout->addWidget(aiOffsetEdit, 0, 1); aiOffsetUnits = new QLabel("1 V/V"); offsetLayout->addWidget(aiOffsetUnits, 0, 2, Qt::AlignCenter); QLabel *aoOffsetLabel = new QLabel("AO Offset:"); offsetLayout->addWidget(aoOffsetLabel, 1, 0); aoOffsetEdit = new AMAmpLineEdit(); aoOffsetEdit->setMaximumWidth(aoOffsetEdit->minimumSizeHint().width()*3); aoOffsetEdit->setValidator( new QDoubleValidator(aoOffsetEdit) ); offsetLayout->addWidget(aoOffsetEdit, 1, 1); aoOffsetUnits = new QLabel("---"); offsetLayout->addWidget(aoOffsetUnits, 1, 2, Qt::AlignCenter); findZeroButton = new QPushButton("Zero AI/AO Channels"); findZeroButton->setToolTip("Find offset that will make output from specified channel = 0"); offsetLayout->addWidget(findZeroButton, 2, 0, 1, 3); ampModeGroupLayout->addLayout(offsetLayout, 0, 0); //add little bit of space betwen offsets and buttons ampModeGroupLayout->addItem( new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum), 2, 0); // add probe gain combobox QGridLayout *probeGainLayout = new QGridLayout; QLabel *probeGainLabel = new QLabel("Probe Gain:"); probeGainComboBox = new AMAmpComboBox; probeGainComboBox->insertItem(0, QString::fromUtf8("Low (10 MΩ)")); probeGainComboBox->insertItem(1, QString::fromUtf8("High (10 GΩ)")); probeGainLayout->addWidget(probeGainLabel, 0, 0); probeGainLayout->addWidget(probeGainComboBox, 0, 1); ampModeGroupLayout->addLayout(probeGainLayout, 3, 0); //add little bit of space betwen offsets and buttons ampModeGroupLayout->addItem( new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum), 4, 0); // make the buttons ampButtonGroup = new QButtonGroup; vclampButton = new QRadioButton("VClamp"); ampButtonGroup->addButton(vclampButton, 1); izeroButton = new QRadioButton("I = 0"); ampButtonGroup->addButton(izeroButton, 2); iclampButton = new QRadioButton("IClamp"); ampButtonGroup->addButton(iclampButton, 3); vcompButton = new QRadioButton("VComp"); ampButtonGroup->addButton(vcompButton, 4); vtestButton = new QRadioButton("VTest"); ampButtonGroup->addButton(vtestButton, 5); iresistButton = new QRadioButton("IResist"); ampButtonGroup->addButton(iresistButton, 6); ifollowButton = new QRadioButton("IFollow"); ampButtonGroup->addButton(ifollowButton, 7); QGridLayout *ampButtonGroupLayout = new QGridLayout; ampButtonGroupLayout->addWidget(vclampButton, 0, 0); ampButtonGroupLayout->addWidget(izeroButton, 0, 1); ampButtonGroupLayout->addWidget(iclampButton, 1, 0); ampButtonGroupLayout->addWidget(vcompButton, 1, 1); ampButtonGroupLayout->addWidget(vtestButton, 2, 0); ampButtonGroupLayout->addWidget(iresistButton, 2, 1); ampButtonGroupLayout->addWidget(ifollowButton, 3, 0); ampModeGroupLayout->addLayout(ampButtonGroupLayout, 5, 0); // add widgets to custom layout customLayout->addWidget(ioGroupBox, 0, 0); customLayout->addWidget(ampModeGroupBox, 2, 0); setLayout(customLayout); checkZeroCalc = new QTimer(this); // connect the widgets to the signals QObject::connect(ampButtonGroup, SIGNAL(buttonPressed(int)), this, SLOT(updateMode(int))); QObject::connect(ampButtonGroup, SIGNAL(buttonPressed(int)), this, SLOT(updateOffset(int))); QObject::connect(inputBox, SIGNAL(valueChanged(int)), this, SLOT(updateInputChannel(int))); QObject::connect(outputBox, SIGNAL(valueChanged(int)), this, SLOT(updateOutputChannel(int))); QObject::connect(aiOffsetEdit, SIGNAL(textEdited(const QString &)), this, SLOT(setAIOffset(const QString &))); QObject::connect(aoOffsetEdit, SIGNAL(textEdited(const QString &)), this, SLOT(setAOOffset(const QString &))); QObject::connect(findZeroButton, SIGNAL(clicked(void)), this, SLOT(findZeroOffset(void))); QObject::connect(checkZeroCalc, SIGNAL(timeout(void)), this, SLOT(calculateOffset(void))); QObject::connect(probeGainComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setProbeGain(int))); }
//------------------------------------------------------------------------------ QWidget* ctkFileDialog::bottomWidget()const { QGridLayout* gridLayout = qobject_cast<QGridLayout*>(this->layout()); QLayoutItem* item = gridLayout->itemAtPosition(4,1); return item ? item->widget() : 0; }
//stores the value of a filter object into the filtervalues map void ParameterWidget::storeFilterValue(int pId, QObject* filter) { if (!filter) { filter = (QObject *)sender(); } QLayoutItem *test; QLayoutItem *test2; QLayoutItem *child; QLayoutItem *child2; QGridLayout *layout; QHBoxLayout *layout2; QWidget *found; XComboBox *mybox; int foundRow = 0; for (int i = 1; i < _filtersLayout->rowCount(); i++) { test = _filtersLayout->itemAtPosition(i, 1); if (test) { layout = (QGridLayout *)test->layout(); child = layout->itemAtPosition(0, 0); layout2 = (QHBoxLayout *)child->layout()->itemAt(0); child2 = layout2->itemAt(0); found = child2->widget(); if (found == filter ) { foundRow = i; } } } test2 = _filtersLayout->itemAtPosition(foundRow, 0)->layout()->itemAt(0); mybox = (XComboBox*)test2->widget(); QString _currText = mybox->currentText(); QPair<QString, ParameterWidgetTypes> tempPair = _types[_currText]; const QMetaObject *metaobject = filter->metaObject(); QString classname(metaobject->className()); if (pId == -1) { if (classname == "QLineEdit") { QLineEdit *lineEdit = (QLineEdit *)filter; _filterValues[foundRow] = qMakePair(tempPair.first, QVariant(lineEdit->text())); emit updated(); } } else { if (classname == "UsernameCluster") { UsernameCluster *usernameCluster = (UsernameCluster *)filter; QString username = usernameCluster->username(); _filterValues[foundRow] = qMakePair(tempPair.first, QVariant(username)); emit updated(); } else { _filterValues[foundRow] = qMakePair(tempPair.first, QVariant(pId)); emit updated(); } } if (!_usedTypes.isEmpty()) _usedTypes.remove(foundRow); _usedTypes[foundRow] = mybox->currentText(); _addFilterRow->setDisabled(false); repopulateComboboxes(); }
void ParameterWidget::applySaved(int pId, int filter_id) { qDebug() << "in applySaved, pid is: " << pId; QGridLayout *container; QLayoutItem *child; QLayoutItem *child2; QHBoxLayout *layout2; QWidget *found; QDate tempdate; XSqlQuery qry; QString query; QString filterValue; int xid; QMapIterator<int, QPair<QString, QVariant> > j(_filterValues); clearFilters(); if (!parent()) return; //if (pId == 0) //addParam(); if (_filterList->id() == -1) { _filterSetName->clear(); setSelectedFilter(-1); emit updated(); return; } if (filter_id == 0 && _filterList->id() != -1) filter_id = _filterList->id(_filterList->currentIndex()); const QMetaObject *metaobject = this->parent()->metaObject(); QString classname(metaobject->className()); //look up filter from database query = " SELECT filter_value " " FROM filter " " WHERE filter_username=current_user " " AND filter_id=:id " " AND filter_screen=:screen "; qry.prepare(query); qry.bindValue(":screen", classname); qry.bindValue(":id", filter_id ); qry.exec(); if (qry.first()) filterValue = qry.value("filter_value").toString(); QStringList filterRows = filterValue.split("|"); QString tempFilter = QString(); int windowIdx = _filtersLayout->rowCount(); for (int i = 0; i < filterRows.size(); ++i) { tempFilter = filterRows[i]; if ( !(tempFilter.isEmpty()) ) { //0 is filterType, 1 is filterValue, 2 is parameterwidgettype QStringList tempFilterList = tempFilter.split(":"); this->addParam(); QLayoutItem *test = _filtersLayout->itemAtPosition(windowIdx, 0)->layout()->itemAt(0); XComboBox *mybox = (XComboBox*)test->widget(); QString key = this->getParameterTypeKey(tempFilterList[0]); int idx = mybox->findText(key); mybox->setCurrentIndex(idx); QString row; row = row.setNum(windowIdx); container = _filtersLayout->findChild<QGridLayout *>("topLayout" + row); child = container->itemAtPosition(0, 0)->layout()->itemAt(0); layout2 = (QHBoxLayout *)child->layout(); child2 = layout2->itemAt(0); found = child2->widget(); int widgetType = tempFilterList[2].toInt(); //grab pointer to newly created filter object switch (widgetType) { case Date: DLineEdit *dLineEdit; dLineEdit = (DLineEdit*)found; dLineEdit->setDate(QDate::fromString(tempFilterList[1], "yyyy-MM-dd"), true); break; case User: UsernameCluster *usernameCluster; usernameCluster = (UsernameCluster*)found; usernameCluster->setUsername(tempFilterList[1]); break; case Crmacct: CRMAcctCluster *crmacctCluster; crmacctCluster = (CRMAcctCluster*)found; crmacctCluster->setId(tempFilterList[1].toInt()); break; case Contact: ContactCluster *contactCluster; contactCluster = (ContactCluster*)found; contactCluster->setId(tempFilterList[1].toInt()); break; case XComBox: XComboBox *xBox; xBox = (XComboBox*)found; //fix for setid not emitting id signal if id found for filter is first in list //set to any other valid id first to fix it xBox->setId(2); xid = tempFilterList[1].toInt(); qDebug() << "xid is: " << xid; xBox->setId(xid); while (j.hasNext()) { j.next(); QPair<QString, QVariant> tempPair = j.value(); qDebug() << j.key() << ": " << tempPair.second << endl; } break; default: QLineEdit *lineEdit; lineEdit = (QLineEdit*)found; lineEdit->setText(tempFilterList[1]); storeFilterValue(-1, lineEdit); break; } }//end of if windowIdx++; }//end of for _filterSetName->setText( _filterList->currentText() ); setSelectedFilter(filter_id); emit updated(); }