Browse Source

added licensing information

fiffty-50 4 years ago
parent
commit
25afea94b9
18 changed files with 303 additions and 20 deletions
  1. 25 4
      calc.cpp
  2. 7 1
      calc.h
  3. 17 0
      dbairport.cpp
  4. 17 0
      dbairport.h
  5. 17 0
      dbflight.cpp
  6. 17 0
      dbflight.h
  7. 17 0
      dbpilots.cpp
  8. 17 0
      dbpilots.h
  9. 17 0
      dbsettings.cpp
  10. 17 0
      dbsettings.h
  11. 17 0
      dbstat.h
  12. 17 0
      homewidget.cpp
  13. 17 0
      homewidget.h
  14. 17 0
      logbookwidget.cpp
  15. 17 0
      logbookwidget.h
  16. 16 15
      newflight.cpp
  17. 17 0
      settingswidget.cpp
  18. 17 0
      settingswidget.h

+ 25 - 4
calc.cpp

@@ -111,9 +111,6 @@ int calc::string_to_minutes(QString timestring)
  * Radians.
  */
 
-
-
-
 /*!
  * \brief radToDeg Converts radians to degrees
  * \param rad
@@ -169,10 +166,34 @@ double calc::greatCircleDistance(double lat1, double lon1, double lat2, double l
 
     double result = pow(sin(deltalat / 2), 2) +
             cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
-    result = 2 * asin(sqrt(result));
+    result = 2 * asin(sqrt(result));  
     return result;
 }
 
+/*!
+ * \brief calc::greatCircleDistanceBetweenAirports Calculates Great
+ * Circle distance between two coordinates, return in nautical miles.
+ * \param dept ICAO 4-letter Airport Identifier
+ * \param dest ICAO 4-letter Airport Identifier
+ * \return Nautical Miles From Departure to Destination
+ */
+double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
+{
+    double lat1 = degToRad(dbAirport::retreiveIcaoCoordinates(dept)[0]);
+    double lon1 = degToRad(dbAirport::retreiveIcaoCoordinates(dept)[1]);
+    double lat2 = degToRad(dbAirport::retreiveIcaoCoordinates(dest)[0]);
+    double lon2 = degToRad(dbAirport::retreiveIcaoCoordinates(dest)[1]);
+
+    // Haversine Formula
+    double deltalon = lon2 - lon1;
+    double deltalat = lat2 - lat1;
+
+    double result = pow(sin(deltalat / 2), 2) +
+            cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
+    result = 2 * asin(sqrt(result));
+    return radToNauticalMiles(result);
+}
+
 /*!
  * \brief  Calculates a list of points (lat,lon) along the Great Circle between two points.
  * The points are spaced equally, one minute of block time apart.

+ 7 - 1
calc.h

@@ -48,7 +48,13 @@ public:
 
     static double greatCircleDistance(double lat1, double lon1, double lat2, double lon2);
 
-    static QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1, double lon1, double lat2, double lon2, int tblk);
+    static double greatCircleDistanceBetweenAirports(QString dept, QString dest);
+
+    static QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1,
+                                                                    double lon1,
+                                                                    double lat2,
+                                                                    double lon2,
+                                                                    int tblk);
 
     static double solarElevation(QDateTime utc_time_point, double lat, double lon);
 

+ 17 - 0
dbairport.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "dbairport.h"
 #include "dbman.cpp"
 

+ 17 - 0
dbairport.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef DBAIRPORT_H
 #define DBAIRPORT_H
 

+ 17 - 0
dbflight.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "dbflight.h"
 #include "dbman.cpp"
 

+ 17 - 0
dbflight.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef DBFLIGHT_H
 #define DBFLIGHT_H
 

+ 17 - 0
dbpilots.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "dbpilots.h"
 #include "dbman.cpp"
 

+ 17 - 0
dbpilots.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef DBPILOTS_H
 #define DBPILOTS_H
 

+ 17 - 0
dbsettings.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "dbsettings.h"
 #include "dbman.cpp"
 

+ 17 - 0
dbsettings.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef DBSETTINGS_H
 #define DBSETTINGS_H
 

+ 17 - 0
dbstat.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef DBSTAT_H
 #define DBSTAT_H
 

+ 17 - 0
homewidget.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "homewidget.h"
 #include "ui_homewidget.h"
 #include "calc.h"

+ 17 - 0
homewidget.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef HOMEWIDGET_H
 #define HOMEWIDGET_H
 

+ 17 - 0
logbookwidget.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "logbookwidget.h"
 #include "ui_logbookwidget.h"
 #include <QSqlTableModel>

+ 17 - 0
logbookwidget.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef LOGBOOKWIDGET_H
 #define LOGBOOKWIDGET_H
 

+ 16 - 15
newflight.cpp

@@ -204,28 +204,29 @@ QString NewFlight::validateTimeInput(QString userinput)
  */
 void NewFlight::fillExtrasLineEdits()
 {
+    QString blockTime = calc::blocktime(tofb,tonb).toString("hh:mm");
     // SP SE
     // SP ME
     // MP
     // TOTAL
-    if(tofb.isValid() && tonb.isValid()) {
-        ui->totalTimeLineEdit->setText(calc::blocktime(tofb,tonb).toString("hh:mm"));
-    }
+    ui->totalTimeLineEdit->setText(blockTime);
     // IFR
     // VFR
     // Night
-    if(tofb.isValid() && tonb.isValid() && dept.length() == 4 && dest.length() == 4) {
-        QString deptDate = date.toString(Qt::ISODate) + 'T' + tofb.toString("hh:mm");
-        qDebug() << "Departure Date: " << deptDate;
-        QDateTime deptDateTime = QDateTime::fromString(deptDate,"yyyy-MM-ddThh:mm");
-        qDebug() << "Departure DateTime " << deptDateTime;
-        int blocktime = calc::time_to_minutes(calc::blocktime(tofb,tonb));
-        qDebug() << "Blocktime: " << blocktime;
-            //qDebug() << calc::calculateNightTime(dept, dest, deptDateTime, blocktime);
-            //qDebug() << calc::minutes_to_string(QString::number(calc::calculateNightTime(dept, dest, deptDateTime, blocktime)));
-            ui->nightTimeLineEdit->setText(calc::minutes_to_string(QString::number(calc::calculateNightTime(dept, dest, deptDateTime, blocktime))));
-    }
-    // XC
+    QString deptDate = date.toString(Qt::ISODate) + 'T' + tofb.toString("hh:mm");
+    QDateTime deptDateTime = QDateTime::fromString(deptDate,"yyyy-MM-ddThh:mm");
+    int blocktime = calc::time_to_minutes(calc::blocktime(tofb,tonb));
+    qDebug() << "Blocktime: " << blocktime;
+    QString nightTime = calc::minutes_to_string(QString::number(calc::calculateNightTime(dept, dest, deptDateTime, blocktime)));
+    ui->nightTimeLineEdit->setText(nightTime);
+
+    // XC - Cross-country flight, if more than 50nm long
+    if(calc::greatCircleDistanceBetweenAirports(dept,dest) >= 50){
+        qDebug() << "Cross-country Flight: nm = " << calc::greatCircleDistanceBetweenAirports(dept,dest);
+        ui->xcTimeLineEdit->setText(blockTime);
+    }else{
+        ui->xcTimeLineEdit->setText("00:00");
+    }
     // PIC
     // Co-Pilot
     // Dual

+ 17 - 0
settingswidget.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #include "settingswidget.h"
 #include "ui_settingswidget.h"
 #include "dbman.cpp"

+ 17 - 0
settingswidget.h

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *This program is free software: you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
 #ifndef SETTINGSWIDGET_H
 #define SETTINGSWIDGET_H