QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
47  out << toString() << endl;
48 #else
49  out << toString() << Qt::endl;
50 #endif
51 }
52 
54 {
55  QString str;
56 
57  switch ( type )
58  {
59  case Text:
60  str = QStringLiteral( "text/text" );
61  break;
62 
63  case ImagePng:
64  str = QStringLiteral( "image/png" );
65  break;
66 
67  case Integer:
68  str = QStringLiteral( "numeric/integer" );
69  break;
70  }
71 
72  return str;
73 }
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
Constructor for QgsDartMeasurement.
#define str(x)
Definition: qgis.cpp:37