diff --git a/src/downloadThread.cpp b/src/downloadThread.cpp index 99c6ecdb2..34906e420 100644 --- a/src/downloadThread.cpp +++ b/src/downloadThread.cpp @@ -158,9 +158,9 @@ downloadThread::~downloadThread(){ abort = true; condition.wakeOne(); mutex.unlock(); - qDebug("downloadThread deleting subthreads..."); + //qDebug("downloadThread deleting subthreads..."); qDeleteAll(subThreads); - qDebug("downloadThread deleted subthreads"); + //qDebug("downloadThread deleted subthreads"); wait(); } @@ -184,16 +184,16 @@ void downloadThread::run(){ if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){ QString url = urls_queue.dequeue(); mutex.unlock(); - qDebug("DownloadThread downloading %s...", url.toLocal8Bit().data()); + //qDebug("DownloadThread downloading %s...", url.toLocal8Bit().data()); subDownloadThread *st = new subDownloadThread(0, url); subThreads << st; connect(st, SIGNAL(downloadFinishedST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadedFile(subDownloadThread*, QString, QString))); connect(st, SIGNAL(downloadFailureST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadFailure(subDownloadThread*, QString, QString))); st->start(); }else{ - qDebug("DownloadThread sleeping..."); + //qDebug("DownloadThread sleeping..."); condition.wait(&mutex); - qDebug("DownloadThread woke up"); + //qDebug("DownloadThread woke up"); mutex.unlock(); } } diff --git a/src/feedList.h b/src/feedList.h index bf3e1a708..806e66db0 100644 --- a/src/feedList.h +++ b/src/feedList.h @@ -53,11 +53,46 @@ public: return feeds_items.values(); } + QStringList getItemPath(QTreeWidgetItem* item) { + QStringList path; + if(item) { + if(item->parent()) + path.append(getItemPath(item->parent())); + path.append(getRSSItem(item)->getID()); + } + return path; + } + + QList getAllOpenFolders(QTreeWidgetItem *parent=0) { + QList open_folders; + int nbChildren; + if(parent) + nbChildren = parent->childCount(); + else + nbChildren = topLevelItemCount(); + for(int i=0; ichild(i); + else + item = topLevelItem(i); + if(getItemType(item) == RssFile::FOLDER && item->isExpanded()) { + QList open_subfolders = getAllOpenFolders(item); + if(!open_subfolders.empty()) { + open_folders.append(open_subfolders); + } else { + open_folders << item; + } + } + } + return open_folders; + } + QList getAllFeedItems(QTreeWidgetItem* folder) { QList feeds; int nbChildren = folder->childCount(); for(int i=0; ichild(i); + QTreeWidgetItem *item = folder->child(i); if(getItemType(item) == RssFile::STREAM) { feeds << item; } else { diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index abdd7379f..150809575 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -198,6 +198,52 @@ void RSSImp::deleteSelectedItems() { } } +void RSSImp::loadFoldersOpenState() { + QSettings settings("qBittorrent", "qBittorrent"); + settings.beginGroup("Rss"); + QVariantList open_folders = settings.value("open_folders", QVariantList()).toList(); + settings.endGroup(); + foreach(QVariant var_path, open_folders) { + QStringList path = var_path.toString().split("\\"); + QTreeWidgetItem *parent = 0; + foreach(QString name, path) { + QList children; + int nbChildren = 0; + if(parent) + nbChildren = parent->childCount(); + else + nbChildren = listStreams->topLevelItemCount(); + for(int i=0; ichild(i); + else + child = listStreams->topLevelItem(i); + if(listStreams->getRSSItem(child)->getID() == name) { + parent = child; + parent->setExpanded(true); + qDebug("expanding folder %s", name.toLocal8Bit().data()); + break; + } + } + } + } +} + +void RSSImp::saveFoldersOpenState() { + QVariantList open_folders; + QList items = listStreams->getAllOpenFolders(); + foreach(QTreeWidgetItem* item, items) { + QString path = listStreams->getItemPath(item).join("\\"); + qDebug("saving open folder: %s", path.toLocal8Bit().data()); + open_folders << path; + } + QSettings settings("qBittorrent", "qBittorrent"); + settings.beginGroup("Rss"); + settings.setValue("open_folders", open_folders); + settings.endGroup(); +} + // refresh all streams by a button void RSSImp::on_updateAllButton_clicked() { foreach(QTreeWidgetItem *item, listStreams->getAllFeedItems()) { @@ -443,6 +489,7 @@ RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){ splitter_h->insertWidget(0, listStreams); fillFeedsList(); + loadFoldersOpenState(); connect(rssmanager, SIGNAL(feedInfosChanged(QString, QString, unsigned int)), this, SLOT(updateFeedInfos(QString, QString, unsigned int))); connect(rssmanager, SIGNAL(feedIconChanged(QString, QString)), this, SLOT(updateFeedIcon(QString, QString))); @@ -482,6 +529,7 @@ RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){ RSSImp::~RSSImp(){ qDebug("Deleting RSSImp..."); + saveFoldersOpenState(); delete listStreams; delete rssmanager; qDebug("RSSImp deleted"); diff --git a/src/rss_imp.h b/src/rss_imp.h index e1058a968..21d6c84ad 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -72,6 +72,8 @@ protected slots: void restoreSlidersPosition(); void showFeedDownloader(); void askNewFolder(); + void saveFoldersOpenState(); + void loadFoldersOpenState(); public: RSSImp(bittorrent *BTSession);