Browse Source

Omit redundant cast

adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
bbd781c420
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 4
      src/gui/rss/articlelistwidget.cpp
  2. 6
      src/gui/rss/feedlistwidget.cpp
  3. 6
      src/gui/rss/rsswidget.cpp

4
src/gui/rss/articlelistwidget.cpp

@ -47,7 +47,7 @@ ArticleListWidget::ArticleListWidget(QWidget *parent) @@ -47,7 +47,7 @@ ArticleListWidget::ArticleListWidget(QWidget *parent)
RSS::Article *ArticleListWidget::getRSSArticle(QListWidgetItem *item) const
{
Q_ASSERT(item);
return reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
return item->data(Qt::UserRole).value<RSS::Article *>();
}
QListWidgetItem *ArticleListWidget::mapRSSArticle(RSS::Article *rssArticle) const
@ -127,7 +127,7 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) 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<quintptr>(article));
item->setData(Qt::UserRole, QVariant::fromValue(article));
if (article->isRead())
{
const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)};

6
src/gui/rss/feedlistwidget.cpp

@ -105,7 +105,7 @@ FeedListWidget::FeedListWidget(QWidget *parent) @@ -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<quintptr>(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 @@ -213,7 +213,7 @@ RSS::Item *FeedListWidget::getRSSItem(QTreeWidgetItem *item) const
{
if (!item) return nullptr;
return reinterpret_cast<RSS::Item *>(item->data(0, Qt::UserRole).value<quintptr>());
return item->data(0, Qt::UserRole).value<RSS::Item *>();
}
QTreeWidgetItem *FeedListWidget::mapRSSItem(RSS::Item *rssItem) const
@ -275,7 +275,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem @@ -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<quintptr>(rssItem));
item->setData(0, Qt::UserRole, QVariant::fromValue(rssItem));
m_rssToTreeItemMapping[rssItem] = item;
QIcon icon;

6
src/gui/rss/rsswidget.cpp

@ -198,7 +198,7 @@ void RSSWidget::displayItemsListMenu() @@ -198,7 +198,7 @@ void RSSWidget::displayItemsListMenu()
bool hasLink = false;
for (const QListWidgetItem *item : asConst(m_articleListWidget->selectedItems()))
{
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
auto article = item->data(Qt::UserRole).value<RSS::Article *>();
Q_ASSERT(article);
if (!article->torrentUrl().isEmpty())
@ -359,7 +359,7 @@ void RSSWidget::downloadSelectedTorrents() @@ -359,7 +359,7 @@ void RSSWidget::downloadSelectedTorrents()
{
for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems()))
{
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
auto article = item->data(Qt::UserRole).value<RSS::Article *>();
Q_ASSERT(article);
// Mark as read
@ -380,7 +380,7 @@ void RSSWidget::openSelectedArticlesUrls() @@ -380,7 +380,7 @@ void RSSWidget::openSelectedArticlesUrls()
{
for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems()))
{
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
auto article = item->data(Qt::UserRole).value<RSS::Article *>();
Q_ASSERT(article);
// Mark as read

Loading…
Cancel
Save