Browse Source

Iter cache more && prefix it

adaptive-webui-19844
Константин Гончарик 13 years ago
parent
commit
bbd1c9ee42
  1. 5
      src/rss/rssdownloadrule.cpp
  2. 4
      src/rss/rssdownloadrulelist.cpp
  3. 24
      src/rss/rssfeed.cpp
  4. 42
      src/rss/rssfolder.cpp

5
src/rss/rssdownloadrule.cpp

@ -122,7 +122,10 @@ QStringList RssDownloadRule::findMatchingArticles(const RssFeedPtr& feed) const @@ -122,7 +122,10 @@ QStringList RssDownloadRule::findMatchingArticles(const RssFeedPtr& feed) const
{
QStringList ret;
const RssArticleHash& feed_articles = feed->articleHash();
for (RssArticleHash::ConstIterator artIt = feed_articles.begin(); artIt != feed_articles.end(); artIt++) {
RssArticleHash::ConstIterator artIt = feed_articles.begin();
RssArticleHash::ConstIterator artItend = feed_articles.end();
for ( ; artIt != artItend ; ++artIt) {
const QString title = artIt.value()->title();
if (matches(title))
ret << title;

4
src/rss/rssdownloadrulelist.cpp

@ -75,7 +75,9 @@ QVariantHash RssDownloadRuleList::toVariantHash() const @@ -75,7 +75,9 @@ QVariantHash RssDownloadRuleList::toVariantHash() const
void RssDownloadRuleList::loadRulesFromVariantHash(const QVariantHash &h)
{
for (QVariantHash::ConstIterator it = h.begin(); it != h.end(); it++) {
QVariantHash::ConstIterator it = h.begin();
QVariantHash::ConstIterator itend = h.end();
for ( ; it != itend; ++it) {
RssDownloadRulePtr rule = RssDownloadRule::fromVariantHash(it.value().toHash());
if (rule && !rule->name().isEmpty())
saveRule(rule);

24
src/rss/rssfeed.cpp

@ -67,7 +67,10 @@ void RssFeed::saveItemsToDisk() { @@ -67,7 +67,10 @@ void RssFeed::saveItemsToDisk() {
return;
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QVariantList old_items;
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
RssArticleHash::ConstIterator it=m_articles.begin();
RssArticleHash::ConstIterator itend=m_articles.end();
for ( ; it != itend; ++it) {
old_items << it.value()->toHash();
}
qDebug("Saving %d old items for feed %s", old_items.size(), displayName().toLocal8Bit().data());
@ -175,7 +178,9 @@ uint RssFeed::count() const { @@ -175,7 +178,9 @@ uint RssFeed::count() const {
}
void RssFeed::markAsRead() {
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
RssArticleHash::ConstIterator it=m_articles.begin();
RssArticleHash::ConstIterator itend=m_articles.end();
for ( ; it != itend; ++it) {
it.value()->markAsRead();
}
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
@ -183,7 +188,10 @@ void RssFeed::markAsRead() { @@ -183,7 +188,10 @@ void RssFeed::markAsRead() {
uint RssFeed::unreadCount() const {
uint nbUnread = 0;
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
RssArticleHash::ConstIterator it=m_articles.begin();
RssArticleHash::ConstIterator itend=m_articles.end();
for ( ; it != itend; ++it) {
if (!it.value()->isRead())
++nbUnread;
}
@ -196,7 +204,10 @@ RssArticleList RssFeed::articleList() const { @@ -196,7 +204,10 @@ RssArticleList RssFeed::articleList() const {
RssArticleList RssFeed::unreadArticleList() const {
RssArticleList unread_news;
for (RssArticleHash::ConstIterator it = m_articles.begin(); it != m_articles.end(); it++) {
RssArticleHash::ConstIterator it = m_articles.begin();
RssArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) {
if (!it.value()->isRead())
unread_news << it.value();
}
@ -296,7 +307,10 @@ bool RssFeed::parseRSS(QIODevice* device) @@ -296,7 +307,10 @@ bool RssFeed::parseRSS(QIODevice* device)
void RssFeed::downloadMatchingArticleTorrents() {
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
RssDownloadRuleList *download_rules = m_manager->downloadRules();
for (RssArticleHash::ConstIterator it = m_articles.begin(); it != m_articles.end(); it++) {
RssArticleHash::ConstIterator it = m_articles.begin();
RssArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) {
RssArticlePtr article = it.value();
// Skip read articles
if (article->isRead())

42
src/rss/rssfolder.cpp

@ -44,7 +44,10 @@ RssFolder::~RssFolder() { @@ -44,7 +44,10 @@ RssFolder::~RssFolder() {
unsigned int RssFolder::unreadCount() const {
uint nb_unread = 0;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
nb_unread += it.value()->unreadCount();
}
return nb_unread;
@ -81,14 +84,19 @@ RssFeedPtr RssFolder::addStream(RssManager* manager, const QString &url) { @@ -81,14 +84,19 @@ RssFeedPtr RssFolder::addStream(RssManager* manager, const QString &url) {
// Refresh All Children
void RssFolder::refresh() {
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
it.value()->refresh();
}
}
RssArticleList RssFolder::articleList() const {
RssArticleList news;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
news << it.value()->articleList();
}
return news;
@ -96,7 +104,10 @@ RssArticleList RssFolder::articleList() const { @@ -96,7 +104,10 @@ RssArticleList RssFolder::articleList() const {
RssArticleList RssFolder::unreadArticleList() const {
RssArticleList unread_news;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
unread_news << it.value()->unreadArticleList();
}
return unread_news;
@ -108,7 +119,10 @@ RssFileList RssFolder::getContent() const { @@ -108,7 +119,10 @@ RssFileList RssFolder::getContent() const {
unsigned int RssFolder::getNbFeeds() const {
uint nbFeeds = 0;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value()))
nbFeeds += folder->getNbFeeds();
else
@ -133,14 +147,19 @@ void RssFolder::rename(const QString &new_name) { @@ -133,14 +147,19 @@ void RssFolder::rename(const QString &new_name) {
}
void RssFolder::markAsRead() {
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
it.value()->markAsRead();
}
}
RssFeedList RssFolder::getAllFeeds() const {
RssFeedList streams;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
if (RssFeedPtr feed = qSharedPointerDynamicCast<RssFeed>(it.value())) {
streams << feed;
} else if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value())) {
@ -152,7 +171,10 @@ RssFeedList RssFolder::getAllFeeds() const { @@ -152,7 +171,10 @@ RssFeedList RssFolder::getAllFeeds() const {
QHash<QString, RssFeedPtr> RssFolder::getAllFeedsAsHash() const {
QHash<QString, RssFeedPtr> ret;
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
if (RssFeedPtr feed = qSharedPointerDynamicCast<RssFeed>(it.value())) {
qDebug() << Q_FUNC_INFO << feed->url();
ret[feed->url()] = feed;
@ -182,7 +204,9 @@ void RssFolder::removeAllItems() { @@ -182,7 +204,9 @@ void RssFolder::removeAllItems() {
}
void RssFolder::removeAllSettings() {
for (RssFileHash::ConstIterator it = m_children.begin(); it != m_children.end(); it++) {
RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end();
for ( ; it != itend; ++it) {
it.value()->removeAllSettings();
}
}

Loading…
Cancel
Save