mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Coding style clean up
This commit is contained in:
@@ -91,7 +91,7 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
|
||||
|
||||
appendLabelToSavePath = pref.appendTorrentLabel();
|
||||
QString display_path = defaultSavePath.replace("\\", "/");
|
||||
if(!display_path.endsWith("/"))
|
||||
if (!display_path.endsWith("/"))
|
||||
display_path += "/";
|
||||
path_history << display_path;
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
@@ -99,7 +99,7 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
|
||||
#endif
|
||||
savePathTxt->addItem(display_path);
|
||||
|
||||
if(pref.addTorrentsInPause()) {
|
||||
if (pref.addTorrentsInPause()) {
|
||||
addInPause->setChecked(true);
|
||||
//addInPause->setEnabled(false);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
|
||||
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
|
||||
const QStringList customLabels = settings.value("customLabels", QStringList()).toStringList();
|
||||
comboLabel->addItem("");
|
||||
foreach(const QString& label, customLabels) {
|
||||
foreach (const QString& label, customLabels) {
|
||||
comboLabel->addItem(label);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ void torrentAdditionDialog::readSettings() {
|
||||
}
|
||||
}
|
||||
if (m_showContentList) {
|
||||
if(!torrentContentList->header()->restoreState(settings.value("TorrentAdditionDlg/ContentHeaderState").toByteArray())) {
|
||||
if (!torrentContentList->header()->restoreState(settings.value("TorrentAdditionDlg/ContentHeaderState").toByteArray())) {
|
||||
qDebug() << Q_FUNC_INFO << "First executation, resize first section to 400px...";
|
||||
torrentContentList->header()->resizeSection(0, 400); // Default
|
||||
}
|
||||
@@ -162,16 +162,16 @@ void torrentAdditionDialog::limitDialogWidth() {
|
||||
int scrn = 0;
|
||||
const QWidget *w = this->window();
|
||||
|
||||
if(w)
|
||||
if (w)
|
||||
scrn = QApplication::desktop()->screenNumber(w);
|
||||
else if(QApplication::desktop()->isVirtualDesktop())
|
||||
else if (QApplication::desktop()->isVirtualDesktop())
|
||||
scrn = QApplication::desktop()->screenNumber(QCursor::pos());
|
||||
else
|
||||
scrn = QApplication::desktop()->screenNumber(this);
|
||||
|
||||
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
||||
int max_width = desk.width();
|
||||
if(max_width > 0)
|
||||
if (max_width > 0)
|
||||
setMaximumWidth(max_width);
|
||||
}
|
||||
|
||||
@@ -179,12 +179,12 @@ void torrentAdditionDialog::hideTorrentContent() {
|
||||
// Disable useless widgets
|
||||
torrentContentList->setVisible(false);
|
||||
//torrentContentLbl->setVisible(false);
|
||||
for(int i=0; i<selectionBtnsLayout->count(); ++i) {
|
||||
if(selectionBtnsLayout->itemAt(i)->widget())
|
||||
for (int i=0; i<selectionBtnsLayout->count(); ++i) {
|
||||
if (selectionBtnsLayout->itemAt(i)->widget())
|
||||
selectionBtnsLayout->itemAt(i)->widget()->setVisible(false);
|
||||
}
|
||||
for(int i=0; i<contentFilterLayout->count(); ++i) {
|
||||
if(contentFilterLayout->itemAt(i)->widget())
|
||||
for (int i=0; i<contentFilterLayout->count(); ++i) {
|
||||
if (contentFilterLayout->itemAt(i)->widget())
|
||||
contentFilterLayout->itemAt(i)->widget()->setVisible(false);
|
||||
}
|
||||
contentFilterLayout->update();
|
||||
@@ -204,13 +204,13 @@ void torrentAdditionDialog::showLoadMagnetURI(QString magnet_uri) {
|
||||
|
||||
// Get torrent hash
|
||||
hash = misc::magnetUriToHash(magnet_uri);
|
||||
if(hash.isEmpty()) {
|
||||
if (hash.isEmpty()) {
|
||||
QBtSession::instance()->addConsoleMessage(tr("Unable to decode magnet link:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
|
||||
return;
|
||||
}
|
||||
// Set torrent name
|
||||
fileName = misc::magnetUriToName(magnet_uri);
|
||||
if(fileName.isEmpty()) {
|
||||
if (fileName.isEmpty()) {
|
||||
fileName = tr("Magnet Link");
|
||||
}
|
||||
fileNameLbl->setText(QString::fromUtf8("<center><b>")+fileName+QString::fromUtf8("</b></center>"));
|
||||
@@ -234,10 +234,10 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
is_magnet = false;
|
||||
|
||||
// This is an URL to a local file, switch to local path
|
||||
if(filePath.startsWith("file:", Qt::CaseInsensitive))
|
||||
if (filePath.startsWith("file:", Qt::CaseInsensitive))
|
||||
filePath = QUrl::fromEncoded(filePath.toLocal8Bit()).toLocalFile();
|
||||
|
||||
if(!QFile::exists(filePath)) {
|
||||
if (!QFile::exists(filePath)) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
@@ -249,11 +249,11 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
// Getting torrent file informations
|
||||
try {
|
||||
t = new torrent_info(filePath.toUtf8().data());
|
||||
if(!t->is_valid())
|
||||
if (!t->is_valid())
|
||||
throw std::exception();
|
||||
} catch(std::exception&) {
|
||||
qDebug("Caught error loading torrent");
|
||||
if(!from_url.isNull()){
|
||||
if (!from_url.isNull()){
|
||||
QBtSession::instance()->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
|
||||
QFile::remove(filePath);
|
||||
}else{
|
||||
@@ -263,7 +263,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
return;
|
||||
}
|
||||
nbFiles = t->num_files();
|
||||
if(nbFiles == 0) {
|
||||
if (nbFiles == 0) {
|
||||
// Empty torrent file!?
|
||||
close();
|
||||
return;
|
||||
@@ -278,18 +278,18 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
hash = misc::toQString(t->info_hash());
|
||||
// Use left() to remove .old extension
|
||||
QString newFileName;
|
||||
if(fileName.endsWith(QString::fromUtf8(".old"))){
|
||||
if (fileName.endsWith(QString::fromUtf8(".old"))){
|
||||
newFileName = fileName.left(fileName.size()-4);
|
||||
}else{
|
||||
newFileName = fileName;
|
||||
}
|
||||
fileNameLbl->setText(QString::fromUtf8("<center><b>")+newFileName+QString::fromUtf8("</b></center>"));
|
||||
if(t->num_files() > 1) {
|
||||
if (t->num_files() > 1) {
|
||||
// List files in torrent
|
||||
PropListModel->model()->setupModelData(*t);
|
||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(updateDiskSpaceLabels()));
|
||||
// Loads files path in the torrent
|
||||
for(uint i=0; i<nbFiles; ++i) {
|
||||
for (uint i=0; i<nbFiles; ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
files_path << misc::toQStringU(fs.file_path(t->file_at(i)));
|
||||
#else
|
||||
@@ -310,13 +310,13 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
save_path.replace("/", "\\");
|
||||
#endif
|
||||
if(!save_path.endsWith(QDir::separator()))
|
||||
if (!save_path.endsWith(QDir::separator()))
|
||||
save_path += QDir::separator();
|
||||
// If the torrent has a root folder, append it to the save path
|
||||
if(!root_folder.isEmpty()) {
|
||||
if (!root_folder.isEmpty()) {
|
||||
save_path += root_folder;
|
||||
}
|
||||
if(nbFiles == 1) {
|
||||
if (nbFiles == 1) {
|
||||
// single file torrent
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
QString single_file_relpath = misc::toQStringU(fs.file_path(t->file_at(0)));
|
||||
@@ -334,7 +334,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
||||
updateDiskSpaceLabels();
|
||||
|
||||
// Hide useless widgets
|
||||
if(t->num_files() <= 1)
|
||||
if (t->num_files() <= 1)
|
||||
hideTorrentContent();
|
||||
|
||||
// Remember dialog geometry
|
||||
@@ -352,7 +352,7 @@ void torrentAdditionDialog::displayContentListMenu(const QPoint&) {
|
||||
QMenu myFilesLlistMenu;
|
||||
const QModelIndexList selectedRows = torrentContentList->selectionModel()->selectedRows(0);
|
||||
QAction *actRename = 0;
|
||||
if(selectedRows.size() == 1 && t->num_files() > 1) {
|
||||
if (selectedRows.size() == 1 && t->num_files() > 1) {
|
||||
actRename = myFilesLlistMenu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
|
||||
myFilesLlistMenu.addSeparator();
|
||||
}
|
||||
@@ -365,24 +365,24 @@ void torrentAdditionDialog::displayContentListMenu(const QPoint&) {
|
||||
myFilesLlistMenu.addMenu(&subMenu);
|
||||
// Call menu
|
||||
QAction *act = myFilesLlistMenu.exec(QCursor::pos());
|
||||
if(act) {
|
||||
if(act == actRename) {
|
||||
if (act) {
|
||||
if (act == actRename) {
|
||||
renameSelectedFile();
|
||||
} else {
|
||||
int prio = 1;
|
||||
if(act == actionHigh) {
|
||||
if (act == actionHigh) {
|
||||
prio = prio::HIGH;
|
||||
} else {
|
||||
if(act == actionMaximum) {
|
||||
if (act == actionMaximum) {
|
||||
prio = prio::MAXIMUM;
|
||||
} else {
|
||||
if(act == actionNot_downloaded) {
|
||||
if (act == actionNot_downloaded) {
|
||||
prio = prio::IGNORED;
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug("Setting files priority");
|
||||
foreach(const QModelIndex &index, selectedRows) {
|
||||
foreach (const QModelIndex &index, selectedRows) {
|
||||
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
||||
PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio);
|
||||
}
|
||||
@@ -401,13 +401,13 @@ void torrentAdditionDialog::renameSelectedFile() {
|
||||
tr("New name:"), QLineEdit::Normal,
|
||||
index.data().toString(), &ok);
|
||||
if (ok && !new_name_last.isEmpty()) {
|
||||
if(!misc::isValidFileSystemName(new_name_last)) {
|
||||
if (!misc::isValidFileSystemName(new_name_last)) {
|
||||
QMessageBox::warning(this, tr("The file could not be renamed"),
|
||||
tr("This file name contains forbidden characters, please choose a different one."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
if(PropListModel->getType(index) == TorrentFileItem::TFILE) {
|
||||
if (PropListModel->getType(index) == TorrentFileItem::TFILE) {
|
||||
// File renaming
|
||||
const uint file_index = PropListModel->getFileIndex(index);
|
||||
QString old_name = files_path.at(file_index);
|
||||
@@ -417,19 +417,19 @@ void torrentAdditionDialog::renameSelectedFile() {
|
||||
path_items.removeLast();
|
||||
path_items << new_name_last;
|
||||
QString new_name = path_items.join("/");
|
||||
if(old_name == new_name) {
|
||||
if (old_name == new_name) {
|
||||
qDebug("Name did not change");
|
||||
return;
|
||||
}
|
||||
new_name = QDir::cleanPath(new_name);
|
||||
qDebug("New name: %s", qPrintable(new_name));
|
||||
// Check if that name is already used
|
||||
for(uint i=0; i<nbFiles; ++i) {
|
||||
if(i == file_index) continue;
|
||||
for (uint i=0; i<nbFiles; ++i) {
|
||||
if (i == file_index) continue;
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
if(files_path.at(i).compare(new_name, Qt::CaseSensitive) == 0) {
|
||||
if (files_path.at(i).compare(new_name, Qt::CaseSensitive) == 0) {
|
||||
#else
|
||||
if(files_path.at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
|
||||
if (files_path.at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
|
||||
#endif
|
||||
// Display error message
|
||||
QMessageBox::warning(this, tr("The file could not be renamed"),
|
||||
@@ -457,14 +457,14 @@ void torrentAdditionDialog::renameSelectedFile() {
|
||||
path_items.removeLast();
|
||||
path_items << new_name_last;
|
||||
QString new_path = path_items.join("/");
|
||||
if(!new_path.endsWith("/")) new_path += "/";
|
||||
if (!new_path.endsWith("/")) new_path += "/";
|
||||
// Check for overwriting
|
||||
for(uint i=0; i<nbFiles; ++i) {
|
||||
for (uint i=0; i<nbFiles; ++i) {
|
||||
const QString ¤t_name = files_path.at(i);
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
if(current_name.startsWith(new_path, Qt::CaseSensitive)) {
|
||||
if (current_name.startsWith(new_path, Qt::CaseSensitive)) {
|
||||
#else
|
||||
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
||||
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
||||
#endif
|
||||
QMessageBox::warning(this, tr("The folder could not be renamed"),
|
||||
tr("This name is already in use in this folder. Please use a different name."),
|
||||
@@ -473,9 +473,9 @@ void torrentAdditionDialog::renameSelectedFile() {
|
||||
}
|
||||
}
|
||||
// Replace path in all files
|
||||
for(uint i=0; i<nbFiles; ++i) {
|
||||
for (uint i=0; i<nbFiles; ++i) {
|
||||
const QString ¤t_name = files_path.at(i);
|
||||
if(current_name.startsWith(old_path)) {
|
||||
if (current_name.startsWith(old_path)) {
|
||||
QString new_name = current_name;
|
||||
new_name.replace(0, old_path.length(), new_path);
|
||||
new_name = QDir::cleanPath(new_name);
|
||||
@@ -494,15 +494,15 @@ void torrentAdditionDialog::updateDiskSpaceLabels() {
|
||||
qDebug("Updating disk space label...");
|
||||
const long long available = misc::freeDiskSpaceOnPath(misc::expandPath(savePathTxt->currentText()));
|
||||
lbl_disk_space->setText(misc::friendlyUnit(available));
|
||||
if(!is_magnet) {
|
||||
if (!is_magnet) {
|
||||
// Determine torrent size
|
||||
qulonglong torrent_size = 0;
|
||||
if(t->num_files() > 1) {
|
||||
if (t->num_files() > 1) {
|
||||
const unsigned int nbFiles = t->num_files();
|
||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(nbFiles);
|
||||
|
||||
for(unsigned int i=0; i<nbFiles; ++i) {
|
||||
if(priorities[i] > 0)
|
||||
for (unsigned int i=0; i<nbFiles; ++i) {
|
||||
if (priorities[i] > 0)
|
||||
torrent_size += t->file_at(i).size;
|
||||
}
|
||||
} else {
|
||||
@@ -511,8 +511,8 @@ void torrentAdditionDialog::updateDiskSpaceLabels() {
|
||||
lbl_torrent_size->setText(misc::friendlyUnit(torrent_size));
|
||||
|
||||
// Check if free space is sufficient
|
||||
if(available > 0) {
|
||||
if((unsigned long long)available > torrent_size) {
|
||||
if (available > 0) {
|
||||
if ((unsigned long long)available > torrent_size) {
|
||||
// Space is sufficient
|
||||
label_space_msg->setText(tr("(%1 left after torrent download)", "e.g. (100MiB left after torrent download)").arg(misc::friendlyUnit(available-torrent_size)));
|
||||
} else {
|
||||
@@ -531,13 +531,13 @@ void torrentAdditionDialog::on_browseButton_clicked(){
|
||||
QString new_path;
|
||||
QString root_folder;
|
||||
const QString label_name = comboLabel->currentText();
|
||||
if(t->num_files() == 1) {
|
||||
if (t->num_files() == 1) {
|
||||
new_path = QFileDialog::getSaveFileName(this, tr("Choose save path"), savePathTxt->currentText(), QString(), 0, QFileDialog::DontConfirmOverwrite);
|
||||
if(!new_path.isEmpty()) {
|
||||
if (!new_path.isEmpty()) {
|
||||
QStringList path_parts = new_path.replace("\\", "/").split("/");
|
||||
const QString filename = path_parts.takeLast();
|
||||
// Append label
|
||||
if(QDir(path_parts.join(QDir::separator())) == QDir(defaultSavePath) && !label_name.isEmpty())
|
||||
if (QDir(path_parts.join(QDir::separator())) == QDir(defaultSavePath) && !label_name.isEmpty())
|
||||
path_parts << label_name;
|
||||
// Append file name
|
||||
path_parts << filename;
|
||||
@@ -546,26 +546,26 @@ void torrentAdditionDialog::on_browseButton_clicked(){
|
||||
}
|
||||
} else {
|
||||
QString truncated_path = getCurrentTruncatedSavePath(&root_folder);
|
||||
if(!truncated_path.isEmpty() && QDir(truncated_path).exists()){
|
||||
if (!truncated_path.isEmpty() && QDir(truncated_path).exists()){
|
||||
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), truncated_path);
|
||||
}else{
|
||||
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
|
||||
}
|
||||
if(!new_path.isEmpty()) {
|
||||
if (!new_path.isEmpty()) {
|
||||
QStringList path_parts = new_path.replace("\\", "/").split("/");
|
||||
if(path_parts.last().isEmpty())
|
||||
if (path_parts.last().isEmpty())
|
||||
path_parts.removeLast();
|
||||
// Append label
|
||||
if(QDir(new_path) == QDir(defaultSavePath) && !label_name.isEmpty())
|
||||
if (QDir(new_path) == QDir(defaultSavePath) && !label_name.isEmpty())
|
||||
path_parts << label_name;
|
||||
// Append root folder
|
||||
if(!root_folder.isEmpty())
|
||||
if (!root_folder.isEmpty())
|
||||
path_parts << root_folder;
|
||||
// Construct new_path
|
||||
new_path = path_parts.join(QDir::separator());
|
||||
}
|
||||
}
|
||||
if(!new_path.isEmpty()) {
|
||||
if (!new_path.isEmpty()) {
|
||||
// Check if this new path already exists in the list
|
||||
QString new_truncated_path = getTruncatedSavePath(new_path);
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
@@ -573,7 +573,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){
|
||||
#else
|
||||
const int cur_index = path_history.indexOf(QRegExp(new_truncated_path, Qt::CaseSensitive));
|
||||
#endif
|
||||
if(cur_index >= 0) {
|
||||
if (cur_index >= 0) {
|
||||
savePathTxt->setCurrentIndex(cur_index);
|
||||
}
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
@@ -602,7 +602,7 @@ void torrentAdditionDialog::savePiecesPriorities(){
|
||||
void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
Preferences pref;
|
||||
qDebug() << "void torrentAdditionDialog::on_OkButton_clicked() - ENTER";
|
||||
if(savePathTxt->currentText().trimmed().isEmpty()){
|
||||
if (savePathTxt->currentText().trimmed().isEmpty()){
|
||||
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
|
||||
return;
|
||||
}
|
||||
@@ -612,7 +612,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
#endif
|
||||
save_path = misc::expandPath(save_path);
|
||||
qDebug("Save path is %s", qPrintable(save_path));
|
||||
if(!is_magnet && t->num_files() == 1) {
|
||||
if (!is_magnet && t->num_files() == 1) {
|
||||
// Remove file name
|
||||
QStringList parts = save_path.split("/");
|
||||
const QString single_file_name = parts.takeLast();
|
||||
@@ -631,15 +631,15 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
qDebug("Saving save path to temp data: %s", qPrintable(savePath.absolutePath()));
|
||||
TorrentTempData::setSavePath(hash, savePath.absolutePath());
|
||||
qDebug("Torrent label is: %s", qPrintable(comboLabel->currentText().trimmed()));
|
||||
if(!current_label.isEmpty())
|
||||
if (!current_label.isEmpty())
|
||||
TorrentTempData::setLabel(hash, current_label);
|
||||
// Is download sequential?
|
||||
TorrentTempData::setSequential(hash, checkIncrementalDL->isChecked());
|
||||
// Save files path
|
||||
// Loads files path in the torrent
|
||||
if(!is_magnet) {
|
||||
if (!is_magnet) {
|
||||
bool path_changed = false;
|
||||
for(uint i=0; i<nbFiles; ++i) {
|
||||
for (uint i=0; i<nbFiles; ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
file_storage fs = t->files();
|
||||
QString old_path = misc::toQStringU(fs.file_path(t->file_at(i)));
|
||||
@@ -647,23 +647,23 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
QString old_path = misc::toQStringU(t->file_at(i).path.string());
|
||||
#endif
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
if(files_path.at(i).compare(old_path, Qt::CaseSensitive) != 0) {
|
||||
if (files_path.at(i).compare(old_path, Qt::CaseSensitive) != 0) {
|
||||
#else
|
||||
if(files_path.at(i).compare(old_path, Qt::CaseInsensitive) != 0) {
|
||||
if (files_path.at(i).compare(old_path, Qt::CaseInsensitive) != 0) {
|
||||
#endif
|
||||
path_changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(path_changed) {
|
||||
if (path_changed) {
|
||||
qDebug("Changing files paths");
|
||||
TorrentTempData::setFilesPath(hash, files_path);
|
||||
}
|
||||
}
|
||||
// Skip file checking and directly start seeding
|
||||
if(addInSeed->isChecked()) {
|
||||
if (addInSeed->isChecked()) {
|
||||
// Check if local file(s) actually exist
|
||||
if(is_magnet || QFile::exists(savePathTxt->currentText())) {
|
||||
if (is_magnet || QFile::exists(savePathTxt->currentText())) {
|
||||
TorrentTempData::setSeedingMode(hash, true);
|
||||
} else {
|
||||
QMessageBox::warning(0, tr("Seeding mode error"), tr("You chose to skip file checking. However, local files do not seem to exist in the current destionation folder. Please disable this feature or update the save path."));
|
||||
@@ -671,7 +671,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
}
|
||||
}
|
||||
// Check if there is at least one selected file
|
||||
if(!is_magnet && t->num_files() > 1 && allFiltered()){
|
||||
if (!is_magnet && t->num_files() > 1 && allFiltered()){
|
||||
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
||||
return;
|
||||
}
|
||||
@@ -683,23 +683,23 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
pref.setSavePath(getCurrentTruncatedSavePath());
|
||||
|
||||
// Check if savePath exists
|
||||
if(!savePath.exists()){
|
||||
if(!savePath.mkpath(savePath.path())){
|
||||
if (!savePath.exists()){
|
||||
if (!savePath.mkpath(savePath.path())){
|
||||
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// save filtered files
|
||||
if(!is_magnet && t->num_files() > 1)
|
||||
if (!is_magnet && t->num_files() > 1)
|
||||
savePiecesPriorities();
|
||||
// Add to download list
|
||||
QTorrentHandle h;
|
||||
if(is_magnet)
|
||||
if (is_magnet)
|
||||
h = QBtSession::instance()->addMagnetUri(from_url, false);
|
||||
else
|
||||
h = QBtSession::instance()->addTorrent(filePath, false, from_url);
|
||||
if(addInPause->isChecked() && h.is_valid()) {
|
||||
if (addInPause->isChecked() && h.is_valid()) {
|
||||
h.pause();
|
||||
}
|
||||
// Close the dialog
|
||||
@@ -710,14 +710,14 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
||||
|
||||
void torrentAdditionDialog::resetComboLabelIndex(QString text) {
|
||||
// Select first index
|
||||
if(text != comboLabel->itemText(comboLabel->currentIndex())) {
|
||||
if (text != comboLabel->itemText(comboLabel->currentIndex())) {
|
||||
comboLabel->setItemText(0, text);
|
||||
comboLabel->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
void torrentAdditionDialog::updateLabelInSavePath(QString label) {
|
||||
if(appendLabelToSavePath) {
|
||||
if (appendLabelToSavePath) {
|
||||
// Update Label in combobox
|
||||
savePathTxt->setItemText(0, misc::updateLabelInSavePath(defaultSavePath, savePathTxt->itemText(0), old_label, label));
|
||||
// update edit text
|
||||
@@ -735,15 +735,15 @@ void torrentAdditionDialog::updateSavePathCurrentText() {
|
||||
QString root_folder_or_file_name = "";
|
||||
getCurrentTruncatedSavePath(&root_folder_or_file_name);
|
||||
// Update other combo items
|
||||
for(int i=0; i<savePathTxt->count(); ++i) {
|
||||
if(i == savePathTxt->currentIndex()) continue;
|
||||
for (int i=0; i<savePathTxt->count(); ++i) {
|
||||
if (i == savePathTxt->currentIndex()) continue;
|
||||
QString item_path = path_history.at(i);
|
||||
if(item_path.isEmpty()) continue;
|
||||
if (item_path.isEmpty()) continue;
|
||||
// Append label
|
||||
if(i == 0 && appendLabelToSavePath && QDir(item_path) == QDir(defaultSavePath) && !comboLabel->currentText().isEmpty())
|
||||
if (i == 0 && appendLabelToSavePath && QDir(item_path) == QDir(defaultSavePath) && !comboLabel->currentText().isEmpty())
|
||||
item_path += comboLabel->currentText() + "/";
|
||||
// Append root_folder or filename
|
||||
if(!root_folder_or_file_name.isEmpty())
|
||||
if (!root_folder_or_file_name.isEmpty())
|
||||
item_path += root_folder_or_file_name;
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
item_path.replace("/", "\\");
|
||||
@@ -763,17 +763,17 @@ QString torrentAdditionDialog::getTruncatedSavePath(QString save_path, QString*
|
||||
save_path = misc::expandPath(save_path);
|
||||
QStringList parts = save_path.replace("\\", "/").split("/");
|
||||
// Remove torrent root folder
|
||||
if(!QDir(save_path).exists() || (!is_magnet && t->num_files() == 1)) {
|
||||
if (!QDir(save_path).exists() || (!is_magnet && t->num_files() == 1)) {
|
||||
QString tmp = parts.takeLast();
|
||||
if(root_folder_or_file_name)
|
||||
if (root_folder_or_file_name)
|
||||
*root_folder_or_file_name = tmp;
|
||||
}
|
||||
// Remove label
|
||||
if(appendLabelToSavePath && savePathTxt->currentIndex() == 0 && parts.last() == comboLabel->currentText()) {
|
||||
if (appendLabelToSavePath && savePathTxt->currentIndex() == 0 && parts.last() == comboLabel->currentText()) {
|
||||
parts.removeLast();
|
||||
}
|
||||
QString truncated_path = parts.join("/");
|
||||
if(!truncated_path.endsWith("/"))
|
||||
if (!truncated_path.endsWith("/"))
|
||||
truncated_path += "/";
|
||||
qDebug("Truncated save path: %s", qPrintable(truncated_path));
|
||||
return truncated_path;
|
||||
@@ -785,14 +785,14 @@ void torrentAdditionDialog::saveTruncatedPathHistory() {
|
||||
// Get current history
|
||||
QStringList history = settings.value("TorrentAdditionDlg/save_path_history").toStringList();
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
if(!history.contains(current_save_path, Qt::CaseSensitive)) {
|
||||
if (!history.contains(current_save_path, Qt::CaseSensitive)) {
|
||||
#else
|
||||
if(!history.contains(current_save_path, Qt::CaseInsensitive)) {
|
||||
if (!history.contains(current_save_path, Qt::CaseInsensitive)) {
|
||||
#endif
|
||||
// Add save path to history
|
||||
history << current_save_path;
|
||||
// Limit list size
|
||||
if(history.size() > 8)
|
||||
if (history.size() > 8)
|
||||
history.removeFirst();
|
||||
// Save history
|
||||
settings.setValue("TorrentAdditionDlg/save_path_history", history);
|
||||
@@ -803,8 +803,8 @@ void torrentAdditionDialog::loadSavePathHistory() {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
// Load save path history
|
||||
QStringList raw_path_history = settings.value("TorrentAdditionDlg/save_path_history").toStringList();
|
||||
foreach(const QString &sp, raw_path_history) {
|
||||
if(QDir(sp) != QDir(defaultSavePath)) {
|
||||
foreach (const QString &sp, raw_path_history) {
|
||||
if (QDir(sp) != QDir(defaultSavePath)) {
|
||||
QString dsp = sp;
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
dsp.replace("/", "\\");
|
||||
|
||||
Reference in New Issue
Block a user