Compare commits

...

19 Commits

Author SHA1 Message Date
Christophe Dumez
f836c40fc4 Bump version to v3.0.2 2012-09-01 14:08:47 +03:00
Christophe Dumez
21fe7f2ca6 Update Changelog 2012-09-01 13:52:59 +03:00
Christophe Dumez
da85a57f83 Fix possible crash due to labels (closes #64) 2012-09-01 13:52:27 +03:00
Christophe Dumez
e35664b188 Correctly escape transfer list filter value typed by user 2012-08-28 18:37:02 +03:00
Christophe Dumez
2fc350b265 Update changelog 2012-08-28 18:29:11 +03:00
Christophe Dumez
83bcd6a2d7 Fix label-based filtering of torrents whose label contains special characters 2012-08-28 18:28:36 +03:00
Christophe Dumez
edcfa4df12 TorrentContentModel code clean up 2012-08-26 21:39:28 +03:00
Christophe Dumez
12a83e1aec Update Changelog 2012-08-26 21:02:26 +03:00
Christophe Dumez
7d50a8b28c Stop updating file priorities regularly in torrent content panel
Performance improvement to address issue #24.
2012-08-26 21:01:07 +03:00
Christophe Dumez
232e112d84 Optimizations to TorrentContentModel
First step to address issue #24.
2012-08-26 15:01:49 +03:00
Christophe Dumez
5b1ee883b4 Update Changelog 2012-08-26 10:14:12 +03:00
Christophe Dumez
b07fceec65 Add "clear" functionality to search field (closes #59) 2012-08-26 10:14:11 +03:00
Christophe Dumez
4c9cf6c773 Update Changelog 2012-08-25 16:54:58 +03:00
Christophe Dumez
164f37e961 Fix encoding problem for detected XDG Download folder (closes #53)
Only affects Linux.
2012-08-25 16:54:37 +03:00
Christophe Dumez
093fb303f3 Minor code clean up 2012-08-25 16:34:35 +03:00
Christophe Dumez
f3d5039e33 Update Changelog. 2012-08-24 19:21:32 +03:00
Christophe Dumez
007c307388 Fix crash when a fastresume file is empty (closes #52) 2012-08-24 19:20:47 +03:00
Christophe Dumez
4079689f32 Update Changelog 2012-08-23 21:21:39 +03:00
Christophe Dumez
2b3d6926c8 Attempt to use qBittorrent icon from theme if available (closes #49) 2012-08-23 21:19:50 +03:00
21 changed files with 129 additions and 120 deletions

View File

@@ -1,3 +1,12 @@
* Sat Sep 1 2012 - Christophe Dumez <chris@qbittorrent.org> - v3.0.2
- FEATURE: Add "clear" functionality to search field (closes #59)
- BUGFIX: Attempt to use qBittorrent icon from theme if available (closes #49)
- BUGFIX: Fix crash when a fastresume file is empty (closes #52)
- BUGFIX: Fix encoding problem for detected XDG Download folder (closes #53)
- BUGFIX: Improve performance when showing torrent content panel (Improves #24)
- BUGFIX: Fix label-based filtering of torrents whose label contains special characters
- BUGFIX: Fix possible crash due to labels (closes #64)
* Tue Aug 21 2012 - Christophe Dumez <chris@qbittorrent.org> - v3.0.1 * Tue Aug 21 2012 - Christophe Dumez <chris@qbittorrent.org> - v3.0.1
- BUGFIX: Fix possible crash when adding a tracker to a magnet torrent without metadata (Closes #1034254) - BUGFIX: Fix possible crash when adding a tracker to a magnet torrent without metadata (Closes #1034254)
- BUGFIX: Remember queue position for torrents without metadata (closes #17) - BUGFIX: Remember queue position for torrents without metadata (closes #17)

View File

@@ -45,7 +45,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.0.1</string> <string>3.0.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>qBit</string> <string>qBit</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>

View File

@@ -445,6 +445,9 @@ QString fsutils::QDesktopServicesDownloadLocation() {
QString user_dirs_file = config_path + "/user-dirs.dirs"; QString user_dirs_file = config_path + "/user-dirs.dirs";
if (QFile::exists(user_dirs_file)) { if (QFile::exists(user_dirs_file)) {
QSettings settings(user_dirs_file, QSettings::IniFormat); QSettings settings(user_dirs_file, QSettings::IniFormat);
// We need to force UTF-8 encoding here since this is not
// the default for Ini files.
settings.setIniCodec("UTF-8");
QString xdg_download_dir = settings.value("XDG_DOWNLOAD_DIR").toString(); QString xdg_download_dir = settings.value("XDG_DOWNLOAD_DIR").toString();
if (!xdg_download_dir.isEmpty()) { if (!xdg_download_dir.isEmpty()) {
// Resolve $HOME environment variables // Resolve $HOME environment variables

View File

@@ -105,7 +105,13 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
// Clean exit on log out // Clean exit on log out
connect(static_cast<SessionApplication*>(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteBTSession())); connect(static_cast<SessionApplication*>(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteBTSession()));
// Setting icons // Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))); #if defined(Q_WS_X11)
if (Preferences().useSystemIconTheme())
setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))));
else
#else
setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")));
#endif
actionOpen->setIcon(IconProvider::instance()->getIcon("list-add")); actionOpen->setIcon(IconProvider::instance()->getIcon("list-add"));
actionDownload_from_URL->setIcon(IconProvider::instance()->getIcon("insert-link")); actionDownload_from_URL->setIcon(IconProvider::instance()->getIcon("insert-link"));
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
@@ -706,7 +712,7 @@ void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e) {
return; return;
} }
// Make sure the window is not minimized // Make sure the window is not minimized
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); setWindowState(windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
// Then show it // Then show it
show(); show();
raise(); raise();
@@ -1399,8 +1405,15 @@ QIcon MainWindow::getSystrayIcon() const
} }
#endif #endif
QIcon icon; QIcon icon;
#if defined(Q_WS_X11)
if (Preferences().useSystemIconTheme()) {
icon = QIcon::fromTheme("qbittorrent");
}
#endif
if (icon.isNull()) {
icon.addFile(":/Icons/skin/qbittorrent22.png", QSize(22, 22)); icon.addFile(":/Icons/skin/qbittorrent22.png", QSize(22, 22));
icon.addFile(":/Icons/skin/qbittorrent16.png", QSize(16, 16)); icon.addFile(":/Icons/skin/qbittorrent16.png", QSize(16, 16));
icon.addFile(":/Icons/skin/qbittorrent32.png", QSize(32, 32)); icon.addFile(":/Icons/skin/qbittorrent32.png", QSize(32, 32));
}
return icon; return icon;
} }

View File

@@ -234,13 +234,12 @@ void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
} }
} }
void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) { void PropertiesWidget::loadTorrentInfos(const QTorrentHandle& _h)
{
clear(); clear();
h = _h; h = _h;
if (!h.is_valid()) { if (!h.is_valid())
clear();
return; return;
}
try { try {
// Save path // Save path
@@ -260,10 +259,10 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
// List files in torrent // List files in torrent
PropListModel->model()->setupModelData(h.get_torrent_info()); PropListModel->model()->setupModelData(h.get_torrent_info());
filesList->setExpanded(PropListModel->index(0, 0), true); filesList->setExpanded(PropListModel->index(0, 0), true);
// Load file priorities
PropListModel->model()->updateFilesPriorities(h.file_priorities());
} }
} catch(invalid_handle& e) { } catch(const invalid_handle& e) { }
}
// Load dynamic data // Load dynamic data
loadDynamicData(); loadDynamicData();
} }
@@ -391,8 +390,11 @@ void PropertiesWidget::loadDynamicData() {
filesList->setUpdatesEnabled(false); filesList->setUpdatesEnabled(false);
std::vector<size_type> fp; std::vector<size_type> fp;
h.file_progress(fp); h.file_progress(fp);
PropListModel->model()->updateFilesPriorities(h.file_priorities());
PropListModel->model()->updateFilesProgress(fp); PropListModel->model()->updateFilesProgress(fp);
// XXX: We don't update file priorities regularly for performance
// reasons. This means that priorities will not be updated if
// set from the Web UI.
// PropListModel->model()->updateFilesPriorities(h.file_priorities());
filesList->setUpdatesEnabled(true); filesList->setUpdatesEnabled(true);
} }
} }

