currencyentry.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2023 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. #include "currencyentry.h"
  19. namespace OPL {
  20. CurrencyEntry::CurrencyEntry(int row_id, const RowData_T &row_data)
  21. : Row(DbTable::Currencies, row_id, row_data)
  22. {}
  23. const QString CurrencyEntry::getTableName() const
  24. {
  25. return TABLE_NAME;
  26. }
  27. void CurrencyEntry::setName(const QString &displayName)
  28. {
  29. auto data = getData();
  30. data.insert(NAME, displayName);
  31. setData(data);
  32. }
  33. const QString CurrencyEntry::getName() const
  34. {
  35. return getData().value(NAME).toString();
  36. }
  37. void CurrencyEntry::setExpiryDate(const Date &date)
  38. {
  39. auto data = getData();
  40. data.insert(EXPIRYDATE, date.toJulianDay());
  41. setData(data);
  42. }
  43. const Date CurrencyEntry::getExpiryDate(const OPL::DateTimeFormat &format) const
  44. {
  45. return OPL::Date(getData().value(EXPIRYDATE).toInt(), format);
  46. }
  47. } // namespace OPL