Skip to content

Commit

Permalink
Don't leak in metadatawidget delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Dec 5, 2017
1 parent 011e254 commit 2b3fbc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/gui/qgsmetadatawidget.cpp
Expand Up @@ -63,7 +63,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
constraintheaders << tr( "Type" ) << tr( "Constraint" );
mConstraintsModel->setHorizontalHeaderLabels( constraintheaders );
tabConstraints->setModel( mConstraintsModel );
tabConstraints->setItemDelegate( new ConstraintItemDelegate() );
tabConstraints->setItemDelegate( new ConstraintItemDelegate( this ) );

// Setup the link view
mLinksModel = new QStandardItemModel( tabLinks );
Expand All @@ -72,7 +72,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
headers << tr( "Name" ) << tr( "Type" ) << tr( "URL" ) << tr( "Description" ) << tr( "Format" ) << tr( "MIME" ) << tr( "Size" );
mLinksModel->setHorizontalHeaderLabels( headers );
tabLinks->setModel( mLinksModel );
tabLinks->setItemDelegate( new LinkItemDelegate() );
tabLinks->setItemDelegate( new LinkItemDelegate( this ) );

// History
mHistoryModel = new QStringListModel( listHistory );
Expand Down Expand Up @@ -794,6 +794,12 @@ void QgsMetadataWidget::removeSelectedCategory() const
}
}

LinkItemDelegate::LinkItemDelegate( QObject *parent )
: QStyledItemDelegate( parent )
{

}

QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( index.column() == 1 )
Expand All @@ -820,6 +826,12 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView
return QStyledItemDelegate::createEditor( parent, option, index );
}

ConstraintItemDelegate::ConstraintItemDelegate( QObject *parent )
: QStyledItemDelegate( parent )
{

}

QWidget *ConstraintItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( index.column() == 0 )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmetadatawidget.h
Expand Up @@ -140,6 +140,8 @@ class LinkItemDelegate : public QStyledItemDelegate

public:

explicit LinkItemDelegate( QObject *parent = nullptr );

/**
* Create a special editor with a QCombobox in the link view.
*/
Expand All @@ -160,6 +162,8 @@ class ConstraintItemDelegate : public QStyledItemDelegate

public:

explicit ConstraintItemDelegate( QObject *parent = nullptr );

/**
* Create a special editor with a QCombobox in the constraint view.
*/
Expand Down

0 comments on commit 2b3fbc7

Please sign in to comment.