Formatting, renaming, Doxygen, minor UI adjustments

This commit is contained in:
Klaus Basan
2017-01-24 20:28:57 +01:00
committed by Mathew Sutcliffe
parent 7ddb69825a
commit 68dccbefa6
16 changed files with 68 additions and 50 deletions

View File

@@ -88,7 +88,6 @@ namespace BlackConfig
static bool isRunningOnUnixPlatform();
//! Application directory where current application is located
//! \todo Move to to CApplication
static const QString &getApplicationDir();
//! Where resource files (static DB files, ...) etc are located

View File

@@ -213,6 +213,7 @@ namespace BlackCore
static void processEventsFor(int milliseconds);
//! Clear the caches
//! \return all cache files
static QStringList clearCaches();
// ----------------------- parsing ----------------------------------------

View File

@@ -132,13 +132,13 @@ namespace BlackCore
bool isPendingConnection() const;
// --------------------- IContextNetwork implementations ---------------------
//! \copydoc IContextNetwork::parseCommandLine
//! \ingroup commandline
//! @{
//! <pre>
//! .m .msg message text
//! </pre>
//! @}
//! \copydoc IContextNetwork::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
//! \publicsection

View File

@@ -104,14 +104,14 @@ namespace BlackCore
BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
//! @}
//! \copydoc IContextSimulator::parseCommandLine
//! \ingroup commandline
//! @{
//! <pre>
//! .plugin forwared to plugin, see details there
//! .driver .drv forwared to plugin (same as above)
//! .plugin forwarded to plugin, see details there
//! .driver .drv forwarded to plugin (same as above)
//! </pre>
//! @}
//! \copydoc IContextSimulator::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
// ----------------------------- context interface -----------------------------

View File

@@ -520,16 +520,19 @@ namespace BlackCore
/*!
* We received a custom packet.
* \deprecated As a short cut you can use this signal directly, but it is better to implement the decoding in INetwork and add a new signal.
* \sa CNetworkVatlib::customPacketDispatcher
*/
void customPacketReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data);
/*!
* We received an FSInn custom packet.
* We received a FSInn custom packet.
*/
void customFSInnPacketReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &airlineDesignator,
const QString &aircraftDesignator, const QString &combinedType, const QString &modelString);
//! We received a aircraft config packet
/*!
* We received an aircraft config packet.
*/
void aircraftConfigPacketReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &incremental, bool isFull);
//! @}

View File

