From 86e82c71e5efa875777c6ed5a701c955d941f5f3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 8 Mar 2017 13:01:59 +0800 Subject: [PATCH] Setup parent pointer Rely on Qt to do the delete, since the parent ownership is setup correctly. --- src/gui/addnewtorrentdialog.cpp | 2 +- src/gui/properties/peerlistwidget.cpp | 8 ++------ src/gui/properties/proplistdelegate.cpp | 4 ++-- src/gui/properties/proplistdelegate.h | 2 +- src/gui/search/searchlistdelegate.h | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index c773a9cbd..eee00034c 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -718,7 +718,7 @@ void AddNewTorrentDialog::setupTreeview() m_contentModel = new TorrentContentFilterModel(this); connect(m_contentModel->model(), SIGNAL(filteredFilesChanged()), SLOT(updateDiskSpaceLabel())); ui->contentTreeView->setModel(m_contentModel); - m_contentDelegate = new PropListDelegate(); + m_contentDelegate = new PropListDelegate(nullptr); ui->contentTreeView->setItemDelegate(m_contentDelegate); connect(ui->contentTreeView, SIGNAL(clicked(const QModelIndex &)), ui->contentTreeView, SLOT(edit(const QModelIndex &))); connect(ui->contentTreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayContentTreeMenu(const QPoint &))); diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index dadf2c0b2..da2f50951 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -67,7 +67,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) setSelectionMode(QAbstractItemView::ExtendedSelection); header()->setStretchLastSection(false); // List Model - m_listModel = new QStandardItemModel(0, PeerListDelegate::COL_COUNT); + m_listModel = new QStandardItemModel(0, PeerListDelegate::COL_COUNT, this); m_listModel->setHeaderData(PeerListDelegate::COUNTRY, Qt::Horizontal, tr("Country")); // Country flag column m_listModel->setHeaderData(PeerListDelegate::IP, Qt::Horizontal, tr("IP")); m_listModel->setHeaderData(PeerListDelegate::PORT, Qt::Horizontal, tr("Port")); @@ -90,7 +90,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole); m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole); // Proxy model to support sorting without actually altering the underlying model - m_proxyModel = new PeerListSortModel(); + m_proxyModel = new PeerListSortModel(this); m_proxyModel->setDynamicSortFilter(true); m_proxyModel->setSourceModel(m_listModel); m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); @@ -144,12 +144,8 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) PeerListWidget::~PeerListWidget() { saveSettings(); - delete m_proxyModel; - delete m_listModel; - delete m_listDelegate; if (m_resolver) delete m_resolver; - delete m_copyHotkey; } void PeerListWidget::displayToggleColumnsMenu(const QPoint&) diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index d8ab3aff8..68bc859ca 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -62,8 +62,8 @@ namespace { } } -PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent) - : QItemDelegate(parent) +PropListDelegate::PropListDelegate(PropertiesWidget *properties) + : QItemDelegate(properties) , m_properties(properties) { } diff --git a/src/gui/properties/proplistdelegate.h b/src/gui/properties/proplistdelegate.h index 7f1ecc251..5c70fd2d7 100644 --- a/src/gui/properties/proplistdelegate.h +++ b/src/gui/properties/proplistdelegate.h @@ -54,7 +54,7 @@ class PropListDelegate : public QItemDelegate Q_OBJECT public: - PropListDelegate(PropertiesWidget *properties = 0, QObject *parent = 0); + PropListDelegate(PropertiesWidget *properties); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; diff --git a/src/gui/search/searchlistdelegate.h b/src/gui/search/searchlistdelegate.h index 27d813735..91e0e46a4 100644 --- a/src/gui/search/searchlistdelegate.h +++ b/src/gui/search/searchlistdelegate.h @@ -36,7 +36,7 @@ class SearchListDelegate: public QItemDelegate { public: - explicit SearchListDelegate(QObject *parent = 0); + explicit SearchListDelegate(QObject *parent); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;