Browse Source

Rely on Qt ownership to delete class members

adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
e74b984a0a
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 4
      src/gui/previewselectdialog.cpp
  2. 13
      src/gui/properties/propertieswidget.cpp
  3. 5
      src/gui/properties/proptabbar.cpp
  4. 2
      src/gui/properties/proptabbar.h
  5. 5
      src/gui/rss/feedlistwidget.cpp
  6. 1
      src/gui/rss/feedlistwidget.h
  7. 5
      src/gui/torrentcontentfiltermodel.cpp
  8. 4
      src/gui/torrentcontentfiltermodel.h
  9. 12
      src/gui/transferlistwidget.cpp

4
src/gui/previewselectdialog.cpp

@ -61,7 +61,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHan
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
// Preview list // Preview list
m_previewListModel = new QStandardItemModel(0, NB_COLUMNS); m_previewListModel = new QStandardItemModel(0, NB_COLUMNS, this);
m_previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name")); m_previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
m_previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); m_previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
m_previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); m_previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
@ -118,8 +118,6 @@ PreviewSelectDialog::~PreviewSelectDialog()
{ {
saveWindowState(); saveWindowState();
delete m_previewListModel;
delete m_listDelegate;
delete m_ui; delete m_ui;
} }

13
src/gui/properties/propertieswidget.cpp

@ -82,7 +82,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
m_state = VISIBLE; m_state = VISIBLE;
// Set Properties list model // Set Properties list model
m_propListModel = new TorrentContentFilterModel(); m_propListModel = new TorrentContentFilterModel(this);
m_ui->filesList->setModel(m_propListModel); m_ui->filesList->setModel(m_propListModel);
m_propListDelegate = new PropListDelegate(this); m_propListDelegate = new PropListDelegate(this);
m_ui->filesList->setItemDelegate(m_propListDelegate); m_ui->filesList->setItemDelegate(m_propListDelegate);
@ -142,7 +142,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
m_peerList = new PeerListWidget(this); m_peerList = new PeerListWidget(this);
m_ui->vBoxLayoutPeerPage->addWidget(m_peerList); m_ui->vBoxLayoutPeerPage->addWidget(m_peerList);
// Tab bar // Tab bar
m_tabBar = new PropTabBar(); m_tabBar = new PropTabBar(nullptr);
m_tabBar->setContentsMargins(0, 5, 0, 0); m_tabBar->setContentsMargins(0, 5, 0, 0);
m_ui->verticalLayout->addLayout(m_tabBar); m_ui->verticalLayout->addLayout(m_tabBar);
connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex); connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex);
@ -168,17 +168,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
PropertiesWidget::~PropertiesWidget() PropertiesWidget::~PropertiesWidget()
{ {
qDebug() << Q_FUNC_INFO << "ENTER";
delete m_trackerList;
delete m_peerList;
delete m_speedWidget;
delete m_downloadedPieces;
delete m_piecesAvailability;
delete m_propListModel;
delete m_propListDelegate;
delete m_tabBar; delete m_tabBar;
delete m_ui; delete m_ui;
qDebug() << Q_FUNC_INFO << "EXIT";
} }
void PropertiesWidget::showPiecesAvailability(bool show) void PropertiesWidget::showPiecesAvailability(bool show)

5
src/gui/properties/proptabbar.cpp

@ -107,11 +107,6 @@ PropTabBar::PropTabBar(QWidget *parent)
btn->setFocusPolicy(Qt::NoFocus); btn->setFocusPolicy(Qt::NoFocus);
} }
PropTabBar::~PropTabBar()
{
delete m_btnGroup;
}
int PropTabBar::currentIndex() const int PropTabBar::currentIndex() const
{ {
return m_currentIndex; return m_currentIndex;

2
src/gui/properties/proptabbar.h

@ -50,7 +50,7 @@ public:
}; };
explicit PropTabBar(QWidget *parent = nullptr); explicit PropTabBar(QWidget *parent = nullptr);
~PropTabBar();
int currentIndex() const; int currentIndex() const;
signals: signals:

5
src/gui/rss/feedlistwidget.cpp