View File

@@ -864,11 +864,16 @@ bool QBtSession::loadFastResumeData(const QString &hash, std::vector<char> &buf)
const QString fastresume_path = QDir(fsutils::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume")); const QString fastresume_path = QDir(fsutils::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume"));
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path)); qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
QFile fastresume_file(fastresume_path); QFile fastresume_file(fastresume_path);
if (!fastresume_file.open(QIODevice::ReadOnly)) return false; if (fastresume_file.size() <= 0)
return false;
if (!fastresume_file.open(QIODevice::ReadOnly))
return false;
const QByteArray content = fastresume_file.readAll(); const QByteArray content = fastresume_file.readAll();
const int content_size = content.size(); const int content_size = content.size();
Q_ASSERT(content_size > 0);
buf.resize(content_size); buf.resize(content_size);
memcpy(&buf[0], content.data(), content_size); memcpy(&buf[0], content.data(), content_size);
fastresume_file.close();
return true; return true;
} }

View File

@@ -37,14 +37,15 @@
using namespace libtorrent; using namespace libtorrent;
TorrentModelItem::TorrentModelItem(const QTorrentHandle &h) TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
: m_torrent(h)
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
, m_seedTime(TorrentPersistentData::getSeedDate(h.hash()))
, m_label(TorrentPersistentData::getLabel(h.hash()))
, m_name(TorrentPersistentData::getName(h.hash()))
, m_hash(h.hash())
{ {
m_torrent = h; if (m_name.isEmpty())
m_hash = h.hash(); m_name = h.name();
m_name = TorrentPersistentData::getName(h.hash());
if (m_name.isEmpty()) m_name = h.name();
m_addedTime = TorrentPersistentData::getAddedDate(h.hash());
m_seedTime = TorrentPersistentData::getSeedDate(h.hash());
m_label = TorrentPersistentData::getLabel(h.hash());
} }
TorrentModelItem::State TorrentModelItem::state() const TorrentModelItem::State TorrentModelItem::state() const

