Skip to content
Permalink
Browse files

[GRASS] do not duplicate modules in list view, fixes #4975

  • Loading branch information
blazek committed Dec 15, 2015
1 parent 695689b commit b57ff40c8b74e05aa08ea0da4031e8baa2e5d2a5
Showing with 24 additions and 14 deletions.
  1. +24 −14 src/plugins/grass/qgsgrasstools.cpp
@@ -500,22 +500,32 @@ void QgsGrassTools::addModules( QStandardItem *parent, QDomElement &element, QSt
item->setData( pixmap, Qt::DecorationRole );
item->setCheckable( false );
item->setEditable( false );
QStandardItem * listItem = item->clone();
listItem->setText( name + "\n" + description.label );

appendItem( treeModel, parent, item );

// setData in the delegate with a variantised QgsDetailedItemData
QgsDetailedItemData myData;
myData.setTitle( name );
myData.setDetail( label );
myData.setIcon( pixmap );
myData.setCheckable( false );
myData.setRenderAsWidget( false );
QVariant myVariant = qVariantFromValue( myData );
listItem->setData( myVariant, Qt::UserRole );

modulesListModel->appendRow( listItem );
bool exists = false;
for ( int i = 0; i < modulesListModel->rowCount(); i++ )
{
if ( modulesListModel->item( i )->data( Qt::UserRole + Name ).toString() == name )
{
exists = true;
break;
}
}
if ( !exists )
{
QStandardItem * listItem = item->clone();
listItem->setText( name + "\n" + description.label );
// setData in the delegate with a variantised QgsDetailedItemData
QgsDetailedItemData myData;
myData.setTitle( name );
myData.setDetail( label );
myData.setIcon( pixmap );
myData.setCheckable( false );
myData.setRenderAsWidget( false );
QVariant myVariant = qVariantFromValue( myData );
listItem->setData( myVariant, Qt::UserRole );
modulesListModel->appendRow( listItem );
}
}
}
}

0 comments on commit b57ff40

Please sign in to comment.
You can’t perform that action at this time.