mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #314, samples for Variant tests, fixed some minor things in other samples
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "samplesmetadata.h"
|
||||
#include "samplescontainer.h"
|
||||
#include "samplesjson.h"
|
||||
#include "samplesvariant.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/pqallquantities.h"
|
||||
|
||||
@@ -28,9 +29,11 @@ int main(int argc, char *argv[])
|
||||
Q_UNUSED(argv);
|
||||
|
||||
BlackMisc::initResources();
|
||||
BlackMisc::registerMetadata();
|
||||
CSamplesJson::samples();
|
||||
CSamplesChangeObject::samples();
|
||||
CSamplesContainer::samples();
|
||||
CSamplesMetadata::samples();
|
||||
CSamplesVariant::samples();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,8 @@ namespace BlackMiscTest
|
||||
stations.fromJson(json);
|
||||
qDebug() << stations;
|
||||
|
||||
qDebug() << "-----------------------------------------------";
|
||||
cin.readLine();
|
||||
qDebug() << "------- Enter ---------------------------------";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,14 @@ namespace BlackMiscTest
|
||||
*/
|
||||
int CSamplesMetadata::samples()
|
||||
{
|
||||
QTextStream cin(stdin);
|
||||
|
||||
BlackMisc::registerMetadata();
|
||||
BlackMisc::displayAllUserMetatypesTypes();
|
||||
|
||||
cin.readLine();
|
||||
qDebug() << "------- Enter --------";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
62
samples/blackmisc/samplesvariant.cpp
Normal file
62
samples/blackmisc/samplesvariant.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "samplesvariant.h"
|
||||
#include "blackmisc/pqallquantities.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
int CSamplesVariant::samples()
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
|
||||
CAngle a1(30.0, CAngleUnit::deg());
|
||||
QVariant qva = a1.toQVariant();
|
||||
qDebug() << a1 << qva.userType();
|
||||
|
||||
CHeading h1(45, CHeading::True, CAngleUnit::deg());
|
||||
CHeading h2(60, CHeading::True, CAngleUnit::deg());
|
||||
|
||||
QVariant qvh = h1.toQVariant();
|
||||
qDebug() << h1 << qvh.userType();
|
||||
|
||||
CAngle *ap_heading = &h1; // angle actually heading
|
||||
CAngle *ap_angle = &a1; // angle really heading
|
||||
qDebug() << (*ap_heading) << ap_heading->toQVariant().userType();
|
||||
qDebug() << (*ap_angle) << ap_angle->toQVariant().userType();
|
||||
|
||||
// This works, because ap is actually heading
|
||||
ap_heading->fromQVariant(h2.toQVariant());
|
||||
qDebug() << (*ap_heading) << ap_heading->toQVariant().userType();
|
||||
|
||||
// This works, angle from variant angle
|
||||
ap_angle->fromQVariant(a1.toQVariant());
|
||||
qDebug() << (*ap_angle) << ap_angle->toQVariant().userType();
|
||||
|
||||
// This gives me an unwanted(!) assert, canConvert is not smart enough to detect upcasting
|
||||
// because CValueObjects are not QObjects
|
||||
ap_angle->fromQVariant(h2.toQVariant());
|
||||
qDebug() << (*ap_angle) << ap_angle->toQVariant().userType();
|
||||
|
||||
// This gives me the intended assert, because I assign angle to heading
|
||||
ap_heading->fromQVariant(a1.toQVariant());
|
||||
qDebug() << (*ap_heading) << ap_heading->toQVariant().userType();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
27
samples/blackmisc/samplesvariant.h
Normal file
27
samples/blackmisc/samplesvariant.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISCTEST_SAMPLESVARIANT_H
|
||||
#define BLACKMISCTEST_SAMPLESVARIANT_H
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
//! Samples for metadata
|
||||
class CSamplesVariant
|
||||
{
|
||||
public:
|
||||
//! Run the samples
|
||||
static int samples();
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user