Browse Source

Merge pull request #793 from Gelmir/f2_edit

Enable edit/rename via F2 or double click in various places
adaptive-webui-19844
sledgehammer999 12 years ago
parent
commit
0e72583c1f
  1. 7
      src/addnewtorrentdialog.cpp
  2. 2
      src/addnewtorrentdialog.h
  3. 5
      src/mainwindow.cpp
  4. 17
      src/properties/propertieswidget.cpp
  5. 4
      src/properties/propertieswidget.h
  6. 5
      src/properties/trackerlist.cpp
  7. 3
      src/properties/trackerlist.h
  8. 17
      src/rss/automatedrssdownloader.cpp
  9. 3
      src/rss/automatedrssdownloader.h
  10. 19
      src/rss/rss_imp.cpp
  11. 3
      src/rss/rss_imp.h
  12. 5
      src/transferlistwidget.cpp
  13. 3
      src/transferlistwidget.h

7
src/addnewtorrentdialog.cpp

@ -81,6 +81,9 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
loadState(); loadState();
// Signal / slots // Signal / slots
connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool))); connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool)));
editHotkey = new QShortcut(QKeySequence("F2"), ui->content_tree, 0, 0, Qt::WidgetShortcut);
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile()));
connect(ui->content_tree, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile()));
} }
AddNewTorrentDialog::~AddNewTorrentDialog() AddNewTorrentDialog::~AddNewTorrentDialog()
@ -89,6 +92,7 @@ AddNewTorrentDialog::~AddNewTorrentDialog()
delete ui; delete ui;
if (m_contentModel) if (m_contentModel)
delete m_contentModel; delete m_contentModel;
delete editHotkey;
} }
void AddNewTorrentDialog::loadState() void AddNewTorrentDialog::loadState()
@ -390,7 +394,8 @@ void AddNewTorrentDialog::relayout()
void AddNewTorrentDialog::renameSelectedFile() void AddNewTorrentDialog::renameSelectedFile()
{ {
const QModelIndexList selectedIndexes = ui->content_tree->selectionModel()->selectedRows(0); const QModelIndexList selectedIndexes = ui->content_tree->selectionModel()->selectedRows(0);
Q_ASSERT(selectedIndexes.size() == 1); if (selectedIndexes.size() != 1)
return;
const QModelIndex &index = selectedIndexes.first(); const QModelIndex &index = selectedIndexes.first();
// Ask for new name // Ask for new name
bool ok; bool ok;

2
src/addnewtorrentdialog.h

@ -31,6 +31,7 @@
#ifndef ADDNEWTORRENTDIALOG_H #ifndef ADDNEWTORRENTDIALOG_H
#define ADDNEWTORRENTDIALOG_H #define ADDNEWTORRENTDIALOG_H
#include <QShortcut>
#include <QDialog> #include <QDialog>
#include <QUrl> #include <QUrl>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
@ -86,6 +87,7 @@ private:
boost::intrusive_ptr<libtorrent::torrent_info> m_torrentInfo; boost::intrusive_ptr<libtorrent::torrent_info> m_torrentInfo;
QStringList m_filesPath; QStringList m_filesPath;
bool m_hasRenamedFile; bool m_hasRenamedFile;
QShortcut *editHotkey;
}; };
#endif // ADDNEWTORRENTDIALOG_H #endif // ADDNEWTORRENTDIALOG_H

5
src/mainwindow.cpp

@ -557,11 +557,6 @@ void MainWindow::createKeyboardShortcuts() {
connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab())); connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab()));
actionDocumentation->setShortcut(QKeySequence("F1")); actionDocumentation->setShortcut(QKeySequence("F1"));
actionOptions->setShortcut(QKeySequence(QString::fromUtf8("Alt+O"))); actionOptions->setShortcut(QKeySequence(QString::fromUtf8("Alt+O")));
#ifdef Q_WS_MAC
actionDelete->setShortcut(QKeySequence("Ctrl+Backspace"));
#else
actionDelete->setShortcut(QKeySequence(QString::fromUtf8("Del")));
#endif
actionStart->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+S"))); actionStart->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+S")));
actionStart_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+S"))); actionStart_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+S")));
actionPause->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+P"))); actionPause->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+P")));

17
src/properties/propertieswidget.cpp

