Browse Source

Support edit/delete/double click hotkeys in rss feed list and rule list.

adaptive-webui-19844
Nick Tiskov 11 years ago
parent
commit
42e81b9d19
  1. 17
      src/rss/automatedrssdownloader.cpp
  2. 3
      src/rss/automatedrssdownloader.h
  3. 19
      src/rss/rss_imp.cpp
  4. 3
      src/rss/rss_imp.h

17
src/rss/automatedrssdownloader.cpp

@ -95,6 +95,14 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& m
Q_ASSERT(ok); Q_ASSERT(ok);
ok = connect(this, SIGNAL(finished(int)), SLOT(on_finished(int))); ok = connect(this, SIGNAL(finished(int)), SLOT(on_finished(int)));
Q_ASSERT(ok); Q_ASSERT(ok);
editHotkey = new QShortcut(QKeySequence("F2"), ui->listRules, 0, 0, Qt::WidgetShortcut);
ok = connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRule()));
Q_ASSERT(ok);
ok = connect(ui->listRules, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRule()));
Q_ASSERT(ok);
deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), ui->listRules, 0, 0, Qt::WidgetShortcut);
ok = connect(deleteHotkey, SIGNAL(activated()), SLOT(on_removeRuleBtn_clicked()));
Q_ASSERT(ok);
updateRuleDefinitionBox(); updateRuleDefinitionBox();
updateFeedList(); updateFeedList();
} }
@ -102,6 +110,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& m
AutomatedRssDownloader::~AutomatedRssDownloader() AutomatedRssDownloader::~AutomatedRssDownloader()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
delete editHotkey;
delete deleteHotkey;
delete ui; delete ui;
delete m_editableRuleList; delete m_editableRuleList;
} }
@ -421,8 +431,11 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos)
void AutomatedRssDownloader::renameSelectedRule() void AutomatedRssDownloader::renameSelectedRule()
{ {
QListWidgetItem *item = ui->listRules->currentItem(); const QList<QListWidgetItem*> selection = ui->listRules->selectedItems();
if (!item) return; if (selection.isEmpty())
return;
QListWidgetItem *item = selection.first();
forever { forever {
QString new_name = QInputDialog::getText(this, tr("Rule renaming"), tr("Please type the new rule name"), QLineEdit::Normal, item->text()); QString new_name = QInputDialog::getText(this, tr("Rule renaming"), tr("Please type the new rule name"), QLineEdit::Normal, item->text());
new_name = new_name.trimmed(); new_name = new_name.trimmed();

3
src/rss/automatedrssdownloader.h

@ -33,6 +33,7 @@
#include <QDialog> #include <QDialog>
#include <QWeakPointer> #include <QWeakPointer>
#include <QShortcut>
#include "rssdownloadrule.h" #include "rssdownloadrule.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -93,6 +94,8 @@ private:
QListWidgetItem* m_editedRule; QListWidgetItem* m_editedRule;
RssDownloadRuleList *m_ruleList; RssDownloadRuleList *m_ruleList;
RssDownloadRuleList *m_editableRuleList; RssDownloadRuleList *m_editableRuleList;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
}; };
#endif // AUTOMATEDRSSDOWNLOADER_H #endif // AUTOMATEDRSSDOWNLOADER_H

19
src/rss/rss_imp.cpp

@ -237,10 +237,13 @@ void RSSImp::deleteSelectedItems()
ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to delete these elements from the list?"), 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"), tr("&Yes"), tr("&No"),
QString(), 0, 1); QString(), 0, 1);
else else {
if (selectedItems.first() == m_feedList->stickyUnreadItem())
return;
ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to delete this element from the list?"), ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to delete this element from the list?"),
tr("&Yes"), tr("&No"), tr("&Yes"), tr("&No"),
QString(), 0, 1); QString(), 0, 1);
}
if (ret) if (ret)
return; return;
@ -250,6 +253,8 @@ void RSSImp::deleteSelectedItems()
m_currentArticle = 0; m_currentArticle = 0;
listArticles->clear(); listArticles->clear();
} }
if (item == m_feedList->stickyUnreadItem())
continue;
RssFilePtr rss_item = m_feedList->getRSSItem(item); RssFilePtr rss_item = m_feedList->getRSSItem(item);
QTreeWidgetItem* parent = item->parent(); QTreeWidgetItem* parent = item->parent();
// Notify TreeWidget // Notify TreeWidget
@ -366,8 +371,11 @@ void RSSImp::openSelectedArticlesUrls()
void RSSImp::renameSelectedRssFile() void RSSImp::renameSelectedRssFile()
{ {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems(); QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
Q_ASSERT(selectedItems.size() == 1); if (selectedItems.size() != 1)
return;
QTreeWidgetItem* item = selectedItems.first(); QTreeWidgetItem* item = selectedItems.first();
if (item == m_feedList->stickyUnreadItem())
return;
RssFilePtr rss_item = m_feedList->getRSSItem(item); RssFilePtr rss_item = m_feedList->getRSSItem(item);
bool ok; bool ok;
QString newName; QString newName;
@ -681,6 +689,11 @@ RSSImp::RSSImp(QWidget *parent) :
splitter_h->insertWidget(0, m_feedList); splitter_h->insertWidget(0, m_feedList);
listArticles->setSelectionBehavior(QAbstractItemView::SelectItems); listArticles->setSelectionBehavior(QAbstractItemView::SelectItems);
listArticles->setSelectionMode(QAbstractItemView::SingleSelection); listArticles->setSelectionMode(QAbstractItemView::SingleSelection);
editHotkey = new QShortcut(QKeySequence("F2"), m_feedList, 0, 0, Qt::WidgetShortcut);
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRssFile()));
connect(m_feedList, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRssFile()));
deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), m_feedList, 0, 0, Qt::WidgetShortcut);
connect(deleteHotkey, SIGNAL(activated()), SLOT(deleteSelectedItems()));
m_rssManager->loadStreamList(); m_rssManager->loadStreamList();
fillFeedsList(); fillFeedsList();
@ -729,6 +742,8 @@ RSSImp::~RSSImp()
{ {
qDebug("Deleting RSSImp..."); qDebug("Deleting RSSImp...");
saveFoldersOpenState(); saveFoldersOpenState();
delete editHotkey;
delete deleteHotkey;
delete m_feedList; delete m_feedList;
qDebug("RSSImp deleted"); qDebug("RSSImp deleted");
} }

3
src/rss/rss_imp.h

@ -33,6 +33,7 @@
#define REFRESH_MAX_LATENCY 600000 #define REFRESH_MAX_LATENCY 600000
#include <QPointer> #include <QPointer>
#include <QShortcut>
#include "ui_rss.h" #include "ui_rss.h"
#include "rssfolder.h" #include "rssfolder.h"
@ -91,6 +92,8 @@ private:
RssManagerPtr m_rssManager; RssManagerPtr m_rssManager;
FeedListWidget *m_feedList; FeedListWidget *m_feedList;
QListWidgetItem* m_currentArticle; QListWidgetItem* m_currentArticle;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
}; };

Loading…
Cancel
Save