QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
29const QString QgsDartMeasurement::toString() const
30{
31 QString elementName = u"DartMeasurement"_s;
32 if ( mType == ImagePng )
33 {
34 elementName = u"DartMeasurementFile"_s;
35 }
36
37 QString dashMessage = u"<%1 name=\"%2\" type=\"%3\">%4</%1>"_s.arg( elementName, mName, typeToString( mType ), mValue );
38 return dashMessage;
39}
40
42{
43 QTextStream out( stdout );
44 out << toString() << Qt::endl;
45}
46
48{
49 QString str;
50
51 switch ( type )
52 {
53 case Text:
54 str = u"text/text"_s;
55 break;
56
57 case ImagePng:
58 str = u"image/png"_s;
59 break;
60
61 case Integer:
62 str = u"numeric/integer"_s;
63 break;
64 }
65
66 return str;
67}
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