QTidy::QTidyXHtmlTree Class Reference
[QtGui Implementation]

#include <QTidyXHtmlTree.h>

List of all members.


Signals

void errorMessage (const QString &mess, int line, int row)

Public Member Functions

 QTidyXHtmlTree (QObject *parent=0)
bool setContent (const QString &data)
 set Document Content e.g. html/xml Document.
QDomDocument getDocument () const
 Current Document.
const QDomNode nodeByTagName (const QString &nodeName=QString::fromUtf8("html"))
 find firstChildNodes by NodeName
QAbstractItemModel * model (const QString &sibling=QString::null)
 Load ItemModel for DomTreeView.
 ~QTidyXHtmlTree ()

Detailed Description

This Class Provides HTML/XML TreeModel for QTreeWidget or QTreeView. A parsed and, optionally, repaired document is represented by QTidyXHtmlTree. If given Document is not like a W3C DOM, no output generated.

 QTreeView *m_QTreeView = new QTreeView ( this );
 connect ( m_QTreeView, SIGNAL ( clicked ( const QModelIndex & ) ),
         this, SLOT ( selectionChanged ( const QModelIndex & ) ) );

 QTidy::QTidyXHtmlTree *tree = new QTidy::QTidyXHtmlTree ( this );
 // Don't forget to reset() your QTree(Widget|View) when using Q_SLOTS.
 if ( tree->setContent ( m_QTextDocument->toHtml() ) )
 {
   // Optional: you can use firstSiblings, if the Element not exits
   // and Document is wellformed then it returns the full document model.
   m_QTreeView->setModel ( tree->model( "body" ) );
   m_QTreeView->expandAll();
 }

How can i access the data model? QtidyXHtmlTree writing data to Qt::DisplayRole and Qt::EditRole.

 QTreeView *m_QTreeView = new QTreeView ( this );
 ...
 connect ( m_QTreeView, SIGNAL ( clicked ( const QModelIndex & ) ),
         this, SLOT ( selectionChanged ( const QModelIndex & ) ) );
 ...
 void myClass::selectionChanged( const QModelIndex &index )
 {
   QVariant data = index.data ( Qt::EditRole );
   if ( ! data.isNull() )
   {
     QTidy::QTidyNodeRole tnr = data.value<QTidy::QTidyNodeRole>();
     QDomNode nNode = tnr.node;
     qDebug() << nNode.nodeName() << nNode.parentNode().nodeName();
   }
 }

Constructor & Destructor Documentation

QTidy::QTidyXHtmlTree::QTidyXHtmlTree ( QObject *  parent = 0  ) 

QTidy::QTidyXHtmlTree::~QTidyXHtmlTree (  ) 


Member Function Documentation

bool QTidy::QTidyXHtmlTree::setContent ( const QString &  data  ) 

set Document Content e.g. html/xml Document.

Insert XML/HTML into Data model. If Document isValid() and Wellformed then it returns TRUE otherwise FALSE.

Note:
QDomDocument can not load broken Documents!
Parameters:
data html/xml Dataset

QDomDocument QTidy::QTidyXHtmlTree::getDocument (  )  const

Current Document.

const QDomNode QTidy::QTidyXHtmlTree::nodeByTagName ( const QString &  nodeName = QString::fromUtf8("html")  ) 

find firstChildNodes by NodeName

Parameters:
nodeName Optional firstChild NodeNames (html|head|body)

QAbstractItemModel* QTidy::QTidyXHtmlTree::model ( const QString &  sibling = QString::null  ) 

Load ItemModel for DomTreeView.

Load Document into QAbstractItemModel and generate QListTreeModel

Parameters:
sibling Optional Siblings (html|head|body)

void QTidy::QTidyXHtmlTree::errorMessage ( const QString &  mess,
int  line,
int  row 
) [signal]

This Signal ist emitted when QDomDocument::setContent fails


Generated with doxygen