refs #780, improved model string completion

* added signatures for completer string (when send via context size matters)
* support of all instaled models in completer
* added BLACKMISC_EXPORT in model cache classes
This commit is contained in:
Klaus Basan
2016-10-27 01:03:36 +02:00
parent 14f3eadc08
commit 1678ca8919
11 changed files with 70 additions and 24 deletions

View File

@@ -18,6 +18,8 @@
using namespace BlackCore;
using namespace BlackCore::Context;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::Data;
namespace BlackGui
{
@@ -42,6 +44,15 @@ namespace BlackGui
if (sGui->getIContextSimulator())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CAircraftModelStringCompleter::ps_simulatorConnected);
const CSimulatorInfo sim(sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulator());
if (sim.isSingleSimulator())
{
this->m_modelCaches.setCurrentSimulator(sim);
}
else
{
this->setSourceVisible(OwnModels, false);
}
}
}
@@ -95,32 +106,27 @@ namespace BlackGui
void CAircraftModelStringCompleter::setCompleter()
{
QStringList modelStrings;
CompleterSourceFlag sourceWithData = None;
if (ui->rb_Db->isChecked())
{
modelStrings = sGui->getWebDataServices()->getModelStrings();
if (this->m_currentSourceWithData == DB) { return; }
modelStrings = sGui->getWebDataServices()->getModelCompleterStrings();
if (!modelStrings.isEmpty()) { sourceWithData = DB; }
}
else if (ui->rb_ModelSet->isChecked())
{
if (!this->m_completerOwnModels)
{
const QStringList modelStrings = sGui->getIContextSimulator()->getModelSet().getModelStringList();
this->m_completerModelSet = new QCompleter(modelStrings, this);
setCompleterParameters(this->m_completerModelSet);
}
ui->le_modelString->setCompleter(this->m_completerOwnModels);
if (this->m_currentSourceWithData == ModelSet) { return; }
modelStrings = sGui->getIContextSimulator()->getModelSetCompleterStrings(true);
if (!modelStrings.isEmpty()) { sourceWithData = ModelSet; }
}
else if (ui->rb_OwnModels->isChecked())
{
if (!this->m_completerOwnModels)
{
const QStringList modelStrings = sGui->getIContextSimulator()->getModelSet().getModelStringList();
this->m_completerOwnModels = new QCompleter(modelStrings, this);
setCompleterParameters(this->m_completerOwnModels);
}
ui->le_modelString->setCompleter(this->m_completerOwnModels);
modelStrings = sGui->getIContextSimulator()->getModelSet().getModelStringList();
if (this->m_currentSourceWithData == OwnModels) { return; }
modelStrings = this->m_modelCaches.getCurrentCachedModels().toCompleterStrings();
if (!modelStrings.isEmpty()) { sourceWithData = OwnModels; }
}
this->m_currentSourceWithData = sourceWithData;
ui->le_modelString->setCompleter(new QCompleter(modelStrings, this));
ui->le_modelString->setPlaceholderText(QString("model strings (%1)").arg(modelStrings.size()));
}

View File

@@ -12,6 +12,7 @@
#ifndef BLACKGUI_COMPLETER_AIRCRAFTMODELSTRINGCOMPLETER_H
#define BLACKGUI_COMPLETER_AIRCRAFTMODELSTRINGCOMPLETER_H
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/simulation/aircraftmodel.h"
#include <QFrame>
#include <QScopedPointer>
@@ -33,10 +34,12 @@ namespace BlackGui
public:
//! Sources for string completion
enum CompleterSourceFlag {
DB,
ModelSet,
OwnModels
enum CompleterSourceFlag
{
None = 0, //!< normally used to indicate nothing was loaded
DB = 1 << 0,
ModelSet = 1 << 1,
OwnModels = 1 << 2
};
Q_DECLARE_FLAGS(CompleterSource, CompleterSourceFlag)
@@ -93,6 +96,8 @@ namespace BlackGui
private:
QScopedPointer <Ui::CAircraftModelStringCompleter> ui;
BlackMisc::Simulation::Data::CModelCaches m_modelCaches { false, this }; //!< all models, works locally only
CompleterSourceFlag m_currentSourceWithData = None;
};
} // ns
} // ns