Browse Source

Fix in decimal time print logic

Formatted print output for decimal time to be limited to 2 decimal digits

Renamed ATime::minutesToString function (overloaded ATime::toString)
Felix 4 years ago
parent
commit
ecf165936b

+ 2 - 2
src/classes/aflightentry.cpp

@@ -42,11 +42,11 @@ const QString AFlightEntry::summary()
     auto space = QStringLiteral(" ");
     flight_summary.append(tableData.value(opl::db::FLIGHTS_DOFT).toString() + space);
     flight_summary.append(tableData.value(opl::db::FLIGHTS_DEPT).toString() + space);
-    flight_summary.append(ATime::minutesToString(
+    flight_summary.append(ATime::toString(
                               tableData.value(opl::db::FLIGHTS_TOFB).toInt(),
                               opl::time::Default)
                           + space);
-    flight_summary.append(ATime::minutesToString(
+    flight_summary.append(ATime::toString(
                               tableData.value(opl::db::FLIGHTS_TONB).toInt(),
                               opl::time::Default)
                           + space);

+ 2 - 3
src/functions/atime.h

@@ -28,9 +28,8 @@ inline const QString toString(const QTime &time, opl::time::FlightTimeFormat for
 /*!
  * \brief Converts an integer of minutes as received from the Datbase to a String
  */
-inline const QString minutesToString(int minutes_in, opl::time::FlightTimeFormat format)
+inline const QString toString(int minutes_in, opl::time::FlightTimeFormat format)
 {
-    DEB << "Hallo";
     switch (format) {
     case opl::time::Default:
     {
@@ -48,7 +47,7 @@ inline const QString minutesToString(int minutes_in, opl::time::FlightTimeFormat
     {
         int hour = minutes_in / 60;
         double minute = (minutes_in % 60) / 60.0;
-        return QString::number(hour+minute);
+        return QString::asprintf("%.2f", (hour+minute));
     }
     default:
         return QString();

+ 2 - 2
src/gui/dialogues/newflightdialog.cpp

@@ -676,8 +676,8 @@ void NewFlightDialog::formFiller()
                 //DEB << "Time Match found: " << key << " - " << leName);
                 auto line_edits = this->findChild<QLineEdit *>(leName);
                 if(line_edits != nullptr){
-                    DEB << "Setting " << line_edits->objectName() << " to " << minutesToString(flightEntry.getData().value(data_key).toInt(), flightTimeFormat);
-                    line_edits->setText(minutesToString(flightEntry.getData().value(data_key).toInt(),
+                    DEB << "Setting " << line_edits->objectName() << " to " << ATime::toString(flightEntry.getData().value(data_key).toInt(), flightTimeFormat);
+                    line_edits->setText(ATime::toString(flightEntry.getData().value(data_key).toInt(),
                                                         flightTimeFormat));
                     line_edits_names.removeOne(leName);
                 }

+ 3 - 0
src/gui/widgets/debugwidget.cpp

@@ -167,6 +167,9 @@ void DebugWidget::on_importCsvPushButton_clicked()
 void DebugWidget::on_debugPushButton_clicked()
 {
     // debug space
+    int mins = 125;
+    DEB << ATime::toString(mins, opl::time::Decimal);
+    DEB << ATime::toString(mins, opl::time::Default);
 }
 
 /* //Comparing two functions template