|
@@ -8166,10 +8166,8 @@ void ZoomLog::newMeasurement(Measurement measure, int tempcolumn)
|
8166
|
8166
|
if(measure.time().second() !=
|
8167
|
8167
|
lastMeasurement.value(tempcolumn).time().second())
|
8168
|
8168
|
{
|
8169
|
|
- Measurement adjusted(measure.temperature(),
|
8170
|
|
- QTime(0, measure.time().minute(),
|
8171
|
|
- measure.time().second(), 0),
|
8172
|
|
- measure.scale());
|
|
8169
|
+ Measurement adjusted = measure;
|
|
8170
|
+ adjusted.setTime(QTime(0, measure.time().minute(), measure.time().second(), 0));
|
8173
|
8171
|
model_1s->newMeasurement(adjusted, tempcolumn);
|
8174
|
8172
|
if(adjusted.time().second() % 5 == 0)
|
8175
|
8173
|
{
|
|
@@ -8238,7 +8236,9 @@ if(lastMeasurement[tempcolumn].time() < measure.time())
|
8238
|
8236
|
}
|
8239
|
8237
|
for(int i = 0; i < timelist.size(); i++)
|
8240
|
8238
|
{
|
8241
|
|
- newMeasurement(Measurement(measure.temperature(), timelist[i], measure.scale()), tempcolumn);
|
|
8239
|
+ Measurement synthesized = measure;
|
|
8240
|
+ synthesized.setTime(timelist[i]);
|
|
8241
|
+ newMeasurement(synthesized, tempcolumn);
|
8242
|
8242
|
}
|
8243
|
8243
|
}
|
8244
|
8244
|
|
|
@@ -8279,12 +8279,13 @@ if(currentColumnSet.contains(tempcolumn))
|
8279
|
8279
|
{
|
8280
|
8280
|
if(measure.time() > lastMeasurement.value(replicationcolumn).time())
|
8281
|
8281
|
{
|
8282
|
|
- Measurement synthetic(lastMeasurement.value(replicationcolumn).temperature(),
|
8283
|
|
- measure.time());
|
|
8282
|
+ Measurement synthetic = lastMeasurement.value(replicationcolumn);
|
|
8283
|
+ synthetic.setTime(measure.time());
|
8284
|
8284
|
model_ms->newMeasurement(synthetic, replicationcolumn);
|
8285
|
8285
|
if(synthetic.time().second() != lastMeasurement.value(replicationcolumn).time().second())
|
8286
|
8286
|
{
|
8287
|
|
- Measurement adjusted(synthetic.temperature(), QTime(0, synthetic.time().minute(), synthetic.time().second(), 0));
|
|
8287
|
+ Measurement adjusted = synthetic;
|
|
8288
|
+ synthetic.setTime(QTime(0, synthetic.time().minute(), synthetic.time().second(), 0));
|
8288
|
8289
|
model_1s->newMeasurement(adjusted, replicationcolumn);
|
8289
|
8290
|
if(adjusted.time().second() % 5 == 0)
|
8290
|
8291
|
{
|
|
@@ -9052,7 +9053,7 @@ if((*i)->size() < tempcolumn + 1)
|
9052
|
9053
|
(*i)->append(QVariant());
|
9053
|
9054
|
}
|
9054
|
9055
|
}
|
9055
|
|
-(*i)->replace(tempcolumn, measure.temperature());
|
|
9056
|
+(*i)->replace(tempcolumn, measure);
|
9056
|
9057
|
lastInsertion = i;
|
9057
|
9058
|
emit dataChanged(createIndex(insertion, tempcolumn),
|
9058
|
9059
|
createIndex(insertion, tempcolumn));
|
|
@@ -9070,7 +9071,7 @@ for(int j = 0; j < tempcolumn + 1; j++)
|
9070
|
9071
|
{
|
9071
|
9072
|
newEntry->append(QVariant());
|
9072
|
9073
|
}
|
9073
|
|
-newEntry->replace(tempcolumn, measure.temperature());
|
|
9074
|
+newEntry->replace(tempcolumn, measure);
|
9074
|
9075
|
lastInsertion = entries->insert(i, newEntry);
|
9075
|
9076
|
endInsertRows();
|
9076
|
9077
|
lastTemperature->insert(tempcolumn, insertion);
|
|
@@ -9161,6 +9162,13 @@ recording a stream of measurements, either from the |DAQ| or when loading saved
|
9161
|
9162
|
data, there are also cases where we'@q'@>d like to edit the data in the model
|
9162
|
9163
|
directly from the table view. For this, we need to reimplement |setData()|.
|
9163
|
9164
|
|
|
9165
|
+Note that editing from the |ZoomLog| has never been supported. While stream
|
|
9166
|
+inserted data currently preserves all properties of inserted measurements,
|
|
9167
|
+using |setData| it is possible to insert a numeric value as if it were a
|
|
9168
|
+measurement. Such an entry will not have any additional information associated
|
|
9169
|
+and cannot be expected to exhibit behavior implemented through the use of that
|
|
9170
|
+extra information.
|
|
9171
|
+
|
9164
|
9172
|
Very little input checking is done here. Editable views may want to place
|
9165
|
9173
|
delegates\nfnote{Qt 4.4: Delegate Classes\par\indent\hbox{%
|
9166
|
9174
|
\pdfURL{http://doc.trolltech.com/4.4/model-view-delegate.html}{%
|
|
@@ -9409,33 +9417,21 @@ QVariant MeasurementModel::data(const QModelIndex &index, int role) const@/
|
9409
|
9417
|
{
|
9410
|
9418
|
return QVariant();
|
9411
|
9419
|
}
|
9412
|
|
- if(controlColumns->contains(index.column()))
|
|
9420
|
+ Measurement v = row->at(index.column());
|
|
9421
|
+ if(v.scale() == Units::Unitless)
|
9413
|
9422
|
{
|
9414
|
|
- if(controlColumns->value(index.column()) == true)
|
9415
|
|
- {
|
9416
|
|
- return QVariant(QString("%1").arg(QVariant(row->at(index.column()).toInt()).toString()));
|
9417
|
|
- }
|
|
9423
|
+ return QVariant(QString("%1").arg(v.temperature()));
|
9418
|
9424
|
}
|
9419
|
|
- switch(unit)
|
|
9425
|
+ else
|
9420
|
9426
|
{
|
9421
|
|
- case Units::Fahrenheit:
|
9422
|
|
- return QVariant(row->at(index.column()).toString());
|
9423
|
|
- break;
|
9424
|
|
- case Units::Celsius:
|
9425
|
|
- return QVariant((row->at(index.column()).toDouble() -
|
9426
|
|
- 32) * 5 / 9);
|
9427
|
|
- break;
|
9428
|
|
- case Units::Kelvin:
|
9429
|
|
- return QVariant((row->at(index.column()).toDouble() +
|
9430
|
|
- 459.67) * 5 / 9);
|
9431
|
|
- break;
|
9432
|
|
- case Units::Rankine:
|
9433
|
|
- return QVariant(row->at(index.column()).toDouble() +
|
9434
|
|
- 459.67);
|
9435
|
|
- break;
|
9436
|
|
- default:
|
9437
|
|
- return QVariant(row->at(index.column()).toString());
|
9438
|
|
- break;
|
|
9427
|
+ if(v.contains("relative"))
|
|
9428
|
+ {
|
|
9429
|
+ if(v.value("relative") == true)
|
|
9430
|
+ {
|
|
9431
|
+ return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.temperature(), v.scale, unit)));
|
|
9432
|
+ }
|
|
9433
|
+ }
|
|
9434
|
+ return QVariant(QString("%1").arg(Units::convertTemperature(v.temperature(), v.scale(), unit)));
|
9439
|
9435
|
}
|
9440
|
9436
|
}
|
9441
|
9437
|
return QVariant(row->at(index.column()).toString());
|
|
@@ -9468,7 +9464,7 @@ an index. In the case of this model, each index is treated in the same way.
|
9468
|
9464
|
|
9469
|
9465
|
It may be a good idea to extend the model class to allow models that can be
|
9470
|
9466
|
edited through the view such as the table view presented in the |LogEditWindow|
|
9471
|
|
-and models that probably shouldn't be edited in the view, such as the models
|
|
9467
|
+and models that probably shouldn'@q'@>t be edited in the view, such as the models
|
9472
|
9468
|
managed by |ZoomLog|. This could be done by subclassing and only reimplementing
|
9473
|
9469
|
this method. Otherwise, a new method to specify that the user should not edit
|
9474
|
9470
|
the model could be provided and a flag would be checked here.
|
|
@@ -9484,7 +9480,7 @@ Qt::ItemFlags MeasurementModel::flags(const QModelIndex &index) const@/
|
9484
|
9480
|
return 0;
|
9485
|
9481
|
}
|
9486
|
9482
|
|
9487
|
|
-@ Much of the way models are interacted with in Qt's model view architecture is
|
|
9483
|
+@ Much of the way models are interacted with in Qt'@q'@>s model view architecture is
|
9488
|
9484
|
through model indices. The model is responsible for creating these indices from
|
9489
|
9485
|
row column pairs.
|
9490
|
9486
|
|