Neal Wilson vor 11 Jahren
Ursprung
Commit
f494c962c7
1 geänderte Dateien mit 19 neuen und 28 gelöschten Zeilen
  1. 19
    28
      src/typica.w

+ 19
- 28
src/typica.w Datei anzeigen

@@ -8063,7 +8063,7 @@ class ZoomLog : public QTableView@/
8063 8063
 		bool saveXML(QIODevice *device);
8064 8064
 		bool saveCSV(QIODevice *device);
8065 8065
 		QString lastTime(int series);
8066
-		@[Q_INVOKABLE@,@, int displayUnits()@];@t\2\2@>@/
8066
+		@[Q_INVOKABLE@,@, Units::Unit displayUnits()@];@t\2\2@>@/
8067 8067
 	@[public slots@]:@/
8068 8068
 		void setVisible(bool visibility);
8069 8069
 		void setHeaderData(int section, QString text);
@@ -8081,7 +8081,7 @@ class ZoomLog : public QTableView@/
8081 8081
 		void addOutputTemperatureColumn(int column);
8082 8082
 		void addOutputAnnotationColumn(int column);
8083 8083
 		void clearOutputColumns();
8084
-		void setDisplayUnits(int scale);
8084
+		void setDisplayUnits(Units::Unit scale);
8085 8085
 		void addToCurrentColumnSet(int column);
8086 8086
 		void clearCurrentColumnSet();@/
8087 8087
 	protected:@/
@@ -8380,10 +8380,10 @@ users will never notice this.
8380 8380
 @<ZoomLog Implementation@>=
8381 8381
 bool ZoomLog::saveXML(QIODevice *device)
8382 8382
 {
8383
-	int prevUnits = model_ms->displayUnits();
8384
-	if(prevUnits != 10144)
8383
+	Units::Unit prevUnits = model_ms->displayUnits();
8384
+	if(prevUnits != Units::Fahrenheit)
8385 8385
 	{
8386
-		model_ms->setDisplayUnits(10144);
8386
+		model_ms->setDisplayUnits(Units::Fahrenheit);
8387 8387
 	}
8388 8388
 	XMLOutput writer(model_ms, device, 0);
8389 8389
 	int c;
@@ -8398,7 +8398,7 @@ bool ZoomLog::saveXML(QIODevice *device)
8398 8398
 		                                     toString(), c);
8399 8399
 	}
8400 8400
 	bool retval = writer.output();
8401
-	if(prevUnits != 10144)
8401
+	if(prevUnits != Units::Fahrenheit)
8402 8402
 	{
8403 8403
 		model_ms->setDisplayUnits(prevUnits);
8404 8404
 	}
@@ -8481,7 +8481,7 @@ so, we simply tell all of the models which unit to provide data in. It is also
8481 8481
 possible to obtain the currently selected unit.
8482 8482
 
8483 8483
 @<ZoomLog Implementation@>=
8484
-void ZoomLog::setDisplayUnits(int scale)
8484
+void ZoomLog::setDisplayUnits(Units::Unit scale)
8485 8485
 {
8486 8486
 	model_ms->setDisplayUnits(scale);
8487 8487
 	model_1s->setDisplayUnits(scale);
@@ -8492,7 +8492,7 @@ void ZoomLog::setDisplayUnits(int scale)
8492 8492
 	model_1m->setDisplayUnits(scale);
8493 8493
 }
8494 8494
 
8495
-int ZoomLog::displayUnits()
8495
+Units::Unit ZoomLog::displayUnits()
8496 8496
 {
8497 8497
 	return model_ms->displayUnits();
8498 8498
 }
@@ -8747,22 +8747,13 @@ class MeasurementList;@/
8747 8747
 class MeasurementModel : public QAbstractItemModel@/
