QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
28 {
29  QString elementName = "DartMeasurement";
30  if ( mType == ImagePng )
31  {
32  elementName = "DartMeasurementFile";
33  }
34 
35  QString dashMessage = QString( "<%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 = "text/text";
57  break;
58 
59  case ImagePng:
60  str = "image/png";
61  break;
62 
63  case Integer:
64  str = "numeric/integer";
65  break;
66  }
67 
68  return str;
69 }
const QString toString() const
static const QString typeToString(Type type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const