Browse Source

Follow project coding style. Issue #2192.

--HG--
branch : magao-dev
adaptive-webui-19844
Tim Delaney 8 years ago
parent
commit
70ce12372d
  1. 4
      src/base/rss/rssdownloadrule.cpp
  2. 28
      src/base/rss/rssfeed.cpp
  3. 2
      src/base/rss/rssfeed.h
  4. 979
      src/gui/rss/automatedrssdownloader.cpp
  5. 76
      src/gui/rss/automatedrssdownloader.h
  6. 132
      src/gui/rss/rss_imp.cpp
  7. 21
      src/gui/rss/rss_imp.h
  8. 24
      src/gui/torrentmodel.cpp

4
src/base/rss/rssdownloadrule.cpp

@ -110,7 +110,7 @@ bool DownloadRule::matches(const QString &articleTitle) const
pos = reg.indexIn(articleTitle); pos = reg.indexIn(articleTitle);
if (pos != -1) { if (pos != -1) {
int epTheirs = reg.cap(1).toInt(); int epTheirs = reg.cap(1).toInt();
if (epOursFirst <= epTheirs && epOursLast >= epTheirs) if ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs))
return true; return true;
} }
} }
@ -300,7 +300,7 @@ QStringList DownloadRule::findMatchingArticles(const FeedPtr &feed) const
ArticleHash::ConstIterator artIt = feedArticles.begin(); ArticleHash::ConstIterator artIt = feedArticles.begin();
ArticleHash::ConstIterator artItend = feedArticles.end(); ArticleHash::ConstIterator artItend = feedArticles.end();
for ( ; artIt != artItend ; ++artIt) { for (; artIt != artItend; ++artIt) {
const QString title = artIt.value()->title(); const QString title = artIt.value()->title();
if (matches(title)) if (matches(title))
ret << title; ret << title;

28
src/base/rss/rssfeed.cpp

@ -78,7 +78,7 @@ Feed::Feed(const QString &url, Manager *manager)
// Download the RSS Feed icon // Download the RSS Feed icon
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(iconUrl(), true); Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(iconUrl(), true);
connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleIconDownloadFinished(QString, QString))); connect(handler, SIGNAL(downloadFinished(QString,QString)), this, SLOT(handleIconDownloadFinished(QString,QString)));
// Load old RSS articles // Load old RSS articles
loadItemsFromDisk(); loadItemsFromDisk();
@ -104,9 +104,8 @@ void Feed::saveItemsToDisk()
ArticleHash::ConstIterator it = m_articles.begin(); ArticleHash::ConstIterator it = m_articles.begin();
ArticleHash::ConstIterator itend = m_articles.end(); ArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) { for (; it != itend; ++it)
oldItems << it.value()->toHash(); oldItems << it.value()->toHash();
}
qDebug("Saving %d old items for feed %s", oldItems.size(), qPrintable(displayName())); qDebug("Saving %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
QHash<QString, QVariant> allOldItems = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> allOldItems = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
allOldItems[m_url] = oldItems; allOldItems[m_url] = oldItems;
@ -155,20 +154,18 @@ void Feed::addArticle(const ArticlePtr &article)
} }
// Check if article was inserted at the end of the list and will break max_articles limit // Check if article was inserted at the end of the list and will break max_articles limit
if (Preferences::instance()->isRssDownloadingEnabled()) { if (Preferences::instance()->isRssDownloadingEnabled())
if ((lbIndex < maxArticles) && !article->isRead()) if ((lbIndex < maxArticles) && !article->isRead())
downloadArticleTorrentIfMatching(article); downloadArticleTorrentIfMatching(article);
}
} }
else { else {
// m_articles.contains(article->guid()) // m_articles.contains(article->guid())
// Try to download skipped articles // Try to download skipped articles
if (Preferences::instance()->isRssDownloadingEnabled()) { if (Preferences::instance()->isRssDownloadingEnabled()) {
ArticlePtr skipped = m_articles.value(article->guid(), ArticlePtr()); ArticlePtr skipped = m_articles.value(article->guid(), ArticlePtr());
if (skipped) { if (skipped)
if (!skipped->isRead()) if (!skipped->isRead())
downloadArticleTorrentIfMatching(skipped); downloadArticleTorrentIfMatching(skipped);
}
} }
} }
} }
@ -182,8 +179,8 @@ bool Feed::refresh()
m_loading = true; m_loading = true;
// Download the RSS again // Download the RSS again
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_url); Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_url);
connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), this, SLOT(handleRssDownloadFinished(QString, QByteArray))); connect(handler, SIGNAL(downloadFinished(QString,QByteArray)), this, SLOT(handleRssDownloadFinished(QString,QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleRssDownloadFailed(QString, QString))); connect(handler, SIGNAL(downloadFailed(QString,QString)), this, SLOT(handleRssDownloadFailed(QString,QString)));
return true; return true;
} }
@ -260,7 +257,7 @@ bool Feed::hasCustomIcon() const
void Feed::setIconPath(const QString &path) void Feed::setIconPath(const QString &path)
{ {
QString nativePath = Utils::Fs::fromNativePath(path); QString nativePath = Utils::Fs::fromNativePath(path);
if (nativePath == m_icon || nativePath.isEmpty() || !QFile::exists(nativePath)) return; if ((nativePath == m_icon) || nativePath.isEmpty() || !QFile::exists(nativePath)) return;
if (!m_icon.startsWith(":/") && QFile::exists(m_icon)) if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
Utils::Fs::forceRemove(m_icon); Utils::Fs::forceRemove(m_icon);
@ -282,9 +279,8 @@ void Feed::markAsRead()
{ {
ArticleHash::ConstIterator it = m_articles.begin(); ArticleHash::ConstIterator it = m_articles.begin();
ArticleHash::ConstIterator itend = m_articles.end(); ArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) { for (; it != itend; ++it)
it.value()->markAsRead(); it.value()->markAsRead();
}
m_unreadCount = 0; m_unreadCount = 0;
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0); m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
} }
@ -310,10 +306,9 @@ ArticleList Feed::unreadArticleListByDateDesc() const
ArticleList::ConstIterator it = m_articlesByDate.begin(); ArticleList::ConstIterator it = m_articlesByDate.begin();
ArticleList::ConstIterator itend = m_articlesByDate.end(); ArticleList::ConstIterator itend = m_articlesByDate.end();
for ( ; it != itend; ++it) { for (; it != itend; ++it)
if (!(*it)->isRead()) if (!(*it)->isRead())
unreadNews << *it; unreadNews << *it;
}
return unreadNews; return unreadNews;
} }
@ -407,10 +402,9 @@ void Feed::downloadArticleTorrentIfMatching(const ArticlePtr &article)
void Feed::recheckRssItemsForDownload() void Feed::recheckRssItemsForDownload()
{ {
Q_ASSERT(Preferences::instance()->isRssDownloadingEnabled()); Q_ASSERT(Preferences::instance()->isRssDownloadingEnabled());
foreach (const ArticlePtr &article, m_articlesByDate) { foreach (const ArticlePtr &article, m_articlesByDate)
if (!article->isRead()) if (!article->isRead())
downloadArticleTorrentIfMatching(article); downloadArticleTorrentIfMatching(article);
}
} }
void Feed::handleNewArticle(const QVariantHash &articleData) void Feed::handleNewArticle(const QVariantHash &articleData)
@ -426,7 +420,7 @@ void Feed::handleNewArticle(const QVariantHash &articleData)
m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount); m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount);
// FIXME: We should forward the information here but this would seriously decrease // FIXME: We should forward the information here but this would seriously decrease
// performance with current design. // performance with current design.
//m_manager->forwardFeedContentChanged(m_url); // m_manager->forwardFeedContentChanged(m_url);
} }
void Feed::handleParsingFinished(const QString &error) void Feed::handleParsingFinished(const QString &error)

