Skip to content

Commit

Permalink
[GRASS] do not duplicate modules in list view, fixes #4975
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 15, 2015
1 parent 695689b commit b57ff40
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/plugins/grass/qgsgrasstools.cpp
Expand Up @@ -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 );
}
}
}
}
Expand Down

0 comments on commit b57ff40

Please sign in to comment.