View File

@@ -40,13 +40,19 @@ public:
unsigned long num_peers; unsigned long num_peers;
//TrackerInfos() {} //TrackerInfos() {}
TrackerInfos(const TrackerInfos &b) { TrackerInfos(const TrackerInfos &b)
name_or_url = b.name_or_url; : name_or_url(b.name_or_url)
, last_message(b.last_message)
, num_peers(b.num_peers)
{
Q_ASSERT(!name_or_url.isEmpty()); Q_ASSERT(!name_or_url.isEmpty());
last_message = b.last_message;
num_peers = b.num_peers;
} }
TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) {
TrackerInfos(QString name_or_url)
: name_or_url(name_or_url)
, last_message("")
, num_peers(0)
{
} }
}; };

View File

@@ -88,12 +88,12 @@
*/ */
QtLockedFile::QtLockedFile() QtLockedFile::QtLockedFile()
: QFile() : QFile()
, m_lock_mode(NoLock)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
wmutex = 0; wmutex = 0;
rmutex = 0; rmutex = 0;
#endif #endif
m_lock_mode = NoLock;
} }
/*! /*!
@@ -105,12 +105,12 @@ QtLockedFile::QtLockedFile()
*/ */
QtLockedFile::QtLockedFile(const QString &name) QtLockedFile::QtLockedFile(const QString &name)
: QFile(name) : QFile(name)
, m_lock_mode(NoLock)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
wmutex = 0; wmutex = 0;
rmutex = 0; rmutex = 0;
#endif #endif
m_lock_mode = NoLock;
} }
/*! /*!

View File

@@ -15,20 +15,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="searchBarLayout">
<item>
<widget class="QLineEdit" name="search_pattern">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="comboCategory"/> <widget class="QComboBox" name="comboCategory"/>
</item> </item>
@@ -112,20 +99,8 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QPushButton" name="download_button"> <widget class="QPushButton" name="download_button">
<property name="enabled"> <property name="enabled">
@@ -173,22 +148,5 @@
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>search_pattern</sender>
<signal>returnPressed()</signal>
<receiver>search_button</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>421</x>
<y>37</y>
</hint>
<hint type="destinationlabel">
<x>685</x>
<y>45</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>

View File

@@ -58,12 +58,19 @@
#include "qinisettings.h" #include "qinisettings.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "lineedit.h"
#define SEARCHHISTORY_MAXSIZE 50 #define SEARCHHISTORY_MAXSIZE 50
/*SEARCH ENGINE START*/ /*SEARCH ENGINE START*/
SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(parent) { SearchEngine::SearchEngine(MainWindow* parent)
: QWidget(parent)
, search_pattern(new LineEdit)
, mp_mainWindow(parent)
{
setupUi(this); setupUi(this);
searchBarLayout->insertWidget(0, search_pattern);
connect(search_pattern, SIGNAL(returnPressed()), search_button, SLOT(click()));
// Icons // Icons
search_button->setIcon(IconProvider::instance()->getIcon("edit-find")); search_button->setIcon(IconProvider::instance()->getIcon("edit-find"));
download_button->setIcon(IconProvider::instance()->getIcon("download")); download_button->setIcon(IconProvider::instance()->getIcon("download"));
@@ -98,6 +105,7 @@ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(
); );
// Fill in category combobox // Fill in category combobox
fillCatCombobox(); fillCatCombobox();
connect(search_pattern, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPatternContextMenu(QPoint))); connect(search_pattern, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPatternContextMenu(QPoint)));
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString)));
} }
@@ -189,6 +197,7 @@ SearchEngine::~SearchEngine() {
downloader->waitForFinished(); downloader->waitForFinished();
delete downloader; delete downloader;
} }
delete search_pattern;
delete searchTimeout; delete searchTimeout;
delete searchProcess; delete searchProcess;
delete supported_engines; delete supported_engines;