8748 8748
 {@t\1@>@/
8749 8749
 	Q_OBJECT@;
8750
-	Q_ENUMS(DisplayUnits);
8751
-	int unit;
8750
+	Units::Unit unit;
8752 8751
 	QList<MeasurementList *> *entries;
8753 8752
 	QStringList *hData;
8754 8753
 	int colcount;
8755 8754
 	QHash<int, int> *lastTemperature;
8756 8755
 	QList<MeasurementList *>::iterator@, lastInsertion;
8757 8756
 	public:@/
8758
-		enum DisplayUnits
8759
-		{
8760
-			Auto = -1,
8761
-			Fahrenheit = 10144,
8762
-			Celsius = 10143,
8763
-			Kelvin = 10325,
8764
-			Rankine = 10145
8765
-		};
8766 8757
 		MeasurementModel(QObject *parent = NULL);
8767 8758
 		~MeasurementModel();
8768 8759
 		int rowCount(const QModelIndex &parent = QModelIndex()) const;
@@ -8778,13 +8769,13 @@ class MeasurementModel : public QAbstractItemModel@/
8778 8769
 		QModelIndex index(int row, int column,
8779 8770
 							const QModelIndex &parent = QModelIndex()) const;
8780 8771
 		QModelIndex parent(const QModelIndex &index) const;
8781
-		int displayUnits();@/
8772
+		Units::Unit displayUnits();@/
8782 8773
 	@t\4@>public slots@t\kern-3pt@>:@/
8783 8774
 		void newMeasurement(Measurement measure, int tempcolumn);
8784 8775
 		void newAnnotation(QString annotation, int tempcolumn,
8785 8776
 							int annotationColumn);
8786 8777
 		void clear();
8787
-		void setDisplayUnits(int scale);
8778
+		void setDisplayUnits(Units::Unit scale);
8788 8779
 	signals:@/
8789 8780
 		void rowChanged(int);@t\2@>@/
8790 8781
 }@t\kern-3pt@>;
@@ -9193,7 +9184,7 @@ constructor.
9193 9184
 
9194 9185
 @<MeasurementModel Implementation@>=
9195 9186
 MeasurementModel::MeasurementModel(QObject *parent) : QAbstractItemModel(parent),
9196
-	unit(Fahrenheit), hData(new QStringList),
9187
+	unit(Units::Fahrenheit), hData(new QStringList),
9197 9188
 	lastTemperature(new QHash<int, int>)@/
9198 9189
 {
9199 9190
 	colcount = 1;
@@ -9284,14 +9275,14 @@ performed before sending that information to the view. Another method is
9284 9275
 available to request a number identifyin the currently displayed units.
9285 9276
 
9286 9277
 @<MeasurementModel Implementation@>=
9287
-void MeasurementModel::setDisplayUnits(int scale)
9278
+void MeasurementModel::setDisplayUnits(Units::Unit scale)
9288 9279
 {
9289 9280
 	beginResetModel();
9290 9281
 	unit = scale;
9291 9282
 	endResetModel();
9292 9283
 }
9293 9284
 
9294
-int MeasurementModel::displayUnits()
9285
+Units::Unit MeasurementModel::displayUnits()
9295 9286
 {
9296 9287
 	return unit;
9297 9288
 }
@@ -9336,23 +9327,23 @@ QVariant MeasurementModel::data(const QModelIndex &index, int role) const@/
9336 9327
 				}
9337 9328
 				switch(unit)
9338 9329
 				{
9339
-					case Auto:
9340
-					case Fahrenheit:
9330
+					case Units::Fahrenheit:
9341 9331
 						return QVariant(row->at(index.column()).toString());
9342 9332
 						break;
9343
-					case Celsius:
9333
+					case Units::Celsius:
9344 9334
 						return QVariant((row->at(index.column()).toDouble() -
9345 9335
 						                32) * 5 / 9);
9346 9336
 						break;
9347
-					case Kelvin:
9337
+					case Units::Kelvin:
9348 9338
 						return QVariant((row->at(index.column()).toDouble() +
9349 9339
 						                459.67) * 5 / 9);
9350 9340
 						break;
9351
-					case Rankine:
9341
+					case Units::Rankine:
9352 9342
 						return QVariant(row->at(index.column()).toDouble() +
9353 9343
 						                459.67);
9354 9344
 						break;
9355 9345
 					default:
9346
+						return QVariant(row->at(index.column()).toString());
9356 9347
 						break;
9357 9348
 				}
9358 9349
 			}

Laden…
Abbrechen
Speichern