2
src/base/rss/rssfeed.h

@ -64,7 +64,7 @@ namespace Rss
Q_OBJECT Q_OBJECT
public: public:
Feed(const QString &url, Manager *manager); Feed(const QString &url, Manager * manager);
~Feed(); ~Feed();
bool refresh(); bool refresh();

979
src/gui/rss/automatedrssdownloader.cpp

File diff suppressed because it is too large Load Diff

76
src/gui/rss/automatedrssdownloader.h

@ -40,7 +40,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { namespace Ui {
class AutomatedRssDownloader; class AutomatedRssDownloader;
} }
QT_END_NAMESPACE QT_END_NAMESPACE
@ -54,54 +54,54 @@ QT_BEGIN_NAMESPACE
class QListWidgetItem; class QListWidgetItem;
QT_END_NAMESPACE QT_END_NAMESPACE
class AutomatedRssDownloader : public QDialog class AutomatedRssDownloader: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AutomatedRssDownloader(const QWeakPointer<Rss::Manager>& manager, QWidget *parent = 0); explicit AutomatedRssDownloader(const QWeakPointer<Rss::Manager> &manager, QWidget *parent = 0);
~AutomatedRssDownloader(); ~AutomatedRssDownloader();
bool isRssDownloaderEnabled() const; bool isRssDownloaderEnabled() const;
protected slots: protected slots:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
void loadRulesList(); void loadRulesList();
void handleFeedCheckStateChange(QListWidgetItem* feed_item); void handleFeedCheckStateChange(QListWidgetItem *feed_item);
void updateRuleDefinitionBox(); void updateRuleDefinitionBox();
void clearRuleDefinitionBox(); void clearRuleDefinitionBox();
void saveEditedRule(); void saveEditedRule();
void loadFeedList(); void loadFeedList();
void updateFeedList(); void updateFeedList();
private slots: private slots:
void displayRulesListMenu(const QPoint& pos); void displayRulesListMenu(const QPoint &pos);
void on_addRuleBtn_clicked(); void on_addRuleBtn_clicked();
void on_removeRuleBtn_clicked(); void on_removeRuleBtn_clicked();
void on_browseSP_clicked(); void on_browseSP_clicked();
void on_exportBtn_clicked(); void on_exportBtn_clicked();
void on_importBtn_clicked(); void on_importBtn_clicked();
void renameSelectedRule(); void renameSelectedRule();
void updateMatchingArticles(); void updateMatchingArticles();
void updateFieldsToolTips(bool regex); void updateFieldsToolTips(bool regex);
void updateMustLineValidity(); void updateMustLineValidity();
void updateMustNotLineValidity(); void updateMustNotLineValidity();
void onFinished(int result); void onFinished(int result);
private: private:
Rss::DownloadRulePtr getCurrentRule() const; Rss::DownloadRulePtr getCurrentRule() const;
void initCategoryCombobox(); void initCategoryCombobox();
void addFeedArticlesToTree(const Rss::FeedPtr& feed, const QStringList& articles); void addFeedArticlesToTree(const Rss::FeedPtr &feed, const QStringList &articles);
private: private:
Ui::AutomatedRssDownloader *ui; Ui::AutomatedRssDownloader *ui;
QWeakPointer<Rss::Manager> m_manager; QWeakPointer<Rss::Manager> m_manager;
QListWidgetItem* m_editedRule; QListWidgetItem *m_editedRule;
Rss::DownloadRuleList *m_ruleList; Rss::DownloadRuleList *m_ruleList;
Rss::DownloadRuleList *m_editableRuleList; Rss::DownloadRuleList *m_editableRuleList;
QRegExpValidator *m_episodeValidator; QRegExpValidator *m_episodeValidator;
QShortcut *editHotkey; QShortcut *editHotkey;
QShortcut *deleteHotkey; QShortcut *deleteHotkey;
}; };
#endif // AUTOMATEDRSSDOWNLOADER_H #endif // AUTOMATEDRSSDOWNLOADER_H

