Skip to content
Permalink
Browse files

Don't leak in metadatawidget delegates

  • Loading branch information
elpaso committed Dec 4, 2017
1 parent 011e254 commit 2b3fbc77612590f742d1852df479d6453b8cea8f
Showing with 18 additions and 2 deletions.
  1. +14 −2 src/gui/qgsmetadatawidget.cpp
  2. +4 −0 src/gui/qgsmetadatawidget.h
@@ -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 );
@@ -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 );
@@ -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 )
@@ -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 )
@@ -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.
*/
@@ -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.
*/

0 comments on commit 2b3fbc7

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