Browse Source

Merge pull request #3685 from glassez/cpp11

Add C++11 support.
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
19ad58c394
  1. 11
      .travis.yml
  2. 4
      macxconf.pri
  3. 3
      os2conf.pri
  4. 5
      src/core/net/private/geoipdatabase.cpp
  5. 4
      src/core/preferences.cpp
  6. 31
      src/core/types.h
  7. 4
      src/gui/options_imp.cpp
  8. 4
      src/src.pro
  9. 4
      src/webui/prefjson.cpp
  10. 11
      unixconf.pri
  11. 3
      winconf-mingw.pri

11
.travis.yml

@ -43,14 +43,19 @@ addons: @@ -43,14 +43,19 @@ addons:
branch_pattern: $coverity_branch
notification_email: sledgehammer999@qbittorrent.org
apt:
sources:
# sources list: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
- ubuntu-toolchain-r-test
- boost-latest
packages:
# packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
- autoconf
- automake
- colormake
- g++-4.8
- libssl-dev
- libboost-dev
- libboost-system-dev
- libboost1.55-dev
- libboost-system1.55-dev
- libqt4-dev
# Uncomment when Travis upgraded "Ubuntu 12.04 LTS" to a newer version whose repo will have a more up-to-date libtorrent package
#- libtorrent-rasterbar6
@ -60,6 +65,7 @@ before_install: @@ -60,6 +65,7 @@ before_install:
- if [ "$TRAVIS_BRANCH" = "$coverity_branch" ] && ! [ "$TRAVIS_OS_NAME" = "linux" -a "$lt_branch" = "RC_1_0" -a "$gui" = true ]; then exit ; fi
- shopt -s expand_aliases
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CC=gcc-4.8 CXX=g++-4.8 ; fi
- if [ "$TRAVIS_BRANCH" != "$coverity_branch" -a "$TRAVIS_OS_NAME" = "linux" ]; then dpkg-query -L ccache && export PATH="/usr/lib/ccache/:$PATH" ; fi
- alias make="colormake -j3" # Using nprocs/2 sometimes may fail (gcc is killed by system)
@ -90,6 +96,7 @@ install: @@ -90,6 +96,7 @@ install:
script:
- if [ "$TRAVIS_BRANCH" = "$coverity_branch" ]; then exit ; fi # Skip usual build when running coverity scan
- ./bootstrap.sh && ./configure $qbtconf
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then echo QMAKE_CC=$CC >> conf.pri && echo QMAKE_CXX=$CXX >> conf.pri ; fi
- make && make install
after_success:

4
macxconf.pri

@ -10,7 +10,9 @@ exists($$OUT_PWD/../conf.pri) { @@ -10,7 +10,9 @@ exists($$OUT_PWD/../conf.pri) {
}
LIBS += -framework Carbon -framework IOKit
CONFIG += c++11
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
QT_LANG_PATH = ../dist/qt-translations
DIST_PATH = ../dist/mac

3
os2conf.pri

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
exists(conf.pri) {
# to the conf.pri goes all system dependent stuff
include(conf.pri)

5
src/core/net/private/geoipdatabase.cpp

@ -63,7 +63,7 @@ namespace @@ -63,7 +63,7 @@ namespace
const quint32 __ENDIAN_TEST__ = 0x00000001;
const bool __IS_LITTLE_ENDIAN__ = (reinterpret_cast<const uchar *>(&__ENDIAN_TEST__)[0] == 0x01);
BEGIN_SCOPED_ENUM(DataType)
enum class DataType
{
Unknown = 0,
Pointer = 1,
@ -81,8 +81,7 @@ namespace @@ -81,8 +81,7 @@ namespace
EndMarker = 13,
Boolean = 14,
Float = 15
}
END_SCOPED_ENUM
};
struct DataFieldDescriptor
{

4
src/core/preferences.cpp

@ -974,12 +974,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio) @@ -974,12 +974,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio)
MaxRatioAction Preferences::getMaxRatioAction() const
{
return value("Preferences/Bittorrent/MaxRatioAction", MaxRatioAction::Pause).toInt();
return value("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(MaxRatioAction::Pause)).value<MaxRatioAction>();
}
void Preferences::setMaxRatioAction(MaxRatioAction act)
{
setValue("Preferences/Bittorrent/MaxRatioAction", act);
setValue("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(act));
}
// IP Filter

31
src/core/types.h

@ -31,43 +31,28 @@ @@ -31,43 +31,28 @@
#include <QVariant>
#define BEGIN_SCOPED_ENUM(name) class name\
{\
int m_val;\
\
public:\
name() {}\
name(int val) : m_val(val) {}\
operator int() const { return m_val; }\
operator QVariant() const { return m_val; }\
\
enum
#define END_SCOPED_ENUM ; };
const qlonglong MAX_ETA = 8640000;
BEGIN_SCOPED_ENUM(MaxRatioAction)
enum class MaxRatioAction
{
Pause,
Remove
}
END_SCOPED_ENUM
};
Q_DECLARE_METATYPE(MaxRatioAction)
BEGIN_SCOPED_ENUM(TorrentExportFolder)
enum class TorrentExportFolder
{
Regular,
Finished
}
END_SCOPED_ENUM
};
BEGIN_SCOPED_ENUM(ShutdownAction)
enum class ShutdownAction
{
None,
Shutdown,
Suspend,
Hibernate
}
END_SCOPED_ENUM
};
#endif // TYPES_H