@ -71,11 +71,6 @@ FeedListWidget::FeedListWidget(QWidget *parent)
// setCurrentItem(m_unreadStickyItem); // setCurrentItem(m_unreadStickyItem);
} }
FeedListWidget::~FeedListWidget()
{
delete m_unreadStickyItem;
}
void FeedListWidget::handleItemAdded(RSS::Item *rssItem) void FeedListWidget::handleItemAdded(RSS::Item *rssItem)
{ {
auto parentItem = m_rssToTreeItemMapping.value( auto parentItem = m_rssToTreeItemMapping.value(

1
src/gui/rss/feedlistwidget.h

@ -47,7 +47,6 @@ class FeedListWidget : public QTreeWidget
public: public:
explicit FeedListWidget(QWidget *parent); explicit FeedListWidget(QWidget *parent);
~FeedListWidget();
QTreeWidgetItem *stickyUnreadItem() const; QTreeWidgetItem *stickyUnreadItem() const;
QList<QTreeWidgetItem *> getAllOpenedFolders(QTreeWidgetItem *parent = nullptr) const; QList<QTreeWidgetItem *> getAllOpenedFolders(QTreeWidgetItem *parent = nullptr) const;

5
src/gui/torrentcontentfiltermodel.cpp

@ -44,11 +44,6 @@ TorrentContentFilterModel::TorrentContentFilterModel(QObject *parent)
setSortCaseSensitivity(Qt::CaseInsensitive); setSortCaseSensitivity(Qt::CaseInsensitive);
} }
TorrentContentFilterModel::~TorrentContentFilterModel()
{
delete m_model;
}
TorrentContentModel *TorrentContentFilterModel::model() const TorrentContentModel *TorrentContentFilterModel::model() const
{ {
return m_model; return m_model;

4
src/gui/torrentcontentfiltermodel.h

@ -41,7 +41,6 @@ class TorrentContentFilterModel : public QSortFilterProxyModel
public: public:
TorrentContentFilterModel(QObject *parent = nullptr); TorrentContentFilterModel(QObject *parent = nullptr);
~TorrentContentFilterModel() override;
TorrentContentModel *model() const; TorrentContentModel *model() const;
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const; TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
@ -60,8 +59,9 @@ protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private: private:
TorrentContentModel *m_model;
bool hasFiltered(const QModelIndex &folder) const; bool hasFiltered(const QModelIndex &folder) const;
TorrentContentModel *m_model;
}; };
#endif // TORRENTCONTENTFILTERMODEL_H #endif // TORRENTCONTENTFILTERMODEL_H

12
src/gui/transferlistwidget.cpp

@ -114,7 +114,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
// Create transfer list model // Create transfer list model
m_listModel = new TransferListModel(this); m_listModel = new TransferListModel(this);
m_sortFilterModel = new TransferListSortModel(); m_sortFilterModel = new TransferListSortModel(this);
m_sortFilterModel->setDynamicSortFilter(true); m_sortFilterModel->setDynamicSortFilter(true);
m_sortFilterModel->setSourceModel(m_listModel); m_sortFilterModel->setSourceModel(m_listModel);
m_sortFilterModel->setFilterKeyColumn(TransferListModel::TR_NAME); m_sortFilterModel->setFilterKeyColumn(TransferListModel::TR_NAME);
@ -207,14 +207,8 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
TransferListWidget::~TransferListWidget() TransferListWidget::~TransferListWidget()
{ {
qDebug() << Q_FUNC_INFO << "ENTER";
// Save settings // Save settings
saveSettings(); saveSettings();
// Clean up
delete m_sortFilterModel;
delete m_listModel;
delete m_listDelegate;
qDebug() << Q_FUNC_INFO << "EXIT";
} }
TransferListModel *TransferListWidget::getSourceModel() const TransferListModel *TransferListWidget::getSourceModel() const
@ -227,7 +221,7 @@ void TransferListWidget::previewFile(const QString &filePath)
Utils::Gui::openPath(filePath); Utils::Gui::openPath(filePath);
} }
inline QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) const QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) const
{ {
Q_ASSERT(index.isValid()); Q_ASSERT(index.isValid());
if (index.model() == m_sortFilterModel) if (index.model() == m_sortFilterModel)
@ -235,7 +229,7 @@ inline QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) con
return index; return index;
} }
inline QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) const QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) const
{ {
Q_ASSERT(index.isValid()); Q_ASSERT(index.isValid());
Q_ASSERT(index.model() == m_sortFilterModel); Q_ASSERT(index.model() == m_sortFilterModel);

Loading…
Cancel
Save