All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions | Protected Member Functions
GeopsyCore::AbstractSignalGroup Class Reference

Brief description of class still missing. More...

#include <AbstractSignalGroup.h>

Inheritance diagram for GeopsyCore::AbstractSignalGroup:
QGpCoreTools::TreeContainer QGpCoreTools::TreeItem QGpCoreTools::XMLClass GeopsyCore::DefaultSignalGroup GeopsyCore::MasterSignalGroup GeopsyCore::SignalGroup GeopsyCore::SignalGroupFolder GeopsyCore::AllFilesGroup GeopsyCore::AllSignalsGroup GeopsyCore::PermanentFilesGroup GeopsyCore::TemporaryFilesGroup GeopsyCore::TemporarySignalsGroup GeopsyCore::AbstractSignalResults GeopsyCore::StationGroup

List of all members.

Public Member Functions

 AbstractSignalGroup (AbstractSignalGroup *parent=0)
AbstractSignalGroupchildAt (int index)
QString comments () const
bool contains (const Signal *sig) const
virtual bool convertIds (const QHash< int, Signal * > &ids)
virtual bool directlyContains (const Signal *sig) const
AbstractSignalGroupfind (QString name) const
QList< AbstractSignalGroup * > find (const Signal *sig) const
virtual bool hasOwnSignal () const
virtual const QIcon * icon () const
bool isModified () const
virtual QString name () const
AbstractSignalGroupparent ()
const AbstractSignalGroupparent () const
QString pathName () const
void printList (QString prefix)
virtual bool readOnly () const
virtual bool readOnlyChildren () const
virtual void removeSignal (Signal *sig)
void setComments (const QString &c)
void setModified (bool m)
virtual void setName (const QString &n)
virtual void setParent (AbstractSignalGroup *p)
virtual int signalCount () const
virtual bool stored () const
virtual SubSignalPool subPool () const
virtual ~AbstractSignalGroup ()

Static Public Member Functions

static bool lessThan (AbstractSignalGroup *g1, AbstractSignalGroup *g2)

Protected Member Functions

virtual void reportDataChanged (AbstractSignalGroup *g) const
virtual void reportParentAboutToBeChanged (AbstractSignalGroup *g, AbstractSignalGroup *newParent) const
virtual void reportParentChanged (AbstractSignalGroup *g, AbstractSignalGroup *oldParent) const
virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual void xml_polishChild (XML_POLISHCHILD_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
void xml_writeChildren (XML_WRITECHILDREN_ARGS) const
virtual void xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Constructor with parent group.

if reportParentAboutToBeChanged() and reportParentChanged() are re-implemented parent must be null.

See also:
MasterSignalGroup()

References reportParentAboutToBeChanged(), reportParentChanged(), setParent(), and TRACE.

    : TreeContainer(), _modified(false)
  {
    TRACE;
    // report...() functions are re-implemented only in MasterSignalGroup
    // For all other classes, these calls are not virtual, hence
    // a constructor call is fine.
    // Current parent is null, the access to Master is possible only through parent.
    if(parent) {
      parent->reportParentAboutToBeChanged(this, parent);
      TreeContainer::setParent(parent);
      parent->reportParentChanged(this, 0);
    }
  }
{}

Member Function Documentation

Reimplemented from QGpCoreTools::TreeContainer.

Referenced by GeopsyCore::MasterSignalGroup::clear().

{return static_cast<AbstractSignalGroup *>(TreeContainer::childAt(index));}
QString GeopsyCore::AbstractSignalGroup::comments ( ) const [inline]

Returns true if this group contains signal sig.

See also:
directlyContains()

References QGpCoreTools::TreeContainer::begin(), directlyContains(), QGpCoreTools::TreeContainer::end(), and TRACE.

Referenced by MonoStation::CategoryGroupItem::belongsTo().

  {
    TRACE;
    if(directlyContains(sig)) {
      return true;
    }
    for(const_iterator it=begin(); it!=end(); ++it) {
      if(static_cast<AbstractSignalGroup *>(*it)->contains(sig)) {
        return true;
      }
    }
    return false;
  }
bool GeopsyCore::AbstractSignalGroup::convertIds ( const QHash< int, Signal * > &  ids) [virtual]

Converts id values according to ids. This is necessary after loading groups from an XML stream.

Reimplemented in GeopsyCore::SignalGroup, and GeopsyCore::DefaultSignalGroup.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), and TRACE.

Referenced by GeopsyCore::SignalDB::xml_polish().

  {
    TRACE;
    for(iterator it=begin(); it!=end(); ++it) {
      if(!static_cast<AbstractSignalGroup *>(*it)->convertIds(ids)) {
        return false;
      }
    }
    return true;
  }
