Fixed file filtering in a torrent

This commit is contained in:
Christophe Dumez 2007-07-03 22:39:49 +00:00
parent b1ed521d6b
commit 107d2c8e7b
4 changed files with 112 additions and 112 deletions

3
TODO
View file

@ -46,5 +46,4 @@
- Allow to scan multiple directories - Allow to scan multiple directories
- Fix all (or almost all) opened bugs in bug tracker - Fix all (or almost all) opened bugs in bug tracker
- Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix - Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix
- update sorting when a new torrent is added - update sorting when a new torrent is added
- fix file filtering in a torrent

View file

@ -112,7 +112,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png"))); actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png")));
actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png"))); actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png")));
actionCreate_torrent->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/new.png"))); actionCreate_torrent->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/new.png")));
info_icon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/log.png"))); tabBottom->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/log.png")));
tabs->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))); tabs->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
// Set default ratio // Set default ratio
lbl_ratio_icon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/stare.png"))); lbl_ratio_icon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/stare.png")));

View file

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>849</width> <width>849</width>
<height>576</height> <height>566</height>
</rect> </rect>
</property> </property>
<property name="contextMenuPolicy" > <property name="contextMenuPolicy" >
@ -17,12 +17,21 @@
</property> </property>
<widget class="QWidget" name="centralwidget" > <widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QTabWidget" name="tabs" > <widget class="QTabWidget" name="tabs" >
<property name="tabPosition" > <property name="tabPosition" >
@ -36,28 +45,40 @@
<string>Downloads</string> <string>Downloads</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -231,6 +252,12 @@
</item> </item>
<item> <item>
<widget class="QTreeView" name="downloadList" > <widget class="QTreeView" name="downloadList" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>238</height>
</size>
</property>
<property name="contextMenuPolicy" > <property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
@ -251,101 +278,70 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <widget class="QTabWidget" name="tabBottom" >
<property name="margin" > <property name="tabPosition" >
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex" >
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <widget class="QWidget" name="log_tab" >
<number>6</number> <attribute name="title" >
</property> <string>Log</string>
<item> </attribute>
<layout class="QHBoxLayout" > <widget class="QWidget" name="" >
<property name="margin" > <property name="geometry" >
<number>0</number> <rect>
</property> <x>0</x>
<property name="spacing" > <y>-10</y>
<number>6</number> <width>809</width>
</property> <height>153</height>
<item> </rect>
<widget class="QLabel" name="info_icon" >
<property name="minimumSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_info" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Log:</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>661</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="infoBar" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>123</height>
</size>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property> </property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="infoBar" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>123</height>
</size>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </widget>
</layout> <widget class="QWidget" name="filter_tab" >
<attribute name="title" >
<string>IP filter</string>
</attribute>
</widget>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -426,7 +422,10 @@
</size> </size>
</property> </property>
<attribute name="toolBarArea" > <attribute name="toolBarArea" >
<number>4</number> <enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak" >
<bool>false</bool>
</attribute> </attribute>
<addaction name="actionOpen" /> <addaction name="actionOpen" />
<addaction name="actionDownload_from_URL" /> <addaction name="actionDownload_from_URL" />

View file

@ -427,14 +427,16 @@ void bittorrent::loadFilteredFiles(torrent_handle &h){
std::cerr << "* Error: Corrupted priorities file\n"; std::cerr << "* Error: Corrupted priorities file\n";
return; return;
} }
std::vector<int> v;
for(unsigned int i=0; i<nbFiles; ++i){ for(unsigned int i=0; i<nbFiles; ++i){
int priority = pieces_priorities_list.at(i).toInt(); int priority = pieces_priorities_list.at(i).toInt();
if( priority < 0 || priority > 7){ if( priority < 0 || priority > 7){
priority = 1; priority = 1;
} }
qDebug("Setting piece piority to %d", priority); qDebug("Setting piece piority to %d", priority);
h.piece_priority(i, priority); v.push_back(priority);
} }
h.prioritize_files(v);
} }
// Save fastresume data for all torrents // Save fastresume data for all torrents