I need a model tree to save PDF Bookmark like QStandardItemModel
and this model must combine on anchorNames () on a QTextDocument

i need a model to validate anchorNames () at QTextDocument .....

at end i save the tree on this way:
Qt Code:
  1. <fo:bookmark-tree>
  2. <fo:bookmark internal-destination="sec0" >
  3. <fo:bookmark-title>Internal dest.0</fo:bookmark-title>
  4. <fo:bookmark internal-destination="sec1" >
  5. <fo:bookmark-title>Internal dest.1</fo:bookmark-title>
  6. </fo:bookmark>
  7. <fo:bookmark internal-destination="sec2" >
  8. <fo:bookmark-title>Internal dest.2</fo:bookmark-title>
  9. </fo:bookmark>
  10. </fo:bookmark>
  11. </fo:bookmark-tree>
To copy to clipboard, switch view to plain text mode 

I search a way to traverse or iterate all node from model
i find only this here ...

http://troll.no/developer/knowledgeb...ndarditemmodel

Is here other way?


on read xml-bookmark i make it so...

Qt Code:
  1. void BookMarkModelRead::openRootBookmark( const QDomElement e )
  2. {
  3. if (e.tagName() !="fo:bookmark-tree")
  4. {
  5. return;
  6. }
  7. foundTree = true;
  8. model = new QStandardItemModel();
  9. internalLinkFound.clear();
  10. setHeader();
  11. //////////////qDebug() << "### openRootBookmark -> " << e.tagName();
  12. QDomElement child = e.firstChildElement("fo:bookmark");
  13. while (!child.isNull()) {
  14. model->invisibleRootItem()->appendRow(Compose(child,0));
  15. child = child.nextSiblingElement("fo:bookmark");
  16. }
  17. }
  18.  
  19. QList<QStandardItem *> BookMarkModelRead::Compose( const QDomElement e , const int leveldeep )
  20. {
  21. Q_ASSERT ( e.tagName() == "fo:bookmark" );
  22. treeLoop++;
  23. QList<QStandardItem *> diritto;
  24. QIcon icob = createBookColorIcon( Qt::darkRed );
  25. QString txt = e.firstChildElement("fo:bookmark-title").text();
  26. if (txt.size() < 2) {
  27. txt = tr("No Title found!");
  28. icob = createBookColorIcon( Qt::red );
  29. }
  30. const QString link = e.attribute("internal-destination","null");
  31. internalLinkFound.append(link);
  32. qDebug() << "### read -> " << txt << "-" << treeLoop;
  33.  
  34. QStandardItem *item0 = new QStandardItem(txt);
  35. item0->setData(leveldeep,Qt::UserRole);
  36. item0->setData(bold_base_font,Qt::FontRole);
  37. item0->setIcon ( icob );
  38. item0->setFlags( flags );
  39.  
  40. diritto.append(item0);
  41.  
  42. QStandardItem *item1 = new QStandardItem(link);
  43. item1->setFlags( flags );
  44. item1->setData(leveldeep,Qt::UserRole);
  45.  
  46. diritto.append(item1);
  47.  
  48. QStandardItem *item2 = new QStandardItem(QString("%1").arg(leveldeep));
  49. item2->setFlags( Qt::ItemIsEnabled );
  50. item2->setData(leveldeep,Qt::UserRole);
  51.  
  52. diritto.append(item2);
  53.  
  54. if (!e.firstChildElement("fo:bookmark").isNull() && leveldeep == 0 ) {
  55. /* one level deep down child */
  56. QDomElement child = e.firstChildElement("fo:bookmark");
  57. while (!child.isNull()) {
  58. if ( child.tagName() == "fo:bookmark") {
  59. const QString nextlink = child.attribute("internal-destination","null");
  60. if (!internalLinkFound.contains(nextlink)) {
  61. diritto.first()->appendRow(Compose(child,leveldeep + 1));
  62. }
  63. }
  64.  
  65. child = child.nextSiblingElement();
  66. }
  67. } else if (!e.nextSiblingElement("fo:bookmark").isNull() && leveldeep > 0 ) {
  68. /* same level is only next on deep */
  69.  
  70. }
  71. return diritto;
  72. }
To copy to clipboard, switch view to plain text mode 

and to read the model it is not possibel?
i can not use QTreeWidget / QTreeWidgetItem why ... i can not set a model at him...
only QTreeView can set a model .... i know only a way to use sqlite3 as model...
Must i use sqlite3 to traverse all tree? QStandardItemModel can not make this job..

the resut... is not possible to read back from QTreeView ...!! onewayQTreeView :-(