QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 <QTextStream>
19 
20 QgsDartMeasurement::QgsDartMeasurement( const QString &name, Type type, const QString &value )
21  : mName( name )
22  , mType( type )
23  , mValue( value )
24 {
25 }
26 
27 const QString QgsDartMeasurement::toString() const
28 {
29  QString elementName = QStringLiteral( "DartMeasurement" );
30  if ( mType == ImagePng )
31  {
32  elementName = QStringLiteral( "DartMeasurementFile" );
33  }
34 
35  QString dashMessage = QStringLiteral( "<%1 name=\"%2\" type=\"%3\">%4</%1>" )
36  .arg( elementName,
37  mName,
38  typeToString( mType ),
39  mValue );
40  return dashMessage;
41 }
42 
44 {
45  QTextStream out( stdout );
46  out << toString() << endl;
47 }
48 
50 {
51  QString str;
52 
53  switch ( type )
54  {
55  case Text:
56  str = QStringLiteral( "text/text" );
57  break;
58 
59  case ImagePng:
60  str = QStringLiteral( "image/png" );
61  break;
62 
63  case Integer:
64  str = QStringLiteral( "numeric/integer" );
65  break;
66  }
67 
68  return str;
69 }
QgsDartMeasurement::QgsDartMeasurement
QgsDartMeasurement()=default
Constructor for QgsDartMeasurement.
QgsDartMeasurement::Text
@ Text
Definition: qgsdartmeasurement.h:32
QgsDartMeasurement::Integer
@ Integer
Definition: qgsdartmeasurement.h:34
qgsdartmeasurement.h
QgsDartMeasurement::Type
Type
Definition: qgsdartmeasurement.h:30
QgsDartMeasurement::toString
const QString toString() const
Definition: qgsdartmeasurement.cpp:27
QgsDartMeasurement::send
void send() const
Definition: qgsdartmeasurement.cpp:43
QgsDartMeasurement::ImagePng
@ ImagePng
Definition: qgsdartmeasurement.h:33
QgsDartMeasurement::typeToString
static const QString typeToString(QgsDartMeasurement::Type type)
Convert a QgsDartMeasurement::Type enum to a string that is understood by the system.
Definition: qgsdartmeasurement.cpp:49