mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
parent
e9d075049b
commit
30be83d445
5 changed files with 36 additions and 38 deletions
|
@ -234,13 +234,12 @@ void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
|
|||
}
|
||||
}
|
||||
|
||||
void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
|
||||
void PropertiesWidget::loadTorrentInfos(const QTorrentHandle& _h)
|
||||
{
|
||||
clear();
|
||||
h = _h;
|
||||
if (!h.is_valid()) {
|
||||
clear();
|
||||
if (!h.is_valid())
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Save path
|
||||
|
@ -261,9 +260,7 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
|
|||
PropListModel->model()->setupModelData(h.get_torrent_info());
|
||||
filesList->setExpanded(PropListModel->index(0, 0), true);
|
||||
}
|
||||
} catch(invalid_handle& e) {
|
||||
|
||||
}
|
||||
} catch(const invalid_handle& e) { }
|
||||
// Load dynamic data
|
||||
loadDynamicData();
|
||||
}
|
||||
|
|
|
@ -71,8 +71,9 @@ void TorrentContentModel::updateFilesPriorities(const std::vector<int> &fprio)
|
|||
std::vector<int> TorrentContentModel::getFilesPriorities() const
|
||||
{
|
||||
std::vector<int> prio;
|
||||
for (int i=0; i<m_filesIndex.size(); ++i) {
|
||||
prio.push_back(m_filesIndex[i]->getPriority());
|
||||
prio.reserve(m_filesIndex.size());
|
||||
foreach (const TorrentContentModelItem* file, m_filesIndex) {
|
||||
prio.push_back(file->getPriority());
|
||||
}
|
||||
return prio;
|
||||
}
|
||||
|
@ -277,22 +278,22 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info &t)
|
|||
|
||||
// Iterate over files
|
||||
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;
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
QString path = QDir::cleanPath(misc::toQStringU(fentry.path)).replace("\\", "/");
|
||||
QString path = misc::toQStringU(fentry.path);
|
||||
#else
|
||||
QString path = QDir::cleanPath(misc::toQStringU(fentry.path.string())).replace("\\", "/");
|
||||
QString path = misc::toQStringU(fentry.path.string());
|
||||
#endif
|
||||
// Iterate of parts of the path to create necessary folders
|
||||
QStringList pathFolders = path.split("/");
|
||||
pathFolders.removeAll(".unwanted");
|
||||
pathFolders.takeLast();
|
||||
QStringList pathFolders = path.split(QRegExp("[/\\\\]"), QString::SkipEmptyParts);
|
||||
pathFolders.removeLast();
|
||||
foreach (const QString& pathPart, pathFolders) {
|
||||
if (pathPart == ".unwanted")
|
||||
continue;
|
||||
TorrentContentModelItem* new_parent = current_parent->childWithName(pathPart);
|
||||
if (!new_parent) {
|
||||
if (!new_parent)
|
||||
new_parent = new TorrentContentModelItem(pathPart, current_parent);
|
||||
}
|
||||
current_parent = new_parent;
|
||||
}
|
||||
// Actually create the file
|
||||
|
|
|
@ -252,8 +252,8 @@ void TorrentContentModelItem::updatePriority()
|
|||
return;
|
||||
}
|
||||
}
|
||||
// All child items have the same priorrity
|
||||
// Update mine if necessary
|
||||
// All child items have the same priority
|
||||
// Update own if necessary
|
||||
if (prio != getPriority())
|
||||
setPriority(prio);
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void TorrentContentModelItem::appendChild(TorrentContentModelItem *item)
|
|||
m_childItems.insert(i, item);
|
||||
}
|
||||
|
||||
TorrentContentModelItem* TorrentContentModelItem::child(int row)
|
||||
TorrentContentModelItem* TorrentContentModelItem::child(int row) const
|
||||
{
|
||||
//Q_ASSERT(row >= 0 && row < childItems.size());
|
||||
return m_childItems.value(row, 0);
|
||||
|
@ -315,7 +315,7 @@ int TorrentContentModelItem::row() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
TorrentContentModelItem* TorrentContentModelItem::parent()
|
||||
TorrentContentModelItem* TorrentContentModelItem::parent() const
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
|
|
|
@ -80,13 +80,13 @@ public:
|
|||
bool isFolder() const;
|
||||
|
||||
void appendChild(TorrentContentModelItem *item);
|
||||
TorrentContentModelItem *child(int row);
|
||||
TorrentContentModelItem* child(int row) const;
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
QVariant data(int column) const;
|
||||
int row() const;
|
||||
|
||||
TorrentContentModelItem *parent();
|
||||
TorrentContentModelItem* parent() const;
|
||||
void deleteAllChildren();
|
||||
const QList<TorrentContentModelItem*>& children() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue