scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

DateTime2StringFilter.cpp
Go to the documentation of this file.
1 
12 
31 #include "DateTime2StringFilter.h"
32 #include "lib/XmlStreamReader.h"
33 #include <QXmlStreamWriter>
34 
35 void DateTime2StringFilter::setFormat(const QString& format)
36 {
38 }
39 
41  : d_target(target), d_other_format(new_format)
42 {
43  if(d_target->parentAspect())
44  setText(QObject::tr("%1: set date-time format to %2").arg(d_target->parentAspect()->name()).arg(new_format));
45  else
46  setText(QObject::tr("set date-time format to %1").arg(new_format));
47 }
48 
50 {
51  QString tmp = d_target->d_format;
53  d_other_format = tmp;
54  emit d_target->formatChanged();
55 }
56 
58 {
59  redo();
60 }
61 
62 void DateTime2StringFilter::writeExtraAttributes(QXmlStreamWriter * writer) const
63 {
64  writer->writeAttribute("format", format());
65 }
66 
68 {
69  QXmlStreamAttributes attribs = reader->attributes();
70  QString str = attribs.value(reader->namespaceUri().toString(), "format").toString();
71 
72  if (AbstractSimpleFilter::load(reader))
73  setFormat(str);
74  else
75  return false;
76 
77  return !reader->hasError();
78 }
79 
DateTime2StringFilterSetFormatCmd::d_target
DateTime2StringFilter * d_target
Definition: DateTime2StringFilter.h:112
DateTime2StringFilter::formatChanged
void formatChanged()
AbstractAspect::exec
void exec(QUndoCommand *command)
Execute the given command, pushing it on the undoStack() if available.
Definition: AbstractAspect.cpp:203
DateTime2StringFilter::setFormat
void setFormat(const QString &format)
Set the format string to be used for conversion.
Definition: DateTime2StringFilter.cpp:35
str
#define str(x)
Definition: PythonScripting.cpp:41
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
DateTime2StringFilterSetFormatCmd::d_other_format
QString d_other_format
Definition: DateTime2StringFilter.h:113
DateTime2StringFilter
Conversion filter QDateTime -> QString.
Definition: DateTime2StringFilter.h:41
DateTime2StringFilter::DateTime2StringFilterSetFormatCmd
friend class DateTime2StringFilterSetFormatCmd
Definition: DateTime2StringFilter.h:64
DateTime2StringFilter.h
DateTime2StringFilterSetFormatCmd::undo
virtual void undo()
Definition: DateTime2StringFilter.cpp:57
DateTime2StringFilterSetFormatCmd::redo
virtual void redo()
Definition: DateTime2StringFilter.cpp:49
DateTime2StringFilter::writeExtraAttributes
virtual void writeExtraAttributes(QXmlStreamWriter *writer) const
Override this in derived classes if they have other attributes than filter_name.
Definition: DateTime2StringFilter.cpp:62
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
XmlStreamReader.h
AbstractAspect::parentAspect
AbstractAspect * parentAspect() const
Return my parent Aspect or 0 if I currently don't have one.
Definition: AbstractAspect.cpp:109
DateTime2StringFilter::load
virtual bool load(XmlStreamReader *reader)
Load from XML.
Definition: DateTime2StringFilter.cpp:67
DateTime2StringFilter::format
QString format() const
Return the format string.
Definition: DateTime2StringFilter.h:55
AbstractSimpleFilter::load
virtual bool load(XmlStreamReader *reader)
Load from XML.
Definition: AbstractSimpleFilter.cpp:135
DateTime2StringFilterSetFormatCmd::DateTime2StringFilterSetFormatCmd
DateTime2StringFilterSetFormatCmd(DateTime2StringFilter *target, const QString &new_format)
Definition: DateTime2StringFilter.cpp:40
DateTime2StringFilter::d_format
QString d_format
The format string.
Definition: DateTime2StringFilter.h:66