#include <QTidyXHtmlTree.h>
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 () | |
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(); } }
| QTidy::QTidyXHtmlTree::QTidyXHtmlTree | ( | QObject * | parent = 0 |
) |
| QTidy::QTidyXHtmlTree::~QTidyXHtmlTree | ( | ) |
| 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.
| 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
| 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
| 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