mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
- Attempt to fix compilation on vc++
This commit is contained in:
parent
1b7449ef4e
commit
8b576fcc50
@ -27,19 +27,19 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
class file {
|
class torrent_file {
|
||||||
private:
|
private:
|
||||||
file *parent;
|
torrent_file *parent;
|
||||||
bool is_dir;
|
bool is_dir;
|
||||||
QString rel_path;
|
QString rel_path;
|
||||||
QList<file*> children;
|
QList<torrent_file*> children;
|
||||||
size_type size;
|
size_type size;
|
||||||
float progress;
|
float progress;
|
||||||
int priority;
|
int priority;
|
||||||
int index; // Index in torrent_info
|
int index; // Index in torrent_info
|
||||||
|
|
||||||
public:
|
public:
|
||||||
file(file *parent, QString path, bool dir, size_type size=0, int index=-1, float progress=0., int priority=1): parent(parent), is_dir(dir), size(size), progress(progress), priority(priority), index(index){
|
torrent_file(torrent_file *parent, QString path, bool dir, size_type size=0, int index=-1, float progress=0., int priority=1): parent(parent), is_dir(dir), size(size), progress(progress), priority(priority), index(index){
|
||||||
qDebug("created a file with index %d", index);
|
qDebug("created a file with index %d", index);
|
||||||
rel_path = QDir::cleanPath(path);
|
rel_path = QDir::cleanPath(path);
|
||||||
if(parent) {
|
if(parent) {
|
||||||
@ -48,7 +48,7 @@ class file {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~file() {
|
~torrent_file() {
|
||||||
qDeleteAll(children);
|
qDeleteAll(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class file {
|
|||||||
}
|
}
|
||||||
float wanted = 0.;
|
float wanted = 0.;
|
||||||
float done = 0.;
|
float done = 0.;
|
||||||
file *child;
|
torrent_file *child;
|
||||||
foreach(child, children) {
|
foreach(child, children) {
|
||||||
wanted += child->getSize();
|
wanted += child->getSize();
|
||||||
done += child->getSize()*child->getProgress();
|
done += child->getSize()*child->getProgress();
|
||||||
@ -80,7 +80,7 @@ class file {
|
|||||||
|
|
||||||
void updatePriority(int prio) {
|
void updatePriority(int prio) {
|
||||||
Q_ASSERT(is_dir);
|
Q_ASSERT(is_dir);
|
||||||
file *child;
|
torrent_file *child;
|
||||||
foreach(child, children) {
|
foreach(child, children) {
|
||||||
if(child->getPriority() != prio) return;
|
if(child->getPriority() != prio) return;
|
||||||
}
|
}
|
||||||
@ -111,13 +111,13 @@ class file {
|
|||||||
return (!children.isEmpty());
|
return (!children.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<file*> getChildren() const {
|
QList<torrent_file*> getChildren() const {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
file* getChild(QString fileName) const {
|
torrent_file* getChild(QString fileName) const {
|
||||||
Q_ASSERT(is_dir);
|
Q_ASSERT(is_dir);
|
||||||
file* f;
|
torrent_file* f;
|
||||||
foreach(f, children) {
|
foreach(f, children) {
|
||||||
if(f->name() == fileName) return f;
|
if(f->name() == fileName) return f;
|
||||||
}
|
}
|
||||||
@ -130,10 +130,10 @@ class file {
|
|||||||
parent->addBytes(b);
|
parent->addBytes(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
file* addChild(QString fileName, bool dir, size_type size=0, int index = -1, float progress=0., int priority=1) {
|
torrent_file* addChild(QString fileName, bool dir, size_type size=0, int index = -1, float progress=0., int priority=1) {
|
||||||
Q_ASSERT(is_dir);
|
Q_ASSERT(is_dir);
|
||||||
qDebug("Adding a new child of size: %ld", (long)size);
|
qDebug("Adding a new child of size: %ld", (long)size);
|
||||||
file *f = new file(this, QDir::cleanPath(rel_path+QDir::separator()+fileName), dir, size, index, progress, priority);
|
torrent_file *f = new torrent_file(this, QDir::cleanPath(rel_path+QDir::separator()+fileName), dir, size, index, progress, priority);
|
||||||
children << f;
|
children << f;
|
||||||
if(size) {
|
if(size) {
|
||||||
addBytes(size);
|
addBytes(size);
|
||||||
@ -148,7 +148,7 @@ class file {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
file *f;
|
torrent_file *f;
|
||||||
qDebug("We have %d children", children.size());
|
qDebug("We have %d children", children.size());
|
||||||
foreach(f, children) {
|
foreach(f, children) {
|
||||||
bool s = f->removeFromFS(saveDir);
|
bool s = f->removeFromFS(saveDir);
|
||||||
@ -169,16 +169,16 @@ class file {
|
|||||||
|
|
||||||
class arborescence {
|
class arborescence {
|
||||||
private:
|
private:
|
||||||
file *root;
|
torrent_file *root;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
arborescence(torrent_info t) {
|
arborescence(torrent_info t) {
|
||||||
torrent_info::file_iterator fi = t.begin_files();
|
torrent_info::file_iterator fi = t.begin_files();
|
||||||
if(t.num_files() > 1) {
|
if(t.num_files() > 1) {
|
||||||
root = new file(0, misc::toQString(t.name()), true);
|
root = new torrent_file(0, misc::toQString(t.name()), true);
|
||||||
} else {
|
} else {
|
||||||
// XXX: Will crash if there is no file in torrent
|
// XXX: Will crash if there is no file in torrent
|
||||||
root = new file(0, misc::toQString(t.name()), false, fi->size, 0);
|
root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -196,11 +196,11 @@ class arborescence {
|
|||||||
torrent_info::file_iterator fi = t.begin_files();
|
torrent_info::file_iterator fi = t.begin_files();
|
||||||
if(t.num_files() > 1) {
|
if(t.num_files() > 1) {
|
||||||
qDebug("More than one file in the torrent, setting a folder as root");
|
qDebug("More than one file in the torrent, setting a folder as root");
|
||||||
root = new file(0, misc::toQString(t.name()), true);
|
root = new torrent_file(0, misc::toQString(t.name()), true);
|
||||||
} else {
|
} else {
|
||||||
// XXX: Will crash if there is no file in torrent
|
// XXX: Will crash if there is no file in torrent
|
||||||
qDebug("one file in the torrent, setting it as root with index 0");
|
qDebug("one file in the torrent, setting it as root with index 0");
|
||||||
root = new file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0], prioritiesTab[0]);
|
root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0], prioritiesTab[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -218,7 +218,7 @@ class arborescence {
|
|||||||
delete root;
|
delete root;
|
||||||
}
|
}
|
||||||
|
|
||||||
file* getRoot() const {
|
torrent_file* getRoot() const {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,13 +240,13 @@ class arborescence {
|
|||||||
relative_path.remove(0, 1);
|
relative_path.remove(0, 1);
|
||||||
QStringList fileNames = relative_path.split(QDir::separator());
|
QStringList fileNames = relative_path.split(QDir::separator());
|
||||||
QString fileName;
|
QString fileName;
|
||||||
file *dad = root;
|
torrent_file *dad = root;
|
||||||
unsigned int nb_i = 0;
|
unsigned int nb_i = 0;
|
||||||
unsigned int size = fileNames.size();
|
unsigned int size = fileNames.size();
|
||||||
foreach(fileName, fileNames) {
|
foreach(fileName, fileNames) {
|
||||||
++nb_i;
|
++nb_i;
|
||||||
if(fileName == ".") continue;
|
if(fileName == ".") continue;
|
||||||
file* child = dad->getChild(fileName);
|
torrent_file* child = dad->getChild(fileName);
|
||||||
if(!child) {
|
if(!child) {
|
||||||
if(nb_i != size) {
|
if(nb_i != size) {
|
||||||
// Folder
|
// Folder
|
||||||
|
@ -143,7 +143,7 @@ properties::~properties(){
|
|||||||
delete progressBar;
|
delete progressBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void properties::addFilesToTree(file *root, QStandardItem *parent) {
|
void properties::addFilesToTree(torrent_file *root, QStandardItem *parent) {
|
||||||
QList<QStandardItem*> child;
|
QList<QStandardItem*> child;
|
||||||
// Name
|
// Name
|
||||||
QStandardItem *first;
|
QStandardItem *first;
|
||||||
@ -165,7 +165,7 @@ void properties::addFilesToTree(file *root, QStandardItem *parent) {
|
|||||||
// Add the child to the tree
|
// Add the child to the tree
|
||||||
parent->appendRow(child);
|
parent->appendRow(child);
|
||||||
// Add childs
|
// Add childs
|
||||||
file *childFile;
|
torrent_file *childFile;
|
||||||
foreach(childFile, root->getChildren()) {
|
foreach(childFile, root->getChildren()) {
|
||||||
addFilesToTree(childFile, first);
|
addFilesToTree(childFile, first);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class PropListDelegate;
|
|||||||
class QTimer;
|
class QTimer;
|
||||||
class bittorrent;
|
class bittorrent;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class file;
|
class torrent_file;
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
class RealProgressBar;
|
class RealProgressBar;
|
||||||
class RealProgressBarThread;
|
class RealProgressBarThread;
|
||||||
@ -73,7 +73,7 @@ class properties : public QDialog, private Ui::properties{
|
|||||||
void loadWebSeedsFromFile();
|
void loadWebSeedsFromFile();
|
||||||
void deleteSelectedUrlSeeds();
|
void deleteSelectedUrlSeeds();
|
||||||
void loadTrackersErrors();
|
void loadTrackersErrors();
|
||||||
void addFilesToTree(file *root, QStandardItem *parent);
|
void addFilesToTree(torrent_file *root, QStandardItem *parent);
|
||||||
void updateChildrenPriority(QStandardItem *item, int priority);
|
void updateChildrenPriority(QStandardItem *item, int priority);
|
||||||
void updateParentsPriority(QStandardItem *item, int priority);
|
void updateParentsPriority(QStandardItem *item, int priority);
|
||||||
void updatePriorities(QStandardItem *item);
|
void updatePriorities(QStandardItem *item);
|
||||||
|
@ -179,7 +179,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFilesToTree(file *root, QStandardItem *parent) {
|
void addFilesToTree(torrent_file *root, QStandardItem *parent) {
|
||||||
QList<QStandardItem*> child;
|
QList<QStandardItem*> child;
|
||||||
// Name
|
// Name
|
||||||
QStandardItem *first;
|
QStandardItem *first;
|
||||||
@ -201,7 +201,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
// Add the child to the tree
|
// Add the child to the tree
|
||||||
parent->appendRow(child);
|
parent->appendRow(child);
|
||||||
// Add childs
|
// Add childs
|
||||||
file *childFile;
|
torrent_file *childFile;
|
||||||
foreach(childFile, root->getChildren()) {
|
foreach(childFile, root->getChildren()) {
|
||||||
addFilesToTree(childFile, first);
|
addFilesToTree(childFile, first);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user