|
|
|
@ -52,23 +52,24 @@
@@ -52,23 +52,24 @@
|
|
|
|
|
#include "iconprovider.h" |
|
|
|
|
#include "autoexpandabledialog.h" |
|
|
|
|
|
|
|
|
|
namespace Article { |
|
|
|
|
enum ArticleRoles { |
|
|
|
|
namespace Article |
|
|
|
|
{ |
|
|
|
|
enum ArticleRoles |
|
|
|
|
{ |
|
|
|
|
TitleRole = Qt::DisplayRole, |
|
|
|
|
IconRole = Qt::DecorationRole, |
|
|
|
|
ColorRole = Qt::ForegroundRole, |
|
|
|
|
IdRole = Qt::UserRole + 1, |
|
|
|
|
FeedUrlRole = Qt::UserRole + 2 |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// display a right-click menu
|
|
|
|
|
void RSSImp::displayRSSListMenu(const QPoint& pos) |
|
|
|
|
{ |
|
|
|
|
if (!m_feedList->indexAt(pos).isValid()) { |
|
|
|
|
if (!m_feedList->indexAt(pos).isValid()) |
|
|
|
|
// No item under the mouse, clear selection
|
|
|
|
|
m_feedList->clearSelection(); |
|
|
|
|
} |
|
|
|
|
QMenu myRSSListMenu(this); |
|
|
|
|
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); |
|
|
|
|
if (selectedItems.size() > 0) { |
|
|
|
@ -80,13 +81,12 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
@@ -80,13 +81,12 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
|
|
|
|
|
myRSSListMenu.addAction(actionRename); |
|
|
|
|
myRSSListMenu.addAction(actionDelete); |
|
|
|
|
myRSSListMenu.addSeparator(); |
|
|
|
|
if (m_feedList->isFolder(selectedItems.first())) { |
|
|
|
|
if (m_feedList->isFolder(selectedItems.first())) |
|
|
|
|
myRSSListMenu.addAction(actionNew_folder); |
|
|
|
|
} else { |
|
|
|
|
else |
|
|
|
|
myRSSListMenu.addAction(actionManage_cookies); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
myRSSListMenu.addAction(actionDelete); |
|
|
|
|
myRSSListMenu.addSeparator(); |
|
|
|
@ -96,7 +96,8 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
@@ -96,7 +96,8 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
|
|
|
|
|
myRSSListMenu.addSeparator(); |
|
|
|
|
myRSSListMenu.addAction(actionCopy_feed_URL); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
myRSSListMenu.addAction(actionNew_subscription); |
|
|
|
|
myRSSListMenu.addAction(actionNew_folder); |
|
|
|
|
myRSSListMenu.addSeparator(); |
|
|
|
@ -150,7 +151,8 @@ void RSSImp::askNewFolder()
@@ -150,7 +151,8 @@ void RSSImp::askNewFolder()
|
|
|
|
|
parent_item = m_feedList->selectedItems().at(0); |
|
|
|
|
rss_parent = qSharedPointerDynamicCast<RssFolder>(m_feedList->getRSSItem(parent_item)); |
|
|
|
|
Q_ASSERT(rss_parent); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
rss_parent = m_rssManager; |
|
|
|
|
} |
|
|
|
|
bool ok; |
|
|
|
@ -181,19 +183,17 @@ void RSSImp::on_newFeedButton_clicked()
@@ -181,19 +183,17 @@ void RSSImp::on_newFeedButton_clicked()
|
|
|
|
|
if (!selected_items.empty()) { |
|
|
|
|
parent_item = selected_items.first(); |
|
|
|
|
// Consider the case where the user clicked on Unread item
|
|
|
|
|
if (parent_item == m_feedList->stickyUnreadItem()) { |
|
|
|
|
if (parent_item == m_feedList->stickyUnreadItem()) |
|
|
|
|
parent_item = 0; |
|
|
|
|
} else { |
|
|
|
|
else |
|
|
|
|
if (!m_feedList->isFolder(parent_item)) |
|
|
|
|
parent_item = parent_item->parent(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RssFolderPtr rss_parent; |
|
|
|
|
if (parent_item) { |
|
|
|
|
if (parent_item) |
|
|
|
|
rss_parent = qSharedPointerCast<RssFolder>(m_feedList->getRSSItem(parent_item)); |
|
|
|
|
} else { |
|
|
|
|
else |
|
|
|
|
rss_parent = m_rssManager; |
|
|
|
|
} |
|
|
|
|
// Ask for feed URL
|
|
|
|
|
bool ok; |
|
|
|
|
QString clip_txt = qApp->clipboard()->text(); |
|
|
|
@ -237,10 +237,11 @@ void RSSImp::deleteSelectedItems()
@@ -237,10 +237,11 @@ void RSSImp::deleteSelectedItems()
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
int ret; |
|
|
|
|
if (selectedItems.size() > 1) |
|
|
|
|
if (selectedItems.size() > 1) { |
|
|
|
|
ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to delete these elements from the list?"), |
|
|
|
|
tr("&Yes"), tr("&No"), |
|
|
|
|
QString(), 0, 1); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
if (selectedItems.first() == m_feedList->stickyUnreadItem()) |
|
|
|
|
return; |
|
|
|
@ -342,8 +343,9 @@ void RSSImp::downloadSelectedTorrents()
@@ -342,8 +343,9 @@ void RSSImp::downloadSelectedTorrents()
|
|
|
|
|
|
|
|
|
|
QString torrentLink = article->torrentUrl(); |
|
|
|
|
// Check if it is a magnet link
|
|
|
|
|
if (torrentLink.startsWith("magnet:", Qt::CaseInsensitive)) |
|
|
|
|
if (torrentLink.startsWith("magnet:", Qt::CaseInsensitive)) { |
|
|
|
|
QBtSession::instance()->addMagnetInteractive(torrentLink); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// Load possible cookies
|
|
|
|
|
QString feed_url = m_feedList->getItemID(m_feedList->selectedItems().first()); |
|
|
|
@ -388,7 +390,8 @@ void RSSImp::renameSelectedRssFile()
@@ -388,7 +390,8 @@ void RSSImp::renameSelectedRssFile()
|
|
|
|
|
QMessageBox::warning(0, tr("Name already in use"), tr("This name is already used by another item, please choose another one.")); |
|
|
|
|
ok = false; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} while (!ok); |
|
|
|
@ -408,13 +411,15 @@ void RSSImp::refreshSelectedItems()
@@ -408,13 +411,15 @@ void RSSImp::refreshSelectedItems()
|
|
|
|
|
if (item == m_feedList->stickyUnreadItem()) { |
|
|
|
|
refreshAllFeeds(); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
if (!file->refresh()) |
|
|
|
|
continue; |
|
|
|
|
// Update UI
|
|
|
|
|
if (qSharedPointerDynamicCast<RssFeed>(file)) { |
|
|
|
|
item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); |
|
|
|
|
} else if (qSharedPointerDynamicCast<RssFolder>(file)) { |
|
|
|
|
} |
|
|
|
|
else if (qSharedPointerDynamicCast<RssFolder>(file)) { |
|
|
|
|
// Update feeds in the folder
|
|
|
|
|
foreach (QTreeWidgetItem *feed, m_feedList->getAllFeedItems(item)) |
|
|
|
|
feed->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); |
|
|
|
@ -428,10 +433,9 @@ void RSSImp::copySelectedFeedsURL()
@@ -428,10 +433,9 @@ void RSSImp::copySelectedFeedsURL()
|
|
|
|
|
QStringList URLs; |
|
|
|
|
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); |
|
|
|
|
QTreeWidgetItem* item; |
|
|
|
|
foreach (item, selectedItems) { |
|
|
|
|
foreach (item, selectedItems) |
|
|
|
|
if (m_feedList->isFeed(item)) |
|
|
|
|
URLs << m_feedList->getItemID(item); |
|
|
|
|
} |
|
|
|
|
qApp->clipboard()->setText(URLs.join("\n")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -453,7 +457,7 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile)
@@ -453,7 +457,7 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile)
|
|
|
|
|
{ |
|
|
|
|
Q_ASSERT(rssFile); |
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem; |
|
|
|
|
item->setData(0, Qt::DisplayRole, QVariant(rssFile->displayName()+ QString::fromUtf8(" (")+QString::number(rssFile->unreadCount())+QString(")"))); |
|
|
|
|
item->setData(0, Qt::DisplayRole, QVariant(rssFile->displayName() + QString::fromUtf8(" (") + QString::number(rssFile->unreadCount()) + QString(")"))); |
|
|
|
|
item->setData(0, Qt::DecorationRole, rssFile->icon()); |
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
@ -462,11 +466,10 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile)
@@ -462,11 +466,10 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile)
|
|
|
|
|
void RSSImp::fillFeedsList(QTreeWidgetItem* parent, const RssFolderPtr& rss_parent) |
|
|
|
|
{ |
|
|
|
|
QList<RssFilePtr> children; |
|
|
|
|
if (parent) { |
|
|
|
|
if (parent) |
|
|
|
|
children = rss_parent->getContent(); |
|
|
|
|
} else { |
|
|
|
|
else |
|
|
|
|
children = m_rssManager->getContent(); |
|
|
|
|
} |
|
|
|
|
foreach (const RssFilePtr& rssFile, children) { |
|
|
|
|
QTreeWidgetItem* item = createFolderListItem(rssFile); |
|
|
|
|
Q_ASSERT(item); |
|
|
|
@ -495,7 +498,8 @@ QListWidgetItem* RSSImp::createArticleListItem(const RssArticlePtr& article)
@@ -495,7 +498,8 @@ QListWidgetItem* RSSImp::createArticleListItem(const RssArticlePtr& article)
|
|
|
|
|
if (article->isRead()) { |
|
|
|
|
item->setData(Article::ColorRole, QVariant(QColor("grey"))); |
|
|
|
|
item->setData(Article::IconRole, QVariant(QIcon(":/Icons/sphere.png"))); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
item->setData(Article::ColorRole, QVariant(QColor("blue"))); |
|
|
|
|
item->setData(Article::IconRole, QVariant(QIcon(":/Icons/sphere2.png"))); |
|
|
|
|
} |
|
|
|
@ -559,18 +563,17 @@ void RSSImp::refreshTextBrowser()
@@ -559,18 +563,17 @@ void RSSImp::refreshTextBrowser()
|
|
|
|
|
RssArticlePtr article = stream->getItem(item->data(Article::IdRole).toString()); |
|
|
|
|
QString html; |
|
|
|
|
html += "<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>"; |
|
|
|
|
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>"+article->title() + "</div>"; |
|
|
|
|
if (article->date().isValid()) { |
|
|
|
|
html += "<div style='background-color: #efefef;'><b>"+tr("Date: ")+"</b>"+article->date().toLocalTime().toString(Qt::SystemLocaleLongDate)+"</div>"; |
|
|
|
|
} |
|
|
|
|
if (!article->author().isEmpty()) { |
|
|
|
|
html += "<div style='background-color: #efefef;'><b>"+tr("Author: ")+"</b>"+article->author()+"</div>"; |
|
|
|
|
} |
|
|
|
|
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>" + article->title() + "</div>"; |
|
|
|
|
if (article->date().isValid()) |
|
|
|
|
html += "<div style='background-color: #efefef;'><b>" + tr("Date: ") + "</b>" + article->date().toLocalTime().toString(Qt::SystemLocaleLongDate) + "</div>"; |
|
|
|
|
if (!article->author().isEmpty()) |
|
|
|
|
html += "<div style='background-color: #efefef;'><b>" + tr("Author: ") + "</b>" + article->author() + "</div>"; |
|
|
|
|
html += "</div>"; |
|
|
|
|
html += "<div style='margin-left: 5px; margin-right: 5px;'>"; |
|
|
|
|
if(Qt::mightBeRichText(article->description())) { |
|
|
|
|
html += article->description(); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
QString description = article->description(); |
|
|
|
|
QRegExp rx; |
|
|
|
|
// If description is plain text, replace BBCode tags with HTML and wrap everything in <pre></pre> so it looks nice
|
|
|
|
@ -620,13 +623,11 @@ void RSSImp::restoreSlidersPosition()
@@ -620,13 +623,11 @@ void RSSImp::restoreSlidersPosition()
|
|
|
|
|
{ |
|
|
|
|
const Preferences* const pref = Preferences::instance(); |
|
|
|
|
QByteArray pos_h = pref->getRssHSplitterState(); |
|
|
|
|
if (!pos_h.isNull()) { |
|
|
|
|
if (!pos_h.isNull()) |
|
|
|
|
splitter_h->restoreState(pos_h); |
|
|
|
|
} |
|
|
|
|
QByteArray pos_v = pref->getRssVSplitterState(); |
|
|
|
|
if (!pos_v.isNull()) { |
|
|
|
|
if (!pos_v.isNull()) |
|
|
|
|
splitter_v->restoreState(pos_v); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RSSImp::updateItemsInfos(const QList<QTreeWidgetItem*>& items) |
|
|
|
@ -646,7 +647,7 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item)
@@ -646,7 +647,7 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item)
|
|
|
|
|
name = tr("Unread"); |
|
|
|
|
else |
|
|
|
|
name = rss_item->displayName(); |
|
|
|
|
item->setText(0, name + QString::fromUtf8(" (") + QString::number(rss_item->unreadCount())+ QString(")")); |
|
|
|
|
item->setText(0, name + QString::fromUtf8(" (") + QString::number(rss_item->unreadCount()) + QString(")")); |
|
|
|
|
// If item has a parent, update it too
|
|
|
|
|
if (item->parent()) |
|
|
|
|
updateItemInfos(item->parent()); |
|
|
|
@ -663,7 +664,7 @@ void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, ui
@@ -663,7 +664,7 @@ void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, ui
|
|
|
|
|
qDebug() << Q_FUNC_INFO << display_name; |
|
|
|
|
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url); |
|
|
|
|
RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item)); |
|
|
|
|
item->setText(0, display_name + QString::fromUtf8(" (") + QString::number(nbUnread)+ QString(")")); |
|
|
|
|
item->setText(0, display_name + QString::fromUtf8(" (") + QString::number(nbUnread) + QString(")")); |
|
|
|
|
if (!stream->isLoading()) |
|
|
|
|
item->setData(0, Qt::DecorationRole, QVariant(stream->icon())); |
|
|
|
|
// Update parent
|
|
|
|
@ -680,12 +681,12 @@ void RSSImp::onFeedContentChanged(const QString& url)
@@ -680,12 +681,12 @@ void RSSImp::onFeedContentChanged(const QString& url)
|
|
|
|
|
// If the feed is selected, update the displayed news
|
|
|
|
|
if (m_feedList->currentItem() == item ) { |
|
|
|
|
populateArticleList(item); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// Update unread items
|
|
|
|
|
if (m_feedList->currentItem() == m_feedList->stickyUnreadItem()) { |
|
|
|
|
if (m_feedList->currentItem() == m_feedList->stickyUnreadItem()) |
|
|
|
|
populateArticleList(m_feedList->stickyUnreadItem()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RSSImp::updateRefreshInterval(uint val) |
|
|
|
@ -693,7 +694,7 @@ void RSSImp::updateRefreshInterval(uint val)
@@ -693,7 +694,7 @@ void RSSImp::updateRefreshInterval(uint val)
|
|
|
|
|
m_rssManager->updateRefreshInterval(val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RSSImp::RSSImp(QWidget *parent) : |
|
|
|
|
RSSImp::RSSImp(QWidget *parent): |
|
|
|
|
QWidget(parent), |
|
|
|
|
m_rssManager(new RssManager) |
|
|
|
|
{ |
|
|
|
@ -735,8 +736,8 @@ RSSImp::RSSImp(QWidget *parent) :
@@ -735,8 +736,8 @@ RSSImp::RSSImp(QWidget *parent) :
|
|
|
|
|
connect(m_rssManager.data(), SIGNAL(feedContentChanged(QString)), SLOT(onFeedContentChanged(QString))); |
|
|
|
|
connect(m_rssManager.data(), SIGNAL(feedIconChanged(QString, QString)), SLOT(updateFeedIcon(QString, QString))); |
|
|
|
|
|
|
|
|
|
connect(m_feedList, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(displayRSSListMenu(const QPoint&))); |
|
|
|
|
connect(listArticles, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(displayItemsListMenu(const QPoint&))); |
|
|
|
|
connect(m_feedList, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(displayRSSListMenu(const QPoint &))); |
|
|
|
|
connect(listArticles, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(displayItemsListMenu(const QPoint &))); |
|
|
|
|
|
|
|
|
|
// Feeds list actions
|
|
|
|
|
connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelectedItems())); |
|
|
|
|