Results 1 to 7 of 7

Thread: QT Nested Sets SQL/XML - categories (tree)

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QT Nested Sets SQL/XML - categories (tree)

    I search an idea how to write and read file like this:
    http://marmo.ch/user/db_marmo/tree_index_de.xml
    http://marmo.ch/user/db_marmo/tree_index_en.xml
    http://marmo.ch/user/db_marmo/tree_index_it.xml

    add categories add page .... title description ... same as a homepage sitemap

    QMap or QMultiMap or class structure data ??
    How i can make this? pleas have you any idea?


    IMO ... on php5 i make so....
    http://ppk.ciz.ch/php_snips/Pulitzer_Category.phps from an example by .... http://www.klempert.de/nested_sets/
    Last edited by patrik08; 12th June 2006 at 14:25.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    But what exactly is the problem? Use QDomDocument and family...

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    Yes to read ok QDomdocument .... and diplay a tree qwidget... (and attributes edit on pop-up) add category on Qt::CustomContextMenu ...
    But on programm I must save / register data array on a Qmap or Qmapmulti ??
    to at end rewrite the file exact same + diffs....

    QDomdocument dont have XPath to get fast on attribute from a xml file... and must read file from new....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    Quote Originally Posted by patrik08
    But on programm I must save / register data array on a Qmap or Qmapmulti ??
    to at end rewrite the file exact same + diffs....
    What for? Work with a QDomDocument all the way...
    QDomdocument dont have XPath to get fast on attribute from a xml file...
    I don't quite understand what you mean. If you want to find some grandchild item, just use QDomNode::firstChildElement() and QDomNode::nextSiblingElement() to traverse the tree.

    and must read file from new....
    I completely don't understand what you mean here... What file? Read when? From "new"? You mean from beginning? What for? If you have the tree in QDomDocument, you don't need to reread the file unless its content changes.

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    and how bring priority up & down on tree ...

    IMO
    Sorry but i love xml / xslt my CMS http://slide.pulitzer.ch/title.html work only on xml....
    mysql work only to search and to admin site....
    And i like to bring admin all to qt ... i have enough with browser version xxx and javascripts version xxx to admin page...


    if user like to bring moore priority to <subdir>(cat3) and move up how to swap this? from xml code down..?

    QDomNode QDomNode::insertBefore ( const QDomNode & newChild, subcat1 )
    or
    $node->parentNode->replaceChild($frag,$node); ?? cat0,cat3

    i see all dom function from php is same name as qt.... only DomXPath not exist and AppenddocumentFragment to node... i suppose QTextDocumentFragment is only a qtextedit QTextDocument class...

    xml code...

    Qt Code:
    1. <root>
    2. <topdir name"qt">
    3. <subdir name="libs1"/>
    4. <subdir name="libs2"/>
    5. <subdir name="libs3">
    6. <subdir name="cat0">
    7. <page name="qtstring"/>
    8. </subdir>
    9. <subdir name="cat3">
    10. <page name="stringlist"/>
    11. </subdir>
    12. </subdir>
    13. </topdir>
    14. <topdir name="wx"/>
    15. <subdir name="cat7">
    16. <page name="wxstring"/>
    17. </subdir>
    18. </topdir>
    19. </root>
    To copy to clipboard, switch view to plain text mode 

    php5 code

    Qt Code:
    1. ///////////////////////// replace strong to b //////////////////////
    2. $dom->loadHTML($xhtml);
    3. $xp = new DomXPath($dom);
    4. $resulta = $xp->query("//strong");
    5. foreach ($resulta as $node) {
    6. $internal=$node->nodeValue;
    7. $frag = $dom->createElement("b",$internal);
    8. $node->parentNode->replaceChild($frag,$node);
    9. }
    10. ///////////////////////// replace strong to b //////////////////////
    11.  
    12.  
    13. class XML extends DOMDocument {
    14.  
    15. function appendXML_or_File($node,$frag) {
    16.  
    17. if (is_file($frag)) {
    18. $frag = @file_get_contents($frag);
    19. }
    20.  
    21. $tmpdoc = new self('1.0', 'utf-8');
    22. $tmpdoc->loadXML("<dummyroot>".$this->Remove_Version($frag)."</dummyroot>") or Error_Manager::msg('Error on fragment not possibel to insert xml Fragment!'.htmlentities($frag, ENT_QUOTES),__FILE__,__LINE__);
    23. $newnode = $node->ownerDocument->importNode($tmpdoc->documentElement,true);
    24. $child = $newnode->firstChild;
    25. while ($child) {
    26. $nextChild = $child->nextSibling;
    27. $node->appendChild($child);
    28. $child = $nextChild;
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    Quote Originally Posted by patrik08
    if user like to bring moore priority to <subdir>(cat3) and move up how to swap this? from xml code down..?

    QDomNode QDomNode::insertBefore ( const QDomNode & newChild, subcat1 )
    or
    $node->parentNode->replaceChild($frag,$node); ?? cat0,cat3
    If you read the docs of those two methods, I'm sure you'll be able to answer that question yourself.

    i see all dom function from php is same name as qt....
    These are standard DOM methods defined in W3C Dom specification which is implemented by (among other) both Qt and PHP. So it's not a situation when Qt has the same function names as PHP -- they both implement the same interface (I think first seen in JavaScript).


    i suppose QTextDocumentFragment is only a qtextedit QTextDocument class...
    QDomDocumentFragment
    only DomXPath not exist and AppenddocumentFragment to node
    QDomDocumentFragment inherits QDomNode so you can append a document fragment to the tree like any other node.

  7. The following user says thank you to wysota for this useful post:

    patrik08 (13th June 2006)

  8. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT Nested Sets SQL/XML - categories (tree)

    Well done... You are convinced me to build and manage this xml tree on dom and leaving Nested Sets SQL from my mind... all the operations is possibel on qtdomdoc.. i hope...

    OK ... Tanks...

    the next battle is QTreeWidgetItem..... and signal from QTreeWidget to find tags...
    QTreeWidgetItem *childItem = createItem(child, item);
    childItem->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsautoSave);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.