132
src/gui/rss/rss_imp.cpp

@ -65,13 +65,13 @@ namespace Article
} }
// display a right-click menu // display a right-click menu
void RSSImp::displayRSSListMenu(const QPoint& pos) 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 // No item under the mouse, clear selection
m_feedList->clearSelection(); m_feedList->clearSelection();
QMenu myRSSListMenu(this); QMenu myRSSListMenu(this);
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
if (selectedItems.size() > 0) { if (selectedItems.size() > 0) {
myRSSListMenu.addAction(actionUpdate); myRSSListMenu.addAction(actionUpdate);
myRSSListMenu.addAction(actionMark_items_read); myRSSListMenu.addAction(actionMark_items_read);
@ -104,16 +104,16 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
myRSSListMenu.exec(QCursor::pos()); myRSSListMenu.exec(QCursor::pos());
} }
void RSSImp::displayItemsListMenu(const QPoint&) void RSSImp::displayItemsListMenu(const QPoint &)
{ {
QMenu myItemListMenu(this); QMenu myItemListMenu(this);
QList<QListWidgetItem*> selectedItems = listArticles->selectedItems(); QList<QListWidgetItem * > selectedItems = listArticles->selectedItems();
if (selectedItems.size() <= 0) if (selectedItems.size() <= 0)
return; return;
bool hasTorrent = false; bool hasTorrent = false;
bool hasLink = false; bool hasLink = false;
foreach (const QListWidgetItem* item, selectedItems) { foreach (const QListWidgetItem *item, selectedItems) {
if (!item) continue; if (!item) continue;
Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()); Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
if (!feed) continue; if (!feed) continue;
@ -137,7 +137,7 @@ void RSSImp::displayItemsListMenu(const QPoint&)
void RSSImp::askNewFolder() void RSSImp::askNewFolder()
{ {
QTreeWidgetItem* parent_item = 0; QTreeWidgetItem *parent_item = 0;
Rss::FolderPtr rss_parent; Rss::FolderPtr rss_parent;
if (m_feedList->selectedItems().size() > 0) { if (m_feedList->selectedItems().size() > 0) {
parent_item = m_feedList->selectedItems().at(0); parent_item = m_feedList->selectedItems().at(0);
@ -154,7 +154,7 @@ void RSSImp::askNewFolder()
Rss::FolderPtr newFolder(new Rss::Folder(new_name)); Rss::FolderPtr newFolder(new Rss::Folder(new_name));
rss_parent->addFile(newFolder); rss_parent->addFile(newFolder);
QTreeWidgetItem* folderItem = createFolderListItem(newFolder); QTreeWidgetItem *folderItem = createFolderListItem(newFolder);
if (parent_item) if (parent_item)
parent_item->addChild(folderItem); parent_item->addChild(folderItem);
else else
@ -172,7 +172,7 @@ void RSSImp::on_newFeedButton_clicked()
{ {
// Determine parent folder for new feed // Determine parent folder for new feed
QTreeWidgetItem *parent_item = 0; QTreeWidgetItem *parent_item = 0;
QList<QTreeWidgetItem *> selected_items = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selected_items = m_feedList->selectedItems();
if (!selected_items.empty()) { if (!selected_items.empty()) {
parent_item = selected_items.first(); parent_item = selected_items.first();
// Consider the case where the user clicked on Unread item // Consider the case where the user clicked on Unread item
@ -212,7 +212,7 @@ void RSSImp::on_newFeedButton_clicked()
Rss::FeedPtr stream(new Rss::Feed(newUrl, m_rssManager.data())); Rss::FeedPtr stream(new Rss::Feed(newUrl, m_rssManager.data()));
rss_parent->addFile(stream); rss_parent->addFile(stream);
// Create TreeWidget item // Create TreeWidget item
QTreeWidgetItem* item = createFolderListItem(stream); QTreeWidgetItem *item = createFolderListItem(stream);
if (parent_item) if (parent_item)
parent_item->addChild(item); parent_item->addChild(item);
else else
@ -226,23 +226,23 @@ void RSSImp::on_newFeedButton_clicked()
// delete a stream by a button // delete a stream by a button
void RSSImp::deleteSelectedItems() void RSSImp::deleteSelectedItems()
{ {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
if (selectedItems.isEmpty()) if (selectedItems.isEmpty())
return; return;
if ((selectedItems.size() == 1) && (selectedItems.first() == m_feedList->stickyUnreadItem())) if ((selectedItems.size() == 1) && (selectedItems.first() == m_feedList->stickyUnreadItem()))
return; return;
QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Deletion confirmation"), QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Deletion confirmation"),
tr("Are you sure you want to delete the selected RSS feeds?"), tr("Are you sure you want to delete the selected RSS feeds?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::No); QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No) if (answer == QMessageBox::No)
return; return;
foreach (QTreeWidgetItem* item, selectedItems) { foreach (QTreeWidgetItem *item, selectedItems) {
if (item == m_feedList->stickyUnreadItem()) if (item == m_feedList->stickyUnreadItem())
continue; continue;
Rss::FilePtr rss_item = m_feedList->getRSSItem(item); Rss::FilePtr rss_item = m_feedList->getRSSItem(item);
QTreeWidgetItem* parent = item->parent(); QTreeWidgetItem *parent = item->parent();
// Notify TreeWidget // Notify TreeWidget
m_feedList->itemAboutToBeRemoved(item); m_feedList->itemAboutToBeRemoved(item);
// Actually delete the item // Actually delete the item
@ -259,23 +259,22 @@ void RSSImp::deleteSelectedItems()
updateItemInfos(m_feedList->stickyUnreadItem()); updateItemInfos(m_feedList->stickyUnreadItem());
if (m_feedList->currentItem() == m_feedList->stickyUnreadItem()) if (m_feedList->currentItem() == m_feedList->stickyUnreadItem())
populateArticleList(m_feedList->stickyUnreadItem()); populateArticleList(m_feedList->stickyUnreadItem());
} }
void RSSImp::loadFoldersOpenState() void RSSImp::loadFoldersOpenState()
{ {
QStringList open_folders = Preferences::instance()->getRssOpenFolders(); QStringList open_folders = Preferences::instance()->getRssOpenFolders();
foreach (const QString& var_path, open_folders) { foreach (const QString &var_path, open_folders) {
QStringList path = var_path.split("\\"); QStringList path = var_path.split("\\");
QTreeWidgetItem* parent = 0; QTreeWidgetItem *parent = 0;
foreach (const QString& name, path) { foreach (const QString &name, path) {
int nbChildren = 0; int nbChildren = 0;
if (parent) if (parent)
nbChildren = parent->childCount(); nbChildren = parent->childCount();
else else
nbChildren = m_feedList->topLevelItemCount(); nbChildren = m_feedList->topLevelItemCount();
for (int i = 0; i < nbChildren; ++i) { for (int i = 0; i < nbChildren; ++i) {
QTreeWidgetItem* child; QTreeWidgetItem *child;
if (parent) if (parent)
child = parent->child(i); child = parent->child(i);
else else
@ -294,8 +293,8 @@ void RSSImp::loadFoldersOpenState()
void RSSImp::saveFoldersOpenState() void RSSImp::saveFoldersOpenState()
{ {
QStringList open_folders; QStringList open_folders;
QList<QTreeWidgetItem*> items = m_feedList->getAllOpenFolders(); QList<QTreeWidgetItem * > items = m_feedList->getAllOpenFolders();
foreach (QTreeWidgetItem* item, items) { foreach (QTreeWidgetItem *item, items) {
QString path = m_feedList->getItemPath(item).join("\\"); QString path = m_feedList->getItemPath(item).join("\\");
qDebug("saving open folder: %s", qPrintable(path)); qDebug("saving open folder: %s", qPrintable(path));
open_folders << path; open_folders << path;
@ -306,17 +305,17 @@ void RSSImp::saveFoldersOpenState()
// refresh all streams by a button // refresh all streams by a button
void RSSImp::refreshAllFeeds() void RSSImp::refreshAllFeeds()
{ {
foreach (QTreeWidgetItem* item, m_feedList->getAllFeedItems()) foreach (QTreeWidgetItem *item, m_feedList->getAllFeedItems())
item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/icons/loading.png"))); item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/icons/loading.png")));
m_rssManager->refresh(); m_rssManager->refresh();
} }
void RSSImp::downloadSelectedTorrents() void RSSImp::downloadSelectedTorrents()
{ {
QList<QListWidgetItem*> selected_items = listArticles->selectedItems(); QList<QListWidgetItem * > selected_items = listArticles->selectedItems();
if (selected_items.size() <= 0) if (selected_items.size() <= 0)
return; return;
foreach (QListWidgetItem* item, selected_items) { foreach (QListWidgetItem *item, selected_items) {
if (!item) continue; if (!item) continue;
Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()); Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
if (!feed) continue; if (!feed) continue;
@ -343,10 +342,10 @@ void RSSImp::downloadSelectedTorrents()
// open the url of the selected RSS articles in the Web browser // open the url of the selected RSS articles in the Web browser
void RSSImp::openSelectedArticlesUrls() void RSSImp::openSelectedArticlesUrls()
{ {
QList<QListWidgetItem *> selected_items = listArticles->selectedItems(); QList<QListWidgetItem * > selected_items = listArticles->selectedItems();
if (selected_items.size() <= 0) if (selected_items.size() <= 0)
return; return;
foreach (QListWidgetItem* item, selected_items) { foreach (QListWidgetItem *item, selected_items) {
if (!item) continue; if (!item) continue;
Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()); Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
if (!feed) continue; if (!feed) continue;
@ -367,13 +366,13 @@ void RSSImp::openSelectedArticlesUrls()
updateItemInfos(m_feedList->getTreeItemFromUrl(selected_items.first()->data(Article::FeedUrlRole).toString())); updateItemInfos(m_feedList->getTreeItemFromUrl(selected_items.first()->data(Article::FeedUrlRole).toString()));
} }
//right-click on stream : give it an alias // right-click on stream : give it an alias
void RSSImp::renameSelectedRssFile() void RSSImp::renameSelectedRssFile()
{ {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
if (selectedItems.size() != 1) if (selectedItems.size() != 1)
return; return;
QTreeWidgetItem* item = selectedItems.first(); QTreeWidgetItem *item = selectedItems.first();
if (item == m_feedList->stickyUnreadItem()) if (item == m_feedList->stickyUnreadItem())
return; return;
Rss::FilePtr rss_item = m_feedList->getRSSItem(item); Rss::FilePtr rss_item = m_feedList->getRSSItem(item);
@ -401,8 +400,8 @@ void RSSImp::renameSelectedRssFile()
// right-click on stream : refresh it // right-click on stream : refresh it
void RSSImp::refreshSelectedItems() void RSSImp::refreshSelectedItems()
{ {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
foreach (QTreeWidgetItem* item, selectedItems) { foreach (QTreeWidgetItem *item, selectedItems) {
Rss::FilePtr file = m_feedList->getRSSItem(item); Rss::FilePtr file = m_feedList->getRSSItem(item);
// Update icons // Update icons
if (item == m_feedList->stickyUnreadItem()) { if (item == m_feedList->stickyUnreadItem()) {
@ -428,8 +427,8 @@ void RSSImp::refreshSelectedItems()
void RSSImp::copySelectedFeedsURL() void RSSImp::copySelectedFeedsURL()
{ {
QStringList URLs; QStringList URLs;
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
QTreeWidgetItem* item; QTreeWidgetItem *item;
foreach (item, selectedItems) foreach (item, selectedItems)
if (m_feedList->isFeed(item)) if (m_feedList->isFeed(item))
URLs << m_feedList->getItemID(item); URLs << m_feedList->getItemID(item);
@ -438,8 +437,8 @@ void RSSImp::copySelectedFeedsURL()
void RSSImp::on_markReadButton_clicked() void RSSImp::on_markReadButton_clicked()
{ {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem * > selectedItems = m_feedList->selectedItems();
foreach (QTreeWidgetItem* item, selectedItems) { foreach (QTreeWidgetItem *item, selectedItems) {
Rss::FilePtr rss_item = m_feedList->getRSSItem(item); Rss::FilePtr rss_item = m_feedList->getRSSItem(item);
Q_ASSERT(rss_item); Q_ASSERT(rss_item);
rss_item->markAsRead(); rss_item->markAsRead();
@ -450,25 +449,25 @@ void RSSImp::on_markReadButton_clicked()
populateArticleList(m_feedList->currentItem()); populateArticleList(m_feedList->currentItem());
} }
QTreeWidgetItem* RSSImp::createFolderListItem(const Rss::FilePtr& rssFile) QTreeWidgetItem *RSSImp::createFolderListItem(const Rss::FilePtr &rssFile)
{ {
Q_ASSERT(rssFile); Q_ASSERT(rssFile);
QTreeWidgetItem* item = new QTreeWidgetItem; 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, QIcon(rssFile->iconPath())); item->setData(0, Qt::DecorationRole, QIcon(rssFile->iconPath()));
return item; return item;
} }
void RSSImp::fillFeedsList(QTreeWidgetItem* parent, const Rss::FolderPtr& rss_parent) void RSSImp::fillFeedsList(QTreeWidgetItem *parent, const Rss::FolderPtr &rss_parent)
{ {
QList<Rss::FilePtr> children; QList<Rss::FilePtr> children;
if (parent) if (parent)
children = rss_parent->getContent(); children = rss_parent->getContent();
else else
children = m_rssManager->rootFolder()->getContent(); children = m_rssManager->rootFolder()->getContent();
foreach (const Rss::FilePtr& rssFile, children) { foreach (const Rss::FilePtr &rssFile, children) {
QTreeWidgetItem* item = createFolderListItem(rssFile); QTreeWidgetItem *item = createFolderListItem(rssFile);
Q_ASSERT(item); Q_ASSERT(item);
if (parent) if (parent)
parent->addChild(item); parent->addChild(item);
@ -484,10 +483,10 @@ void RSSImp::fillFeedsList(QTreeWidgetItem* parent, const Rss::FolderPtr& rss_pa
} }
} }
QListWidgetItem* RSSImp::createArticleListItem(const Rss::ArticlePtr& article) QListWidgetItem *RSSImp::createArticleListItem(const Rss::ArticlePtr &article)
{ {
Q_ASSERT(article); Q_ASSERT(article);
QListWidgetItem* item = new QListWidgetItem; QListWidgetItem *item = new QListWidgetItem;
item->setData(Article::TitleRole, article->title()); item->setData(Article::TitleRole, article->title());
item->setData(Article::FeedUrlRole, article->parent()->url()); item->setData(Article::FeedUrlRole, article->parent()->url());
@ -505,7 +504,7 @@ QListWidgetItem* RSSImp::createArticleListItem(const Rss::ArticlePtr& article)
} }
// fills the newsList // fills the newsList
void RSSImp::populateArticleList(QTreeWidgetItem* item) void RSSImp::populateArticleList(QTreeWidgetItem *item)
{ {
if (!item) { if (!item) {
listArticles->clear(); listArticles->clear();
@ -529,8 +528,8 @@ void RSSImp::populateArticleList(QTreeWidgetItem* item)
articles = rss_item->articleListByDateDesc(); articles = rss_item->articleListByDateDesc();
qDebug("Got the list of news"); qDebug("Got the list of news");
foreach (const Rss::ArticlePtr& article, articles) { foreach (const Rss::ArticlePtr &article, articles) {
QListWidgetItem* articleItem = createArticleListItem(article); QListWidgetItem *articleItem = createArticleListItem(article);
listArticles->addItem(articleItem); listArticles->addItem(articleItem);
} }
qDebug("Added all news to the GUI"); qDebug("Added all news to the GUI");
@ -539,7 +538,7 @@ void RSSImp::populateArticleList(QTreeWidgetItem* item)
// display a news // display a news
void RSSImp::refreshTextBrowser() void RSSImp::refreshTextBrowser()
{ {
QList<QListWidgetItem*> selection = listArticles->selectedItems(); QList<QListWidgetItem * > selection = listArticles->selectedItems();
if (selection.empty()) return; if (selection.empty()) return;
QListWidgetItem *item = selection.first(); QListWidgetItem *item = selection.first();
Q_ASSERT(item); Q_ASSERT(item);
@ -559,7 +558,7 @@ void RSSImp::refreshTextBrowser()
html += "<div style='background-color: #efefef;'><b>" + tr("Author: ") + "</b>" + article->author() + "</div>"; html += "<div style='background-color: #efefef;'><b>" + tr("Author: ") + "</b>" + article->author() + "</div>";
html += "</div>"; html += "</div>";
html += "<div style='margin-left: 5px; margin-right: 5px;'>"; html += "<div style='margin-left: 5px; margin-right: 5px;'>";
if(Qt::mightBeRichText(article->description())) { if (Qt::mightBeRichText(article->description())) {
html += article->description(); html += article->description();
} }
else { else {
@ -602,7 +601,7 @@ void RSSImp::refreshTextBrowser()
void RSSImp::saveSlidersPosition() void RSSImp::saveSlidersPosition()
{ {
// Remember sliders positions // Remember sliders positions
Preferences* const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
pref->setRssSideSplitterState(splitterSide->saveState()); pref->setRssSideSplitterState(splitterSide->saveState());
pref->setRssMainSplitterState(splitterMain->saveState()); pref->setRssMainSplitterState(splitterMain->saveState());
qDebug("Splitters position saved"); qDebug("Splitters position saved");
@ -610,7 +609,7 @@ void RSSImp::saveSlidersPosition()
void RSSImp::restoreSlidersPosition() void RSSImp::restoreSlidersPosition()
{ {
const Preferences* const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
const QByteArray stateSide = pref->getRssSideSplitterState(); const QByteArray stateSide = pref->getRssSideSplitterState();
if (!stateSide.isEmpty()) if (!stateSide.isEmpty())
splitterSide->restoreState(stateSide); splitterSide->restoreState(stateSide);
@ -619,9 +618,9 @@ void RSSImp::restoreSlidersPosition()
splitterMain->restoreState(stateMain); splitterMain->restoreState(stateMain);
} }
void RSSImp::updateItemsInfos(const QList<QTreeWidgetItem*>& items) void RSSImp::updateItemsInfos(const QList<QTreeWidgetItem *> &items)
{ {
foreach (QTreeWidgetItem* item, items) foreach (QTreeWidgetItem *item, items)
updateItemInfos(item); updateItemInfos(item);
} }
@ -636,21 +635,22 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item)
name = tr("Unread"); name = tr("Unread");
emit updateRSSCount(rss_item->unreadCount()); emit updateRSSCount(rss_item->unreadCount());
} }
else else {
name = rss_item->displayName(); 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 has a parent, update it too
if (item->parent()) if (item->parent())
updateItemInfos(item->parent()); updateItemInfos(item->parent());
} }
void RSSImp::updateFeedIcon(const QString& url, const QString& iconPath) void RSSImp::updateFeedIcon(const QString &url, const QString &iconPath)
{ {
QTreeWidgetItem* item = m_feedList->getTreeItemFromUrl(url); QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
item->setData(0, Qt::DecorationRole, QVariant(QIcon(iconPath))); item->setData(0, Qt::DecorationRole, QVariant(QIcon(iconPath)));
} }
void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, uint nbUnread) void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread)
{ {
qDebug() << Q_FUNC_INFO << display_name; qDebug() << Q_FUNC_INFO << display_name;
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url); QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
@ -665,7 +665,7 @@ void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, ui
updateItemInfos(m_feedList->stickyUnreadItem()); updateItemInfos(m_feedList->stickyUnreadItem());
} }
void RSSImp::onFeedContentChanged(const QString& url) void RSSImp::onFeedContentChanged(const QString &url)
{ {
qDebug() << Q_FUNC_INFO << url; qDebug() << Q_FUNC_INFO << url;
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url); QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
@ -682,8 +682,8 @@ void RSSImp::updateRefreshInterval(uint val)
m_rssManager->updateRefreshInterval(val); m_rssManager->updateRefreshInterval(val);
} }
RSSImp::RSSImp(QWidget *parent): RSSImp::RSSImp(QWidget *parent)
QWidget(parent), : QWidget(parent),
m_rssManager(new Rss::Manager) m_rssManager(new Rss::Manager)
{ {
setupUi(this); setupUi(this);
@ -717,12 +717,12 @@ RSSImp::RSSImp(QWidget *parent):
populateArticleList(m_feedList->currentItem()); populateArticleList(m_feedList->currentItem());
loadFoldersOpenState(); loadFoldersOpenState();
connect(m_rssManager.data(), SIGNAL(feedInfosChanged(QString, QString, unsigned int)), SLOT(updateFeedInfos(QString, QString, unsigned int))); connect(m_rssManager.data(), SIGNAL(feedInfosChanged(QString,QString,unsigned int)), SLOT(updateFeedInfos(QString,QString,unsigned int)));
connect(m_rssManager.data(), SIGNAL(feedContentChanged(QString)), SLOT(onFeedContentChanged(QString))); connect(m_rssManager.data(), SIGNAL(feedContentChanged(QString)), SLOT(onFeedContentChanged(QString)));
connect(m_rssManager.data(), SIGNAL(feedIconChanged(QString, QString)), SLOT(updateFeedIcon(QString, 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(m_feedList, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(displayRSSListMenu(const QPoint&)));
connect(listArticles, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(displayItemsListMenu(const QPoint &))); connect(listArticles, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(displayItemsListMenu(const QPoint&)));
// Feeds list actions // Feeds list actions
connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelectedItems())); connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelectedItems()));
@ -738,8 +738,8 @@ RSSImp::RSSImp(QWidget *parent):
connect(actionOpen_news_URL, SIGNAL(triggered()), this, SLOT(openSelectedArticlesUrls())); connect(actionOpen_news_URL, SIGNAL(triggered()), this, SLOT(openSelectedArticlesUrls()));
connect(actionDownload_torrent, SIGNAL(triggered()), this, SLOT(downloadSelectedTorrents())); connect(actionDownload_torrent, SIGNAL(triggered()), this, SLOT(downloadSelectedTorrents()));
connect(m_feedList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(populateArticleList(QTreeWidgetItem*))); connect(m_feedList, SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)), this, SLOT(populateArticleList(QTreeWidgetItem *)));
connect(m_feedList, SIGNAL(foldersAltered(QList<QTreeWidgetItem*>)), this, SLOT(updateItemsInfos(QList<QTreeWidgetItem*>))); connect(m_feedList, SIGNAL(foldersAltered(QList<QTreeWidgetItem * >)), this, SLOT(updateItemsInfos(QList<QTreeWidgetItem * >)));
connect(listArticles, SIGNAL(itemSelectionChanged()), this, SLOT(refreshTextBrowser())); connect(listArticles, SIGNAL(itemSelectionChanged()), this, SLOT(refreshTextBrowser()));
connect(listArticles, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadSelectedTorrents())); connect(listArticles, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadSelectedTorrents()));
@ -747,8 +747,8 @@ RSSImp::RSSImp(QWidget *parent):
// Restore sliders position // Restore sliders position
restoreSlidersPosition(); restoreSlidersPosition();
// Bind saveSliders slots // Bind saveSliders slots
connect(splitterMain, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition())); connect(splitterMain, SIGNAL(splitterMoved(int,int)), this, SLOT(saveSlidersPosition()));
connect(splitterSide, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition())); connect(splitterSide, SIGNAL(splitterMoved(int,int)), this, SLOT(saveSlidersPosition()));
qDebug("RSSImp constructed"); qDebug("RSSImp constructed");
} }

21
src/gui/rss/rss_imp.h

@ -50,7 +50,7 @@ class RSSImp: public QWidget, public Ui::RSS
Q_OBJECT Q_OBJECT
public: public:
RSSImp(QWidget *parent); RSSImp(QWidget * parent);
~RSSImp(); ~RSSImp();
public slots: public slots:
@ -64,21 +64,21 @@ private slots:
void on_newFeedButton_clicked(); void on_newFeedButton_clicked();
void refreshAllFeeds(); void refreshAllFeeds();
void on_markReadButton_clicked(); void on_markReadButton_clicked();
void displayRSSListMenu(const QPoint&); void displayRSSListMenu(const QPoint &);
void displayItemsListMenu(const QPoint&); void displayItemsListMenu(const QPoint &);
void renameSelectedRssFile(); void renameSelectedRssFile();
void refreshSelectedItems(); void refreshSelectedItems();
void copySelectedFeedsURL(); void copySelectedFeedsURL();
void populateArticleList(QTreeWidgetItem* item); void populateArticleList(QTreeWidgetItem *item);
void refreshTextBrowser(); void refreshTextBrowser();
void updateFeedIcon(const QString &url, const QString &icon_path); void updateFeedIcon(const QString &url, const QString &icon_path);
void updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread); void updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread);
void onFeedContentChanged(const QString& url); void onFeedContentChanged(const QString &url);
void updateItemsInfos(const QList<QTreeWidgetItem*> &items); void updateItemsInfos(const QList<QTreeWidgetItem *> &items);
void updateItemInfos(QTreeWidgetItem *item); void updateItemInfos(QTreeWidgetItem *item);
void openSelectedArticlesUrls(); void openSelectedArticlesUrls();
void downloadSelectedTorrents(); void downloadSelectedTorrents();
void fillFeedsList(QTreeWidgetItem *parent = 0, const Rss::FolderPtr& rss_parent = Rss::FolderPtr()); void fillFeedsList(QTreeWidgetItem *parent = 0, const Rss::FolderPtr &rss_parent = Rss::FolderPtr());
void saveSlidersPosition(); void saveSlidersPosition();
void restoreSlidersPosition(); void restoreSlidersPosition();
void askNewFolder(); void askNewFolder();
@ -88,16 +88,15 @@ private slots:
void on_rssDownloaderBtn_clicked(); void on_rssDownloaderBtn_clicked();
private: private:
static QListWidgetItem* createArticleListItem(const Rss::ArticlePtr& article); static QListWidgetItem *createArticleListItem(const Rss::ArticlePtr &article);
static QTreeWidgetItem* createFolderListItem(const Rss::FilePtr& rssFile); static QTreeWidgetItem *createFolderListItem(const Rss::FilePtr &rssFile);
private: private:
Rss::ManagerPtr m_rssManager; Rss::ManagerPtr m_rssManager;
FeedListWidget *m_feedList; FeedListWidget *m_feedList;
QListWidgetItem* m_currentArticle; QListWidgetItem *m_currentArticle;
QShortcut *editHotkey; QShortcut *editHotkey;
QShortcut *deleteHotkey; QShortcut *deleteHotkey;
}; };
#endif #endif

24
src/gui/torrentmodel.cpp

@ -65,15 +65,15 @@ TorrentModel::TorrentModel(QObject *parent)
addTorrent(torrent); addTorrent(torrent);
// Listen for torrent changes // Listen for torrent changes
connect(BitTorrent::Session::instance(), SIGNAL(torrentAdded(BitTorrent::TorrentHandle *const)), SLOT(addTorrent(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentAdded(BitTorrent::TorrentHandle * const)), SLOT(addTorrent(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentAboutToBeRemoved(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentsUpdated()), SLOT(handleTorrentsUpdated())); connect(BitTorrent::Session::instance(), SIGNAL(torrentsUpdated()), SLOT(handleTorrentsUpdated()));
connect(BitTorrent::Session::instance(), SIGNAL(torrentFinished(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentFinished(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentResumed(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentResumed(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentPaused(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentPaused(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentFinishedChecking(BitTorrent::TorrentHandle *const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentFinishedChecking(BitTorrent::TorrentHandle * const)), SLOT(handleTorrentStatusUpdated(BitTorrent::TorrentHandle * const)));
} }
int TorrentModel::rowCount(const QModelIndex &index) const int TorrentModel::rowCount(const QModelIndex &index) const
@ -92,7 +92,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, int
{ {
if (orientation == Qt::Horizontal) { if (orientation == Qt::Horizontal) {
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
switch(section) { switch (section) {
case TR_PRIORITY: return "#"; case TR_PRIORITY: return "#";
case TR_NAME: return tr("Name", "i.e: torrent name"); case TR_NAME: return tr("Name", "i.e: torrent name");
case TR_SIZE: return tr("Size", "i.e: torrent size"); case TR_SIZE: return tr("Size", "i.e: torrent size");
@ -127,7 +127,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, int
} }
} }
else if (role == Qt::TextAlignmentRole) { else if (role == Qt::TextAlignmentRole) {
switch(section) { switch (section) {
case TR_AMOUNT_DOWNLOADED: case TR_AMOUNT_DOWNLOADED:
case TR_AMOUNT_UPLOADED: case TR_AMOUNT_UPLOADED:
case TR_AMOUNT_DOWNLOADED_SESSION: case TR_AMOUNT_DOWNLOADED_SESSION:
@ -173,7 +173,7 @@ QVariant TorrentModel::data(const QModelIndex &index, int role) const
if ((role != Qt::DisplayRole) && (role != Qt::UserRole)) if ((role != Qt::DisplayRole) && (role != Qt::UserRole))
return QVariant(); return QVariant();
switch(index.column()) { switch (index.column()) {
case TR_NAME: case TR_NAME:
return torrent->name(); return torrent->name();
case TR_PRIORITY: case TR_PRIORITY:
@ -233,7 +233,7 @@ QVariant TorrentModel::data(const QModelIndex &index, int role) const
return -1; return -1;
return torrent->timeSinceActivity(); return torrent->timeSinceActivity();
case TR_TOTAL_SIZE: case TR_TOTAL_SIZE:
return torrent->totalSize(); return torrent->totalSize();
default: default:
return QVariant(); return QVariant();
} }
@ -251,7 +251,7 @@ bool TorrentModel::setData(const QModelIndex &index, const QVariant &value, int
if (!torrent) return false; if (!torrent) return false;
// Category, seed date and Name columns can be edited // Category, seed date and Name columns can be edited
switch(index.column()) { switch (index.column()) {
case TR_NAME: case TR_NAME:
torrent->setName(value.toString()); torrent->setName(value.toString());
break; break;

Loading…
Cancel
Save