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 @@ -95,6 +95,14 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& m
Q_ASSERT(ok);
ok = connect(this, SIGNAL(finished(int)), SLOT(on_finished(int)));
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();
updateFeedList();
}
@ -102,6 +110,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& m @@ -102,6 +110,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& m
AutomatedRssDownloader::~AutomatedRssDownloader()
{
qDebug() << Q_FUNC_INFO;
delete editHotkey;
delete deleteHotkey;
delete ui;
delete m_editableRuleList;
}
@ -421,8 +431,11 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos) @@ -421,8 +431,11 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos)
void AutomatedRssDownloader::renameSelectedRule()
{
QListWidgetItem *item = ui->listRules->currentItem();
if (!item) return;
const QList<QListWidgetItem*> selection = ui->listRules->selectedItems();
if (selection.isEmpty())
return;
QListWidgetItem *item = selection.first();
forever {
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();

3
src/rss/automatedrssdownloader.h

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

19
src/rss/rss_imp.cpp

@ -237,10 +237,13 @@ void RSSImp::deleteSelectedItems() @@ -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?"),
tr("&Yes"), tr("&No"),
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?"),
tr("&Yes"), tr("&No"),
QString(), 0, 1);
}
if (ret)
return;
@ -250,6 +253,8 @@ void RSSImp::deleteSelectedItems() @@ -250,6 +253,8 @@ void RSSImp::deleteSelectedItems()
m_currentArticle = 0;
listArticles->clear();
}
if (item == m_feedList->stickyUnreadItem())
continue;
RssFilePtr rss_item = m_feedList->getRSSItem(item);
QTreeWidgetItem* parent = item->parent();
// Notify TreeWidget
@ -366,8 +371,11 @@ void RSSImp::openSelectedArticlesUrls() @@ -366,8 +371,11 @@ void RSSImp::openSelectedArticlesUrls()
void RSSImp::renameSelectedRssFile()
{
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
Q_ASSERT(selectedItems.size() == 1);
if (selectedItems.size() != 1)
return;
QTreeWidgetItem* item = selectedItems.first();
if (item == m_feedList->stickyUnreadItem())
return;
RssFilePtr rss_item = m_feedList->getRSSItem(item);
bool ok;
QString newName;
@ -681,6 +689,11 @@ RSSImp::RSSImp(QWidget *parent) : @@ -681,6 +689,11 @@ RSSImp::RSSImp(QWidget *parent) :
splitter_h->insertWidget(0, m_feedList);
listArticles->setSelectionBehavior(QAbstractItemView::SelectItems);
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();
fillFeedsList();
@ -729,6 +742,8 @@ RSSImp::~RSSImp() @@ -729,6 +742,8 @@ RSSImp::~RSSImp()
{
qDebug("Deleting RSSImp...");
saveFoldersOpenState();
delete editHotkey;
delete deleteHotkey;
delete m_feedList;
qDebug("RSSImp deleted");
}

3
src/rss/rss_imp.h

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

Loading…
Cancel
Save