Author: mir3x
Date: Sun Dec 14 16:17:27 2014
New Revision: 27298

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

See bug #23052



Modified:
    trunk/client/gui-qt/helpdlg.cpp

Modified: trunk/client/gui-qt/helpdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/helpdlg.cpp?rev=27298&r1=27297&r2=27298&view=diff
==============================================================================
--- trunk/client/gui-qt/helpdlg.cpp     (original)
+++ trunk/client/gui-qt/helpdlg.cpp     Sun Dec 14 16:17:27 2014
@@ -164,35 +164,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