Combine qAsConst() with copyAsConst() to asConst()

This commit is contained in:
thalieht
2018-11-27 22:15:04 +02:00
parent 6b1d26d555
commit 1f36b8b89f
57 changed files with 199 additions and 202 deletions

View File

@@ -47,7 +47,7 @@ Folder::~Folder()
{
emit aboutToBeDestroyed(this);
for (auto item : copyAsConst(items()))
for (auto item : asConst(items()))
delete item;
}
@@ -55,7 +55,7 @@ QList<Article *> Folder::articles() const
{
QList<Article *> news;
for (Item *item : copyAsConst(items())) {
for (Item *item : asConst(items())) {
int n = news.size();
news << item->articles();
std::inplace_merge(news.begin(), news.begin() + n, news.end()
@@ -70,20 +70,20 @@ QList<Article *> Folder::articles() const
int Folder::unreadCount() const
{
int count = 0;
for (Item *item : copyAsConst(items()))
for (Item *item : asConst(items()))
count += item->unreadCount();
return count;
}
void Folder::markAsRead()
{
for (Item *item : copyAsConst(items()))
for (Item *item : asConst(items()))
item->markAsRead();
}
void Folder::refresh()
{
for (Item *item : copyAsConst(items()))
for (Item *item : asConst(items()))
item->refresh();
}
@@ -95,7 +95,7 @@ QList<Item *> Folder::items() const
QJsonValue Folder::toJsonValue(bool withData) const
{
QJsonObject jsonObj;
for (Item *item : copyAsConst(items()))
for (Item *item : asConst(items()))
jsonObj.insert(item->name(), item->toJsonValue(withData));
return jsonObj;
@@ -108,7 +108,7 @@ void Folder::handleItemUnreadCountChanged()
void Folder::cleanup()
{
for (Item *item : copyAsConst(items()))
for (Item *item : asConst(items()))
item->cleanup();
}
@@ -123,7 +123,7 @@ void Folder::addItem(Item *item)
connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved);
connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged);
for (auto article : copyAsConst(item->articles()))
for (auto article : asConst(item->articles()))
emit newArticle(article);
if (item->unreadCount() > 0)
@@ -134,7 +134,7 @@ void Folder::removeItem(Item *item)
{
Q_ASSERT(m_items.contains(item));
for (auto article : copyAsConst(item->articles()))
for (auto article : asConst(item->articles()))
emit articleAboutToBeRemoved(article);
item->disconnect(this);