Main Page | Class Hierarchy | Compound List | File List | Compound Members

MP7Doc Class Reference

This class represents an MPEG-7 document. More...

#include <MP7Doc.hpp>

List of all members.

Signals

void modificationChanged (bool m)
 This signal is emitted when the modification status of the MPEG-7 document has changed.


Public Member Functions

 MP7Doc (QListView *listView)
 Constructor.

bool parse (const QString &filename)
 Parse a valid MPEG-7 file in XML format.

bool save (const QString &filename)
 Save the MPEG-7 document in XML format to the given file.

QString filePath () const
 Return the filename (full path name) of the document.

QString dirPath () const
 Return the directory path of the document's filename.

bool isModified () const
 Return true if this document has been modified.

MP7ListViewItemaddElement (MP7ListViewItem *parent, MP7ListViewItem *after, const QString &name)
 Add an XML element as child of parent.

MP7ListViewItemaddElement (MP7ListViewItem *parent, const QString &name, int pos=-1)
 Add an XML element as child of parent.

int setElementValue (MP7ListViewItem *item, const QString &value)
 Set the text value of the XML element corresponding to the MP7ListViewItem object.

bool setAttribute (MP7ListViewItem *item, const QString &attribute, const QString &value)
 Set an attribute of the XML element corresponding to the MP7ListViewItem object.

bool moveElement (MP7ListViewItem *item, MP7ListViewItem *newParent, MP7ListViewItem *newSibling=NULL)
 Move an XML element (with all children) to a new parent node, right after the given new sibling.

bool removeElementDeep (MP7ListViewItem *item)
 Remove an XML element and all its descendants recursively.

int removeChildrenDeep (MP7ListViewItem *parent, const QString &name=QString::null)
 Remove all XML child elements with the given tag name and its descendants recursively.

MP7ListViewItemnodeByPath (const QString &path, MP7ListViewItem *root=NULL, bool create=false)
 Return the element specified by a simple XML path.

QPtrList< MP7ListViewItemchildren (MP7ListViewItem *parent, const QString &name=QString::null) const
 Return all XML child elements with the given tag name.

MP7ListViewItemnearestElement (MP7ListViewItem *start, const QString &name, bool searchUp) const
 Find the nearest XML element with the given tag name.

MP7ListViewItemnearestElement (MP7ListViewItem *start, const QStringList &names, bool searchUp) const
 Find the nearest XML element equal to one of the given tag names.


Protected Member Functions

void updateTreeWidget ()
 Traverse the DOM tree recursively and construct a tree of QListViewItem objects corresponding to XML elements.

void setModified (bool modified)
 Set the document modification status and emit a modificationChanged() signal if the status is being changed.


Detailed Description

This class represents an MPEG-7 document.

It manages a graphical tree representation of the document within a QListView widget.

Author:
Mario Taschwer
Version:
Id
MP7Doc.hpp,v 1.8 2004/09/24 13:15:09 mtaschwer Exp


Constructor & Destructor Documentation

MP7Doc::MP7Doc QListView *  listView  ) 
 

Constructor.

Creates an MPEG-7 document consisting of an empty Mpeg7 descriptor.

Parameters:
listView the QListView widget where the MPEG-7 XML tree will be displayed. The widget should have been initialized with two columns; XML element names will be displayed in the first column, text values will be shown in the second column.


Member Function Documentation

MP7ListViewItem* MP7Doc::addElement MP7ListViewItem parent,
const QString &  name,
int  pos = -1
 

Add an XML element as child of parent.

Parameters:
parent parent element.
name the new element's tag name.
pos the position of the new element within the list of children. -1 means end of the list.
Returns:
the new XML element, or NULL on error.

MP7ListViewItem* MP7Doc::addElement MP7ListViewItem parent,
MP7ListViewItem after,
const QString &  name
 

Add an XML element as child of parent.

Parameters:
parent parent element.
after the sibling after which the new element should be inserted.
name the new element's tag name.
Returns:
the new XML element, or NULL on error.

QPtrList<MP7ListViewItem> MP7Doc::children MP7ListViewItem parent,
const QString &  name = QString::null
const
 

