Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GRASS toolbox fix
- avoid an endless recursion with Qt 4.4
- reduce toolbox noise (std::cerr->QgsDebugMsg)


git-svn-id: http://svn.osgeo.org/qgis/trunk@8353 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 15, 2008
1 parent b528687 commit ed93065
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
22 changes: 9 additions & 13 deletions src/plugins/grass/qgsgrassmodel.cpp
Expand Up @@ -35,6 +35,7 @@

#include "qgis.h"
#include "qgsapplication.h"
#include "qgslogger.h"

extern "C" {
#include <grass/gis.h>
Expand Down Expand Up @@ -463,7 +464,7 @@ QgsGrassModelItem *QgsGrassModelItem::child ( int i )

void QgsGrassModelItem::populate()
{
std::cerr << "QgsGrassModelItem::populate()" << std::endl;
QgsDebugMsg("called.");

if ( mPopulated ) return;

Expand All @@ -475,9 +476,7 @@ void QgsGrassModelItem::populate()
QgsGrassModel::QgsGrassModel ( QObject * parent )
: QAbstractItemModel ( parent )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassModel()" << std::endl;
#endif
QgsDebugMsg("called.");

// Icons
QStyle *style = QApplication::style();
Expand Down Expand Up @@ -509,9 +508,7 @@ QgsGrassModel::~QgsGrassModel() { }

void QgsGrassModel::refresh()
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassModel::refresh()" << std::endl;
#endif
QgsDebugMsg("called.");

//mRoot->refresh();
refreshItem(mRoot);
Expand Down Expand Up @@ -550,7 +547,7 @@ void QgsGrassModel::removeItems(QgsGrassModelItem *item, QStringList list)
{
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);
Expand Down Expand Up @@ -592,7 +589,7 @@ void QgsGrassModel::addItems(QgsGrassModelItem *item, QStringList list, int type

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 );
Expand Down Expand Up @@ -629,8 +626,10 @@ void QgsGrassModel::addItems(QgsGrassModelItem *item, QStringList list, int type

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 )
{
Expand All @@ -639,7 +638,6 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
QStringList list = QgsGrass::mapsets ( item->mGisbase, item->mLocation );
removeItems(item, list);
addItems(item, list, QgsGrassModel::Mapset );

}
break;

Expand Down Expand Up @@ -730,8 +728,6 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
refreshItem( item->mChildren[i] );
}
}

item->mPopulated = true;
}

QModelIndex QgsGrassModel::index( int row, int column,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/grass/qgsgrasstools.cpp
Expand Up @@ -56,6 +56,7 @@
#include "qgsvectorlayer.h"
#include "qgsdataprovider.h"
#include "qgsfield.h"
#include "qgslogger.h"

extern "C" {
#include <grass/gis.h>
Expand Down Expand Up @@ -352,7 +353,7 @@ void QgsGrassTools::addModules ( QTreeWidgetItem *parent, QDomElement &element

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

Expand All @@ -361,7 +362,7 @@ void QgsGrassTools::addModules ( QTreeWidgetItem *parent, QDomElement &element
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 );
Expand Down

0 comments on commit ed93065

Please sign in to comment.