@ -119,6 +119,13 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
refreshTimer = new QTimer(this); refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData())); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
refreshTimer->start(3000); // 3sec refreshTimer->start(3000); // 3sec
editHotkeyFile = new QShortcut(QKeySequence("F2"), filesList, 0, 0, Qt::WidgetShortcut);
connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
editHotkeyWeb = new QShortcut(QKeySequence("F2"), listWebSeeds, 0, 0, Qt::WidgetShortcut);
connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
connect(listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed()));
deleteHotkeyWeb = new QShortcut(QKeySequence(QKeySequence::Delete), listWebSeeds, 0, 0, Qt::WidgetShortcut);
connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
} }
PropertiesWidget::~PropertiesWidget() { PropertiesWidget::~PropertiesWidget() {
@ -131,6 +138,9 @@ PropertiesWidget::~PropertiesWidget() {
delete PropListModel; delete PropListModel;
delete PropDelegate; delete PropDelegate;
delete m_tabBar; delete m_tabBar;
delete editHotkeyFile;
delete editHotkeyWeb;
delete deleteHotkeyWeb;
qDebug() << Q_FUNC_INFO << "EXIT"; qDebug() << Q_FUNC_INFO << "EXIT";
} }
@ -519,7 +529,8 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint&) {
void PropertiesWidget::renameSelectedFile() { void PropertiesWidget::renameSelectedFile() {
const QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(0); const QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(0);
Q_ASSERT(selectedIndexes.size() == 1); if (selectedIndexes.size() != 1)
return;
const QModelIndex index = selectedIndexes.first(); const QModelIndex index = selectedIndexes.first();
// Ask for new name // Ask for new name
bool ok; bool ok;
@ -655,6 +666,8 @@ void PropertiesWidget::askWebSeed() {
void PropertiesWidget::deleteSelectedUrlSeeds() { void PropertiesWidget::deleteSelectedUrlSeeds() {
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems(); const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
if (selectedItems.isEmpty())
return;
bool change = false; bool change = false;
foreach (const QListWidgetItem *item, selectedItems) { foreach (const QListWidgetItem *item, selectedItems) {
QString url_seed = item->text(); QString url_seed = item->text();
@ -683,7 +696,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const {
void PropertiesWidget::editWebSeed() { void PropertiesWidget::editWebSeed() {
const QList<QListWidgetItem *> selected_items = listWebSeeds->selectedItems(); const QList<QListWidgetItem *> selected_items = listWebSeeds->selectedItems();
if (selected_items.isEmpty()) if (selected_items.size() != 1)
return; return;
const QListWidgetItem *selected_item = selected_items.last(); const QListWidgetItem *selected_item = selected_items.last();

4
src/properties/propertieswidget.h

@ -31,6 +31,7 @@
#ifndef PROPERTIESWIDGET_H #ifndef PROPERTIESWIDGET_H
#define PROPERTIESWIDGET_H #define PROPERTIESWIDGET_H
#include <QShortcut>
#include <QWidget> #include <QWidget>
#include "ui_propertieswidget.h" #include "ui_propertieswidget.h"
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
@ -112,6 +113,9 @@ private:
PieceAvailabilityBar *pieces_availability; PieceAvailabilityBar *pieces_availability;
PropTabBar *m_tabBar; PropTabBar *m_tabBar;
LineEdit *m_contentFilerLine; LineEdit *m_contentFilerLine;
QShortcut *editHotkeyFile;
QShortcut *editHotkeyWeb;
QShortcut *deleteHotkeyWeb;
}; };
#endif // PROPERTIESWIDGET_H #endif // PROPERTIESWIDGET_H

5
src/properties/trackerlist.cpp

@ -75,11 +75,16 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
lsd_item = new QTreeWidgetItem(QStringList() << "" << "** [LSD] **"); lsd_item = new QTreeWidgetItem(QStringList() << "" << "** [LSD] **");
insertTopLevelItem(2, lsd_item); insertTopLevelItem(2, lsd_item);
setRowColor(2, QColor("grey")); setRowColor(2, QColor("grey"));
editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut);
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker()));
deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
loadSettings(); loadSettings();
} }
TrackerList::~TrackerList() { TrackerList::~TrackerList() {
delete editHotkey;
delete deleteHotkey;
saveSettings(); saveSettings();
} }

3
src/properties/trackerlist.h

@ -31,6 +31,7 @@
#ifndef TRACKERLIST_H #ifndef TRACKERLIST_H
#define TRACKERLIST_H #define TRACKERLIST_H
#include <QShortcut>
#include <QTreeWidget> #include <QTreeWidget>
#include <QList> #include <QList>
#include <QClipboard> #include <QClipboard>
@ -52,6 +53,8 @@ private:
QTreeWidgetItem* dht_item; QTreeWidgetItem* dht_item;
QTreeWidgetItem* pex_item; QTreeWidgetItem* pex_item;
QTreeWidgetItem* lsd_item; QTreeWidgetItem* lsd_item;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
public: public:
TrackerList(PropertiesWidget *properties); TrackerList(PropertiesWidget *properties);

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;
}; };

5
src/transferlistwidget.cpp

@ -141,6 +141,9 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayListMenu(const QPoint&))); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayListMenu(const QPoint&)));
header()->setContextMenuPolicy(Qt::CustomContextMenu); header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&))); connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut);
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut);
} }
TransferListWidget::~TransferListWidget() { TransferListWidget::~TransferListWidget() {
@ -153,6 +156,8 @@ TransferListWidget::~TransferListWidget() {
delete nameFilterModel; delete nameFilterModel;
delete listModel; delete listModel;
delete listDelegate; delete listDelegate;
delete editHotkey;
delete deleteHotkey;
qDebug() << Q_FUNC_INFO << "EXIT"; qDebug() << Q_FUNC_INFO << "EXIT";
} }

3
src/transferlistwidget.h

@ -31,6 +31,7 @@
#ifndef TRANSFERLISTWIDGET_H #ifndef TRANSFERLISTWIDGET_H
#define TRANSFERLISTWIDGET_H #define TRANSFERLISTWIDGET_H
#include <QShortcut>
#include <QTreeView> #include <QTreeView>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
@ -116,6 +117,8 @@ private:
QSortFilterProxyModel *labelFilterModel; QSortFilterProxyModel *labelFilterModel;
QBtSession* BTSession; QBtSession* BTSession;
MainWindow *main_window; MainWindow *main_window;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
}; };
#endif // TRANSFERLISTWIDGET_H #endif // TRANSFERLISTWIDGET_H

Loading…
Cancel
Save