Author: mir3x
Date: Sun Dec 14 16:16:25 2014
New Revision: 27297

URL: http://svn.gna.org/viewcvs/freeciv?rev=27297&view=rev
Log:
Fixed creating tree in qt-manual

See bug #23052



Modified:
    branches/S2_5/client/gui-qt/helpdlg.cpp

Modified: branches/S2_5/client/gui-qt/helpdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/helpdlg.cpp?rev=27297&r1=27296&r2=27297&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/helpdlg.cpp     (original)
+++ branches/S2_5/client/gui-qt/helpdlg.cpp     Sun Dec 14 16:16:25 2014
@@ -171,35 +171,27 @@
 void help_dialog::make_tree()
 {
   QTreeWidgetItem *item;
-  int d, depht = 0;
-  QStack<QTreeWidgetItem *> stack;
+  int dep;
   char *title;
+  QHash<int, QTreeWidgetItem*> hash;
 
   help_items_iterate(pitem) {
+    const char *s;
+    int last;
     title = pitem->topic;
-    for (d = 0; *title == ' '; ++title, ++d) {
-      // Do nothing
+    for (s = pitem->topic; *s == ' '; s++) {
+      /* nothing */
     }
     item = new QTreeWidgetItem(QStringList(title));
     topics_map[item] = pitem;
-    if (d > 0 && d == depht) {
-      // Same level in the tree
-      stack.pop();
-    } else if (d > 0 && d < depht) {
-      // Less deep
-      for ( ; d <= depht; --depht) {
-        stack.pop();
-      }
-      stack.top()->addChild(item);
-      stack.push(item);
+    dep = s - pitem->topic;
+    hash.insert(dep, item);
+    if (dep == 0) {
+      tree_wdg->addTopLevelItem(item);
+    } else {
+      last = dep - 1;
+      hash.value(last)->addChild(item);
     }
-    depht = d;
-    if (depht > 0) {
-      stack.top()->addChild(item);
-    } else {
-      tree_wdg->addTopLevelItem(item);
-    }
-    stack.push(item);
   } help_items_iterate_end;
 }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to