[Kstars-devel] KDE/kdeedu/kstars/kstars/tools

Akarsh Simha akarshsimha at gmail.com
Tue May 26 06:37:26 CEST 2009


SVN commit 972950 by asimha:

Applying Alexey Khudyakov's patch refactoring astrocalc code. Quoting
from his description:

 * Choose widgets not by their names but by their pointers. Saves small amount
of memory and CPU cycles.

Thanks Alexey!

CCMAIL: kstars-devel at kde.org



 M  +4 -5      astrocalc.cpp  
 M  +2 -2      astrocalc.h  


--- trunk/KDE/kdeedu/kstars/kstars/tools/astrocalc.cpp #972949:972950
@@ -196,14 +196,14 @@
 QTreeWidgetItem* AstroCalc::addTreeItem(QTreeWidgetItem* parent, QString title, QWidget* widget)
 {
     QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(title));
-    dispatchTable.insert(title, widget);
+    dispatchTable.insert(item, widget);
     return item;
 }
 
 QTreeWidgetItem* AstroCalc::addTreeTopItem(QTreeWidget* parent, QString title, QString html)
 {
     QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(title));
-    htmlTable.insert(title, html);
+    htmlTable.insert(item, html);
     return item;
 }
 
@@ -219,16 +219,15 @@
     //DEBUG
     kDebug() << "Item clicked: " << item->text(0);
 
-    QString s = item->text(0);
     // Lookup in HTML table
-    QMap<QString, QString>::iterator iterHTML = htmlTable.find(s);
+    QMap<QTreeWidgetItem*, QString>::iterator iterHTML = htmlTable.find(item);
     if( iterHTML != htmlTable.end() ) {
         splashScreen->setHtml(*iterHTML);
         acStack->setCurrentWidget(splashScreen);
         return;
     }
     // Lookup in frames table
-    QMap<QString, QWidget*>::iterator iter = dispatchTable.find(s);
+    QMap<QTreeWidgetItem*, QWidget*>::iterator iter = dispatchTable.find(item);
     if( iter != dispatchTable.end() ) {
         acStack->setCurrentWidget( *iter );
     }
--- trunk/KDE/kdeedu/kstars/kstars/tools/astrocalc.h #972949:972950
@@ -69,9 +69,9 @@
     QTreeWidgetItem* addTreeItem(QTreeWidgetItem* parent, QString title, QWidget* widget);
 
     /** Lookup table for help texts. Maps navpanel item name to help text. */
-    QMap<QString, QString>  htmlTable;
+    QMap<QTreeWidgetItem*, QString>  htmlTable;
     /** Lookup table for widgets. Maps navpanel item name to widget to be displayed. */
-    QMap<QString, QWidget*> dispatchTable;
+    QMap<QTreeWidgetItem*, QWidget*> dispatchTable;
     QSplitter *split;
     QTreeWidget *navigationPanel;
     QStackedWidget *acStack;


More information about the Kstars-devel mailing list