mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
Merge msvc fixes from stable branch
This commit is contained in:
parent
682377ff66
commit
8ec1621334
@ -288,13 +288,13 @@ void Bittorrent::configureSession() {
|
||||
startTorrentsInPause(Preferences::addTorrentsInPause());
|
||||
// * Scan dirs
|
||||
const QStringList &scan_dirs = Preferences::getScanDirs();
|
||||
QVariantList downloadInDirList = Preferences::getDownloadInScanDirs();
|
||||
QList<bool> downloadInDirList = Preferences::getDownloadInScanDirs();
|
||||
while(scan_dirs.size() > downloadInDirList.size()) {
|
||||
downloadInDirList << QVariant(false);
|
||||
downloadInDirList << false;
|
||||
}
|
||||
int i = 0;
|
||||
foreach (const QString &dir, scan_dirs) {
|
||||
m_scanFolders->addPath(dir, downloadInDirList.at(i).toBool());
|
||||
m_scanFolders->addPath(dir, downloadInDirList.at(i));
|
||||
++i;
|
||||
}
|
||||
// * Export Dir
|
||||
|
@ -133,7 +133,11 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
||||
if(m.contains("temp_path"))
|
||||
Preferences::setTempPath(m["temp_path"].toString());
|
||||
if(m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
|
||||
QVariantList download_at_path = m["download_in_scan_dirs"].toList();
|
||||
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
|
||||
QList<bool> download_at_path;
|
||||
foreach(QVariant var, download_at_path_tmp) {
|
||||
download_at_path << var.toBool();
|
||||
}
|
||||
QStringList old_folders = Preferences::getScanDirs();
|
||||
QStringList new_folders = m["scan_dirs"].toStringList();
|
||||
if(download_at_path.size() == new_folders.size()) {
|
||||
@ -149,7 +153,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
||||
foreach(const QString &new_folder, new_folders) {
|
||||
// Update new folders
|
||||
if(!old_folders.contains(new_folder)) {
|
||||
BTSession->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i).toBool());
|
||||
BTSession->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
@ -258,7 +262,11 @@ QVariantMap EventManager::getGlobalPreferences() const {
|
||||
data["temp_path_enabled"] = Preferences::isTempPathEnabled();
|
||||
data["temp_path"] = Preferences::getTempPath();
|
||||
data["scan_dirs"] = Preferences::getScanDirs();
|
||||
data["download_in_scan_dirs"] = Preferences::getDownloadInScanDirs();
|
||||
QVariantList var_list;
|
||||
foreach(bool b, Preferences::getDownloadInScanDirs()) {
|
||||
var_list << b;
|
||||
}
|
||||
data["download_in_scan_dirs"] = var_list;
|
||||
data["export_dir_enabled"] = Preferences::isTorrentExportEnabled();
|
||||
data["export_dir"] = Preferences::getExportDir();
|
||||
data["preallocate_all"] = Preferences::preAllocateAllFiles();
|
||||
|
30
src/misc.cpp
30
src/misc.cpp
@ -544,3 +544,33 @@ QString misc::userFriendlyDuration(qlonglong seconds) {
|
||||
}
|
||||
return QString::fromUtf8("∞");
|
||||
}
|
||||
|
||||
QStringList misc::toStringList(const QList<bool> &l) {
|
||||
QStringList ret;
|
||||
foreach(const bool &b, l) {
|
||||
if(b)
|
||||
ret << "1";
|
||||
else
|
||||
ret << "0";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<int> misc::intListfromStringList(const QStringList &l) {
|
||||
QList<int> ret;
|
||||
foreach(const QString &s, l) {
|
||||
ret << s.toInt();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<bool> misc::boolListfromStringList(const QStringList &l) {
|
||||
QList<bool> ret;
|
||||
foreach(const QString &s, l) {
|
||||
if(s == "1")
|
||||
ret << true;
|
||||
else
|
||||
ret << false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -121,6 +121,11 @@ public:
|
||||
// Take a number of seconds and return an user-friendly
|
||||
// time duration like "1d 2h 10m".
|
||||
static QString userFriendlyDuration(qlonglong seconds);
|
||||
|
||||
// Convert functions
|
||||
static QStringList toStringList(const QList<bool> &l);
|
||||
static QList<int> intListfromStringList(const QStringList &l);
|
||||
static QList<bool> boolListfromStringList(const QStringList &l);
|
||||
};
|
||||
|
||||
// Trick to get a portable sleep() function
|
||||
|
@ -44,8 +44,6 @@
|
||||
#include <QMenu>
|
||||
#include <vector>
|
||||
|
||||
Q_DECLARE_METATYPE(QList<int>)
|
||||
|
||||
PeerListWidget::PeerListWidget(PropertiesWidget *parent): properties(parent), display_flags(false) {
|
||||
// Visual settings
|
||||
setRootIsDecorated(false);
|
||||
@ -246,7 +244,7 @@ void PeerListWidget::clear() {
|
||||
|
||||
void PeerListWidget::loadSettings() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariantList()).value<QList<int> >();
|
||||
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth")).toStringList());
|
||||
if(!contentColsWidths.empty()) {
|
||||
for(int i=0; i<contentColsWidths.size(); ++i) {
|
||||
setColumnWidth(i, contentColsWidths.at(i));
|
||||
@ -268,11 +266,11 @@ void PeerListWidget::loadSettings() {
|
||||
|
||||
void PeerListWidget::saveSettings() const {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths;
|
||||
QStringList contentColsWidths;
|
||||
for(int i=0; i<listModel->columnCount(); ++i) {
|
||||
contentColsWidths.append(columnWidth(i));
|
||||
contentColsWidths << QString::number(columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariant::fromValue<QList<int> >(contentColsWidths));
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths);
|
||||
// Save sorted column
|
||||
Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
|
||||
QString sortOrderLetter;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QPair>
|
||||
#include <QDir>
|
||||
#include <QTime>
|
||||
#include <QList>
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#include <QApplication>
|
||||
@ -47,6 +48,8 @@
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#define QBT_REALM "Web UI Access"
|
||||
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
|
||||
|
||||
@ -223,14 +226,14 @@ public:
|
||||
settings.setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), dirs);
|
||||
}
|
||||
|
||||
static QVariantList getDownloadInScanDirs() {
|
||||
static QList<bool> getDownloadInScanDirs() {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
return settings.value(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), QVariantList()).toList();
|
||||
return misc::boolListfromStringList(settings.value(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs")).toStringList());
|
||||
}
|
||||
|
||||
static void setDownloadInScanDirs(const QVariantList &list) {
|
||||
static void setDownloadInScanDirs(const QList<bool> &list) {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
settings.setValue(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), list);
|
||||
settings.setValue(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), misc::toStringList(list));
|
||||
}
|
||||
|
||||
static bool isTorrentExportEnabled() {
|
||||
|
@ -52,8 +52,6 @@
|
||||
#include "downloadedpiecesbar.h"
|
||||
#include "pieceavailabilitybar.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QList<int>)
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#define DEFAULT_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px; margin-left: 8px; margin-right: 8px;}"
|
||||
#define SELECTED_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px;background-color: rgb(255, 208, 105); margin-left: 8px; margin-right: 8px;}"
|
||||
@ -267,7 +265,7 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
||||
|
||||
void PropertiesWidget::readSettings() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth"), QVariantList()).value<QList<int> >();
|
||||
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth")).toStringList());
|
||||
if(contentColsWidths.empty()) {
|
||||
filesList->header()->resizeSection(0, 300);
|
||||
} else {
|
||||
@ -294,11 +292,11 @@ void PropertiesWidget::readSettings() {
|
||||
void PropertiesWidget::saveSettings() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
||||
QList<int> contentColsWidths;
|
||||
QStringList contentColsWidths;
|
||||
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
||||
contentColsWidths.append(filesList->columnWidth(i));
|
||||
contentColsWidths << QString::number(filesList->columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), QVariant::fromValue<QList<int> >(contentColsWidths));
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
||||
// Splitter sizes
|
||||
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
|
||||
QList<int> sizes;
|
||||
|
@ -345,7 +345,7 @@ public:
|
||||
return item;
|
||||
}
|
||||
|
||||
static RssItem* fromHash(RssStream* parent, QHash<QString, QVariant> h) {
|
||||
static RssItem* fromHash(RssStream* parent, const QHash<QString, QVariant> &h) {
|
||||
return new RssItem(parent, h.value("id", "").toString(), h["title"].toString(), h["torrent_url"].toString(), h["news_link"].toString(),
|
||||
h["description"].toString(), h["date"].toDateTime(), h["author"].toString(), h["read"].toBool());
|
||||
}
|
||||
|
@ -251,13 +251,12 @@ void RSSImp::deleteSelectedItems() {
|
||||
void RSSImp::loadFoldersOpenState() {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
settings.beginGroup("Rss");
|
||||
QVariantList open_folders = settings.value("open_folders", QVariantList()).toList();
|
||||
QStringList open_folders = settings.value("open_folders", QStringList()).toStringList();
|
||||
settings.endGroup();
|
||||
foreach(QVariant var_path, open_folders) {
|
||||
QStringList path = var_path.toString().split("\\");
|
||||
foreach(QString var_path, open_folders) {
|
||||
QStringList path = var_path.split("\\");
|
||||
QTreeWidgetItem *parent = 0;
|
||||
foreach(QString name, path) {
|
||||
QList<QTreeWidgetItem*> children;
|
||||
int nbChildren = 0;
|
||||
if(parent)
|
||||
nbChildren = parent->childCount();
|
||||
@ -281,7 +280,7 @@ void RSSImp::loadFoldersOpenState() {
|
||||
}
|
||||
|
||||
void RSSImp::saveFoldersOpenState() {
|
||||
QVariantList open_folders;
|
||||
QStringList open_folders;
|
||||
QList<QTreeWidgetItem*> items = listStreams->getAllOpenFolders();
|
||||
foreach(QTreeWidgetItem* item, items) {
|
||||
QString path = listStreams->getItemPath(item).join("\\");
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "transferlistwidget.h"
|
||||
|
||||
using namespace libtorrent;
|
||||
Q_DECLARE_METATYPE(QList<int>)
|
||||
|
||||
class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||
Q_OBJECT
|
||||
@ -126,7 +125,7 @@ public:
|
||||
resize(settings.value(QString::fromUtf8("TorrentAdditionDlg/size"), size()).toSize());
|
||||
move(settings.value(QString::fromUtf8("TorrentAdditionDlg/pos"), misc::screenCenter(this)).toPoint());
|
||||
// Restore column width
|
||||
const QList<int> &contentColsWidths = settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth")).value<QList<int> >();
|
||||
const QList<int> &contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth")).toStringList());
|
||||
if(contentColsWidths.empty()) {
|
||||
torrentContentList->header()->resizeSection(0, 200);
|
||||
} else {
|
||||
@ -139,12 +138,12 @@ public:
|
||||
void saveSettings() {
|
||||
if(is_magnet) return;
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths;
|
||||
QStringList contentColsWidths;
|
||||
// -1 because we hid PROGRESS column
|
||||
for(int i=0; i<PropListModel->columnCount()-1; ++i) {
|
||||
contentColsWidths.append(torrentContentList->columnWidth(i));
|
||||
contentColsWidths << QString::number(torrentContentList->columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), QVariant::fromValue<QList<int> >(contentColsWidths));
|
||||
settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), contentColsWidths);
|
||||
settings.setValue("TorrentAdditionDlg/size", size());
|
||||
settings.setValue("TorrentAdditionDlg/pos", pos());
|
||||
}
|
||||
|
@ -69,9 +69,9 @@ public:
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
std::vector<int>::const_iterator pp_it = pp.begin();
|
||||
QVariantList pieces_priority;
|
||||
QStringList pieces_priority;
|
||||
while(pp_it != pp.end()) {
|
||||
pieces_priority << *pp_it;
|
||||
pieces_priority << QString::number(*pp_it);
|
||||
pp_it++;
|
||||
}
|
||||
data["files_priority"] = pieces_priority;
|
||||
@ -179,9 +179,9 @@ public:
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
std::vector<int> fp;
|
||||
if(data.contains("files_priority")) {
|
||||
QVariantList list_var = data["files_priority"].toList();
|
||||
foreach(const QVariant& var, list_var) {
|
||||
fp.push_back(var.toInt());
|
||||
QList<int> list_var = misc::intListfromStringList(data["files_priority"].toStringList());
|
||||
foreach(int var, list_var) {
|
||||
fp.push_back(var);
|
||||
}
|
||||
}
|
||||
return fp;
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "misc.h"
|
||||
#include "bittorrent.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QList<int>)
|
||||
|
||||
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
||||
// Graphical settings
|
||||
setRootIsDecorated(false);
|
||||
@ -363,7 +361,7 @@ void TrackerList::showTrackerListMenu(QPoint) {
|
||||
|
||||
void TrackerList::loadSettings() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth")).value<QList<int> >();
|
||||
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth")).toStringList());
|
||||
if(!contentColsWidths.empty()) {
|
||||
for(int i=0; i<contentColsWidths.size(); ++i) {
|
||||
setColumnWidth(i, contentColsWidths.at(i));
|
||||
@ -375,9 +373,9 @@ void TrackerList::loadSettings() {
|
||||
|
||||
void TrackerList::saveSettings() const {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QList<int> contentColsWidths;
|
||||
QStringList contentColsWidths;
|
||||
for(int i=0; i<columnCount(); ++i) {
|
||||
contentColsWidths.append(columnWidth(i));
|
||||
contentColsWidths << QString::number(columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth"), QVariant::fromValue<QList<int> >(contentColsWidths));
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth"), contentColsWidths);
|
||||
}
|
||||
|
@ -52,8 +52,6 @@
|
||||
#include <QFileDialog>
|
||||
#include <vector>
|
||||
|
||||
Q_DECLARE_METATYPE(QList<int>)
|
||||
|
||||
TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession):
|
||||
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
@ -1263,11 +1261,11 @@ void TransferListWidget::saveColWidthList() {
|
||||
}
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TransferListColsWidth"), new_width_list.join(QString::fromUtf8(" ")));
|
||||
QList<int> visualIndexes;
|
||||
QStringList visualIndexes;
|
||||
for(int i=0; i<nbColumns; ++i) {
|
||||
visualIndexes.append(header()->visualIndex(i));
|
||||
visualIndexes << QString::number(header()->visualIndex(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TransferListVisualIndexes"), QVariant::fromValue< QList<int> >(visualIndexes));
|
||||
settings.setValue(QString::fromUtf8("TransferListVisualIndexes"), visualIndexes);
|
||||
qDebug("Download list columns width saved");
|
||||
}
|
||||
|
||||
@ -1287,7 +1285,7 @@ bool TransferListWidget::loadColWidthList() {
|
||||
for(unsigned int i=0; i<listSize; ++i) {
|
||||
header()->resizeSection(i, width_list.at(i).toInt());
|
||||
}
|
||||
const QList<int> visualIndexes = settings.value(QString::fromUtf8("TransferListVisualIndexes")).value<QList<int> >();
|
||||
const QList<int> visualIndexes = misc::intListfromStringList(settings.value(QString::fromUtf8("TransferListVisualIndexes")).toStringList());
|
||||
if(visualIndexes.size() != listModel->columnCount()-1) {
|
||||
qDebug("Corrupted values for transfer list columns indexes");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user