View File

@@ -44,6 +44,7 @@
class DownloadThread; class DownloadThread;
class SearchEngine; class SearchEngine;
class MainWindow; class MainWindow;
class LineEdit;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTimer; class QTimer;
@@ -122,6 +123,7 @@ private slots:
private: private:
// Search related // Search related
LineEdit* search_pattern;
QProcess *searchProcess; QProcess *searchProcess;
QList<QProcess*> downloaders; QList<QProcess*> downloaders;
bool search_stopped; bool search_stopped;

View File

@@ -57,7 +57,7 @@ void TorrentContentModel::updateFilesProgress(const std::vector<libtorrent::size
emit dataChanged(index(0,0), index(rowCount(), columnCount())); emit dataChanged(index(0,0), index(rowCount(), columnCount()));
} }
void TorrentContentModel::updateFilesPriorities(const std::vector<int> &fprio) void TorrentContentModel::updateFilesPriorities(const std::vector<int>& fprio)
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
Q_ASSERT(m_filesIndex.size() == (int)fprio.size()); Q_ASSERT(m_filesIndex.size() == (int)fprio.size());
@@ -71,8 +71,9 @@ void TorrentContentModel::updateFilesPriorities(const std::vector<int> &fprio)
std::vector<int> TorrentContentModel::getFilesPriorities() const std::vector<int> TorrentContentModel::getFilesPriorities() const
{ {
std::vector<int> prio; std::vector<int> prio;
for (int i=0; i<m_filesIndex.size(); ++i) { prio.reserve(m_filesIndex.size());
prio.push_back(m_filesIndex[i]->getPriority()); foreach (const TorrentContentModelItem* file, m_filesIndex) {
prio.push_back(file->getPriority());
} }
return prio; return prio;
} }
@@ -147,7 +148,7 @@ TorrentContentModelItem::FileType TorrentContentModel::getType(const QModelIndex
int TorrentContentModel::getFileIndex(const QModelIndex& index) int TorrentContentModel::getFileIndex(const QModelIndex& index)
{ {
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer()); TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer());
return item->getFileIndex(); return item->getFileIndex();
} }
@@ -238,7 +239,7 @@ QModelIndex TorrentContentModel::parent(const QModelIndex& index) const
int TorrentContentModel::rowCount(const QModelIndex& parent) const int TorrentContentModel::rowCount(const QModelIndex& parent) const
{ {
TorrentContentModelItem *parentItem; TorrentContentModelItem* parentItem;
if (parent.column() > 0) if (parent.column() > 0)
return 0; return 0;
@@ -260,7 +261,7 @@ void TorrentContentModel::clear()
endResetModel(); endResetModel();
} }
void TorrentContentModel::setupModelData(const libtorrent::torrent_info &t) void TorrentContentModel::setupModelData(const libtorrent::torrent_info& t)
{ {
qDebug("setup model data called"); qDebug("setup model data called");
if (t.num_files() == 0) if (t.num_files() == 0)
@@ -271,32 +272,32 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info &t)
qDebug("Torrent contains %d files", t.num_files()); qDebug("Torrent contains %d files", t.num_files());
m_filesIndex.reserve(t.num_files()); m_filesIndex.reserve(t.num_files());
TorrentContentModelItem *parent = m_rootItem; TorrentContentModelItem* parent = m_rootItem;
TorrentContentModelItem *root_folder = parent; TorrentContentModelItem* root_folder = parent;
TorrentContentModelItem *current_parent; TorrentContentModelItem* current_parent;
// Iterate over files // Iterate over files
for (int i=0; i<t.num_files(); ++i) { for (int i=0; i<t.num_files(); ++i) {
libtorrent::file_entry fentry = t.file_at(i); const libtorrent::file_entry& fentry = t.file_at(i);
current_parent = root_folder; current_parent = root_folder;
#if LIBTORRENT_VERSION_MINOR >= 16 #if LIBTORRENT_VERSION_MINOR >= 16
QString path = QDir::cleanPath(misc::toQStringU(fentry.path)).replace("\\", "/"); QString path = misc::toQStringU(fentry.path);
#else #else
QString path = QDir::cleanPath(misc::toQStringU(fentry.path.string())).replace("\\", "/"); QString path = misc::toQStringU(fentry.path.string());
#endif #endif
// Iterate of parts of the path to create necessary folders // Iterate of parts of the path to create necessary folders
QStringList pathFolders = path.split("/"); QStringList pathFolders = path.split(QRegExp("[/\\\\]"), QString::SkipEmptyParts);
pathFolders.removeAll(".unwanted"); pathFolders.removeLast();
pathFolders.takeLast(); foreach (const QString& pathPart, pathFolders) {
foreach (const QString &pathPart, pathFolders) { if (pathPart == ".unwanted")
TorrentContentModelItem *new_parent = current_parent->childWithName(pathPart); continue;
if (!new_parent) { TorrentContentModelItem* new_parent = current_parent->childWithName(pathPart);
if (!new_parent)
new_parent = new TorrentContentModelItem(pathPart, current_parent); new_parent = new TorrentContentModelItem(pathPart, current_parent);
}
current_parent = new_parent; current_parent = new_parent;
} }
// Actually create the file // Actually create the file
m_filesIndex.push_back(new TorrentContentModelItem(t, fentry, current_parent, i)); m_filesIndex.push_back(new TorrentContentModelItem(fentry, current_parent, i));
} }
emit layoutChanged(); emit layoutChanged();
} }
@@ -304,7 +305,7 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info &t)
void TorrentContentModel::selectAll() void TorrentContentModel::selectAll()
{ {
for (int i=0; i<m_rootItem->childCount(); ++i) { for (int i=0; i<m_rootItem->childCount(); ++i) {
TorrentContentModelItem *child = m_rootItem->child(i); TorrentContentModelItem* child = m_rootItem->child(i);
if (child->getPriority() == prio::IGNORED) if (child->getPriority() == prio::IGNORED)
child->setPriority(prio::NORMAL); child->setPriority(prio::NORMAL);
} }

View File

@@ -70,8 +70,8 @@ public slots:
void selectNone(); void selectNone();
private: private:
TorrentContentModelItem *m_rootItem; TorrentContentModelItem* m_rootItem;
QVector<TorrentContentModelItem *> m_filesIndex; QVector<TorrentContentModelItem*> m_filesIndex;
}; };
#endif // TORRENTCONTENTMODEL_H #endif // TORRENTCONTENTMODEL_H

