mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 15:07:22 -06:00
Improve coding style
This commit is contained in:
@@ -65,13 +65,16 @@ void ArticleListWidget::setRSSItem(RSS::Item *rssItem, bool unreadOnly)
|
||||
|
||||
m_unreadOnly = unreadOnly;
|
||||
m_rssItem = rssItem;
|
||||
if (m_rssItem) {
|
||||
if (m_rssItem)
|
||||
{
|
||||
connect(m_rssItem, &RSS::Item::newArticle, this, &ArticleListWidget::handleArticleAdded);
|
||||
connect(m_rssItem, &RSS::Item::articleRead, this, &ArticleListWidget::handleArticleRead);
|
||||
connect(m_rssItem, &RSS::Item::articleAboutToBeRemoved, this, &ArticleListWidget::handleArticleAboutToBeRemoved);
|
||||
|
||||
for (const auto article : asConst(rssItem->articles())) {
|
||||
if (!(m_unreadOnly && article->isRead())) {
|
||||
for (const auto article : asConst(rssItem->articles()))
|
||||
{
|
||||
if (!(m_unreadOnly && article->isRead()))
|
||||
{
|
||||
auto item = createItem(article);
|
||||
addItem(item);
|
||||
m_rssArticleToListItemMapping.insert(article, item);
|
||||
@@ -84,7 +87,8 @@ void ArticleListWidget::setRSSItem(RSS::Item *rssItem, bool unreadOnly)
|
||||
|
||||
void ArticleListWidget::handleArticleAdded(RSS::Article *rssArticle)
|
||||
{
|
||||
if (!(m_unreadOnly && rssArticle->isRead())) {
|
||||
if (!(m_unreadOnly && rssArticle->isRead()))
|
||||
{
|
||||
auto item = createItem(rssArticle);
|
||||
insertItem(0, item);
|
||||
m_rssArticleToListItemMapping.insert(rssArticle, item);
|
||||
@@ -124,13 +128,15 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const
|
||||
|
||||
item->setData(Qt::DisplayRole, article->title());
|
||||
item->setData(Qt::UserRole, reinterpret_cast<quintptr>(article));
|
||||
if (article->isRead()) {
|
||||
if (article->isRead())
|
||||
{
|
||||
const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)};
|
||||
const QBrush foregroundBrush {UIThemeManager::instance()->getColor("RSS.ReadArticle", defaultColor)};
|
||||
item->setData(Qt::ForegroundRole, foregroundBrush);
|
||||
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("sphere")));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
const QColor defaultColor {palette().color(QPalette::Active, QPalette::Link)};
|
||||
const QBrush foregroundBrush {UIThemeManager::instance()->getColor("RSS.UnreadArticle", defaultColor)};
|
||||
item->setData(Qt::ForegroundRole, foregroundBrush);
|
||||
|
||||
Reference in New Issue
Block a user