Files
pilotclient/samples/blacksim/samplesfscommon.cpp
Klaus Basan dbc3339599 Fixes in samples
* removed qSleep / dependency of Qt test libs
* QCoreApplication not required
2014-06-23 01:19:14 +02:00

62 lines
2.0 KiB
C++

/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "samplesfscommon.h"
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
#include "blacksim/fscommon/aircraftindexer.h"
#include <QDebug>
#include <QFuture>
#include <QTextStream>
namespace BlackSimTest
{
/*
* Samples
*/
int CSamplesFsCommon::samples()
{
QTextStream streamIn(stdin);
QTextStream streamOut(stdout);
QString fsxDir = "P:/FlightSimulatorX (MSI)/SimObjects";
streamOut << "Enter FSX directory:" << endl;
streamOut << fsxDir << '\r';
streamOut.flush();
QString input = streamIn.readLine();
if (!input.isEmpty()) fsxDir = input;
streamOut << "d .. direct, b .. background" << endl;
input = streamIn.readLine();
if (!input.startsWith("b"))
{
qDebug() << "reading directly";
BlackSim::FsCommon::CAircraftCfgEntriesList entriesList(fsxDir);
if (entriesList.existsDir())
{
streamOut << "reading " << entriesList.getRootDirectory() << endl;
entriesList.read();
streamOut << "read entries: " << entriesList.size() << endl;
// streamOut << entriesList << endl;
}
}
else
{
qDebug() << "reading in background";
QFuture<int> f = BlackSim::FsCommon::CAircraftIndexer::readInBackground(fsxDir);
do
{
streamOut << ".";
streamOut.flush();
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 * 3);
}
while (!f.isFinished());
streamOut << endl << f.result() << " entries" << endl;
}
streamOut << "-----------------------------------------------" << endl;
return 0;
}
} // namespace