Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
MimePoints.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 "MimePoints.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 
18 MimePoints::MimePoints(const QString &csvGraph,
19  const QString &htmlGraph) :
20  m_csvGraph (csvGraph),
21  m_htmlGraph (htmlGraph)
22 {
23  m_formats << FORMAT_CSV << FORMAT_HTML << FORMAT_PLAIN;
24 }
25 
26 MimePoints::MimePoints (const QString &csvPoints) :
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 
46 QString MimePoints::csvGraph () const
47 {
48  return m_csvGraph;
49 }
50 
51 QString MimePoints::csvPoints () const
52 {
53  return m_csvPoints;
54 }
55 
56 QStringList MimePoints::formats() const
57 {
58  return m_formats;
59 }
60 
61 QString MimePoints::htmlGraph () const
62 {
63  return m_htmlGraph;
64 }
65 
66 QVariant MimePoints::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 }
MimePoints()
Default constructor. Initial contents are overwritten by other constructors.
Definition: MimePoints.cpp:14
virtual QStringList formats() const
Available formats, which depend on whether or not the transform is defined.
Definition: MimePoints.cpp:56
Custom mime type for separate treatment of graph coordinates and, when there is no transform...
Definition: MimePoints.h:15
virtual ~MimePoints()
Destructor.
Definition: MimePoints.cpp:42
QString htmlGraph() const
Get methjod for htmlGraph.
Definition: MimePoints.cpp:61
QString csvGraph() const
Get method for csvGraph.
Definition: MimePoints.cpp:46
virtual QVariant retrieveData(const QString &format, QVariant::Type preferredType) const
Returns a variant with the data for the specified format.
Definition: MimePoints.cpp:66
QString csvPoints() const
Get method for csvPoints.
Definition: MimePoints.cpp:51
MimePoints & operator=(const MimePoints &other)
Assignment operator.
Definition: MimePoints.cpp:32