entry_deprecated.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. *openPilot Log - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020 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 ENTRY1_H
  19. #define ENTRY1_H
  20. #include <QCoreApplication>
  21. #include "db.h"
  22. #include "dbinfo.h"
  23. /*!
  24. * \brief The Entry class is the base class for database entries.
  25. * It can be seen as a row in a table within the database.
  26. *
  27. */
  28. class Entry_deprecated
  29. {
  30. public:
  31. Entry_deprecated();
  32. Entry_deprecated(QString table, int row);
  33. Entry_deprecated(QString table, QMap<QString, QString> newData);
  34. QPair <QString, int> position = QPair<QString, int>(); // Position within the database, i.e. <table,row>
  35. QVector <QString> columns = QVector<QString>(); // The columns within the table
  36. QMap <QString, QString> data = QMap<QString, QString>(); // Tha data to fill that table, <column,value>
  37. QString error = QString(); // holds sql errors (if they ocurred)
  38. void setData(QMap<QString, QString> &value);
  39. bool commit();
  40. bool remove();
  41. bool exists();
  42. // Debug functionality
  43. void print();
  44. QString debug();
  45. operator QString()
  46. {
  47. return debug(); //overload for compatibility with qDebug()
  48. }
  49. private:
  50. bool insert();
  51. bool update();
  52. };
  53. #endif // ENTRY_H