mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
refs #236, aircraft indexer to read FSX/9 models on disk in background
This commit is contained in:
@@ -21,6 +21,15 @@ namespace BlackSim
|
||||
return (dir.exists());
|
||||
}
|
||||
|
||||
/*
|
||||
* Model for title
|
||||
*/
|
||||
bool CAircraftCfgEntriesList::containsModeWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
return this->contains([ = ](const CAircraftCfgEntries & entries) -> bool
|
||||
{ return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
||||
}
|
||||
|
||||
/*
|
||||
* Read all entrities in given directory
|
||||
*/
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace BlackSim
|
||||
//! \brief Current root directory
|
||||
QString getRootDirectory() const { return this->m_rootDirectory; }
|
||||
|
||||
//! Contains model with title?
|
||||
bool containsModeWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive);
|
||||
|
||||
//! \brief Unknown entries
|
||||
static const CAircraftCfgEntries &UnknownCfgEntries()
|
||||
{
|
||||
|
||||
23
src/blacksim/fscommon/aircraftindexer.cpp
Normal file
23
src/blacksim/fscommon/aircraftindexer.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "aircraftindexer.h"
|
||||
|
||||
namespace BlackSim
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
CAircraftIndexer::CAircraftIndexer(QObject *parent) : QObject(parent) {}
|
||||
|
||||
int CAircraftIndexer::read(const QString directory)
|
||||
{
|
||||
if (!directory.isEmpty()) indexer().m_entries.changeDirectory(directory);
|
||||
int n = indexer().m_entries.read();
|
||||
emit indexer().entriesRead(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
QFuture<int> CAircraftIndexer::readInBackground(const QString directory)
|
||||
{
|
||||
QFuture<int> f = QtConcurrent::run(CAircraftIndexer::read, directory);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/blacksim/fscommon/aircraftindexer.h
Normal file
45
src/blacksim/fscommon/aircraftindexer.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
||||
#define BLACKSIM_FSCOMMON_AIRCRAFTINDEXER_H
|
||||
|
||||
#include "aircraftcfgentrieslist.h"
|
||||
#include <QObject>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
namespace BlackSim
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
/*!
|
||||
* \brief Indexer for all modelsThe CAircraftIndexer class
|
||||
*/
|
||||
class CAircraftIndexer : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
//! Constructor
|
||||
CAircraftIndexer(QObject *parent = nullptr);
|
||||
|
||||
CAircraftCfgEntriesList m_entries; //!< all entries
|
||||
|
||||
signals:
|
||||
void entriesRead(int number);
|
||||
|
||||
public:
|
||||
//! Single entity indexer
|
||||
static CAircraftIndexer &indexer()
|
||||
{
|
||||
static CAircraftIndexer indexer;
|
||||
return indexer;
|
||||
}
|
||||
|
||||
//! Read for directory or re-read
|
||||
static int read(const QString directory = "");
|
||||
|
||||
//! Read in background
|
||||
static QFuture<int> readInBackground(const QString directory = "");
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user