Browse Source

- Improved a lot the torrent creation module

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
ff0dd88ee1
  1. 1
      Changelog
  2. 5
      TODO
  3. 829
      src/createtorrent.ui
  4. 131
      src/createtorrent_imp.cpp
  5. 9
      src/createtorrent_imp.h

1
Changelog

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
- FEATURE: Allow user to change qBT's style (Plastique, Cleanlooks, Motif, CDE, MacOSX, WinXP)
- FEATURE: Allow the user to disable system tray integration
- FEATURE: Search engine is now using one thread per website for faster results
- FEATURE: Improved a lot the torrent creation module
- FEATURE: Ask for exit confirmation only if download list is not empty
- BUGFIX: Window can now stay maximized on exit
- COSMETIC: Redesigned torrent properties a little

5
TODO

@ -32,10 +32,7 @@ @@ -32,10 +32,7 @@
// in v0.10 (partial) - WIP
- Download from RSS feeds (WIP by gtsoul, clean & finish rss.h, add a tab in mainWindow, debug)
- Move finished torrent to another tab and keep on seeding them even after restart (debug)
- Improve torrent creation dialog (look & features) :
- Add Private combobox (allow to share on DHT or not)
- Use a QListWidget to allow multiple input paths
- Possibility to add url seeds
- Check storage st creation + hasher in torrent creation
- Add IPv6 support (at least start working on it, libtorrent seems to support it, we should limit our code to IPv4 anymore)
- Display Url seeds in torrent properties and allow to edit them
- Use tooltips to explain options?

829
src/createtorrent.ui

