All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions
QGpCoreTools::XMLGenericItem Class Reference

Brief description of class still missing. More...

#include <XMLGenericItem.h>

Inheritance diagram for QGpCoreTools::XMLGenericItem:
QGpCoreTools::TreeContainer QGpCoreTools::TreeItem QGpCoreTools::XMLClass

List of all members.

Public Member Functions

void addAttribute (const QString &key, const QString &value=QString::null)
const XMLSaveAttributesattributes () const
XMLSaveAttributesattributes ()
XMLGenericItemchildAt (int index)
const XMLGenericItemchildAt (int index) const
QList< XMLGenericItem * > children (const QString &tag) const
void find (QList< XMLGenericItem * > &itemList, const XMLGenericItem *queryItem) const
bool isEnabled () const
bool isParentEnabled () const
XMLGenericItemparent ()
const XMLGenericItemparent () const
void setEnabled (bool e)
void setTag (const QString &tag)
void setValue (const QVariant &v)
const QVariant & value () const
virtual void xml_attributes (XML_ATTRIBUTES_ARGS) const
virtual bool xml_setAttributes (XML_SETATTRIBUTES_ARGS)
virtual const QString & xml_tagName () const
 XMLGenericItem (XMLGenericItem *parent=0)
 XMLGenericItem (const QString &tag, XMLGenericItem *parent=0)

Protected Member Functions

virtual TreeItemcreateNewItem (TreeItem *)
virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual bool xml_setBinaryData (XML_SETBINARYDATA_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
virtual 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

Default constructor with an empty tag.

Referenced by xml_member().

    : TreeContainer(parent), _enabled(true)
  {
  }
QGpCoreTools::XMLGenericItem::XMLGenericItem ( const QString &  tag,
XMLGenericItem parent = 0 
)

Constructor with tag.

    : TreeContainer(parent), _enabled(true), _tag(tag)
  {
  }

Member Function Documentation

void QGpCoreTools::XMLGenericItem::addAttribute ( const QString &  key,
const QString &  value = QString::null 
) [inline]

Referenced by xml_attributes(), xml_member(), xml_setAttributes(), and xml_setProperty().

{return _attributes;}
{return _attributes;}

Reimplemented from QGpCoreTools::TreeContainer.

References TRACE.

Referenced by childAt(), and find().

  {
    TRACE;
    return static_cast<XMLGenericItem *>(TreeContainer::childAt(index));
  }
const XMLGenericItem * QGpCoreTools::XMLGenericItem::childAt ( int  index) const [inline]

Reimplemented from QGpCoreTools::TreeContainer.

References childAt(), and TRACE.

  {
    TRACE;
    return static_cast<const XMLGenericItem *>(TreeContainer::childAt(index));
  }
QList< XMLGenericItem * > QGpCoreTools::XMLGenericItem::children ( const QString &  tag) const

Return item with tag. Only direct children are searched. tag can be a path to a sub-child

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

  {
    QList<XMLGenericItem *> cList;
    int pathSeparator=tag.indexOf("/");
    if(pathSeparator==-1) {
      for(const_iterator it=begin();it!=end();it++) {
        XMLGenericItem * item=static_cast<XMLGenericItem *>(*it);
        if(item->_tag==tag) {
          cList.append(item);
        }
      }
    } else {
      QString tag0=tag.left(pathSeparator);
      for(const_iterator it=begin();it!=end();it++) {
        XMLGenericItem * item=static_cast<XMLGenericItem *>(*it);
        if(item->_tag==tag0) {
          cList += children(tag.mid(pathSeparator+1));
        }
      }
    }
    return cList;
  }
virtual TreeItem* QGpCoreTools::XMLGenericItem::createNewItem ( TreeItem ) [inline, protected, virtual]
{return 0;}
void QGpCoreTools::XMLGenericItem::find ( QList< XMLGenericItem * > &  itemList,
const XMLGenericItem queryItem 
) const

Returns the list of items that match the same structure as (tag name, similar attributes and tree).

Set empty tags to match anything. If attributes are similar if they have at least those listed by queryItem. It their values are null, only the keyword name is considered.

References QGpCoreTools::TreeContainer::begin(), childAt(), QGpCoreTools::TreeContainer::childrenCount(), QGpCoreTools::TreeContainer::end(), find(), QGpCoreTools::XMLSaveAttributes::isEmpty(), QGpCoreTools::XMLSaveAttributes::isSimilar(), parent(), TRACE, and xml_tagName().

Referenced by find(), SciFigs::SciFigsXMLEditor::setAxisProperty(), SciFigs::SciFigsXMLEditor::setAxisWindowProperty(), and SciFigs::SciFigsXMLEditor::setLayers().

  {
    TRACE;
    for(const_iterator it=begin(); it!=end(); it++) {
      XMLGenericItem * item=static_cast<XMLGenericItem *>(*it);
      if(queryItem->xml_tagName().isEmpty() || item->xml_tagName()==queryItem->xml_tagName()) {
        if(queryItem->_attributes.isEmpty() || item->_attributes.isSimilar(queryItem->_attributes)) {
          if(queryItem->childrenCount()>0) {
            item->find(itemList, queryItem->childAt(0));
          } else {
            itemList.append(item);
          }
        }
      } else if(!queryItem->parent()) { // If still at root level for queryItem structure
        item->find(itemList, queryItem);
      }
    }
  }
bool QGpCoreTools::XMLGenericItem::isEnabled ( ) const [inline]

Referenced by QGpGuiTools::XMLItem::data().

{return _enabled;}

Returns true if the parent of this item is enabled. For root items (without parent), true is always returned.

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

Referenced by QGpGuiTools::XMLItem::flags(), and isParentEnabled().

  {
    TRACE;
    if(parent()) {
      if(parent()->_enabled) {
        return parent()->isParentEnabled();
      } else {
        return false;
      }
    } else {
      return true;
    }
  }

Reimplemented from QGpCoreTools::TreeItem.

References parent(), and TRACE.

  {
    TRACE;
    return static_cast<const XMLGenericItem *>(TreeContainer::parent());
  }
void QGpCoreTools::XMLGenericItem::setEnabled ( bool  e) [inline]
void QGpCoreTools::XMLGenericItem::setTag ( const QString &  tag) [inline]
void QGpCoreTools::XMLGenericItem::setValue ( const QVariant &  v) [inline]

Referenced by QGpGuiTools::XMLItem::setData().

{_value=v;}
const QVariant& QGpCoreTools::XMLGenericItem::value ( ) const [inline]

Referenced by QGpGuiTools::XMLItem::data(), and xml_writeProperties().

{return _value;}

Reimplemented from QGpCoreTools::XMLClass.

References attributes(), and TRACE.

Referenced by QGpGuiTools::XMLItem::data().

  {
    TRACE;
    Q_UNUSED(context);
    attributes=_attributes;
  }

Accept all members

Reimplemented from QGpCoreTools::XMLClass.

References attributes(), setTag(), TRACE, and XMLGenericItem().

  {
    TRACE;
    Q_UNUSED(context);
    Q_UNUSED(attributes); // Ignored here because we always return a child for which XMLParser sets automatically attributes.
    XMLGenericItem * o=new XMLGenericItem(this);
    o->setTag(tag.toString());
    // Returns a member either child or properties, we don't know at this time
    return XMLMember(o, false);
  }

Get the list of attributes

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::XMLSaveAttributes::add(), attributes(), QGpCoreTools::XMLSaveAttributes::clear(), and TRACE.

  {
    TRACE;
    Q_UNUSED(context);
    _attributes.clear();
    for(XMLRestoreAttributeIterator it=attributes.begin();it!=attributes.end();it++) {
      _attributes.add(it.key().toString(), it.value().toString());
    }
    return true;
  }

This function must be re-implemented in all classes dealing with binary data that cannot be saved in an ASCII xml file (e.g. due to the amount of data).

See also xml_writeBinaryData().

The difference between xml_setBinaryData() and xml_setBinaryData200410() is detected by the type of tag at the beginning of each block if it can be read with QString ==> 200510, else try with a normal C string, if it match the current tag then execute xml_setBinaryData200411().

See also xml_setBinaryData200411() to maintain compatibility with previous versions of xml storages.

For the arguments of this function use Macro XML_SETBINARYDATA_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References TRACE.

  {
    TRACE;
    Q_UNUSED(s);
    Q_UNUSED(context);
    return true;
  }

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.

References attributes(), and TRACE.

  {
    TRACE;
    Q_UNUSED(tag);
    Q_UNUSED(attributes);
    Q_UNUSED(memberID);
    Q_UNUSED(context);
    _value=content.toString();
    return true;
  }
virtual const QString& QGpCoreTools::XMLGenericItem::xml_tagName ( ) const [inline, virtual]

Reimplemented from QGpCoreTools::TreeItem.

Referenced by QGpGuiTools::XMLItem::data(), find(), and xml_writeProperties().

{return _tag;}

Saves all children to an XML structure.

Reimplemented from QGpCoreTools::TreeContainer.

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

  {
    TRACE;
    Q_UNUSED(context);
    for(const_iterator it=begin(); it!=end(); it++) {
      XMLGenericItem * item=static_cast<XMLGenericItem *>(*it);
      if(item->_enabled && item->childrenCount()>0) { // A children with children has real "real" children in the XMLClass sense
        item->xml_save(s, context, item->_attributes);
      }
    }
  }

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::TreeContainer::begin(), QGpCoreTools::TreeContainer::childrenCount(), QGpCoreTools::TreeContainer::end(), TRACE, value(), QGpCoreTools::XMLClass::writeProperty(), and xml_tagName().

  {
    TRACE;
    Q_UNUSED(context);
    for(const_iterator it=begin(); it!=end(); it++) {
      XMLGenericItem * item=static_cast<XMLGenericItem *>(*it);
      if(item->_enabled && item->childrenCount()==0) { // A children with no children is a property
        writeProperty(s, item->xml_tagName(), item->_attributes, item->value().toString());
      }
    }
  }

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