Browse Source

- Attempt to fix compilation on vc++

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
8b576fcc50
  1. 42
      src/arborescence.h
  2. 4
      src/properties_imp.cpp
  3. 4
      src/properties_imp.h
  4. 4
      src/torrentAddition.h

42
src/arborescence.h

@ -27,19 +27,19 @@ @@ -27,19 +27,19 @@
#include <QDir>
#include "misc.h"
class file {
class torrent_file {
private:
file *parent;
torrent_file *parent;
bool is_dir;
QString rel_path;
QList<file*> children;
QList<torrent_file*> children;
size_type size;
float progress;
int priority;
int index; // Index in torrent_info
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);
rel_path = QDir::cleanPath(path);
if(parent) {
@ -48,7 +48,7 @@ class file { @@ -48,7 +48,7 @@ class file {
}
}
~file() {
~torrent_file() {
qDeleteAll(children);
}
@ -68,7 +68,7 @@ class file { @@ -68,7 +68,7 @@ class file {
}
float wanted = 0.;
float done = 0.;
file *child;
torrent_file *child;
foreach(child, children) {
wanted += child->getSize();
done += child->getSize()*child->getProgress();
@ -80,7 +80,7 @@ class file { @@ -80,7 +80,7 @@ class file {
void updatePriority(int prio) {
Q_ASSERT(is_dir);
file *child;
torrent_file *child;
foreach(child, children) {
if(child->getPriority() != prio) return;
}
@ -111,13 +111,13 @@ class file { @@ -111,13 +111,13 @@ class file {
return (!children.isEmpty());
}
QList<file*> getChildren() const {
QList<torrent_file*> getChildren() const {
return children;
}
file* getChild(QString fileName) const {
torrent_file* getChild(QString fileName) const {
Q_ASSERT(is_dir);
file* f;
torrent_file* f;
foreach(f, children) {
if(f->name() == fileName) return f;
}
@ -130,10 +130,10 @@ class file { @@ -130,10 +130,10 @@ class file {
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);
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;
if(size) {
addBytes(size);
@ -148,7 +148,7 @@ class file { @@ -148,7 +148,7 @@ class file {
return true;
}
bool success = true;
file *f;
torrent_file *f;
qDebug("We have %d children", children.size());
foreach(f, children) {
bool s = f->removeFromFS(saveDir);
@ -169,16 +169,16 @@ class file { @@ -169,16 +169,16 @@ class file {
class arborescence {
private:
file *root;
torrent_file *root;
public:
arborescence(torrent_info t) {
torrent_info::file_iterator fi = t.begin_files();
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 {
// 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;
}
int i = 0;
@ -196,11 +196,11 @@ class arborescence { @@ -196,11 +196,11 @@ class arborescence {
torrent_info::file_iterator fi = t.begin_files();
if(t.num_files() > 1) {
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 {
// XXX: Will crash if there is no file in torrent
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;
}
int i = 0;
@ -218,7 +218,7 @@ class arborescence { @@ -218,7 +218,7 @@ class arborescence {
delete root;
}
file* getRoot() const {
torrent_file* getRoot() const {
return root;
}
@ -240,13 +240,13 @@ class arborescence { @@ -240,13 +240,13 @@ class arborescence {
relative_path.remove(0, 1);
QStringList fileNames = relative_path.split(QDir::separator());
QString fileName;
file *dad = root;
torrent_file *dad = root;
unsigned int nb_i = 0;
unsigned int size = fileNames.size();
foreach(fileName, fileNames) {
++nb_i;
if(fileName == ".") continue;
file* child = dad->getChild(fileName);
torrent_file* child = dad->getChild(fileName);
if(!child) {
if(nb_i != size) {
// Folder

4
src/properties_imp.cpp

@ -143,7 +143,7 @@ properties::~properties(){ @@ -143,7 +143,7 @@ properties::~properties(){
delete progressBar;
}
void properties::addFilesToTree(file *root, QStandardItem *parent) {
void properties::addFilesToTree(torrent_file *root, QStandardItem *parent) {
QList<QStandardItem*> child;
// Name
QStandardItem *first;
@ -165,7 +165,7 @@ void properties::addFilesToTree(file *root, QStandardItem *parent) { @@ -165,7 +165,7 @@ void properties::addFilesToTree(file *root, QStandardItem *parent) {
// Add the child to the tree
parent->appendRow(child);
// Add childs
file *childFile;
torrent_file *childFile;
foreach(childFile, root->getChildren()) {
addFilesToTree(childFile, first);
}

4
src/properties_imp.h

@ -29,7 +29,7 @@ class PropListDelegate; @@ -29,7 +29,7 @@ class PropListDelegate;
class QTimer;
class bittorrent;
class QStandardItemModel;
class file;
class torrent_file;
class QStandardItem;
class RealProgressBar;
class RealProgressBarThread;
@ -73,7 +73,7 @@ class properties : public QDialog, private Ui::properties{ @@ -73,7 +73,7 @@ class properties : public QDialog, private Ui::properties{
void loadWebSeedsFromFile();
void deleteSelectedUrlSeeds();
void loadTrackersErrors();
void addFilesToTree(file *root, QStandardItem *parent);
void addFilesToTree(torrent_file *root, QStandardItem *parent);
void updateChildrenPriority(QStandardItem *item, int priority);
void updateParentsPriority(QStandardItem *item, int priority);
void updatePriorities(QStandardItem *item);

4
src/torrentAddition.h

@ -179,7 +179,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -179,7 +179,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
show();
}
void addFilesToTree(file *root, QStandardItem *parent) {
void addFilesToTree(torrent_file *root, QStandardItem *parent) {
QList<QStandardItem*> child;
// Name
QStandardItem *first;
@ -201,7 +201,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -201,7 +201,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
// Add the child to the tree
parent->appendRow(child);
// Add childs
file *childFile;
torrent_file *childFile;
foreach(childFile, root->getChildren()) {
addFilesToTree(childFile, first);
}

Loading…
Cancel
Save