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::Private Class Reference

Private data managed by AbstractAspect. More...

#include <AspectPrivate.h>

Collaboration diagram for AbstractAspect::Private:
[legend]

Public Member Functions

 Private (AbstractAspect *owner, const QString &name)
 
 ~Private ()
 
void addChild (AbstractAspect *child)
 
void insertChild (int index, AbstractAspect *child)
 
int indexOfChild (const AbstractAspect *child) const
 
int removeChild (AbstractAspect *child)
 
int childCount () const
 
AbstractAspectchild (int index)
 
QString name () const
 
void setName (const QString &value)
 
QString comment () const
 
void setComment (const QString &value)
 
QString captionSpec () const
 
void setCaptionSpec (const QString &value)
 
QDateTime creationTime () const
 
void setCreationTime (const QDateTime &time)
 
QString caption () const
 
AbstractAspectowner ()
 
AbstractAspectparent ()
 
QString uniqueNameFor (const QString &current_name) const
 

Static Public Attributes

static QSettings * g_settings
 
static QHash< QString, QVariant > g_defaults
 

Static Private Member Functions

static int indexOfMatchingBrace (const QString &str, int start)
 

Private Attributes

QList< AbstractAspect * > d_children
 
QString d_name
 
QString d_comment
 
QString d_caption_spec
 
QDateTime d_creation_time
 
AbstractAspectd_owner
 
AbstractAspectd_parent
 

Detailed Description

Private data managed by AbstractAspect.

File : AspectPrivate.h

Project : SciDAVis

Copyright : (C) 2007 by Knut Franke, Tilman Benkert Email (use @ for *) : knut.franke*gmx.de, thzs*gmx.net Description : Private data managed by AbstractAspect.

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 41 of file AspectPrivate.h.

Constructor & Destructor Documentation

◆ Private()

AbstractAspect::Private::Private ( AbstractAspect owner,
const QString &  name 
)

Definition at line 44 of file AspectPrivate.cpp.

45  : d_name(name.isEmpty() ? "1" : name), d_caption_spec("%n%C{ - }%c"), d_owner(owner), d_parent(0)
46 {
47  d_creation_time = QDateTime::currentDateTime();
48 }

References d_creation_time.

◆ ~Private()

AbstractAspect::Private::~Private ( )

Definition at line 50 of file AspectPrivate.cpp.

51 {
52  foreach(AbstractAspect * child, d_children)
53  delete child;
54 }

References AbstractAspect::child().

Here is the call graph for this function:

Member Function Documentation

◆ addChild()

void AbstractAspect::Private::addChild ( AbstractAspect child)

Definition at line 56 of file AspectPrivate.cpp.

57 {
58  insertChild(d_children.count(), child);
59 }

References AbstractAspect::child(), and AbstractAspect::insertChild().

Here is the call graph for this function:

◆ caption()

QString AbstractAspect::Private::caption ( ) const

Definition at line 171 of file AspectPrivate.cpp.

172 {
173  QString result = d_caption_spec;
174  QRegExp magic("%(.)");
175  for(int pos=magic.indexIn(result, 0); pos >= 0; pos=magic.indexIn(result, pos)) {
176  QString replacement;
177  int length;
178  switch(magic.cap(1).at(0).toLatin1()) {
179  case '%': replacement = "%"; length=2; break;
180  case 'n': replacement = d_name; length=2; break;
181  case 'c': replacement = d_comment; length=2; break;
182  case 't': replacement = d_creation_time.toString(); length=2; break;
183  case 'C':
184  length = indexOfMatchingBrace(result, pos) - pos + 1;
185  replacement = d_comment.isEmpty() ? "" : result.mid(pos+3, length-4);
186  break;
187  default:
188  throw runtime_error("Invalid magic cap");
189  }
190  result.replace(pos, length, replacement);
191  pos += replacement.size();
192  }
193  return result;
194 }

Referenced by AbstractAspect::caption().

Here is the caller graph for this function:

◆ captionSpec()

QString AbstractAspect::Private::captionSpec ( ) const

Definition at line 146 of file AspectPrivate.cpp.

147 {
148  return d_caption_spec;
149 }

Referenced by AbstractAspect::captionSpec(), AspectCaptionSpecChangeCmd::redo(), and AbstractAspect::setCaptionSpec().