@ -1,258 +1,607 @@ @@ -1,258 +1,607 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>createTorrentDialog</class>
<widget class="QDialog" name="createTorrentDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>307</height>
<width>605</width>
<height>588</height>
</rect>
</property>
<property name="windowTitle" >
<string>Torrent Creation Tool</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
<widget class="QLabel" name="createTorrent_title" >
<property name="geometry" >
<rect>
<x>9</x>
<y>9</y>
<width>587</width>
<height>27</height>
</rect>
</property>
<property name="spacing" >
<number>6</number>
<property name="minimumSize" >
<size>
<width>0</width>
<height>27</height>
</size>
</property>
<item>
<widget class="QLabel" name="createTorrent_title" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>27</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>27</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Create Torrent file</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_destination" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Destination torrent file:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_destination</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_input" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Input file or directory:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_input</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_announce_url" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Announce url:&lt;br>(One per line)&lt;/center></string>
</property>
<property name="buddy" >
<cstring></cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_comment" >
<property name="text" >
<string>&lt;center>Comment:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_comment</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="txt_destination" />
</item>
<item>
<widget class="QToolButton" name="browse_destination" >
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="txt_input" />
</item>
<item>
<widget class="QCheckBox" name="checkDirectory" >
<property name="text" >
<string>Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="browse_input" >
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="txt_announce" />
</item>
<item>
<widget class="QTextEdit" name="txt_comment" >
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createButton" >
<property name="text" >
<string>Create</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>27</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Torrent file creation</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>9</x>
<y>42</y>
<width>587</width>
<height>438</height>
</rect>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_input" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>101</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>Input files or directories:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_announce_url" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>102</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="text" >
<string>Announce urls (trackers):</string>
</property>
<property name="buddy" >
<cstring></cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="urlSeeds_lbl" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>101</height>
</size>
</property>
<property name="text" >
<string>URL seeds (optional):</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_comment" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>102</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>102</height>
</size>
</property>
<property name="text" >
<string>Comment (optional):</string>
</property>
<property name="buddy" >
<cstring>txt_comment</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QListWidget" name="input_list" >
<property name="selectionMode" >
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addFolder_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeFolder_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addFile_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QListWidget" name="trackers_list" >
<property name="selectionMode" >
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addTracker_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeTracker_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QListWidget" name="URLSeeds_list" >
<property name="selectionMode" >
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addURLSeed_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeURLSeed_button" >
<property name="minimumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="txt_comment" >
<property name="minimumSize" >
<size>
<width>421</width>
<height>102</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>421</width>
<height>102</height>
</size>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QCheckBox" name="check_private" >
<property name="geometry" >
<rect>
<x>9</x>
<y>482</y>
<width>587</width>
<height>22</height>
</rect>
</property>
<property name="text" >
<string>Private (won't be distributed on trackerless network / DHT if enabled)</string>
</property>
</widget>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>9</x>
<y>510</y>
<width>587</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_destination" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>Destination torrent file:</string>
</property>
<property name="buddy" >
<cstring>txt_destination</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="txt_destination" />
</item>
<item>
<widget class="QToolButton" name="browse_destination" >
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>9</x>
<y>546</y>
<width>587</width>
<height>33</height>
</rect>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createButton" >
<property name="text" >
<string>Create</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>

131
src/createtorrent_imp.cpp

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
@ -41,6 +42,14 @@ using namespace boost::filesystem; @@ -41,6 +42,14 @@ using namespace boost::filesystem;
createtorrent::createtorrent(QWidget *parent): QDialog(parent){
setupUi(this);
addTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
removeTracker_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
addURLSeed_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
removeURLSeed_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
removeFolder_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
//TODO: Change those two
addFolder_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
addFile_button->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
setAttribute(Qt::WA_DeleteOnClose);
show();
}
@ -48,23 +57,71 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){ @@ -48,23 +57,71 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){
void createtorrent::on_browse_destination_clicked(){
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+" (*.torrent)");
if(!destination.isEmpty()){
if(!destination.endsWith(".torrent"))
destination += ".torrent";
txt_destination->setText(destination);
}
}
void createtorrent::on_browse_input_clicked(){
// Can't use QFileDialog static functions for this because
// user can select a file or a directory
QFileDialog *fd = new QFileDialog(this, tr("Select input directory or file"), QDir::homePath());
if(checkDirectory->isChecked()){
fd->setFileMode(QFileDialog::DirectoryOnly);
}else{
fd->setFileMode(QFileDialog::ExistingFile);
void createtorrent::on_addFolder_button_clicked(){
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), QDir::homePath(), QFileDialog::ShowDirsOnly);
if(!dir.isEmpty() && input_list->findItems(dir, Qt::MatchCaseSensitive).size() == 0)
input_list->addItem(dir);
}
void createtorrent::on_addFile_button_clicked(){
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select files to add to the torrent"), QDir::homePath(), QString(), 0, QFileDialog::ShowDirsOnly);
QString file;
foreach(file, files){
if(input_list->findItems(file, Qt::MatchCaseSensitive).size() == 0){
input_list->addItem(file);
}
}
}
void createtorrent::on_removeFolder_button_clicked(){
QModelIndexList selectedIndexes = input_list->selectionModel()->selectedIndexes();
for(int i=selectedIndexes.size()-1; i>=0; --i){
QListWidgetItem *item = input_list->takeItem(selectedIndexes.at(i).row());
delete item;
}
}
void createtorrent::on_removeTracker_button_clicked(){
QModelIndexList selectedIndexes = trackers_list->selectionModel()->selectedIndexes();
for(int i=selectedIndexes.size()-1; i>=0; --i){
QListWidgetItem *item = trackers_list->takeItem(selectedIndexes.at(i).row());
delete item;
}
}
void createtorrent::on_addTracker_button_clicked(){
bool ok;
QString URL = QInputDialog::getText(this, tr("Please type an announce URL"),
tr("Announce URL:"), QLineEdit::Normal,
"http://", &ok);
if(ok){
if(trackers_list->findItems(URL, Qt::MatchFixedString).size() == 0)
trackers_list->addItem(URL);
}
}
void createtorrent::on_removeURLSeed_button_clicked(){
QModelIndexList selectedIndexes = URLSeeds_list->selectionModel()->selectedIndexes();
for(int i=selectedIndexes.size()-1; i>=0; --i){
QListWidgetItem *item = URLSeeds_list->takeItem(selectedIndexes.at(i).row());
delete item;
}
QStringList fileNames;
if (fd->exec()){
fileNames = fd->selectedFiles();
txt_input->setText(fileNames.first());
}
void createtorrent::on_addURLSeed_button_clicked(){
bool ok;
QString URL = QInputDialog::getText(this, tr("Please type an URL Seed"),
tr("URL Seed:"), QLineEdit::Normal,
"http://", &ok);
if(ok){
if(URLSeeds_list->findItems(URL, Qt::MatchFixedString).size() == 0)
URLSeeds_list->addItem(URL);
}
}
@ -80,6 +137,15 @@ void add_files(torrent_info& t, path const& p, path const& l){ @@ -80,6 +137,15 @@ void add_files(torrent_info& t, path const& p, path const& l){
}
}
QStringList createtorrent::allItems(QListWidget *list){
QStringList res;
unsigned int nbItems = list->count();
for(unsigned int i=0; i< nbItems; ++i){
res << list->item(i)->text();
}
return res;
}
// Main function that create a .torrent file
void createtorrent::on_createButton_clicked(){
QString destination = txt_destination->text();
@ -87,37 +153,40 @@ void createtorrent::on_createButton_clicked(){ @@ -87,37 +153,40 @@ void createtorrent::on_createButton_clicked(){
QMessageBox::critical(0, tr("No destination path set"), tr("Please type a destination path first"));
return;
}
QString input = txt_input->text();
if(input.isEmpty()){
QStringList input = allItems(input_list);
if(input.size() == 0){
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
return;
}
if(!QFile::exists(input)){
QMessageBox::critical(0, tr("Input path does not exist"), tr("Please type a valid input path first"));
return;
}
char const* creator_str = "qBittorrent";
int piece_size = 256 * 1024;
char const* creator_str = "qBittorrent "VERSION;
try {
torrent_info t;
path full_path = complete(path((const char*)input.toUtf8()));
QString input_path;
path full_path;
ofstream out(complete(path((const char*)destination.toUtf8())), std::ios_base::binary);
add_files(t, full_path.branch_path(), full_path.leaf());
foreach(input_path, input){
full_path = complete(path((const char*)input_path.toUtf8()));
add_files(t, full_path.branch_path(), full_path.leaf());
}
int piece_size = 256 * 1024;
t.set_piece_size(piece_size);
file_pool fp;
storage st(t, full_path.branch_path(), fp);
QStringList trackers = txt_announce->toPlainText().split('\n');
// Add url seeds
QStringList urlSeeds = allItems(URLSeeds_list);
QString seed;
foreach(seed, urlSeeds){
t.add_url_seed((const char*)seed.toUtf8());
}
QStringList trackers = allItems(trackers_list);
for(int i=0; i<trackers.size(); ++i){
t.add_tracker((const char*)trackers.at(i).toUtf8());
}
// calculate the hash for all pieces
file_pool fp;
storage st(t, full_path.branch_path(), fp);
int num = t.num_pieces();
std::vector<char> buf(piece_size);
for (int i = 0; i < num; ++i)
{
for (int i = 0; i < num; ++i) {
st.read(&buf[0], i, 0, t.piece_size(i));
hasher h(&buf[0], t.piece_size(i));
t.set_hash(i, h.final());
@ -126,6 +195,10 @@ void createtorrent::on_createButton_clicked(){ @@ -126,6 +195,10 @@ void createtorrent::on_createButton_clicked(){
// torrent_info structure
t.set_creator(creator_str);
t.set_comment((const char*)txt_comment->toPlainText().toUtf8());
// Is private ?
if(check_private->isChecked()){
t.set_priv(true);
}
// create the torrent and print it to out
entry e = t.create_torrent();
libtorrent::bencode(std::ostream_iterator<char>(out), e);

9
src/createtorrent_imp.h

@ -30,11 +30,18 @@ class createtorrent : public QDialog, private Ui::createTorrentDialog{ @@ -30,11 +30,18 @@ class createtorrent : public QDialog, private Ui::createTorrentDialog{
public:
createtorrent(QWidget *parent = 0);
QStringList allItems(QListWidget *list);
protected slots:
void on_browse_destination_clicked();
void on_browse_input_clicked();
void on_createButton_clicked();
void on_addFile_button_clicked();
void on_addFolder_button_clicked();
void on_removeFolder_button_clicked();
void on_addTracker_button_clicked();
void on_removeTracker_button_clicked();
void on_addURLSeed_button_clicked();
void on_removeURLSeed_button_clicked();
};
#endif

Loading…
Cancel
Save