diff --git a/AUTHORS b/AUTHORS index fc4e7d208..77eb4b16f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,6 +4,7 @@ Author: Contributors: * Stefanos Antaris * Mohammad Dib +* Mirco Chinelli * Ishan Arora * Arnaud Demaizière * Grigis Gaëtan diff --git a/src/about_imp.h b/src/about_imp.h index d5400c470..b902a5cbb 100644 --- a/src/about_imp.h +++ b/src/about_imp.h @@ -54,7 +54,7 @@ class about : public QDialog, private Ui::AboutDlg{ te_thanks->append(QString::fromUtf8("")); te_thanks->append(QString::fromUtf8("
  • I would first like to thank sourceforge.net for hosting qBittorrent project and for their support.
  • ")); te_thanks->append(QString::fromUtf8("
  • I am pleased that people from all over the world are contributing to qBittorrent: Ishan Arora (India), Arnaud Demaizière (France) and Stephanos Antaris (Greece). Their help is greatly appreciated
  • ")); - te_thanks->append(QString::fromUtf8("
  • I also want to thank Στέφανος Αντάρης (santaris@csd.auth.gr) for working on Mac OS X packaging.
  • ")); + te_thanks->append(QString::fromUtf8("
  • I also want to thank Στέφανος Αντάρης (santaris@csd.auth.gr) and Mirco Chinelli (infinity89@fastwebmail.it) for working on Mac OS X packaging.
  • ")); te_thanks->append(QString::fromUtf8("
  • I am grateful to Peter Koeleman (peter@qbittorrent.org) and Mohammad Dib (mdib@qbittorrent.org) for working on qBittorrent port to Windows.
  • ")); te_thanks->append(QString::fromUtf8("
  • Thanks a lot to our graphist Mateusz Toboła (tobejodok@qbittorrent.org) for his great work.


")); te_thanks->scrollToAnchor(QString::fromUtf8("top")); diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 207ec0a47..13f9ec9d8 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -285,23 +285,23 @@ void Bittorrent::configureSession() { startTorrentsInPause(Preferences::addTorrentsInPause()); // * Scan dirs const QStringList &scan_dirs = Preferences::getScanDirs(); - QVariantList downloadInDirList = Preferences::getDownloadInScanDirs(); + QList 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()); - ++i; + m_scanFolders->addPath(dir, downloadInDirList.at(i)); + ++i; } // * Export Dir const bool newTorrentExport = Preferences::isTorrentExportEnabled(); if(torrentExport != newTorrentExport) { - torrentExport = newTorrentExport; - if(torrentExport) { - qDebug("Torrent export is enabled, exporting the current torrents"); - exportTorrentFiles(Preferences::getExportDir()); - } + torrentExport = newTorrentExport; + if(torrentExport) { + qDebug("Torrent export is enabled, exporting the current torrents"); + exportTorrentFiles(Preferences::getExportDir()); + } } // Connection // * Ports binding diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 25b27f7a8..5bdbdc52e 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -131,7 +131,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 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()) { @@ -147,7 +151,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; } @@ -256,7 +260,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(); diff --git a/src/misc.cpp b/src/misc.cpp index c0677e237..951198b05 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -75,7 +75,7 @@ QString misc::QDesktopServicesDataLocation() { if (!QCoreApplication::applicationName().isEmpty()) result = result + QLatin1String("\\") + qApp->applicationName(); if(!result.endsWith("\\")) - result += "\\"; + result += "\\"; return result; #else #ifdef Q_WS_MAC @@ -484,3 +484,33 @@ QString misc::userFriendlyDuration(qlonglong seconds) { } return QString::fromUtf8("∞"); } + +QStringList misc::toStringList(const QList &l) { + QStringList ret; + foreach(const bool &b, l) { + if(b) + ret << "1"; + else + ret << "0"; + } + return ret; +} + +QList misc::intListfromStringList(const QStringList &l) { + QList ret; + foreach(const QString &s, l) { + ret << s.toInt(); + } + return ret; +} + +QList misc::boolListfromStringList(const QStringList &l) { + QList ret; + foreach(const QString &s, l) { + if(s == "1") + ret << true; + else + ret << false; + } + return ret; +} diff --git a/src/misc.h b/src/misc.h index 9126910a3..c8307dd9f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -114,6 +114,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 &l); + static QList intListfromStringList(const QStringList &l); + static QList boolListfromStringList(const QStringList &l); }; // Trick to get a portable sleep() function diff --git a/src/peerlistwidget.cpp b/src/peerlistwidget.cpp index d66197571..78b4ceb23 100644 --- a/src/peerlistwidget.cpp +++ b/src/peerlistwidget.cpp @@ -44,8 +44,6 @@ #include #include -Q_DECLARE_METATYPE(QList) - 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 contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariantList()).value >(); + QList contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth")).toStringList()); if(!contentColsWidths.empty()) { for(int i=0; i contentColsWidths; + QStringList contentColsWidths; for(int i=0; icolumnCount(); ++i) { - contentColsWidths.append(columnWidth(i)); + contentColsWidths << QString::number(columnWidth(i)); } - settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariant::fromValue >(contentColsWidths)); + settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths); // Save sorted column Qt::SortOrder sortOrder = header()->sortIndicatorOrder(); QString sortOrderLetter; diff --git a/src/preferences.h b/src/preferences.h index 07b7d2eb3..8fb8f90a5 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -36,6 +36,7 @@ #include #include #include +#include #ifndef DISABLE_GUI #include @@ -47,6 +48,8 @@ #include #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 }; @@ -213,14 +216,14 @@ public: settings.setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), dirs); } - static QVariantList getDownloadInScanDirs() { + static QList 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 &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() { diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index dce3493e6..3f48eda4b 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -52,8 +52,6 @@ #include "downloadedpiecesbar.h" #include "pieceavailabilitybar.h" -Q_DECLARE_METATYPE(QList) - #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;}" @@ -260,7 +258,7 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { void PropertiesWidget::readSettings() { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - QList contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth"), QVariantList()).value >(); + QList contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth")).toStringList()); if(contentColsWidths.empty()) { filesList->header()->resizeSection(0, 300); } else { @@ -287,11 +285,11 @@ void PropertiesWidget::readSettings() { void PropertiesWidget::saveSettings() { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); settings.setValue("TorrentProperties/Visible", state==VISIBLE); - QList contentColsWidths; + QStringList contentColsWidths; for(int i=0; icolumnCount(); ++i) { - contentColsWidths.append(filesList->columnWidth(i)); + contentColsWidths << QString::number(filesList->columnWidth(i)); } - settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), QVariant::fromValue >(contentColsWidths)); + settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths); // Splitter sizes QSplitter *hSplitter = static_cast(parentWidget()); QList sizes; diff --git a/src/rss.h b/src/rss.h index f8be682c0..459b5c20d 100644 --- a/src/rss.h +++ b/src/rss.h @@ -345,7 +345,7 @@ public: return item; } - static RssItem* fromHash(RssStream* parent, QHash h) { + static RssItem* fromHash(RssStream* parent, const QHash &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()); } diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 207f281bb..9de8c4ccf 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -232,13 +232,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 children; int nbChildren = 0; if(parent) nbChildren = parent->childCount(); @@ -262,7 +261,7 @@ void RSSImp::loadFoldersOpenState() { } void RSSImp::saveFoldersOpenState() { - QVariantList open_folders; + QStringList open_folders; QList items = listStreams->getAllOpenFolders(); foreach(QTreeWidgetItem* item, items) { QString path = listStreams->getItemPath(item).join("\\"); diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index 0245fe0a5..368ceaedb 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -56,7 +56,6 @@ #include "transferlistwidget.h" using namespace libtorrent; -Q_DECLARE_METATYPE(QList) class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ Q_OBJECT @@ -119,7 +118,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 &contentColsWidths = settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth")).value >(); + const QList &contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth")).toStringList()); if(contentColsWidths.empty()) { torrentContentList->header()->resizeSection(0, 200); } else { @@ -132,12 +131,12 @@ public: void saveSettings() { if(is_magnet) return; QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - QList contentColsWidths; + QStringList contentColsWidths; // -1 because we hid PROGRESS column for(int i=0; icolumnCount()-1; ++i) { - contentColsWidths.append(torrentContentList->columnWidth(i)); + contentColsWidths << QString::number(torrentContentList->columnWidth(i)); } - settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), QVariant::fromValue >(contentColsWidths)); + settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), contentColsWidths); settings.setValue("TorrentAdditionDlg/size", size()); settings.setValue("TorrentAdditionDlg/pos", pos()); } diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 3f9d162f4..44d1b2184 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -69,9 +69,9 @@ public: QHash all_data = settings.value("torrents-tmp", QHash()).toHash(); QHash data = all_data[hash].toHash(); std::vector::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 data = all_data[hash].toHash(); std::vector 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 list_var = misc::intListfromStringList(data["files_priority"].toStringList()); + foreach(int var, list_var) { + fp.push_back(var); } } return fp; diff --git a/src/trackerlist.cpp b/src/trackerlist.cpp index d0343d82b..29d8c3bb0 100644 --- a/src/trackerlist.cpp +++ b/src/trackerlist.cpp @@ -42,8 +42,6 @@ #include "misc.h" #include "bittorrent.h" -Q_DECLARE_METATYPE(QList) - 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 contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth")).value >(); + QList contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth")).toStringList()); if(!contentColsWidths.empty()) { for(int i=0; i contentColsWidths; + QStringList contentColsWidths; for(int i=0; i >(contentColsWidths)); + settings.setValue(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth"), contentColsWidths); } diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 5568cc5c4..49c9853ba 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -51,8 +51,6 @@ #include #include -Q_DECLARE_METATYPE(QList) - TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession): QTreeView(parent), BTSession(_BTSession), main_window(main_window) { QSettings settings("qBittorrent", "qBittorrent"); @@ -1219,11 +1217,11 @@ void TransferListWidget::saveColWidthList() { } } settings.setValue(QString::fromUtf8("TransferListColsWidth"), new_width_list.join(QString::fromUtf8(" "))); - QList visualIndexes; + QStringList visualIndexes; for(int i=0; ivisualIndex(i)); + visualIndexes << QString::number(header()->visualIndex(i)); } - settings.setValue(QString::fromUtf8("TransferListVisualIndexes"), QVariant::fromValue< QList >(visualIndexes)); + settings.setValue(QString::fromUtf8("TransferListVisualIndexes"), visualIndexes); qDebug("Download list columns width saved"); } @@ -1243,7 +1241,7 @@ bool TransferListWidget::loadColWidthList() { for(unsigned int i=0; iresizeSection(i, width_list.at(i).toInt()); } - const QList visualIndexes = settings.value(QString::fromUtf8("TransferListVisualIndexes")).value >(); + const QList 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;