|
|
@ -195,9 +195,9 @@ namespace |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) |
|
|
|
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) |
|
|
|
: QTreeView(parent) |
|
|
|
: QTreeView(parent) |
|
|
|
, main_window(main_window) |
|
|
|
, m_mainWindow(mainWindow) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
setUniformRowHeights(true); |
|
|
|
setUniformRowHeights(true); |
|
|
@ -205,20 +205,20 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) |
|
|
|
bool column_loaded = loadSettings(); |
|
|
|
bool column_loaded = loadSettings(); |
|
|
|
|
|
|
|
|
|
|
|
// Create and apply delegate
|
|
|
|
// Create and apply delegate
|
|
|
|
listDelegate = new TransferListDelegate(this); |
|
|
|
m_listDelegate = new TransferListDelegate(this); |
|
|
|
setItemDelegate(listDelegate); |
|
|
|
setItemDelegate(m_listDelegate); |
|
|
|
|
|
|
|
|
|
|
|
// Create transfer list model
|
|
|
|
// Create transfer list model
|
|
|
|
listModel = new TorrentModel(this); |
|
|
|
m_listModel = new TorrentModel(this); |
|
|
|
|
|
|
|
|
|
|
|
nameFilterModel = new TransferListSortModel(); |
|
|
|
m_sortFilterModel = new TransferListSortModel(); |
|
|
|
nameFilterModel->setDynamicSortFilter(true); |
|
|
|
m_sortFilterModel->setDynamicSortFilter(true); |
|
|
|
nameFilterModel->setSourceModel(listModel); |
|
|
|
m_sortFilterModel->setSourceModel(m_listModel); |
|
|
|
nameFilterModel->setFilterKeyColumn(TorrentModel::TR_NAME); |
|
|
|
m_sortFilterModel->setFilterKeyColumn(TorrentModel::TR_NAME); |
|
|
|
nameFilterModel->setFilterRole(Qt::DisplayRole); |
|
|
|
m_sortFilterModel->setFilterRole(Qt::DisplayRole); |
|
|
|
nameFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
m_sortFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
|
|
|
|
|
|
|
|
setModel(nameFilterModel); |
|
|
|
setModel(m_sortFilterModel); |
|
|
|
|
|
|
|
|
|
|
|
// Visual settings
|
|
|
|
// Visual settings
|
|
|
|
setRootIsDecorated(false); |
|
|
|
setRootIsDecorated(false); |
|
|
@ -283,11 +283,11 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) |
|
|
|
connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); |
|
|
|
connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); |
|
|
|
connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); |
|
|
|
connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); |
|
|
|
|
|
|
|
|
|
|
|
editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); |
|
|
|
m_editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); |
|
|
|
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(softDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(softDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, SLOT(permDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
m_permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, SLOT(permDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut); |
|
|
|
m_doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut); |
|
|
|
recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
m_recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut); |
|
|
|
|
|
|
|
|
|
|
|
// This hack fixes reordering of first column with Qt5.
|
|
|
|
// This hack fixes reordering of first column with Qt5.
|
|
|
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
|
|
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
|
|
@ -303,15 +303,15 @@ TransferListWidget::~TransferListWidget() |
|
|
|
// Save settings
|
|
|
|
// Save settings
|
|
|
|
saveSettings(); |
|
|
|
saveSettings(); |
|
|
|
// Clean up
|
|
|
|
// Clean up
|
|
|
|
delete nameFilterModel; |
|
|
|
delete m_sortFilterModel; |
|
|
|
delete listModel; |
|
|
|
delete m_listModel; |
|
|
|
delete listDelegate; |
|
|
|
delete m_listDelegate; |
|
|
|
qDebug() << Q_FUNC_INFO << "EXIT"; |
|
|
|
qDebug() << Q_FUNC_INFO << "EXIT"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TorrentModel* TransferListWidget::getSourceModel() const |
|
|
|
TorrentModel* TransferListWidget::getSourceModel() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return listModel; |
|
|
|
return m_listModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::previewFile(QString filePath) |
|
|
|
void TransferListWidget::previewFile(QString filePath) |
|
|
@ -322,16 +322,16 @@ void TransferListWidget::previewFile(QString filePath) |
|
|
|
inline QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) const |
|
|
|
inline QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(index.isValid()); |
|
|
|
Q_ASSERT(index.isValid()); |
|
|
|
if (index.model() == nameFilterModel) |
|
|
|
if (index.model() == m_sortFilterModel) |
|
|
|
return nameFilterModel->mapToSource(index); |
|
|
|
return m_sortFilterModel->mapToSource(index); |
|
|
|
return index; |
|
|
|
return index; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) const |
|
|
|
inline QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(index.isValid()); |
|
|
|
Q_ASSERT(index.isValid()); |
|
|
|
Q_ASSERT(index.model() == nameFilterModel); |
|
|
|
Q_ASSERT(index.model() == m_sortFilterModel); |
|
|
|
return nameFilterModel->mapFromSource(index); |
|
|
|
return m_sortFilterModel->mapFromSource(index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::torrentDoubleClicked() |
|
|
|
void TransferListWidget::torrentDoubleClicked() |
|
|
@ -339,8 +339,8 @@ void TransferListWidget::torrentDoubleClicked() |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; |
|
|
|
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; |
|
|
|
|
|
|
|
|
|
|
|
const QModelIndex index = listModel->index(mapToSource(selectedIndexes.first()).row()); |
|
|
|
const QModelIndex index = m_listModel->index(mapToSource(selectedIndexes.first()).row()); |
|
|
|
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(index); |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(index); |
|
|
|
if (!torrent) return; |
|
|
|
if (!torrent) return; |
|
|
|
|
|
|
|
|
|
|
|
int action; |
|
|
|
int action; |
|
|
@ -369,7 +369,7 @@ QList<BitTorrent::TorrentHandle *> TransferListWidget::getSelectedTorrents() con |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<BitTorrent::TorrentHandle *> torrents; |
|
|
|
QList<BitTorrent::TorrentHandle *> torrents; |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) |
|
|
|
torrents << listModel->torrentHandle(mapToSource(index)); |
|
|
|
torrents << m_listModel->torrentHandle(mapToSource(index)); |
|
|
|
|
|
|
|
|
|
|
|
return torrents; |
|
|
|
return torrents; |
|
|
|
} |
|
|
|
} |
|
|
@ -420,8 +420,8 @@ void TransferListWidget::forceStartSelectedTorrents() |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::startVisibleTorrents() |
|
|
|
void TransferListWidget::startVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < nameFilterModel->rowCount(); ++i) { |
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) { |
|
|
|
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mapToSource(nameFilterModel->index(i, 0))); |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
if (torrent) |
|
|
|
if (torrent) |
|
|
|
torrent->resume(); |
|
|
|
torrent->resume(); |
|
|
|
} |
|
|
|
} |
|
|
@ -435,8 +435,8 @@ void TransferListWidget::pauseSelectedTorrents() |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::pauseVisibleTorrents() |
|
|
|
void TransferListWidget::pauseVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < nameFilterModel->rowCount(); ++i) { |
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) { |
|
|
|
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mapToSource(nameFilterModel->index(i, 0))); |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
if (torrent) |
|
|
|
if (torrent) |
|
|
|
torrent->pause(); |
|
|
|
torrent->pause(); |
|
|
|
} |
|
|
|
} |
|
|
@ -454,7 +454,7 @@ void TransferListWidget::permDeleteSelectedTorrents() |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) |
|
|
|
void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (main_window->currentTabWidget() != this) return; |
|
|
|
if (m_mainWindow->currentTabWidget() != this) return; |
|
|
|
|
|
|
|
|
|
|
|
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents(); |
|
|
|
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents(); |
|
|
|
if (torrents.empty()) return; |
|
|
|
if (torrents.empty()) return; |
|
|
@ -468,11 +468,11 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::deleteVisibleTorrents() |
|
|
|
void TransferListWidget::deleteVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nameFilterModel->rowCount() <= 0) return; |
|
|
|
if (m_sortFilterModel->rowCount() <= 0) return; |
|
|
|
|
|
|
|
|
|
|
|
QList<BitTorrent::TorrentHandle *> torrents; |
|
|
|
QList<BitTorrent::TorrentHandle *> torrents; |
|
|
|
for (int i = 0; i < nameFilterModel->rowCount(); ++i) |
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) |
|
|
|
torrents << listModel->torrentHandle(mapToSource(nameFilterModel->index(i, 0))); |
|
|
|
torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
|
|
|
|
|
|
|
|
bool deleteLocalFiles = false; |
|
|
|
bool deleteLocalFiles = false; |
|
|
|
if (Preferences::instance()->confirmTorrentDeletion() |
|
|
|
if (Preferences::instance()->confirmTorrentDeletion() |
|
|
@ -486,26 +486,26 @@ void TransferListWidget::deleteVisibleTorrents() |
|
|
|
void TransferListWidget::increasePrioSelectedTorrents() |
|
|
|
void TransferListWidget::increasePrioSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << Q_FUNC_INFO; |
|
|
|
qDebug() << Q_FUNC_INFO; |
|
|
|
if (main_window->currentTabWidget() == this) |
|
|
|
if (m_mainWindow->currentTabWidget() == this) |
|
|
|
BitTorrent::Session::instance()->increaseTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
BitTorrent::Session::instance()->increaseTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::decreasePrioSelectedTorrents() |
|
|
|
void TransferListWidget::decreasePrioSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << Q_FUNC_INFO; |
|
|
|
qDebug() << Q_FUNC_INFO; |
|
|
|
if (main_window->currentTabWidget() == this) |
|
|
|
if (m_mainWindow->currentTabWidget() == this) |
|
|
|
BitTorrent::Session::instance()->decreaseTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
BitTorrent::Session::instance()->decreaseTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::topPrioSelectedTorrents() |
|
|
|
void TransferListWidget::topPrioSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (main_window->currentTabWidget() == this) |
|
|
|
if (m_mainWindow->currentTabWidget() == this) |
|
|
|
BitTorrent::Session::instance()->topTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
BitTorrent::Session::instance()->topTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::bottomPrioSelectedTorrents() |
|
|
|
void TransferListWidget::bottomPrioSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (main_window->currentTabWidget() == this) |
|
|
|
if (m_mainWindow->currentTabWidget() == this) |
|
|
|
BitTorrent::Session::instance()->bottomTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
BitTorrent::Session::instance()->bottomTorrentsPriority(extractHashes(getSelectedTorrents())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -666,12 +666,12 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) |
|
|
|
QMenu hideshowColumn(this); |
|
|
|
QMenu hideshowColumn(this); |
|
|
|
hideshowColumn.setTitle(tr("Column visibility")); |
|
|
|
hideshowColumn.setTitle(tr("Column visibility")); |
|
|
|
QList<QAction*> actions; |
|
|
|
QList<QAction*> actions; |
|
|
|
for (int i = 0; i < listModel->columnCount(); ++i) { |
|
|
|
for (int i = 0; i < m_listModel->columnCount(); ++i) { |
|
|
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && i == TorrentModel::TR_PRIORITY) { |
|
|
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && i == TorrentModel::TR_PRIORITY) { |
|
|
|
actions.append(0); |
|
|
|
actions.append(0); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
QAction *myAct = hideshowColumn.addAction(listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); |
|
|
|
QAction *myAct = hideshowColumn.addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); |
|
|
|
myAct->setCheckable(true); |
|
|
|
myAct->setCheckable(true); |
|
|
|
myAct->setChecked(!isColumnHidden(i)); |
|
|
|
myAct->setChecked(!isColumnHidden(i)); |
|
|
|
actions.append(myAct); |
|
|
|
actions.append(myAct); |
|
|
@ -793,7 +793,7 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle) |
|
|
|
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn) |
|
|
|
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) { |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) { |
|
|
|
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mapToSource(index)); |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(index)); |
|
|
|
Q_ASSERT(torrent); |
|
|
|
Q_ASSERT(torrent); |
|
|
|
fn(torrent); |
|
|
|
fn(torrent); |
|
|
|
} |
|
|
|
} |
|
|
@ -804,8 +804,8 @@ void TransferListWidget::renameSelectedTorrent() |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; |
|
|
|
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; |
|
|
|
|
|
|
|
|
|
|
|
const QModelIndex mi = listModel->index(mapToSource(selectedIndexes.first()).row(), TorrentModel::TR_NAME); |
|
|
|
const QModelIndex mi = m_listModel->index(mapToSource(selectedIndexes.first()).row(), TorrentModel::TR_NAME); |
|
|
|
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mi); |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mi); |
|
|
|
if (!torrent) return; |
|
|
|
if (!torrent) return; |
|
|
|
|
|
|
|
|
|
|
|
// Ask for a new Name
|
|
|
|
// Ask for a new Name
|
|
|
@ -814,14 +814,14 @@ void TransferListWidget::renameSelectedTorrent() |
|
|
|
if (ok && !name.isEmpty()) { |
|
|
|
if (ok && !name.isEmpty()) { |
|
|
|
name.replace(QRegExp("\r?\n|\r"), " "); |
|
|
|
name.replace(QRegExp("\r?\n|\r"), " "); |
|
|
|
// Rename the torrent
|
|
|
|
// Rename the torrent
|
|
|
|
listModel->setData(mi, name, Qt::DisplayRole); |
|
|
|
m_listModel->setData(mi, name, Qt::DisplayRole); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setSelectionCategory(QString category) |
|
|
|
void TransferListWidget::setSelectionCategory(QString category) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) |
|
|
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) |
|
|
|
listModel->setData(listModel->index(mapToSource(index).row(), TorrentModel::TR_CATEGORY), category, Qt::DisplayRole); |
|
|
|
m_listModel->setData(m_listModel->index(mapToSource(index).row(), TorrentModel::TR_CATEGORY), category, Qt::DisplayRole); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::addSelectionTag(const QString &tag) |
|
|
|
void TransferListWidget::addSelectionTag(const QString &tag) |
|
|
@ -918,7 +918,7 @@ void TransferListWidget::displayListMenu(const QPoint&) |
|
|
|
foreach (const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach (const QModelIndex &index, selectedIndexes) { |
|
|
|
// Get the file name
|
|
|
|
// Get the file name
|
|
|
|
// Get handle and pause the torrent
|
|
|
|
// Get handle and pause the torrent
|
|
|
|
torrent = listModel->torrentHandle(mapToSource(index)); |
|
|
|
torrent = m_listModel->torrentHandle(mapToSource(index)); |
|
|
|
if (!torrent) continue; |
|
|
|
if (!torrent) continue; |
|
|
|
|
|
|
|
|
|
|
|
if (firstCategory.isEmpty() && first) |
|
|
|
if (firstCategory.isEmpty() && first) |
|
|
@ -1131,7 +1131,7 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel |
|
|
|
qDebug("CURRENT CHANGED"); |
|
|
|
qDebug("CURRENT CHANGED"); |
|
|
|
BitTorrent::TorrentHandle *torrent = 0; |
|
|
|
BitTorrent::TorrentHandle *torrent = 0; |
|
|
|
if (current.isValid()) { |
|
|
|
if (current.isValid()) { |
|
|
|
torrent = listModel->torrentHandle(mapToSource(current)); |
|
|
|
torrent = m_listModel->torrentHandle(mapToSource(current)); |
|
|
|
// Scroll Fix
|
|
|
|
// Scroll Fix
|
|
|
|
scrollTo(current); |
|
|
|
scrollTo(current); |
|
|
|
} |
|
|
|
} |
|
|
@ -1141,41 +1141,41 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel |
|
|
|
void TransferListWidget::applyCategoryFilter(QString category) |
|
|
|
void TransferListWidget::applyCategoryFilter(QString category) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (category.isNull()) |
|
|
|
if (category.isNull()) |
|
|
|
nameFilterModel->disableCategoryFilter(); |
|
|
|
m_sortFilterModel->disableCategoryFilter(); |
|
|
|
else |
|
|
|
else |
|
|
|
nameFilterModel->setCategoryFilter(category); |
|
|
|
m_sortFilterModel->setCategoryFilter(category); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::applyTagFilter(const QString &tag) |
|
|
|
void TransferListWidget::applyTagFilter(const QString &tag) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (tag.isNull()) |
|
|
|
if (tag.isNull()) |
|
|
|
nameFilterModel->disableTagFilter(); |
|
|
|
m_sortFilterModel->disableTagFilter(); |
|
|
|
else |
|
|
|
else |
|
|
|
nameFilterModel->setTagFilter(tag); |
|
|
|
m_sortFilterModel->setTagFilter(tag); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::applyTrackerFilterAll() |
|
|
|
void TransferListWidget::applyTrackerFilterAll() |
|
|
|
{ |
|
|
|
{ |
|
|
|
nameFilterModel->disableTrackerFilter(); |
|
|
|
m_sortFilterModel->disableTrackerFilter(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::applyTrackerFilter(const QStringList &hashes) |
|
|
|
void TransferListWidget::applyTrackerFilter(const QStringList &hashes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nameFilterModel->setTrackerFilter(hashes); |
|
|
|
m_sortFilterModel->setTrackerFilter(hashes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::applyNameFilter(const QString& name) |
|
|
|
void TransferListWidget::applyNameFilter(const QString& name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nameFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, QRegExp::WildcardUnix)); |
|
|
|
m_sortFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, QRegExp::WildcardUnix)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::applyStatusFilter(int f) |
|
|
|
void TransferListWidget::applyStatusFilter(int f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nameFilterModel->setStatusFilter(static_cast<TorrentFilter::Type>(f)); |
|
|
|
m_sortFilterModel->setStatusFilter(static_cast<TorrentFilter::Type>(f)); |
|
|
|
// Select first item if nothing is selected
|
|
|
|
// Select first item if nothing is selected
|
|
|
|
if (selectionModel()->selectedRows(0).empty() && nameFilterModel->rowCount() > 0) { |
|
|
|
if (selectionModel()->selectedRows(0).empty() && m_sortFilterModel->rowCount() > 0) { |
|
|
|
qDebug("Nothing is selected, selecting first row: %s", qUtf8Printable(nameFilterModel->index(0, TorrentModel::TR_NAME).data().toString())); |
|
|
|
qDebug("Nothing is selected, selecting first row: %s", qUtf8Printable(m_sortFilterModel->index(0, TorrentModel::TR_NAME).data().toString())); |
|
|
|
selectionModel()->setCurrentIndex(nameFilterModel->index(0, TorrentModel::TR_NAME), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); |
|
|
|
selectionModel()->setCurrentIndex(m_sortFilterModel->index(0, TorrentModel::TR_NAME), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|