bool GeopsyCore::AbstractSignalGroup::directlyContains ( const Signal sig) const [virtual]

Returns true if this group directly contains signal sig. For instance, a folder containing a group with signal sig does not directly contain the signal.

See also:
contains(), find()

Reimplemented in GeopsyCore::SignalGroup.

References TRACE.

Referenced by contains().

  {
    TRACE;
    Q_UNUSED(sig);
    return false;
  }

Returns group with name if any in the children list. Name may contains '/' to access sub-groups. name may start with '/' but all group names are always absolute, there is not relative paths.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), find(), name(), and TRACE.

Referenced by MonoStation::WinResults::categoriesToGroups(), find(), and GeopsyCore::SignalDB::findGroup().

  {
    TRACE;
    int sepIndex=name.indexOf("/");
    QString subName;
    switch(sepIndex) {
    case -1:
      break;
    case 0: // First character is '/'
      name=name.mid(1);
      sepIndex=name.indexOf("/");
      if(sepIndex>-1) {
        subName=name.mid(sepIndex+1);
        name=name.left(sepIndex);
      }
      break;
    default:
      subName=name.mid(sepIndex+1);
      name=name.left(sepIndex);
      break;
    }
    for(const_iterator it=begin(); it!=end(); ++it) {
      AbstractSignalGroup * g=static_cast<AbstractSignalGroup *>(*it);
      if(g->name()==name) {
        if(subName.isEmpty())
          return g;
        else
          return g->find(subName);
      }
    }
    return 0;
  }

Returns the list of groups in the children list which contains sig.

Currently this is used only for reporting to user group ownership of temporary signals.

References find(), and TRACE.

  {
    TRACE;
    QList<AbstractSignalGroup *> groups;
    find(groups, sig);
    return groups;
  }
int GeopsyCore::AbstractSignalGroup::hasOwnSignal ( ) const [inline, virtual]

Returns true if there are signals owned only by this group.

Returns true.

Reimplemented in GeopsyCore::SignalGroup, and GeopsyCore::DefaultSignalGroup.

Referenced by GeopsyGui::SignalGroupItem::data().

{return false;}
const QIcon * GeopsyCore::AbstractSignalGroup::icon ( ) const [virtual]

Used to display an icon related to the type of group. For core groups (SignalGroupFolder and SignalGroup) a null value is returned, and standard icon are displayed.

In any re-implementation, never return a newly allocated icon. Instead return a pointer to a static QIcon.

Referenced by GeopsyGui::SignalGroupItem::data().

  {
    return 0;
  }

Returns true if this group has been modified since last save/load. If not modified, it still returns true if one of its children is modified.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), isModified(), and TRACE.

Referenced by isModified(), and GeopsyCore::SignalDB::isModified().

  {
    TRACE;
    if(_modified) return true;
    for(const_iterator it=begin(); it!=end(); ++it) {
      AbstractSignalGroup * g=static_cast<AbstractSignalGroup *>(*it);
      if(g->isModified()) {
        return true;
      }
    }
    return false;
  }

References name(), and TRACE.

  {
    TRACE;
    return g1->name()<g2->name();
  }
virtual QString GeopsyCore::AbstractSignalGroup::name ( ) const [inline, virtual]

Reimplemented from QGpCoreTools::TreeItem.

{return static_cast<const AbstractSignalGroup *>(TreeContainer::parent());}

Returns group's full path.

References name(), parent(), and TRACE.

Referenced by GeopsyCore::SignalGroup::convertIds(), and WaveformConsole::subtractSignals().

  {
    TRACE;
    const AbstractSignalGroup * p=parent();
    if(p) {
      return p->pathNameHelper()+"/"+name();
    } else {
      return name();
    }
  }

Prints a list of all children paths. Root folder is ignored.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), QGpCoreTools::endl(), name(), parent(), printList(), and TRACE.

Referenced by modeGroupList(), and printList().

  {
    TRACE;
    if(parent()) {
      if(!prefix.isEmpty()) {
        prefix+="/";
      }
      prefix+=name();
      App::stream() << prefix << endl;
    }
    for(const_iterator it=begin(); it!=end(); ++it) {
      static_cast<AbstractSignalGroup *>(*it)->printList(prefix);
    }
  }
virtual bool GeopsyCore::AbstractSignalGroup::readOnly ( ) const [inline, virtual]
virtual bool GeopsyCore::AbstractSignalGroup::readOnlyChildren ( ) const [inline, virtual]

Reimplemented in GeopsyCore::SignalGroupFolder.

