XML Mill  1.0.0
A GUI based XML editor with a memory.
Public Member Functions | Private Member Functions | Private Attributes
GCTreeWidgetItem Class Reference

Used by GCDomTreeWidget, each GCTreeWidgetItem can be associated with a QDomElement. More...

#include <gctreewidgetitem.h>

List of all members.

Public Member Functions

 GCTreeWidgetItem (QDomElement element)
 Constructor.
 GCTreeWidgetItem (QDomElement element, int index)
 Constructor.
GCTreeWidgetItemgcParent () const
 Returns this item's parent item as a GCTreeWidgetItem.
GCTreeWidgetItemgcChild (int index) const
 Returns this item's child item at "index" as a GCTreeWidgetItem.
QDomElement element () const
 Returns the associated element via QDomElement's default shallow copy constructor.
void setExcludeElement (bool exclude)
 Sets the "exclude" flag used to determine whether or not the element must be included in GCDomTreeWidget's DOM document (elements are included by default).
bool elementExcluded () const
 Returns "true" if the element should be excluded from the active document (elements are included by default).
void excludeAttribute (const QString &attribute)
 Removes "attribute" from the underlying DOM element.
void includeAttribute (const QString &attribute, const QString &value)
 Includes "attribute" with "value" in the underlying DOM element.
bool attributeIncluded (const QString &attribute) const
 Returns true if the underlying element contains "attribute".
void setIncrementAttribute (const QString &attribute, bool increment)
 Adds "attribute" to a list of attributes whose values must be incremented when multiple snippets are added to the active DOM.
bool incrementAttribute (const QString &attribute) const
 Returns true if "attribute" must be incremented automatically when multiple snippets are added to the active DOM.
void fixAttributeValues ()
 Takes a snapshot of the current attribute values so that element attributes may be incremented automatically with reference to (and without losing) the original values.
QString fixedValue (const QString &attribute) const
 Returns the fixed value saved against "attribute".
void revertToFixedValues ()
 Reverts to the attribute values set with the "fixedAttributeValues" call.
QString toString () const
 Provides a string representation of the element, its attributes and attribute values (including brackets and other XML characters).
void setIndex (int index)
 Sets the item's index to "index".
int index () const
 Returns the index associated with this element.
void rename (const QString &newName)
 Renames the element to "newName".
QString name () const
 Returns the element name.
void setVerbose (bool verbose)
 Sets the item's element display as "verbose".
