QGIS API Documentation 3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
qgsdartmeasurement.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdartmeasurement.cpp
3 --------------------------------------
4 Date : 8.11.2014
5 Copyright : (C) 2014 Matthias Kuhn
6 Email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsdartmeasurement.h"
17
18#include <QString>
19#include <QTextStream>
20
21using namespace Qt::StringLiterals;
22
23QgsDartMeasurement::QgsDartMeasurement( const QString &name, Type type, const QString &value )
24 : mName( name )
25 , mType( type )
26 , mValue( value )
27{
28}
29
30const QString QgsDartMeasurement::toString() const
31{
32 QString elementName = u"DartMeasurement"_s;
33 if ( mType == ImagePng )
34 {
35 elementName = u"DartMeasurementFile"_s;
36 }
37
38 QString dashMessage = u"<%1 name=\"%2\" type=\"%3\">%4</%1>"_s
39 .arg( elementName,
40 mName,
41 typeToString( mType ),
42 mValue );
43 return dashMessage;
44}
45
47{
48 QTextStream out( stdout );
49 out << toString() << Qt::endl;
50}
51
53{
54 QString str;
55
56 switch ( type )
57 {
58 case Text:
59 str = u"text/text"_s;
60 break;
61
62 case ImagePng:
63 str = u"image/png"_s;
64 break;
65
66 case Integer:
67 str = u"numeric/integer"_s;
68 break;
69 }
70
71 return str;
72}
static const QString typeToString(QgsDartMeasurement::Type type)
Convert a QgsDartMeasurement::Type enum to a string that is understood by the system.
const QString toString() const
QgsDartMeasurement()=default