mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -06:00
Move utilities to core/utils folder.
Also move the names to Utils namespace.
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include "core/bittorrent/magneturi.h"
|
||||
#include "core/bittorrent/torrentinfo.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "messageboxraised.h"
|
||||
|
||||
@@ -66,7 +66,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
|
||||
|
||||
Preferences* const pref = Preferences::instance();
|
||||
ui->start_torrent_cb->setChecked(!pref->addTorrentsInPause());
|
||||
ui->save_path_combo->addItem(fsutils::toNativePath(pref->getSavePath()), pref->getSavePath());
|
||||
ui->save_path_combo->addItem(Utils::Fs::toNativePath(pref->getSavePath()), pref->getSavePath());
|
||||
loadSavePathHistory();
|
||||
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int)));
|
||||
connect(ui->browse_button, SIGNAL(clicked()), SLOT(browseButton_clicked()));
|
||||
@@ -125,12 +125,12 @@ void AddNewTorrentDialog::show(QString source, QWidget *parent)
|
||||
{
|
||||
if (source.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||
qDebug("Converting bc link to magnet link");
|
||||
source = misc::bcLinkToMagnet(source);
|
||||
source = Utils::Misc::bcLinkToMagnet(source);
|
||||
}
|
||||
|
||||
AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent);
|
||||
|
||||
if (misc::isUrl(source)) {
|
||||
if (Utils::Misc::isUrl(source)) {
|
||||
// Launch downloader
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, 10485760 /* 10MB */);
|
||||
connect(handler, SIGNAL(downloadFinished(QString, QString)), dlg, SLOT(handleDownloadFinished(QString, QString)));
|
||||
@@ -303,7 +303,7 @@ void AddNewTorrentDialog::updateFileNameInSavePaths(const QString &new_filename)
|
||||
{
|
||||
for(int i = 0; i < ui->save_path_combo->count(); ++i) {
|
||||
const QDir folder(ui->save_path_combo->itemData(i).toString());
|
||||
ui->save_path_combo->setItemText(i, fsutils::toNativePath(folder.absoluteFilePath(new_filename)));
|
||||
ui->save_path_combo->setItemText(i, Utils::Fs::toNativePath(folder.absoluteFilePath(new_filename)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,9 +325,9 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||
}
|
||||
}
|
||||
|
||||
QString size_string = torrent_size ? misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable."));
|
||||
QString size_string = torrent_size ? Utils::Misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable."));
|
||||
size_string += " (";
|
||||
size_string += tr("Disk space: %1").arg(misc::friendlyUnit(fsutils::freeDiskSpaceOnPath(
|
||||
size_string += tr("Disk space: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
|
||||
ui->save_path_combo->itemData(
|
||||
ui->save_path_combo->currentIndex()).toString())));
|
||||
size_string += ")";
|
||||
@@ -353,10 +353,10 @@ void AddNewTorrentDialog::browseButton_clicked()
|
||||
QString new_path, old_filename, new_filename;
|
||||
|
||||
if (m_torrentInfo.isValid() && (m_torrentInfo.filesCount() == 1)) {
|
||||
old_filename = fsutils::fileName(cur_save_path);
|
||||
old_filename = Utils::Fs::fileName(cur_save_path);
|
||||
new_path = QFileDialog::getSaveFileName(this, tr("Choose save path"), cur_save_path, QString(), 0, QFileDialog::DontConfirmOverwrite);
|
||||
if (!new_path.isEmpty())
|
||||
new_path = fsutils::branchPath(new_path, &new_filename);
|
||||
new_path = Utils::Fs::branchPath(new_path, &new_filename);
|
||||
qDebug() << "new_path: " << new_path;
|
||||
qDebug() << "new_filename: " << new_filename;
|
||||
}
|
||||
@@ -374,13 +374,13 @@ void AddNewTorrentDialog::browseButton_clicked()
|
||||
else {
|
||||
// New path, prepend to combo box
|
||||
if (!new_filename.isEmpty())
|
||||
ui->save_path_combo->insertItem(0, fsutils::toNativePath(QDir(new_path).absoluteFilePath(new_filename)), new_path);
|
||||
ui->save_path_combo->insertItem(0, Utils::Fs::toNativePath(QDir(new_path).absoluteFilePath(new_filename)), new_path);
|
||||
else
|
||||
ui->save_path_combo->insertItem(0, fsutils::toNativePath(new_path), new_path);
|
||||
ui->save_path_combo->insertItem(0, Utils::Fs::toNativePath(new_path), new_path);
|
||||
ui->save_path_combo->setCurrentIndex(0);
|
||||
}
|
||||
// Update file name in all save_paths
|
||||
if (!new_filename.isEmpty() && !fsutils::sameFileNames(old_filename, new_filename)) {
|
||||
if (!new_filename.isEmpty() && !Utils::Fs::sameFileNames(old_filename, new_filename)) {
|
||||
m_torrentInfo.renameFile(0, new_filename);
|
||||
updateFileNameInSavePaths(new_filename);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
tr("New name:"), QLineEdit::Normal,
|
||||
index.data().toString(), &ok).trimmed();
|
||||
if (ok && !new_name_last.isEmpty()) {
|
||||
if (!fsutils::isValidFileSystemName(new_name_last)) {
|
||||
if (!Utils::Fs::isValidFileSystemName(new_name_last)) {
|
||||
MessageBoxRaised::warning(this, tr("The file could not be renamed"),
|
||||
tr("This file name contains forbidden characters, please choose a different one."),
|
||||
QMessageBox::Ok);
|
||||
@@ -428,22 +428,22 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
if (m_contentModel->itemType(index) == TorrentContentModelItem::FileType) {
|
||||
// File renaming
|
||||
const int file_index = m_contentModel->getFileIndex(index);
|
||||
QString old_name = fsutils::fromNativePath(m_torrentInfo.filePath(file_index));
|
||||
QString old_name = Utils::Fs::fromNativePath(m_torrentInfo.filePath(file_index));
|
||||
qDebug("Old name: %s", qPrintable(old_name));
|
||||
QStringList path_items = old_name.split("/");
|
||||
path_items.removeLast();
|
||||
path_items << new_name_last;
|
||||
QString new_name = path_items.join("/");
|
||||
if (fsutils::sameFileNames(old_name, new_name)) {
|
||||
if (Utils::Fs::sameFileNames(old_name, new_name)) {
|
||||
qDebug("Name did not change");
|
||||
return;
|
||||
}
|
||||
new_name = fsutils::expandPath(new_name);
|
||||
new_name = Utils::Fs::expandPath(new_name);
|
||||
qDebug("New name: %s", qPrintable(new_name));
|
||||
// Check if that name is already used
|
||||
for (int i = 0; i < m_torrentInfo.filesCount(); ++i) {
|
||||
if (i == file_index) continue;
|
||||
if (fsutils::sameFileNames(m_torrentInfo.filePath(i), new_name)) {
|
||||
if (Utils::Fs::sameFileNames(m_torrentInfo.filePath(i), new_name)) {
|
||||
// Display error message
|
||||
MessageBoxRaised::warning(this, tr("The file could not be renamed"),
|
||||
tr("This name is already in use in this folder. Please use a different name."),
|
||||
@@ -490,7 +490,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
if (current_name.startsWith(old_path)) {
|
||||
QString new_name = current_name;
|
||||
new_name.replace(0, old_path.length(), new_path);
|
||||
new_name = fsutils::expandPath(new_name);
|
||||
new_name = Utils::Fs::expandPath(new_name);
|
||||
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
||||
m_torrentInfo.renameFile(i, new_name);
|
||||
}
|
||||
@@ -505,7 +505,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
void AddNewTorrentDialog::setdialogPosition()
|
||||
{
|
||||
qApp->processEvents();
|
||||
QPoint center(misc::screenCenter(this));
|
||||
QPoint center(Utils::Misc::screenCenter(this));
|
||||
// Adjust y
|
||||
int y = Preferences::instance()->getAddNewTorrentDialogPos();
|
||||
if (y >= 0) {
|
||||
@@ -526,7 +526,7 @@ void AddNewTorrentDialog::loadSavePathHistory()
|
||||
QStringList raw_path_history = Preferences::instance()->getAddNewTorrentDialogPathHistory();
|
||||
foreach (const QString &sp, raw_path_history)
|
||||
if (QDir(sp) != default_save_path)
|
||||
ui->save_path_combo->addItem(fsutils::toNativePath(sp), sp);
|
||||
ui->save_path_combo->addItem(Utils::Fs::toNativePath(sp), sp);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint&)
|
||||
@@ -694,7 +694,7 @@ void AddNewTorrentDialog::setupTreeview()
|
||||
// Update save paths (append file name to them)
|
||||
QString single_file_relpath = m_torrentInfo.filePath(0);
|
||||
for (int i = 0; i < ui->save_path_combo->count(); ++i)
|
||||
ui->save_path_combo->setItemText(i, fsutils::toNativePath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
||||
ui->save_path_combo->setItemText(i, Utils::Fs::toNativePath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "ui_confirmdeletiondlg.h"
|
||||
#include "core/preferences.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
|
||||
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||
Q_OBJECT
|
||||
@@ -53,7 +53,7 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||
lbl_warn->setFixedWidth(lbl_warn->height());
|
||||
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
||||
|
||||
move(misc::screenCenter(this));
|
||||
move(Utils::Misc::screenCenter(this));
|
||||
checkPermDelete->setChecked(Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
#include <QFile>
|
||||
#include <QChar>
|
||||
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
using namespace libtorrent;
|
||||
@@ -73,7 +73,7 @@ QString GeoIPManager::geoipFolder(bool embedded) {
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
if (embedded)
|
||||
return ":/geoip/";
|
||||
return fsutils::QDesktopServicesDataLocation()+"geoip"+"/";
|
||||
return Utils::Fs::QDesktopServicesDataLocation()+"geoip"+"/";
|
||||
#else
|
||||
Q_UNUSED(embedded);
|
||||
if (QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||
@@ -102,7 +102,7 @@ void GeoIPManager::exportEmbeddedDb() {
|
||||
}
|
||||
// Remove destination files
|
||||
if (QFile::exists(geoipDBpath(false)))
|
||||
fsutils::forceRemove(geoipDBpath(false));
|
||||
Utils::Fs::forceRemove(geoipDBpath(false));
|
||||
// Copy from executable to hard disk
|
||||
qDebug("%s -> %s", qPrintable(geoipDBpath(true)), qPrintable(geoipDBpath(false)));
|
||||
if (!QFile::copy(geoipDBpath(true), geoipDBpath(false))) {
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "transferlistwidget.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "torrentcreatordlg.h"
|
||||
#include "downloadfromurldlg.h"
|
||||
#include "addnewtorrentdialog.h"
|
||||
@@ -874,7 +874,7 @@ void MainWindow::showEvent(QShowEvent *e)
|
||||
|
||||
// Make sure the window is initially centered
|
||||
if (!m_posInitialized) {
|
||||
move(misc::screenCenter(this));
|
||||
move(Utils::Misc::screenCenter(this));
|
||||
m_posInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -1045,9 +1045,9 @@ void MainWindow::on_actionOpen_triggered()
|
||||
}
|
||||
|
||||
// Save last dir to remember it
|
||||
QStringList top_dir = fsutils::fromNativePath(pathsList.at(0)).split("/");
|
||||
QStringList top_dir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/");
|
||||
top_dir.removeLast();
|
||||
pref->setMainLastDir(fsutils::fromNativePath(top_dir.join("/")));
|
||||
pref->setMainLastDir(Utils::Fs::fromNativePath(top_dir.join("/")));
|
||||
}
|
||||
|
||||
void MainWindow::activate()
|
||||
@@ -1186,21 +1186,21 @@ void MainWindow::updateGUI()
|
||||
html += "qBittorrent";
|
||||
html += "</div>";
|
||||
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||||
html += "<img src=':/icons/skin/download.png'/> " + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(misc::friendlyUnit(status.payloadDownloadRate(), true));
|
||||
html += "<img src=':/icons/skin/download.png'/> " + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true));
|
||||
html += "</div>";
|
||||
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||||
html += "<img src=':/icons/skin/seeding.png'/> " + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(misc::friendlyUnit(status.payloadUploadRate(), true));
|
||||
html += "<img src=':/icons/skin/seeding.png'/> " + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true));
|
||||
html += "</div>";
|
||||
#else
|
||||
// OSes such as Windows do not support html here
|
||||
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(misc::friendlyUnit(status.payloadDownloadRate(), true));
|
||||
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true));
|
||||
html += "\n";
|
||||
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(misc::friendlyUnit(status.payloadUploadRate(), true));
|
||||
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true));
|
||||
#endif
|
||||
systrayIcon->setToolTip(html); // tray icon
|
||||
}
|
||||
if (displaySpeedInTitle)
|
||||
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version").arg(misc::friendlyUnit(status.payloadDownloadRate(), true)).arg(misc::friendlyUnit(status.payloadUploadRate(), true)).arg(QString::fromUtf8(VERSION)));
|
||||
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true)).arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true)).arg(QString::fromUtf8(VERSION)));
|
||||
}
|
||||
|
||||
void MainWindow::showNotificationBaloon(QString title, QString msg) const
|
||||
@@ -1377,7 +1377,7 @@ void MainWindow::on_actionSearch_engine_triggered()
|
||||
bool res = false;
|
||||
|
||||
// Check if python is already in PATH
|
||||
if (misc::pythonVersion() > 0)
|
||||
if (Utils::Misc::pythonVersion() > 0)
|
||||
res = true;
|
||||
else
|
||||
res = addPythonPathToEnv();
|
||||
@@ -1567,7 +1567,7 @@ bool MainWindow::addPythonPathToEnv()
|
||||
path_envar = "";
|
||||
path_envar = python_path + ";" + path_envar;
|
||||
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
||||
qputenv("PATH", fsutils::toNativePath(path_envar).toLocal8Bit());
|
||||
qputenv("PATH", Utils::Fs::toNativePath(path_envar).toLocal8Bit());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1590,7 +1590,7 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa
|
||||
QProcess installer;
|
||||
qDebug("Launching Python installer in passive mode...");
|
||||
|
||||
installer.start("msiexec.exe /passive /i " + fsutils::toNativePath(filePath) + ".msi");
|
||||
installer.start("msiexec.exe /passive /i " + Utils::Fs::toNativePath(filePath) + ".msi");
|
||||
// Wait for setup to complete
|
||||
installer.waitForFinished();
|
||||
|
||||
@@ -1598,7 +1598,7 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa
|
||||
qDebug("Installer stderr: %s", installer.readAllStandardError().data());
|
||||
qDebug("Setup should be complete!");
|
||||
// Delete temp file
|
||||
fsutils::forceRemove(filePath);
|
||||
Utils::Fs::forceRemove(filePath);
|
||||
// Reload search engine
|
||||
has_python = addPythonPathToEnv();
|
||||
if (has_python) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#include "options_imp.h"
|
||||
#include "core/preferences.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "advancedsettings.h"
|
||||
#include "core/scanfoldersmodel.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
@@ -545,14 +545,14 @@ void options_imp::loadOptions() {
|
||||
#endif
|
||||
// End General preferences
|
||||
// Downloads preferences
|
||||
textSavePath->setText(fsutils::toNativePath(pref->getSavePath()));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(pref->getSavePath()));
|
||||
if (pref->isTempPathEnabled()) {
|
||||
// enable
|
||||
checkTempFolder->setChecked(true);
|
||||
} else {
|
||||
checkTempFolder->setChecked(false);
|
||||
}
|
||||
textTempPath->setText(fsutils::toNativePath(pref->getTempPath()));
|
||||
textTempPath->setText(Utils::Fs::toNativePath(pref->getTempPath()));
|
||||
checkAppendLabel->setChecked(pref->appendTorrentLabel());
|
||||
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
||||
checkPreallocateAll->setChecked(pref->preAllocateAllFiles());
|
||||
@@ -560,7 +560,7 @@ void options_imp::loadOptions() {
|
||||
checkAdditionDialogFront->setChecked(pref->additionDialogFront());
|
||||
checkStartPaused->setChecked(pref->addTorrentsInPause());
|
||||
|
||||
strValue = fsutils::toNativePath(pref->getTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(pref->getTorrentExportDir());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDir->setChecked(false);
|
||||
@@ -570,7 +570,7 @@ void options_imp::loadOptions() {
|
||||
textExportDir->setText(strValue);
|
||||
}
|
||||
|
||||
strValue = fsutils::toNativePath(pref->getFinishedTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDirFin->setChecked(false);
|
||||
@@ -735,7 +735,7 @@ void options_imp::loadOptions() {
|
||||
// Misc preferences
|
||||
// * IP Filter
|
||||
checkIPFilter->setChecked(pref->isFilteringEnabled());
|
||||
textFilterPath->setText(fsutils::toNativePath(pref->getFilter()));
|
||||
textFilterPath->setText(Utils::Fs::toNativePath(pref->getFilter()));
|
||||
// End IP Filter
|
||||
// Queueing system preferences
|
||||
checkEnableQueueing->setChecked(pref->isQueueingSystemEnabled());
|
||||
@@ -850,13 +850,13 @@ qreal options_imp::getMaxRatio() const {
|
||||
QString options_imp::getSavePath() const {
|
||||
if (textSavePath->text().trimmed().isEmpty()) {
|
||||
QString save_path = Preferences::instance()->getSavePath();
|
||||
textSavePath->setText(fsutils::toNativePath(save_path));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(save_path));
|
||||
}
|
||||
return fsutils::expandPathAbs(textSavePath->text());
|
||||
return Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
}
|
||||
|
||||
QString options_imp::getTempPath() const {
|
||||
return fsutils::expandPathAbs(textTempPath->text());
|
||||
return Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
}
|
||||
|
||||
bool options_imp::isTempPathEnabled() const {
|
||||
@@ -1051,13 +1051,13 @@ void options_imp::setLocale(const QString &localeStr) {
|
||||
|
||||
QString options_imp::getTorrentExportDir() const {
|
||||
if (checkExportDir->isChecked())
|
||||
return fsutils::expandPathAbs(textExportDir->text());
|
||||
return Utils::Fs::expandPathAbs(textExportDir->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString options_imp::getFinishedTorrentExportDir() const {
|
||||
if (checkExportDirFin->isChecked())
|
||||
return fsutils::expandPathAbs(textExportDirFin->text());
|
||||
return Utils::Fs::expandPathAbs(textExportDirFin->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -1078,7 +1078,7 @@ int options_imp::getActionOnDblClOnTorrentFn() const {
|
||||
void options_imp::on_addScanFolderButton_clicked() {
|
||||
Preferences* const pref = Preferences::instance();
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
||||
fsutils::toNativePath(fsutils::folderName(pref->getScanDirsLastPath())));
|
||||
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||||
if (!dir.isEmpty()) {
|
||||
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
|
||||
QString error;
|
||||
@@ -1120,7 +1120,7 @@ void options_imp::handleScanFolderViewSelectionChanged() {
|
||||
|
||||
QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||
{
|
||||
QDir currentExportDir(fsutils::expandPathAbs(currentExportPath));
|
||||
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
||||
QString dir;
|
||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||
@@ -1133,17 +1133,17 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||
void options_imp::on_browseExportDirButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDir->setText(fsutils::toNativePath(newExportDir));
|
||||
textExportDir->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDirFin->setText(fsutils::toNativePath(newExportDir));
|
||||
textExportDirFin->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseFilterButton_clicked() {
|
||||
const QString filter_path = fsutils::expandPathAbs(textFilterPath->text());
|
||||
const QString filter_path = Utils::Fs::expandPathAbs(textFilterPath->text());
|
||||
QDir filterDir(filter_path);
|
||||
QString ipfilter;
|
||||
if (!filter_path.isEmpty() && filterDir.exists()) {
|
||||
@@ -1152,12 +1152,12 @@ void options_imp::on_browseFilterButton_clicked() {
|
||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||
}
|
||||
if (!ipfilter.isNull())
|
||||
textFilterPath->setText(fsutils::toNativePath(ipfilter));
|
||||
textFilterPath->setText(Utils::Fs::toNativePath(ipfilter));
|
||||
}
|
||||
|
||||
// Display dialog to choose save dir
|
||||
void options_imp::on_browseSaveDirButton_clicked() {
|
||||
const QString save_path = fsutils::expandPathAbs(textSavePath->text());
|
||||
const QString save_path = Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
QDir saveDir(save_path);
|
||||
QString dir;
|
||||
if (!save_path.isEmpty() && saveDir.exists()) {
|
||||
@@ -1166,11 +1166,11 @@ void options_imp::on_browseSaveDirButton_clicked() {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textSavePath->setText(fsutils::toNativePath(dir));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseTempDirButton_clicked() {
|
||||
const QString temp_path = fsutils::expandPathAbs(textTempPath->text());
|
||||
const QString temp_path = Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
QDir tempDir(temp_path);
|
||||
QString dir;
|
||||
if (!temp_path.isEmpty() && tempDir.exists()) {
|
||||
@@ -1179,12 +1179,12 @@ void options_imp::on_browseTempDirButton_clicked() {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textTempPath->setText(fsutils::toNativePath(dir));
|
||||
textTempPath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
// Return Filter object to apply to BT session
|
||||
QString options_imp::getFilter() const {
|
||||
return fsutils::fromNativePath(textFilterPath->text());
|
||||
return Utils::Fs::fromNativePath(textFilterPath->text());
|
||||
}
|
||||
|
||||
// Web UI
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
#include <QModelIndex>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "previewselect.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -63,13 +64,13 @@ class PreviewListDelegate: public QItemDelegate {
|
||||
switch(index.column()) {
|
||||
case PreviewSelect::SIZE:
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||
break;
|
||||
case PreviewSelect::PROGRESS:{
|
||||
QStyleOptionProgressBarV2 newopt;
|
||||
qreal progress = index.data().toDouble()*100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : misc::accurateDoubleToString(progress, 1) + "%");
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <QMessageBox>
|
||||
#include <QFile>
|
||||
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "previewlistdelegate.h"
|
||||
#include "previewselect.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/preferences.h"
|
||||
|
||||
PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const torrent)
|
||||
@@ -64,8 +64,8 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
|
||||
QString fileName = torrent->fileName(i);
|
||||
if (fileName.endsWith(".!qB"))
|
||||
fileName.chop(4);
|
||||
QString extension = fsutils::fileExtension(fileName).toUpper();
|
||||
if (misc::isPreviewable(extension)) {
|
||||
QString extension = Utils::Fs::fileExtension(fileName).toUpper();
|
||||
if (Utils::Misc::isPreviewable(extension)) {
|
||||
int row = previewListModel->rowCount();
|
||||
previewListModel->insertRow(row);
|
||||
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include "programupdater.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/preferences.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -122,7 +122,7 @@ void ProgramUpdater::rssDownloadFinished(QNetworkReply *reply)
|
||||
} else if (xml.isEndElement()) {
|
||||
if (in_item && xml.name() == "title") {
|
||||
in_title = false;
|
||||
const QString ext = fsutils::fileExtension(item_title).toUpper();
|
||||
const QString ext = Utils::Fs::fileExtension(item_title).toUpper();
|
||||
qDebug("Found an update with file extension: %s", qPrintable(ext));
|
||||
if (ext == FILE_EXT) {
|
||||
qDebug("The last update available is %s", qPrintable(item_title));
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QPainter>
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/string.h"
|
||||
|
||||
class PeerListDelegate: public QItemDelegate {
|
||||
Q_OBJECT
|
||||
@@ -54,21 +55,21 @@ public:
|
||||
case TOT_DOWN:
|
||||
case TOT_UP:
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||
break;
|
||||
case DOWN_SPEED:
|
||||
case UP_SPEED:{
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
qreal speed = index.data().toDouble();
|
||||
if (speed > 0.0)
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
|
||||
break;
|
||||
}
|
||||
case PROGRESS:
|
||||
case RELEVANCE:{
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
qreal progress = index.data().toDouble();
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::accurateDoubleToString(progress*100.0, 1)+"%");
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress*100.0, 1)+"%");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -52,7 +52,7 @@ protected:
|
||||
Q_ASSERT(vR.isValid());
|
||||
|
||||
bool res = false;
|
||||
if (misc::naturalSort(vL.toString(), vR.toString(), res))
|
||||
if (Utils::String::naturalSort(vL.toString(), vR.toString(), res))
|
||||
return res;
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
#include "proptabbar.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "lineedit.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList):
|
||||
@@ -264,9 +265,9 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent
|
||||
// Creation date
|
||||
lbl_creationDate->setText(m_torrent->creationDate().toString());
|
||||
// Piece size
|
||||
pieceSize_lbl->setText(misc::friendlyUnit(m_torrent->pieceLength()));
|
||||
pieceSize_lbl->setText(Utils::Misc::friendlyUnit(m_torrent->pieceLength()));
|
||||
// Comment
|
||||
comment_text->setHtml(misc::parseHtmlLinks(m_torrent->comment()));
|
||||
comment_text->setHtml(Utils::Misc::parseHtmlLinks(m_torrent->comment()));
|
||||
// URL seeds
|
||||
loadUrlSeeds();
|
||||
// List files in torrent
|
||||
@@ -333,14 +334,14 @@ void PropertiesWidget::loadDynamicData() {
|
||||
// Transfer infos
|
||||
if (stackedProperties->currentIndex() == PropTabBar::MAIN_TAB) {
|
||||
|
||||
wasted->setText(misc::friendlyUnit(m_torrent->wastedSize()));
|
||||
upTotal->setText(misc::friendlyUnit(m_torrent->totalUpload()) + " ("+misc::friendlyUnit(m_torrent->totalPayloadUpload())+" "+tr("this session")+")");
|
||||
dlTotal->setText(misc::friendlyUnit(m_torrent->totalDownload()) + " ("+misc::friendlyUnit(m_torrent->totalPayloadDownload())+" "+tr("this session")+")");
|
||||
lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8("∞") : misc::friendlyUnit(m_torrent->uploadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||
lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8("∞") : misc::friendlyUnit(m_torrent->downloadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||
QString elapsed_txt = misc::userFriendlyDuration(m_torrent->activeTime());
|
||||
wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
|
||||
upTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalUpload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())+" "+tr("this session")+")");
|
||||
dlTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalDownload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())+" "+tr("this session")+")");
|
||||
lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->uploadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||
lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->downloadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||
QString elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
|
||||
if (m_torrent->isSeed()) {
|
||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(m_torrent->seedingTime()))+")";
|
||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")";
|
||||
}
|
||||
lbl_elapsed->setText(elapsed_txt);
|
||||
if (m_torrent->connectionsLimit() > 0)
|
||||
@@ -348,10 +349,10 @@ void PropertiesWidget::loadDynamicData() {
|
||||
else
|
||||
lbl_connections->setText(QString::number(m_torrent->connectionsLimit()));
|
||||
// Update next announce time
|
||||
reannounce_lbl->setText(misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
||||
reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
||||
// Update ratio info
|
||||
const qreal ratio = m_torrent->realRatio();
|
||||
shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2));
|
||||
shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2));
|
||||
if (!m_torrent->isSeed() && m_torrent->hasMetadata()) {
|
||||
showPiecesDownloaded(true);
|
||||
// Downloaded pieces
|
||||
@@ -360,13 +361,13 @@ void PropertiesWidget::loadDynamicData() {
|
||||
if (!m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
|
||||
showPiecesAvailability(true);
|
||||
pieces_availability->setAvailability(m_torrent->pieceAvailability());
|
||||
avail_average_lbl->setText(misc::accurateDoubleToString(m_torrent->distributedCopies(), 3));
|
||||
avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
|
||||
} else {
|
||||
showPiecesAvailability(false);
|
||||
}
|
||||
// Progress
|
||||
qreal progress = m_torrent->progress() * 100.;
|
||||
progress_lbl->setText(misc::accurateDoubleToString(progress, 1)+"%");
|
||||
progress_lbl->setText(Utils::String::fromDouble(progress, 1)+"%");
|
||||
} else {
|
||||
showPiecesAvailability(false);
|
||||
showPiecesDownloaded(false);
|
||||
@@ -422,13 +423,13 @@ void PropertiesWidget::openFile(const QModelIndex &index) {
|
||||
int i = PropListModel->getFileIndex(index);
|
||||
const QDir saveDir(m_torrent->actualSavePath());
|
||||
const QString filename = m_torrent->filePath(i);
|
||||
const QString file_path = fsutils::expandPath(saveDir.absoluteFilePath(filename));
|
||||
const QString file_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(filename));
|
||||
qDebug("Trying to open file at %s", qPrintable(file_path));
|
||||
// Flush data
|
||||
m_torrent->flushCache();
|
||||
if (QFile::exists(file_path)) {
|
||||
if (file_path.startsWith("//"))
|
||||
QDesktopServices::openUrl(fsutils::toNativePath("file:" + file_path));
|
||||
QDesktopServices::openUrl(Utils::Fs::toNativePath("file:" + file_path));
|
||||
else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
|
||||
}
|
||||
@@ -457,17 +458,17 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_fold
|
||||
#endif
|
||||
const QDir saveDir(m_torrent->actualSavePath());
|
||||
const QString relative_path = path_items.join("/");
|
||||
absolute_path = fsutils::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
}
|
||||
else {
|
||||
int i = PropListModel->getFileIndex(index);
|
||||
const QDir saveDir(m_torrent->actualSavePath());
|
||||
const QString relative_path = m_torrent->filePath(i);
|
||||
absolute_path = fsutils::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
|
||||
#if !(defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)))
|
||||
if (containing_folder)
|
||||
absolute_path = fsutils::folderName(absolute_path);
|
||||
absolute_path = Utils::Fs::folderName(absolute_path);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -481,7 +482,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_fold
|
||||
if (containing_folder) {
|
||||
// Syntax is: explorer /select, "C:\Folder1\Folder2\file_to_select"
|
||||
// Dir separators MUST be win-style slashes
|
||||
QProcess::startDetached("explorer.exe", QStringList() << "/select," << fsutils::toNativePath(absolute_path));
|
||||
QProcess::startDetached("explorer.exe", QStringList() << "/select," << Utils::Fs::toNativePath(absolute_path));
|
||||
} else {
|
||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
if (containing_folder) {
|
||||
@@ -491,11 +492,11 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_fold
|
||||
proc.waitForFinished();
|
||||
output = proc.readLine().simplified();
|
||||
if (output == "dolphin.desktop")
|
||||
proc.startDetached("dolphin", QStringList() << "--select" << fsutils::toNativePath(absolute_path));
|
||||
proc.startDetached("dolphin", QStringList() << "--select" << Utils::Fs::toNativePath(absolute_path));
|
||||
else if (output == "nautilus-folder-handler.desktop")
|
||||
proc.startDetached("nautilus", QStringList() << "--no-desktop" << fsutils::toNativePath(absolute_path));
|
||||
proc.startDetached("nautilus", QStringList() << "--no-desktop" << Utils::Fs::toNativePath(absolute_path));
|
||||
else if (output == "kfmclient_dir.desktop")
|
||||
proc.startDetached("konqueror", QStringList() << "--select" << fsutils::toNativePath(absolute_path));
|
||||
proc.startDetached("konqueror", QStringList() << "--select" << Utils::Fs::toNativePath(absolute_path));
|
||||
else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(absolute_path).absolutePath()));
|
||||
} else {
|
||||
@@ -503,7 +504,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_fold
|
||||
if (QFile::exists(absolute_path)) {
|
||||
// Hack to access samba shares with QDesktopServices::openUrl
|
||||
if (absolute_path.startsWith("//"))
|
||||
QDesktopServices::openUrl(fsutils::toNativePath("file:" + absolute_path));
|
||||
QDesktopServices::openUrl(Utils::Fs::toNativePath("file:" + absolute_path));
|
||||
else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(absolute_path));
|
||||
} else {
|
||||
@@ -616,7 +617,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
tr("New name:"), QLineEdit::Normal,
|
||||
index.data().toString(), &ok).trimmed();
|
||||
if (ok && !new_name_last.isEmpty()) {
|
||||
if (!fsutils::isValidFileSystemName(new_name_last)) {
|
||||
if (!Utils::Fs::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);
|
||||
@@ -638,7 +639,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
qDebug("Name did not change");
|
||||
return;
|
||||
}
|
||||
new_name = fsutils::expandPath(new_name);
|
||||
new_name = Utils::Fs::expandPath(new_name);
|
||||
// Check if that name is already used
|
||||
for (int i = 0; i < m_torrent->filesCount(); ++i) {
|
||||
if (i == file_index) continue;
|
||||
@@ -701,7 +702,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
new_name.replace(0, old_path.length(), new_path);
|
||||
if (!force_recheck && QDir(m_torrent->actualSavePath()).exists(new_name))
|
||||
force_recheck = true;
|
||||
new_name = fsutils::expandPath(new_name);
|
||||
new_name = Utils::Fs::expandPath(new_name);
|
||||
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
||||
m_torrent->renameFile(i, new_name);
|
||||
}
|
||||
@@ -714,8 +715,8 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
const QDir old_folder(m_torrent->actualSavePath() + "/" + old_path);
|
||||
int timeout = 10;
|
||||
while(!QDir().rmpath(old_folder.absolutePath()) && timeout > 0) {
|
||||
// XXX: We should not sleep here (freezes the UI for 1 second)
|
||||
misc::msleep(100);
|
||||
// FIXME: We should not sleep here (freezes the UI for 1 second)
|
||||
Utils::Misc::msleep(100);
|
||||
--timeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <QPainter>
|
||||
#include <QProgressBar>
|
||||
#include <QApplication>
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "propertieswidget.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -75,14 +76,14 @@ public:
|
||||
switch(index.column()) {
|
||||
case PCSIZE:
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||
break;
|
||||
case PROGRESS:{
|
||||
if (index.data().toDouble() >= 0) {
|
||||
QStyleOptionProgressBarV2 newopt;
|
||||
qreal progress = index.data().toDouble()*100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : misc::accurateDoubleToString(progress, 1) + "%");
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "core/bittorrent/peerinfo.h"
|
||||
#include "core/bittorrent/trackerentry.h"
|
||||
#include "core/preferences.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
|
||||
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
||||
|
||||
@@ -37,13 +37,13 @@
|
||||
#include <QFile>
|
||||
#include <QUrl>
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "ui_trackersadditiondlg.h"
|
||||
#include "core/net/downloadmanager.h"
|
||||
#include "core/net/downloadhandler.h"
|
||||
#include "core/bittorrent/trackerentry.h"
|
||||
#include "core/bittorrent/torrenthandle.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
class TrackersAdditionDlg : public QDialog, private Ui::TrackersAdditionDlg{
|
||||
Q_OBJECT
|
||||
@@ -80,7 +80,7 @@ public slots:
|
||||
QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
uTorrentListButton->setEnabled(true);
|
||||
fsutils::forceRemove(path);
|
||||
Utils::Fs::forceRemove(path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public slots:
|
||||
}
|
||||
// Clean up
|
||||
list_file.close();
|
||||
fsutils::forceRemove(path);
|
||||
Utils::Fs::forceRemove(path);
|
||||
//To restore the cursor ...
|
||||
setCursor(Qt::ArrowCursor);
|
||||
uTorrentListButton->setEnabled(true);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "rssfeed.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& manager, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -247,7 +247,7 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
|
||||
else
|
||||
ui->lineEFilter->clear();
|
||||
ui->saveDiffDir_check->setChecked(!rule->savePath().isEmpty());
|
||||
ui->lineSavePath->setText(fsutils::toNativePath(rule->savePath()));
|
||||
ui->lineSavePath->setText(Utils::Fs::toNativePath(rule->savePath()));
|
||||
ui->checkRegex->setChecked(rule->useRegex());
|
||||
if (rule->label().isEmpty()) {
|
||||
ui->comboLabel->setCurrentIndex(-1);
|
||||
@@ -398,7 +398,7 @@ void AutomatedRssDownloader::on_browseSP_clicked()
|
||||
{
|
||||
QString save_path = QFileDialog::getExistingDirectory(this, tr("Destination directory"), QDir::homePath());
|
||||
if (!save_path.isEmpty())
|
||||
ui->lineSavePath->setText(fsutils::toNativePath(save_path));
|
||||
ui->lineSavePath->setText(Utils::Fs::toNativePath(save_path));
|
||||
}
|
||||
|
||||
void AutomatedRssDownloader::on_exportBtn_clicked()
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include <QDateTime>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
HtmlBrowser::HtmlBrowser(QWidget* parent)
|
||||
: QTextBrowser(parent)
|
||||
{
|
||||
m_netManager = new QNetworkAccessManager(this);
|
||||
m_diskCache = new QNetworkDiskCache(this);
|
||||
m_diskCache->setCacheDirectory(QDir::cleanPath(fsutils::cacheLocation() + "/rss"));
|
||||
m_diskCache->setCacheDirectory(QDir::cleanPath(Utils::Fs::cacheLocation() + "/rss"));
|
||||
m_diskCache->setMaximumCacheSize(50 * 1024 * 1024);
|
||||
qDebug() << "HtmlBrowser cache path:" << m_diskCache->cacheDirectory() << " max size:" << m_diskCache->maximumCacheSize() / 1024 / 1024 << "MB";
|
||||
m_netManager->setCache(m_diskCache);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "core/preferences.h"
|
||||
#include "rssfeed.h"
|
||||
#include "rssarticle.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
RssDownloadRule::RssDownloadRule(): m_enabled(false), m_useRegex(false), m_apstate(USE_GLOBAL)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ bool RssDownloadRule::operator==(const RssDownloadRule &other) const {
|
||||
void RssDownloadRule::setSavePath(const QString &save_path)
|
||||
{
|
||||
if (!save_path.isEmpty() && QDir(save_path) != QDir(Preferences::instance()->getSavePath()))
|
||||
m_savePath = fsutils::fromNativePath(save_path);
|
||||
m_savePath = Utils::Fs::fromNativePath(save_path);
|
||||
else
|
||||
m_savePath = QString();
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
#include "core/qinisettings.h"
|
||||
#include "rssarticle.h"
|
||||
#include "rssparser.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "rssdownloadrulelist.h"
|
||||
#include "core/net/downloadmanager.h"
|
||||
#include "core/net/downloadhandler.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/logger.h"
|
||||
|
||||
bool rssArticleDateRecentThan(const RssArticlePtr& left, const RssArticlePtr& right)
|
||||
@@ -78,7 +78,7 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString& url):
|
||||
RssFeed::~RssFeed()
|
||||
{
|
||||
if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
|
||||
fsutils::forceRemove(m_icon);
|
||||
Utils::Fs::forceRemove(m_icon);
|
||||
}
|
||||
|
||||
void RssFeed::saveItemsToDisk()
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "rssparser.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
@@ -214,7 +214,7 @@ void RssParser::parseRssFile(const QString& feedUrl, const QString& filePath)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << feedUrl << filePath;
|
||||
m_mutex.lock();
|
||||
ParsingJob job = { feedUrl, fsutils::fromNativePath(filePath) };
|
||||
ParsingJob job = { feedUrl, Utils::Fs::fromNativePath(filePath) };
|
||||
m_queue.enqueue(job);
|
||||
// Wake up thread.
|
||||
if (m_queue.count() == 1) {
|
||||
@@ -499,11 +499,11 @@ void RssParser::parseFeed(const ParsingJob& job)
|
||||
// Clean up
|
||||
fileRss.close();
|
||||
emit feedParsingFinished(job.feedUrl, QString());
|
||||
fsutils::forceRemove(job.filePath);
|
||||
Utils::Fs::forceRemove(job.filePath);
|
||||
}
|
||||
|
||||
void RssParser::reportFailure(const ParsingJob& job, const QString& error)
|
||||
{
|
||||
emit feedParsingFinished(job.feedUrl, error);
|
||||
fsutils::forceRemove(job.filePath);
|
||||
Utils::Fs::forceRemove(job.filePath);
|
||||
}
|
||||
|
||||
@@ -30,17 +30,18 @@
|
||||
* Contact : hammered999@gmail.com
|
||||
*/
|
||||
|
||||
#include "core/types.h"
|
||||
#include "shutdownconfirm.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutDownAction &action)
|
||||
ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownAction &action)
|
||||
: m_exitNow(0)
|
||||
, m_timeout(15)
|
||||
, m_action(action)
|
||||
{
|
||||
// Title and button
|
||||
if (m_action == NO_SHUTDOWN) {
|
||||
if (m_action == ShutdownAction::None) {
|
||||
setWindowTitle(tr("Exit confirmation"));
|
||||
m_exitNow = addButton(tr("Exit now"), QMessageBox::AcceptRole);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutDownAction &action)
|
||||
connect(&m_timer, SIGNAL(m_timeout()), this, SLOT(updateSeconds()));
|
||||
show();
|
||||
// Move to center
|
||||
move(misc::screenCenter(this));
|
||||
move(Utils::Misc::screenCenter(this));
|
||||
}
|
||||
|
||||
void ShutdownConfirmDlg::showEvent(QShowEvent *event)
|
||||
@@ -71,7 +72,7 @@ void ShutdownConfirmDlg::showEvent(QShowEvent *event)
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
bool ShutdownConfirmDlg::askForConfirmation(const ShutDownAction &action)
|
||||
bool ShutdownConfirmDlg::askForConfirmation(const ShutdownAction &action)
|
||||
{
|
||||
ShutdownConfirmDlg dlg(action);
|
||||
dlg.exec();
|
||||
@@ -104,16 +105,16 @@ void ShutdownConfirmDlg::updateText()
|
||||
QString text;
|
||||
|
||||
switch (m_action) {
|
||||
case NO_SHUTDOWN:
|
||||
case ShutdownAction::None:
|
||||
text = tr("qBittorrent will now exit unless you cancel within the next %1 seconds.").arg(QString::number(m_timeout));
|
||||
break;
|
||||
case SHUTDOWN_COMPUTER:
|
||||
case ShutdownAction::Shutdown:
|
||||
text = tr("The computer will now be switched off unless you cancel within the next %1 seconds.").arg(QString::number(m_timeout));
|
||||
break;
|
||||
case SUSPEND_COMPUTER:
|
||||
case ShutdownAction::Suspend:
|
||||
text = tr("The computer will now go to sleep mode unless you cancel within the next %1 seconds.").arg(QString::number(m_timeout));
|
||||
break;
|
||||
case HIBERNATE_COMPUTER:
|
||||
case ShutdownAction::Hibernate:
|
||||
text = tr("The computer will now go to hibernation mode unless you cancel within the next %1 seconds.").arg(QString::number(m_timeout));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
|
||||
class ShutdownConfirmDlg : public QMessageBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShutdownConfirmDlg(const ShutDownAction &action);
|
||||
ShutdownConfirmDlg(const ShutdownAction &action);
|
||||
bool shutdown() const;
|
||||
|
||||
static bool askForConfirmation(const ShutDownAction &action);
|
||||
static bool askForConfirmation(const ShutdownAction &action);
|
||||
|
||||
QAbstractButton *getExit_now() const;
|
||||
void setExit_now(QAbstractButton *value);
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
QAbstractButton *m_exitNow;
|
||||
QTimer m_timer;
|
||||
int m_timeout;
|
||||
ShutDownAction m_action;
|
||||
ShutdownAction m_action;
|
||||
};
|
||||
|
||||
#endif // SHUTDOWNCONFIRM_H
|
||||
|
||||
@@ -37,7 +37,7 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent): QDialog(parent)
|
||||
// Connect to slots
|
||||
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int)));
|
||||
connect(spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int)));
|
||||
move(misc::screenCenter(this));
|
||||
move(Utils::Misc::screenCenter(this));
|
||||
}
|
||||
|
||||
SpeedLimitDialog::~SpeedLimitDialog()
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include "ui_bandwidth_limit.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
|
||||
class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg {
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
#include "statsdialog.h"
|
||||
#include "ui_statsdialog.h"
|
||||
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "core/bittorrent/sessionstatus.h"
|
||||
#include "core/bittorrent/cachestatus.h"
|
||||
@@ -65,21 +66,21 @@ void StatsDialog::updateUI() {
|
||||
// Alltime DL/UL
|
||||
quint64 atd = BitTorrent::Session::instance()->getAlltimeDL();
|
||||
quint64 atu = BitTorrent::Session::instance()->getAlltimeUL();
|
||||
ui->labelAlltimeDL->setText(misc::friendlyUnit(atd));
|
||||
ui->labelAlltimeUL->setText(misc::friendlyUnit(atu));
|
||||
ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd));
|
||||
ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu));
|
||||
// Total waste (this session)
|
||||
ui->labelWaste->setText(misc::friendlyUnit(ss.totalWasted()));
|
||||
ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted()));
|
||||
// Global ratio
|
||||
ui->labelGlobalRatio->setText(
|
||||
( atd > 0 && atu > 0 ) ?
|
||||
misc::accurateDoubleToString((qreal)atu / (qreal)atd, 2) :
|
||||
Utils::String::fromDouble((qreal)atu / (qreal)atd, 2) :
|
||||
"-"
|
||||
);
|
||||
// Cache hits
|
||||
qreal readRatio = cs.readRatio();
|
||||
ui->labelCacheHits->setText((readRatio >= 0) ? misc::accurateDoubleToString(100 * readRatio, 2) : "-");
|
||||
ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-");
|
||||
// Buffers size
|
||||
ui->labelTotalBuf->setText(misc::friendlyUnit(cs.totalUsedBuffers() * 16 * 1024));
|
||||
ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers() * 16 * 1024));
|
||||
// Disk overload (100%) equivalent
|
||||
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
|
||||
// to complete before it receives or sends any more data on the socket. It'a a metric of how disk bound you are.
|
||||
@@ -90,15 +91,15 @@ void StatsDialog::updateUI() {
|
||||
peers += torrent->peersCount();
|
||||
|
||||
ui->labelWriteStarve->setText(QString("%1%").arg(((ss.diskWriteQueue() > 0) && (peers > 0))
|
||||
? misc::accurateDoubleToString((100. * ss.diskWriteQueue()) / peers, 2)
|
||||
? Utils::String::fromDouble((100. * ss.diskWriteQueue()) / peers, 2)
|
||||
: "0"));
|
||||
ui->labelReadStarve->setText(QString("%1%").arg(((ss.diskReadQueue() > 0) && (peers > 0))
|
||||
? misc::accurateDoubleToString((100. * ss.diskReadQueue()) / peers, 2)
|
||||
? Utils::String::fromDouble((100. * ss.diskReadQueue()) / peers, 2)
|
||||
: "0"));
|
||||
// Disk queues
|
||||
ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength()));
|
||||
ui->labelJobsTime->setText(QString::number(cs.averageJobTime()));
|
||||
ui->labelQueuedBytes->setText(misc::friendlyUnit(cs.queuedBytes()));
|
||||
ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes()));
|
||||
|
||||
// Total connected peers
|
||||
ui->labelPeers->setText(QString::number(ss.peersCount()));
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "speedlimitdlg.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/preferences.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/logger.h"
|
||||
|
||||
StatusBar::StatusBar(QStatusBar *bar)
|
||||
@@ -181,15 +181,15 @@ void StatusBar::refreshStatusBar() {
|
||||
//statusSep1->setVisible(false);
|
||||
}
|
||||
// Update speed labels
|
||||
QString speedLbl = misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true)+" ("+misc::friendlyUnit(sessionStatus.totalPayloadDownload())+")";
|
||||
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload())+")";
|
||||
int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
|
||||
if (speedLimit)
|
||||
speedLbl = "["+misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
|
||||
speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
|
||||
dlSpeedLbl->setText(speedLbl);
|
||||
speedLimit = BitTorrent::Session::instance()->uploadRateLimit();
|
||||
speedLbl = misc::friendlyUnit(sessionStatus.payloadUploadRate(), true)+" ("+misc::friendlyUnit(sessionStatus.totalPayloadUpload())+")";
|
||||
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload())+")";
|
||||
if (speedLimit)
|
||||
speedLbl = "["+misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
|
||||
speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
|
||||
upSpeedLbl->setText(speedLbl);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "core/utils/string.h"
|
||||
#include "torrentcontentfiltermodel.h"
|
||||
#include "torrentcontentmodel.h"
|
||||
|
||||
@@ -95,7 +96,7 @@ bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIn
|
||||
rightType = m_model->itemType(m_model->index(right.row(), 0, right.parent()));
|
||||
if (leftType == rightType) {
|
||||
bool res = false;
|
||||
if (misc::naturalSort(vL.toString(), vR.toString(), res))
|
||||
if (Utils::String::naturalSort(vL.toString(), vR.toString(), res))
|
||||
return res;
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#include <QIcon>
|
||||
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "torrentcontentmodel.h"
|
||||
#include "torrentcontentmodelitem.h"
|
||||
#include "torrentcontentmodelfolder.h"
|
||||
@@ -296,7 +296,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
|
||||
// Iterate over files
|
||||
for (int i = 0; i < info.filesCount(); ++i) {
|
||||
current_parent = m_rootItem;
|
||||
QString path = fsutils::fromNativePath(info.filePath(i));
|
||||
QString path = Utils::Fs::fromNativePath(info.filePath(i));
|
||||
// Iterate of parts of the path to create necessary folders
|
||||
QStringList pathFolders = path.split("/", QString::SkipEmptyParts);
|
||||
pathFolders.removeLast();
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "core/misc.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "torrentcontentmodelitem.h"
|
||||
#include "torrentcontentmodelfolder.h"
|
||||
#include <QDebug>
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "torrentcreatordlg.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/preferences.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
@@ -73,7 +73,7 @@ void TorrentCreatorDlg::on_addFolder_button_clicked() {
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
|
||||
if (!dir.isEmpty()) {
|
||||
pref->setCreateTorLastAddPath(dir);
|
||||
textInputPath->setText(fsutils::toNativePath(dir));
|
||||
textInputPath->setText(Utils::Fs::toNativePath(dir));
|
||||
// Update piece size
|
||||
if (checkAutoPieceSize->isChecked())
|
||||
updateOptimalPieceSize();
|
||||
@@ -85,8 +85,8 @@ void TorrentCreatorDlg::on_addFile_button_clicked() {
|
||||
QString last_path = pref->getCreateTorLastAddPath();
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
|
||||
if (!file.isEmpty()) {
|
||||
pref->setCreateTorLastAddPath(fsutils::branchPath(file));
|
||||
textInputPath->setText(fsutils::toNativePath(file));
|
||||
pref->setCreateTorLastAddPath(Utils::Fs::branchPath(file));
|
||||
textInputPath->setText(Utils::Fs::toNativePath(file));
|
||||
// Update piece size
|
||||
if (checkAutoPieceSize->isChecked())
|
||||
updateOptimalPieceSize();
|
||||
@@ -99,7 +99,7 @@ int TorrentCreatorDlg::getPieceSize() const {
|
||||
|
||||
// Main function that create a .torrent file
|
||||
void TorrentCreatorDlg::on_createButton_clicked() {
|
||||
QString input = fsutils::fromNativePath(textInputPath->text()).trimmed();
|
||||
QString input = Utils::Fs::fromNativePath(textInputPath->text()).trimmed();
|
||||
if (input.endsWith("/"))
|
||||
input.chop(1);
|
||||
if (input.isEmpty()) {
|
||||
@@ -115,7 +115,7 @@ void TorrentCreatorDlg::on_createButton_clicked() {
|
||||
|
||||
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), last_path, tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
|
||||
if (!destination.isEmpty()) {
|
||||
pref->setCreateTorLastSavePath(fsutils::branchPath(destination));
|
||||
pref->setCreateTorLastSavePath(Utils::Fs::branchPath(destination));
|
||||
if (!destination.toUpper().endsWith(".TORRENT"))
|
||||
destination += QString::fromUtf8(".torrent");
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||
setCursor(QCursor(Qt::ArrowCursor));
|
||||
if (checkStartSeeding->isChecked()) {
|
||||
// Create save path temp data
|
||||
BitTorrent::TorrentInfo t = BitTorrent::TorrentInfo::loadFromFile(fsutils::toNativePath(path));
|
||||
BitTorrent::TorrentInfo t = BitTorrent::TorrentInfo::loadFromFile(Utils::Fs::toNativePath(path));
|
||||
if (!t.isValid()) {
|
||||
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
|
||||
return;
|
||||
@@ -164,7 +164,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||
BitTorrent::Session::instance()->addTorrent(t, params);
|
||||
}
|
||||
|
||||
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+fsutils::toNativePath(path));
|
||||
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+Utils::Fs::toNativePath(path));
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ void TorrentCreatorDlg::on_checkAutoPieceSize_clicked(bool checked)
|
||||
|
||||
void TorrentCreatorDlg::updateOptimalPieceSize()
|
||||
{
|
||||
qint64 torrent_size = fsutils::computePathSize(textInputPath->text());
|
||||
qint64 torrent_size = Utils::Fs::computePathSize(textInputPath->text());
|
||||
qDebug("Torrent size is %lld", torrent_size);
|
||||
if (torrent_size < 0) return;
|
||||
int i = 0;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "core/bittorrent/infohash.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
|
||||
TorrentImportDlg::TorrentImportDlg(QWidget *parent):
|
||||
QDialog(parent),
|
||||
@@ -73,15 +73,15 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
{
|
||||
const QString default_dir = Preferences::instance()->getTorImportLastContentDir();
|
||||
bool multifile = (m_torrentInfo.filesCount() > 1);
|
||||
QString filePath = fsutils::fromNativePath(m_torrentInfo.filePath(0));
|
||||
QString filePath = Utils::Fs::fromNativePath(m_torrentInfo.filePath(0));
|
||||
if (!multifile && (filePath.indexOf('/') != -1))
|
||||
multifile = true;
|
||||
|
||||
if (!multifile) {
|
||||
// Single file torrent
|
||||
const QString file_name = fsutils::fileName(filePath);
|
||||
const QString file_name = Utils::Fs::fileName(filePath);
|
||||
qDebug("Torrent has only one file: %s", qPrintable(file_name));
|
||||
QString extension = fsutils::fileExtension(file_name);
|
||||
QString extension = Utils::Fs::fileExtension(file_name);
|
||||
qDebug("File extension is : %s", qPrintable(extension));
|
||||
QString filter;
|
||||
if (!extension.isEmpty()) {
|
||||
@@ -96,7 +96,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
return;
|
||||
}
|
||||
// Update display
|
||||
ui->lineContent->setText(fsutils::toNativePath(m_contentPath));
|
||||
ui->lineContent->setText(Utils::Fs::toNativePath(m_contentPath));
|
||||
// Check file size
|
||||
const qint64 file_size = QFile(m_contentPath).size();
|
||||
if (m_torrentInfo.fileSize(0) == file_size) {
|
||||
@@ -130,16 +130,16 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||
return;
|
||||
}
|
||||
// Update the display
|
||||
ui->lineContent->setText(fsutils::toNativePath(m_contentPath));
|
||||
ui->lineContent->setText(Utils::Fs::toNativePath(m_contentPath));
|
||||
bool size_mismatch = false;
|
||||
QDir content_dir(m_contentPath);
|
||||
content_dir.cdUp();
|
||||
// Check file sizes
|
||||
for (int i = 0; i < m_torrentInfo.filesCount(); ++i) {
|
||||
const QString rel_path = m_torrentInfo.filePath(i);
|
||||
if (QFile(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))).size() != m_torrentInfo.fileSize(i)) {
|
||||
if (QFile(Utils::Fs::expandPath(content_dir.absoluteFilePath(rel_path))).size() != m_torrentInfo.fileSize(i)) {
|
||||
qDebug("%s is %lld",
|
||||
qPrintable(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))).size());
|
||||
qPrintable(Utils::Fs::expandPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(Utils::Fs::expandPath(content_dir.absoluteFilePath(rel_path))).size());
|
||||
qDebug("%s is %lld",
|
||||
qPrintable(rel_path), (long long int)m_torrentInfo.fileSize(i));
|
||||
size_mismatch = true;
|
||||
@@ -204,8 +204,8 @@ void TorrentImportDlg::importTorrent()
|
||||
BitTorrent::Session::instance()->addTorrent(torrentInfo, params);
|
||||
// Remember the last opened folder
|
||||
Preferences* const pref = Preferences::instance();
|
||||
pref->setMainLastDir(fsutils::fromNativePath(torrentPath));
|
||||
pref->setTorImportLastContentDir(fsutils::fromNativePath(contentPath));
|
||||
pref->setMainLastDir(Utils::Fs::fromNativePath(torrentPath));
|
||||
pref->setTorImportLastContentDir(Utils::Fs::fromNativePath(contentPath));
|
||||
return;
|
||||
}
|
||||
qDebug() << Q_FUNC_INFO << "EXIT";
|
||||
@@ -223,7 +223,7 @@ void TorrentImportDlg::loadTorrent(const QString &torrentPath)
|
||||
}
|
||||
else {
|
||||
// Update display
|
||||
ui->lineTorrent->setText(fsutils::toNativePath(torrentPath));
|
||||
ui->lineTorrent->setText(Utils::Fs::toNativePath(torrentPath));
|
||||
ui->browseContentBtn->setEnabled(true);
|
||||
// Load the file names
|
||||
initializeFilesPath();
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "core/torrentfilter.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "torrentmodel.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
#include <QStyleOptionViewItemV2>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "torrentmodel.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "core/bittorrent/torrenthandle.h"
|
||||
@@ -65,13 +66,13 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
case TorrentModelItem::TR_TOTAL_SIZE: {
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::TR_ETA: {
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong()));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::userFriendlyDuration(index.data().toLongLong()));
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::TR_SEEDS:
|
||||
@@ -142,7 +143,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
const qulonglong speed = index.data().toULongLong();
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::TR_UPLIMIT:
|
||||
@@ -150,15 +151,15 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
const qlonglong limit = index.data().toLongLong();
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? misc::accurateDoubleToString(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8("∞"));
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::String::fromDouble(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8("∞"));
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::TR_TIME_ELAPSED: {
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
QString txt = misc::userFriendlyDuration(index.data().toLongLong());
|
||||
QString txt = Utils::Misc::userFriendlyDuration(index.data().toLongLong());
|
||||
qlonglong seeding_time = index.data(Qt::UserRole).toLongLong();
|
||||
if (seeding_time > 0)
|
||||
txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(seeding_time))+")";
|
||||
txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(seeding_time))+")";
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, txt);
|
||||
break;
|
||||
}
|
||||
@@ -173,7 +174,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
const qreal ratio = index.data().toDouble();
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect,
|
||||
((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2));
|
||||
((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2));
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::TR_PRIORITY: {
|
||||
@@ -191,7 +192,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
QStyleOptionProgressBarV2 newopt;
|
||||
qreal progress = index.data().toDouble()*100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : misc::accurateDoubleToString(progress, 1) + "%");
|
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
@@ -219,9 +220,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
// Show '< 1m ago' when elapsed time is 0
|
||||
elapsed = 1;
|
||||
if (elapsed < 0)
|
||||
elapsedString = misc::userFriendlyDuration(elapsed);
|
||||
elapsedString = Utils::Misc::userFriendlyDuration(elapsed);
|
||||
else
|
||||
elapsedString = tr("%1 ago", "e.g.: 1h 20m ago").arg(misc::userFriendlyDuration(elapsed));
|
||||
elapsedString = tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed));
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,14 +44,15 @@
|
||||
#include "core/preferences.h"
|
||||
#include "torrentmodel.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "core/torrentfilter.h"
|
||||
#include "core/bittorrent/trackerentry.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "core/net/downloadmanager.h"
|
||||
#include "core/net/downloadhandler.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/utils/misc.h"
|
||||
#include "core/logger.h"
|
||||
|
||||
FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList)
|
||||
@@ -202,7 +203,7 @@ void LabelFiltersList::addItem(QString &label, bool hasTorrent)
|
||||
{
|
||||
int labelCount = 0;
|
||||
QListWidgetItem *labelItem = 0;
|
||||
label = fsutils::toValidFileSystemName(label.trimmed());
|
||||
label = Utils::Fs::toValidFileSystemName(label.trimmed());
|
||||
item(0)->setText(tr("All (%1)", "this is for the label filter").arg(m_totalTorrents));
|
||||
|
||||
if (label.isEmpty()) {
|
||||
@@ -235,7 +236,7 @@ void LabelFiltersList::addItem(QString &label, bool hasTorrent)
|
||||
Q_ASSERT(count() >= 2);
|
||||
for (int i = 2; i<count(); ++i) {
|
||||
bool less = false;
|
||||
if (!(misc::naturalSort(label, item(i)->text(), less)))
|
||||
if (!(Utils::String::naturalSort(label, item(i)->text(), less)))
|
||||
less = (label.localeAwareCompare(item(i)->text()) < 0);
|
||||
if (less) {
|
||||
insertItem(i, labelItem);
|
||||
@@ -357,7 +358,7 @@ void LabelFiltersList::showMenu(QPoint)
|
||||
invalid = false;
|
||||
label = AutoExpandableDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, label, &ok);
|
||||
if (ok && !label.isEmpty()) {
|
||||
if (fsutils::isValidFileSystemName(label)) {
|
||||
if (Utils::Fs::isValidFileSystemName(label)) {
|
||||
addItem(label, false);
|
||||
}
|
||||
else {
|
||||
@@ -445,7 +446,7 @@ TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *tran
|
||||
TrackerFiltersList::~TrackerFiltersList()
|
||||
{
|
||||
foreach (const QString &iconPath, m_iconPaths)
|
||||
fsutils::forceRemove(iconPath);
|
||||
Utils::Fs::forceRemove(iconPath);
|
||||
}
|
||||
|
||||
void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
|
||||
@@ -493,7 +494,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
|
||||
Q_ASSERT(count() >= 4);
|
||||
for (int i = 4; i<count(); ++i) {
|
||||
bool less = false;
|
||||
if (!(misc::naturalSort(host, item(i)->text(), less)))
|
||||
if (!(Utils::String::naturalSort(host, item(i)->text(), less)))
|
||||
less = (host.localeAwareCompare(item(i)->text()) < 0);
|
||||
if (less) {
|
||||
insertItem(i, trackerItem);
|
||||
@@ -633,7 +634,7 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString&
|
||||
else {
|
||||
Logger::instance()->addMessage(tr("Couldn't decode favico for url `%1`.").arg(url), Log::WARNING);
|
||||
}
|
||||
fsutils::forceRemove(filePath);
|
||||
Utils::Fs::forceRemove(filePath);
|
||||
}
|
||||
else {
|
||||
trackerItem->setData(Qt::DecorationRole, QVariant(QIcon(filePath)));
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/misc.h"
|
||||
#include "core/types.h"
|
||||
#include "core/utils/string.h"
|
||||
#include "core/bittorrent/torrenthandle.h"
|
||||
#include "torrentmodel.h"
|
||||
#include "transferlistsortmodel.h"
|
||||
@@ -81,7 +82,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
return lowerPositionThan(left, right);
|
||||
|
||||
bool res = false;
|
||||
if (misc::naturalSort(vL.toString(), vR.toString(), res))
|
||||
if (Utils::String::naturalSort(vL.toString(), vR.toString(), res))
|
||||
return res;
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#include "deletionconfirmationdlg.h"
|
||||
#include "propertieswidget.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/fs_utils.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "transferlistsortmodel.h"
|
||||
|
||||
@@ -255,7 +255,7 @@ void TransferListWidget::setSelectedTorrentsLocation()
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
if (!torrent) continue;
|
||||
|
||||
torrent->move(fsutils::expandPathAbs(dir));
|
||||
torrent->move(Utils::Fs::expandPathAbs(dir));
|
||||
main_window->getProperties()->updateSavePath(torrent);
|
||||
}
|
||||
}
|
||||
@@ -622,7 +622,7 @@ void TransferListWidget::askNewLabelForSelection()
|
||||
invalid = false;
|
||||
const QString label = AutoExpandableDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, "", &ok).trimmed();
|
||||
if (ok && !label.isEmpty()) {
|
||||
if (fsutils::isValidFileSystemName(label)) {
|
||||
if (Utils::Fs::isValidFileSystemName(label)) {
|
||||
setSelectionLabel(label);
|
||||
}
|
||||
else {
|
||||
@@ -635,10 +635,10 @@ void TransferListWidget::askNewLabelForSelection()
|
||||
|
||||
bool TransferListWidget::openUrl(const QString &_path) const
|
||||
{
|
||||
const QString path = fsutils::fromNativePath(_path);
|
||||
const QString path = Utils::Fs::fromNativePath(_path);
|
||||
// Hack to access samba shares with QDesktopServices::openUrl
|
||||
if (path.startsWith("//"))
|
||||
return QDesktopServices::openUrl(fsutils::toNativePath("file:" + path));
|
||||
return QDesktopServices::openUrl(Utils::Fs::toNativePath("file:" + path));
|
||||
else
|
||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user