void insertGcChild (int index, GCTreeWidgetItem *item)
 Inserts "item" at "index" and ensures that the corresponding DOM element is also inserted in the correct position (relative to the item's siblings).

Private Member Functions

void init (QDomElement element, int index)
 Initialise the item.
void setDisplayText ()
 Sets the item's text depending on the "verbose" flag.

Private Attributes

QDomElement m_element
bool m_elementExcluded
bool m_verbose
int m_index
QStringList m_includedAttributes
QStringList m_incrementedAttributes
QHash< QString, QString > m_fixedValues

Detailed Description

Used by GCDomTreeWidget, each GCTreeWidgetItem can be associated with a QDomElement.

Can be associated with a QDomElement in order to provide additional information in the XML Mill context regarding whether or not the element or any of its attributes should be excluded from the DOM document being built. This item DOES NOT OWN the QDomElement (hence all the non const return values...QDomElement's default copy constructor is shallow).

Some specialisation specific to GCAddSnippetsForm was added to this class (all functions related to incrementation and fixing of attribute values). The reason this functionality was added here is due to complications derived from the default shallow copy constructors of QDomAttr (I originally tried to use maps confined to GCAddSnippetForm objects, but to no avail).

Definition at line 51 of file gctreewidgetitem.h.


Constructor & Destructor Documentation

GCTreeWidgetItem::GCTreeWidgetItem ( QDomElement  element) [explicit]

Constructor.

Associates "element" with this item.

Definition at line 33 of file gctreewidgetitem.cpp.

GCTreeWidgetItem::GCTreeWidgetItem ( QDomElement  element,
int  index 
) [explicit]

Constructor.

Associates "element" with this item and assigns it an "index" which is used to determine the underlying DOM element's relative position within the DOM (roughly corresponding to "line numbers").

Definition at line 40 of file gctreewidgetitem.cpp.


Member Function Documentation

bool GCTreeWidgetItem::attributeIncluded ( const QString &  attribute) const

Returns true if the underlying element contains "attribute".

See also:
excludeAttribute
includeAttribute

Definition at line 150 of file gctreewidgetitem.cpp.

QDomElement GCTreeWidgetItem::element ( ) const

Returns the associated element via QDomElement's default shallow copy constructor.

Definition at line 96 of file gctreewidgetitem.cpp.

Returns "true" if the element should be excluded from the active document (elements are included by default).

See also:
setExcludeElement

Definition at line 122 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::excludeAttribute ( const QString &  attribute)

Removes "attribute" from the underlying DOM element.

See also:
includeAttribute
attributeIncluded

Definition at line 129 of file gctreewidgetitem.cpp.

Takes a snapshot of the current attribute values so that element attributes may be incremented automatically with reference to (and without losing) the original values.

See also:
incrementAttribute
setIncrementAttribute
fixedValue
revertToFixedValues

Definition at line 180 of file gctreewidgetitem.cpp.

QString GCTreeWidgetItem::fixedValue ( const QString &  attribute) const

Returns the fixed value saved against "attribute".

See also:
incrementAttribute
setIncrementAttribute
fixAttributeValues
revertToFixedValues

Definition at line 195 of file gctreewidgetitem.cpp.

Returns this item's child item at "index" as a GCTreeWidgetItem.

Definition at line 89 of file gctreewidgetitem.cpp.

Returns this item's parent item as a GCTreeWidgetItem.

Definition at line 82 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::includeAttribute ( const QString &  attribute,
const QString &  value 
)

Includes "attribute" with "value" in the underlying DOM element.

See also:
excludeAttribute
attributeIncluded

Definition at line 139 of file gctreewidgetitem.cpp.

bool GCTreeWidgetItem::incrementAttribute ( const QString &  attribute) const

Returns true if "attribute" must be incremented automatically when multiple snippets are added to the active DOM.

See also:
setIncrementAttribute
fixAttributeValues
fixedValue
revertToFixedValues

Definition at line 173 of file gctreewidgetitem.cpp.

int GCTreeWidgetItem::index ( ) const

Returns the index associated with this element.

Indices in this context are rough indications of an element's relative position within the DOM document (approximating "line numbers").

See also:
setIndex

Definition at line 270 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::init ( QDomElement  element,
int  index 
) [private]

Initialise the item.

Definition at line 47 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::insertGcChild ( int  index,
GCTreeWidgetItem item 
)

Inserts "item" at "index" and ensures that the corresponding DOM element is also inserted in the correct position (relative to the item's siblings).

Definition at line 305 of file gctreewidgetitem.cpp.

QString GCTreeWidgetItem::name ( ) const

Returns the element name.

Definition at line 285 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::rename ( const QString &  newName)

Renames the element to "newName".

Definition at line 277 of file gctreewidgetitem.cpp.

Reverts to the attribute values set with the "fixedAttributeValues" call.

See also:
setIncrementAttribute
incrementAttribute
fixAttributeValues
fixedValue

Definition at line 202 of file gctreewidgetitem.cpp.

Sets the item's text depending on the "verbose" flag.

See also:
setVerbose

Definition at line 66 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::setExcludeElement ( bool  exclude)

Sets the "exclude" flag used to determine whether or not the element must be included in GCDomTreeWidget's DOM document (elements are included by default).

See also:
elementExcluded

Definition at line 103 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::setIncrementAttribute ( const QString &  attribute,
bool  increment 
)

Adds "attribute" to a list of attributes whose values must be incremented when multiple snippets are added to the active DOM.

The reason this functionality was added here is due to the complications inherent in the default shallow copy constructors of QDomAttr (I originally tried to use maps confined to GCAddSnippetForm objects, but to no avail).

See also:
incrementAttribute
fixAttributeValues
fixedValue
revertToFixedValues

Definition at line 157 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::setIndex ( int  index)

Sets the item's index to "index".

See also:
index

Definition at line 263 of file gctreewidgetitem.cpp.

void GCTreeWidgetItem::setVerbose ( bool  verbose)

Sets the item's element display as "verbose".

When "verbose", the entire node is displayed (element attributes and values), otherwise only the element name is displayed.

See also:
setDisplayText

Definition at line 297 of file gctreewidgetitem.cpp.

QString GCTreeWidgetItem::toString ( ) const

Provides a string representation of the element, its attributes and attribute values (including brackets and other XML characters).

Definition at line 212 of file gctreewidgetitem.cpp.


The documentation for this class was generated from the following files: