mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Drop Qt 4 support
This commit is contained in:
parent
60998a68eb
commit
e64bb1de8c
67 changed files with 48 additions and 8809 deletions
28
.travis.yml
28
.travis.yml
|
@ -12,17 +12,9 @@ env:
|
||||||
#- lt_branch=dist gui=false
|
#- lt_branch=dist gui=false
|
||||||
- lt_branch=RC_1_0 qt=5 gui=true
|
- lt_branch=RC_1_0 qt=5 gui=true
|
||||||
- lt_branch=RC_1_0 qt=5 gui=false
|
- lt_branch=RC_1_0 qt=5 gui=false
|
||||||
- lt_branch=RC_1_0 qt=4 gui=true
|
|
||||||
- lt_branch=RC_1_0 qt=4 gui=false
|
|
||||||
global:
|
global:
|
||||||
- secure: "OI9CUjj4lTb0HwwIZU5PbECU3hLlAL6KC8KsbwohG8/O3j5fLcnmDsK4Ad9us5cC39sS11Jcd1kDP2qRcCuST/glVNhLkcjKkiQerOfd5nQ/qL4JYfz/1mfP5mdpz9jHKzpLUIG+TXkbSTjP6VVmsb5KPT+3pKEdRFZB+Pu9+J8="
|
- secure: "OI9CUjj4lTb0HwwIZU5PbECU3hLlAL6KC8KsbwohG8/O3j5fLcnmDsK4Ad9us5cC39sS11Jcd1kDP2qRcCuST/glVNhLkcjKkiQerOfd5nQ/qL4JYfz/1mfP5mdpz9jHKzpLUIG+TXkbSTjP6VVmsb5KPT+3pKEdRFZB+Pu9+J8="
|
||||||
- coverity_branch: coverity_scan
|
- coverity_branch: coverity_scan
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- os: osx
|
|
||||||
env: lt_branch=RC_1_0 qt=4 gui=true
|
|
||||||
- os: osx
|
|
||||||
env: lt_branch=RC_1_0 qt=4 gui=false
|
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
except:
|
except:
|
||||||
|
@ -79,7 +71,7 @@ before_install:
|
||||||
#- libt_path="$HOME/libt_install"
|
#- libt_path="$HOME/libt_install"
|
||||||
#- ltconf="$ltconf --prefix="$libt_path" --disable-geoip"
|
#- ltconf="$ltconf --prefix="$libt_path" --disable-geoip"
|
||||||
- qbt_path="$HOME/qbt_install"
|
- qbt_path="$HOME/qbt_install"
|
||||||
- qbtconf="$qbtconf --prefix="$qbt_path" PKG_CONFIG_PATH="$libt_path/lib/pkgconfig":$PKG_CONFIG_PATH"
|
- qbtconf="$qbtconf --prefix="$qbt_path" PKG_CONFIG_PATH="$libt_path/lib/pkgconfig":/opt/qt55/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
|
||||||
# options for specific branches
|
# options for specific branches
|
||||||
- if [ "$qt" = 4 ]; then qbtconf="$qbtconf --with-qt4" ; fi
|
- if [ "$qt" = 4 ]; then qbtconf="$qbtconf --with-qt4" ; fi
|
||||||
|
@ -88,6 +80,9 @@ before_install:
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
# setup virtual display for after_success target
|
# setup virtual display for after_success target
|
||||||
if [ "$gui" = true ]; then export "DISPLAY=:99.0" && /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 ; fi ;
|
if [ "$gui" = true ]; then export "DISPLAY=:99.0" && /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 ; fi ;
|
||||||
|
|
||||||
|
# Qt 5
|
||||||
|
PATH=/opt/qt55/bin:${PATH}
|
||||||
fi
|
fi
|
||||||
- |
|
- |
|
||||||
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||||
|
@ -103,21 +98,23 @@ before_install:
|
||||||
install:
|
install:
|
||||||
- |
|
- |
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||||
# libtorrent
|
# repositories
|
||||||
sudo add-apt-repository --yes ppa:qbittorrent-team/qbittorrent-stable ;
|
sudo add-apt-repository --yes ppa:qbittorrent-team/qbittorrent-stable ;
|
||||||
|
sudo add-apt-repository --yes ppa:beineri/opt-qt551-trusty ;
|
||||||
sudo apt-get update -qq ;
|
sudo apt-get update -qq ;
|
||||||
|
|
||||||
|
# libtorrent
|
||||||
sudo apt-get install -qq libtorrent-rasterbar-dev ;
|
sudo apt-get install -qq libtorrent-rasterbar-dev ;
|
||||||
|
|
||||||
|
# Qt 5.5.1
|
||||||
|
sudo apt-get install -qq qt55base qt55tools ;
|
||||||
|
|
||||||
# build libtorrent from source
|
# build libtorrent from source
|
||||||
#if [ "$lt_branch" != "dist" ]; then
|
#if [ "$lt_branch" != "dist" ]; then
|
||||||
#cd "$HOME" && pwd && git clone --depth 1 https://github.com/arvidn/libtorrent.git --branch $lt_branch ;
|
#cd "$HOME" && pwd && git clone --depth 1 https://github.com/arvidn/libtorrent.git --branch $lt_branch ;
|
||||||
#cd libtorrent && ./autotool.sh && ./configure $ltconf && make install ;
|
#cd libtorrent && ./autotool.sh && ./configure $ltconf && make install ;
|
||||||
#fi ;
|
#fi ;
|
||||||
|
|
||||||
# Qt
|
|
||||||
if [ "$qt" = 4 ]; then sudo apt-get -qq install qt4-default libqt4-dev ; fi ;
|
|
||||||
if [ "$qt" = 5 ]; then sudo apt-get -qq install qt5-default qtbase5-dev qttools5-dev-tools ; fi ;
|
|
||||||
|
|
||||||
# ccache
|
# ccache
|
||||||
if [ "$TRAVIS_BRANCH" != "$coverity_branch" ]; then
|
if [ "$TRAVIS_BRANCH" != "$coverity_branch" ]; then
|
||||||
dpkg-query -L ccache && export use_ccache=true ;
|
dpkg-query -L ccache && export use_ccache=true ;
|
||||||
|
@ -151,15 +148,12 @@ install:
|
||||||
brew install "$HOME/hombebrew_cache/libtorrent-rasterbar.rb" ;
|
brew install "$HOME/hombebrew_cache/libtorrent-rasterbar.rb" ;
|
||||||
|
|
||||||
# Qt
|
# Qt
|
||||||
if [ "$qt" = 4 ]; then brew install qt && ln -s /usr/local/Cellar/qt/4.8.7_2/plugins /usr/local ; fi ;
|
|
||||||
if [ "$qt" = 5 ]; then
|
|
||||||
# Copy custom qt5 bottle to homebrew's cache so it can find and install it
|
# Copy custom qt5 bottle to homebrew's cache so it can find and install it
|
||||||
# Also install our custom qt5 formula by passing the local path to it
|
# Also install our custom qt5 formula by passing the local path to it
|
||||||
# These 2 files are restored from Travis' cache.
|
# These 2 files are restored from Travis' cache.
|
||||||
cp "$HOME/hombebrew_cache/qt5-5.7.1_1.el_capitan.bottle.tar.gz" "$(brew --cache)" ;
|
cp "$HOME/hombebrew_cache/qt5-5.7.1_1.el_capitan.bottle.tar.gz" "$(brew --cache)" ;
|
||||||
brew install "$HOME/hombebrew_cache/qt5.rb" ;
|
brew install "$HOME/hombebrew_cache/qt5.rb" ;
|
||||||
brew link --force qt5 ;
|
brew link --force qt5 ;
|
||||||
fi
|
|
||||||
|
|
||||||
# ccache
|
# ccache
|
||||||
if [ "$TRAVIS_BRANCH" != "$coverity_branch" ]; then
|
if [ "$TRAVIS_BRANCH" != "$coverity_branch" ]; then
|
||||||
|
|
|
@ -40,11 +40,8 @@ endif(WIN32)
|
||||||
# we need options here, because they are used not only in "src" subdir, but in the "dist" dir too
|
# we need options here, because they are used not only in "src" subdir, but in the "dist" dir too
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
option(QT5 "Compile using Qt5" ON)
|
|
||||||
option(SYSTEM_QTSINGLEAPPLICATION
|
option(SYSTEM_QTSINGLEAPPLICATION
|
||||||
"Use the system qtsingleapplication library or shipped one otherwise")
|
"Use the system qtsingleapplication library or shipped one otherwise")
|
||||||
cmake_dependent_option(SYSTEM_QJSON
|
|
||||||
"Use the shipped qjson library or the system one (Qt4 only)" OFF "NOT QT5" OFF)
|
|
||||||
|
|
||||||
option(GUI "Allows to disable GUI for headless running. Disables QtDBus and the GeoIP Database" ON)
|
option(GUI "Allows to disable GUI for headless running. Disables QtDBus and the GeoIP Database" ON)
|
||||||
|
|
||||||
|
|
275
configure
vendored
275
configure
vendored
|
@ -603,8 +603,6 @@ zlib_LIBS
|
||||||
zlib_CFLAGS
|
zlib_CFLAGS
|
||||||
libtorrent_LIBS
|
libtorrent_LIBS
|
||||||
libtorrent_CFLAGS
|
libtorrent_CFLAGS
|
||||||
qjson_LIBS
|
|
||||||
qjson_CFLAGS
|
|
||||||
BOOST_SYSTEM_LIB
|
BOOST_SYSTEM_LIB
|
||||||
BOOST_LDFLAGS
|
BOOST_LDFLAGS
|
||||||
BOOST_CPPFLAGS
|
BOOST_CPPFLAGS
|
||||||
|
@ -690,7 +688,6 @@ infodir
|
||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
runstatedir
|
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
|
@ -715,9 +712,7 @@ ac_user_opts='
|
||||||
enable_option_checking
|
enable_option_checking
|
||||||
enable_dependency_tracking
|
enable_dependency_tracking
|
||||||
enable_silent_rules
|
enable_silent_rules
|
||||||
with_qt4
|
|
||||||
with_qtsingleapplication
|
with_qtsingleapplication
|
||||||
with_qjson
|
|
||||||
enable_debug
|
enable_debug
|
||||||
enable_gui
|
enable_gui
|
||||||
enable_systemd
|
enable_systemd
|
||||||
|
@ -742,8 +737,6 @@ PKG_CONFIG
|
||||||
PKG_CONFIG_PATH
|
PKG_CONFIG_PATH
|
||||||
PKG_CONFIG_LIBDIR
|
PKG_CONFIG_LIBDIR
|
||||||
QT_QMAKE
|
QT_QMAKE
|
||||||
qjson_CFLAGS
|
|
||||||
qjson_LIBS
|
|
||||||
libtorrent_CFLAGS
|
libtorrent_CFLAGS
|
||||||
libtorrent_LIBS
|
libtorrent_LIBS
|
||||||
zlib_CFLAGS
|
zlib_CFLAGS
|
||||||
|
@ -786,7 +779,6 @@ datadir='${datarootdir}'
|
||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
runstatedir='${localstatedir}/run'
|
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||||
|
@ -1039,15 +1031,6 @@ do
|
||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
|
||||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
|
||||||
| --run | --ru | --r)
|
|
||||||
ac_prev=runstatedir ;;
|
|
||||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
|
||||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
|
||||||
| --run=* | --ru=* | --r=*)
|
|
||||||
runstatedir=$ac_optarg ;;
|
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
|
@ -1185,7 +1168,7 @@ fi
|
||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir runstatedir
|
libdir localedir mandir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
|
@ -1338,7 +1321,6 @@ Fine tuning of the installation directories:
|
||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
|
@ -1393,13 +1375,9 @@ Optional Features:
|
||||||
Optional Packages:
|
Optional Packages:
|
||||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||||
--with-qt4 Compile using Qt4 (default=no)
|
|
||||||
--with-qtsingleapplication=[system|shipped]
|
--with-qtsingleapplication=[system|shipped]
|
||||||
Use the shipped qtsingleapplication library or the
|
Use the shipped qtsingleapplication library or the
|
||||||
system one (default=shipped)
|
system one (default=shipped)
|
||||||
--with-qjson=[system|shipped]
|
|
||||||
Use the shipped qjson library or the system one
|
|
||||||
(default=shipped) (Qt4 only)
|
|
||||||
--with-boost[=ARG] use Boost library from a standard location
|
--with-boost[=ARG] use Boost library from a standard location
|
||||||
(ARG=yes), from the specified location (ARG=<path>),
|
(ARG=yes), from the specified location (ARG=<path>),
|
||||||
or disable it (ARG=no) [ARG=yes]
|
or disable it (ARG=no) [ARG=yes]
|
||||||
|
@ -1430,9 +1408,6 @@ Some influential environment variables:
|
||||||
PKG_CONFIG_LIBDIR
|
PKG_CONFIG_LIBDIR
|
||||||
path overriding pkg-config's built-in search path
|
path overriding pkg-config's built-in search path
|
||||||
QT_QMAKE value of host_bins for Qt5Core >= 5.2.0, overriding pkg-config
|
QT_QMAKE value of host_bins for Qt5Core >= 5.2.0, overriding pkg-config
|
||||||
qjson_CFLAGS
|
|
||||||
C compiler flags for qjson, overriding pkg-config
|
|
||||||
qjson_LIBS linker flags for qjson, overriding pkg-config
|
|
||||||
libtorrent_CFLAGS
|
libtorrent_CFLAGS
|
||||||
C compiler flags for libtorrent, overriding pkg-config
|
C compiler flags for libtorrent, overriding pkg-config
|
||||||
libtorrent_LIBS
|
libtorrent_LIBS
|
||||||
|
@ -4179,15 +4154,6 @@ fi
|
||||||
# Define --wth-* and --enable-* arguments
|
# Define --wth-* and --enable-* arguments
|
||||||
|
|
||||||
|
|
||||||
# Check whether --with-qt4 was given.
|
|
||||||
if test "${with_qt4+set}" = set; then :
|
|
||||||
withval=$with_qt4;
|
|
||||||
else
|
|
||||||
with_qt4=no
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --with-qtsingleapplication was given.
|
# Check whether --with-qtsingleapplication was given.
|
||||||
if test "${with_qtsingleapplication+set}" = set; then :
|
if test "${with_qtsingleapplication+set}" = set; then :
|
||||||
withval=$with_qtsingleapplication;
|
withval=$with_qtsingleapplication;
|
||||||
|
@ -4196,15 +4162,6 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --with-qjson was given.
|
|
||||||
if test "${with_qjson+set}" = set; then :
|
|
||||||
withval=$with_qjson;
|
|
||||||
else
|
|
||||||
with_qjson=shipped
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --enable-debug was given.
|
# Check whether --enable-debug was given.
|
||||||
if test "${enable_debug+set}" = set; then :
|
if test "${enable_debug+set}" = set; then :
|
||||||
enableval=$enable_debug;
|
enableval=$enable_debug;
|
||||||
|
@ -4466,12 +4423,6 @@ $as_echo "$enable_webui" >&6; }
|
||||||
as_fn_error $? "Unknown option \"$enable_webui\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
|
as_fn_error $? "Unknown option \"$enable_webui\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Qt4 should be enabled" >&5
|
|
||||||
$as_echo_n "checking whether Qt4 should be enabled... " >&6; }
|
|
||||||
case "x$with_qt4" in #(
|
|
||||||
"xno") :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
||||||
$as_echo "no" >&6; }
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
if test -n "$PKG_CONFIG" && \
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.2.0\""; } >&5
|
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.2.0\""; } >&5
|
||||||
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.2.0") 2>&5
|
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.2.0") 2>&5
|
||||||
|
@ -4524,97 +4475,6 @@ else
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
||||||
$as_echo "not found" >&6; }
|
$as_echo "not found" >&6; }
|
||||||
|
|
||||||
fi
|
|
||||||
;; #(
|
|
||||||
"xyes") :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
||||||
$as_echo "yes" >&6; }
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QtCore >= 4.8.0\""; } >&5
|
|
||||||
($PKG_CONFIG --exists --print-errors "QtCore >= 4.8.0") 2>&5
|
|
||||||
ac_status=$?
|
|
||||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
||||||
test $ac_status = 0; }; then
|
|
||||||
|
|
||||||
if test -n "$QT_QMAKE"; then
|
|
||||||
pkg_cv_QT_QMAKE="$QT_QMAKE"
|
|
||||||
elif test -n "$PKG_CONFIG"; then
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QtCore >= 4.8.0\""; } >&5
|
|
||||||
($PKG_CONFIG --exists --print-errors "QtCore >= 4.8.0") 2>&5
|
|
||||||
ac_status=$?
|
|
||||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
||||||
test $ac_status = 0; }; then
|
|
||||||
pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="moc_location" "QtCore >= 4.8.0" 2>/dev/null`
|
|
||||||
test "x$?" != "x0" && pkg_failed=yes
|
|
||||||
else
|
|
||||||
pkg_failed=yes
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
pkg_failed=untried
|
|
||||||
fi
|
|
||||||
QT_QMAKE=$pkg_cv_QT_QMAKE
|
|
||||||
|
|
||||||
if test "x$QT_QMAKE" = x""; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
QT_QMAKE=`$as_dirname -- "$QT_QMAKE" ||
|
|
||||||
$as_expr X"$QT_QMAKE" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
|
||||||
X"$QT_QMAKE" : 'X\(//\)[^/]' \| \
|
|
||||||
X"$QT_QMAKE" : 'X\(//\)$' \| \
|
|
||||||
X"$QT_QMAKE" : 'X\(/\)' \| . 2>/dev/null ||
|
|
||||||
$as_echo X"$QT_QMAKE" |
|
|
||||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
|
||||||
s//\1/
|
|
||||||
q
|
|
||||||
}
|
|
||||||
/^X\(\/\/\)[^/].*/{
|
|
||||||
s//\1/
|
|
||||||
q
|
|
||||||
}
|
|
||||||
/^X\(\/\/\)$/{
|
|
||||||
s//\1/
|
|
||||||
q
|
|
||||||
}
|
|
||||||
/^X\(\/\).*/{
|
|
||||||
s//\1/
|
|
||||||
q
|
|
||||||
}
|
|
||||||
s/.*/./; q'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -f "$QT_QMAKE/qmake"; then :
|
|
||||||
QT_QMAKE="$QT_QMAKE/qmake"
|
|
||||||
else
|
|
||||||
if test -f "$QT_QMAKE/qmake-qt4"; then :
|
|
||||||
QT_QMAKE="$QT_QMAKE/qmake-qt4"
|
|
||||||
else
|
|
||||||
QT_QMAKE=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt4 qmake >= 4.8.0" >&5
|
|
||||||
$as_echo_n "checking for Qt4 qmake >= 4.8.0... " >&6; }
|
|
||||||
if test "x$QT_QMAKE" != "x"; then :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5
|
|
||||||
$as_echo "$QT_QMAKE" >&6; }
|
|
||||||
else
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
|
||||||
$as_echo "not found" >&6; }
|
|
||||||
|
|
||||||
fi
|
|
||||||
;; #(
|
|
||||||
*) :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_qt4" >&5
|
|
||||||
$as_echo "$with_qt4" >&6; }
|
|
||||||
as_fn_error $? "Unknown option \"$with_qt4\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
|
|
||||||
esac
|
|
||||||
if test "x$QT_QMAKE" = "x"; then :
|
|
||||||
as_fn_error $? "Could not find qmake" "$LINENO" 5
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether QtDBus should be enabled" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether QtDBus should be enabled" >&5
|
||||||
|
@ -4623,7 +4483,6 @@ case "x$enable_qt_dbus" in #(
|
||||||
"xyes") :
|
"xyes") :
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||||
$as_echo "yes" >&6; }
|
$as_echo "yes" >&6; }
|
||||||
if test "x$with_qt4" = "xno"; then :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.2.0" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.2.0" >&5
|
||||||
$as_echo_n "checking for Qt5DBus >= 5.2.0... " >&6; }
|
$as_echo_n "checking for Qt5DBus >= 5.2.0... " >&6; }
|
||||||
if test -n "$PKG_CONFIG" && \
|
if test -n "$PKG_CONFIG" && \
|
||||||
|
@ -4639,26 +4498,6 @@ else
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
||||||
$as_echo "not found" >&6; }
|
$as_echo "not found" >&6; }
|
||||||
HAVE_QTDBUS=false
|
HAVE_QTDBUS=false
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for QtDBus >= 4.8.0" >&5
|
|
||||||
$as_echo_n "checking for QtDBus >= 4.8.0... " >&6; }
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QtDBus >= 4.8.0\""; } >&5
|
|
||||||
($PKG_CONFIG --exists --print-errors "QtDBus >= 4.8.0") 2>&5
|
|
||||||
ac_status=$?
|
|
||||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
||||||
test $ac_status = 0; }; then
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
|
|
||||||
$as_echo "found" >&6; }
|
|
||||||
HAVE_QTDBUS=true
|
|
||||||
else
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
|
||||||
$as_echo "not found" >&6; }
|
|
||||||
HAVE_QTDBUS=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$HAVE_QTDBUS" = "xfalse"; then :
|
if test "x$HAVE_QTDBUS" = "xfalse"; then :
|
||||||
|
@ -5247,118 +5086,6 @@ $as_echo "$with_qtsingleapplication" >&6; }
|
||||||
as_fn_error $? "Unknown option \"$with_qtsingleapplication\". Use either \"system\" or \"shipped\"." "$LINENO" 5 ;;
|
as_fn_error $? "Unknown option \"$with_qtsingleapplication\". Use either \"system\" or \"shipped\"." "$LINENO" 5 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if test "x$with_qt4" = "xyes"; then :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which qjson to use" >&5
|
|
||||||
$as_echo_n "checking which qjson to use... " >&6; }
|
|
||||||
case "x$with_qjson" in #(
|
|
||||||
"xshipped") :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: shipped" >&5
|
|
||||||
$as_echo "shipped" >&6; }
|
|
||||||
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqjson" ;; #(
|
|
||||||
"xsystem") :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: system" >&5
|
|
||||||
$as_echo "system" >&6; }
|
|
||||||
|
|
||||||
pkg_failed=no
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for qjson" >&5
|
|
||||||
$as_echo_n "checking for qjson... " >&6; }
|
|
||||||
|
|
||||||
if test -n "$qjson_CFLAGS"; then
|
|
||||||
pkg_cv_qjson_CFLAGS="$qjson_CFLAGS"
|
|
||||||
elif test -n "$PKG_CONFIG"; then
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QJson >= 0.8.1\""; } >&5
|
|
||||||
($PKG_CONFIG --exists --print-errors "QJson >= 0.8.1") 2>&5
|
|
||||||
ac_status=$?
|
|
||||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
||||||
test $ac_status = 0; }; then
|
|
||||||
pkg_cv_qjson_CFLAGS=`$PKG_CONFIG --cflags "QJson >= 0.8.1" 2>/dev/null`
|
|
||||||
test "x$?" != "x0" && pkg_failed=yes
|
|
||||||
else
|
|
||||||
pkg_failed=yes
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
pkg_failed=untried
|
|
||||||
fi
|
|
||||||
if test -n "$qjson_LIBS"; then
|
|
||||||
pkg_cv_qjson_LIBS="$qjson_LIBS"
|
|
||||||
elif test -n "$PKG_CONFIG"; then
|
|
||||||
if test -n "$PKG_CONFIG" && \
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QJson >= 0.8.1\""; } >&5
|
|
||||||
($PKG_CONFIG --exists --print-errors "QJson >= 0.8.1") 2>&5
|
|
||||||
ac_status=$?
|
|
||||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
||||||
test $ac_status = 0; }; then
|
|
||||||
pkg_cv_qjson_LIBS=`$PKG_CONFIG --libs "QJson >= 0.8.1" 2>/dev/null`
|
|
||||||
test "x$?" != "x0" && pkg_failed=yes
|
|
||||||
else
|
|
||||||
pkg_failed=yes
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
pkg_failed=untried
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if test $pkg_failed = yes; then
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
||||||
$as_echo "no" >&6; }
|
|
||||||
|
|
||||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
|
||||||
_pkg_short_errors_supported=yes
|
|
||||||
else
|
|
||||||
_pkg_short_errors_supported=no
|
|
||||||
fi
|
|
||||||
if test $_pkg_short_errors_supported = yes; then
|
|
||||||
qjson_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "QJson >= 0.8.1" 2>&1`
|
|
||||||
else
|
|
||||||
qjson_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "QJson >= 0.8.1" 2>&1`
|
|
||||||
fi
|
|
||||||
# Put the nasty error message in config.log where it belongs
|
|
||||||
echo "$qjson_PKG_ERRORS" >&5
|
|
||||||
|
|
||||||
as_fn_error $? "Package requirements (QJson >= 0.8.1) were not met:
|
|
||||||
|
|
||||||
$qjson_PKG_ERRORS
|
|
||||||
|
|
||||||
Consider adjusting the PKG_CONFIG_PATH environment variable if you
|
|
||||||
installed software in a non-standard prefix.
|
|
||||||
|
|
||||||
Alternatively, you may set the environment variables qjson_CFLAGS
|
|
||||||
and qjson_LIBS to avoid the need to call pkg-config.
|
|
||||||
See the pkg-config man page for more details." "$LINENO" 5
|
|
||||||
elif test $pkg_failed = untried; then
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
||||||
$as_echo "no" >&6; }
|
|
||||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
||||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
||||||
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
|
|
||||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
|
||||||
path to pkg-config.
|
|
||||||
|
|
||||||
Alternatively, you may set the environment variables qjson_CFLAGS
|
|
||||||
and qjson_LIBS to avoid the need to call pkg-config.
|
|
||||||
See the pkg-config man page for more details.
|
|
||||||
|
|
||||||
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
|
|
||||||
See \`config.log' for more details" "$LINENO" 5; }
|
|
||||||
else
|
|
||||||
qjson_CFLAGS=$pkg_cv_qjson_CFLAGS
|
|
||||||
qjson_LIBS=$pkg_cv_qjson_LIBS
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
||||||
$as_echo "yes" >&6; }
|
|
||||||
CPPFLAGS="$qjson_CFLAGS $CPPFLAGS"
|
|
||||||
LIBS="$qjson_LIBS $LIBS"
|
|
||||||
fi
|
|
||||||
QBT_ADD_CONFIG="$QBT_ADD_CONFIG usesystemqjson" ;; #(
|
|
||||||
*) :
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_qjson" >&5
|
|
||||||
$as_echo "$with_qjson" >&6; }
|
|
||||||
as_fn_error $? "Unknown option \"$with_qjson\". Use either \"system\" or \"shipped\"." "$LINENO" 5 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
pkg_failed=no
|
pkg_failed=no
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libtorrent" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libtorrent" >&5
|
||||||
|
|
44
configure.ac
44
configure.ac
|
@ -12,24 +12,12 @@ AM_INIT_AUTOMAKE
|
||||||
|
|
||||||
# Define --wth-* and --enable-* arguments
|
# Define --wth-* and --enable-* arguments
|
||||||
|
|
||||||
AC_ARG_WITH(qt4,
|
|
||||||
[AS_HELP_STRING([--with-qt4],
|
|
||||||
[Compile using Qt4 (default=no)])],
|
|
||||||
[],
|
|
||||||
[with_qt4=no])
|
|
||||||
|
|
||||||
AC_ARG_WITH(qtsingleapplication,
|
AC_ARG_WITH(qtsingleapplication,
|
||||||
[AS_HELP_STRING([--with-qtsingleapplication=@<:@system|shipped@:>@],
|
[AS_HELP_STRING([--with-qtsingleapplication=@<:@system|shipped@:>@],
|
||||||
[Use the shipped qtsingleapplication library or the system one (default=shipped)])],
|
[Use the shipped qtsingleapplication library or the system one (default=shipped)])],
|
||||||
[],
|
[],
|
||||||
[with_qtsingleapplication=shipped])
|
[with_qtsingleapplication=shipped])
|
||||||
|
|
||||||
AC_ARG_WITH(qjson,
|
|
||||||
[AS_HELP_STRING([--with-qjson=@<:@system|shipped@:>@],
|
|
||||||
[Use the shipped qjson library or the system one (default=shipped) (Qt4 only)])],
|
|
||||||
[],
|
|
||||||
[with_qjson=shipped])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(debug,
|
AC_ARG_ENABLE(debug,
|
||||||
[AS_HELP_STRING([--enable-debug],
|
[AS_HELP_STRING([--enable-debug],
|
||||||
[Enable debug build])],
|
[Enable debug build])],
|
||||||
|
@ -127,20 +115,7 @@ AS_CASE(["x$enable_webui"],
|
||||||
[AC_MSG_RESULT([$enable_webui])
|
[AC_MSG_RESULT([$enable_webui])
|
||||||
AC_MSG_ERROR([Unknown option "$enable_webui". Use either "yes" or "no".])])
|
AC_MSG_ERROR([Unknown option "$enable_webui". Use either "yes" or "no".])])
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether Qt4 should be enabled])
|
FIND_QT5()
|
||||||
AS_CASE(["x$with_qt4"],
|
|
||||||
["xno"],
|
|
||||||
[AC_MSG_RESULT([no])
|
|
||||||
FIND_QT5()],
|
|
||||||
["xyes"],
|
|
||||||
[AC_MSG_RESULT([yes])
|
|
||||||
FIND_QT4()],
|
|
||||||
[AC_MSG_RESULT([$with_qt4])
|
|
||||||
AC_MSG_ERROR([Unknown option "$with_qt4". Use either "yes" or "no".])])
|
|
||||||
AS_IF([test "x$QT_QMAKE" = "x"],
|
|
||||||
[AC_MSG_ERROR([Could not find qmake])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether QtDBus should be enabled])
|
AC_MSG_CHECKING([whether QtDBus should be enabled])
|
||||||
AS_CASE(["x$enable_qt_dbus"],
|
AS_CASE(["x$enable_qt_dbus"],
|
||||||
["xyes"],
|
["xyes"],
|
||||||
|
@ -185,23 +160,6 @@ AS_CASE(["x$with_qtsingleapplication"],
|
||||||
[AC_MSG_RESULT([$with_qtsingleapplication])
|
[AC_MSG_RESULT([$with_qtsingleapplication])
|
||||||
AC_MSG_ERROR([Unknown option "$with_qtsingleapplication". Use either "system" or "shipped".])])
|
AC_MSG_ERROR([Unknown option "$with_qtsingleapplication". Use either "system" or "shipped".])])
|
||||||
|
|
||||||
AS_IF([test "x$with_qt4" = "xyes"],
|
|
||||||
[AC_MSG_CHECKING([which qjson to use])
|
|
||||||
AS_CASE(["x$with_qjson"],
|
|
||||||
["xshipped"],
|
|
||||||
[AC_MSG_RESULT([shipped])
|
|
||||||
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqjson"],
|
|
||||||
["xsystem"],
|
|
||||||
[AC_MSG_RESULT([system])
|
|
||||||
PKG_CHECK_MODULES(qjson,
|
|
||||||
[QJson >= 0.8.1],
|
|
||||||
[CPPFLAGS="$qjson_CFLAGS $CPPFLAGS"
|
|
||||||
LIBS="$qjson_LIBS $LIBS"])
|
|
||||||
QBT_ADD_CONFIG="$QBT_ADD_CONFIG usesystemqjson"],
|
|
||||||
[AC_MSG_RESULT([$with_qjson])
|
|
||||||
AC_MSG_ERROR([Unknown option "$with_qjson". Use either "system" or "shipped".])])
|
|
||||||
])
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(libtorrent,
|
PKG_CHECK_MODULES(libtorrent,
|
||||||
[libtorrent-rasterbar >= 1.0.6],
|
[libtorrent-rasterbar >= 1.0.6],
|
||||||
[CPPFLAGS="$libtorrent_CFLAGS $CPPFLAGS"
|
[CPPFLAGS="$libtorrent_CFLAGS $CPPFLAGS"
|
||||||
|
|
|
@ -1,31 +1,6 @@
|
||||||
# Checking for pkg-config. If found, check for QtCore and query pkg-config
|
# Checking for pkg-config. If found, check for QtCore and query pkg-config
|
||||||
# for its exec-prefix variable.
|
# for its exec-prefix variable.
|
||||||
|
|
||||||
# FIND_QT4()
|
|
||||||
# Sets the QT_QMAKE variable to the path of Qt4 qmake if found.
|
|
||||||
# --------------------------------------
|
|
||||||
AC_DEFUN([FIND_QT4],
|
|
||||||
[PKG_CHECK_EXISTS([QtCore >= 4.8.0],
|
|
||||||
[PKG_CHECK_VAR(QT_QMAKE,
|
|
||||||
[QtCore >= 4.8.0],
|
|
||||||
[moc_location],
|
|
||||||
[QT_QMAKE=`AS_DIRNAME(["$QT_QMAKE"])`])
|
|
||||||
])
|
|
||||||
|
|
||||||
AS_IF([test -f "$QT_QMAKE/qmake"],
|
|
||||||
[QT_QMAKE="$QT_QMAKE/qmake"],
|
|
||||||
[AS_IF([test -f "$QT_QMAKE/qmake-qt4"],
|
|
||||||
[QT_QMAKE="$QT_QMAKE/qmake-qt4"],
|
|
||||||
[QT_QMAKE=""])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for Qt4 qmake >= 4.8.0])
|
|
||||||
AS_IF([test "x$QT_QMAKE" != "x"],
|
|
||||||
[AC_MSG_RESULT([$QT_QMAKE])],
|
|
||||||
[AC_MSG_RESULT([not found])]
|
|
||||||
)
|
|
||||||
])
|
|
||||||
|
|
||||||
# FIND_QT5()
|
# FIND_QT5()
|
||||||
# Sets the QT_QMAKE variable to the path of Qt5 qmake if found.
|
# Sets the QT_QMAKE variable to the path of Qt5 qmake if found.
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
@ -54,19 +29,10 @@ AS_IF([test "x$QT_QMAKE" != "x"],
|
||||||
# Sets the HAVE_QTDBUS variable to true or false.
|
# Sets the HAVE_QTDBUS variable to true or false.
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
AC_DEFUN([FIND_QTDBUS],
|
AC_DEFUN([FIND_QTDBUS],
|
||||||
[AS_IF([test "x$with_qt4" = "xno"],
|
|
||||||
[AC_MSG_CHECKING([for Qt5DBus >= 5.2.0])
|
[AC_MSG_CHECKING([for Qt5DBus >= 5.2.0])
|
||||||
PKG_CHECK_EXISTS([Qt5DBus >= 5.2.0],
|
PKG_CHECK_EXISTS([Qt5DBus >= 5.2.0],
|
||||||
[AC_MSG_RESULT([found])
|
[AC_MSG_RESULT([found])
|
||||||
HAVE_QTDBUS=[true]],
|
HAVE_QTDBUS=[true]],
|
||||||
[AC_MSG_RESULT([not found])
|
[AC_MSG_RESULT([not found])
|
||||||
HAVE_QTDBUS=[false]])
|
HAVE_QTDBUS=[false]])
|
||||||
],
|
|
||||||
[AC_MSG_CHECKING([for QtDBus >= 4.8.0])
|
|
||||||
PKG_CHECK_EXISTS([QtDBus >= 4.8.0],
|
|
||||||
[AC_MSG_RESULT([found])
|
|
||||||
HAVE_QTDBUS=[true]],
|
|
||||||
[AC_MSG_RESULT([not found])
|
|
||||||
HAVE_QTDBUS=[false]])
|
|
||||||
])
|
|
||||||
])
|
])
|
||||||
|
|
|
@ -8,8 +8,6 @@ include(QbtTargetSources)
|
||||||
find_package(LibtorrentRasterbar REQUIRED)
|
find_package(LibtorrentRasterbar REQUIRED)
|
||||||
|
|
||||||
# Qt
|
# Qt
|
||||||
if (QT5)
|
|
||||||
add_definitions(-DQBT_USES_QT5)
|
|
||||||
list(APPEND QBT_QT_COMPONENTS Core Network Xml)
|
list(APPEND QBT_QT_COMPONENTS Core Network Xml)
|
||||||
if (GUI)
|
if (GUI)
|
||||||
list (APPEND QBT_QT_COMPONENTS Concurrent Gui Widgets)
|
list (APPEND QBT_QT_COMPONENTS Concurrent Gui Widgets)
|
||||||
|
@ -18,17 +16,7 @@ if (QT5)
|
||||||
list (APPEND QBT_QT_COMPONENTS DBus)
|
list (APPEND QBT_QT_COMPONENTS DBus)
|
||||||
endif (DBUS)
|
endif (DBUS)
|
||||||
find_package(Qt5 5.2.0 COMPONENTS ${QBT_QT_COMPONENTS} REQUIRED)
|
find_package(Qt5 5.2.0 COMPONENTS ${QBT_QT_COMPONENTS} REQUIRED)
|
||||||
else (QT5)
|
|
||||||
list(APPEND QBT_QT_COMPONENTS QtCore QtNetwork QtXml)
|
|
||||||
if (GUI)
|
|
||||||
list (APPEND QBT_QT_COMPONENTS QtGui)
|
|
||||||
endif (GUI)
|
|
||||||
if (DBUS)
|
|
||||||
list (APPEND QBT_QT_COMPONENTS QtDBus)
|
|
||||||
endif (DBUS)
|
|
||||||
find_package(Qt4 4.8.0 COMPONENTS ${QBT_QT_COMPONENTS} REQUIRED)
|
|
||||||
include(${QT_USE_FILE})
|
|
||||||
endif (QT5)
|
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC True)
|
set(CMAKE_AUTOMOC True)
|
||||||
list(APPEND CMAKE_AUTORCC_OPTIONS -compress 9 -threshold 5)
|
list(APPEND CMAKE_AUTORCC_OPTIONS -compress 9 -threshold 5)
|
||||||
|
|
|
@ -17,12 +17,8 @@ file(GLOB QBT_TS_FILES ../lang/*.ts)
|
||||||
get_filename_component(QBT_QM_FILES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/../lang" ABSOLUTE)
|
get_filename_component(QBT_QM_FILES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/../lang" ABSOLUTE)
|
||||||
set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${QBT_QM_FILES_BINARY_DIR}")
|
set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${QBT_QM_FILES_BINARY_DIR}")
|
||||||
|
|
||||||
if (QT5)
|
|
||||||
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
|
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
|
||||||
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
|
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
|
||||||
else (QT5)
|
|
||||||
qt4_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
|
|
||||||
endif (QT5)
|
|
||||||
|
|
||||||
get_filename_component(_lang_qrc_src "${CMAKE_CURRENT_SOURCE_DIR}/../lang.qrc" ABSOLUTE)
|
get_filename_component(_lang_qrc_src "${CMAKE_CURRENT_SOURCE_DIR}/../lang.qrc" ABSOLUTE)
|
||||||
get_filename_component(_lang_qrc_dst "${CMAKE_CURRENT_BINARY_DIR}/../lang.qrc" ABSOLUTE)
|
get_filename_component(_lang_qrc_dst "${CMAKE_CURRENT_BINARY_DIR}/../lang.qrc" ABSOLUTE)
|
||||||
|
|
|
@ -114,9 +114,7 @@ Application::Application(const QString &id, int &argc, char **argv)
|
||||||
setApplicationName("qBittorrent");
|
setApplicationName("qBittorrent");
|
||||||
initializeTranslation();
|
initializeTranslation();
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
|
setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
|
||||||
#endif // QBT_USES_QT5
|
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
connect(this, SIGNAL(commitDataRequest(QSessionManager &)), this, SLOT(shutdownCleanup(QSessionManager &)), Qt::DirectConnection);
|
connect(this, SIGNAL(commitDataRequest(QSessionManager &)), this, SLOT(shutdownCleanup(QSessionManager &)), Qt::DirectConnection);
|
||||||
|
@ -514,14 +512,12 @@ void Application::initializeTranslation()
|
||||||
QString localeStr = pref->getLocale();
|
QString localeStr = pref->getLocale();
|
||||||
QLocale::setDefault(QLocale(localeStr));
|
QLocale::setDefault(QLocale(localeStr));
|
||||||
|
|
||||||
if (
|
if (m_qtTranslator.load(QString::fromUtf8("qtbase_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
m_qtTranslator.load(QString::fromUtf8("qtbase_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
|
|
||||||
#endif
|
|
||||||
m_qtTranslator.load(QString::fromUtf8("qt_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
m_qtTranslator.load(QString::fromUtf8("qt_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||||
qDebug("Qt %s locale recognized, using translation.", qPrintable(localeStr));
|
qDebug("Qt %s locale recognized, using translation.", qPrintable(localeStr));
|
||||||
else
|
else
|
||||||
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(localeStr));
|
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(localeStr));
|
||||||
|
|
||||||
installTranslator(&m_qtTranslator);
|
installTranslator(&m_qtTranslator);
|
||||||
|
|
||||||
if (m_translator.load(QString::fromUtf8(":/lang/qbittorrent_") + localeStr))
|
if (m_translator.load(QString::fromUtf8(":/lang/qbittorrent_") + localeStr))
|
||||||
|
|
|
@ -42,11 +42,7 @@
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
#ifdef QBT_STATIC_QT
|
#ifdef QBT_STATIC_QT
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
Q_IMPORT_PLUGIN(QICOPlugin)
|
Q_IMPORT_PLUGIN(QICOPlugin)
|
||||||
#else
|
|
||||||
Q_IMPORT_PLUGIN(qico)
|
|
||||||
#endif
|
|
||||||
#endif // QBT_STATIC_QT
|
#endif // QBT_STATIC_QT
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -225,7 +221,7 @@ int main(int argc, char *argv[])
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(QBT_USES_QT5)
|
#if defined(Q_OS_WIN)
|
||||||
// This affects only Windows apparently and Qt5.
|
// This affects only Windows apparently and Qt5.
|
||||||
// When QNetworkAccessManager is instantiated it regularly starts polling
|
// When QNetworkAccessManager is instantiated it regularly starts polling
|
||||||
// the network interfaces to see what's available and their status.
|
// the network interfaces to see what's available and their status.
|
||||||
|
|
|
@ -18,19 +18,10 @@ endif (GUI)
|
||||||
|
|
||||||
add_library(qtsingleapplication ${QBT_QTSINGLEAPPLICATION_HEADERS} ${QBT_QTSINGLEAPPLICATION_SOURCES})
|
add_library(qtsingleapplication ${QBT_QTSINGLEAPPLICATION_HEADERS} ${QBT_QTSINGLEAPPLICATION_SOURCES})
|
||||||
target_include_directories(qtsingleapplication INTERFACE "${qtsingleapplication_SOURCE_DIR}")
|
target_include_directories(qtsingleapplication INTERFACE "${qtsingleapplication_SOURCE_DIR}")
|
||||||
|
target_link_qt_components(qtsingleapplication Network)
|
||||||
if (QT4_FOUND)
|
|
||||||
target_link_libraries(qtsingleapplication Qt4::QtNetwork)
|
|
||||||
else (QT4_FOUND)
|
|
||||||
target_link_libraries(qtsingleapplication Qt5::Network)
|
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
||||||
if (GUI)
|
if (GUI)
|
||||||
if (QT4_FOUND)
|
target_link_qt_components(qtsingleapplication Widgets)
|
||||||
target_link_libraries(qtsingleapplication Qt4::QtGui)
|
|
||||||
else (QT4_FOUND)
|
|
||||||
target_link_libraries(qtsingleapplication Qt5::Widgets)
|
|
||||||
endif(QT4_FOUND)
|
|
||||||
endif (GUI)
|
endif (GUI)
|
||||||
|
|
||||||
add_library(QtSingleApplication::QtSingleApplication ALIAS qtsingleapplication)
|
add_library(QtSingleApplication::QtSingleApplication ALIAS qtsingleapplication)
|
||||||
|
|
|
@ -121,15 +121,10 @@ tristatebool.cpp
|
||||||
add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES})
|
add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES})
|
||||||
target_link_libraries(qbt_base PRIVATE ZLIB::ZLIB PUBLIC LibtorrentRasterbar::LibTorrent)
|
target_link_libraries(qbt_base PRIVATE ZLIB::ZLIB PUBLIC LibtorrentRasterbar::LibTorrent)
|
||||||
target_link_qt_components(qbt_base PUBLIC Core Network Xml)
|
target_link_qt_components(qbt_base PUBLIC Core Network Xml)
|
||||||
if (QT4_FOUND)
|
|
||||||
if (GUI)
|
|
||||||
target_link_libraries(qbt_base PUBLIC Qt4::QtGui)
|
|
||||||
endif (GUI)
|
|
||||||
else (QT4_FOUND)
|
|
||||||
if (GUI)
|
if (GUI)
|
||||||
target_link_libraries(qbt_base PUBLIC Qt5::Gui Qt5::Widgets)
|
target_link_libraries(qbt_base PUBLIC Qt5::Gui Qt5::Widgets)
|
||||||
endif (GUI)
|
endif (GUI)
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
||||||
if (DBUS)
|
if (DBUS)
|
||||||
target_link_qt_components(qbt_base PRIVATE DBus)
|
target_link_qt_components(qbt_base PRIVATE DBus)
|
||||||
|
|
|
@ -27,11 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#else
|
|
||||||
#include <QFile>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
@ -48,18 +44,12 @@ void ResumeDataSavingManager::saveResumeData(QString infoHash, QByteArray data)
|
||||||
QString filepath = m_resumeDataDir.absoluteFilePath(filename);
|
QString filepath = m_resumeDataDir.absoluteFilePath(filename);
|
||||||
|
|
||||||
qDebug() << "Saving resume data in" << filepath;
|
qDebug() << "Saving resume data in" << filepath;
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
QSaveFile resumeFile(filepath);
|
QSaveFile resumeFile(filepath);
|
||||||
#else
|
|
||||||
QFile resumeFile(filepath);
|
|
||||||
#endif
|
|
||||||
if (resumeFile.open(QIODevice::WriteOnly)) {
|
if (resumeFile.open(QIODevice::WriteOnly)) {
|
||||||
resumeFile.write(data);
|
resumeFile.write(data);
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
if (!resumeFile.commit()) {
|
if (!resumeFile.commit()) {
|
||||||
Logger::instance()->addMessage(QString("Couldn't save resume data in %1. Error: %2")
|
Logger::instance()->addMessage(QString("Couldn't save resume data in %1. Error: %2")
|
||||||
.arg(filepath).arg(resumeFile.errorString()), Log::WARNING);
|
.arg(filepath).arg(resumeFile.errorString()), Log::WARNING);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#endif
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "requestparser.h"
|
#include "requestparser.h"
|
||||||
|
@ -121,11 +119,7 @@ bool RequestParser::parseStartingLine(const QString &line)
|
||||||
m_request.path = url.path(); // Path
|
m_request.path = url.path(); // Path
|
||||||
|
|
||||||
// Parse GET parameters
|
// Parse GET parameters
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
|
||||||
#else
|
|
||||||
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems());
|
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems());
|
||||||
#endif
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
QPair<QString, QString> pair = i.next();
|
QPair<QString, QString> pair = i.next();
|
||||||
m_request.gets[pair.first] = pair.second;
|
m_request.gets[pair.first] = pair.second;
|
||||||
|
@ -220,13 +214,8 @@ bool RequestParser::parseContent(const QByteArray& data)
|
||||||
// Parse url-encoded POST data
|
// Parse url-encoded POST data
|
||||||
if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) {
|
if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) {
|
||||||
QUrl url;
|
QUrl url;
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
url.setEncodedQuery(data);
|
|
||||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
|
||||||
#else
|
|
||||||
url.setQuery(data);
|
url.setQuery(data);
|
||||||
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems(QUrl::FullyDecoded));
|
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems(QUrl::FullyDecoded));
|
||||||
#endif
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
QPair<QString, QString> pair = i.next();
|
QPair<QString, QString> pair = i.next();
|
||||||
m_request.posts[pair.first.toLower()] = pair.second;
|
m_request.posts[pair.first.toLower()] = pair.second;
|
||||||
|
|
|
@ -76,11 +76,7 @@ void Server::disableHttps()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
void Server::incomingConnection(qintptr socketDescriptor)
|
void Server::incomingConnection(qintptr socketDescriptor)
|
||||||
#else
|
|
||||||
void Server::incomingConnection(int socketDescriptor)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
QTcpSocket *serverSocket;
|
QTcpSocket *serverSocket;
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
|
@ -95,11 +91,7 @@ void Server::incomingConnection(int socketDescriptor)
|
||||||
if (m_https) {
|
if (m_https) {
|
||||||
static_cast<QSslSocket *>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
static_cast<QSslSocket *>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
||||||
static_cast<QSslSocket *>(serverSocket)->setPrivateKey(m_key);
|
static_cast<QSslSocket *>(serverSocket)->setPrivateKey(m_key);
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificateChain(m_certificates);
|
static_cast<QSslSocket *>(serverSocket)->setLocalCertificateChain(m_certificates);
|
||||||
#else
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificate(m_certificates.first());
|
|
||||||
#endif
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->setPeerVerifyMode(QSslSocket::VerifyNone);
|
static_cast<QSslSocket *>(serverSocket)->setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||||
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
|
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,15 +62,10 @@ namespace Http
|
||||||
private:
|
private:
|
||||||
IRequestHandler *m_requestHandler;
|
IRequestHandler *m_requestHandler;
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
void incomingConnection(qintptr socketDescriptor);
|
void incomingConnection(qintptr socketDescriptor);
|
||||||
#else
|
|
||||||
void incomingConnection(int socketDescriptor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
QList<QSslCipher> safeCipherList() const;
|
QList<QSslCipher> safeCipherList() const;
|
||||||
|
|
||||||
bool m_https;
|
bool m_https;
|
||||||
QList<QSslCertificate> m_certificates;
|
QList<QSslCertificate> m_certificates;
|
||||||
QSslKey m_key;
|
QSslKey m_key;
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
|
@ -158,15 +156,10 @@ QString DNSUpdater::getUpdateUrl() const
|
||||||
}
|
}
|
||||||
url.setPath("/nic/update");
|
url.setPath("/nic/update");
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
url.addQueryItem("hostname", m_domain);
|
|
||||||
url.addQueryItem("myip", m_lastIP.toString());
|
|
||||||
#else
|
|
||||||
QUrlQuery urlQuery(url);
|
QUrlQuery urlQuery(url);
|
||||||
urlQuery.addQueryItem("hostname", m_domain);
|
urlQuery.addQueryItem("hostname", m_domain);
|
||||||
urlQuery.addQueryItem("myip", m_lastIP.toString());
|
urlQuery.addQueryItem("myip", m_lastIP.toString());
|
||||||
url.setQuery(urlQuery);
|
url.setQuery(urlQuery);
|
||||||
#endif
|
|
||||||
Q_ASSERT(url.isValid());
|
Q_ASSERT(url.isValid());
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << url.toString();
|
qDebug() << Q_FUNC_INFO << url.toString();
|
||||||
|
|
|
@ -79,26 +79,6 @@ namespace
|
||||||
using QNetworkCookieJar::allCookies;
|
using QNetworkCookieJar::allCookies;
|
||||||
using QNetworkCookieJar::setAllCookies;
|
using QNetworkCookieJar::setAllCookies;
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
virtual bool deleteCookie(const QNetworkCookie &cookie)
|
|
||||||
{
|
|
||||||
auto myCookies = allCookies();
|
|
||||||
|
|
||||||
QList<QNetworkCookie>::Iterator it;
|
|
||||||
for (it = myCookies.begin(); it != myCookies.end(); ++it) {
|
|
||||||
if ((it->name() == cookie.name())
|
|
||||||
&& (it->domain() == cookie.domain())
|
|
||||||
&& (it->path() == cookie.path())) {
|
|
||||||
myCookies.erase(it);
|
|
||||||
setAllCookies(myCookies);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
|
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
|
@ -65,10 +65,6 @@ namespace
|
||||||
Boolean = 14,
|
Boolean = 14,
|
||||||
Float = 15
|
Float = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
Q_IPV6ADDR createMappedAddress(quint32 ip4);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DataFieldDescriptor
|
struct DataFieldDescriptor
|
||||||
|
@ -166,13 +162,7 @@ QDateTime GeoIPDatabase::buildEpoch() const
|
||||||
|
|
||||||
QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||||
{
|
{
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
Q_IPV6ADDR addr = hostAddr.protocol() == QAbstractSocket::IPv4Protocol
|
|
||||||
? createMappedAddress(hostAddr.toIPv4Address())
|
|
||||||
: hostAddr.toIPv6Address();
|
|
||||||
#else
|
|
||||||
Q_IPV6ADDR addr = hostAddr.toIPv6Address();
|
Q_IPV6ADDR addr = hostAddr.toIPv6Address();
|
||||||
#endif
|
|
||||||
|
|
||||||
const uchar *ptr = m_data;
|
const uchar *ptr = m_data;
|
||||||
|
|
||||||
|
@ -496,25 +486,3 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
Q_IPV6ADDR createMappedAddress(quint32 ip4)
|
|
||||||
{
|
|
||||||
Q_IPV6ADDR ip6;
|
|
||||||
memset(&ip6, 0, sizeof(ip6));
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 15; ip4 != 0; i--) {
|
|
||||||
ip6[i] = ip4 & 0xFF;
|
|
||||||
ip4 >>= 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip6[11] = 0xFF;
|
|
||||||
ip6[10] = 0xFF;
|
|
||||||
|
|
||||||
return ip6;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -126,8 +126,4 @@ namespace Net
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
Q_DECLARE_METATYPE(QAbstractSocket::SocketError)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1109,20 +1109,12 @@ void Preferences::setMainGeometry(const QByteArray &geometry)
|
||||||
|
|
||||||
QByteArray Preferences::getMainVSplitterState() const
|
QByteArray Preferences::getMainVSplitterState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("MainWindow/qt5/vsplitterState").toByteArray();
|
return value("MainWindow/qt5/vsplitterState").toByteArray();
|
||||||
#else
|
|
||||||
return value("MainWindow/vsplitterState").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setMainVSplitterState(const QByteArray &state)
|
void Preferences::setMainVSplitterState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("MainWindow/qt5/vsplitterState", state);
|
setValue("MainWindow/qt5/vsplitterState", state);
|
||||||
#else
|
|
||||||
setValue("MainWindow/vsplitterState", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Preferences::getMainLastDir() const
|
QString Preferences::getMainLastDir() const
|
||||||
|
@ -1169,20 +1161,12 @@ void Preferences::setPrefHSplitterSizes(const QStringList &sizes)
|
||||||
|
|
||||||
QByteArray Preferences::getPeerListState() const
|
QByteArray Preferences::getPeerListState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray();
|
return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray();
|
||||||
#else
|
|
||||||
return value("TorrentProperties/Peers/PeerListState").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPeerListState(const QByteArray &state)
|
void Preferences::setPeerListState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("TorrentProperties/Peers/qt5/PeerListState", state);
|
setValue("TorrentProperties/Peers/qt5/PeerListState", state);
|
||||||
#else
|
|
||||||
setValue("TorrentProperties/Peers/PeerListState", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Preferences::getPropSplitterSizes() const
|
QString Preferences::getPropSplitterSizes() const
|
||||||
|
@ -1197,20 +1181,12 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
|
||||||
|
|
||||||
QByteArray Preferences::getPropFileListState() const
|
QByteArray Preferences::getPropFileListState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("TorrentProperties/qt5/FilesListState").toByteArray();
|
return value("TorrentProperties/qt5/FilesListState").toByteArray();
|
||||||
#else
|
|
||||||
return value("TorrentProperties/FilesListState").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPropFileListState(const QByteArray &state)
|
void Preferences::setPropFileListState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("TorrentProperties/qt5/FilesListState", state);
|
setValue("TorrentProperties/qt5/FilesListState", state);
|
||||||
#else
|
|
||||||
setValue("TorrentProperties/FilesListState", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Preferences::getPropCurTab() const
|
int Preferences::getPropCurTab() const
|
||||||
|
@ -1235,20 +1211,12 @@ void Preferences::setPropVisible(const bool visible)
|
||||||
|
|
||||||
QByteArray Preferences::getPropTrackerListState() const
|
QByteArray Preferences::getPropTrackerListState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray();
|
return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray();
|
||||||
#else
|
|
||||||
return value("TorrentProperties/Trackers/TrackerListState").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPropTrackerListState(const QByteArray &state)
|
void Preferences::setPropTrackerListState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
||||||
#else
|
|
||||||
setValue("TorrentProperties/Trackers/TrackerListState", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Preferences::getRssGeometry() const
|
QByteArray Preferences::getRssGeometry() const
|
||||||
|
@ -1263,20 +1231,12 @@ void Preferences::setRssGeometry(const QByteArray &geometry)
|
||||||
|
|
||||||
QByteArray Preferences::getRssHSplitterSizes() const
|
QByteArray Preferences::getRssHSplitterSizes() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray();
|
return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray();
|
||||||
#else
|
|
||||||
return value("RssFeedDownloader/hsplitterSizes").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
|
void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
|
setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
|
||||||
#else
|
|
||||||
setValue("RssFeedDownloader/hsplitterSizes", sizes);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Preferences::getRssOpenFolders() const
|
QStringList Preferences::getRssOpenFolders() const
|
||||||
|
@ -1291,38 +1251,22 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
|
||||||
|
|
||||||
QByteArray Preferences::getRssSideSplitterState() const
|
QByteArray Preferences::getRssSideSplitterState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("Rss/qt5/splitter_h").toByteArray();
|
return value("Rss/qt5/splitter_h").toByteArray();
|
||||||
#else
|
|
||||||
return value("Rss/splitter_h").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setRssSideSplitterState(const QByteArray &state)
|
void Preferences::setRssSideSplitterState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("Rss/qt5/splitter_h", state);
|
setValue("Rss/qt5/splitter_h", state);
|
||||||
#else
|
|
||||||
setValue("Rss/splitter_h", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Preferences::getRssMainSplitterState() const
|
QByteArray Preferences::getRssMainSplitterState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("Rss/qt5/splitterMain").toByteArray();
|
return value("Rss/qt5/splitterMain").toByteArray();
|
||||||
#else
|
|
||||||
return value("Rss/splitterMain").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setRssMainSplitterState(const QByteArray &state)
|
void Preferences::setRssMainSplitterState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("Rss/qt5/splitterMain", state);
|
setValue("Rss/qt5/splitterMain", state);
|
||||||
#else
|
|
||||||
setValue("Rss/splitterMain", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Preferences::getSearchTabHeaderState() const
|
QByteArray Preferences::getSearchTabHeaderState() const
|
||||||
|
@ -1465,20 +1409,12 @@ void Preferences::setTransSelFilter(const int &index)
|
||||||
|
|
||||||
QByteArray Preferences::getTransHeaderState() const
|
QByteArray Preferences::getTransHeaderState() const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return value("TransferList/qt5/HeaderState").toByteArray();
|
return value("TransferList/qt5/HeaderState").toByteArray();
|
||||||
#else
|
|
||||||
return value("TransferList/HeaderState").toByteArray();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setTransHeaderState(const QByteArray &state)
|
void Preferences::setTransHeaderState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
setValue("TransferList/qt5/HeaderState", state);
|
setValue("TransferList/qt5/HeaderState", state);
|
||||||
#else
|
|
||||||
setValue("TransferList/HeaderState", state);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//From old RssSettings class
|
//From old RssSettings class
|
||||||
|
|
|
@ -75,20 +75,7 @@ namespace
|
||||||
QString m_name;
|
QString m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
typedef QHash<QString, QString> MappingTable;
|
typedef QHash<QString, QString> MappingTable;
|
||||||
#else
|
|
||||||
class MappingTable: public QHash<QString, QString>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MappingTable(std::initializer_list<std::pair<QString, QString>> list)
|
|
||||||
{
|
|
||||||
reserve(static_cast<int>(list.size()));
|
|
||||||
for (const auto &i : list)
|
|
||||||
insert(i.first, i.second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QString mapKey(const QString &key)
|
QString mapKey(const QString &key)
|
||||||
{
|
{
|
||||||
|
@ -161,11 +148,7 @@ namespace
|
||||||
{"Network/Proxy/IP", "Preferences/Connection/Proxy/IP"},
|
{"Network/Proxy/IP", "Preferences/Connection/Proxy/IP"},
|
||||||
{"Network/Proxy/Port", "Preferences/Connection/Proxy/Port"},
|
{"Network/Proxy/Port", "Preferences/Connection/Proxy/Port"},
|
||||||
{"Network/PortForwardingEnabled", "Preferences/Connection/UPnP"},
|
{"Network/PortForwardingEnabled", "Preferences/Connection/UPnP"},
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/qt5/treeHeaderState"},
|
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/qt5/treeHeaderState"},
|
||||||
#else
|
|
||||||
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/treeHeaderState"},
|
|
||||||
#endif
|
|
||||||
{"AddNewTorrentDialog/Width", "AddNewTorrentDialog/width"},
|
{"AddNewTorrentDialog/Width", "AddNewTorrentDialog/width"},
|
||||||
{"AddNewTorrentDialog/Position", "AddNewTorrentDialog/y"},
|
{"AddNewTorrentDialog/Position", "AddNewTorrentDialog/y"},
|
||||||
{"AddNewTorrentDialog/Expanded", "AddNewTorrentDialog/expanded"},
|
{"AddNewTorrentDialog/Expanded", "AddNewTorrentDialog/expanded"},
|
||||||
|
|
|
@ -55,15 +55,7 @@
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@ -182,24 +174,7 @@ bool Utils::Fs::forceRemove(const QString& file_path)
|
||||||
*/
|
*/
|
||||||
void Utils::Fs::removeDirRecursive(const QString& dirName)
|
void Utils::Fs::removeDirRecursive(const QString& dirName)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
QDir(dirName).removeRecursively();
|
QDir(dirName).removeRecursively();
|
||||||
#else
|
|
||||||
QDir dir(dirName);
|
|
||||||
|
|
||||||
if (!dir.exists()) return;
|
|
||||||
|
|
||||||
Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot |
|
|
||||||
QDir::System |
|
|
||||||
QDir::Hidden |
|
|
||||||
QDir::AllDirs |
|
|
||||||
QDir::Files, QDir::DirsFirst)) {
|
|
||||||
if (info.isDir()) removeDirRecursive(info.absoluteFilePath());
|
|
||||||
else forceRemove(info.absoluteFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
dir.rmdir(dirName);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,74 +388,12 @@ QString Utils::Fs::QDesktopServicesCacheLocation()
|
||||||
|
|
||||||
QString Utils::Fs::QDesktopServicesDownloadLocation()
|
QString Utils::Fs::QDesktopServicesDownloadLocation()
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
|
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
|
||||||
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(
|
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(
|
||||||
QCoreApplication::translate("fsutils", "Downloads"));
|
QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
#endif
|
#endif
|
||||||
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(Q_OS_OS2)
|
|
||||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
|
||||||
QCoreApplication::translate("fsutils", "Downloads"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
// as long as it stays WinXP like we do the same on OS/2
|
|
||||||
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
|
||||||
// instead of hardcoding "Downloads"
|
|
||||||
// Unfortunately, this would break compatibility with WinXP
|
|
||||||
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
|
|
||||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
|
||||||
QCoreApplication::translate("fsutils", "Downloads"));
|
|
||||||
else
|
|
||||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).absoluteFilePath("Downloads");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
|
||||||
QString save_path;
|
|
||||||
// Default save path on Linux
|
|
||||||
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
|
||||||
if (config_path.isEmpty())
|
|
||||||
config_path = QDir::home().absoluteFilePath(".config");
|
|
||||||
|
|
||||||
QString user_dirs_file = config_path + "/user-dirs.dirs";
|
|
||||||
if (QFile::exists(user_dirs_file)) {
|
|
||||||
QSettings settings(user_dirs_file, QSettings::IniFormat);
|
|
||||||
// We need to force UTF-8 encoding here since this is not
|
|
||||||
// the default for Ini files.
|
|
||||||
settings.setIniCodec("UTF-8");
|
|
||||||
QString xdg_download_dir = settings.value("XDG_DOWNLOAD_DIR").toString();
|
|
||||||
if (!xdg_download_dir.isEmpty()) {
|
|
||||||
// Resolve $HOME environment variables
|
|
||||||
xdg_download_dir.replace("$HOME", QDir::homePath());
|
|
||||||
save_path = xdg_download_dir;
|
|
||||||
qDebug() << Q_FUNC_INFO << "SUCCESS: Using XDG path for downloads: " << save_path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback
|
|
||||||
if (!save_path.isEmpty() && !QFile::exists(save_path)) {
|
|
||||||
QDir().mkpath(save_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (save_path.isEmpty() || !QFile::exists(save_path)) {
|
|
||||||
save_path = QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
|
||||||
qDebug() << Q_FUNC_INFO << "using" << save_path << "as fallback since the XDG detection did not work";
|
|
||||||
}
|
|
||||||
|
|
||||||
return save_path;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
|
||||||
// TODO: How to support this on Mac OS?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fallback
|
|
||||||
return QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::Fs::cacheLocation()
|
QString Utils::Fs::cacheLocation()
|
||||||
|
|
|
@ -32,12 +32,9 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QCollator>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QCollator>
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <QThreadStorage>
|
#include <QThreadStorage>
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +47,6 @@ namespace
|
||||||
explicit NaturalCompare(const bool caseSensitive = true)
|
explicit NaturalCompare(const bool caseSensitive = true)
|
||||||
: m_caseSensitive(caseSensitive)
|
: m_caseSensitive(caseSensitive)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
||||||
// sorts older versions of μTorrent differently than the newer ones because the
|
// sorts older versions of μTorrent differently than the newer ones because the
|
||||||
|
@ -63,12 +59,10 @@ namespace
|
||||||
#endif
|
#endif
|
||||||
m_collator.setNumericMode(true);
|
m_collator.setNumericMode(true);
|
||||||
m_collator.setCaseSensitivity(caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
m_collator.setCaseSensitivity(caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(const QString &left, const QString &right) const
|
bool operator()(const QString &left, const QString &right) const
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
||||||
// sorts older versions of μTorrent differently than the newer ones because the
|
// sorts older versions of μTorrent differently than the newer ones because the
|
||||||
|
@ -80,9 +74,6 @@ namespace
|
||||||
return lessThan(left, right);
|
return lessThan(left, right);
|
||||||
#endif
|
#endif
|
||||||
return (m_collator.compare(left, right) < 0);
|
return (m_collator.compare(left, right) < 0);
|
||||||
#else
|
|
||||||
return lessThan(left, right);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lessThan(const QString &left, const QString &right) const
|
bool lessThan(const QString &left, const QString &right) const
|
||||||
|
@ -111,20 +102,12 @@ namespace
|
||||||
int startL = posL;
|
int startL = posL;
|
||||||
while ((posL < left.size()) && left[posL].isDigit())
|
while ((posL < left.size()) && left[posL].isDigit())
|
||||||
++posL;
|
++posL;
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
int numL = left.midRef(startL, posL - startL).toInt();
|
int numL = left.midRef(startL, posL - startL).toInt();
|
||||||
#else
|
|
||||||
int numL = left.mid(startL, posL - startL).toInt();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int startR = posR;
|
int startR = posR;
|
||||||
while ((posR < right.size()) && right[posR].isDigit())
|
while ((posR < right.size()) && right[posR].isDigit())
|
||||||
++posR;
|
++posR;
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
int numR = right.midRef(startR, posR - startR).toInt();
|
int numR = right.midRef(startR, posR - startR).toInt();
|
||||||
#else
|
|
||||||
int numR = right.mid(startR, posR - startR).toInt();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (numL != numR)
|
if (numL != numR)
|
||||||
return (numL < numR);
|
return (numL < numR);
|
||||||
|
@ -136,9 +119,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
QCollator m_collator;
|
QCollator m_collator;
|
||||||
#endif
|
|
||||||
const bool m_caseSensitive;
|
const bool m_caseSensitive;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#cmakedefine QBT_USES_QT5
|
|
||||||
#cmakedefine QBT_USE_GUI
|
#cmakedefine QBT_USE_GUI
|
||||||
|
|
||||||
#ifndef QBT_USE_GUI
|
#ifndef QBT_USE_GUI
|
||||||
|
|
|
@ -424,9 +424,7 @@ bool ICOHandler::canRead(QIODevice *device)
|
||||||
|
|
||||||
class ICOPlugin : public QImageIOPlugin
|
class ICOPlugin : public QImageIOPlugin
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin")
|
Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin")
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
|
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
|
||||||
|
@ -460,8 +458,3 @@ QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format)
|
||||||
handler->setFormat(format);
|
handler->setFormat(format);
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
|
|
||||||
Q_EXPORT_PLUGIN2(ico, ICOPlugin)
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -11,10 +11,6 @@ resources/lineeditimages.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(qbt_lineedit STATIC ${QBT_LINEEDIT_SOURCES} ${QBT_LINEEDIT_HEADERS})
|
add_library(qbt_lineedit STATIC ${QBT_LINEEDIT_SOURCES} ${QBT_LINEEDIT_HEADERS})
|
||||||
if (QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_lineedit Qt4::QtGui)
|
|
||||||
else (QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_lineedit Qt5::Widgets)
|
target_link_libraries(qbt_lineedit Qt5::Widgets)
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
||||||
qbt_target_sources(${QBT_LINEEDIT_RESOURCES})
|
qbt_target_sources(${QBT_LINEEDIT_RESOURCES})
|
||||||
|
|
|
@ -25,24 +25,8 @@ LineEdit::LineEdit(QWidget *parent)
|
||||||
QSize searchButtonHint = searchButton->sizeHint();
|
QSize searchButtonHint = searchButton->sizeHint();
|
||||||
|
|
||||||
QSize clearButtonHint(0, 0);
|
QSize clearButtonHint(0, 0);
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QPixmap pixmap2(":/lineeditimages/clear_left.png");
|
|
||||||
clearButton = new QToolButton(this);
|
|
||||||
clearButton->setIcon(QIcon(pixmap2));
|
|
||||||
clearButton->setIconSize(pixmap2.size());
|
|
||||||
clearButton->setCursor(Qt::ArrowCursor);
|
|
||||||
clearButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
|
|
||||||
clearButton->setToolTip(tr("Clear the text"));
|
|
||||||
clearButton->hide();
|
|
||||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
|
||||||
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(updateCloseButton(const QString &)));
|
|
||||||
|
|
||||||
clearButtonHint = clearButton->sizeHint();
|
|
||||||
setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(searchButtonHint.width()).arg(clearButtonHint.width()));
|
|
||||||
#else
|
|
||||||
setClearButtonEnabled(true);
|
setClearButtonEnabled(true);
|
||||||
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButtonHint.width())); // padding between text and widget borders
|
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButtonHint.width())); // padding between text and widget borders
|
||||||
#endif
|
|
||||||
|
|
||||||
QSize widgetHint = sizeHint();
|
QSize widgetHint = sizeHint();
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
|
@ -56,15 +40,5 @@ void LineEdit::resizeEvent(QResizeEvent *e)
|
||||||
|
|
||||||
QSize sz = searchButton->sizeHint();
|
QSize sz = searchButton->sizeHint();
|
||||||
searchButton->move(frameWidth, (e->size().height() - sz.height()) / 2);
|
searchButton->move(frameWidth, (e->size().height() - sz.height()) / 2);
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QSize cz = clearButton->sizeHint();
|
|
||||||
clearButton->move((e->size().width() - frameWidth - cz.width()), (e->size().height() - sz.height()) / 2);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
void LineEdit::updateCloseButton(const QString &text)
|
|
||||||
{
|
|
||||||
clearButton->setVisible(!text.isEmpty());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -24,16 +24,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
private slots:
|
|
||||||
void updateCloseButton(const QString &text);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QToolButton *searchButton;
|
QToolButton *searchButton;
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QToolButton *clearButton;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LIENEDIT_H
|
#endif // LIENEDIT_H
|
||||||
|
|
|
@ -122,11 +122,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
m_ui->scanFoldersView->header()->setResizeMode(QHeaderView::ResizeToContents);
|
|
||||||
#else
|
|
||||||
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
#endif
|
|
||||||
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
|
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
|
||||||
m_ui->scanFoldersView->setItemDelegate(new ScanFoldersDelegate(this, m_ui->scanFoldersView));
|
m_ui->scanFoldersView->setItemDelegate(new ScanFoldersDelegate(this, m_ui->scanFoldersView));
|
||||||
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(enableApplyButton()));
|
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(enableApplyButton()));
|
||||||
|
|
|
@ -42,12 +42,8 @@
|
||||||
#include "previewselect.h"
|
#include "previewselect.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
#include <QPlastiqueStyle>
|
|
||||||
#else
|
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
class PreviewListDelegate: public QItemDelegate {
|
class PreviewListDelegate: public QItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -80,11 +76,7 @@ class PreviewListDelegate: public QItemDelegate {
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QPlastiqueStyle st;
|
|
||||||
#else
|
|
||||||
QProxyStyle st("fusion");
|
QProxyStyle st("fusion");
|
||||||
#endif
|
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -32,9 +32,7 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "previewlistdelegate.h"
|
#include "previewlistdelegate.h"
|
||||||
|
@ -54,14 +52,12 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
|
||||||
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
|
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
|
||||||
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
|
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
|
||||||
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
|
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(previewList->header());
|
unused.setVerticalHeader(previewList->header());
|
||||||
previewList->header()->setParent(previewList);
|
previewList->header()->setParent(previewList);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
previewList->setModel(previewListModel);
|
previewList->setModel(previewListModel);
|
||||||
previewList->hideColumn(FILE_INDEX);
|
previewList->hideColumn(FILE_INDEX);
|
||||||
listDelegate = new PreviewListDelegate(this);
|
listDelegate = new PreviewListDelegate(this);
|
||||||
|
|
|
@ -44,6 +44,4 @@ speedplotview.cpp
|
||||||
|
|
||||||
add_library(qbt_properties STATIC ${QBT_PROPERTIES_HEADERS} ${QBT_PROPERTIES_SOURCES})
|
add_library(qbt_properties STATIC ${QBT_PROPERTIES_HEADERS} ${QBT_PROPERTIES_SOURCES})
|
||||||
target_link_libraries(qbt_properties qbt_base)
|
target_link_libraries(qbt_properties qbt_base)
|
||||||
if (NOT QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_properties Qt5::Widgets Qt5::Concurrent)
|
target_link_libraries(qbt_properties Qt5::Widgets Qt5::Concurrent)
|
||||||
endif (NOT QT4_FOUND)
|
|
||||||
|
|
|
@ -36,9 +36,7 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/net/reverseresolution.h"
|
#include "base/net/reverseresolution.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
@ -135,14 +133,12 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||||
handleSortColumnChanged(header()->sortIndicatorSection());
|
handleSortColumnChanged(header()->sortIndicatorSection());
|
||||||
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copySelectedPeers()), 0, Qt::WidgetShortcut);
|
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copySelectedPeers()), 0, Qt::WidgetShortcut);
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(this->header());
|
unused.setVerticalHeader(this->header());
|
||||||
this->header()->setParent(this);
|
this->header()->setParent(this);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerListWidget::~PeerListWidget()
|
PeerListWidget::~PeerListWidget()
|
||||||
|
|
|
@ -39,10 +39,8 @@ PeersAdditionDlg::PeersAdditionDlg(QWidget *parent)
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
label_format->hide();
|
label_format->hide();
|
||||||
peers_txt->setPlaceholderText("Format: IPv4:port / [IPv6]:port");
|
peers_txt->setPlaceholderText("Format: IPv4:port / [IPv6]:port");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BitTorrent::PeerAddress> PeersAdditionDlg::askForPeers()
|
QList<BitTorrent::PeerAddress> PeersAdditionDlg::askForPeers()
|
||||||
|
|
|
@ -102,15 +102,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
|
||||||
connect(filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
|
connect(filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
|
||||||
connect(filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
|
connect(filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// set bar height relative to screen dpi
|
// set bar height relative to screen dpi
|
||||||
int barHeight = devicePixelRatio() * 18;
|
int barHeight = devicePixelRatio() * 18;
|
||||||
#else
|
|
||||||
// set bar height relative to font height
|
|
||||||
QFont defFont;
|
|
||||||
QFontMetrics fMetrics(defFont, 0); // need to be device-dependent
|
|
||||||
int barHeight = fMetrics.height() * 5 / 4;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Downloaded pieces progress bar
|
// Downloaded pieces progress bar
|
||||||
tempProgressBarArea->setVisible(false);
|
tempProgressBarArea->setVisible(false);
|
||||||
|
|
|
@ -36,12 +36,8 @@
|
||||||
#include <QStyleOptionProgressBar>
|
#include <QStyleOptionProgressBar>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
#include <QPlastiqueStyle>
|
|
||||||
#else
|
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
@ -106,11 +102,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QPlastiqueStyle st;
|
|
||||||
#else
|
|
||||||
QProxyStyle st("fusion");
|
QProxyStyle st("fusion");
|
||||||
#endif
|
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
@ -88,14 +86,12 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
|
||||||
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
|
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
|
||||||
copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
|
copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(this->header());
|
unused.setVerticalHeader(this->header());
|
||||||
this->header()->setParent(this);
|
this->header()->setParent(this);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,4 @@ rsssettingsdlg.ui
|
||||||
|
|
||||||
add_library(qbt_rss STATIC ${QBT_RSS_HEADERS} ${QBT_RSS_SOURCE} ${QBT_RSS_FORMS})
|
add_library(qbt_rss STATIC ${QBT_RSS_HEADERS} ${QBT_RSS_SOURCE} ${QBT_RSS_FORMS})
|
||||||
target_link_libraries(qbt_rss qbt_base)
|
target_link_libraries(qbt_rss qbt_base)
|
||||||
if (QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_rss Qt4::QtGui Qt4::QtNetwork)
|
|
||||||
else (QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_rss Qt5::Gui Qt5::Widgets Qt5::Network)
|
target_link_libraries(qbt_rss Qt5::Gui Qt5::Widgets Qt5::Network)
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
|
@ -36,9 +36,7 @@
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
|
@ -69,14 +67,13 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(pluginsTree->header());
|
unused.setVerticalHeader(pluginsTree->header());
|
||||||
pluginsTree->header()->setParent(pluginsTree);
|
pluginsTree->header()->setParent(pluginsTree);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
pluginsTree->setRootIsDecorated(false);
|
pluginsTree->setRootIsDecorated(false);
|
||||||
pluginsTree->header()->resizeSection(0, 160);
|
pluginsTree->header()->resizeSection(0, 160);
|
||||||
pluginsTree->header()->resizeSection(1, 80);
|
pluginsTree->header()->resizeSection(1, 80);
|
||||||
|
|
|
@ -39,9 +39,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
|
@ -67,14 +65,13 @@ SearchTab::SearchTab(SearchWidget *parent)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(m_ui->resultsBrowser->header());
|
unused.setVerticalHeader(m_ui->resultsBrowser->header());
|
||||||
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
|
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
m_ui->resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
m_ui->resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
header()->setStretchLastSection(false);
|
header()->setStretchLastSection(false);
|
||||||
|
|
|
@ -32,24 +32,20 @@
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QModelIndexList>
|
#include <QModelIndexList>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "torrentcontentmodelitem.h"
|
#include "torrentcontentmodelitem.h"
|
||||||
|
|
||||||
TorrentContentTreeView::TorrentContentTreeView(QWidget* parent)
|
TorrentContentTreeView::TorrentContentTreeView(QWidget* parent)
|
||||||
: QTreeView(parent)
|
: QTreeView(parent)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(header());
|
unused.setVerticalHeader(header());
|
||||||
header()->setParent(this);
|
header()->setParent(this);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) {
|
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
|
@ -44,12 +44,8 @@
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
#include <QPlastiqueStyle>
|
|
||||||
#else
|
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
TransferListDelegate::TransferListDelegate(QObject *parent)
|
TransferListDelegate::TransferListDelegate(QObject *parent)
|
||||||
: QItemDelegate(parent)
|
: QItemDelegate(parent)
|
||||||
|
@ -175,11 +171,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QPlastiqueStyle st;
|
|
||||||
#else
|
|
||||||
QProxyStyle st("fusion");
|
QProxyStyle st("fusion");
|
||||||
#endif
|
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -41,9 +41,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "transferlistwidget.h"
|
#include "transferlistwidget.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
@ -161,14 +159,12 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window)
|
||||||
doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut);
|
doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut);
|
||||||
recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut);
|
recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut);
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
QTableView unused;
|
QTableView unused;
|
||||||
unused.setVerticalHeader(header());
|
unused.setVerticalHeader(header());
|
||||||
header()->setParent(this);
|
header()->setParent(this);
|
||||||
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListWidget::~TransferListWidget()
|
TransferListWidget::~TransferListWidget()
|
||||||
|
|
|
@ -5,7 +5,6 @@ CONFIG += qt thread silent
|
||||||
# C++11 support
|
# C++11 support
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES
|
DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): DEFINES += QBT_USES_QT5
|
|
||||||
|
|
||||||
lessThan(QT_MAJOR_VERSION, 5): DEFINES += QStringLiteral=QLatin1String
|
lessThan(QT_MAJOR_VERSION, 5): DEFINES += QStringLiteral=QLatin1String
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,8 @@ webapplication.cpp
|
||||||
webui.cpp
|
webui.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (QT4_FOUND)
|
|
||||||
if (NOT SYSTEM_QJSON)
|
|
||||||
add_subdirectory(qjson)
|
|
||||||
else (NOT SYSTEM_QJSON)
|
|
||||||
find_package(QJSON REQUIRED)
|
|
||||||
add_definitions(-DUSE_SYSTEM_QJSON)
|
|
||||||
endif(NOT SYSTEM_QJSON)
|
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
||||||
qbt_target_sources(webui.qrc)
|
qbt_target_sources(webui.qrc)
|
||||||
|
|
||||||
add_library(qbt_webui STATIC ${QBT_WEBUI_HEADERS} ${QBT_WEBUI_SOURCES})
|
add_library(qbt_webui STATIC ${QBT_WEBUI_HEADERS} ${QBT_WEBUI_SOURCES})
|
||||||
target_link_libraries(qbt_webui qbt_base)
|
target_link_libraries(qbt_webui qbt_base)
|
||||||
|
|
||||||
if (QT4_FOUND)
|
|
||||||
target_link_libraries(qbt_webui qjson)
|
|
||||||
endif (QT4_FOUND)
|
|
||||||
|
|
|
@ -271,20 +271,12 @@ void AbstractWebApplication::translateDocument(QString& data)
|
||||||
if (isTranslationNeeded) {
|
if (isTranslationNeeded) {
|
||||||
QString context = regex.cap(4);
|
QString context = regex.cap(4);
|
||||||
if (context.length() > 0) {
|
if (context.length() > 0) {
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1);
|
|
||||||
#else
|
|
||||||
translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1);
|
translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t context_index = 0;
|
size_t context_index = 0;
|
||||||
while ((context_index < context_count) && (translation == word)) {
|
while ((context_index < context_count) && (translation == word)) {
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1);
|
|
||||||
#else
|
|
||||||
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1);
|
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1);
|
||||||
#endif
|
|
||||||
++context_index;
|
++context_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,6 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
#include <QMetaType>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,8 +50,6 @@
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "jsonutils.h"
|
#include "jsonutils.h"
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
|
||||||
|
|
||||||
#define CACHED_VARIABLE(VARTYPE, VAR, DUR) \
|
#define CACHED_VARIABLE(VARTYPE, VAR, DUR) \
|
||||||
static VARTYPE VAR; \
|
static VARTYPE VAR; \
|
||||||
static QElapsedTimer cacheTimer; \
|
static QElapsedTimer cacheTimer; \
|
||||||
|
@ -76,15 +70,6 @@
|
||||||
cacheTimer.start(); \
|
cacheTimer.start(); \
|
||||||
VAR = VARTYPE()
|
VAR = VARTYPE()
|
||||||
|
|
||||||
#else
|
|
||||||
// We don't support caching for Qt < 4.7 at the moment
|
|
||||||
#define CACHED_VARIABLE(VARTYPE, VAR, DUR) \
|
|
||||||
VARTYPE VAR
|
|
||||||
|
|
||||||
#define CACHED_VARIABLE_FOR_HASH(VARTYPE, VAR, DUR, HASH) \
|
|
||||||
VARTYPE VAR
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Numerical constants
|
// Numerical constants
|
||||||
static const int CACHE_DURATION_MS = 1500; // 1500ms
|
static const int CACHE_DURATION_MS = 1500; // 1500ms
|
||||||
|
@ -238,50 +223,18 @@ public:
|
||||||
QTorrentCompare(QString key, bool greaterThan = false)
|
QTorrentCompare(QString key, bool greaterThan = false)
|
||||||
: key_(key)
|
: key_(key)
|
||||||
, greaterThan_(greaterThan)
|
, greaterThan_(greaterThan)
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
, type_(QVariant::Invalid)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(QVariant torrent1, QVariant torrent2)
|
bool operator()(QVariant torrent1, QVariant torrent2)
|
||||||
{
|
{
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
if (type_ == QVariant::Invalid)
|
|
||||||
type_ = torrent1.toMap().value(key_).type();
|
|
||||||
|
|
||||||
switch (static_cast<QMetaType::Type>(type_)) {
|
|
||||||
case QMetaType::Int:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toInt() > torrent2.toMap().value(key_).toInt()
|
|
||||||
: torrent1.toMap().value(key_).toInt() < torrent2.toMap().value(key_).toInt();
|
|
||||||
case QMetaType::LongLong:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toLongLong() > torrent2.toMap().value(key_).toLongLong()
|
|
||||||
: torrent1.toMap().value(key_).toLongLong() < torrent2.toMap().value(key_).toLongLong();
|
|
||||||
case QMetaType::ULongLong:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toULongLong() > torrent2.toMap().value(key_).toULongLong()
|
|
||||||
: torrent1.toMap().value(key_).toULongLong() < torrent2.toMap().value(key_).toULongLong();
|
|
||||||
case QMetaType::Float:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toFloat() > torrent2.toMap().value(key_).toFloat()
|
|
||||||
: torrent1.toMap().value(key_).toFloat() < torrent2.toMap().value(key_).toFloat();
|
|
||||||
case QMetaType::Double:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toDouble() > torrent2.toMap().value(key_).toDouble()
|
|
||||||
: torrent1.toMap().value(key_).toDouble() < torrent2.toMap().value(key_).toDouble();
|
|
||||||
default:
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toString() > torrent2.toMap().value(key_).toString()
|
|
||||||
: torrent1.toMap().value(key_).toString() < torrent2.toMap().value(key_).toString();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_) > torrent2.toMap().value(key_)
|
return greaterThan_ ? torrent1.toMap().value(key_) > torrent2.toMap().value(key_)
|
||||||
: torrent1.toMap().value(key_) < torrent2.toMap().value(key_);
|
: torrent1.toMap().value(key_) < torrent2.toMap().value(key_);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString key_;
|
QString key_;
|
||||||
bool greaterThan_;
|
bool greaterThan_;
|
||||||
#ifndef QBT_USES_QT5
|
|
||||||
QVariant::Type type_;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -947,7 +900,7 @@ QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantM
|
||||||
lastAcceptedData.clear();
|
lastAcceptedData.clear();
|
||||||
syncData = data;
|
syncData = data;
|
||||||
|
|
||||||
#if (QBT_USES_QT5 && QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
// QJsonDocument::fromVariant() supports QVariantHash only
|
// QJsonDocument::fromVariant() supports QVariantHash only
|
||||||
// since Qt5.5, so manually convert data["torrents"]
|
// since Qt5.5, so manually convert data["torrents"]
|
||||||
QVariantMap torrentsMap;
|
QVariantMap torrentsMap;
|
||||||
|
|
|
@ -30,41 +30,20 @@
|
||||||
#define JSONUTILS_H
|
#define JSONUTILS_H
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#else
|
|
||||||
#include <QString>
|
|
||||||
#ifndef USE_SYSTEM_QJSON
|
|
||||||
#include "qjson/parser.h"
|
|
||||||
#include "qjson/serializer.h"
|
|
||||||
#else // USE_SYSTEM_QJSON
|
|
||||||
#include <qjson/parser.h>
|
|
||||||
#include <qjson/serializer.h>
|
|
||||||
#endif // USE_SYSTEM_QJSON
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace json {
|
namespace json {
|
||||||
|
|
||||||
inline QByteArray toJson(const QVariant& var)
|
inline QByteArray toJson(const QVariant& var)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return QJsonDocument::fromVariant(var).toJson(QJsonDocument::Compact);
|
return QJsonDocument::fromVariant(var).toJson(QJsonDocument::Compact);
|
||||||
#else
|
|
||||||
QJson::Serializer serializer;
|
|
||||||
serializer.setIndentMode(QJson::IndentCompact);
|
|
||||||
return serializer.serialize(var);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QVariant fromJson(const QString& json)
|
inline QVariant fromJson(const QString& json)
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_QT5
|
|
||||||
return QJsonDocument::fromJson(json.toUtf8()).toVariant();
|
return QJsonDocument::fromJson(json.toUtf8()).toVariant();
|
||||||
#else
|
|
||||||
return QJson::Parser().parse(json.toUtf8());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
set(QJSON_HEADERS
|
|
||||||
FlexLexer.h
|
|
||||||
stack.hh
|
|
||||||
position.hh
|
|
||||||
location.hh
|
|
||||||
json_parser.hh
|
|
||||||
json_scanner.h
|
|
||||||
parser.h
|
|
||||||
parser_p.h
|
|
||||||
qjson_debug.h
|
|
||||||
qjson_export.h
|
|
||||||
serializer.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(QJSON_SOURCES
|
|
||||||
json_parser.cc
|
|
||||||
json_scanner.cc
|
|
||||||
json_scanner.cpp
|
|
||||||
parser.cpp
|
|
||||||
serializer.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(qjson STATIC ${QJSON_HEADERS} ${QJSON_SOURCES})
|
|
||||||
|
|
|
@ -1,206 +0,0 @@
|
||||||
// -*-C++-*-
|
|
||||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
|
||||||
// by flex
|
|
||||||
|
|
||||||
// Copyright (c) 1993 The Regents of the University of California.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This code is derived from software contributed to Berkeley by
|
|
||||||
// Kent Williams and Tom Epperly.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions
|
|
||||||
// are met:
|
|
||||||
|
|
||||||
// 1. Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
// Neither the name of the University nor the names of its contributors
|
|
||||||
// may be used to endorse or promote products derived from this software
|
|
||||||
// without specific prior written permission.
|
|
||||||
|
|
||||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE.
|
|
||||||
|
|
||||||
// This file defines FlexLexer, an abstract class which specifies the
|
|
||||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
|
||||||
// which defines a particular lexer class.
|
|
||||||
//
|
|
||||||
// If you want to create multiple lexer classes, you use the -P flag
|
|
||||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
|
||||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
|
||||||
//
|
|
||||||
// #undef yyFlexLexer
|
|
||||||
// #define yyFlexLexer xxFlexLexer
|
|
||||||
// #include <FlexLexer.h>
|
|
||||||
//
|
|
||||||
// #undef yyFlexLexer
|
|
||||||
// #define yyFlexLexer zzFlexLexer
|
|
||||||
// #include <FlexLexer.h>
|
|
||||||
// ...
|
|
||||||
|
|
||||||
#ifndef __FLEX_LEXER_H
|
|
||||||
// Never included before - need to define base class.
|
|
||||||
#define __FLEX_LEXER_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
# ifndef FLEX_STD
|
|
||||||
# define FLEX_STD std::
|
|
||||||
# endif
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
struct yy_buffer_state;
|
|
||||||
typedef int yy_state_type;
|
|
||||||
|
|
||||||
class FlexLexer {
|
|
||||||
public:
|
|
||||||
virtual ~FlexLexer() { }
|
|
||||||
|
|
||||||
const char* YYText() const { return yytext; }
|
|
||||||
int YYLeng() const { return yyleng; }
|
|
||||||
|
|
||||||
virtual void
|
|
||||||
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
|
||||||
virtual struct yy_buffer_state*
|
|
||||||
yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
|
|
||||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
|
||||||
virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
|
||||||
|
|
||||||
virtual int yylex() = 0;
|
|
||||||
|
|
||||||
// Call yylex with new input/output sources.
|
|
||||||
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
|
||||||
{
|
|
||||||
switch_streams( new_in, new_out );
|
|
||||||
return yylex();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch to new input/output streams. A nil stream pointer
|
|
||||||
// indicates "keep the current one".
|
|
||||||
virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
|
||||||
FLEX_STD ostream* new_out = 0 ) = 0;
|
|
||||||
|
|
||||||
int lineno() const { return yylineno; }
|
|
||||||
|
|
||||||
int debug() const { return yy_flex_debug; }
|
|
||||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
char* yytext;
|
|
||||||
int yyleng;
|
|
||||||
int yylineno; // only maintained if you use %option yylineno
|
|
||||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // FLEXLEXER_H
|
|
||||||
|
|
||||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
|
||||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
|
||||||
// or this is a repeated include to define a different flavor of
|
|
||||||
// yyFlexLexer, as discussed in the flex manual.
|
|
||||||
#define yyFlexLexerOnce
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
class yyFlexLexer : public FlexLexer {
|
|
||||||
public:
|
|
||||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
|
||||||
// only make that assignment when initializing in yylex().
|
|
||||||
yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
|
|
||||||
|
|
||||||
virtual ~yyFlexLexer();
|
|
||||||
|
|
||||||
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
|
|
||||||
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
|
|
||||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
|
||||||
void yyrestart( FLEX_STD istream* s );
|
|
||||||
|
|
||||||
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
|
|
||||||
void yypop_buffer_state();
|
|
||||||
|
|
||||||
virtual int yylex();
|
|
||||||
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
|
|
||||||
virtual int yywrap();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int LexerInput( char* buf, int max_size );
|
|
||||||
virtual void LexerOutput( const char* buf, int size );
|
|
||||||
virtual void LexerError( const char* msg );
|
|
||||||
|
|
||||||
void yyunput( int c, char* buf_ptr );
|
|
||||||
int yyinput();
|
|
||||||
|
|
||||||
void yy_load_buffer_state();
|
|
||||||
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
|
|
||||||
void yy_flush_buffer( struct yy_buffer_state* b );
|
|
||||||
|
|
||||||
int yy_start_stack_ptr;
|
|
||||||
int yy_start_stack_depth;
|
|
||||||
int* yy_start_stack;
|
|
||||||
|
|
||||||
void yy_push_state( int new_state );
|
|
||||||
void yy_pop_state();
|
|
||||||
int yy_top_state();
|
|
||||||
|
|
||||||
yy_state_type yy_get_previous_state();
|
|
||||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
|
||||||
int yy_get_next_buffer();
|
|
||||||
|
|
||||||
FLEX_STD istream* yyin; // input source for default LexerInput
|
|
||||||
FLEX_STD ostream* yyout; // output sink for default LexerOutput
|
|
||||||
|
|
||||||
// yy_hold_char holds the character lost when yytext is formed.
|
|
||||||
char yy_hold_char;
|
|
||||||
|
|
||||||
// Number of characters read into yy_ch_buf.
|
|
||||||
int yy_n_chars;
|
|
||||||
|
|
||||||
// Points to current character in buffer.
|
|
||||||
char* yy_c_buf_p;
|
|
||||||
|
|
||||||
int yy_init; // whether we need to initialize
|
|
||||||
int yy_start; // start state number
|
|
||||||
|
|
||||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
|
||||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
|
||||||
int yy_did_buffer_switch_on_eof;
|
|
||||||
|
|
||||||
|
|
||||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
|
||||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
|
||||||
struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
|
|
||||||
void yyensure_buffer_stack(void);
|
|
||||||
|
|
||||||
// The following are not always needed, but may be depending
|
|
||||||
// on use of certain flex features (like REJECT or yymore()).
|
|
||||||
|
|
||||||
yy_state_type yy_last_accepting_state;
|
|
||||||
char* yy_last_accepting_cpos;
|
|
||||||
|
|
||||||
yy_state_type* yy_state_buf;
|
|
||||||
yy_state_type* yy_state_ptr;
|
|
||||||
|
|
||||||
char* yy_full_match;
|
|
||||||
int* yy_full_state;
|
|
||||||
int yy_full_lp;
|
|
||||||
|
|
||||||
int yy_lp;
|
|
||||||
int yy_looking_for_trail_begin;
|
|
||||||
|
|
||||||
int yy_more_flag;
|
|
||||||
int yy_more_len;
|
|
||||||
int yy_more_offset;
|
|
||||||
int yy_prev_more_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,300 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.7. */
|
|
||||||
|
|
||||||
/* Skeleton interface for Bison LALR(1) parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file json_parser.hh
|
|
||||||
** Define the yy::parser class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
|
||||||
|
|
||||||
#ifndef YY_YY_JSON_PARSER_HH_INCLUDED
|
|
||||||
# define YY_YY_JSON_PARSER_HH_INCLUDED
|
|
||||||
|
|
||||||
/* "%code requires" blocks. */
|
|
||||||
/* Line 33 of lalr1.cc */
|
|
||||||
#line 26 "json_parser.yy"
|
|
||||||
|
|
||||||
#include "parser_p.h"
|
|
||||||
#include "json_scanner.h"
|
|
||||||
#include "qjson_debug.h"
|
|
||||||
|
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
class JSonScanner;
|
|
||||||
|
|
||||||
namespace QJson {
|
|
||||||
class Parser;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YYERROR_VERBOSE 1
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QVector<QVariant>*)
|
|
||||||
Q_DECLARE_METATYPE(QVariantMap*)
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 33 of lalr1.cc */
|
|
||||||
#line 72 "json_parser.hh"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include "stack.hh"
|
|
||||||
#include "location.hh"
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# define YYDEBUG 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
/* Line 33 of lalr1.cc */
|
|
||||||
#line 88 "json_parser.hh"
|
|
||||||
|
|
||||||
/// A Bison parser.
|
|
||||||
class json_parser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Symbol semantic values.
|
|
||||||
#ifndef YYSTYPE
|
|
||||||
typedef int semantic_type;
|
|
||||||
#else
|
|
||||||
typedef YYSTYPE semantic_type;
|
|
||||||
#endif
|
|
||||||
/// Symbol locations.
|
|
||||||
typedef location location_type;
|
|
||||||
/// Tokens.
|
|
||||||
struct token
|
|
||||||
{
|
|
||||||
/* Tokens. */
|
|
||||||
enum yytokentype {
|
|
||||||
END = 0,
|
|
||||||
CURLY_BRACKET_OPEN = 1,
|
|
||||||
CURLY_BRACKET_CLOSE = 2,
|
|
||||||
SQUARE_BRACKET_OPEN = 3,
|
|
||||||
SQUARE_BRACKET_CLOSE = 4,
|
|
||||||
COLON = 5,
|
|
||||||
COMMA = 6,
|
|
||||||
NUMBER = 7,
|
|
||||||
TRUE_VAL = 8,
|
|
||||||
FALSE_VAL = 9,
|
|
||||||
NULL_VAL = 10,
|
|
||||||
STRING = 11,
|
|
||||||
INVALID = 12
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
/// Token type.
|
|
||||||
typedef token::yytokentype token_type;
|
|
||||||
|
|
||||||
/// Build a parser object.
|
|
||||||
json_parser (QJson::ParserPrivate* driver_yyarg);
|
|
||||||
virtual ~json_parser ();
|
|
||||||
|
|
||||||
/// Parse.
|
|
||||||
/// \returns 0 iff parsing succeeded.
|
|
||||||
virtual int parse ();
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/// The current debugging stream.
|
|
||||||
std::ostream& debug_stream () const;
|
|
||||||
/// Set the current debugging stream.
|
|
||||||
void set_debug_stream (std::ostream &);
|
|
||||||
|
|
||||||
/// Type for debugging levels.
|
|
||||||
typedef int debug_level_type;
|
|
||||||
/// The current debugging level.
|
|
||||||
debug_level_type debug_level () const;
|
|
||||||
/// Set the current debugging level.
|
|
||||||
void set_debug_level (debug_level_type l);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Report a syntax error.
|
|
||||||
/// \param loc where the syntax error is found.
|
|
||||||
/// \param msg a description of the syntax error.
|
|
||||||
virtual void error (const location_type& loc, const std::string& msg);
|
|
||||||
|
|
||||||
/// Generate an error message.
|
|
||||||
/// \param state the state where the error occurred.
|
|
||||||
/// \param tok the lookahead token.
|
|
||||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/// \brief Report a symbol value on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
/// \brief Report a symbol on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/// State numbers.
|
|
||||||
typedef int state_type;
|
|
||||||
/// State stack type.
|
|
||||||
typedef stack<state_type> state_stack_type;
|
|
||||||
/// Semantic value stack type.
|
|
||||||
typedef stack<semantic_type> semantic_stack_type;
|
|
||||||
/// location stack type.
|
|
||||||
typedef stack<location_type> location_stack_type;
|
|
||||||
|
|
||||||
/// The state stack.
|
|
||||||
state_stack_type yystate_stack_;
|
|
||||||
/// The semantic value stack.
|
|
||||||
semantic_stack_type yysemantic_stack_;
|
|
||||||
/// The location stack.
|
|
||||||
location_stack_type yylocation_stack_;
|
|
||||||
|
|
||||||
/// Whether the given \c yypact_ value indicates a defaulted state.
|
|
||||||
/// \param yyvalue the value to check
|
|
||||||
static bool yy_pact_value_is_default_ (int yyvalue);
|
|
||||||
|
|
||||||
/// Whether the given \c yytable_ value indicates a syntax error.
|
|
||||||
/// \param yyvalue the value to check
|
|
||||||
static bool yy_table_value_is_error_ (int yyvalue);
|
|
||||||
|
|
||||||
/// Internal symbol numbers.
|
|
||||||
typedef unsigned char token_number_type;
|
|
||||||
/* Tables. */
|
|
||||||
/// For a state, the index in \a yytable_ of its portion.
|
|
||||||
static const signed char yypact_[];
|
|
||||||
static const signed char yypact_ninf_;
|
|
||||||
|
|
||||||
/// For a state, default reduction number.
|
|
||||||
/// Unless\a yytable_ specifies something else to do.
|
|
||||||
/// Zero means the default is an error.
|
|
||||||
static const unsigned char yydefact_[];
|
|
||||||
|
|
||||||
static const signed char yypgoto_[];
|
|
||||||
static const signed char yydefgoto_[];
|
|
||||||
|
|
||||||
/// What to do in a state.
|
|
||||||
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
|
||||||
/// - if positive, shift that token.
|
|
||||||
/// - if negative, reduce the rule which number is the opposite.
|
|
||||||
/// - if zero, do what YYDEFACT says.
|
|
||||||
static const unsigned char yytable_[];
|
|
||||||
static const signed char yytable_ninf_;
|
|
||||||
|
|
||||||
static const signed char yycheck_[];
|
|
||||||
|
|
||||||
/// For a state, its accessing symbol.
|
|
||||||
static const unsigned char yystos_[];
|
|
||||||
|
|
||||||
/// For a rule, its LHS.
|
|
||||||
static const unsigned char yyr1_[];
|
|
||||||
/// For a rule, its RHS length.
|
|
||||||
static const unsigned char yyr2_[];
|
|
||||||
|
|
||||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
|
||||||
static std::string yytnamerr_ (const char *n);
|
|
||||||
|
|
||||||
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
#if YYDEBUG
|
|
||||||
/// A type to store symbol numbers and -1.
|
|
||||||
typedef signed char rhs_number_type;
|
|
||||||
/// A `-1'-separated list of the rules' RHS.
|
|
||||||
static const rhs_number_type yyrhs_[];
|
|
||||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
|
||||||
static const unsigned char yyprhs_[];
|
|
||||||
/// For each rule, its source line number.
|
|
||||||
static const unsigned char yyrline_[];
|
|
||||||
/// For each scanner token number, its symbol number.
|
|
||||||
static const unsigned short int yytoken_number_[];
|
|
||||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
|
||||||
virtual void yy_reduce_print_ (int r);
|
|
||||||
/// Print the state stack on the debug stream.
|
|
||||||
virtual void yystack_print_ ();
|
|
||||||
|
|
||||||
/* Debugging. */
|
|
||||||
int yydebug_;
|
|
||||||
std::ostream* yycdebug_;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Convert a scanner token number \a t to a symbol number.
|
|
||||||
token_number_type yytranslate_ (int t);
|
|
||||||
|
|
||||||
/// \brief Reclaim the memory associated to a symbol.
|
|
||||||
/// \param yymsg Why this token is reclaimed.
|
|
||||||
/// If null, do not display the symbol, just free it.
|
|
||||||
/// \param yytype The symbol type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
inline void yydestruct_ (const char* yymsg,
|
|
||||||
int yytype,
|
|
||||||
semantic_type* yyvaluep,
|
|
||||||
location_type* yylocationp);
|
|
||||||
|
|
||||||
/// Pop \a n symbols the three stacks.
|
|
||||||
inline void yypop_ (unsigned int n = 1);
|
|
||||||
|
|
||||||
/* Constants. */
|
|
||||||
static const int yyeof_;
|
|
||||||
/* LAST_ -- Last index in TABLE_. */
|
|
||||||
static const int yylast_;
|
|
||||||
static const int yynnts_;
|
|
||||||
static const int yyempty_;
|
|
||||||
static const int yyfinal_;
|
|
||||||
static const int yyterror_;
|
|
||||||
static const int yyerrcode_;
|
|
||||||
static const int yyntokens_;
|
|
||||||
static const unsigned int yyuser_token_number_max_;
|
|
||||||
static const token_number_type yyundef_token_;
|
|
||||||
|
|
||||||
/* User arguments. */
|
|
||||||
QJson::ParserPrivate* driver;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // yy
|
|
||||||
/* Line 33 of lalr1.cc */
|
|
||||||
#line 297 "json_parser.hh"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !YY_YY_JSON_PARSER_HH_INCLUDED */
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,82 +0,0 @@
|
||||||
/* This file is part of QJson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
|
||||||
* Copyright (C) 2013 Silvio Moioli <silvio@moioli.net>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
#include "json_scanner.cc"
|
|
||||||
|
|
||||||
#include "qjson_debug.h"
|
|
||||||
#include "json_scanner.h"
|
|
||||||
#include "json_parser.hh"
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
#include <QtCore/QRegExp>
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
|
|
||||||
JSonScanner::JSonScanner(QIODevice* io)
|
|
||||||
: m_allowSpecialNumbers(false),
|
|
||||||
m_io (io),
|
|
||||||
m_criticalError(false),
|
|
||||||
m_C_locale(QLocale::C)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JSonScanner::~JSonScanner()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSonScanner::allowSpecialNumbers(bool allow) {
|
|
||||||
m_allowSpecialNumbers = allow;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) {
|
|
||||||
m_yylval = yylval;
|
|
||||||
m_yylloc = yylloc;
|
|
||||||
m_yylloc->step();
|
|
||||||
int result = yylex();
|
|
||||||
|
|
||||||
if (m_criticalError) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JSonScanner::LexerInput(char* buf, int max_size) {
|
|
||||||
if (!m_io->isOpen()) {
|
|
||||||
qCritical() << "JSonScanner::yylex - io device is not open";
|
|
||||||
m_criticalError = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int readBytes = m_io->read(buf, max_size);
|
|
||||||
if(readBytes < 0) {
|
|
||||||
qCritical() << "JSonScanner::yylex - error while reading from io device";
|
|
||||||
m_criticalError = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return readBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/* This file is part of QJson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _JSON_SCANNER
|
|
||||||
#define _JSON_SCANNER
|
|
||||||
|
|
||||||
#include <QtCore/QIODevice>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
#include <QtCore/QLocale>
|
|
||||||
|
|
||||||
#define YYSTYPE QVariant
|
|
||||||
|
|
||||||
// Only include FlexLexer.h if it hasn't been already included
|
|
||||||
#if ! defined(yyFlexLexerOnce)
|
|
||||||
#include <FlexLexer.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "parser_p.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
class location;
|
|
||||||
int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
class JSonScanner : public yyFlexLexer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit JSonScanner(QIODevice* io);
|
|
||||||
~JSonScanner();
|
|
||||||
|
|
||||||
void allowSpecialNumbers(bool allow);
|
|
||||||
|
|
||||||
int yylex(YYSTYPE* yylval, yy::location *yylloc);
|
|
||||||
int yylex();
|
|
||||||
int LexerInput(char* buf, int max_size);
|
|
||||||
protected:
|
|
||||||
bool m_allowSpecialNumbers;
|
|
||||||
QIODevice* m_io;
|
|
||||||
|
|
||||||
YYSTYPE* m_yylval;
|
|
||||||
yy::location* m_yylloc;
|
|
||||||
bool m_criticalError;
|
|
||||||
QString m_currentString;
|
|
||||||
QLocale m_C_locale;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,181 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.7. */
|
|
||||||
|
|
||||||
/* Locations for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file location.hh
|
|
||||||
** Define the yy::location class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef YY_YY_LOCATION_HH_INCLUDED
|
|
||||||
# define YY_YY_LOCATION_HH_INCLUDED
|
|
||||||
|
|
||||||
# include "position.hh"
|
|
||||||
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
/* Line 166 of location.cc */
|
|
||||||
#line 47 "location.hh"
|
|
||||||
|
|
||||||
/// Abstract a location.
|
|
||||||
class location
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a location from \a b to \a e.
|
|
||||||
location (const position& b, const position& e)
|
|
||||||
: begin (b)
|
|
||||||
, end (e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct a 0-width location in \a p.
|
|
||||||
explicit location (const position& p = position ())
|
|
||||||
: begin (p)
|
|
||||||
, end (p)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
|
||||||
explicit location (std::string* f,
|
|
||||||
unsigned int l = 1u,
|
|
||||||
unsigned int c = 1u)
|
|
||||||
: begin (f, l, c)
|
|
||||||
, end (f, l, c)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
void initialize (std::string* f = YY_NULL,
|
|
||||||
unsigned int l = 1u,
|
|
||||||
unsigned int c = 1u)
|
|
||||||
{
|
|
||||||
begin.initialize (f, l, c);
|
|
||||||
end = begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
public:
|
|
||||||
/// Reset initial location to final location.
|
|
||||||
void step ()
|
|
||||||
{
|
|
||||||
begin = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next columns.
|
|
||||||
void columns (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next lines.
|
|
||||||
void lines (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end.lines (count);
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Beginning of the located region.
|
|
||||||
position begin;
|
|
||||||
/// End of the located region.
|
|
||||||
position end;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Join two location objects to create a location.
|
|
||||||
inline const location operator+ (const location& begin, const location& end)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.end = end.end;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two location objects.
|
|
||||||
inline const location operator+ (const location& begin, unsigned int width)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a location.
|
|
||||||
inline location& operator+= (location& res, unsigned int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compare two location objects.
|
|
||||||
inline bool
|
|
||||||
operator== (const location& loc1, const location& loc2)
|
|
||||||
{
|
|
||||||
return loc1.begin == loc2.begin && loc1.end == loc2.end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compare two location objects.
|
|
||||||
inline bool
|
|
||||||
operator!= (const location& loc1, const location& loc2)
|
|
||||||
{
|
|
||||||
return !(loc1 == loc2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param loc a reference to the location to redirect
|
|
||||||
**
|
|
||||||
** Avoid duplicate information.
|
|
||||||
*/
|
|
||||||
template <typename YYChar>
|
|
||||||
inline std::basic_ostream<YYChar>&
|
|
||||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
|
||||||
{
|
|
||||||
position last = loc.end - 1;
|
|
||||||
ostr << loc.begin;
|
|
||||||
if (last.filename
|
|
||||||
&& (!loc.begin.filename
|
|
||||||
|| *loc.begin.filename != *last.filename))
|
|
||||||
ostr << '-' << last;
|
|
||||||
else if (loc.begin.line != last.line)
|
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
|
||||||
else if (loc.begin.column != last.column)
|
|
||||||
ostr << '-' << last.column;
|
|
||||||
return ostr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // yy
|
|
||||||
/* Line 296 of location.cc */
|
|
||||||
#line 180 "location.hh"
|
|
||||||
|
|
||||||
#endif /* !YY_YY_LOCATION_HH_INCLUDED */
|
|
|
@ -1,142 +0,0 @@
|
||||||
/* This file is part of QJson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
|
||||||
* Copyright (C) 2016 Anton Kudryavtsev <a.kudryavtsev@netris.ru>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
#include "parser_p.h"
|
|
||||||
#include "json_parser.hh"
|
|
||||||
#include "json_scanner.h"
|
|
||||||
|
|
||||||
#include <QtCore/QBuffer>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QTextStream>
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
|
|
||||||
using namespace QJson;
|
|
||||||
|
|
||||||
ParserPrivate::ParserPrivate() :
|
|
||||||
m_scanner(0),
|
|
||||||
m_specialNumbersAllowed(false)
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
ParserPrivate::~ParserPrivate()
|
|
||||||
{
|
|
||||||
if (m_scanner)
|
|
||||||
delete m_scanner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserPrivate::setError(const QString &errorMsg, int errorLine) {
|
|
||||||
m_error = true;
|
|
||||||
m_errorMsg = errorMsg;
|
|
||||||
m_errorLine = errorLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserPrivate::reset()
|
|
||||||
{
|
|
||||||
m_error = false;
|
|
||||||
m_errorLine = 0;
|
|
||||||
m_errorMsg.clear();
|
|
||||||
if (m_scanner) {
|
|
||||||
delete m_scanner;
|
|
||||||
m_scanner = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Parser::Parser() :
|
|
||||||
d(new ParserPrivate)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Parser::~Parser()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Parser::parse (QIODevice* io, bool* ok)
|
|
||||||
{
|
|
||||||
d->reset();
|
|
||||||
|
|
||||||
if (!io->isOpen()) {
|
|
||||||
if (!io->open(QIODevice::ReadOnly)) {
|
|
||||||
if (ok != 0)
|
|
||||||
*ok = false;
|
|
||||||
qCritical ("Error opening device");
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!io->isReadable()) {
|
|
||||||
if (ok != 0)
|
|
||||||
*ok = false;
|
|
||||||
qCritical ("Device is not readable");
|
|
||||||
io->close();
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (io->atEnd()) {
|
|
||||||
if (ok != 0)
|
|
||||||
*ok = false;
|
|
||||||
d->setError(QLatin1String("No data"), 0);
|
|
||||||
io->close();
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->m_scanner = new JSonScanner (io);
|
|
||||||
d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed);
|
|
||||||
yy::json_parser parser(d);
|
|
||||||
parser.parse();
|
|
||||||
|
|
||||||
delete d->m_scanner;
|
|
||||||
d->m_scanner = 0;
|
|
||||||
|
|
||||||
if (ok != 0)
|
|
||||||
*ok = !d->m_error;
|
|
||||||
|
|
||||||
io->close();
|
|
||||||
return d->m_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Parser::parse(const QByteArray& jsonString, bool* ok) {
|
|
||||||
QBuffer buffer;
|
|
||||||
buffer.open(QBuffer::ReadWrite | QBuffer::Text);
|
|
||||||
buffer.write(jsonString);
|
|
||||||
buffer.seek(0);
|
|
||||||
return parse (&buffer, ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Parser::errorString() const
|
|
||||||
{
|
|
||||||
return d->m_errorMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Parser::errorLine() const
|
|
||||||
{
|
|
||||||
return d->m_errorLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) {
|
|
||||||
d->m_specialNumbersAllowed = allowSpecialNumbers;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Parser::specialNumbersAllowed() const {
|
|
||||||
return d->m_specialNumbersAllowed;
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/* This file is part of QJson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QJSON_PARSER_H
|
|
||||||
#define QJSON_PARSER_H
|
|
||||||
|
|
||||||
#include "qjson_export.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QIODevice;
|
|
||||||
class QVariant;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace used by QJson
|
|
||||||
*/
|
|
||||||
namespace QJson {
|
|
||||||
|
|
||||||
class ParserPrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Main class used to convert JSON data to QVariant objects
|
|
||||||
*/
|
|
||||||
class QJSON_EXPORT Parser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Parser();
|
|
||||||
~Parser();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read JSON string from the I/O Device and converts it to a QVariant object
|
|
||||||
* @param io Input output device
|
|
||||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
|
|
||||||
* @returns a QVariant object generated from the JSON string
|
|
||||||
*/
|
|
||||||
QVariant parse(QIODevice* io, bool* ok = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a method provided for convenience.
|
|
||||||
* @param jsonData data containing the JSON object representation
|
|
||||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
|
|
||||||
* @returns a QVariant object generated from the JSON string
|
|
||||||
* @sa errorString
|
|
||||||
* @sa errorLine
|
|
||||||
*/
|
|
||||||
QVariant parse(const QByteArray& jsonData, bool* ok = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the error message
|
|
||||||
* @returns a QString object containing the error message of the last parse operation
|
|
||||||
* @sa errorLine
|
|
||||||
*/
|
|
||||||
QString errorString() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns line number where the error occurred
|
|
||||||
* @returns the line number where the error occurred
|
|
||||||
* @sa errorString
|
|
||||||
*/
|
|
||||||
int errorLine() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to
|
|
||||||
* the standard
|
|
||||||
* @param allowSpecialNumbers new value of whether special numbers are allowed
|
|
||||||
* @sa specialNumbersAllowed
|
|
||||||
*/
|
|
||||||
void allowSpecialNumbers(bool allowSpecialNumbers);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns whether special numbers (Infinity, -Infinity, NaN) are allowed
|
|
||||||
* @sa allowSpecialNumbers
|
|
||||||
*/
|
|
||||||
bool specialNumbersAllowed() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(Parser)
|
|
||||||
ParserPrivate* const d;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // QJSON_PARSER_H
|
|
|
@ -1,57 +0,0 @@
|
||||||
/* This file is part of QJson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
|
||||||
* Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QJSON_PARSER_P_H
|
|
||||||
#define QJSON_PARSER_P_H
|
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
class JSonScanner;
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
class json_parser;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace QJson {
|
|
||||||
|
|
||||||
class ParserPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ParserPrivate();
|
|
||||||
~ParserPrivate();
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
void setError(const QString &errorMsg, int line);
|
|
||||||
|
|
||||||
JSonScanner* m_scanner;
|
|
||||||
bool m_error;
|
|
||||||
int m_errorLine;
|
|
||||||
QString m_errorMsg;
|
|
||||||
QVariant m_result;
|
|
||||||
bool m_specialNumbersAllowed;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // QJSON_PARSER_H
|
|
|
@ -1,172 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.7. */
|
|
||||||
|
|
||||||
/* Positions for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file position.hh
|
|
||||||
** Define the yy::position class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef YY_YY_POSITION_HH_INCLUDED
|
|
||||||
# define YY_YY_POSITION_HH_INCLUDED
|
|
||||||
|
|
||||||
# include <algorithm> // std::max
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
# ifndef YY_NULL
|
|
||||||
# if defined __cplusplus && 201103L <= __cplusplus
|
|
||||||
# define YY_NULL nullptr
|
|
||||||
# else
|
|
||||||
# define YY_NULL 0
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
/* Line 36 of location.cc */
|
|
||||||
#line 57 "position.hh"
|
|
||||||
/// Abstract a position.
|
|
||||||
class position
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a position.
|
|
||||||
explicit position (std::string* f = YY_NULL,
|
|
||||||
unsigned int l = 1u,
|
|
||||||
unsigned int c = 1u)
|
|
||||||
: filename (f)
|
|
||||||
, line (l)
|
|
||||||
, column (c)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
void initialize (std::string* fn = YY_NULL,
|
|
||||||
unsigned int l = 1u,
|
|
||||||
unsigned int c = 1u)
|
|
||||||
{
|
|
||||||
filename = fn;
|
|
||||||
line = l;
|
|
||||||
column = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
/// (line related) Advance to the COUNT next lines.
|
|
||||||
void lines (int count = 1)
|
|
||||||
{
|
|
||||||
column = 1u;
|
|
||||||
line += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// (column related) Advance to the COUNT next columns.
|
|
||||||
void columns (int count = 1)
|
|
||||||
{
|
|
||||||
column = std::max (1u, column + count);
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
/// File name to which this position refers.
|
|
||||||
std::string* filename;
|
|
||||||
/// Current line number.
|
|
||||||
unsigned int line;
|
|
||||||
/// Current column number.
|
|
||||||
unsigned int column;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline position&
|
|
||||||
operator+= (position& res, const int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator+ (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
position res = begin;
|
|
||||||
return res += width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline position&
|
|
||||||
operator-= (position& res, const int width)
|
|
||||||
{
|
|
||||||
return res += -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator- (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
return begin + -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compare two position objects.
|
|
||||||
inline bool
|
|
||||||
operator== (const position& pos1, const position& pos2)
|
|
||||||
{
|
|
||||||
return (pos1.line == pos2.line
|
|
||||||
&& pos1.column == pos2.column
|
|
||||||
&& (pos1.filename == pos2.filename
|
|
||||||
|| (pos1.filename && pos2.filename
|
|
||||||
&& *pos1.filename == *pos2.filename)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compare two position objects.
|
|
||||||
inline bool
|
|
||||||
operator!= (const position& pos1, const position& pos2)
|
|
||||||
{
|
|
||||||
return !(pos1 == pos2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param pos a reference to the position to redirect
|
|
||||||
*/
|
|
||||||
template <typename YYChar>
|
|
||||||
inline std::basic_ostream<YYChar>&
|
|
||||||
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
|
||||||
{
|
|
||||||
if (pos.filename)
|
|
||||||
ostr << *pos.filename << ':';
|
|
||||||
return ostr << pos.line << '.' << pos.column;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // yy
|
|
||||||
/* Line 148 of location.cc */
|
|
||||||
#line 172 "position.hh"
|
|
||||||
#endif /* !YY_YY_POSITION_HH_INCLUDED */
|
|
|
@ -1,19 +0,0 @@
|
||||||
INCLUDEPATH += $$PWD
|
|
||||||
|
|
||||||
HEADERS += $$PWD/FlexLexer.h \
|
|
||||||
$$PWD/stack.hh \
|
|
||||||
$$PWD/position.hh \
|
|
||||||
$$PWD/location.hh \
|
|
||||||
$$PWD/json_parser.hh \
|
|
||||||
$$PWD/json_scanner.h \
|
|
||||||
$$PWD/parser.h \
|
|
||||||
$$PWD/parser_p.h \
|
|
||||||
$$PWD_debug.h \
|
|
||||||
$$PWD_export.h \
|
|
||||||
$$PWD/serializer.h
|
|
||||||
|
|
||||||
SOURCES += $$PWD/json_parser.cc \
|
|
||||||
$$PWD/json_scanner.cc \
|
|
||||||
$$PWD/json_scanner.cpp \
|
|
||||||
$$PWD/parser.cpp \
|
|
||||||
$$PWD/serializer.cpp
|
|
|
@ -1,34 +0,0 @@
|
||||||
/* This file is part of qjson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
|
|
||||||
* Copyright (C) 2013 Silvio Moioli <silvio@moioli.net>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QJSON_DEBUG_H
|
|
||||||
#define QJSON_DEBUG_H
|
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
|
|
||||||
// define qjsonDebug()
|
|
||||||
#ifdef QJSON_VERBOSE_DEBUG_OUTPUT
|
|
||||||
inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); }
|
|
||||||
#else
|
|
||||||
#define qjsonDebug() if(false) QDebug(QtDebugMsg)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
|
||||||
* Copyright (C) 2014 Vladimir Golovnev
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give permission to
|
|
||||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
||||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
||||||
* and distribute the linked executables. You must obey the GNU General Public
|
|
||||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
||||||
* modify file(s), you may extend this exception to your version of the file(s),
|
|
||||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
||||||
* exception statement from your version.
|
|
||||||
*
|
|
||||||
* Contact : glassez@yandex.ru
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QJSON_EXPORT_H
|
|
||||||
#define QJSON_EXPORT_H
|
|
||||||
|
|
||||||
#include <qglobal.h>
|
|
||||||
#define QJSON_EXPORT
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,469 +0,0 @@
|
||||||
/* This file is part of qjson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Till Adam <adam@kde.org>
|
|
||||||
* Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
|
|
||||||
* Copyright (C) 2016 Anton Kudryavtsev <a.kudryavtsev@netris.ru>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "serializer.h"
|
|
||||||
|
|
||||||
#include <QtCore/QDataStream>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
// cmath does #undef for isnan and isinf macroses what can be defined in math.h
|
|
||||||
#if defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS)
|
|
||||||
# include <math.h>
|
|
||||||
#else
|
|
||||||
# include <cmath>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_SOLARIS
|
|
||||||
# ifndef isinf
|
|
||||||
# include <ieeefp.h>
|
|
||||||
# define isinf(x) (!finite((x)) && (x)==(x))
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER // using MSVC compiler
|
|
||||||
#include <float.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace QJson;
|
|
||||||
|
|
||||||
class Serializer::SerializerPrivate {
|
|
||||||
public:
|
|
||||||
SerializerPrivate() :
|
|
||||||
specialNumbersAllowed(false),
|
|
||||||
indentMode(QJson::IndentNone),
|
|
||||||
doublePrecision(6) {
|
|
||||||
errorMessage.clear();
|
|
||||||
}
|
|
||||||
QString errorMessage;
|
|
||||||
bool specialNumbersAllowed;
|
|
||||||
IndentMode indentMode;
|
|
||||||
int doublePrecision;
|
|
||||||
|
|
||||||
QByteArray serialize( const QVariant &v, bool *ok, int indentLevel = 0);
|
|
||||||
|
|
||||||
static QByteArray buildIndent(int spaces);
|
|
||||||
static QByteArray escapeString( const QString& str );
|
|
||||||
static QByteArray join( const QList<QByteArray>& list, const QByteArray& sep );
|
|
||||||
static QByteArray join( const QList<QByteArray>& list, char sep );
|
|
||||||
};
|
|
||||||
|
|
||||||
QByteArray Serializer::SerializerPrivate::join( const QList<QByteArray>& list, const QByteArray& sep ) {
|
|
||||||
QByteArray res;
|
|
||||||
Q_FOREACH( const QByteArray& i, list ) {
|
|
||||||
if ( !res.isEmpty() )
|
|
||||||
res += sep;
|
|
||||||
res += i;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::SerializerPrivate::join( const QList<QByteArray>& list, char sep ) {
|
|
||||||
QByteArray res;
|
|
||||||
Q_FOREACH( const QByteArray& i, list ) {
|
|
||||||
if ( !res.isEmpty() )
|
|
||||||
res += sep;
|
|
||||||
res += i;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, bool *ok, int indentLevel)
|
|
||||||
{
|
|
||||||
QByteArray str;
|
|
||||||
const QVariant::Type type = v.type();
|
|
||||||
|
|
||||||
if ( ! v.isValid() ) { // invalid or null?
|
|
||||||
str = "null";
|
|
||||||
} else if (( type == QVariant::List ) || ( type == QVariant::StringList )) { // an array or a stringlist?
|
|
||||||
const QVariantList list = v.toList();
|
|
||||||
QList<QByteArray> values;
|
|
||||||
Q_FOREACH( const QVariant& var, list )
|
|
||||||
{
|
|
||||||
QByteArray serializedValue;
|
|
||||||
|
|
||||||
serializedValue = serialize( var, ok, indentLevel+1);
|
|
||||||
|
|
||||||
if ( !*ok ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch(indentMode) {
|
|
||||||
case QJson::IndentFull :
|
|
||||||
case QJson::IndentMedium :
|
|
||||||
case QJson::IndentMinimum :
|
|
||||||
values << serializedValue;
|
|
||||||
break;
|
|
||||||
case QJson::IndentCompact :
|
|
||||||
case QJson::IndentNone :
|
|
||||||
default:
|
|
||||||
values << serializedValue.trimmed();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull ) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str = indent + "[\n" + join( values, ",\n" ) + '\n' + indent + ']';
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentMinimum) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str = indent + "[\n" + join( values, ",\n" ) + '\n' + indent + ']';
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str = '[' + join( values, "," ) + ']';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str = "[ " + join( values, ", " ) + " ]";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if ( type == QVariant::Map ) { // variant is a map?
|
|
||||||
const QVariantMap vmap = v.toMap();
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentMinimum) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str = indent + "{ ";
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
QByteArray nextindent = buildIndent(indentLevel + 1);
|
|
||||||
str = indent + "{\n" + nextindent;
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str = "{";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str = "{ ";
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QByteArray> pairs;
|
|
||||||
for (QVariantMap::const_iterator it = vmap.begin(), end = vmap.end(); it != end; ++it) {
|
|
||||||
indentLevel++;
|
|
||||||
QByteArray serializedValue = serialize( it.value(), ok, indentLevel);
|
|
||||||
indentLevel--;
|
|
||||||
if ( !*ok ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QByteArray key = escapeString( it.key() );
|
|
||||||
QByteArray value = serializedValue.trimmed();
|
|
||||||
if (indentMode == QJson::IndentCompact) {
|
|
||||||
pairs << key + ':' + value;
|
|
||||||
} else {
|
|
||||||
pairs << key + " : " + value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel + 1);
|
|
||||||
str += join( pairs, ",\n" + indent);
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str += join( pairs, ',' );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str += join( pairs, ", " );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str += '\n' + indent + '}';
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str += '}';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str += " }";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if ( type == QVariant::Hash ) { // variant is a hash?
|
|
||||||
const QVariantHash vhash = v.toHash();
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentMinimum) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str = indent + "{ ";
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
QByteArray nextindent = buildIndent(indentLevel + 1);
|
|
||||||
str = indent + "{\n" + nextindent;
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str = "{";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str = "{ ";
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QByteArray> pairs;
|
|
||||||
for (QVariantHash::const_iterator it = vhash.begin(), end = vhash.end(); it != end; ++it) {
|
|
||||||
QByteArray serializedValue = serialize( it.value(), ok, indentLevel + 1);
|
|
||||||
|
|
||||||
if ( !*ok ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QByteArray key = escapeString( it.key() );
|
|
||||||
QByteArray value = serializedValue.trimmed();
|
|
||||||
if (indentMode == QJson::IndentCompact) {
|
|
||||||
pairs << key + ':' + value;
|
|
||||||
} else {
|
|
||||||
pairs << key + " : " + value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel + 1);
|
|
||||||
str += join( pairs, ",\n" + indent);
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str += join( pairs, ',' );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str += join( pairs, ", " );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
|
|
||||||
QByteArray indent = buildIndent(indentLevel);
|
|
||||||
str += '\n' + indent + '}';
|
|
||||||
}
|
|
||||||
else if (indentMode == QJson::IndentCompact) {
|
|
||||||
str += '}';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str += " }";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Add indent, we may need to remove it later for some layouts
|
|
||||||
switch(indentMode) {
|
|
||||||
case QJson::IndentFull :
|
|
||||||
case QJson::IndentMedium :
|
|
||||||
case QJson::IndentMinimum :
|
|
||||||
str += buildIndent(indentLevel);
|
|
||||||
break;
|
|
||||||
case QJson::IndentCompact :
|
|
||||||
case QJson::IndentNone :
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (( type == QVariant::String ) || ( type == QVariant::ByteArray )) { // a string or a byte array?
|
|
||||||
str += escapeString( v.toString() );
|
|
||||||
} else if (( type == QVariant::Double) || ((QMetaType::Type)type == QMetaType::Float)) { // a double or a float?
|
|
||||||
const double value = v.toDouble();
|
|
||||||
#if defined _WIN32 && !defined(Q_OS_SYMBIAN)
|
|
||||||
const bool special = _isnan(value) || !_finite(value);
|
|
||||||
#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS)
|
|
||||||
const bool special = isnan(value) || isinf(value);
|
|
||||||
#else
|
|
||||||
const bool special = std::isnan(value) || std::isinf(value);
|
|
||||||
#endif
|
|
||||||
if (special) {
|
|
||||||
if (specialNumbersAllowed) {
|
|
||||||
#if defined _WIN32 && !defined(Q_OS_SYMBIAN)
|
|
||||||
if (_isnan(value)) {
|
|
||||||
#elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS)
|
|
||||||
if (isnan(value)) {
|
|
||||||
#else
|
|
||||||
if (std::isnan(value)) {
|
|
||||||
#endif
|
|
||||||
str += "NaN";
|
|
||||||
} else {
|
|
||||||
if (value<0) {
|
|
||||||
str += '-';
|
|
||||||
}
|
|
||||||
str += "Infinity";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorMessage += QLatin1String("Attempt to write NaN or infinity, which is not supported by json\n");
|
|
||||||
*ok = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
str = QByteArray::number( value , 'g', doublePrecision);
|
|
||||||
if( !str.contains( '.' ) && !str.contains( 'e' ) ) {
|
|
||||||
str += ".0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ( type == QVariant::Bool ) { // boolean value?
|
|
||||||
str += ( v.toBool() ? "true" : "false" );
|
|
||||||
} else if ( type == QVariant::ULongLong ) { // large unsigned number?
|
|
||||||
str += QByteArray::number( v.value<qulonglong>() );
|
|
||||||
} else if ( type == QVariant::UInt ) { // unsigned int number?
|
|
||||||
str += QByteArray::number( v.value<quint32>() );
|
|
||||||
} else if ( v.canConvert<qlonglong>() ) { // any signed number?
|
|
||||||
str += QByteArray::number( v.value<qlonglong>() );
|
|
||||||
} else if ( v.canConvert<int>() ) { // unsigned short number?
|
|
||||||
str += QByteArray::number( v.value<int>() );
|
|
||||||
} else if ( v.canConvert<QString>() ){ // can value be converted to string?
|
|
||||||
// this will catch QDate, QDateTime, QUrl, ...
|
|
||||||
str += escapeString( v.toString() );
|
|
||||||
//TODO: catch other values like QImage, QRect, ...
|
|
||||||
} else {
|
|
||||||
*ok = false;
|
|
||||||
errorMessage += QLatin1String("Cannot serialize ");
|
|
||||||
errorMessage += v.toString();
|
|
||||||
errorMessage += QLatin1String(" because type ");
|
|
||||||
errorMessage += QLatin1String(v.typeName());
|
|
||||||
errorMessage += QLatin1String(" is not supported by QJson\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( *ok )
|
|
||||||
{
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::SerializerPrivate::buildIndent(int spaces)
|
|
||||||
{
|
|
||||||
QByteArray indent;
|
|
||||||
if (spaces < 0) {
|
|
||||||
spaces = 0;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < spaces; i++ ) {
|
|
||||||
indent += ' ';
|
|
||||||
}
|
|
||||||
return indent;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::SerializerPrivate::escapeString( const QString& str )
|
|
||||||
{
|
|
||||||
QByteArray result;
|
|
||||||
result.reserve(str.size() + 2);
|
|
||||||
result.append('\"');
|
|
||||||
for (QString::const_iterator it = str.begin(), end = str.end(); it != end; ++it) {
|
|
||||||
ushort unicode = it->unicode();
|
|
||||||
switch ( unicode ) {
|
|
||||||
case '\"':
|
|
||||||
result.append("\\\"");
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
result.append("\\\\");
|
|
||||||
break;
|
|
||||||
case '\b':
|
|
||||||
result.append("\\b");
|
|
||||||
break;
|
|
||||||
case '\f':
|
|
||||||
result.append("\\f");
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
result.append("\\n");
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
result.append("\\r");
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
result.append("\\t");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if ( unicode > 0x1F && unicode < 128 ) {
|
|
||||||
result.append(static_cast<char>(unicode));
|
|
||||||
} else {
|
|
||||||
char escaped[7];
|
|
||||||
qsnprintf(escaped, sizeof(escaped)/sizeof(char), "\\u%04x", unicode);
|
|
||||||
result.append(escaped);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.append('\"');
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Serializer::Serializer()
|
|
||||||
: d( new SerializerPrivate )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Serializer::~Serializer() {
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok)
|
|
||||||
{
|
|
||||||
Q_ASSERT( io );
|
|
||||||
*ok = true;
|
|
||||||
|
|
||||||
if (!io->isOpen()) {
|
|
||||||
if (!io->open(QIODevice::WriteOnly)) {
|
|
||||||
d->errorMessage = QLatin1String("Error opening device");
|
|
||||||
*ok = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!io->isWritable()) {
|
|
||||||
d->errorMessage = QLatin1String("Device is not readable");
|
|
||||||
io->close();
|
|
||||||
*ok = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QByteArray str = serialize( v, ok);
|
|
||||||
if (*ok && (io->write(str) != str.count())) {
|
|
||||||
*ok = false;
|
|
||||||
d->errorMessage = QLatin1String("Something went wrong while writing to IO device");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::serialize( const QVariant &v)
|
|
||||||
{
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
return serialize(v, &ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Serializer::serialize( const QVariant &v, bool *ok)
|
|
||||||
{
|
|
||||||
bool _ok = true;
|
|
||||||
d->errorMessage.clear();
|
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
*ok = true;
|
|
||||||
} else {
|
|
||||||
ok = &_ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d->serialize(v, ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QJson::Serializer::allowSpecialNumbers(bool allow) {
|
|
||||||
d->specialNumbersAllowed = allow;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QJson::Serializer::specialNumbersAllowed() const {
|
|
||||||
return d->specialNumbersAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QJson::Serializer::setIndentMode(IndentMode mode) {
|
|
||||||
d->indentMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QJson::Serializer::setDoublePrecision(int precision) {
|
|
||||||
d->doublePrecision = precision;
|
|
||||||
}
|
|
||||||
|
|
||||||
IndentMode QJson::Serializer::indentMode() const {
|
|
||||||
return d->indentMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QJson::Serializer::errorMessage() const {
|
|
||||||
return d->errorMessage;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,230 +0,0 @@
|
||||||
/* This file is part of qjson
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Till Adam <adam@kde.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2.1, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; see the file COPYING.LIB. If not, write to
|
|
||||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QJSON_SERIALIZER_H
|
|
||||||
#define QJSON_SERIALIZER_H
|
|
||||||
|
|
||||||
#include "qjson_export.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QIODevice;
|
|
||||||
class QString;
|
|
||||||
class QVariant;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace QJson {
|
|
||||||
/**
|
|
||||||
@brief How the indentation should work.
|
|
||||||
\verbatim
|
|
||||||
none (default) :
|
|
||||||
{ "foo" : 0, "foo1" : 1, "foo2" : [ { "bar" : 1, "foo" : 0, "foobar" : 0 }, { "bar" : 1, "foo" : 1, "foobar" : 1 } ], "foo3" : [ 1, 2, 3, 4, 5, 6 ] }
|
|
||||||
|
|
||||||
compact :
|
|
||||||
{"foo":0,"foo1":1,"foo2":[{"bar":1,"foo":0,"foobar":0},{"bar":1,"foo":1,"foobar":1}],"foo3":[1,2,3,4,5,6]}
|
|
||||||
|
|
||||||
minimum :
|
|
||||||
{ "foo" : 0, "foo1" : 1, "foo2" : [
|
|
||||||
{ "bar" : 1, "foo" : 0, "foobar" : 0 },
|
|
||||||
{ "bar" : 1, "foo" : 1, "foobar" : 1 }
|
|
||||||
], "foo3" : [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
6
|
|
||||||
] }
|
|
||||||
|
|
||||||
medium :
|
|
||||||
{
|
|
||||||
"foo" : 0, "foo1" : 1, "foo2" : [
|
|
||||||
{
|
|
||||||
"bar" : 1, "foo" : 0, "foobar" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bar" : 1, "foo" : 1, "foobar" : 1
|
|
||||||
}
|
|
||||||
], "foo3" : [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
6
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
full :
|
|
||||||
{
|
|
||||||
"foo" : 0,
|
|
||||||
"foo1" : 1,
|
|
||||||
"foo2" : [
|
|
||||||
{
|
|
||||||
"bar" : 1,
|
|
||||||
"foo" : 0,
|
|
||||||
"foobar" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bar" : 1,
|
|
||||||
"foo" : 1,
|
|
||||||
"foobar" : 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"foo3" : [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
6
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
\endverbatim
|
|
||||||
*/
|
|
||||||
enum IndentMode {
|
|
||||||
IndentNone,
|
|
||||||
IndentCompact,
|
|
||||||
IndentMinimum,
|
|
||||||
IndentMedium,
|
|
||||||
IndentFull
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @brief Main class used to convert QVariant objects to JSON data.
|
|
||||||
*
|
|
||||||
* QVariant objects are converted to a string containing the JSON data.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* QVariantList people;
|
|
||||||
*
|
|
||||||
* QVariantMap bob;
|
|
||||||
* bob.insert("Name", "Bob");
|
|
||||||
* bob.insert("Phonenumber", 123);
|
|
||||||
*
|
|
||||||
* QVariantMap alice;
|
|
||||||
* alice.insert("Name", "Alice");
|
|
||||||
* alice.insert("Phonenumber", 321);
|
|
||||||
*
|
|
||||||
* people << bob << alice;
|
|
||||||
*
|
|
||||||
* QJson::Serializer serializer;
|
|
||||||
* bool ok;
|
|
||||||
* QByteArray json = serializer.serialize(people, &ok);
|
|
||||||
*
|
|
||||||
* if (ok) {
|
|
||||||
* qDebug() << json;
|
|
||||||
* } else {
|
|
||||||
* qCritical() << "Something went wrong:" << serializer.errorMessage();
|
|
||||||
* }
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* The output will be:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* "[ { "Name" : "Bob", "Phonenumber" : 123 },
|
|
||||||
* { "Name" : "Alice", "Phonenumber" : 321 } ]"
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* It's possible to tune the indentation level of the resulting string. \sa setIndentMode
|
|
||||||
*/
|
|
||||||
class QJSON_EXPORT Serializer {
|
|
||||||
public:
|
|
||||||
Serializer();
|
|
||||||
~Serializer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method generates a textual JSON representation and outputs it to the
|
|
||||||
* passed in I/O Device.
|
|
||||||
* @param variant The JSON document in its in-memory representation as generated by the
|
|
||||||
* parser.
|
|
||||||
* @param out Input output device
|
|
||||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true
|
|
||||||
*/
|
|
||||||
void serialize( const QVariant& variant, QIODevice* out, bool* ok);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a method provided for convenience. It turns the passed in in-memory
|
|
||||||
* representation of the JSON document into a textual one, which is returned.
|
|
||||||
* If the returned string is empty, the document was empty. If it was null, there
|
|
||||||
* was a parsing error.
|
|
||||||
*
|
|
||||||
* @param variant The JSON document in its in-memory representation as generated by the
|
|
||||||
* parser.
|
|
||||||
*
|
|
||||||
* \deprecated This method is going to be removed with the next major release of QJson.
|
|
||||||
*/
|
|
||||||
QByteArray serialize( const QVariant& variant);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a method provided for convenience. It turns the passed in in-memory
|
|
||||||
* representation of the JSON document into a textual one, which is returned.
|
|
||||||
* If the returned string is empty, the document was empty. If it was null, there
|
|
||||||
* was a parsing error.
|
|
||||||
*
|
|
||||||
* @param variant The JSON document in its in-memory representation as generated by the
|
|
||||||
* parser.
|
|
||||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true
|
|
||||||
*/
|
|
||||||
QByteArray serialize( const QVariant& variant, bool *ok);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow or disallow writing of NaN and/or Infinity (as an extension to QJson)
|
|
||||||
*/
|
|
||||||
void allowSpecialNumbers(bool allow);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is Nan and/or Infinity allowed?
|
|
||||||
*/
|
|
||||||
bool specialNumbersAllowed() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set output indentation mode as defined in QJson::IndentMode
|
|
||||||
*/
|
|
||||||
void setIndentMode(IndentMode mode = QJson::IndentNone);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set double precision used while converting Double
|
|
||||||
* \sa QByteArray::number
|
|
||||||
*/
|
|
||||||
void setDoublePrecision(int precision);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns one of the indentation modes defined in QJson::IndentMode
|
|
||||||
*/
|
|
||||||
IndentMode indentMode() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the error message
|
|
||||||
*/
|
|
||||||
QString errorMessage() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(Serializer)
|
|
||||||
class SerializerPrivate;
|
|
||||||
SerializerPrivate* const d;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // QJSON_SERIALIZER_H
|
|
|
@ -1,133 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.7. */
|
|
||||||
|
|
||||||
/* Stack handling for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file stack.hh
|
|
||||||
** Define the yy::stack class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef YY_YY_STACK_HH_INCLUDED
|
|
||||||
# define YY_YY_STACK_HH_INCLUDED
|
|
||||||
|
|
||||||
# include <deque>
|
|
||||||
|
|
||||||
|
|
||||||
namespace yy {
|
|
||||||
/* Line 34 of stack.hh */
|
|
||||||
#line 47 "stack.hh"
|
|
||||||
template <class T, class S = std::deque<T> >
|
|
||||||
class stack
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Hide our reversed order.
|
|
||||||
typedef typename S::reverse_iterator iterator;
|
|
||||||
typedef typename S::const_reverse_iterator const_iterator;
|
|
||||||
|
|
||||||
stack () : seq_ ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
stack (unsigned int n) : seq_ (n)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
T&
|
|
||||||
operator [] (unsigned int i)
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
push (const T& t)
|
|
||||||
{
|
|
||||||
seq_.push_front (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
pop (unsigned int n = 1)
|
|
||||||
{
|
|
||||||
for (; n; --n)
|
|
||||||
seq_.pop_front ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
unsigned int
|
|
||||||
height () const
|
|
||||||
{
|
|
||||||
return seq_.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const_iterator begin () const { return seq_.rbegin (); }
|
|
||||||
inline const_iterator end () const { return seq_.rend (); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
S seq_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Present a slice of the top of a stack.
|
|
||||||
template <class T, class S = stack<T> >
|
|
||||||
class slice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
slice (const S& stack, unsigned int range)
|
|
||||||
: stack_ (stack)
|
|
||||||
, range_ (range)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return stack_[range_ - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const S& stack_;
|
|
||||||
unsigned int range_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // yy
|
|
||||||
/* Line 116 of stack.hh */
|
|
||||||
#line 132 "stack.hh"
|
|
||||||
|
|
||||||
#endif /* !YY_YY_STACK_HH_INCLUDED */
|
|
|
@ -15,10 +15,4 @@ SOURCES += \
|
||||||
$$PWD/webapplication.cpp \
|
$$PWD/webapplication.cpp \
|
||||||
$$PWD/abstractwebapplication.cpp
|
$$PWD/abstractwebapplication.cpp
|
||||||
|
|
||||||
# QJson JSON parser/serializer for using with Qt4
|
|
||||||
lessThan(QT_MAJOR_VERSION, 5) {
|
|
||||||
!usesystemqjson: include(qjson/qjson.pri)
|
|
||||||
else: DEFINES += USE_SYSTEM_QJSON
|
|
||||||
}
|
|
||||||
|
|
||||||
RESOURCES += $$PWD/webui.qrc
|
RESOURCES += $$PWD/webui.qrc
|
||||||
|
|
Loading…
Reference in a new issue