Return all XML child elements with the given tag name.

Parameters:
parent the parent element.
name the tag name; if null, all child elements will be returned.

QString MP7Doc::dirPath  )  const
 

Return the directory path of the document's filename.

If no filename has been set, QString::null is returned.

QString MP7Doc::filePath  )  const
 

Return the filename (full path name) of the document.

If none has been set, QString::null is returned.

void MP7Doc::modificationChanged bool  m  )  [signal]
 

This signal is emitted when the modification status of the MPEG-7 document has changed.

Parameters:
m if true, the status has changed to modified.

bool MP7Doc::moveElement MP7ListViewItem item,
MP7ListViewItem newParent,
MP7ListViewItem newSibling = NULL
 

Move an XML element (with all children) to a new parent node, right after the given new sibling.

Parameters:
item element to be moved.
newParent new parent element.
newSibling new sibling element; if NULL the item will be inserted as the first child of newParent.
Returns:
false on error.

MP7ListViewItem* MP7Doc::nearestElement MP7ListViewItem start,
const QStringList &  names,
bool  searchUp
const
 

Find the nearest XML element equal to one of the given tag names.

Parameters:
start element where to start the search.
names list of XML tag names to search for.
searchUp if searchUP == true, the XML tree is searched along the path to the document root; otherwise, the tree is searched in a breadth-first manner descending from start.
Returns:
NULL if no suitable element could be found.

MP7ListViewItem* MP7Doc::nearestElement MP7ListViewItem start,
const QString &  name,
bool  searchUp
const
 

Find the nearest XML element with the given tag name.

Parameters:
start element where to start the search.
name XML tag name to search for.
searchUp if searchUP == true, the XML tree is searched along the path to the document root; otherwise, the tree is searched in a breadth-first manner descending from start.
Returns:
NULL if no suitable element could be found.

MP7ListViewItem* MP7Doc::nodeByPath const QString &  path,
MP7ListViewItem root = NULL,
bool  create = false
 

Return the element specified by a simple XML path.

Path element names are case-insensitive.

Parameters:
path the XML path relative to root to the desired XML element; the path may consist of / characters, element names, and an attribute specification. The latter is of the form [@attr="value"] (The quotes are optional). If an element name is not unique, the first element with that name is chosen to follow the path.
root the root of the subtree where to apply path. If NULL, the document root is used.
create if true, any non existing path elements and attributes will be created.
Returns:
NULL if the node does not exist.

bool MP7Doc::parse const QString &  filename  ) 
 

Parse a valid MPEG-7 file in XML format.

The QListView widget is populated with QListViewItem objects corresponding to XML elements.

Returns:
true on success, false on error.

int MP7Doc::removeChildrenDeep MP7ListViewItem parent,
const QString &  name = QString::null
 

Remove all XML child elements with the given tag name and its descendants recursively.

Parameters:
parent the parent element.
name the tag name; if null, all child elements will be removed.
Returns:
the number of (direct) child elements that have been removed.

bool MP7Doc::removeElementDeep MP7ListViewItem item  ) 
 

Remove an XML element and all its descendants recursively.

Returns:
true if element has actually been removed.

bool MP7Doc::save const QString &  filename  ) 
 

Save the MPEG-7 document in XML format to the given file.

Returns:
true on success, false on error.

bool MP7Doc::setAttribute MP7ListViewItem item,
const QString &  attribute,
const QString &  value
 

Set an attribute of the XML element corresponding to the MP7ListViewItem object.

Returns:
false on error.

int MP7Doc::setElementValue MP7ListViewItem item,
const QString &  value
 

Set the text value of the XML element corresponding to the MP7ListViewItem object.

If there is no text child node of the XML element, one will be created.

Parameters:
item both the MP7ListViewItem object and the corresponding XML element will be updated.
value the new text value of the XML element.
Returns:
0 - success.
-1 - the XML element corresponding to item could not be found.


The documentation for this class was generated from the following file:
Generated on Mon Sep 27 09:12:05 2004 for Muvino by doxygen 1.3.2