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)  

AbstractAspect.h
Go to the documentation of this file.
1 
11 
29 #ifndef ABSTRACT_ASPECT_H
30 #define ABSTRACT_ASPECT_H
31 
32 #include <QObject>
33 #include <QDateTime>
34 
35 class AspectPrivate;
36 class Project;
37 class QUndoStack;
38 class QString;
39 class QDateTime;
40 class QUndoCommand;
41 class QIcon;
42 class QMenu;
43 namespace future{
44 class Folder;
45 }
46 class XmlStreamReader;
47 #ifdef Q_OS_MAC32
48 // A hack in Qt 4.4 and later forces us to include QXmlStream* headers on MacOS instead of simple
49 // forward declarations. See
50 // http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
51 #include <QXmlStreamWriter>
52 #else
53 class QXmlStreamWriter;
54 #endif
55 class QAction;
56 
58 
85 class AbstractAspect : public QObject
86 {
87  Q_OBJECT
88 
89  public:
90  class Private;
91  friend class Private;
92 
93  AbstractAspect(const QString &name);
94  virtual ~AbstractAspect();
95 
97  AbstractAspect * parentAspect() const;
99 
104 
107  bool isDescendantOf(AbstractAspect *other);
108 
114 
122  void removeChild(AbstractAspect* child, bool detach=false);
124 
129  void removeChild(int index);
131  AbstractAspect* child(int index) const;
133  int childCount() const;
135  int indexOfChild(const AbstractAspect * child) const;
137  int index() const { return parentAspect() ? parentAspect()->indexOfChild(this) : 0; }
139  void moveChild(int from, int to);
141  void reparentChild(AbstractAspect *new_parent, AbstractAspect *child, int d_new_index);
143  void reparentChild(AbstractAspect *new_parent, AbstractAspect *child);
145  QList<AbstractAspect *> descendantsThatInherit(const char *class_name);
147  virtual void removeAllChildAspects();
148 
150  virtual const Project *project() const { return parentAspect() ? parentAspect()->project() : 0; }
152  virtual Project *project() { return parentAspect() ? parentAspect()->project() : 0; }
154  virtual QString path() const { return parentAspect() ? parentAspect()->path() + "/" + name() : ""; }
155 
157  virtual QIcon icon() const;
159 
162  virtual QMenu *createContextMenu() const;
163 
164  QString name() const;
165  QString comment() const;
167 
170  QString captionSpec() const;
171  QDateTime creationTime() const;
172  QString caption() const;
173 
175 
176 
182  virtual QUndoStack *undoStack() const { return parentAspect() ? parentAspect()->undoStack() : 0; }
184  void exec(QUndoCommand *command);
186  void beginMacro(const QString& text);
188  void endMacro();
190 
192  static QVariant global(const QString &key);
194  static void setGlobal(const QString &key, const QVariant &value);
196  static void setGlobalDefault(const QString &key, const QVariant &value);
197 
199 
200  virtual void save(QXmlStreamWriter *) const {};
203 
217  virtual bool load(XmlStreamReader *) { return false; };
218  protected:
220 
223  bool readBasicAttributes(XmlStreamReader * reader);
225  void writeBasicAttributes(QXmlStreamWriter * writer) const;
227  void writeCommentElement(QXmlStreamWriter * writer) const;
229  bool readCommentElement(XmlStreamReader * reader);
231 
232  public slots:
233  void setName(const QString &value);
234  void setComment(const QString &value);
236 
248  void setCaptionSpec(const QString &value);
250  virtual void remove() { if(parentAspect()) parentAspect()->removeChild(parentAspect()->indexOfChild(this)); }
252  QString uniqueNameFor(const QString &current_name) const;
253 
254  public:
255  void importV0x0001XXCreationTime(const QString& str)
256  {
257  setCreationTime(QDateTime::fromString(str, Qt::LocalDate));
258  }
259 
260 
261  signals:
267  void aspectAboutToBeAdded(const AbstractAspect *parent, int index);
269  void aspectAdded(const AbstractAspect *aspect);
271  void aspectAdded(const AbstractAspect *parent, int index);
275  void aspectAboutToBeRemoved(const AbstractAspect *parent, int index);
277  void aspectRemoved(const AbstractAspect *parent, int index);
279  void statusInfo(const QString &text);
280 
281  protected:
283 
288  void setCreationTime(const QDateTime& time);
290 
294  virtual void completeAspectInsertion(AbstractAspect * aspect, int index) { Q_UNUSED(aspect); Q_UNUSED(index); }
296 
300  virtual void prepareAspectRemoval(AbstractAspect * aspect) { Q_UNUSED(aspect); }
302 
307  void info(const QString &text) { emit statusInfo(text); }
308 
309  private:
311 };
312 
313 #endif // ifndef ABSTRACT_ASPECT_H
AbstractAspect::importV0x0001XXCreationTime
void importV0x0001XXCreationTime(const QString &str)
Definition: AbstractAspect.h:255
future
Definition: AbstractAspect.h:43
AbstractAspect::writeCommentElement
void writeCommentElement(QXmlStreamWriter *writer) const
Save the comment to XML.
Definition: AbstractAspect.cpp:52
AbstractAspect::reparentChild
void reparentChild(AbstractAspect *new_parent, AbstractAspect *child, int d_new_index)
Move a child to another aspect and transfer ownership.
Definition: AbstractAspect.cpp:157
AbstractAspect::exec
void exec(QUndoCommand *command)
Execute the given command, pushing it on the undoStack() if available.
Definition: AbstractAspect.cpp:203
AbstractAspect::aspectAboutToBeAdded
void aspectAboutToBeAdded(const AbstractAspect *parent, int index)
Emit this when a parent aspect is about to get a new child inserted.
AbstractAspect::global
static QVariant global(const QString &key)
Retrieve a global setting.
Definition: AbstractAspect.cpp:360
AbstractAspect::createContextMenu
virtual QMenu * createContextMenu() const
Return a new context menu.
Definition: AbstractAspect.cpp:303
AbstractAspect::aspectRemoved
void aspectRemoved(const AbstractAspect *parent, int index)
Emit this from the parent after removing a child.
str
#define str(x)
Definition: PythonScripting.cpp:41
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
AbstractAspect::setComment
void setComment(const QString &value)
Definition: AbstractAspect.cpp:265
AbstractAspect::moveChild
void moveChild(int from, int to)
Change the positon of a child in my list of children.
Definition: AbstractAspect.cpp:196
AbstractAspect::insertChild
void insertChild(AbstractAspect *child, int index)
Insert the given Aspect at a specific position in my list of children.
Definition: AbstractAspect.cpp:128
AbstractAspect::removeAllChildAspects
virtual void removeAllChildAspects()
Remove all child aspects.
Definition: AbstractAspect.cpp:352
AbstractAspect::index
int index() const
Return my position in my parent's list of children.
Definition: AbstractAspect.h:137
AbstractAspect::creationTime
QDateTime creationTime() const
Definition: AbstractAspect.cpp:288
Project
Represents a SciDAVis project.
Definition: Project.h:47
AbstractAspect::d_aspect_private
Private * d_aspect_private
Definition: AbstractAspect.h:310
AbstractAspect::isDescendantOf
bool isDescendantOf(AbstractAspect *other)
Return whether the there is a path upwards to the given aspect.
Definition: AbstractAspect.cpp:325
AbstractAspect::descendantsThatInherit
QList< AbstractAspect * > descendantsThatInherit(const char *class_name)
Get all descendents that inherit the given class.
Definition: AbstractAspect.cpp:342
future::Folder
Folder in a project.
Definition: future_Folder.h:38
AbstractAspect::uniqueNameFor
QString uniqueNameFor(const QString &current_name) const
Make the specified name unique among my children by incrementing a trailing number.
Definition: AbstractAspect.cpp:337
AbstractAspect::icon
virtual QIcon icon() const
Return an icon to be used for decorating my views.
Definition: AbstractAspect.cpp:298
AbstractAspect::aspectAboutToBeRemoved
void aspectAboutToBeRemoved(const AbstractAspect *parent, int index)
Emit this from a parent before removing its child.
AbstractAspect::indexOfChild
int indexOfChild(const AbstractAspect *child) const
Return the position of child in my list of children.
Definition: AbstractAspect.cpp:191
AbstractAspect::~AbstractAspect
virtual ~AbstractAspect()
Definition: AbstractAspect.cpp:47
AbstractAspect::endMacro
void endMacro()
End the undo stack macro.
Definition: AbstractAspect.cpp:222
AbstractAspect::captionSpec
QString captionSpec() const
Return the specification string used for constructing the caption().
Definition: AbstractAspect.cpp:271
AbstractAspect::beginMacro
void beginMacro(const QString &text)
Begin an undo stack macro (series of commands)
Definition: AbstractAspect.cpp:215
AbstractAspect::statusInfo
void statusInfo(const QString &text)
Emit this to give status information to the user.
AbstractAspect::load
virtual bool load(XmlStreamReader *)
Load from XML.
Definition: AbstractAspect.h:217
AbstractAspect::childCount
int childCount() const
Return the number of child Aspects.
Definition: AbstractAspect.cpp:186
AbstractAspect::caption
QString caption() const
Definition: AbstractAspect.cpp:293
AbstractAspect::completeAspectInsertion
virtual void completeAspectInsertion(AbstractAspect *aspect, int index)
Called after a new child has been inserted or added.
Definition: AbstractAspect.h:294
AbstractAspect::Private
Private data managed by AbstractAspect.
Definition: AspectPrivate.h:42
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
AbstractAspect::path
virtual QString path() const
Return the path that leads from the top-most Aspect (usually a Project) to me.
Definition: AbstractAspect.h:154
AbstractAspect::readBasicAttributes
bool readBasicAttributes(XmlStreamReader *reader)
Load name, creation time and caption spec from XML.
Definition: AbstractAspect.cpp:77
AbstractAspect::child
AbstractAspect * child(int index) const
Get a child by its position in my list of children.
Definition: AbstractAspect.cpp:180
AbstractAspect::undoStack
virtual QUndoStack * undoStack() const
Return the undo stack of the Project, or 0 if this Aspect is not part of a Project.
Definition: AbstractAspect.h:182
AbstractAspect::aspectDescriptionAboutToChange
void aspectDescriptionAboutToChange(const AbstractAspect *aspect)
Emit this before the name, comment or caption spec is changed.
AbstractAspect::aspectAdded
void aspectAdded(const AbstractAspect *parent, int index)
Emit this from a parent after adding a new child to it.
AbstractAspect::parentAspect
AbstractAspect * parentAspect() const
Return my parent Aspect or 0 if I currently don't have one.
Definition: AbstractAspect.cpp:109
AbstractAspect::setGlobalDefault
static void setGlobalDefault(const QString &key, const QVariant &value)
Set default value for a global setting.
Definition: AbstractAspect.cpp:375
AbstractAspect::aspectDescriptionChanged
void aspectDescriptionChanged(const AbstractAspect *aspect)
Emit this when the name, comment or caption spec changed.
AbstractAspect::writeBasicAttributes
void writeBasicAttributes(QXmlStreamWriter *writer) const
Save name, creation time and caption spec to XML.
Definition: AbstractAspect.cpp:70
AbstractAspect::folder
future::Folder * folder()
Return the folder the Aspect is contained in or 0 if not.
Definition: AbstractAspect.cpp:316
AbstractAspect::removeChild
void removeChild(AbstractAspect *child, bool detach=false)
Remove the given Aspect from my list of children.
Definition: AbstractAspect.cpp:142
AbstractAspect::project
virtual const Project * project() const
Return the Project this Aspect belongs to, or 0 if it is currently not part of one.
Definition: AbstractAspect.h:150
AbstractAspect::setCaptionSpec
void setCaptionSpec(const QString &value)
Set the specification string used for constructing the caption().
Definition: AbstractAspect.cpp:276
AbstractAspect::setName
void setName(const QString &value)
Definition: AbstractAspect.cpp:234
AbstractAspect::comment
QString comment() const
Definition: AbstractAspect.cpp:260
AbstractAspect::project
virtual Project * project()
Return the Project this Aspect belongs to, or 0 if it is currently not part of one.
Definition: AbstractAspect.h:152
AbstractAspect::addChild
void addChild(AbstractAspect *child)
Add the given Aspect to my list of children.
Definition: AbstractAspect.cpp:114
AbstractAspect::remove
virtual void remove()
Remove me from my parent's list of children.
Definition: AbstractAspect.h:250
AbstractAspect::setGlobal
static void setGlobal(const QString &key, const QVariant &value)
Update a global setting.
Definition: AbstractAspect.cpp:370
AbstractAspect::AbstractAspect
AbstractAspect(const QString &name)
Definition: AbstractAspect.cpp:42
AbstractAspect::setCreationTime
void setCreationTime(const QDateTime &time)
Set the creation time.
Definition: AbstractAspect.cpp:282
AbstractAspect::aspectAboutToBeRemoved
void aspectAboutToBeRemoved(const AbstractAspect *aspect)
Emit this from an aspect about to be removed from its parent's children.
AbstractAspect::save
virtual void save(QXmlStreamWriter *) const
Save as XML.
Definition: AbstractAspect.h:201
AbstractAspect::aspectAdded
void aspectAdded(const AbstractAspect *aspect)
Emit this from a newly added aspect.
AbstractAspect::readCommentElement
bool readCommentElement(XmlStreamReader *reader)
Load comment from an XML element.
Definition: AbstractAspect.cpp:61
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
AbstractAspect::prepareAspectRemoval
virtual void prepareAspectRemoval(AbstractAspect *aspect)
Called before a child is removed.
Definition: AbstractAspect.h:300
AbstractAspect::info
void info(const QString &text)
Implementations should call this whenever status information should be given to the user.
Definition: AbstractAspect.h:307