Ejemplo n.º 1
0
void
MetarListModel::clear() {
  beginRemoveRows(QModelIndex(), 0, __metarList.size() - 1);
  __metarList.clear();
  endRemoveRows();
  emit newMetarsAvailable();
}
Ejemplo n.º 2
0
MetarsWindow::MetarsWindow(QWidget* _parent) :
    QWidget(_parent),
    __awaited("") {

  setupUi(this);

  UserInterface::setWindowPosition(this);

  __httpHandler = new HttpHandler();

  __metarsHandler = new MetarListModel(__httpHandler);

  connect(FetchButton,      SIGNAL(clicked()),
          this,             SLOT(metarRequested()));
  connect(RefreshAllButton, SIGNAL(clicked()),
          __metarsHandler,  SLOT(updateAll()));
  connect(ClearButton,      SIGNAL(clicked()),
          __metarsHandler,  SLOT(clear()));
  connect(MetarICAO,        SIGNAL(textChanged(const QString&)),
          this,             SLOT(__handleTextChange(const QString&)));
  connect(__metarsHandler,  SIGNAL(newMetarsAvailable()),
          this,             SLOT(__handleNewMetars()));
  
  FetchButton->setEnabled(false);
  MetarsDisplay->setModel(__metarsHandler);
  
  MetarICAO->setFocus();
}
Ejemplo n.º 3
0
void
MetarListModel::__gotMetar(const QString& _metar) {
  QString metar = _metar.simplified();

  if (metar.isEmpty())
    return;

  if (metar.contains(METAR_NO_AVAIL)) {
    emit noMetar(__requests.dequeue());
    return;
  }

  QString oneMetar;

for (QString & word: metar.split(' ')) {
    if (__matches(word)) {
      if (!oneMetar.isEmpty())
        __addMetar(oneMetar);

      oneMetar.clear();
    }

    oneMetar.append(word + " ");
  }

  if (!oneMetar.isEmpty())
    __addMetar(oneMetar);

  __requests.dequeue();

  emit newMetarsAvailable();
}
Ejemplo n.º 4
0
AirportDetailsWindow::AirportDetailsWindow(QWidget* _parent) :
    QWidget(_parent),
    __currentICAO("") {
    setupUi(this);
    UserInterface::setWindowPosition(this);

    connect(MetarListModel::getSingletonPtr(),  SIGNAL(newMetarsAvailable()),
            this,                               SLOT(updateMetar()));

    connect(MetarListModel::getSingletonPtr(),  SIGNAL(noMetar(QString)),
            this,                               SLOT(updateMetar(QString)));

    connect(VatsinatorApplication::getSingletonPtr(), SIGNAL(dataUpdated()),
            this,                                     SLOT(__updateData()));

    connect(ShowButton, SIGNAL(clicked()),
            this,       SLOT(__handleShowClicked()));
}