4
src/gui/options_imp.cpp

@ -469,7 +469,7 @@ void options_imp::saveOptions() @@ -469,7 +469,7 @@ void options_imp::saveOptions()
pref->setEncryptionSetting(getEncryptionSetting());
pref->enableAnonymousMode(checkAnonymousMode->isChecked());
pref->setGlobalMaxRatio(getMaxRatio());
pref->setMaxRatioAction(comboRatioLimitAct->currentIndex());
pref->setMaxRatioAction(static_cast<MaxRatioAction>(comboRatioLimitAct->currentIndex()));
// End Bittorrent preferences
// Misc preferences
// * IPFilter
@ -804,7 +804,7 @@ void options_imp::loadOptions() @@ -804,7 +804,7 @@ void options_imp::loadOptions()
spinMaxRatio->setEnabled(false);
comboRatioLimitAct->setEnabled(false);
}
comboRatioLimitAct->setCurrentIndex(pref->getMaxRatioAction());
comboRatioLimitAct->setCurrentIndex(static_cast<int>(pref->getMaxRatioAction()));
// End Bittorrent preferences
// Web UI preferences

4
src/src.pro

@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
TEMPLATE = app
CONFIG += qt thread silent
# C++11 support
CONFIG += c++11
DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES
# Windows specific configuration
win32: include(../winconf.pri)

4
src/webui/prefjson.cpp

@ -141,7 +141,7 @@ QByteArray prefjson::getPreferences() @@ -141,7 +141,7 @@ QByteArray prefjson::getPreferences()
// Share Ratio Limiting
data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.);
data["max_ratio"] = pref->getGlobalMaxRatio();
data["max_ratio_act"] = pref->getMaxRatioAction();
data["max_ratio_act"] = QVariant::fromValue(pref->getMaxRatioAction());
// Web UI
// Language
@ -337,7 +337,7 @@ void prefjson::setPreferences(const QString& json) @@ -337,7 +337,7 @@ void prefjson::setPreferences(const QString& json)
else
pref->setGlobalMaxRatio(-1);
if (m.contains("max_ratio_act"))
pref->setMaxRatioAction(m["max_ratio_act"].toInt());
pref->setMaxRatioAction(m["max_ratio_act"].value<MaxRatioAction>());
// Web UI
// Language

11
unixconf.pri

@ -9,15 +9,14 @@ exists($$OUT_PWD/../conf.pri) { @@ -9,15 +9,14 @@ exists($$OUT_PWD/../conf.pri) {
include(conf.pri)
}
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
# COMPILATION SPECIFIC
!nogui:dbus {
QT += dbus
}
!nogui:dbus: QT += dbus
QMAKE_CXXFLAGS += -Wformat -Wformat-security
!haiku {
QMAKE_LFLAGS_APP += -rdynamic
}
!haiku: QMAKE_LFLAGS_APP += -rdynamic
# Man page
nogui {

3
winconf-mingw.pri

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
# C++11 support
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=gnu++11
strace_win{
contains(QMAKE_HOST.arch, x86) {
# i686 arch requires frame pointer preservation

Loading…
Cancel
Save