openPilotLog
dbsummary.h
1 /*
2  *openPilotLog - A FOSS Pilot Logbook Application
3  *Copyright (C) 2020-2022 Felix Turowsky
4  *
5  *This program is free software: you can redistribute it and/or modify
6  *it under the terms of the GNU General Public License as published by
7  *the Free Software Foundation, either version 3 of the License, or
8  *(at your option) any later version.
9  *
10  *This program is distributed in the hope that it will be useful,
11  *but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *GNU General Public License for more details.
14  *
15  *You should have received a copy of the GNU General Public License
16  *along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 #ifndef DBSUMMARY_H
19 #define DBSUMMARY_H
20 
21 #include "src/database/database.h"
22 
23 namespace OPL {
24 
28 enum class DbSummaryKey {
29  total_flights,
30  total_tails,
31  total_pilots,
32  last_flight,
33  total_time,
34 };
35 
44 class DbSummary : public QObject
45 {
46 public:
47  DbSummary() = default;
48 
57  static const QMap<DbSummaryKey, QString> databaseSummary(const QString& db_path);
58 
62  static const QString summaryString(const QString& db_path);
63 
64 private:
65  Q_OBJECT
66  inline const static QString SQLITE_DRIVER = QStringLiteral("QSQLITE");
67 
68 };
69 
70 
71 } // namespace OPL
72 
73 #endif // DBSUMMARY_H
The DbSummary class collects summaries of entries and relevant data from the database.
Definition: dbsummary.h:45
static const QString summaryString(const QString &db_path)
returns a short summary string of the database, containing total time and date of last flight.
Definition: dbsummary.cpp:83
static const QMap< DbSummaryKey, QString > databaseSummary(const QString &db_path)
Return a summary of a database.
Definition: dbsummary.cpp:22
A namespace to collect constants and enums used throughout the application.
Definition: paths.cpp:3
DbSummaryKey
Enumerates the QHash keys used when summarising a database.
Definition: dbsummary.h:28