// delay
delegateSpinBox = new DoubleSpinBoxDelegate(this) ;
delegateSpinBox
->setLocalLanguage
(QLocale::German);
delegateSpinBox->Editor()->setRange(10,20e7);
delegateSpinBox->Editor()->setDecimals(3);
delegateSpinBox->Editor()->setSingleStep(1);
tableViewVariation->setItemDelegateForColumn(4,delegateSpinBox);
// delay
delegateSpinBox = new DoubleSpinBoxDelegate(this) ;
delegateSpinBox->setEditor(new QDoubleSpinBox(this));
delegateSpinBox->setLocalLanguage(QLocale::German);
delegateSpinBox->Editor()->setRange(10,20e7);
delegateSpinBox->Editor()->setDecimals(3);
delegateSpinBox->Editor()->setSingleStep(1);
tableViewVariation->setItemDelegateForColumn(4,delegateSpinBox);
To copy to clipboard, switch view to plain text mode
void widgetCouplerVariationList
::OnTableDataChanged(const QModelIndex & index
) {
int col = index.column();
int row = index.row();
switch(col)
{
case 4: // delay
{
double delay = index.data().toDouble();
(*VariationList)[row].delay = delay;
updateModelList();
break;
}
} // end switch
void widgetCouplerVariationList::OnTableDataChanged(const QModelIndex & index)
{
int col = index.column();
int row = index.row();
switch(col)
{
case 4: // delay
{
double delay = index.data().toDouble();
(*VariationList)[row].delay = delay;
updateModelList();
break;
}
} // end switch
To copy to clipboard, switch view to plain text mode
void widgetCouplerVariationList::updateModelList()
{
size_t size = VariationList->size();
if (size > 0)
{
double length = 0;
modelVariationList->blockSignals(true);
// modelVariationList->clear();
modelVariationList->setRowCount(size);
modelVariationList->setColumnCount(5);
int column = 0;
item
= new QStandardItem(QString("lines")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
item
= new QStandardItem(QString("period")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
item
= new QStandardItem(QString("graylevel")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
item
= new QStandardItem(QString("chirp")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
item
= new QStandardItem(QString("delay")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
item
= new QStandardItem(QString("length")); modelVariationList
->setHorizontalHeaderItem
(column, item
); column
++;
tableViewVariation->verticalHeader()->setDefaultSectionSize(tableViewVariation->verticalHeader()->minimumSectionSize()+2);
for (int i = 0; i < (int)size ; i++)
{
double velocity = CouplerSettings.Velocity;
double chirp = (*VariationList)[i].chirp * 1e3;
double delay = (*VariationList)[i].delay;
double phase = (*VariationList)[i].phase;
length = length + velocity*delay*1e-3;
int column = 0;
modelVariationList->setItem(i, column, newItem); column++;
modelVariationList->setItem(i, column, newItem); column++;
//newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
modelVariationList->setItem(i, column, newItem); column++;
modelVariationList->setItem(i, column, newItem); column++;
modelVariationList->setItem(i, column, newItem); column++;
modelVariationList->setItem(i, column, newItem); column++;
}
tableViewVariation->setModel(modelVariationList);
modelVariationList->blockSignals(false);
}
}
void widgetCouplerVariationList::updateModelList()
{
size_t size = VariationList->size();
if (size > 0)
{
double length = 0;
modelVariationList->blockSignals(true);
// modelVariationList->clear();
modelVariationList->setRowCount(size);
modelVariationList->setColumnCount(5);
int column = 0;
QStandardItem *item;
item = new QStandardItem(QString("lines")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
item = new QStandardItem(QString("period")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
item = new QStandardItem(QString("graylevel")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
item = new QStandardItem(QString("chirp")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
item = new QStandardItem(QString("delay")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
item = new QStandardItem(QString("length")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
tableViewVariation->verticalHeader()->setDefaultSectionSize(tableViewVariation->verticalHeader()->minimumSectionSize()+2);
for (int i = 0; i < (int)size ; i++)
{
double velocity = CouplerSettings.Velocity;
double chirp = (*VariationList)[i].chirp * 1e3;
double delay = (*VariationList)[i].delay;
double phase = (*VariationList)[i].phase;
length = length + velocity*delay*1e-3;
int column = 0;
QStandardItem *newItem;
newItem = new QStandardItem(QString("%L1").arg((*VariationList)[i].powerIndex + 1));
modelVariationList->setItem(i, column, newItem); column++;
newItem = new QStandardItem(QString("%L1").arg((*VariationList)[i].period,0,'f',3));
modelVariationList->setItem(i, column, newItem); column++;
newItem = new QStandardItem(QString("%L1").arg(int(phase)));
//newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
modelVariationList->setItem(i, column, newItem); column++;
newItem = new QStandardItem(QString("%L1").arg(chirp,0,'f',4));
modelVariationList->setItem(i, column, newItem); column++;
newItem = new QStandardItem(QString("%L1").arg(delay,0,'f',3));
modelVariationList->setItem(i, column, newItem); column++;
newItem = new QStandardItem(QString("%L1").arg(length,0,'f',3));
modelVariationList->setItem(i, column, newItem); column++;
}
tableViewVariation->setModel(modelVariationList);
modelVariationList->blockSignals(false);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks