00001 /****************************************************************************************************** 00002 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #include "MimePointsExport.h" 00008 00009 const QString FORMAT_CSV ("text/csv"); 00010 const QString FORMAT_CSV_INTERNAL ("text/engauge-points-csv"); // Custom mime type keeps points coordinates internal to engauge 00011 const QString FORMAT_HTML ("text/html"); 00012 const QString FORMAT_PLAIN ("text/plain"); 00013 00014 MimePointsExport::MimePointsExport () 00015 { 00016 } 00017 00018 MimePointsExport::MimePointsExport(const QString &csvGraph, 00019 const QString &htmlGraph) : 00020 m_csvGraph (csvGraph), 00021 m_htmlGraph (htmlGraph) 00022 { 00023 m_formats << FORMAT_CSV << FORMAT_HTML << FORMAT_PLAIN; 00024 } 00025 00026 MimePointsExport::MimePointsExport (const QString &csvPoints) : 00027 m_csvPoints (csvPoints) 00028 { 00029 m_formats << FORMAT_CSV_INTERNAL; 00030 } 00031 00032 MimePointsExport &MimePointsExport::operator=(const MimePointsExport &other) 00033 { 00034 m_csvGraph = other.csvGraph(); 00035 m_csvPoints = other.csvPoints(); 00036 m_htmlGraph = other.htmlGraph(); 00037 m_formats = other.formats(); 00038 00039 return *this; 00040 } 00041 00042 MimePointsExport::~MimePointsExport () 00043 { 00044 } 00045 00046 QString MimePointsExport::csvGraph () const 00047 { 00048 return m_csvGraph; 00049 } 00050 00051 QString MimePointsExport::csvPoints () const 00052 { 00053 return m_csvPoints; 00054 } 00055 00056 QStringList MimePointsExport::formats() const 00057 { 00058 return m_formats; 00059 } 00060 00061 QString MimePointsExport::htmlGraph () const 00062 { 00063 return m_htmlGraph; 00064 } 00065 00066 QVariant MimePointsExport::retrieveData (const QString &format, 00067 QVariant::Type /* preferredType */) const 00068 { 00069 if (format == FORMAT_CSV) { 00070 return m_csvGraph; 00071 } else if (format == FORMAT_CSV_INTERNAL) { 00072 return m_csvPoints; 00073 } else if (format == FORMAT_HTML) { 00074 return m_htmlGraph; 00075 } else if (format == FORMAT_PLAIN) { 00076 return m_csvGraph; 00077 } else { 00078 QVariant null; 00079 return null; 00080 } 00081 }