Skip to content
Permalink
Browse files

Merge pull request #5795 from elpaso/delegate-leaks

Fix Some Delegate leaks
  • Loading branch information
elpaso committed Dec 5, 2017
2 parents 011e254 + efad2f6 commit 85a7ba77d6823c5727971c5819fba884965ff700
@@ -297,11 +297,11 @@ QgsNodeEditor::QgsNodeEditor(

mTableView->setSelectionMode( QTableWidget::ExtendedSelection );
mTableView->setSelectionBehavior( QTableWidget::SelectRows );
mTableView->setItemDelegateForColumn( 0, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 1, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 2, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 3, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 4, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 0, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 1, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 2, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 3, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 4, new CoordinateItemDelegate( this ) );

setWidget( mTableView );

@@ -396,6 +396,12 @@ void QgsNodeEditor::keyPressEvent( QKeyEvent *e )
// CoordinateItemDelegate
//

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

}

QString CoordinateItemDelegate::displayText( const QVariant &value, const QLocale &locale ) const
{
return locale.toString( value.toDouble(), 'f', 4 );
@@ -107,6 +107,9 @@ class CoordinateItemDelegate : public QStyledItemDelegate
Q_OBJECT

public:

explicit CoordinateItemDelegate( QObject *parent = nullptr );

QString displayText( const QVariant &value, const QLocale &locale ) const override;

protected:
@@ -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 85a7ba7

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