summaryrefslogtreecommitdiffstats
path: root/examples/network
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network')
-rw-r--r--examples/network/bearermonitor/bearermonitor.cpp424
-rw-r--r--examples/network/bearermonitor/bearermonitor.h96
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro22
-rw-r--r--examples/network/bearermonitor/bearermonitor_240_320.ui420
-rw-r--r--examples/network/bearermonitor/bearermonitor_640_480.ui386
-rw-r--r--examples/network/bearermonitor/main.cpp69
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp203
-rw-r--r--examples/network/bearermonitor/sessionwidget.h88
-rw-r--r--examples/network/bearermonitor/sessionwidget.ui307
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.cpp39
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.h2
-rw-r--r--examples/network/blockingfortuneclient/fortunethread.cpp4
-rw-r--r--examples/network/blockingfortuneclient/fortunethread.h2
-rw-r--r--examples/network/broadcastreceiver/receiver.cpp13
-rw-r--r--examples/network/dnslookup/dnslookup.cpp4
-rw-r--r--examples/network/doc/src/blockingfortuneclient.qdoc7
-rw-r--r--examples/network/download/main.cpp10
-rw-r--r--examples/network/downloadmanager/downloadmanager.cpp18
-rw-r--r--examples/network/downloadmanager/main.cpp3
-rw-r--r--examples/network/fortuneclient/client.cpp48
-rw-r--r--examples/network/fortuneclient/client.h4
-rw-r--r--examples/network/fortuneserver/server.cpp41
-rw-r--r--examples/network/fortuneserver/server.h5
-rw-r--r--examples/network/googlesuggest/googlesuggest.cpp18
-rw-r--r--examples/network/googlesuggest/searchbox.cpp8
-rw-r--r--examples/network/http/httpwindow.cpp2
-rw-r--r--examples/network/multicastreceiver/receiver.cpp10
-rw-r--r--examples/network/multistreamclient/client.cpp4
-rw-r--r--examples/network/network-chat/chatdialog.cpp16
-rw-r--r--examples/network/network-chat/chatdialog.h2
-rw-r--r--examples/network/network-chat/client.cpp20
-rw-r--r--examples/network/network-chat/connection.cpp13
-rw-r--r--examples/network/network-chat/connection.h4
-rw-r--r--examples/network/network-chat/main.cpp39
-rw-r--r--examples/network/network-chat/peermanager.cpp8
-rw-r--r--examples/network/network-chat/server.h2
-rw-r--r--examples/network/network.pro14
-rw-r--r--examples/network/securesocketclient/main.cpp4
-rw-r--r--examples/network/securesocketclient/sslclient.cpp37
-rw-r--r--examples/network/threadedfortuneserver/dialog.cpp2
-rw-r--r--examples/network/threadedfortuneserver/dialog.h2
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.cpp2
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.h2
-rw-r--r--examples/network/threadedfortuneserver/fortunethread.cpp2
-rw-r--r--examples/network/torrent/addtorrentdialog.cpp12
-rw-r--r--examples/network/torrent/addtorrentdialog.h2
-rw-r--r--examples/network/torrent/filemanager.h2
-rw-r--r--examples/network/torrent/mainwindow.cpp92
-rw-r--r--examples/network/torrent/mainwindow.h2
-rw-r--r--examples/network/torrent/peerwireclient.cpp34
-rw-r--r--examples/network/torrent/peerwireclient.h2
-rw-r--r--examples/network/torrent/ratecontroller.cpp6
-rw-r--r--examples/network/torrent/ratecontroller.h9
-rw-r--r--examples/network/torrent/torrentclient.cpp90
-rw-r--r--examples/network/torrent/torrentclient.h5
-rw-r--r--examples/network/torrent/torrentserver.cpp10
-rw-r--r--examples/network/torrent/trackerclient.cpp20
-rw-r--r--examples/network/torrent/trackerclient.h16
58 files changed, 297 insertions, 2431 deletions
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp
deleted file mode 100644
index 1a54f5ec8a..0000000000
--- a/examples/network/bearermonitor/bearermonitor.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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 Qt Company Ltd 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "bearermonitor.h"
-#include "sessionwidget.h"
-
-#include <QtCore/QDebug>
-
-#ifdef Q_OS_WIN
-#include <winsock2.h>
-#undef interface
-
-#ifndef NS_NLA
-#define NS_NLA 15
-#endif
-#endif
-
-BearerMonitor::BearerMonitor(QWidget *parent)
-: QWidget(parent)
-{
- setupUi(this);
- delete tabWidget->currentWidget();
- sessionGroup->hide();
- updateConfigurations();
- onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty());
- QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) {
- treeWidget->setCurrentItem(item);
- showConfigurationFor(item);
- break;
- }
- }
- connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool)));
- connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
- this, SLOT(configurationAdded(const QNetworkConfiguration&)));
- connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
- this, SLOT(configurationRemoved(const QNetworkConfiguration&)));
- connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
- this, SLOT(configurationChanged(const QNetworkConfiguration)));
- connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations()));
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork()));
- connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork()));
-#else // Q_OS_WIN && !Q_OS_WINRT
- nlaGroup->hide();
-#endif
-
- connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
- this, SLOT(createSessionFor(QTreeWidgetItem*)));
-
- connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
- this, SLOT(showConfigurationFor(QTreeWidgetItem*)));
-
- connect(newSessionButton, SIGNAL(clicked()),
- this, SLOT(createNewSession()));
- connect(deleteSessionButton, SIGNAL(clicked()),
- this, SLOT(deleteSession()));
- connect(scanButton, SIGNAL(clicked()),
- this, SLOT(performScan()));
-
- // Just in case update all configurations so that all
- // configurations are up to date.
- manager.updateConfigurations();
-}
-
-BearerMonitor::~BearerMonitor()
-{
-}
-
-static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config)
-{
- item->setText(0, config.name());
- item->setData(0, Qt::UserRole, config.identifier());
-
- QFont font = item->font(1);
- font.setBold((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active);
- item->setFont(0, font);
-}
-
-void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent)
-{
- if (!config.isValid())
- return;
-
- QTreeWidgetItem *item = new QTreeWidgetItem;
- updateItem(item, config);
-
- if (parent)
- parent->addChild(item);
- else
- treeWidget->addTopLevelItem(item);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork) {
- const QList<QNetworkConfiguration> children = config.children();
- for (const QNetworkConfiguration &child : children)
- configurationAdded(child, item);
- }
-}
-
-void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config)
-{
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
- delete item;
- break;
- }
- }
-}
-
-void BearerMonitor::configurationChanged(const QNetworkConfiguration &config)
-{
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
- QTreeWidgetItem *item = treeWidget->topLevelItem(i);
-
- if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
- updateItem(item, config);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
-
- if (item == treeWidget->currentItem())
- showConfigurationFor(item);
-
- break;
- }
- }
-}
-
-void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap)
-{
- QMap<QString, QTreeWidgetItem *> itemMap;
- const QList<QTreeWidgetItem *> children = parent->takeChildren();
- for (QTreeWidgetItem *item : children)
- itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
-
- QList<QNetworkConfiguration> allConfigurations = snap.children();
-
- while (!allConfigurations.isEmpty()) {
- QNetworkConfiguration config = allConfigurations.takeFirst();
-
- QTreeWidgetItem *item = itemMap.take(config.identifier());
- if (item) {
- updateItem(item, config);
-
- parent->addChild(item);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
- } else {
- configurationAdded(config, parent);
- }
- }
-
- qDeleteAll(itemMap);
-}
-
-void BearerMonitor::updateConfigurations()
-{
- progressBar->hide();
- scanButton->show();
-
- // Just in case update online state, on Symbian platform
- // WLAN scan needs to be triggered initially to have their true state.
- onlineStateChanged(manager.isOnline());
-
- QList<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard);
- QMap<QString, QTreeWidgetItem *> itemMap;
- while (!items.isEmpty()) {
- QTreeWidgetItem *item = items.takeFirst();
- itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
- }
-
- QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
- QTreeWidgetItem *defaultItem = itemMap.take(defaultConfiguration.identifier());
-
- if (defaultItem) {
- updateItem(defaultItem, defaultConfiguration);
-
- if (defaultConfiguration.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(defaultItem, defaultConfiguration);
- } else {
- configurationAdded(defaultConfiguration);
- }
-
- QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
-
- while (!allConfigurations.isEmpty()) {
- QNetworkConfiguration config = allConfigurations.takeFirst();
-
- if (config.identifier() == defaultConfiguration.identifier())
- continue;
-
- QTreeWidgetItem *item = itemMap.take(config.identifier());
- if (item) {
- updateItem(item, config);
-
- if (config.type() == QNetworkConfiguration::ServiceNetwork)
- updateSnapConfiguration(item, config);
- } else {
- configurationAdded(config);
- }
- }
-
- qDeleteAll(itemMap);
-}
-
-void BearerMonitor::onlineStateChanged(bool isOnline)
-{
- if (isOnline)
- onlineState->setText(tr("Online"));
- else
- onlineState->setText(tr("Offline"));
-}
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-void BearerMonitor::registerNetwork()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- QNetworkConfiguration configuration =
- manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
-
- const QString name = configuration.name();
-
- qDebug() << "Registering" << name << "with system";
-
- WSAQUERYSET networkInfo;
- memset(&networkInfo, 0, sizeof(networkInfo));
- networkInfo.dwSize = sizeof(networkInfo);
- networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
- networkInfo.dwNameSpace = NS_NLA;
-
- if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR)
- qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError();
-}
-
-void BearerMonitor::unregisterNetwork()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- QNetworkConfiguration configuration =
- manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
-
- const QString name = configuration.name();
-
- qDebug() << "Unregistering" << name << "with system";
-
- WSAQUERYSET networkInfo;
- memset(&networkInfo, 0, sizeof(networkInfo));
- networkInfo.dwSize = sizeof(networkInfo);
- networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
- networkInfo.dwNameSpace = NS_NLA;
-
- if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR)
- qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError();
-}
-#endif // Q_OS_WIN && !Q_OS_WINRT
-
-void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item)
-{
- QString identifier;
-
- if (item)
- identifier = item->data(0, Qt::UserRole).toString();
-
- QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
-
- switch (conf.state()) {
- case QNetworkConfiguration::Active:
- configurationState->setText(tr("Active"));
- break;
- case QNetworkConfiguration::Discovered:
- configurationState->setText(tr("Discovered"));
- break;
- case QNetworkConfiguration::Defined:
- configurationState->setText(tr("Defined"));
- break;
- case QNetworkConfiguration::Undefined:
- configurationState->setText(tr("Undefined"));
- break;
- default:
- configurationState->setText(QString());
- }
-
- switch (conf.type()) {
- case QNetworkConfiguration::InternetAccessPoint:
- configurationType->setText(tr("Internet Access Point"));
- break;
- case QNetworkConfiguration::ServiceNetwork:
- configurationType->setText(tr("Service Network"));
- break;
- case QNetworkConfiguration::UserChoice:
- configurationType->setText(tr("User Choice"));
- break;
- case QNetworkConfiguration::Invalid:
- configurationType->setText(tr("Invalid"));
- break;
- default:
- configurationType->setText(QString());
- }
-
- switch (conf.purpose()) {
- case QNetworkConfiguration::UnknownPurpose:
- configurationPurpose->setText(tr("Unknown"));
- break;
- case QNetworkConfiguration::PublicPurpose:
- configurationPurpose->setText(tr("Public"));
- break;
- case QNetworkConfiguration::PrivatePurpose:
- configurationPurpose->setText(tr("Private"));
- break;
- case QNetworkConfiguration::ServiceSpecificPurpose:
- configurationPurpose->setText(tr("Service Specific"));
- break;
- default:
- configurationPurpose->setText(QString());
- }
-
- configurationIdentifier->setText(conf.identifier());
-
- configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available"));
-
- configurationChildren->setText(QString::number(conf.children().count()));
-
- configurationName->setText(conf.name());
-}
-
-void BearerMonitor::createSessionFor(QTreeWidgetItem *item)
-{
- const QString identifier = item->data(0, Qt::UserRole).toString();
-
- QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
-
- SessionWidget *session = new SessionWidget(conf);
-
- tabWidget->addTab(session, conf.name());
-
- sessionGroup->show();
-
- sessionWidgets.append(session);
-}
-
-void BearerMonitor::createNewSession()
-{
- QTreeWidgetItem *item = treeWidget->currentItem();
- if (!item) return;
-
- createSessionFor(item);
-}
-
-void BearerMonitor::deleteSession()
-{
- SessionWidget *session = qobject_cast<SessionWidget *>(tabWidget->currentWidget());
- if (session) {
- sessionWidgets.removeAll(session);
-
- delete session;
-
- if (tabWidget->count() == 0)
- sessionGroup->hide();
- }
-}
-
-void BearerMonitor::performScan()
-{
- scanButton->hide();
- progressBar->show();
- manager.updateConfigurations();
-}
diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h
deleted file mode 100644
index 7de186cd14..0000000000
--- a/examples/network/bearermonitor/bearermonitor.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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 Qt Company Ltd 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef BEARERMONITOR_H
-#define BEARERMONITOR_H
-
-#include <qnetworkconfigmanager.h>
-#include <qnetworksession.h>
-#include "ui_bearermonitor_640_480.h"
-
-QT_USE_NAMESPACE
-
-class SessionWidget;
-
-class BearerMonitor : public QWidget, public Ui_BearerMonitor
-{
- Q_OBJECT
-
-public:
- BearerMonitor(QWidget *parent = 0);
- ~BearerMonitor();
-
-private slots:
- void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = 0);
- void configurationRemoved(const QNetworkConfiguration &config);
- void configurationChanged(const QNetworkConfiguration &config);
- void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap);
- void updateConfigurations();
-
- void onlineStateChanged(bool isOnline);
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- void registerNetwork();
- void unregisterNetwork();
-#endif // Q_OS_WIN && !Q_OS_WINRT
-
- void showConfigurationFor(QTreeWidgetItem *item);
-
- void createSessionFor(QTreeWidgetItem *item);
- void createNewSession();
- void deleteSession();
- void performScan();
-
-private:
- QNetworkConfigurationManager manager;
- QList<SessionWidget *> sessionWidgets;
-};
-
-#endif //BEARERMONITOR_H
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
deleted file mode 100644
index 16ac41298a..0000000000
--- a/examples/network/bearermonitor/bearermonitor.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TARGET = bearermonitor
-QT = core gui network widgets
-requires(qtConfig(treeview))
-
-HEADERS = sessionwidget.h \
- bearermonitor.h
-
-SOURCES = main.cpp \
- bearermonitor.cpp \
- sessionwidget.cpp
-
-FORMS = bearermonitor_240_320.ui \
- bearermonitor_640_480.ui \
- sessionwidget.ui
-
-win32: QMAKE_USE += ws2_32
-
-CONFIG += console
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/bearermonitor
-INSTALLS += target
diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui
deleted file mode 100644
index 93cfc5e0e3..0000000000
--- a/examples/network/bearermonitor/bearermonitor_240_320.ui
+++ /dev/null
@@ -1,420 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BearerMonitor</class>
- <widget class="QWidget" name="BearerMonitor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>240</width>
- <height>320</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>BearerMonitor</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>-274</y>
- <width>206</width>
- <height>576</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QGroupBox" name="systemState">
- <property name="title">
- <string>System State</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="onlineStateLayout">
- <item>
- <widget class="QLabel" name="onlineStateLabel">
- <property name="text">
- <string>Online State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="onlineState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Configurations</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="configurationNameLayout">
- <item>
- <widget class="QLabel" name="configurationNameLabel">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationStateLayout">
- <item>
- <widget class="QLabel" name="configurationStateLabel">
- <property name="text">
- <string>State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationTypeLayout">
- <item>
- <widget class="QLabel" name="configurationTypeLabel">
- <property name="text">
- <string>Type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationPurposeLayout">
- <item>
- <widget class="QLabel" name="configurationPurposeLabel">
- <property name="text">
- <string>Purpose:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationPurpose">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Unknown</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationIdentifierLayout">
- <item>
- <widget class="QLabel" name="configurationIdentifierLabel">
- <property name="text">
- <string>Identifier:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationIdentifier">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationRoamingLayout">
- <item>
- <widget class="QLabel" name="configurationRoamingLabel">
- <property name="text">
- <string>Roaming:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationRoaming">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationChildrenLayout">
- <item>
- <widget class="QLabel" name="configurationChildrenLabel">
- <property name="text">
- <string>Children:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationChildren">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="nlaGroup">
- <property name="title">
- <string>Network Location Awareness</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="registerButton">
- <property name="text">
- <string>Register</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="unregisterButton">
- <property name="text">
- <string>Unregister</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="newSessionButton">
- <property name="text">
- <string>New Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteSessionButton">
- <property name="text">
- <string>Delete Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="scanButton">
- <property name="text">
- <string>Scan</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="maximum">
- <number>0</number>
- </property>
- <property name="value">
- <number>-1</number>
- </property>
- <property name="textVisible">
- <bool>false</bool>
- </property>
- <property name="invertedAppearance">
- <bool>false</bool>
- </property>
- <property name="format">
- <string>%p%</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QTreeWidget" name="treeWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string>1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="sessionGroup">
- <property name="title">
- <string>Sessions</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Session 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui
deleted file mode 100644
index 52866bc9cd..0000000000
--- a/examples/network/bearermonitor/bearermonitor_640_480.ui
+++ /dev/null
@@ -1,386 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BearerMonitor</class>
- <widget class="QWidget" name="BearerMonitor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>640</width>
- <height>515</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>BearerMonitor</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QGroupBox" name="systemState">
- <property name="title">
- <string>System State</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="onlineStateLayout">
- <item>
- <widget class="QLabel" name="onlineStateLabel">
- <property name="text">
- <string>Online State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="onlineState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Configurations</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTreeWidget" name="treeWidget">
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string>1</string>
- </property>
- </column>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="configurationNameLayout">
- <item>
- <widget class="QLabel" name="configurationNameLabel">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationStateLayout">
- <item>
- <widget class="QLabel" name="configurationStateLabel">
- <property name="text">
- <string>State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationTypeLayout">
- <item>
- <widget class="QLabel" name="configurationTypeLabel">
- <property name="text">
- <string>Type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationPurposeLayout">
- <item>
- <widget class="QLabel" name="configurationPurposeLabel">
- <property name="text">
- <string>Purpose:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationPurpose">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Unknown</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationIdentifierLayout">
- <item>
- <widget class="QLabel" name="configurationIdentifierLabel">
- <property name="text">
- <string>Identifier:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationIdentifier">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationRoamingLayout">
- <item>
- <widget class="QLabel" name="configurationRoamingLabel">
- <property name="text">
- <string>Roaming:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationRoaming">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationChildrenLayout">
- <item>
- <widget class="QLabel" name="configurationChildrenLabel">
- <property name="text">
- <string>Children:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configurationChildren">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="nlaGroup">
- <property name="title">
- <string>Network Location Awareness</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="registerButton">
- <property name="text">
- <string>Register</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="unregisterButton">
- <property name="text">
- <string>Unregister</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="newSessionButton">
- <property name="text">
- <string>New Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteSessionButton">
- <property name="text">
- <string>Delete Session</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="scanButton">
- <property name="text">
- <string>Scan</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="maximum">
- <number>0</number>
- </property>
- <property name="value">
- <number>-1</number>
- </property>
- <property name="textVisible">
- <bool>false</bool>
- </property>
- <property name="invertedAppearance">
- <bool>false</bool>
- </property>
- <property name="format">
- <string>%p%</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="sessionGroup">
- <property name="title">
- <string>Sessions</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Session 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp
deleted file mode 100644
index 363889dee4..0000000000
--- a/examples/network/bearermonitor/main.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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 Qt Company Ltd 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QMainWindow>
-
-#include "bearermonitor.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QMainWindow mainWindow;
-
- BearerMonitor monitor;
-
- mainWindow.setCentralWidget(&monitor);
- mainWindow.show();
-
- return app.exec();
-}
-
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
deleted file mode 100644
index 237ceee2bd..0000000000
--- a/examples/network/bearermonitor/sessionwidget.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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 Qt Company Ltd 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "sessionwidget.h"
-#include "qnetworkconfigmanager.h"
-
-SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
-: QWidget(parent), statsTimer(-1)
-{
- setupUi(this);
-
-#ifdef QT_NO_NETWORKINTERFACE
- interfaceName->setVisible(false);
- interfaceNameLabel->setVisible(false);
- interfaceGuid->setVisible(false);
- interfaceGuidLabel->setVisible(false);
-#endif
-
- session = new QNetworkSession(config, this);
-
- connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
- this, SLOT(updateSession()));
- connect(session, SIGNAL(error(QNetworkSession::SessionError)),
- this, SLOT(updateSessionError(QNetworkSession::SessionError)));
-
- updateSession();
-
- sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0')));
-
- configuration->setText(session->configuration().name());
-
- connect(openSessionButton, SIGNAL(clicked()),
- this, SLOT(openSession()));
- connect(openSyncSessionButton, SIGNAL(clicked()),
- this, SLOT(openSyncSession()));
- connect(closeSessionButton, SIGNAL(clicked()),
- this, SLOT(closeSession()));
- connect(stopSessionButton, SIGNAL(clicked()),
- this, SLOT(stopSession()));
-}
-
-SessionWidget::~SessionWidget()
-{
- delete session;
-}
-
-void SessionWidget::timerEvent(QTimerEvent *e)
-{
- if (e->timerId() == statsTimer) {
- rxData->setText(QString::number(session->bytesReceived()));
- txData->setText(QString::number(session->bytesWritten()));
- activeTime->setText(QString::number(session->activeTime()));
- }
-}
-
-void SessionWidget::updateSession()
-{
- updateSessionState(session->state());
-
- if (session->state() == QNetworkSession::Connected)
- statsTimer = startTimer(1000);
- else if (statsTimer != -1)
- killTimer(statsTimer);
-
- if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint)
- bearer->setText(session->configuration().bearerTypeName());
- else {
- QNetworkConfigurationManager mgr;
- QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString());
- bearer->setText(c.bearerTypeName());
- }
-
-#ifndef QT_NO_NETWORKINTERFACE
- interfaceName->setText(session->interface().humanReadableName());
- interfaceGuid->setText(session->interface().name());
-#endif
-}
-
-void SessionWidget::openSession()
-{
- clearError();
- session->open();
- updateSession();
-}
-
-void SessionWidget::openSyncSession()
-{
- clearError();
- session->open();
- session->waitForOpened();
- updateSession();
-}
-
-void SessionWidget::closeSession()
-{
- clearError();
- session->close();
- updateSession();
-}
-
-void SessionWidget::stopSession()
-{
- clearError();
- session->stop();
- updateSession();
-}
-
-void SessionWidget::updateSessionState(QNetworkSession::State state)
-{
- QString s = tr("%1 (%2)");
-
- switch (state) {
- case QNetworkSession::Invalid:
- s = s.arg(tr("Invalid"));
- break;
- case QNetworkSession::NotAvailable:
- s = s.arg(tr("Not Available"));
- break;
- case QNetworkSession::Connecting:
- s = s.arg(tr("Connecting"));
- break;
- case QNetworkSession::Connected:
- s = s.arg(tr("Connected"));
- break;
- case QNetworkSession::Closing:
- s = s.arg(tr("Closing"));
- break;
- case QNetworkSession::Disconnected:
- s = s.arg(tr("Disconnected"));
- break;
- case QNetworkSession::Roaming:
- s = s.arg(tr("Roaming"));
- break;
- default:
- s = s.arg(tr("Unknown"));
- }
-
- if (session->isOpen())
- s = s.arg(tr("Open"));
- else
- s = s.arg(tr("Closed"));
-
- sessionState->setText(s);
-}
-
-void SessionWidget::updateSessionError(QNetworkSession::SessionError error)
-{
- lastError->setText(QString::number(error));
- errorString->setText(session->errorString());
-}
-
-void SessionWidget::clearError()
-{
- lastError->clear();
- errorString->clear();
-}
diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h
deleted file mode 100644
index ba352eefee..0000000000
--- a/examples/network/bearermonitor/sessionwidget.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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 Qt Company Ltd 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SESSIONWIDGET_H
-#define SESSIONWIDGET_H
-
-#include <qnetworksession.h>
-
-#include "ui_sessionwidget.h"
-
-QT_USE_NAMESPACE
-
-class SessionWidget : public QWidget, public Ui_SessionWidget
-{
- Q_OBJECT
-
-public:
- explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
- ~SessionWidget();
-
- void timerEvent(QTimerEvent *) override;
-
-private:
- void updateSessionState(QNetworkSession::State state);
- void clearError();
-
-private Q_SLOTS:
- void openSession();
- void openSyncSession();
- void closeSession();
- void stopSession();
- void updateSession();
- void updateSessionError(QNetworkSession::SessionError error);
-
-private:
- QNetworkSession *session;
- int statsTimer;
-};
-
-#endif
-
diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui
deleted file mode 100644
index 4199109ce3..0000000000
--- a/examples/network/bearermonitor/sessionwidget.ui
+++ /dev/null
@@ -1,307 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SessionWidget</class>
- <widget class="QWidget" name="SessionWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>340</width>
- <height>276</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Session Details</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="sessionIdLayout">
- <item>
- <widget class="QLabel" name="sessionIdLabel">
- <property name="text">
- <string>Session ID:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="sessionId">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="sessionStateLayout">
- <item>
- <widget class="QLabel" name="sessionStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Session State:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="sessionState">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Invalid</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="configurationLayout">
- <item>
- <widget class="QLabel" name="configurationLabel">
- <property name="text">
- <string>Configuration:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="configuration">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="bearerLayout">
- <item>
- <widget class="QLabel" name="bearerLabel">
- <property name="text">
- <string>Bearer:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="bearer">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="interfaceNameLayout">
- <item>
- <widget class="QLabel" name="interfaceNameLabel">
- <property name="text">
- <string>Interface Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="interfaceName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="interfaceGuidLayout">
- <item>
- <widget class="QLabel" name="interfaceGuidLabel">
- <property name="text">
- <string>Interface GUID:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="interfaceGuid">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="lastErrorLayout">
- <item>
- <widget class="QLabel" name="lastErrorLabel">
- <property name="text">
- <string>Last Error:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lastError">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="errorStringLayout">
- <item>
- <widget class="QLabel" name="errorStringLabel">
- <property name="text">
- <string>Error String:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="errorString">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="rxData">
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="txData">
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Active Time:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="activeTime">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>0 seconds</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="openSessionButton">
- <property name="text">
- <string>Open</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="openSyncSessionButton">
- <property name="text">
- <string>Blocking Open</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="closeSessionButton">
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="stopSessionButton">
- <property name="text">
- <string>Stop</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp
index 607215cf13..5a1500d084 100644
--- a/examples/network/blockingfortuneclient/blockingclient.cpp
+++ b/examples/network/blockingfortuneclient/blockingclient.cpp
@@ -96,20 +96,21 @@ BlockingClient::BlockingClient(QWidget *parent)
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
-
- connect(hostLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
- connect(portLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
+ connect(getFortuneButton, &QPushButton::clicked,
+ this, &BlockingClient::requestNewFortune);
+ connect(quitButton, &QPushButton::clicked,
+ this, &BlockingClient::close);
+
+ connect(hostLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+ connect(portLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+//! [0]
+ connect(&thread, &FortuneThread::newFortune,
+ this, &BlockingClient::showFortune);
+ connect(&thread, &FortuneThread::error,
+ this, &BlockingClient::displayError);
//! [0]
- connect(&thread, SIGNAL(newFortune(QString)),
- this, SLOT(showFortune(QString)));
-//! [0] //! [1]
- connect(&thread, SIGNAL(error(int,QString)),
- this, SLOT(displayError(int,QString)));
-//! [1]
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
@@ -124,30 +125,30 @@ BlockingClient::BlockingClient(QWidget *parent)
portLineEdit->setFocus();
}
-//! [2]
+//! [1]
void BlockingClient::requestNewFortune()
{
getFortuneButton->setEnabled(false);
thread.requestNewFortune(hostLineEdit->text(),
portLineEdit->text().toInt());
}
-//! [2]
+//! [1]
-//! [3]
+//! [2]
void BlockingClient::showFortune(const QString &nextFortune)
{
if (nextFortune == currentFortune) {
requestNewFortune();
return;
}
-//! [3]
+//! [2]
-//! [4]
+//! [3]
currentFortune = nextFortune;
statusLabel->setText(currentFortune);
getFortuneButton->setEnabled(true);
}
-//! [4]
+//! [3]
void BlockingClient::displayError(int socketError, const QString &message)
{
diff --git a/examples/network/blockingfortuneclient/blockingclient.h b/examples/network/blockingfortuneclient/blockingclient.h
index 2a2dd81b71..b8a7163160 100644
--- a/examples/network/blockingfortuneclient/blockingclient.h
+++ b/examples/network/blockingfortuneclient/blockingclient.h
@@ -69,7 +69,7 @@ class BlockingClient : public QWidget
Q_OBJECT
public:
- BlockingClient(QWidget *parent = 0);
+ BlockingClient(QWidget *parent = nullptr);
private slots:
void requestNewFortune();
diff --git a/examples/network/blockingfortuneclient/fortunethread.cpp b/examples/network/blockingfortuneclient/fortunethread.cpp
index 67ac7ebfa5..24801436df 100644
--- a/examples/network/blockingfortuneclient/fortunethread.cpp
+++ b/examples/network/blockingfortuneclient/fortunethread.cpp
@@ -103,7 +103,7 @@ void FortuneThread::run()
//! [6] //! [8]
if (!socket.waitForConnected(Timeout)) {
- emit error(socket.error(), socket.errorString());
+ emit error(socket.socketError(), socket.errorString());
return;
}
//! [8] //! [11]
@@ -115,7 +115,7 @@ void FortuneThread::run()
do {
if (!socket.waitForReadyRead(Timeout)) {
- emit error(socket.error(), socket.errorString());
+ emit error(socket.socketError(), socket.errorString());
return;
}
diff --git a/examples/network/blockingfortuneclient/fortunethread.h b/examples/network/blockingfortuneclient/fortunethread.h
index 0cbc3961fc..b6b63d9319 100644
--- a/examples/network/blockingfortuneclient/fortunethread.h
+++ b/examples/network/blockingfortuneclient/fortunethread.h
@@ -61,7 +61,7 @@ class FortuneThread : public QThread
Q_OBJECT
public:
- FortuneThread(QObject *parent = 0);
+ FortuneThread(QObject *parent = nullptr);
~FortuneThread();
void requestNewFortune(const QString &hostName, quint16 port);
diff --git a/examples/network/broadcastreceiver/receiver.cpp b/examples/network/broadcastreceiver/receiver.cpp
index 2f111b4795..5b932a27b9 100644
--- a/examples/network/broadcastreceiver/receiver.cpp
+++ b/examples/network/broadcastreceiver/receiver.cpp
@@ -48,8 +48,10 @@
**
****************************************************************************/
-#include <QtWidgets>
-#include <QtNetwork>
+#include <QLabel>
+#include <QPushButton>
+#include <QUdpSocket>
+#include <QVBoxLayout>
#include "receiver.h"
@@ -67,10 +69,11 @@ Receiver::Receiver(QWidget *parent)
//! [0]
//! [1]
- connect(udpSocket, SIGNAL(readyRead()),
- this, SLOT(processPendingDatagrams()));
+ connect(udpSocket, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
//! [1]
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked,
+ this, &Receiver::close);
auto buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/dnslookup/dnslookup.cpp b/examples/network/dnslookup/dnslookup.cpp
index a2d927d43d..61f8d35a3d 100644
--- a/examples/network/dnslookup/dnslookup.cpp
+++ b/examples/network/dnslookup/dnslookup.cpp
@@ -151,9 +151,9 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *qu
//! [0]
DnsManager::DnsManager()
+ : dns(new QDnsLookup(this))
{
- dns = new QDnsLookup(this);
- connect(dns, SIGNAL(finished()), this, SLOT(showResults()));
+ connect(dns, &QDnsLookup::finished, this, &DnsManager::showResults);
}
void DnsManager::execute()
diff --git a/examples/network/doc/src/blockingfortuneclient.qdoc b/examples/network/doc/src/blockingfortuneclient.qdoc
index ecb9a7ba62..d1c0aa79bf 100644
--- a/examples/network/doc/src/blockingfortuneclient.qdoc
+++ b/examples/network/doc/src/blockingfortuneclient.qdoc
@@ -176,21 +176,20 @@
but its implementation is slightly different:
\snippet blockingfortuneclient/blockingclient.cpp 0
- \snippet blockingfortuneclient/blockingclient.cpp 1
We connect our FortuneThread's two signals newFortune() and error() (which
are somewhat similar to QTcpSocket::readyRead() and QTcpSocket::error() in
the previous example) to requestNewFortune() and displayError().
- \snippet blockingfortuneclient/blockingclient.cpp 2
+ \snippet blockingfortuneclient/blockingclient.cpp 1
The requestNewFortune() slot calls FortuneThread::requestNewFortune(),
which \e shedules the request. When the thread has received a new fortune
and emits newFortune(), our showFortune() slot is called:
- \snippet blockingfortuneclient/blockingclient.cpp 3
+ \snippet blockingfortuneclient/blockingclient.cpp 2
\codeline
- \snippet blockingfortuneclient/blockingclient.cpp 4
+ \snippet blockingfortuneclient/blockingclient.cpp 3
Here, we simply display the fortune we received as the argument.
diff --git a/examples/network/download/main.cpp b/examples/network/download/main.cpp
index 96111983ea..f496c1723e 100644
--- a/examples/network/download/main.cpp
+++ b/examples/network/download/main.cpp
@@ -80,8 +80,8 @@ public slots:
DownloadManager::DownloadManager()
{
- connect(&manager, SIGNAL(finished(QNetworkReply*)),
- SLOT(downloadFinished(QNetworkReply*)));
+ connect(&manager, &QNetworkAccessManager::finished,
+ this, &DownloadManager::downloadFinished);
}
void DownloadManager::doDownload(const QUrl &url)
@@ -90,8 +90,8 @@ void DownloadManager::doDownload(const QUrl &url)
QNetworkReply *reply = manager.get(request);
#if QT_CONFIG(ssl)
- connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
- SLOT(sslErrors(QList<QSslError>)));
+ connect(reply, &QNetworkReply::sslErrors,
+ this, &DownloadManager::sslErrors);
#endif
currentDownloads.append(reply);
@@ -175,7 +175,7 @@ void DownloadManager::sslErrors(const QList<QSslError> &sslErrors)
void DownloadManager::downloadFinished(QNetworkReply *reply)
{
QUrl url = reply->url();
- if (reply->error()) {
+ if (reply->networkError()) {
fprintf(stderr, "Download of %s failed: %s\n",
url.toEncoded().constData(),
qPrintable(reply->errorString()));
diff --git a/examples/network/downloadmanager/downloadmanager.cpp b/examples/network/downloadmanager/downloadmanager.cpp
index 9e0c03c6af..eceb48977b 100644
--- a/examples/network/downloadmanager/downloadmanager.cpp
+++ b/examples/network/downloadmanager/downloadmanager.cpp
@@ -67,13 +67,13 @@ void DownloadManager::append(const QStringList &urls)
append(QUrl::fromEncoded(urlAsString.toLocal8Bit()));
if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, SIGNAL(finished()));
+ QTimer::singleShot(0, this, &DownloadManager::finished);
}
void DownloadManager::append(const QUrl &url)
{
if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, SLOT(startNextDownload()));
+ QTimer::singleShot(0, this, &DownloadManager::startNextDownload);
downloadQueue.enqueue(url);
++totalCount;
@@ -123,12 +123,12 @@ void DownloadManager::startNextDownload()
QNetworkRequest request(url);
currentDownload = manager.get(request);
- connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
- SLOT(downloadProgress(qint64,qint64)));
- connect(currentDownload, SIGNAL(finished()),
- SLOT(downloadFinished()));
- connect(currentDownload, SIGNAL(readyRead()),
- SLOT(downloadReadyRead()));
+ connect(currentDownload, &QNetworkReply::downloadProgress,
+ this, &DownloadManager::downloadProgress);
+ connect(currentDownload, &QNetworkReply::finished,
+ this, &DownloadManager::downloadFinished);
+ connect(currentDownload, &QNetworkReply::readyRead,
+ this, &DownloadManager::downloadReadyRead);
// prepare the output
printf("Downloading %s...\n", url.toEncoded().constData());
@@ -162,7 +162,7 @@ void DownloadManager::downloadFinished()
progressBar.clear();
output.close();
- if (currentDownload->error()) {
+ if (currentDownload->networkError()) {
// download failed
fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString()));
output.remove();
diff --git a/examples/network/downloadmanager/main.cpp b/examples/network/downloadmanager/main.cpp
index e3ba490992..eb1bd1ce9a 100644
--- a/examples/network/downloadmanager/main.cpp
+++ b/examples/network/downloadmanager/main.cpp
@@ -76,6 +76,7 @@ int main(int argc, char **argv)
DownloadManager manager;
manager.append(arguments);
- QObject::connect(&manager, SIGNAL(finished()), &app, SLOT(quit()));
+ QObject::connect(&manager, &DownloadManager::finished,
+ &app, &QCoreApplication::quit);
app.exec();
}
diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp
index 4d3a318a7b..0ccbf51df8 100644
--- a/examples/network/fortuneclient/client.cpp
+++ b/examples/network/fortuneclient/client.cpp
@@ -150,29 +150,6 @@ Client::Client(QWidget *parent)
setWindowTitle(QGuiApplication::applicationDisplayName());
portLineEdit->setFocus();
-
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, &QNetworkSession::opened, this, &Client::sessionOpened);
-
- getFortuneButton->setEnabled(false);
- statusLabel->setText(tr("Opening network session."));
- networkSession->open();
- }
//! [5]
}
//! [5]
@@ -241,30 +218,7 @@ void Client::displayError(QAbstractSocket::SocketError socketError)
void Client::enableGetFortuneButton()
{
- getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) &&
- !hostCombo->currentText().isEmpty() &&
+ getFortuneButton->setEnabled(!hostCombo->currentText().isEmpty() &&
!portLineEdit->text().isEmpty());
}
-
-void Client::sessionOpened()
-{
- // Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice)
- id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
- else
- id = config.identifier();
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
-
- statusLabel->setText(tr("This examples requires that you run the "
- "Fortune Server example as well."));
-
- enableGetFortuneButton();
-}
-
diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h
index ac335acb83..80177bacbf 100644
--- a/examples/network/fortuneclient/client.h
+++ b/examples/network/fortuneclient/client.h
@@ -61,7 +61,6 @@ class QLabel;
class QLineEdit;
class QPushButton;
class QTcpSocket;
-class QNetworkSession;
QT_END_NAMESPACE
//! [0]
@@ -77,7 +76,6 @@ private slots:
void readFortune();
void displayError(QAbstractSocket::SocketError socketError);
void enableGetFortuneButton();
- void sessionOpened();
private:
QComboBox *hostCombo = nullptr;
@@ -88,8 +86,6 @@ private:
QTcpSocket *tcpSocket = nullptr;
QDataStream in;
QString currentFortune;
-
- QNetworkSession *networkSession = nullptr;
};
//! [0]
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index 7db81fe07a..c91b6a5c0c 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -61,29 +61,7 @@ Server::Server(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened);
-
- statusLabel->setText(tr("Opening network session."));
- networkSession->open();
- } else {
- sessionOpened();
- }
+ initServer();
//! [2]
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
@@ -128,23 +106,8 @@ Server::Server(QWidget *parent)
setWindowTitle(QGuiApplication::applicationDisplayName());
}
-void Server::sessionOpened()
+void Server::initServer()
{
- // Save the used configuration
- if (networkSession) {
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice)
- id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
- else
- id = config.identifier();
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
- }
-
//! [0] //! [1]
tcpServer = new QTcpServer(this);
if (!tcpServer->listen()) {
diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h
index c5bfa7d928..96d7145148 100644
--- a/examples/network/fortuneserver/server.h
+++ b/examples/network/fortuneserver/server.h
@@ -58,7 +58,6 @@
QT_BEGIN_NAMESPACE
class QLabel;
class QTcpServer;
-class QNetworkSession;
QT_END_NAMESPACE
//! [0]
@@ -70,14 +69,14 @@ public:
explicit Server(QWidget *parent = nullptr);
private slots:
- void sessionOpened();
void sendFortune();
private:
+ void initServer();
+
QLabel *statusLabel = nullptr;
QTcpServer *tcpServer = nullptr;
QVector<QString> fortunes;
- QNetworkSession *networkSession = nullptr;
};
//! [0]
diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp
index d27beafd1e..1ae515f530 100644
--- a/examples/network/googlesuggest/googlesuggest.cpp
+++ b/examples/network/googlesuggest/googlesuggest.cpp
@@ -48,9 +48,9 @@
**
****************************************************************************/
-//! [1]
#include "googlesuggest.h"
+//! [1]
const QString gsuggestUrl(QStringLiteral("http://google.com/complete/search?output=toolbar&q=%1"));
//! [1]
@@ -74,16 +74,18 @@ GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), edit
popup->installEventFilter(this);
- connect(popup, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
- SLOT(doneCompletion()));
+ connect(popup, &QTreeWidget::itemClicked,
+ this, &GSuggestCompletion::doneCompletion);
timer.setSingleShot(true);
timer.setInterval(500);
- connect(&timer, SIGNAL(timeout()), SLOT(autoSuggest()));
- connect(editor, SIGNAL(textEdited(QString)), &timer, SLOT(start()));
+ connect(&timer, &QTimer::timeout,
+ this, &GSuggestCompletion::autoSuggest);
+ connect(editor, &QLineEdit::textEdited,
+ &timer, QOverload<>::of(&QTimer::start));
- connect(&networkManager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(handleNetworkData(QNetworkReply*)));
+ connect(&networkManager, &QNetworkAccessManager::finished,
+ this, &GSuggestCompletion::handleNetworkData);
}
//! [2]
@@ -207,7 +209,7 @@ void GSuggestCompletion::preventSuggest()
void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply)
{
QUrl url = networkReply->url();
- if (networkReply->error() == QNetworkReply::NoError) {
+ if (networkReply->networkError() == QNetworkReply::NoError) {
QVector<QString> choices;
QByteArray response(networkReply->readAll());
diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp
index d0bdb70daa..9057c1ccdf 100644
--- a/examples/network/googlesuggest/searchbox.cpp
+++ b/examples/network/googlesuggest/searchbox.cpp
@@ -57,11 +57,11 @@
const QString gsearchUrl = QStringLiteral("http://www.google.com/search?q=%1");
//! [1]
-SearchBox::SearchBox(QWidget *parent): QLineEdit(parent)
+SearchBox::SearchBox(QWidget *parent)
+ : QLineEdit(parent)
+ , completer(new GSuggestCompletion(this))
{
- completer = new GSuggestCompletion(this);
-
- connect(this, SIGNAL(returnPressed()),this, SLOT(doSearch()));
+ connect(this, &SearchBox::returnPressed, this, &SearchBox::doSearch);
setWindowTitle("Search with Google");
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index c7bf0c0dff..d0eb2529cd 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -249,7 +249,7 @@ void HttpWindow::httpFinished()
return;
}
- if (reply->error()) {
+ if (reply->networkError()) {
QFile::remove(fi.absoluteFilePath());
statusLabel->setText(tr("Download failed:\n%1.").arg(reply->errorString()));
downloadButton->setEnabled(true);
diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp
index d793242ad0..3737d64f96 100644
--- a/examples/network/multicastreceiver/receiver.cpp
+++ b/examples/network/multicastreceiver/receiver.cpp
@@ -80,10 +80,12 @@ Receiver::Receiver(QWidget *parent)
!udpSocket6.joinMulticastGroup(groupAddress6))
statusLabel->setText(tr("Listening for multicast messages on IPv4 only"));
- connect(&udpSocket4, SIGNAL(readyRead()),
- this, SLOT(processPendingDatagrams()));
- connect(&udpSocket6, &QUdpSocket::readyRead, this, &Receiver::processPendingDatagrams);
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(&udpSocket4, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
+ connect(&udpSocket6, &QUdpSocket::readyRead,
+ this, &Receiver::processPendingDatagrams);
+ connect(quitButton, &QPushButton::clicked,
+ this, &Receiver::close);
}
void Receiver::processPendingDatagrams()
diff --git a/examples/network/multistreamclient/client.cpp b/examples/network/multistreamclient/client.cpp
index 112fb2e1a0..db6e3ba304 100644
--- a/examples/network/multistreamclient/client.cpp
+++ b/examples/network/multistreamclient/client.cpp
@@ -126,8 +126,8 @@ Client::Client(QWidget *parent)
connect(sctpSocket, &QSctpSocket::connected, this, &Client::connected);
connect(sctpSocket, &QSctpSocket::disconnected, this, &Client::disconnected);
connect(sctpSocket, &QSctpSocket::channelReadyRead, this, &Client::readDatagram);
- connect(sctpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(displayError(QAbstractSocket::SocketError)));
+ connect(sctpSocket, QOverload<QAbstractSocket::SocketError>::of(&QSctpSocket::error),
+ this, &Client::displayError);
connect(consumers[SctpChannels::Time], &Consumer::writeDatagram, this, &Client::writeDatagram);
connect(consumers[SctpChannels::Chat], &Consumer::writeDatagram, this, &Client::writeDatagram);
diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp
index 615df3a318..ce6e39a8fc 100644
--- a/examples/network/network-chat/chatdialog.cpp
+++ b/examples/network/network-chat/chatdialog.cpp
@@ -62,14 +62,14 @@ ChatDialog::ChatDialog(QWidget *parent)
textEdit->setReadOnly(true);
listWidget->setFocusPolicy(Qt::NoFocus);
- connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- connect(&client, SIGNAL(newMessage(QString,QString)),
- this, SLOT(appendMessage(QString,QString)));
- connect(&client, SIGNAL(newParticipant(QString)),
- this, SLOT(newParticipant(QString)));
- connect(&client, SIGNAL(participantLeft(QString)),
- this, SLOT(participantLeft(QString)));
+ connect(lineEdit, &QLineEdit::returnPressed,
+ this, &ChatDialog::returnPressed);
+ connect(&client, &Client::newMessage,
+ this, &ChatDialog::appendMessage);
+ connect(&client, &Client::newParticipant,
+ this, &ChatDialog::newParticipant);
+ connect(&client, &Client::participantLeft,
+ this, &ChatDialog::participantLeft);
myNickName = client.nickName();
newParticipant(myNickName);
diff --git a/examples/network/network-chat/chatdialog.h b/examples/network/network-chat/chatdialog.h
index c65861c6e6..27ae0ca72a 100644
--- a/examples/network/network-chat/chatdialog.h
+++ b/examples/network/network-chat/chatdialog.h
@@ -59,7 +59,7 @@ class ChatDialog : public QDialog, private Ui::ChatDialog
Q_OBJECT
public:
- ChatDialog(QWidget *parent = 0);
+ ChatDialog(QWidget *parent = nullptr);
public slots:
void appendMessage(const QString &from, const QString &message);
diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp
index b76ef18238..d451181813 100644
--- a/examples/network/network-chat/client.cpp
+++ b/examples/network/network-chat/client.cpp
@@ -60,10 +60,10 @@ Client::Client()
peerManager->setServerPort(server.serverPort());
peerManager->startBroadcasting();
- QObject::connect(peerManager, SIGNAL(newConnection(Connection*)),
- this, SLOT(newConnection(Connection*)));
- QObject::connect(&server, SIGNAL(newConnection(Connection*)),
- this, SLOT(newConnection(Connection*)));
+ connect(peerManager, &PeerManager::newConnection,
+ this, &Client::newConnection);
+ connect(&server, &Server::newConnection,
+ this, &Client::newConnection);
}
void Client::sendMessage(const QString &message)
@@ -102,10 +102,10 @@ void Client::newConnection(Connection *connection)
{
connection->setGreetingMessage(peerManager->userName());
- connect(connection, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(connectionError(QAbstractSocket::SocketError)));
- connect(connection, SIGNAL(disconnected()), this, SLOT(disconnected()));
- connect(connection, SIGNAL(readyForUse()), this, SLOT(readyForUse()));
+ connect(connection, QOverload<QAbstractSocket::SocketError>::of(&Connection::error),
+ this, &Client::connectionError);
+ connect(connection, &Connection::disconnected, this, &Client::disconnected);
+ connect(connection, &Connection::readyForUse, this, &Client::readyForUse);
}
void Client::readyForUse()
@@ -115,8 +115,8 @@ void Client::readyForUse()
connection->peerPort()))
return;
- connect(connection, SIGNAL(newMessage(QString,QString)),
- this, SIGNAL(newMessage(QString,QString)));
+ connect(connection, &Connection::newMessage,
+ this, &Client::newMessage);
peers.insert(connection->peerAddress(), connection);
QString nick = connection->name();
diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp
index 58cf67eb6d..cffd495349 100644
--- a/examples/network/network-chat/connection.cpp
+++ b/examples/network/network-chat/connection.cpp
@@ -82,11 +82,14 @@ Connection::Connection(QObject *parent)
isGreetingMessageSent = false;
pingTimer.setInterval(PingInterval);
- QObject::connect(this, SIGNAL(readyRead()), this, SLOT(processReadyRead()));
- QObject::connect(this, SIGNAL(disconnected()), &pingTimer, SLOT(stop()));
- QObject::connect(&pingTimer, SIGNAL(timeout()), this, SLOT(sendPing()));
- QObject::connect(this, SIGNAL(connected()),
- this, SLOT(sendGreetingMessage()));
+ connect(this, &QTcpSocket::readyRead, this,
+ &Connection::processReadyRead);
+ connect(this, &QTcpSocket::disconnected,
+ &pingTimer, &QTimer::stop);
+ connect(&pingTimer, &QTimer::timeout,
+ this, &Connection::sendPing);
+ connect(this, &QTcpSocket::connected,
+ this, &Connection::sendGreetingMessage);
}
Connection::Connection(qintptr socketDescriptor, QObject *parent)
diff --git a/examples/network/network-chat/connection.h b/examples/network/network-chat/connection.h
index fa0671a522..e6f36f7cd9 100644
--- a/examples/network/network-chat/connection.h
+++ b/examples/network/network-chat/connection.h
@@ -79,8 +79,8 @@ public:
Undefined
};
- Connection(QObject *parent = 0);
- Connection(qintptr socketDescriptor, QObject *parent = 0);
+ Connection(QObject *parent = nullptr);
+ Connection(qintptr socketDescriptor, QObject *parent = nullptr);
~Connection();
QString name() const;
diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp
index f88e29977b..029c18f0ff 100644
--- a/examples/network/network-chat/main.cpp
+++ b/examples/network/network-chat/main.cpp
@@ -53,50 +53,11 @@
#include "chatdialog.h"
#include <QtCore/QSettings>
-#include <QtNetwork/QNetworkConfigurationManager>
-#include <QtNetwork/QNetworkSession>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- QNetworkSession *networkSession = new QNetworkSession(config, &app);
- networkSession->open();
- networkSession->waitForOpened();
-
- if (networkSession->isOpen()) {
- // Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice) {
- id = networkSession->sessionProperty(
- QLatin1String("UserChoiceConfiguration")).toString();
- } else {
- id = config.identifier();
- }
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
- }
- }
-
ChatDialog dialog;
dialog.show();
return app.exec();
diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp
index 5c48edb1b9..2c9d182211 100644
--- a/examples/network/network-chat/peermanager.cpp
+++ b/examples/network/network-chat/peermanager.cpp
@@ -81,12 +81,12 @@ PeerManager::PeerManager(Client *client)
broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress
| QUdpSocket::ReuseAddressHint);
- connect(&broadcastSocket, SIGNAL(readyRead()),
- this, SLOT(readBroadcastDatagram()));
+ connect(&broadcastSocket, &QUdpSocket::readyRead,
+ this, &PeerManager::readBroadcastDatagram);
broadcastTimer.setInterval(BroadcastInterval);
- connect(&broadcastTimer, SIGNAL(timeout()),
- this, SLOT(sendBroadcastDatagram()));
+ connect(&broadcastTimer, &QTimer::timeout,
+ this, &PeerManager::sendBroadcastDatagram);
}
void PeerManager::setServerPort(int port)
diff --git a/examples/network/network-chat/server.h b/examples/network/network-chat/server.h
index d86ed36bce..0a7e6e18c1 100644
--- a/examples/network/network-chat/server.h
+++ b/examples/network/network-chat/server.h
@@ -60,7 +60,7 @@ class Server : public QTcpServer
Q_OBJECT
public:
- Server(QObject *parent = 0);
+ Server(QObject *parent = nullptr);
signals:
void newConnection(Connection *connection);
diff --git a/examples/network/network.pro b/examples/network/network.pro
index 1556e26ab1..3f851d7c71 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -19,17 +19,13 @@ qtHaveModule(widgets) {
multicastreceiver \
multicastsender
- qtConfig(bearermanagement) {
- qtConfig(processenvironment): SUBDIRS += network-chat
+ qtConfig(processenvironment): SUBDIRS += network-chat
- SUBDIRS += \
- bearermonitor \
- fortuneclient \
- fortuneserver
+ SUBDIRS += \
+ fortuneclient \
+ fortuneserver
- }
-
- qtConfig(openssl): SUBDIRS += securesocketclient
+ qtConfig(ssl): SUBDIRS += securesocketclient
qtConfig(dtls): SUBDIRS += secureudpserver secureudpclient
qtConfig(sctp): SUBDIRS += multistreamserver multistreamclient
}
diff --git a/examples/network/securesocketclient/main.cpp b/examples/network/securesocketclient/main.cpp
index e9c413577f..7cda94cc34 100644
--- a/examples/network/securesocketclient/main.cpp
+++ b/examples/network/securesocketclient/main.cpp
@@ -63,8 +63,8 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
if (!QSslSocket::supportsSsl()) {
- QMessageBox::information(0, "Secure Socket Client",
- "This system does not support SSL/TLS.");
+ QMessageBox::information(nullptr, "Secure Socket Client",
+ "This system does not support TLS.");
return -1;
}
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 79ed7746d6..6eb1075996 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -54,8 +54,6 @@
#include "ui_sslclient.h"
#include "ui_sslerrors.h"
-#include <QtCore>
-
SslClient::SslClient(QWidget *parent)
: QWidget(parent)
{
@@ -185,16 +183,17 @@ void SslClient::setupUi()
form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size());
form->sessionOutput->setHtml(tr("&lt;not connected&gt;"));
- connect(form->hostNameEdit, SIGNAL(textChanged(QString)),
- this, SLOT(updateEnabledState()));
- connect(form->connectButton, SIGNAL(clicked()),
- this, SLOT(secureConnect()));
- connect(form->sendButton, SIGNAL(clicked()),
- this, SLOT(sendData()));
+ connect(form->hostNameEdit, &QLineEdit::textChanged,
+ this, &SslClient::updateEnabledState);
+ connect(form->connectButton, &QPushButton::clicked,
+ this, &SslClient::secureConnect);
+ connect(form->sendButton, &QPushButton::clicked,
+ this, &SslClient::sendData);
padLock = new QToolButton;
padLock->setIcon(QIcon(":/encrypted.png"));
- connect(padLock, SIGNAL(clicked()), this, SLOT(displayCertificateInfo()));
+ connect(padLock, &QToolButton::clicked,
+ this, &SslClient::displayCertificateInfo);
#if QT_CONFIG(cursor)
padLock->setCursor(Qt::ArrowCursor);
@@ -223,16 +222,16 @@ void SslClient::setupSecureSocket()
socket = new QSslSocket(this);
- connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
- this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
- connect(socket, SIGNAL(encrypted()),
- this, SLOT(socketEncrypted()));
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(socketError(QAbstractSocket::SocketError)));
- connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(sslErrors(QList<QSslError>)));
- connect(socket, SIGNAL(readyRead()),
- this, SLOT(socketReadyRead()));
+ connect(socket, &QSslSocket::stateChanged,
+ this, &SslClient::socketStateChanged);
+ connect(socket, &QSslSocket::encrypted,
+ this, &SslClient::socketEncrypted);
+ connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QSslSocket::error),
+ this, &SslClient::socketError);
+ connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors),
+ this, &SslClient::sslErrors);
+ connect(socket, &QSslSocket::readyRead,
+ this, &SslClient::socketReadyRead);
}
diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp
index fcd6655ab9..e5b389f1e6 100644
--- a/examples/network/threadedfortuneserver/dialog.cpp
+++ b/examples/network/threadedfortuneserver/dialog.cpp
@@ -89,7 +89,7 @@ Dialog::Dialog(QWidget *parent)
"Run the Fortune Client example now.")
.arg(ipAddress).arg(server.serverPort()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked, this, &Dialog::close);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/threadedfortuneserver/dialog.h b/examples/network/threadedfortuneserver/dialog.h
index d127b8bfc2..2898c5311c 100644
--- a/examples/network/threadedfortuneserver/dialog.h
+++ b/examples/network/threadedfortuneserver/dialog.h
@@ -64,7 +64,7 @@ class Dialog : public QWidget
Q_OBJECT
public:
- Dialog(QWidget *parent = 0);
+ Dialog(QWidget *parent = nullptr);
private:
QLabel *statusLabel;
diff --git a/examples/network/threadedfortuneserver/fortuneserver.cpp b/examples/network/threadedfortuneserver/fortuneserver.cpp
index 791ffc71f4..73d7e22531 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.cpp
+++ b/examples/network/threadedfortuneserver/fortuneserver.cpp
@@ -74,7 +74,7 @@ void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
- connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ connect(thread, &FortuneThread::finished, thread, &FortuneThread::deleteLater);
thread->start();
}
//! [1]
diff --git a/examples/network/threadedfortuneserver/fortuneserver.h b/examples/network/threadedfortuneserver/fortuneserver.h
index dc0949bcb2..26ea3d1cbb 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.h
+++ b/examples/network/threadedfortuneserver/fortuneserver.h
@@ -60,7 +60,7 @@ class FortuneServer : public QTcpServer
Q_OBJECT
public:
- FortuneServer(QObject *parent = 0);
+ FortuneServer(QObject *parent = nullptr);
protected:
void incomingConnection(qintptr socketDescriptor) override;
diff --git a/examples/network/threadedfortuneserver/fortunethread.cpp b/examples/network/threadedfortuneserver/fortunethread.cpp
index ddde5121a3..2e730c6c8f 100644
--- a/examples/network/threadedfortuneserver/fortunethread.cpp
+++ b/examples/network/threadedfortuneserver/fortunethread.cpp
@@ -65,7 +65,7 @@ void FortuneThread::run()
QTcpSocket tcpSocket;
//! [1] //! [2]
if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
- emit error(tcpSocket.error());
+ emit error(tcpSocket.socketError());
return;
}
//! [2] //! [3]
diff --git a/examples/network/torrent/addtorrentdialog.cpp b/examples/network/torrent/addtorrentdialog.cpp
index c87110ac4a..129ad8c968 100644
--- a/examples/network/torrent/addtorrentdialog.cpp
+++ b/examples/network/torrent/addtorrentdialog.cpp
@@ -73,12 +73,12 @@ AddTorrentDialog::AddTorrentDialog(QWidget *parent)
{
ui.setupUi(this);
- connect(ui.browseTorrents, SIGNAL(clicked()),
- this, SLOT(selectTorrent()));
- connect(ui.browseDestination, SIGNAL(clicked()),
- this, SLOT(selectDestination()));
- connect(ui.torrentFile, SIGNAL(textChanged(QString)),
- this, SLOT(setTorrent(QString)));
+ connect(ui.browseTorrents, &QPushButton::clicked,
+ this, &AddTorrentDialog::selectTorrent);
+ connect(ui.browseDestination, &QPushButton::clicked,
+ this, &AddTorrentDialog::selectDestination);
+ connect(ui.torrentFile, &QLineEdit::textChanged,
+ this, &AddTorrentDialog::setTorrent);
ui.destinationFolder->setText(destinationDirectory = QDir::current().path());
ui.torrentFile->setFocus();
diff --git a/examples/network/torrent/addtorrentdialog.h b/examples/network/torrent/addtorrentdialog.h
index b5bd1df84f..00546c624c 100644
--- a/examples/network/torrent/addtorrentdialog.h
+++ b/examples/network/torrent/addtorrentdialog.h
@@ -60,7 +60,7 @@ class AddTorrentDialog : public QDialog
Q_OBJECT
public:
- AddTorrentDialog(QWidget *parent = 0);
+ AddTorrentDialog(QWidget *parent = nullptr);
QString torrentFileName() const;
QString destinationFolder() const;
diff --git a/examples/network/torrent/filemanager.h b/examples/network/torrent/filemanager.h
index 82f9983ea6..1438ed5404 100644
--- a/examples/network/torrent/filemanager.h
+++ b/examples/network/torrent/filemanager.h
@@ -70,7 +70,7 @@ class FileManager : public QThread
Q_OBJECT
public:
- FileManager(QObject *parent = 0);
+ FileManager(QObject *parent = nullptr);
virtual ~FileManager();
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 704012ef6d..331fa12944 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -60,7 +60,7 @@ class TorrentView : public QTreeWidget
{
Q_OBJECT
public:
- TorrentView(QWidget *parent = 0);
+ TorrentView(QWidget *parent = nullptr);
#if QT_CONFIG(draganddrop)
signals:
@@ -110,7 +110,7 @@ public:
};
MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent), quitDialog(0), saveChanges(false)
+ : QMainWindow(parent), quitDialog(nullptr), saveChanges(false)
{
// Initialize some static strings
QStringList headers;
@@ -147,12 +147,12 @@ MainWindow::MainWindow(QWidget *parent)
fileMenu->addAction(pauseTorrentAction);
fileMenu->addAction(removeTorrentAction);
fileMenu->addSeparator();
- fileMenu->addAction(QIcon(":/icons/exit.png"), tr("E&xit"), this, SLOT(close()));
+ fileMenu->addAction(QIcon(":/icons/exit.png"), tr("E&xit"), this, &MainWindow::close);
// Help menu
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, SLOT(about()));
- helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
+ helpMenu->addAction(tr("&About"), this, &MainWindow::about);
+ helpMenu->addAction(tr("About &Qt"), qApp, QApplication::aboutQt);
// Top toolbar
QToolBar *topBar = new QToolBar(tr("Tools"));
@@ -188,24 +188,24 @@ MainWindow::MainWindow(QWidget *parent)
#endif
// Set up connections
- connect(torrentView, SIGNAL(itemSelectionChanged()),
- this, SLOT(setActionsEnabled()));
- connect(torrentView, SIGNAL(fileDropped(QString)),
- this, SLOT(acceptFileDrop(QString)));
- connect(uploadLimitSlider, SIGNAL(valueChanged(int)),
- this, SLOT(setUploadLimit(int)));
- connect(downloadLimitSlider, SIGNAL(valueChanged(int)),
- this, SLOT(setDownloadLimit(int)));
- connect(newTorrentAction, SIGNAL(triggered()),
- this, SLOT(addTorrent()));
- connect(pauseTorrentAction, SIGNAL(triggered()),
- this, SLOT(pauseTorrent()));
- connect(removeTorrentAction, SIGNAL(triggered()),
- this, SLOT(removeTorrent()));
- connect(upActionTool, SIGNAL(triggered(bool)),
- this, SLOT(moveTorrentUp()));
- connect(downActionTool, SIGNAL(triggered(bool)),
- this, SLOT(moveTorrentDown()));
+ connect(torrentView, &TorrentView::itemSelectionChanged,
+ this, &MainWindow::setActionsEnabled);
+ connect(torrentView, &TorrentView::fileDropped,
+ this, &MainWindow::acceptFileDrop);
+ connect(uploadLimitSlider, &QSlider::valueChanged,
+ this, &MainWindow::setUploadLimit);
+ connect(downloadLimitSlider, &QSlider::valueChanged,
+ this, &MainWindow::setDownloadLimit);
+ connect(newTorrentAction, &QAction::triggered,
+ this, QOverload<>::of(&MainWindow::addTorrent));
+ connect(pauseTorrentAction, &QAction::triggered,
+ this, &MainWindow::pauseTorrent);
+ connect(removeTorrentAction, &QAction::triggered,
+ this, &MainWindow::removeTorrent);
+ connect(upActionTool, &QAction::triggered,
+ this, &MainWindow::moveTorrentUp);
+ connect(downActionTool, &QAction::triggered,
+ this, &MainWindow::moveTorrentDown);
// Load settings and start
setWindowTitle(tr("Torrent Client"));
@@ -297,7 +297,7 @@ bool MainWindow::addTorrent()
addTorrent(fileName, addTorrentDialog->destinationFolder());
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(1000, this, SLOT(saveSettings()));
+ QTimer::singleShot(1000, this, &MainWindow::saveSettings);
}
return true;
}
@@ -311,7 +311,8 @@ void MainWindow::removeTorrent()
// Stop the client.
client->disconnect();
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
+ connect(client, &TorrentClient::stopped,
+ this, &MainWindow::torrentStopped);
client->stop();
// Remove the row from the view.
@@ -379,13 +380,20 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
client->setDumpedState(resumeState);
// Setup the client connections.
- connect(client, SIGNAL(stateChanged(TorrentClient::State)), this, SLOT(updateState(TorrentClient::State)));
- connect(client, SIGNAL(peerInfoUpdated()), this, SLOT(updatePeerInfo()));
- connect(client, SIGNAL(progressUpdated(int)), this, SLOT(updateProgress(int)));
- connect(client, SIGNAL(downloadRateUpdated(int)), this, SLOT(updateDownloadRate(int)));
- connect(client, SIGNAL(uploadRateUpdated(int)), this, SLOT(updateUploadRate(int)));
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
- connect(client, SIGNAL(error(TorrentClient::Error)), this, SLOT(torrentError(TorrentClient::Error)));
+ connect(client, &TorrentClient::stateChanged,
+ this, &MainWindow::updateState);
+ connect(client, &TorrentClient::peerInfoUpdated,
+ this, &MainWindow::updatePeerInfo);
+ connect(client, &TorrentClient::progressUpdated,
+ this, &MainWindow::updateProgress);
+ connect(client, &TorrentClient::downloadRateUpdated,
+ this, &MainWindow::updateDownloadRate);
+ connect(client, &TorrentClient::uploadRateUpdated,
+ this, &MainWindow::updateUploadRate);
+ connect(client, &TorrentClient::stopped,
+ this, &MainWindow::torrentStopped);
+ connect(client, QOverload<TorrentClient::Error>::of(&TorrentClient::error),
+ this, &MainWindow::torrentError);
// Add the client to the list of downloading jobs.
Job job;
@@ -414,7 +422,7 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
client->start();
return true;
@@ -491,15 +499,15 @@ void MainWindow::setActionsEnabled()
{
// Find the view item and client for the current row, and update
// the states of the actions.
- QTreeWidgetItem *item = 0;
+ QTreeWidgetItem *item = nullptr;
if (!torrentView->selectedItems().isEmpty())
item = torrentView->selectedItems().first();
- TorrentClient *client = item ? jobs.at(torrentView->indexOfTopLevelItem(item)).client : 0;
+ TorrentClient *client = item ? jobs.at(torrentView->indexOfTopLevelItem(item)).client : nullptr;
bool pauseEnabled = client && ((client->state() == TorrentClient::Paused)
|| (client->state() > TorrentClient::Preparing));
- removeTorrentAction->setEnabled(item != 0);
- pauseTorrentAction->setEnabled(item != 0 && pauseEnabled);
+ removeTorrentAction->setEnabled(item != nullptr);
+ pauseTorrentAction->setEnabled(item && pauseEnabled);
if (client && client->state() == TorrentClient::Paused) {
pauseTorrentAction->setIcon(QIcon(":/icons/player_play.png"));
@@ -524,7 +532,7 @@ void MainWindow::updateDownloadRate(int bytesPerSecond)
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
}
@@ -538,7 +546,7 @@ void MainWindow::updateUploadRate(int bytesPerSecond)
if (!saveChanges) {
saveChanges = true;
- QTimer::singleShot(5000, this, SLOT(saveSettings()));
+ QTimer::singleShot(5000, this, &MainWindow::saveSettings);
}
}
@@ -649,7 +657,7 @@ void MainWindow::about()
about.setWindowTitle(tr("About Torrent Client"));
about.setLayout(mainLayout);
- connect(quitButton, SIGNAL(clicked()), &about, SLOT(close()));
+ connect(quitButton, &QPushButton::clicked, &about, &QDialog::close);
about.exec();
}
@@ -688,7 +696,7 @@ void MainWindow::closeEvent(QCloseEvent *)
++jobsToStop;
TorrentClient *client = job.client;
client->disconnect();
- connect(client, SIGNAL(stopped()), this, SLOT(torrentStopped()));
+ connect(client, &TorrentClient::stopped, this, &MainWindow::torrentStopped);
client->stop();
delete torrentView->takeTopLevelItem(0);
}
@@ -696,7 +704,7 @@ void MainWindow::closeEvent(QCloseEvent *)
if (jobsToStop > jobsStopped)
quitDialog->exec();
quitDialog->deleteLater();
- quitDialog = 0;
+ quitDialog = nullptr;
}
TorrentView::TorrentView(QWidget *parent)
diff --git a/examples/network/torrent/mainwindow.h b/examples/network/torrent/mainwindow.h
index 9c55b72256..78542b535b 100644
--- a/examples/network/torrent/mainwindow.h
+++ b/examples/network/torrent/mainwindow.h
@@ -71,7 +71,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
+ MainWindow(QWidget *parent = nullptr);
QSize sizeHint() const override;
const TorrentClient *clientForRow(int row) const;
diff --git a/examples/network/torrent/peerwireclient.cpp b/examples/network/torrent/peerwireclient.cpp
index 7a53c85f0c..cea4ef53fa 100644
--- a/examples/network/torrent/peerwireclient.cpp
+++ b/examples/network/torrent/peerwireclient.cpp
@@ -87,7 +87,7 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
: QTcpSocket(parent), pendingBlockSizes(0),
pwState(ChokingPeer | ChokedByPeer), receivedHandShake(false), gotPeerId(false),
sentHandShake(false), nextPacketLength(-1), pendingRequestTimer(0), invalidateTimeout(false),
- keepAliveTimer(0), torrentPeer(0)
+ keepAliveTimer(0), torrentPeer(nullptr)
{
memset(uploadSpeedData, 0, sizeof(uploadSpeedData));
memset(downloadSpeedData, 0, sizeof(downloadSpeedData));
@@ -96,21 +96,23 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
timeoutTimer = startTimer(ConnectTimeout);
peerIdString = peerId;
- connect(this, SIGNAL(readyRead()), this, SIGNAL(readyToTransfer()));
- connect(this, SIGNAL(connected()), this, SIGNAL(readyToTransfer()));
-
- connect(&socket, SIGNAL(connected()),
- this, SIGNAL(connected()));
- connect(&socket, SIGNAL(readyRead()),
- this, SIGNAL(readyRead()));
- connect(&socket, SIGNAL(disconnected()),
- this, SIGNAL(disconnected()));
- connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SIGNAL(error(QAbstractSocket::SocketError)));
- connect(&socket, SIGNAL(bytesWritten(qint64)),
- this, SIGNAL(bytesWritten(qint64)));
- connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
- this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+ connect(this, &PeerWireClient::readyRead,
+ this, &PeerWireClient::readyToTransfer);
+ connect(this, &PeerWireClient::connected,
+ this, &PeerWireClient::readyToTransfer);
+
+ connect(&socket, &QTcpSocket::connected,
+ this, &PeerWireClient::connected);
+ connect(&socket, &QTcpSocket::readyRead,
+ this, &PeerWireClient::readyRead);
+ connect(&socket, &QTcpSocket::disconnected,
+ this, &PeerWireClient::disconnected);
+ connect(&socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::error),
+ this, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error));
+ connect(&socket, &QTcpSocket::bytesWritten,
+ this, &PeerWireClient::bytesWritten);
+ connect(&socket, &QTcpSocket::stateChanged,
+ this, &PeerWireClient::socketStateChanged);
}
diff --git a/examples/network/torrent/peerwireclient.h b/examples/network/torrent/peerwireclient.h
index e03b538f63..75edf8ee77 100644
--- a/examples/network/torrent/peerwireclient.h
+++ b/examples/network/torrent/peerwireclient.h
@@ -92,7 +92,7 @@ public:
};
Q_DECLARE_FLAGS(PeerWireState, PeerWireStateFlag)
- explicit PeerWireClient(const QByteArray &peerId, QObject *parent = 0);
+ explicit PeerWireClient(const QByteArray &peerId, QObject *parent = nullptr);
void initialize(const QByteArray &infoHash, int pieceCount);
void setPeer(TorrentPeer *peer);
diff --git a/examples/network/torrent/ratecontroller.cpp b/examples/network/torrent/ratecontroller.cpp
index 96474806f5..756947b65c 100644
--- a/examples/network/torrent/ratecontroller.cpp
+++ b/examples/network/torrent/ratecontroller.cpp
@@ -62,7 +62,8 @@ RateController *RateController::instance()
void RateController::addSocket(PeerWireClient *socket)
{
- connect(socket, SIGNAL(readyToTransfer()), this, SLOT(scheduleTransfer()));
+ connect(socket, &PeerWireClient::readyToTransfer,
+ this, &RateController::scheduleTransfer);
socket->setReadBufferSize(downLimit * 4);
sockets << socket;
scheduleTransfer();
@@ -70,7 +71,8 @@ void RateController::addSocket(PeerWireClient *socket)
void RateController::removeSocket(PeerWireClient *socket)
{
- disconnect(socket, SIGNAL(readyToTransfer()), this, SLOT(scheduleTransfer()));
+ disconnect(socket, &PeerWireClient::readyToTransfer,
+ this, &RateController::scheduleTransfer);
socket->setReadBufferSize(0);
sockets.remove(socket);
}
diff --git a/examples/network/torrent/ratecontroller.h b/examples/network/torrent/ratecontroller.h
index f8bff0cc36..593a76f592 100644
--- a/examples/network/torrent/ratecontroller.h
+++ b/examples/network/torrent/ratecontroller.h
@@ -62,8 +62,7 @@ class RateController : public QObject
Q_OBJECT
public:
- inline RateController(QObject *parent = 0)
- : QObject(parent), transferScheduled(false) { }
+ using QObject::QObject;
static RateController *instance();
void addSocket(PeerWireClient *socket);
@@ -81,9 +80,9 @@ public slots:
private:
QElapsedTimer stopWatch;
QSet<PeerWireClient *> sockets;
- int upLimit;
- int downLimit;
- bool transferScheduled;
+ int upLimit = 0;
+ int downLimit = 0;
+ bool transferScheduled = false;
};
#endif
diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp
index bddf3caa1a..00f46df892 100644
--- a/examples/network/torrent/torrentclient.cpp
+++ b/examples/network/torrent/torrentclient.cpp
@@ -75,13 +75,12 @@ static const int MinimumTimeBeforeRevisit = 30;
static const int MaxUploads = 4;
static const int UploadScheduleInterval = 10000;
-class TorrentPiece {
-public:
- int index;
- int length;
+struct TorrentPiece {
QBitArray completedBlocks;
QBitArray requestedBlocks;
- bool inProgress;
+ int index = 0;
+ int length = 0;
+ bool inProgress = false;
};
class TorrentClientPrivate
@@ -227,7 +226,7 @@ void TorrentClientPrivate::callPeerConnector()
{
if (!connectingToClients) {
connectingToClients = true;
- QTimer::singleShot(10000, q, SLOT(connectToPeers()));
+ QTimer::singleShot(10000, q, &TorrentClient::connectToPeers);
}
}
@@ -235,22 +234,22 @@ TorrentClient::TorrentClient(QObject *parent)
: QObject(parent), d(new TorrentClientPrivate(this))
{
// Connect the file manager
- connect(&d->fileManager, SIGNAL(dataRead(int,int,int,QByteArray)),
- this, SLOT(sendToPeer(int,int,int,QByteArray)));
- connect(&d->fileManager, SIGNAL(verificationProgress(int)),
- this, SLOT(updateProgress(int)));
- connect(&d->fileManager, SIGNAL(verificationDone()),
- this, SLOT(fullVerificationDone()));
- connect(&d->fileManager, SIGNAL(pieceVerified(int,bool)),
- this, SLOT(pieceVerified(int,bool)));
- connect(&d->fileManager, SIGNAL(error()),
- this, SLOT(handleFileError()));
+ connect(&d->fileManager, &FileManager::dataRead,
+ this, &TorrentClient::sendToPeer);
+ connect(&d->fileManager, &FileManager::verificationProgress,
+ this, &TorrentClient::updateProgress);
+ connect(&d->fileManager, &FileManager::verificationDone,
+ this, &TorrentClient::fullVerificationDone);
+ connect(&d->fileManager, &FileManager::pieceVerified,
+ this, &TorrentClient::pieceVerified);
+ connect(&d->fileManager, &FileManager::error,
+ this, &TorrentClient::handleFileError);
// Connect the tracker client
- connect(&d->trackerClient, SIGNAL(peerListUpdated(QList<TorrentPeer>)),
- this, SLOT(addToPeerList(QList<TorrentPeer>)));
- connect(&d->trackerClient, SIGNAL(stopped()),
- this, SIGNAL(stopped()));
+ connect(&d->trackerClient, &TrackerClient::peerListUpdated,
+ this, &TorrentClient::addToPeerList);
+ connect(&d->trackerClient, &TrackerClient::stopped,
+ this, &TorrentClient::stopped);
}
TorrentClient::~TorrentClient()
@@ -840,26 +839,26 @@ void TorrentClient::setupOutgoingConnection()
void TorrentClient::initializeConnection(PeerWireClient *client)
{
- connect(client, SIGNAL(connected()),
- this, SLOT(setupOutgoingConnection()));
- connect(client, SIGNAL(disconnected()),
- this, SLOT(removeClient()));
- connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(removeClient()));
- connect(client, SIGNAL(piecesAvailable(QBitArray)),
- this, SLOT(peerPiecesAvailable(QBitArray)));
- connect(client, SIGNAL(blockRequested(int,int,int)),
- this, SLOT(peerRequestsBlock(int,int,int)));
- connect(client, SIGNAL(blockReceived(int,int,QByteArray)),
- this, SLOT(blockReceived(int,int,QByteArray)));
- connect(client, SIGNAL(choked()),
- this, SLOT(peerChoked()));
- connect(client, SIGNAL(unchoked()),
- this, SLOT(peerUnchoked()));
- connect(client, SIGNAL(bytesWritten(qint64)),
- this, SLOT(peerWireBytesWritten(qint64)));
- connect(client, SIGNAL(bytesReceived(qint64)),
- this, SLOT(peerWireBytesReceived(qint64)));
+ connect(client, &PeerWireClient::connected,
+ this, &TorrentClient::setupOutgoingConnection);
+ connect(client, &PeerWireClient::disconnected,
+ this, &TorrentClient::removeClient);
+ connect(client, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error),
+ this, &TorrentClient::removeClient);
+ connect(client, &PeerWireClient::piecesAvailable,
+ this, &TorrentClient::peerPiecesAvailable);
+ connect(client, &PeerWireClient::blockRequested,
+ this, &TorrentClient::peerRequestsBlock);
+ connect(client, &PeerWireClient::blockReceived,
+ this, &TorrentClient::blockReceived);
+ connect(client, &PeerWireClient::choked,
+ this, &TorrentClient::peerChoked);
+ connect(client, &PeerWireClient::unchoked,
+ this, &TorrentClient::peerUnchoked);
+ connect(client, &PeerWireClient::bytesWritten,
+ this, &TorrentClient::peerWireBytesWritten);
+ connect(client, &PeerWireClient::bytesReceived,
+ this, &TorrentClient::peerWireBytesReceived);
}
void TorrentClient::removeClient()
@@ -868,7 +867,7 @@ void TorrentClient::removeClient()
// Remove the host from our list of known peers if the connection
// failed.
- if (client->peer() && client->error() == QAbstractSocket::ConnectionRefusedError)
+ if (client->peer() && client->socketError() == QAbstractSocket::ConnectionRefusedError)
d->peers.removeAll(client->peer());
// Remove the client from RateController and all structures.
@@ -890,7 +889,8 @@ void TorrentClient::removeClient()
}
// Delete the client later.
- disconnect(client, SIGNAL(disconnected()), this, SLOT(removeClient()));
+ disconnect(client, &PeerWireClient::disconnected,
+ this, &TorrentClient::removeClient);
client->deleteLater();
ConnectionManager::instance()->removeConnection(client);
@@ -905,7 +905,7 @@ void TorrentClient::peerPiecesAvailable(const QBitArray &pieces)
// Find the peer in our list of announced peers. If it's there,
// then we can use the piece list into to gather statistics that
// help us decide what peers to connect to.
- TorrentPeer *peer = 0;
+ TorrentPeer *peer = nullptr;
QList<TorrentPeer *>::Iterator it = d->peers.begin();
while (it != d->peers.end()) {
if ((*it)->address == client->peerAddress() && (*it)->port == client->peerPort()) {
@@ -1163,7 +1163,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// many blocks have been requested.
QList<int> currentPieces;
bool somePiecesAreNotInProgress = false;
- TorrentPiece *lastPendingPiece = 0;
+ TorrentPiece *lastPendingPiece = nullptr;
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
while (it != d->payloads.end() && it.key() == client) {
lastPendingPiece = it.value();
@@ -1183,7 +1183,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// If all pieces are in progress, but we haven't filled up our
// block requesting quota, then we need to schedule another piece.
if (!somePiecesAreNotInProgress || client->incomingBlocks().size() > 0)
- lastPendingPiece = 0;
+ lastPendingPiece = nullptr;
TorrentPiece *piece = lastPendingPiece;
// In warmup state, all clients request blocks from the same pieces.
diff --git a/examples/network/torrent/torrentclient.h b/examples/network/torrent/torrentclient.h
index b9b88b3a07..ad77caa66c 100644
--- a/examples/network/torrent/torrentclient.h
+++ b/examples/network/torrent/torrentclient.h
@@ -58,8 +58,7 @@
class MetaInfo;
class PeerWireClient;
class TorrentClientPrivate;
-class TorrentPeer;
-class TorrentPiece;
+struct TorrentPiece;
QT_BEGIN_NAMESPACE
class QTimerEvent;
QT_END_NAMESPACE
@@ -110,7 +109,7 @@ public:
ServerError
};
- TorrentClient(QObject *parent = 0);
+ TorrentClient(QObject *parent = nullptr);
~TorrentClient();
bool setTorrent(const QString &fileName);
diff --git a/examples/network/torrent/torrentserver.cpp b/examples/network/torrent/torrentserver.cpp
index c68f33249c..215498194b 100644
--- a/examples/network/torrent/torrentserver.cpp
+++ b/examples/network/torrent/torrentserver.cpp
@@ -78,10 +78,10 @@ void TorrentServer::incomingConnection(qintptr socketDescriptor)
if (client->setSocketDescriptor(socketDescriptor)) {
if (ConnectionManager::instance()->canAddConnection() && !clients.isEmpty()) {
- connect(client, SIGNAL(infoHashReceived(QByteArray)),
- this, SLOT(processInfoHash(QByteArray)));
- connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(removeClient()));
+ connect(client, &PeerWireClient::infoHashReceived,
+ this, &TorrentServer::processInfoHash);
+ connect(client, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error),
+ this, QOverload<>::of(&TorrentServer::removeClient));
RateController::instance()->addSocket(client);
ConnectionManager::instance()->addConnection(client);
return;
@@ -104,7 +104,7 @@ void TorrentServer::processInfoHash(const QByteArray &infoHash)
PeerWireClient *peer = qobject_cast<PeerWireClient *>(sender());
for (TorrentClient *client : qAsConst(clients)) {
if (client->state() >= TorrentClient::Searching && client->infoHash() == infoHash) {
- peer->disconnect(peer, 0, this, 0);
+ peer->disconnect(peer, nullptr, this, nullptr);
client->setupIncomingConnection(peer);
return;
}
diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp
index e883317b12..a50a49fd64 100644
--- a/examples/network/torrent/trackerclient.cpp
+++ b/examples/network/torrent/trackerclient.cpp
@@ -60,14 +60,8 @@
TrackerClient::TrackerClient(TorrentClient *downloader, QObject *parent)
: QObject(parent), torrentDownloader(downloader)
{
- length = 0;
- requestInterval = 5 * 60;
- requestIntervalTimer = -1;
- firstTrackerRequest = true;
- lastTrackerRequest = false;
- firstSeeding = true;
-
- connect(&http, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpRequestDone(QNetworkReply*)));
+ connect(&http, &QNetworkAccessManager::finished,
+ this, &TrackerClient::httpRequestDone);
}
void TrackerClient::start(const MetaInfo &info)
@@ -157,8 +151,8 @@ void TrackerClient::fetchPeerList()
if (!url.userName().isEmpty()) {
uname = url.userName();
pwd = url.password();
- connect(&http, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
- this, SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
+ connect(&http, &QNetworkAccessManager::authenticationRequired,
+ this, &TrackerClient::provideAuthentication);
}
http.get(req);
}
@@ -171,8 +165,8 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
return;
}
- if (reply->error() != QNetworkReply::NoError) {
- emit connectionError(reply->error());
+ if (reply->networkError() != QNetworkReply::NoError) {
+ emit connectionError(reply->networkError());
return;
}
@@ -215,7 +209,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
// store it
peers.clear();
QVariant peerEntry = dict.value("peers");
- if (peerEntry.type() == QVariant::List) {
+ if (peerEntry.userType() == QMetaType::QVariantList) {
QList<QVariant> peerTmp = peerEntry.toList();
for (int i = 0; i < peerTmp.size(); ++i) {
TorrentPeer tmp;
diff --git a/examples/network/torrent/trackerclient.h b/examples/network/torrent/trackerclient.h
index 323fc67eba..b8c169ff22 100644
--- a/examples/network/torrent/trackerclient.h
+++ b/examples/network/torrent/trackerclient.h
@@ -69,7 +69,7 @@ class TrackerClient : public QObject
Q_OBJECT
public:
- explicit TrackerClient(TorrentClient *downloader, QObject *parent = 0);
+ explicit TrackerClient(TorrentClient *downloader, QObject *parent = nullptr);
void start(const MetaInfo &info);
void stop();
@@ -98,21 +98,19 @@ private slots:
private:
TorrentClient *torrentDownloader;
- int requestInterval;
- int requestIntervalTimer;
+ int requestInterval = 5 * 60;
+ int requestIntervalTimer = -1;
QNetworkAccessManager http;
MetaInfo metaInfo;
QByteArray trackerId;
QList<TorrentPeer> peers;
- qint64 uploadedBytes;
- qint64 downloadedBytes;
- qint64 length;
+ qint64 length = 0;
QString uname;
QString pwd;
- bool firstTrackerRequest;
- bool lastTrackerRequest;
- bool firstSeeding;
+ bool firstTrackerRequest = true;
+ bool lastTrackerRequest = false;
+ bool firstSeeding = true;
};
#endif