Ref T298, buttons for re-matching

This commit is contained in:
Klaus Basan
2018-08-24 17:00:02 +02:00
parent cb351aca1a
commit e0e47a46f6
6 changed files with 101 additions and 37 deletions

View File

@@ -96,6 +96,7 @@ namespace BlackGui
connect(ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::onSaveAircraft); connect(ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::onSaveAircraft);
connect(ui->pb_ResetAircraft, &QPushButton::clicked, this, &CMappingComponent::onResetAircraft); connect(ui->pb_ResetAircraft, &QPushButton::clicked, this, &CMappingComponent::onResetAircraft);
connect(ui->pb_LoadModels, &QPushButton::clicked, this, &CMappingComponent::onModelsUpdateRequested); connect(ui->pb_LoadModels, &QPushButton::clicked, this, &CMappingComponent::onModelsUpdateRequested);
connect(ui->pb_DoMatchingAgain, &QPushButton::clicked, this, &CMappingComponent::doMatchingsAgain);
m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this); m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this);
ui->tvp_RenderedAircraft->setItemDelegateForColumn(0, m_currentMappingsViewDelegate); ui->tvp_RenderedAircraft->setItemDelegateForColumn(0, m_currentMappingsViewDelegate);
@@ -294,6 +295,13 @@ namespace BlackGui
ui->comp_SimulatorSelector->setToConnectedSimulator(50); ui->comp_SimulatorSelector->setToConnectedSimulator(50);
} }
void CMappingComponent::doMatchingsAgain()
{
if (!sGui || !sGui->getISimulator() || !sGui->getISimulator()->isConnected()) { return; }
const int reMatchedNo = sGui->getIContextSimulator()->doMatchingsAgain();
CLogMessage(this).info("Triggered re-apping of %1 aircraft") << reMatchedNo;
}
void CMappingComponent::onSaveAircraft() void CMappingComponent::onSaveAircraft()
{ {
if (!sGui->getIContextSimulator()->isSimulatorSimulating()) { return; } if (!sGui->getIContextSimulator()->isSimulatorSimulating()) { return; }

View File

@@ -31,7 +31,6 @@
#include <QString> #include <QString>
#include <Qt> #include <Qt>
class QCompleter;
class QModelIndex; class QModelIndex;
namespace BlackMisc namespace BlackMisc
@@ -168,13 +167,16 @@ namespace BlackGui
//! Plugin info has been changed //! Plugin info has been changed
void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo); void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo);
//! Do re-matching
void doMatchingsAgain();
static constexpr int OverlayMessageMs = 5000; static constexpr int OverlayMessageMs = 5000;
QScopedPointer<Ui::CMappingComponent> ui; QScopedPointer<Ui::CMappingComponent> ui;
bool m_missedRenderedAircraftUpdate = true; //! Rendered aircraft need update bool m_missedRenderedAircraftUpdate = true; //! Rendered aircraft need update
QTimer m_updateTimer; QTimer m_updateTimer;
BlackMisc::CTokenBucket m_bucket { 3, BlackMisc::PhysicalQuantities::CTime(5.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()), 1}; BlackMisc::CTokenBucket m_bucket { 3, BlackMisc::PhysicalQuantities::CTime(5.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()), 1};
Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr; //! checkbox in view
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CMappingComponent::settingsChanged }; //!< settings changed BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CMappingComponent::settingsChanged }; //!< settings changed
Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr; //! checkbox in view
}; };
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>319</width> <width>376</width>
<height>303</height> <height>293</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -170,27 +170,20 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>3</number> <number>3</number>
</property> </property>
<item row="2" column="0" colspan="5"> <item row="1" column="5">
<widget class="BlackGui::Components::CAircraftModelStringCompleter" name="completer_ModelStrings"> <widget class="QPushButton" name="pb_SaveAircraft">
<property name="minimumSize"> <property name="toolTip">
<size> <string>save selected model</string>
<width>0</width>
<height>20</height>
</size>
</property> </property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Aircraft">
<property name="text"> <property name="text">
<string>Aircraft</string> <string>save</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="cb_AircraftEnabled"> <widget class="QCheckBox" name="cb_AircraftEnabled">
<property name="toolTip"> <property name="toolTip">
<string>enabled / disable</string> <string>aircraft enabled/disable</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@@ -210,13 +203,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="0">
<widget class="QPushButton" name="pb_SaveAircraft"> <widget class="QLabel" name="lbl_Aircraft">
<property name="toolTip"> <property name="toolTip">
<string>save selected model</string> <string>aircraft enabled</string>
</property> </property>
<property name="text"> <property name="text">
<string>save</string> <string>Enbl.</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -227,13 +220,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="0" column="5">
<widget class="QPushButton" name="pb_ResetAircraft"> <widget class="QPushButton" name="pb_LoadModels">
<property name="toolTip"> <property name="toolTip">
<string>reset model by callsign</string> <string>load model set</string>
</property> </property>
<property name="text"> <property name="text">
<string>reset</string> <string>load set</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -256,17 +249,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="2" column="0" colspan="6">
<widget class="QPushButton" name="pb_LoadModels"> <widget class="BlackGui::Components::CAircraftModelStringCompleter" name="completer_ModelStrings">
<property name="toolTip"> <property name="minimumSize">
<string>load model set</string> <size>
</property> <width>0</width>
<property name="text"> <height>20</height>
<string>load set</string> </size>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2" colspan="2"> <item row="1" column="4">
<widget class="QPushButton" name="pb_DoMatchingAgain">
<property name="toolTip">
<string>do all matchings again</string>
</property>
<property name="text">
<string>re-match</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="3">
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector"> <widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
@@ -276,6 +279,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3">
<widget class="QPushButton" name="pb_ResetAircraft">
<property name="toolTip">
<string>reset model by callsign</string>
</property>
<property name="text">
<string>reset</string>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/pastel/icons/pastel/16/arrow-refresh.png</normaloff>:/pastel/icons/pastel/16/arrow-refresh.png</iconset>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@@ -318,6 +335,20 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <tabstops>
<tabstop>tw_SpecializedViews</tabstop>
<tabstop>tvp_RenderedAircraft</tabstop>
<tabstop>cb_AircraftIconDisplayed</tabstop>
<tabstop>pb_LoadModels</tabstop>
<tabstop>cb_AircraftEnabled</tabstop>
<tabstop>le_Callsign</tabstop>
<tabstop>pb_ResetAircraft</tabstop>
<tabstop>pb_DoMatchingAgain</tabstop>
<tabstop>pb_SaveAircraft</tabstop>
<tabstop>tvp_AircraftModels</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -12,8 +12,10 @@
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h" #include "blackcore/context/contextsimulator.h"
#include "blackmisc/simulation/aircraftmatchersetup.h" #include "blackmisc/simulation/aircraftmatchersetup.h"
#include "blackmisc/logmessage.h"
#include <QPointer> #include <QPointer>
using namespace BlackMisc;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
using namespace BlackCore::Context; using namespace BlackCore::Context;
@@ -28,6 +30,7 @@ namespace BlackGui
ui->setupUi(this); ui->setupUi(this);
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed); connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed); connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
connect(ui->pb_MatchingAgain, &QPushButton::released, this, &CSettingsMatchingComponent::onMatchingsAgainPressed);
IContextSimulator *simContext = simulatorContext(); IContextSimulator *simContext = simulatorContext();
if (simContext) if (simContext)
@@ -53,6 +56,13 @@ namespace BlackGui
this->deferredReload(0); this->deferredReload(0);
} }
void CSettingsMatchingComponent::onMatchingsAgainPressed()
{
if (!sGui || !sGui->getISimulator() || !sGui->getISimulator()->isConnected()) { return; }
const int reMatchedNo = sGui->getIContextSimulator()->doMatchingsAgain();
CLogMessage(this).info("Triggered re-apping of %1 aircraft") << reMatchedNo;
}
void CSettingsMatchingComponent::onSetupChanged() void CSettingsMatchingComponent::onSetupChanged()
{ {
const IContextSimulator *simContext = simulatorContext(); const IContextSimulator *simContext = simulatorContext();

View File

@@ -42,6 +42,9 @@ namespace BlackGui
//! Reload pressed //! Reload pressed
void onReloadPressed(); void onReloadPressed();
//! Do re-matching
void onMatchingsAgainPressed();
//! Setup has been changed //! Setup has been changed
void onSetupChanged(); void onSetupChanged();

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>230</width> <width>315</width>
<height>197</height> <height>309</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -36,7 +36,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>211</width> <width>296</width>
<height>375</height> <height>375</height>
</rect> </rect>
</property> </property>
@@ -83,6 +83,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="pb_MatchingAgain">
<property name="toolTip">
<string>do matching for all models again</string>
</property>
<property name="text">
<string>re-matching</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="pb_Reload"> <widget class="QPushButton" name="pb_Reload">
<property name="text"> <property name="text">