mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
- Always keep number of unread news per folders up to date
- RefreshAllFeeds() only sets loading.png icon for feeds (and not folders)
This commit is contained in:
parent
f2d2e70967
commit
e126de8ff5
@ -46,6 +46,10 @@ public:
|
|||||||
return feeds_items.contains(QUrl(url).toString());
|
return feeds_items.contains(QUrl(url).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> getAllFeedItems() {
|
||||||
|
return feeds_items.values();
|
||||||
|
}
|
||||||
|
|
||||||
RssFile* getRSSItem(QTreeWidgetItem *item) {
|
RssFile* getRSSItem(QTreeWidgetItem *item) {
|
||||||
return mapping[item];
|
return mapping[item];
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,11 @@ RssFolder::~RssFolder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RssFolder::getNbUnRead() const {
|
unsigned int RssFolder::getNbUnRead() const {
|
||||||
// FIXME
|
unsigned int nb_unread = 0;
|
||||||
return 0;
|
foreach(RssFile *file, this->values()) {
|
||||||
|
nb_unread += file->getNbUnRead();
|
||||||
|
}
|
||||||
|
return nb_unread;
|
||||||
}
|
}
|
||||||
|
|
||||||
RssFile::FileType RssFolder::getType() const {
|
RssFile::FileType RssFolder::getType() const {
|
||||||
|
@ -202,9 +202,9 @@ void RSSImp::deleteSelectedItems() {
|
|||||||
|
|
||||||
// refresh all streams by a button
|
// refresh all streams by a button
|
||||||
void RSSImp::on_updateAllButton_clicked() {
|
void RSSImp::on_updateAllButton_clicked() {
|
||||||
unsigned int nbFeeds = listStreams->topLevelItemCount();
|
foreach(QTreeWidgetItem *item, listStreams->getAllFeedItems()) {
|
||||||
for(unsigned int i=0; i<nbFeeds; ++i)
|
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
|
||||||
listStreams->topLevelItem(i)->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
|
}
|
||||||
rssmanager->refreshAll();
|
rssmanager->refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,12 +236,12 @@ void RSSImp::renameFiles() {
|
|||||||
bool ok;
|
bool ok;
|
||||||
QString newName;
|
QString newName;
|
||||||
do {
|
do {
|
||||||
newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, listStreams->getRSSItem(item)->getName(), &ok);
|
newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, listStreams->getRSSItem(item)->getName(), &ok);
|
||||||
// Check if name is already taken
|
// Check if name is already taken
|
||||||
if(ok && rss_item->getParent()->contains(newName)) {
|
if(ok && rss_item->getParent()->contains(newName)) {
|
||||||
QMessageBox::warning(0, tr("Name already in use"), tr("This name is already used by another item, please choose another one."));
|
QMessageBox::warning(0, tr("Name already in use"), tr("This name is already used by another item, please choose another one."));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}while(!ok);
|
}while(!ok);
|
||||||
if(ok) {
|
if(ok) {
|
||||||
// Rename item
|
// Rename item
|
||||||
@ -405,6 +405,9 @@ void RSSImp::updateItemsInfos(QList<QTreeWidgetItem *> items) {
|
|||||||
void RSSImp::updateItemInfos(QTreeWidgetItem *item) {
|
void RSSImp::updateItemInfos(QTreeWidgetItem *item) {
|
||||||
RssFile *rss_item = listStreams->getRSSItem(item);
|
RssFile *rss_item = listStreams->getRSSItem(item);
|
||||||
item->setText(0, rss_item->getName() + QString::fromUtf8(" (") + QString::number(rss_item->getNbUnRead(), 10)+ QString(")"));
|
item->setText(0, rss_item->getName() + QString::fromUtf8(" (") + QString::number(rss_item->getNbUnRead(), 10)+ QString(")"));
|
||||||
|
// If item has a parent, update it too
|
||||||
|
if(item->parent())
|
||||||
|
updateItemInfos(item->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSImp::updateFeedIcon(QString url, QString icon_path){
|
void RSSImp::updateFeedIcon(QString url, QString icon_path){
|
||||||
@ -422,6 +425,9 @@ void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnr
|
|||||||
RssStream *stream = (RssStream*)listStreams->getRSSItem(item);
|
RssStream *stream = (RssStream*)listStreams->getRSSItem(item);
|
||||||
item->setText(0, aliasOrUrl + QString::fromUtf8(" (") + QString::number(nbUnread, 10)+ QString(")"));
|
item->setText(0, aliasOrUrl + QString::fromUtf8(" (") + QString::number(nbUnread, 10)+ QString(")"));
|
||||||
item->setData(0,Qt::DecorationRole, QVariant(QIcon(stream->getIconPath())));
|
item->setData(0,Qt::DecorationRole, QVariant(QIcon(stream->getIconPath())));
|
||||||
|
// Update parent
|
||||||
|
if(item->parent())
|
||||||
|
updateItemInfos(item->parent());
|
||||||
// If the feed is selected, update the displayed news
|
// If the feed is selected, update the displayed news
|
||||||
if(listStreams->currentItem() == item){
|
if(listStreams->currentItem() == item){
|
||||||
refreshNewsList(item);
|
refreshNewsList(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user