mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 13:47:01 -04:00
FeatureWebAPIUtils: Add method to open Sky Map and find a target.
This commit is contained in:
@@ -210,3 +210,56 @@ bool FeatureWebAPIUtils::satelliteLOS(const QString name)
|
||||
// Not currently required by any features
|
||||
return true;
|
||||
}
|
||||
|
||||
// Open a Sky Map feature and find the specified target
|
||||
bool FeatureWebAPIUtils::openSkyMapAndFind(const QString& target)
|
||||
{
|
||||
return SkyMapOpener::open(target);
|
||||
}
|
||||
|
||||
bool SkyMapOpener::open(const QString& target)
|
||||
{
|
||||
// Create a SkyMap feature
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
PluginAPI::FeatureRegistrations *featureRegistrations = mainCore->getPluginManager()->getFeatureRegistrations();
|
||||
int nbRegistrations = featureRegistrations->size();
|
||||
int index = 0;
|
||||
|
||||
for (; index < nbRegistrations; index++)
|
||||
{
|
||||
if (featureRegistrations->at(index).m_featureId == "SkyMap") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index < nbRegistrations)
|
||||
{
|
||||
new SkyMapOpener(target);
|
||||
|
||||
MainCore::MsgAddFeature *msg = MainCore::MsgAddFeature::create(0, index);
|
||||
mainCore->getMainMessageQueue()->push(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Sky Map feature not available";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SkyMapOpener::SkyMapOpener(const QString& target) :
|
||||
m_target(target)
|
||||
{
|
||||
connect(MainCore::instance(), &MainCore::featureAdded, this, &SkyMapOpener::onSkyMapAdded);
|
||||
}
|
||||
|
||||
void SkyMapOpener::onSkyMapAdded(int featureSetIndex, Feature *feature)
|
||||
{
|
||||
if (feature->getURI() == "sdrangel.feature.skymap")
|
||||
{
|
||||
disconnect(MainCore::instance(), &MainCore::featureAdded, this, &SkyMapOpener::onSkyMapAdded);
|
||||
FeatureWebAPIUtils::skyMapFind(m_target, featureSetIndex, feature->getIndexInFeatureSet());
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user