Browse Source

- Fix compilation warning regarding sortNewsList()

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
061a9c7ecf
  1. 2
      src/rss.cpp
  2. 30
      src/rss.h
  3. 4
      src/rss_imp.cpp

2
src/rss.cpp

@ -604,7 +604,7 @@ void RssStream::resizeList() {
unsigned int max_articles = settings.value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 100).toInt(); unsigned int max_articles = settings.value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 100).toInt();
unsigned int nb_articles = this->size(); unsigned int nb_articles = this->size();
if(nb_articles > max_articles) { if(nb_articles > max_articles) {
QList<RssItem*> listItem = sortNewsList(this->values()); QList<RssItem*> listItem = RssManager::sortNewsList(this->values());
int excess = nb_articles - max_articles; int excess = nb_articles - max_articles;
for(int i=0; i<excess; ++i){ for(int i=0; i<excess; ++i){
RssItem *lastItem = listItem.takeLast(); RssItem *lastItem = listItem.takeLast();

30
src/rss.h

@ -492,23 +492,25 @@ public slots:
public: public:
RssManager(bittorrent *BTSession); RssManager(bittorrent *BTSession);
~RssManager(); ~RssManager();
static void insertSortElem(QList<RssItem*> &list, RssItem *item) {
int i = 0;
while(i < list.size() && item->getDate() < list.at(i)->getDate()) {
++i;
}
list.insert(i, item);
}
static QList<RssItem*> sortNewsList(QList<RssItem*> news_list) {
QList<RssItem*> new_list;
foreach(RssItem *item, news_list) {
insertSortElem(new_list, item);
}
return new_list;
}
}; };
static void insertSortElem(QList<RssItem*> &list, RssItem *item) {
int i = 0;
while(i < list.size() && item->getDate() < list.at(i)->getDate()) {
++i;
}
list.insert(i, item);
}
static QList<RssItem*> sortNewsList(QList<RssItem*> news_list) {
QList<RssItem*> new_list;
foreach(RssItem *item, news_list) {
insertSortElem(new_list, item);
}
return new_list;
}
#endif #endif

4
src/rss_imp.cpp

@ -431,9 +431,9 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
qDebug("Getting the list of news"); qDebug("Getting the list of news");
QList<RssItem*> news; QList<RssItem*> news;
if(rss_item == rssmanager) if(rss_item == rssmanager)
news = sortNewsList(rss_item->getUnreadNewsList()); news = RssManager::sortNewsList(rss_item->getUnreadNewsList());
else else
news = sortNewsList(rss_item->getNewsList()); news = RssManager::sortNewsList(rss_item->getNewsList());
// Clear the list first // Clear the list first
textBrowser->clear(); textBrowser->clear();
previous_news = 0; previous_news = 0;

Loading…
Cancel
Save