|
|
@ -68,8 +68,11 @@ const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY("SavePathHistory"); |
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
|
//just a shortcut
|
|
|
|
// just a shortcut
|
|
|
|
inline SettingsStorage *settings() { return SettingsStorage::instance(); } |
|
|
|
inline SettingsStorage *settings() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return SettingsStorage::instance(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) |
|
|
|
AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) |
|
|
@ -88,7 +91,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) |
|
|
|
auto session = BitTorrent::Session::instance(); |
|
|
|
auto session = BitTorrent::Session::instance(); |
|
|
|
|
|
|
|
|
|
|
|
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused()); |
|
|
|
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused()); |
|
|
|
ui->comboTTM->blockSignals(true); //the TreeView size isn't correct if the slot does it job at this point
|
|
|
|
ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
|
|
|
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); |
|
|
|
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); |
|
|
|
ui->comboTTM->blockSignals(false); |
|
|
|
ui->comboTTM->blockSignals(false); |
|
|
|
populateSavePathComboBox(); |
|
|
|
populateSavePathComboBox(); |
|
|
@ -181,9 +184,9 @@ void AddNewTorrentDialog::show(QString source, QWidget *parent) |
|
|
|
if (Utils::Misc::isUrl(source)) { |
|
|
|
if (Utils::Misc::isUrl(source)) { |
|
|
|
// Launch downloader
|
|
|
|
// Launch downloader
|
|
|
|
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); |
|
|
|
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); |
|
|
|
connect(handler, SIGNAL(downloadFinished(QString, QString)), dlg, SLOT(handleDownloadFinished(QString, QString))); |
|
|
|
connect(handler, SIGNAL(downloadFinished(QString,QString)), dlg, SLOT(handleDownloadFinished(QString,QString))); |
|
|
|
connect(handler, SIGNAL(downloadFailed(QString, QString)), dlg, SLOT(handleDownloadFailed(QString, QString))); |
|
|
|
connect(handler, SIGNAL(downloadFailed(QString,QString)), dlg, SLOT(handleDownloadFailed(QString,QString))); |
|
|
|
connect(handler, SIGNAL(redirectedToMagnet(QString, QString)), dlg, SLOT(handleRedirectedToMagnet(QString, QString))); |
|
|
|
connect(handler, SIGNAL(redirectedToMagnet(QString,QString)), dlg, SLOT(handleRedirectedToMagnet(QString,QString))); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
@ -309,7 +312,6 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event) |
|
|
|
raise(); |
|
|
|
raise(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddNewTorrentDialog::showAdvancedSettings(bool show) |
|
|
|
void AddNewTorrentDialog::showAdvancedSettings(bool show) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const int minimumW = minimumWidth(); |
|
|
|
const int minimumW = minimumWidth(); |
|
|
@ -319,7 +321,7 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show) |
|
|
|
ui->settings_group->setVisible(true); |
|
|
|
ui->settings_group->setVisible(true); |
|
|
|
ui->infoGroup->setVisible(true); |
|
|
|
ui->infoGroup->setVisible(true); |
|
|
|
ui->contentTreeView->setVisible(m_hasMetadata); |
|
|
|
ui->contentTreeView->setVisible(m_hasMetadata); |
|
|
|
static_cast<QVBoxLayout*>(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button); |
|
|
|
static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
ui->adv_button->setText(QString::fromUtf8(C_DOWN)); |
|
|
|
ui->adv_button->setText(QString::fromUtf8(C_DOWN)); |
|
|
@ -337,7 +339,7 @@ void AddNewTorrentDialog::saveSavePathHistory() const |
|
|
|
// Get current history
|
|
|
|
// Get current history
|
|
|
|
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList(); |
|
|
|
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList(); |
|
|
|
QList<QDir> historyDirs; |
|
|
|
QList<QDir> historyDirs; |
|
|
|
foreach(const QString dir, history) |
|
|
|
foreach (const QString dir, history) |
|
|
|
historyDirs << QDir(dir); |
|
|
|
historyDirs << QDir(dir); |
|
|
|
if (!historyDirs.contains(selectedSavePath)) { |
|
|
|
if (!historyDirs.contains(selectedSavePath)) { |
|
|
|
// Add save path to history
|
|
|
|
// Add save path to history
|
|
|
@ -502,7 +504,7 @@ void AddNewTorrentDialog::renameSelectedFile() |
|
|
|
QStringList path_items; |
|
|
|
QStringList path_items; |
|
|
|
path_items << index.data().toString(); |
|
|
|
path_items << index.data().toString(); |
|
|
|
QModelIndex parent = m_contentModel->parent(index); |
|
|
|
QModelIndex parent = m_contentModel->parent(index); |
|
|
|
while(parent.isValid()) { |
|
|
|
while (parent.isValid()) { |
|
|
|
path_items.prepend(parent.data().toString()); |
|
|
|
path_items.prepend(parent.data().toString()); |
|
|
|
parent = m_contentModel->parent(parent); |
|
|
|
parent = m_contentModel->parent(parent); |
|
|
|
} |
|
|
|
} |
|
|
@ -577,7 +579,7 @@ void AddNewTorrentDialog::populateSavePathComboBox() |
|
|
|
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath); |
|
|
|
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint&) |
|
|
|
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QMenu myFilesLlistMenu; |
|
|
|
QMenu myFilesLlistMenu; |
|
|
|
const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0); |
|
|
|
const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0); |
|
|
@ -620,7 +622,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint&) |
|
|
|
void AddNewTorrentDialog::accept() |
|
|
|
void AddNewTorrentDialog::accept() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_hasMetadata) |
|
|
|
if (!m_hasMetadata) |
|
|
|
disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo &))); |
|
|
|
disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo&))); |
|
|
|
|
|
|
|
|
|
|
|
BitTorrent::AddTorrentParams params; |
|
|
|
BitTorrent::AddTorrentParams params; |
|
|
|
|
|
|
|
|
|
|
@ -720,8 +722,8 @@ void AddNewTorrentDialog::setupTreeview() |
|
|
|
ui->contentTreeView->setModel(m_contentModel); |
|
|
|
ui->contentTreeView->setModel(m_contentModel); |
|
|
|
m_contentDelegate = new PropListDelegate(nullptr); |
|
|
|
m_contentDelegate = new PropListDelegate(nullptr); |
|
|
|
ui->contentTreeView->setItemDelegate(m_contentDelegate); |
|
|
|
ui->contentTreeView->setItemDelegate(m_contentDelegate); |
|
|
|
connect(ui->contentTreeView, SIGNAL(clicked(const QModelIndex &)), ui->contentTreeView, SLOT(edit(const QModelIndex &))); |
|
|
|
connect(ui->contentTreeView, SIGNAL(clicked(const QModelIndex&)), ui->contentTreeView, SLOT(edit(const QModelIndex&))); |
|
|
|
connect(ui->contentTreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayContentTreeMenu(const QPoint &))); |
|
|
|
connect(ui->contentTreeView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentTreeMenu(const QPoint&))); |
|
|
|
|
|
|
|
|
|
|
|
// List files in torrent
|
|
|
|
// List files in torrent
|
|
|
|
m_contentModel->model()->setupModelData(m_torrentInfo); |
|
|
|
m_contentModel->model()->setupModelData(m_torrentInfo); |
|
|
|