Here is the caller graph for this function:

◆ child()

AbstractAspect * AbstractAspect::Private::child ( int  index)

Definition at line 116 of file AspectPrivate.cpp.

117 {
118  Q_ASSERT(index >= 0 && index <= childCount());
119  return d_children.at(index);
120 }

References AbstractAspect::childCount(), and AbstractAspect::index().

Referenced by AbstractAspect::child(), AspectChildMoveCmd::redo(), AbstractAspect::removeChild(), and AspectChildMoveCmd::undo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ childCount()

int AbstractAspect::Private::childCount ( ) const

Definition at line 111 of file AspectPrivate.cpp.

112 {
113  return d_children.count();
114 }

Referenced by AbstractAspect::addChild(), and AbstractAspect::childCount().

Here is the caller graph for this function:

◆ comment()

QString AbstractAspect::Private::comment ( ) const

Definition at line 134 of file AspectPrivate.cpp.

135 {
136  return d_comment;
137 }

Referenced by AbstractAspect::comment(), AspectCommentChangeCmd::redo(), and AbstractAspect::setComment().

Here is the caller graph for this function:

◆ creationTime()

QDateTime AbstractAspect::Private::creationTime ( ) const

Definition at line 196 of file AspectPrivate.cpp.

197 {
198  return d_creation_time;
199 }

Referenced by AbstractAspect::creationTime(), AspectCreationTimeChangeCmd::redo(), and AbstractAspect::setCreationTime().

Here is the caller graph for this function:

◆ indexOfChild()

int AbstractAspect::Private::indexOfChild ( const AbstractAspect child) const

Definition at line 91 of file AspectPrivate.cpp.

92 {
93  for(int i=0; i<d_children.size(); i++)
94  if(d_children.at(i) == child) return i;
95  return -1;
96 }

References AbstractAspect::child().

Referenced by AbstractAspect::indexOfChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexOfMatchingBrace()

int AbstractAspect::Private::indexOfMatchingBrace ( const QString &  str,
int  start 
)
staticprivate

Definition at line 163 of file AspectPrivate.cpp.

164 {
165  int result = str.indexOf('}', start);
166  if (result < 0)
167  result = start;
168  return result;
169 }

References str.

◆ insertChild()

void AbstractAspect::Private::insertChild ( int  index,
AbstractAspect child 
)

Definition at line 61 of file AspectPrivate.cpp.

62 {
64  d_children.insert(index, child);
65  // Always remove from any previous parent before adding to a new one!
66  // Can't handle this case here since two undo commands have to be created.
67  Q_ASSERT(child->d_aspect_private->d_parent == 0);
69  connect(child, SIGNAL(aspectDescriptionAboutToChange(const AbstractAspect *)),
71  connect(child, SIGNAL(aspectDescriptionChanged(const AbstractAspect *)),
73  connect(child, SIGNAL(aspectAboutToBeAdded(const AbstractAspect *, int)),
74  d_owner, SIGNAL(aspectAboutToBeAdded(const AbstractAspect *, int)));
75  connect(child, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect *, int)),
76  d_owner, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect *, int)));
77  connect(child, SIGNAL(aspectAdded(const AbstractAspect *, int)),
78  d_owner, SIGNAL(aspectAdded(const AbstractAspect *, int)));
79  connect(child, SIGNAL(aspectRemoved(const AbstractAspect *, int)),
80  d_owner, SIGNAL(aspectRemoved(const AbstractAspect *, int)));
81  connect(child, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect *)),
83  connect(child, SIGNAL(aspectAdded(const AbstractAspect *)),
84  d_owner, SIGNAL(aspectAdded(const AbstractAspect *)));
85  connect(child, SIGNAL(statusInfo(const QString&)),
86  d_owner, SIGNAL(statusInfo(const QString&)));
88  emit child->aspectAdded(child);
89 }

References AbstractAspect::aspectAboutToBeAdded(), AbstractAspect::aspectAboutToBeRemoved(), AbstractAspect::aspectAdded(), AbstractAspect::aspectDescriptionAboutToChange(), AbstractAspect::aspectDescriptionChanged(), AbstractAspect::aspectRemoved(), AbstractAspect::child(), AbstractAspect::d_aspect_private, d_parent, AbstractAspect::index(), and AbstractAspect::statusInfo().

