mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 21:52:32 -06:00
FEATURE: Added search field for torrent content
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include "qinisettings.h"
|
||||
#include "proptabbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "lineedit.h"
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
@@ -72,15 +73,19 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
|
||||
setEnabled(false);
|
||||
|
||||
// Set Properties list model
|
||||
PropListModel = new TorrentFilesModel();
|
||||
PropListModel = new TorrentFilesFilterModel();
|
||||
filesList->setModel(PropListModel);
|
||||
PropDelegate = new PropListDelegate(this);
|
||||
filesList->setItemDelegate(PropDelegate);
|
||||
// Torrent content filtering
|
||||
m_contentFilerLine = new LineEdit(this);
|
||||
connect(m_contentFilerLine, SIGNAL(textChanged(QString)), PropListModel, SLOT(setFilterFixedString(QString)));
|
||||
contentFilterLayout->insertWidget(1, m_contentFilerLine);
|
||||
|
||||
// SIGNAL/SLOTS
|
||||
connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&)));
|
||||
connect(selectAllButton, SIGNAL(clicked()), this, SLOT(selectAllFiles()));
|
||||
connect(selectNoneButton, SIGNAL(clicked()), this, SLOT(selectNoneFiles()));
|
||||
connect(selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll()));
|
||||
connect(selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone()));
|
||||
connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
|
||||
connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex)));
|
||||
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||
@@ -197,7 +202,8 @@ void PropertiesWidget::clear() {
|
||||
reannounce_lbl->clear();
|
||||
shareRatio->clear();
|
||||
listWebSeeds->clear();
|
||||
PropListModel->clear();
|
||||
m_contentFilerLine->clear();
|
||||
PropListModel->model()->clear();
|
||||
showPiecesAvailability(false);
|
||||
showPiecesDownloaded(false);
|
||||
setEnabled(false);
|
||||
@@ -245,7 +251,7 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
|
||||
changeSavePathButton->setEnabled(h.has_metadata());
|
||||
// Hash
|
||||
hash_lbl->setText(h.hash());
|
||||
PropListModel->clear();
|
||||
PropListModel->model()->clear();
|
||||
if(h.has_metadata()) {
|
||||
// Creation date
|
||||
lbl_creationDate->setText(h.creation_date());
|
||||
@@ -256,7 +262,7 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
|
||||
// URL seeds
|
||||
loadUrlSeeds();
|
||||
// List files in torrent
|
||||
PropListModel->setupModelData(h.get_torrent_info());
|
||||
PropListModel->model()->setupModelData(h.get_torrent_info());
|
||||
}
|
||||
} catch(invalid_handle& e) {
|
||||
|
||||
@@ -294,7 +300,7 @@ void PropertiesWidget::saveSettings() {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
||||
QStringList contentColsWidths;
|
||||
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
||||
for(int i=0; i<PropListModel->model()->columnCount(); ++i) {
|
||||
contentColsWidths << QString::number(filesList->columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
||||
@@ -393,43 +399,16 @@ void PropertiesWidget::loadDynamicData() {
|
||||
if(stackedProperties->currentIndex() == PropTabBar::FILES_TAB) {
|
||||
// Files progress
|
||||
if(h.is_valid() && h.has_metadata()) {
|
||||
if(PropListModel->rowCount() == 0) {
|
||||
PropListModel->setupModelData(h.get_torrent_info());
|
||||
// Expand first item if possible
|
||||
filesList->expand(PropListModel->index(0, 0));
|
||||
}
|
||||
qDebug("Updating priorities in files tab");
|
||||
std::vector<size_type> fp;
|
||||
h.file_progress(fp);
|
||||
PropListModel->updateFilesPriorities(h.file_priorities());
|
||||
PropListModel->updateFilesProgress(fp);
|
||||
PropListModel->model()->updateFilesPriorities(h.file_priorities());
|
||||
PropListModel->model()->updateFilesProgress(fp);
|
||||
}
|
||||
}
|
||||
} catch(invalid_handle e) {}
|
||||
}
|
||||
|
||||
void PropertiesWidget::selectAllFiles() {
|
||||
// Update torrent properties
|
||||
std::vector<int> prio = h.file_priorities();
|
||||
for(std::vector<int>::iterator it = prio.begin(); it != prio.end(); it++) {
|
||||
if(*it == prio::IGNORED) {
|
||||
*it = prio::NORMAL;
|
||||
}
|
||||
}
|
||||
h.prioritize_files(prio);
|
||||
// Update model
|
||||
PropListModel->selectAll();
|
||||
}
|
||||
|
||||
void PropertiesWidget::selectNoneFiles() {
|
||||
// Update torrent properties
|
||||
std::vector<int> prio;
|
||||
prio.assign(h.num_files(), prio::IGNORED);
|
||||
h.prioritize_files(prio);
|
||||
// Update model
|
||||
PropListModel->selectNone();
|
||||
}
|
||||
|
||||
void PropertiesWidget::loadUrlSeeds(){
|
||||
listWebSeeds->clear();
|
||||
qDebug("Loading URL seeds");
|
||||
@@ -682,7 +661,7 @@ void PropertiesWidget::deleteSelectedUrlSeeds(){
|
||||
|
||||
bool PropertiesWidget::applyPriorities() {
|
||||
qDebug("Saving files priorities");
|
||||
const std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files());
|
||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(h.get_torrent_info().num_files());
|
||||
// Save first/last piece first option state
|
||||
bool first_last_piece_first = h.first_last_piece_first();
|
||||
// Prioritize the files
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
class TransferListWidget;
|
||||
class QTimer;
|
||||
class TorrentFilesModel;
|
||||
class TorrentFilesFilterModel;
|
||||
class PropListDelegate;
|
||||
class QAction;
|
||||
class torrent_file;
|
||||
@@ -48,6 +48,7 @@ class MainWindow;
|
||||
class DownloadedPiecesBar;
|
||||
class PieceAvailabilityBar;
|
||||
class PropTabBar;
|
||||
class LineEdit;
|
||||
|
||||
class PropertiesWidget : public QWidget, private Ui::PropertiesWidget {
|
||||
Q_OBJECT
|
||||
@@ -80,8 +81,6 @@ protected slots:
|
||||
void showPiecesDownloaded(bool show);
|
||||
void showPiecesAvailability(bool show);
|
||||
void renameSelectedFile();
|
||||
void selectAllFiles();
|
||||
void selectNoneFiles();
|
||||
|
||||
public slots:
|
||||
void setVisibility(bool visible);
|
||||
@@ -99,7 +98,7 @@ private:
|
||||
QTorrentHandle h;
|
||||
QTimer *refreshTimer;
|
||||
SlideState state;
|
||||
TorrentFilesModel *PropListModel;
|
||||
TorrentFilesFilterModel *PropListModel;
|
||||
PropListDelegate *PropDelegate;
|
||||
PeerListWidget *peersList;
|
||||
TrackerList *trackerList;
|
||||
@@ -107,6 +106,7 @@ private:
|
||||
DownloadedPiecesBar *downloaded_pieces;
|
||||
PieceAvailabilityBar *pieces_availability;
|
||||
PropTabBar *m_tabBar;
|
||||
LineEdit *m_contentFilerLine;
|
||||
};
|
||||
|
||||
#endif // PROPERTIESWIDGET_H
|
||||
|
||||
@@ -561,6 +561,7 @@ p, li { white-space: pre-wrap; }
|
||||
<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;">
|
||||
<tr>
|
||||
<td style="border: none;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"></p>
|
||||
@@ -758,7 +759,37 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="contentFilterLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Torrent content:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="filesList">
|
||||
<property name="contextMenuPolicy">
|
||||
|
||||
Reference in New Issue
Block a user