Browse Source

Merge pull request #10537 from Chocobo1/template

Minor cleanups
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
2d7b833ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/base/bittorrent/session.cpp
  2. 6
      src/base/bittorrent/session.h
  3. 8
      src/base/settingvalue.h
  4. 1
      src/gui/torrentcategorydialog.cpp
  5. 1
      src/gui/torrentcontentmodel.cpp
  6. 2
      src/webui/webapplication.cpp
  7. 5
      src/webui/webapplication.h

15
src/base/bittorrent/session.cpp

@ -34,13 +34,16 @@
#include <queue> #include <queue>
#include <string> #include <string>
#include <QCoreApplication> #ifdef Q_OS_WIN
#include <wincrypt.h>
#include <iphlpapi.h>
#endif
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QHostAddress> #include <QHostAddress>
#include <QNetworkAddressEntry> #include <QNetworkAddressEntry>
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QProcess>
#include <QRegularExpression> #include <QRegularExpression>
#include <QString> #include <QString>
#include <QThread> #include <QThread>
@ -50,12 +53,10 @@
#include <libtorrent/alert_types.hpp> #include <libtorrent/alert_types.hpp>
#include <libtorrent/bdecode.hpp> #include <libtorrent/bdecode.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include <libtorrent/disk_io_thread.hpp>
#include <libtorrent/error_code.hpp> #include <libtorrent/error_code.hpp>
#include <libtorrent/extensions/ut_metadata.hpp> #include <libtorrent/extensions/ut_metadata.hpp>
#include <libtorrent/extensions/ut_pex.hpp> #include <libtorrent/extensions/ut_pex.hpp>
#include <libtorrent/extensions/smart_ban.hpp> #include <libtorrent/extensions/smart_ban.hpp>
#include <libtorrent/identify_client.hpp>
#include <libtorrent/ip_filter.hpp> #include <libtorrent/ip_filter.hpp>
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
@ -78,7 +79,6 @@
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/net.h" #include "base/utils/net.h"
#include "base/utils/random.h" #include "base/utils/random.h"
#include "base/utils/string.h"
#include "magneturi.h" #include "magneturi.h"
#include "private/bandwidthscheduler.h" #include "private/bandwidthscheduler.h"
#include "private/filterparserthread.h" #include "private/filterparserthread.h"
@ -89,11 +89,6 @@
#include "tracker.h" #include "tracker.h"
#include "trackerentry.h" #include "trackerentry.h"
#ifdef Q_OS_WIN
#include <wincrypt.h>
#include <iphlpapi.h>
#endif
#if defined(Q_OS_WIN) && (_WIN32_WINNT < 0x0600) #if defined(Q_OS_WIN) && (_WIN32_WINNT < 0x0600)
using NETIO_STATUS = LONG; using NETIO_STATUS = LONG;
#endif #endif

6
src/base/bittorrent/session.h

@ -36,13 +36,9 @@
#include <QFile> #include <QFile>
#include <QHash> #include <QHash>
#include <QList> #include <QList>
#include <QMap>
#include <QNetworkConfigurationManager> #include <QNetworkConfigurationManager>
#include <QPointer> #include <QPointer>
#include <QSet> #include <QSet>
#include <QStringList>
#include <QVector>
#include <QWaitCondition>
#include "base/settingvalue.h" #include "base/settingvalue.h"
#include "base/tristatebool.h" #include "base/tristatebool.h"
@ -55,8 +51,8 @@
class QThread; class QThread;
class QTimer; class QTimer;
class QStringList;
class QString; class QString;
class QStringList;
class QUrl; class QUrl;
class FilterParserThread; class FilterParserThread;

8
src/base/settingvalue.h

@ -29,7 +29,6 @@
#ifndef SETTINGVALUE_H #ifndef SETTINGVALUE_H
#define SETTINGVALUE_H #define SETTINGVALUE_H
#include <functional>
#include <type_traits> #include <type_traits>
#include <QMetaEnum> #include <QMetaEnum>
@ -41,8 +40,6 @@
template <typename T> template <typename T>
class CachedSettingValue class CachedSettingValue
{ {
using ProxyFunc = std::function<T (const T&)>;
public: public:
explicit CachedSettingValue(const char *keyName, const T &defaultValue = T()) explicit CachedSettingValue(const char *keyName, const T &defaultValue = T())
: m_keyName(QLatin1String(keyName)) : m_keyName(QLatin1String(keyName))
@ -50,8 +47,11 @@ public:
{ {
} }
// The signature of the ProxyFunc should be equivalent to the following:
// T proxyFunc(const T &a);
template <typename ProxyFunc>
explicit CachedSettingValue(const char *keyName, const T &defaultValue explicit CachedSettingValue(const char *keyName, const T &defaultValue
, const ProxyFunc &proxyFunc) , ProxyFunc proxyFunc)
: m_keyName(QLatin1String(keyName)) : m_keyName(QLatin1String(keyName))
, m_value(proxyFunc(loadValue(defaultValue))) , m_value(proxyFunc(loadValue(defaultValue)))
{ {

1
src/gui/torrentcategorydialog.cpp

@ -28,7 +28,6 @@
#include "torrentcategorydialog.h" #include "torrentcategorydialog.h"
#include <QMap>
#include <QMessageBox> #include <QMessageBox>
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"

1
src/gui/torrentcontentmodel.cpp

@ -34,7 +34,6 @@
#include <QFileIconProvider> #include <QFileIconProvider>
#include <QFileInfo> #include <QFileInfo>
#include <QIcon> #include <QIcon>
#include <QMap>
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include <Windows.h> #include <Windows.h>

2
src/webui/webapplication.cpp

@ -537,7 +537,7 @@ void WebApplication::sessionStart()
// remove outdated sessions // remove outdated sessions
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000; const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
const QMap<QString, WebSession *> sessionsCopy {m_sessions}; const QHash<QString, WebSession *> sessionsCopy {m_sessions};
for (const auto session : sessionsCopy) { for (const auto session : sessionsCopy) {
if ((now - session->timestamp()) > INACTIVE_TIME) if ((now - session->timestamp()) > INACTIVE_TIME)
delete m_sessions.take(session->id()); delete m_sessions.take(session->id());

5
src/webui/webapplication.h

@ -30,7 +30,6 @@
#include <QDateTime> #include <QDateTime>
#include <QHash> #include <QHash>
#include <QMap>
#include <QObject> #include <QObject>
#include <QRegularExpression> #include <QRegularExpression>
#include <QSet> #include <QSet>
@ -120,7 +119,7 @@ private:
bool validateHostHeader(const QStringList &domains) const; bool validateHostHeader(const QStringList &domains) const;
// Persistent data // Persistent data
QMap<QString, WebSession *> m_sessions; QHash<QString, WebSession *> m_sessions;
// Current data // Current data
WebSession *m_currentSession = nullptr; WebSession *m_currentSession = nullptr;
@ -141,7 +140,7 @@ private:
QByteArray data; QByteArray data;
QDateTime lastModified; QDateTime lastModified;
}; };
QMap<QString, TranslatedFile> m_translatedFiles; QHash<QString, TranslatedFile> m_translatedFiles;
QString m_currentLocale; QString m_currentLocale;
QTranslator m_translator; QTranslator m_translator;
bool m_translationFileLoaded = false; bool m_translationFileLoaded = false;

Loading…
Cancel
Save