[QGIS Commit] r8353 - trunk/qgis/src/plugins/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Apr 15 12:43:49 EDT 2008


Author: jef
Date: 2008-04-15 12:43:49 -0400 (Tue, 15 Apr 2008)
New Revision: 8353

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassmodel.cpp
   trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
Log:
GRASS toolbox fix
- avoid an endless recursion with Qt 4.4
- reduce toolbox noise (std::cerr->QgsDebugMsg)


Modified: trunk/qgis/src/plugins/grass/qgsgrassmodel.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodel.cpp	2008-04-15 15:41:15 UTC (rev 8352)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodel.cpp	2008-04-15 16:43:49 UTC (rev 8353)
@@ -35,6 +35,7 @@
 
 #include "qgis.h"
 #include "qgsapplication.h"
+#include "qgslogger.h"
 
 extern "C" {
 #include <grass/gis.h>
@@ -463,7 +464,7 @@
 
 void QgsGrassModelItem::populate()
 {
-  std::cerr << "QgsGrassModelItem::populate()" << std::endl;
+  QgsDebugMsg("called.");
 
   if ( mPopulated ) return;
 
@@ -475,9 +476,7 @@
 QgsGrassModel::QgsGrassModel ( QObject * parent )
              : QAbstractItemModel ( parent  )
 {
-#ifdef QGISDEBUG
-  std::cerr << "QgsGrassModel()" << std::endl;
-#endif
+  QgsDebugMsg("called.");
 
   // Icons
   QStyle *style = QApplication::style();
@@ -509,9 +508,7 @@
 
 void QgsGrassModel::refresh() 
 {
-#ifdef QGISDEBUG
-  std::cerr << "QgsGrassModel::refresh()" << std::endl;
-#endif
+  QgsDebugMsg("called.");
 
   //mRoot->refresh(); 
   refreshItem(mRoot); 
@@ -550,7 +547,7 @@
   {
     if ( !list.contains(item->mChildren[i]->name()) )
     {
-      //std::cerr << "remove " << item->mChildren[i]->name().ascii() << std::endl;
+      QgsDebugMsg( QString("remove %1").arg( item->mChildren[i]->name() ) );
       beginRemoveRows( index, i, i );
       delete item->mChildren[i];
       item->mChildren.remove(i);
@@ -592,7 +589,7 @@
 
     if ( insertAt >= 0 )
     {
-      std::cerr << "insert " << name.ascii() << " at " << insertAt << std::endl;
+      QgsDebugMsg( QString("insert %1 at %2").arg(name).arg(insertAt) );;
       beginInsertRows( index, insertAt, insertAt );
       QgsGrassModelItem *newItem = new QgsGrassModelItem();
       item->mChildren.insert( insertAt, newItem );
@@ -629,8 +626,10 @@
 
 void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
 {
-  std::cerr << "QgsGrassModel::refreshItem() item->mType = " << item->mType << std::endl;
+  QgsDebugMsg( QString("called with item type %1").arg(item->mType) );
 
+  // to avoid and endless recusion with Qt 4.4 let's pretend we already have populated 
+  item->mPopulated = true;
 
   switch ( item->mType ) 
   {
@@ -639,7 +638,6 @@
       QStringList list = QgsGrass::mapsets ( item->mGisbase, item->mLocation );
       removeItems(item, list);
       addItems(item, list, QgsGrassModel::Mapset );
-
     }
     break;
 
@@ -730,8 +728,6 @@
       refreshItem( item->mChildren[i] );
     }
   }
-
-  item->mPopulated = true;
 }
 
 QModelIndex QgsGrassModel::index( int row, int column, 

Modified: trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2008-04-15 15:41:15 UTC (rev 8352)
+++ trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2008-04-15 16:43:49 UTC (rev 8353)
@@ -56,6 +56,7 @@
 #include "qgsvectorlayer.h"
 #include "qgsdataprovider.h"
 #include "qgsfield.h"
+#include "qgslogger.h"
 
 extern "C" {
 #include <grass/gis.h>
@@ -352,7 +353,7 @@
 
       if ( e.tagName() == "section" ) {
         QString label = e.attribute("label");
-        std::cout << "label = " << label.toLocal8Bit().data() << std::endl;
+        QgsDebugMsg( QString("label = %1").arg(label) );
         item->setText( 0, label );
         item->setExpanded(true); // for debuging to spare one click
 
@@ -361,7 +362,7 @@
         lastItem = item;
       } else if ( e.tagName() == "grass" ) { // GRASS module
         QString name = e.attribute("name");
-        std::cout << "name = " << name.toLocal8Bit().data() << std::endl;
+        QgsDebugMsg( QString("name = %1").arg(name) );
 
         QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
         QString label = QgsGrassModule::label ( path );



More information about the QGIS-commit mailing list