2
0

acompletiondata.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "acompletiondata.h"
  2. void ACompletionData::init()
  3. {
  4. // retreive user modifiable data
  5. pilotsIdMap = aDB->getIdMap(DatabaseTarget::PilotNames);
  6. tailsIdMap = aDB->getIdMap(DatabaseTarget::Registrations);
  7. pilotList = aDB->getCompletionList(DatabaseTarget::PilotNames);
  8. tailsList = aDB->getCompletionList(DatabaseTarget::Registrations);
  9. // For tails, also provide completion for registration stripped of the '-' character
  10. QStringList tails_list = aDB->getCompletionList(DatabaseTarget::Registrations);
  11. for (auto &reg : tails_list) {
  12. if(reg.contains(QLatin1Char('-'))) { // check to avoid duplication if reg has no '-'
  13. QString copy = reg;
  14. reg.remove(QLatin1Char('-'));
  15. reg = copy + " (" + reg + QLatin1Char(')');
  16. }
  17. }
  18. tailsList = tails_list;
  19. // retreive default data
  20. airportIcaoIdMap = aDB->getIdMap(DatabaseTarget::AirportIdentifierICAO);
  21. airportIataIdMap = aDB->getIdMap(DatabaseTarget::AirportIdentifierIATA);
  22. airportNameIdMap = aDB->getIdMap(DatabaseTarget::AirportNames);
  23. airportList = aDB->getCompletionList(DatabaseTarget::AirportIdentifier);
  24. current_state = aDB->getUserDataState();
  25. }
  26. void ACompletionData::update()
  27. {
  28. if (current_state != aDB->getUserDataState()) {
  29. // retreive user modifiable data
  30. pilotList = aDB->getCompletionList(DatabaseTarget::PilotNames);
  31. tailsList = aDB->getCompletionList(DatabaseTarget::Registrations);
  32. pilotsIdMap = aDB->getIdMap(DatabaseTarget::PilotNames);
  33. tailsIdMap = aDB->getIdMap(DatabaseTarget::Registrations);
  34. current_state = aDB->getUserDataState();
  35. }
  36. }
  37. void ACompletionData::updateTails()
  38. {
  39. tailsIdMap = aDB->getIdMap(DatabaseTarget::Registrations);
  40. tailsList = aDB->getCompletionList(DatabaseTarget::Registrations);
  41. }
  42. void ACompletionData::updatePilots()
  43. {
  44. pilotsIdMap = aDB->getIdMap(DatabaseTarget::PilotNames);
  45. pilotList = aDB->getCompletionList(DatabaseTarget::PilotNames);
  46. }