summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-25 22:09:36 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-25 22:09:36 (GMT)
commit11b9190a182c5f3c1055c100145b02a3975509ed (patch)
tree2c664ad92363204c320e23f9d1e6ca29505eaf2e /examples
parent03686225036ebfc5cf78e3fcc66f5810a140c7d2 (diff)
parent3671dbf34940e166b747b6f8f3f5758fd486073c (diff)
downloadQt-11b9190a182c5f3c1055c100145b02a3975509ed.zip
Qt-11b9190a182c5f3c1055c100145b02a3975509ed.tar.gz
Qt-11b9190a182c5f3c1055c100145b02a3975509ed.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts: src/declarative/graphicsitems/qdeclarativeitem.cpp
Diffstat (limited to 'examples')
-rw-r--r--examples/network/bearercloud/bearercloud.h4
-rw-r--r--examples/network/bearercloud/cloud.cpp4
-rw-r--r--examples/network/bearercloud/cloud.h8
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp9
-rw-r--r--examples/network/bearermonitor/sessionwidget.h2
-rw-r--r--examples/script/customclass/bytearrayclass.cpp17
-rw-r--r--examples/script/customclass/bytearrayclass.h2
7 files changed, 36 insertions, 10 deletions
diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h
index f09cb53..09de4c6 100644
--- a/examples/network/bearercloud/bearercloud.h
+++ b/examples/network/bearercloud/bearercloud.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <qnetworkconfigmanager.h>
+#include <QNetworkConfigurationManager>
#include <QGraphicsScene>
#include <QMap>
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
index 81e13a6..d041034 100644
--- a/examples/network/bearercloud/cloud.cpp
+++ b/examples/network/bearercloud/cloud.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -253,10 +253,12 @@ void Cloud::stateChanged(QNetworkSession::State state)
else
tooltip += tr("<b>%1</b><br>").arg(configuration.name());
+#ifndef QT_NO_NETWORKINTERFACE
const QNetworkInterface interface = session->interface();
if (interface.isValid())
tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName());
tooltip += tr("<br>Id: %1").arg(configuration.identifier());
+#endif
const QString bearerName = configuration.bearerName();
if (!bearerName.isEmpty())
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
index 38f8aff..9e25fb6 100644
--- a/examples/network/bearercloud/cloud.h
+++ b/examples/network/bearercloud/cloud.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include <qnetworkconfiguration.h>
-#include <qnetworksession.h>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
#include <QGraphicsItem>
QT_USE_NAMESPACE
@@ -56,7 +56,7 @@ class Cloud : public QObject, public QGraphicsItem
Q_INTERFACES(QGraphicsItem)
public:
- Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
+ explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
~Cloud();
enum { Type = UserType + 1 };
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
index 46ffb20..655c1ac 100644
--- a/examples/network/bearermonitor/sessionwidget.cpp
+++ b/examples/network/bearermonitor/sessionwidget.cpp
@@ -47,6 +47,13 @@ SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *paren
{
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)),
@@ -102,8 +109,10 @@ void SessionWidget::updateSession()
bearer->setText(c.bearerName());
}
+#ifndef QT_NO_NETWORKINTERFACE
interfaceName->setText(session->interface().humanReadableName());
interfaceGuid->setText(session->interface().name());
+#endif
}
void SessionWidget::openSession()
diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h
index cc9c067..ae5cc96 100644
--- a/examples/network/bearermonitor/sessionwidget.h
+++ b/examples/network/bearermonitor/sessionwidget.h
@@ -53,7 +53,7 @@ class SessionWidget : public QWidget, public Ui_SessionWidget
Q_OBJECT
public:
- SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
+ explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
~SessionWidget();
void timerEvent(QTimerEvent *);
diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp
index 1dbf2d4..239b4b4 100644
--- a/examples/script/customclass/bytearrayclass.cpp
+++ b/examples/script/customclass/bytearrayclass.cpp
@@ -148,13 +148,13 @@ void ByteArrayClass::setProperty(QScriptValue &object,
if (!ba)
return;
if (name == length) {
- ba->resize(value.toInt32());
+ resize(*ba, value.toInt32());
} else {
qint32 pos = id;
if (pos < 0)
return;
if (ba->size() <= pos)
- ba->resize(pos + 1);
+ resize(*ba, pos + 1);
(*ba)[pos] = char(value.toInt32());
}
}
@@ -194,10 +194,13 @@ QScriptValue ByteArrayClass::constructor()
return ctor;
}
+//! [10]
QScriptValue ByteArrayClass::newInstance(int size)
{
+ engine()->reportAdditionalMemoryCost(size);
return newInstance(QByteArray(size, /*ch=*/0));
}
+//! [10]
//! [1]
QScriptValue ByteArrayClass::newInstance(const QByteArray &ba)
@@ -235,6 +238,16 @@ void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba)
ba = qvariant_cast<QByteArray>(obj.data().toVariant());
}
+//! [9]
+void ByteArrayClass::resize(QByteArray &ba, int newSize)
+{
+ int oldSize = ba.size();
+ ba.resize(newSize);
+ if (newSize > oldSize)
+ engine()->reportAdditionalMemoryCost(newSize - oldSize);
+}
+//! [9]
+
ByteArrayClassPropertyIterator::ByteArrayClassPropertyIterator(const QScriptValue &object)
diff --git a/examples/script/customclass/bytearrayclass.h b/examples/script/customclass/bytearrayclass.h
index f185754..3f7ce22 100644
--- a/examples/script/customclass/bytearrayclass.h
+++ b/examples/script/customclass/bytearrayclass.h
@@ -82,6 +82,8 @@ private:
static QScriptValue toScriptValue(QScriptEngine *eng, const QByteArray &ba);
static void fromScriptValue(const QScriptValue &obj, QByteArray &ba);
+ void resize(QByteArray &ba, int newSize);
+
QScriptString length;
QScriptValue proto;
QScriptValue ctor;