Engauge Digitizer  2
MimePointsExport.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "MimePointsExport.h"
8 
9 const QString FORMAT_CSV ("text/csv");
10 const QString FORMAT_CSV_INTERNAL ("text/engauge-points-csv"); // Custom mime type keeps points coordinates internal to engauge
11 const QString FORMAT_HTML ("text/html");
12 const QString FORMAT_PLAIN ("text/plain");
13 
15 {
16 }
17 
19  const QString &htmlGraph) :
20  m_csvGraph (csvGraph),
21  m_htmlGraph (htmlGraph)
22 {
23  m_formats << FORMAT_CSV << FORMAT_HTML << FORMAT_PLAIN;
24 }
25 
27  m_csvPoints (csvPoints)
28 {
29  m_formats << FORMAT_CSV_INTERNAL;
30 }
31 
33 {
34  m_csvGraph = other.csvGraph();
35  m_csvPoints = other.csvPoints();
36  m_htmlGraph = other.htmlGraph();
37  m_formats = other.formats();
38 
39  return *this;
40 }
41 
43 {
44 }
45 
47 {
48  return m_csvGraph;
49 }
50 
52 {
53  return m_csvPoints;
54 }
55 
56 QStringList MimePointsExport::formats() const
57 {
58  return m_formats;
59 }
60 
62 {
63  return m_htmlGraph;
64 }
65 
66 QVariant MimePointsExport::retrieveData (const QString &format,
67  QVariant::Type /* preferredType */) const
68 {
69  if (format == FORMAT_CSV) {
70  return m_csvGraph;
71  } else if (format == FORMAT_CSV_INTERNAL) {
72  return m_csvPoints;
73  } else if (format == FORMAT_HTML) {
74  return m_htmlGraph;
75  } else if (format == FORMAT_PLAIN) {
76  return m_csvGraph;
77  } else {
78  QVariant null;
79  return null;
80  }
81 }
QString htmlGraph() const
Get methjod for htmlGraph.
MimePointsExport & operator=(const MimePointsExport &other)
Assignment operator.
MimePointsExport()
Default constructor. Initial contents are overwritten by other constructors.
QString csvPoints() const
Get method for csvPoints.
QString csvGraph() const
Get method for csvGraph.
Custom mime type for separate treatment of graph coordinates and, when there is no transform...
virtual QStringList formats() const
Available formats, which depend on whether or not the transform is defined.
virtual ~MimePointsExport()
Destructor.
virtual QVariant retrieveData(const QString &format, QVariant::Type preferredType) const
Returns a variant with the data for the specified format.