|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
@ -277,22 +278,22 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info &t) |
|
|
|
|
|
|
|
|
|
|
|
// 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") |
|
|
|
|
|
|
|
continue; |
|
|
|
TorrentContentModelItem* new_parent = current_parent->childWithName(pathPart); |
|
|
|
TorrentContentModelItem* new_parent = current_parent->childWithName(pathPart); |
|
|
|
if (!new_parent) { |
|
|
|
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
|
|
|
|