From 1a63c00a71ff612b839663c5911c47aa6635248e Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Thu, 18 Oct 2018 15:01:16 +0200 Subject: [PATCH] Change CService::getAircraftLivery() to return livery without path CService::getAircraftLivery() is expected to return the livery name itself without the full path. ref T378 --- src/xswiftbus/service.cpp | 10 ++++++++++ src/xswiftbus/service.h | 4 ++-- tests/blackmisc/simulation/testxplane/testxplane.cpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index 12faca02e..146adf998 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -104,6 +104,16 @@ namespace XSwiftBus return acfProperties.modelName; } + std::string CService::getAircraftLivery() const + { + std::string liveryPath = m_liveryPath.get(); + if (liveryPath.empty()) { return {}; } + + // liveryPath end with / and we need to get rid of it + liveryPath.pop_back(); + return getFileName(liveryPath); + } + int CService::getXPlaneVersionMajor() const { int version; diff --git a/src/xswiftbus/service.h b/src/xswiftbus/service.h index 6dc8a302f..96a9b1793 100644 --- a/src/xswiftbus/service.h +++ b/src/xswiftbus/service.h @@ -79,8 +79,8 @@ namespace XSwiftBus //! Get name of current aircraft model std::string getAircraftName() const; - //! Get path to current aircraft livery - std::string getAircraftLivery() const { return m_liveryPath.get(); } + //! Get current aircraft livery + std::string getAircraftLivery() const; //! Get the ICAO code of the current aircraft model std::string getAircraftIcaoCode() const { return m_icao.get(); } diff --git a/tests/blackmisc/simulation/testxplane/testxplane.cpp b/tests/blackmisc/simulation/testxplane/testxplane.cpp index 91c6b8d4c..c9044a48e 100644 --- a/tests/blackmisc/simulation/testxplane/testxplane.cpp +++ b/tests/blackmisc/simulation/testxplane/testxplane.cpp @@ -43,6 +43,7 @@ namespace BlackMiscTest QCOMPARE(QString::fromStdString(getFileName("foo/test.txt")), QString("test.txt")); QCOMPARE(QString::fromStdString(getFileName("test.txt")), QString("test.txt")); QCOMPARE(QString::fromStdString(getFileName("foo/test.txt.txt")), QString("test.txt.txt")); + QCOMPARE(QString::fromStdString(getFileName("foo/bar")), QString("bar")); } void CTestXPlane::getDirNameTest()