mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
refs #354, initial cleanup of cfg entries samples / code before adding new functionality
* fixed styles such as copyright headers * use text stream instead of qDebug() for output * int instead of qint * misc. smaller tweaks * extended the JSON example (special chars). JSON might be used to "cache" the FSX entries
This commit is contained in:
@@ -84,9 +84,18 @@ namespace BlackMiscTest
|
|||||||
stations.clear();
|
stations.clear();
|
||||||
stations.convertFromJson(json);
|
stations.convertFromJson(json);
|
||||||
qDebug() << stations;
|
qDebug() << stations;
|
||||||
|
qDebug() << "------- Enter -----";
|
||||||
cin.readLine();
|
cin.readLine();
|
||||||
|
|
||||||
|
// testing escaping special characters
|
||||||
|
CUser specialCharacters("123456", "With quote \"", "With double quote\"\"", "foobar");
|
||||||
|
json = specialCharacters.toJson();
|
||||||
|
doc.setObject(json);
|
||||||
|
qDebug() << doc.toJson(QJsonDocument::Indented);
|
||||||
|
|
||||||
qDebug() << "------- Enter ---------------------------------";
|
qDebug() << "------- Enter ---------------------------------";
|
||||||
|
cin.readLine();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "blacksim/blacksimfreefunctions.h"
|
#include "blacksim/blacksimfreefunctions.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
@@ -12,40 +16,49 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(argc);
|
||||||
|
Q_UNUSED(argv);
|
||||||
|
|
||||||
QTextStream streamIn(stdin);
|
QTextStream streamIn(stdin);
|
||||||
|
QTextStream streamOut(stdout);
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
BlackSim::registerMetadata();
|
BlackSim::registerMetadata();
|
||||||
|
|
||||||
qDebug() << "Run samples:";
|
streamOut << "Run samples:" << endl;
|
||||||
qDebug() << "1 .. FS common";
|
streamOut << "1 .. FS common" << endl;
|
||||||
qDebug() << "2 .. FSX";
|
streamOut << "2 .. FSX" << endl;
|
||||||
qDebug() << "3 .. Mappings";
|
streamOut << "3 .. Mappings" << endl;
|
||||||
qDebug() << "x .. exit";
|
streamOut << "x .. exit" << endl;
|
||||||
QString i = streamIn.readLine().toLower().trimmed();
|
QString i = streamIn.readLine().toLower().trimmed();
|
||||||
|
|
||||||
|
QTime t;
|
||||||
|
t.start();
|
||||||
if (i.startsWith("1"))
|
if (i.startsWith("1"))
|
||||||
{
|
{
|
||||||
BlackSimTest::CSamplesFsCommon::samples();
|
BlackSimTest::CSamplesFsCommon::samples(streamOut, streamIn);
|
||||||
}
|
}
|
||||||
else if (i.startsWith("2"))
|
else if (i.startsWith("2"))
|
||||||
{
|
{
|
||||||
BlackSimTest::CSamplesFsx::samples();
|
BlackSimTest::CSamplesFsx::samples(streamOut);
|
||||||
}
|
}
|
||||||
else if (i.startsWith("3"))
|
else if (i.startsWith("3"))
|
||||||
{
|
{
|
||||||
BlackSimTest::CSamplesModelMapping::samples();
|
BlackSimTest::CSamplesModelMapping::samples(streamOut);
|
||||||
}
|
}
|
||||||
else if (i.startsWith("x"))
|
else if (i.startsWith("x"))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCoreApplication a(argc, argv);
|
streamOut << "time elapsed: " << t.elapsed() << "ms" << endl;
|
||||||
return a.exec();
|
streamOut << "press key to exit" << endl;
|
||||||
|
streamIn.readLine();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "samplesfscommon.h"
|
#include "samplesfscommon.h"
|
||||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||||
@@ -9,7 +13,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
#include <QTime>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
using namespace BlackSim::FsCommon;
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
{
|
{
|
||||||
@@ -17,11 +25,10 @@ namespace BlackSimTest
|
|||||||
/*
|
/*
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int CSamplesFsCommon::samples()
|
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||||
{
|
{
|
||||||
QTextStream streamIn(stdin);
|
// QString fsxDir = "P:/FlightSimulatorX (MSI)/SimObjects";
|
||||||
QTextStream streamOut(stdout);
|
QString fsxDir = "P:/Temp/SimObjects";
|
||||||
QString fsxDir = "P:/FlightSimulatorX (MSI)/SimObjects";
|
|
||||||
streamOut << "Enter FSX directory:" << endl;
|
streamOut << "Enter FSX directory:" << endl;
|
||||||
streamOut << fsxDir << '\r';
|
streamOut << fsxDir << '\r';
|
||||||
streamOut.flush();
|
streamOut.flush();
|
||||||
@@ -31,25 +38,49 @@ namespace BlackSimTest
|
|||||||
input = streamIn.readLine();
|
input = streamIn.readLine();
|
||||||
if (!input.startsWith("b"))
|
if (!input.startsWith("b"))
|
||||||
{
|
{
|
||||||
qDebug() << "reading directly";
|
streamOut << "reading directly" << endl;
|
||||||
BlackSim::FsCommon::CAircraftCfgEntriesList entriesList(fsxDir);
|
CAircraftCfgEntriesList entriesList(fsxDir);
|
||||||
if (entriesList.existsDir())
|
if (entriesList.existsDir())
|
||||||
{
|
{
|
||||||
|
QTime time;
|
||||||
|
time.start();
|
||||||
streamOut << "reading " << entriesList.getRootDirectory() << endl;
|
streamOut << "reading " << entriesList.getRootDirectory() << endl;
|
||||||
entriesList.read();
|
entriesList.read();
|
||||||
streamOut << "read entries: " << entriesList.size() << endl;
|
streamOut << "read entries: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||||
// streamOut << entriesList << endl;
|
|
||||||
|
QJsonDocument doc(entriesList.toJson());
|
||||||
|
QByteArray jsonArray(doc.toJson());
|
||||||
|
streamOut << "write JSON array with size " << jsonArray.size() << endl;
|
||||||
|
QTemporaryFile tempFile;
|
||||||
|
tempFile.open();
|
||||||
|
tempFile.write(jsonArray);
|
||||||
|
tempFile.close();
|
||||||
|
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << endl;
|
||||||
|
|
||||||
|
// re-read
|
||||||
|
tempFile.open();
|
||||||
|
jsonArray = tempFile.readAll();
|
||||||
|
doc = QJsonDocument::fromJson(jsonArray);
|
||||||
|
entriesList.clear();
|
||||||
|
entriesList.convertFromJson(doc.object());
|
||||||
|
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
||||||
|
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||||
|
tempFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "reading in background";
|
streamOut << "reading in background" << endl;
|
||||||
QFuture<int> f = BlackSim::FsCommon::CAircraftIndexer::readInBackground(fsxDir);
|
QFuture<int> f = BlackSim::FsCommon::CAircraftIndexer::readInBackground(fsxDir);
|
||||||
|
int i = 0;
|
||||||
do
|
do
|
||||||
|
{
|
||||||
|
if (i % 20 == 0)
|
||||||
{
|
{
|
||||||
streamOut << ".";
|
streamOut << ".";
|
||||||
streamOut.flush();
|
streamOut.flush();
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 * 3);
|
}
|
||||||
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 * 5);
|
||||||
}
|
}
|
||||||
while (!f.isFinished());
|
while (!f.isFinished());
|
||||||
streamOut << endl << f.result() << " entries" << endl;
|
streamOut << endl << f.result() << " entries" << endl;
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKSIMTEST_SAMPLESFSCOMMON_H
|
#ifndef BLACKSIMTEST_SAMPLESFSCOMMON_H
|
||||||
#define BLACKSIMTEST_SAMPLESFSCOMMON_H
|
#define BLACKSIMTEST_SAMPLESFSCOMMON_H
|
||||||
|
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
{
|
{
|
||||||
/*!
|
//! Samples for FsCommon classes
|
||||||
* \brief Samples for FsCommon classes
|
|
||||||
*/
|
|
||||||
class CSamplesFsCommon
|
class CSamplesFsCommon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Run the samples
|
||||||
* \brief Run the samples
|
static int samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||||
*/
|
|
||||||
static int samples();
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "samplesfsx.h"
|
#include "samplesfsx.h"
|
||||||
#include "blacksim/blacksimfreefunctions.h"
|
#include "blacksim/blacksimfreefunctions.h"
|
||||||
@@ -16,12 +20,12 @@ namespace BlackSimTest
|
|||||||
/*
|
/*
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int CSamplesFsx::samples()
|
int CSamplesFsx::samples(QTextStream &streamOut)
|
||||||
{
|
{
|
||||||
BlackSim::registerMetadata();
|
BlackSim::registerMetadata();
|
||||||
qDebug() << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED);
|
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED) << endl;
|
||||||
qDebug() << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION);
|
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION) << endl;
|
||||||
qDebug() << CSimConnectUtilities::simConnectSurfaceTypeToString(CSimConnectUtilities::Bituminus);
|
streamOut << CSimConnectUtilities::simConnectSurfaceTypeToString(CSimConnectUtilities::Bituminus) << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKSIMTEST_SAMPLESFSX_H
|
#ifndef BLACKSIMTEST_SAMPLESFSX_H
|
||||||
#define BLACKSIMTEST_SAMPLESFSX_H
|
#define BLACKSIMTEST_SAMPLESFSX_H
|
||||||
|
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
{
|
{
|
||||||
/*!
|
//! Samples for FSX classes
|
||||||
* \brief Samples for FSX classes
|
|
||||||
*/
|
|
||||||
class CSamplesFsx
|
class CSamplesFsx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Run the samples
|
||||||
* \brief Run the samples
|
static int samples(QTextStream &streamOut);
|
||||||
*/
|
|
||||||
static int samples();
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "samplesmodelmapping.h"
|
#include "samplesmodelmapping.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
@@ -18,7 +22,7 @@ namespace BlackSimTest
|
|||||||
/*
|
/*
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int CSamplesModelMapping::samples()
|
int CSamplesModelMapping::samples(QTextStream &streamOut)
|
||||||
{
|
{
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
BlackSim::registerMetadata();
|
BlackSim::registerMetadata();
|
||||||
@@ -26,10 +30,10 @@ namespace BlackSimTest
|
|||||||
CVPilotModelMappings cvm;
|
CVPilotModelMappings cvm;
|
||||||
cvm.addDirectory(CVPilotModelMappings::standardMappingsDirectory());
|
cvm.addDirectory(CVPilotModelMappings::standardMappingsDirectory());
|
||||||
bool s = cvm.load();
|
bool s = cvm.load();
|
||||||
qDebug() << "loaded:" << s << "size:" << cvm.size();
|
streamOut << "loaded:" << s << "size:" << cvm.size() << endl;
|
||||||
|
|
||||||
BlackMisc::Aviation::CAircraftIcao icao("C172");
|
BlackMisc::Aviation::CAircraftIcao icao("C172");
|
||||||
qDebug() << cvm.findByIcaoWildcard(icao);
|
streamOut << cvm.findByIcaoWildcard(icao) << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* 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/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKSIMTEST_SAMPLESMODELMAPPING_H
|
#ifndef BLACKSIMTEST_SAMPLESMODELMAPPING_H
|
||||||
#define BLACKSIMTEST_SAMPLESMODELMAPPING_H
|
#define BLACKSIMTEST_SAMPLESMODELMAPPING_H
|
||||||
|
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
{
|
{
|
||||||
/*!
|
//! Samples for model mapping classes
|
||||||
* \brief Samples for model mapping classes
|
|
||||||
*/
|
|
||||||
class CSamplesModelMapping
|
class CSamplesModelMapping
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Run the samples
|
||||||
* \brief Run the samples
|
static int samples(QTextStream &streamOut);
|
||||||
*/
|
|
||||||
static int samples();
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -98,5 +98,5 @@ namespace BlackSim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace BlackSim
|
|||||||
* \param atcModel
|
* \param atcModel
|
||||||
* \param atcParkingCode
|
* \param atcParkingCode
|
||||||
*/
|
*/
|
||||||
CAircraftCfgEntries(const QString &filePath, qint32 index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode);
|
CAircraftCfgEntries(const QString &filePath, int index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode);
|
||||||
|
|
||||||
//! Filepath
|
//! Filepath
|
||||||
QString getFilePath() const { return this->m_filePath; }
|
QString getFilePath() const { return this->m_filePath; }
|
||||||
@@ -58,7 +58,7 @@ namespace BlackSim
|
|||||||
QString getTitle() const { return this->m_title; }
|
QString getTitle() const { return this->m_title; }
|
||||||
|
|
||||||
//! Index
|
//! Index
|
||||||
qint32 getIndex() const { return this->m_index; }
|
int getIndex() const { return this->m_index; }
|
||||||
|
|
||||||
//! ATC model
|
//! ATC model
|
||||||
QString getAtcModel() const { return this->m_atcModel; }
|
QString getAtcModel() const { return this->m_atcModel; }
|
||||||
@@ -76,7 +76,7 @@ namespace BlackSim
|
|||||||
void setTitle(const QString &title) { this->m_title = title; }
|
void setTitle(const QString &title) { this->m_title = title; }
|
||||||
|
|
||||||
//! Index
|
//! Index
|
||||||
void setIndex(const qint32 index) { this->m_index = index; }
|
void setIndex(int index) { this->m_index = index; }
|
||||||
|
|
||||||
//! ATC model
|
//! ATC model
|
||||||
void setAtcModel(const QString &atcModel) { this->m_atcModel = atcModel; }
|
void setAtcModel(const QString &atcModel) { this->m_atcModel = atcModel; }
|
||||||
@@ -99,7 +99,7 @@ namespace BlackSim
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftCfgEntries)
|
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftCfgEntries)
|
||||||
qint32 m_index; //!< current index in given config
|
int m_index; //!< current index in given config
|
||||||
QString m_filePath; //!< file path of aircraft.cfg
|
QString m_filePath; //!< file path of aircraft.cfg
|
||||||
QString m_title; //!< Title in aircraft.cfg
|
QString m_title; //!< Title in aircraft.cfg
|
||||||
QString m_atcType; //!< ATC type
|
QString m_atcType; //!< ATC type
|
||||||
|
|||||||
@@ -28,22 +28,31 @@ namespace BlackSim
|
|||||||
/*
|
/*
|
||||||
* Model for title
|
* Model for title
|
||||||
*/
|
*/
|
||||||
bool CAircraftCfgEntriesList::containsModeWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
||||||
{
|
{
|
||||||
return this->containsBy([ = ](const CAircraftCfgEntries & entries) -> bool
|
return this->containsBy([ = ](const CAircraftCfgEntries & entries) -> bool
|
||||||
{ return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
{ return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Models for title
|
||||||
|
*/
|
||||||
|
CAircraftCfgEntriesList CAircraftCfgEntriesList::findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
||||||
|
{
|
||||||
|
return this->findBy([ = ](const CAircraftCfgEntries & entries) -> bool
|
||||||
|
{ return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read all entrities in given directory
|
* Read all entrities in given directory
|
||||||
*/
|
*/
|
||||||
qint32 CAircraftCfgEntriesList::read(const QString &directory)
|
int CAircraftCfgEntriesList::read(const QString &directory)
|
||||||
{
|
{
|
||||||
// set directory with name filters, get aircraft.cfg and sub directories
|
// set directory with name filters, get aircraft.cfg and sub directories
|
||||||
QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs);
|
QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs);
|
||||||
if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available
|
if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available
|
||||||
|
|
||||||
qint32 counter = 0;
|
int counter = 0;
|
||||||
QString currentDir = dir.absolutePath();
|
QString currentDir = dir.absolutePath();
|
||||||
|
|
||||||
// Dirs last is crucial,since I will break recursion on "aircraft.cfg" level
|
// Dirs last is crucial,since I will break recursion on "aircraft.cfg" level
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ namespace BlackSim
|
|||||||
//! Utility, providing FSX aircraft.cfg entries
|
//! Utility, providing FSX aircraft.cfg entries
|
||||||
class CAircraftCfgEntriesList : public BlackMisc::CSequence<CAircraftCfgEntries>
|
class CAircraftCfgEntriesList : public BlackMisc::CSequence<CAircraftCfgEntries>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
QString m_rootDirectory; //!< root directory reading aircraft.cfg files
|
|
||||||
bool m_readForDirectory; //!< valid read for given directory
|
|
||||||
|
|
||||||
//! Read all entries in one directory
|
|
||||||
qint32 read(const QString &directory);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -41,7 +35,7 @@ namespace BlackSim
|
|||||||
CAircraftCfgEntriesList(const QString &rootDirectory = "") : m_rootDirectory(rootDirectory), m_readForDirectory(false) {}
|
CAircraftCfgEntriesList(const QString &rootDirectory = "") : m_rootDirectory(rootDirectory), m_readForDirectory(false) {}
|
||||||
|
|
||||||
//! Read all aircraft.cfg files starting from root directory
|
//! Read all aircraft.cfg files starting from root directory
|
||||||
qint32 read()
|
int read()
|
||||||
{
|
{
|
||||||
if (this->m_readForDirectory) return this->size();
|
if (this->m_readForDirectory) return this->size();
|
||||||
|
|
||||||
@@ -75,7 +69,10 @@ namespace BlackSim
|
|||||||
QString getRootDirectory() const { return this->m_rootDirectory; }
|
QString getRootDirectory() const { return this->m_rootDirectory; }
|
||||||
|
|
||||||
//! Contains model with title?
|
//! Contains model with title?
|
||||||
bool containsModeWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive);
|
bool containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
//! Find by title
|
||||||
|
CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity);
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
@@ -92,9 +89,17 @@ namespace BlackSim
|
|||||||
|
|
||||||
//! Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_rootDirectory; //!< root directory reading aircraft.cfg files
|
||||||
|
bool m_readForDirectory; //!< valid read for given directory
|
||||||
|
|
||||||
|
//! Read all entries in one directory
|
||||||
|
int read(const QString &directory);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftCfgEntriesList)
|
Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftCfgEntriesList)
|
||||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackSim::FsCommon::CAircraftCfgEntries>)
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackSim::FsCommon::CAircraftCfgEntries>)
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/* Copyright (C) 2013
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
||||||
#define BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
#define BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
||||||
|
|
||||||
@@ -9,19 +20,13 @@ namespace BlackSim
|
|||||||
{
|
{
|
||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
/*!
|
//! Indexer for all models
|
||||||
* \brief Indexer for all modelsThe CAircraftIndexer class
|
//! \sa CAircraftCfgEntries
|
||||||
*/
|
//! \sa CAircraftCfgEntriesList
|
||||||
class CAircraftIndexer : QObject
|
class CAircraftIndexer : QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
//! Constructor
|
|
||||||
CAircraftIndexer(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
CAircraftCfgEntriesList m_entries; //!< all entries
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Number of entries read
|
//! Number of entries read
|
||||||
void entriesRead(int number);
|
void entriesRead(int number);
|
||||||
@@ -40,7 +45,12 @@ namespace BlackSim
|
|||||||
//! Read in background
|
//! Read in background
|
||||||
static QFuture<int> readInBackground(const QString directory = "");
|
static QFuture<int> readInBackground(const QString directory = "");
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Constructor
|
||||||
|
CAircraftIndexer(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
CAircraftCfgEntriesList m_entries; //!< all entries
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
}
|
} // namespace
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ namespace BlackSim
|
|||||||
{
|
{
|
||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
/*!
|
//! Model mappings
|
||||||
* Model mappings
|
|
||||||
*/
|
|
||||||
class CVPilotModelMappings : public ISimulatorModelMappings
|
class CVPilotModelMappings : public ISimulatorModelMappings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user