Browse Source

Update Main UI

adaptive-webui-19844
Nick Tiskov 11 years ago
parent
commit
4390530cbe
  1. 4
      src/mainwindow.cpp
  2. 16
      src/properties/propertieswidget.cpp
  3. 3
      src/qtlibtorrent/torrentmodel.cpp
  4. 5
      src/torrentcontentmodel.cpp
  5. 2
      src/transferlistwidget.cpp

4
src/mainwindow.cpp

@ -943,9 +943,9 @@ void MainWindow::on_actionOpen_triggered() { @@ -943,9 +943,9 @@ void MainWindow::on_actionOpen_triggered() {
QBtSession::instance()->addTorrent(pathsList.at(i));
}
// Save last dir to remember it
QStringList top_dir = pathsList.at(0).split(QDir::separator());
QStringList top_dir = fsutils::fromNativePath(pathsList.at(0)).split("/");
top_dir.removeLast();
settings.setValue(QString::fromUtf8("MainWindowLastDir"), top_dir.join(QDir::separator()));
settings.setValue(QString::fromUtf8("MainWindowLastDir"), fsutils::fromNativePath(top_dir.join("/")));
}
}

16
src/properties/propertieswidget.cpp

@ -220,7 +220,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const { @@ -220,7 +220,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
if (h.is_valid() && h == _h) {
save_path->setText(h.save_path_parsed());
save_path->setText(fsutils::toNativePath(h.save_path_parsed()));
}
}
@ -414,7 +414,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { @@ -414,7 +414,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
int i = PropListModel->getFileIndex(index);
const QDir saveDir(h.save_path());
const QString filename = h.filepath_at(i);
const QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
const QString file_path = fsutils::expandPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open file at %s", qPrintable(file_path));
// Flush data
h.flush_cache();
@ -433,8 +433,8 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { @@ -433,8 +433,8 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
parent = PropListModel->parent(parent);
}
const QDir saveDir(h.save_path());
const QString filename = path_items.join(QDir::separator());
const QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
const QString filename = path_items.join("/");
const QString file_path = fsutils::expandPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open folder at %s", qPrintable(file_path));
// Flush data
h.flush_cache();
@ -541,7 +541,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -541,7 +541,7 @@ void PropertiesWidget::renameSelectedFile() {
// File renaming
const int file_index = PropListModel->getFileIndex(index);
if (!h.is_valid() || !h.has_metadata()) return;
QString old_name = h.filepath_at(file_index).replace("\\", "/");
QString old_name = h.filepath_at(file_index);
if (old_name.endsWith(".!qB") && !new_name_last.endsWith(".!qB")) {
new_name_last += ".!qB";
}
@ -553,7 +553,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -553,7 +553,7 @@ void PropertiesWidget::renameSelectedFile() {
qDebug("Name did not change");
return;
}
new_name = QDir::cleanPath(new_name);
new_name = fsutils::expandPathAbs(new_name);
// Check if that name is already used
for (int i=0; i<h.num_files(); ++i) {
if (i == file_index) continue;
@ -569,7 +569,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -569,7 +569,7 @@ void PropertiesWidget::renameSelectedFile() {
return;
}
}
const bool force_recheck = QFile::exists(h.save_path()+QDir::separator()+new_name);
const bool force_recheck = QFile::exists(h.save_path()+"/"+new_name);
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
h.rename_file(file_index, new_name);
// Force recheck
@ -616,7 +616,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -616,7 +616,7 @@ void PropertiesWidget::renameSelectedFile() {
new_name.replace(0, old_path.length(), new_path);
if (!force_recheck && QDir(h.save_path()).exists(new_name))
force_recheck = true;
new_name = QDir::cleanPath(new_name);
new_name = fsutils::expandPathAbs(new_name);
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
h.rename_file(i, new_name);
}

3
src/qtlibtorrent/torrentmodel.cpp

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include "torrentmodel.h"
#include "torrentpersistentdata.h"
#include "qbtsession.h"
#include "fs_utils.h"
using namespace libtorrent;
@ -215,7 +216,7 @@ QVariant TorrentModelItem::data(int column, int role) const @@ -215,7 +216,7 @@ QVariant TorrentModelItem::data(int column, int role) const
case TR_TIME_ELAPSED:
return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time();
case TR_SAVE_PATH:
return m_torrent.save_path_parsed();
return fsutils::toNativePath(m_torrent.save_path_parsed());
default:
return QVariant();
}

5
src/torrentcontentmodel.cpp

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#include "iconprovider.h"
#include "misc.h"
#include "fs_utils.h"
#include "torrentcontentmodel.h"
#include "torrentcontentmodelitem.h"
#include "torrentcontentmodelfolder.h"
@ -283,9 +284,9 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info& t) @@ -283,9 +284,9 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info& t)
for (int i = 0; i < t.num_files(); ++i) {
const libtorrent::file_entry& fentry = t.file_at(i);
current_parent = m_rootItem;
QString path = misc::toQStringU(fentry.path);
QString path = fsutils::fromNativePath(misc::toQStringU(fentry.path));
// Iterate of parts of the path to create necessary folders
QStringList pathFolders = path.split(QRegExp("[/\\\\]"), QString::SkipEmptyParts);
QStringList pathFolders = path.split("/", QString::SkipEmptyParts);
pathFolders.removeLast();
foreach (const QString& pathPart, pathFolders) {
if (pathPart == ".unwanted")

2
src/transferlistwidget.cpp

@ -260,7 +260,7 @@ void TransferListWidget::setSelectedTorrentsLocation() { @@ -260,7 +260,7 @@ void TransferListWidget::setSelectedTorrentsLocation() {
if (!dir.isNull()) {
qDebug("New path is %s", qPrintable(dir));
// Check if savePath exists
QDir savePath(fsutils::expandPath(dir));
QDir savePath(fsutils::expandPathAbs(dir));
qDebug("New path after clean up is %s", qPrintable(savePath.absolutePath()));
foreach (const QString & hash, hashes) {
// Actually move storage

Loading…
Cancel
Save