Selaa lähdekoodia

Small adjustments to AStandardPaths

Implemented suggested changes to creation of the static map of QDirs.

Also cleaned up documentation and added some licensing headers where they were missing.
Felix Turo 4 vuotta sitten
vanhempi
commit
c5cb45c1c1

+ 1 - 2
main.cpp

@@ -41,8 +41,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain(ORGDOMAIN);
     QCoreApplication::setApplicationName(APPNAME);
 
-    AStandardPaths::setup();
-    if(!AStandardPaths::scan_dirs()){
+    if(!AStandardPaths::setup()){
         DEB << "Standard paths not valid.";
         return 1;
     }

+ 0 - 1
mainwindow.cpp

@@ -24,7 +24,6 @@ MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
     , ui(new Ui::MainWindow)
 {
-    ATimer timer(this);
     ui->setupUi(this);
 
     // Set up Toolbar

+ 17 - 0
src/classes/aaircraftentry.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 AAIRCRAFTENTRY_H
 #define AAIRCRAFTENTRY_H
 

+ 32 - 11
src/classes/astandardpaths.cpp

@@ -1,22 +1,43 @@
+/*
+ *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 "src/classes/astandardpaths.h"
 
 QMap<AStandardPaths::Directories, QDir> AStandardPaths::directories;
 
-void AStandardPaths::setup()
+bool AStandardPaths::setup()
 {
     auto data_location = QStandardPaths::AppDataLocation;
-    directories = { // [F]: Dir could be ambiguous since it is very similar to QDir
-        {Database, QDir(QStandardPaths::writableLocation(data_location) + '/')},
-        {Templates, QDir(QStandardPaths::writableLocation(data_location)).filePath(
-         QStringLiteral("templates/"))},
-        {Backup, QDir(QStandardPaths::writableLocation(data_location)).filePath(
-         QStringLiteral("backup/"))}
+    directories = {
+        {Database, QDir(QStandardPaths::writableLocation(data_location))},
+        {Templates, QDir(QStandardPaths::writableLocation(data_location)
+         + QStringLiteral("/templates"))},
+        {Backup, QDir(QStandardPaths::writableLocation(data_location)
+         + QStringLiteral("/backup"))}
     };
+    if (scan_directories())
+        return true;
+
+    return false;
 }
 
-const QDir& AStandardPaths::directory(Directories loc)
+const QDir& AStandardPaths::directory(Directories location)
 {
-    return directories[loc];
+    return directories[location];
 }
 
 const QMap<AStandardPaths::Directories, QDir>& AStandardPaths::allDirectories()
@@ -24,11 +45,11 @@ const QMap<AStandardPaths::Directories, QDir>& AStandardPaths::allDirectories()
     return directories;
 }
 
-bool AStandardPaths::scan_dirs()
+bool AStandardPaths::scan_directories()
 {
     for(const auto& dir : directories){
         if(!dir.exists()) {
-            DEB << dir << "Does not exist. Creating: " << dir.absolutePath();
+            DEB << dir << "Does not exist. Creating:" << dir.absolutePath();
             if (!dir.mkpath(dir.absolutePath()))
                 return false;
         }

+ 40 - 14
src/classes/astandardpaths.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 ASTANDARDPATHS_H
 #define ASTANDARDPATHS_H
 
@@ -9,9 +26,7 @@
 
 /*!
  * \brief The AStandardAppPaths class encapsulates a static QMap holding
- * the standard paths of the application. Setup should be called after
- * `QCoreApplication::setWhateverName`. The paths contained in this class
- * include a trailing seperator and all seperators are platform-agnostic.
+ * the standard paths of the application.
  */
 class AStandardPaths{
 public:
@@ -22,19 +37,30 @@ public:
     };
 private:
     static QMap<Directories, QDir> directories;
+
+    /*!
+     * \brief Ensures the standard app directories exists and creates
+     * them if neccessary.
+     */
+    static bool scan_directories();
+
 public:
-    /// Initialise paths with corresponding StandardLocation paths
-    static void setup();
-
-    // [G]: Subjective opinion:
-    // We should move away from getThis getThat functions.
-    // I believe we can give better namings while avoiding this
-    // OOP cliche of getEverything
-    static const QDir &directory(Directories loc);
-    static const QMap<Directories, QDir> &allDirectories();
+    /*!
+     * \brief Creates and verifies a static map of the standard paths used in the app.
+     */
+    static bool setup();
+
+    /*!
+     * \brief Returns the QDir for the standard directory referenced
+     * by the Directories enum 'loc'
+     */
+    static const QDir &directory(Directories location);
 
-    /// Ensure standard app directories exist, if not mkpath them.
-    static bool scan_dirs();
+    /*!
+     * \brief returns the static map of all standard directories
+     * \return static const QMap<Directories, QDir>
+     */
+    static const QMap<Directories, QDir> &allDirectories();
 };
 
 

+ 17 - 0
src/classes/astyle.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 "astyle.h"
 #include <QStyle>
 #include <QStyleFactory>

+ 17 - 0
src/classes/astyle.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 ASTYLE_H
 #define ASTYLE_H
 #include <QString>

+ 17 - 0
src/database/declarations.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 DECLARATIONS_H
 #define DECLARATIONS_H
 

+ 17 - 0
src/functions/acalc.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 "acalc.h"
 #include "src/testing/adebug.h"
 #include "src/database/adatabase.h"

+ 17 - 0
src/functions/acalc.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 ACALC_H
 #define ACALC_H
 

+ 17 - 0
src/functions/adatetime.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 ADATETIME_H
 #define ADATETIME_H
 #include <QtCore>

+ 17 - 0
src/functions/areadcsv.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 "areadcsv.h"
 
 /*!

+ 17 - 0
src/functions/areadcsv.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 AREADCSV_H
 #define AREADCSV_H
 

+ 17 - 0
src/functions/atime.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 ATIME_H
 #define ATIME_H
 

+ 17 - 0
src/gui/dialogues/firstrundialog.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 "firstrundialog.h"
 #include "ui_firstrundialog.h"
 #include "src/testing/adebug.h"

+ 17 - 0
src/gui/dialogues/firstrundialog.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 FIRSTRUNDIALOG_H
 #define FIRSTRUNDIALOG_H
 

+ 18 - 3
src/gui/widgets/debugwidget.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 "debugwidget.h"
 #include "ui_debugwidget.h"
 #include "src/classes/astandardpaths.h"
@@ -145,7 +162,7 @@ void DebugWidget::on_importCsvPushButton_clicked()
 {
     ATimer timer(this);
     auto file = QFileInfo(ui->importCsvLineEdit->text());
-    DEB << "File exists/is file: " << file.exists() << file.isFile() << " Path: " << file.absoluteFilePath();
+    DEB << "File exists/is file:" << file.exists() << file.isFile() << " Path:" << file.absoluteFilePath();
 
     if (file.exists() && file.isFile()) {
 
@@ -169,8 +186,6 @@ void DebugWidget::on_debugPushButton_clicked()
 {
     // debug space
     //ASettings::write(ASettings::Setup::SetupComplete, false);
-    ASettings::write(ASettings::FlightLogging::Approach, 5);
-    DEB << ASettings::read(ASettings::FlightLogging::Approach);
 
 }
 

+ 17 - 0
src/gui/widgets/debugwidget.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 DEBUGWIDGET_H
 #define DEBUGWIDGET_H
 

+ 17 - 0
src/gui/widgets/totalswidget.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 "totalswidget.h"
 #include "ui_totalswidget.h"
 #include "src/testing/adebug.h"

+ 17 - 0
src/gui/widgets/totalswidget.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 TOTALSWIDGET_H
 #define TOTALSWIDGET_H
 

+ 17 - 0
src/oplconstants.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 OPLCONSTANTS_H
 #define OPLCONSTANTS_H