|
|
@ -41,13 +41,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
|
QIcon get_directory_icon() |
|
|
|
QIcon getDirectoryIcon() |
|
|
|
{ |
|
|
|
{ |
|
|
|
static QIcon cached = GuiIconProvider::instance()->getIcon("inode-directory"); |
|
|
|
static QIcon cached = GuiIconProvider::instance()->getIcon("inode-directory"); |
|
|
|
return cached; |
|
|
|
return cached; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QIcon get_file_icon() |
|
|
|
QIcon getFileIcon() |
|
|
|
{ |
|
|
|
{ |
|
|
|
static QIcon cached = GuiIconProvider::instance()->getIcon("text-plain"); |
|
|
|
static QIcon cached = GuiIconProvider::instance()->getIcon("text-plain"); |
|
|
|
return cached; |
|
|
|
return cached; |
|
|
@ -180,9 +180,9 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const |
|
|
|
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer()); |
|
|
|
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer()); |
|
|
|
if ((index.column() == 0) && (role == Qt::DecorationRole)) { |
|
|
|
if ((index.column() == 0) && (role == Qt::DecorationRole)) { |
|
|
|
if (item->itemType() == TorrentContentModelItem::FolderType) |
|
|
|
if (item->itemType() == TorrentContentModelItem::FolderType) |
|
|
|
return get_directory_icon(); |
|
|
|
return getDirectoryIcon(); |
|
|
|
else |
|
|
|
else |
|
|
|
return get_file_icon(); |
|
|
|
return getFileIcon(); |
|
|
|
} |
|
|
|
} |
|
|
|
if ((index.column() == 0) && (role == Qt::CheckStateRole)) { |
|
|
|
if ((index.column() == 0) && (role == Qt::CheckStateRole)) { |
|
|
|
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED) |
|
|
|
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED) |
|
|
@ -290,10 +290,10 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) |
|
|
|
qDebug("Torrent contains %d files", info.filesCount()); |
|
|
|
qDebug("Torrent contains %d files", info.filesCount()); |
|
|
|
m_filesIndex.reserve(info.filesCount()); |
|
|
|
m_filesIndex.reserve(info.filesCount()); |
|
|
|
|
|
|
|
|
|
|
|
TorrentContentModelFolder* current_parent; |
|
|
|
TorrentContentModelFolder* currentParent; |
|
|
|
// Iterate over files
|
|
|
|
// Iterate over files
|
|
|
|
for (int i = 0; i < info.filesCount(); ++i) { |
|
|
|
for (int i = 0; i < info.filesCount(); ++i) { |
|
|
|
current_parent = m_rootItem; |
|
|
|
currentParent = m_rootItem; |
|
|
|
QString path = Utils::Fs::fromNativePath(info.filePath(i)); |
|
|
|
QString path = Utils::Fs::fromNativePath(info.filePath(i)); |
|
|
|
// Iterate of parts of the path to create necessary folders
|
|
|
|
// Iterate of parts of the path to create necessary folders
|
|
|
|
QStringList pathFolders = path.split("/", QString::SkipEmptyParts); |
|
|
|
QStringList pathFolders = path.split("/", QString::SkipEmptyParts); |
|
|
@ -301,16 +301,16 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) |
|
|
|
foreach (const QString& pathPart, pathFolders) { |
|
|
|
foreach (const QString& pathPart, pathFolders) { |
|
|
|
if (pathPart == ".unwanted") |
|
|
|
if (pathPart == ".unwanted") |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
TorrentContentModelFolder* new_parent = current_parent->childFolderWithName(pathPart); |
|
|
|
TorrentContentModelFolder* newParent = currentParent->childFolderWithName(pathPart); |
|
|
|
if (!new_parent) { |
|
|
|
if (!newParent) { |
|
|
|
new_parent = new TorrentContentModelFolder(pathPart, current_parent); |
|
|
|
newParent = new TorrentContentModelFolder(pathPart, currentParent); |
|
|
|
current_parent->appendChild(new_parent); |
|
|
|
currentParent->appendChild(newParent); |
|
|
|
} |
|
|
|
} |
|
|
|
current_parent = new_parent; |
|
|
|
currentParent = newParent; |
|
|
|
} |
|
|
|
} |
|
|
|
// Actually create the file
|
|
|
|
// Actually create the file
|
|
|
|
TorrentContentModelFile* fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), current_parent, i); |
|
|
|
TorrentContentModelFile* fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), currentParent, i); |
|
|
|
current_parent->appendChild(fileItem); |
|
|
|
currentParent->appendChild(fileItem); |
|
|
|
m_filesIndex.push_back(fileItem); |
|
|
|
m_filesIndex.push_back(fileItem); |
|
|
|
} |
|
|
|
} |
|
|
|
emit layoutChanged(); |
|
|
|
emit layoutChanged(); |
|
|
|