View File

@@ -33,8 +33,7 @@
#include "torrentcontentmodelitem.h" #include "torrentcontentmodelitem.h"
#include <QDebug> #include <QDebug>
TorrentContentModelItem::TorrentContentModelItem(const libtorrent::torrent_info &t, TorrentContentModelItem::TorrentContentModelItem(const libtorrent::file_entry &f,
const libtorrent::file_entry &f,
TorrentContentModelItem *parent, TorrentContentModelItem *parent,
int file_index): int file_index):
m_parentItem(parent), m_type(TFILE), m_fileIndex(file_index), m_totalDone(0) m_parentItem(parent), m_type(TFILE), m_fileIndex(file_index), m_totalDone(0)
@@ -42,7 +41,7 @@ TorrentContentModelItem::TorrentContentModelItem(const libtorrent::torrent_info
Q_ASSERT(parent); Q_ASSERT(parent);
#if LIBTORRENT_VERSION_MINOR >= 16 #if LIBTORRENT_VERSION_MINOR >= 16
QString name = fsutils::fileName(misc::toQStringU(t.files().file_path(f))); QString name = fsutils::fileName(misc::toQStringU(f.path.c_str()));
#else #else
Q_UNUSED(t); Q_UNUSED(t);
QString name = misc::toQStringU(f.path.filename()); QString name = misc::toQStringU(f.path.filename());
@@ -252,15 +251,15 @@ void TorrentContentModelItem::updatePriority()
return; return;
} }
} }
// All child items have the same priorrity // All child items have the same priority
// Update mine if necessary // Update own if necessary
if (prio != getPriority()) if (prio != getPriority())
setPriority(prio); setPriority(prio);
} }
TorrentContentModelItem* TorrentContentModelItem::childWithName(const QString& name) const TorrentContentModelItem* TorrentContentModelItem::childWithName(const QString& name) const
{ {
foreach (TorrentContentModelItem *child, m_childItems) { foreach (TorrentContentModelItem* child, m_childItems) {
if (child->getName() == name) if (child->getName() == name)
return child; return child;
} }
@@ -272,7 +271,7 @@ bool TorrentContentModelItem::isFolder() const
return (m_type==FOLDER); return (m_type==FOLDER);
} }
void TorrentContentModelItem::appendChild(TorrentContentModelItem *item) void TorrentContentModelItem::appendChild(TorrentContentModelItem* item)
{ {
Q_ASSERT(item); Q_ASSERT(item);
Q_ASSERT(m_type != TFILE); Q_ASSERT(m_type != TFILE);
@@ -285,7 +284,7 @@ void TorrentContentModelItem::appendChild(TorrentContentModelItem *item)
m_childItems.insert(i, item); m_childItems.insert(i, item);
} }
TorrentContentModelItem* TorrentContentModelItem::child(int row) TorrentContentModelItem* TorrentContentModelItem::child(int row) const
{ {
//Q_ASSERT(row >= 0 && row < childItems.size()); //Q_ASSERT(row >= 0 && row < childItems.size());
return m_childItems.value(row, 0); return m_childItems.value(row, 0);
@@ -315,7 +314,7 @@ int TorrentContentModelItem::row() const
return 0; return 0;
} }
TorrentContentModelItem* TorrentContentModelItem::parent() TorrentContentModelItem* TorrentContentModelItem::parent() const
{ {
return m_parentItem; return m_parentItem;
} }