Referenced by AspectChildMoveCmd::redo(), AspectChildReparentCmd::redo(), AspectChildRemoveCmd::undo(), AspectChildMoveCmd::undo(), and AspectChildReparentCmd::undo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

◆ owner()

AbstractAspect* AbstractAspect::Private::owner ( )
inline

Definition at line 64 of file AspectPrivate.h.

64 { return d_owner; }

References d_owner.

◆ parent()

AbstractAspect* AbstractAspect::Private::parent ( )
inline

Definition at line 65 of file AspectPrivate.h.

65 { return d_parent; }

References d_parent.

Referenced by AbstractAspect::parentAspect(), and AbstractAspect::setName().

Here is the caller graph for this function:

◆ removeChild()

int AbstractAspect::Private::removeChild ( AbstractAspect child)

Definition at line 98 of file AspectPrivate.cpp.

99 {
100  int index = indexOfChild(child);
101  Q_ASSERT(index != -1);
104  d_children.removeAll(child);
105  QObject::disconnect(child, 0, d_owner, 0);
108  return index;
109 }

References AbstractAspect::aspectAboutToBeRemoved(), AbstractAspect::aspectRemoved(), AbstractAspect::child(), AbstractAspect::d_aspect_private, d_parent, AbstractAspect::index(), and AbstractAspect::indexOfChild().

Referenced by AspectChildRemoveCmd::redo(), AspectChildMoveCmd::redo(), AspectChildReparentCmd::redo(), AspectChildMoveCmd::undo(), and AspectChildReparentCmd::undo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCaptionSpec()

void AbstractAspect::Private::setCaptionSpec ( const QString &  value)

Definition at line 151 of file AspectPrivate.cpp.

152 {
154  d_caption_spec = value;
156 }

Referenced by AspectCaptionSpecChangeCmd::redo().

Here is the caller graph for this function:

◆ setComment()

void AbstractAspect::Private::setComment ( const QString &  value)

Definition at line 139 of file AspectPrivate.cpp.

140 {
142  d_comment = value;
144 }

Referenced by AspectCommentChangeCmd::redo().

Here is the caller graph for this function:

◆ setCreationTime()

void AbstractAspect::Private::setCreationTime ( const QDateTime &  time)

Definition at line 158 of file AspectPrivate.cpp.

159 {
160  d_creation_time = time;
161 }

Referenced by AspectCreationTimeChangeCmd::redo().

Here is the caller graph for this function:

◆ setName()

void AbstractAspect::Private::setName ( const QString &  value)

Definition at line 127 of file AspectPrivate.cpp.

128 {
130  d_name = value;
132 }

Referenced by AspectNameChangeCmd::redo().

Here is the caller graph for this function:

◆ uniqueNameFor()

QString AbstractAspect::Private::uniqueNameFor ( const QString &  current_name) const

Definition at line 201 of file AspectPrivate.cpp.

202 {
203  QStringList child_names;
204  foreach(AbstractAspect * child, d_children)
205  child_names << child->name();
206 
207  if (!child_names.contains(current_name))
208  return current_name;
209 
210  QString base = current_name;
211  int last_non_digit;
212  for (last_non_digit = base.size()-1; last_non_digit>=0 &&
213  base[last_non_digit].category() == QChar::Number_DecimalDigit; --last_non_digit)
214  base.chop(1);
215  if (last_non_digit >=0 && base[last_non_digit].category() != QChar::Separator_Space)
216  base.append(" ");
217 
218  int new_nr = current_name.right(current_name.size() - base.size()).toInt();
219  QString new_name;
220  do
221  new_name = base + QString::number(++new_nr);
222  while (child_names.contains(new_name));
223 
224  return new_name;
225 }

References AbstractAspect::child(), and AbstractAspect::name().

Referenced by AbstractAspect::addChild(), AbstractAspect::insertChild(), AbstractAspect::reparentChild(), and AbstractAspect::uniqueNameFor().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ d_caption_spec

QString AbstractAspect::Private::d_caption_spec
private

Definition at line 75 of file AspectPrivate.h.

◆ d_children

QList< AbstractAspect* > AbstractAspect::Private::d_children
private

