Editor for sensor channels. More...
#include <projecteditor.h>
Public Member Functions | |
SensorChannelEditor (QWidget *parent=0, int sens_id=-1, int sens_chan_nr=-1) | |
Protected Member Functions | |
virtual void | onCurrentRecordChange (int row) |
virtual void | updateButtons () |
virtual void | onNewButtonPress () |
Editor for sensor channels.
SensorChannelEditor::SensorChannelEditor | ( | QWidget * | parent = 0 , |
|
int | sens_id = -1 , |
|||
int | sens_chan_nr = -1 | |||
) | [inline] |
: MappedBaseEditor(parent) { setObjectName("SensorChannelEditor"); setWindowTitle("Sensor channel editor"); //set source setTable("tbl_sensor_channels", "sens_chan_nr", Qt::AscendingOrder, sens_id != -1 ? QString::number(sens_id).prepend("sens_id = ") : QString()); // widget setup QLabel *name = new QLabel("&Name*:", this); QLabel *nr = new QLabel("Numbe&r* (>0):", this); QLabel *caliUnit = new QLabel("&Calibrated unit*:", this); QLabel *desc = new QLabel("&Description:", this); QLineEdit *nameEdit = new QLineEdit(this); QSpinBox *nrEdit = new QSpinBox(this); QComboBox *caliUnitEdit = new QComboBox(this); QTextEdit *descEdit = new QTextEdit(this); name->setBuddy(nameEdit); nr->setBuddy(nrEdit); caliUnit->setBuddy(caliUnitEdit); desc->setBuddy(descEdit); // set calibrations view QLabel *cLabel = new QLabel("&Calibrations:", this); cView = new SensorChannelCalibrationsView(sens_id, sens_chan_nr, this); cView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); cLabel->setBuddy(cView); // add widgets addWidget(name, 0, 0, 1, 1); addWidget(nameEdit, 0, 1, 1, 1, "sens_chan_name"); addWidget(nr, 1, 0, 1, 1); addWidget(nrEdit, 1, 1, 1, 1, "sens_chan_nr"); addWidget(caliUnit, 0, 2, 1, 1); addWidget(caliUnitEdit, 0, 3, 1, 1, QSqlRelation("tbl_units", "unit_id", "unit_symbol"), "sens_chan_cali_unit_id"); addWidget(cLabel, 1, 2, 1, 2); addWidget(cView, 2, 2, 2, 2); addWidget(desc, 2, 0, 1, 1); addWidget(descEdit, 3, 0, 1, 2, "sens_chan_desc", "plainText"); // setup connections connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(updateButtons())); connect(nrEdit, SIGNAL(valueChanged(int)), this, SLOT(updateButtons())); connect(descEdit, SIGNAL(textChanged()), this, SLOT(updateButtons())); connect(caliUnitEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(updateButtons())); // update changes select(); // update mapper to current record if (sens_chan_nr > 0) setCurrent("sens_chan_nr", QVariant::fromValue<int>(sens_chan_nr)); // update cView if (sens_chan_nr > 0) cView->setConstraint(sens_id == -1 ? 0 : sens_id, sens_id == -1 ? 0 : sens_chan_nr); }
virtual void SensorChannelEditor::onCurrentRecordChange | ( | int | row | ) | [inline, protected, virtual] |
Reimplemented from MappedBaseEditor.
{ MappedBaseEditor::onCurrentRecordChange(row); updateSensorChannelView(); }
virtual void SensorChannelEditor::onNewButtonPress | ( | ) | [inline, protected, virtual] |
Reimplemented from MappedBaseEditor.
{ MappedBaseEditor::onNewButtonPress(); bool ok; model()->setData(model()->index(model()->rowCount() - 1, model()->record().indexOf("sens_id")), QVariant::fromValue(model()->filter().remove("sens_id = ").toInt(&ok))); Q_ASSERT(ok); }
virtual void SensorChannelEditor::updateButtons | ( | ) | [inline, protected, virtual] |
Reimplemented from MappedBaseEditor.
Referenced by SensorChannelEditor().
{ MappedBaseEditor::updateButtons(); cView->setDisabled(isCurrentRecordNew() || model()->rowCount() == 0); }