View File

@@ -45,8 +45,7 @@ public:
enum FileType {TFILE, FOLDER, ROOT}; enum FileType {TFILE, FOLDER, ROOT};
// File Construction // File Construction
TorrentContentModelItem(const libtorrent::torrent_info &t, TorrentContentModelItem(const libtorrent::file_entry &f,
const libtorrent::file_entry &f,
TorrentContentModelItem *parent, TorrentContentModelItem *parent,
int file_index); int file_index);
// Folder constructor // Folder constructor
@@ -80,18 +79,18 @@ public:
bool isFolder() const; bool isFolder() const;
void appendChild(TorrentContentModelItem *item); void appendChild(TorrentContentModelItem *item);
TorrentContentModelItem *child(int row); TorrentContentModelItem* child(int row) const;
int childCount() const; int childCount() const;
int columnCount() const; int columnCount() const;
QVariant data(int column) const; QVariant data(int column) const;
int row() const; int row() const;
TorrentContentModelItem *parent(); TorrentContentModelItem* parent() const;
void deleteAllChildren(); void deleteAllChildren();
const QList<TorrentContentModelItem*>& children() const; const QList<TorrentContentModelItem*>& children() const;
private: private:
TorrentContentModelItem *m_parentItem; TorrentContentModelItem* m_parentItem;
FileType m_type; FileType m_type;
QList<TorrentContentModelItem*> m_childItems; QList<TorrentContentModelItem*> m_childItems;
QList<QVariant> m_itemData; QList<QVariant> m_itemData;

