mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-05 11:09:13 -04:00
Map feature: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
541b8449fd
commit
79808fb852
@ -103,7 +103,7 @@ bool Map::handleMessage(const Message& cmd)
|
||||
{
|
||||
MsgConfigureMap& cfg = (MsgConfigureMap&) cmd;
|
||||
qDebug() << "Map::handleMessage: MsgConfigureMap";
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -130,55 +130,38 @@ bool Map::deserialize(const QByteArray& data)
|
||||
{
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(m_settings, true);
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(m_settings, true);
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Map::applySettings(const MapSettings& settings, bool force)
|
||||
void Map::applySettings(const MapSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
qDebug() << "Map::applySettings:"
|
||||
<< " m_displayNames: " << settings.m_displayNames
|
||||
<< " m_title: " << settings.m_title
|
||||
<< " m_rgbColor: " << settings.m_rgbColor
|
||||
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
||||
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
||||
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
|
||||
<< " m_reverseAPIFeatureSetIndex: " << settings.m_reverseAPIFeatureSetIndex
|
||||
<< " m_reverseAPIFeatureIndex: " << settings.m_reverseAPIFeatureIndex
|
||||
<< " force: " << force;
|
||||
qDebug() << "Map::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
if ((m_settings.m_displayNames != settings.m_displayNames) || force) {
|
||||
reverseAPIKeys.append("displayNames");
|
||||
}
|
||||
if ((m_settings.m_title != settings.m_title) || force) {
|
||||
reverseAPIKeys.append("title");
|
||||
}
|
||||
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
|
||||
reverseAPIKeys.append("rgbColor");
|
||||
}
|
||||
|
||||
if (settings.m_useReverseAPI)
|
||||
if (settingsKeys.contains("useReverseAPI"))
|
||||
{
|
||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
||||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) ||
|
||||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||
settingsKeys.contains("reverseAPIAddress") ||
|
||||
settingsKeys.contains("reverseAPIPort") ||
|
||||
settingsKeys.contains("reverseAPIFeatureSetIndex") ||
|
||||
settingsKeys.contains("m_reverseAPIFeatureIndex");
|
||||
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
if (force) {
|
||||
m_settings = settings;
|
||||
} else {
|
||||
m_settings.applySettings(settingsKeys, settings);
|
||||
}
|
||||
}
|
||||
|
||||
int Map::webapiRun(bool run,
|
||||
@ -212,12 +195,12 @@ int Map::webapiSettingsPutPatch(
|
||||
MapSettings settings = m_settings;
|
||||
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
||||
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(settings, force);
|
||||
MsgConfigureMap *msg = MsgConfigureMap::create(settings, featureSettingsKeys, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureMap *msgToGUI = MsgConfigureMap::create(settings, force);
|
||||
MsgConfigureMap *msgToGUI = MsgConfigureMap::create(settings, featureSettingsKeys, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
@ -346,7 +329,7 @@ void Map::webapiUpdateFeatureSettings(
|
||||
}
|
||||
}
|
||||
|
||||
void Map::webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const MapSettings& settings, bool force)
|
||||
void Map::webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const MapSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
||||
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
||||
|
@ -46,19 +46,22 @@ public:
|
||||
|
||||
public:
|
||||
const MapSettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureMap* create(const MapSettings& settings, bool force) {
|
||||
return new MsgConfigureMap(settings, force);
|
||||
static MsgConfigureMap* create(const MapSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||
return new MsgConfigureMap(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
MapSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureMap(const MapSettings& settings, bool force) :
|
||||
MsgConfigureMap(const MapSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -176,9 +179,9 @@ private:
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
void applySettings(const MapSettings& settings, bool force = false);
|
||||
void applySettings(const MapSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const MapSettings& settings, bool force);
|
||||
void webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const MapSettings& settings, bool force);
|
||||
void registerPipe(QObject *object);
|
||||
void notifyUpdate();
|
||||
|
||||
|
@ -90,7 +90,13 @@ bool MapGUI::handleMessage(const Message& message)
|
||||
{
|
||||
qDebug("MapGUI::handleMessage: Map::MsgConfigureMap");
|
||||
const Map::MsgConfigureMap& cfg = (Map::MsgConfigureMap&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
|
||||
if (cfg.getForce()) {
|
||||
m_settings = cfg.getSettings();
|
||||
} else {
|
||||
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
||||
}
|
||||
|
||||
blockApplySettings(true);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
@ -164,7 +170,6 @@ void MapGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
||||
(void) rollDown;
|
||||
|
||||
getRollupContents()->saveState(m_rollupState);
|
||||
applySettings();
|
||||
}
|
||||
|
||||
MapGUI::MapGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) :
|
||||
@ -859,9 +864,11 @@ void MapGUI::on_mapTypes_currentIndexChanged(int index)
|
||||
QVariant mapType = index;
|
||||
QMetaObject::invokeMethod(ui->map->rootObject(), "setMapType", Q_ARG(QVariant, mapType));
|
||||
QString currentMap = ui->mapTypes->currentText();
|
||||
|
||||
if (!currentMap.isEmpty())
|
||||
{
|
||||
m_settings.m_mapType = currentMap;
|
||||
m_settingsKeys.append("mapType");
|
||||
applySettings();
|
||||
}
|
||||
}
|
||||
@ -982,6 +989,14 @@ void MapGUI::onMenuDialogCalled(const QPoint &p)
|
||||
setTitle(m_settings.m_title);
|
||||
setTitleColor(m_settings.m_rgbColor);
|
||||
|
||||
m_settingsKeys.append("title");
|
||||
m_settingsKeys.append("rgbColor");
|
||||
m_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIFeatureSetIndex");
|
||||
m_settingsKeys.append("reverseAPIFeatureIndex");
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -992,9 +1007,11 @@ void MapGUI::applySettings(bool force)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
Map::MsgConfigureMap* message = Map::MsgConfigureMap::create(m_settings, force);
|
||||
Map::MsgConfigureMap* message = Map::MsgConfigureMap::create(m_settings, m_settingsKeys, force);
|
||||
m_map->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
m_settingsKeys.clear();
|
||||
}
|
||||
|
||||
void MapGUI::on_maidenhead_clicked()
|
||||
|
@ -162,6 +162,7 @@ private:
|
||||
PluginAPI* m_pluginAPI;
|
||||
FeatureUISet* m_featureUISet;
|
||||
MapSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
RollupState m_rollupState;
|
||||
bool m_doApplySettings;
|
||||
QList<MapSettings::AvailableChannelOrFeature> m_availableChannelOrFeatures;
|
||||
|
@ -101,7 +101,7 @@ void MapSettings::resetToDefaults()
|
||||
m_displaySelectedGroundTracks = true;
|
||||
m_displayAllGroundTracks = true;
|
||||
m_title = "Map";
|
||||
m_rgbColor = QColor(225, 25, 99).rgb();
|
||||
m_displayAllGroundTracks = QColor(225, 25, 99).rgb();
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
@ -392,3 +392,174 @@ void MapSettings::deserializeItemSettings(const QByteArray& data, QHash<QString,
|
||||
idx += 2;
|
||||
} while(!done);
|
||||
}
|
||||
|
||||
void MapSettings::applySettings(const QStringList& settingsKeys, const MapSettings& settings)
|
||||
{
|
||||
if (settingsKeys.contains("displayNames")) {
|
||||
m_displayNames = settings.m_displayNames;
|
||||
}
|
||||
if (settingsKeys.contains("mapProvider")) {
|
||||
m_mapProvider = settings.m_mapProvider;
|
||||
}
|
||||
if (settingsKeys.contains("thunderforestAPIKey")) {
|
||||
m_thunderforestAPIKey = settings.m_thunderforestAPIKey;
|
||||
}
|
||||
if (settingsKeys.contains("maptilerAPIKey")) {
|
||||
m_maptilerAPIKey = settings.m_maptilerAPIKey;
|
||||
}
|
||||
if (settingsKeys.contains("osmURL")) {
|
||||
m_osmURL = settings.m_osmURL;
|
||||
}
|
||||
if (settingsKeys.contains("mapBoxStyles")) {
|
||||
m_mapBoxStyles = settings.m_mapBoxStyles;
|
||||
}
|
||||
if (settingsKeys.contains("displaySelectedGroundTracks")) {
|
||||
m_displaySelectedGroundTracks = settings.m_displaySelectedGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("displayAllGroundTracks")) {
|
||||
m_displayAllGroundTracks = settings.m_displayAllGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("title")) {
|
||||
m_title = settings.m_title;
|
||||
}
|
||||
if (settingsKeys.contains("displayAllGroundTracks")) {
|
||||
m_displayAllGroundTracks = settings.m_displayAllGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI")) {
|
||||
m_useReverseAPI = settings.m_useReverseAPI;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIAddress")) {
|
||||
m_reverseAPIAddress = settings.m_reverseAPIAddress;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIPort")) {
|
||||
m_reverseAPIPort = settings.m_reverseAPIPort;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
|
||||
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
|
||||
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
|
||||
}
|
||||
if (settingsKeys.contains("map2DEnabled")) {
|
||||
m_map2DEnabled = settings.m_map2DEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("map3DEnabled")) {
|
||||
m_map3DEnabled = settings.m_map3DEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("terrain")) {
|
||||
m_terrain = settings.m_terrain;
|
||||
}
|
||||
if (settingsKeys.contains("buildings")) {
|
||||
m_buildings = settings.m_buildings;
|
||||
}
|
||||
if (settingsKeys.contains("sunLightEnabled")) {
|
||||
m_sunLightEnabled = settings.m_sunLightEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("eciCamera")) {
|
||||
m_eciCamera = settings.m_eciCamera;
|
||||
}
|
||||
if (settingsKeys.contains("modelDir")) {
|
||||
m_modelDir = settings.m_modelDir;
|
||||
}
|
||||
if (settingsKeys.contains("antiAliasing")) {
|
||||
m_antiAliasing = settings.m_antiAliasing;
|
||||
}
|
||||
if (settingsKeys.contains("displayMUF")) {
|
||||
m_displayMUF = settings.m_displayMUF;
|
||||
}
|
||||
if (settingsKeys.contains("misplayfoF2")) {
|
||||
m_displayfoF2 = settings.m_displayfoF2;
|
||||
}
|
||||
if (settingsKeys.contains("workspaceIndex")) {
|
||||
m_workspaceIndex = settings.m_workspaceIndex;
|
||||
}
|
||||
}
|
||||
|
||||
QString MapSettings::getDebugString(const QStringList& settingsKeys, bool force=false) const
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
if (settingsKeys.contains("displayNames") || force) {
|
||||
ostr << " m_displayNames: " << m_displayNames;
|
||||
}
|
||||
if (settingsKeys.contains("mapProvider") || force) {
|
||||
ostr << " m_mapProvider: " << m_mapProvider.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("thunderforestAPIKey") || force) {
|
||||
ostr << " m_thunderforestAPIKey: " << m_thunderforestAPIKey.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("maptilerAPIKey") || force) {
|
||||
ostr << " m_maptilerAPIKey: " << m_maptilerAPIKey.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("mapBoxAPIKey") || force) {
|
||||
ostr << " m_mapBoxAPIKey: " << m_mapBoxAPIKey.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("osmURL") || force) {
|
||||
ostr << " m_osmURL: " << m_osmURL.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("mapBoxStyles") || force) {
|
||||
ostr << " m_mapBoxStyles: " << m_mapBoxStyles.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("displaySelectedGroundTracks") || force) {
|
||||
ostr << " m_displaySelectedGroundTracks: " << m_displaySelectedGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("_displayAllGroundTracks") || force) {
|
||||
ostr << " m_displayAllGroundTracks: " << m_displayAllGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("title") || force) {
|
||||
ostr << " m_title: " << m_title.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("displayAllGroundTracks") || force) {
|
||||
ostr << " m_displayAllGroundTracks: " << m_displayAllGroundTracks;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI") || force) {
|
||||
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIAddress") || force) {
|
||||
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIPort") || force) {
|
||||
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) {
|
||||
ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureIndex") || force) {
|
||||
ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex;
|
||||
}
|
||||
if (settingsKeys.contains("map2DEnabled") || force) {
|
||||
ostr << " m_map2DEnabled: " << m_map2DEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("map3DEnabled") || force) {
|
||||
ostr << " m_map3DEnabled: " << m_map3DEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("terrain") || force) {
|
||||
ostr << " m_terrain: " << m_terrain.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("buildings") || force) {
|
||||
ostr << " m_buildings: " << m_buildings.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("sunLightEnabled") || force) {
|
||||
ostr << " m_sunLightEnabled: " << m_sunLightEnabled;
|
||||
}
|
||||
if (settingsKeys.contains("eciCamera") || force) {
|
||||
ostr << " m_eciCamera: " << m_eciCamera;
|
||||
}
|
||||
if (settingsKeys.contains("modelDir") || force) {
|
||||
ostr << " m_modelDir: " << m_modelDir.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("antiAliasing") || force) {
|
||||
ostr << " m_antiAliasing: " << m_antiAliasing.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("displayMUF") || force) {
|
||||
ostr << " m_displayMUF: " << m_displayMUF;
|
||||
}
|
||||
if (settingsKeys.contains("displayfoF2") || force) {
|
||||
ostr << " m_displayfoF2: " << m_displayfoF2;
|
||||
}
|
||||
if (settingsKeys.contains("workspaceIndex") || force) {
|
||||
ostr << " m_workspaceIndex: " << m_workspaceIndex;
|
||||
}
|
||||
|
||||
return QString(ostr.str().c_str());
|
||||
}
|
||||
|
@ -118,6 +118,8 @@ struct MapSettings
|
||||
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
||||
QByteArray serializeItemSettings(QHash<QString, MapItemSettings *> itemSettings) const;
|
||||
void deserializeItemSettings(const QByteArray& data, QHash<QString, MapItemSettings *>& itemSettings);
|
||||
void applySettings(const QStringList& settingsKeys, const MapSettings& settings);
|
||||
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||
|
||||
static const QStringList m_pipeTypes;
|
||||
static const QStringList m_pipeURIs;
|
||||
|
Loading…
Reference in New Issue
Block a user