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:
@@ -65,7 +65,7 @@ void TorrentImportDlg::on_browseTorrentBtn_clicked()
|
||||
const QString default_dir = settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString();
|
||||
// Ask for a torrent file
|
||||
m_torrentPath = QFileDialog::getOpenFileName(this, tr("Torrent file to import"), default_dir, tr("Torrent files (*.torrent)"));
|
||||
if(!m_torrentPath.isEmpty()) {
|
||||
if (!m_torrentPath.isEmpty()) {
|
||||
loadTorrent(m_torrentPath);
|
||||
} else {
|
||||
ui->lineTorrent->clear();
|
||||
@@ -76,7 +76,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
{
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
const QString default_dir = settings.value(QString::fromUtf8("TorrentImport/LastContentDir"), QDir::homePath()).toString();
|
||||
if(t->num_files() == 1) {
|
||||
if (t->num_files() == 1) {
|
||||
// Single file torrent
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
const QString file_name = misc::fileName(misc::toQStringU(t->file_at(0).path));
|
||||
@@ -87,12 +87,12 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
QString extension = misc::file_extension(file_name);
|
||||
qDebug("File extension is : %s", qPrintable(extension));
|
||||
QString filter;
|
||||
if(!extension.isEmpty()) {
|
||||
if (!extension.isEmpty()) {
|
||||
extension = extension.toUpper();
|
||||
filter = tr("%1 Files", "%1 is a file extension (e.g. PDF)").arg(extension)+" (*."+extension+")";
|
||||
}
|
||||
m_contentPath = QFileDialog::getOpenFileName(this, tr("Please provide the location of %1", "%1 is a file name").arg(file_name), default_dir, filter);
|
||||
if(m_contentPath.isEmpty() || !QFile(m_contentPath).exists()) {
|
||||
if (m_contentPath.isEmpty() || !QFile(m_contentPath).exists()) {
|
||||
m_contentPath = QString::null;
|
||||
ui->importBtn->setEnabled(false);
|
||||
ui->checkSkipCheck->setEnabled(false);
|
||||
@@ -106,7 +106,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
#endif
|
||||
// Check file size
|
||||
const qint64 file_size = QFile(m_contentPath).size();
|
||||
if(t->file_at(0).size == file_size) {
|
||||
if (t->file_at(0).size == file_size) {
|
||||
qDebug("The file size matches, allowing fast seeding...");
|
||||
ui->checkSkipCheck->setEnabled(true);
|
||||
} else {
|
||||
@@ -117,7 +117,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
// Handle file renaming
|
||||
QStringList parts = m_contentPath.replace("\\", "/").split("/");
|
||||
QString new_file_name = parts.takeLast();
|
||||
if(new_file_name != file_name) {
|
||||
if (new_file_name != file_name) {
|
||||
qDebug("The file has been renamed");
|
||||
QStringList new_parts = m_filesPath.first().split("/");
|
||||
new_parts.replace(new_parts.count()-1, new_file_name);
|
||||
@@ -128,7 +128,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
// multiple files torrent
|
||||
m_contentPath = QFileDialog::getExistingDirectory(this, tr("Please point to the location of the torrent: %1").arg(misc::toQStringU(t->name())),
|
||||
default_dir);
|
||||
if(m_contentPath.isEmpty() || !QDir(m_contentPath).exists()) {
|
||||
if (m_contentPath.isEmpty() || !QDir(m_contentPath).exists()) {
|
||||
m_contentPath = QString::null;
|
||||
ui->importBtn->setEnabled(false);
|
||||
ui->checkSkipCheck->setEnabled(false);
|
||||
@@ -143,13 +143,13 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
bool size_mismatch = false;
|
||||
QDir content_dir(m_contentPath);
|
||||
// Check file sizes
|
||||
for(int i=0; i<t->num_files(); ++i) {
|
||||
for (int i=0; i<t->num_files(); ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
const QString rel_path = misc::toQStringU(t->file_at(i).path);
|
||||
#else
|
||||
const QString rel_path = misc::toQStringU(t->file_at(i).path.string());
|
||||
#endif
|
||||
if(QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size() != t->file_at(i).size) {
|
||||
if (QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size() != t->file_at(i).size) {
|
||||
qDebug("%s is %lld",
|
||||
qPrintable(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size());
|
||||
qDebug("%s is %lld",
|
||||
@@ -158,7 +158,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(size_mismatch) {
|
||||
if (size_mismatch) {
|
||||
qDebug("The file size does not match, forbidding fast seeding...");
|
||||
ui->checkSkipCheck->setChecked(false);
|
||||
ui->checkSkipCheck->setEnabled(false);
|
||||
@@ -193,14 +193,14 @@ void TorrentImportDlg::importTorrent()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "ENTER";
|
||||
TorrentImportDlg dlg;
|
||||
if(dlg.exec()) {
|
||||
if (dlg.exec()) {
|
||||
qDebug() << "Loading the torrent file...";
|
||||
boost::intrusive_ptr<libtorrent::torrent_info> t = dlg.torrent();
|
||||
if(!t->is_valid())
|
||||
if (!t->is_valid())
|
||||
return;
|
||||
QString torrent_path = dlg.getTorrentPath();
|
||||
QString content_path = dlg.getContentPath();
|
||||
if(torrent_path.isEmpty() || content_path.isEmpty() || !QFile(torrent_path).exists()) {
|
||||
if (torrent_path.isEmpty() || content_path.isEmpty() || !QFile(torrent_path).exists()) {
|
||||
qWarning() << "Incorrect input, aborting." << torrent_path << content_path;
|
||||
return;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void TorrentImportDlg::loadTorrent(const QString &torrent_path)
|
||||
// Load the torrent file
|
||||
try {
|
||||
t = new torrent_info(torrent_path.toUtf8().constData());
|
||||
if(!t->is_valid() || t->num_files() == 0)
|
||||
if (!t->is_valid() || t->num_files() == 0)
|
||||
throw std::exception();
|
||||
} catch(std::exception&) {
|
||||
ui->browseContentBtn->setEnabled(false);
|
||||
@@ -251,7 +251,7 @@ void TorrentImportDlg::initializeFilesPath()
|
||||
{
|
||||
m_filesPath.clear();
|
||||
// Loads files path in the torrent
|
||||
for(int i=0; i<t->num_files(); ++i) {
|
||||
for (int i=0; i<t->num_files(); ++i) {
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
m_filesPath << misc::toQStringU(t->file_at(i).path).replace("\\", "/");
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user