Browse Source

Code clean up

adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
307ca61c86
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 8
      src/base/utils/string.h
  2. 12
      src/gui/properties/propertieswidget.cpp
  3. 6
      src/gui/properties/propertieswidget.h

8
src/base/utils/string.h

@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
#ifndef UTILS_STRING_H
#define UTILS_STRING_H
#include <QLatin1String>
#include <QChar>
#include <QVector>
class QString;
@ -54,13 +54,13 @@ namespace Utils @@ -54,13 +54,13 @@ namespace Utils
QString wildcardToRegex(const QString &pattern);
template <typename T>
T unquote(const T &str, const QString &quotes = QLatin1String("\""))
T unquote(const T &str, const QString &quotes = QChar('"'))
{
if (str.length() < 2) return str;
for (const auto &quote : quotes) {
for (const QChar quote : quotes) {
if (str.startsWith(quote) && str.endsWith(quote))
return str.mid(1, str.length() - 2);
return str.mid(1, (str.length() - 2));
}
return str;

12
src/gui/properties/propertieswidget.cpp

@ -517,7 +517,7 @@ void PropertiesWidget::loadUrlSeeds() @@ -517,7 +517,7 @@ void PropertiesWidget::loadUrlSeeds()
}
}
void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index) const
{
if (!index.isValid() || !m_torrent || !m_torrent->hasMetadata()) return;
@ -527,7 +527,7 @@ void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index) @@ -527,7 +527,7 @@ void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
openFolder(index, false);
}
void PropertiesWidget::openFile(const QModelIndex &index)
void PropertiesWidget::openFile(const QModelIndex &index) const
{
int i = m_propListModel->getFileIndex(index);
const QDir saveDir(m_torrent->savePath(true));
@ -539,14 +539,13 @@ void PropertiesWidget::openFile(const QModelIndex &index) @@ -539,14 +539,13 @@ void PropertiesWidget::openFile(const QModelIndex &index)
Utils::Gui::openPath(filePath);
}
void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolder)
void PropertiesWidget::openFolder(const QModelIndex &index, const bool containingFolder) const
{
QString absolutePath;
// FOLDER
if (m_propListModel->itemType(index) == TorrentContentModelItem::FolderType) {
// Generate relative path to selected folder
QStringList pathItems;
pathItems << index.data().toString();
QStringList pathItems {index.data().toString()};
QModelIndex parent = m_propListModel->parent(index);
while (parent.isValid()) {
pathItems.prepend(parent.data().toString());
@ -554,12 +553,13 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde @@ -554,12 +553,13 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde
}
if (pathItems.isEmpty())
return;
const QDir saveDir(m_torrent->savePath(true));
const QString relativePath = pathItems.join('/');
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
}
else {
int i = m_propListModel->getFileIndex(index);
const int i = m_propListModel->getFileIndex(index);
const QDir saveDir(m_torrent->savePath(true));
const QString relativePath = m_torrent->filePath(i);
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));

6
src/gui/properties/propertieswidget.h

@ -82,7 +82,7 @@ public slots: @@ -82,7 +82,7 @@ public slots:
void readSettings();
void saveSettings();
void reloadPreferences();
void openDoubleClickedFile(const QModelIndex &);
void openDoubleClickedFile(const QModelIndex &index) const;
void loadTrackers(BitTorrent::TorrentHandle *const torrent);
protected slots:
@ -107,8 +107,8 @@ private slots: @@ -107,8 +107,8 @@ private slots:
private:
QPushButton *getButtonFromIndex(int index);
void applyPriorities();
void openFile(const QModelIndex &index);
void openFolder(const QModelIndex &index, bool containingFolder);
void openFile(const QModelIndex &index) const;
void openFolder(const QModelIndex &index, bool containingFolder) const;
Ui::PropertiesWidget *m_ui;
BitTorrent::TorrentHandle *m_torrent;

Loading…
Cancel
Save