2
0

adatabasesetup.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 DBSETUP_H
  19. #define DBSETUP_H
  20. #include <QCoreApplication>
  21. #include <QStringBuilder>
  22. #include <QEventLoop>
  23. #define DATABASE_REVISION 17
  24. const auto TEMPLATE_URL = QStringLiteral("https://raw.githubusercontent.com/fiffty-50/openpilotlog/develop/assets/database/templates/");
  25. /*!
  26. * \brief The DataBaseSetup class is responsible for the inital setup of the database when
  27. * the application is first launched. It creates the database in the specified default
  28. * location and creates all required tables and views. It can also be used to reset the
  29. * database currently used
  30. */
  31. class DataBaseSetup
  32. {
  33. public:
  34. static void debug();
  35. static bool createDatabase();
  36. static bool downloadTemplates();
  37. static bool backupOldData();
  38. static bool fillTemplates();
  39. static bool importDefaultData(bool use_local_data);
  40. static bool resetToDefault();
  41. static bool commitData(QVector<QStringList> from_csv, const QString &table_name);
  42. /*!
  43. * \brief commitDataJson Commits data read from a JSON array to the database.
  44. * \param json_arr
  45. * \param table_name The table that will be written to
  46. */
  47. static bool commitDataJson(const QJsonArray &json_arr, const QString &table_name);
  48. private:
  49. static bool createSchemata(const QStringList &statements);
  50. };
  51. #endif // DBSETUP_H