@@ -473,7 +473,7 @@ namespace BlackCore
if (messages.isEmpty()) { return; }
CTextMessageList privateMessages = messages.getPrivateMessages();
privateMessages.markAsSent();
for (const auto &message : privateMessages)
for (const auto &message : as_const(privateMessages))
{
if (message.getRecipientCallsign().isEmpty()) { continue; }
Vat_SendTextMessage(m_net.data(), toFSD(message.getRecipientCallsign()), toFSD(message.getMessage()));
@@ -646,7 +646,7 @@ namespace BlackCore
void CNetworkVatlib::sendIncrementalAircraftConfig()
{
if (!isConnected()) { return; }
CAircraftParts currentParts(getOwnAircraftParts());
const CAircraftParts currentParts(getOwnAircraftParts());
// If it hasn't changed, return
if (m_sentAircraftConfig == currentParts) { return; }
@@ -661,9 +661,9 @@ namespace BlackCore
// Method could have been triggered by another change in aircraft config
// so a previous update might still be scheduled. Stop it.
if (m_scheduledConfigUpdate.isActive()) m_scheduledConfigUpdate.stop();
QJsonObject previousConfig = m_sentAircraftConfig.toJson();
QJsonObject currentConfig = currentParts.toJson();
QJsonObject incrementalConfig = getIncrementalObject(previousConfig, currentConfig);
const QJsonObject previousConfig = m_sentAircraftConfig.toJson();
const QJsonObject currentConfig = currentParts.toJson();
const QJsonObject incrementalConfig = getIncrementalObject(previousConfig, currentConfig);
broadcastAircraftConfig(incrementalConfig);
m_sentAircraftConfig = currentParts;
}
@@ -734,7 +734,7 @@ namespace BlackCore
QString modelString = myAircraft.getModel().getModelString();
if (modelString.isEmpty()) { modelString = defaultModelString(); }
QStringList data { { "0" },
const QStringList data { { "0" },
myAircraft.getAirlineIcaoCodeDesignator(),
myAircraft.getAircraftIcaoCodeDesignator(),
{ "" }, { "" }, { "" }, { "" },
@@ -751,7 +751,7 @@ namespace BlackCore
QString modelString = myAircraft.getModel().getModelString();
if (modelString.isEmpty()) { modelString = defaultModelString(); }
QStringList data { { "0" },
const QStringList data { { "0" },
myAircraft.getAirlineIcaoCodeDesignator(),
myAircraft.getAircraftIcaoCodeDesignator(),
{ "" }, { "" }, { "" }, { "" },
@@ -770,8 +770,8 @@ namespace BlackCore
void CNetworkVatlib::sendAircraftConfigQuery(const CCallsign &callsign)
{
QJsonDocument doc(JsonPackets::aircraftConfigRequest());
QString data { doc.toJson(QJsonDocument::Compact) };
const QJsonDocument doc(JsonPackets::aircraftConfigRequest());
const QString data { doc.toJson(QJsonDocument::Compact) };
Vat_SendAircraftConfig(m_net.data(), toFSD(callsign), toFSD(data));
}

View File

@@ -157,8 +157,11 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_VatsimHomeAirport">
<property name="toolTip">
<string>Home airport, e.g. &quot;KLAX&quot;</string>
</property>
<property name="text">
<string>Home airport</string>
<string>Home</string>
</property>
</widget>
</item>

View File

@@ -248,6 +248,9 @@
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pb_ResetAircraft">
<property name="toolTip">
<string>reset model by callsign</string>
</property>
<property name="text">
<string>reset</string>
</property>
@@ -268,6 +271,9 @@
</item>
<item row="1" column="5">
<widget class="QPushButton" name="pb_SaveAircraft">
<property name="toolTip">
<string>save selected model</string>
</property>
<property name="text">
<string>save</string>
</property>

View File

@@ -843,7 +843,7 @@ namespace BlackGui
}
template <class ModelClass, class ContainerType, class ObjectType>
BlackMisc::CWorker *CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
CWorker *CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
{
// avoid unnecessary effort when empty
if (container.isEmpty())
@@ -857,7 +857,7 @@ namespace BlackGui
auto sortColumn = model->getSortColumn();
auto sortOrder = model->getSortOrder();
this->showLoadIndicator(container.size());
BlackMisc::CWorker *worker = BlackMisc::CWorker::fromTask(this, "ViewSort", [model, container, sortColumn, sortOrder]()
CWorker *worker = CWorker::fromTask(this, "ViewSort", [model, container, sortColumn, sortOrder]()
{
return model->sortContainerByColumn(container, sortColumn, sortOrder);
});

View File

@@ -23,7 +23,6 @@
namespace BlackMisc
{
//! Class to write log messages to file
class BLACKMISC_EXPORT CFileLogger : public QObject
{
@@ -45,7 +44,7 @@ namespace BlackMisc
CFileLogger(const QString &applicationName, const QString &logPath, QObject *parent = nullptr);
//! Destructor.
~CFileLogger();
virtual ~CFileLogger();
//! Change the log pattern. Default is to log all messages.
void changeLogPattern(const CLogPattern &pattern) { m_logPattern = pattern; }

View File

@@ -139,7 +139,7 @@ namespace BlackSimPlugin
{
m_fsuipc->connect(); // connect FSUIPC too
}
initInternalsObject();
initSimulatorInternals();
m_dispatchTimerId = startTimer(50);
return true;
}

View File

@@ -38,23 +38,24 @@ namespace BlackSimPlugin
CSimulatorFsCommon::~CSimulatorFsCommon() { }
void CSimulatorFsCommon::initInternalsObject()
void CSimulatorFsCommon::initSimulatorInternals()
{
CSimulatorInternals s;
s.setSimulatorName(this->m_simulatorName);
s.setSimulatorVersion(this->m_simulatorVersion);
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
if (m_fsuipc)
s.setValue("fscommon/fsuipc", boolToOnOff(this->m_useFsuipc));
if (this->m_fsuipc)
{
const QString v(m_fsuipc->getVersion());
const QString v(this->m_fsuipc->getVersion());
if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); }
s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
s.setValue("fscommon/fsuipcconnect", boolToYesNo(this->m_fsuipc->isConnected()));
}
this->m_simulatorInternals = s;
}
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
{
// .driver fsuipc on|off
if (parser.matchesPart(1, "fsuipc") && parser.hasPart(2))
{
const bool on = parser.toBool(2);

View File

@@ -59,10 +59,16 @@ namespace BlackSimPlugin
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent = nullptr);
//! Init the internals objects
virtual void initInternalsObject();
//! Init the internal objects
virtual void initSimulatorInternals();
//! \copydoc BlackCore::CSimulatorCommon::parseDetails
//! \ingroup commandline
//! @{
//! <pre>
//! .plugin fsuipc on|off FSUIPC on/off
//! </pre>
//! @}
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
QString m_simulatorName; //!< name of simulator

View File

@@ -309,12 +309,12 @@ namespace BlackSimPlugin
void CSimulatorFsx::setSimConnected()
{
m_simConnected = true;
this->initInternalsObject();
this->initSimulatorInternals();
emitSimulatorCombinedStatus();
// Internals depends on sim data which take a while to be read
// this is a trich and I re-init again after a while (which is not really expensive)
QTimer::singleShot(1000, this, [this] { this->initInternalsObject(); });
QTimer::singleShot(1000, this, [this] { this->initSimulatorInternals(); });
}
void CSimulatorFsx::onSimRunning()
@@ -1081,9 +1081,9 @@ namespace BlackSimPlugin
return false;
}
void CSimulatorFsx::initInternalsObject()
void CSimulatorFsx::initSimulatorInternals()
{
CSimulatorFsCommon::initInternalsObject();
CSimulatorFsCommon::initSimulatorInternals();
CSimulatorInternals s = this->m_simulatorInternals;
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX
if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); }

View File

@@ -113,7 +113,7 @@ namespace BlackSimPlugin
//! @{
virtual void reset() override;
virtual void clearAllAircraft() override;
virtual void initInternalsObject() override;
virtual void initSimulatorInternals() override;
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
//! @}

View File

@@ -131,23 +131,23 @@ namespace BlackMiscTest
QVERIFY2(cs1 == cs2, "Callsigns shall be equal");
QVERIFY2(cs1 != cs3, "Callsigns shall not be equal");
CCallsignSet list;
list.push_back(cs1);
QVERIFY2(list.size() == 1, "List shall be 1");
QVERIFY2(list.contains(cs1), "Callsign is in list");
QVERIFY2(list.contains(cs2), "Callsign is in list");
list.remove(cs1);
CCallsignSet set;
set.push_back(cs1);
QVERIFY2(set.size() == 1, "List shall be 1");
QVERIFY2(set.contains(cs1), "Callsign is in list");
QVERIFY2(set.contains(cs2), "Callsign is in list");
set.remove(cs1);
QVERIFY2(cs1 == cs1, "Callsign is the same, shall be equal");
QVERIFY2(list.size() == 0, "List shall be 0 after removal");
list.push_back(cs1);
if (!list.contains(cs2)) list.push_back(cs2);
QVERIFY2(list.size() == 1, "Duplicates shall not be added");
list.push_back(cs3);
QVERIFY2(list.size() == 2, "2 different callsigns");
list.remove(cs1);
QVERIFY2(list.size() == 1, "Only one should be left in list");
list.removeIf(&CCallsign::getTelephonyDesignator, "München Radar");
QVERIFY2(list.size() == 0, "Last should be gone");
QVERIFY2(set.size() == 0, "List shall be 0 after removal");
set.push_back(cs1);
if (!set.contains(cs2)) set.push_back(cs2);
QVERIFY2(set.size() == 1, "Duplicates shall not be added");
set.push_back(cs3);
QVERIFY2(set.size() == 2, "2 different callsigns");
set.remove(cs1);
QVERIFY2(set.size() == 1, "Only one should be left in list");
set.removeIf(&CCallsign::getTelephonyDesignator, "München Radar");
QVERIFY2(set.size() == 0, "Last should be gone");
}
/*