From bbd781c420b37d5046ba855b1409a3997aa559fc Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 2 Apr 2022 16:08:05 +0800 Subject: [PATCH] Omit redundant cast --- src/gui/rss/articlelistwidget.cpp | 4 ++-- src/gui/rss/feedlistwidget.cpp | 6 +++--- src/gui/rss/rsswidget.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/rss/articlelistwidget.cpp b/src/gui/rss/articlelistwidget.cpp index 64d32635c..031c59383 100644 --- a/src/gui/rss/articlelistwidget.cpp +++ b/src/gui/rss/articlelistwidget.cpp @@ -47,7 +47,7 @@ ArticleListWidget::ArticleListWidget(QWidget *parent) RSS::Article *ArticleListWidget::getRSSArticle(QListWidgetItem *item) const { Q_ASSERT(item); - return reinterpret_cast(item->data(Qt::UserRole).value()); + return item->data(Qt::UserRole).value(); } QListWidgetItem *ArticleListWidget::mapRSSArticle(RSS::Article *rssArticle) const @@ -127,7 +127,7 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const auto *item = new QListWidgetItem; item->setData(Qt::DisplayRole, article->title()); - item->setData(Qt::UserRole, reinterpret_cast(article)); + item->setData(Qt::UserRole, QVariant::fromValue(article)); if (article->isRead()) { const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)}; diff --git a/src/gui/rss/feedlistwidget.cpp b/src/gui/rss/feedlistwidget.cpp index 681fc840a..92cacd4d1 100644 --- a/src/gui/rss/feedlistwidget.cpp +++ b/src/gui/rss/feedlistwidget.cpp @@ -105,7 +105,7 @@ FeedListWidget::FeedListWidget(QWidget *parent) m_rssToTreeItemMapping[RSS::Session::instance()->rootFolder()] = invisibleRootItem(); m_unreadStickyItem = new FeedListItem(this); - m_unreadStickyItem->setData(0, Qt::UserRole, reinterpret_cast(RSS::Session::instance()->rootFolder())); + m_unreadStickyItem->setData(0, Qt::UserRole, QVariant::fromValue(RSS::Session::instance()->rootFolder())); m_unreadStickyItem->setText(0, tr("Unread (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); m_unreadStickyItem->setData(0, Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"mail-folder-inbox"_qs)); m_unreadStickyItem->setData(0, StickyItemTagRole, true); @@ -213,7 +213,7 @@ RSS::Item *FeedListWidget::getRSSItem(QTreeWidgetItem *item) const { if (!item) return nullptr; - return reinterpret_cast(item->data(0, Qt::UserRole).value()); + return item->data(0, Qt::UserRole).value(); } QTreeWidgetItem *FeedListWidget::mapRSSItem(RSS::Item *rssItem) const @@ -275,7 +275,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem { auto *item = new FeedListItem; item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount()))); - item->setData(0, Qt::UserRole, reinterpret_cast(rssItem)); + item->setData(0, Qt::UserRole, QVariant::fromValue(rssItem)); m_rssToTreeItemMapping[rssItem] = item; QIcon icon; diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index b1d637ccf..13dd7880f 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -198,7 +198,7 @@ void RSSWidget::displayItemsListMenu() bool hasLink = false; for (const QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = reinterpret_cast(item->data(Qt::UserRole).value()); + auto article = item->data(Qt::UserRole).value(); Q_ASSERT(article); if (!article->torrentUrl().isEmpty()) @@ -359,7 +359,7 @@ void RSSWidget::downloadSelectedTorrents() { for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = reinterpret_cast(item->data(Qt::UserRole).value()); + auto article = item->data(Qt::UserRole).value(); Q_ASSERT(article); // Mark as read @@ -380,7 +380,7 @@ void RSSWidget::openSelectedArticlesUrls() { for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = reinterpret_cast(item->data(Qt::UserRole).value()); + auto article = item->data(Qt::UserRole).value(); Q_ASSERT(article); // Mark as read