Definition at line 74 of file AspectPrivate.h.

◆ d_comment

QString AbstractAspect::Private::d_comment
private

Definition at line 75 of file AspectPrivate.h.

◆ d_creation_time

QDateTime AbstractAspect::Private::d_creation_time
private

Definition at line 76 of file AspectPrivate.h.

Referenced by Private().

◆ d_name

QString AbstractAspect::Private::d_name
private

Definition at line 75 of file AspectPrivate.h.

◆ d_owner

AbstractAspect* AbstractAspect::Private::d_owner
private

Definition at line 77 of file AspectPrivate.h.

Referenced by owner().

◆ d_parent

AbstractAspect* AbstractAspect::Private::d_parent
private

Definition at line 78 of file AspectPrivate.h.

Referenced by insertChild(), parent(), and removeChild().

◆ g_defaults

QHash< QString, QVariant > AbstractAspect::Private::g_defaults
static

Definition at line 70 of file AspectPrivate.h.

Referenced by AbstractAspect::global(), and AbstractAspect::setGlobalDefault().

◆ g_settings

QSettings * AbstractAspect::Private::g_settings
static
Initial value:
=
new QSettings(QSettings::NativeFormat, QSettings::UserScope, "SciDAVis", "SciDAVis")

Definition at line 69 of file AspectPrivate.h.

Referenced by AbstractAspect::global(), and AbstractAspect::setGlobal().


The documentation for this class was generated from the following files:
AbstractAspect::Private::d_parent
AbstractAspect * d_parent
Definition: AspectPrivate.h:78
AbstractAspect::aspectAboutToBeAdded
void aspectAboutToBeAdded(const AbstractAspect *parent, int index)
Emit this when a parent aspect is about to get a new child inserted.
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
AbstractAspect::Private::d_comment
QString d_comment
Definition: AspectPrivate.h:75
AbstractAspect::Private::indexOfMatchingBrace
static int indexOfMatchingBrace(const QString &str, int start)
Definition: AspectPrivate.cpp:163
AbstractAspect::Private::childCount
int childCount() const
Definition: AspectPrivate.cpp:111
AbstractAspect::index
int index() const
Return my position in my parent's list of children.
Definition: AbstractAspect.h:137
AbstractAspect::Private::d_children
QList< AbstractAspect * > d_children
Definition: AspectPrivate.h:74
AbstractAspect::d_aspect_private
Private * d_aspect_private
Definition: AbstractAspect.h:310
AbstractAspect::Private::indexOfChild
int indexOfChild(const AbstractAspect *child) const
Definition: AspectPrivate.cpp:91
AbstractAspect::statusInfo
void statusInfo(const QString &text)
Emit this to give status information to the user.
AbstractAspect::Private::d_name
QString d_name
Definition: AspectPrivate.h:75
AbstractAspect::Private::owner
AbstractAspect * owner()
Definition: AspectPrivate.h:64
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
AbstractAspect::Private::name
QString name() const
Definition: AspectPrivate.cpp:122
AbstractAspect::aspectDescriptionAboutToChange
void aspectDescriptionAboutToChange(const AbstractAspect *aspect)
Emit this before the name, comment or caption spec is changed.
AbstractAspect::aspectDescriptionChanged
void aspectDescriptionChanged(const AbstractAspect *aspect)
Emit this when the name, comment or caption spec changed.
AbstractAspect::Private::insertChild
void insertChild(int index, AbstractAspect *child)
Definition: AspectPrivate.cpp:61
AbstractAspect::Private::child
AbstractAspect * child(int index)
Definition: AspectPrivate.cpp:116
AbstractAspect::Private::d_owner
AbstractAspect * d_owner
Definition: AspectPrivate.h:77
AbstractAspect::aspectAboutToBeRemoved
void aspectAboutToBeRemoved(const AbstractAspect *aspect)
Emit this from an aspect about to be removed from its parent's children.
AbstractAspect::Private::d_creation_time
QDateTime d_creation_time
Definition: AspectPrivate.h:76
AbstractAspect::aspectAdded
void aspectAdded(const AbstractAspect *aspect)
Emit this from a newly added aspect.
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
AbstractAspect::Private::d_caption_spec
QString d_caption_spec
Definition: AspectPrivate.h:75