Improved samples and debugging information

* DBus test for CSimulatedAircraft
* Output of metatypes in GUI/core
* Changed output from qDebug() to QTextStream
* Variant test for CSimulatedAircraft
This commit is contained in:
Klaus Basan
2015-01-25 03:49:32 +01:00
parent deba08eef0
commit ca07e68c34
14 changed files with 95 additions and 24 deletions

View File

@@ -333,13 +333,15 @@ size_t BlackMisc::heapSizeOf(const QMetaObject &)
/*
* Dump all user types
*/
void BlackMisc::displayAllUserMetatypesTypes()
void BlackMisc::displayAllUserMetatypesTypes(QTextStream &out)
{
for (int mt = QMetaType::User; mt < QMetaType::User + 1000; mt++)
{
if (!QMetaType::isRegistered(mt)) continue;
if (!QMetaType::isRegistered(mt)) { continue; }
QMetaType metaType(mt);
qDebug() << "type:" << mt << "name:" << QMetaType::typeName(mt) << QMetaType::sizeOf(mt) << BlackMisc::heapSizeOf(metaType);
out << "type: " << mt << " name:" << QMetaType::typeName(mt) << " | "
<< QMetaType::sizeOf(mt) << " / " << BlackMisc::heapSizeOf(metaType) << endl;
}
}

View File

@@ -16,7 +16,9 @@
#include <QList>
#include <QMap>
#include <QVariant>
#include <QMetaType>
#include <QDBusArgument>
#include <QTextStream>
#include <memory>
@@ -145,9 +147,9 @@ namespace BlackMisc
*/
QVariant complexQtTypeFromDbusArgument(const QDBusArgument &argument, int type);
//! brief Display all user metatypes
//! Display all user metatypes
//! \remarks Used in order to debug code, do not remove
void displayAllUserMetatypesTypes();
void displayAllUserMetatypesTypes(QTextStream &out = QTextStream(stdout));
/*!
* \brief Calculate a single hash value based on a list of individual hash values

View File

@@ -500,19 +500,18 @@ namespace BlackSound
if (removeFileAfterPlaying) BlackMisc::CFileDeleter::addFileForDeletion(file);
}
void CSoundGenerator::printAllQtSoundDevices()
void CSoundGenerator::printAllQtSoundDevices(QTextStream &out)
{
QTextStream qtout(stdout);
qtout << "output" << endl;
out << "output:" << endl;
foreach(QAudioDeviceInfo qd, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
{
qtout << qd.deviceName() << endl;
out << qd.deviceName() << endl;
}
qtout << "input" << endl;
out << "input:" << endl;
foreach(QAudioDeviceInfo qd, QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
{
qtout << qd.deviceName() << endl;
out << qd.deviceName() << endl;
}
}

View File

@@ -191,7 +191,7 @@ namespace BlackSound
static void playNotificationSound(qint32 volume, CNotificationSounds::Notification notification);
//! For debugging purposes
void static printAllQtSoundDevices();
void static printAllQtSoundDevices(QTextStream &qtout = QTextStream(stdout));
signals:
/*!

View File

@@ -96,7 +96,7 @@ namespace BlackMiscTest
{
qtout << "-------------" << endl;
qtout << "Qt audio devices" << endl;
BlackSound::CSoundGenerator::printAllQtSoundDevices();
BlackSound::CSoundGenerator::printAllQtSoundDevices(qtout);
}
else if (line.startsWith("level"))
{
@@ -105,6 +105,10 @@ namespace BlackMiscTest
refreshSubscriptionSeverities();
qtout << "Changed level to " << CStatusMessage::severityToString(messageSeverity) << endl;
}
else if (line.startsWith("meta"))
{
BlackMisc::displayAllUserMetatypesTypes(qtout);
}
else if (line.startsWith("log"))
{
line.replace("log", "");
@@ -124,7 +128,8 @@ namespace BlackMiscTest
qtout << " log + context + [e]nabled / [d]isabled" << endl;
qtout << " contexts: app / aud / net / own (aircraft) / set / sim / all" << endl;
qtout << " examples: logappd, lognete, logsimd, logalle" << endl;
qtout << "3) all . commands can be used, e.g. .com1 127.35" << endl;
qtout << "3) display metadata data: meta" << endl;
qtout << "4) all . commands can be used, e.g. .com1 127.35" << endl;
qtout << endl;
}
else if (line.startsWith("."))

View File

@@ -243,8 +243,15 @@
</property>
<addaction name="menu_ReloadSettings"/>
</widget>
<widget class="QMenu" name="menu_Debug">
<property name="title">
<string>Debug</string>
</property>
<addaction name="menu_DebugMetaTypes"/>
</widget>
<addaction name="menu_PlanePositions"/>
<addaction name="menu_Reload"/>
<addaction name="menu_Debug"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
@@ -357,6 +364,11 @@
<string>Font</string>
</property>
</action>
<action name="menu_DebugMetaTypes">
<property name="text">
<string>Meta types (to console)</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@@ -157,6 +157,7 @@ void SwiftGuiStd::initGuiSignals()
connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(this->ui->menu_FileFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
// command line / text messages
connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);

View File

@@ -66,6 +66,13 @@ void SwiftGuiStd::ps_onMenuClicked()
Q_ASSERT(this->getIContextSettings());
this->getIContextSettings()->reset(true);
}
else if (sender == this->ui->menu_DebugMetaTypes)
{
QString metadata;
QTextStream stream(&metadata);
BlackMisc::displayAllUserMetatypesTypes(stream);
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(metadata);
}
}
void SwiftGuiStd::initDynamicMenus()