mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
some fixes
* as of slack discussion with MG, made area finding a bit more robust * removed unused function in keypadarea * added unit test subproject for GUI
This commit is contained in:
committed by
Mathew Sutcliffe
parent
03e16e37e7
commit
f8c83ce2a3
@@ -217,12 +217,6 @@ namespace BlackGui
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CAircraft CMainKeypadAreaComponent::getOwnAircraft() const
|
||||
{
|
||||
if (!this->getIContextOwnAircraft()) { return CAircraft(); }
|
||||
return this->getIContextOwnAircraft()->getOwnAircraft();
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::unsetInfoAreaButtons()
|
||||
{
|
||||
ui->pb_MainAircrafts->setChecked(false);
|
||||
@@ -241,8 +235,9 @@ namespace BlackGui
|
||||
CIdentifier CMainKeypadAreaComponent::keypadIdentifier()
|
||||
{
|
||||
if (m_identifier.getName().isEmpty())
|
||||
{
|
||||
m_identifier = CIdentifier(QStringLiteral("KEYPADAREACOMPONENT"));
|
||||
|
||||
}
|
||||
return m_identifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,9 +95,6 @@ namespace BlackGui
|
||||
//! Main info area to corresponding button
|
||||
QPushButton *mainInfoAreaToButton(CMainInfoAreaComponent::InfoArea area) const;
|
||||
|
||||
//! Own aircraft
|
||||
BlackMisc::Aviation::CAircraft getOwnAircraft() const;
|
||||
|
||||
//! Info area buttons
|
||||
void unsetInfoAreaButtons();
|
||||
|
||||
|
||||
@@ -91,6 +91,25 @@ namespace BlackGui
|
||||
a.installTranslator(&translator);
|
||||
}
|
||||
|
||||
bool CGuiUtility::lenientTitleComparison(const QString &title, const QString &comparison)
|
||||
{
|
||||
if (title == comparison) { return true; }
|
||||
|
||||
QString t(title.trimmed().toLower().simplified());
|
||||
QString c(comparison.trimmed().toLower().simplified());
|
||||
Q_ASSERT_X(!t.isEmpty(), Q_FUNC_INFO, "missing value");
|
||||
Q_ASSERT_X(!c.isEmpty(), Q_FUNC_INFO, "missing value");
|
||||
if (t == c) { return true; }
|
||||
|
||||
// further unify
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("[^a-z0-9\\s]")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
t = t.remove(regexp);
|
||||
c = c.remove(regexp);
|
||||
return t == c;
|
||||
}
|
||||
|
||||
QWidgetList CGuiUtility::topLevelApplicationWidgetsWithName()
|
||||
{
|
||||
QWidgetList tlw = QApplication::topLevelWidgets();
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace BlackGui
|
||||
//! Standard initialization for a swift GUI application
|
||||
static void initSwiftGuiApplication(QApplication &a, const QString &applicationName, const QPixmap &icon = BlackMisc::CIcons::swift24());
|
||||
|
||||
//! Leninet / relaxed
|
||||
static bool lenientTitleComparison(const QString &title, const QString &comparison);
|
||||
|
||||
private:
|
||||
//! Constructor, use static methods only
|
||||
CGuiUtility() {}
|
||||
|
||||
@@ -649,7 +649,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "No title");
|
||||
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
|
||||
{
|
||||
if (dw->windowTitleOrBackup() == title) { return dw; }
|
||||
if (CGuiUtility::lenientTitleComparison(dw->windowTitleOrBackup(), title)) { return dw; }
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -659,7 +659,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "No title");
|
||||
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
|
||||
{
|
||||
if (title == m_dockWidgetInfoAreas.at(i)->windowTitleOrBackup()) { return i; }
|
||||
if (CGuiUtility::lenientTitleComparison(m_dockWidgetInfoAreas.at(i)->windowTitleOrBackup(), title)) { return i; }
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No area for title");
|
||||
return -1;
|
||||
@@ -671,7 +671,7 @@ namespace BlackGui
|
||||
if (m_tabBar->count() < 1) { return -1;}
|
||||
for (int i = 0; i < m_tabBar->count(); i++)
|
||||
{
|
||||
if (m_tabBar->tabText(i) == title) { return i; }
|
||||
if (CGuiUtility::lenientTitleComparison(m_tabBar->tabText(i), title)) { return i; }
|
||||
}
|
||||
Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "Wrong title");
|
||||
return -1;
|
||||
|
||||
@@ -150,14 +150,14 @@ namespace BlackMisc
|
||||
|
||||
bool CAircraftIcaoCode::isValidDesignator(const QString &designator)
|
||||
{
|
||||
static QRegularExpression regexp("^[A-Z]+[A-Z0-9]*$");
|
||||
static const QRegularExpression regexp("^[A-Z]+[A-Z0-9]*$");
|
||||
if (designator.length() < 2 || designator.length() > 5) { return false; }
|
||||
return (regexp.match(designator).hasMatch());
|
||||
}
|
||||
|
||||
bool CAircraftIcaoCode::isValidCombinedType(const QString &combinedType)
|
||||
{
|
||||
static QRegularExpression regexp("^[A-Z][0-9][A-Z]$");
|
||||
static const QRegularExpression regexp("^[A-Z][0-9][A-Z]$");
|
||||
if (combinedType.length() != 3) return false;
|
||||
return (regexp.match(combinedType).hasMatch());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user