mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T268, interpolation setup provider (no QObject) can "emit signal" by using a virtual function
This commit is contained in:
@@ -84,12 +84,11 @@ namespace BlackMisc
|
||||
bool IInterpolationSetupProvider::setInterpolationSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup)
|
||||
{
|
||||
{
|
||||
QReadLocker l(&m_lockSetup);
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
if (m_globalSetup == setup) { return false; }
|
||||
m_globalSetup = setup;
|
||||
}
|
||||
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
m_globalSetup = setup;
|
||||
this->emitInterpolationSetupChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,11 +104,25 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
}
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
m_setups[callsign] = setup;
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
m_setups[callsign] = setup;
|
||||
}
|
||||
this->emitInterpolationSetupChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IInterpolationSetupProvider::removeInterpolationSetupPerCallsign(const CCallsign &callsign)
|
||||
{
|
||||
bool removed = false;
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
removed = m_setups.remove(callsign) > 0;
|
||||
}
|
||||
if (removed) { this->emitInterpolationSetupChanged(); }
|
||||
return removed;
|
||||
}
|
||||
|
||||
void IInterpolationSetupProvider::setLogCallsign(bool log, const CCallsign &callsign)
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
@@ -134,9 +147,24 @@ namespace BlackMisc
|
||||
if (setup.isEqualToGlobal(global)) { continue; }
|
||||
setupsToKeep.insert(cs, setup);
|
||||
}
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
m_setups = setupsToKeep;
|
||||
}
|
||||
this->emitInterpolationSetupChanged();
|
||||
}
|
||||
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
m_setups = setupsToKeep;
|
||||
int IInterpolationSetupProvider::clearInterpolationSetupsPerCallsign()
|
||||
{
|
||||
int r = 0;
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
r = m_setups.size();
|
||||
m_setups.clear();
|
||||
}
|
||||
|
||||
if (r > 0) { this->emitInterpolationSetupChanged(); }
|
||||
return r;
|
||||
}
|
||||
|
||||
bool IInterpolationSetupProvider::logAnyCallsign() const
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual bool setInterpolationSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup);
|
||||
|
||||
//! Insert specialized setup
|
||||
//! Insert specialized setup per callsign
|
||||
//! \threadsafe
|
||||
virtual bool setInterpolationSetupPerCallsign(const CInterpolationAndRenderingSetupPerCallsign &setup, const Aviation::CCallsign &callsign, bool removeGlobalSetup = true);
|
||||
|
||||
@@ -71,10 +71,17 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
void setLogCallsign(bool log, const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Remove specialized setup per callsign
|
||||
bool removeInterpolationSetupPerCallsign(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Clear all interpolation log callsigns
|
||||
//! \threadsafe
|
||||
void clearInterpolationLogCallsigns();
|
||||
|
||||
//! Clear all setups
|
||||
//! \threadsafe
|
||||
int clearInterpolationSetupsPerCallsign();
|
||||
|
||||
//! Log any callsign?
|
||||
//! \threadsafe
|
||||
bool logAnyCallsign() const;
|
||||
@@ -83,6 +90,9 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
SetupsPerCallsign getSetupsPerCallsign() const;
|
||||
|
||||
//! Pseudo signal, override to emit signal
|
||||
virtual void emitInterpolationSetupChanged() {}
|
||||
|
||||
private:
|
||||
CInterpolationAndRenderingSetupGlobal m_globalSetup;
|
||||
SetupsPerCallsign m_setups;
|
||||
|
||||
Reference in New Issue
Block a user