mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
- Started to implement drag n drop in feed list but it is still very buggy
This commit is contained in:
parent
b9f1586068
commit
2fa43dd973
@ -158,7 +158,9 @@ downloadThread::~downloadThread(){
|
|||||||
abort = true;
|
abort = true;
|
||||||
condition.wakeOne();
|
condition.wakeOne();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug("downloadThread deleting subthreads...");
|
||||||
qDeleteAll(subThreads);
|
qDeleteAll(subThreads);
|
||||||
|
qDebug("downloadThread deleted subthreads");
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,25 +176,31 @@ void downloadThread::downloadUrl(QString url){
|
|||||||
|
|
||||||
void downloadThread::run(){
|
void downloadThread::run(){
|
||||||
forever{
|
forever{
|
||||||
if(abort)
|
if(abort) {
|
||||||
|
qDebug("DownloadThread aborting...");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){
|
if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){
|
||||||
QString url = urls_queue.dequeue();
|
QString url = urls_queue.dequeue();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug("DownloadThread downloading %s...", url.toLocal8Bit().data());
|
||||||
subDownloadThread *st = new subDownloadThread(0, url);
|
subDownloadThread *st = new subDownloadThread(0, url);
|
||||||
subThreads << st;
|
subThreads << st;
|
||||||
connect(st, SIGNAL(downloadFinishedST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadedFile(subDownloadThread*, QString, QString)));
|
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)));
|
connect(st, SIGNAL(downloadFailureST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadFailure(subDownloadThread*, QString, QString)));
|
||||||
st->start();
|
st->start();
|
||||||
}else{
|
}else{
|
||||||
|
qDebug("DownloadThread sleeping...");
|
||||||
condition.wait(&mutex);
|
condition.wait(&mutex);
|
||||||
|
qDebug("DownloadThread woke up");
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, QString path){
|
void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, QString path){
|
||||||
|
qDebug("Downloading %s was successful", url.toLocal8Bit().data());
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
int index = subThreads.indexOf(st);
|
int index = subThreads.indexOf(st);
|
||||||
Q_ASSERT(index != -1);
|
Q_ASSERT(index != -1);
|
||||||
@ -208,6 +216,7 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){
|
void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){
|
||||||
|
qDebug("Downloading %s failed", url.toLocal8Bit().data());
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
int index = subThreads.indexOf(st);
|
int index = subThreads.indexOf(st);
|
||||||
Q_ASSERT(index != -1);
|
Q_ASSERT(index != -1);
|
||||||
|
71
src/feedList.h
Normal file
71
src/feedList.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#ifndef FEEDLIST_H
|
||||||
|
#define FEEDLIST_H
|
||||||
|
|
||||||
|
#include <QTreeWidget>
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QDragMoveEvent>
|
||||||
|
#include <QStringList>
|
||||||
|
#include "rss.h"
|
||||||
|
|
||||||
|
class FeedList : public QTreeWidget {
|
||||||
|
|
||||||
|
private:
|
||||||
|
RssManager *rssmanager;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FeedList(QWidget *parent, RssManager *rssmanager): QTreeWidget(parent), rssmanager(rssmanager) {
|
||||||
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
setColumnCount(3);
|
||||||
|
QTreeWidgetItem *___qtreewidgetitem = headerItem();
|
||||||
|
___qtreewidgetitem->setText(2, QApplication::translate("RSS", "type", 0, QApplication::UnicodeUTF8));
|
||||||
|
___qtreewidgetitem->setText(1, QApplication::translate("RSS", "url", 0, QApplication::UnicodeUTF8));
|
||||||
|
___qtreewidgetitem->setText(0, QApplication::translate("RSS", "RSS feeds", 0, QApplication::UnicodeUTF8));
|
||||||
|
// Hide second column (url) and third column (type)
|
||||||
|
hideColumn(1);
|
||||||
|
hideColumn(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList getItemPath(QTreeWidgetItem *item) const {
|
||||||
|
QStringList path;
|
||||||
|
if(item) {
|
||||||
|
if(item->parent()) {
|
||||||
|
path = getItemPath(item->parent());
|
||||||
|
}
|
||||||
|
path << item->text(1);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void dragMoveEvent(QDragMoveEvent * event) {
|
||||||
|
QTreeWidgetItem *item = itemAt(event->pos());
|
||||||
|
if(item && rssmanager->getFile(getItemPath(item))->getType() != RssFile::FOLDER)
|
||||||
|
event->ignore();
|
||||||
|
else {
|
||||||
|
QAbstractItemView::dragMoveEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dropEvent(QDropEvent *event) {
|
||||||
|
qDebug("dropEvent");
|
||||||
|
QTreeWidgetItem *dest_item = itemAt(event->pos());
|
||||||
|
QStringList dest_folder_path = getItemPath(dest_item);
|
||||||
|
QList<QTreeWidgetItem *> src_items = selectedItems();
|
||||||
|
foreach(QTreeWidgetItem *src_item, src_items) {
|
||||||
|
QStringList src_path = getItemPath(src_item);
|
||||||
|
QStringList dest_path = dest_folder_path;
|
||||||
|
dest_path << src_item->text(1);
|
||||||
|
qDebug("Moving file %s to %s", src_path.join("\\").toLocal8Bit().data(), dest_path.join("\\").toLocal8Bit().data());
|
||||||
|
rssmanager->moveFile(src_path, dest_path);
|
||||||
|
}
|
||||||
|
QAbstractItemView::dropEvent (event);
|
||||||
|
if(dest_item)
|
||||||
|
dest_item->setExpanded(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FEEDLIST_H
|
32
src/rss.cpp
32
src/rss.cpp
@ -40,9 +40,11 @@ RssFolder::RssFolder(RssFolder *parent, RssManager *rssmanager, bittorrent *BTSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
RssFolder::~RssFolder() {
|
RssFolder::~RssFolder() {
|
||||||
qDebug("Deleting downloader thread");
|
qDebug("Deleting a RSS folder, removing elements");
|
||||||
qDeleteAll(this->values());
|
qDeleteAll(this->values());
|
||||||
|
qDebug("Deleting downloader thread");
|
||||||
delete downloader;
|
delete downloader;
|
||||||
|
qDebug("Downloader thread removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RssFolder::getNbUnRead() const {
|
unsigned int RssFolder::getNbUnRead() const {
|
||||||
@ -165,6 +167,7 @@ void RssFolder::refresh(QStringList full_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RssFile* RssFolder::getFile(QStringList full_path) const {
|
RssFile* RssFolder::getFile(QStringList full_path) const {
|
||||||
|
if(full_path.isEmpty()) return rssmanager;
|
||||||
QString name = full_path.last();
|
QString name = full_path.last();
|
||||||
if(full_path.size() == 1) {
|
if(full_path.size() == 1) {
|
||||||
Q_ASSERT(this->contains(name));
|
Q_ASSERT(this->contains(name));
|
||||||
@ -363,8 +366,22 @@ void RssManager::moveFile(QStringList old_path, QStringList new_path) {
|
|||||||
RssFolder* src_folder = item->getParent();
|
RssFolder* src_folder = item->getParent();
|
||||||
QString new_name = new_path.takeLast();
|
QString new_name = new_path.takeLast();
|
||||||
RssFolder* dest_folder = (RssFolder*)getFile(new_path);
|
RssFolder* dest_folder = (RssFolder*)getFile(new_path);
|
||||||
|
if(dest_folder != src_folder) {
|
||||||
dest_folder->addFile(item);
|
dest_folder->addFile(item);
|
||||||
src_folder->removeFileRef(item);
|
src_folder->removeFileRef(item);
|
||||||
|
} else {
|
||||||
|
qDebug("Nothing to move, same destination folder");
|
||||||
|
}
|
||||||
|
// Need to rename?
|
||||||
|
QString current_name;
|
||||||
|
if(item->getType() == RssFile::FOLDER)
|
||||||
|
current_name = item->getName();
|
||||||
|
else
|
||||||
|
current_name = ((RssStream*)item)->getUrl();
|
||||||
|
if(current_name != new_name) {
|
||||||
|
qDebug("Renaming file from %s to %s...", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data());
|
||||||
|
dest_folder->rename(item->getPath(), new_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssManager::saveStreamList(){
|
void RssManager::saveStreamList(){
|
||||||
@ -373,7 +390,9 @@ void RssManager::saveStreamList(){
|
|||||||
QStringList aliases;
|
QStringList aliases;
|
||||||
QList<RssStream*> streams = getAllFeeds();
|
QList<RssStream*> streams = getAllFeeds();
|
||||||
foreach(RssStream *stream, streams) {
|
foreach(RssStream *stream, streams) {
|
||||||
streamsUrl << stream->getPath().join("\\");
|
QString stream_path = stream->getPath().join("\\");
|
||||||
|
qDebug("Saving stream path: %s", stream_path.toLocal8Bit().data());
|
||||||
|
streamsUrl << stream_path;
|
||||||
aliases << stream->getName();
|
aliases << stream->getName();
|
||||||
}
|
}
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
@ -401,6 +420,7 @@ RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, bittorrent *BTSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
RssStream::~RssStream(){
|
RssStream::~RssStream(){
|
||||||
|
qDebug("Deleting a RSS stream: %s", getName().toLocal8Bit().data());
|
||||||
if(refreshed) {
|
if(refreshed) {
|
||||||
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
||||||
QVariantList old_items;
|
QVariantList old_items;
|
||||||
@ -412,7 +432,9 @@ RssStream::~RssStream(){
|
|||||||
all_old_items[url] = old_items;
|
all_old_items[url] = old_items;
|
||||||
qBTRSS.setValue("old_items", all_old_items);
|
qBTRSS.setValue("old_items", all_old_items);
|
||||||
}
|
}
|
||||||
|
qDebug("Removing all item from feed");
|
||||||
removeAllItems();
|
removeAllItems();
|
||||||
|
qDebug("All items were removed");
|
||||||
if(QFile::exists(filePath))
|
if(QFile::exists(filePath))
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
if(QFile::exists(iconPath) && !iconPath.startsWith(":/"))
|
if(QFile::exists(iconPath) && !iconPath.startsWith(":/"))
|
||||||
@ -469,14 +491,14 @@ void RssStream::rename(QStringList, QString new_name){
|
|||||||
// Return the alias if the stream has one, the url if it has no alias
|
// Return the alias if the stream has one, the url if it has no alias
|
||||||
QString RssStream::getName() const{
|
QString RssStream::getName() const{
|
||||||
if(!alias.isEmpty()) {
|
if(!alias.isEmpty()) {
|
||||||
qDebug("getName() returned alias: %s", (const char*)alias.toLocal8Bit());
|
//qDebug("getName() returned alias: %s", (const char*)alias.toLocal8Bit());
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
if(!title.isEmpty()) {
|
if(!title.isEmpty()) {
|
||||||
qDebug("getName() returned title: %s", (const char*)title.toLocal8Bit());
|
//qDebug("getName() returned title: %s", (const char*)title.toLocal8Bit());
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
qDebug("getName() returned url: %s", (const char*)url.toLocal8Bit());
|
//qDebug("getName() returned url: %s", (const char*)url.toLocal8Bit());
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
src/rss.ui
36
src/rss.ui
@ -10,6 +10,9 @@
|
|||||||
<height>447</height>
|
<height>447</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Search</string>
|
<string>Search</string>
|
||||||
</property>
|
</property>
|
||||||
@ -93,32 +96,6 @@
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTreeWidget" name="listStreams">
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="columnCount">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>RSS feeds</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>url</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>type</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -274,13 +251,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QWebView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>QtWebKit/QWebView</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -35,9 +35,11 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QDragMoveEvent>
|
||||||
|
|
||||||
#include "rss_imp.h"
|
#include "rss_imp.h"
|
||||||
#include "FeedDownloader.h"
|
#include "FeedDownloader.h"
|
||||||
|
#include "feedList.h"
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
|
|
||||||
// display a right-click menu
|
// display a right-click menu
|
||||||
@ -54,7 +56,7 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
|
|||||||
myRSSListMenu.addSeparator();
|
myRSSListMenu.addSeparator();
|
||||||
if(selectedItems.size() == 1) {
|
if(selectedItems.size() == 1) {
|
||||||
myRSSListMenu.addAction(actionRename);
|
myRSSListMenu.addAction(actionRename);
|
||||||
RssFile *rss_item = rssmanager->getFile(getItemPath(selectedItems.first()));
|
RssFile *rss_item = rssmanager->getFile(listStreams->getItemPath(selectedItems.first()));
|
||||||
if(rss_item->getType() == RssFile::FOLDER)
|
if(rss_item->getType() == RssFile::FOLDER)
|
||||||
myRSSListMenu.addAction(actionNew_folder);
|
myRSSListMenu.addAction(actionNew_folder);
|
||||||
}
|
}
|
||||||
@ -85,19 +87,8 @@ void RSSImp::displayItemsListMenu(const QPoint&){
|
|||||||
myItemListMenu.exec(QCursor::pos());
|
myItemListMenu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList RSSImp::getItemPath(QTreeWidgetItem *item) const {
|
|
||||||
QStringList path;
|
|
||||||
if(item) {
|
|
||||||
if(item->parent()) {
|
|
||||||
path = getItemPath(item->parent());
|
|
||||||
}
|
|
||||||
path << item->text(1);
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList RSSImp::getCurrentFeedPath() const {
|
QStringList RSSImp::getCurrentFeedPath() const {
|
||||||
return getItemPath(listStreams->currentItem());
|
return listStreams->getItemPath(listStreams->currentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
RssFile::FileType RSSImp::getItemType(QTreeWidgetItem *item) const {
|
RssFile::FileType RSSImp::getItemType(QTreeWidgetItem *item) const {
|
||||||
@ -111,7 +102,7 @@ void RSSImp::askNewFolder() {
|
|||||||
QTreeWidgetItem *parent_item = 0;
|
QTreeWidgetItem *parent_item = 0;
|
||||||
if(listStreams->selectedItems().size() > 0) {
|
if(listStreams->selectedItems().size() > 0) {
|
||||||
parent_item = listStreams->selectedItems().at(0);
|
parent_item = listStreams->selectedItems().at(0);
|
||||||
foreach(QString name, getItemPath(parent_item)) {
|
foreach(QString name, listStreams->getItemPath(parent_item)) {
|
||||||
dest_path << name;
|
dest_path << name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,6 +121,7 @@ void RSSImp::askNewFolder() {
|
|||||||
folder_item->setData(2,Qt::DisplayRole, QVariant((int)RssFile::FOLDER));
|
folder_item->setData(2,Qt::DisplayRole, QVariant((int)RssFile::FOLDER));
|
||||||
folder_item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/folder.png")));
|
folder_item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/folder.png")));
|
||||||
// Expand parent folder to display new folder
|
// Expand parent folder to display new folder
|
||||||
|
if(parent_item)
|
||||||
parent_item->setExpanded(true);
|
parent_item->setExpanded(true);
|
||||||
rssmanager->saveStreamList();
|
rssmanager->saveStreamList();
|
||||||
}
|
}
|
||||||
@ -140,9 +132,9 @@ void RSSImp::on_newFeedButton_clicked() {
|
|||||||
QStringList dest_path;
|
QStringList dest_path;
|
||||||
QTreeWidgetItem *current_item = listStreams->currentItem();
|
QTreeWidgetItem *current_item = listStreams->currentItem();
|
||||||
if(getItemType(current_item) != RssFile::FOLDER)
|
if(getItemType(current_item) != RssFile::FOLDER)
|
||||||
dest_path = getItemPath(current_item->parent());
|
dest_path = listStreams->getItemPath(current_item->parent());
|
||||||
else
|
else
|
||||||
dest_path = getItemPath(current_item);
|
dest_path = listStreams->getItemPath(current_item);
|
||||||
bool ok;
|
bool ok;
|
||||||
QString clip_txt = qApp->clipboard()->text();
|
QString clip_txt = qApp->clipboard()->text();
|
||||||
QString default_url = "http://";
|
QString default_url = "http://";
|
||||||
@ -189,7 +181,7 @@ void RSSImp::deleteSelectedItems() {
|
|||||||
textBrowser->clear();
|
textBrowser->clear();
|
||||||
listNews->clear();
|
listNews->clear();
|
||||||
}
|
}
|
||||||
rssmanager->removeFile(getItemPath(item));
|
rssmanager->removeFile(listStreams->getItemPath(item));
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
rssmanager->saveStreamList();
|
rssmanager->saveStreamList();
|
||||||
@ -229,9 +221,9 @@ void RSSImp::renameFiles() {
|
|||||||
Q_ASSERT(selectedItems.size() == 1);
|
Q_ASSERT(selectedItems.size() == 1);
|
||||||
QTreeWidgetItem *item = selectedItems.at(0);
|
QTreeWidgetItem *item = selectedItems.at(0);
|
||||||
bool ok;
|
bool ok;
|
||||||
QString newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, rssmanager->getFile(getItemPath(item))->getName(), &ok);
|
QString newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, rssmanager->getFile(listStreams->getItemPath(item))->getName(), &ok);
|
||||||
if(ok) {
|
if(ok) {
|
||||||
rssmanager->rename(getItemPath(item), newName);
|
rssmanager->rename(listStreams->getItemPath(item), newName);
|
||||||
item->setText(0, newName);
|
item->setText(0, newName);
|
||||||
item->setText(1, newName);
|
item->setText(1, newName);
|
||||||
}
|
}
|
||||||
@ -242,7 +234,7 @@ void RSSImp::refreshSelectedStreams() {
|
|||||||
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
|
||||||
QTreeWidgetItem* item;
|
QTreeWidgetItem* item;
|
||||||
foreach(item, selectedItems){
|
foreach(item, selectedItems){
|
||||||
rssmanager->refresh(getItemPath(item));
|
rssmanager->refresh(listStreams->getItemPath(item));
|
||||||
if(getItemType(item) == RssFile::STREAM)
|
if(getItemType(item) == RssFile::STREAM)
|
||||||
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
|
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
|
||||||
}
|
}
|
||||||
@ -260,7 +252,7 @@ void RSSImp::copySelectedFeedsURL() {
|
|||||||
|
|
||||||
void RSSImp::showFeedDownloader() {
|
void RSSImp::showFeedDownloader() {
|
||||||
QTreeWidgetItem* item = listStreams->selectedItems()[0];
|
QTreeWidgetItem* item = listStreams->selectedItems()[0];
|
||||||
RssFile* rss_item = rssmanager->getFile(getItemPath(item));
|
RssFile* rss_item = rssmanager->getFile(listStreams->getItemPath(item));
|
||||||
if(rss_item->getType() == RssFile::STREAM)
|
if(rss_item->getType() == RssFile::STREAM)
|
||||||
new FeedDownloaderDlg(this, item->text(1), rss_item->getName(), BTSession);
|
new FeedDownloaderDlg(this, item->text(1), rss_item->getName(), BTSession);
|
||||||
}
|
}
|
||||||
@ -269,7 +261,7 @@ void RSSImp::on_markReadButton_clicked() {
|
|||||||
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
|
||||||
QTreeWidgetItem* item;
|
QTreeWidgetItem* item;
|
||||||
foreach(item, selectedItems){
|
foreach(item, selectedItems){
|
||||||
RssFile *rss_item = rssmanager->getFile(getItemPath(item));
|
RssFile *rss_item = rssmanager->getFile(listStreams->getItemPath(item));
|
||||||
rss_item->markAllAsRead();
|
rss_item->markAllAsRead();
|
||||||
item->setData(0, Qt::DisplayRole, rss_item->getName()+ QString::fromUtf8(" (0)"));
|
item->setData(0, Qt::DisplayRole, rss_item->getName()+ QString::fromUtf8(" (0)"));
|
||||||
}
|
}
|
||||||
@ -407,7 +399,7 @@ QString RSSImp::getCurrentFeedUrl() const {
|
|||||||
|
|
||||||
void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnread){
|
void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnread){
|
||||||
QTreeWidgetItem *item = getTreeItemFromUrl(url);
|
QTreeWidgetItem *item = getTreeItemFromUrl(url);
|
||||||
RssStream *stream = (RssStream*)rssmanager->getFile(getItemPath(item));
|
RssStream *stream = (RssStream*)rssmanager->getFile(listStreams->getItemPath(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())));
|
||||||
// If the feed is selected, update the displayed news
|
// If the feed is selected, update the displayed news
|
||||||
@ -419,11 +411,11 @@ void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnr
|
|||||||
RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
// Hide second column (url) and third column (type)
|
|
||||||
listStreams->hideColumn(1);
|
|
||||||
listStreams->hideColumn(2);
|
|
||||||
|
|
||||||
rssmanager = new RssManager(BTSession);
|
rssmanager = new RssManager(BTSession);
|
||||||
|
|
||||||
|
listStreams = new FeedList(splitter_h, rssmanager);
|
||||||
|
splitter_h->insertWidget(0, listStreams);
|
||||||
|
|
||||||
fillFeedsList();
|
fillFeedsList();
|
||||||
connect(rssmanager, SIGNAL(feedInfosChanged(QString, QString, unsigned int)), this, SLOT(updateFeedInfos(QString, QString, unsigned int)));
|
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)));
|
connect(rssmanager, SIGNAL(feedIconChanged(QString, QString)), this, SLOT(updateFeedIcon(QString, QString)));
|
||||||
@ -458,6 +450,7 @@ RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
|||||||
// Bind saveSliders slots
|
// Bind saveSliders slots
|
||||||
connect(splitter_v, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition()));
|
connect(splitter_v, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition()));
|
||||||
connect(splitter_h, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition()));
|
connect(splitter_h, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition()));
|
||||||
|
|
||||||
qDebug("RSSImp constructed");
|
qDebug("RSSImp constructed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,6 +463,7 @@ void RSSImp::selectFirstFeed(){
|
|||||||
|
|
||||||
RSSImp::~RSSImp(){
|
RSSImp::~RSSImp(){
|
||||||
qDebug("Deleting RSSImp...");
|
qDebug("Deleting RSSImp...");
|
||||||
|
delete listStreams;
|
||||||
delete rssmanager;
|
delete rssmanager;
|
||||||
qDebug("RSSImp deleted");
|
qDebug("RSSImp deleted");
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include "rss.h"
|
#include "rss.h"
|
||||||
|
|
||||||
class bittorrent;
|
class bittorrent;
|
||||||
|
class FeedList;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
class RSSImp : public QWidget, public Ui::RSS{
|
class RSSImp : public QWidget, public Ui::RSS{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -43,6 +45,7 @@ class RSSImp : public QWidget, public Ui::RSS{
|
|||||||
private:
|
private:
|
||||||
RssManager *rssmanager;
|
RssManager *rssmanager;
|
||||||
bittorrent *BTSession;
|
bittorrent *BTSession;
|
||||||
|
FeedList *listStreams;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void deleteSelectedItems();
|
void deleteSelectedItems();
|
||||||
@ -76,9 +79,9 @@ public:
|
|||||||
QTreeWidgetItem* getTreeItemFromUrl(QString url) const;
|
QTreeWidgetItem* getTreeItemFromUrl(QString url) const;
|
||||||
QString getCurrentFeedUrl() const;
|
QString getCurrentFeedUrl() const;
|
||||||
QTreeWidgetItem* getItemFromPath(QStringList path) const;
|
QTreeWidgetItem* getItemFromPath(QStringList path) const;
|
||||||
QStringList getItemPath(QTreeWidgetItem *item) const;
|
|
||||||
QStringList getCurrentFeedPath() const;
|
QStringList getCurrentFeedPath() const;
|
||||||
RssFile::FileType getItemType(QTreeWidgetItem *item) const;
|
RssFile::FileType getItemType(QTreeWidgetItem *item) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -184,7 +184,8 @@ HEADERS += GUI.h \
|
|||||||
ico.h \
|
ico.h \
|
||||||
stacktrace.h \
|
stacktrace.h \
|
||||||
torrentPersistentData.h \
|
torrentPersistentData.h \
|
||||||
FeedDownloader.h
|
FeedDownloader.h \
|
||||||
|
feedList.h
|
||||||
FORMS += MainWindow.ui \
|
FORMS += MainWindow.ui \
|
||||||
options.ui \
|
options.ui \
|
||||||
about.ui \
|
about.ui \
|
||||||
|
Loading…
Reference in New Issue
Block a user