mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-12 18:24:58 +08:00
Merge pull request #11 from BotanEgg/master
More end iterator caching and iterator preincrement.
This commit is contained in:
commit
ef34285855
@ -122,7 +122,10 @@ QStringList RssDownloadRule::findMatchingArticles(const RssFeedPtr& feed) const
|
|||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
const RssArticleHash& feed_articles = feed->articleHash();
|
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();
|
const QString title = artIt.value()->title();
|
||||||
if (matches(title))
|
if (matches(title))
|
||||||
ret << title;
|
ret << title;
|
||||||
|
@ -75,7 +75,9 @@ QVariantHash RssDownloadRuleList::toVariantHash() const
|
|||||||
|
|
||||||
void RssDownloadRuleList::loadRulesFromVariantHash(const QVariantHash &h)
|
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());
|
RssDownloadRulePtr rule = RssDownloadRule::fromVariantHash(it.value().toHash());
|
||||||
if (rule && !rule->name().isEmpty())
|
if (rule && !rule->name().isEmpty())
|
||||||
saveRule(rule);
|
saveRule(rule);
|
||||||
|
@ -67,7 +67,10 @@ void RssFeed::saveItemsToDisk() {
|
|||||||
return;
|
return;
|
||||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
||||||
QVariantList old_items;
|
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();
|
old_items << it.value()->toHash();
|
||||||
}
|
}
|
||||||
qDebug("Saving %d old items for feed %s", old_items.size(), displayName().toLocal8Bit().data());
|
qDebug("Saving %d old items for feed %s", old_items.size(), displayName().toLocal8Bit().data());
|
||||||
@ -175,7 +178,9 @@ uint RssFeed::count() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RssFeed::markAsRead() {
|
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();
|
it.value()->markAsRead();
|
||||||
}
|
}
|
||||||
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
|
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
|
||||||
@ -183,7 +188,10 @@ void RssFeed::markAsRead() {
|
|||||||
|
|
||||||
uint RssFeed::unreadCount() const {
|
uint RssFeed::unreadCount() const {
|
||||||
uint nbUnread = 0;
|
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())
|
if (!it.value()->isRead())
|
||||||
++nbUnread;
|
++nbUnread;
|
||||||
}
|
}
|
||||||
@ -196,7 +204,10 @@ RssArticleList RssFeed::articleList() const {
|
|||||||
|
|
||||||
RssArticleList RssFeed::unreadArticleList() const {
|
RssArticleList RssFeed::unreadArticleList() const {
|
||||||
RssArticleList unread_news;
|
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())
|
if (!it.value()->isRead())
|
||||||
unread_news << it.value();
|
unread_news << it.value();
|
||||||
}
|
}
|
||||||
@ -296,7 +307,10 @@ bool RssFeed::parseRSS(QIODevice* device)
|
|||||||
void RssFeed::downloadMatchingArticleTorrents() {
|
void RssFeed::downloadMatchingArticleTorrents() {
|
||||||
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
||||||
RssDownloadRuleList *download_rules = m_manager->downloadRules();
|
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();
|
RssArticlePtr article = it.value();
|
||||||
// Skip read articles
|
// Skip read articles
|
||||||
if (article->isRead())
|
if (article->isRead())
|
||||||
|
@ -44,7 +44,10 @@ RssFolder::~RssFolder() {
|
|||||||
|
|
||||||
unsigned int RssFolder::unreadCount() const {
|
unsigned int RssFolder::unreadCount() const {
|
||||||
uint nb_unread = 0;
|
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();
|
nb_unread += it.value()->unreadCount();
|
||||||
}
|
}
|
||||||
return nb_unread;
|
return nb_unread;
|
||||||
@ -81,14 +84,19 @@ RssFeedPtr RssFolder::addStream(RssManager* manager, const QString &url) {
|
|||||||
|
|
||||||
// Refresh All Children
|
// Refresh All Children
|
||||||
void RssFolder::refresh() {
|
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();
|
it.value()->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RssArticleList RssFolder::articleList() const {
|
RssArticleList RssFolder::articleList() const {
|
||||||
RssArticleList news;
|
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();
|
news << it.value()->articleList();
|
||||||
}
|
}
|
||||||
return news;
|
return news;
|
||||||
@ -96,7 +104,10 @@ RssArticleList RssFolder::articleList() const {
|
|||||||
|
|
||||||
RssArticleList RssFolder::unreadArticleList() const {
|
RssArticleList RssFolder::unreadArticleList() const {
|
||||||
RssArticleList unread_news;
|
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();
|
unread_news << it.value()->unreadArticleList();
|
||||||
}
|
}
|
||||||
return unread_news;
|
return unread_news;
|
||||||
@ -108,7 +119,10 @@ RssFileList RssFolder::getContent() const {
|
|||||||
|
|
||||||
unsigned int RssFolder::getNbFeeds() const {
|
unsigned int RssFolder::getNbFeeds() const {
|
||||||
uint nbFeeds = 0;
|
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()))
|
if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value()))
|
||||||
nbFeeds += folder->getNbFeeds();
|
nbFeeds += folder->getNbFeeds();
|
||||||
else
|
else
|
||||||
@ -133,14 +147,19 @@ void RssFolder::rename(const QString &new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RssFolder::markAsRead() {
|
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();
|
it.value()->markAsRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RssFeedList RssFolder::getAllFeeds() const {
|
RssFeedList RssFolder::getAllFeeds() const {
|
||||||
RssFeedList streams;
|
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())) {
|
if (RssFeedPtr feed = qSharedPointerDynamicCast<RssFeed>(it.value())) {
|
||||||
streams << feed;
|
streams << feed;
|
||||||
} else if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value())) {
|
} else if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value())) {
|
||||||
@ -152,7 +171,10 @@ RssFeedList RssFolder::getAllFeeds() const {
|
|||||||
|
|
||||||
QHash<QString, RssFeedPtr> RssFolder::getAllFeedsAsHash() const {
|
QHash<QString, RssFeedPtr> RssFolder::getAllFeedsAsHash() const {
|
||||||
QHash<QString, RssFeedPtr> ret;
|
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())) {
|
if (RssFeedPtr feed = qSharedPointerDynamicCast<RssFeed>(it.value())) {
|
||||||
qDebug() << Q_FUNC_INFO << feed->url();
|
qDebug() << Q_FUNC_INFO << feed->url();
|
||||||
ret[feed->url()] = feed;
|
ret[feed->url()] = feed;
|
||||||
@ -182,7 +204,9 @@ void RssFolder::removeAllItems() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RssFolder::removeAllSettings() {
|
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();
|
it.value()->removeAllSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user