mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
No updates when UI component is invisible or unchanged HTML code
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4a0ddfb5d1
commit
6a63bcf666
@@ -19,6 +19,7 @@
|
|||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -106,7 +107,8 @@ namespace BlackGui
|
|||||||
void CAircraftPartsHistory::updatePartsHistory()
|
void CAircraftPartsHistory::updatePartsHistory()
|
||||||
{
|
{
|
||||||
if (!this->hasContexts()) { return; }
|
if (!this->hasContexts()) { return; }
|
||||||
if (isBeingModified) { return; }
|
if (!this->isVisible()) { return; }
|
||||||
|
if (m_isBeingModified) { return; }
|
||||||
const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper());
|
const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper());
|
||||||
if (cs.isEmpty()) { return; }
|
if (cs.isEmpty()) { return; }
|
||||||
const auto currentAircraftParts = sGui->getIContextNetwork()->getRemoteAircraftParts(cs, -1).frontOrDefault();
|
const auto currentAircraftParts = sGui->getIContextNetwork()->getRemoteAircraftParts(cs, -1).frontOrDefault();
|
||||||
@@ -149,6 +151,9 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint hash = qHash(html);
|
||||||
|
if (hash == m_htmlHash) { return; } // avoid to always scroll to the end when there is no update
|
||||||
|
m_htmlHash = hash;
|
||||||
this->m_text.setHtml(html);
|
this->m_text.setHtml(html);
|
||||||
ui->te_Messages->setDocument(&this->m_text);
|
ui->te_Messages->setDocument(&this->m_text);
|
||||||
|
|
||||||
@@ -162,14 +167,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAircraftPartsHistory::callsignEntered()
|
void CAircraftPartsHistory::callsignEntered()
|
||||||
{
|
{
|
||||||
isBeingModified = false;
|
m_isBeingModified = false;
|
||||||
updatePartsHistory();
|
updatePartsHistory();
|
||||||
m_timerUpdateHistory.start();
|
m_timerUpdateHistory.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftPartsHistory::callsignModified()
|
void CAircraftPartsHistory::callsignModified()
|
||||||
{
|
{
|
||||||
isBeingModified = true;
|
m_isBeingModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftPartsHistory::valuesChanged()
|
void CAircraftPartsHistory::valuesChanged()
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ namespace BlackGui
|
|||||||
QTimer m_timerCallsignUpdate { this };
|
QTimer m_timerCallsignUpdate { this };
|
||||||
QTimer m_timerUpdateHistory { this };
|
QTimer m_timerUpdateHistory { this };
|
||||||
QTextDocument m_text { this };
|
QTextDocument m_text { this };
|
||||||
bool isBeingModified = false;
|
uint m_htmlHash = 0;
|
||||||
|
bool m_isBeingModified = false;
|
||||||
|
|
||||||
//! Init
|
//! Init
|
||||||
void initGui();
|
void initGui();
|
||||||
|
|||||||
Reference in New Issue
Block a user