mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
Issue #77 Move class to sampleblackmiscsim because it is only used there
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
//! \ingroup sampleblackmiscsim
|
||||
|
||||
#include "samplesfscommon.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "sampleutils.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
//! \ingroup sampleblackmiscsim
|
||||
|
||||
#include "samplesmodelmapping.h"
|
||||
#include "sampleutils.h"
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
|
||||
48
samples/blackmiscsim/sampleutils.cpp
Normal file
48
samples/blackmiscsim/sampleutils.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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. 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 "sampleutils.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
QString CSampleUtils::selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
Q_ASSERT(!directoryOptions.isEmpty());
|
||||
if (directoryOptions.isEmpty()) { return {}; }
|
||||
if (directoryOptions.size() < 2) { return directoryOptions.first(); }
|
||||
|
||||
QString selectedDir;
|
||||
do
|
||||
{
|
||||
for (int i = 0; i < directoryOptions.size(); i++)
|
||||
{
|
||||
if (i > 0) { streamOut << " "; }
|
||||
streamOut << (i + 1) << ") " << directoryOptions.at(i) ;
|
||||
}
|
||||
streamOut << Qt::endl;
|
||||
streamOut << "Select [1-" << directoryOptions.size() << "]: ";
|
||||
streamOut.flush();
|
||||
|
||||
QString input = streamIn.readLine();
|
||||
bool ok;
|
||||
int s = input.trimmed().toInt(&ok);
|
||||
if (ok && s > 0 && s <= directoryOptions.size())
|
||||
{
|
||||
selectedDir = directoryOptions.at(s - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
return selectedDir;
|
||||
}
|
||||
}
|
||||
32
samples/blackmiscsim/sampleutils.h
Normal file
32
samples/blackmiscsim/sampleutils.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* 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. 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 BLACKSAMPLE_SAMPLEUTILS_H
|
||||
#define BLACKSAMPLE_SAMPLEUTILS_H
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QTextStream;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
//! Utils for sample programms
|
||||
class CSampleUtils
|
||||
{
|
||||
public:
|
||||
//! Select directory among given ones
|
||||
static QString selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn);
|
||||
|
||||
private:
|
||||
CSampleUtils() = delete;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user