diff --git a/src/downloadThread.h b/src/downloadThread.h index 049a707e0..696cac6a4 100644 --- a/src/downloadThread.h +++ b/src/downloadThread.h @@ -151,7 +151,7 @@ class downloadThread : public QThread { ++retries; SleeperThread::msleep(1000); } - }while(to_many_users && retries < 10); + }while(to_many_users && retries < 10 && response!=0); // Cleanup curl_easy_cleanup(curl); // Close tmp file diff --git a/src/rss.h b/src/rss.h index d1e8cc000..44496255b 100644 --- a/src/rss.h +++ b/src/rss.h @@ -19,9 +19,9 @@ * Contact : chris@qbittorrent.org, arnaud@qbittorrent.org */ +#define STREAM_MAX_ITEM 15 +// TODO : not used yet #define GLOBAL_MAX_ITEM 150 -#define STREAM_MAX_ITEM 20 - #ifndef RSS_H #define RSS_H @@ -191,6 +191,7 @@ class RssStream : public QObject{ return this->alias; } + //prefer the RssManager::setAlias, do not save the changed ones void setAlias(const QString& _alias){ this->alias = _alias; } @@ -319,7 +320,6 @@ class RssManager{ private : QList streamList; - QList ignoredStreamList; QStringList streamListUrl; QStringList streamListAlias; @@ -333,9 +333,6 @@ class RssManager{ for(unsigned short i=0; i=0){ - for(unsigned short i=0; igetUrl()==stream->getUrl()){ - delete ignoredStreamList.at(i); - this->ignoredStreamList.removeAt(i); - } - } for(unsigned short i=0; igetUrl()==stream->getUrl()){ delete streamList.at(i); @@ -414,37 +405,38 @@ class RssManager{ // remove all the streams in the manager void removeAll(){ - QList newIgnoredList, newStreamList; + QList newStreamList; QStringList newUrlList, newAliasList; for(unsigned short i=0; istreamList = newStreamList; - this->ignoredStreamList = newIgnoredList; this->streamListUrl = newUrlList; this->streamListAlias = newAliasList; } // reload all the xml files from the web void refreshAll(){ - QList newIgnoredList, newStreamList; + QList newStreamList; for(unsigned short i=0; istreamList = newStreamList; - this->ignoredStreamList = newIgnoredList; for(unsigned short i=0; istreamListUrl.at(i)); stream->setAlias(this->streamListAlias.at(i)); this->streamList.append(stream); } } + + void refresh(int index) { + if(index>=0 && indexstreamListUrl.at(index)); + stream->setAlias(this->streamListAlias.at(index)); + this->streamList.replace(index, stream); + } + } // return the position index of a stream, if the manager owns it short hasStream(RssStream* stream) const{ @@ -460,23 +452,23 @@ class RssManager{ return streamList.at(index); } - RssStream* getIgnored(const int& index) const{ - return ignoredStreamList.at(index); - } - void displayManager(){ for(unsigned short i=0; idisplayStream(); } - qDebug("#### rss ignored streams ####"); - for(unsigned short i=0; igetTitle().toUtf8()+" - "+getIgnored(i)->getUrl().toUtf8()+" // "+getIgnored(i)->getAlias().toUtf8()); - } } int getNbStream() { return streamList.size(); } + + //set an alias to an stream and save it for later + void setAlias(int index, QString newAlias) { + if(newAlias.length()>=2 && !streamListAlias.contains(newAlias, Qt::CaseInsensitive)) { + getStream(index)->setAlias(newAlias); + streamListAlias.replace(index, newAlias); + } + } }; diff --git a/src/rss.ui b/src/rss.ui index 85b91d93a..07ed41b31 100644 --- a/src/rss.ui +++ b/src/rss.ui @@ -49,7 +49,11 @@ - + + + Qt::CustomContextMenu + + @@ -171,7 +175,7 @@ - 600 + 520 0 @@ -195,6 +199,31 @@ + + + Delete + + + + + Rename + + + + + Refresh + + + + + Create + + + + + RefreshAll + + diff --git a/src/rss_imp.h b/src/rss_imp.h index 7b0bd3733..433d8ea27 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -21,8 +21,14 @@ #ifndef __RSS_IMP_H__ #define __RSS_IMP_H__ +// avoid crash if too many refresh +#define REFRESH_FREQ_MAX 5000 + +#include +#include #include "ui_rss.h" #include "rss.h" +#include "GUI.h" class RSSImp : public QWidget, public Ui::RSS{ Q_OBJECT @@ -32,6 +38,8 @@ class RSSImp : public QWidget, public Ui::RSS{ void refreshStreamList(); void refreshNewsList(); void refreshTextBrowser(); + QTimer* timer; + QTime lastRefresh; protected slots: void on_addStream_button_clicked(); @@ -40,6 +48,13 @@ class RSSImp : public QWidget, public Ui::RSS{ void on_listStreams_clicked(); void on_listNews_clicked(); void on_listNews_doubleClicked(); + void displayFinishedListMenu(const QPoint&); + void deleteStream(); + void renameStream(); + void refreshStream(); + void createStream(); + void refreshAllStream(); + void updateStreamNbNews(); public: RSSImp();