diff --git a/src/base/net/geoipdatabase.cpp b/src/base/net/geoipdatabase.cpp index 34260c625..0379e83fa 100644 --- a/src/base/net/geoipdatabase.cpp +++ b/src/base/net/geoipdatabase.cpp @@ -516,3 +516,22 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, const quint32 count) con return array; } + +template +QVariant GeoIPDatabase::readPlainValue(quint32 &offset, const quint8 len) const +{ + T value = 0; + const uchar *const data = m_data + offset; + const quint32 availSize = m_size - offset; + + if ((len > 0) && (len <= sizeof(T) && (availSize >= len))) + { + // copy input data to last 'len' bytes of 'value' + uchar *dst = reinterpret_cast(&value) + (sizeof(T) - len); + memcpy(dst, data, len); + fromBigEndian(reinterpret_cast(&value), sizeof(T)); + offset += len; + } + + return QVariant::fromValue(value); +} diff --git a/src/base/net/geoipdatabase.h b/src/base/net/geoipdatabase.h index f0b2b6400..3d9495c10 100644 --- a/src/base/net/geoipdatabase.h +++ b/src/base/net/geoipdatabase.h @@ -70,24 +70,7 @@ private: QVariant readMapValue(quint32 &offset, quint32 count) const; QVariant readArrayValue(quint32 &offset, quint32 count) const; - template - QVariant readPlainValue(quint32 &offset, quint8 len) const - { - T value = 0; - const uchar *const data = m_data + offset; - const quint32 availSize = m_size - offset; - - if ((len > 0) && (len <= sizeof(T) && (availSize >= len))) - { - // copy input data to last 'len' bytes of 'value' - uchar *dst = reinterpret_cast(&value) + (sizeof(T) - len); - memcpy(dst, data, len); - fromBigEndian(reinterpret_cast(&value), sizeof(T)); - offset += len; - } - - return QVariant::fromValue(value); - } + template QVariant readPlainValue(quint32 &offset, quint8 len) const; // Metadata quint16 m_ipVersion; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 5907762aa..306444213 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -156,7 +156,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) { // column setColumnCount(COL_COUNT); - QStringList header = {tr("Setting"), tr("Value", "Value set for this setting")}; + const QStringList header = {tr("Setting"), tr("Value", "Value set for this setting")}; setHorizontalHeaderLabels(header); // row setRowCount(ROW_COUNT); @@ -171,7 +171,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) horizontalHeader()->setStretchLastSection(true); } -void AdvancedSettings::saveAdvancedSettings() +void AdvancedSettings::saveAdvancedSettings() const { Preferences *const pref = Preferences::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance(); @@ -314,7 +314,7 @@ void AdvancedSettings::saveAdvancedSettings() } #ifndef QBT_USES_LIBTORRENT2 -void AdvancedSettings::updateCacheSpinSuffix(int value) +void AdvancedSettings::updateCacheSpinSuffix(const int value) { if (value == 0) m_spinBoxCache.setSuffix(tr(" (disabled)")); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 1dc52ebc6..8d42c741c 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -34,15 +34,16 @@ #include #include -class AdvancedSettings : public QTableWidget +class AdvancedSettings final : public QTableWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(AdvancedSettings) public: AdvancedSettings(QWidget *parent); public slots: - void saveAdvancedSettings(); + void saveAdvancedSettings() const; signals: void settingsChanged();