Referenced by GeopsyGui::SignalGroupItem::flags().

{return false;}

Removes one signal sig from group.

Reimplemented in GeopsyCore::SignalGroup, and GeopsyCore::DefaultSignalGroup.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), removeSignal(), and TRACE.

Referenced by GeopsyCore::SignalDB::removeFile(), and removeSignal().

  {
    TRACE;
    for(const_iterator it=begin();it!=end();++it) {
      static_cast<AbstractSignalGroup *>(*it)->removeSignal(sig);
    }
  }

Reports a data modification to the top of the tree. To exploit this feature, you must have a MasterSignalGroup at the top of the tree.

Reimplemented in GeopsyCore::MasterSignalGroup.

References parent(), and reportDataChanged().

Referenced by reportDataChanged(), and setModified().

  {
    const AbstractSignalGroup * p=parent();
    if(p) {
      p->reportDataChanged(g);
    }
  }

Reports a parent change to the top of the tree. To exploit this feature, you must have a MasterSignalGroup at the top of the tree.

reportParentAboutToBeChanged() and reportParentChanged() must be called one after the other with the same group and g cannot be this.

Reimplemented in GeopsyCore::MasterSignalGroup.

References parent(), and reportParentAboutToBeChanged().

Referenced by AbstractSignalGroup(), reportParentAboutToBeChanged(), and setParent().

  {
    // If current parent is null nothing is reported to Master group.
    // There must be at least one of new and old parent that is not null.
    ASSERT(g!=this);
    const AbstractSignalGroup * p=parent();
    if(p) {
      p->reportParentAboutToBeChanged(g, newParent);
    }
  }
void GeopsyCore::AbstractSignalGroup::reportParentChanged ( AbstractSignalGroup g,
AbstractSignalGroup oldParent 
) const [protected, virtual]

Reports a parent change to the top of the tree. To exploit this feature, you must have a MasterSignalGroup at the top of the tree.

reportParentAboutToBeChanged() and reportParentChanged() must be called one after the other with the same group and g cannot be this.

Reimplemented in GeopsyCore::MasterSignalGroup.

References parent(), and reportParentChanged().

Referenced by AbstractSignalGroup(), reportParentChanged(), and setParent().

  {
    // If new parent is null nothing is reported to Master group.
    // There must be at least one of new and old parent that is not null.
    ASSERT(g!=this);
    const AbstractSignalGroup * p=parent();
    if(p) {
      p->reportParentChanged(g, oldParent);
    }
  }
void GeopsyCore::AbstractSignalGroup::setComments ( const QString &  c)
void GeopsyCore::AbstractSignalGroup::setName ( const QString &  n) [virtual]

Reparent this group. Modified flag is changed if parent is changed. New parent must belong to the same tree as the current parent. To move one group from one tree to another, first set parent to null and then insert it in the new tree.

References QGpCoreTools::endl(), QGpCoreTools::TreeItem::isValidParent(), parent(), reportParentAboutToBeChanged(), reportParentChanged(), setModified(), QGpCoreTools::tr(), and TRACE.

Referenced by AbstractSignalGroup(), MonoStation::WinResults::categoriesToGroups(), GeopsyCore::MasterSignalGroup::clear(), GeopsyMainWindow::createNewGroup(), GeopsyGui::SignalGroupItem::dropMimeData(), GroupView::properties(), xml_member(), and xml_polishChild().

  {
    TRACE;
    AbstractSignalGroup * oldp=parent();
    if(p!=oldp) {
      if(isValidParent(p)) {
        ASSERT(isSameMaster(oldp, p));
        if(p) {
          p->reportParentAboutToBeChanged(this, p);
          TreeContainer::setParent(p);
          p->reportParentChanged(this, oldp);
          setModified(true);
        } else {
          oldp->reportParentAboutToBeChanged(this, p);
          TreeContainer::setParent(p);
          oldp->reportParentChanged(this, oldp);
          oldp->setModified(true); // Old parent lost a child, changing modification status of this group has no effect
                                   // on global modification status of the tree because this group is likely to be deleted.
        }
      } else {
        App::stream() << tr("SignalGroup::setParent: circular reference detected") << endl;
      }
    }
  }

Returns the number of signals contained in all its children.

Reimplemented in GeopsyCore::SignalGroup.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), signalCount(), and TRACE.

Referenced by SubtractGroupItem::flags(), GroupProperties::setValues(), and signalCount().

  {
    TRACE;
    int nSigs=0;
    for(const_iterator it=begin(); it!=end(); ++it) {
      nSigs+=static_cast<AbstractSignalGroup *>(*it)->signalCount();
    }
    return nSigs;
  }
