View for sensor channel calibrations. More...
#include <projecteditor.h>


Public Member Functions | |
| SensorChannelCalibrationsView (int sens_id, int sens_chan_nr, QWidget *parent=0) | |
| SqlQueryModel * | model () const |
| void | setConstraint (int sens_id, int sens_chan_nr) |
Protected Member Functions | |
| virtual void | setModel (SqlQueryModel *model) |
| virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
View for sensor channel calibrations.
| SensorChannelCalibrationsView::SensorChannelCalibrationsView | ( | int | sens_id, | |
| int | sens_chan_nr, | |||
| QWidget * | parent = 0 | |||
| ) | [inline] |
: QListView(parent) { // setup base query baseQuery = QString("SELECT '#' || row_number() OVER (PARTITION BY scc.sens_id, scc.sens_chan_nr ORDER BY scc.sens_chan_cali_timestamp ASC) || ' @ ' || sens_chan_cali_timestamp || ': ' || replace(sens_chan_cali_formula, '$1', 'RAW') || '' AS Calibrations, sens_chan_cali_id " "FROM tbl_sensor_channel_calibrations scc " "WHERE scc.sens_id = %1 AND scc.sens_chan_nr = %2 " "ORDER BY scc.sens_chan_cali_timestamp DESC"); // pk validity check Q_ASSERT(sens_id > 0); // sens_chan_nr > 0 geldt niet, bijvoorbeeld voor een nieuwe sensor! // setup model setModel(new SqlQueryModel(this)); model()->setDependency("tbl_sensor_channel_calibrations"); // constrain model setConstraint(sens_id, sens_chan_nr); }
| SqlQueryModel* SensorChannelCalibrationsView::model | ( | ) | const [inline] |
Referenced by mouseDoubleClickEvent(), SensorChannelCalibrationsView(), and setConstraint().
{
Q_ASSERT(QListView::model()); // roep hier niet model() --> infinite loop!
Q_ASSERT(dynamic_cast<SqlQueryModel*>(QListView::model()));
return dynamic_cast<SqlQueryModel*>(QListView::model());
}
| virtual void SensorChannelCalibrationsView::mouseDoubleClickEvent | ( | QMouseEvent * | event | ) | [inline, protected, virtual] |
{
QModelIndex idx = indexAt(event->pos());
if (idx.isValid() || model()->rowCount() == 0) {
Q_ASSERT(model()->record().indexOf("sens_chan_cali_id") != -1 || model()->rowCount() == 0); // cannot be found = -1
int sens_chan_cali_id = -1;
if (model()->rowCount() != 0) {
bool ok;
sens_chan_cali_id = model()->index(idx.row(), model()->record().indexOf("sens_chan_cali_id")).data(Qt::DisplayRole).toInt(&ok);
Q_ASSERT(ok);
}
Q_ASSERT(sens_id > 0);
Q_ASSERT(sens_chan_nr > 0); // Dit is de constraint van de DB
CalibrationEditDialog e(sens_id, sens_chan_nr, sens_chan_cali_id, this);
e.exec();
}
}
| void SensorChannelCalibrationsView::setConstraint | ( | int | sens_id, | |
| int | sens_chan_nr | |||
| ) | [inline] |
Referenced by SensorChannelCalibrationsView(), and SensorChannelEditor::SensorChannelEditor().
{
// pk validity check
Q_ASSERT(sens_id > 0);
if (sens_chan_nr <= 0) return;
this->sens_id = sens_id;
this->sens_chan_nr = sens_chan_nr;
model()->setQuery(Database::execStatic(baseQuery.arg(QString::number(sens_id), QString::number(sens_chan_nr))));
if (model()->query().lastError().isValid()) {
qWarning() << "Unable to constrain SensorChannelCalibrationView with " << sens_id << " and " << sens_chan_nr;
model()->clear();
}
}
| virtual void SensorChannelCalibrationsView::setModel | ( | SqlQueryModel * | model | ) | [inline, protected, virtual] |
Referenced by SensorChannelCalibrationsView().
{
QListView::setModel(model);
}
1.7.1