View File

@@ -447,6 +447,8 @@ protected slots:
if (!label.isEmpty()) { if (!label.isEmpty()) {
if (!customLabels.contains(label)) { if (!customLabels.contains(label)) {
addLabel(label); addLabel(label);
// addLabel may have changed the label, update the model accordingly.
torrentItem->setData(TorrentModelItem::TR_LABEL, label);
} }
// Update label counter // Update label counter
Q_ASSERT(customLabels.contains(label)); Q_ASSERT(customLabels.contains(label));

View File

@@ -856,11 +856,11 @@ void TransferListWidget::applyLabelFilter(QString label) {
return; return;
} }
qDebug("Applying Label filter: %s", qPrintable(label)); qDebug("Applying Label filter: %s", qPrintable(label));
labelFilterModel->setFilterRegExp(QRegExp("^"+label+"$", Qt::CaseSensitive)); labelFilterModel->setFilterRegExp(QRegExp("^" + QRegExp::escape(label) + "$", Qt::CaseSensitive));
} }
void TransferListWidget::applyNameFilter(QString name) { void TransferListWidget::applyNameFilter(const QString& name) {
nameFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive)); nameFilterModel->setFilterRegExp(QRegExp(QRegExp::escape(name), Qt::CaseInsensitive));
} }
void TransferListWidget::applyStatusFilter(int f) { void TransferListWidget::applyStatusFilter(int f) {

View File

@@ -78,7 +78,7 @@ public slots:
void previewSelectedTorrents(); void previewSelectedTorrents();
void hidePriorityColumn(bool hide); void hidePriorityColumn(bool hide);
void displayDLHoSMenu(const QPoint&); void displayDLHoSMenu(const QPoint&);
void applyNameFilter(QString name); void applyNameFilter(const QString& name);
void applyStatusFilter(int f); void applyStatusFilter(int f);
void applyLabelFilter(QString label); void applyLabelFilter(QString label);
void previewFile(QString filePath); void previewFile(QString filePath);

View File

@@ -37,7 +37,7 @@
class HttpResponseGenerator : public QHttpResponseHeader class HttpResponseGenerator : public QHttpResponseHeader
{ {
public: public:
void setMessage(const QByteArray& message); void setMessage(const QByteArray& message);
void setMessage(const QString& message); void setMessage(const QString& message);
void setContentTypeByExt(const QString& ext); void setContentTypeByExt(const QString& ext);

View File

@@ -1,5 +1,5 @@
PROJECT_NAME = qbittorrent PROJECT_NAME = qbittorrent
PROJECT_VERSION = 3.0.1 PROJECT_VERSION = 3.0.2
os2 { os2 {
DEFINES += VERSION=\'\"v$${PROJECT_VERSION}\"\' DEFINES += VERSION=\'\"v$${PROJECT_VERSION}\"\'
@@ -9,4 +9,4 @@ os2 {
DEFINES += VERSION_MAJOR=3 DEFINES += VERSION_MAJOR=3
DEFINES += VERSION_MINOR=0 DEFINES += VERSION_MINOR=0
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=2