virtual bool GeopsyCore::AbstractSignalGroup::stored ( ) const [inline, virtual]

Reimplemented in GeopsyCore::SignalGroupFolder.

Referenced by xml_writeChildren().

{return true;}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

Reimplemented in GeopsyCore::SignalGroup, GeopsyCore::DefaultSignalGroup, and GeopsyCore::MasterSignalGroup.

References GeopsyCore::SignalGroupFactory::create(), GeopsyCore::SignalResultsFactory::create(), QGpCoreTools::endl(), QGpCoreTools::XMLClassFactory::id(), GeopsyCore::SignalResultsFactory::instance(), GeopsyCore::SignalGroupFactory::instance(), GeopsyCore::SignalDB::setName(), setParent(), QGpCoreTools::tr(), and TRACE.

  {
    TRACE;
    if(tag.size()>0) {
      switch (tag[0].unicode()) {
      case 'c':
        if(tag=="comments") return XMLMember(1);
        break;
      case 'n':
        if(tag=="name") return XMLMember(0);
        break;
      case 'f':
        if(tag=="folder") return XMLMember(XMLMember::Skip);         // Kept for compatibility
        break;
      default: {
          AbstractSignalGroup * g=SignalGroupFactory::instance()->create(tag.toString());
          if(g) {
            g->setParent(this);
            return XMLMember(g);
          }
        }
        break;
      }
    }
    // Custom group types
    int id=SignalResultsFactory::instance()->id(tag.toString());
    if(id>-1) {
      AbstractSignalResults * r=SignalResultsFactory::instance()->create(id);
      r->TreeContainer::setParent(this); // Avoid modified flag
      return XMLMember(r);
    } else {
      App::stream() << tr("Unknown result type '%1', probably a missing plugin.\n"
                          "You may loose some results if you save the database!").arg(tag.toString()) << endl;
      SignalDB * db=static_cast<SignalDB *>(context);
      db->setName(QString::null); // Forces saveAs() and avoid overwriting
      return XMLMember(new SignalGroup(this));
    }
    return TreeContainer::xml_member(tag, attributes, context)+2;
  }

Reimplemented from QGpCoreTools::XMLClass.

References comments(), GeopsyCore::SignalGroup::hasIds(), name(), parent(), setComments(), setName(), setParent(), QGpCoreTools::TreeContainer::takeChildren(), TRACE, and GeopsyCore::SignalDB::version().

  {
    TRACE;
    SignalDB * db=static_cast<SignalDB *>(context);
    if(db->version()<5) { // Kept for compatibility
      SignalGroup * g=static_cast<SignalGroup *>(child);
      if(!g->hasIds()) { // A group with obsolete folder property set to true and no ids
        SignalGroupFolder * f=new SignalGroupFolder(g->parent());
        f->setName(g->name());
        f->setComments(g->comments());
        f->takeChildren(g);
        g->setParent(0);
        delete g;
      }
    }
  }

Re-implement this function to offer XML restore properties support to your class.

From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).

For a general case:

  Q_UNUSED(attributes);
  double val=content.toDouble();
  switch (memberID) {
  case 0:
    _x1=val;
    return true;
  case 1:
    _y1=val;
    return true;
  case 2:
    _x2=val;
    return true;
  case 3:
    _y2=val;
    return true;
  default:
    return false;
  }

For classes inheriting other classes (see also xml_member())

  switch (memberID) {
  case 0:
    _anInteger=content.toString();
    return true;
  case 1:
    _aString=content.toInt();
    return true;
  case 2:
    _aDouble=content.toDouble();
    return true;
  default:
    return AbstractLine::xml_setProperty(memberID-3, map, content);

For the arguments of this function use Macro XML_SETPROPERTY_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

Reimplemented in GeopsyCore::SignalGroup.

References setComments(), setName(), and TRACE.

  {
    TRACE;
    switch (memberID) {
    case 0:
      setName(content.toString());
      return true;
    case 1:
      setComments(content.toString());
      return true;
    default:
      return TreeContainer::xml_setProperty(memberID-2, tag, attributes, content, context);
    }
  }

Saves all children to an XML structure.

Reimplemented from QGpCoreTools::TreeContainer.

Reimplemented in GeopsyCore::DefaultSignalGroup.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::end(), stored(), TRACE, and QGpCoreTools::XMLClass::xml_save().

  {
    TRACE;
    Q_UNUSED(context);
    for(const_iterator it=begin(); it!=end(); ++it) {
      AbstractSignalGroup * g=static_cast<AbstractSignalGroup *>(*it);
      if(g->stored()) {
        g->xml_save(s, context);
      }
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines