mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
- Ported propertiesWidget from arborescence.h to new TorrentFiles Tree Model. (Needs to do the same thing for TorrentAddition.h now)
This commit is contained in:
parent
2e2e506162
commit
81658b9648
@ -341,7 +341,7 @@ public:
|
|||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const {
|
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const {
|
||||||
if (parent.isValid() && parent.column() != 0)
|
if (parent.isValid() && parent.column() != 0)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
|
|
||||||
@ -351,10 +351,11 @@ public:
|
|||||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||||
|
|
||||||
TreeItem *childItem = parentItem->child(row);
|
TreeItem *childItem = parentItem->child(row);
|
||||||
if (childItem)
|
if (childItem) {
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
else
|
} else {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex parent(const QModelIndex &index) const {
|
QModelIndex parent(const QModelIndex &index) const {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>756</width>
|
<width>756</width>
|
||||||
<height>291</height>
|
<height>292</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -839,21 +839,9 @@
|
|||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="uniformRowHeights">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="allColumnsShowFocus">
|
<property name="allColumnsShowFocus">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="expandsOnDoubleClick">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QStandardItem>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
@ -45,7 +43,6 @@
|
|||||||
#include "torrentPersistentData.h"
|
#include "torrentPersistentData.h"
|
||||||
#include "realprogressbar.h"
|
#include "realprogressbar.h"
|
||||||
#include "realprogressbarthread.h"
|
#include "realprogressbarthread.h"
|
||||||
#include "arborescence.h"
|
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
#include "PropListDelegate.h"
|
#include "PropListDelegate.h"
|
||||||
#include "TrackersAdditionDlg.h"
|
#include "TrackersAdditionDlg.h"
|
||||||
@ -66,21 +63,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set Properties list model
|
// Set Properties list model
|
||||||
PropListModel = new QStandardItemModel(0,5);
|
PropListModel = new TorrentFilesModel();
|
||||||
PropListModel->setHeaderData(NAME, Qt::Horizontal, tr("File name"));
|
|
||||||
PropListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
|
|
||||||
PropListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
|
|
||||||
PropListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Priority"));
|
|
||||||
filesList->setModel(PropListModel);
|
filesList->setModel(PropListModel);
|
||||||
filesList->hideColumn(INDEX);
|
filesList->hideColumn(INDEX);
|
||||||
PropDelegate = new PropListDelegate(0);
|
PropDelegate = new PropListDelegate(0);
|
||||||
filesList->setItemDelegate(PropDelegate);
|
filesList->setItemDelegate(PropDelegate);
|
||||||
|
|
||||||
// QActions
|
// QActions
|
||||||
actionIgnored = new QAction(this);
|
actionIgnored = new QAction(tr("Ignored"), this);
|
||||||
actionNormal = new QAction(this);
|
actionNormal = new QAction(tr("Normal"), this);
|
||||||
actionMaximum = new QAction(this);
|
actionMaximum = new QAction(tr("Maximum"), this);
|
||||||
actionHigh = new QAction(this);
|
actionHigh = new QAction(tr("High"), this);
|
||||||
|
|
||||||
// SIGNAL/SLOTS
|
// SIGNAL/SLOTS
|
||||||
connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&)));
|
connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&)));
|
||||||
@ -99,7 +92,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
||||||
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
||||||
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
|
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
|
||||||
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
|
||||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
|
|
||||||
// Downloaded pieces progress bar
|
// Downloaded pieces progress bar
|
||||||
@ -109,7 +101,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
progressBarVbox->addWidget(progressBar);
|
progressBarVbox->addWidget(progressBar);
|
||||||
// Pointers init
|
// Pointers init
|
||||||
progressBarUpdater = 0;
|
progressBarUpdater = 0;
|
||||||
arb = 0;
|
|
||||||
// Dynamic data refresher
|
// Dynamic data refresher
|
||||||
refreshTimer = new QTimer(this);
|
refreshTimer = new QTimer(this);
|
||||||
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
|
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
|
||||||
@ -124,8 +115,6 @@ PropertiesWidget::~PropertiesWidget() {
|
|||||||
delete progressBar;
|
delete progressBar;
|
||||||
delete progressBarVbox;
|
delete progressBarVbox;
|
||||||
delete PropListModel;
|
delete PropListModel;
|
||||||
if(arb)
|
|
||||||
delete arb;
|
|
||||||
// Delete QActions
|
// Delete QActions
|
||||||
delete actionIgnored;
|
delete actionIgnored;
|
||||||
delete actionNormal;
|
delete actionNormal;
|
||||||
@ -161,7 +150,7 @@ void PropertiesWidget::clear() {
|
|||||||
dlTotal->clear();
|
dlTotal->clear();
|
||||||
shareRatio->clear();
|
shareRatio->clear();
|
||||||
listWebSeeds->clear();
|
listWebSeeds->clear();
|
||||||
PropListModel->removeRows(0, PropListModel->rowCount());
|
PropListModel->clear();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +165,7 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
|||||||
delete progressBarUpdater;
|
delete progressBarUpdater;
|
||||||
progressBarUpdater = 0;
|
progressBarUpdater = 0;
|
||||||
}
|
}
|
||||||
if(arb != 0) {
|
|
||||||
delete arb;
|
|
||||||
arb = 0;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// Save path
|
// Save path
|
||||||
save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
|
save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
|
||||||
@ -201,14 +187,14 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
|||||||
// downloaded pieces updater
|
// downloaded pieces updater
|
||||||
progressBarUpdater = new RealProgressBarThread(progressBar, h);
|
progressBarUpdater = new RealProgressBarThread(progressBar, h);
|
||||||
progressBarUpdater->start();
|
progressBarUpdater->start();
|
||||||
// Create arborescence (Tree representation of files in the torrent)
|
|
||||||
std::vector<size_type> fp;
|
|
||||||
h.file_progress(fp);
|
|
||||||
std::vector<int> files_priority = loadFilesPriorities();
|
|
||||||
// List files in torrent
|
// List files in torrent
|
||||||
arborescence *arb = new arborescence(h.get_torrent_info(), fp, files_priority);
|
PropListModel->clear();
|
||||||
PropListModel->removeRows(0, PropListModel->rowCount());
|
PropListModel->setupModelData(h.get_torrent_info());
|
||||||
addFilesToTree(arb->getRoot(), PropListModel->invisibleRootItem());
|
std::vector<int> files_priority = loadFilesPriorities();
|
||||||
|
PropListModel->updateFilesPriorities(files_priority);
|
||||||
|
// Expand first item if possible
|
||||||
|
if(PropListModel->rowCount())
|
||||||
|
filesList->expand(PropListModel->index(0, 0));
|
||||||
// Increase first column width
|
// Increase first column width
|
||||||
//filesList->resizeColumnToContents(0); // does not work
|
//filesList->resizeColumnToContents(0); // does not work
|
||||||
} catch(invalid_handle e) {
|
} catch(invalid_handle e) {
|
||||||
@ -264,6 +250,10 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
// Downloaded pieces
|
// Downloaded pieces
|
||||||
if(progressBarUpdater)
|
if(progressBarUpdater)
|
||||||
progressBarUpdater->refresh();
|
progressBarUpdater->refresh();
|
||||||
|
// Files progress
|
||||||
|
std::vector<size_type> fp;
|
||||||
|
h.file_progress(fp);
|
||||||
|
PropListModel->updateFilesProgress(fp);
|
||||||
} catch(invalid_handle e) {}
|
} catch(invalid_handle e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,96 +377,6 @@ void PropertiesWidget::on_files_button_clicked() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// priority is the new priority of given item
|
|
||||||
void PropertiesWidget::updateParentsPriority(QStandardItem *item, int priority) {
|
|
||||||
QStandardItem *parent = item->parent();
|
|
||||||
if(!parent) return;
|
|
||||||
// Check if children have different priorities
|
|
||||||
// then folder must have NORMAL priority
|
|
||||||
unsigned int rowCount = parent->rowCount();
|
|
||||||
for(unsigned int i=0; i<rowCount; ++i) {
|
|
||||||
if(parent->child(i, PRIORITY)->text().toInt() != priority) {
|
|
||||||
QStandardItem *grandFather = parent->parent();
|
|
||||||
if(!grandFather) {
|
|
||||||
grandFather = PropListModel->invisibleRootItem();
|
|
||||||
}
|
|
||||||
QStandardItem *parentPrio = grandFather->child(parent->row(), PRIORITY);
|
|
||||||
if(parentPrio->text().toInt() != NORMAL) {
|
|
||||||
parentPrio->setText(misc::toQString(NORMAL));
|
|
||||||
setItemColor(parentPrio->index(), "green");
|
|
||||||
// Recursively update ancesters of this parent too
|
|
||||||
updateParentsPriority(grandFather->child(parent->row()), priority);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// All the children have the same priority
|
|
||||||
// Parent folder should have the same priority too
|
|
||||||
QStandardItem *grandFather = parent->parent();
|
|
||||||
if(!grandFather) {
|
|
||||||
grandFather = PropListModel->invisibleRootItem();
|
|
||||||
}
|
|
||||||
QStandardItem *parentPrio = grandFather->child(parent->row(), PRIORITY);
|
|
||||||
if(parentPrio->text().toInt() != priority) {
|
|
||||||
parentPrio->setText(misc::toQString(priority));
|
|
||||||
if(priority == IGNORED)
|
|
||||||
setItemColor(parentPrio->index(), "red");
|
|
||||||
else
|
|
||||||
setItemColor(parentPrio->index(), "green");
|
|
||||||
// Recursively update ancesters of this parent too
|
|
||||||
updateParentsPriority(grandFather->child(parent->row()), priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertiesWidget::updateChildrenPriority(QStandardItem *item, int priority) {
|
|
||||||
QStandardItem *parent = item->parent();
|
|
||||||
if(!parent) {
|
|
||||||
parent = PropListModel->invisibleRootItem();
|
|
||||||
}
|
|
||||||
parent = parent->child(item->row());
|
|
||||||
unsigned int rowCount = parent->rowCount();
|
|
||||||
for(unsigned int i=0; i<rowCount; ++i) {
|
|
||||||
QStandardItem * childPrio = parent->child(i, PRIORITY);
|
|
||||||
if(childPrio->text().toInt() != priority) {
|
|
||||||
childPrio->setText(misc::toQString(priority));
|
|
||||||
if(priority == IGNORED)
|
|
||||||
setItemColor(childPrio->index(), "red");
|
|
||||||
else
|
|
||||||
setItemColor(childPrio->index(), "green");
|
|
||||||
// recursively update children of this child too
|
|
||||||
updateChildrenPriority(parent->child(i), priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertiesWidget::updatePriorities(QStandardItem *item) {
|
|
||||||
qDebug("Priority changed");
|
|
||||||
// First we disable the signal/slot on item edition
|
|
||||||
// temporarily so that it doesn't mess with our manual updates
|
|
||||||
disconnect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
|
||||||
QStandardItem *parent = item->parent();
|
|
||||||
if(!parent) {
|
|
||||||
parent = PropListModel->invisibleRootItem();
|
|
||||||
}
|
|
||||||
int priority = parent->child(item->row(), PRIORITY)->text().toInt();
|
|
||||||
if(priority == IGNORED)
|
|
||||||
setItemColor(item->index(), "red");
|
|
||||||
else
|
|
||||||
setItemColor(item->index(), "green");
|
|
||||||
// Update parents priorities
|
|
||||||
updateParentsPriority(item, priority);
|
|
||||||
// If this is not a directory, then there are
|
|
||||||
// no children to update
|
|
||||||
if(parent->child(item->row(), INDEX)->text().toInt() == -1) {
|
|
||||||
// Updating children
|
|
||||||
qDebug("Priority changed for a folder to %d", priority);
|
|
||||||
updateChildrenPriority(item, priority);
|
|
||||||
}
|
|
||||||
// Reconnect the signal/slot on item edition so that we
|
|
||||||
// get future updates
|
|
||||||
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> PropertiesWidget::loadFilesPriorities(){
|
std::vector<int> PropertiesWidget::loadFilesPriorities(){
|
||||||
std::vector<int> fp;
|
std::vector<int> fp;
|
||||||
QVariantList files_priority = TorrentPersistentData::getFilesPriority(h.hash());
|
QVariantList files_priority = TorrentPersistentData::getFilesPriority(h.hash());
|
||||||
@ -497,38 +397,12 @@ std::vector<int> PropertiesWidget::loadFilesPriorities(){
|
|||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertiesWidget::allFiltered() const {
|
|
||||||
unsigned int nbRows = PropListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PropertiesWidget::getPriorities(QStandardItem *parent, int *priorities) {
|
|
||||||
qDebug("In getPriorities");
|
|
||||||
unsigned int nbRows = parent->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
QStandardItem *item = parent->child(i, INDEX);
|
|
||||||
int index = item->text().toInt();
|
|
||||||
if(index < 0) {
|
|
||||||
getPriorities(parent->child(i, NAME), priorities);
|
|
||||||
} else {
|
|
||||||
item = parent->child(i, PRIORITY);
|
|
||||||
priorities[index] = item->text().toInt();
|
|
||||||
qDebug("File at index %d has priority %d", index, priorities[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertiesWidget::displayFilesListMenu(const QPoint&){
|
void PropertiesWidget::displayFilesListMenu(const QPoint&){
|
||||||
if(h.get_torrent_info().num_files() == 1) return;
|
//if(h.get_torrent_info().num_files() == 1) return;
|
||||||
QMenu myFilesLlistMenu(this);
|
QMenu myFilesLlistMenu(this);
|
||||||
QModelIndex index;
|
//QModelIndex index;
|
||||||
// Enable/disable pause/start action given the DL state
|
// Enable/disable pause/start action given the DL state
|
||||||
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes();
|
//QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes();
|
||||||
myFilesLlistMenu.setTitle(tr("Priority"));
|
myFilesLlistMenu.setTitle(tr("Priority"));
|
||||||
myFilesLlistMenu.addAction(actionIgnored);
|
myFilesLlistMenu.addAction(actionIgnored);
|
||||||
myFilesLlistMenu.addAction(actionNormal);
|
myFilesLlistMenu.addAction(actionNormal);
|
||||||
@ -545,7 +419,6 @@ void PropertiesWidget::ignoreSelection(){
|
|||||||
if(PropListModel->data(index) != QVariant(IGNORED)){
|
if(PropListModel->data(index) != QVariant(IGNORED)){
|
||||||
PropListModel->setData(index, QVariant(IGNORED));
|
PropListModel->setData(index, QVariant(IGNORED));
|
||||||
filteredFilesChanged();
|
filteredFilesChanged();
|
||||||
setItemColor(index, "red");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -558,7 +431,6 @@ void PropertiesWidget::normalSelection(){
|
|||||||
if(PropListModel->data(index) != QVariant(NORMAL)){
|
if(PropListModel->data(index) != QVariant(NORMAL)){
|
||||||
PropListModel->setData(index, QVariant(NORMAL));
|
PropListModel->setData(index, QVariant(NORMAL));
|
||||||
filteredFilesChanged();
|
filteredFilesChanged();
|
||||||
setItemColor(index, "green");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -571,7 +443,6 @@ void PropertiesWidget::highSelection(){
|
|||||||
if(PropListModel->data(index) != QVariant(HIGH)){
|
if(PropListModel->data(index) != QVariant(HIGH)){
|
||||||
PropListModel->setData(index, QVariant(HIGH));
|
PropListModel->setData(index, QVariant(HIGH));
|
||||||
filteredFilesChanged();
|
filteredFilesChanged();
|
||||||
setItemColor(index, "green");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,7 +455,6 @@ void PropertiesWidget::maximumSelection(){
|
|||||||
if(PropListModel->data(index) != QVariant(MAXIMUM)){
|
if(PropListModel->data(index) != QVariant(MAXIMUM)){
|
||||||
PropListModel->setData(index, QVariant(MAXIMUM));
|
PropListModel->setData(index, QVariant(MAXIMUM));
|
||||||
filteredFilesChanged();
|
filteredFilesChanged();
|
||||||
setItemColor(index, "green");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -743,28 +613,11 @@ void PropertiesWidget::lowerSelectedTracker(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::setItemColor(QModelIndex index, QString color){
|
|
||||||
for(int i=0; i<PropListModel->columnCount(); ++i){
|
|
||||||
PropListModel->setData(index.sibling(index.row(), i), QVariant(QColor(color)), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PropertiesWidget::savePiecesPriorities() {
|
bool PropertiesWidget::savePiecesPriorities() {
|
||||||
/*if(!changedFilteredfiles) return true;
|
|
||||||
if(allFiltered()) {
|
|
||||||
QMessageBox::warning(0, tr("Priorities error"), tr("Error, you can't filter all the files in a torrent."));
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
qDebug("Saving pieces priorities");
|
qDebug("Saving pieces priorities");
|
||||||
int *priorities = new int[h.get_torrent_info().num_files()];
|
std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files());
|
||||||
getPriorities(PropListModel->invisibleRootItem(), priorities);
|
h.prioritize_files(priorities);
|
||||||
unsigned int nbFiles = h.get_torrent_info().num_files();
|
|
||||||
for(unsigned int i=0; i<nbFiles; ++i) {
|
|
||||||
h.file_priority(i, priorities[i]);
|
|
||||||
}
|
|
||||||
delete[] priorities;
|
|
||||||
TorrentPersistentData::saveFilesPriority(h);
|
TorrentPersistentData::saveFilesPriority(h);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,34 +655,3 @@ void PropertiesWidget::filteredFilesChanged() {
|
|||||||
transferList->updateTorrentSizeAndProgress(h.hash());
|
transferList->updateTorrentSizeAndProgress(h.hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::addFilesToTree(torrent_file *root, QStandardItem *parent) {
|
|
||||||
QList<QStandardItem*> child;
|
|
||||||
// Name
|
|
||||||
QStandardItem *first;
|
|
||||||
if(root->isDir()) {
|
|
||||||
first = new QStandardItem(QIcon(":/Icons/oxygen/folder.png"), root->name());
|
|
||||||
} else {
|
|
||||||
first = new QStandardItem(QIcon(":/Icons/oxygen/file.png"), root->name());
|
|
||||||
}
|
|
||||||
child << first;
|
|
||||||
// Size
|
|
||||||
child << new QStandardItem(misc::toQString(root->getSize()));
|
|
||||||
// Progress
|
|
||||||
child << new QStandardItem(misc::toQString(root->getProgress()));
|
|
||||||
// Prio
|
|
||||||
child << new QStandardItem(misc::toQString(root->getPriority()));
|
|
||||||
// INDEX
|
|
||||||
child << new QStandardItem(misc::toQString(root->getIndex()));
|
|
||||||
// Add the child to the tree
|
|
||||||
parent->appendRow(child);
|
|
||||||
// Set row color
|
|
||||||
if(root->getPriority() == IGNORED)
|
|
||||||
setItemColor(first->index(), "red");
|
|
||||||
else
|
|
||||||
setItemColor(first->index(), "green");
|
|
||||||
// Add childs
|
|
||||||
foreach(torrent_file *childFile, root->getChildren()) {
|
|
||||||
addFilesToTree(childFile, first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -35,16 +35,15 @@
|
|||||||
#include "ui_propertiesWidget.h"
|
#include "ui_propertiesWidget.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
|
|
||||||
class TransferListWidget;
|
class TransferListWidget;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class RealProgressBar;
|
class RealProgressBar;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class RealProgressBarThread;
|
class RealProgressBarThread;
|
||||||
class bittorrent;
|
class bittorrent;
|
||||||
class arborescence;
|
class TorrentFilesModel;
|
||||||
class QStandardItemModel;
|
|
||||||
class PropListDelegate;
|
class PropListDelegate;
|
||||||
class QStandardItem;
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class torrent_file;
|
class torrent_file;
|
||||||
|
|
||||||
@ -63,8 +62,7 @@ private:
|
|||||||
QVBoxLayout *progressBarVbox;
|
QVBoxLayout *progressBarVbox;
|
||||||
bittorrent* BTSession;
|
bittorrent* BTSession;
|
||||||
SlideState state;
|
SlideState state;
|
||||||
arborescence *arb;
|
TorrentFilesModel *PropListModel;
|
||||||
QStandardItemModel *PropListModel;
|
|
||||||
PropListDelegate *PropDelegate;
|
PropListDelegate *PropDelegate;
|
||||||
QAction *actionIgnored;
|
QAction *actionIgnored;
|
||||||
QAction *actionNormal;
|
QAction *actionNormal;
|
||||||
@ -74,7 +72,6 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
QPushButton* getButtonFromIndex(int index);
|
QPushButton* getButtonFromIndex(int index);
|
||||||
std::vector<int> loadFilesPriorities();
|
std::vector<int> loadFilesPriorities();
|
||||||
bool allFiltered() const;
|
|
||||||
bool savePiecesPriorities();
|
bool savePiecesPriorities();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
@ -87,9 +84,6 @@ protected slots:
|
|||||||
void on_trackers_button_clicked();
|
void on_trackers_button_clicked();
|
||||||
void on_url_seeds_button_clicked();
|
void on_url_seeds_button_clicked();
|
||||||
void on_files_button_clicked();
|
void on_files_button_clicked();
|
||||||
void updateChildrenPriority(QStandardItem *item, int priority);
|
|
||||||
void updateParentsPriority(QStandardItem *item, int priority);
|
|
||||||
void updatePriorities(QStandardItem *item);
|
|
||||||
void ignoreSelection();
|
void ignoreSelection();
|
||||||
void normalSelection();
|
void normalSelection();
|
||||||
void highSelection();
|
void highSelection();
|
||||||
@ -101,10 +95,7 @@ protected slots:
|
|||||||
void lowerSelectedTracker();
|
void lowerSelectedTracker();
|
||||||
void riseSelectedTracker();
|
void riseSelectedTracker();
|
||||||
void displayFilesListMenu(const QPoint& pos);
|
void displayFilesListMenu(const QPoint& pos);
|
||||||
void setItemColor(QModelIndex index, QString color);
|
|
||||||
void on_changeSavePathButton_clicked();
|
void on_changeSavePathButton_clicked();
|
||||||
void addFilesToTree(torrent_file *root, QStandardItem *parent);
|
|
||||||
void getPriorities(QStandardItem *parent, int *priorities);
|
|
||||||
void addTrackerList(QStringList myTrackers);
|
void addTrackerList(QStringList myTrackers);
|
||||||
void filteredFilesChanged();
|
void filteredFilesChanged();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user