From 0948de26bca9a68a354b436895bdf9e2db9c4288 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 8 Jun 2010 04:40:42 +1000 Subject: initial connman bearer backend. still needs work, debugging, additional threading support, and probably refactoring. This includes a connman dbus service wrapper that has more functionality than is needed by the bearer backend but still missing some 'set' functionality for a complete connman wrapper. Developed with wifi/desktop on 'lucid' kubuntu, using the connman available at http://ppa.launchpad.net/indicator-network-developers/ppa/ubuntu --- src/plugins/bearer/bearer.pro | 3 +- src/plugins/bearer/connman/connman.pro | 19 + src/plugins/bearer/connman/main.cpp | 93 ++ src/plugins/bearer/connman/qconnmanengine.cpp | 651 ++++++++++++ src/plugins/bearer/connman/qconnmanengine.h | 144 +++ .../bearer/connman/qconnmanservice_linux.cpp | 1038 ++++++++++++++++++++ .../bearer/connman/qconnmanservice_linux_p.h | 377 +++++++ 7 files changed, 2324 insertions(+), 1 deletion(-) create mode 100644 src/plugins/bearer/connman/connman.pro create mode 100644 src/plugins/bearer/connman/main.cpp create mode 100644 src/plugins/bearer/connman/qconnmanengine.cpp create mode 100644 src/plugins/bearer/connman/qconnmanengine.h create mode 100644 src/plugins/bearer/connman/qconnmanservice_linux.cpp create mode 100644 src/plugins/bearer/connman/qconnmanservice_linux_p.h diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index f95e8af..6d8f7f2 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -4,7 +4,8 @@ contains(QT_CONFIG, dbus) { contains(QT_CONFIG, icd) { SUBDIRS += icd } else { - SUBDIRS += networkmanager generic + SUBDIRS += generic + !mac:SUBDIRS += connman networkmanager } } diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro new file mode 100644 index 0000000..4be752b --- /dev/null +++ b/src/plugins/bearer/connman/connman.pro @@ -0,0 +1,19 @@ +TARGET = qconnmanbearer +include(../../qpluginbase.pri) + +QT = core network dbus + +HEADERS += qconnmanservice_linux_p.h \ + qconnmanengine.h \ + ../qnetworksession_impl.h \ + ../qbearerengine_impl.h + +SOURCES += main.cpp \ + qconnmanservice_linux.cpp \ + qconnmanengine.cpp \ + ../qnetworksession_impl.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target + diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp new file mode 100644 index 0000000..d483cf0 --- /dev/null +++ b/src/plugins/bearer/connman/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qconnmanengine.h" + +#include + +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanEnginePlugin : public QBearerEnginePlugin +{ +public: + QConnmanEnginePlugin(); + ~QConnmanEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QConnmanEnginePlugin::QConnmanEnginePlugin() +{ +} + +QConnmanEnginePlugin::~QConnmanEnginePlugin() +{ +} + +QStringList QConnmanEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("connman"); +} + +QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("connman")) { + QConnmanEngine *engine = new QConnmanEngine; + if (engine->connmanAvailable()) + return engine; + else + delete engine; + } + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin) +Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin) + +QT_END_NAMESPACE + +#endif +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp new file mode 100644 index 0000000..e4cab92 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -0,0 +1,651 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qconnmanengine.h" +#include "qconnmanservice_linux_p.h" +#include "../qnetworksession_impl.h" + +#include + +#include + +#include + +#include +#include +//#include +#include +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +QConnmanEngine::QConnmanEngine(QObject *parent) +: QBearerEngineImpl(parent), + connmanManager(new QConnmanManagerInterface(this)) +{ +// qWarning() << Q_FUNC_INFO; +} + +QConnmanEngine::~QConnmanEngine() +{ +} + +bool QConnmanEngine::connmanAvailable() const +{ + QMutexLocker locker(&mutex); + return connmanManager->isValid(); +} + +void QConnmanEngine::initialize() +{ + connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(propertyChangedContext(QString,QString,QDBusVariant))); + + foreach(const QString techPath, connmanManager->getTechnologies()) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(techPath, this); + + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + + foreach(const QString devicePath,tech->getDevices()) { + QConnmanDeviceInterface *dev; + dev = new QConnmanDeviceInterface(devicePath); + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + deviceMap.insert(techPath,QStringList() << devicePath); + } + } + // Get current list of access points. + getConfigurations(); +} + +QList QConnmanEngine::getConfigurations() +{ + QMutexLocker locker(&mutex); + foundConfigurations.clear(); + getNetworkListing(); + return foundConfigurations; +} + +void QConnmanEngine::getNetworkListing() +{ + QMutexLocker locker(&mutex); + + QMapIterator i(deviceMap); + while(i.hasNext()) { + i.next(); + QConnmanDeviceInterface dev(i.value().at(0)); + if(dev.isValid()) { + foreach(const QString network,dev.getNetworks()) { + addNetworkConfiguration(network); + } + } + } +} + +void QConnmanEngine::doRequestUpdate() +{ + getConfigurations(); + emit updateCompleted(); +} + +QString QConnmanEngine::getInterfaceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + + QString servicePath = serviceFromId(id); + QString netPath = getNetworkForService(servicePath); + + QMapIterator i(deviceMap); + while(i.hasNext()) { + i.next(); + if(i.value().count() > 0) { + QConnmanDeviceInterface dev(i.value().at(0)); + foreach(const QString network, dev.getNetworks()) { + if(network == netPath) { + return dev.getInterface(); + } + } + } + } + return QString(); +} + +bool QConnmanEngine::hasIdentifier(const QString &id) +{ + QMutexLocker locker(&mutex); + return accessPointConfigurations.contains(id); +} + +QString QConnmanEngine::bearerName(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(serviceFromId(id)); + QString connectionType = serv.getType(); + + if (connectionType == "ethernet") + return QLatin1String("Ethernet"); + else if (connectionType == "wifi") + return QLatin1String("WLAN"); + else if (connectionType == "cellular") { + QString mode = serv.getMode(); + if(mode == "gprs" || mode == "edge") { + return QLatin1String("2G"); + } else if(mode == "umts") { + return QLatin1String("WCDMA"); + } + } + else if (connectionType == "wimax") + return QLatin1String("WIMAX"); + + return QString(); +} + +void QConnmanEngine::connectToId(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(serviceFromId(id)); + if(!serv.isValid()) { + emit connectionError(id, InterfaceLookupError); + } else { + serv.connect(); + } +} + +void QConnmanEngine::disconnectFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(serviceFromId(id)); + if(!serv.isValid()) { + emit connectionError(id, DisconnectionError); + } else { + serv.disconnect(); + } +} + +void QConnmanEngine::requestUpdate() +{ + QMutexLocker locker(&mutex); + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); +} + +QString QConnmanEngine::serviceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + foreach(QString service, connmanManager->getServices()) { + if (id == QString::number(qHash(service))) + return service; + } + + return QString(); +} + +QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) +{ + QMutexLocker locker(&mutex); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + return QNetworkSession::Connected; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } + + return QNetworkSession::Invalid; +} + +quint64 QConnmanEngine::bytesWritten(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); + if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&tx); + in >> result; + tx.close(); + } + return result; +} + +quint64 QConnmanEngine::bytesReceived(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); + if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&rx); + in >> result; + rx.close(); + } + return result; +} + +quint64 QConnmanEngine::startTime(const QString &/*id*/) +{ + // TODO + QMutexLocker locker(&mutex); + if (activeTime.isNull()) { + return 0; + } + return activeTime.secsTo(QDateTime::currentDateTime()); +} + +QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming | + QNetworkConfigurationManager::DataStatistics | + QNetworkConfigurationManager::CanStartAndStopInterfaces; +} + +QNetworkSessionPrivate *QConnmanEngine::createSessionBackend() +{ + return new QNetworkSessionPrivateImpl; +} + +QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration() +{ + return QNetworkConfigurationPrivatePointer(); +} + + +QString QConnmanEngine::getServiceForNetwork(const QString &netPath) +{ + QMutexLocker locker(&mutex); + QConnmanNetworkInterface network(netPath, this); + foreach(QString service,connmanManager->getServices()) { + QConnmanServiceInterface serv(service,this); + if(serv.getName() == network.getName() + && network.getSignalStrength() == serv.getSignalStrength()) { + return service; + } + } + return QString(); +} + +QString QConnmanEngine::getNetworkForService(const QString &servPath) +{ + QMutexLocker locker(&mutex); + QMap map; + + QMapIterator i(deviceMap); + while(i.hasNext()) { + i.next(); + if(i.value().count() > 0) { + QConnmanDeviceInterface device(i.value().at(0)); + QMap netMapStrength; + + foreach(const QString netPath, knownNetworks[device.getType()]) { + QConnmanNetworkInterface network1(netPath, this); + QString netname = network1.getName(); + qint32 sigStrength = network1.getSignalStrength(); + + if(netMapStrength.contains(netname) + && netMapStrength.value(netname) < sigStrength) { + netMapStrength.remove(netname); + map.remove(netname); + } + netMapStrength.insert(netname, sigStrength); + map.insert(netname,netPath); + } + } + } + + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servPath); + if(map.contains(serv->getName())) { + return map.value(serv->getName()); + } + return QString(); +} + +void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ +// qDebug() << __FUNCTION__ << path << item; + QMutexLocker locker(&mutex); + + if(item == "Technologies") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList newlist = qdbus_cast(arg); + if(newlist.count() > 0) { + QMap oldtech = technologies; + + foreach(const QString listPath, newlist) { + if(!oldtech.contains(listPath)) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(listPath,this); + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + technologies.insert(listPath, tech); + } + } + + foreach(const QString old, oldtech.keys()) { + if(!newlist.contains(old)) { + QConnmanTechnologyInterface *tech = oldtech.value(old); + disconnect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + + technologies.remove(old); + getNetworkListing(); + } + } + } + } +} + +void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ +// qDebug() << __FUNCTION__ << path << item; + QMutexLocker locker(&mutex); + if(item == "State") { + configurationChange(QString::number(qHash(path))); + if(value.variant().toString() == "failure") { + QConnmanServiceInterface serv(path); + qDebug() <<__FUNCTION__ <<"Error" << serv.getError(); + emit connectionError(QString::number(qHash(path)), ConnectError); + } + } +} + +void QConnmanEngine::networkPropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &/*value*/) +{ +// qDebug() << __FUNCTION__ << path << item; + QMutexLocker locker(&mutex); +} + +void QConnmanEngine::devicePropertyChangedContext(const QString &path,const QString &item,const QDBusVariant &value) +{ +// qDebug() << __FUNCTION__ << path << item << value.variant(); + QMutexLocker locker(&mutex); + if(item == "Networks") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList remainingNetworks = qdbus_cast(arg); + + QConnmanDeviceInterface dev(path); + QStringList oldnetworks = knownNetworks[dev.getType()]; + if(remainingNetworks.count() != oldnetworks.count()) { + + foreach(const QString netPath, remainingNetworks) { + if(!oldnetworks.contains(netPath)) { + addNetworkConfiguration(netPath); + } + } + + foreach(const QString netPath, oldnetworks) { + QString servicePath = getServiceForNetwork(netPath); + if(!remainingNetworks.contains(netPath)) { + if(servicePath.isEmpty()) { + removeConfiguration(netPath); + } else { + if(!remainingNetworks.contains(servicePath)) { + removeConfiguration(QString::number(qHash(servicePath))); + } + } + } + } + } + } +} + +void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value) +{ +// qWarning() << __FUNCTION__ << path << item << value.variant(); +// if(item == "Devices") { +// QDBusArgument arg = qvariant_cast(value.variant()); +// QStringList list = qdbus_cast(arg); +// } + if(item == "State") { + if(value.variant().toString() == "enabled") { + } + if(value.variant().toString() == "offline") { + deviceMap.remove(path); + } + if(value.variant().toString() == "available") { + QConnmanTechnologyInterface tech(connmanManager->getPathForTechnology(path)); + foreach(const QString devPath, tech.getDevices()) { + QConnmanDeviceInterface *dev; + dev = new QConnmanDeviceInterface(devPath,this); + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + + deviceMap.insert(path,QStringList() << devPath); + } + } + } +} + +void QConnmanEngine::configurationChange(const QString &id) +{ + QMutexLocker locker(&mutex); + bool changed = false; + + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + QString servicePath = serviceFromId(id); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + QString networkName = serv->getName(); + QNetworkConfiguration::StateFlags curState = getStateForService(servicePath); + + ptr->mutex.lock(); + + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } + + if (ptr->name != networkName) { + ptr->name = networkName; + changed = true; + } + + if (ptr->state != curState) { + ptr->state = curState; + changed = true; + } + + ptr->mutex.unlock(); + + if (changed) { + locker.unlock(); + emit configurationChanged(ptr); + locker.relock(); + } + + } + locker.unlock(); + emit updateCompleted(); +} + +QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service) +{ + qWarning() << __FUNCTION__; + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(service); + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; + if(serv.isFavorite()) { + flag = ( flag | QNetworkConfiguration::Discovered); + } else { + flag = QNetworkConfiguration::Undefined; + } + + if(serv.getState() == "ready" || serv.getState() == "online") { + flag = ( flag | QNetworkConfiguration::Active); + } + + return flag; +} + +QString QConnmanEngine::typeToBearer(const QString &type) +{ + QMutexLocker locker(&mutex); + if(type == "wifi") + return "WLAN"; + if(type == "ethernet") + return "Ethernet"; + if(type == "bluetooth") + return "Bluetooth"; + if(type == "cellular") { + return "Cellular"; + // not handled: CDMA2000 HSPA + } + if(type == "wimax") + return "WiMax"; +// if(type == "gps") +// if(type == "vpn") + + return "Unknown"; +} + +void QConnmanEngine::removeConfiguration(const QString &netpath) +{ + QMutexLocker locker(&mutex); + const QString id = QString::number(qHash(netpath)); + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); + QConnmanDeviceInterface device(netpath.section("/",0,5),this); + locker.unlock(); + knownNetworks[device.getType()].removeAll(netpath); + emit configurationRemoved(ptr); + locker.relock(); + } +} + +void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) +{ +// qWarning() << __FUNCTION__ << networkPath; + QMutexLocker locker(&mutex); + + QConnmanNetworkInterface *network; + network = new QConnmanNetworkInterface(networkPath, this); + QString servicePath = getServiceForNetwork(networkPath); + QConnmanServiceInterface *serv; + + QString id; + if(servicePath.isEmpty()) { + id = QString::number(qHash(networkPath)); + } else { + id = QString::number(qHash(servicePath)); + } + if (!accessPointConfigurations.contains(id)) { + connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + + QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); + + QString networkName = network->getName(); + + if(networkName.isEmpty()) + networkName = "Hidden Network"; + + QString bearerName; + + QConnmanDeviceInterface device(networkPath.section("/",0,5),this); + if(servicePath.isEmpty()) { + bearerName = typeToBearer(device.getType()); + } else { + serv = new QConnmanServiceInterface(servicePath,this); + bearerName = typeToBearer(serv->getType()); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + } + knownNetworks[device.getType()]<< networkPath; + + if(bearerName == "Cellular") { + QString mode = serv->getMode(); + if(mode == "gprs" || mode == "edge") { + bearerName = "2G"; + } else if(mode == "umts") { + bearerName = "WCDMA"; + } + networkName = serv->getAPN(); + } + + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + cpPriv->bearer = bearerName; + + if(network->getWifiSecurity() == "none") { + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + } else { + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + } + + if(servicePath.isEmpty()) + cpPriv->state = QNetworkConfiguration::Undefined; + else + cpPriv->state = getStateForService(servicePath); + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + foundConfigurations.append(cpPriv); + locker.unlock(); + emit configurationAdded(ptr); + locker.relock(); + } +} + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h new file mode 100644 index 0000000..849d8c9 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCONNMANENGINE_P_H +#define QCONNMANENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "../qbearerengine_impl.h" + +#include "qconnmanservice_linux_p.h" + +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanEngine : public QBearerEngineImpl +{ + Q_OBJECT + +public: + QConnmanEngine(QObject *parent = 0); + ~QConnmanEngine(); + + bool connmanAvailable() const; + + virtual QString getInterfaceFromId(const QString &id); + bool hasIdentifier(const QString &id); + + virtual QString bearerName(const QString &id); + + virtual void connectToId(const QString &id); + virtual void disconnectFromId(const QString &id); + + Q_INVOKABLE void initialize(); + Q_INVOKABLE void requestUpdate(); + + QNetworkSession::State sessionStateForId(const QString &id); + QNetworkSessionPrivate *createSessionBackend(); + + virtual quint64 bytesWritten(const QString &id); + virtual quint64 bytesReceived(const QString &id); + virtual quint64 startTime(const QString &id); + + + virtual QNetworkConfigurationManager::Capabilities capabilities() const; + virtual QNetworkConfigurationPrivatePointer defaultConfiguration(); + + void configurationChange(const QString &id); + QList getConfigurations(); + + +private Q_SLOTS: + + void doRequestUpdate(); + void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void networkPropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void devicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &); + +private: + QConnmanManagerInterface *connmanManager; + + QList foundConfigurations; + void getNetworkListing(); + + QString getServiceForNetwork(const QString &network); + QString getNetworkForService(const QString &network); + + QString serviceFromId(const QString &id); + QString networkFromId(const QString &id); + + QNetworkConfiguration::StateFlags getStateForService(const QString &service); + QString typeToBearer(const QString &type); + + void removeConfiguration(const QString &path); + void addNetworkConfiguration(const QString &worknetPath); + QDateTime activeTime; + + + QMap technologies; + QMap knownNetworks; + QMap deviceMap; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + +#endif + diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp new file mode 100644 index 0000000..ca76ffd --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -0,0 +1,1038 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qconnmanservice_linux_p.h" + + +QT_BEGIN_NAMESPACE +static QDBusConnection dbusConnection = QDBusConnection::systemBus(); + + +QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + CONNMAN_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanManagerInterface::~QConnmanManagerInterface() +{ +} + +void QConnmanManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(stateChanged(QString))) { + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("StateChanged"), + this,SIGNAL(stateChanged(const QString&)))) { + qWarning() << "StateChanged not connected"; + + } + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QConnmanManagerInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << "does not contain" << property; + } + return var; +} + +QVariantMap QConnmanManagerInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QString QConnmanManagerInterface::getState() +{ + QDBusReply reply = this->call("GetState"); + return reply.value(); +} + +bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value) +{ + Q_UNUSED(name); + Q_UNUSED(value); + return false; +} + +QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/) +{ + return QDBusObjectPath(); +} + +bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/) +{ + return false; +} + +bool QConnmanManagerInterface::requestScan(const QString &type) +{ + QDBusReply reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type)); + + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::enableTechnology(const QString &type) +{ + QDBusReply > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::disableTechnology(const QString &type) +{ + QDBusReply > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map) +{ + QDBusReply reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + + } + return reply; +} + +void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/) +{ +} + +void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/) +{ +} + +void QConnmanManagerInterface::registerCounter(QDBusObjectPath /*path*/, quint32 /*interval*/) +{ +} + +void QConnmanManagerInterface::unregisterCounter(QDBusObjectPath /*path*/) +{ +} + +QString QConnmanManagerInterface::requestSession(const QString &bearerName) +{ + QDBusReply > reply = this->call(QLatin1String("RequestSession"), QVariant::fromValue(bearerName)); + return QString(); +} + +void QConnmanManagerInterface::releaseSession() +{ + QDBusReply > reply = this->call(QLatin1String("ReleaseSession")); +} + + +QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service) +{ + QDBusReply reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + } + return reply; +} + +// properties + +QStringList QConnmanManagerInterface::getAvailableTechnologies() +{ + QVariant var = getProperty("AvailableTechnologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getEnabledTechnologies() +{ + QVariant var = getProperty("EnabledTechnologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getConnectedTechnologies() +{ + QVariant var = getProperty("ConnectedTechnologies"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getDefaultTechnology() +{ + QVariant var = getProperty("DefaultTechnology"); + return qdbus_cast(var); +} + +bool QConnmanManagerInterface::getOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getActiveProfile() +{ + QVariant var = getProperty("ActiveProfile"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getProfiles() +{ + QVariant var = getProperty("Profiles"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getTechnologies() +{ + QVariant var = getProperty("Technologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getPathForTechnology(const QString &name) +{ + foreach(const QString path, getTechnologies()) { + if(path.contains(name)) { + return path; + } + } + return ""; +} + +QConnmanNetworkInterface::QConnmanNetworkInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_NETWORK_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanNetworkInterface::~QConnmanNetworkInterface() +{ +} + +void QConnmanNetworkInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_NETWORK_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))) ) { + qWarning() << "network properties not connected"; + } + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_NETWORK_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanNetworkInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + + } +} + +QVariantMap QConnmanNetworkInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanNetworkInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +//properties + +QString QConnmanNetworkInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +bool QConnmanNetworkInterface::isConnected() +{ + QVariant var = getProperty("Connected"); + return qdbus_cast(var); +} + +quint8 QConnmanNetworkInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getDevice() +{ + QVariant var = getProperty("Device"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getWifiSsid() +{ + QVariant var = getProperty("WiFi.SSID"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getWifiMode() +{ + QVariant var = getProperty("WiFi.Mode"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getWifiSecurity() +{ + QVariant var = getProperty("WiFi.Security"); + return qdbus_cast(var); +} + +QString QConnmanNetworkInterface::getWifiPassphrase() +{ + QVariant var = getProperty("WiFi.Passphrase"); + return qdbus_cast(var); +} + + +////////////////////////// + +QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_PROFILE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanProfileInterface::~QConnmanProfileInterface() +{ +} + +void QConnmanProfileInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_PROFILE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } +} + +void QConnmanProfileInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QVariant))) { + + } +} + +QVariantMap QConnmanProfileInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanProfileInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() <<__FUNCTION__<< "Could not find" << property; + } + return var; +} + +// properties +QString QConnmanProfileInterface::getName() +{ + + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +bool QConnmanProfileInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QStringList QConnmanProfileInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + +/////////////////////////// +QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_SERVICE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanServiceInterface::~QConnmanServiceInterface() +{ +} + +void QConnmanServiceInterface::connectNotify(const char *signal) +{ +// qWarning() << __FUNCTION__ << signal << this->path(); + + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanServiceInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanServiceInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanServiceInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { +// qDebug() <<__FUNCTION__<< "Could not find" << property; + } + return var; +} + +// clearProperty +void QConnmanServiceInterface::connect() +{ + QDBusReply reply = this->call(QLatin1String("Connect")); +} + +void QConnmanServiceInterface::disconnect() +{ + QDBusReply reply = this->call(QLatin1String("Disconnect")); +} + +void QConnmanServiceInterface::remove() +{ + QDBusReply reply = this->call(QLatin1String("Remove")); +} + +// void moveBefore(QDBusObjectPath &service); +// void moveAfter(QDBusObjectPath &service); + +// properties +QString QConnmanServiceInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getError() +{ + QVariant var = getProperty("Error"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMode() +{ + QVariant var = getProperty("Mode"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getSecurity() +{ + QVariant var = getProperty("Security"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getPassphrase() +{ + QVariant var = getProperty("Passphrase"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isPassphraseRequired() +{ + QVariant var = getProperty("PassphraseRequired"); + return qdbus_cast(var); +} + +quint8 QConnmanServiceInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isFavorite() +{ + QVariant var = getProperty("Favorite"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isImmutable() +{ + QVariant var = getProperty("Immutable"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isAutoConnect() +{ + QVariant var = getProperty("AutoConnect"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isSetupRequired() +{ + QVariant var = getProperty("SetupRequired"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getAPN() +{ + QVariant var = getProperty("APN"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMCC() +{ + QVariant var = getProperty("MCC"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMNC() +{ + QVariant var = getProperty("MNC"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isRoaming() +{ + QVariant var = getProperty("Roaming"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getNameservers() +{ + QVariant var = getProperty("NameServers"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getDomains() +{ + QVariant var = getProperty("Domains"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4() +{ + QVariant var = getProperty("IPv4"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4Configuration() +{ + QVariant var = getProperty("IPv4.Configuration"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getProxy() +{ + QVariant var = getProperty("Proxy"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getEthernet() +{ + QVariant var = getProperty("Ethernet"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + + +////////////////////////// +QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_TECHNOLOGY_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanTechnologyInterface::~QConnmanTechnologyInterface() +{ +} + +void QConnmanTechnologyInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanTechnologyInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanTechnologyInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanTechnologyInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +// properties +QString QConnmanTechnologyInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast(var); +} + +QString QConnmanTechnologyInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QConnmanTechnologyInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + + +QStringList QConnmanTechnologyInterface::getDevices() +{ + QVariant var = getProperty("Devices"); + return qdbus_cast(var); +} + + +////////////////////////////////// +QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_AGENT_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanAgentInterface::~QConnmanAgentInterface() +{ +} + +void QConnmanAgentInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { +// dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), +// this->path(), +// QLatin1String(CONNMAN_NETWORK_INTERFACE), +// QLatin1String("PropertyChanged"), +// this,SIGNAL(propertyChanged(const QString &, QVariant &))); + } +} + +void QConnmanAgentInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QDBusVariant))) { + + } +} + + +void QConnmanAgentInterface::release() +{ +} + +void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/) +{ +} + +//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields) +//{ +//} + +void QConnmanAgentInterface::cancel() +{ +} + + +///////////////////////////////////////// + +QConnmanDeviceInterface::QConnmanDeviceInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_DEVICE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanDeviceInterface::~QConnmanDeviceInterface() +{ +} + +void QConnmanDeviceInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_DEVICE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_DEVICE_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanDeviceInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanDeviceInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +bool QConnmanDeviceInterface::setProperty(const QString &name, const QDBusVariant &value) +{ + +// QList args; + qWarning() << __FUNCTION__ << name << value.variant(); +// args << qVariantFromValue(name); +// args << qVariantFromValue(value); + + QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, qVariantFromValue(value)); +qWarning() << reply.errorMessage(); + + return true; +} + +void QConnmanDeviceInterface::scan() +{ + QDBusReply reply = this->call(QLatin1String("ProposeScan")); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + } +} + +QVariant QConnmanDeviceInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +//properties +QString QConnmanDeviceInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast(var); +} + +QString QConnmanDeviceInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QConnmanDeviceInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + +QString QConnmanDeviceInterface::getInterface() +{ + QVariant var = getProperty("Interface"); + return qdbus_cast(var); +} + +bool QConnmanDeviceInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast(var); +} + +quint16 QConnmanDeviceInterface::getScanInterval() +{ + QVariant var = getProperty("ScanInterval"); + return qdbus_cast(var); +} + +bool QConnmanDeviceInterface::setScanInterval(const QString & interval) +{ +// QList args; +// args << qVariantFromValue(name) +// << value.variant(); + +// QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); + + return setProperty("ScanInterval", QDBusVariant(interval)); +} + +bool QConnmanDeviceInterface::isScanning() +{ + QVariant var = getProperty("Scanning"); + return qdbus_cast(var); +} + +QStringList QConnmanDeviceInterface::getNetworks() +{ + QVariant var = getProperty("Networks"); + return qdbus_cast(var); +} + +bool QConnmanDeviceInterface::setEnabled(bool powered) +{ + QList args; + args << qVariantFromValue(QString("Powered")) + << qVariantFromValue(QDBusVariant(powered)); + + QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); + qWarning() << reply.errorMessage() << reply.errorName(); + return true; +} + +QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent) + : QObject(parent) +{ +} + +QConnmanDBusHelper::~QConnmanDBusHelper() +{ +} + +void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) +{ + QDBusMessage msg = this->message(); +// qWarning() << sender(); + // qWarning() << msg.interface() << msg.path() << item << var.variant() <<"\n"; + Q_EMIT propertyChangedContext(msg.path() ,item, var); +} + +///////////////// +QT_END_NAMESPACE diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h new file mode 100644 index 0000000..9475296 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -0,0 +1,377 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCONNMANSERVICE_H +#define QCONNMANSERVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifndef __CONNMAN_DBUS_H + +#define CONNMAN_SERVICE "org.moblin.connman" +#define CONNMAN_PATH "/org/moblin/connman" + +#define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug" +#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error" +#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent" +#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter" + +#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager" +#define CONNMAN_MANAGER_PATH "/" + +#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task" +#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" +#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" +#define CONNMAN_DEVICE_INTERFACE CONNMAN_SERVICE ".Device" +#define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network" +#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider" +#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology" +#endif + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + + +QT_BEGIN_NAMESPACE + +class QConnmanManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanManagerInterface( QObject *parent = 0); + ~QConnmanManagerInterface(); + + QDBusObjectPath path() const; + + QVariantMap getProperties(); + bool setProperty(const QString &name, const QDBusVariant &value); + QDBusObjectPath createProfile(const QString &name); + bool removeProfile(QDBusObjectPath path); + bool requestScan(const QString &type); + bool enableTechnology(const QString &type); + bool disableTechnology(const QString &type); + QDBusObjectPath connectService(QVariantMap &map); + void registerAgent(QDBusObjectPath &path); + void unregisterAgent(QDBusObjectPath path); + void registerCounter(QDBusObjectPath path, quint32 interval); + void unregisterCounter(QDBusObjectPath path); + + QString requestSession(const QString &bearerName); + void releaseSession(); + + // properties + QString getState(); + QStringList getAvailableTechnologies(); + QStringList getEnabledTechnologies(); + QStringList getConnectedTechnologies(); + QString getDefaultTechnology(); + bool getOfflineMode(); + QString getActiveProfile(); + QStringList getProfiles(); + QStringList getTechnologies(); + QStringList getServices(); + QDBusObjectPath lookupService(const QString &); + + QString getPathForTechnology(const QString &tech); + + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void stateChanged(const QString &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QConnmanNetworkInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanNetworkInterface(const QString &dbusPathName, QObject *parent = 0); + ~QConnmanNetworkInterface(); + + QVariantMap getProperties(); + + //properties + QString getAddress(); + QString getName(); + bool isConnected(); + quint8 getSignalStrength(); + QString getDevice(); + QString getWifiSsid(); + QString getWifiMode(); + QString getWifiSecurity(); + QString getWifiPassphrase(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanProfileInterfacePrivate; +class QConnmanProfileInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanProfileInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanProfileInterface(); + + QVariantMap getProperties(); +// properties + QString getName(); + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); +private: + QConnmanProfileInterfacePrivate *d; + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanServiceInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanServiceInterface(); + + QVariantMap getProperties(); + // clearProperty + void connect(); + void disconnect(); + void remove(); + // void moveBefore(QDBusObjectPath &service); + // void moveAfter(QDBusObjectPath &service); + +// properties + QString getState(); + QString getError(); + QString getName(); + QString getType(); + QString getMode(); + QString getSecurity(); + QString getPassphrase(); + bool isPassphraseRequired(); + quint8 getSignalStrength(); + bool isFavorite(); + bool isImmutable(); + bool isAutoConnect(); + bool isSetupRequired(); + QString getAPN(); + QString getMCC(); + QString getMNC(); + bool isRoaming(); + QStringList getNameservers(); + QStringList getDomains(); + QVariantMap getIPv4(); + QVariantMap getIPv4Configuration(); + QVariantMap getProxy(); + QVariantMap getEthernet(); + + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanTechnologyInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanTechnologyInterface(); + + QVariantMap getProperties(); +// properties + QString getState(); + QString getName(); + QString getType(); + + QStringList getDevices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + +class QConnmanAgentInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanAgentInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanAgentInterface(); + + void release(); + void reportError(QDBusObjectPath &path, const QString &error); +// dict requestInput(QDBusObjectPath &path, dict fields); + void cancel(); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); +}; + +//class QConnmanCounterInterfacePrivate; +//class QConnmanCounterInterface : public QDBusAbstractInterface +//{ +// Q_OBJECT +// +//public: +// +// QConnmanCounterInterface(QObject *parent = 0); +// ~QConnmanCounterInterface(); +// +// void release(); +//private: +// QConnmanCounterInterfacePrivate *d; +//}; + +class QConnmanDeviceInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanDeviceInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanDeviceInterface(); + + QVariantMap getProperties(); + void scan(); + +//properties + QString getAddress(); + QString getName(); + QString getType(); + QString getInterface(); + bool isPowered(); + quint16 getScanInterval(); + bool setScanInterval(const QString &interval); + + bool isScanning(); + QStringList getNetworks(); + bool setEnabled(bool powered); + bool setProperty(const QString &name, const QDBusVariant &value); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + +class QConnmanDBusHelper: public QObject, protected QDBusContext + { + Q_OBJECT + public: + QConnmanDBusHelper(QObject *parent = 0); + ~QConnmanDBusHelper(); + + public slots: + void propertyChanged(const QString &, const QDBusVariant &); + +Q_SIGNALS: + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + +QT_END_NAMESPACE + +#endif //QCONNMANSERVICE_H -- cgit v0.12 From 066fe8ab70508af6310c49e6eb9cdd74962b6401 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 22 Jun 2010 04:14:21 +1000 Subject: fix ghost ap issue, and dont block on connect --- src/plugins/bearer/connman/qconnmanengine.cpp | 276 ++++++++++++++++++-------- src/plugins/bearer/connman/qconnmanengine.h | 41 +++- 2 files changed, 235 insertions(+), 82 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index e4cab92..c1df710 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -51,7 +51,6 @@ #include #include -//#include #include #include #include @@ -65,7 +64,6 @@ QConnmanEngine::QConnmanEngine(QObject *parent) : QBearerEngineImpl(parent), connmanManager(new QConnmanManagerInterface(this)) { -// qWarning() << Q_FUNC_INFO; } QConnmanEngine::~QConnmanEngine() @@ -98,6 +96,7 @@ void QConnmanEngine::initialize() deviceMap.insert(techPath,QStringList() << devicePath); } } + // Get current list of access points. getConfigurations(); } @@ -113,7 +112,6 @@ QList QConnmanEngine::getConfigurations() void QConnmanEngine::getNetworkListing() { QMutexLocker locker(&mutex); - QMapIterator i(deviceMap); while(i.hasNext()) { i.next(); @@ -126,6 +124,8 @@ void QConnmanEngine::getNetworkListing() } } + + void QConnmanEngine::doRequestUpdate() { getConfigurations(); @@ -141,16 +141,16 @@ QString QConnmanEngine::getInterfaceFromId(const QString &id) QMapIterator i(deviceMap); while(i.hasNext()) { - i.next(); - if(i.value().count() > 0) { - QConnmanDeviceInterface dev(i.value().at(0)); - foreach(const QString network, dev.getNetworks()) { - if(network == netPath) { - return dev.getInterface(); - } - } - } - } + i.next(); + if(i.value().count() > 0) { + QConnmanDeviceInterface dev(i.value().at(0)); + foreach(const QString network, dev.getNetworks()) { + if(network == netPath) { + return dev.getInterface(); + } + } + } + } return QString(); } @@ -187,12 +187,13 @@ QString QConnmanEngine::bearerName(const QString &id) void QConnmanEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); - QConnmanServiceInterface serv(serviceFromId(id)); - if(!serv.isValid()) { - emit connectionError(id, InterfaceLookupError); - } else { - serv.connect(); - } + QConnmanConnectThread *thread; + thread = new QConnmanConnectThread(this); + thread->setServicePath(serviceFromId(id)); + thread->setIdentifier(id); + connect(thread,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)), + this,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError))); + thread->start(); } void QConnmanEngine::disconnectFromId(const QString &id) @@ -234,9 +235,24 @@ QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) if (!ptr->isValid) { return QNetworkSession::Invalid; - } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + + } + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + QString servState = serv.getState(); + + if(servState == "idle" || servState == "failure") { + return QNetworkSession::Disconnected; + } + + if(servState == "association" || servState == "configuration" || servState == "login") { + return QNetworkSession::Connecting; + } + if(servState == "ready" || servState == "online") { return QNetworkSession::Connected; - } else if ((ptr->state & QNetworkConfiguration::Discovered) == + } + + if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { return QNetworkSession::Disconnected; } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { @@ -324,14 +340,14 @@ QString QConnmanEngine::getNetworkForService(const QString &servPath) QMutexLocker locker(&mutex); QMap map; - QMapIterator i(deviceMap); - while(i.hasNext()) { - i.next(); - if(i.value().count() > 0) { - QConnmanDeviceInterface device(i.value().at(0)); - QMap netMapStrength; + QMapIterator i(deviceMap); + while(i.hasNext()) { + i.next(); + if(i.value().count() > 0) { + QConnmanDeviceInterface device(i.value().at(0)); + QMap netMapStrength; + foreach(const QString netPath, knownNetworks[device.getType()]) { - foreach(const QString netPath, knownNetworks[device.getType()]) { QConnmanNetworkInterface network1(netPath, this); QString netname = network1.getName(); qint32 sigStrength = network1.getSignalStrength(); @@ -355,10 +371,19 @@ QString QConnmanEngine::getNetworkForService(const QString &servPath) return QString(); } -void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +void QConnmanEngine::propertyChangedContext(const QString &/*path*/,const QString &item, const QDBusVariant &value) { -// qDebug() << __FUNCTION__ << path << item; QMutexLocker locker(&mutex); + if(item == "Services") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList list = qdbus_cast(arg); + + if(list.count() > accessPointConfigurations.count()) { + foreach(const QString service, list) { + addServiceConfiguration(service); + } + } + } if(item == "Technologies") { QDBusArgument arg = qvariant_cast(value.variant()); @@ -392,52 +417,47 @@ void QConnmanEngine::propertyChangedContext(const QString &path,const QString &i void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { -// qDebug() << __FUNCTION__ << path << item; +// qWarning() << __FUNCTION__ << path << item << value.variant(); QMutexLocker locker(&mutex); - if(item == "State") { + if(item == "State") { configurationChange(QString::number(qHash(path))); if(value.variant().toString() == "failure") { QConnmanServiceInterface serv(path); - qDebug() <<__FUNCTION__ <<"Error" << serv.getError(); - emit connectionError(QString::number(qHash(path)), ConnectError); + emit connectionError(QString::number(qHash(path)), ConnectError); } } } -void QConnmanEngine::networkPropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &/*value*/) +void QConnmanEngine::networkPropertyChangedContext(const QString &/*path*/,const QString &/*item*/, const QDBusVariant &/*value*/) { -// qDebug() << __FUNCTION__ << path << item; QMutexLocker locker(&mutex); } -void QConnmanEngine::devicePropertyChangedContext(const QString &path,const QString &item,const QDBusVariant &value) +void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const QString &item,const QDBusVariant &value) { -// qDebug() << __FUNCTION__ << path << item << value.variant(); QMutexLocker locker(&mutex); if(item == "Networks") { QDBusArgument arg = qvariant_cast(value.variant()); - QStringList remainingNetworks = qdbus_cast(arg); - - QConnmanDeviceInterface dev(path); - QStringList oldnetworks = knownNetworks[dev.getType()]; - if(remainingNetworks.count() != oldnetworks.count()) { + QStringList remainingNetworks = qdbus_cast(arg); + QConnmanDeviceInterface device(devpath); + QStringList oldnetworks = knownNetworks[device.getType()]; + if(remainingNetworks.count() > oldnetworks.count()) { foreach(const QString netPath, remainingNetworks) { if(!oldnetworks.contains(netPath)) { addNetworkConfiguration(netPath); } } - + } else { foreach(const QString netPath, oldnetworks) { QString servicePath = getServiceForNetwork(netPath); if(!remainingNetworks.contains(netPath)) { if(servicePath.isEmpty()) { - removeConfiguration(netPath); + removeConfiguration(QString::number(qHash(netPath))); } else { - if(!remainingNetworks.contains(servicePath)) { - removeConfiguration(QString::number(qHash(servicePath))); - } + removeConfiguration(QString::number(qHash(servicePath))); } + knownNetworks[device.getType()].removeAll(netPath); } } } @@ -446,17 +466,11 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &path,const QStr void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value) { -// qWarning() << __FUNCTION__ << path << item << value.variant(); -// if(item == "Devices") { -// QDBusArgument arg = qvariant_cast(value.variant()); -// QStringList list = qdbus_cast(arg); -// } + if(item == "Devices") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList list = qdbus_cast(arg); + } if(item == "State") { - if(value.variant().toString() == "enabled") { - } - if(value.variant().toString() == "offline") { - deviceMap.remove(path); - } if(value.variant().toString() == "available") { QConnmanTechnologyInterface tech(connmanManager->getPathForTechnology(path)); foreach(const QString devPath, tech.getDevices()) { @@ -464,51 +478,49 @@ void QConnmanEngine::technologyPropertyChangedContext(const QString & path, cons dev = new QConnmanDeviceInterface(devPath,this); connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); - deviceMap.insert(path,QStringList() << devPath); } } + if(value.variant().toString() == "offline") { + deviceMap.remove(path); + } } } void QConnmanEngine::configurationChange(const QString &id) { QMutexLocker locker(&mutex); - bool changed = false; if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); QString servicePath = serviceFromId(id); QConnmanServiceInterface *serv; serv = new QConnmanServiceInterface(servicePath); QString networkName = serv->getName(); + QNetworkConfiguration::StateFlags curState = getStateForService(servicePath); ptr->mutex.lock(); if (!ptr->isValid) { ptr->isValid = true; - changed = true; } if (ptr->name != networkName) { ptr->name = networkName; - changed = true; } if (ptr->state != curState) { ptr->state = curState; - changed = true; } ptr->mutex.unlock(); - if (changed) { - locker.unlock(); - emit configurationChanged(ptr); - locker.relock(); - } + locker.unlock(); + emit configurationChanged(ptr); + locker.relock(); } locker.unlock(); @@ -517,7 +529,6 @@ void QConnmanEngine::configurationChange(const QString &id) QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service) { - qWarning() << __FUNCTION__; QMutexLocker locker(&mutex); QConnmanServiceInterface serv(service); QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; @@ -555,23 +566,76 @@ QString QConnmanEngine::typeToBearer(const QString &type) return "Unknown"; } -void QConnmanEngine::removeConfiguration(const QString &netpath) +void QConnmanEngine::removeConfiguration(const QString &id) { QMutexLocker locker(&mutex); - const QString id = QString::number(qHash(netpath)); + if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); - QConnmanDeviceInterface device(netpath.section("/",0,5),this); locker.unlock(); - knownNetworks[device.getType()].removeAll(netpath); emit configurationRemoved(ptr); locker.relock(); } } +void QConnmanEngine::addServiceConfiguration(const QString &servicePath) +{ + + QMutexLocker locker(&mutex); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + const QString netPath = getNetworkForService(servicePath); + + QConnmanNetworkInterface *network; + network = new QConnmanNetworkInterface(netPath, this); + + const QString id = QString::number(qHash(servicePath)); + + if (!accessPointConfigurations.contains(id)) { + QConnmanDeviceInterface device(netPath.section("/",0,5),this); + knownNetworks[device.getType()]<< netPath; +// knownNetworks << servicePath; + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + + QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); + + QString networkName = serv->getName(); + + if(serv->getType() == "Cellular") { + networkName = serv->getAPN(); + } + + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + cpPriv->bearer = bearerName(id); + + if(serv->getSecurity() == "none") { + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + } else { + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + } + + connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + + cpPriv->state = getStateForService(servicePath); + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + foundConfigurations.append(cpPriv); + + locker.unlock(); + emit configurationAdded(ptr); + locker.relock(); + emit updateCompleted(); + } +} + void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) { -// qWarning() << __FUNCTION__ << networkPath; QMutexLocker locker(&mutex); QConnmanNetworkInterface *network; @@ -580,11 +644,18 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) QConnmanServiceInterface *serv; QString id; + QConnmanDeviceInterface device(networkPath.section("/",0,5),this); + if(servicePath.isEmpty()) { id = QString::number(qHash(networkPath)); } else { id = QString::number(qHash(servicePath)); + serv = new QConnmanServiceInterface(servicePath,this); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); } + knownNetworks[device.getType()]<< networkPath; + if (!accessPointConfigurations.contains(id)) { connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); @@ -598,16 +669,13 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) QString bearerName; - QConnmanDeviceInterface device(networkPath.section("/",0,5),this); if(servicePath.isEmpty()) { + QString devicePath = networkPath.section("/",0,5); + QConnmanDeviceInterface device(devicePath,this); bearerName = typeToBearer(device.getType()); } else { - serv = new QConnmanServiceInterface(servicePath,this); bearerName = typeToBearer(serv->getType()); - connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); } - knownNetworks[device.getType()]<< networkPath; if(bearerName == "Cellular") { QString mode = serv->getMode(); @@ -642,7 +710,57 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) locker.unlock(); emit configurationAdded(ptr); locker.relock(); + emit updateCompleted(); + } +} + +bool QConnmanEngine::requiresPolling() const +{ + return false; +} + + +QConnmanConnectThread::QConnmanConnectThread(QObject *parent) + :QThread(parent), + servicePath(), identifier() +{ +} + +QConnmanConnectThread::~QConnmanConnectThread() +{ +} + +void QConnmanConnectThread::stop() +{ + if(currentThread() != this) { + QMetaObject::invokeMethod(this, "quit", + Qt::QueuedConnection); + } else { + quit(); } + wait(); +} + +void QConnmanConnectThread::run() +{ + QConnmanServiceInterface serv(servicePath); + if(!serv.isValid()) { + emit connectionError(identifier, QBearerEngineImpl::InterfaceLookupError); + } else { + serv.connect(); + } +} + +void QConnmanConnectThread::setServicePath(const QString &path) +{ + QMutexLocker locker(&mutex); + servicePath = path; +} + +void QConnmanConnectThread::setIdentifier(const QString &id) +{ + QMutexLocker locker(&mutex); + identifier = id; } QT_END_NAMESPACE diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index 849d8c9..b5f1488 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -59,12 +59,14 @@ #include #include +#include #ifndef QT_NO_BEARERMANAGEMENT #ifndef QT_NO_DBUS QT_BEGIN_NAMESPACE +class QConnmanConnectThread; class QConnmanEngine : public QBearerEngineImpl { Q_OBJECT @@ -114,6 +116,7 @@ private: QConnmanManagerInterface *connmanManager; QList foundConfigurations; + void getNetworkListing(); QString getServiceForNetwork(const QString &network); @@ -125,14 +128,46 @@ private: QNetworkConfiguration::StateFlags getStateForService(const QString &service); QString typeToBearer(const QString &type); - void removeConfiguration(const QString &path); + void removeConfiguration(const QString &servicePath); + void addServiceConfiguration(const QString &servicePath); void addNetworkConfiguration(const QString &worknetPath); QDateTime activeTime; QMap technologies; - QMap knownNetworks; - QMap deviceMap; + // QStringList knownNetworks; + + QMap knownNetworks; + QMap deviceMap; + +protected: + bool requiresPolling() const; + QConnmanConnectThread *connThread; +}; + +class QConnmanConnectThread : public QThread +{ + Q_OBJECT + +public: + QConnmanConnectThread(QObject *parent = 0); + ~QConnmanConnectThread(); + bool keepRunning; + void stop(); + void setServicePath(const QString &path); + void setIdentifier(const QString &id); + +Q_SIGNALS: + void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error); + +protected: + void run(); + QString servicePath; + QString identifier; + +private: + QMutex mutex; + }; QT_END_NAMESPACE -- cgit v0.12 From 5aa3b45acf810f444487d0904a9c84be8687623d Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 24 Jun 2010 12:23:34 +1000 Subject: Added surround sound support to win32 low-level audio backend. Task-number:QTBUG-11586 Reviewed-by:Andrew den Exter --- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 5 +++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 54 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 465bc98..4e6b2df 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -374,6 +374,11 @@ void QAudioDeviceInfoInternal::updateLists() #endif channelz.append(1); channelz.append(2); + if (mode == QAudio::AudioOutput) { + channelz.append(4); + channelz.append(6); + channelz.append(8); + } byteOrderz.append(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 533583a..513c16c 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -52,6 +52,10 @@ #include "qaudiooutput_win32_p.h" +#include + +#define _KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}} + //#define DEBUG_AUDIO 1 QT_BEGIN_NAMESPACE @@ -258,15 +262,47 @@ bool QAudioOutputPrivate::open() } } - if(waveOutOpen(&hWaveOut, devId, &wfx, - (DWORD_PTR)&waveOutProc, - (DWORD_PTR) this, - CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioOutput: open error"); - return false; + if ( settings.channels() <= 2) { + if(waveOutOpen(&hWaveOut, devId, &wfx, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } + } else { + WAVEFORMATEXTENSIBLE wfex; + wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfex.Format.nChannels = settings.channels(); + wfex.Format.wBitsPerSample = settings.sampleSize(); + wfex.Format.nSamplesPerSec = settings.frequency(); + wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; + wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; + wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; + wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; + wfex.Format.cbSize=22; + + wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + if (settings.channels() >= 4) + wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; + if (settings.channels() >= 6) + wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; + if (settings.channels() == 8) + wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; + + if(waveOutOpen(&hWaveOut, devId, &wfex.Format, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } } totalTimeValue = 0; -- cgit v0.12 From c2cc288a3acb9493a13449fd36fcc9ebce40807b Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 24 Jun 2010 13:18:37 +1000 Subject: Added surround sound support to alsa low-level audio backend. Task-number:QTBUG-11586 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 46 ++++++++++++++++++++++++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 5 +++ 2 files changed, 51 insertions(+) diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 36270a7..f663dd2 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -62,6 +62,8 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode device = QLatin1String(dev); this->mode = mode; + + checkSurround(); } QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() @@ -389,6 +391,9 @@ void QAudioDeviceInfoInternal::updateLists() } channelz.append(1); channelz.append(2); + if (surround40) channelz.append(4); + if (surround51) channelz.append(6); + if (surround71) channelz.append(8); sizez.append(8); sizez.append(16); sizez.append(32); @@ -483,4 +488,45 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() return devices.first(); } +void QAudioDeviceInfoInternal::checkSurround() +{ + QList devices; + surround40 = false; + surround51 = false; + surround71 = false; + + void **hints, **n; + char *name, *descr, *io; + + if(snd_device_name_hint(-1, "pcm", &hints) < 0) + return; + + n = hints; + + while (*n != NULL) { + name = snd_device_name_get_hint(*n, "NAME"); + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + if((name != NULL) && (descr != NULL)) { + QString deviceName = QLatin1String(name); + if (mode == QAudio::AudioOutput) { + if(deviceName.contains(QLatin1String("surround40"))) + surround40 = true; + if(deviceName.contains(QLatin1String("surround51"))) + surround51 = true; + if(deviceName.contains(QLatin1String("surround71"))) + surround71 = true; + } + } + if(name != NULL) + free(name); + if(descr != NULL) + free(descr); + if(io != NULL) + free(io); + ++n; + } + snd_device_name_free_hint(hints); +} + QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 6f9a459..8525980 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -98,6 +98,11 @@ private: bool open(); void close(); + void checkSurround(); + bool surround40; + bool surround51; + bool surround71; + QString device; QAudio::Mode mode; QAudioFormat nearest; -- cgit v0.12 From 19ef773e1308b2bdce8ec2efd700d5754c01f6d3 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 24 Jun 2010 14:19:26 +1000 Subject: Fixed compile error introduced by win32 surround sound support change. Reviewed-by:Andrew den Exter --- src/multimedia/audio/qaudiooutput_win32_p.cpp | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 513c16c..56de4ee 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -52,7 +52,48 @@ #include "qaudiooutput_win32_p.h" -#include +#ifndef SPEAKER_FRONT_LEFT + #define SPEAKER_FRONT_LEFT 0x00000001 + #define SPEAKER_FRONT_RIGHT 0x00000002 + #define SPEAKER_FRONT_CENTER 0x00000004 + #define SPEAKER_LOW_FREQUENCY 0x00000008 + #define SPEAKER_BACK_LEFT 0x00000010 + #define SPEAKER_BACK_RIGHT 0x00000020 + #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 + #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 + #define SPEAKER_BACK_CENTER 0x00000100 + #define SPEAKER_SIDE_LEFT 0x00000200 + #define SPEAKER_SIDE_RIGHT 0x00000400 + #define SPEAKER_TOP_CENTER 0x00000800 + #define SPEAKER_TOP_FRONT_LEFT 0x00001000 + #define SPEAKER_TOP_FRONT_CENTER 0x00002000 + #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 + #define SPEAKER_TOP_BACK_LEFT 0x00008000 + #define SPEAKER_TOP_BACK_CENTER 0x00010000 + #define SPEAKER_TOP_BACK_RIGHT 0x00020000 + #define SPEAKER_RESERVED 0x7FFC0000 + #define SPEAKER_ALL 0x80000000 +#endif + +#ifndef _WAVEFORMATEXTENSIBLE_ + + #define _WAVEFORMATEXTENSIBLE_ + typedef struct + { + WAVEFORMATEX Format; // Base WAVEFORMATEX data + union + { + WORD wValidBitsPerSample; // Valid bits in each sample container + WORD wSamplesPerBlock; // Samples per block of audio data; valid + // if wBitsPerSample=0 (but rarely used). + WORD wReserved; // Zero if neither case above applies. + } Samples; + DWORD dwChannelMask; // Positions of the audio channels + GUID SubFormat; // Format identifier GUID + } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE, *LPPWAVEFORMATEXTENSIBLE; + typedef const WAVEFORMATEXTENSIBLE* LPCWAVEFORMATEXTENSIBLE; + +#endif #define _KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}} -- cgit v0.12 From a67e9a9a0d0e335db2f7b7232c6c7ec42750533c Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 25 Jun 2010 08:41:04 +1000 Subject: Fixed compile error in multimedia module WAVE_FORMAT_EXTENSIBLE not in v6.0 ms SDK only in v6.1's Reviewed-by:TrustMe --- src/multimedia/audio/qaudiooutput_win32_p.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 56de4ee..d0f1791 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -95,6 +95,10 @@ #endif +#if !defined(WAVE_FORMAT_EXTENSIBLE) +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE +#endif + #define _KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}} //#define DEBUG_AUDIO 1 -- cgit v0.12 From 473eb62791f2e489aacd4be88df101ce26fe92ea Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 25 Jun 2010 10:47:40 +1000 Subject: Fix compile err with win2005 compiler for multimedia lib. Reviewed-by:TrustMe --- src/multimedia/audio/qaudiooutput_win32_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index d0f1791..f26198f 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -99,7 +99,8 @@ #define WAVE_FORMAT_EXTENSIBLE 0xFFFE #endif -#define _KSDATAFORMAT_SUBTYPE_PCM (GUID) {0x00000001,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}} +DEFINE_GUID(_KSDATAFORMAT_SUBTYPE_PCM, +0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); //#define DEBUG_AUDIO 1 -- cgit v0.12 From 0ad9edf26daf78d697cd9e83c639c65879461b0f Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 25 Jun 2010 12:40:38 +1000 Subject: Fix compile error on win32 with multimedia lib. Reviewed-by:TrustMe --- src/multimedia/audio/qaudiooutput_win32_p.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index f26198f..075d100 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -99,9 +99,6 @@ #define WAVE_FORMAT_EXTENSIBLE 0xFFFE #endif -DEFINE_GUID(_KSDATAFORMAT_SUBTYPE_PCM, -0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - //#define DEBUG_AUDIO 1 QT_BEGIN_NAMESPACE @@ -328,6 +325,8 @@ bool QAudioOutputPrivate::open() wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; + static const GUID _KSDATAFORMAT_SUBTYPE_PCM = { + 0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; wfex.Format.cbSize=22; -- cgit v0.12 From c049aff3ce283b9ba9a17a63aedaa70efb51ad09 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 Jun 2010 10:32:47 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to 4b88f595ab62b7c5f703a286c4f5f13f8784a936 * Fix crash/regression in thai line word breaking when libthai is installed: Commit 4b88f595ab62b7c5f703a286c4f5f13f8784a936 upstream ensures the zero termination of the string passed to libthai. --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index fc2bdbf..e153ba9 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -53,6 +53,8 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) else result[i] = '?'; } + + result[len] = 0; } static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes) @@ -70,8 +72,8 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (!th_brk) return; - if (len > 128) - cstr = (char *)malloc(len*sizeof(char)); + if (len >= 128) + cstr = (char *)malloc(len*sizeof(char) + 1); to_tis620(string, len, cstr); @@ -96,7 +98,7 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (break_positions != brp) free(break_positions); - if (len > 128) + if (len >= 128) free(cstr); } -- cgit v0.12 From 63e3ded08cc619993598462ca0f839b2239dd2c5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 27 Jun 2010 00:00:16 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( fc13f9b396e1448cd71266f56ba7a93de5cf6ed9 ) Changes in WebKit/qt since the last update: * Benjamin's update/fixes to the backport of https://bugs.webkit.org/show_bug.cgi?id=33150 --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/page/FrameView.cpp | 30 ++++++++++++++-------- src/3rdparty/webkit/WebCore/page/FrameView.h | 6 +++-- .../webkit/WebCore/platform/ScrollView.cpp | 7 +++-- src/3rdparty/webkit/WebCore/platform/ScrollView.h | 5 +++- .../webkit/WebCore/rendering/RenderLayer.cpp | 24 +++++++++++++++++ .../webkit/WebCore/rendering/RenderLayer.h | 2 ++ .../WebKit/qt/tests/qwebview/tst_qwebview.cpp | 26 ++++++++++++++++++- 8 files changed, 84 insertions(+), 18 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1b8e789..354e21d 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - be1a105be93d7fcbe36d93d0827dc6e98b55de0c + fc13f9b396e1448cd71266f56ba7a93de5cf6ed9 diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.cpp b/src/3rdparty/webkit/WebCore/page/FrameView.cpp index cc7d171..1ea166f 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.cpp +++ b/src/3rdparty/webkit/WebCore/page/FrameView.cpp @@ -780,7 +780,7 @@ void FrameView::removeFixedObject() setCanBlitOnScroll(!useSlowRepaints()); } -void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) +bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) { const size_t fixedObjectThreshold = 5; @@ -790,7 +790,7 @@ void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect if (!positionedObjects || positionedObjects->isEmpty()) { hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); - return; + return true; } // Get the rects of the fixed objects visible in the rectToScroll @@ -801,9 +801,9 @@ void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect RenderBox* renderBox = *it; if (renderBox->style()->position() != FixedPosition) continue; - IntRect topLevelRect; - IntRect updateRect = renderBox->paintingRootRect(topLevelRect); - updateRect.move(-scrollX(), -scrollY()); + IntRect updateRect = renderBox->layer()->repaintRectIncludingDescendants(); + updateRect = contentsToWindow(updateRect); + updateRect.intersect(rectToScroll); if (!updateRect.isEmpty()) { if (subRectToUpdate.size() >= fixedObjectThreshold) { @@ -819,7 +819,7 @@ void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect // 1) scroll hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); - // 2) update the area of fixed objets that has been invalidated + // 2) update the area of fixed objects that has been invalidated size_t fixObjectsCount = subRectToUpdate.size(); for (size_t i = 0; i < fixObjectsCount; ++i) { IntRect updateRect = subRectToUpdate[i]; @@ -829,12 +829,11 @@ void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect updateRect.intersect(rectToScroll); hostWindow()->repaint(updateRect, true, false, true); } - } else { - // the number of fixed objects exceed the threshold, so we repaint everything. - IntRect updateRect = clipRect; - updateRect.intersect(rectToScroll); - hostWindow()->repaint(updateRect, true, false, true); + return true; } + + // the number of fixed objects exceed the threshold, we cannot use the fast path + return false; } void FrameView::setIsOverlapped(bool isOverlapped) @@ -964,6 +963,15 @@ void FrameView::scrollPositionChanged() { frame()->eventHandler()->sendScrollEvent(); + // For fixed position elements, update widget positions and compositing layers after scrolling, + // but only if we're not inside of layout. + if (!m_nestedLayoutCount && hasFixedObjects()) { + if (RenderView* root = m_frame->contentRenderer()) { + root->updateWidgetPositions(); + root->layer()->updateRepaintRectsAfterScroll(); + } + } + #if USE(ACCELERATED_COMPOSITING) // We need to update layer positions after scrolling to account for position:fixed layers. Document* document = m_frame->document(); diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.h b/src/3rdparty/webkit/WebCore/page/FrameView.h index ed1e6c6..6350a2a 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.h +++ b/src/3rdparty/webkit/WebCore/page/FrameView.h @@ -131,7 +131,7 @@ public: virtual void scrollRectIntoViewRecursively(const IntRect&); virtual void setScrollPosition(const IntPoint&); - void scrollPositionChanged(); + virtual void scrollPositionChanged(); String mediaType() const; void setMediaType(const String&); @@ -200,7 +200,7 @@ public: void invalidateScrollCorner(); protected: - virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); + virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); private: FrameView(Frame*); @@ -214,6 +214,8 @@ private: bool useSlowRepaints() const; bool useSlowRepaintsIfNotOverlapped() const; + bool hasFixedObjects() const { return m_fixedObjectCount > 0; } + void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode); void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp index 9e15c43..518c454 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp @@ -259,6 +259,7 @@ void ScrollView::valueChanged(Scrollbar* scrollbar) if (scrollbarsSuppressed()) return; + scrollPositionChanged(); scrollContents(scrollDelta); } @@ -509,7 +510,8 @@ void ScrollView::scrollContents(const IntSize& scrollDelta) if (canBlitOnScroll()) { // The main frame can just blit the WebView window // FIXME: Find a way to blit subframes without blitting overlapping content - scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect); + if (!scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect)) + hostWindow()->repaint(updateRect, true, false, true); } else { // We need to go ahead and repaint the entire backing store. Do it now before moving the // windowed plugins. @@ -524,9 +526,10 @@ void ScrollView::scrollContents(const IntSize& scrollDelta) hostWindow()->paint(); } -void ScrollView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) +bool ScrollView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) { hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); + return true; } IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.h b/src/3rdparty/webkit/WebCore/platform/ScrollView.h index 7060d07..0e40334 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.h +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.h @@ -246,7 +246,7 @@ protected: virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect); // Scroll the content by blitting the pixels - virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); + virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); private: RefPtr m_horizontalScrollbar; @@ -281,6 +281,9 @@ private: // Called to update the scrollbars to accurately reflect the state of the view. void updateScrollbars(const IntSize& desiredOffset); + // Called when the scroll position within this view changes. FrameView overrides this to generate repaint invalidations. + virtual void scrollPositionChanged() {} + void platformInit(); void platformDestroy(); void platformAddChild(Widget*); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp index fea61c9..6c73114 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp @@ -331,6 +331,14 @@ void RenderLayer::updateLayerPositions(UpdateLayerPositionsFlags flags) m_marquee->updateMarqueePosition(); } +IntRect RenderLayer::repaintRectIncludingDescendants() const +{ + IntRect repaintRect = m_repaintRect; + for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) + repaintRect.unite(child->repaintRectIncludingDescendants()); + return repaintRect; +} + void RenderLayer::computeRepaintRects() { RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint(); @@ -338,6 +346,22 @@ void RenderLayer::computeRepaintRects() m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); } +void RenderLayer::updateRepaintRectsAfterScroll(bool fixed) +{ + if (fixed || renderer()->style()->position() == FixedPosition) { + computeRepaintRects(); + fixed = true; + } else if (renderer()->hasTransform()) { + // Transforms act as fixed position containers, so nothing inside a + // transformed element can be fixed relative to the viewport if the + // transformed element is not fixed itself or child of a fixed element. + return; + } + + for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) + child->updateRepaintRectsAfterScroll(fixed); +} + void RenderLayer::updateTransform() { // hasTransform() on the renderer is also true when there is transform-style: preserve-3d or perspective set, diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h index a274638..ac51d9d 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h @@ -384,7 +384,9 @@ public: // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint. IntRect repaintRect() const { return m_repaintRect; } + IntRect repaintRectIncludingDescendants() const; void computeRepaintRects(); + void updateRepaintRectsAfterScroll(bool fixed = false); void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; } int staticX() const { return m_staticX; } diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp index d466ab5..5e8e8a9 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -29,7 +29,31 @@ #include #include #include - +#include +#include + +/** + * Starts an event loop that runs until the given signal is received. + Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} class tst_QWebView : public QObject { Q_OBJECT -- cgit v0.12 From 361f409d513b7360b1a6f919799cc1948835aef3 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 28 Jun 2010 09:30:53 +1000 Subject: fix actions regarding removal of connman. make tests pass on desktop --- src/plugins/bearer/connman/qconnmanengine.cpp | 162 ++++++++++++++------------ src/plugins/bearer/connman/qconnmanengine.h | 10 +- 2 files changed, 91 insertions(+), 81 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index c1df710..bdff815 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -91,9 +91,14 @@ void QConnmanEngine::initialize() foreach(const QString devicePath,tech->getDevices()) { QConnmanDeviceInterface *dev; dev = new QConnmanDeviceInterface(devicePath); - connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); - deviceMap.insert(techPath,QStringList() << devicePath); + if(!deviceMap.value(techPath).contains(devicePath)) { + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + deviceMap.insert(techPath,QStringList() << devicePath); + foreach(const QString network,dev->getNetworks()) { + serviceNetworks.insert(getServiceForNetwork(network),network); + } + } } } @@ -104,9 +109,28 @@ void QConnmanEngine::initialize() QList QConnmanEngine::getConfigurations() { QMutexLocker locker(&mutex); - foundConfigurations.clear(); + // foundConfigurations.clear(); getNetworkListing(); - return foundConfigurations; + QList fetchedConfigurations; + QNetworkConfigurationPrivate* cpPriv = 0; + + for (int i = 0; i < foundConfigurations.count(); ++i) { + QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate; + cpPriv = foundConfigurations.at(i); + + config->name = cpPriv->name; + config->isValid = cpPriv->isValid; + config->id = cpPriv->id; + config->state = cpPriv->state; + config->type = cpPriv->type; + config->roamingSupported = cpPriv->roamingSupported; + config->purpose = cpPriv->purpose; + config->bearer = cpPriv->bearer; + + fetchedConfigurations.append(config); + } + return fetchedConfigurations; +// return foundConfigurations; } void QConnmanEngine::getNetworkListing() @@ -128,6 +152,7 @@ void QConnmanEngine::getNetworkListing() void QConnmanEngine::doRequestUpdate() { + connmanManager->requestScan(""); getConfigurations(); emit updateCompleted(); } @@ -135,23 +160,7 @@ void QConnmanEngine::doRequestUpdate() QString QConnmanEngine::getInterfaceFromId(const QString &id) { QMutexLocker locker(&mutex); - - QString servicePath = serviceFromId(id); - QString netPath = getNetworkForService(servicePath); - - QMapIterator i(deviceMap); - while(i.hasNext()) { - i.next(); - if(i.value().count() > 0) { - QConnmanDeviceInterface dev(i.value().at(0)); - foreach(const QString network, dev.getNetworks()) { - if(network == netPath) { - return dev.getInterface(); - } - } - } - } - return QString(); + return configInterfaces.value(id); } bool QConnmanEngine::hasIdentifier(const QString &id) @@ -216,7 +225,7 @@ void QConnmanEngine::requestUpdate() QString QConnmanEngine::serviceFromId(const QString &id) { QMutexLocker locker(&mutex); - foreach(QString service, connmanManager->getServices()) { + foreach(const QString service, serviceNetworks.keys()) { if (id == QString::number(qHash(service))) return service; } @@ -241,7 +250,7 @@ QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) QConnmanServiceInterface serv(service); QString servState = serv.getState(); - if(servState == "idle" || servState == "failure") { + if(serv.isFavorite() && servState == "idle" || servState == "failure") { return QNetworkSession::Disconnected; } @@ -335,43 +344,8 @@ QString QConnmanEngine::getServiceForNetwork(const QString &netPath) return QString(); } -QString QConnmanEngine::getNetworkForService(const QString &servPath) -{ - QMutexLocker locker(&mutex); - QMap map; - - QMapIterator i(deviceMap); - while(i.hasNext()) { - i.next(); - if(i.value().count() > 0) { - QConnmanDeviceInterface device(i.value().at(0)); - QMap netMapStrength; - foreach(const QString netPath, knownNetworks[device.getType()]) { - - QConnmanNetworkInterface network1(netPath, this); - QString netname = network1.getName(); - qint32 sigStrength = network1.getSignalStrength(); - - if(netMapStrength.contains(netname) - && netMapStrength.value(netname) < sigStrength) { - netMapStrength.remove(netname); - map.remove(netname); - } - netMapStrength.insert(netname, sigStrength); - map.insert(netname,netPath); - } - } - } - QConnmanServiceInterface *serv; - serv = new QConnmanServiceInterface(servPath); - if(map.contains(serv->getName())) { - return map.value(serv->getName()); - } - return QString(); -} - -void QConnmanEngine::propertyChangedContext(const QString &/*path*/,const QString &item, const QDBusVariant &value) +void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { QMutexLocker locker(&mutex); if(item == "Services") { @@ -413,14 +387,17 @@ void QConnmanEngine::propertyChangedContext(const QString &/*path*/,const QStrin } } } + if(item == "State") { +// qDebug() << value.variant(); + } } void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { -// qWarning() << __FUNCTION__ << path << item << value.variant(); QMutexLocker locker(&mutex); if(item == "State") { configurationChange(QString::number(qHash(path))); + if(value.variant().toString() == "failure") { QConnmanServiceInterface serv(path); emit connectionError(QString::number(qHash(path)), ConnectError); @@ -439,8 +416,17 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q if(item == "Networks") { QDBusArgument arg = qvariant_cast(value.variant()); QStringList remainingNetworks = qdbus_cast(arg); - QConnmanDeviceInterface device(devpath); - QStringList oldnetworks = knownNetworks[device.getType()]; + QString devicetype; + QMapIterator i(deviceMap); + while(i.hasNext()) { + i.next(); + if(i.value().contains(devpath)) { + devicetype = i.key(); + } + } + + + QStringList oldnetworks = knownNetworks[devicetype]; if(remainingNetworks.count() > oldnetworks.count()) { foreach(const QString netPath, remainingNetworks) { @@ -450,14 +436,14 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q } } else { foreach(const QString netPath, oldnetworks) { - QString servicePath = getServiceForNetwork(netPath); + QString servicePath = serviceNetworks.key(netPath); if(!remainingNetworks.contains(netPath)) { if(servicePath.isEmpty()) { removeConfiguration(QString::number(qHash(netPath))); } else { removeConfiguration(QString::number(qHash(servicePath))); } - knownNetworks[device.getType()].removeAll(netPath); + knownNetworks[devicetype].removeAll(netPath); } } } @@ -471,14 +457,18 @@ void QConnmanEngine::technologyPropertyChangedContext(const QString & path, cons QStringList list = qdbus_cast(arg); } if(item == "State") { + if(value.variant().toString() == "available") { QConnmanTechnologyInterface tech(connmanManager->getPathForTechnology(path)); foreach(const QString devPath, tech.getDevices()) { - QConnmanDeviceInterface *dev; - dev = new QConnmanDeviceInterface(devPath,this); - connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); - deviceMap.insert(path,QStringList() << devPath); + + if(!deviceMap.value(path).contains(devPath)) { + QConnmanDeviceInterface *dev; + dev = new QConnmanDeviceInterface(devPath,this); + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + deviceMap.insert(path,QStringList() << devPath); + } } } if(value.variant().toString() == "offline") { @@ -571,6 +561,20 @@ void QConnmanEngine::removeConfiguration(const QString &id) QMutexLocker locker(&mutex); if (accessPointConfigurations.contains(id)) { + + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + + disconnect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + + QString netPath = serviceNetworks.value(service); + serviceNetworks.remove(service); + + QConnmanServiceInterface network(netPath); + disconnect(&network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); locker.unlock(); emit configurationRemoved(ptr); @@ -584,20 +588,21 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) QMutexLocker locker(&mutex); QConnmanServiceInterface *serv; serv = new QConnmanServiceInterface(servicePath); - const QString netPath = getNetworkForService(servicePath); + const QString netPath = serviceNetworks.value(servicePath); QConnmanNetworkInterface *network; network = new QConnmanNetworkInterface(netPath, this); + serviceNetworks.insert(servicePath,netPath); + const QString id = QString::number(qHash(servicePath)); if (!accessPointConfigurations.contains(id)) { + QConnmanDeviceInterface device(netPath.section("/",0,5),this); knownNetworks[device.getType()]<< netPath; -// knownNetworks << servicePath; connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); QString networkName = serv->getName(); @@ -626,6 +631,8 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); foundConfigurations.append(cpPriv); + configInterfaces[cpPriv->id] = device.getInterface(); + locker.unlock(); emit configurationAdded(ptr); @@ -650,11 +657,12 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) id = QString::number(qHash(networkPath)); } else { id = QString::number(qHash(servicePath)); - serv = new QConnmanServiceInterface(servicePath,this); - connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + serv = new QConnmanServiceInterface(servicePath,this); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); } knownNetworks[device.getType()]<< networkPath; + serviceNetworks.insert(servicePath,networkPath); if (!accessPointConfigurations.contains(id)) { connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), @@ -707,6 +715,8 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); foundConfigurations.append(cpPriv); + configInterfaces[cpPriv->id] = device.getInterface(); + locker.unlock(); emit configurationAdded(ptr); locker.relock(); diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index b5f1488..0f6dc1c 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -120,7 +120,6 @@ private: void getNetworkListing(); QString getServiceForNetwork(const QString &network); - QString getNetworkForService(const QString &network); QString serviceFromId(const QString &id); QString networkFromId(const QString &id); @@ -134,11 +133,12 @@ private: QDateTime activeTime; - QMap technologies; - // QStringList knownNetworks; + QMap technologies; // techpath, tech interface + QMap configInterfaces; // id, interface name + QMap knownNetworks; //device path, net paths list + QMap deviceMap; //tech path, device path + QMap serviceNetworks; //service, network - QMap knownNetworks; - QMap deviceMap; protected: bool requiresPolling() const; -- cgit v0.12 From e620e6626454f0ee10655033841baa6e3b2f4990 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 29 Jun 2010 12:54:11 +1000 Subject: QAudioInput push mode does not work Task-number:QTBUG-11755 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudioinput_alsa_p.cpp | 54 +++++++++++++++++++++-------- src/multimedia/audio/qaudioinput_alsa_p.h | 1 + 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index c9a8b71..58669b3 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -120,7 +120,7 @@ int QAudioInputPrivate::xrun_recovery(int err) if(err < 0) reset = true; else { - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable <= 0) reset = true; } @@ -408,7 +408,7 @@ bool QAudioInputPrivate::open() snd_pcm_start(handle); // Step 5: Setup timer - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if(pullMode) connect(audioSource,SIGNAL(readyRead()),this,SLOT(userFeed())); @@ -437,19 +437,29 @@ void QAudioInputPrivate::close() } } -int QAudioInputPrivate::bytesReady() const +int QAudioInputPrivate::checkBytesReady() { if(resuming) - return period_size; - - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - int frames = snd_pcm_avail_update(handle); - if (frames < 0) return frames; - if((int)frames > (int)buffer_frames) - frames = buffer_frames; + bytesAvailable = period_size; + else if(deviceState != QAudio::ActiveState + && deviceState != QAudio::IdleState) + bytesAvailable = 0; + else { + int frames = snd_pcm_avail_update(handle); + if (frames < 0) { + bytesAvailable = frames; + } else { + if((int)frames > (int)buffer_frames) + frames = buffer_frames; + bytesAvailable = snd_pcm_frames_to_bytes(handle, frames); + } + } + return bytesAvailable; +} - return snd_pcm_frames_to_bytes(handle, frames); +int QAudioInputPrivate::bytesReady() const +{ + return qMax(bytesAvailable, 0); } qint64 QAudioInputPrivate::read(char* data, qint64 len) @@ -460,12 +470,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if ( !handle ) return 0; - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable < 0) { // bytesAvailable as negative is error code, try to recover from it. xrun_recovery(bytesAvailable); - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable < 0) { // recovery failed must stop and set error. close(); @@ -639,11 +649,25 @@ bool QAudioInputPrivate::deviceReady() InputPrivate* a = qobject_cast(audioSource); a->trigger(); } - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if(deviceState != QAudio::ActiveState) return true; + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = checkBytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h index 92cef83..191235e 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.h +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -109,6 +109,7 @@ private slots: bool deviceReady(); private: + int checkBytesReady(); int xrun_recovery(int err); int setFormat(); bool open(); -- cgit v0.12 From d198186cdb18bbb9428ca51e8771cc4fd9563452 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 29 Jun 2010 10:24:44 +0200 Subject: Layout direction change by key should change alignment of QLineEdit When QLineControl was split out of QLineEdit, a regression was introduced. When the layout direction was altered by a key press, the layout direction of the QLineControl would be set, but not the QLineEdit. This would in turn mean that QLineEdit would use the wrong layout direction for its visual alignment. Patch is a small hack to read back the layout direction from the control after it has been set. Task-number: QTBUG-11204 Reviewed-by: Trond --- src/gui/widgets/qlineedit.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index f041a36..6e8daee 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1665,8 +1665,11 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) } #endif d->control->processKeyEvent(event); - if (event->isAccepted()) + if (event->isAccepted()) { + if (layoutDirection() != d->control->layoutDirection()) + setLayoutDirection(d->control->layoutDirection()); d->control->setCursorBlinkPeriod(0); + } } /*! -- cgit v0.12 From 5a6d8c40791da2e8751965d05ae2d5ef69bed301 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 30 Jun 2010 12:20:14 +1000 Subject: make sure ap's are removed when the device is removed --- src/plugins/bearer/connman/qconnmanengine.cpp | 24 ++++++++---- .../bearer/connman/qconnmanservice_linux.cpp | 44 +++++++++++++++++++--- .../bearer/connman/qconnmanservice_linux_p.h | 34 +++++++++-------- 3 files changed, 74 insertions(+), 28 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index bdff815..8775623 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -250,7 +250,7 @@ QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) QConnmanServiceInterface serv(service); QString servState = serv.getState(); - if(serv.isFavorite() && servState == "idle" || servState == "failure") { + if(serv.isFavorite() && (servState == "idle" || servState == "failure")) { return QNetworkSession::Disconnected; } @@ -285,6 +285,7 @@ quint64 QConnmanEngine::bytesWritten(const QString &id) in >> result; tx.close(); } + return result; } @@ -347,6 +348,9 @@ QString QConnmanEngine::getServiceForNetwork(const QString &netPath) void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { + Q_UNUSED(path); +// qDebug() << __FUNCTION__ << path << item << value.variant(); + QMutexLocker locker(&mutex); if(item == "Services") { QDBusArgument arg = qvariant_cast(value.variant()); @@ -421,11 +425,10 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q while(i.hasNext()) { i.next(); if(i.value().contains(devpath)) { - devicetype = i.key(); + devicetype = i.key().section("/",-1); } } - QStringList oldnetworks = knownNetworks[devicetype]; if(remainingNetworks.count() > oldnetworks.count()) { @@ -593,14 +596,16 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) QConnmanNetworkInterface *network; network = new QConnmanNetworkInterface(netPath, this); - serviceNetworks.insert(servicePath,netPath); const QString id = QString::number(qHash(servicePath)); if (!accessPointConfigurations.contains(id)) { - QConnmanDeviceInterface device(netPath.section("/",0,5),this); - knownNetworks[device.getType()]<< netPath; + + serviceNetworks.insert(servicePath,netPath); + + knownNetworks[device.getType()].append(netPath); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); @@ -661,10 +666,13 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); } - knownNetworks[device.getType()]<< networkPath; - serviceNetworks.insert(servicePath,networkPath); if (!accessPointConfigurations.contains(id)) { + + knownNetworks[device.getType()].append(networkPath); + + serviceNetworks.insert(servicePath,networkPath); + connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index ca76ffd..b20e7c1 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -208,17 +208,29 @@ void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/) { } -void QConnmanManagerInterface::registerCounter(QDBusObjectPath /*path*/, quint32 /*interval*/) -{ +void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval) +{ QDBusReply > reply = this->call(QLatin1String("RegisterCounter"), + QVariant::fromValue(path), + QVariant::fromValue(interval)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } } -void QConnmanManagerInterface::unregisterCounter(QDBusObjectPath /*path*/) -{ +void QConnmanManagerInterface::unregisterCounter(const QString &path) +{ QDBusReply > reply = this->call(QLatin1String("UnregisterCounter"), + QVariant::fromValue(path)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } } QString QConnmanManagerInterface::requestSession(const QString &bearerName) { - QDBusReply > reply = this->call(QLatin1String("RequestSession"), QVariant::fromValue(bearerName)); + QDBusReply > reply = this->call(QLatin1String("RequestSession"), + QVariant::fromValue(bearerName)); return QString(); } @@ -863,7 +875,29 @@ void QConnmanAgentInterface::cancel() ///////////////////////////////////////// +QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_COUNTER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanCounterInterface::~QConnmanCounterInterface() +{ +} + +quint32 QConnmanCounterInterface::getReceivedByteCount() +{ +return 0; +} + +quint32 QConnmanCounterInterface::getTransmittedByteCount() +{ +return 0; +} +///////////////////////////////////////// QConnmanDeviceInterface::QConnmanDeviceInterface(const QString &dbusPathName,QObject *parent) : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), dbusPathName, diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index 9475296..35e3f3d 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -115,8 +115,8 @@ public: QDBusObjectPath connectService(QVariantMap &map); void registerAgent(QDBusObjectPath &path); void unregisterAgent(QDBusObjectPath path); - void registerCounter(QDBusObjectPath path, quint32 interval); - void unregisterCounter(QDBusObjectPath path); + void registerCounter(const QString &path, quint32 interval); + void unregisterCounter(const QString &path); QString requestSession(const QString &bearerName); void releaseSession(); @@ -307,20 +307,24 @@ protected: void disconnectNotify(const char *signal); }; -//class QConnmanCounterInterfacePrivate; -//class QConnmanCounterInterface : public QDBusAbstractInterface -//{ -// Q_OBJECT -// -//public: -// -// QConnmanCounterInterface(QObject *parent = 0); -// ~QConnmanCounterInterface(); -// +class QConnmanCounterInterfacePrivate; +class QConnmanCounterInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanCounterInterface(const QString &dbusPathName, QObject *parent = 0); + ~QConnmanCounterInterface(); + // void release(); -//private: -// QConnmanCounterInterfacePrivate *d; -//}; + QString getInterface(); + quint32 getReceivedByteCount(); + quint32 getTransmittedByteCount(); + +private: + QConnmanCounterInterfacePrivate *d; +}; class QConnmanDeviceInterface : public QDBusAbstractInterface { -- cgit v0.12 From b0bbabe728fedb8531fc2837403856bd5ed44e1b Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 30 Jun 2010 14:31:49 +0200 Subject: Avoid blurry text with OpenVG on Symbian Qt's graphics system uses qreal as measurement unit. The established paint engines (such as "raster") implicitly round textitem coordinates for technical reasons, e.g. for optimized blitting. Some Qt based Ui libraries (such as QWidgets) can in some cases cause textitems to be drawn on non-integer coordinates. In particular, this happens when centering text. Since these libraries have been developed against the established paint engines with implicit rounding, these non-integer coordinates were never an issue. The new OpenVG paintengine took these coordinates seriously without rounding them. On some OpenVG implementations (e.g. that of some Symbian phones), this led to blurry text rendering. This patch adds coordinate rounding for unscaled, unrotated textitems to the OpenVG paintengine. So that it does the same as the raster paint engine. Task-number: QT-3071 Reviewed-By: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index cfc481e..515197a 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3424,7 +3424,13 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) // Set the transformation to use for drawing the current glyphs. QTransform glyphTransform(d->pathTransform); - glyphTransform.translate(p.x(), p.y()); + if (d->transform.type() <= QTransform::TxTranslate) { + // Prevent blurriness of unscaled, unrotated text by using integer coordinates. + // Using ceil(x-0.5) instead of qRound() or int-cast, behave like other paint engines. + glyphTransform.translate(ceil(p.x() - 0.5), ceil(p.y() - 0.5)); + } else { + glyphTransform.translate(p.x(), p.y()); + } #if defined(QVG_NO_IMAGE_GLYPHS) glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY); #endif -- cgit v0.12 From 76274d40569f45cec50ad5df8646e09e40117007 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 1 Jul 2010 10:12:58 +0100 Subject: Fix QXmlQuery autotest on Symbian Deployment of the test files to ../xmlpatterns resolves to c:/private/xmlpatterns, which is an illegal location to deploy to on symbian. Changed the deployment and test to put the xmlpatterns directory inside the app's private directory on symbian Regression tested on windows build. Reviewed-by: mread --- tests/auto/qxmlquery/qxmlquery.pro | 7 ++++++- tests/auto/qxmlquery/tst_qxmlquery.cpp | 25 ++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/auto/qxmlquery/qxmlquery.pro b/tests/auto/qxmlquery/qxmlquery.pro index cfab564..c9429ed 100644 --- a/tests/auto/qxmlquery/qxmlquery.pro +++ b/tests/auto/qxmlquery/qxmlquery.pro @@ -23,7 +23,12 @@ wince*|symbian*: { addFiles.path = . patternistFiles.sources = ../xmlpatterns/queries - patternistFiles.path = ../xmlpatterns + symbian: { + #../xmlpatterns resolves to an illegal path for deployment + patternistFiles.path = xmlpatterns + } else { + patternistFiles.path = ../xmlpatterns + } DEPLOYMENT += addFiles patternistFiles } diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index be0d708..9a3d65d 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -67,6 +67,9 @@ #if defined(Q_OS_SYMBIAN) #define SRCDIR "" +#define XMLPATTERNSDIR "xmlpatterns" +#else +#define XMLPATTERNSDIR SRCDIR "../xmlpatterns" #endif /*! @@ -264,7 +267,7 @@ void tst_QXmlQuery::checkBaseURI(const QUrl &baseURI, const QString &candidate) QVERIFY(QDir(baseURI.toLocalFile()).relativeFilePath(QFileInfo(candidate).canonicalFilePath()).startsWith("../")); } -const char *const tst_QXmlQuery::queriesDirectory = SRCDIR "../xmlpatterns/queries/"; +const char *const tst_QXmlQuery::queriesDirectory = XMLPATTERNSDIR "/queries/"; QStringList tst_QXmlQuery::queries() { @@ -857,7 +860,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"), QVariant(QLatin1String("param5"))); - stylesheet.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); + stylesheet.setQuery(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/parameters.xsl")))); QVERIFY(stylesheet.isValid()); @@ -1798,11 +1801,11 @@ void tst_QXmlQuery::setFocusQUrl() const { QXmlQuery query(QXmlQuery::XSLT20); - const TestURIResolver resolver(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + const TestURIResolver resolver(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setUriResolver(&resolver); QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI")))); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); + query.setQuery(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/copyWholeDocument.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -2997,7 +3000,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const QCOMPARE(query.initialTemplateName(), name); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); + query.setQuery(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/namedTemplate.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -3059,7 +3062,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure fn:doc() picks up the right QNetworkAccessManager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); + QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3075,7 +3078,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure setQuery() is using the right network manager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); + QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/queries/concat.xq")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3133,9 +3136,9 @@ void tst_QXmlQuery::multipleDocsAndFocus() const /* We use string concatenation, since variable bindings might disturb what * we're testing. */ query.setQuery(QLatin1String("string(doc('") + - inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) + + inputFile(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml")) + QLatin1String("'))")); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QStringList result; @@ -3159,11 +3162,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const QXmlQuery query; QStringList result; - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QVERIFY(query.evaluateTo(&result)); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFile(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); QVERIFY(query.evaluateTo(&result)); } -- cgit v0.12 From 47589ccc85c4aa2f40d7ceb5f0363b76b782198a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 1 Jul 2010 10:17:57 +0100 Subject: Fix RVCT compile error in QGraphicsSceneIndex autotest The test code used the 'using' keyword to try and change access control of a base class method from protected to public. With the RVCT 2.2 compiler, 'using' imports the function(s) from the base class, but they retain their existing access control. Used an inline public function to call the base class as a workaround Reviewed-by: mread --- tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 6396e44..dba8a64 100644 --- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -224,7 +224,18 @@ void tst_QGraphicsSceneIndex::connectedToSceneRectChanged() { class MyScene : public QGraphicsScene - { public: using QGraphicsScene::receivers; }; + { + public: +#ifdef Q_CC_RVCT + //using keyword doesn't change visibility to public in RVCT2.2 compiler + inline int receivers(const char* signal) const + { + return QGraphicsScene::receivers(signal); + } +#else + using QGraphicsScene::receivers; +#endif + }; MyScene scene; // Uses QGraphicsSceneBspTreeIndex by default. QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1); -- cgit v0.12 From cb3309b28b9d81af33b0ef92f2ae727d0d91b939 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 20 Apr 2010 15:42:16 +0200 Subject: Fix compile error in QFileDialog autotest Reviewed-by: Trust Me --- tests/auto/qfiledialog/tst_qfiledialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 9adb4fc..38a1ee7 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -548,7 +548,7 @@ void tst_QFiledialog::completer() // ### FIXME: This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel // are fixed to properly capitalize paths, so that some folders are not duplicated in QFileSystemModel. #if defined(Q_OS_SYMBIAN) - QSKIP("This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel are fixed to properly capitalize paths") + QSKIP("This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel are fixed to properly capitalize paths", SkipAll); #endif QTRY_COMPARE(cModel->rowCount(), expected); } QT_CATCH(...) { -- cgit v0.12 From 3475453895ff5fb393d375202581e3236c0340e8 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 1 Jul 2010 15:32:20 +0200 Subject: Using the remaining valid data to construct the QTime object when msec parsing failed. It's relevant with QTBUG-11623, but not a fix for it. Reviewed-by: Aleksandar Sasha Babic --- src/corelib/tools/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index c1027ed..347de0c 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1914,7 +1914,7 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f) const QString msec_s(QLatin1String("0.") + s.mid(9, 4)); const float msec(msec_s.toFloat(&ok)); if (!ok) - return QTime(); + return QTime(hour, minute, second, 0); return QTime(hour, minute, second, qMin(qRound(msec * 1000.0), 999)); } } -- cgit v0.12 From 6d5e561be6f013f7cb5c77e15ee6b7640cad7563 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 2 Jul 2010 10:12:47 +1000 Subject: Segmentation Fault in QAudioOutputPrivate::freeBlocks() caused by wrong pointer increment Task-number:QTBUG-11883 Reviewed-by:Andrew den Exter --- src/multimedia/audio/qaudioinput_win32_p.cpp | 2 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 8240047..3f6e778 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -148,7 +148,7 @@ void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) for(int i = 0; i < count; i++) { waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); - blocks+=sizeof(WAVEHDR); + blocks++; } HeapFree(GetProcessHeap(), 0, blockArray); } diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 075d100..09771b3 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -193,7 +193,7 @@ void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) for(int i = 0; i < count; i++) { waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); - blocks+=sizeof(WAVEHDR); + blocks++; } HeapFree(GetProcessHeap(), 0, blockArray); } -- cgit v0.12 From f5c5e20ab20f016c07351330d03432e4912f20b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 28 Jun 2010 15:56:33 +0200 Subject: Fixed missing clip when computing the graphics item effect source rect. If item clips children to shape we should take that into account when computing the source rect, to avoid creating unnecessary large source pixmaps which might have a significant performance impact. Task-number: QT-3551 Reviewed-by: Gunnar Reviewed-by: Trond --- src/gui/graphicsview/qgraphicsitem.cpp | 27 +++++++++++++++++++--- src/gui/graphicsview/qgraphicsitem_p.h | 14 +++++++---- .../tst_qgraphicseffectsource.cpp | 15 ++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 074e571..88e9952 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1205,8 +1205,14 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q Returns the bounding rect of this item's children (excluding itself). */ -void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect) +void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, bool doClip) { + Q_Q(QGraphicsItem); + + QRectF childrenRect; + QRectF *result = rect; + rect = &childrenRect; + for (int i = 0; i < children.size(); ++i) { QGraphicsItem *child = children.at(i); QGraphicsItemPrivate *childd = child->d_ptr.data(); @@ -1228,6 +1234,15 @@ void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rec childd->childrenBoundingRectHelper(x, rect); } } + + if (doClip && (flags & QGraphicsItem::ItemClipsChildrenToShape)){ + if (x) + *rect &= x->mapRect(q->boundingRect()); + else + *rect &= q->boundingRect(); + } + + *result |= *rect; } void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, @@ -10816,8 +10831,14 @@ QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem syste } QRectF rect = item->boundingRect(); - if (!item->d_ptr->children.isEmpty()) - rect |= item->childrenBoundingRect(); + if (!item->d_ptr->children.isEmpty()) { + if (dirtyChildrenBoundingRect) { + childrenBoundingRect = QRectF(); + item->d_ptr->childrenBoundingRectHelper(0, &childrenBoundingRect, true); + dirtyChildrenBoundingRect = false; + } + rect |= childrenBoundingRect; + } if (deviceCoordinates) { Q_ASSERT(info->painter); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index e737773..ead240b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -239,7 +239,7 @@ public: void removeChild(QGraphicsItem *child); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); - void childrenBoundingRectHelper(QTransform *x, QRectF *rect); + void childrenBoundingRectHelper(QTransform *x, QRectF *rect, bool doClip = true); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; QRectF effectiveBoundingRect() const; @@ -580,7 +580,7 @@ class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QGraphicsItemEffectSourcePrivate(QGraphicsItem *i) - : QGraphicsEffectSourcePrivate(), item(i), info(0) + : QGraphicsEffectSourcePrivate(), dirtyChildrenBoundingRect(true), item(i), info(0) {} inline void detach() @@ -631,6 +631,9 @@ public: QGraphicsEffect::PixmapPadMode mode) const; QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const; + mutable bool dirtyChildrenBoundingRect; + mutable QRectF childrenBoundingRect; + QGraphicsItem *item; QGraphicsItemPaintInfo *info; QTransform lastEffectTransform; @@ -788,9 +791,12 @@ inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) #ifndef QT_NO_GRAPHICSEFFECT if (parentp->graphicsEffect) { if (updateBoundingRect) { + QGraphicsItemEffectSourcePrivate *sourcep = + static_cast(parentp->graphicsEffect->d_func() + ->source->d_func()); + parentp->dirtyChildrenBoundingRect = 1; parentp->notifyInvalidated = 1; - static_cast(parentp->graphicsEffect->d_func() - ->source->d_func())->invalidateCache(); + sourcep->invalidateCache(); } if (parentp->graphicsEffect->isEnabled()) { parentp->dirty = 1; diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 49f110e..49a76fa 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -161,6 +161,7 @@ private slots: void draw(); void update(); void boundingRect(); + void clippedBoundingRect(); void deviceRect(); void pixmap(); @@ -282,6 +283,20 @@ void tst_QGraphicsEffectSource::boundingRect() QTRY_COMPARE(effect->source()->boundingRect(), itemBoundingRect); } +void tst_QGraphicsEffectSource::clippedBoundingRect() +{ + QRectF itemBoundingRect = item->boundingRect(); + item->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *child = new QGraphicsRectItem(-1000, -1000, 2000, 2000); + child->setBrush(Qt::red); + child->setParentItem(item); + + effect->storeDeviceDependentStuff = true; + effect->source()->update(); + QTRY_COMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); +} + void tst_QGraphicsEffectSource::deviceRect() { effect->storeDeviceDependentStuff = true; -- cgit v0.12 From ce4ed8fa50a72927d68c4c68c04a28d783546c07 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 2 Jul 2010 16:55:00 +0200 Subject: Removed missing symbols from DEF files. RevBy: Jason Barron --- src/s60installs/bwins/QtGuiu.def | 2 +- src/s60installs/eabi/QtGuiu.def | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 3368e4c..cde0b60 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -2645,7 +2645,7 @@ EXPORTS ?childItems@QGraphicsItem@@QBE?AV?$QList@PAVQGraphicsItem@@@@XZ @ 2644 NONAME ; class QList QGraphicsItem::childItems(void) const ?children@QGraphicsItem@@QBE?AV?$QList@PAVQGraphicsItem@@@@XZ @ 2645 NONAME ; class QList QGraphicsItem::children(void) const ?childrenBoundingRect@QGraphicsItem@@QBE?AVQRectF@@XZ @ 2646 NONAME ; class QRectF QGraphicsItem::childrenBoundingRect(void) const - ?childrenBoundingRectHelper@QGraphicsItemPrivate@@QAEXPAVQTransform@@PAVQRectF@@@Z @ 2647 NONAME ; void QGraphicsItemPrivate::childrenBoundingRectHelper(class QTransform *, class QRectF *) + ?childrenBoundingRectHelper@QGraphicsItemPrivate@@QAEXPAVQTransform@@PAVQRectF@@@Z @ 2647 NONAME ABSENT ; void QGraphicsItemPrivate::childrenBoundingRectHelper(class QTransform *, class QRectF *) ?childrenCheckState@QTreeWidgetItem@@ABE?AVQVariant@@H@Z @ 2648 NONAME ; class QVariant QTreeWidgetItem::childrenCheckState(int) const ?childrenClippedToShape@QGraphicsItemPrivate@@QBE_NXZ @ 2649 NONAME ; bool QGraphicsItemPrivate::childrenClippedToShape(void) const ?childrenCollapsible@QSplitter@@QBE_NXZ @ 2650 NONAME ; bool QSplitter::childrenCollapsible(void) const diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index cfe2630..4c57c03 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -4675,7 +4675,7 @@ EXPORTS _ZN20QGraphicsItemPrivate20removeExtraItemCacheEv @ 4674 NONAME _ZN20QGraphicsItemPrivate23appendGraphicsTransformEP18QGraphicsTransform @ 4675 NONAME _ZN20QGraphicsItemPrivate25movableAncestorIsSelectedEPK13QGraphicsItem @ 4676 NONAME - _ZN20QGraphicsItemPrivate26childrenBoundingRectHelperEP10QTransformP6QRectF @ 4677 NONAME + _ZN20QGraphicsItemPrivate26childrenBoundingRectHelperEP10QTransformP6QRectF @ 4677 NONAME ABSENT _ZN20QGraphicsItemPrivate26invalidateDepthRecursivelyEv @ 4678 NONAME _ZN20QGraphicsItemPrivate28ensureSequentialSiblingIndexEv @ 4679 NONAME _ZN20QGraphicsItemPrivate29ensureSceneTransformRecursiveEPP13QGraphicsItem @ 4680 NONAME -- cgit v0.12 From 46ff093e22f95aa5e634e7edc6484ee717054625 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 5 Jul 2010 14:46:09 +1000 Subject: Include qmath.h to get the definition of ceil() Reviewed-by: Julian de Bhal --- src/openvg/qpaintengine_vg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 515197a..7a050f6 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include -- cgit v0.12 From 752d46c90ee0fc5f06f01feedd8e0659178b15d4 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 5 Jul 2010 15:35:51 +0200 Subject: Support time zone designator in QDateTime::fromString() based on ISO 8601-2004 standard. Task-number: QTBUG-11623 Reviewed-by: Denis Dzyubenko Reviewed-by: David Boddie --- doc/src/external-resources.qdoc | 5 +++++ src/corelib/global/qnamespace.qdoc | 5 +++-- src/corelib/tools/qdatetime.cpp | 27 ++++++++++++++++++++++++++- tests/auto/qdatetime/tst_qdatetime.cpp | 6 ++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 3ca50b4..b4324af 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -422,3 +422,8 @@ \externalpage http://www.w3.org/XML/Schema \title XML Schema */ + +/*! + \externalpage http://www.iso.org/iso/date_and_time_format + \title ISO 8601 +*/ diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index a756565..15c4efc 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -577,8 +577,9 @@ be short, localized names. This is basically equivalent to using the date format string, "ddd MMM d yyyy". See QDate::toString() for more information. - \value ISODate ISO 8601 extended format: either \c{YYYY-MM-DD} for dates or - \c{YYYY-MM-DDTHH:MM:SS} for combined dates and times. + \value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or + \c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00) + for combined dates and times. \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used by the \l{QLocale::system()}{operating system}. diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 347de0c..c6ab4e4 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3044,12 +3044,37 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) if (tmp.size() == 10) return QDateTime(date); + tmp = tmp.mid(11); + // Recognize UTC specifications if (tmp.endsWith(QLatin1Char('Z'))) { ts = Qt::UTC; tmp.chop(1); } - return QDateTime(date, QTime::fromString(tmp.mid(11), Qt::ISODate), ts); + + // Recognize timezone specifications + QRegExp rx(QLatin1String("[+-]")); + if (tmp.contains(rx)) { + int idx = tmp.indexOf(rx); + QString tmp2 = tmp.mid(idx); + tmp = tmp.left(idx); + bool ok = true; + int ntzhour = 1; + int ntzminute = 3; + if ( tmp2.indexOf(QLatin1Char(':')) == 3 ) + ntzminute = 4; + const int tzhour(tmp2.mid(ntzhour, 2).toInt(&ok)); + const int tzminute(tmp2.mid(ntzminute, 2).toInt(&ok)); + QTime tzt(tzhour, tzminute); + int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60; + if ( utcOffset != 0 ) { + ts = Qt::OffsetFromUTC; + QDateTime dt(date, QTime::fromString(tmp, Qt::ISODate), ts); + dt.setUtcOffset( utcOffset * (tmp2.startsWith(QLatin1Char('-')) ? -1 : 1) ); + return dt; + } + } + return QDateTime(date, QTime::fromString(tmp, Qt::ISODate), ts); } case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 86a4c80..d23133d 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -1286,6 +1286,12 @@ void tst_QDateTime::fromString() dt = QDateTime::fromString("2002-10-01", Qt::ISODate); QCOMPARE(dt, QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0))); + dt = QDateTime::fromString("1987-02-13T13:24:51+01:00", Qt::ISODate); + QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC)); + + dt = QDateTime::fromString("1987-02-13T13:24:51-01:00", Qt::ISODate); + QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC)); + dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT"); QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); -- cgit v0.12 From 8ef60f0791c1fb7fa649214238db6db3e2d975c6 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 5 Jul 2010 16:42:44 +0200 Subject: Revert "Support time zone designator in QDateTime::fromString() based on ISO 8601-2004 standard." This reverts commit 752d46c90ee0fc5f06f01feedd8e0659178b15d4. --- doc/src/external-resources.qdoc | 5 ----- src/corelib/global/qnamespace.qdoc | 5 ++--- src/corelib/tools/qdatetime.cpp | 27 +-------------------------- tests/auto/qdatetime/tst_qdatetime.cpp | 6 ------ 4 files changed, 3 insertions(+), 40 deletions(-) diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index b4324af..3ca50b4 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -422,8 +422,3 @@ \externalpage http://www.w3.org/XML/Schema \title XML Schema */ - -/*! - \externalpage http://www.iso.org/iso/date_and_time_format - \title ISO 8601 -*/ diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 15c4efc..a756565 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -577,9 +577,8 @@ be short, localized names. This is basically equivalent to using the date format string, "ddd MMM d yyyy". See QDate::toString() for more information. - \value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or - \c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00) - for combined dates and times. + \value ISODate ISO 8601 extended format: either \c{YYYY-MM-DD} for dates or + \c{YYYY-MM-DDTHH:MM:SS} for combined dates and times. \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used by the \l{QLocale::system()}{operating system}. diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index c6ab4e4..347de0c 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3044,37 +3044,12 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) if (tmp.size() == 10) return QDateTime(date); - tmp = tmp.mid(11); - // Recognize UTC specifications if (tmp.endsWith(QLatin1Char('Z'))) { ts = Qt::UTC; tmp.chop(1); } - - // Recognize timezone specifications - QRegExp rx(QLatin1String("[+-]")); - if (tmp.contains(rx)) { - int idx = tmp.indexOf(rx); - QString tmp2 = tmp.mid(idx); - tmp = tmp.left(idx); - bool ok = true; - int ntzhour = 1; - int ntzminute = 3; - if ( tmp2.indexOf(QLatin1Char(':')) == 3 ) - ntzminute = 4; - const int tzhour(tmp2.mid(ntzhour, 2).toInt(&ok)); - const int tzminute(tmp2.mid(ntzminute, 2).toInt(&ok)); - QTime tzt(tzhour, tzminute); - int utcOffset = (tzt.hour() * 60 + tzt.minute()) * 60; - if ( utcOffset != 0 ) { - ts = Qt::OffsetFromUTC; - QDateTime dt(date, QTime::fromString(tmp, Qt::ISODate), ts); - dt.setUtcOffset( utcOffset * (tmp2.startsWith(QLatin1Char('-')) ? -1 : 1) ); - return dt; - } - } - return QDateTime(date, QTime::fromString(tmp, Qt::ISODate), ts); + return QDateTime(date, QTime::fromString(tmp.mid(11), Qt::ISODate), ts); } case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index d23133d..86a4c80 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -1286,12 +1286,6 @@ void tst_QDateTime::fromString() dt = QDateTime::fromString("2002-10-01", Qt::ISODate); QCOMPARE(dt, QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0))); - dt = QDateTime::fromString("1987-02-13T13:24:51+01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC)); - - dt = QDateTime::fromString("1987-02-13T13:24:51-01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC)); - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT"); QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); -- cgit v0.12 From 919dc2dca2ceff3848f6c91819845819f91fb68e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 5 Jul 2010 07:22:42 -0700 Subject: Spectrum build: fixed DLL rpath Rather than explicitly modifying LD_LIBRARY_PATH using a shell script when the application is launched, the relative path from the application binary to the FFT library is encoded in the application using an --rpath flag. Task-number: QTBUG-11756 Reviewed-by: Andy Shaw --- demos/spectrum/app/app.pro | 13 +++-------- demos/spectrum/app/spectrum.sh | 50 ------------------------------------------ 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 demos/spectrum/app/spectrum.sh diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index 22ee3b1..5410b2b 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -3,7 +3,6 @@ include(../spectrum.pri) TEMPLATE = app TARGET = spectrum -unix: !macx: !symbian: TARGET = spectrum.bin QT += multimedia @@ -112,15 +111,9 @@ symbian { # Specify directory in which to create spectrum application DESTDIR = ../bin - unix: !symbian { - # On unices other than Mac OSX, we copy a shell script into the bin directory. - # This script takes care of correctly setting the LD_LIBRARY_PATH so that - # the dynamic library can be located. - copy_launch_script.target = copy_launch_script - copy_launch_script.commands = \ - install -m 0555 $$QT_SOURCE_TREE/demos/spectrum/app/spectrum.sh ../bin/spectrum - QMAKE_EXTRA_TARGETS += copy_launch_script - POST_TARGETDEPS += copy_launch_script + unix: { + # Provide relative path from application to fftreal library + QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN } } } diff --git a/demos/spectrum/app/spectrum.sh b/demos/spectrum/app/spectrum.sh deleted file mode 100644 index 2a230ed..0000000 --- a/demos/spectrum/app/spectrum.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -############################################################################# -## -## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -## All rights reserved. -## Contact: Nokia Corporation (qt-info@nokia.com) -## -## This file is part of the examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:LGPL$ -## No Commercial Usage -## This file contains pre-release code and may not be distributed. -## You may use this file in accordance with the terms and conditions -## contained in the Technology Preview License Agreement accompanying -## this package. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 2.1 as published by the Free Software -## Foundation and appearing in the file LICENSE.LGPL included in the -## packaging of this file. Please review the following information to -## ensure the GNU Lesser General Public License version 2.1 requirements -## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -## -## In addition, as a special exception, Nokia gives you certain additional -## rights. These rights are described in the Nokia Qt LGPL Exception -## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -## -## If you have questions regarding the use of this file, please contact -## Nokia at qt-info@nokia.com. -## -## -## -## -## -## -## -## -## $QT_END_LICENSE$ -## -############################################################################# - - -# Shell script for launching spectrum application on Unix systems other than Mac OSX - -bindir=`dirname "$0"` -LD_LIBRARY_PATH="${bindir}:${LD_LIBRARY_PATH}" -export LD_LIBRARY_PATH -exec "${bindir}/spectrum.bin" ${1+"$@"} - -- cgit v0.12 From e7f6c2d9625bda1d063b9ec3acd7eb5f79f30ba7 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 5 Jul 2010 11:39:37 +0100 Subject: Spectrum demo: fixed installation All binaries must be written into $$QT_BUILD_DIR/demos/spectrum in order for them to be correctly installed. Task-number: QTBUG-11572 Task-number: QTBUG-11756 Reviewed-by: Andy Shaw --- demos/spectrum/3rdparty/fftreal/fftreal.pro | 14 ++++++++------ demos/spectrum/app/app.pro | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pro b/demos/spectrum/3rdparty/fftreal/fftreal.pro index 6801b42..c9da205 100644 --- a/demos/spectrum/3rdparty/fftreal/fftreal.pro +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pro @@ -1,3 +1,5 @@ +include(../../spectrum.pri) + TEMPLATE = lib TARGET = fftreal @@ -31,13 +33,13 @@ symbian { # Provide unique ID for the generated binary, required by Symbian OS TARGET.UID3 = 0xA000E403 TARGET.CAPABILITY = UserEnvironment +} + +macx { + CONFIG += lib_bundle } else { - macx { - CONFIG += lib_bundle - } else { - DESTDIR = ../../bin - } -} + !symbian: DESTDIR = ../.. +} # Install diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index 5410b2b..6c74b27 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -62,8 +62,7 @@ symbian { LIBS += -F$${fftreal_dir} LIBS += -framework fftreal } else { - # Link to dynamic library which is written to ../bin - LIBS += -L../bin + LIBS += -L.. LIBS += -lfftreal } } @@ -109,7 +108,7 @@ symbian { } } else { # Specify directory in which to create spectrum application - DESTDIR = ../bin + DESTDIR = .. unix: { # Provide relative path from application to fftreal library -- cgit v0.12 From 2de46daf6568c85d976a1e784c0bafbea89adb3a Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 7 Jul 2010 15:21:48 +1000 Subject: Don't try and use QFactoryLoader when relevant features are turned off. Task-number: QTBUG-11900 Reviewed-by: Andrew den Exter --- src/multimedia/audio/qaudiodevicefactory.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 4f45110..523075c 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -67,8 +67,11 @@ QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QAudioEngineFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) +#endif class QNullDeviceInfo : public QAbstractAudioDeviceInfo @@ -137,6 +140,7 @@ QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif #endif +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QFactoryLoader* l = loader(); foreach (QString const& key, l->keys()) { @@ -148,12 +152,13 @@ QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) delete plugin; } - +#endif return devices; } QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() { +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { @@ -161,6 +166,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } +#endif #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); @@ -171,6 +177,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { @@ -178,6 +185,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } +#endif #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); @@ -196,12 +204,13 @@ QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &re return new QAudioDeviceInfoInternal(handle, mode); #endif #endif +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(realm)); if (plugin) rc = plugin->createDeviceInfo(handle, mode); - +#endif return rc == 0 ? new QNullDeviceInfo() : rc; } @@ -225,12 +234,13 @@ QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo con return new QAudioInputPrivate(deviceInfo.handle(), format); #endif #endif +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(deviceInfo.realm())); if (plugin) return plugin->createInput(deviceInfo.handle(), format); - +#endif return new QNullInputDevice(); } @@ -244,12 +254,13 @@ QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo c return new QAudioOutputPrivate(deviceInfo.handle(), format); #endif #endif +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(deviceInfo.realm())); if (plugin) return plugin->createOutput(deviceInfo.handle(), format); - +#endif return new QNullOutputDevice(); } -- cgit v0.12 From 0c71b098965ce4779a7da785249497c15b9d1d14 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Jun 2010 11:30:05 +0100 Subject: Prevent crash when video is played without a VideoWidget The Phonon API allows video to be played via a Phonon::MediaObject, even if no Phonon::VideoWidget has been connected to it. This patch prevents the Phonon MMF backend crashing in this scenario due to dereferencing a null pointer. Reviewed-by: Thierry Bastian --- src/3rdparty/phonon/mmf/abstractvideoplayer.cpp | 10 ++++++++-- src/3rdparty/phonon/mmf/videoplayer_dsa.cpp | 7 ++++++- src/3rdparty/phonon/mmf/videoplayer_surface.cpp | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp index 2e0ab1c..ecfce9e 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -211,7 +211,8 @@ void MMF::AbstractVideoPlayer::aspectRatioChanged() TRACE_CONTEXT(AbstractVideoPlayer::aspectRatioChanged, EVideoInternal); TRACE_ENTRY("state %d aspectRatio %d", state()); - updateScaleFactors(m_videoOutput->videoWindowSize()); + if (m_videoOutput) + updateScaleFactors(m_videoOutput->videoWindowSize()); TRACE_EXIT_0(); } @@ -221,7 +222,8 @@ void MMF::AbstractVideoPlayer::scaleModeChanged() TRACE_CONTEXT(AbstractVideoPlayer::scaleModeChanged, EVideoInternal); TRACE_ENTRY("state %d", state()); - updateScaleFactors(m_videoOutput->videoWindowSize()); + if (m_videoOutput) + updateScaleFactors(m_videoOutput->videoWindowSize()); TRACE_EXIT_0(); } @@ -357,6 +359,8 @@ void MMF::AbstractVideoPlayer::videoOutputChanged() void MMF::AbstractVideoPlayer::initVideoOutput() { + Q_ASSERT(m_videoOutput); + bool connected = connect( m_videoOutput, SIGNAL(videoWindowChanged()), this, SLOT(videoWindowChanged()) @@ -400,6 +404,8 @@ QSize scaleToAspect(const QSize &srcRect, int aspectWidth, int aspectHeight) void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply) { + Q_ASSERT(m_videoOutput); + if (m_videoFrameSize.isValid()) { QRect videoRect; diff --git a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp index 1925471..f0255b1 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp @@ -61,6 +61,8 @@ DsaVideoPlayer::~DsaVideoPlayer() void MMF::DsaVideoPlayer::videoWindowScreenRectChanged() { + Q_ASSERT(m_videoOutput); + QRect windowRect = static_cast(m_videoOutput)->videoWindowScreenRect(); // Clip to physical window size @@ -130,6 +132,8 @@ void MMF::DsaVideoPlayer::createPlayer() void MMF::DsaVideoPlayer::initVideoOutput() { + Q_ASSERT(m_videoOutput); + bool connected = connect( m_videoOutput, SIGNAL(videoWindowScreenRectChanged()), this, SLOT(videoWindowScreenRectChanged()) @@ -156,7 +160,8 @@ void MMF::DsaVideoPlayer::initVideoOutput() void MMF::DsaVideoPlayer::prepareCompleted() { - videoWindowScreenRectChanged(); + if (m_videoOutput) + videoWindowScreenRectChanged(); } void MMF::DsaVideoPlayer::handleVideoWindowChanged() diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp index fda7342..5d8db26 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp @@ -59,7 +59,8 @@ SurfaceVideoPlayer::~SurfaceVideoPlayer() void MMF::SurfaceVideoPlayer::videoWindowSizeChanged() { - updateScaleFactors(m_videoOutput->videoWindowSize()); + if (m_videoOutput) + updateScaleFactors(m_videoOutput->videoWindowSize()); } @@ -80,6 +81,8 @@ void MMF::SurfaceVideoPlayer::createPlayer() void MMF::SurfaceVideoPlayer::initVideoOutput() { + Q_ASSERT(m_videoOutput); + bool connected = connect( m_videoOutput, SIGNAL(videoWindowSizeChanged()), this, SLOT(videoWindowSizeChanged()) -- cgit v0.12 From 80af9a7b09b531a849b863695b244dd1df7dfb1d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Jun 2010 14:56:31 +0100 Subject: Enable bufferStatus signal during video clip loading on NGA platforms CVideoPlayerUtility::RegisterForVideoLoadingNotification() was only called in the DSA, not the NGA, variant of the Phonon MMF backend. Task-number: QTBUG-11378 Reviewed-by: Thierry Bastian --- src/3rdparty/phonon/mmf/abstractvideoplayer.cpp | 2 ++ src/3rdparty/phonon/mmf/videoplayer_dsa.cpp | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp index ecfce9e..c45ed98 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -66,6 +66,8 @@ void MMF::AbstractVideoPlayer::construct() createPlayer(); + m_player->RegisterForVideoLoadingNotification(*this); + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp index f0255b1..deb9774 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp @@ -126,8 +126,6 @@ void MMF::DsaVideoPlayer::createPlayer() // CVideoPlayerUtility::NewL starts DSA m_dsaActive = true; - - m_player->RegisterForVideoLoadingNotification(*this); } void MMF::DsaVideoPlayer::initVideoOutput() -- cgit v0.12 From 50fbb9d19b3f524361c146de8ff0fb2fe6abacc9 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Jun 2010 14:37:21 +0100 Subject: Close media clip before creating new player object Failure to Close() an existing MMF player utility object before creating a new one - which happens in the MMF backend's implementation of Phonon::MediaObject::setCurrentSource() - causes intialization of the newly-created utility to fail later on. Task-number: QTBUG-11377 Reviewed-by: Thierry Bastian --- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 1 - src/3rdparty/phonon/mmf/abstractplayer.h | 1 + src/3rdparty/phonon/mmf/dummyplayer.cpp | 4 ++++ src/3rdparty/phonon/mmf/dummyplayer.h | 1 + src/3rdparty/phonon/mmf/mediaobject.cpp | 3 +++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 23a8233..7d28caf 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -71,7 +71,6 @@ protected: virtual int openFile(RFile& file) = 0; virtual int openUrl(const QString& url) = 0; virtual int bufferStatus() const = 0; - virtual void close() = 0; void updateMetaData(); virtual int numberOfMetaDataEntries() const = 0; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index ab892f5..30d5243 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -55,6 +55,7 @@ public: AbstractPlayer(const AbstractPlayer *player); virtual void open(const Phonon::MediaSource&, RFile&) = 0; + virtual void close() = 0; // MediaObjectInterface (implemented) qint32 tickInterval() const; diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index 6970088..d39ef76 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -97,6 +97,10 @@ void MMF::DummyPlayer::open(const Phonon::MediaSource &, RFile &) } +void MMF::DummyPlayer::close() +{ + +} //----------------------------------------------------------------------------- // AbstractPlayer diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 6841b5d..9d45696 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -58,6 +58,7 @@ public: // AbstractPlayer virtual void open(const Phonon::MediaSource&, RFile&); + virtual void close(); virtual void doSetTickInterval(qint32 interval); }; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index e1b921b..d264377 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -281,6 +281,9 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; } + if (oldPlayer) + oldPlayer->close(); + AbstractPlayer* newPlayer = 0; // Construct newPlayer using oldPlayer (if not 0) in order to copy -- cgit v0.12 From 31d4037ad8e07fc4302a846271b28965f3e11069 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Jun 2010 16:06:37 +0100 Subject: Fixed crash which occurs when switching between video clips When Phonon::MediaObject::setCurrentSource() is called when the MediaObject is connected to a Phonon::VideoWidget, the MMF::AbstractVideoOutput pointer is propagated inside the backend from the first MMF::AbstractVideoPlayer to the second. If the VideoWidget is subsquently re-sized, the code path enters the ScaleFactors branch of the MMF::SurfaceVideoPlayer::handleParametersChanged function. At this point, m_displayWindow is still set to the inital null value, and the assertion therefore fails. This change ensures that m_displayWindow is updated before attempting to apply the scale factor change. Task-number: QTBUG-11377 Reviewed-by: Thierry Bastian --- src/3rdparty/phonon/mmf/videoplayer_surface.cpp | 42 +++++++++++++++++-------- src/3rdparty/phonon/mmf/videoplayer_surface.h | 3 ++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp index 5d8db26..343370c 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp @@ -118,23 +118,14 @@ void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters if (player) { int err = KErrNone; if (parameters & WindowHandle) { - if (m_displayWindow) - player->RemoveDisplayWindow(*m_displayWindow); - - RWindow *window = static_cast(m_window); - if (window) { - window->SetBackgroundColor(TRgb(0, 0, 0, 255)); - TRAP(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect)); - if (KErrNone != err) { - setError(tr("Video display error"), err); - window = 0; - } - } - m_displayWindow = window; + removeDisplayWindow(); + addDisplayWindow(rect); } if (KErrNone == err) { if (parameters & ScaleFactors) { + if (!m_displayWindow) + addDisplayWindow(rect); Q_ASSERT(m_displayWindow); TRAP(err, player->SetVideoExtentL(*m_displayWindow, rect)); if (KErrNone == err) @@ -148,5 +139,30 @@ void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters } } +void MMF::SurfaceVideoPlayer::addDisplayWindow(const TRect &rect) +{ + Q_ASSERT(!m_displayWindow); + RWindow *window = static_cast(m_window); + if (window) { + window->SetBackgroundColor(TRgb(0, 0, 0, 255)); + CVideoPlayerUtility2 *player = static_cast(m_player.data()); + Q_ASSERT(player); + TRAPD(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect)); + if (KErrNone == err) + m_displayWindow = window; + else + setError(tr("Video display error"), err); + } +} + +void MMF::SurfaceVideoPlayer::removeDisplayWindow() +{ + CVideoPlayerUtility2 *player = static_cast(m_player.data()); + if (player && m_displayWindow) { + player->RemoveDisplayWindow(*m_displayWindow); + m_displayWindow = 0; + } +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.h b/src/3rdparty/phonon/mmf/videoplayer_surface.h index c05da9c..8572fdc 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_surface.h +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.h @@ -62,6 +62,9 @@ private: void handleVideoWindowChanged(); void handleParametersChanged(VideoParameters parameters); + void addDisplayWindow(const TRect &rect); + void removeDisplayWindow(); + private: // Window handle which has been passed to the MMF via // CVideoPlayerUtility2::SetDisplayWindowL -- cgit v0.12 From 64f711e91a30c7689314f4bceca78745236f8bee Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Jun 2010 09:42:52 +0100 Subject: MMF Phonon backend: call winId() from VideoWidget constructor This is to be consistent with the backends for other platforms, which also call QWidget::winId() on the VideoWidget (or one of its children) during construction. Reviewed-by: Thierry Bastian --- src/3rdparty/phonon/mmf/abstractvideooutput.cpp | 3 ++- src/3rdparty/phonon/mmf/abstractvideoplayer.cpp | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractvideooutput.cpp b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp index a8aabfd..2d221ed 100644 --- a/src/3rdparty/phonon/mmf/abstractvideooutput.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp @@ -60,7 +60,8 @@ MMF::AbstractVideoOutput::AbstractVideoOutput(QWidget *parent) , m_aspectRatio(DefaultAspectRatio) , m_scaleMode(DefaultScaleMode) { - + // Ensure that this widget has a native window handle + winId(); } MMF::AbstractVideoOutput::~AbstractVideoOutput() diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp index c45ed98..9ea4d18 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -384,9 +384,6 @@ void MMF::AbstractVideoPlayer::initVideoOutput() // Suppress warnings in release builds Q_UNUSED(connected); - // Do these after all connections are complete, to ensure - // that any signals generated get to their destinations. - m_videoOutput->winId(); m_videoOutput->setVideoSize(m_videoFrameSize); } -- cgit v0.12 From f91a2789c385af25310ac5f0463d5bb3311ec089 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 7 Jul 2010 16:06:11 +0200 Subject: Fix crash when removing columns in merged row Change 4b709b41f5a7ae8dc6e537b644158f5201ce0a98 tried to make sure that rows with merged cells would not be completely removed, as this would cause a crash. However, when removing just a few columns from a merged cell, the span of the cell should be reduced by the number of columns removed. The "touched" guard would cause the span to be decreased a maximum of one time, regardless of how many columns were removed, leaving the table in an invalid state, as the column count would be smaller than the span of the cell. This would assert later on. To avoid this, we only guard against removal, not against decreasing the span. Task-number: QTBUG-11646 Reviewed-by: Thomas Zander --- src/gui/text/qtexttable.cpp | 7 ++++--- tests/auto/qtexttable/tst_qtexttable.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 5100176..ada18c8 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -915,12 +915,13 @@ void QTextTable::removeColumns(int pos, int num) for (int r = 0; r < d->nRows; ++r) { for (int c = pos; c < pos + num; ++c) { int cell = d->grid[r*d->nCols + c]; - if (touchedCells.contains(cell)) - continue; - touchedCells << cell; QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); QTextCharFormat fmt = collection->charFormat(it->format); int span = fmt.tableCellColumnSpan(); + if (touchedCells.contains(cell) && span <= 1) + continue; + touchedCells << cell; + if (span > 1) { fmt.setTableCellColumnSpan(span - 1); p->setCharFormat(it.position(), 1, fmt); diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp index 2e6007e..c6ead5a 100644 --- a/tests/auto/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/qtexttable/tst_qtexttable.cpp @@ -93,6 +93,7 @@ private slots: void removeColumns3(); void removeColumns4(); void removeColumns5(); + void removeColumnsInTableWithMergedRows(); private: QTextTable *create2x2Table(); @@ -931,5 +932,18 @@ void tst_QTextTable::removeColumns5() QCOMPARE(table->cellAt(3, 2).firstPosition(), 11); } +void tst_QTextTable::removeColumnsInTableWithMergedRows() +{ + QTextTable *table = cursor.insertTable(3, 4); + table->mergeCells(0, 0, 1, 4); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 4); + + table->removeColumns(0, table->columns() - 1); + + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 1); +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" -- cgit v0.12 From 4c100e6f1ddecff46e5b1e46a481b62c275bc30d Mon Sep 17 00:00:00 2001 From: Roland Wolf Date: Wed, 26 May 2010 16:53:41 +0200 Subject: dummy commit to check permissions --- src/testfile.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/testfile.txt diff --git a/src/testfile.txt b/src/testfile.txt new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 09f3e7adf39ef93a9181486680fb6575b4d56de5 Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Wed, 26 May 2010 17:30:14 +0200 Subject: Michaels first commit --- doc/src/frameworks-technologies/modelview.qdoc | 840 +++++++++++++++++++++++++ doc/src/images/clock.png | Bin 0 -> 16514 bytes doc/src/images/columnview.png | Bin 0 -> 11717 bytes doc/src/images/combobox.png | Bin 0 -> 5022 bytes doc/src/images/dummy_tree.png | Bin 0 -> 20189 bytes doc/src/images/edit.png | Bin 0 -> 19636 bytes doc/src/images/example_model.png | Bin 0 -> 16577 bytes doc/src/images/header.png | Bin 0 -> 30302 bytes doc/src/images/lineedit.png | Bin 0 -> 2613 bytes doc/src/images/list_table_tree.png | Bin 0 -> 85530 bytes doc/src/images/listview.png | Bin 0 -> 9695 bytes doc/src/images/lotto.png | Bin 0 -> 17015 bytes doc/src/images/modelview.png | Bin 0 -> 2887 bytes doc/src/images/path.png | Bin 0 -> 31015 bytes doc/src/images/qcompleter.png | Bin 0 -> 17017 bytes doc/src/images/readonlytable.png | Bin 0 -> 28971 bytes doc/src/images/readonlytable_role.png | Bin 0 -> 27467 bytes doc/src/images/selection2.png | Bin 0 -> 23784 bytes doc/src/images/standardwidget.png | Bin 0 -> 1466 bytes doc/src/images/tableview.png | Bin 0 -> 10102 bytes doc/src/images/tree.png | Bin 0 -> 27074 bytes doc/src/images/tree_2.png | Bin 0 -> 14084 bytes doc/src/images/tree_2_with_algorithm.png | Bin 0 -> 16921 bytes doc/src/images/tree_city.png | Bin 0 -> 30398 bytes doc/src/images/treeview.png | Bin 0 -> 17173 bytes doc/src/images/widgetmapper.png | Bin 0 -> 20145 bytes 26 files changed, 840 insertions(+) create mode 100755 doc/src/frameworks-technologies/modelview.qdoc create mode 100755 doc/src/images/clock.png create mode 100755 doc/src/images/columnview.png create mode 100755 doc/src/images/combobox.png create mode 100755 doc/src/images/dummy_tree.png create mode 100755 doc/src/images/edit.png create mode 100755 doc/src/images/example_model.png create mode 100755 doc/src/images/header.png create mode 100755 doc/src/images/lineedit.png create mode 100755 doc/src/images/list_table_tree.png create mode 100755 doc/src/images/listview.png create mode 100755 doc/src/images/lotto.png create mode 100755 doc/src/images/modelview.png create mode 100755 doc/src/images/path.png create mode 100755 doc/src/images/qcompleter.png create mode 100755 doc/src/images/readonlytable.png create mode 100755 doc/src/images/readonlytable_role.png create mode 100755 doc/src/images/selection2.png create mode 100755 doc/src/images/standardwidget.png create mode 100755 doc/src/images/tableview.png create mode 100755 doc/src/images/tree.png create mode 100755 doc/src/images/tree_2.png create mode 100755 doc/src/images/tree_2_with_algorithm.png create mode 100755 doc/src/images/tree_city.png create mode 100755 doc/src/images/treeview.png create mode 100755 doc/src/images/widgetmapper.png diff --git a/doc/src/frameworks-technologies/modelview.qdoc b/doc/src/frameworks-technologies/modelview.qdoc new file mode 100755 index 0000000..7729cd2 --- /dev/null +++ b/doc/src/frameworks-technologies/modelview.qdoc @@ -0,0 +1,840 @@ +/*! + + \contentspage{modelview.html}{Crash Course in Model/View Programming} + \page modelview.html + +\title Crash Course in Model/View Programming +Contents: +\tableofcontents + +\section1 1 Introduction +Model/View is a technology used to separate data from views in widgets that handle data sets. Standard Widgets are not designed for separating data from views and this is why Qt 4 has two different types of widgets. Both types of widgets look the same, but they interact with data differently. + \table + \row + \o Standard widgets use data that is part of the widget. + \o \image standardwidget.png + \row + \o View classes operate on external data (the model) + \o \image modelview.png + \endtable +\section2 1.1 Standard widgets +Let's have a closer look at a standard table widget. A table widget is a 2D array of the data elements that the user can change. The table widget can be integrated into a program flow by reading and writing the data elements that the table widget provides. This method is very intuitive and useful in many applications. + +Displaying and editing a database table with a standard table widget can be problematic. Two copies of the data have to be coordinated: one outside the widget; one inside the widget. The developer needs to know where up-to-date data is so the both copies contain the most recent data. The tight coupling of presentation and data makes it harder to write unit tests. + +\section2 1.2 Model/View to the rescue +Model/View stepped up to provide a solution that uses a more versatile architecture. Model/View eliminates the data consistency problems that may occur with standard widgets. Model/View also makes it easier to use more than one view of the same data because one model can be passed on to many views. The most important difference is that model/view widgets do not store data behind the table cells. In fact, they operate directly from your data. Since view classes do not know your data's structure, you need to provide a wrapper to make your data conform to the \l QAbstractItemModel interface. A view uses this interface to read from and write to your data and any class that implements \l QAbstractItemModel is a model. Once the view receives a pointer to a model, it will read and display its content and be its editor. + +\section2 1.3 Overview of the model/view widgets +Here is an overview of the model/view widgets and their corresponding standard widgets. + \table + \header + \o Widget + \o Standard Widget +(a convenience class with data in the widget) + \o Model/View View Class (for use with external data) + \row + \o \image listview.png + \o \l QListWidget + \o \l QListView + \row + \o \image tableview.png + \o \l QTableWidget + \o \l QTableView + \row + \o \image treeview.png + \o \l QTreeWidget + \o \l QTreeView + \row + \o \image columnview.png + \o + \o \l QColumnView shows a tree as a hierarchy of lists + \row + \o \image combobox.png + \o {2, 1} \l QComboBox can work as both a view class and also as a traditional widget + \endtable +\section2 1.4 Having adapters between forms and models can come in handy. +We often prefer editing data stored in tables (e.g. in database tables) in forms rather than in tables. There is no direct model/view counterpart for separating data and views for widgets that operate on one value instead of a dataset, so we need an adapter in order to connect the form to the source of data. + +\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. \image widgetmapper.png + +Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. \image qcompleter.png + +\section1 2 A Simple Model/View Application +If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. + +Below are 7 very simple and independent applications that show different sides of model/view programming. The source code can be downloaded from @todo___________paste link here_________________________ + +\section2 2.1 A read only table +We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. + +-------------------------------------------------------------main.cpp--------------------- +\code +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} +\endcode + +We have the usual main() function; +-------------------------------------------------------------modelview.h--------------------- +\code +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); + +}; + +#endif // MODELVIEW_H +\endcode + +The application is a \l QMainWindow that holds a \l QTableView. + +-------------------------------------------------------------modelview.cpp--------------------- +\code +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + tableView->setModel(new MyModel(this) ); +} + +\endcode + +Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: + \list + \o How many rows and columns should be displayed + \o What content should be printed into each cell. + \endlist + +The model needs some code to respond to this. + +We have a table data set, so let's start with QAbstractTableModel since it is easier to use. +-------------------------------------------------------------mymodel.h--------------------- +\code +#ifndef MYMODEL_H +#define MYMODEL_H + +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; + +#endif // MYMODEL_H +\endcode + +QAbstractTableModel requires the implementation of three abstract methods. + + +-------------------------------------------------------------mymodel.cpp--------------------- +\code +HIER FEHLT mymodel.cpp !!! +\endcode + +The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). +When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. + +This small example demonstrates the passive nature of a model. The model does not know when it will be used or which data is needed. It simply provides data each time the view requests it. + +What happens when the model 's data needs to be changed? How does the view know when data changes and needs to be read again? The model has to emit a signal that indicates what range of cells has changed. This will be demonstrated in section 2.3. + +\section2 2.2 Extending the read only example with roles +In addition to controlling what text the view displays, the model also controls the text's appearance. When we slightly change the model, we get the following result: \image readonlytable_role.png + + +In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: + +\code +HIER FEHLT WAS !!! +\endcode + +Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: + + \table + \header + \o Role (enum Qt::ItemDataRole ) + \o Meaning + \o Type + \row + \o Qt::DisplayRole + \o text + \o QString + \row + \o Qt::FontRole + \o font + \o QFont + \row + \o Qt::BackgroundRole + \o brush for the background of the cell + \o QBrush + \row + \o Qt::TextAlignmentRole + \o text alignment + \o enum Qt::AlignmentFlag + \row + \o {1, 3} Qt::CheckStateRole + \o {1, 3} suppresses checkboxes with QVariant(), sets checkboxes with Qt::Checked or Qt::Unchecked + \o {1, 3} enum Qt::ItemDataRole + + \endtable + +Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. + + +Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()}) is invoked and expensive lookup operations are cached. + +\section2 2.3 A clock inside a table cell +\image clock.png + +We still have a read only table, but this time the content changes every second because we are showing the current time. +\code +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + QVariant returnVal; + int row = index.row(); + int col = index.column(); + + if(role == Qt::DisplayRole) + + { + if(row == 0 && col == 0 ) + { + returnVal = QTime::currentTime().toString(); + } + } + return returnVal; +} +\endcode + +Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. +\code +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +// selectedCell = 0; + timer = new QTimer(this); + timer->setInterval(1000); + connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); + timer->start(); +} +\endcode + +Here is the corresponding slot: +\code + +void MyModel::timerHit() +{ + //we identify the top left cell + QModelIndex topLeft = createIndex ( 0,0 ); + //emit a signal to make the view reread identified data + emit dataChanged ( topLeft, topLeft ); +} +\endcode + +We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QAbstractItemModel::setModel()}{setModel()} . + +\section2 2.4 Setting up Headers for Columns and Rows +Headers can be hidden via a view method. +\c tableView->verticalHeader()->hide(); +\image header.png + + +The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: +\code +QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole) + { + if (orientation == Qt::Horizontal) { + switch (section) + { + case 0: + return QString("first"); + case 1: + return QString("second"); + case 2: + return QString("third"); + } + } + } + return QVariant(); +} +\endcode + + +\section2 2.5 The minimal Editing example +In this example, we are going to build an application that automatically populates a window title with content by repeating values entered into table cells. + +The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. +\code +#ifndef MYMODEL_H +#define MYMODEL_H + +#include +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + Qt::ItemFlags flags ( const QModelIndex & index ) const ; +private: + QStringList m_gridData; //holds text entered into QTableView + int modelIndexToOffset(const QModelIndex & index) const; +signals: + void editCompleted(const QString &); +}; + +#endif // MYMODEL_H +\endcode + +We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. +\code +#include "mymodel.h" + +const int COLS= 3; +const int ROWS= 2; + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ + //gridData needs to have 6 element, one for each table cell + m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; +} +\endcode + +In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) +\code +HIER FEHLT WAS!!! +\endcode + +\l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. +\code +HIER FEHLT WAS!!! +\endcode + +Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. + +\section1 3 Intermediate Topics +\section2 3.1 TreeView +You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. +\image dummy_tree.png + + +QListView, QTableView and QTreeView all use a model abstraction, which is a merged list, table and tree. This makes it possible to use several different types of view classes from the same model. +\image list_table_tree.png + +This is how our example model looks so far: +\image example_model.png + + +We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png +\code +#include +#include +#include +#include "modelview.h" + + +const int ROWS = 2; +const int COLUMNS = 3; + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + treeView = new QTreeView(this); + setCentralWidget(treeView); + standardModel = new QStandardItemModel ; + + QList preparedColumn =prepareColumn("first", "second", "third"); + QStandardItem *item = standardModel->invisibleRootItem(); + // adding a row to the invisible root item produces a root element + item->appendRow(preparedColumn); + + QList secondRow =prepareColumn("111", "222", "333"); + // adding a row to an item starts a subtree + preparedColumn.first()->appendRow(secondRow); + + treeView->setModel( standardModel ); + treeView->expandAll(); +} + +//--------------------------------------------------------------------------- +QList ModelView::prepareColumn(const QString &first, + const QString &second, + const QString &third ) +{ + QList colItems; + colItems << new QStandardItem(first); + colItems << new QStandardItem(second); + colItems << new QStandardItem(third); + return colItems; +} + +\endcode + +We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. + +\section2 3.2 Working with selection +We want to access a selected item's content in order to output it into the window title together with the hierarchy level. +\image selection2.png + + +So let's create a couple of items: +\code +#include +#include +#include +#include "modelview.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + treeView = new QTreeView(this); + setCentralWidget(treeView); + standardModel = new QStandardItemModel ; + QStandardItem *rootNode = standardModel->invisibleRootItem(); + + + //defining a couple of items + QStandardItem *americaItem = new QStandardItem("America"); + QStandardItem *mexicoItem = new QStandardItem("Canada"); + QStandardItem *usaItem = new QStandardItem("USA"); + QStandardItem *bostonItem = new QStandardItem("Boston"); + QStandardItem *europeItem = new QStandardItem("Europe"); + QStandardItem *italyItem = new QStandardItem("Italy"); + QStandardItem *romeItem = new QStandardItem("Rome"); + QStandardItem *veronaItem = new QStandardItem("Verona"); + + //building up the hierarchy + rootNode-> appendRow(americaItem); + rootNode-> appendRow(europeItem); + americaItem-> appendRow(mexicoItem); + americaItem-> appendRow(usaItem); + usaItem-> appendRow(bostonItem); + europeItem-> appendRow(italyItem); + italyItem-> appendRow(romeItem); + italyItem-> appendRow(veronaItem); + + //register the model + treeView->setModel( standardModel ); + treeView->expandAll(); + + //selection changes shall trigger a slot + QItemSelectionModel *selectionModel= treeView->selectionModel(); + connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), + this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); +} +\endcode + +Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. +\code +HIER FEHLT WAS!!! +\endcode + +We get the model index that corresponds to the selection by calling +\c treeView->selectionModel()->currentIndex() and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed QModelIndex(). This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. + +The selection model (as shown above) can be retrieved, but it can also be set with \c QAbstractItemView::setSelectionModel. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; +\section2 3.3 Predefined Models +The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. + + \table + \row + \o QStringListModel + \o Stores a list of strings + \row + \o QStandardItemModel + \o Stores arbitrary hierarchical items + \row + \o {1, 2} QFileSystemModel +QDirModel (deprecated) + \o {1, 2} Encapsulate the local file system + \row + \o QSqlQueryModel + \o Encapsulate an SQL result set + \row + \o QSqlTableModel + \o Encapsulates an SQL table + \row + \o QSqlRelationalTableModel + \o Encapsulates an SQL table with foreign keys + \row + \o QSortFilterProxyModel + \o Sorts and/or filters another model + + \endtable + +\section2 3.4 Delegates +In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png + +The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemModel::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. +\code + class StarDelegate : public QStyledItemDelegate + { + Q_OBJECT + public: + StarDelegate(QWidget *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const; + }; + +\endcode + +\l{QAbstractItemModel::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \c index.data(). \c SizeHint specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. + +Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. + +\section2 3.5 Debugging with ModelTest +The passive nature of models provides new challenges for programmers. Inconsistencies in the model can cause the application to crash. Since the model is hit by numerous calls from the view, it is hard to find out which call has crashed the application and which operation has introduced the problem. + +Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest + +Unlike view classes, ModelTest uses out of range indexes to test the model. This means your application may crash with ModelTest even if it runs perfectly without it. So you also need to handle all of the indexes that are out of range when using ModelTest. + + + + + + + + + +\section2 3.6 Model/View NG + +\image path.png + +Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. + +One limitation of model/view is that view classes are basically all fixed grids. It is possible, but really hard to make a list view with icons placed on a curve; or cells expanding on mouse over events to show additional information. In order to achieve graphically rich view experiences, Model/View NG will use QGraphicsView to render elements. Nodel/View NG also aims to make model/view programming more intuitive. One way to achieve this is to have separate models for lists, tables and trees. The current model abstraction is complex because it is capable of representing a list, a table or a tree. + +Model/View NG is a research project. You are welcome to checkout the source code, monitor progress and take part in discussions at the following address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} + +\section1 4 Good Sources for Additional Information +\section2 4.1 Books +Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. + \list 1 + \o 1.C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 +also available in German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, Addison-Wesley, ISBN 3-827327-29-6 + \o 1.The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 +Translated from: Qt 4, Einführung in die Applikationsentwicklung, Open Source Press, ISBN 3-937514-12-0 + \o 1.Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 + \endlist + + +The following list provides an overview of example programs contained in the books above. Some of them make very good templates for developing similar applications. + + \table + \header + \o example name + \o view class used + \o model used + \o aspects touched + \o + \row + \o Team Leaders + \o QListview + \o QStringListModel + \o + \o Book 1, Chapter 10, Figure 10.6 + \row + \o Directory Viewer + \o QTreeView + \o QDirModel + \o + \o Book 1, Chapter 10, Figure 10.7 + \row + \o Color Names + \o QListView + \o QSortFilterProxyModel +applied to QStringListModel + \o + \o Book 1, Chapter 10, Figure 10.8 + \row + \o Currencies + \o QTableView + \o custom model based on +QAbstractTableModel + \o read only + \o Book 1, Chapter 10, Figure 10.10 + \row + \o Cities + \o QTableView + \o custom model based on +QAbstractTableModel + \o read / write + \o Book 1, Chapter 10, Figure 10.12 + \row + \o Boolean Parser + \o QTreeView + \o custom model based on +QAbstractItemModel + \o read only + \o Book 1, Chapter 10, Figure 10.14 + \row + \o Track Editor + \o {2, 1} QTableWidget + \o custom delegate providing a custom editor + \o Book 1, Chapter 10, Figure 10.15 + + \row + \o Four directory views + \o QListView +QTableView +QTreeView + \o QDirModel + \o demonstrates the use of multiple views + \o Book2, Chapter 8.2 + \row + \o Address Book + \o QListView +QTableView +QTreeView + \o custom model based on +QAbstractTableModel + \o read / write + \o Book2, Chapter 8.4 + \row + \o Address Book with sorting + \o + \o QProxyModel + \o introducing sort and filter capabilities + \o Book2, Chapter 8.5 + \row + \o Address Book +with checkboxes + \o + \o + \o introducing checkboxes +in model/view + \o Book2, Chapter 8.6 + \row + \o Address Book +with transposed grid + \o + \o custom proxy Model based on QAbstractProxyModel + \o introducing a custom model + \o Book2, Chapter 8.7 + \row + \o Address Book +with drag and drop + \o + \o + \o introducing drag and drop support + \o Book2, Chapter 8.8 + \row + \o Address Book with custom editor + \o + \o + \o introducing custom delegates + \o Book2, Chapter 8.9 + \row + \o Views + \o QListView +QTableView +QTreeView + \o QStandardItemModel + \o read only + \o Book 3, Chapter 5, figure 5-3 + \row + \o Bardelegate + \o QTableView + \o + \o custom delegate for presentation based on QAbstractItemDelegate + \o Book 3, Chapter 5, figure 5-5 + \row + \o Editdelegate + \o QTableView + \o + \o custom delegate for editing based on QAbstractItemDelegate + \o Book 3, Chapter 5, figure 5-6 + \row + \o Singleitemview + \o custom view based on +QAbstractItemView + \o + \o custom view + \o Book 3, +Chapter 5, +figure 5-7 + \row + \o listmodel + \o QTableView + \o custom Model based on +QAbstractTableModel + \o read only + \o Book 3, +Chapter 5, +Figure 5-8 + \row + \o treemodel + \o QTreeView + \o custom Model based on +QAbstractItemModel + \o read only + \o Book 3, +Chapter 5, +Figure 5-10 + \row + \o edit integers + \o QListView + \o custom Model based on +QAbstractListModel + \o read / write + \o Book 3, +Chapter 5, +Listing 5-37, Figure 5-11 + \row + \o sorting + \o QTableView + \o QSortFilterProxyModel +applied to QStringListModel + \o demonstrates sorting + \o Book 3, Chapter 5, Figure 5-12 + + \endtable + + +\section2 4.2 Qt documentation +Qt 4.6 comes with 17 examples and 2 Demonstrations for model/view. The examples can be found here: \l{http://doc.qt.nokia.com/4.6/examples-itemviews.html}{http://doc.qt.nokia.com/4.6/examples-itemviews.html} + \table + \header + \o example name + \o view class used + \o model used + \o aspects touched + \row + \o Address Book + \o QTableView + \o QTableModel +QSortFilterProxyModel + \o usage of QSortFilterProxyModel to generate different subsets from one data pool + \row + \o Basic Sort/Filter Model + \o QTreeView + \o QStandardItemModel +QSortFilterProxyModel + \o + \row + \o Chart + \o custom view + \o QStandardItemModel + \o designing custom views that cooperate with selection models + \row + \o Color Editor Factory + \o {2, 1} QTableWidget + \o enhancing the standard delegate with a new custom editor to choose colours + \row + \o Combo Widget Mapper + \o QDataWidgetMapper to map QLineEdit, QTextEdit and QComboBox + \o QStandardItemModel + \o shows how a QComboBox can serve as a view class + \row + \o Custom Sort/Filter Model + \o QTreeView + \o QStandardItemModel +QSortFilterProxyModel + \o subclass QSortFilterProxyModel +for advanced sorting and filtering + \row + \o Dir View + \o QTreeView + \o QDirModel + \o very small example to demonstrate how to assign a model to a view + \row + \o Editable Tree Model + \o QTreeView + \o custom tree model + \o comprehensive example for working with trees, demonstrates editing cells and tree structure with an underlying custom model + \row + \o Fetch More + \o QListView + \o custom list model + \o dynamically changing model + \row + \o Frozen Column + \o QTableView + \o QStandardItemModel + \o + \row + \o Pixelator + \o QTableView + \o custom table model + \o implementation of a custom delegate + \row + \o Puzzle + \o QListView + \o custom list model + \o model/view with drag and drop + \row + \o Simple DOM Model + \o QTreeView + \o custom tree model + \o read only example for a custom tree model + \row + \o Simple Tree Model + \o QTreeView + \o custom tree model + \o read only example for a custom tree model + \row + \o Simple Widget Mapper + \o QDataWidgetMapper to map QLineEdit, QTextEdit and QSpinBox + \o QStandardItemModel + \o basic QDataWidgetMapper usage + \row + \o Spin Box Delegate + \o QTableView + \o QStandardItemModel + \o custom delegate that uses a spin box as a cell editor + \row + \o Star Delegate + \o {2, 1} QTableWidget + \o comprehensive custom delegate example. + \endtable + +Demonstrations are similar to examples except that no walk-through is provided for the code lines. Demonstrations are also sometimes more feature rich. + \l{http://doc.qt.nokia.com/4.6/demos.html}{http://doc.qt.nokia.com/4.6/demos.html} + \list + \o The \bold Interview demonstration shows the same model and selection being shared between three different views. + \o Demonstration \bold Spreadsheet demonstrates the use of a table view as a spreadsheet, using custom delegates to render each item according to the type of data it contains. + \endlist + +A reference documentation for model/view technology is also available. \l{http://doc.qt.nokia.com/4.6/model-view-programming.html}{http://doc.qt.nokia.com/4.6/model-view-programming.html} + +*/ \ No newline at end of file diff --git a/doc/src/images/clock.png b/doc/src/images/clock.png new file mode 100755 index 0000000..c7f6a1b Binary files /dev/null and b/doc/src/images/clock.png differ diff --git a/doc/src/images/columnview.png b/doc/src/images/columnview.png new file mode 100755 index 0000000..2fb972e Binary files /dev/null and b/doc/src/images/columnview.png differ diff --git a/doc/src/images/combobox.png b/doc/src/images/combobox.png new file mode 100755 index 0000000..d172b41 Binary files /dev/null and b/doc/src/images/combobox.png differ diff --git a/doc/src/images/dummy_tree.png b/doc/src/images/dummy_tree.png new file mode 100755 index 0000000..7373ea6 Binary files /dev/null and b/doc/src/images/dummy_tree.png differ diff --git a/doc/src/images/edit.png b/doc/src/images/edit.png new file mode 100755 index 0000000..161b06f Binary files /dev/null and b/doc/src/images/edit.png differ diff --git a/doc/src/images/example_model.png b/doc/src/images/example_model.png new file mode 100755 index 0000000..4261261 Binary files /dev/null and b/doc/src/images/example_model.png differ diff --git a/doc/src/images/header.png b/doc/src/images/header.png new file mode 100755 index 0000000..2597635 Binary files /dev/null and b/doc/src/images/header.png differ diff --git a/doc/src/images/lineedit.png b/doc/src/images/lineedit.png new file mode 100755 index 0000000..83d1c47 Binary files /dev/null and b/doc/src/images/lineedit.png differ diff --git a/doc/src/images/list_table_tree.png b/doc/src/images/list_table_tree.png new file mode 100755 index 0000000..b2daf1f Binary files /dev/null and b/doc/src/images/list_table_tree.png differ diff --git a/doc/src/images/listview.png b/doc/src/images/listview.png new file mode 100755 index 0000000..fa49c52 Binary files /dev/null and b/doc/src/images/listview.png differ diff --git a/doc/src/images/lotto.png b/doc/src/images/lotto.png new file mode 100755 index 0000000..dd751cf Binary files /dev/null and b/doc/src/images/lotto.png differ diff --git a/doc/src/images/modelview.png b/doc/src/images/modelview.png new file mode 100755 index 0000000..7b042af Binary files /dev/null and b/doc/src/images/modelview.png differ diff --git a/doc/src/images/path.png b/doc/src/images/path.png new file mode 100755 index 0000000..73107ff Binary files /dev/null and b/doc/src/images/path.png differ diff --git a/doc/src/images/qcompleter.png b/doc/src/images/qcompleter.png new file mode 100755 index 0000000..d25caac Binary files /dev/null and b/doc/src/images/qcompleter.png differ diff --git a/doc/src/images/readonlytable.png b/doc/src/images/readonlytable.png new file mode 100755 index 0000000..90bcba4 Binary files /dev/null and b/doc/src/images/readonlytable.png differ diff --git a/doc/src/images/readonlytable_role.png b/doc/src/images/readonlytable_role.png new file mode 100755 index 0000000..7d2d416 Binary files /dev/null and b/doc/src/images/readonlytable_role.png differ diff --git a/doc/src/images/selection2.png b/doc/src/images/selection2.png new file mode 100755 index 0000000..66c757f Binary files /dev/null and b/doc/src/images/selection2.png differ diff --git a/doc/src/images/standardwidget.png b/doc/src/images/standardwidget.png new file mode 100755 index 0000000..3ccccf1 Binary files /dev/null and b/doc/src/images/standardwidget.png differ diff --git a/doc/src/images/tableview.png b/doc/src/images/tableview.png new file mode 100755 index 0000000..8be1b6c Binary files /dev/null and b/doc/src/images/tableview.png differ diff --git a/doc/src/images/tree.png b/doc/src/images/tree.png new file mode 100755 index 0000000..3f046c9 Binary files /dev/null and b/doc/src/images/tree.png differ diff --git a/doc/src/images/tree_2.png b/doc/src/images/tree_2.png new file mode 100755 index 0000000..6ee1f4a Binary files /dev/null and b/doc/src/images/tree_2.png differ diff --git a/doc/src/images/tree_2_with_algorithm.png b/doc/src/images/tree_2_with_algorithm.png new file mode 100755 index 0000000..ecf9101 Binary files /dev/null and b/doc/src/images/tree_2_with_algorithm.png differ diff --git a/doc/src/images/tree_city.png b/doc/src/images/tree_city.png new file mode 100755 index 0000000..57f03d9 Binary files /dev/null and b/doc/src/images/tree_city.png differ diff --git a/doc/src/images/treeview.png b/doc/src/images/treeview.png new file mode 100755 index 0000000..af31fe9 Binary files /dev/null and b/doc/src/images/treeview.png differ diff --git a/doc/src/images/widgetmapper.png b/doc/src/images/widgetmapper.png new file mode 100755 index 0000000..9627088 Binary files /dev/null and b/doc/src/images/widgetmapper.png differ -- cgit v0.12 From 4df3fb13821e13ecf581d87f2d224b2f1b964609 Mon Sep 17 00:00:00 2001 From: Roland Wolf Date: Thu, 27 May 2010 10:37:48 +0200 Subject: clean up previous test commit --- src/testfile.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/testfile.txt diff --git a/src/testfile.txt b/src/testfile.txt deleted file mode 100644 index e69de29..0000000 -- cgit v0.12 From f574700f920ae5d5bda25ba217d6face9f3d3902 Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Thu, 27 May 2010 15:12:58 +0200 Subject: Rolands ModelView Source --- .../tutorials/modelview/1_readonly/1_readonly.pro | 10 +++ examples/tutorials/modelview/1_readonly/main.cpp | 10 +++ .../tutorials/modelview/1_readonly/modelview.cpp | 12 ++++ .../tutorials/modelview/1_readonly/modelview.h | 18 ++++++ .../tutorials/modelview/1_readonly/mymodel.cpp | 30 +++++++++ examples/tutorials/modelview/1_readonly/mymodel.h | 16 +++++ .../modelview/2_formatting/2_formatting.pro | 10 +++ examples/tutorials/modelview/2_formatting/main.cpp | 10 +++ .../tutorials/modelview/2_formatting/modelview.cpp | 12 ++++ .../tutorials/modelview/2_formatting/modelview.h | 17 +++++ .../tutorials/modelview/2_formatting/mymodel.cpp | 73 ++++++++++++++++++++++ .../tutorials/modelview/2_formatting/mymodel.h | 16 +++++ .../modelview/3_changingmodel/3_changingmodel.pro | 10 +++ .../tutorials/modelview/3_changingmodel/main.cpp | 10 +++ .../modelview/3_changingmodel/modelview.cpp | 12 ++++ .../modelview/3_changingmodel/modelview.h | 17 +++++ .../modelview/3_changingmodel/mymodel.cpp | 53 ++++++++++++++++ .../tutorials/modelview/3_changingmodel/mymodel.h | 23 +++++++ .../tutorials/modelview/4_headers/4_headers.pro | 10 +++ examples/tutorials/modelview/4_headers/main.cpp | 10 +++ .../tutorials/modelview/4_headers/modelview.cpp | 14 +++++ examples/tutorials/modelview/4_headers/modelview.h | 18 ++++++ examples/tutorials/modelview/4_headers/mymodel.cpp | 50 +++++++++++++++ examples/tutorials/modelview/4_headers/mymodel.h | 17 +++++ examples/tutorials/modelview/5_edit/5_edit.pro | 10 +++ examples/tutorials/modelview/5_edit/main.cpp | 10 +++ examples/tutorials/modelview/5_edit/modelview.cpp | 20 ++++++ examples/tutorials/modelview/5_edit/modelview.h | 19 ++++++ examples/tutorials/modelview/5_edit/mymodel.cpp | 58 +++++++++++++++++ examples/tutorials/modelview/5_edit/mymodel.h | 24 +++++++ .../tutorials/modelview/6_treeview/6_treeview.pro | 5 ++ examples/tutorials/modelview/6_treeview/main.cpp | 10 +++ .../tutorials/modelview/6_treeview/modelview.cpp | 40 ++++++++++++ .../tutorials/modelview/6_treeview/modelview.h | 24 +++++++ .../modelview/7_selections/7_selections.pro | 5 ++ examples/tutorials/modelview/7_selections/main.cpp | 10 +++ .../tutorials/modelview/7_selections/modelview.cpp | 63 +++++++++++++++++++ .../tutorials/modelview/7_selections/modelview.h | 23 +++++++ examples/tutorials/modelview/qmake.pro | 10 +++ 39 files changed, 809 insertions(+) create mode 100755 examples/tutorials/modelview/1_readonly/1_readonly.pro create mode 100755 examples/tutorials/modelview/1_readonly/main.cpp create mode 100755 examples/tutorials/modelview/1_readonly/modelview.cpp create mode 100755 examples/tutorials/modelview/1_readonly/modelview.h create mode 100755 examples/tutorials/modelview/1_readonly/mymodel.cpp create mode 100755 examples/tutorials/modelview/1_readonly/mymodel.h create mode 100755 examples/tutorials/modelview/2_formatting/2_formatting.pro create mode 100755 examples/tutorials/modelview/2_formatting/main.cpp create mode 100755 examples/tutorials/modelview/2_formatting/modelview.cpp create mode 100755 examples/tutorials/modelview/2_formatting/modelview.h create mode 100755 examples/tutorials/modelview/2_formatting/mymodel.cpp create mode 100755 examples/tutorials/modelview/2_formatting/mymodel.h create mode 100755 examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro create mode 100755 examples/tutorials/modelview/3_changingmodel/main.cpp create mode 100755 examples/tutorials/modelview/3_changingmodel/modelview.cpp create mode 100755 examples/tutorials/modelview/3_changingmodel/modelview.h create mode 100755 examples/tutorials/modelview/3_changingmodel/mymodel.cpp create mode 100755 examples/tutorials/modelview/3_changingmodel/mymodel.h create mode 100755 examples/tutorials/modelview/4_headers/4_headers.pro create mode 100755 examples/tutorials/modelview/4_headers/main.cpp create mode 100755 examples/tutorials/modelview/4_headers/modelview.cpp create mode 100755 examples/tutorials/modelview/4_headers/modelview.h create mode 100755 examples/tutorials/modelview/4_headers/mymodel.cpp create mode 100755 examples/tutorials/modelview/4_headers/mymodel.h create mode 100755 examples/tutorials/modelview/5_edit/5_edit.pro create mode 100755 examples/tutorials/modelview/5_edit/main.cpp create mode 100755 examples/tutorials/modelview/5_edit/modelview.cpp create mode 100755 examples/tutorials/modelview/5_edit/modelview.h create mode 100755 examples/tutorials/modelview/5_edit/mymodel.cpp create mode 100755 examples/tutorials/modelview/5_edit/mymodel.h create mode 100755 examples/tutorials/modelview/6_treeview/6_treeview.pro create mode 100755 examples/tutorials/modelview/6_treeview/main.cpp create mode 100755 examples/tutorials/modelview/6_treeview/modelview.cpp create mode 100755 examples/tutorials/modelview/6_treeview/modelview.h create mode 100755 examples/tutorials/modelview/7_selections/7_selections.pro create mode 100755 examples/tutorials/modelview/7_selections/main.cpp create mode 100755 examples/tutorials/modelview/7_selections/modelview.cpp create mode 100755 examples/tutorials/modelview/7_selections/modelview.h create mode 100755 examples/tutorials/modelview/qmake.pro diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro new file mode 100755 index 0000000..1162d5a --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro @@ -0,0 +1,10 @@ +TARGET = mv_readonly + +TEMPLATE = app + +SOURCES += main.cpp \ + modelview.cpp \ + mymodel.cpp + +HEADERS += modelview.h \ + mymodel.h diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp new file mode 100755 index 0000000..becd61d --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/modelview.cpp @@ -0,0 +1,12 @@ +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + tableView->setModel(new MyModel(this) ); +} + diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h new file mode 100755 index 0000000..f1b63bd --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/modelview.h @@ -0,0 +1,18 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); + +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp new file mode 100755 index 0000000..ff3e2d2 --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp @@ -0,0 +1,30 @@ +#include "mymodel.h" + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +} + +//------------------------------------------------------- +int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +{ + return 2; +} + +//------------------------------------------------------- +int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +{ + return 3; +} + +//------------------------------------------------------- +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + if(role == Qt::DisplayRole) + { + return QString("Row%1, Column%2") + .arg(index.row() + 1) + .arg(index.column() +1); + } + return QVariant(); +} diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h new file mode 100755 index 0000000..01ae6cb --- /dev/null +++ b/examples/tutorials/modelview/1_readonly/mymodel.h @@ -0,0 +1,16 @@ +#ifndef MYMODEL_H +#define MYMODEL_H + +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; + +#endif // MYMODEL_H diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro new file mode 100755 index 0000000..7e70d81 --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro @@ -0,0 +1,10 @@ +TARGET = mv_formatting + +TEMPLATE = app + +SOURCES += main.cpp \ + modelview.cpp \ + mymodel.cpp + +HEADERS += modelview.h \ + mymodel.h diff --git a/examples/tutorials/modelview/2_formatting/main.cpp b/examples/tutorials/modelview/2_formatting/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/2_formatting/modelview.cpp b/examples/tutorials/modelview/2_formatting/modelview.cpp new file mode 100755 index 0000000..becd61d --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/modelview.cpp @@ -0,0 +1,12 @@ +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + tableView->setModel(new MyModel(this) ); +} + diff --git a/examples/tutorials/modelview/2_formatting/modelview.h b/examples/tutorials/modelview/2_formatting/modelview.h new file mode 100755 index 0000000..98bee38 --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/modelview.h @@ -0,0 +1,17 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp new file mode 100755 index 0000000..48b1134 --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp @@ -0,0 +1,73 @@ +#include +#include +#include "mymodel.h" +#include + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +} + +//------------------------------------------------------- +int MyModel::rowCount(const QModelIndex & /*parent */ ) const +{ + return 2; +} + +//------------------------------------------------------- +int MyModel::columnCount(const QModelIndex & /*parent */ ) const +{ + return 3; +} + +//------------------------------------------------------- +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + int row = index.row(); + int col = index.column(); + // generate a log message when this method gets called + qDebug() << QString("row %1, col%2, role %3") + .arg(row).arg(col).arg(role); + + switch(role){ + case Qt::DisplayRole: + if(row == 0 && col == 1 )return QString("<--left"); + if(row == 1 && col == 1 )return QString("right-->"); + + return QString("Row%1, Column%2") + .arg(row + 1) + .arg(col +1); + break; + case Qt::FontRole: + if(row == 0 && col ==0 ) //change font only for cell(0,0) + { + QFont boldFont; + boldFont.setBold(true); + return boldFont; + } + break; + case Qt::BackgroundRole: + + if(row == 1 && col ==2 ) //change background only for cell(1,2) + { + QBrush redBackground(QColor(Qt::red)); + return redBackground; + } + break; + case Qt::TextAlignmentRole: + + if(row == 1 && col ==1 ) //change text alignment only for cell(1,1) + { + return Qt::AlignRight + Qt::AlignVCenter; + } + break; + case Qt::CheckStateRole: + + if(row == 1 && col ==0 ) //add a checkbox to cell(1,0) + { + return Qt::Checked; + } + } + return QVariant(); +} + diff --git a/examples/tutorials/modelview/2_formatting/mymodel.h b/examples/tutorials/modelview/2_formatting/mymodel.h new file mode 100755 index 0000000..01ae6cb --- /dev/null +++ b/examples/tutorials/modelview/2_formatting/mymodel.h @@ -0,0 +1,16 @@ +#ifndef MYMODEL_H +#define MYMODEL_H + +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; + +#endif // MYMODEL_H diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro new file mode 100755 index 0000000..d61ee4c --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro @@ -0,0 +1,10 @@ +TARGET = mv_changingmodel + +TEMPLATE = app + +SOURCES += main.cpp \ + modelview.cpp \ + mymodel.cpp + +HEADERS += modelview.h \ + mymodel.h diff --git a/examples/tutorials/modelview/3_changingmodel/main.cpp b/examples/tutorials/modelview/3_changingmodel/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.cpp b/examples/tutorials/modelview/3_changingmodel/modelview.cpp new file mode 100755 index 0000000..becd61d --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/modelview.cpp @@ -0,0 +1,12 @@ +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + tableView->setModel(new MyModel(this) ); +} + diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.h b/examples/tutorials/modelview/3_changingmodel/modelview.h new file mode 100755 index 0000000..98bee38 --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/modelview.h @@ -0,0 +1,17 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp new file mode 100755 index 0000000..d594175 --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include "mymodel.h" + + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +// selectedCell = 0; + timer = new QTimer(this); + timer->setInterval(1000); + connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); + timer->start(); +} + +//------------------------------------------------------- +int MyModel::rowCount(const QModelIndex & /*parent */ ) const +{ + return 2; +} + +//------------------------------------------------------- +int MyModel::columnCount(const QModelIndex & /*parent */ ) const +{ + return 3; +} + +//------------------------------------------------------- +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + int row = index.row(); + int col = index.column(); + + if(role == Qt::DisplayRole) + { + if(row == 0 && col == 0 ) + { + return QTime::currentTime().toString(); + } + } + return QVariant(); +} + +//------------------------------------------------------- +void MyModel::timerHit() +{ + //we identify the top left cell + QModelIndex topLeft = createIndex ( 0,0 ); + //emit a signal to make the view reread identified data + emit dataChanged ( topLeft, topLeft ); +} + diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.h b/examples/tutorials/modelview/3_changingmodel/mymodel.h new file mode 100755 index 0000000..9cc023b --- /dev/null +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.h @@ -0,0 +1,23 @@ +#ifndef MYMODEL_H +#define MYMODEL_H + +#include + +class QTimer; // forward declaration + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QTimer *timer; +private: + int selectedCell; +private slots: + void timerHit(); +}; + +#endif // MYMODEL_H diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro new file mode 100755 index 0000000..d6f8d23 --- /dev/null +++ b/examples/tutorials/modelview/4_headers/4_headers.pro @@ -0,0 +1,10 @@ +TARGET = mv_headers + +TEMPLATE = app + +SOURCES += main.cpp \ + modelview.cpp \ + mymodel.cpp + +HEADERS += modelview.h \ + mymodel.h diff --git a/examples/tutorials/modelview/4_headers/main.cpp b/examples/tutorials/modelview/4_headers/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/4_headers/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/4_headers/modelview.cpp b/examples/tutorials/modelview/4_headers/modelview.cpp new file mode 100755 index 0000000..39394da --- /dev/null +++ b/examples/tutorials/modelview/4_headers/modelview.cpp @@ -0,0 +1,14 @@ +#include +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + tableView->setModel(new MyModel(this) ); + tableView->verticalHeader()->hide(); +} + diff --git a/examples/tutorials/modelview/4_headers/modelview.h b/examples/tutorials/modelview/4_headers/modelview.h new file mode 100755 index 0000000..f1b63bd --- /dev/null +++ b/examples/tutorials/modelview/4_headers/modelview.h @@ -0,0 +1,18 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); + +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp new file mode 100755 index 0000000..a032fe5 --- /dev/null +++ b/examples/tutorials/modelview/4_headers/mymodel.cpp @@ -0,0 +1,50 @@ +#include "mymodel.h" + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +} + +//------------------------------------------------------- +int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +{ + return 2; +} + +//------------------------------------------------------- +int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +{ + return 3; +} + +//------------------------------------------------------- +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + if(role == Qt::DisplayRole) + { + return QString("Row%1, Column%2") + .arg(index.row() + 1) + .arg(index.column() +1); + } + return QVariant(); +} + + +QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole) + { + if (orientation == Qt::Horizontal) { + switch (section) + { + case 0: + return QString("first"); + case 1: + return QString("second"); + case 2: + return QString("third"); + } + } + } + return QVariant(); +} diff --git a/examples/tutorials/modelview/4_headers/mymodel.h b/examples/tutorials/modelview/4_headers/mymodel.h new file mode 100755 index 0000000..327ca10 --- /dev/null +++ b/examples/tutorials/modelview/4_headers/mymodel.h @@ -0,0 +1,17 @@ +#ifndef MYMODEL_H +#define MYMODEL_H + +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; +}; + +#endif // MYMODEL_H diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro new file mode 100755 index 0000000..e18c596 --- /dev/null +++ b/examples/tutorials/modelview/5_edit/5_edit.pro @@ -0,0 +1,10 @@ +TARGET = mv_edit + +TEMPLATE = app + +SOURCES += main.cpp \ + modelview.cpp \ + mymodel.cpp + +HEADERS += modelview.h \ + mymodel.h diff --git a/examples/tutorials/modelview/5_edit/main.cpp b/examples/tutorials/modelview/5_edit/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/5_edit/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/5_edit/modelview.cpp b/examples/tutorials/modelview/5_edit/modelview.cpp new file mode 100755 index 0000000..b6e8e34 --- /dev/null +++ b/examples/tutorials/modelview/5_edit/modelview.cpp @@ -0,0 +1,20 @@ +#include +#include "modelview.h" +#include "mymodel.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + tableView = new QTableView(this); + setCentralWidget(tableView); + QAbstractTableModel *myModel = new MyModel(this); + tableView->setModel( myModel ); + + //transfer changes to the model to the window title + connect(myModel, SIGNAL(editCompleted(const QString &) ), this, SLOT(setWindowTitle(const QString &))); +} + +void ModelView::showWindowTitle(const QString & title) +{ +setWindowTitle( title ); +} diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/modelview.h new file mode 100755 index 0000000..e1591f9 --- /dev/null +++ b/examples/tutorials/modelview/5_edit/modelview.h @@ -0,0 +1,19 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTableView; //forward declaration + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTableView *tableView; +public: + ModelView(QWidget *parent = 0); +public slots: + void showWindowTitle(const QString & title); +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp new file mode 100755 index 0000000..c64a6b7 --- /dev/null +++ b/examples/tutorials/modelview/5_edit/mymodel.cpp @@ -0,0 +1,58 @@ +#include "mymodel.h" + +const int COLS= 3; +const int ROWS= 2; + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ + //gridData needs to have 6 element, one for each table cell + m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; +} + +//------------------------------------------------------- +int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +{ + return ROWS; +} + +//------------------------------------------------------- +int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +{ + return COLS; +} + +//------------------------------------------------------- +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + if(role == Qt::DisplayRole) + { + return m_gridData[modelIndexToOffset(index)]; + } + return QVariant(); +} + +//----------------------------------------------------------------- +bool MyModel::setData ( const QModelIndex & index, const QVariant & value, int role ) +{ + if(role == Qt::EditRole) + { + m_gridData[modelIndexToOffset(index)] = value.toString(); + emit editCompleted(m_gridData.join(" | ") ); + } + return true; +} + +//----------------------------------------------------------------- +Qt::ItemFlags MyModel::flags ( const QModelIndex & /*index*/ ) const +{ + return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ; +} + +//----------------------------------------------------------------- +//convert row and column information to array offset +int MyModel::modelIndexToOffset(const QModelIndex & index) const +{ + return index.row()*COLS + index.column(); +} + diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h new file mode 100755 index 0000000..f8fac77 --- /dev/null +++ b/examples/tutorials/modelview/5_edit/mymodel.h @@ -0,0 +1,24 @@ +#ifndef MYMODEL_H +#define MYMODEL_H + +#include +#include + +class MyModel : public QAbstractTableModel +{ + Q_OBJECT +public: + MyModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + Qt::ItemFlags flags ( const QModelIndex & index ) const ; +private: + QStringList m_gridData; //holds text entered into QTableView + int modelIndexToOffset(const QModelIndex & index) const; +signals: + void editCompleted(const QString &); +}; + +#endif // MYMODEL_H diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro new file mode 100755 index 0000000..6d078be --- /dev/null +++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro @@ -0,0 +1,5 @@ +TARGET = mv_tree +TEMPLATE = app +SOURCES += main.cpp \ + modelview.cpp +HEADERS += modelview.h diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/6_treeview/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/modelview.cpp new file mode 100755 index 0000000..a5488f7 --- /dev/null +++ b/examples/tutorials/modelview/6_treeview/modelview.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include "modelview.h" + + +const int ROWS = 2; +const int COLUMNS = 3; + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + treeView = new QTreeView(this); + setCentralWidget(treeView); + standardModel = new QStandardItemModel ; + + QList preparedColumn =prepareColumn("first", "second", "third"); + QStandardItem *item = standardModel->invisibleRootItem(); + // adding a row to the invisible root item produces a root element + item->appendRow(preparedColumn); + + QList secondRow =prepareColumn("111", "222", "333"); + // adding a row to an item starts a subtree + preparedColumn.first()->appendRow(secondRow); + + treeView->setModel( standardModel ); + treeView->expandAll(); +} + +//--------------------------------------------------------------------------- +QList ModelView::prepareColumn(const QString &first, + const QString &second, + const QString &third ) +{ + QList colItems; + colItems << new QStandardItem(first); + colItems << new QStandardItem(second); + colItems << new QStandardItem(third); + return colItems; +} diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/modelview.h new file mode 100755 index 0000000..1ab23ea --- /dev/null +++ b/examples/tutorials/modelview/6_treeview/modelview.h @@ -0,0 +1,24 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTreeView; //forward declaration +class QStandardItemModel; +class QStandardItem; + + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTreeView *treeView; + QStandardItemModel *standardModel; + QList prepareColumn(const QString &first, + const QString &second, + const QString &third ); +public: + ModelView(QWidget *parent = 0); +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro new file mode 100755 index 0000000..952641c6 --- /dev/null +++ b/examples/tutorials/modelview/7_selections/7_selections.pro @@ -0,0 +1,5 @@ +TARGET = mv_selections +TEMPLATE = app +SOURCES += main.cpp \ + modelview.cpp +HEADERS += modelview.h diff --git a/examples/tutorials/modelview/7_selections/main.cpp b/examples/tutorials/modelview/7_selections/main.cpp new file mode 100755 index 0000000..998503c --- /dev/null +++ b/examples/tutorials/modelview/7_selections/main.cpp @@ -0,0 +1,10 @@ +#include +#include "modelview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + ModelView w; + w.show(); + return a.exec(); +} diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/modelview.cpp new file mode 100755 index 0000000..49c5bb8 --- /dev/null +++ b/examples/tutorials/modelview/7_selections/modelview.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include "modelview.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + treeView = new QTreeView(this); + setCentralWidget(treeView); + standardModel = new QStandardItemModel ; + QStandardItem *rootNode = standardModel->invisibleRootItem(); + + + //defining a couple of items + QStandardItem *americaItem = new QStandardItem("America"); + QStandardItem *mexicoItem = new QStandardItem("Canada"); + QStandardItem *usaItem = new QStandardItem("USA"); + QStandardItem *bostonItem = new QStandardItem("Boston"); + QStandardItem *europeItem = new QStandardItem("Europe"); + QStandardItem *italyItem = new QStandardItem("Italy"); + QStandardItem *romeItem = new QStandardItem("Rome"); + QStandardItem *veronaItem = new QStandardItem("Verona"); + + //building up the hierarchy + rootNode-> appendRow(americaItem); + rootNode-> appendRow(europeItem); + americaItem-> appendRow(mexicoItem); + americaItem-> appendRow(usaItem); + usaItem-> appendRow(bostonItem); + europeItem-> appendRow(italyItem); + italyItem-> appendRow(romeItem); + italyItem-> appendRow(veronaItem); + + //register the model + treeView->setModel( standardModel ); + treeView->expandAll(); + + //selection changes shall trigger a slot + QItemSelectionModel *selectionModel= treeView->selectionModel(); + connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), + this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); +} + +//------------------------------------------------------------------------------------ +void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/) +{ + const QModelIndex index = treeView->selectionModel()->currentIndex(); + QString selectedText = index.data(Qt::DisplayRole).toString(); + int hierarchyLevel=1; + QModelIndex seekRoot = index; + while(seekRoot.parent() != QModelIndex() ) + { + seekRoot = seekRoot.parent(); + hierarchyLevel++; + } + QString showString = QString("%1, Level %2").arg(selectedText) + .arg(hierarchyLevel); + setWindowTitle(showString); +} + + + diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/modelview.h new file mode 100755 index 0000000..0e638a9 --- /dev/null +++ b/examples/tutorials/modelview/7_selections/modelview.h @@ -0,0 +1,23 @@ +#ifndef MODELVIEW_H +#define MODELVIEW_H + +#include + +class QTreeView; //forward declaration +class QStandardItemModel; +class QItemSelection; + + +class ModelView : public QMainWindow +{ + Q_OBJECT +private: + QTreeView *treeView; + QStandardItemModel *standardModel; +private slots: + void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection); +public: + ModelView(QWidget *parent = 0); +}; + +#endif // MODELVIEW_H diff --git a/examples/tutorials/modelview/qmake.pro b/examples/tutorials/modelview/qmake.pro new file mode 100755 index 0000000..7f684ba --- /dev/null +++ b/examples/tutorials/modelview/qmake.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS = 1_readonly \ + 2_formatting \ + 3_changingmodel \ + 4_headers \ + 5_edit \ + 6_treeview \ + 7_selections + -- cgit v0.12 From cdc354e3e777b6de28710c05b83567fa3ad63658 Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Tue, 22 Jun 2010 11:56:24 +0200 Subject: new version of modelview.qdoc with snippets --- doc/src/frameworks-technologies/modelview.qdoc | 168 +++++-------------------- 1 file changed, 29 insertions(+), 139 deletions(-) diff --git a/doc/src/frameworks-technologies/modelview.qdoc b/doc/src/frameworks-technologies/modelview.qdoc index 7729cd2..5f9969b 100755 --- a/doc/src/frameworks-technologies/modelview.qdoc +++ b/doc/src/frameworks-technologies/modelview.qdoc @@ -69,59 +69,16 @@ Below are 7 very simple and independent applications that show different sides o We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. -------------------------------------------------------------main.cpp--------------------- -\code -#include -#include "modelview.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - ModelView w; - w.show(); - return a.exec(); -} -\endcode + \snippet examples/tutorials/modelview/1_readonly/main.cpp We have the usual main() function; -------------------------------------------------------------modelview.h--------------------- -\code -#ifndef MODELVIEW_H -#define MODELVIEW_H - -#include - -class QTableView; //forward declaration - -class ModelView : public QMainWindow -{ - Q_OBJECT -private: - QTableView *tableView; -public: - ModelView(QWidget *parent = 0); - -}; - -#endif // MODELVIEW_H -\endcode + \snippet examples/tutorials/modelview/1_readonly/modelview.h The application is a \l QMainWindow that holds a \l QTableView. -------------------------------------------------------------modelview.cpp--------------------- -\code -#include -#include "modelview.h" -#include "mymodel.h" - -ModelView::ModelView(QWidget *parent) - : QMainWindow(parent) -{ - tableView = new QTableView(this); - setCentralWidget(tableView); - tableView->setModel(new MyModel(this) ); -} - -\endcode + \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: \list @@ -133,32 +90,13 @@ The model needs some code to respond to this. We have a table data set, so let's start with QAbstractTableModel since it is easier to use. -------------------------------------------------------------mymodel.h--------------------- -\code -#ifndef MYMODEL_H -#define MYMODEL_H - -#include - -class MyModel : public QAbstractTableModel -{ - Q_OBJECT -public: - MyModel(QObject *parent); - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; -}; - -#endif // MYMODEL_H -\endcode + \snippet examples/tutorials/modelview/1_readonly/mymodel.h QAbstractTableModel requires the implementation of three abstract methods. -------------------------------------------------------------mymodel.cpp--------------------- -\code -HIER FEHLT mymodel.cpp !!! -\endcode + \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. @@ -173,9 +111,8 @@ In addition to controlling what text the view displays, the model also controls In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: -\code -HIER FEHLT WAS !!! -\endcode +-------------------------------------------------------------mymodel.cpp--------------------- + \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: @@ -216,6 +153,8 @@ Now we need to determine how using a seperated model impacts the application's p \image clock.png We still have a read only table, but this time the content changes every second because we are showing the current time. + +!!!!!I CAN'T FIND THIS FILE!!!!! \code QVariant MyModel::data(const QModelIndex &index, int role ) const { @@ -236,6 +175,8 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const \endcode Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. + +?????(include section from 3_changingmodel/mymodel.cpp)????? \code MyModel::MyModel(QObject *parent) :QAbstractTableModel(parent) @@ -249,6 +190,8 @@ MyModel::MyModel(QObject *parent) \endcode Here is the corresponding slot: + +?????(include section from 3_changingmodel/mymodel.cpp)????? \code void MyModel::timerHit() @@ -269,6 +212,9 @@ Headers can be hidden via a view method. The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: + + +?????(include section from 4_headers/mymodel.cpp)????? \code QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -295,34 +241,12 @@ QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) In this example, we are going to build an application that automatically populates a window title with content by repeating values entered into table cells. The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. -\code -#ifndef MYMODEL_H -#define MYMODEL_H - -#include -#include - -class MyModel : public QAbstractTableModel -{ - Q_OBJECT -public: - MyModel(QObject *parent); - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); - Qt::ItemFlags flags ( const QModelIndex & index ) const ; -private: - QStringList m_gridData; //holds text entered into QTableView - int modelIndexToOffset(const QModelIndex & index) const; -signals: - void editCompleted(const QString &); -}; - -#endif // MYMODEL_H -\endcode +-------------------------------------------------------------mymodel.h--------------------- + \snippet examples/tutorials/modelview/5_edit/mymodel.h We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. + +?????(include section from 5_edit/mymodel.cpp)????? \code #include "mymodel.h" @@ -338,11 +262,13 @@ MyModel::MyModel(QObject *parent) \endcode In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) +?????(include section from 5_edit/mymodel.cpp)????? \code HIER FEHLT WAS!!! \endcode \l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. +?????(include section from 5_edit/mymodel.cpp)????? \code HIER FEHLT WAS!!! \endcode @@ -363,49 +289,8 @@ This is how our example model looks so far: We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png -\code -#include -#include -#include -#include "modelview.h" - - -const int ROWS = 2; -const int COLUMNS = 3; - -ModelView::ModelView(QWidget *parent) - : QMainWindow(parent) -{ - treeView = new QTreeView(this); - setCentralWidget(treeView); - standardModel = new QStandardItemModel ; - - QList preparedColumn =prepareColumn("first", "second", "third"); - QStandardItem *item = standardModel->invisibleRootItem(); - // adding a row to the invisible root item produces a root element - item->appendRow(preparedColumn); - - QList secondRow =prepareColumn("111", "222", "333"); - // adding a row to an item starts a subtree - preparedColumn.first()->appendRow(secondRow); - - treeView->setModel( standardModel ); - treeView->expandAll(); -} - -//--------------------------------------------------------------------------- -QList ModelView::prepareColumn(const QString &first, - const QString &second, - const QString &third ) -{ - QList colItems; - colItems << new QStandardItem(first); - colItems << new QStandardItem(second); - colItems << new QStandardItem(third); - return colItems; -} - -\endcode +-------------------------------------------------------------modelview.cpp--------------------- + \snippet examples/tutorials/modelview/6_treeview/modelview.cpp We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. @@ -415,6 +300,7 @@ We want to access a selected item's content in order to output it into the windo So let's create a couple of items: +?????(include section from 7_selections/modelview.cpp)????? \code #include #include @@ -462,6 +348,8 @@ ModelView::ModelView(QWidget *parent) \endcode Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. + +?????(include section from 7_selections/modelview.cpp)????? \code HIER FEHLT WAS!!! \endcode @@ -503,6 +391,8 @@ QDirModel (deprecated) In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemModel::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. + +!!!!!I CAN'T FIND THIS FILE!!!!! \code class StarDelegate : public QStyledItemDelegate { -- cgit v0.12 From 6de484f195366b560e10f95b04d2f0e7303a2b63 Mon Sep 17 00:00:00 2001 From: Roland Wolf Date: Tue, 22 Jun 2010 14:26:05 +0200 Subject: integrating modelview tutorial in the build system, first attempt --- doc/src/frameworks-technologies/modelview.qdoc | 730 ------------------------ doc/src/tutorials/modelview.qdoc | 732 +++++++++++++++++++++++++ examples/tutorials/modelview/modelview.pro | 10 + examples/tutorials/modelview/qmake.pro | 10 - examples/tutorials/tutorials.pro | 4 +- 5 files changed, 745 insertions(+), 741 deletions(-) delete mode 100755 doc/src/frameworks-technologies/modelview.qdoc create mode 100755 doc/src/tutorials/modelview.qdoc create mode 100755 examples/tutorials/modelview/modelview.pro delete mode 100755 examples/tutorials/modelview/qmake.pro diff --git a/doc/src/frameworks-technologies/modelview.qdoc b/doc/src/frameworks-technologies/modelview.qdoc deleted file mode 100755 index 5f9969b..0000000 --- a/doc/src/frameworks-technologies/modelview.qdoc +++ /dev/null @@ -1,730 +0,0 @@ -/*! - - \contentspage{modelview.html}{Crash Course in Model/View Programming} - \page modelview.html - -\title Crash Course in Model/View Programming -Contents: -\tableofcontents - -\section1 1 Introduction -Model/View is a technology used to separate data from views in widgets that handle data sets. Standard Widgets are not designed for separating data from views and this is why Qt 4 has two different types of widgets. Both types of widgets look the same, but they interact with data differently. - \table - \row - \o Standard widgets use data that is part of the widget. - \o \image standardwidget.png - \row - \o View classes operate on external data (the model) - \o \image modelview.png - \endtable -\section2 1.1 Standard widgets -Let's have a closer look at a standard table widget. A table widget is a 2D array of the data elements that the user can change. The table widget can be integrated into a program flow by reading and writing the data elements that the table widget provides. This method is very intuitive and useful in many applications. - -Displaying and editing a database table with a standard table widget can be problematic. Two copies of the data have to be coordinated: one outside the widget; one inside the widget. The developer needs to know where up-to-date data is so the both copies contain the most recent data. The tight coupling of presentation and data makes it harder to write unit tests. - -\section2 1.2 Model/View to the rescue -Model/View stepped up to provide a solution that uses a more versatile architecture. Model/View eliminates the data consistency problems that may occur with standard widgets. Model/View also makes it easier to use more than one view of the same data because one model can be passed on to many views. The most important difference is that model/view widgets do not store data behind the table cells. In fact, they operate directly from your data. Since view classes do not know your data's structure, you need to provide a wrapper to make your data conform to the \l QAbstractItemModel interface. A view uses this interface to read from and write to your data and any class that implements \l QAbstractItemModel is a model. Once the view receives a pointer to a model, it will read and display its content and be its editor. - -\section2 1.3 Overview of the model/view widgets -Here is an overview of the model/view widgets and their corresponding standard widgets. - \table - \header - \o Widget - \o Standard Widget -(a convenience class with data in the widget) - \o Model/View View Class (for use with external data) - \row - \o \image listview.png - \o \l QListWidget - \o \l QListView - \row - \o \image tableview.png - \o \l QTableWidget - \o \l QTableView - \row - \o \image treeview.png - \o \l QTreeWidget - \o \l QTreeView - \row - \o \image columnview.png - \o - \o \l QColumnView shows a tree as a hierarchy of lists - \row - \o \image combobox.png - \o {2, 1} \l QComboBox can work as both a view class and also as a traditional widget - \endtable -\section2 1.4 Having adapters between forms and models can come in handy. -We often prefer editing data stored in tables (e.g. in database tables) in forms rather than in tables. There is no direct model/view counterpart for separating data and views for widgets that operate on one value instead of a dataset, so we need an adapter in order to connect the form to the source of data. - -\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. \image widgetmapper.png - -Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. \image qcompleter.png - -\section1 2 A Simple Model/View Application -If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. - -Below are 7 very simple and independent applications that show different sides of model/view programming. The source code can be downloaded from @todo___________paste link here_________________________ - -\section2 2.1 A read only table -We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. - --------------------------------------------------------------main.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/main.cpp - -We have the usual main() function; --------------------------------------------------------------modelview.h--------------------- - \snippet examples/tutorials/modelview/1_readonly/modelview.h - -The application is a \l QMainWindow that holds a \l QTableView. - --------------------------------------------------------------modelview.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/modelview.cpp - -Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: - \list - \o How many rows and columns should be displayed - \o What content should be printed into each cell. - \endlist - -The model needs some code to respond to this. - -We have a table data set, so let's start with QAbstractTableModel since it is easier to use. --------------------------------------------------------------mymodel.h--------------------- - \snippet examples/tutorials/modelview/1_readonly/mymodel.h - -QAbstractTableModel requires the implementation of three abstract methods. - - --------------------------------------------------------------mymodel.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp - -The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). -When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. - -This small example demonstrates the passive nature of a model. The model does not know when it will be used or which data is needed. It simply provides data each time the view requests it. - -What happens when the model 's data needs to be changed? How does the view know when data changes and needs to be read again? The model has to emit a signal that indicates what range of cells has changed. This will be demonstrated in section 2.3. - -\section2 2.2 Extending the read only example with roles -In addition to controlling what text the view displays, the model also controls the text's appearance. When we slightly change the model, we get the following result: \image readonlytable_role.png - - -In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: - --------------------------------------------------------------mymodel.cpp--------------------- - \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp - -Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: - - \table - \header - \o Role (enum Qt::ItemDataRole ) - \o Meaning - \o Type - \row - \o Qt::DisplayRole - \o text - \o QString - \row - \o Qt::FontRole - \o font - \o QFont - \row - \o Qt::BackgroundRole - \o brush for the background of the cell - \o QBrush - \row - \o Qt::TextAlignmentRole - \o text alignment - \o enum Qt::AlignmentFlag - \row - \o {1, 3} Qt::CheckStateRole - \o {1, 3} suppresses checkboxes with QVariant(), sets checkboxes with Qt::Checked or Qt::Unchecked - \o {1, 3} enum Qt::ItemDataRole - - \endtable - -Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. - - -Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()}) is invoked and expensive lookup operations are cached. - -\section2 2.3 A clock inside a table cell -\image clock.png - -We still have a read only table, but this time the content changes every second because we are showing the current time. - -!!!!!I CAN'T FIND THIS FILE!!!!! -\code -QVariant MyModel::data(const QModelIndex &index, int role ) const -{ - QVariant returnVal; - int row = index.row(); - int col = index.column(); - - if(role == Qt::DisplayRole) - - { - if(row == 0 && col == 0 ) - { - returnVal = QTime::currentTime().toString(); - } - } - return returnVal; -} -\endcode - -Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. - -?????(include section from 3_changingmodel/mymodel.cpp)????? -\code -MyModel::MyModel(QObject *parent) - :QAbstractTableModel(parent) -{ -// selectedCell = 0; - timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); - timer->start(); -} -\endcode - -Here is the corresponding slot: - -?????(include section from 3_changingmodel/mymodel.cpp)????? -\code - -void MyModel::timerHit() -{ - //we identify the top left cell - QModelIndex topLeft = createIndex ( 0,0 ); - //emit a signal to make the view reread identified data - emit dataChanged ( topLeft, topLeft ); -} -\endcode - -We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QAbstractItemModel::setModel()}{setModel()} . - -\section2 2.4 Setting up Headers for Columns and Rows -Headers can be hidden via a view method. -\c tableView->verticalHeader()->hide(); -\image header.png - - -The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: - - -?????(include section from 4_headers/mymodel.cpp)????? -\code -QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) { - switch (section) - { - case 0: - return QString("first"); - case 1: - return QString("second"); - case 2: - return QString("third"); - } - } - } - return QVariant(); -} -\endcode - - -\section2 2.5 The minimal Editing example -In this example, we are going to build an application that automatically populates a window title with content by repeating values entered into table cells. - -The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. --------------------------------------------------------------mymodel.h--------------------- - \snippet examples/tutorials/modelview/5_edit/mymodel.h - -We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. - -?????(include section from 5_edit/mymodel.cpp)????? -\code -#include "mymodel.h" - -const int COLS= 3; -const int ROWS= 2; - -MyModel::MyModel(QObject *parent) - :QAbstractTableModel(parent) -{ - //gridData needs to have 6 element, one for each table cell - m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; -} -\endcode - -In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) -?????(include section from 5_edit/mymodel.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode - -\l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. -?????(include section from 5_edit/mymodel.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode - -Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. - -\section1 3 Intermediate Topics -\section2 3.1 TreeView -You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. -\image dummy_tree.png - - -QListView, QTableView and QTreeView all use a model abstraction, which is a merged list, table and tree. This makes it possible to use several different types of view classes from the same model. -\image list_table_tree.png - -This is how our example model looks so far: -\image example_model.png - - -We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png --------------------------------------------------------------modelview.cpp--------------------- - \snippet examples/tutorials/modelview/6_treeview/modelview.cpp - -We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. - -\section2 3.2 Working with selection -We want to access a selected item's content in order to output it into the window title together with the hierarchy level. -\image selection2.png - - -So let's create a couple of items: -?????(include section from 7_selections/modelview.cpp)????? -\code -#include -#include -#include -#include "modelview.h" - -ModelView::ModelView(QWidget *parent) - : QMainWindow(parent) -{ - treeView = new QTreeView(this); - setCentralWidget(treeView); - standardModel = new QStandardItemModel ; - QStandardItem *rootNode = standardModel->invisibleRootItem(); - - - //defining a couple of items - QStandardItem *americaItem = new QStandardItem("America"); - QStandardItem *mexicoItem = new QStandardItem("Canada"); - QStandardItem *usaItem = new QStandardItem("USA"); - QStandardItem *bostonItem = new QStandardItem("Boston"); - QStandardItem *europeItem = new QStandardItem("Europe"); - QStandardItem *italyItem = new QStandardItem("Italy"); - QStandardItem *romeItem = new QStandardItem("Rome"); - QStandardItem *veronaItem = new QStandardItem("Verona"); - - //building up the hierarchy - rootNode-> appendRow(americaItem); - rootNode-> appendRow(europeItem); - americaItem-> appendRow(mexicoItem); - americaItem-> appendRow(usaItem); - usaItem-> appendRow(bostonItem); - europeItem-> appendRow(italyItem); - italyItem-> appendRow(romeItem); - italyItem-> appendRow(veronaItem); - - //register the model - treeView->setModel( standardModel ); - treeView->expandAll(); - - //selection changes shall trigger a slot - QItemSelectionModel *selectionModel= treeView->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), - this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); -} -\endcode - -Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. - -?????(include section from 7_selections/modelview.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode - -We get the model index that corresponds to the selection by calling -\c treeView->selectionModel()->currentIndex() and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed QModelIndex(). This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. - -The selection model (as shown above) can be retrieved, but it can also be set with \c QAbstractItemView::setSelectionModel. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; -\section2 3.3 Predefined Models -The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. - - \table - \row - \o QStringListModel - \o Stores a list of strings - \row - \o QStandardItemModel - \o Stores arbitrary hierarchical items - \row - \o {1, 2} QFileSystemModel -QDirModel (deprecated) - \o {1, 2} Encapsulate the local file system - \row - \o QSqlQueryModel - \o Encapsulate an SQL result set - \row - \o QSqlTableModel - \o Encapsulates an SQL table - \row - \o QSqlRelationalTableModel - \o Encapsulates an SQL table with foreign keys - \row - \o QSortFilterProxyModel - \o Sorts and/or filters another model - - \endtable - -\section2 3.4 Delegates -In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png - -The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemModel::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. - -!!!!!I CAN'T FIND THIS FILE!!!!! -\code - class StarDelegate : public QStyledItemDelegate - { - Q_OBJECT - public: - StarDelegate(QWidget *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const; - }; - -\endcode - -\l{QAbstractItemModel::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \c index.data(). \c SizeHint specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. - -Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. - -\section2 3.5 Debugging with ModelTest -The passive nature of models provides new challenges for programmers. Inconsistencies in the model can cause the application to crash. Since the model is hit by numerous calls from the view, it is hard to find out which call has crashed the application and which operation has introduced the problem. - -Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest - -Unlike view classes, ModelTest uses out of range indexes to test the model. This means your application may crash with ModelTest even if it runs perfectly without it. So you also need to handle all of the indexes that are out of range when using ModelTest. - - - - - - - - - -\section2 3.6 Model/View NG - -\image path.png - -Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. - -One limitation of model/view is that view classes are basically all fixed grids. It is possible, but really hard to make a list view with icons placed on a curve; or cells expanding on mouse over events to show additional information. In order to achieve graphically rich view experiences, Model/View NG will use QGraphicsView to render elements. Nodel/View NG also aims to make model/view programming more intuitive. One way to achieve this is to have separate models for lists, tables and trees. The current model abstraction is complex because it is capable of representing a list, a table or a tree. - -Model/View NG is a research project. You are welcome to checkout the source code, monitor progress and take part in discussions at the following address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} - -\section1 4 Good Sources for Additional Information -\section2 4.1 Books -Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. - \list 1 - \o 1.C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 -also available in German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, Addison-Wesley, ISBN 3-827327-29-6 - \o 1.The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 -Translated from: Qt 4, Einführung in die Applikationsentwicklung, Open Source Press, ISBN 3-937514-12-0 - \o 1.Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 - \endlist - - -The following list provides an overview of example programs contained in the books above. Some of them make very good templates for developing similar applications. - - \table - \header - \o example name - \o view class used - \o model used - \o aspects touched - \o - \row - \o Team Leaders - \o QListview - \o QStringListModel - \o - \o Book 1, Chapter 10, Figure 10.6 - \row - \o Directory Viewer - \o QTreeView - \o QDirModel - \o - \o Book 1, Chapter 10, Figure 10.7 - \row - \o Color Names - \o QListView - \o QSortFilterProxyModel -applied to QStringListModel - \o - \o Book 1, Chapter 10, Figure 10.8 - \row - \o Currencies - \o QTableView - \o custom model based on -QAbstractTableModel - \o read only - \o Book 1, Chapter 10, Figure 10.10 - \row - \o Cities - \o QTableView - \o custom model based on -QAbstractTableModel - \o read / write - \o Book 1, Chapter 10, Figure 10.12 - \row - \o Boolean Parser - \o QTreeView - \o custom model based on -QAbstractItemModel - \o read only - \o Book 1, Chapter 10, Figure 10.14 - \row - \o Track Editor - \o {2, 1} QTableWidget - \o custom delegate providing a custom editor - \o Book 1, Chapter 10, Figure 10.15 - - \row - \o Four directory views - \o QListView -QTableView -QTreeView - \o QDirModel - \o demonstrates the use of multiple views - \o Book2, Chapter 8.2 - \row - \o Address Book - \o QListView -QTableView -QTreeView - \o custom model based on -QAbstractTableModel - \o read / write - \o Book2, Chapter 8.4 - \row - \o Address Book with sorting - \o - \o QProxyModel - \o introducing sort and filter capabilities - \o Book2, Chapter 8.5 - \row - \o Address Book -with checkboxes - \o - \o - \o introducing checkboxes -in model/view - \o Book2, Chapter 8.6 - \row - \o Address Book -with transposed grid - \o - \o custom proxy Model based on QAbstractProxyModel - \o introducing a custom model - \o Book2, Chapter 8.7 - \row - \o Address Book -with drag and drop - \o - \o - \o introducing drag and drop support - \o Book2, Chapter 8.8 - \row - \o Address Book with custom editor - \o - \o - \o introducing custom delegates - \o Book2, Chapter 8.9 - \row - \o Views - \o QListView -QTableView -QTreeView - \o QStandardItemModel - \o read only - \o Book 3, Chapter 5, figure 5-3 - \row - \o Bardelegate - \o QTableView - \o - \o custom delegate for presentation based on QAbstractItemDelegate - \o Book 3, Chapter 5, figure 5-5 - \row - \o Editdelegate - \o QTableView - \o - \o custom delegate for editing based on QAbstractItemDelegate - \o Book 3, Chapter 5, figure 5-6 - \row - \o Singleitemview - \o custom view based on -QAbstractItemView - \o - \o custom view - \o Book 3, -Chapter 5, -figure 5-7 - \row - \o listmodel - \o QTableView - \o custom Model based on -QAbstractTableModel - \o read only - \o Book 3, -Chapter 5, -Figure 5-8 - \row - \o treemodel - \o QTreeView - \o custom Model based on -QAbstractItemModel - \o read only - \o Book 3, -Chapter 5, -Figure 5-10 - \row - \o edit integers - \o QListView - \o custom Model based on -QAbstractListModel - \o read / write - \o Book 3, -Chapter 5, -Listing 5-37, Figure 5-11 - \row - \o sorting - \o QTableView - \o QSortFilterProxyModel -applied to QStringListModel - \o demonstrates sorting - \o Book 3, Chapter 5, Figure 5-12 - - \endtable - - -\section2 4.2 Qt documentation -Qt 4.6 comes with 17 examples and 2 Demonstrations for model/view. The examples can be found here: \l{http://doc.qt.nokia.com/4.6/examples-itemviews.html}{http://doc.qt.nokia.com/4.6/examples-itemviews.html} - \table - \header - \o example name - \o view class used - \o model used - \o aspects touched - \row - \o Address Book - \o QTableView - \o QTableModel -QSortFilterProxyModel - \o usage of QSortFilterProxyModel to generate different subsets from one data pool - \row - \o Basic Sort/Filter Model - \o QTreeView - \o QStandardItemModel -QSortFilterProxyModel - \o - \row - \o Chart - \o custom view - \o QStandardItemModel - \o designing custom views that cooperate with selection models - \row - \o Color Editor Factory - \o {2, 1} QTableWidget - \o enhancing the standard delegate with a new custom editor to choose colours - \row - \o Combo Widget Mapper - \o QDataWidgetMapper to map QLineEdit, QTextEdit and QComboBox - \o QStandardItemModel - \o shows how a QComboBox can serve as a view class - \row - \o Custom Sort/Filter Model - \o QTreeView - \o QStandardItemModel -QSortFilterProxyModel - \o subclass QSortFilterProxyModel -for advanced sorting and filtering - \row - \o Dir View - \o QTreeView - \o QDirModel - \o very small example to demonstrate how to assign a model to a view - \row - \o Editable Tree Model - \o QTreeView - \o custom tree model - \o comprehensive example for working with trees, demonstrates editing cells and tree structure with an underlying custom model - \row - \o Fetch More - \o QListView - \o custom list model - \o dynamically changing model - \row - \o Frozen Column - \o QTableView - \o QStandardItemModel - \o - \row - \o Pixelator - \o QTableView - \o custom table model - \o implementation of a custom delegate - \row - \o Puzzle - \o QListView - \o custom list model - \o model/view with drag and drop - \row - \o Simple DOM Model - \o QTreeView - \o custom tree model - \o read only example for a custom tree model - \row - \o Simple Tree Model - \o QTreeView - \o custom tree model - \o read only example for a custom tree model - \row - \o Simple Widget Mapper - \o QDataWidgetMapper to map QLineEdit, QTextEdit and QSpinBox - \o QStandardItemModel - \o basic QDataWidgetMapper usage - \row - \o Spin Box Delegate - \o QTableView - \o QStandardItemModel - \o custom delegate that uses a spin box as a cell editor - \row - \o Star Delegate - \o {2, 1} QTableWidget - \o comprehensive custom delegate example. - \endtable - -Demonstrations are similar to examples except that no walk-through is provided for the code lines. Demonstrations are also sometimes more feature rich. - \l{http://doc.qt.nokia.com/4.6/demos.html}{http://doc.qt.nokia.com/4.6/demos.html} - \list - \o The \bold Interview demonstration shows the same model and selection being shared between three different views. - \o Demonstration \bold Spreadsheet demonstrates the use of a table view as a spreadsheet, using custom delegates to render each item according to the type of data it contains. - \endlist - -A reference documentation for model/view technology is also available. \l{http://doc.qt.nokia.com/4.6/model-view-programming.html}{http://doc.qt.nokia.com/4.6/model-view-programming.html} - -*/ \ No newline at end of file diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc new file mode 100755 index 0000000..1be4b46 --- /dev/null +++ b/doc/src/tutorials/modelview.qdoc @@ -0,0 +1,732 @@ +/*! + + \page modelview.html + \startpage {index.html}{Qt Reference Documentation} + \contentspage Tutorials + \contentspage{modelview.html}{Crash Course in Model/View Programming} + +\title Crash Course in Model/View Programming +Contents: +\tableofcontents + +\section1 1 Introduction +Model/View is a technology used to separate data from views in widgets that handle data sets. Standard Widgets are not designed for separating data from views and this is why Qt 4 has two different types of widgets. Both types of widgets look the same, but they interact with data differently. + \table + \row + \o Standard widgets use data that is part of the widget. + \o \image standardwidget.png + \row + \o View classes operate on external data (the model) + \o \image modelview.png + \endtable +\section2 1.1 Standard widgets +Let's have a closer look at a standard table widget. A table widget is a 2D array of the data elements that the user can change. The table widget can be integrated into a program flow by reading and writing the data elements that the table widget provides. This method is very intuitive and useful in many applications. + +Displaying and editing a database table with a standard table widget can be problematic. Two copies of the data have to be coordinated: one outside the widget; one inside the widget. The developer needs to know where up-to-date data is so the both copies contain the most recent data. The tight coupling of presentation and data makes it harder to write unit tests. + +\section2 1.2 Model/View to the rescue +Model/View stepped up to provide a solution that uses a more versatile architecture. Model/View eliminates the data consistency problems that may occur with standard widgets. Model/View also makes it easier to use more than one view of the same data because one model can be passed on to many views. The most important difference is that model/view widgets do not store data behind the table cells. In fact, they operate directly from your data. Since view classes do not know your data's structure, you need to provide a wrapper to make your data conform to the \l QAbstractItemModel interface. A view uses this interface to read from and write to your data and any class that implements \l QAbstractItemModel is a model. Once the view receives a pointer to a model, it will read and display its content and be its editor. + +\section2 1.3 Overview of the model/view widgets +Here is an overview of the model/view widgets and their corresponding standard widgets. + \table + \header + \o Widget + \o Standard Widget +(a convenience class with data in the widget) + \o Model/View View Class (for use with external data) + \row + \o \image listview.png + \o \l QListWidget + \o \l QListView + \row + \o \image tableview.png + \o \l QTableWidget + \o \l QTableView + \row + \o \image treeview.png + \o \l QTreeWidget + \o \l QTreeView + \row + \o \image columnview.png + \o + \o \l QColumnView shows a tree as a hierarchy of lists + \row + \o \image combobox.png + \o {2, 1} \l QComboBox can work as both a view class and also as a traditional widget + \endtable +\section2 1.4 Having adapters between forms and models can come in handy. +We often prefer editing data stored in tables (e.g. in database tables) in forms rather than in tables. There is no direct model/view counterpart for separating data and views for widgets that operate on one value instead of a dataset, so we need an adapter in order to connect the form to the source of data. + +\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. \image widgetmapper.png + +Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. \image qcompleter.png + +\section1 2 A Simple Model/View Application +If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. + +Below are 7 very simple and independent applications that show different sides of model/view programming. The source code can be downloaded from @todo___________paste link here_________________________ + +\section2 2.1 A read only table +We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. + +-------------------------------------------------------------main.cpp--------------------- + \snippet examples/tutorials/modelview/1_readonly/main.cpp + +We have the usual main() function; +-------------------------------------------------------------modelview.h--------------------- + \snippet examples/tutorials/modelview/1_readonly/modelview.h + +The application is a \l QMainWindow that holds a \l QTableView. + +-------------------------------------------------------------modelview.cpp--------------------- + \snippet examples/tutorials/modelview/1_readonly/modelview.cpp + +Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: + \list + \o How many rows and columns should be displayed + \o What content should be printed into each cell. + \endlist + +The model needs some code to respond to this. + +We have a table data set, so let's start with QAbstractTableModel since it is easier to use. +-------------------------------------------------------------mymodel.h--------------------- + \snippet examples/tutorials/modelview/1_readonly/mymodel.h + +QAbstractTableModel requires the implementation of three abstract methods. + + +-------------------------------------------------------------mymodel.cpp--------------------- + \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp + +The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). +When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. + +This small example demonstrates the passive nature of a model. The model does not know when it will be used or which data is needed. It simply provides data each time the view requests it. + +What happens when the model 's data needs to be changed? How does the view know when data changes and needs to be read again? The model has to emit a signal that indicates what range of cells has changed. This will be demonstrated in section 2.3. + +\section2 2.2 Extending the read only example with roles +In addition to controlling what text the view displays, the model also controls the text's appearance. When we slightly change the model, we get the following result: \image readonlytable_role.png + + +In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: + +-------------------------------------------------------------mymodel.cpp--------------------- + \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp + +Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: + + \table + \header + \o Role (enum Qt::ItemDataRole ) + \o Meaning + \o Type + \row + \o Qt::DisplayRole + \o text + \o QString + \row + \o Qt::FontRole + \o font + \o QFont + \row + \o Qt::BackgroundRole + \o brush for the background of the cell + \o QBrush + \row + \o Qt::TextAlignmentRole + \o text alignment + \o enum Qt::AlignmentFlag + \row + \o {1, 3} Qt::CheckStateRole + \o {1, 3} suppresses checkboxes with QVariant(), sets checkboxes with Qt::Checked or Qt::Unchecked + \o {1, 3} enum Qt::ItemDataRole + + \endtable + +Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. + + +Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()}) is invoked and expensive lookup operations are cached. + +\section2 2.3 A clock inside a table cell +\image clock.png + +We still have a read only table, but this time the content changes every second because we are showing the current time. + +!!!!!I CAN'T FIND THIS FILE!!!!! +\code +QVariant MyModel::data(const QModelIndex &index, int role ) const +{ + QVariant returnVal; + int row = index.row(); + int col = index.column(); + + if(role == Qt::DisplayRole) + + { + if(row == 0 && col == 0 ) + { + returnVal = QTime::currentTime().toString(); + } + } + return returnVal; +} +\endcode + +Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. + +?????(include section from 3_changingmodel/mymodel.cpp)????? +\code +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ +// selectedCell = 0; + timer = new QTimer(this); + timer->setInterval(1000); + connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); + timer->start(); +} +\endcode + +Here is the corresponding slot: + +?????(include section from 3_changingmodel/mymodel.cpp)????? +\code + +void MyModel::timerHit() +{ + //we identify the top left cell + QModelIndex topLeft = createIndex ( 0,0 ); + //emit a signal to make the view reread identified data + emit dataChanged ( topLeft, topLeft ); +} +\endcode + +We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QAbstractItemModel::setModel()}{setModel()} . + +\section2 2.4 Setting up Headers for Columns and Rows +Headers can be hidden via a view method. +\c tableView->verticalHeader()->hide(); +\image header.png + + +The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: + + +?????(include section from 4_headers/mymodel.cpp)????? +\code +QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole) + { + if (orientation == Qt::Horizontal) { + switch (section) + { + case 0: + return QString("first"); + case 1: + return QString("second"); + case 2: + return QString("third"); + } + } + } + return QVariant(); +} +\endcode + + +\section2 2.5 The minimal Editing example +In this example, we are going to build an application that automatically populates a window title with content by repeating values entered into table cells. + +The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. +-------------------------------------------------------------mymodel.h--------------------- + \snippet examples/tutorials/modelview/5_edit/mymodel.h + +We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. + +?????(include section from 5_edit/mymodel.cpp)????? +\code +#include "mymodel.h" + +const int COLS= 3; +const int ROWS= 2; + +MyModel::MyModel(QObject *parent) + :QAbstractTableModel(parent) +{ + //gridData needs to have 6 element, one for each table cell + m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; +} +\endcode + +In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) +?????(include section from 5_edit/mymodel.cpp)????? +\code +HIER FEHLT WAS!!! +\endcode + +\l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. +?????(include section from 5_edit/mymodel.cpp)????? +\code +HIER FEHLT WAS!!! +\endcode + +Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. + +\section1 3 Intermediate Topics +\section2 3.1 TreeView +You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. +\image dummy_tree.png + + +QListView, QTableView and QTreeView all use a model abstraction, which is a merged list, table and tree. This makes it possible to use several different types of view classes from the same model. +\image list_table_tree.png + +This is how our example model looks so far: +\image example_model.png + + +We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png +-------------------------------------------------------------modelview.cpp--------------------- + \snippet examples/tutorials/modelview/6_treeview/modelview.cpp + +We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. + +\section2 3.2 Working with selection +We want to access a selected item's content in order to output it into the window title together with the hierarchy level. +\image selection2.png + + +So let's create a couple of items: +?????(include section from 7_selections/modelview.cpp)????? +\code +#include +#include +#include +#include "modelview.h" + +ModelView::ModelView(QWidget *parent) + : QMainWindow(parent) +{ + treeView = new QTreeView(this); + setCentralWidget(treeView); + standardModel = new QStandardItemModel ; + QStandardItem *rootNode = standardModel->invisibleRootItem(); + + + //defining a couple of items + QStandardItem *americaItem = new QStandardItem("America"); + QStandardItem *mexicoItem = new QStandardItem("Canada"); + QStandardItem *usaItem = new QStandardItem("USA"); + QStandardItem *bostonItem = new QStandardItem("Boston"); + QStandardItem *europeItem = new QStandardItem("Europe"); + QStandardItem *italyItem = new QStandardItem("Italy"); + QStandardItem *romeItem = new QStandardItem("Rome"); + QStandardItem *veronaItem = new QStandardItem("Verona"); + + //building up the hierarchy + rootNode-> appendRow(americaItem); + rootNode-> appendRow(europeItem); + americaItem-> appendRow(mexicoItem); + americaItem-> appendRow(usaItem); + usaItem-> appendRow(bostonItem); + europeItem-> appendRow(italyItem); + italyItem-> appendRow(romeItem); + italyItem-> appendRow(veronaItem); + + //register the model + treeView->setModel( standardModel ); + treeView->expandAll(); + + //selection changes shall trigger a slot + QItemSelectionModel *selectionModel= treeView->selectionModel(); + connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), + this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); +} +\endcode + +Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. + +?????(include section from 7_selections/modelview.cpp)????? +\code +HIER FEHLT WAS!!! +\endcode + +We get the model index that corresponds to the selection by calling +\c treeView->selectionModel()->currentIndex() and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed QModelIndex(). This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. + +The selection model (as shown above) can be retrieved, but it can also be set with \c QAbstractItemView::setSelectionModel. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; +\section2 3.3 Predefined Models +The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. + + \table + \row + \o QStringListModel + \o Stores a list of strings + \row + \o QStandardItemModel + \o Stores arbitrary hierarchical items + \row + \o {1, 2} QFileSystemModel +QDirModel (deprecated) + \o {1, 2} Encapsulate the local file system + \row + \o QSqlQueryModel + \o Encapsulate an SQL result set + \row + \o QSqlTableModel + \o Encapsulates an SQL table + \row + \o QSqlRelationalTableModel + \o Encapsulates an SQL table with foreign keys + \row + \o QSortFilterProxyModel + \o Sorts and/or filters another model + + \endtable + +\section2 3.4 Delegates +In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png + +The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemModel::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. + +!!!!!I CAN'T FIND THIS FILE!!!!! +\code + class StarDelegate : public QStyledItemDelegate + { + Q_OBJECT + public: + StarDelegate(QWidget *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const; + }; + +\endcode + +\l{QAbstractItemModel::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \c index.data(). \c SizeHint specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. + +Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. + +\section2 3.5 Debugging with ModelTest +The passive nature of models provides new challenges for programmers. Inconsistencies in the model can cause the application to crash. Since the model is hit by numerous calls from the view, it is hard to find out which call has crashed the application and which operation has introduced the problem. + +Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest + +Unlike view classes, ModelTest uses out of range indexes to test the model. This means your application may crash with ModelTest even if it runs perfectly without it. So you also need to handle all of the indexes that are out of range when using ModelTest. + + + + + + + + + +\section2 3.6 Model/View NG + +\image path.png + +Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. + +One limitation of model/view is that view classes are basically all fixed grids. It is possible, but really hard to make a list view with icons placed on a curve; or cells expanding on mouse over events to show additional information. In order to achieve graphically rich view experiences, Model/View NG will use QGraphicsView to render elements. Nodel/View NG also aims to make model/view programming more intuitive. One way to achieve this is to have separate models for lists, tables and trees. The current model abstraction is complex because it is capable of representing a list, a table or a tree. + +Model/View NG is a research project. You are welcome to checkout the source code, monitor progress and take part in discussions at the following address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} + +\section1 4 Good Sources for Additional Information +\section2 4.1 Books +Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. + \list 1 + \o 1.C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 +also available in German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, Addison-Wesley, ISBN 3-827327-29-6 + \o 1.The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 +Translated from: Qt 4, Einführung in die Applikationsentwicklung, Open Source Press, ISBN 3-937514-12-0 + \o 1.Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 + \endlist + + +The following list provides an overview of example programs contained in the books above. Some of them make very good templates for developing similar applications. + + \table + \header + \o example name + \o view class used + \o model used + \o aspects touched + \o + \row + \o Team Leaders + \o QListview + \o QStringListModel + \o + \o Book 1, Chapter 10, Figure 10.6 + \row + \o Directory Viewer + \o QTreeView + \o QDirModel + \o + \o Book 1, Chapter 10, Figure 10.7 + \row + \o Color Names + \o QListView + \o QSortFilterProxyModel +applied to QStringListModel + \o + \o Book 1, Chapter 10, Figure 10.8 + \row + \o Currencies + \o QTableView + \o custom model based on +QAbstractTableModel + \o read only + \o Book 1, Chapter 10, Figure 10.10 + \row + \o Cities + \o QTableView + \o custom model based on +QAbstractTableModel + \o read / write + \o Book 1, Chapter 10, Figure 10.12 + \row + \o Boolean Parser + \o QTreeView + \o custom model based on +QAbstractItemModel + \o read only + \o Book 1, Chapter 10, Figure 10.14 + \row + \o Track Editor + \o {2, 1} QTableWidget + \o custom delegate providing a custom editor + \o Book 1, Chapter 10, Figure 10.15 + + \row + \o Four directory views + \o QListView +QTableView +QTreeView + \o QDirModel + \o demonstrates the use of multiple views + \o Book2, Chapter 8.2 + \row + \o Address Book + \o QListView +QTableView +QTreeView + \o custom model based on +QAbstractTableModel + \o read / write + \o Book2, Chapter 8.4 + \row + \o Address Book with sorting + \o + \o QProxyModel + \o introducing sort and filter capabilities + \o Book2, Chapter 8.5 + \row + \o Address Book +with checkboxes + \o + \o + \o introducing checkboxes +in model/view + \o Book2, Chapter 8.6 + \row + \o Address Book +with transposed grid + \o + \o custom proxy Model based on QAbstractProxyModel + \o introducing a custom model + \o Book2, Chapter 8.7 + \row + \o Address Book +with drag and drop + \o + \o + \o introducing drag and drop support + \o Book2, Chapter 8.8 + \row + \o Address Book with custom editor + \o + \o + \o introducing custom delegates + \o Book2, Chapter 8.9 + \row + \o Views + \o QListView +QTableView +QTreeView + \o QStandardItemModel + \o read only + \o Book 3, Chapter 5, figure 5-3 + \row + \o Bardelegate + \o QTableView + \o + \o custom delegate for presentation based on QAbstractItemDelegate + \o Book 3, Chapter 5, figure 5-5 + \row + \o Editdelegate + \o QTableView + \o + \o custom delegate for editing based on QAbstractItemDelegate + \o Book 3, Chapter 5, figure 5-6 + \row + \o Singleitemview + \o custom view based on +QAbstractItemView + \o + \o custom view + \o Book 3, +Chapter 5, +figure 5-7 + \row + \o listmodel + \o QTableView + \o custom Model based on +QAbstractTableModel + \o read only + \o Book 3, +Chapter 5, +Figure 5-8 + \row + \o treemodel + \o QTreeView + \o custom Model based on +QAbstractItemModel + \o read only + \o Book 3, +Chapter 5, +Figure 5-10 + \row + \o edit integers + \o QListView + \o custom Model based on +QAbstractListModel + \o read / write + \o Book 3, +Chapter 5, +Listing 5-37, Figure 5-11 + \row + \o sorting + \o QTableView + \o QSortFilterProxyModel +applied to QStringListModel + \o demonstrates sorting + \o Book 3, Chapter 5, Figure 5-12 + + \endtable + + +\section2 4.2 Qt documentation +Qt 4.6 comes with 17 examples and 2 Demonstrations for model/view. The examples can be found here: \l{http://doc.qt.nokia.com/4.6/examples-itemviews.html}{http://doc.qt.nokia.com/4.6/examples-itemviews.html} + \table + \header + \o example name + \o view class used + \o model used + \o aspects touched + \row + \o Address Book + \o QTableView + \o QTableModel +QSortFilterProxyModel + \o usage of QSortFilterProxyModel to generate different subsets from one data pool + \row + \o Basic Sort/Filter Model + \o QTreeView + \o QStandardItemModel +QSortFilterProxyModel + \o + \row + \o Chart + \o custom view + \o QStandardItemModel + \o designing custom views that cooperate with selection models + \row + \o Color Editor Factory + \o {2, 1} QTableWidget + \o enhancing the standard delegate with a new custom editor to choose colours + \row + \o Combo Widget Mapper + \o QDataWidgetMapper to map QLineEdit, QTextEdit and QComboBox + \o QStandardItemModel + \o shows how a QComboBox can serve as a view class + \row + \o Custom Sort/Filter Model + \o QTreeView + \o QStandardItemModel +QSortFilterProxyModel + \o subclass QSortFilterProxyModel +for advanced sorting and filtering + \row + \o Dir View + \o QTreeView + \o QDirModel + \o very small example to demonstrate how to assign a model to a view + \row + \o Editable Tree Model + \o QTreeView + \o custom tree model + \o comprehensive example for working with trees, demonstrates editing cells and tree structure with an underlying custom model + \row + \o Fetch More + \o QListView + \o custom list model + \o dynamically changing model + \row + \o Frozen Column + \o QTableView + \o QStandardItemModel + \o + \row + \o Pixelator + \o QTableView + \o custom table model + \o implementation of a custom delegate + \row + \o Puzzle + \o QListView + \o custom list model + \o model/view with drag and drop + \row + \o Simple DOM Model + \o QTreeView + \o custom tree model + \o read only example for a custom tree model + \row + \o Simple Tree Model + \o QTreeView + \o custom tree model + \o read only example for a custom tree model + \row + \o Simple Widget Mapper + \o QDataWidgetMapper to map QLineEdit, QTextEdit and QSpinBox + \o QStandardItemModel + \o basic QDataWidgetMapper usage + \row + \o Spin Box Delegate + \o QTableView + \o QStandardItemModel + \o custom delegate that uses a spin box as a cell editor + \row + \o Star Delegate + \o {2, 1} QTableWidget + \o comprehensive custom delegate example. + \endtable + +Demonstrations are similar to examples except that no walk-through is provided for the code lines. Demonstrations are also sometimes more feature rich. + \l{http://doc.qt.nokia.com/4.6/demos.html}{http://doc.qt.nokia.com/4.6/demos.html} + \list + \o The \bold Interview demonstration shows the same model and selection being shared between three different views. + \o Demonstration \bold Spreadsheet demonstrates the use of a table view as a spreadsheet, using custom delegates to render each item according to the type of data it contains. + \endlist + +A reference documentation for model/view technology is also available. \l{http://doc.qt.nokia.com/4.6/model-view-programming.html}{http://doc.qt.nokia.com/4.6/model-view-programming.html} + +*/ \ No newline at end of file diff --git a/examples/tutorials/modelview/modelview.pro b/examples/tutorials/modelview/modelview.pro new file mode 100755 index 0000000..7f684ba --- /dev/null +++ b/examples/tutorials/modelview/modelview.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS = 1_readonly \ + 2_formatting \ + 3_changingmodel \ + 4_headers \ + 5_edit \ + 6_treeview \ + 7_selections + diff --git a/examples/tutorials/modelview/qmake.pro b/examples/tutorials/modelview/qmake.pro deleted file mode 100755 index 7f684ba..0000000 --- a/examples/tutorials/modelview/qmake.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = 1_readonly \ - 2_formatting \ - 3_changingmodel \ - 4_headers \ - 5_edit \ - 6_treeview \ - 7_selections - diff --git a/examples/tutorials/tutorials.pro b/examples/tutorials/tutorials.pro index 949fdf6..34723c2 100644 --- a/examples/tutorials/tutorials.pro +++ b/examples/tutorials/tutorials.pro @@ -1,6 +1,8 @@ TEMPLATE = subdirs SUBDIRS = \ - addressbook + addressbook \ + modelview + # install sources.files = README *.pro -- cgit v0.12 From ca10c2c5a8190cac9c2ae0526f2e250add09d6f2 Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Wed, 23 Jun 2010 17:19:49 +0200 Subject: correction of snippet tags --- doc/src/tutorials/modelview.qdoc | 41 ++++++--------------- examples/tutorials/modelview/._.DS_Store | Bin 0 -> 4096 bytes examples/tutorials/modelview/1_readonly/main.cpp | 2 + .../tutorials/modelview/1_readonly/modelview.cpp | 3 +- .../tutorials/modelview/1_readonly/modelview.h | 3 ++ .../tutorials/modelview/1_readonly/mymodel.cpp | 2 + examples/tutorials/modelview/1_readonly/mymodel.h | 2 + .../tutorials/modelview/2_formatting/mymodel.cpp | 3 +- .../modelview/3_changingmodel/mymodel.cpp | 7 ++-- examples/tutorials/modelview/4_headers/mymodel.cpp | 3 +- examples/tutorials/modelview/5_edit/mymodel.cpp | 8 +++- examples/tutorials/modelview/5_edit/mymodel.h | 2 + .../tutorials/modelview/6_treeview/modelview.cpp | 2 + .../tutorials/modelview/7_selections/modelview.cpp | 6 ++- examples/tutorials/modelview/qmake.pro | 10 +++++ 15 files changed, 57 insertions(+), 37 deletions(-) create mode 100755 examples/tutorials/modelview/._.DS_Store create mode 100755 examples/tutorials/modelview/qmake.pro diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index 1be4b46..3c73a80 100755 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -1,9 +1,7 @@ /*! - \page modelview.html - \startpage {index.html}{Qt Reference Documentation} - \contentspage Tutorials \contentspage{modelview.html}{Crash Course in Model/View Programming} + \page modelview.html \title Crash Course in Model/View Programming Contents: @@ -71,16 +69,16 @@ Below are 7 very simple and independent applications that show different sides o We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. -------------------------------------------------------------main.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/main.cpp + \snippet examples/tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial We have the usual main() function; -------------------------------------------------------------modelview.h--------------------- - \snippet examples/tutorials/modelview/1_readonly/modelview.h + \snippet examples/tutorials/modelview/1_readonly/modelview.h Quoting ModelView Tutorial The application is a \l QMainWindow that holds a \l QTableView. -------------------------------------------------------------modelview.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/modelview.cpp + \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Quoting ModelView Tutorial Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: \list @@ -92,13 +90,13 @@ The model needs some code to respond to this. We have a table data set, so let's start with QAbstractTableModel since it is easier to use. -------------------------------------------------------------mymodel.h--------------------- - \snippet examples/tutorials/modelview/1_readonly/mymodel.h + \snippet examples/tutorials/modelview/1_readonly/mymodel.h Quoting ModelView Tutorial QAbstractTableModel requires the implementation of three abstract methods. -------------------------------------------------------------mymodel.cpp--------------------- - \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp + \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp Quoting ModelView Tutorial The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. @@ -114,7 +112,7 @@ In addition to controlling what text the view displays, the model also controls In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: -------------------------------------------------------------mymodel.cpp--------------------- - \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp + \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp Quoting ModelView Tutorial Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: @@ -178,7 +176,6 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. -?????(include section from 3_changingmodel/mymodel.cpp)????? \code MyModel::MyModel(QObject *parent) :QAbstractTableModel(parent) @@ -193,7 +190,6 @@ MyModel::MyModel(QObject *parent) Here is the corresponding slot: -?????(include section from 3_changingmodel/mymodel.cpp)????? \code void MyModel::timerHit() @@ -215,8 +211,6 @@ Headers can be hidden via a view method. The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: - -?????(include section from 4_headers/mymodel.cpp)????? \code QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -244,11 +238,10 @@ In this example, we are going to build an application that automatically populat The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. -------------------------------------------------------------mymodel.h--------------------- - \snippet examples/tutorials/modelview/5_edit/mymodel.h + \snippet examples/tutorials/modelview/5_edit/mymodel.h Quoting ModelView Tutorial We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. -?????(include section from 5_edit/mymodel.cpp)????? \code #include "mymodel.h" @@ -264,16 +257,10 @@ MyModel::MyModel(QObject *parent) \endcode In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) -?????(include section from 5_edit/mymodel.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode + \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_e \l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. -?????(include section from 5_edit/mymodel.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode + \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. @@ -292,7 +279,7 @@ This is how our example model looks so far: We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png -------------------------------------------------------------modelview.cpp--------------------- - \snippet examples/tutorials/modelview/6_treeview/modelview.cpp + \snippet examples/tutorials/modelview/6_treeview/modelview.cpp Quoting ModelView Tutorial We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. @@ -302,7 +289,6 @@ We want to access a selected item's content in order to output it into the windo So let's create a couple of items: -?????(include section from 7_selections/modelview.cpp)????? \code #include #include @@ -351,10 +337,7 @@ ModelView::ModelView(QWidget *parent) Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. -?????(include section from 7_selections/modelview.cpp)????? -\code -HIER FEHLT WAS!!! -\endcode + \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b We get the model index that corresponds to the selection by calling \c treeView->selectionModel()->currentIndex() and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed QModelIndex(). This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. diff --git a/examples/tutorials/modelview/._.DS_Store b/examples/tutorials/modelview/._.DS_Store new file mode 100755 index 0000000..338bd7b Binary files /dev/null and b/examples/tutorials/modelview/._.DS_Store differ diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp index 998503c..bdf740c 100755 --- a/examples/tutorials/modelview/1_readonly/main.cpp +++ b/examples/tutorials/modelview/1_readonly/main.cpp @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #include #include "modelview.h" @@ -8,3 +9,4 @@ int main(int argc, char *argv[]) w.show(); return a.exec(); } +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp index becd61d..14311f9 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.cpp +++ b/examples/tutorials/modelview/1_readonly/modelview.cpp @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #include #include "modelview.h" #include "mymodel.h" @@ -9,4 +10,4 @@ ModelView::ModelView(QWidget *parent) setCentralWidget(tableView); tableView->setModel(new MyModel(this) ); } - +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h index f1b63bd..93b6b90 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.h +++ b/examples/tutorials/modelview/1_readonly/modelview.h @@ -1,6 +1,8 @@ +//! [Quoting ModelView Tutorial] #ifndef MODELVIEW_H #define MODELVIEW_H + #include class QTableView; //forward declaration @@ -16,3 +18,4 @@ public: }; #endif // MODELVIEW_H +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp index ff3e2d2..3386907 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.cpp +++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #include "mymodel.h" MyModel::MyModel(QObject *parent) @@ -28,3 +29,4 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } return QVariant(); } +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h index 01ae6cb..aac1bf0 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.h +++ b/examples/tutorials/modelview/1_readonly/mymodel.h @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H @@ -14,3 +15,4 @@ public: }; #endif // MYMODEL_H +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp index 48b1134..916dabc 100755 --- a/examples/tutorials/modelview/2_formatting/mymodel.cpp +++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp @@ -3,6 +3,7 @@ #include "mymodel.h" #include +//! [Quoting ModelView Tutorial] MyModel::MyModel(QObject *parent) :QAbstractTableModel(parent) { @@ -70,4 +71,4 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } return QVariant(); } - +//! [Quoting ModelView Tutorial] diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp index d594175..fa7f566 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -3,7 +3,7 @@ #include #include "mymodel.h" - +//! [quoting mymodel_a] MyModel::MyModel(QObject *parent) :QAbstractTableModel(parent) { @@ -13,7 +13,7 @@ MyModel::MyModel(QObject *parent) connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); timer->start(); } - +//! [quoting mymodel_a] //------------------------------------------------------- int MyModel::rowCount(const QModelIndex & /*parent */ ) const { @@ -43,6 +43,7 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } //------------------------------------------------------- +//! [quoting mymodel_b ] void MyModel::timerHit() { //we identify the top left cell @@ -50,4 +51,4 @@ void MyModel::timerHit() //emit a signal to make the view reread identified data emit dataChanged ( topLeft, topLeft ); } - +//! [quoting mymodel_b ] diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp index a032fe5..7891c80 100755 --- a/examples/tutorials/modelview/4_headers/mymodel.cpp +++ b/examples/tutorials/modelview/4_headers/mymodel.cpp @@ -29,7 +29,7 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const return QVariant(); } - +//! [quoting mymodel_c] QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::DisplayRole) @@ -48,3 +48,4 @@ QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) } return QVariant(); } +//! [quoting mymodel_c] \ No newline at end of file diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp index c64a6b7..ef45bc3 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.cpp +++ b/examples/tutorials/modelview/5_edit/mymodel.cpp @@ -1,3 +1,4 @@ +//! [quoting mymodel_d] #include "mymodel.h" const int COLS= 3; @@ -9,7 +10,9 @@ MyModel::MyModel(QObject *parent) //gridData needs to have 6 element, one for each table cell m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; } +//! [quoting mymodel_d] +//! [quoting mymodel_e] //------------------------------------------------------- int MyModel::rowCount(const QModelIndex & /*parent*/ ) const { @@ -31,8 +34,11 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } return QVariant(); } +//! [quoting mymodel_e] //----------------------------------------------------------------- + +//! [quoting mymodel_f] bool MyModel::setData ( const QModelIndex & index, const QVariant & value, int role ) { if(role == Qt::EditRole) @@ -55,4 +61,4 @@ int MyModel::modelIndexToOffset(const QModelIndex & index) const { return index.row()*COLS + index.column(); } - +//! [quoting mymodel_f] diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h index f8fac77..1612fa0 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.h +++ b/examples/tutorials/modelview/5_edit/mymodel.h @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H @@ -22,3 +23,4 @@ signals: }; #endif // MYMODEL_H +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/modelview.cpp index a5488f7..b5b4d06 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.cpp +++ b/examples/tutorials/modelview/6_treeview/modelview.cpp @@ -1,3 +1,4 @@ +//! [Quoting ModelView Tutorial] #include #include #include @@ -38,3 +39,4 @@ QList ModelView::prepareColumn(const QString &first, colItems << new QStandardItem(third); return colItems; } +//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/modelview.cpp index 49c5bb8..eac6df9 100755 --- a/examples/tutorials/modelview/7_selections/modelview.cpp +++ b/examples/tutorials/modelview/7_selections/modelview.cpp @@ -1,3 +1,4 @@ +//! [quoting modelview_a] #include #include #include @@ -41,8 +42,11 @@ ModelView::ModelView(QWidget *parent) connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); } +//! [quoting modelview_a] //------------------------------------------------------------------------------------ + +//! [quoting modelview_b] void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/) { const QModelIndex index = treeView->selectionModel()->currentIndex(); @@ -58,6 +62,6 @@ void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, co .arg(hierarchyLevel); setWindowTitle(showString); } - +//! [quoting modelview_b] diff --git a/examples/tutorials/modelview/qmake.pro b/examples/tutorials/modelview/qmake.pro new file mode 100755 index 0000000..7f684ba --- /dev/null +++ b/examples/tutorials/modelview/qmake.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS = 1_readonly \ + 2_formatting \ + 3_changingmodel \ + 4_headers \ + 5_edit \ + 6_treeview \ + 7_selections + -- cgit v0.12 From 798433c9046281a8739eb6b313c7dd0fc7b5e3b1 Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Mon, 28 Jun 2010 12:49:05 +0200 Subject: I've cleaned up the qdoc file a bit. --- doc/src/tutorials/modelview.qdoc | 213 +++++++-------------- .../modelview/3_changingmodel/mymodel.cpp | 3 +- 2 files changed, 70 insertions(+), 146 deletions(-) diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index 3c73a80..c9caf17 100755 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -56,9 +56,13 @@ Here is an overview of the model/view widgets and their corresponding standard w \section2 1.4 Having adapters between forms and models can come in handy. We often prefer editing data stored in tables (e.g. in database tables) in forms rather than in tables. There is no direct model/view counterpart for separating data and views for widgets that operate on one value instead of a dataset, so we need an adapter in order to connect the form to the source of data. -\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. \image widgetmapper.png -Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. \image qcompleter.png +\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. +\image widgetmapper.png + + +Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. +\image qcompleter.png \section1 2 A Simple Model/View Application If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. @@ -71,7 +75,7 @@ We start with an application that uses a \l QTableView to show data. We will add -------------------------------------------------------------main.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial -We have the usual main() function; +We have the usual \l {tutorials/modelview/1_readonly/main.cpp}{main()} function; -------------------------------------------------------------modelview.h--------------------- \snippet examples/tutorials/modelview/1_readonly/modelview.h Quoting ModelView Tutorial @@ -80,7 +84,7 @@ The application is a \l QMainWindow that holds a \l QTableView. -------------------------------------------------------------modelview.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Quoting ModelView Tutorial -Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView::}{tableView()} OR \l QTableView::tableView() OR \l QTableView::tableView . \l {QTableView::}{tableView} will invoke the methods of the pointer it has received to find out two things: +Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView}{tableView()}. \l {QTableView}{tableView} will invoke the methods of the pointer it has received to find out two things: \list \o How many rows and columns should be displayed \o What content should be printed into each cell. @@ -154,54 +158,17 @@ Now we need to determine how using a seperated model impacts the application's p We still have a read only table, but this time the content changes every second because we are showing the current time. -!!!!!I CAN'T FIND THIS FILE!!!!! -\code -QVariant MyModel::data(const QModelIndex &index, int role ) const -{ - QVariant returnVal; - int row = index.row(); - int col = index.column(); - - if(role == Qt::DisplayRole) - - { - if(row == 0 && col == 0 ) - { - returnVal = QTime::currentTime().toString(); - } - } - return returnVal; -} -\endcode + \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_QVariant Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. -\code -MyModel::MyModel(QObject *parent) - :QAbstractTableModel(parent) -{ -// selectedCell = 0; - timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); - timer->start(); -} -\endcode + \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_a Here is the corresponding slot: -\code + \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_b -void MyModel::timerHit() -{ - //we identify the top left cell - QModelIndex topLeft = createIndex ( 0,0 ); - //emit a signal to make the view reread identified data - emit dataChanged ( topLeft, topLeft ); -} -\endcode - -We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QAbstractItemModel::setModel()}{setModel()} . +We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QTableView::setModel}{setModel()} . \section2 2.4 Setting up Headers for Columns and Rows Headers can be hidden via a view method. @@ -209,28 +176,9 @@ Headers can be hidden via a view method. \image header.png -The header content, however , is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: +The header content, however, is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: -\code -QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) { - switch (section) - { - case 0: - return QString("first"); - case 1: - return QString("second"); - case 2: - return QString("third"); - } - } - } - return QVariant(); -} -\endcode + \snippet examples/tutorials/modelview/4_headers/mymodel.cpp quoting mymodel_c \section2 2.5 The minimal Editing example @@ -242,19 +190,7 @@ The model decides whether editing capabilities are available . We only have to m We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. -\code -#include "mymodel.h" - -const int COLS= 3; -const int ROWS= 2; - -MyModel::MyModel(QObject *parent) - :QAbstractTableModel(parent) -{ - //gridData needs to have 6 element, one for each table cell - m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ; -} -\endcode + \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_d In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_e @@ -266,6 +202,7 @@ Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags() \section1 3 Intermediate Topics \section2 3.1 TreeView + You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. \image dummy_tree.png @@ -273,76 +210,33 @@ You can convert the example above into an application with a tree view. Simply r QListView, QTableView and QTreeView all use a model abstraction, which is a merged list, table and tree. This makes it possible to use several different types of view classes from the same model. \image list_table_tree.png + This is how our example model looks so far: \image example_model.png -We want to, however, present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with QStandardItems, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png +We want to present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with \l{QStandardItem}{QStandardItems}, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png -------------------------------------------------------------modelview.cpp--------------------- \snippet examples/tutorials/modelview/6_treeview/modelview.cpp Quoting ModelView Tutorial -We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other QStandardItems. Nodes are collapsed and expanded within the view. +We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within the view. \section2 3.2 Working with selection + + We want to access a selected item's content in order to output it into the window title together with the hierarchy level. \image selection2.png - So let's create a couple of items: -\code -#include -#include -#include -#include "modelview.h" - -ModelView::ModelView(QWidget *parent) - : QMainWindow(parent) -{ - treeView = new QTreeView(this); - setCentralWidget(treeView); - standardModel = new QStandardItemModel ; - QStandardItem *rootNode = standardModel->invisibleRootItem(); - - - //defining a couple of items - QStandardItem *americaItem = new QStandardItem("America"); - QStandardItem *mexicoItem = new QStandardItem("Canada"); - QStandardItem *usaItem = new QStandardItem("USA"); - QStandardItem *bostonItem = new QStandardItem("Boston"); - QStandardItem *europeItem = new QStandardItem("Europe"); - QStandardItem *italyItem = new QStandardItem("Italy"); - QStandardItem *romeItem = new QStandardItem("Rome"); - QStandardItem *veronaItem = new QStandardItem("Verona"); - - //building up the hierarchy - rootNode-> appendRow(americaItem); - rootNode-> appendRow(europeItem); - americaItem-> appendRow(mexicoItem); - americaItem-> appendRow(usaItem); - usaItem-> appendRow(bostonItem); - europeItem-> appendRow(italyItem); - italyItem-> appendRow(romeItem); - italyItem-> appendRow(veronaItem); - - //register the model - treeView->setModel( standardModel ); - treeView->expandAll(); - - //selection changes shall trigger a slot - QItemSelectionModel *selectionModel= treeView->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), - this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); -} -\endcode - + \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_a Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b We get the model index that corresponds to the selection by calling -\c treeView->selectionModel()->currentIndex() and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed QModelIndex(). This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. +\l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()} and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed \l{QModelIndex}{QModelIndex()}. This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. -The selection model (as shown above) can be retrieved, but it can also be set with \c QAbstractItemView::setSelectionModel. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; +The selection model (as shown above) can be retrieved, but it can also be set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; \section2 3.3 Predefined Models The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. @@ -354,9 +248,12 @@ The typical way to use model/view is to wrap specific data to make it usable wit \o QStandardItemModel \o Stores arbitrary hierarchical items \row - \o {1, 2} QFileSystemModel -QDirModel (deprecated) - \o {1, 2} Encapsulate the local file system + \o QFileSystemModel + \raw HTML +
+ \endraw + QDirModel (deprecated) + \o Encapsulate the local file system \row \o QSqlQueryModel \o Encapsulate an SQL result set @@ -375,9 +272,8 @@ QDirModel (deprecated) \section2 3.4 Delegates In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png -The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemModel::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. +The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemView::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. -!!!!!I CAN'T FIND THIS FILE!!!!! \code class StarDelegate : public QStyledItemDelegate { @@ -392,20 +288,22 @@ The view has a method that replaces the default delegate and installs a custom d \endcode -\l{QAbstractItemModel::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \c index.data(). \c SizeHint specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. +\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QStyledItemDelegate::SizeHint}{SizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. \section2 3.5 Debugging with ModelTest The passive nature of models provides new challenges for programmers. Inconsistencies in the model can cause the application to crash. Since the model is hit by numerous calls from the view, it is hard to find out which call has crashed the application and which operation has introduced the problem. -Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest +Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. \l http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest Unlike view classes, ModelTest uses out of range indexes to test the model. This means your application may crash with ModelTest even if it runs perfectly without it. So you also need to handle all of the indexes that are out of range when using ModelTest. - +\raw HTML +
+\endraw @@ -413,25 +311,50 @@ Unlike view classes, ModelTest uses out of range indexes to test the model. Thi \section2 3.6 Model/View NG -\image path.png +\raw HTML + +
+\endraw -Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. +\raw HTML + +\endraw +Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. +\raw HTML +
+\endraw One limitation of model/view is that view classes are basically all fixed grids. It is possible, but really hard to make a list view with icons placed on a curve; or cells expanding on mouse over events to show additional information. In order to achieve graphically rich view experiences, Model/View NG will use QGraphicsView to render elements. Nodel/View NG also aims to make model/view programming more intuitive. One way to achieve this is to have separate models for lists, tables and trees. The current model abstraction is complex because it is capable of representing a list, a table or a tree. - +\raw HTML +
+\endraw Model/View NG is a research project. You are welcome to checkout the source code, monitor progress and take part in discussions at the following address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} +\raw HTML +
+\endraw + +\inlineimage path.png + +\raw HTML +
+\endraw +\raw HTML +
+\endraw \section1 4 Good Sources for Additional Information \section2 4.1 Books Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. \list 1 - \o 1.C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 + \o C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 also available in German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, Addison-Wesley, ISBN 3-827327-29-6 - \o 1.The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 + \o The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 Translated from: Qt 4, Einführung in die Applikationsentwicklung, Open Source Press, ISBN 3-937514-12-0 - \o 1.Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 + \o Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 \endlist - +\raw HTML +
+\endraw The following list provides an overview of example programs contained in the books above. Some of them make very good templates for developing similar applications. diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp index fa7f566..8943003 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -27,6 +27,7 @@ int MyModel::columnCount(const QModelIndex & /*parent */ ) const } //------------------------------------------------------- +//! [quoting mymodel_QVariant ] QVariant MyModel::data(const QModelIndex &index, int role ) const { int row = index.row(); @@ -41,7 +42,7 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } return QVariant(); } - +//! [quoting mymodel_QVariant ] //------------------------------------------------------- //! [quoting mymodel_b ] void MyModel::timerHit() -- cgit v0.12 From 269b910f08f54333834c3a4d91b250b185a53863 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 28 Jun 2010 15:52:45 +0200 Subject: Doc: Added the standard three clause BSD license header. Reviewed-by: Trust Me --- examples/tutorials/modelview/1_readonly/main.cpp | 42 +++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp index bdf740c..ad11f38 100755 --- a/examples/tutorials/modelview/1_readonly/main.cpp +++ b/examples/tutorials/modelview/1_readonly/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #include #include "modelview.h" @@ -9,4 +49,4 @@ int main(int argc, char *argv[]) w.show(); return a.exec(); } -//! [Quoting ModelView Tutorial] \ No newline at end of file +//! [Quoting ModelView Tutorial] -- cgit v0.12 From 5938c706524fa9a7de531847bedae19a97fa130b Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Thu, 1 Jul 2010 10:32:05 +0200 Subject: replaced image, license headers, more links in modelview.qdoc file --- doc/src/images/columnview.png | Bin 11717 -> 3480 bytes doc/src/tutorials/modelview.qdoc | 30 ++++++++-------- .../tutorials/modelview/1_readonly/1_readonly.pro | 40 +++++++++++++++++++++ .../tutorials/modelview/1_readonly/modelview.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/1_readonly/modelview.h | 40 +++++++++++++++++++++ .../tutorials/modelview/1_readonly/mymodel.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/1_readonly/mymodel.h | 40 +++++++++++++++++++++ .../modelview/2_formatting/2_formatting.pro | 40 +++++++++++++++++++++ examples/tutorials/modelview/2_formatting/main.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/2_formatting/modelview.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/2_formatting/modelview.h | 40 +++++++++++++++++++++ .../tutorials/modelview/2_formatting/mymodel.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/2_formatting/mymodel.h | 40 +++++++++++++++++++++ .../modelview/3_changingmodel/3_changingmodel.pro | 40 +++++++++++++++++++++ .../tutorials/modelview/3_changingmodel/main.cpp | 40 +++++++++++++++++++++ .../modelview/3_changingmodel/modelview.cpp | 40 +++++++++++++++++++++ .../modelview/3_changingmodel/modelview.h | 40 +++++++++++++++++++++ .../modelview/3_changingmodel/mymodel.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/3_changingmodel/mymodel.h | 40 +++++++++++++++++++++ .../tutorials/modelview/4_headers/4_headers.pro | 40 +++++++++++++++++++++ examples/tutorials/modelview/4_headers/main.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/4_headers/modelview.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/4_headers/modelview.h | 40 +++++++++++++++++++++ examples/tutorials/modelview/4_headers/mymodel.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/4_headers/mymodel.h | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/5_edit.pro | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/main.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/modelview.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/modelview.h | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/mymodel.cpp | 40 +++++++++++++++++++++ examples/tutorials/modelview/5_edit/mymodel.h | 40 +++++++++++++++++++++ .../tutorials/modelview/6_treeview/6_treeview.pro | 40 +++++++++++++++++++++ examples/tutorials/modelview/6_treeview/main.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/6_treeview/modelview.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/6_treeview/modelview.h | 40 +++++++++++++++++++++ .../modelview/7_selections/7_selections.pro | 40 +++++++++++++++++++++ examples/tutorials/modelview/7_selections/main.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/7_selections/modelview.cpp | 40 +++++++++++++++++++++ .../tutorials/modelview/7_selections/modelview.h | 40 +++++++++++++++++++++ 39 files changed, 1495 insertions(+), 15 deletions(-) mode change 100755 => 100644 doc/src/images/columnview.png diff --git a/doc/src/images/columnview.png b/doc/src/images/columnview.png old mode 100755 new mode 100644 index 2fb972e..127b795 Binary files a/doc/src/images/columnview.png and b/doc/src/images/columnview.png differ diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index c9caf17..67908b9 100755 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -3,7 +3,7 @@ \contentspage{modelview.html}{Crash Course in Model/View Programming} \page modelview.html -\title Crash Course in Model/View Programming +\title An Introduction to Model/View Programming Contents: \tableofcontents @@ -84,7 +84,7 @@ The application is a \l QMainWindow that holds a \l QTableView. -------------------------------------------------------------modelview.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Quoting ModelView Tutorial -Here is the interesting part: We use \c tableView->setModel(new MyModel(this) ); to instantiate the Model and pass its pointer to \l {QTableView}{tableView()}. \l {QTableView}{tableView} will invoke the methods of the pointer it has received to find out two things: +Here is the interesting part: We use \l{QTableView::setModel()}{tableView->setModel(new MyModel(this) );} to instantiate the Model and pass its pointer to \l {QTableView}{tableView()}. \l {QTableView}{tableView} will invoke the methods of the pointer it has received to find out two things: \list \o How many rows and columns should be displayed \o What content should be printed into each cell. @@ -102,8 +102,8 @@ QAbstractTableModel requires the implementation of three abstract methods. -------------------------------------------------------------mymodel.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp Quoting ModelView Tutorial -The number of rows and columns is set by \c MyModel::rowCount() and \c MyModel::columnCount(). -When the view has to know what the cell 's text is, it calls the \l{QAbstractItemModel::data()}{data()} method. Row and column information is specified with parameter \c index and the role is set to Qt::Display Role. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. +The number of rows and columns is set by \l{QAbstractItemModel::rowCount()}{MyModel::rowCount()} and \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}. +When the view has to know what the cell 's text is, it calls the method. Row and column information is specified with parameter \c index and the role is set to \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. This small example demonstrates the passive nature of a model. The model does not know when it will be used or which data is needed. It simply provides data each time the view requests it. @@ -126,7 +126,7 @@ Each formatting property will be requested from the model with a separate call t \o Meaning \o Type \row - \o Qt::DisplayRole + \o \l{Qt::ItemDataRole}{Qt::DisplayRole} \o text \o QString \row @@ -143,15 +143,15 @@ Each formatting property will be requested from the model with a separate call t \o enum Qt::AlignmentFlag \row \o {1, 3} Qt::CheckStateRole - \o {1, 3} suppresses checkboxes with QVariant(), sets checkboxes with Qt::Checked or Qt::Unchecked - \o {1, 3} enum Qt::ItemDataRole + \o {1, 3} suppresses checkboxes with \l{QVariant}{QVariant()}, sets checkboxes with Qt::Checked or Qt::Unchecked + \o {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole} \endtable Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. -Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()}) is invoked and expensive lookup operations are cached. +Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()} is invoked and expensive lookup operations are cached. \section2 2.3 A clock inside a table cell \image clock.png @@ -168,7 +168,7 @@ Here is the corresponding slot: \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_b -We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QTableView::setModel}{setModel()} . +We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QTableView::setModel()}{setModel()}. \section2 2.4 Setting up Headers for Columns and Rows Headers can be hidden via a view method. @@ -219,7 +219,7 @@ We want to present a real tree. We have wrapped our data in the examples above i -------------------------------------------------------------modelview.cpp--------------------- \snippet examples/tutorials/modelview/6_treeview/modelview.cpp Quoting ModelView Tutorial -We simply instantiate a QStandardItemModel and add a couple of QStandardItems to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within the view. +We simply instantiate a QStandardItemModel and add a couple of \l{QStandardItem}{QStandardItems} to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within the view. \section2 3.2 Working with selection @@ -229,14 +229,14 @@ We want to access a selected item's content in order to output it into the windo So let's create a couple of items: \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_a -Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemModel::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemModel::selectionChanged()}{selectionChanged()} signal. +Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemView::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemView::selectionChanged()}{selectionChanged()} signal. \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b We get the model index that corresponds to the selection by calling \l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()} and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed \l{QModelIndex}{QModelIndex()}. This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. -The selection model (as shown above) can be retrieved, but it can also be set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemModel::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemModel::setSelectionModel()}{setSelectionModel()}; +The selection model (as shown above) can be retrieved, but it can also be set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemView::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemView::setSelectionModel()}{setSelectionModel()}; \section2 3.3 Predefined Models The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. @@ -252,7 +252,7 @@ The typical way to use model/view is to wrap specific data to make it usable wit \raw HTML
\endraw - QDirModel (deprecated) + QDirModel \o Encapsulate the local file system \row \o QSqlQueryModel @@ -288,7 +288,7 @@ The view has a method that replaces the default delegate and installs a custom d \endcode -\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QStyledItemDelegate::SizeHint}{SizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. +\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QGraphicsLayoutItem::sizeHint()}{sizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. @@ -540,7 +540,7 @@ Qt 4.6 comes with 17 examples and 2 Demonstrations for model/view. The examples \row \o Address Book \o QTableView - \o QTableModel + \o QAbstractTableModel QSortFilterProxyModel \o usage of QSortFilterProxyModel to generate different subsets from one data pool \row diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro index 1162d5a..8528cde 100755 --- a/examples/tutorials/modelview/1_readonly/1_readonly.pro +++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_readonly TEMPLATE = app diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp index 14311f9..027be56 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.cpp +++ b/examples/tutorials/modelview/1_readonly/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #include #include "modelview.h" diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h index 93b6b90..d0f96cd 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.h +++ b/examples/tutorials/modelview/1_readonly/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #ifndef MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp index 3386907..c441720 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.cpp +++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #include "mymodel.h" diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h index aac1bf0..c0ddf4ac6 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.h +++ b/examples/tutorials/modelview/1_readonly/mymodel.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro index 7e70d81..cdf72bf 100755 --- a/examples/tutorials/modelview/2_formatting/2_formatting.pro +++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_formatting TEMPLATE = app diff --git a/examples/tutorials/modelview/2_formatting/main.cpp b/examples/tutorials/modelview/2_formatting/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/2_formatting/main.cpp +++ b/examples/tutorials/modelview/2_formatting/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/2_formatting/modelview.cpp b/examples/tutorials/modelview/2_formatting/modelview.cpp index becd61d..2b05d4c 100755 --- a/examples/tutorials/modelview/2_formatting/modelview.cpp +++ b/examples/tutorials/modelview/2_formatting/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" #include "mymodel.h" diff --git a/examples/tutorials/modelview/2_formatting/modelview.h b/examples/tutorials/modelview/2_formatting/modelview.h index 98bee38..7291487 100755 --- a/examples/tutorials/modelview/2_formatting/modelview.h +++ b/examples/tutorials/modelview/2_formatting/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp index 916dabc..e9e68de 100755 --- a/examples/tutorials/modelview/2_formatting/mymodel.cpp +++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include #include "mymodel.h" diff --git a/examples/tutorials/modelview/2_formatting/mymodel.h b/examples/tutorials/modelview/2_formatting/mymodel.h index 01ae6cb..4dc405a 100755 --- a/examples/tutorials/modelview/2_formatting/mymodel.h +++ b/examples/tutorials/modelview/2_formatting/mymodel.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MYMODEL_H #define MYMODEL_H diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro index d61ee4c..8b217cb 100755 --- a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro +++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_changingmodel TEMPLATE = app diff --git a/examples/tutorials/modelview/3_changingmodel/main.cpp b/examples/tutorials/modelview/3_changingmodel/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/3_changingmodel/main.cpp +++ b/examples/tutorials/modelview/3_changingmodel/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.cpp b/examples/tutorials/modelview/3_changingmodel/modelview.cpp index becd61d..2b05d4c 100755 --- a/examples/tutorials/modelview/3_changingmodel/modelview.cpp +++ b/examples/tutorials/modelview/3_changingmodel/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" #include "mymodel.h" diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.h b/examples/tutorials/modelview/3_changingmodel/modelview.h index 98bee38..7291487 100755 --- a/examples/tutorials/modelview/3_changingmodel/modelview.h +++ b/examples/tutorials/modelview/3_changingmodel/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp index 8943003..d806945 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include #include diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.h b/examples/tutorials/modelview/3_changingmodel/mymodel.h index 9cc023b..47b026e 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.h +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MYMODEL_H #define MYMODEL_H diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro index d6f8d23..13b0b1d 100755 --- a/examples/tutorials/modelview/4_headers/4_headers.pro +++ b/examples/tutorials/modelview/4_headers/4_headers.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_headers TEMPLATE = app diff --git a/examples/tutorials/modelview/4_headers/main.cpp b/examples/tutorials/modelview/4_headers/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/4_headers/main.cpp +++ b/examples/tutorials/modelview/4_headers/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/4_headers/modelview.cpp b/examples/tutorials/modelview/4_headers/modelview.cpp index 39394da..f661ab5 100755 --- a/examples/tutorials/modelview/4_headers/modelview.cpp +++ b/examples/tutorials/modelview/4_headers/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include #include "modelview.h" diff --git a/examples/tutorials/modelview/4_headers/modelview.h b/examples/tutorials/modelview/4_headers/modelview.h index f1b63bd..7669e35 100755 --- a/examples/tutorials/modelview/4_headers/modelview.h +++ b/examples/tutorials/modelview/4_headers/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp index 7891c80..94fde34 100755 --- a/examples/tutorials/modelview/4_headers/mymodel.cpp +++ b/examples/tutorials/modelview/4_headers/mymodel.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 "mymodel.h" MyModel::MyModel(QObject *parent) diff --git a/examples/tutorials/modelview/4_headers/mymodel.h b/examples/tutorials/modelview/4_headers/mymodel.h index 327ca10..ada3169 100755 --- a/examples/tutorials/modelview/4_headers/mymodel.h +++ b/examples/tutorials/modelview/4_headers/mymodel.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MYMODEL_H #define MYMODEL_H diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro index e18c596..d0a2571 100755 --- a/examples/tutorials/modelview/5_edit/5_edit.pro +++ b/examples/tutorials/modelview/5_edit/5_edit.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_edit TEMPLATE = app diff --git a/examples/tutorials/modelview/5_edit/main.cpp b/examples/tutorials/modelview/5_edit/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/5_edit/main.cpp +++ b/examples/tutorials/modelview/5_edit/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/5_edit/modelview.cpp b/examples/tutorials/modelview/5_edit/modelview.cpp index b6e8e34..d8853c9 100755 --- a/examples/tutorials/modelview/5_edit/modelview.cpp +++ b/examples/tutorials/modelview/5_edit/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" #include "mymodel.h" diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/modelview.h index e1591f9..97c840c 100755 --- a/examples/tutorials/modelview/5_edit/modelview.h +++ b/examples/tutorials/modelview/5_edit/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp index ef45bc3..6007da1 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.cpp +++ b/examples/tutorials/modelview/5_edit/mymodel.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [quoting mymodel_d] #include "mymodel.h" diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h index 1612fa0..54f2b30 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.h +++ b/examples/tutorials/modelview/5_edit/mymodel.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro index 6d078be..fa27c3a 100755 --- a/examples/tutorials/modelview/6_treeview/6_treeview.pro +++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_tree TEMPLATE = app SOURCES += main.cpp \ diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/6_treeview/main.cpp +++ b/examples/tutorials/modelview/6_treeview/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/modelview.cpp index b5b4d06..a25e4e9 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.cpp +++ b/examples/tutorials/modelview/6_treeview/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [Quoting ModelView Tutorial] #include #include diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/modelview.h index 1ab23ea..2329e89 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.h +++ b/examples/tutorials/modelview/6_treeview/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro index 952641c6..671dc24 100755 --- a/examples/tutorials/modelview/7_selections/7_selections.pro +++ b/examples/tutorials/modelview/7_selections/7_selections.pro @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + TARGET = mv_selections TEMPLATE = app SOURCES += main.cpp \ diff --git a/examples/tutorials/modelview/7_selections/main.cpp b/examples/tutorials/modelview/7_selections/main.cpp index 998503c..7be212e 100755 --- a/examples/tutorials/modelview/7_selections/main.cpp +++ b/examples/tutorials/modelview/7_selections/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 #include "modelview.h" diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/modelview.cpp index eac6df9..2ef980d 100755 --- a/examples/tutorials/modelview/7_selections/modelview.cpp +++ b/examples/tutorials/modelview/7_selections/modelview.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + //! [quoting modelview_a] #include #include diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/modelview.h index 0e638a9..5229ac3 100755 --- a/examples/tutorials/modelview/7_selections/modelview.h +++ b/examples/tutorials/modelview/7_selections/modelview.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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 MODELVIEW_H #define MODELVIEW_H -- cgit v0.12 From b7bf2ab2d0aa9e3bf073126f0e15c71e39567fcc Mon Sep 17 00:00:00 2001 From: Michael D Scull Date: Fri, 2 Jul 2010 18:10:13 +0200 Subject: new image for tutorial.qdoc --- doc/src/getting-started/tutorials.qdoc | 12 ++++ doc/src/images/treeview_sml.png | Bin 0 -> 17419 bytes doc/src/tutorials/modelview.qdoc | 115 ++++++++++++++++++++++++++++++--- 3 files changed, 118 insertions(+), 9 deletions(-) create mode 100755 doc/src/images/treeview_sml.png diff --git a/doc/src/getting-started/tutorials.qdoc b/doc/src/getting-started/tutorials.qdoc index 6e1cee8..0a83170 100644 --- a/doc/src/getting-started/tutorials.qdoc +++ b/doc/src/getting-started/tutorials.qdoc @@ -71,6 +71,18 @@ A guided tour through the translations process, explaining the tools provided for developers, translators and release managers. + + \row + \o{2,1} \l{modelview.html}{\bold{ModelView}} + \o{2,1} + + \row + \o \image treeview_sml.png ModelView + \o This tutorial gives an introduction to ModelView programming using the Qt cross-platform framework + + \o + \o + \row \o{2,1} \l{QTestLib Tutorial}{\bold QTestLib} \o{2,1} \l{qmake Tutorial}{\bold qmake} diff --git a/doc/src/images/treeview_sml.png b/doc/src/images/treeview_sml.png new file mode 100755 index 0000000..fb6de1d Binary files /dev/null and b/doc/src/images/treeview_sml.png differ diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index 67908b9..bc03f44 100755 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -1,12 +1,63 @@ /*! - - \contentspage{modelview.html}{Crash Course in Model/View Programming} \page modelview.html -\title An Introduction to Model/View Programming -Contents: -\tableofcontents + \startpage {index.html}{Qt Reference Documentation} + \contentspage {modelview-index.html}{ModelView Contents} + \nextpage {modelview-part1.html}{Introduction} + \title ModelView Contents Page + \brief An introduction to ModelView programming + + This tutorial gives an introduction to ModelView programming using the Qt + cross-platform framework. + + \image treeview.png + + \omit + It doesn't cover everything; the emphasis is on teaching the programming + philosophy of ModelView programming, and Qt's features are introduced as needed. + Some commonly used features are never used in this tutorial. + \endomit + + In the process, we will learn about some basic technologies provided by Qt, + such as: + + \list + \o The difference between standard and modelview widgets + \o Adapters betweeen forms and models + \o Developing a simple Model/View application + \o Intermediate topics such as: + \list + \o Tree views + \o Selection + \o Predefined models + \o Delegates + \o Debugging with model test + \endlist + \endlist + + If you are completely new to Qt, please read \l{How to Learn Qt} if you + have not already done so. + + The tutorial's source code is located in Qt's \c examples/tutorials/modelview + directory. + + \list 1 + \o \l{modelview-part1.html}{Introduction} + \o \l{modelview-part2.html}{Developing a simple ModelView application} + \o \l{modelview-part3.html}{Intermediate Topics} + \o \l{modelview-part4.html}{Good Sources for Additional Information} + \endlist + +*/ + +/*! + \page modelview-part1.html + \title An Introduction to Model/View Programming + + \raw HTML +
+ \endraw \section1 1 Introduction Model/View is a technology used to separate data from views in widgets that handle data sets. Standard Widgets are not designed for separating data from views and this is why Qt 4 has two different types of widgets. Both types of widgets look the same, but they interact with data differently. \table @@ -64,6 +115,27 @@ We often prefer editing data stored in tables (e.g. in database tables) in forms Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. \image qcompleter.png + +*/ + +/*! + + + \page modelview-part2-main-cpp.html + \title main.cpp + \quotefile tutorials/modelview/1_readonly/main.cpp + + +*/ + +/*! + \page modelview-part2.html + \title ModelView Chapter 2 - A Simple Model/View Application + + \raw HTML +
+ \endraw + \section1 2 A Simple Model/View Application If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. @@ -75,7 +147,7 @@ We start with an application that uses a \l QTableView to show data. We will add -------------------------------------------------------------main.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial -We have the usual \l {tutorials/modelview/1_readonly/main.cpp}{main()} function; +We have the usual \l {modelview-part2-main-cpp.html}{main()} function; -------------------------------------------------------------modelview.h--------------------- \snippet examples/tutorials/modelview/1_readonly/modelview.h Quoting ModelView Tutorial @@ -148,7 +220,7 @@ Each formatting property will be requested from the model with a separate call t \endtable -Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. +Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()} is invoked and expensive lookup operations are cached. @@ -198,9 +270,20 @@ In the constructor, we fill \c QStringList gridData with 6 items. (one item for \l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f -Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. +Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | \c Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. + +*/ +/*! + \page modelview-part3.html + \title ModelView Chapter 3 - Intermediate Topics + \raw HTML +
+ \endraw \section1 3 Intermediate Topics + \raw HTML +
+ \endraw \section2 3.1 TreeView You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. @@ -288,7 +371,7 @@ The view has a method that replaces the default delegate and installs a custom d \endcode -\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QGraphicsLayoutItem::sizeHint()}{sizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. +\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QAbstractItemDelegate::sizeHint()}{sizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. @@ -342,7 +425,21 @@ Model/View NG is a research project. You are welcome to checkout the source code \raw HTML
\endraw + +*/ + +/*! + \page modelview-part4.html + + \title ModelView Chapter 4 - Good Sources for Additional Information + + \raw HTML +
+ \endraw \section1 4 Good Sources for Additional Information +\raw HTML +
+\endraw \section2 4.1 Books Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. \list 1 -- cgit v0.12 From 03da6bf799823d8b2f7aa8ebe337076dd5d170e4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 7 Jul 2010 18:12:46 +0100 Subject: Added trace statements to Phonon MMF backend Reviewed-by: trustme --- src/3rdparty/phonon/mmf/videoplayer_surface.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp index 343370c..f380e69 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_surface.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_surface.cpp @@ -107,6 +107,9 @@ void MMF::SurfaceVideoPlayer::handleVideoWindowChanged() void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters) { + TRACE_CONTEXT(SurfaceVideoPlayer::handleParametersChanged, EVideoApi); + TRACE_ENTRY("parameters 0x%x", parameters.operator int()); + TRect rect; if (m_videoOutput) { m_videoOutput->dump(); @@ -137,12 +140,20 @@ void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters } } } + + TRACE_EXIT_0(); } void MMF::SurfaceVideoPlayer::addDisplayWindow(const TRect &rect) { + TRACE_CONTEXT(SurfaceVideoPlayer::addDisplayWindow, EVideoApi); + TRACE_ENTRY("rect %d %d - %d %d", rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY); + Q_ASSERT(!m_displayWindow); RWindow *window = static_cast(m_window); + + TRACE("window 0x%08x", window); + if (window) { window->SetBackgroundColor(TRgb(0, 0, 0, 255)); CVideoPlayerUtility2 *player = static_cast(m_player.data()); @@ -152,11 +163,17 @@ void MMF::SurfaceVideoPlayer::addDisplayWindow(const TRect &rect) m_displayWindow = window; else setError(tr("Video display error"), err); + TRACE("err %d", err); } + + TRACE_EXIT_0(); } void MMF::SurfaceVideoPlayer::removeDisplayWindow() { + TRACE_CONTEXT(SurfaceVideoPlayer::removeDisplayWindow, EVideoApi); + TRACE("player 0x%08x window 0x%08x", m_player.data(), m_displayWindow); + CVideoPlayerUtility2 *player = static_cast(m_player.data()); if (player && m_displayWindow) { player->RemoveDisplayWindow(*m_displayWindow); -- cgit v0.12 From 656fd8d3f308205c811a8b1b1c9230ce5f8fc49e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 7 Jul 2010 18:43:04 +0100 Subject: Use lower case for including system header files All platform includes are now lower case, i.e. '#include ' rather than '#include '. Note that Qt includes are still camel case, e.g. '#include ' Task-number: QTBUG-6528 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 +- src/3rdparty/phonon/mmf/audioequalizer.cpp | 2 +- src/3rdparty/phonon/mmf/bassboost.cpp | 2 +- src/3rdparty/phonon/mmf/environmentalreverb.cpp | 2 +- src/3rdparty/phonon/mmf/loudness.cpp | 2 +- src/3rdparty/phonon/mmf/stereowidening.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 70adcf6..8879636 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -21,7 +21,7 @@ along with this library. If not, see . #include -#include +#include #include diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 1d2bbd4..28433f6 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "audioequalizer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 67076f6..81d9208 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "bassboost.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp index d4f5223..c500385 100644 --- a/src/3rdparty/phonon/mmf/environmentalreverb.cpp +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "environmentalreverb.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp index ca05ab0..22d7518 100644 --- a/src/3rdparty/phonon/mmf/loudness.cpp +++ b/src/3rdparty/phonon/mmf/loudness.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "loudness.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp index f90651b..e452160 100644 --- a/src/3rdparty/phonon/mmf/stereowidening.cpp +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "stereowidening.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 95e55e6bbfaf76166b64e7f57c612826afd19a86 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 7 Jul 2010 20:39:30 +0200 Subject: typos fixed Reviewed-by: TrustMe --- examples/qtconcurrent/progressdialog/main.cpp | 2 +- src/corelib/concurrent/qtconcurrentmap.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/qtconcurrent/progressdialog/main.cpp b/examples/qtconcurrent/progressdialog/main.cpp index 04a18dc..369d82c 100644 --- a/examples/qtconcurrent/progressdialog/main.cpp +++ b/examples/qtconcurrent/progressdialog/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char **argv) QProgressDialog dialog; dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount())); - // Create a QFutureWatcher and conncect signals and slots. + // Create a QFutureWatcher and connect signals and slots. QFutureWatcher futureWatcher; QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset())); QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel())); diff --git a/src/corelib/concurrent/qtconcurrentmap.cpp b/src/corelib/concurrent/qtconcurrentmap.cpp index 39a13fb..e74d69c 100644 --- a/src/corelib/concurrent/qtconcurrentmap.cpp +++ b/src/corelib/concurrent/qtconcurrentmap.cpp @@ -70,7 +70,7 @@ \value UnorderedReduce Reduction is done in an arbitrary order. \value OrderedReduce Reduction is done in the order of the original sequence. - \value SequentialReduce Reduction is done sequentally: only one + \value SequentialReduce Reduction is done sequentially: only one thread will enter the reduce function at a time. (Parallel reduction might be supported in a future version of Qt Concurrent.) */ -- cgit v0.12 From 2ef8b92ececbf9d33d7c0b44f46c7c975fb0fdaa Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 8 Jul 2010 08:42:27 +0200 Subject: QUUid::createUuid() should not generate identical sequences on UNIX An unintended side-effect of commit 90a082c9076f35dcca092ade019891e92692710e is that if qrand() is used without being seeded first, then createUuid() would always generate the same sequence. This quite likely to happen considering the Qt does not actually seed the PRNG, but does use it in many places (we do not call qsrand(), but we do often call qrand()). Fix this by changing qrand() to calculate a seed, instead of defaulting to 1. This allows us to remove the qsrand() overload with no arguments, since qrand() will now seed automatically unless manually seeded by the programmer. Task-number: QTBUG-11213 Reviewed-by: thiago --- src/corelib/global/qglobal.cpp | 58 ++++++------------------------------------ src/corelib/plugin/quuid.cpp | 12 +++------ 2 files changed, 12 insertions(+), 58 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 66519be..b24ba38 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2586,55 +2586,6 @@ void qsrand(uint seed) #endif } -/*! \internal - \relates - \since 4.6 - - Seed the PRNG, but only if it has not already been seeded. - - The default seed is a combination of current time, a stack address and a - serial counter (since thread stack addresses are re-used). -*/ -void qsrand() -{ -#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) - SeedStorage *seedStorage = randTLS(); - if (seedStorage) { - SeedStorageType *pseed = seedStorage->localData(); - if (pseed) { - // already seeded - return; - } - seedStorage->setLocalData(pseed = new SeedStorageType); - // start beyond 1 to avoid the sequence reset - static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); - *pseed = QDateTime::currentDateTime().toTime_t() - + quintptr(&pseed) - + serial.fetchAndAddRelaxed(1); -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - // for Windows and Symbian the srand function must still be called. - srand(*pseed); -#endif - } - -//QT_NO_THREAD implementations -#else - static unsigned int seed = 0; - - if (seed) - return; - -#if defined(Q_OS_SYMBIAN) - seed = Math::Random(); -#elif defined(Q_OS_WIN) - seed = GetTickCount(); -#else - seed = quintptr(&seed) + QDateTime::currentDateTime().toTime_t(); -#endif - srand(seed); -#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) -} - /*! \relates \since 4.2 @@ -2658,7 +2609,14 @@ int qrand() SeedStorageType *pseed = seedStorage->localData(); if (!pseed) { seedStorage->setLocalData(pseed = new SeedStorageType); - *pseed = 1; + + // Seed the PRNG, but only if it has not already been seeded. The + // default seed is a combination of current time, a stack address + // and a serial counter (since thread stack addresses are re-used). + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); + *pseed = QDateTime::currentDateTime().toTime_t() + + quintptr(&pseed) + + serial.fetchAndAddRelaxed(1); } return rand_r(pseed); } else { diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 8541c7d..6a7d35c 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -577,23 +577,19 @@ QUuid QUuid::createUuid() QT_BEGIN_INCLUDE_NAMESPACE #include "qdatetime.h" -#include "stdlib.h" // For srand/rand QT_END_INCLUDE_NAMESPACE -extern void qsrand(); // in qglobal.cpp - QUuid QUuid::createUuid() { static const int intbits = sizeof(int)*8; static int randbits = 0; if (!randbits) { + int r = 0; int max = RAND_MAX; - do { ++randbits; } while ((max=max>>1)); + do { ++r; } while ((max=max>>1)); + randbits = r; } - // reseed, but only if not already seeded - qsrand(); - QUuid result; uint *data = &(result.data1); int chunks = 16 / sizeof(uint); @@ -601,7 +597,7 @@ QUuid QUuid::createUuid() uint randNumber = 0; for (int filled = 0; filled < intbits; filled += randbits) randNumber |= qrand()< Date: Thu, 8 Jul 2010 11:47:09 +0200 Subject: Compile Re-add the stdlib.h include, since it brings in RAND_MAX Reviewed-by: TrustMe --- src/corelib/plugin/quuid.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 6a7d35c..f48cc2e 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -577,6 +577,7 @@ QUuid QUuid::createUuid() QT_BEGIN_INCLUDE_NAMESPACE #include "qdatetime.h" +#include // for RAND_MAX QT_END_INCLUDE_NAMESPACE QUuid QUuid::createUuid() -- cgit v0.12 From 48469ecd3f2918d16ccfacb5d65f3a5e0bbfa8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 8 Jul 2010 15:19:04 +0200 Subject: The Q_WGL define was removed years ago. The proper define should be Q_WS_WIN. Task-number: QTBUG-12040 Reviewed-by: Prasanth Reviewed-by: Eskil --- src/opengl/qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index c294e4f..0521bab 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3447,7 +3447,7 @@ QGLWidget::~QGLWidget() bool doRelease = (glcx && glcx->windowCreated()); #endif delete d->glcx; -#if defined(Q_WGL) +#if defined(Q_WS_WIN) delete d->olcx; #endif #if defined(GLX_MESA_release_buffers) && defined(QGL_USE_MESA_EXT) -- cgit v0.12 From c48eb6d5d0a299449330dea8a6a59514942c8781 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 8 Jul 2010 15:27:14 +0200 Subject: Initalize the nativeDialogInUse variable When the variable was not initalized it would randomly show a native font dialog or a non native one if the DontUseNativeDialogs flag was set. Task-number: QTBUG-12042 Reviewed-by: cduclos --- src/gui/dialogs/qfontdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index a4bf15d..e9e3f23 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -332,6 +332,7 @@ void QFontDialogPrivate::init() #ifdef Q_WS_MAC delegate = 0; + nativeDialogInUse = false; #endif } -- cgit v0.12 From aba1572d588396d3c9e29192ae86047b5b10070a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 8 Jul 2010 20:58:46 +0200 Subject: Doc: Fixed incorrect QML property type. Reviewed-by: Trust Me --- src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 0342c9f..9dcba60 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -612,7 +612,7 @@ QAction* QDeclarativeWebView::stopAction() const #endif // QT_NO_ACTION /*! - \qmlproperty real WebView::title + \qmlproperty string WebView::title This property holds the title of the web page currently viewed By default, this property contains an empty string. -- cgit v0.12 From 8079d2951419a983df7b83cfa31f00665c3e76a3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 9 Jul 2010 11:52:06 +0200 Subject: Fix a couple of memory leaks due to not releasing CFTypes on Mac Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfsfileengine_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 33e00f6..76a3512 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1017,7 +1017,7 @@ QString QFSFileEngine::fileName(FileName file) const #if !defined(QWS) && defined(Q_OS_MAC) QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath), kCFURLPOSIXPathStyle, true); - if (CFDictionaryRef dict = CFBundleCopyInfoDictionaryForURL(url)) { + if (QCFType dict = CFBundleCopyInfoDictionaryForURL(url)) { if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { if (CFGetTypeID(name) == CFStringGetTypeID()) return QCFString::toQString((CFStringRef)name); @@ -1135,7 +1135,7 @@ QString QFSFileEngine::fileName(FileName file) const if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { AliasHandle alias; if (FSNewAlias(0, &fref, &alias) == noErr && alias) { - CFStringRef cfstr; + QCFString cfstr; if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) return QCFString::toQString(cfstr); } -- cgit v0.12 From 3e326e54856b1fce33ab2c005de2a46af6a4ea0f Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 9 Jul 2010 13:59:56 +0200 Subject: Doc: Removed accidentally committed file. Reviewed-by: Trust Me --- examples/tutorials/modelview/._.DS_Store | Bin 4096 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 examples/tutorials/modelview/._.DS_Store diff --git a/examples/tutorials/modelview/._.DS_Store b/examples/tutorials/modelview/._.DS_Store deleted file mode 100755 index 338bd7b..0000000 Binary files a/examples/tutorials/modelview/._.DS_Store and /dev/null differ -- cgit v0.12 From 943d63e45ad09f75daa7d2f3dcc17bb28fda1766 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 9 Jul 2010 17:43:19 +0200 Subject: Fix a crash when recursing into QSharedPointer from QSharedPointer::clear() We used to delete the tracked object before the new tracking was properly set up in QSharedPointer. That means if the tracked object's destructor or deletion function recursed into the QSharedPointer, it would find itself in an inconsistent state. So instead finish the setup and only then call out to user code. That ensures the internal state is always valid. Task-number: QTBUG-11730 Reviewed-by: ossi --- src/corelib/tools/qsharedpointer_impl.h | 31 +++++++------ tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 56 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 964b279..d581751 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -323,12 +323,17 @@ namespace QtSharedPointer { typedef ExternalRefCountData Data; inline void ref() const { d->weakref.ref(); d->strongref.ref(); } - inline bool deref() + inline void deref() + { deref(d, this->value); } + static inline void deref(Data *d, T *value) { + if (!d) return; if (!d->strongref.deref()) { - internalDestroy(); + if (!d->destroy()) + delete value; } - return d->weakref.deref(); + if (!d->weakref.deref()) + delete d; } inline void internalConstruct(T *ptr) @@ -377,7 +382,7 @@ namespace QtSharedPointer { template inline ExternalRefCount(const ExternalRefCount &other) : Basic(other.value), d(other.d) { if (d) ref(); } - inline ~ExternalRefCount() { if (d && !deref()) delete d; } + inline ~ExternalRefCount() { deref(); } template inline void internalCopy(const ExternalRefCount &other) @@ -385,12 +390,6 @@ namespace QtSharedPointer { internalSet(other.d, other.data()); } - inline void internalDestroy() - { - if (!d->destroy()) - delete this->value; - } - inline void internalSwap(ExternalRefCount &other) { qSwap(d, other.d); @@ -423,10 +422,14 @@ namespace QtSharedPointer { else o = 0; } - if (d && !deref()) - delete d; - d = o; - this->value = d && d->strongref ? actual : 0; + + qSwap(d, o); + qSwap(this->value, actual); + if (!d || d->strongref == 0) + this->value = 0; + + // dereference saved data + deref(o, actual); } Data *d; diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index cb32c9a..4bbc9d8 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -92,6 +92,8 @@ private slots: void creating(); void creatingQObject(); void mixTrackingPointerCode(); + void reentrancyWhileDestructing(); + void threadStressTest_data(); void threadStressTest(); void validConstructs(); @@ -1770,6 +1772,60 @@ void tst_QSharedPointer::invalidConstructs() } } +namespace QTBUG11730 { + struct IB + { + virtual ~IB() {} + }; + + struct IA + { + virtual QSharedPointer getB() = 0; + }; + + struct B: public IB + { + IA *m_a; + B(IA *a_a) :m_a(a_a) + { } + ~B() + { + QSharedPointer b = m_a->getB(); + } + }; + + struct A: public IA + { + QSharedPointer b; + + virtual QSharedPointer getB() + { + return b; + } + + A() + { + b = QSharedPointer(new B(this)); + } + + ~A() + { + b.clear(); + } + }; +} + +void tst_QSharedPointer::reentrancyWhileDestructing() +{ + // this bug is about recursing back into QSharedPointer::clear() + // from inside it + // that is, the destructor of the object being deleted recurses + // into the same QSharedPointer object. + // First reported as QTBUG-11730 + QTBUG11730::A obj; +} + + QTEST_MAIN(tst_QSharedPointer) #include "tst_qsharedpointer.moc" -- cgit v0.12 From 29dcc069ba9a2c38b4461d5fd19d5fa9a1531595 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 12 Jul 2010 10:44:12 +0200 Subject: syncqt: fix wrong paths in include/ActiveQt/headers.pri Assigning a semicolon separated list of directories to a Qt module does not work correctly. The values of %modules must be split into single values before operating on them. This doesn't happen in all places. ActiveQt is the only module where this feature is used. Also, it is not needed anymore for this particular module. Thus, I'll just remove the semicolon separated list from ActiveQt and replace it with the module directory. Task-number: QTBUG-4586 Reviewed-by: ossi --- bin/syncqt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/syncqt b/bin/syncqt index db6dce6..4f8e343 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -42,7 +42,7 @@ my %modules = ( # path to module name map "QtScript" => "$basedir/src/script", "QtScriptTools" => "$basedir/src/scripttools", "Qt3Support" => "$basedir/src/qt3support", - "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared", + "ActiveQt" => "$basedir/src/activeqt", "QtTest" => "$basedir/src/testlib", "QtAssistant" => "$basedir/tools/assistant/compat/lib", "QtHelp" => "$basedir/tools/assistant/lib", -- cgit v0.12 From 4ba6646150300feb79af9510c7c5d238d653a98e Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 12 Jul 2010 11:10:43 +0200 Subject: syncqt: don't try to split %module's values Using semiconlon separated directory lists in module values is broken and unused. Removing this feature. Task-number: QTBUG-4586 Reviewed-by: ossi --- bin/syncqt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/syncqt b/bin/syncqt index 4f8e343..d665e87 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -960,7 +960,7 @@ if($check_includes) { #iteration info my $lib = $_; my $dir = "$modules{$lib}"; - foreach (split(/;/, $dir)) { + { my $current_dir = "$_"; #calc subdirs my @subdirs = ($current_dir); -- cgit v0.12 From a0fffeed6fceb8244328b649a3f6feb520493bc2 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 12 Jul 2010 14:18:29 +0200 Subject: Fix regression in tst_qrand::testqrand() qrand() has seeded with a default value of 1 for quite a long time, and is checked by the test mentioned above. The previous commit to change the default seed value must be reverted to keep compatibility. Change qrand() and qsrand() back to the way they were in 4.5. This fixes the qrand() regression. Change QUuid::createUuid() to seed exactly once per thread, which is a change from 4.5, where QUuid would see only once per application. This solves the original bug, QTBUG-3543, where multiple threads would generate the same UUID sequences. This also fixes the regression reported in QTBUG-11213, where seeding did not happen in certain cases. Reviewed-by: Prasanth Ullattil --- src/corelib/global/qglobal.cpp | 9 +-------- src/corelib/plugin/quuid.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b24ba38..12745e9 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2609,14 +2609,7 @@ int qrand() SeedStorageType *pseed = seedStorage->localData(); if (!pseed) { seedStorage->setLocalData(pseed = new SeedStorageType); - - // Seed the PRNG, but only if it has not already been seeded. The - // default seed is a combination of current time, a stack address - // and a serial counter (since thread stack addresses are re-used). - static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); - *pseed = QDateTime::currentDateTime().toTime_t() - + quintptr(&pseed) - + serial.fetchAndAddRelaxed(1); + *pseed = 1; } return rand_r(pseed); } else { diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index f48cc2e..d0c59a4 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -577,6 +577,7 @@ QUuid QUuid::createUuid() QT_BEGIN_INCLUDE_NAMESPACE #include "qdatetime.h" +#include "qthreadstorage.h" #include // for RAND_MAX QT_END_INCLUDE_NAMESPACE @@ -591,6 +592,19 @@ QUuid QUuid::createUuid() randbits = r; } + static QThreadStorage uuidseed; + if (!uuidseed.hasLocalData()) { + // Seed the PRNG once per thread with a combination of current time, a + // stack address and a serial counter (since thread stack addresses are + // re-used). + int *pseed = new int; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); + qsrand(*pseed = QDateTime::currentDateTime().toTime_t() + + quintptr(&pseed) + + serial.fetchAndAddRelaxed(1)); + uuidseed.setLocalData(pseed); + } + QUuid result; uint *data = &(result.data1); int chunks = 16 / sizeof(uint); -- cgit v0.12 From a736d333aab9e2e97fdbb738b3f3f4646afe192e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 13 Jul 2010 12:23:05 +0200 Subject: Compile when bootstrapping qmake QThreadStorage is not available when bootstrapping qmake, so fall back to a simple static bool instead. Reviewed-by: TrustMe --- src/corelib/plugin/quuid.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index d0c59a4..e1d4fc0 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -592,11 +592,13 @@ QUuid QUuid::createUuid() randbits = r; } + // Seed the PRNG once per thread with a combination of current time, a + // stack address and a serial counter (since thread stack addresses are + // re-used). +#ifndef QT_BOOTSTRAPPED static QThreadStorage uuidseed; - if (!uuidseed.hasLocalData()) { - // Seed the PRNG once per thread with a combination of current time, a - // stack address and a serial counter (since thread stack addresses are - // re-used). + if (!uuidseed.hasLocalData()) + { int *pseed = new int; static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); qsrand(*pseed = QDateTime::currentDateTime().toTime_t() @@ -604,6 +606,12 @@ QUuid QUuid::createUuid() + serial.fetchAndAddRelaxed(1)); uuidseed.setLocalData(pseed); } +#else + static bool seeded = false; + if (!seeded) + qsrand(QDateTime::currentDateTime().toTime_t() + + quintptr(&seeded)); +#endif QUuid result; uint *data = &(result.data1); -- cgit v0.12 From f7fe575bc5f628533aeeca3eb564af89a1a1426b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 12 Jul 2010 18:32:06 +0200 Subject: QSslSocket: Improve error handling Reviewed-by: Markus Goetz Task-number: QT-3567 --- src/network/ssl/qsslsocket_openssl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index ce2aee1..6f77600 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -680,8 +680,20 @@ void QSslSocketBackendPrivate::transmit() #endif plainSocket->disconnectFromHost(); break; + case SSL_ERROR_SYSCALL: // some IO error + case SSL_ERROR_SSL: // error in the SSL library + // we do not know exactly what the error is, nor whether we can recover from it, + // so just return to prevent an endless loop in the outer "while" statement + q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(SSL_ERRORSTR())); + q->setSocketError(QAbstractSocket::UnknownSocketError); + emit q->error(QAbstractSocket::UnknownSocketError); + return; default: - // ### Handle errors better. + // SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT: can only happen with a + // BIO_s_connect() or BIO_s_accept(), which we do not call. + // SSL_ERROR_WANT_X509_LOOKUP: can only happen with a + // SSL_CTX_set_client_cert_cb(), which we do not call. + // So this default case should never be triggered. q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(SSL_ERRORSTR())); q->setSocketError(QAbstractSocket::UnknownSocketError); emit q->error(QAbstractSocket::UnknownSocketError); -- cgit v0.12 From b8622b62289474c45d60eba110b201d400492ea3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 13 Jul 2010 15:33:01 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 038b62085831eef4dee423361c65ecd55b7b9b1d ) Changes in WebKit/qt since the last update: * backport: https://bugs.webkit.org/show_bug.cgi?id=30978 -- [Qt] ASSERT failure while running DRT --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 15 +++++++++++++++ src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp | 8 ++++++++ src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h | 4 +++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 354e21d..b6178b9 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - fc13f9b396e1448cd71266f56ba7a93de5cf6ed9 + 038b62085831eef4dee423361c65ecd55b7b9b1d diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 8a75d6b..3a9fce0 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2009-11-14 Yael Aharon + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] ASSERT failure while running DRT + https://bugs.webkit.org/show_bug.cgi?id=30978 + + Add needed Structure typeInfo flags to QtRuntimeObjectImpl and QtRuntimeMethod. + These flags are needed after r49649, where HasDefaultmark was changed to OverrideMarkChildren. + + * bridge/qt/qt_instance.cpp: + (JSC::Bindings::QtRuntimeObjectImp::createStructure): + * bridge/qt/qt_runtime.h: + (JSC::Bindings::QtRuntimeMethod::createStructure): + 2010-06-16 Dawit Alemayehu Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp index ec362ec..c6185e9 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp @@ -58,6 +58,14 @@ public: instance->markAggregate(markStack); } + static PassRefPtr createStructure(JSValue prototype) + { + return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags)); + } + +protected: + static const unsigned StructureFlags = RuntimeObjectImp::StructureFlags | OverridesMarkChildren; + private: virtual const ClassInfo* classInfo() const { return &s_info; } }; diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h index f2ce954..dc55f61 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h @@ -151,10 +151,12 @@ public: static PassRefPtr createStructure(JSValue prototype) { - return Structure::create(prototype, TypeInfo(ObjectType, OverridesGetOwnPropertySlot | OverridesMarkChildren)); + return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags)); } protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags | OverridesMarkChildren; + QtRuntimeMethodData *d_func() const {return d_ptr;} QtRuntimeMethod(QtRuntimeMethodData *dd, ExecState *exec, const Identifier &n, PassRefPtr inst); QtRuntimeMethodData *d_ptr; -- cgit v0.12 From 5608f5c35dd3f4470f51436ead9a7048d561affa Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 13 Jul 2010 17:04:31 +0200 Subject: Doc: Reviewed Michael's model/view tutorial and overview document. Reviewed-by: Trust Me --- doc/src/tutorials/modelview.qdoc | 791 +++++++++++++-------- examples/tutorials/modelview/1_readonly/main.cpp | 1 + .../tutorials/modelview/1_readonly/modelview.cpp | 5 +- .../tutorials/modelview/1_readonly/modelview.h | 6 +- .../tutorials/modelview/1_readonly/mymodel.cpp | 14 +- examples/tutorials/modelview/1_readonly/mymodel.h | 5 +- .../tutorials/modelview/2_formatting/modelview.cpp | 2 +- .../tutorials/modelview/2_formatting/mymodel.cpp | 22 +- .../modelview/3_changingmodel/modelview.cpp | 2 +- .../modelview/3_changingmodel/mymodel.cpp | 16 +- .../tutorials/modelview/4_headers/modelview.cpp | 2 +- examples/tutorials/modelview/4_headers/mymodel.cpp | 10 +- examples/tutorials/modelview/5_edit/modelview.cpp | 6 +- examples/tutorials/modelview/5_edit/mymodel.cpp | 21 +- examples/tutorials/modelview/5_edit/mymodel.h | 9 +- .../tutorials/modelview/6_treeview/modelview.cpp | 8 +- .../tutorials/modelview/6_treeview/modelview.h | 2 +- .../tutorials/modelview/7_selections/modelview.cpp | 8 +- examples/tutorials/modelview/qmake.pro | 10 - 19 files changed, 564 insertions(+), 376 deletions(-) delete mode 100755 examples/tutorials/modelview/qmake.pro diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index bc03f44..98096a0 100755 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -1,10 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in a +** written agreement between you and Nokia. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page modelview.html \startpage {index.html}{Qt Reference Documentation} - \contentspage {modelview-index.html}{ModelView Contents} \nextpage {modelview-part1.html}{Introduction} - \title ModelView Contents Page + + \title Model/View Contents \brief An introduction to ModelView programming This tutorial gives an introduction to ModelView programming using the Qt @@ -14,17 +41,17 @@ \omit It doesn't cover everything; the emphasis is on teaching the programming - philosophy of ModelView programming, and Qt's features are introduced as needed. - Some commonly used features are never used in this tutorial. + philosophy of Model/View programming, and Qt's features are introduced as + needed. Some commonly used features are never used in this tutorial. \endomit In the process, we will learn about some basic technologies provided by Qt, such as: \list - \o The difference between standard and modelview widgets + \o The difference between standard and model/view widgets \o Adapters betweeen forms and models - \o Developing a simple Model/View application + \o Developing a simple model/view application \o Intermediate topics such as: \list \o Tree views @@ -43,9 +70,9 @@ \list 1 \o \l{modelview-part1.html}{Introduction} - \o \l{modelview-part2.html}{Developing a simple ModelView application} + \o \l{modelview-part2.html}{Developing a Simple Model/View Application} \o \l{modelview-part3.html}{Intermediate Topics} - \o \l{modelview-part4.html}{Good Sources for Additional Information} + \o \l{modelview-part4.html}{Good Sources of Additional Information} \endlist @@ -53,13 +80,18 @@ /*! \page modelview-part1.html + \contentspage {modelview-index.html}{Model/View Contents} + \previouspage {modelview-index.html}{Model/View Contents} + \nextpage {modelview-part2.html}{Developing a Simple Model/View Application} \title An Introduction to Model/View Programming - \raw HTML -
- \endraw -\section1 1 Introduction -Model/View is a technology used to separate data from views in widgets that handle data sets. Standard Widgets are not designed for separating data from views and this is why Qt 4 has two different types of widgets. Both types of widgets look the same, but they interact with data differently. + \section1 1. Introduction + + Model/View is a technology used to separate data from views in widgets that + handle data sets. Standard widgets are not designed for separating data + from views and this is why Qt 4 has two different types of widgets. Both + types of widgets look the same, but they interact with data differently. + \table \row \o Standard widgets use data that is part of the widget. @@ -68,129 +100,193 @@ Model/View is a technology used to separate data from views in widgets that hand \o View classes operate on external data (the model) \o \image modelview.png \endtable -\section2 1.1 Standard widgets -Let's have a closer look at a standard table widget. A table widget is a 2D array of the data elements that the user can change. The table widget can be integrated into a program flow by reading and writing the data elements that the table widget provides. This method is very intuitive and useful in many applications. -Displaying and editing a database table with a standard table widget can be problematic. Two copies of the data have to be coordinated: one outside the widget; one inside the widget. The developer needs to know where up-to-date data is so the both copies contain the most recent data. The tight coupling of presentation and data makes it harder to write unit tests. + \section2 1.1 Standard Widgets + + Let's have a closer look at a standard table widget. A table widget is a 2D + array of the data elements that the user can change. The table widget can + be integrated into a program flow by reading and writing the data elements + that the table widget provides. This method is very intuitive and useful in + many applications. + + Displaying and editing a database table with a standard table widget can be + problematic. Two copies of the data have to be coordinated: one outside the + widget; one inside the widget. The developer needs to know where up-to-date + data is so the both copies contain the most recent data. The tight coupling + of presentation and data makes it harder to write unit tests. + + \section2 1.2 Model/View to the Rescue + + Model/view stepped up to provide a solution that uses a more versatile + architecture. Model/view eliminates the data consistency problems that may + occur with standard widgets. Model/view also makes it easier to use more + than one view of the same data because one model can be passed on to many + views. The most important difference is that model/view widgets do not + store data behind the table cells. In fact, they operate directly from your + data. Since view classes do not know your data's structure, you need to + provide a wrapper to make your data conform to the QAbstractItemModel + interface. A view uses this interface to read from and write to your data + and any class that implements QAbstractItemModel is a model. Once the view + receives a pointer to a model, it will read and display its content and be + its editor. + + \section2 1.3 Overview of the Model/View Widgets -\section2 1.2 Model/View to the rescue -Model/View stepped up to provide a solution that uses a more versatile architecture. Model/View eliminates the data consistency problems that may occur with standard widgets. Model/View also makes it easier to use more than one view of the same data because one model can be passed on to many views. The most important difference is that model/view widgets do not store data behind the table cells. In fact, they operate directly from your data. Since view classes do not know your data's structure, you need to provide a wrapper to make your data conform to the \l QAbstractItemModel interface. A view uses this interface to read from and write to your data and any class that implements \l QAbstractItemModel is a model. Once the view receives a pointer to a model, it will read and display its content and be its editor. + Here is an overview of the model/view widgets and their corresponding + standard widgets. -\section2 1.3 Overview of the model/view widgets -Here is an overview of the model/view widgets and their corresponding standard widgets. \table \header \o Widget - \o Standard Widget -(a convenience class with data in the widget) + \o Standard Widget (a convenience class with data in + the widget) \o Model/View View Class (for use with external data) \row - \o \image listview.png + \o \inlineimage listview.png \o \l QListWidget \o \l QListView \row - \o \image tableview.png + \o \inlineimage tableview.png \o \l QTableWidget \o \l QTableView \row - \o \image treeview.png + \o \inlineimage treeview.png \o \l QTreeWidget \o \l QTreeView \row - \o \image columnview.png - \o + \o \inlineimage columnview.png + \o \o \l QColumnView shows a tree as a hierarchy of lists \row - \o \image combobox.png - \o {2, 1} \l QComboBox can work as both a view class and also as a traditional widget + \o \inlineimage combobox.png + \o {2, 1} \l QComboBox can work as both a view class and also + as a traditional widget \endtable -\section2 1.4 Having adapters between forms and models can come in handy. -We often prefer editing data stored in tables (e.g. in database tables) in forms rather than in tables. There is no direct model/view counterpart for separating data and views for widgets that operate on one value instead of a dataset, so we need an adapter in order to connect the form to the source of data. + \section2 1.4 Using Adapters between Forms and Models -\l QDataWidgetMapper is a great solution because it maps form widgets to a table row and it makes it very easy to build forms for database tables. -\image widgetmapper.png + Having adapters between forms and models can come in handy. + We often prefer editing data stored in tables (e.g. in database tables) in + forms rather than in tables. There is no direct model/view counterpart for + separating data and views for widgets that operate on one value instead of + a dataset, so we need an adapter in order to connect the form to the source + of data. -Another example of an adapter is \l QCompleter. Qt has QCompleter for providing auto completions in Qt widgets such as \l QComboBox and, as shown below, \l QLineEdit. \l QCompleter uses a model as its data source, so \l QCompleter, in itself, is a very handy adapter. -\image qcompleter.png + \l QDataWidgetMapper is a great solution because it maps form widgets to a + table row and it makes it very easy to build forms for database tables. + \image widgetmapper.png + Another example of an adapter is QCompleter. Qt has QCompleter for + providing auto-completions in Qt widgets such as QComboBox and, as shown + below, QLineEdit. QCompleter uses a model as its data source, so QCompleter, + in itself, is a very handy adapter. + + \image qcompleter.png */ /*! - - \page modelview-part2-main-cpp.html \title main.cpp \quotefile tutorials/modelview/1_readonly/main.cpp - - */ /*! \page modelview-part2.html - \title ModelView Chapter 2 - A Simple Model/View Application - - \raw HTML -
- \endraw - -\section1 2 A Simple Model/View Application -If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own. + \contentspage {modelview-index.html}{Model/View Contents} + \previouspage {modelview-part1.html}{Introduction} + \nextpage {modelview-part3.html}{Intermediate Topics} + \title Model/View Chapter 2 - A Simple Model/View Application + + \section1 2. A Simple Model/View Application + + If you want to develop a model/view application, where should you start? We + recommend starting with a simple example and extending it step-by-step. + This makes understanding the architecture a lot easier. Trying to + understand the model/view architecture in detail before invoking the IDE + has proven to be less convenient for many developers. It is substantially + easier to start with a simple model/view application that has demo data. + Give it a try! Simply replace the data in the examples below with your own. + + Below are 7 very simple and independent applications that show different + sides of model/view programming. The source code can be found inside the + \c{examples/tutorials/modelview} directory. -Below are 7 very simple and independent applications that show different sides of model/view programming. The source code can be downloaded from @todo___________paste link here_________________________ + \section2 2.1 A Read Only Table -\section2 2.1 A read only table -We start with an application that uses a \l QTableView to show data. We will add editing capabilities later. + We start with an application that uses a QTableView to show data. We will + add editing capabilities later. --------------------------------------------------------------main.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial -We have the usual \l {modelview-part2-main-cpp.html}{main()} function; --------------------------------------------------------------modelview.h--------------------- + We have the usual \l {modelview-part2-main-cpp.html}{main()} function: + \snippet examples/tutorials/modelview/1_readonly/modelview.h Quoting ModelView Tutorial -The application is a \l QMainWindow that holds a \l QTableView. + The application is a \l QMainWindow that holds a \l QTableView. --------------------------------------------------------------modelview.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Quoting ModelView Tutorial -Here is the interesting part: We use \l{QTableView::setModel()}{tableView->setModel(new MyModel(this) );} to instantiate the Model and pass its pointer to \l {QTableView}{tableView()}. \l {QTableView}{tableView} will invoke the methods of the pointer it has received to find out two things: + Here is the interesting part: We use + \l{QTableView::setModel()}{tableView->setModel(new MyModel(this));} to + instantiate the Model and pass its pointer to \l {QTableView}{tableView()}. + \l{QTableView}{tableView} will invoke the methods of the pointer it has + received to find out two things: + \list \o How many rows and columns should be displayed \o What content should be printed into each cell. \endlist -The model needs some code to respond to this. + The model needs some code to respond to this. -We have a table data set, so let's start with QAbstractTableModel since it is easier to use. --------------------------------------------------------------mymodel.h--------------------- - \snippet examples/tutorials/modelview/1_readonly/mymodel.h Quoting ModelView Tutorial + We have a table data set, so let's start with QAbstractTableModel since it + is easier to use. -QAbstractTableModel requires the implementation of three abstract methods. + \snippet examples/tutorials/modelview/1_readonly/mymodel.h Quoting ModelView Tutorial + QAbstractTableModel requires the implementation of three abstract methods. --------------------------------------------------------------mymodel.cpp--------------------- \snippet examples/tutorials/modelview/1_readonly/mymodel.cpp Quoting ModelView Tutorial -The number of rows and columns is set by \l{QAbstractItemModel::rowCount()}{MyModel::rowCount()} and \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}. -When the view has to know what the cell 's text is, it calls the method. Row and column information is specified with parameter \c index and the role is set to \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are covered in the next section. In our example, the data that should be displayed is generated. In a real application, \c MyModel would have a member called \c MyData, which serves as the target for all reading and writing operations. - -This small example demonstrates the passive nature of a model. The model does not know when it will be used or which data is needed. It simply provides data each time the view requests it. - -What happens when the model 's data needs to be changed? How does the view know when data changes and needs to be read again? The model has to emit a signal that indicates what range of cells has changed. This will be demonstrated in section 2.3. + The number of rows and columns is set by + \l{QAbstractItemModel::rowCount()}{MyModel::rowCount()} and + \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}. + When the view has to know what the cell's text is, it calls the method. + Row and column information is specified with parameter \c index and the + role is set to \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are + covered in the next section. In our example, the data that should be + displayed is generated. In a real application, \c MyModel would have a + member called \c MyData, which serves as the target for all reading and + writing operations. + + This small example demonstrates the passive nature of a model. The model + does not know when it will be used or which data is needed. It simply + provides data each time the view requests it. + + What happens when the model 's data needs to be changed? How does the view + know when data changes and needs to be read again? The model has to emit a + signal that indicates what range of cells has changed. This will be + demonstrated in section 2.3. + + \section2 2.2 Extending the Read Only Example with Roles + + In addition to controlling what text the view displays, the model also + controls the text's appearance. When we slightly change the model, we get + the following result: \image readonlytable_role.png + + In fact, nothing except for the \l{QAbstractItemModel::}{data()} + method needs to be changed to set fonts, background colour, alignment and a + checkbox. + Here is the \l{QAbstractItemModel::data()}{data()} method that produces the + result shown above: -\section2 2.2 Extending the read only example with roles -In addition to controlling what text the view displays, the model also controls the text's appearance. When we slightly change the model, we get the following result: \image readonlytable_role.png - - -In fact, nothing except for the \l{QAbstractItemModel::data()}{data()} method needs to be changed to set fonts, background colour, alignment and a checkbox. Here is the \l{QAbstractItemModel::data()}{data()} method that produces the result shown above: - --------------------------------------------------------------mymodel.cpp--------------------- \snippet examples/tutorials/modelview/2_formatting/mymodel.cpp Quoting ModelView Tutorial -Each formatting property will be requested from the model with a separate call to the \l{QAbstractItemModel::data()}{data()} method. The \c role parameter is used to let the model know which property is being requested: + Each formatting property will be requested from the model with a separate + call to the \l{QAbstractItemModel::data()}{data()} method. The \c role + parameter is used to let the model know which property is being requested: \table \header @@ -214,114 +310,194 @@ Each formatting property will be requested from the model with a separate call t \o text alignment \o enum Qt::AlignmentFlag \row - \o {1, 3} Qt::CheckStateRole - \o {1, 3} suppresses checkboxes with \l{QVariant}{QVariant()}, sets checkboxes with Qt::Checked or Qt::Unchecked - \o {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole} - + \o {1, 3} Qt::CheckStateRole + \o {1, 3} suppresses checkboxes with \l{QVariant}{QVariant()}, + sets checkboxes with Qt::Checked or Qt::Unchecked + \o {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole} \endtable -Refer to Qt documentation to learn more about enum Qt::ItemDataRole's capabilities. + Refer to the Qt namespace documentation to learn more about the + Qt::ItemDataRole enum's capabilities. + Now we need to determine how using a seperated model impacts the + application's performance, so let's trace how often the view calls the + \l{QAbstractItemModel::}{data()} method. In order to track how often + the view calls the model, we have put a debug statement in the + \l{QAbstractItemModel::}{data()} method, which logs onto stdio. In + our small example, \l{QAbstractItemModel::}{data()} will be called 42 + times. + Each time you hover the cursor over the field, + \l{QAbstractItemModel::}{data()} will be called again \mdash 7 times for + each cell. That's why it is important to make sure that your data is + available when \l{QAbstractItemModel::}{data()} is invoked and expensive + lookup operations are cached. -Now we need to determine how using a seperated model impacts the application's performance, so let's trace how often the view calls the \l{QAbstractItemModel::data()}{data()} method. In order to track how often the view calls the model, we have put a debug statement in the \l{QAbstractItemModel::data()}{data()} method, which logs onto stdio. In our small example, \l{QAbstractItemModel::data()}{data()} will be called 42 times. Each time you hover the cursor over the field, \l{QAbstractItemModel::data()}{data()} will be called again - 7 times for each cell. That's why it is important to make sure that your data is available when \l{QAbstractItemModel::data()}{data()} is invoked and expensive lookup operations are cached. + \section2 2.3 A Clock inside a Table Cell -\section2 2.3 A clock inside a table cell -\image clock.png + \image clock.png -We still have a read only table, but this time the content changes every second because we are showing the current time. + We still have a read only table, but this time the content changes every + second because we are showing the current time. \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_QVariant -Something is missing to make the clock tick. We need to tell the view every second that the time has changed and that it needs to be read again. We do this with a timer. In the constructor, we set its interval to 1 second and it connect its timeout signal. + Something is missing to make the clock tick. We need to tell the view every + second that the time has changed and that it needs to be read again. We do + this with a timer. In the constructor, we set its interval to 1 second and + connect its timeout signal. \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_a -Here is the corresponding slot: + Here is the corresponding slot: \snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_b -We ask the view to read the data in the top left cell again by emitting the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Note that we did not explicitly connect the \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal to the view. This happened automatically when we called \l{QTableView::setModel()}{setModel()}. + We ask the view to read the data in the top left cell again by emitting the + \l{QAbstractItemModel::}{dataChanged()} signal. Note that we did not + explicitly connect the \l{QAbstractItemModel::}{dataChanged()} signal to + the view. This happened automatically when we called + \l{QTableView::}{setModel()}. -\section2 2.4 Setting up Headers for Columns and Rows -Headers can be hidden via a view method. -\c tableView->verticalHeader()->hide(); -\image header.png + \section2 2.4 Setting up Headers for Columns and Rows + Headers can be hidden via a view method: \c{tableView->verticalHeader()->hide();} + \image header.png -The header content, however, is set via the model, so we reimplement the \l{QAbstractItemModel::headerData()}{headerData()} method: + The header content, however, is set via the model, so we reimplement the + \l{QAbstractItemModel::headerData()}{headerData()} method: \snippet examples/tutorials/modelview/4_headers/mymodel.cpp quoting mymodel_c -\section2 2.5 The minimal Editing example -In this example, we are going to build an application that automatically populates a window title with content by repeating values entered into table cells. + \section2 2.5 The Minimal Editing Example + + In this example, we are going to build an application that automatically + populates a window title with content by repeating values entered into + table cells. + + The model decides whether editing capabilities are available . We only have + to modify the model in order for the available editing capabilities to be + enabled. This is done by reimplementing the following virtual methods: + \l{QAbstractItemModel::}{setData()} and \l{QAbstractItemModel::}{flags()}. -The model decides whether editing capabilities are available . We only have to modify the model in order for the available editing capabilities to be enabled. This is done by reimplementing the following virtual methods: \l{QAbstractItemModel::setData()}{setData()} and \l{QAbstractItemModel::flags()}{flags()}. --------------------------------------------------------------mymodel.h--------------------- \snippet examples/tutorials/modelview/5_edit/mymodel.h Quoting ModelView Tutorial -We use \c QStringList m_gridData to store our data. This makes \c m_gridData the core of MyModel. The rest of \c MyModel acts like a wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We have also introduced the \l{QAbstractItemModel::editCompleted()}{editCompleted()} signal, which makes it possible to transfer the modified text to the window title. + We use \c QStringList m_gridData to store our data. This makes + \c m_gridData the core of MyModel. The rest of \c MyModel acts like a + wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We + have also introduced the \c editCompleted() signal, + which makes it possible to transfer the modified text to the window title. \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_d -In the constructor, we fill \c QStringList gridData with 6 items. (one item for every field in the table) + In the constructor, we fill \c QStringList gridData with 6 items (one item + for every field in the table): + \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_e -\l{QAbstractItemModel::setData()}{setData()} will be called each time the user edits a cell. The \c index parameter tells us which field has been edited and \c value provides the result of the editing process. The role will always be set to \c Qt::EditRole because our cells only contain text. If a checkbox were present and user permissions are set to allow the checkbox to be selected, calls would also be made with the role set to \c Qt::CheckStateRole. - \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f + \l{QAbstractItemModel::setData()}{setData()} will be called each time the + user edits a cell. The \c index parameter tells us which field has been + edited and \c value provides the result of the editing process. The role + will always be set to \c Qt::EditRole because our cells only contain text. + If a checkbox were present and user permissions are set to allow the + checkbox to be selected, calls would also be made with the role set to + \c Qt::CheckStateRole. -Various properties of a cell can be adjusted with \l{QAbstractItemModel::flags()}{flags()}. Returning \c Qt::ItemIsEditable | \c Qt::ItemIsEnabled is enough to show an editor that a cell has been selected. If editing one cell modifies more data than the data in that particular cell, the model must emit a \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal in order for the data that has been changed to be read. + \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f + Various properties of a cell can be adjusted with + \l{QAbstractItemModel::flags()}{flags()}. Returning + \c Qt::ItemIsEditable | \c Qt::ItemIsEnabled is enough to show an editor + that a cell has been selected. If editing one cell modifies more data than + the data in that particular cell, the model must emit a + \l{QAbstractItemModel::}{dataChanged()} signal in order for the data that + has been changed to be read. */ /*! \page modelview-part3.html - \title ModelView Chapter 3 - Intermediate Topics - \raw HTML -
- \endraw -\section1 3 Intermediate Topics - \raw HTML -
- \endraw -\section2 3.1 TreeView + \contentspage {modelview-index.html}{Model/View Contents} + \previouspage {modelview-part2.html}{Developing a Simple Model/View Application} + \nextpage {modelview-part4.html}{Good Sources of Additional Information} + \title Model/View Chapter 3 - Intermediate Topics + + \section1 3. Intermediate Topics + + \section2 3.1 TreeView -You can convert the example above into an application with a tree view. Simply replace QTableView with QTreeView, which results in a read/write tree. No changes have to be made to the model. The tree won't have any hierarchies because there aren't any hierarchies in the model itself. -\image dummy_tree.png + You can convert the example above into an application with a tree view. + Simply replace QTableView with QTreeView, which results in a read/write + tree. No changes have to be made to the model. The tree won't have any + hierarchies because there aren't any hierarchies in the model itself. + \image dummy_tree.png -QListView, QTableView and QTreeView all use a model abstraction, which is a merged list, table and tree. This makes it possible to use several different types of view classes from the same model. -\image list_table_tree.png + QListView, QTableView and QTreeView all use a model abstraction, which is a + merged list, table and tree. This makes it possible to use several different + types of view classes from the same model. + \image list_table_tree.png -This is how our example model looks so far: -\image example_model.png + This is how our example model looks so far: + \image example_model.png -We want to present a real tree. We have wrapped our data in the examples above in order to make a model. This time we use QStandardItemModel, which is a container for hierarchical data that also implements QAbstractItemModel. To show a tree, QStandardItemModel must be populated with \l{QStandardItem}{QStandardItems}, which are able to hold all the standard properties of items like text, fonts, checkboxes or brushes. \image tree_2_with_algorithm.png --------------------------------------------------------------modelview.cpp--------------------- + We want to present a real tree. We have wrapped our data in the examples + above in order to make a model. This time we use QStandardItemModel, which + is a container for hierarchical data that also implements + QAbstractItemModel. To show a tree, QStandardItemModel must be populated + with \l{QStandardItem}{QStandardItems}, which are able to hold all the + standard properties of items like text, fonts, checkboxes or brushes. + \image tree_2_with_algorithm.png + \snippet examples/tutorials/modelview/6_treeview/modelview.cpp Quoting ModelView Tutorial -We simply instantiate a QStandardItemModel and add a couple of \l{QStandardItem}{QStandardItems} to the constructor. We can then make a hierarchical data structure because a QStandardItem can hold other \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within the view. + We simply instantiate a QStandardItemModel and add a couple of + \l{QStandardItem}{QStandardItems} to the constructor. We can then make a + hierarchical data structure because a QStandardItem can hold other + \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within + the view. -\section2 3.2 Working with selection + \section2 3.2 Working with Selections + We want to access a selected item's content in order to output it into the + window title together with the hierarchy level. + \image selection2.png -We want to access a selected item's content in order to output it into the window title together with the hierarchy level. -\image selection2.png + So let's create a couple of items: -So let's create a couple of items: \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_a -Views manage selections within a separate selection model, which can be retrieved with the \l{QAbstractItemView::selectionModel()}{selectionModel()} method. We retrieve the selection Model in order to connect a slot to its \l{QAbstractItemView::selectionChanged()}{selectionChanged()} signal. - \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b + Views manage selections within a separate selection model, which can be + retrieved with the \l{QAbstractItemView::}{selectionModel()} + method. We retrieve the selection Model in order to connect a slot to its + \l{QAbstractItemView::}{selectionChanged()} signal. -We get the model index that corresponds to the selection by calling -\l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()} and we get the the field's string by using the model index. Then we just calculate the item's \c hierarchyLevel. Top level items do not have parents and the \l{QAbstractItemModel::parent()}{parent()} method will return a default constructed \l{QModelIndex}{QModelIndex()}. This is why we use the \l{QAbstractItemModel::parent()}{parent()} method to iterate to the top level while counting the steps performed during iteration. + \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b -The selection model (as shown above) can be retrieved, but it can also be set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This is how it's possible to have 3 view classes with synchronised selections because only one instance of a selection model is used. The instance of a selection model is retrieved from the first view class with \l{QAbstractItemView::selectionModel()}{selectionModel()} and the result is assigned to the second and third view class with \l{QAbstractItemView::setSelectionModel()}{setSelectionModel()}; -\section2 3.3 Predefined Models -The typical way to use model/view is to wrap specific data to make it usable with view classes. Qt, however, also provides predefined models for common underlying data structures. If one of the available data structures is suitable for your application, a predefined model can be a good choice. + We get the model index that corresponds to the selection by calling + \l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()} + and we get the the field's string by using the model index. Then we just + calculate the item's \c hierarchyLevel. Top level items do not have + parents and the \l{QAbstractItemModel::}{parent()} method will return a + default constructed \l{QModelIndex}{QModelIndex()}. This is why we use the + \l{QAbstractItemModel::}{parent()} method to iterate to the top level while + counting the steps performed during iteration. + + The selection model (as shown above) can be retrieved, but it can also be + set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This + is how it's possible to have 3 view classes with synchronised selections + because only one instance of a selection model is used. The instance of a + selection model is retrieved from the first view class with + \l{QAbstractItemView::}{selectionModel()} and the result is assigned to the + second and third view class with \l{QAbstractItemView::}{setSelectionModel()}. + + \section2 3.3 Predefined Models + + The typical way to use model/view is to wrap specific data to make it + usable with view classes. Qt, however, also provides predefined models for + common underlying data structures. If one of the available data structures + is suitable for your application, a predefined model can be a good choice. \table \row @@ -331,11 +507,8 @@ The typical way to use model/view is to wrap specific data to make it usable wit \o QStandardItemModel \o Stores arbitrary hierarchical items \row - \o QFileSystemModel - \raw HTML -
- \endraw - QDirModel + \o QFileSystemModel\br + QDirModel \o Encapsulate the local file system \row \o QSqlQueryModel @@ -352,108 +525,144 @@ The typical way to use model/view is to wrap specific data to make it usable wit \endtable -\section2 3.4 Delegates -In all examples so far, data is presented as text or a checkbox in a cell and is edited as text or a checkbox. The component that provides these presentation and editing services is called a “delegate.” We are only just beginning to work with the delegate because the view uses a default delegate. But imagine that we want to have a different editor.(e.g. a slider or a drop down list) Or imagine that we want to present data as graphics. Let's take a look at an example called Stardelegate, ( \l{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html}{http://qt.nokia.com/doc/4.6/itemviews-stardelegate.html} ) in which stars are used to show a rating: \image stardelegate.png - -The view has a method that replaces the default delegate and installs a custom delegate. This method is called \l{QAbstractItemView::setItemDelegate()}{setItemDelegate()}. A new delegate can be written by creating a class that inherits from QStyledItemDelegate. In order to write a delegate that displays stars and has no input capabilities, we only need to overwrite 2 methods. - -\code - class StarDelegate : public QStyledItemDelegate - { - Q_OBJECT - public: - StarDelegate(QWidget *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, + \section2 3.4 Delegates + + In all examples so far, data is presented as text or a checkbox in a cell + and is edited as text or a checkbox. The component that provides these + presentation and editing services is called a \e delegate. We are only just + beginning to work with the delegate because the view uses a default + delegate. But imagine that we want to have a different editor.(e.g. a + slider or a drop down list) Or imagine that we want to present data as + graphics. Let's take a look at an example called + \l{Star Delegate Example}{Star Delegate}, in which stars are used to show + a rating: + \image stardelegate.png + + The view has a method that replaces the default delegate and installs a + custom delegate. This method is called + \l{QAbstractItemView::}{setItemDelegate()}. A new delegate can be written + by creating a class that inherits from QStyledItemDelegate. In order to + write a delegate that displays stars and has no input capabilities, we only + need to overwrite 2 methods. + + \code + class StarDelegate : public QStyledItemDelegate + { + Q_OBJECT + public: + StarDelegate(QWidget *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - }; - -\endcode - -\l{QStyledItemDelegate::paint()}{paint()} draws stars depending on the content of the underlying data. The data can be looked up with parameter \l{QModelIndex::data()}{index.data()}. \l{QAbstractItemDelegate::sizeHint()}{sizeHint} specifies the stars dimensions so the the cell will provide enough height and width to accommodate the stars. + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const; + }; + \endcode -Writing custom delegates is the right choice if you want to show your data with a custom graphical representation inside the grid of the view class. If you want to leave the grid, you can write a custom view class. + \l{QStyledItemDelegate::}{paint()} draws stars depending on the content + of the underlying data. The data can be looked up with parameter + \l{QModelIndex::data()}{index.data()}. + \l{QAbstractItemDelegate::}{sizeHint()} specifies each star's dimensions + so the the cell will provide enough height and width to accommodate the + stars. -\section2 3.5 Debugging with ModelTest -The passive nature of models provides new challenges for programmers. Inconsistencies in the model can cause the application to crash. Since the model is hit by numerous calls from the view, it is hard to find out which call has crashed the application and which operation has introduced the problem. + Writing custom delegates is the right choice if you want to show your data + with a custom graphical representation inside the grid of the view class. + If you want to leave the grid, you can write a custom view class. -Qt provides software called ModelTest, which checks models while your programming is running. Every time the model is changed, ModelTest scans the model and reports errors with an assert. This is especially important for tree models, since their hierarchical nature leaves many possibilities for subtle inconsistencies. \l http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest + \section2 3.5 Debugging with ModelTest -Unlike view classes, ModelTest uses out of range indexes to test the model. This means your application may crash with ModelTest even if it runs perfectly without it. So you also need to handle all of the indexes that are out of range when using ModelTest. + The passive nature of models provides new challenges for programmers. + Inconsistencies in the model can cause the application to crash. Since the + model is hit by numerous calls from the view, it is hard to find out which + call has crashed the application and which operation has introduced the + problem. + Qt provides software called + \l{http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest}{ModelTest}, + which checks models while your programming is running. Every time the model + is changed, ModelTest scans the model and reports errors with an assert. + This is especially important for tree models, since their hierarchical + nature leaves many possibilities for subtle inconsistencies. - -\raw HTML -
-\endraw + Unlike view classes, ModelTest uses out of range indexes to test the model. + This means your application may crash with ModelTest even if it runs + perfectly without it. So you also need to handle all of the indexes that + are out of range when using ModelTest. + \section2 3.6 Model/View NG + \raw HTML + +
+ \endraw + \raw HTML + + \endraw -\section2 3.6 Model/View NG + Model/View was introduced in Qt 4.0 and is a frequently used technology. + Feedback from developers and new development trends have shown that there + is a need to further develop the model/view technology. Therefore a + research project originated at Nokia is looking into ways to go beyond the + current implementation. + + One limitation of model/view is that view classes are basically all fixed + grids. It is possible, but really hard to make a list view with icons + placed on a curve; or cells expanding on mouse over events to show + additional information. + In order to achieve graphically rich view experiences, Model/View NG will + use QGraphicsView to render elements. Nodel/View NG also aims to make + model/view programming more intuitive. One way to achieve this is to have + separate models for lists, tables and trees. The current model abstraction + is complex because it is capable of representing a list, a table or a tree. + + Model/View NG is a research project. You are welcome to checkout the source + code, monitor progress and take part in discussions at the following + address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} -\raw HTML - -
-\endraw + \raw HTML + + \endraw -\raw HTML - -\endraw + \inlineimage path.png -Model/View was introduced in Qt 4.0 and is a frequently used technology. Feedback from clients and new development trends have shown, that there is a need to further develop the model/view technology. Therefore a research project at Nokia is looking into ways to go beyond the current implementation. -\raw HTML -
-\endraw -One limitation of model/view is that view classes are basically all fixed grids. It is possible, but really hard to make a list view with icons placed on a curve; or cells expanding on mouse over events to show additional information. In order to achieve graphically rich view experiences, Model/View NG will use QGraphicsView to render elements. Nodel/View NG also aims to make model/view programming more intuitive. One way to achieve this is to have separate models for lists, tables and trees. The current model abstraction is complex because it is capable of representing a list, a table or a tree. -\raw HTML -
-\endraw -Model/View NG is a research project. You are welcome to checkout the source code, monitor progress and take part in discussions at the following address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG} + \raw HTML +
+ \endraw +*/ -\raw HTML -
-\endraw +/*! + \page modelview-part4.html + \contentspage {modelview-index.html}{Model/View Contents} + \previouspage {modelview-part3.html}{Intermediate Topics} + \title Model/View Chapter 4 - Good Sources of Additional Information -\inlineimage path.png + \section1 4. Good Sources of Additional Information -\raw HTML -
-\endraw -\raw HTML -
-\endraw + \section2 4.1 Books -*/ + Model/View programming is covered quite extensively in the documentation of + Qt but also in several good books. -/*! - \page modelview-part4.html - - \title ModelView Chapter 4 - Good Sources for Additional Information - - \raw HTML -
- \endraw -\section1 4 Good Sources for Additional Information -\raw HTML -
-\endraw -\section2 4.1 Books -Model/View programming is covered quite extensively in the documentation of Qt but also in several good books. \list 1 - \o C++ GUI Programming with Qt 4 / Jasmin Blanchette, Mark Summerfield, Prentice Hall, 2nd edition, ISBN 0-13-235416-0 -also available in German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, Addison-Wesley, ISBN 3-827327-29-6 - \o The Book of Qt4, The Art of Building Qt Applications / Daniel Molkentin, Open Source Press ISBN 1-59327-147-6 -Translated from: Qt 4, Einführung in die Applikationsentwicklung, Open Source Press, ISBN 3-937514-12-0 - \o Foundations of Qt Development / Johan Thelin, Apress, ISBN 1-59059-831-8 + \o \bold{C++ GUI Programming with Qt 4} / Jasmin Blanchette, Mark Summerfield, + \e{Prentice Hall, 2nd edition}, ISBN 0-13-235416-0. Also available in + German: C++ GUI Programmierung mit Qt 4: Die offizielle Einführung, + \e{Addison-Wesley}, ISBN 3-827327-29-6 + \o \bold{The Book of Qt4, The Art of Building Qt Applications} / Daniel Molkentin, + \e{Open Source Press}, ISBN 1-59327-147-6. + Translated from \bold{Qt 4, Einführung in die Applikationsentwicklung}, + \e{Open Source Press}, ISBN 3-937514-12-0. + \o \bold{Foundations of Qt Development} / Johan Thelin, \e{Apress}, ISBN 1-59059-831-8. \endlist -\raw HTML -
-\endraw -The following list provides an overview of example programs contained in the books above. Some of them make very good templates for developing similar applications. + More information about these books is available on the + \l{Books about Qt Programming}{Qt Web site}. + + The following list provides an overview of example programs contained in the + books above. Some of them make very good templates for developing similar + applications. \table \header @@ -461,45 +670,45 @@ The following list provides an overview of example programs contained in the boo \o view class used \o model used \o aspects touched - \o + \o \row \o Team Leaders \o QListview \o QStringListModel - \o + \o \o Book 1, Chapter 10, Figure 10.6 \row \o Directory Viewer \o QTreeView \o QDirModel - \o + \o \o Book 1, Chapter 10, Figure 10.7 \row \o Color Names \o QListView \o QSortFilterProxyModel -applied to QStringListModel - \o + applied to QStringListModel + \o \o Book 1, Chapter 10, Figure 10.8 \row \o Currencies \o QTableView \o custom model based on -QAbstractTableModel + QAbstractTableModel \o read only \o Book 1, Chapter 10, Figure 10.10 \row \o Cities \o QTableView \o custom model based on -QAbstractTableModel + QAbstractTableModel \o read / write \o Book 1, Chapter 10, Figure 10.12 \row \o Boolean Parser \o QTreeView \o custom model based on -QAbstractItemModel + QAbstractItemModel \o read only \o Book 1, Chapter 10, Figure 10.14 \row @@ -511,141 +720,129 @@ QAbstractItemModel \row \o Four directory views \o QListView -QTableView -QTreeView + QTableView + QTreeView \o QDirModel \o demonstrates the use of multiple views \o Book2, Chapter 8.2 \row \o Address Book \o QListView -QTableView -QTreeView + QTableView + QTreeView \o custom model based on -QAbstractTableModel + QAbstractTableModel \o read / write \o Book2, Chapter 8.4 \row \o Address Book with sorting - \o + \o \o QProxyModel \o introducing sort and filter capabilities \o Book2, Chapter 8.5 \row - \o Address Book -with checkboxes - \o - \o - \o introducing checkboxes -in model/view + \o Address Book + with checkboxes + \o + \o + \o introducing checkboxes in model/view \o Book2, Chapter 8.6 \row - \o Address Book -with transposed grid - \o + \o Address Book with transposed grid + \o \o custom proxy Model based on QAbstractProxyModel \o introducing a custom model \o Book2, Chapter 8.7 \row - \o Address Book -with drag and drop - \o - \o + \o Address Book with drag and drop + \o + \o \o introducing drag and drop support \o Book2, Chapter 8.8 \row \o Address Book with custom editor - \o - \o + \o + \o \o introducing custom delegates \o Book2, Chapter 8.9 \row \o Views \o QListView -QTableView -QTreeView + QTableView + QTreeView \o QStandardItemModel \o read only \o Book 3, Chapter 5, figure 5-3 \row \o Bardelegate \o QTableView - \o + \o \o custom delegate for presentation based on QAbstractItemDelegate \o Book 3, Chapter 5, figure 5-5 \row \o Editdelegate \o QTableView - \o + \o \o custom delegate for editing based on QAbstractItemDelegate \o Book 3, Chapter 5, figure 5-6 \row \o Singleitemview - \o custom view based on -QAbstractItemView - \o + \o custom view based on QAbstractItemView + \o \o custom view \o Book 3, -Chapter 5, -figure 5-7 + Chapter 5, + figure 5-7 \row \o listmodel \o QTableView - \o custom Model based on -QAbstractTableModel + \o custom Model based on QAbstractTableModel \o read only - \o Book 3, -Chapter 5, -Figure 5-8 + \o Book 3, Chapter 5, Figure 5-8 \row \o treemodel \o QTreeView - \o custom Model based on -QAbstractItemModel + \o custom Model based on QAbstractItemModel \o read only - \o Book 3, -Chapter 5, -Figure 5-10 + \o Book 3, Chapter 5, Figure 5-10 \row \o edit integers \o QListView - \o custom Model based on -QAbstractListModel + \o custom Model based on QAbstractListModel \o read / write - \o Book 3, -Chapter 5, -Listing 5-37, Figure 5-11 + \o Book 3, Chapter 5, Listing 5-37, Figure 5-11 \row \o sorting \o QTableView - \o QSortFilterProxyModel -applied to QStringListModel + \o QSortFilterProxyModel applied to QStringListModel \o demonstrates sorting \o Book 3, Chapter 5, Figure 5-12 - \endtable -\section2 4.2 Qt documentation -Qt 4.6 comes with 17 examples and 2 Demonstrations for model/view. The examples can be found here: \l{http://doc.qt.nokia.com/4.6/examples-itemviews.html}{http://doc.qt.nokia.com/4.6/examples-itemviews.html} + \section2 4.2 Qt Documentation + + Qt 4.7 comes with 17 examples and 2 Demonstrations for model/view. + The examples can be found here: \l{Item Views Examples} \table \header - \o example name - \o view class used - \o model used - \o aspects touched + \o Example name + \o View class used + \o Model used + \o Aspects touched \row \o Address Book \o QTableView \o QAbstractTableModel -QSortFilterProxyModel - \o usage of QSortFilterProxyModel to generate different subsets from one data pool + QSortFilterProxyModel + \o usage of QSortFilterProxyModel to generate different + subsets from one data pool \row \o Basic Sort/Filter Model \o QTreeView \o QStandardItemModel -QSortFilterProxyModel - \o + QSortFilterProxyModel + \o \row \o Chart \o custom view @@ -664,9 +861,8 @@ QSortFilterProxyModel \o Custom Sort/Filter Model \o QTreeView \o QStandardItemModel -QSortFilterProxyModel - \o subclass QSortFilterProxyModel -for advanced sorting and filtering + QSortFilterProxyModel + \o subclass QSortFilterProxyModel for advanced sorting and filtering \row \o Dir View \o QTreeView @@ -676,17 +872,19 @@ for advanced sorting and filtering \o Editable Tree Model \o QTreeView \o custom tree model - \o comprehensive example for working with trees, demonstrates editing cells and tree structure with an underlying custom model + \o comprehensive example for working with trees, demonstrates + editing cells and tree structure with an underlying custom + model \row \o Fetch More \o QListView \o custom list model - \o dynamically changing model + \o dynamically changing model \row \o Frozen Column \o QTableView \o QStandardItemModel - \o + \o \row \o Pixelator \o QTableView @@ -723,13 +921,18 @@ for advanced sorting and filtering \o comprehensive custom delegate example. \endtable -Demonstrations are similar to examples except that no walk-through is provided for the code lines. Demonstrations are also sometimes more feature rich. - \l{http://doc.qt.nokia.com/4.6/demos.html}{http://doc.qt.nokia.com/4.6/demos.html} + \l{Qt Demonstrations}{Demonstrations} are similar to examples except + that no walkthrough is provided for the code. Demonstrations are also + sometimes more feature rich. + \list - \o The \bold Interview demonstration shows the same model and selection being shared between three different views. - \o Demonstration \bold Spreadsheet demonstrates the use of a table view as a spreadsheet, using custom delegates to render each item according to the type of data it contains. + \o The \bold Interview demonstration shows the same model and + selection being shared between three different views. + \o Demonstration \bold Spreadsheet demonstrates the use of a + table view as a spreadsheet, using custom delegates to render + each item according to the type of data it contains. \endlist -A reference documentation for model/view technology is also available. \l{http://doc.qt.nokia.com/4.6/model-view-programming.html}{http://doc.qt.nokia.com/4.6/model-view-programming.html} - -*/ \ No newline at end of file + A \l{Model/View Programming}{reference document} for model/view technology + is also available. +*/ diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp index ad11f38..fb4726a 100755 --- a/examples/tutorials/modelview/1_readonly/main.cpp +++ b/examples/tutorials/modelview/1_readonly/main.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ //! [Quoting ModelView Tutorial] +// main.cpp #include #include "modelview.h" diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp index 027be56..91a97bf 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.cpp +++ b/examples/tutorials/modelview/1_readonly/modelview.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ //! [Quoting ModelView Tutorial] +// modelview.cpp #include #include "modelview.h" #include "mymodel.h" @@ -48,6 +49,6 @@ ModelView::ModelView(QWidget *parent) { tableView = new QTableView(this); setCentralWidget(tableView); - tableView->setModel(new MyModel(this) ); + tableView->setModel(new MyModel(this)); } -//! [Quoting ModelView Tutorial] \ No newline at end of file +//! [Quoting ModelView Tutorial] diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h index d0f96cd..9307083 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.h +++ b/examples/tutorials/modelview/1_readonly/modelview.h @@ -38,11 +38,11 @@ ** ****************************************************************************/ -//! [Quoting ModelView Tutorial] #ifndef MODELVIEW_H #define MODELVIEW_H - +//! [Quoting ModelView Tutorial] +// modelview.h #include class QTableView; //forward declaration @@ -56,6 +56,6 @@ public: ModelView(QWidget *parent = 0); }; +//! [Quoting ModelView Tutorial] #endif // MODELVIEW_H -//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp index c441720..394605a 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.cpp +++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ //! [Quoting ModelView Tutorial] +// mymodel.cpp #include "mymodel.h" MyModel::MyModel(QObject *parent) @@ -46,22 +47,19 @@ MyModel::MyModel(QObject *parent) { } -//------------------------------------------------------- -int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +int MyModel::rowCount(const QModelIndex & /*parent*/) const { return 2; } -//------------------------------------------------------- -int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +int MyModel::columnCount(const QModelIndex & /*parent*/) const { return 3; } -//------------------------------------------------------- -QVariant MyModel::data(const QModelIndex &index, int role ) const +QVariant MyModel::data(const QModelIndex &index, int role) const { - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) { return QString("Row%1, Column%2") .arg(index.row() + 1) @@ -69,4 +67,4 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const } return QVariant(); } -//! [Quoting ModelView Tutorial] \ No newline at end of file +//! [Quoting ModelView Tutorial] diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h index c0ddf4ac6..6065f6e 100755 --- a/examples/tutorials/modelview/1_readonly/mymodel.h +++ b/examples/tutorials/modelview/1_readonly/mymodel.h @@ -38,10 +38,11 @@ ** ****************************************************************************/ -//! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H +//! [Quoting ModelView Tutorial] +// mymodel.h #include class MyModel : public QAbstractTableModel @@ -53,6 +54,6 @@ public: int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; }; +//! [Quoting ModelView Tutorial] #endif // MYMODEL_H -//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/2_formatting/modelview.cpp b/examples/tutorials/modelview/2_formatting/modelview.cpp index 2b05d4c..9a5ce64 100755 --- a/examples/tutorials/modelview/2_formatting/modelview.cpp +++ b/examples/tutorials/modelview/2_formatting/modelview.cpp @@ -47,6 +47,6 @@ ModelView::ModelView(QWidget *parent) { tableView = new QTableView(this); setCentralWidget(tableView); - tableView->setModel(new MyModel(this) ); + tableView->setModel(new MyModel(this)); } diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp index e9e68de..e34e014 100755 --- a/examples/tutorials/modelview/2_formatting/mymodel.cpp +++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp @@ -44,25 +44,23 @@ #include //! [Quoting ModelView Tutorial] +// mymodel.cpp MyModel::MyModel(QObject *parent) :QAbstractTableModel(parent) { } -//------------------------------------------------------- -int MyModel::rowCount(const QModelIndex & /*parent */ ) const +int MyModel::rowCount(const QModelIndex & /*parent */) const { return 2; } -//------------------------------------------------------- -int MyModel::columnCount(const QModelIndex & /*parent */ ) const +int MyModel::columnCount(const QModelIndex & /*parent */) const { return 3; } -//------------------------------------------------------- -QVariant MyModel::data(const QModelIndex &index, int role ) const +QVariant MyModel::data(const QModelIndex &index, int role) const { int row = index.row(); int col = index.column(); @@ -72,15 +70,15 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const switch(role){ case Qt::DisplayRole: - if(row == 0 && col == 1 )return QString("<--left"); - if(row == 1 && col == 1 )return QString("right-->"); + if (row == 0 && col == 1) return QString("<--left"); + if (row == 1 && col == 1) return QString("right-->"); return QString("Row%1, Column%2") .arg(row + 1) .arg(col +1); break; case Qt::FontRole: - if(row == 0 && col ==0 ) //change font only for cell(0,0) + if (row == 0 && col == 0) //change font only for cell(0,0) { QFont boldFont; boldFont.setBold(true); @@ -89,7 +87,7 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const break; case Qt::BackgroundRole: - if(row == 1 && col ==2 ) //change background only for cell(1,2) + if (row == 1 && col == 2) //change background only for cell(1,2) { QBrush redBackground(QColor(Qt::red)); return redBackground; @@ -97,14 +95,14 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const break; case Qt::TextAlignmentRole: - if(row == 1 && col ==1 ) //change text alignment only for cell(1,1) + if (row == 1 && col == 1) //change text alignment only for cell(1,1) { return Qt::AlignRight + Qt::AlignVCenter; } break; case Qt::CheckStateRole: - if(row == 1 && col ==0 ) //add a checkbox to cell(1,0) + if (row == 1 && col == 0) //add a checkbox to cell(1,0) { return Qt::Checked; } diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.cpp b/examples/tutorials/modelview/3_changingmodel/modelview.cpp index 2b05d4c..9a5ce64 100755 --- a/examples/tutorials/modelview/3_changingmodel/modelview.cpp +++ b/examples/tutorials/modelview/3_changingmodel/modelview.cpp @@ -47,6 +47,6 @@ ModelView::ModelView(QWidget *parent) { tableView = new QTableView(this); setCentralWidget(tableView); - tableView->setModel(new MyModel(this) ); + tableView->setModel(new MyModel(this)); } diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp index d806945..42915b0 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp @@ -50,32 +50,32 @@ MyModel::MyModel(QObject *parent) // selectedCell = 0; timer = new QTimer(this); timer->setInterval(1000); - connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit()) ); + connect(timer, SIGNAL(timeout()) , this, SLOT(timerHit())); timer->start(); } //! [quoting mymodel_a] //------------------------------------------------------- -int MyModel::rowCount(const QModelIndex & /*parent */ ) const +int MyModel::rowCount(const QModelIndex & /*parent */) const { return 2; } //------------------------------------------------------- -int MyModel::columnCount(const QModelIndex & /*parent */ ) const +int MyModel::columnCount(const QModelIndex & /*parent */) const { return 3; } //------------------------------------------------------- //! [quoting mymodel_QVariant ] -QVariant MyModel::data(const QModelIndex &index, int role ) const +QVariant MyModel::data(const QModelIndex &index, int role) const { int row = index.row(); int col = index.column(); - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) { - if(row == 0 && col == 0 ) + if (row == 0 && col == 0) { return QTime::currentTime().toString(); } @@ -88,8 +88,8 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const void MyModel::timerHit() { //we identify the top left cell - QModelIndex topLeft = createIndex ( 0,0 ); + QModelIndex topLeft = createIndex(0,0); //emit a signal to make the view reread identified data - emit dataChanged ( topLeft, topLeft ); + emit dataChanged(topLeft, topLeft); } //! [quoting mymodel_b ] diff --git a/examples/tutorials/modelview/4_headers/modelview.cpp b/examples/tutorials/modelview/4_headers/modelview.cpp index f661ab5..449dbbc 100755 --- a/examples/tutorials/modelview/4_headers/modelview.cpp +++ b/examples/tutorials/modelview/4_headers/modelview.cpp @@ -48,7 +48,7 @@ ModelView::ModelView(QWidget *parent) { tableView = new QTableView(this); setCentralWidget(tableView); - tableView->setModel(new MyModel(this) ); + tableView->setModel(new MyModel(this)); tableView->verticalHeader()->hide(); } diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp index 94fde34..e6f977d 100755 --- a/examples/tutorials/modelview/4_headers/mymodel.cpp +++ b/examples/tutorials/modelview/4_headers/mymodel.cpp @@ -46,21 +46,21 @@ MyModel::MyModel(QObject *parent) } //------------------------------------------------------- -int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +int MyModel::rowCount(const QModelIndex & /*parent*/) const { return 2; } //------------------------------------------------------- -int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +int MyModel::columnCount(const QModelIndex & /*parent*/) const { return 3; } //------------------------------------------------------- -QVariant MyModel::data(const QModelIndex &index, int role ) const +QVariant MyModel::data(const QModelIndex &index, int role) const { - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) { return QString("Row%1, Column%2") .arg(index.row() + 1) @@ -88,4 +88,4 @@ QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) } return QVariant(); } -//! [quoting mymodel_c] \ No newline at end of file +//! [quoting mymodel_c] diff --git a/examples/tutorials/modelview/5_edit/modelview.cpp b/examples/tutorials/modelview/5_edit/modelview.cpp index d8853c9..a6c6ef5 100755 --- a/examples/tutorials/modelview/5_edit/modelview.cpp +++ b/examples/tutorials/modelview/5_edit/modelview.cpp @@ -48,13 +48,13 @@ ModelView::ModelView(QWidget *parent) tableView = new QTableView(this); setCentralWidget(tableView); QAbstractTableModel *myModel = new MyModel(this); - tableView->setModel( myModel ); + tableView->setModel(myModel); //transfer changes to the model to the window title - connect(myModel, SIGNAL(editCompleted(const QString &) ), this, SLOT(setWindowTitle(const QString &))); + connect(myModel, SIGNAL(editCompleted(const QString &)), this, SLOT(setWindowTitle(const QString &))); } void ModelView::showWindowTitle(const QString & title) { -setWindowTitle( title ); +setWindowTitle(title); } diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp index 6007da1..67181ca 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.cpp +++ b/examples/tutorials/modelview/5_edit/mymodel.cpp @@ -53,22 +53,19 @@ MyModel::MyModel(QObject *parent) //! [quoting mymodel_d] //! [quoting mymodel_e] -//------------------------------------------------------- -int MyModel::rowCount(const QModelIndex & /*parent*/ ) const +int MyModel::rowCount(const QModelIndex & /*parent*/) const { return ROWS; } -//------------------------------------------------------- -int MyModel::columnCount(const QModelIndex & /*parent*/ ) const +int MyModel::columnCount(const QModelIndex & /*parent*/) const { return COLS; } -//------------------------------------------------------- -QVariant MyModel::data(const QModelIndex &index, int role ) const +QVariant MyModel::data(const QModelIndex &index, int role) const { - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) { return m_gridData[modelIndexToOffset(index)]; } @@ -79,23 +76,21 @@ QVariant MyModel::data(const QModelIndex &index, int role ) const //----------------------------------------------------------------- //! [quoting mymodel_f] -bool MyModel::setData ( const QModelIndex & index, const QVariant & value, int role ) +bool MyModel::setData(const QModelIndex & index, const QVariant & value, int role) { - if(role == Qt::EditRole) + if (role == Qt::EditRole) { m_gridData[modelIndexToOffset(index)] = value.toString(); - emit editCompleted(m_gridData.join(" | ") ); + emit editCompleted(m_gridData.join(" | ")); } return true; } -//----------------------------------------------------------------- -Qt::ItemFlags MyModel::flags ( const QModelIndex & /*index*/ ) const +Qt::ItemFlags MyModel::flags(const QModelIndex & /*index*/) const { return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ; } -//----------------------------------------------------------------- //convert row and column information to array offset int MyModel::modelIndexToOffset(const QModelIndex & index) const { diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h index 54f2b30..0d2a1b8 100755 --- a/examples/tutorials/modelview/5_edit/mymodel.h +++ b/examples/tutorials/modelview/5_edit/mymodel.h @@ -38,10 +38,11 @@ ** ****************************************************************************/ -//! [Quoting ModelView Tutorial] #ifndef MYMODEL_H #define MYMODEL_H +//! [Quoting ModelView Tutorial] +// mymodel.h #include #include @@ -53,14 +54,14 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const ; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); - Qt::ItemFlags flags ( const QModelIndex & index ) const ; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex & index) const ; private: QStringList m_gridData; //holds text entered into QTableView int modelIndexToOffset(const QModelIndex & index) const; signals: void editCompleted(const QString &); }; +//! [Quoting ModelView Tutorial] #endif // MYMODEL_H -//! [Quoting ModelView Tutorial] \ No newline at end of file diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/modelview.cpp index a25e4e9..772dbdd 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.cpp +++ b/examples/tutorials/modelview/6_treeview/modelview.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ //! [Quoting ModelView Tutorial] +// modelview.cpp #include #include #include @@ -64,14 +65,13 @@ ModelView::ModelView(QWidget *parent) // adding a row to an item starts a subtree preparedColumn.first()->appendRow(secondRow); - treeView->setModel( standardModel ); + treeView->setModel(standardModel); treeView->expandAll(); } -//--------------------------------------------------------------------------- QList ModelView::prepareColumn(const QString &first, const QString &second, - const QString &third ) + const QString &third) { QList colItems; colItems << new QStandardItem(first); @@ -79,4 +79,4 @@ QList ModelView::prepareColumn(const QString &first, colItems << new QStandardItem(third); return colItems; } -//! [Quoting ModelView Tutorial] \ No newline at end of file +//! [Quoting ModelView Tutorial] diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/modelview.h index 2329e89..a47111c 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.h +++ b/examples/tutorials/modelview/6_treeview/modelview.h @@ -56,7 +56,7 @@ private: QStandardItemModel *standardModel; QList prepareColumn(const QString &first, const QString &second, - const QString &third ); + const QString &third); public: ModelView(QWidget *parent = 0); }; diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/modelview.cpp index 2ef980d..3b373c6 100755 --- a/examples/tutorials/modelview/7_selections/modelview.cpp +++ b/examples/tutorials/modelview/7_selections/modelview.cpp @@ -74,13 +74,13 @@ ModelView::ModelView(QWidget *parent) italyItem-> appendRow(veronaItem); //register the model - treeView->setModel( standardModel ); + treeView->setModel(standardModel); treeView->expandAll(); //selection changes shall trigger a slot QItemSelectionModel *selectionModel= treeView->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & )), - this, SLOT(selectionChangedSlot(const QItemSelection & , const QItemSelection & ))); + connect(selectionModel, SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)), + this, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &))); } //! [quoting modelview_a] @@ -93,7 +93,7 @@ void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, co QString selectedText = index.data(Qt::DisplayRole).toString(); int hierarchyLevel=1; QModelIndex seekRoot = index; - while(seekRoot.parent() != QModelIndex() ) + while(seekRoot.parent() != QModelIndex()) { seekRoot = seekRoot.parent(); hierarchyLevel++; diff --git a/examples/tutorials/modelview/qmake.pro b/examples/tutorials/modelview/qmake.pro deleted file mode 100755 index 7f684ba..0000000 --- a/examples/tutorials/modelview/qmake.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = 1_readonly \ - 2_formatting \ - 3_changingmodel \ - 4_headers \ - 5_edit \ - 6_treeview \ - 7_selections - -- cgit v0.12 From 7acf2417bd2ae17c2e3c289c7caed84219e5fecd Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 13 Jul 2010 13:04:36 +0200 Subject: Fix last character being overwritten in password field The temporary cursor position was not being updated after committing the input (changing the cleartext into a *), as a result of which, the next keypress was mistaken for a multitap input which should replace the last character. Task-number: QTBUG-11673 Reviewed-by: axis --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index d081cfd..999edda 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -294,6 +294,10 @@ void QCoeFepInputContext::commitTemporaryPreeditString() return; commitCurrentString(false); + + //update cursor position, now this pre-edit text has been committed. + //this prevents next keypress overwriting it (QTBUG-11673) + m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); } void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event) -- cgit v0.12 From 6d29bcc28c4ee9b7583a62d23a931b9389004966 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Wed, 14 Jul 2010 16:12:04 +0200 Subject: Avoid a crash in the OpenVG paint engine when clipping to an empty path The convertToPainterPath() function assumes that the QVectorPath contains at least one path element when creating the QPainterPath. This is not necessarily the case here though because if QVG_SCISSOR_CLIP is defined and setClipPath() is called with an empty QPainterPath, this is then converted to an empty QVectorPath in QPaintEngineEx::clip() which then calls QVGPaintEngine::clip(). This function then goes on to convert the QVectorPath back into a QPainterPath using the aforementioned function which crashes when attempting to access the first element of the path. In case you are wondering why this seemingly redundant conversion happens at all, it happens because when QVG_SCISSOR_CLIP is defined, we attempt to convert the path to a series of rects for scissor clipping and this conversion function operates on QPainterPath instead of QVectorPath which is what this clip() function was designed to deal with. The fix is to skip over the path conversion for empty paths and go directly to an empty QRegion. Reviewed-by: Alessandro Portale --- src/openvg/qpaintengine_vg.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 7a050f6..7de09ce 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1632,7 +1632,10 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) // Try converting the path into a QRegion that tightly follows // the outline of the path we want to clip with. - QRegion region(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon()); + QRegion region; + if (!path.isEmpty()) + region = QRegion(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon()); + switch (op) { case Qt::NoClip: { -- cgit v0.12 From d52e3d553664f0fe9a5313908eeb10104f539249 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 10 May 2010 16:45:05 +0100 Subject: Remove test cases which cause stack overflow These test cases are not considered reasonable for a small screen device (625 widgets). Patching the QWidget code to use iteration rather than recursion is considered too risky, as the code is performance critical. Task-number: QTBUG-8512 Reviewed-by: Bjoern Erik Nilsen --- tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp index 8c30be4..7015bd1 100644 --- a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp +++ b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp @@ -159,12 +159,17 @@ void tst_QWidget::update_data() QTest::newRow("10x10x1 opaque") << 10 << 10 << 1 << true; QTest::newRow("10x10x10 opaque") << 10 << 10 << 10 << true; QTest::newRow("10x10x100 opaque") << 10 << 10 << 100 << true; +#ifndef Q_OS_SYMBIAN + //These test cases cause stack overflow in QWidgetPrivate::paintSiblingsRecursive + //see http://bugreports.qt.nokia.com/browse/QTBUG-8512 + //Symbian threads have a hard limit of 80kB user stack QTest::newRow("25x25x1 transparent ") << 25 << 25 << 1 << false; QTest::newRow("25x25x10 transparent") << 25 << 25 << 10 << false; QTest::newRow("25x25x100 transparent") << 25 << 25 << 100 << false; QTest::newRow("25x25x1 opaque") << 25 << 25 << 1 << true; QTest::newRow("25x25x10 opaque") << 25 << 25 << 10 << true; QTest::newRow("25x25x100 opaque") << 25 << 25 << 100 << true; +#endif } void tst_QWidget::update() -- cgit v0.12 From f90ce20ad1c7feec9b72fdeda42ab56fe7c079c5 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 16 Jul 2010 10:03:17 +1000 Subject: Fixed some network tests never being run. This logic for private_tests was the opposite of what it should be, meaning that network tests which use Q_AUTOTEST_EXPORTs have not been run for some time :-( --- tests/auto/network.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network.pro b/tests/auto/network.pro index bda03d3..c3ca58a 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -31,7 +31,7 @@ SUBDIRS=\ qsslkey \ qsslsocket \ -contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!contains(QT_CONFIG, private_tests): SUBDIRS -= \ qhttpnetworkconnection \ qhttpnetworkreply \ qnativesocketengine \ -- cgit v0.12 From 6771ce532f8b61499c998a502ea8c73e8e42262b Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Fri, 16 Jul 2010 14:06:03 +1000 Subject: Added a QPixmap based QAbstractVideoBuffer HandleType. It can be used for example when the hw video decoder can use X11 pixmaps as a rendering target. Reviewed-by: Justin McPherson --- src/multimedia/video/qabstractvideobuffer.cpp | 1 + src/multimedia/video/qabstractvideobuffer.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp index e9d30d0..db05ee5 100644 --- a/src/multimedia/video/qabstractvideobuffer.cpp +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. + \value QPixmapHandle The handle of the buffer is a QPixmap. \value UserHandle Start value for user defined handle types. \sa handleType() diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h index a8389db..98e12da 100644 --- a/src/multimedia/video/qabstractvideobuffer.h +++ b/src/multimedia/video/qabstractvideobuffer.h @@ -63,6 +63,7 @@ public: GLTextureHandle, XvShmImageHandle, CoreImageHandle, + QPixmapHandle, UserHandle = 1000 }; -- cgit v0.12 From 875ae40157aa9a34e0b74941fa905f7445c365df Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Jul 2010 15:56:42 +1000 Subject: Minor animation doc improvement --- doc/src/declarative/animation.qdoc | 4 +++- src/declarative/util/qdeclarativeanimation.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index c5333df..401cf16 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -67,7 +67,9 @@ A property animation can also be specified as a resource that is manipulated fro \snippet doc/src/snippets/declarative/animation.qml property-anim-3 As can be seen, when an animation is used like this (as opposed to as a value source) you will need -to explicitly set the \c target and \c property to animate. +to explicitly set the \c target and \c property to animate. This also the only case where +an animation needs to be started explictly by either setting the \c running property to +true or calling the \c start() method. Animations can be joined into a group using SequentialAnimation and ParallelAnimation. diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index bdb9510..5005746 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1671,6 +1671,9 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int different. For more information see the individual property documentation, as well as the \l{QML Animation} introduction. + Note that PropertyAnimation inherits the abstract \l Animation element. + This includes additional properties and methods for controlling the animation. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ -- cgit v0.12 From 6d5d19b5d92868ed1cd53ea9e6bf8b1119d0da10 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Jul 2010 16:32:27 +1000 Subject: Allow test to pass on smaller screens (eg. 480 high). --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index b08da0f..de8d222 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -152,16 +152,16 @@ void tst_QDeclarativeViewer::loading() TEST_INITIAL_SIZES(viewer); - viewer->resize(QSize(400, 500)); + viewer->resize(QSize(250, 350)); qApp->processEvents(); // window resized - QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); + QTRY_COMPARE(rootItem->width(), 250.0); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); + QCOMPARE(viewer->size(), QSize(250, 350)); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->reload(); @@ -177,16 +177,16 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); - viewer->resize(QSize(400, 500)); + viewer->resize(QSize(250, 350)); qApp->processEvents(); // window resized again - QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); + QTRY_COMPARE(rootItem->width(), 250.0); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); + QCOMPARE(viewer->size(), QSize(250, 350)); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->open(SRCDIR "/data/orientation.qml"); -- cgit v0.12 From 571b85896ee3663479b4a10d2418e2e19b3639f3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 16 Jul 2010 08:58:04 +0200 Subject: Fix compilation after merge Reviewed-by: TrustMe --- src/gui/dialogs/qfontdialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index 5859e63..b159fa7 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -334,7 +334,6 @@ void QFontDialogPrivate::init() familyList->setFocus(); retranslateStrings(); - nativeDialogInUse = false; } /*! -- cgit v0.12 From ae39a510f86fd13d6d41bc85d4f5c243eca45eab Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Wed, 14 Jul 2010 15:17:35 +0200 Subject: Fixed debugger's evaluation of dynamic properties in context Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeenginedebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 001da46..008d054 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -495,7 +495,7 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId, QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); } else { QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - QDeclarativeProperty property(object, propertyName); + QDeclarativeProperty property(object, propertyName, context); binding->setTarget(property); binding->setNotifyOnValueChanged(true); QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); -- cgit v0.12 From bca7646d81d8c580820cf5f6e52122da6d984c6b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 16 Jul 2010 09:34:51 +0200 Subject: Network Proxy Query: Fix memleak on OS X Task-number: QTBUG-12106 --- src/network/kernel/qnetworkproxy_mac.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 1e22212..4139a7e 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -157,8 +157,10 @@ QList macQueryInternal(const QNetworkProxyQuery &query) return result; // failed } - if (isHostExcluded(dict, query.peerHostName())) + if (isHostExcluded(dict, query.peerHostName())) { + CFRelease(dict); return result; // no proxy for this host + } // is there a PAC enabled? If so, use it first. CFNumberRef pacEnabled; @@ -222,6 +224,7 @@ QList macQueryInternal(const QNetworkProxyQuery &query) result << https; } + CFRelease(dict); return result; } -- cgit v0.12 From 1ea53e6055a7c4e9677a5003725785ad503bb242 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 16 Jul 2010 18:11:36 +1000 Subject: fixes, improvements for various docs and example code --- doc/src/declarative/qdeclarativemodels.qdoc | 16 +- doc/src/snippets/declarative/coloranimation.qml | 52 +++++++ doc/src/snippets/declarative/numberanimation.qml | 52 +++++++ doc/src/snippets/declarative/propertyanimation.qml | 101 +++++++++++++ doc/src/snippets/declarative/smoothedanimation.qml | 69 +++++++++ doc/src/snippets/declarative/springanimation.qml | 65 ++++++++ doc/src/snippets/declarative/state.qml | 23 +-- .../snippets/declarative/transition-from-to.qml | 62 ++++++++ .../snippets/declarative/transition-reversible.qml | 65 ++++++++ doc/src/snippets/declarative/transition.qml | 59 ++++++++ .../modelviews/abstractitemmodel/model.cpp | 2 + .../graphicsitems/qdeclarativeborderimage.cpp | 2 + src/declarative/util/qdeclarativeanimation.cpp | 163 ++++++++++++++------- .../util/qdeclarativesmoothedanimation.cpp | 44 ++---- .../util/qdeclarativespringanimation.cpp | 32 +++- src/declarative/util/qdeclarativestate.cpp | 24 ++- src/declarative/util/qdeclarativetransition.cpp | 96 ++++++++++-- 17 files changed, 805 insertions(+), 122 deletions(-) create mode 100644 doc/src/snippets/declarative/coloranimation.qml create mode 100644 doc/src/snippets/declarative/numberanimation.qml create mode 100644 doc/src/snippets/declarative/propertyanimation.qml create mode 100644 doc/src/snippets/declarative/smoothedanimation.qml create mode 100644 doc/src/snippets/declarative/springanimation.qml create mode 100644 doc/src/snippets/declarative/transition-from-to.qml create mode 100644 doc/src/snippets/declarative/transition-reversible.qml create mode 100644 doc/src/snippets/declarative/transition.qml diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index b44e6f2..e02575d 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -208,7 +208,10 @@ Models can be defined in C++ and then made available to QML. This is useful for exposing existing C++ data models or otherwise complex datasets to QML. A C++ model class can be defined as a QStringList, a QList or a -QAbstractItemModel. +QAbstractItemModel. The first two are useful for exposing simpler datasets, +while QAbstractItemModel provides a more flexible solution for more complex +models. + \section2 QStringList @@ -268,7 +271,10 @@ the model by calling QDeclarativeContext::setContextProperty() again. \section2 QAbstractItemModel -A model can be defined by subclassing QAbstractItemModel. +A model can be defined by subclassing QAbstractItemModel. This is the +best approach if you have a more complex model that cannot be supported +by the other approaches. A QAbstractItemModel can also automatically +notify a QML view when the model data has changed. The roles of a QAbstractItemModel subclass can be exposed to QML by calling QAbstractItemModel::setRoleNames(). The default role names set by Qt are: @@ -305,6 +311,12 @@ roles: \snippet examples/declarative/modelviews/abstractitemmodel/view.qml 0 +QML views are automatically updated when the model changes. Remember the model +must follow the standard rules for model changes and notify the view when +the model has changed by using QAbstractItemModel::dataChanged(), +QAbstractItemModel::beginInsertRows(), etc. See the \l {Model subclassing reference} for +more information. + The complete example is available in Qt's \l {declarative/modelviews/abstractitemmodel}{examples/declarative/modelviews/abstractitemmodel} directory. QAbstractItemModel presents a hierarchy of tables, but the views currently provided by QML diff --git a/doc/src/snippets/declarative/coloranimation.qml b/doc/src/snippets/declarative/coloranimation.qml new file mode 100644 index 0000000..4e35f22 --- /dev/null +++ b/doc/src/snippets/declarative/coloranimation.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + width: 100; height: 100 + color: "red" + + ColorAnimation on color { to: "yellow"; duration: 1000 } +} +//![0] + diff --git a/doc/src/snippets/declarative/numberanimation.qml b/doc/src/snippets/declarative/numberanimation.qml new file mode 100644 index 0000000..57d23b1 --- /dev/null +++ b/doc/src/snippets/declarative/numberanimation.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + width: 100; height: 100 + color: "red" + + NumberAnimation on x { to: 50; duration: 1000 } +} +//![0] + diff --git a/doc/src/snippets/declarative/propertyanimation.qml b/doc/src/snippets/declarative/propertyanimation.qml new file mode 100644 index 0000000..059cde5 --- /dev/null +++ b/doc/src/snippets/declarative/propertyanimation.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Row { + +//![transition] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + states: State { + name: "moved" + PropertyChanges { target: rect; x: 50 } + } + + transitions: Transition { + PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } + } +} +//![transition] + +//![behavior] +Rectangle { + width: 100; height: 100 + color: "red" + + Behavior on x { PropertyAnimation {} } + + MouseArea { anchors.fill: parent; onClicked: parent.x = 50 } +} +//![behavior] + +//![propertyvaluesource] +Rectangle { + width: 100; height: 100 + color: "red" + + SequentialAnimation on x { + loops: Animation.Infinite + PropertyAnimation { to: 50 } + PropertyAnimation { to: 0 } + } +} +//![propertyvaluesource] + +//![standalone] +Rectangle { + id: theRect + width: 100; height: 100 + color: "red" + + // this is a standalone animation, it's not running by default + PropertyAnimation { id: animation; target: theRect; property: "width"; to: 30; duration: 500 } + + MouseArea { anchors.fill: parent; onClicked: animation.running = true } +} +//![standalone] + + +} diff --git a/doc/src/snippets/declarative/smoothedanimation.qml b/doc/src/snippets/declarative/smoothedanimation.qml new file mode 100644 index 0000000..20c90b5 --- /dev/null +++ b/doc/src/snippets/declarative/smoothedanimation.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + width: 800; height: 600 + color: "blue" + + Rectangle { + width: 60; height: 60 + x: rect1.x - 5; y: rect1.y - 5 + color: "green" + + Behavior on x { SmoothedAnimation { velocity: 200 } } + Behavior on y { SmoothedAnimation { velocity: 200 } } + } + + Rectangle { + id: rect1 + width: 50; height: 50 + color: "red" + } + + focus: true + Keys.onRightPressed: rect1.x = rect1.x + 100 + Keys.onLeftPressed: rect1.x = rect1.x - 100 + Keys.onUpPressed: rect1.y = rect1.y - 100 + Keys.onDownPressed: rect1.y = rect1.y + 100 +} +//![0] diff --git a/doc/src/snippets/declarative/springanimation.qml b/doc/src/snippets/declarative/springanimation.qml new file mode 100644 index 0000000..b73a9d2 --- /dev/null +++ b/doc/src/snippets/declarative/springanimation.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + width: 300; height: 300 + + Rectangle { + id: rect + width: 50; height: 50 + color: "red" + + Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + } + + MouseArea { + anchors.fill: parent + onClicked: { + rect.x = mouse.x + rect.y = mouse.y + } + } +} +//![0] + diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml index a99c2e2..af6b103 100644 --- a/doc/src/snippets/declarative/state.qml +++ b/doc/src/snippets/declarative/state.qml @@ -44,26 +44,13 @@ import Qt 4.7 Rectangle { id: myRect width: 100; height: 100 - color: "black" + color: "red" - states: [ - State { - name: "clicked" - PropertyChanges { - target: myRect - color: "red" - } - } - ] + MouseArea { id: mouseArea; anchors.fill: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (myRect.state == "") // i.e. the default state - myRect.state = "clicked"; - else - myRect.state = ""; - } + states: State { + name: "hidden"; when: mouseArea.pressed + PropertyChanges { target: myRect; opacity: 0 } } } //![0] diff --git a/doc/src/snippets/declarative/transition-from-to.qml b/doc/src/snippets/declarative/transition-from-to.qml new file mode 100644 index 0000000..615de17 --- /dev/null +++ b/doc/src/snippets/declarative/transition-from-to.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +//![0] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "brighter"; when: mouseArea.pressed + PropertyChanges { target: rect; color: "yellow" } + } + + transitions: Transition { + ColorAnimation { duration: 1000 } + } +} +//![0] + + diff --git a/doc/src/snippets/declarative/transition-reversible.qml b/doc/src/snippets/declarative/transition-reversible.qml new file mode 100644 index 0000000..8a7b69a --- /dev/null +++ b/doc/src/snippets/declarative/transition-reversible.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +//![0] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "brighter" + when: mouseArea.pressed + PropertyChanges { target: rect; color: "yellow"; x: 50 } + } + + transitions: Transition { + SequentialAnimation { + PropertyAnimation { property: "x"; duration: 1000 } + ColorAnimation { duration: 1000 } + } + } +} +//![0] + diff --git a/doc/src/snippets/declarative/transition.qml b/doc/src/snippets/declarative/transition.qml new file mode 100644 index 0000000..b884750 --- /dev/null +++ b/doc/src/snippets/declarative/transition.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + states: State { + name: "moved" + PropertyChanges { target: rect; x: 50; y: 50 } + } + + transitions: Transition { + PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } + } +} +//![0] + diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp index d0e0971..940a44d 100644 --- a/examples/declarative/modelviews/abstractitemmodel/model.cpp +++ b/examples/declarative/modelviews/abstractitemmodel/model.cpp @@ -67,7 +67,9 @@ AnimalModel::AnimalModel(QObject *parent) void AnimalModel::addAnimal(const Animal &animal) { + beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_animals << animal; + endInsertRows(); } int AnimalModel::rowCount(const QModelIndex & parent) const { diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 44c206b..4881248 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -149,6 +149,8 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() \endqml The URL may be absolute, or relative to the URL of the component. + + \sa QDeclarativeImageProvider */ void QDeclarativeBorderImage::setSource(const QUrl &url) { diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 5005746..88ec5ba 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -634,13 +634,23 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation() \inherits PropertyAnimation \brief The ColorAnimation element allows you to animate color changes. - \code - ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 } - \endcode + ColorAnimation defines an animation to be applied when a color value + changes. + + Here is a ColorAnimation applied to the \c color property of a \l Rectangle + as a property value source: + + \snippet doc/src/snippets/declarative/coloranimation.qml 0 + + Like any other animation element, a NumberAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. When used in a transition, ColorAnimation will by default animate - all properties of type color that are changing. If a property or properties - are explicitly set for the animation, then those will be used instead. + all properties of type color that have changed. If a \l{PropertyAnimation::}{property} + or \l{PropertyAnimation::}{properties} are explicitly set for the animation, + then those are used instead. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -665,6 +675,17 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation() /*! \qmlproperty color ColorAnimation::from This property holds the starting color. + + For example, the following animation is not applied until a color value + has reached "#c0c0c0": + + Item { + states: [ ... ] + + transition: Transition { + NumberAnimation { from: "#c0c0c0"; duration: 2000 } + } + } */ QColor QDeclarativeColorAnimation::from() const { @@ -1098,11 +1119,22 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions, \inherits PropertyAnimation \brief The NumberAnimation element allows you to animate changes in properties of type qreal. - For example, to animate a set of properties over 200ms, from their values in the start state to - their values in the end state of the transition: - \code - NumberAnimation { properties: "x,y,scale"; duration: 200 } - \endcode + NumberAnimation defines an animation to be applied when a numerical value + changes. + + Here is a NumberAnimation applied to the \c x property of a \l Rectangle + as a property value source: + + \snippet doc/src/snippets/declarative/numberanimation.qml 0 + + Like any other animation element, a NumberAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + + Note that NumberAnimation may not animate smoothly if there are irregular + changes in the number value that it is tracking. If this is the case, use + SmoothedAnimation instead. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1137,9 +1169,23 @@ void QDeclarativeNumberAnimation::init() /*! \qmlproperty real NumberAnimation::from - This property holds the starting value. - If not set, then the value defined in the start state of the transition. + This property holds the starting number value. + + For example, the following animation is not applied until the \c x value + has reached 100: + + Item { + states: [ ... ] + + transition: Transition { + NumberAnimation { properties: "x"; from: 100; duration: 200 } + } + } + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ + qreal QDeclarativeNumberAnimation::from() const { Q_D(const QDeclarativePropertyAnimation); @@ -1153,8 +1199,10 @@ void QDeclarativeNumberAnimation::setFrom(qreal f) /*! \qmlproperty real NumberAnimation::to - This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + This property holds the ending number value. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ qreal QDeclarativeNumberAnimation::to() const { @@ -1199,7 +1247,9 @@ QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation() /*! \qmlproperty real Vector3dAnimation::from This property holds the starting value. - If not set, then the value defined in the start state of the transition. + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ QVector3D QDeclarativeVector3dAnimation::from() const { @@ -1215,7 +1265,9 @@ void QDeclarativeVector3dAnimation::setFrom(QVector3D f) /*! \qmlproperty real Vector3dAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ QVector3D QDeclarativeVector3dAnimation::to() const { @@ -1320,8 +1372,21 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation() /*! \qmlproperty real RotationAnimation::from - This property holds the starting value. - If not set, then the value defined in the start state of the transition. + This property holds the starting number value. + + For example, the following animation is not applied until the \c angle value + has reached 100: + + Item { + states: [ ... ] + + transition: Transition { + RotationAnimation { properties: "angle"; from: 100; duration: 2000 } + } + } + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ qreal QDeclarativeRotationAnimation::from() const { @@ -1337,7 +1402,9 @@ void QDeclarativeRotationAnimation::setFrom(qreal f) /*! \qmlproperty real RotationAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ qreal QDeclarativeRotationAnimation::to() const { @@ -1620,51 +1687,49 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. - PropertyAnimation provides a way to animate changes to a property's value. It can - be used in many different situations: + PropertyAnimation provides a way to animate changes to a property's value. + + It can be used to define animations in a number of ways: + \list - \o In a Transition + \o In a \l Transition + + For example, to animate any objects that have changed their \c x or \c y properties + as a result of a state change, using an \c InOutQuad easing curve: + + \snippet doc/src/snippets/declarative/propertyanimation.qml transition + + + \o In a \l Behavior + + For example, to animate all changes to a rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml behavior - Animate any objects that have changed their x or y properties in the target state using - an InOutQuad easing curve: - \qml - Transition { PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } } - \endqml - \o In a Behavior - Animate all changes to a rectangle's x property. - \qml - Rectangle { - Behavior on x { PropertyAnimation {} } - } - \endqml \o As a property value source - Repeatedly animate the rectangle's x property. - \qml - Rectangle { - SequentialAnimation on x { - loops: Animation.Infinite - PropertyAnimation { to: 50 } - PropertyAnimation { to: 0 } - } - } - \endqml + For example, to repeatedly animate the rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml propertyvaluesource + + \o In a signal handler - Fade out \c theObject when clicked: + For example, to fade out \c theObject when clicked: \qml MouseArea { anchors.fill: theObject onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } } \endqml + \o Standalone - Animate \c theObject's size property over 200ms, from its current size to 20-by-20: - \qml - PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 } - \endqml + For example, to animate \c rect's \c width property over 500ms, from its current width to 30: + + \snippet doc/src/snippets/declarative/propertyanimation.qml standalone + \endlist Depending on how the animation is used, the set of properties normally used will be diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 5d47c30..e0d1097 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -272,33 +272,8 @@ void QSmoothedAnimation::init() with both a velocity of 200 and a duration of 8000 set. The follow example shows one rectangle tracking the position of another. -\code -import Qt 4.7 - -Rectangle { - width: 800; height: 600; color: "blue" - - Rectangle { - color: "green" - width: 60; height: 60; - x: rect1.x - 5; y: rect1.y - 5; - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - - Rectangle { - id: rect1 - color: "red" - width: 50; height: 50; - } - focus: true - Keys.onRightPressed: rect1.x = rect1.x + 100 - Keys.onLeftPressed: rect1.x = rect1.x - 100 - Keys.onUpPressed: rect1.y = rect1.y - 100 - Keys.onDownPressed: rect1.y = rect1.y + 100 -} -\endcode + \snippet doc/src/snippets/declarative/smoothedanimation.qml 0 The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the value being animated is small, then the velocity will need to be adjusted @@ -307,6 +282,11 @@ Rectangle { set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity of 0.5 will take 2000 ms to complete. + Like any other animation element, a SmoothedAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -388,11 +368,13 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions Sets how the SmoothedAnimation behaves if an animation direction is reversed. - If reversing mode is \c SmoothedAnimation.Eased, the animation will smoothly decelerate, and - then reverse direction. If the reversing mode is \c SmoothedAnimation.Immediate, the - animation will immediately begin accelerating in the reverse direction, - begining with a velocity of 0. If the reversing mode is \c SmoothedAnimation.Sync, the - property is immediately set to the target value. + Possible values are: + + \list + \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction + \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, begining with a velocity of 0 + \o SmoothedAnimation.Sync - the property is immediately set to the target value + \endlist */ QDeclarativeSmoothedAnimation::ReversingMode QDeclarativeSmoothedAnimation::reversingMode() const { diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp index 4cf2fc0..be0af6d 100644 --- a/src/declarative/util/qdeclarativespringanimation.cpp +++ b/src/declarative/util/qdeclarativespringanimation.cpp @@ -207,14 +207,24 @@ void QDeclarativeSpringAnimationPrivate::updateMode() \qmlclass SpringAnimation QDeclarativeSpringAnimation \since 4.7 - \brief The SpringAnimation element allows a property to track a value in a spring-like motion + \brief The SpringAnimation element allows a property to track a value in a spring-like motion. SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to control the acceleration and the \l damping to control how quickly the effect dies away. You can also limit the maximum \l velocity of the animation. + The following \l Rectangle moves to the position of the mouse using a + SpringAnimation when the mouse is clicked: + \snippet doc/src/snippets/declarative/springanimation.qml 0 + + Like any other animation element, a SpringAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} */ QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent) @@ -244,6 +254,11 @@ qreal QDeclarativeSpringAnimation::to() const /*! \qmlproperty real SpringAnimation::to + + This property holds the value at which the animation will end. + + If not set, the animation will continue until it reaches the + value that is being tracked. */ void QDeclarativeSpringAnimation::setTo(qreal value) @@ -266,6 +281,11 @@ qreal QDeclarativeSpringAnimation::from() const /*! \qmlproperty real SpringAnimation::from + + This property holds the value from which the animation will begin. + + If not set, the animation will start regardless of the + value being tracked. */ void QDeclarativeSpringAnimation::setFrom(qreal value) @@ -325,10 +345,12 @@ void QDeclarativeSpringAnimation::setSpring(qreal spring) /*! \qmlproperty real SpringAnimation::damping - This property holds the spring damping constant + This property holds the spring damping value. + + This value describes how quickly a sprung follower comes to rest. - The damping constant describes how quickly a sprung follower comes to rest. - Useful range is 0 - 1.0 + The useful range is 0 - 1.0. The lower the value, the faster the + follower comes to rest. */ qreal QDeclarativeSpringAnimation::damping() const { @@ -348,7 +370,7 @@ void QDeclarativeSpringAnimation::setDamping(qreal damping) /*! \qmlproperty real SpringAnimation::epsilon - This property holds the spring epsilon + This property holds the spring epsilon. The epsilon is the rate and amount of change in the value which is close enough to 0 to be considered equal to zero. This will depend on the usage of the value. diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index ae19a9c..9f4cc39 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -144,7 +144,7 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje can, for example, be used to apply different sets of property values or execute different scripts. - The following example displays a single Rectangle. In the default state, the rectangle + The following example displays a single \l Rectangle. In the default state, the rectangle is colored black. In the "clicked" state, a PropertyChanges element changes the rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state between the default state and the "clicked" state, thus toggling the color of the @@ -157,7 +157,7 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje States are commonly used together with \l {state-transitions}{Transitions} to provide animations when state changes occur. - \note setting the state of an object from within another state of the same object is + \note Setting the state of an object from within another state of the same object is not allowed. \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, QtDeclarative @@ -194,7 +194,7 @@ QDeclarativeState::~QDeclarativeState() \qmlproperty string State::name This property holds the name of the state. - Each state should have a unique name. + Each state should have a unique name within its item. */ QString QDeclarativeState::name() const { @@ -226,7 +226,23 @@ bool QDeclarativeState::isWhenKnown() const This property holds when the state should be applied. This should be set to an expression that evaluates to \c true when you want the state to - be applied. + be applied. For example, the following \l Rectangle changes in and out of the "hidden" + state when the \l MouseArea is pressed: + + \qml + Rectangle { + id: myRect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "hidden"; when: mouseArea.pressed + PropertyChanges { target: myRect; opacity: 0 } + } + } + \endqml If multiple states in a group have \c when clauses that evaluate to \c true at the same time, the first matching state will be applied. For example, in the following snippet diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 38ed97e..34e1e2b 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -56,6 +56,30 @@ QT_BEGIN_NAMESPACE \since 4.7 \brief The Transition element defines animated transitions that occur on state changes. + A Transition defines the animations to be applied when a \l State change occurs. + + For example, the following \l Rectangle has two states: the default state, and + an added "moved" state. In the "moved state, the rectangle's position changes + to (50, 50). The added \l Transition specifies that when the rectangle + changes between the default and the "moved" state, any changes + to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. + + \snippet doc/src/snippets/declarative/transition.qml 0 + + Items can have multiple transitions, if + + To specify multiple transitions, specify \l Item::transitions as a list: + + \qml + Item { + ... + transitions: [ + Transition { ... } + Transition { ... } + ] + } + |endqml + \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} */ @@ -171,18 +195,31 @@ void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &act /*! \qmlproperty string Transition::from \qmlproperty string Transition::to - These properties are selectors indicating which state changes should trigger the transition. - from is used in conjunction with to to determine when a transition should - be applied. By default from and to are both "*" (any state). In the following example, - the transition is applied when changing from state1 to state2. - \code - Transition { - from: "state1" - to: "state2" - ... + These properties indicate the state changes that trigger the transition. + + The default values for these properties is "*" (that is, any state). + + For example, the following transition has not set the \c to and \c from + properties, so the animation is always applied when changing between + the two states (i.e. when the mouse is pressed and released). + + \snippet doc/src/snippets/declarative/transition-from-to.qml 0 + + If the transition was changed to this: + + \qml + transitions: Transition { + to: "brighter" + ColorAnimation { duration: 1000 } + } } - \endcode + \endqml + + The animation would only be applied when changing from the default state to + the "brighter" state (i.e. when the mouse is pressed, but not on release). + + \sa reversible */ QString QDeclarativeTransition::fromState() const { @@ -205,6 +242,24 @@ void QDeclarativeTransition::setFromState(const QString &f) This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed. The default value is false. + + By default, transitions run in parallel and are applied to all state + changes if the \l from and \l to states have not been set. In this + situation, the transition is automatically applied when a state change + is reversed, and it is not necessary to set this property to reverse + the transition. + + However, if a SequentialAnimation is used, or if the \l from or \l to + properties have been set, this property will need to be set to reverse + a transition when a state change is reverted. For example, the following + transition applies a sequential animation when the mouse is pressed, + and reverses the sequence of the animation when the mouse is released: + + \snippet doc/src/snippets/declarative/transition-reversible.qml 0 + + If the transition did not set the \c to and \c reversible values, then + on the mouse release, the transition would play the PropertyAnimation + before the ColorAnimation instead of reversing the sequence. */ bool QDeclarativeTransition::reversible() const { @@ -241,12 +296,27 @@ void QDeclarativeTransition::setToState(const QString &t) /*! \qmlproperty list Transition::animations \default + This property holds a list of the animations to be run for this transition. + \qml + Transition { + PropertyAnimation { ... } + NumberAnimation { ... } + } + \endqml + The top-level animations are run in parallel. To run them sequentially, - you can create a single SequentialAnimation which contains all the animations, - and assign that to animations the animations property. - \default + define them within a SequentialAnimation: + + \qml + Transition { + SequentialAnimation { + PropertyAnimation { ... } + NumberAnimation { ... } + } + } + \endqml */ QDeclarativeListProperty QDeclarativeTransition::animations() { -- cgit v0.12 From 11f5b578e398c99570215facb905f1d82f6d6817 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 16 Jul 2010 10:33:26 +0200 Subject: update def files for 69027cdb2ab9b89673edf29d5034bed33e614a05 Reviewed-by: Trust Me --- src/s60installs/bwins/QtNetworku.def | 3 +++ src/s60installs/eabi/QtNetworku.def | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 9d4507b..9911b36 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1144,4 +1144,7 @@ EXPORTS ?startPolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1143 NONAME ; void QNetworkConfigurationManagerPrivate::startPolling(void) ?capabilities@QNetworkConfigurationManagerPrivate@@QAE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1144 NONAME ; class QFlags QNetworkConfigurationManagerPrivate::capabilities(void) ?addPendingConnection@QTcpServer@@IAEXPAVQTcpSocket@@@Z @ 1145 NONAME ; void QTcpServer::addPendingConnection(class QTcpSocket *) + ?option@QAuthenticator@@QBE?AVQVariant@@ABVQString@@@Z @ 1146 NONAME ; class QVariant QAuthenticator::option(class QString const &) const + ?options@QAuthenticator@@QBE?AV?$QHash@VQString@@VQVariant@@@@XZ @ 1147 NONAME ; class QHash QAuthenticator::options(void) const + ?setOption@QAuthenticator@@QAEXABVQString@@ABVQVariant@@@Z @ 1148 NONAME ; void QAuthenticator::setOption(class QString const &, class QVariant const &) diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index 3cc3644..eb30832 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1164,4 +1164,7 @@ EXPORTS _ZTV35QNetworkConfigurationManagerPrivate @ 1163 NONAME _ZThn8_N19QBearerEnginePluginD0Ev @ 1164 NONAME _ZThn8_N19QBearerEnginePluginD1Ev @ 1165 NONAME + _ZN14QAuthenticator9setOptionERK7QStringRK8QVariant @ 1166 NONAME + _ZNK14QAuthenticator6optionERK7QString @ 1167 NONAME + _ZNK14QAuthenticator7optionsEv @ 1168 NONAME -- cgit v0.12 From 70ffe96013dcf7b4be11d1fbe850b9bbcf37c741 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 16 Jul 2010 10:40:55 +0200 Subject: Added LatinAmericaAndTheCaribbean country to the doc. Task-number: QTBUG-12063 Reviewed-by: trustme --- src/corelib/tools/qlocale.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index a51ee81..6b1de5e 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2096,6 +2096,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) \value Serbia \value SaintBarthelemy \value SaintMartin + \value LatinAmericaAndTheCaribbean \omitvalue LastCountry \sa country() -- cgit v0.12 From 4942890f85e5fa74bf8c37cf7f53f6f3eaf40596 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 31 May 2010 11:03:24 +0200 Subject: Revert the change in applicationShouldTerminate(). It used to fix an issue during logout but it seems to be fine now. Related issue: QTBUG-6296 Task-number: QTBUG-10993 Reviewed-by: Morten Sorvig --- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 5dcf613..7a9dc70 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -196,7 +196,6 @@ static void cleanupCocoaApplicationDelegate() qAppInstance()->quit(); startedQuit = false; } - return NSTerminateNow; } if (qtPrivate->threadData->eventLoops.size() == 0) { -- cgit v0.12 From 975b1913e44128a3e9b9055f9bf2ff40d86adf2a Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 16 Jul 2010 11:42:16 +0200 Subject: Fix RightBearing confusion in text layout Negative RightBearing was wrongly taken into account when calculating the line wrap Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d6535ea..674064e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1935,7 +1935,7 @@ void QTextLine::layout_helper(int maxGlyphs) // We ignore the right bearing if the minimum negative bearing is too little to // expand the text beyond the edge. if (sb_or_ws|breakany) { - if (lbh.calculateNewWidth(line) + lbh.minimumRightBearing > line.width) + if (lbh.calculateNewWidth(line) - lbh.minimumRightBearing > line.width) lbh.adjustRightBearing(); if (lbh.checkFullOtherwiseExtend(line)) { if (!breakany) { -- cgit v0.12 From 0f4dc1226bcc1204a2b11d737fbcb4b58acfaf08 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 14 Jul 2010 14:07:33 +0200 Subject: QDeclarativeDebugTrace: Do not send message if the client did not enabled CanvasFrameRate This silents a lot of warnings in creator. Reviewed-by: Aaron Kennedy --- src/declarative/debugger/qdeclarativedebugtrace.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp index 5e6d5e7..b2b0c8a 100644 --- a/src/declarative/debugger/qdeclarativedebugtrace.cpp +++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp @@ -78,6 +78,9 @@ void QDeclarativeDebugTrace::endRange(RangeType t) void QDeclarativeDebugTrace::addEventImpl(EventType event) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)Event << (int)event; @@ -86,6 +89,9 @@ void QDeclarativeDebugTrace::addEventImpl(EventType event) void QDeclarativeDebugTrace::startRangeImpl(RangeType range) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeStart << (int)range; @@ -94,6 +100,9 @@ void QDeclarativeDebugTrace::startRangeImpl(RangeType range) void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeData << (int)range << (QString)u.toString(); @@ -102,6 +111,9 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u) void QDeclarativeDebugTrace::endRangeImpl(RangeType range) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeEnd << (int)range; -- cgit v0.12 From 790417ac69cd4fa780d6e298567908fc3d7ef6d0 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 15:33:59 +0200 Subject: Doc: Fixed whitespace issues. Reviewed-by: Trust Me --- examples/itemviews/addressbook/addresswidget.cpp | 2 +- examples/itemviews/addressbook/tablemodel.cpp | 48 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/itemviews/addressbook/addresswidget.cpp b/examples/itemviews/addressbook/addresswidget.cpp index e226643..22dfae3 100644 --- a/examples/itemviews/addressbook/addresswidget.cpp +++ b/examples/itemviews/addressbook/addresswidget.cpp @@ -230,7 +230,7 @@ void AddressWidget::writeToFile(QString fileName) return; } - QList< QPair > pairs = table->getList(); + QList< QPair > pairs = table->getList(); QDataStream out(&file); out << pairs; } diff --git a/examples/itemviews/addressbook/tablemodel.cpp b/examples/itemviews/addressbook/tablemodel.cpp index 603c926..e9a08f0 100644 --- a/examples/itemviews/addressbook/tablemodel.cpp +++ b/examples/itemviews/addressbook/tablemodel.cpp @@ -72,13 +72,13 @@ QVariant TableModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); - + if (index.row() >= listOfPairs.size() || index.row() < 0) return QVariant(); - + if (role == Qt::DisplayRole) { QPair pair = listOfPairs.at(index.row()); - + if (index.column() == 0) return pair.first; else if (index.column() == 1) @@ -93,15 +93,15 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, int ro { if (role != Qt::DisplayRole) return QVariant(); - + if (orientation == Qt::Horizontal) { switch (section) { case 0: return tr("Name"); - + case 1: return tr("Address"); - + default: return QVariant(); } @@ -115,7 +115,7 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &index) { Q_UNUSED(index); beginInsertRows(QModelIndex(), position, position+rows-1); - + for (int row=0; row < rows; row++) { QPair pair(" ", " "); listOfPairs.insert(position, pair); @@ -129,9 +129,9 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &index) //! [5] bool TableModel::removeRows(int position, int rows, const QModelIndex &index) { - Q_UNUSED(index); + Q_UNUSED(index); beginRemoveRows(QModelIndex(), position, position+rows-1); - + for (int row=0; row < rows; ++row) { listOfPairs.removeAt(position); } @@ -144,25 +144,25 @@ bool TableModel::removeRows(int position, int rows, const QModelIndex &index) //! [6] bool TableModel::setData(const QModelIndex &index, const QVariant &value, int role) { - if (index.isValid() && role == Qt::EditRole) { - int row = index.row(); - - QPair p = listOfPairs.value(row); - - if (index.column() == 0) - p.first = value.toString(); - else if (index.column() == 1) - p.second = value.toString(); + if (index.isValid() && role == Qt::EditRole) { + int row = index.row(); + + QPair p = listOfPairs.value(row); + + if (index.column() == 0) + p.first = value.toString(); + else if (index.column() == 1) + p.second = value.toString(); else return false; - + listOfPairs.replace(row, p); - emit(dataChanged(index, index)); - + emit(dataChanged(index, index)); + return true; - } + } - return false; + return false; } //! [6] @@ -171,7 +171,7 @@ Qt::ItemFlags TableModel::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::ItemIsEnabled; - + return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; } //! [7] -- cgit v0.12 From 3db1408bb63ada82fb9d5adb4c082e5525d46ab0 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 15:36:27 +0200 Subject: Doc: Whitespace fixes. Reviewed-by: Trust Me --- doc/src/index.qdoc | 32 ++++++++--------- tools/qdoc3/test/qt.qdocconf | 82 ++++++++++++++++++++++---------------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 42fd4fc..ca7fef5 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -56,29 +56,29 @@ @@ -103,7 +103,7 @@ - + \endraw */ diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index d132771..e4ed1bc 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -9,7 +9,7 @@ versionsym = version = %VERSION% description = Qt Reference Documentation url = http://qt.nokia.com/doc/4.7 -online = true +online = true sourceencoding = UTF-8 outputencoding = UTF-8 @@ -26,46 +26,46 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/bg_l.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ul_blank.png \ - images/header_bg.png \ + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ul_blank.png \ + images/header_bg.png \ images/bg_r.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_gt.png \ - images/bullet_dn.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/arrow_down.png \ - images/feedbackground.png \ - images/horBar.png \ - images/page.png \ - images/page_bg.png \ - images/sprites-combined.png \ - images/spinner.gif \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - scripts/shBrushCpp.js \ - scripts/shCore.js \ - scripts/shLegacy.js \ - scripts/narrow.js \ - scripts/superfish.js \ - style/shCore.css \ - style/shThemeDefault.css \ - style/narrow.css \ - style/superfish.css \ - style/superfish_skin.css \ - style/OfflineStyle.css \ - style/style_ie6.css \ - style/style_ie7.css \ - style/style_ie8.css \ - style/style.css + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/arrow_down.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/spinner.gif \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + scripts/shBrushCpp.js \ + scripts/shCore.js \ + scripts/shLegacy.js \ + scripts/narrow.js \ + scripts/superfish.js \ + style/shCore.css \ + style/shThemeDefault.css \ + style/narrow.css \ + style/superfish.css \ + style/superfish_skin.css \ + style/OfflineStyle.css \ + style/style_ie6.css \ + style/style_ie7.css \ + style/style_ie8.css \ + style/style.css qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc qhp.Qt.customFilters.Qt.name = Qt 4.7.0 @@ -146,7 +146,7 @@ exampledirs = $QTDIR/doc/src \ imagedirs = $QTDIR/doc/src/images \ $QTDIR/examples \ $QTDIR/doc/src/declarative/pics \ - $QTDIR/doc/src/template/images + $QTDIR/doc/src/template/images outputdir = $QTDIR/doc/html tagfile = $QTDIR/doc/html/qt.tags base = file:$QTDIR/doc/html -- cgit v0.12 From eef1d13743baddf41bd135d98fc2ad12944b8477 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 16:09:20 +0200 Subject: Doc: Excluded the QML documentation from the Qt-only set. Reviewed-by: Trust Me --- tools/qdoc3/test/qt-api-only.qdocconf | 7 +++++++ tools/qdoc3/test/qt-api-only_ja_JP.qdocconf | 7 +++++++ tools/qdoc3/test/qt-api-only_zh_CN.qdocconf | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/tools/qdoc3/test/qt-api-only.qdocconf b/tools/qdoc3/test/qt-api-only.qdocconf index 10b7be5..bf6c0dc 100644 --- a/tools/qdoc3/test/qt-api-only.qdocconf +++ b/tools/qdoc3/test/qt-api-only.qdocconf @@ -25,6 +25,13 @@ qhp.Qt.excluded += $QT_SOURCE_TREE/doc/src/development/assistant-manual.qdoc \ $QT_SOURCE_TREE/doc/src/examples/trollprint.qdoc \ $QT_SOURCE_TREE/doc/src/development/qmake-manual.qdoc +# Remove the QML documentation from the Qt-only documentation. + +excludedirs += $QT_SOURCE_TREE/src/declarative \ + $QT_SOURCE_TREE/src/imports \ + $QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative \ + $QT_SOURCE_TREE/doc/src/declarative + outputdir = $QT_BUILD_TREE/doc-build/html-qt tagfile = $QT_BUILD_TREE/doc-build/html-qt/qt.tags base = file:$QT_BUILD_TREE/doc-build/html-qt diff --git a/tools/qdoc3/test/qt-api-only_ja_JP.qdocconf b/tools/qdoc3/test/qt-api-only_ja_JP.qdocconf index aa3ab01..70e0235 100644 --- a/tools/qdoc3/test/qt-api-only_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-api-only_ja_JP.qdocconf @@ -25,6 +25,13 @@ qhp.Qt.excluded += $QT_SOURCE_TREE/doc/src/development/assistant-manual.qdoc \ $QT_SOURCE_TREE/doc/src/examples/trollprint.qdoc \ $QT_SOURCE_TREE/doc/src/development/qmake-manual.qdoc +# Remove the QML documentation from the Qt-only documentation. + +excludedirs += $QT_SOURCE_TREE/src/declarative \ + $QT_SOURCE_TREE/src/imports \ + $QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative \ + $QT_SOURCE_TREE/doc/src/declarative + outputdir = $QT_BUILD_TREE/doc-build/html-qt_ja_JP tagfile = $QT_BUILD_TREE/doc-build/html-qt_ja_JP/qt.tags base = file:$QT_BUILD_TREE/doc-build/html-qt_ja_JP diff --git a/tools/qdoc3/test/qt-api-only_zh_CN.qdocconf b/tools/qdoc3/test/qt-api-only_zh_CN.qdocconf index c722ee8..d6bf410 100644 --- a/tools/qdoc3/test/qt-api-only_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-api-only_zh_CN.qdocconf @@ -25,6 +25,13 @@ qhp.Qt.excluded += $QT_SOURCE_TREE/doc/src/development/assistant-manual.qdoc \ $QT_SOURCE_TREE/doc/src/examples/trollprint.qdoc \ $QT_SOURCE_TREE/doc/src/development/qmake-manual.qdoc +# Remove the QML documentation from the Qt-only documentation. + +excludedirs += $QT_SOURCE_TREE/src/declarative \ + $QT_SOURCE_TREE/src/imports \ + $QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative \ + $QT_SOURCE_TREE/doc/src/declarative + outputdir = $QT_BUILD_TREE/doc-build/html-qt_zh_CN tagfile = $QT_BUILD_TREE/doc-build/html-qt_zh_CN/qt.tags base = file:$QT_BUILD_TREE/doc-build/html-qt_zh_CN -- cgit v0.12 From f231bd03007484d239cb5456db9e20a1f9ab7a63 Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Wed, 7 Jul 2010 16:30:14 +0300 Subject: Link to the unsinstalled libraries first. Task-number: QT-3371 Reviewed-by: Harald Fernengel --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 62e0863..fb544bd 100755 --- a/configure +++ b/configure @@ -7746,7 +7746,7 @@ EOF # Ensure we can link to uninistalled libraries if [ "$XPLATFORM_MINGW" != "yes" ] && linkerSupportsFlag -rpath-link "$outpath/lib"; then - echo "QMAKE_LFLAGS += -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib" >> "$CACHEFILE.tmp" + echo "QMAKE_LFLAGS = -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib \$\$QMAKE_LFLAGS" >> "$CACHEFILE.tmp" fi if [ -n "$QT_CFLAGS_PSQL" ]; then -- cgit v0.12 From ab4dde176cfa314522964e5e5fbf9f2d388f8fdf Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 29 Jun 2010 09:29:29 +0300 Subject: Do not crash if addrinfo signal does not contain ip address information. Fixes: NB#176643 - Segmentation fault occurs while using networking Reviewed-by: Adrian Constantin --- src/plugins/bearer/icd/qnetworksession_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp index e375b4f..aeac620 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.cpp +++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp @@ -620,6 +620,9 @@ static QString get_network_interface() return iface; } + if (addr_results.first().ip_info.isEmpty()) + return QString(); + const char *address = addr_results.first().ip_info.first().address.toAscii().constData(); struct in_addr addr; if (inet_aton(address, &addr) == 0) { -- cgit v0.12 From bba06aacb84b5ae9fc286345e721cab639db35c8 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 18:20:49 +0200 Subject: Doc: Added license documentation for 3rd party code and data. Task-number: QT-3585 Pre-approved-by: Legal Reviewed-by: Trust Me --- doc/src/legal/3rdparty.qdoc | 234 +++++++++++++++++++++++++++++++++++++++++--- doc/src/legal/licenses.qdoc | 49 +++++++++- 2 files changed, 267 insertions(+), 16 deletions(-) diff --git a/doc/src/legal/3rdparty.qdoc b/doc/src/legal/3rdparty.qdoc index 110dac7..e7133e3 100644 --- a/doc/src/legal/3rdparty.qdoc +++ b/doc/src/legal/3rdparty.qdoc @@ -194,16 +194,16 @@ \hr copyright (C) 1999 by Willem van Schaik - + version 1.0 - 1999.10.15 - First version. - + Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. - + \hr Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. @@ -293,7 +293,7 @@ Copyright (c) 1987, 1993, 1994\br The Regents of the University of California. All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\br @@ -305,7 +305,7 @@ 3. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 @@ -336,7 +336,7 @@ Copyright (C) 2004, Andrey Kiselev \br Copyright (c( 1996 USAF Phillips Laboratory\br Additions (c) Richard Nolde 2006-2009 - + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in @@ -344,11 +344,11 @@ Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics. - + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - + IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, @@ -360,11 +360,11 @@ Copyright (c) 1985, 1986 The Regents of the University of California.\br All rights reserved. - + This code is derived from software contributed to Berkeley by James A. Woods, derived from original work by Spencer Thomas and Joseph Orost. - + Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, @@ -381,7 +381,7 @@ Copyright (c) 1996-1997 Sam Leffler\br Copyright (c) 1996 Pixar - + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in @@ -389,11 +389,11 @@ Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Pixar, Sam Leffler and Silicon Graphics. - + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - + IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, @@ -423,8 +423,6 @@ \section1 JavaScriptCore - \hr - Copyright (c) 1991, 2000, 2001 by Lucent Technologies.\br Copyright (C) 2002, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. @@ -441,6 +439,60 @@ See \c src/3rdparty/webkit/JavaScriptCore/wtf/dtoa.cpp for license details. + \hr + + Copyright (C) 2009 Company 100, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met:\br + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + + \hr + + Copyright (C) 2009 Apple Inc. All rights reserved.\br + Copyright (C) 2009 University of Szeged\br + All rights reserved.\br + Copyright (C) 2010 MIPS Technologies, Inc. All rights reserved.\br + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met:\br + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY MIPS TECHNOLOGIES, INC. ``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 MIPS TECHNOLOGIES, INC. 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. + + \section1 Pixman (\c pixman) version 0.17.11 \e{pixman is a library that provides low-level pixel manipulation @@ -479,4 +531,156 @@ See \c src/3rdparty/pixman/pixman-arm-neon-asm.h and \c src/3rdparty/pixman/pixman-arm-neon-asm.S + + \section1 WebCore (WebKit) + + Copyright (C) 2009 Ericsson AB\br + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution.\br + 3. Neither the name of Ericsson 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. + + \hr + + Copyright (C) 2004, Apple Computer, Inc. and The Mozilla Foundation.\br + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution.\br + 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla + Foundation ("Mozilla") nor the names of their contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR 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 APPLE, MOZILLA OR + THEIR 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. + + \hr + + Copyright (C) 2009 Igalia S.L.\br + Copyright (C) 2009 Antonio Gomes \br + Copyright (C) 2008 Christian Dywan \br + Copyright (C) 2007 Nicholas Shanks \br + Copyright (C) 2006 Charles Samuels \br + Copyright (C) 2009 Dominik Röttsches \br + Copyright (C) 2009 Brent Fulgham\br + Copyright (C) 2009 Girish Ramakrishnan \br + Copyright (C) 2006 Alexander Kellett \br + Copyright (C) 2009 Cameron McCormack \br + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met:\br + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + + \hr + + Copyright (C) 2007, 2008 Apple Inc. All rights reserved.\br + Copyright (C) IBM Corp. 2009 All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution.\br + 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission.\br + + THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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. + + \hr + + Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.\br + Copyright (C) 2010 François Sausset (sausset@gmail.com). All rights reserved\br + Copyright (C) 2007 Marius Renn All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met:\br + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 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. */ diff --git a/doc/src/legal/licenses.qdoc b/doc/src/legal/licenses.qdoc index 96d5d29..a04a256 100644 --- a/doc/src/legal/licenses.qdoc +++ b/doc/src/legal/licenses.qdoc @@ -328,7 +328,7 @@ 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. - + \list \o Parts of WebKit used by the QtWebKit module \endlist @@ -716,6 +716,53 @@ \list \o Parts of WebKit used by the QtWebKit module \endlist + + \hr + + Copyright (c) 1991-2009 Unicode, Inc. All rights reserved. + Distributed under the Terms of Use in + http://www.unicode.org/copyright.html. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of the Unicode data files and any associated + documentation (the "Data Files") or Unicode software and any + associated documentation (the "Software") to deal in the Data + Files or Software without restriction, including without + limitation the rights to use, copy, modify, merge, publish, + distribute, and/or sell copies of the Data Files or Software, + and to permit persons to whom the Data Files or Software are + furnished to do so, provided that (a) the above copyright + notice(s) and this permission notice appear with all copies + of the Data Files or Software, (b) both the above copyright + notice(s) and this permission notice appear in associated + documentation, and (c) there is clear notice in each modified + Data File or in the Software as well as in the documentation + associated with the Data File(s) or Software that the data or + software has been modified. + + THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT + WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED + IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES + OR SOFTWARE. + + Except as contained in this notice, the name of a copyright + holder shall not be used in advertising or otherwise to promote + the sale, use or other dealings in these Data Files or Software + without prior written authorization of the copyright holder. + + \list + \o Included in \c{util/unicode/data}, + \c{tests/auto/qtextboundaryfinder/data} and + \c{tests/auto/qchar} + \o Parts of the \l makeqpf tool + \endlist */ /*! -- cgit v0.12 From 3c11c0a8f2a99cb3734a24d9d6c43977807471d7 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 16 Jul 2010 20:32:38 +0200 Subject: Used aligned load and store when possible for the blending of ARGB32 Unaligned load and store can be costly. This patch mitigate the problem by aligning the destination before using SSE2. The destination is aligned because it is used by load and store, while the source is only use by load. On Atom, the blending test is 7% faster for ARGB32. Reviewed-by: Andreas Kling --- src/gui/painting/qdrawingprimitive_sse2_p.h | 34 ++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 3c96946..65292bc 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -43,6 +43,7 @@ #define QDRAWINGPRIMITIVE_SSE2_P_H #include +#include #ifdef QT_HAVE_SSE2 @@ -141,12 +142,24 @@ QT_BEGIN_NAMESPACE // with shortcuts if fully opaque or fully transparent. #define BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, length, nullVector, half, one, colorMask, alphaMask) { \ int x = 0; \ +\ + /* First, get dst aligned. */ \ + const int offsetToAlignOn16Bytes = (4 - (reinterpret_cast(dst) >> 2 & 0x3)) & 0x3;\ + const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ + for (; x < prologLength; ++x) { \ + uint s = src[x]; \ + if (s >= 0xff000000) \ + dst[x] = s; \ + else if (s != 0) \ + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ + } \ +\ for (; x < length-3; x += 4) { \ const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { \ /* all opaque */ \ - _mm_storeu_si128((__m128i *)&dst[x], srcVector); \ + _mm_store_si128((__m128i *)&dst[x], srcVector); \ } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) { \ /* not fully transparent */ \ /* extract the alpha channel on 2 x 16 bits */ \ @@ -157,13 +170,13 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ /* result = s + d * (1-alpha) */\ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_storeu_si128((__m128i *)&dst[x], result); \ + _mm_store_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ @@ -189,6 +202,17 @@ QT_BEGIN_NAMESPACE #define BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, length, nullVector, half, one, colorMask, constAlphaVector) \ { \ int x = 0; \ +\ + const int offsetToAlignOn16Bytes = (4 - (reinterpret_cast(dst) >> 2 & 0x3)) & 0x3;\ + const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ + for (; x < prologLength; ++x) { \ + uint s = src[x]; \ + if (s >= 0xff000000) \ + dst[x] = s; \ + else if (s != 0) \ + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ + } \ +\ for (; x < length-3; x += 4) { \ __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { \ @@ -198,12 +222,12 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_storeu_si128((__m128i *)&dst[x], result); \ + _mm_store_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ -- cgit v0.12 From 956081702b5701ec570085174878a264c86c136b Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Sat, 17 Jul 2010 12:08:52 +1000 Subject: Rebuild configure.exe. --- configure.exe | Bin 1318912 -> 1318400 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 6817331..0863ecc 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 0e74ba543228b541394b95b477008aaea89549c1 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Sat, 17 Jul 2010 12:49:42 +1000 Subject: Revert "Used aligned load and store when possible for the blending of ARGB32" This reverts commit 3c11c0a8f2a99cb3734a24d9d6c43977807471d7, which breaks compilation on some platforms. --- src/gui/painting/qdrawingprimitive_sse2_p.h | 34 +++++------------------------ 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 65292bc..3c96946 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -43,7 +43,6 @@ #define QDRAWINGPRIMITIVE_SSE2_P_H #include -#include #ifdef QT_HAVE_SSE2 @@ -142,24 +141,12 @@ QT_BEGIN_NAMESPACE // with shortcuts if fully opaque or fully transparent. #define BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, length, nullVector, half, one, colorMask, alphaMask) { \ int x = 0; \ -\ - /* First, get dst aligned. */ \ - const int offsetToAlignOn16Bytes = (4 - (reinterpret_cast(dst) >> 2 & 0x3)) & 0x3;\ - const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ - for (; x < prologLength; ++x) { \ - uint s = src[x]; \ - if (s >= 0xff000000) \ - dst[x] = s; \ - else if (s != 0) \ - dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ - } \ -\ for (; x < length-3; x += 4) { \ const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { \ /* all opaque */ \ - _mm_store_si128((__m128i *)&dst[x], srcVector); \ + _mm_storeu_si128((__m128i *)&dst[x], srcVector); \ } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) { \ /* not fully transparent */ \ /* extract the alpha channel on 2 x 16 bits */ \ @@ -170,13 +157,13 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ /* result = s + d * (1-alpha) */\ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_store_si128((__m128i *)&dst[x], result); \ + _mm_storeu_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ @@ -202,17 +189,6 @@ QT_BEGIN_NAMESPACE #define BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, length, nullVector, half, one, colorMask, constAlphaVector) \ { \ int x = 0; \ -\ - const int offsetToAlignOn16Bytes = (4 - (reinterpret_cast(dst) >> 2 & 0x3)) & 0x3;\ - const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ - for (; x < prologLength; ++x) { \ - uint s = src[x]; \ - if (s >= 0xff000000) \ - dst[x] = s; \ - else if (s != 0) \ - dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ - } \ -\ for (; x < length-3; x += 4) { \ __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { \ @@ -222,12 +198,12 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_store_si128((__m128i *)&dst[x], result); \ + _mm_storeu_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ -- cgit v0.12 From 11c80193772b51575a8c59d59215a8b9523647ea Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Sat, 17 Jul 2010 16:50:25 +1000 Subject: Remove license headers from .pro files in new modelview examples. This commit attempts to fix the latest staging failure. According to Nokia Legal, .pro files are not copyrightable and thus need not carry license headers. In any case, C-style comments aren't valid for .pro files and broke the build. --- .../tutorials/modelview/1_readonly/1_readonly.pro | 40 ---------------------- .../modelview/2_formatting/2_formatting.pro | 40 ---------------------- .../modelview/3_changingmodel/3_changingmodel.pro | 40 ---------------------- .../tutorials/modelview/4_headers/4_headers.pro | 40 ---------------------- examples/tutorials/modelview/5_edit/5_edit.pro | 40 ---------------------- .../tutorials/modelview/6_treeview/6_treeview.pro | 40 ---------------------- .../modelview/7_selections/7_selections.pro | 40 ---------------------- 7 files changed, 280 deletions(-) diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro index 8528cde..1162d5a 100755 --- a/examples/tutorials/modelview/1_readonly/1_readonly.pro +++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_readonly TEMPLATE = app diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro index cdf72bf..7e70d81 100755 --- a/examples/tutorials/modelview/2_formatting/2_formatting.pro +++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_formatting TEMPLATE = app diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro index 8b217cb..d61ee4c 100755 --- a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro +++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_changingmodel TEMPLATE = app diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro index 13b0b1d..d6f8d23 100755 --- a/examples/tutorials/modelview/4_headers/4_headers.pro +++ b/examples/tutorials/modelview/4_headers/4_headers.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_headers TEMPLATE = app diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro index d0a2571..e18c596 100755 --- a/examples/tutorials/modelview/5_edit/5_edit.pro +++ b/examples/tutorials/modelview/5_edit/5_edit.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_edit TEMPLATE = app diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro index fa27c3a..6d078be 100755 --- a/examples/tutorials/modelview/6_treeview/6_treeview.pro +++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_tree TEMPLATE = app SOURCES += main.cpp \ diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro index 671dc24..952641c6 100755 --- a/examples/tutorials/modelview/7_selections/7_selections.pro +++ b/examples/tutorials/modelview/7_selections/7_selections.pro @@ -1,43 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - TARGET = mv_selections TEMPLATE = app SOURCES += main.cpp \ -- cgit v0.12 From 9427b4c8f3b557524cda3f72cf81f68940cb7246 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 16 Jul 2010 20:32:38 +0200 Subject: Used aligned load and store when possible for the blending of ARGB32 Unaligned load and store can be costly. This patch mitigate the problem by aligning the destination before using SSE2. The destination is aligned because it is used by load and store, while the source is only use by load. On Atom, the blending test is 7% faster for ARGB32. Re-pushing that patch, thanks to awesome policies... Reviewed-by: Andreas Kling --- src/gui/painting/qdrawingprimitive_sse2_p.h | 33 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 3c96946..b1f8306 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -141,12 +141,24 @@ QT_BEGIN_NAMESPACE // with shortcuts if fully opaque or fully transparent. #define BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, length, nullVector, half, one, colorMask, alphaMask) { \ int x = 0; \ +\ + /* First, get dst aligned. */ \ + const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3;\ + const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ + for (; x < prologLength; ++x) { \ + uint s = src[x]; \ + if (s >= 0xff000000) \ + dst[x] = s; \ + else if (s != 0) \ + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ + } \ +\ for (; x < length-3; x += 4) { \ const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { \ /* all opaque */ \ - _mm_storeu_si128((__m128i *)&dst[x], srcVector); \ + _mm_store_si128((__m128i *)&dst[x], srcVector); \ } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) { \ /* not fully transparent */ \ /* extract the alpha channel on 2 x 16 bits */ \ @@ -157,13 +169,13 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ /* result = s + d * (1-alpha) */\ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_storeu_si128((__m128i *)&dst[x], result); \ + _mm_store_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ @@ -189,6 +201,17 @@ QT_BEGIN_NAMESPACE #define BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, length, nullVector, half, one, colorMask, constAlphaVector) \ { \ int x = 0; \ +\ + const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3;\ + const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ + for (; x < prologLength; ++x) { \ + uint s = src[x]; \ + if (s >= 0xff000000) \ + dst[x] = s; \ + else if (s != 0) \ + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ + } \ +\ for (; x < length-3; x += 4) { \ __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); \ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { \ @@ -198,12 +221,12 @@ QT_BEGIN_NAMESPACE alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ alphaChannel = _mm_sub_epi16(one, alphaChannel); \ \ - const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ __m128i destMultipliedByOneMinusAlpha; \ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ \ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ - _mm_storeu_si128((__m128i *)&dst[x], result); \ + _mm_store_si128((__m128i *)&dst[x], result); \ } \ } \ for (; x < length; ++x) { \ -- cgit v0.12 From 23ea4340a622cbfed81eb7afb2e09ec64b0ebef8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 18 Jul 2010 07:30:35 +0200 Subject: Corrected BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2 The unaligned prologue was processed without using the const alpha. Regressed with 9427b4c8f3b5. --- src/gui/painting/qdrawingprimitive_sse2_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index b1f8306..18355c2 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -205,11 +205,11 @@ QT_BEGIN_NAMESPACE const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3;\ const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ for (; x < prologLength; ++x) { \ - uint s = src[x]; \ - if (s >= 0xff000000) \ - dst[x] = s; \ - else if (s != 0) \ + quint32 s = src[x]; \ + if (s != 0) { \ + s = BYTE_MUL(s, const_alpha); \ dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \ + } \ } \ \ for (; x < length-3; x += 4) { \ -- cgit v0.12 From c6812138900b05012831e0f94d7d00aeac86cc2f Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 18 Jul 2010 23:05:44 +0200 Subject: Remove qMemCopy() usage from all .cpp files of Qt itself. This is (supposedly) more efficient as the compiler can optimise it to a builtin, per Thiago. Merge-request: 2430 Reviewed-by: Andreas Kling --- src/corelib/tools/qbytearray.cpp | 6 +++--- src/corelib/tools/qbytearraymatcher.cpp | 2 +- src/corelib/tools/qstring.cpp | 6 +++--- src/corelib/tools/qstringmatcher.cpp | 2 +- src/gui/text/qfontengine_s60.cpp | 4 ++-- src/gui/text/qstatictext.cpp | 12 ++++++------ src/gui/text/qtextdocument_p.cpp | 2 +- tests/auto/compiler/tst_compiler.cpp | 2 +- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 2 +- tools/makeqpf/qpf2.cpp | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index b46af1f..a5cb16a 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -2152,18 +2152,18 @@ QByteArray QByteArray::repeated(int times) const if (result.d->alloc != resultSize) return QByteArray(); // not enough memory - qMemCopy(result.d->data, d->data, d->size); + memcpy(result.d->data, d->data, d->size); int sizeSoFar = d->size; char *end = result.d->data + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - qMemCopy(end, result.d->data, sizeSoFar); + memcpy(end, result.d->data, sizeSoFar); end += sizeSoFar; sizeSoFar <<= 1; } - qMemCopy(end, result.d->data, resultSize - sizeSoFar); + memcpy(end, result.d->data, resultSize - sizeSoFar); result.d->data[resultSize] = '\0'; result.d->size = resultSize; return result; diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index d5a59c9..f8504f0 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -171,7 +171,7 @@ QByteArrayMatcher::~QByteArrayMatcher() QByteArrayMatcher &QByteArrayMatcher::operator=(const QByteArrayMatcher &other) { q_pattern = other.q_pattern; - qMemCopy(&p, &other.p, sizeof(p)); + memcpy(&p, &other.p, sizeof(p)); return *this; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b2cf49b..b5651de 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6156,18 +6156,18 @@ QString QString::repeated(int times) const if (result.d->alloc != resultSize) return QString(); // not enough memory - qMemCopy(result.d->data, d->data, d->size * sizeof(ushort)); + memcpy(result.d->data, d->data, d->size * sizeof(ushort)); int sizeSoFar = d->size; ushort *end = result.d->data + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - qMemCopy(end, result.d->data, sizeSoFar * sizeof(ushort)); + memcpy(end, result.d->data, sizeSoFar * sizeof(ushort)); end += sizeSoFar; sizeSoFar <<= 1; } - qMemCopy(end, result.d->data, (resultSize - sizeSoFar) * sizeof(ushort)); + memcpy(end, result.d->data, (resultSize - sizeSoFar) * sizeof(ushort)); result.d->data[resultSize] = '\0'; result.d->size = resultSize; return result; diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp index ff13624..80a8457 100644 --- a/src/corelib/tools/qstringmatcher.cpp +++ b/src/corelib/tools/qstringmatcher.cpp @@ -208,7 +208,7 @@ QStringMatcher &QStringMatcher::operator=(const QStringMatcher &other) if (this != &other) { q_pattern = other.q_pattern; q_cs = other.q_cs; - qMemCopy(q_data, other.q_data, sizeof(q_data)); + memcpy(q_data, other.q_data, sizeof(q_data)); } return *this; } diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index f691413..74ef646 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -94,7 +94,7 @@ bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *len } else { *length = tableByteLength; if (buffer) - qMemCopy(buffer, fontTable.TableContent(), tableByteLength); + memcpy(buffer, fontTable.TableContent(), tableByteLength); } fontTable.Close(); @@ -146,7 +146,7 @@ bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *len } else { *length = tableByteLength; if (buffer) - qMemCopy(buffer, table, tableByteLength); + memcpy(buffer, table, tableByteLength); } m_trueTypeExtension->ReleaseTrueTypeTable(table); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 91a6612..ab518d0 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -465,13 +465,13 @@ namespace { m_chars.resize(m_chars.size() + ti.num_chars); glyph_t *glyphsDestination = m_glyphs.data() + currentItem.glyphOffset; - qMemCopy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * currentItem.numGlyphs); + memcpy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * currentItem.numGlyphs); QFixedPoint *positionsDestination = m_positions.data() + currentItem.positionOffset; - qMemCopy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * currentItem.numGlyphs); + memcpy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * currentItem.numGlyphs); QChar *charsDestination = m_chars.data() + currentItem.charOffset; - qMemCopy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); + memcpy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); m_items.append(currentItem); } @@ -681,13 +681,13 @@ void QStaticTextPrivate::init() items = new QStaticTextItem[itemCount]; glyphPool = new glyph_t[glyphs.size()]; - qMemCopy(glyphPool, glyphs.constData(), glyphs.size() * sizeof(glyph_t)); + memcpy(glyphPool, glyphs.constData(), glyphs.size() * sizeof(glyph_t)); positionPool = new QFixedPoint[positions.size()]; - qMemCopy(positionPool, positions.constData(), positions.size() * sizeof(QFixedPoint)); + memcpy(positionPool, positions.constData(), positions.size() * sizeof(QFixedPoint)); charPool = new QChar[chars.size()]; - qMemCopy(charPool, chars.constData(), chars.size() * sizeof(QChar)); + memcpy(charPool, chars.constData(), chars.size() * sizeof(QChar)); for (int i=0; istringPosition, it->size_array[0] * sizeof(QChar)); + memcpy(newTextPtr, text.constData() + it->stringPosition, it->size_array[0] * sizeof(QChar)); it->stringPosition = newLen; newTextPtr += it->size_array[0]; newLen += it->size_array[0]; diff --git a/tests/auto/compiler/tst_compiler.cpp b/tests/auto/compiler/tst_compiler.cpp index 368620d..90eb357 100644 --- a/tests/auto/compiler/tst_compiler.cpp +++ b/tests/auto/compiler/tst_compiler.cpp @@ -640,7 +640,7 @@ static inline double qt_inf() #endif union { uchar c[8]; double d; } returnValue; - qMemCopy(returnValue.c, bytes, sizeof(returnValue.c)); + memcpy(returnValue.c, bytes, sizeof(returnValue.c)); return returnValue.d; } diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index dcbbf2c..221e1b8 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -101,7 +101,7 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) TRACE_OBJ qint64 len = qMin(qint64(data.length()), maxlen); if (len) { - qMemCopy(buffer, data.constData(), len); + memcpy(buffer, data.constData(), len); data.remove(0, len); } if (!data.length()) diff --git a/tools/makeqpf/qpf2.cpp b/tools/makeqpf/qpf2.cpp index ab57cea..cafdb79 100644 --- a/tools/makeqpf/qpf2.cpp +++ b/tools/makeqpf/qpf2.cpp @@ -543,7 +543,7 @@ void QPF::addGlyphs(QFontEngine *fe, const QList &ranges) ; } - qMemCopy(data, img.bits(), img.byteCount()); + memcpy(data, img.bits(), img.byteCount()); } } } -- cgit v0.12 From d191c5bd1d0e3963dc8a4f3ffdba80af0800ec22 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 13 Jul 2010 16:53:27 +1000 Subject: Fix build on Symbian. --- examples/network/network-chat/chatdialog.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index 14fabaa..2bab535 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -53,9 +53,6 @@ ChatDialog::ChatDialog(QWidget *parent) listWidget->setFocusPolicy(Qt::NoFocus); connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); -#ifdef Q_OS_SYMBIAN - connect(sendButton, SIGNAL(clicked()), this, SLOT(returnPressed())); -#endif connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(&client, SIGNAL(newMessage(QString,QString)), this, SLOT(appendMessage(QString,QString))); -- cgit v0.12 From 192a3c6d69b42f02aa9033c30502a6930cceb8f7 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 12 Jul 2010 15:12:48 +1000 Subject: Fixes deployment rules for embedded qml demos application. The deployment rules for the qml resources in the embedded qml demo applications were not being generated correctly as data_caging_paths was not being loaded. --- demos/embedded/qmlcalculator/deployment.pri | 1 + demos/embedded/qmlclocks/deployment.pri | 1 + demos/embedded/qmldialcontrol/deployment.pri | 1 + demos/embedded/qmleasing/deployment.pri | 1 + demos/embedded/qmlflickr/deployment.pri | 1 + demos/embedded/qmlphotoviewer/deployment.pri | 1 + demos/embedded/qmltwitter/deployment.pri | 1 + 7 files changed, 7 insertions(+) diff --git a/demos/embedded/qmlcalculator/deployment.pri b/demos/embedded/qmlcalculator/deployment.pri index 53c6dbf..a31303d 100644 --- a/demos/embedded/qmlcalculator/deployment.pri +++ b/demos/embedded/qmlcalculator/deployment.pri @@ -1,5 +1,6 @@ qmlcalculator_src = $$PWD/../../declarative/calculator symbian { + load(data_caging_paths) qmlcalculator_uid3 = A000E3FB qmlcalculator_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlcalculator_uid3 } diff --git a/demos/embedded/qmlclocks/deployment.pri b/demos/embedded/qmlclocks/deployment.pri index 03ba129..0946733 100644 --- a/demos/embedded/qmlclocks/deployment.pri +++ b/demos/embedded/qmlclocks/deployment.pri @@ -1,5 +1,6 @@ qmlclocks_src = $$PWD/../../../examples/declarative/toys/clocks symbian { + load(data_caging_paths) qmlclocks_uid3 = A000E3FC qmlclocks_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlclocks_uid3 } diff --git a/demos/embedded/qmldialcontrol/deployment.pri b/demos/embedded/qmldialcontrol/deployment.pri index 097c74c..e0e72e6 100644 --- a/demos/embedded/qmldialcontrol/deployment.pri +++ b/demos/embedded/qmldialcontrol/deployment.pri @@ -1,5 +1,6 @@ qmldialcontrol_src = $$PWD/../../../examples/declarative/ui-components/dialcontrol symbian { + load(data_caging_paths) qmldialcontrol_uid3 = A000E3FD qmldialcontrol_files.path = $$APP_PRIVATE_DIR_BASE/$$qmldialcontrol_uid3 } diff --git a/demos/embedded/qmleasing/deployment.pri b/demos/embedded/qmleasing/deployment.pri index 47192e6..984f5c8 100644 --- a/demos/embedded/qmleasing/deployment.pri +++ b/demos/embedded/qmleasing/deployment.pri @@ -1,5 +1,6 @@ qmleasing_src = $$PWD/../../../examples/declarative/animation/easing symbian { + load(data_caging_paths) qmleasing_uid3 = A000E3FE qmleasing_files.path = $$APP_PRIVATE_DIR_BASE/$$qmleasing_uid3 } diff --git a/demos/embedded/qmlflickr/deployment.pri b/demos/embedded/qmlflickr/deployment.pri index c8fef1a..b508292 100644 --- a/demos/embedded/qmlflickr/deployment.pri +++ b/demos/embedded/qmlflickr/deployment.pri @@ -1,5 +1,6 @@ qmlflickr_src = $$PWD/../../declarative/flickr symbian { + load(data_caging_paths) qmlflickr_uid3 = A000E3FF qmlflickr_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlflickr_uid3 } diff --git a/demos/embedded/qmlphotoviewer/deployment.pri b/demos/embedded/qmlphotoviewer/deployment.pri index 128a1f7..35937a8 100644 --- a/demos/embedded/qmlphotoviewer/deployment.pri +++ b/demos/embedded/qmlphotoviewer/deployment.pri @@ -1,5 +1,6 @@ qmlphotoviewer_src = $$PWD/../../declarative/photoviewer symbian { + load(data_caging_paths) qmlphotoviewer_uid3 = A000E400 qmlphotoviewer_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlphotoviewer_uid3 } diff --git a/demos/embedded/qmltwitter/deployment.pri b/demos/embedded/qmltwitter/deployment.pri index 40c53ad..4404e33 100644 --- a/demos/embedded/qmltwitter/deployment.pri +++ b/demos/embedded/qmltwitter/deployment.pri @@ -1,5 +1,6 @@ qmltwitter_src = $$PWD/../../declarative/twitter symbian { + load(data_caging_paths) qmltwitter_uid3 = A000E401 qmltwitter_files.path = $$APP_PRIVATE_DIR_BASE/$$qmltwitter_uid3 } -- cgit v0.12 From 75db37022a9fd479e2a446b57e774eaf8e3e73ea Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 7 Jul 2010 16:28:45 +1000 Subject: Convert examples and demos to use Bearer Management. Task-number: QTBUG-10439 --- demos/embedded/anomaly/anomaly.pro | 2 - demos/embedded/anomaly/src/BrowserView.cpp | 33 +- demos/embedded/anomaly/src/BrowserView.h | 3 - demos/embedded/lightmaps/lightmaps.cpp | 49 ++- demos/embedded/lightmaps/lightmaps.pro | 2 - demos/embedded/qmlflickr/qmlflickr.cpp | 63 +-- demos/embedded/qmlflickr/qmlflickr.pro | 2 - demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp | 63 +-- demos/embedded/qmlphotoviewer/qmlphotoviewer.pro | 2 - demos/embedded/qmltwitter/qmltwitter.cpp | 63 +-- demos/embedded/qmltwitter/qmltwitter.pro | 2 - examples/network/fortuneclient/client.cpp | 65 ++- examples/network/fortuneclient/client.h | 7 +- examples/network/fortuneclient/fortuneclient.pro | 2 - examples/network/fortuneserver/fortuneserver.pro | 2 - examples/network/fortuneserver/main.cpp | 7 - examples/network/fortuneserver/server.cpp | 96 +++-- examples/network/fortuneserver/server.h | 3 + examples/network/network-chat/main.cpp | 48 ++- examples/network/network-chat/network-chat.pro | 2 - examples/network/qftp/ftpwindow.cpp | 56 ++- examples/network/qftp/ftpwindow.h | 6 +- examples/network/qftp/qftp.pro | 2 - examples/network/qftp/sym_iap_util.h | 519 ----------------------- 24 files changed, 388 insertions(+), 711 deletions(-) delete mode 100644 examples/network/qftp/sym_iap_util.h diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 584e5cd..a786b46 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -26,8 +26,6 @@ RESOURCES += src/anomaly.qrc symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp index a6e6f7a..73d0b70 100644 --- a/demos/embedded/anomaly/src/BrowserView.cpp +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -51,10 +51,6 @@ #include "webview.h" #include "ZoomStrip.h" -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - BrowserView::BrowserView(QWidget *parent) : QWidget(parent) , m_titleBar(0) @@ -71,6 +67,26 @@ BrowserView::BrowserView(QWidget *parent) m_zoomLevels << 100; m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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(); + } + + m_webView->page()->networkAccessManager()->setConfiguration(config); + } + QTimer::singleShot(0, this, SLOT(initialize())); } @@ -100,9 +116,6 @@ void BrowserView::initialize() m_webView->setHtml("about:blank"); m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_webView->setFocus(); -#ifdef Q_OS_SYMBIAN - QTimer::singleShot(0, this, SLOT(setDefaultIap())); -#endif } void BrowserView::start() @@ -173,12 +186,6 @@ void BrowserView::resizeEvent(QResizeEvent *event) int zh = m_zoomStrip->sizeHint().height(); m_zoomStrip->move(width() - zw, (height() - zh) / 2); } -#ifdef Q_OS_SYMBIAN -void BrowserView::setDefaultIap() -{ - qt_SetDefaultIap(); -} -#endif void BrowserView::navigate(const QUrl &url) { diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h index 5ab1dd7..8981582 100644 --- a/demos/embedded/anomaly/src/BrowserView.h +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -63,9 +63,6 @@ public slots: void navigate(const QUrl &url); void zoomIn(); void zoomOut(); -#ifdef Q_OS_SYMBIAN - void setDefaultIap(); -#endif private slots: void initialize(); diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp index c76aed0..2eb1733 100644 --- a/demos/embedded/lightmaps/lightmaps.cpp +++ b/demos/embedded/lightmaps/lightmaps.cpp @@ -43,10 +43,6 @@ #include #include -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - #include #ifndef M_PI @@ -490,6 +486,7 @@ class MapZoom : public QMainWindow private: LightMaps *map; + QNetworkSession *networkSession; public: MapZoom(): QMainWindow(0) { @@ -526,15 +523,49 @@ public: menu->addAction(osmAction); #endif - QTimer::singleShot(0, this, SLOT(delayedInit())); + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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, SIGNAL(opened()), this, SLOT(sessionOpened())); + + networkSession->open(); + } else { + networkSession = 0; + } } private slots: - void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif + void 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("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); } void chooseOslo() { diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro index ee4cc5a..9d83721 100644 --- a/demos/embedded/lightmaps/lightmaps.pro +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -5,8 +5,6 @@ QT += network symbian { TARGET.UID3 = 0xA000CF75 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/qmlflickr/qmlflickr.cpp b/demos/embedded/qmlflickr/qmlflickr.cpp index 6f0c528..7068f88 100644 --- a/demos/embedded/qmlflickr/qmlflickr.cpp +++ b/demos/embedded/qmlflickr/qmlflickr.cpp @@ -40,41 +40,59 @@ ****************************************************************************/ #include +#include #include #include #include +#include +#include +#include +#include -#if defined(Q_OS_SYMBIAN) -#include -#include -#include "sym_iap_util.h" - -class QmlAppView : public QDeclarativeView +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory { -Q_OBJECT public: - QmlAppView(QWidget *parent = 0) - : QDeclarativeView(parent) - { - QTimer::singleShot(0, this, SLOT(setDefaultIap())); - } + ~NetworkAccessManagerFactory() { } -private slots: - void setDefaultIap() - { - qt_SetDefaultIap(); - } + QNetworkAccessManager *create(QObject *parent); }; -#else // Q_OS_SYMBIAN -typedef QDeclarativeView QmlAppView; -#endif // Q_OS_SYMBIAN + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} int main(int argc, char *argv[]) { QApplication application(argc, argv); + NetworkAccessManagerFactory networkAccessManagerFactory; + const QString mainQmlApp = QLatin1String("flickr.qml"); - QmlAppView view; + QDeclarativeView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); @@ -87,6 +105,3 @@ int main(int argc, char *argv[]) return application.exec(); } -#if defined(Q_OS_SYMBIAN) -#include "qmlflickr.moc" -#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmlflickr/qmlflickr.pro b/demos/embedded/qmlflickr/qmlflickr.pro index e706134..39b316a 100644 --- a/demos/embedded/qmlflickr/qmlflickr.pro +++ b/demos/embedded/qmlflickr/qmlflickr.pro @@ -7,8 +7,6 @@ include($$PWD/deployment.pri) symbian { TARGET.UID3 = 0x$$qmlflickr_uid3 # defined in deployment.pri include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp index 7889842..2b9db5e 100644 --- a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp +++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp @@ -40,41 +40,59 @@ ****************************************************************************/ #include +#include #include #include #include +#include +#include +#include +#include -#if defined(Q_OS_SYMBIAN) -#include -#include -#include "sym_iap_util.h" - -class QmlAppView : public QDeclarativeView +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory { -Q_OBJECT public: - QmlAppView(QWidget *parent = 0) - : QDeclarativeView(parent) - { - QTimer::singleShot(0, this, SLOT(setDefaultIap())); - } + ~NetworkAccessManagerFactory() { } -private slots: - void setDefaultIap() - { - qt_SetDefaultIap(); - } + QNetworkAccessManager *create(QObject *parent); }; -#else // Q_OS_SYMBIAN -typedef QDeclarativeView QmlAppView; -#endif // Q_OS_SYMBIAN + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} int main(int argc, char *argv[]) { QApplication application(argc, argv); + NetworkAccessManagerFactory networkAccessManagerFactory; + const QString mainQmlApp = QLatin1String("photoviewer.qml"); - QmlAppView view; + QDeclarativeView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); @@ -87,6 +105,3 @@ int main(int argc, char *argv[]) return application.exec(); } -#if defined(Q_OS_SYMBIAN) -#include "qmlphotoviewer.moc" -#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro index ead5e67..a4234cf 100644 --- a/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro +++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro @@ -7,8 +7,6 @@ include($$PWD/deployment.pri) symbian { TARGET.UID3 = 0x$$qmlphotoviewer_uid3 # defined in deployment.pri include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/qmltwitter/qmltwitter.cpp b/demos/embedded/qmltwitter/qmltwitter.cpp index e30ab24..c53098a4 100644 --- a/demos/embedded/qmltwitter/qmltwitter.cpp +++ b/demos/embedded/qmltwitter/qmltwitter.cpp @@ -40,41 +40,59 @@ ****************************************************************************/ #include +#include #include #include #include +#include +#include +#include +#include -#if defined(Q_OS_SYMBIAN) -#include -#include -#include "sym_iap_util.h" - -class QmlAppView : public QDeclarativeView +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory { -Q_OBJECT public: - QmlAppView(QWidget *parent = 0) - : QDeclarativeView(parent) - { - QTimer::singleShot(0, this, SLOT(setDefaultIap())); - } + ~NetworkAccessManagerFactory() { } -private slots: - void setDefaultIap() - { - qt_SetDefaultIap(); - } + QNetworkAccessManager *create(QObject *parent); }; -#else // Q_OS_SYMBIAN -typedef QDeclarativeView QmlAppView; -#endif // Q_OS_SYMBIAN + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} int main(int argc, char *argv[]) { QApplication application(argc, argv); + NetworkAccessManagerFactory networkAccessManagerFactory; + const QString mainQmlApp = QLatin1String("twitter.qml"); - QmlAppView view; + QDeclarativeView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); @@ -87,6 +105,3 @@ int main(int argc, char *argv[]) return application.exec(); } -#if defined(Q_OS_SYMBIAN) -#include "qmltwitter.moc" -#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmltwitter/qmltwitter.pro b/demos/embedded/qmltwitter/qmltwitter.pro index 7f9be57..7bd4617 100644 --- a/demos/embedded/qmltwitter/qmltwitter.pro +++ b/demos/embedded/qmltwitter/qmltwitter.pro @@ -7,8 +7,6 @@ include($$PWD/deployment.pri) symbian { TARGET.UID3 = 0x$$qmltwitter_uid3 # defined in deployment.pri include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index b9a85c4..fe35906 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -43,13 +43,9 @@ #include "client.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - //! [0] Client::Client(QWidget *parent) - : QDialog(parent) +: QDialog(parent), networkSession(0) { //! [0] hostLabel = new QLabel(tr("&Server name:")); @@ -121,9 +117,28 @@ Client::Client(QWidget *parent) setWindowTitle(tr("Fortune Client")); portLineEdit->setFocus(); -#ifdef Q_OS_SYMBIAN - isDefaultIapSet = false; -#endif + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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, SIGNAL(opened()), this, SLOT(sessionOpened())); + + getFortuneButton->setEnabled(false); + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } //! [5] } //! [5] @@ -132,12 +147,6 @@ Client::Client(QWidget *parent) void Client::requestNewFortune() { getFortuneButton->setEnabled(false); -#ifdef Q_OS_SYMBIAN - if(!isDefaultIapSet) { - qt_SetDefaultIap(); - isDefaultIapSet = true; - } -#endif blockSize = 0; tcpSocket->abort(); //! [7] @@ -214,6 +223,30 @@ void Client::displayError(QAbstractSocket::SocketError socketError) void Client::enableGetFortuneButton() { - getFortuneButton->setEnabled(!hostLineEdit->text().isEmpty() - && !portLineEdit->text().isEmpty()); + getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) && + !hostLineEdit->text().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("Trolltech")); + 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 50a9037..d0c0718 100644 --- a/examples/network/fortuneclient/client.h +++ b/examples/network/fortuneclient/client.h @@ -50,6 +50,7 @@ class QLabel; class QLineEdit; class QPushButton; class QTcpSocket; +class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -65,6 +66,7 @@ private slots: void readFortune(); void displayError(QAbstractSocket::SocketError socketError); void enableGetFortuneButton(); + void sessionOpened(); private: QLabel *hostLabel; @@ -79,9 +81,8 @@ private: QTcpSocket *tcpSocket; QString currentFortune; quint16 blockSize; -#ifdef Q_OS_SYMBIAN - bool isDefaultIapSet; -#endif + + QNetworkSession *networkSession; }; //! [0] diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro index edbf14d..f79679d 100644 --- a/examples/network/fortuneclient/fortuneclient.pro +++ b/examples/network/fortuneclient/fortuneclient.pro @@ -11,8 +11,6 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro index 474ec11..e13f309 100644 --- a/examples/network/fortuneserver/fortuneserver.pro +++ b/examples/network/fortuneserver/fortuneserver.pro @@ -12,8 +12,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "NetworkServices ReadUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneserver/main.cpp b/examples/network/fortuneserver/main.cpp index 29fe777..53149c0 100644 --- a/examples/network/fortuneserver/main.cpp +++ b/examples/network/fortuneserver/main.cpp @@ -45,15 +45,8 @@ #include "server.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - int main(int argc, char *argv[]) { -#ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); -#endif QApplication app(argc, argv); Server server; #ifdef Q_OS_SYMBIAN diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 98234e0..b931b96 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -46,12 +46,79 @@ #include "server.h" Server::Server(QWidget *parent) - : QDialog(parent) +: QDialog(parent), tcpServer(0), networkSession(0) { statusLabel = new QLabel; quitButton = new QPushButton(tr("Quit")); quitButton->setAutoDefault(false); + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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, SIGNAL(opened()), this, SLOT(sessionOpened())); + + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } else { + sessionOpened(); + } + + //! [2] + fortunes << tr("You've been leading a dog's life. Stay off the furniture.") + << tr("You've got to think about tomorrow.") + << tr("You will be surprised by a loud noise.") + << tr("You will feel hungry again in another hour.") + << tr("You might have mail.") + << tr("You cannot kill time without injuring eternity.") + << tr("Computers are not intelligent. They only think they are."); + //! [2] + + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + //! [3] + connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); + //! [3] + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(1); + buttonLayout->addWidget(quitButton); + buttonLayout->addStretch(1); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(statusLabel); + mainLayout->addLayout(buttonLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Fortune Server")); +} + +void Server::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("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + //! [0] //! [1] tcpServer = new QTcpServer(this); if (!tcpServer->listen()) { @@ -79,33 +146,6 @@ Server::Server(QWidget *parent) "Run the Fortune Client example now.") .arg(ipAddress).arg(tcpServer->serverPort())); //! [1] - -//! [2] - fortunes << tr("You've been leading a dog's life. Stay off the furniture.") - << tr("You've got to think about tomorrow.") - << tr("You will be surprised by a loud noise.") - << tr("You will feel hungry again in another hour.") - << tr("You might have mail.") - << tr("You cannot kill time without injuring eternity.") - << tr("Computers are not intelligent. They only think they are."); -//! [2] - - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); -//! [3] - connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); -//! [3] - - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(1); - buttonLayout->addWidget(quitButton); - buttonLayout->addStretch(1); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(statusLabel); - mainLayout->addLayout(buttonLayout); - setLayout(mainLayout); - - setWindowTitle(tr("Fortune Server")); } //! [4] diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h index 2d8d116..9d9ef62 100644 --- a/examples/network/fortuneserver/server.h +++ b/examples/network/fortuneserver/server.h @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE class QLabel; class QPushButton; class QTcpServer; +class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -58,6 +59,7 @@ public: Server(QWidget *parent = 0); private slots: + void sessionOpened(); void sendFortune(); private: @@ -65,6 +67,7 @@ private: QPushButton *quitButton; QTcpServer *tcpServer; QStringList fortunes; + QNetworkSession *networkSession; }; //! [0] diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index 7226217..e3db74b 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -41,16 +41,52 @@ #include #include "chatdialog.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif + +#include +#include +#include int main(int argc, char *argv[]) { -#ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); -#endif QApplication app(argc, argv); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + } + } + ChatDialog dialog; #ifdef Q_OS_SYMBIAN // Make application better looking and more usable on small screen diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro index 1215aea..b3d429e 100644 --- a/examples/network/network-chat/network-chat.pro +++ b/examples/network/network-chat/network-chat.pro @@ -20,8 +20,6 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection LIBS += -lcharconv TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp index 635b679..f39f9a0 100644 --- a/examples/network/qftp/ftpwindow.cpp +++ b/examples/network/qftp/ftpwindow.cpp @@ -43,12 +43,8 @@ #include "ftpwindow.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - FtpWindow::FtpWindow(QWidget *parent) - : QDialog(parent), ftp(0) + : QDialog(parent), ftp(0), networkSession(0) { ftpServerLabel = new QLabel(tr("Ftp &server:")); ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); @@ -118,9 +114,28 @@ FtpWindow::FtpWindow(QWidget *parent) mainLayout->addWidget(buttonBox); setLayout(mainLayout); -#ifdef Q_OS_SYMBIAN - bDefaultIapSet = false; -#endif + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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, SIGNAL(opened()), this, SLOT(enableConnectButton())); + + connectButton->setEnabled(false); + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } setWindowTitle(tr("FTP")); } @@ -133,12 +148,6 @@ QSize FtpWindow::sizeHint() const //![0] void FtpWindow::connectOrDisconnect() { -#ifdef Q_OS_SYMBIAN - if(!bDefaultIapSet) { - qt_SetDefaultIap(); - bDefaultIapSet = true; - } -#endif if (ftp) { ftp->abort(); ftp->deleteLater(); @@ -377,3 +386,22 @@ void FtpWindow::enableDownloadButton() } //![14] +void FtpWindow::enableConnectButton() +{ + // 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("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + + connectButton->setEnabled(networkSession->isOpen()); + statusLabel->setText(tr("Please enter the name of an FTP server.")); +} + diff --git a/examples/network/qftp/ftpwindow.h b/examples/network/qftp/ftpwindow.h index 25a7a56..9f39ccd 100644 --- a/examples/network/qftp/ftpwindow.h +++ b/examples/network/qftp/ftpwindow.h @@ -55,6 +55,7 @@ class QTreeWidgetItem; class QProgressDialog; class QPushButton; class QUrlInfo; +class QNetworkSession; QT_END_NAMESPACE class FtpWindow : public QDialog @@ -78,6 +79,7 @@ private slots: void updateDataTransferProgress(qint64 readBytes, qint64 totalBytes); void enableDownloadButton(); + void enableConnectButton(); //![0] private: @@ -98,9 +100,7 @@ private: QFtp *ftp; QFile *file; -#ifdef Q_OS_SYMBIAN - bool bDefaultIapSet; -#endif + QNetworkSession *networkSession; //![1] }; diff --git a/examples/network/qftp/qftp.pro b/examples/network/qftp/qftp.pro index b3106c3..232e8eb 100644 --- a/examples/network/qftp/qftp.pro +++ b/examples/network/qftp/qftp.pro @@ -13,8 +13,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000A648 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - HEADERS += sym_iap_util.h INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE TARGET.CAPABILITY="NetworkServices ReadUserData WriteUserData" - LIBS+=-lesock -lcommdb -linsock # For IAP selection } diff --git a/examples/network/qftp/sym_iap_util.h b/examples/network/qftp/sym_iap_util.h deleted file mode 100644 index bea447c..0000000 --- a/examples/network/qftp/sym_iap_util.h +++ /dev/null @@ -1,519 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Nokia Corporation and its Subsidiary(-ies) 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 QSYM_IAP_UTIL_H -#define QSYM_IAP_UTIL_H - -// Symbian -#include -#include -#include -#include -#include -#include -#include - -// OpenC -#include -#include - -//Qt -#include -#include -//#include - -_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory -_LIT(KIapTableIdField, "IAP\\Id"); -_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional -_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory -_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory -_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional -_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional -_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional - -const QLatin1String qtOrganizationTag("Trolltech"); -const QLatin1String qtNetworkModuleTag("QtNetwork"); -const QLatin1String iapGroupTag("IAP"); -const QLatin1String iapNamesArrayTag("Names"); -const QLatin1String iapNameItemTag("Name"); - -static QTextCodec *utf16LETextCodec = 0; - -void clearIapNamesSettings(QSettings &settings) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.remove(iapNamesArrayTag); - settings.endGroup(); - settings.endGroup(); -} - -void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { - clearIapNamesSettings(settings); - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.beginWriteArray(iapNamesArrayTag); - for (int index = 0; index < iapNames.size(); ++index) { - settings.setArrayIndex(index); - settings.setValue(iapNameItemTag, iapNames.at(index)); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - int last = settings.beginReadArray(iapNamesArrayTag); - for (int index = 0; index < last; ++index) { - settings.setArrayIndex(index); - iapNames.append(settings.value(iapNameItemTag).toString()); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -static QString qt_TNameToQString(TName data) { - if(utf16LETextCodec == 0) - utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); - - QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); - return utf16LETextCodec->toUnicode(tmpByteArray); -} - -static QString qt_InterfaceInfoL() -{ - QString output; - - TBuf8<512> buffer; - TBuf<128> t; - TAutoClose ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); - - TProtocolDesc in; - User::LeaveIfError(sock.iObj.Info(in)); - printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); - - TPckgBuf info, next; - - TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); - if(res!=KErrNone) - User::Leave(res); - TInt count = 0; - while(res==KErrNone) { - res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); - - if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { - printf("Interface %d\n", count++); - - printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); - printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); - - printf("State "); - switch (info().iState) - { - case EIfPending: - printf("pending\n"); - break; - case EIfUp: - printf("up\n"); - break; - case EIfBusy: - printf("busy\n"); - break; - default: - printf("down\n"); - break; - } - - printf("Mtu %d\n", info().iMtu); - printf("Speed Metric %d\n", info().iSpeedMetric); - - printf("Features:"); - info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); - info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); - info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); - info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); - info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); - info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); - info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); - info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); - printf("\n"); - - TName address; - info().iAddress.Output(address); - printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if(info().iAddress.IsLinkLocal()) { - printf(" -link local\n"); - } else if(info().iAddress.IsSiteLocal()) { - printf(" -site local\n"); - } else { - printf(" -global\n"); - } - - info().iNetMask.Output(address); - printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iBrdAddr.Output(address); - printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iDefGate.Output(address); - printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer1.Output(address); - printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer2.Output(address); - printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if (info().iHwAddr.Family() != KAFUnspec) { - printf("Hardware address "); - TUint j; - for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { - if(j < (TUint)info().iHwAddr.Length()) { - printf("%02X", info().iHwAddr[j]); - } else { - printf("??"); - } - if(j < sizeof(SSockAddr) + 5) - printf("-"); - else - printf("\n"); - } - } - } - if(res == KErrNone) { - info = next; - printf("\n"); - } else { - printf("\n"); - } - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -static QString qt_RouteInfoL() { - QString output; - TAutoClose ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - TSoInetRouteInfo routeInfo; - TPckg routeInfoPkg(routeInfo); - - TName destAddr; - TName netMask; - TName gateway; - TName ifAddr; - - // Begins enumeration of routes by setting this option - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); - - // The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone - for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) - { - // Extract the destination and netmask - routeInfo.iDstAddr.Output(destAddr); - routeInfo.iNetMask.Output(netMask); - routeInfo.iGateway.Output(gateway); - routeInfo.iIfAddr.Output(ifAddr); -/* - if(destAddr.Length() <= 2) - continue; - - if(netMask.Find(_L("255.255.255.255")) != KErrNotFound - || netMask.Find(_L("0.0.0.0")) != KErrNotFound - || netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) - continue; -*/ - printf("Route Info #[%i]\n", i); - printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); - printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); - printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); - printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); - printf("\n"); - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -QString qt_TDesC2QStringL(const TDesC& aDescriptor) -{ -#ifdef QT_NO_UNICODE - return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); -#else - return QString((const QChar *)aDescriptor.Ptr(), aDescriptor.Length()); -#endif -} - -static bool qt_SetDefaultIapName(const QString &iapName, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set IAP name value - // make sure it is in UTF8 - strcpy(ifReq.ifr_name, iapName.toUtf8().data()); - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} -static bool qt_SetDefaultSnapId(const int snapId, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set SNAP ID value - ifReq.ifr_ifru.snap_id = snapId; - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} - -static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { - if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { - // no need to update - } else { - if(iapNameValue != QString("Easy WLAN")) { - // new selection alway on top - iapNames.removeAll(iapNameValue); - iapNames.prepend(iapNameValue); - writeIapNamesSettings(settings, iapNames); - } else { - // Unbeliveable ... if IAP dodn't exist before - // no matter what you choose from IAP selection list - // you will get "Easy WLAN" as IAP name value - - // somehow commsdb is not in sync - } - } -} - -static QString qt_OfferIapDialog() { - TBuf8<256> iapName; - - RSocketServ socketServ; - CleanupClosePushL(socketServ); - - RConnection connection; - CleanupClosePushL(connection); - - socketServ.Connect(); - - TCommDbConnPref prefs; - prefs.SetDialogPreference(ECommDbDialogPrefPrompt); - - connection.Open(socketServ); - connection.Start(prefs); - - connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); - //connection.Stop(); - - iapName.ZeroTerminate(); - QString strIapName((char*)iapName.Ptr()); - - int error = 0; - if(!strIapName.isEmpty()) { - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - } - - CleanupStack::PopAndDestroy(&connection); - CleanupStack::PopAndDestroy(&socketServ); - - return strIapName; -} - -static QString qt_CheckForActiveConnection() { - TUint count; - - RSocketServ serv; - CleanupClosePushL(serv); - - RConnection conn; - CleanupClosePushL(conn); - - serv.Connect(); - conn.Open(serv); - - TConnectionInfoBuf connInfo; - - TBuf8<256> iapName; - TBuf8<256> iapServiceType; - - QString strIapName; - - if (conn.EnumerateConnections(count) == KErrNone) { - if(count > 0) { - for (TUint i = 1; i <= count; i++) { - if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { - RConnection tempConn; - CleanupClosePushL(tempConn); - tempConn.Open(serv); - if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { - tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); - tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); - //tempConn.Stop(); - iapName.ZeroTerminate(); - iapServiceType.ZeroTerminate(); - -// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { -// activeLanConnectionFound = ETrue; -// break; -// } - strIapName = QString((char*)iapName.Ptr()); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - - CleanupStack::PopAndDestroy(&tempConn); - break; - } - } - } - } - } - - //conn.Stop(); - - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); - - return strIapName; -} - -static QString qt_CheckSettingsForConnection(QStringList& iapNames) { - QString strIapName; - for(int index = 0; index < iapNames.size(); ++index) { - strIapName = iapNames.at(index); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } else { - return strIapName; - } - } - return strIapName; -} - -static void qt_SetDefaultIapL() -{ - // settings @ /c/data/.config/Trolltech.com - QSettings settings(QSettings::UserScope, qtOrganizationTag); - // populate iap name list - QStringList iapNames; - readIapNamesSettings(settings, iapNames); - - QString iapNameValue; - - iapNameValue = qt_CheckForActiveConnection(); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - iapNameValue = qt_CheckSettingsForConnection(iapNames); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - /* - * no active LAN connections yet - * no IAP in settings - * offer IAP dialog to user - */ - iapNameValue = qt_OfferIapDialog(); - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - -} - -static int qt_SetDefaultIap() -{ -#ifndef __WINS__ - TRAPD(err1, qt_SetDefaultIapL()); -// TRAPD(err2, qt_InterfaceInfoL()); -// TRAPD(err3, qt_RouteInfoL()); - return err1; -#else - return 0; // IAP dialog not required for emulator -#endif -} - -#endif // QSYM_IAP_UTIL_H -- cgit v0.12 From 4e6b3f4c6f4bf8ea84b616031cbd54124c5b50d0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Jul 2010 10:39:18 +1000 Subject: Add a PathView example. --- doc/src/declarative/examples.qdoc | 1 + .../modelviews/pathview/pathview-example.qml | 108 +++++++++++++++++++++ .../modelviews/pathview/pathview.qmlproject | 16 +++ .../modelviews/pathview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/pathview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../modelviews/pathview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../modelviews/pathview/pics/DateBook_48.png | Bin 0 -> 2610 bytes .../modelviews/pathview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../modelviews/pathview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/pathview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes 10 files changed, 125 insertions(+) create mode 100644 examples/declarative/modelviews/pathview/pathview-example.qml create mode 100644 examples/declarative/modelviews/pathview/pathview.qmlproject create mode 100644 examples/declarative/modelviews/pathview/pics/AddressBook_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/Camera_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/DateBook_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/EMail_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/TodoList_48.png create mode 100644 examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 8a24228..39da323 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -175,6 +175,7 @@ The examples can be found in Qt's \c examples/declarative directory. \list \o \l{declarative/modelviews/gridview}{GridView} \o \l{declarative/modelviews/listview}{ListView} +\o \l{declarative/modelviews/pathview}{PathView} \o \l{declarative/modelviews/package}{Package} \o \l{declarative/modelviews/parallax}{Parallax} \o \l{declarative/modelviews/visualitemmodel}{VisualItemModel} diff --git a/examples/declarative/modelviews/pathview/pathview-example.qml b/examples/declarative/modelviews/pathview/pathview-example.qml new file mode 100644 index 0000000..59a0acb --- /dev/null +++ b/examples/declarative/modelviews/pathview/pathview-example.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Nokia Corporation and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + width: 400; height: 240 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + scale: PathView.scale + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + smooth: true + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + } + + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + PathView { + id: view + anchors.fill: parent + highlight: appHighlight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + focus: true + model: appModel + delegate: appDelegate + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "scale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "scale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "scale"; value: 0.5 } + } + } +} diff --git a/examples/declarative/modelviews/pathview/pathview.qmlproject b/examples/declarative/modelviews/pathview/pathview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/pathview/pathview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/pathview/pics/AddressBook_48.png b/examples/declarative/modelviews/pathview/pics/AddressBook_48.png new file mode 100644 index 0000000..1ab7c8e Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/AddressBook_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png new file mode 100644 index 0000000..f4b8689 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/Camera_48.png b/examples/declarative/modelviews/pathview/pics/Camera_48.png new file mode 100644 index 0000000..c76b524 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/Camera_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/DateBook_48.png b/examples/declarative/modelviews/pathview/pics/DateBook_48.png new file mode 100644 index 0000000..58f5787 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/DateBook_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/EMail_48.png b/examples/declarative/modelviews/pathview/pics/EMail_48.png new file mode 100644 index 0000000..d6d84a6 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/EMail_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/TodoList_48.png b/examples/declarative/modelviews/pathview/pics/TodoList_48.png new file mode 100644 index 0000000..0988448 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/TodoList_48.png differ diff --git a/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png new file mode 100644 index 0000000..52638c5 Binary files /dev/null and b/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png differ -- cgit v0.12 From 5572ec653fe735c4f413195c1ef34382aa8c6105 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Jul 2010 11:29:35 +1000 Subject: Always place PathView delegates centered on the path The scale of the delegate was used to offset the item. This was a bad way of making the item appear to be positioned correctly when the default transform origin was the top-left. Now that transform origin is center, it is obvious that it was a bad idea. Task-number: QTBUG-12245 Reviewed-by: Michael Brasser --- tests/auto/declarative/qdeclarativepathview/data/pathview0.qml | 2 ++ .../declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index 8956205..ff6f224 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -6,6 +6,7 @@ Rectangle { property int currentB: -1 property real delegateWidth: 60 property real delegateHeight: 20 + property real delegateScale: 1.0 width: 240 height: 320 color: "#ffffff" @@ -17,6 +18,7 @@ Rectangle { objectName: "wrapper" height: root.delegateHeight width: root.delegateWidth + scale: root.delegateScale color: PathView.isCurrentItem ? "lightsteelblue" : "white" border.color: "black" Text { diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index bf1e13a..fdbb16d 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -451,11 +451,19 @@ void tst_QDeclarativePathView::pathMoved() QCOMPARE(firstItem->pos() + offset, start); // Change delegate size + pathview->setOffset(0.1); + pathview->setOffset(0.0); canvas->rootObject()->setProperty("delegateWidth", 30); QCOMPARE(firstItem->width(), 30.0); offset.setX(firstItem->width()/2); QTRY_COMPARE(firstItem->pos() + offset, start); + // Change delegate scale + pathview->setOffset(0.1); + pathview->setOffset(0.0); + canvas->rootObject()->setProperty("delegateScale", 1.2); + QTRY_COMPARE(firstItem->pos() + offset, start); + delete canvas; } -- cgit v0.12 From 19473443dbeff4a57cd6ec6572ca29c2e70d672c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Jul 2010 11:47:16 +1000 Subject: Missed the actual change in 5572ec653fe735c4f413195c1ef34382aa8c6105 Always place PathView delegates centered on the path The scale of the delegate was used to offset the item. This was a bad way of making the item appear to be positioned correctly when the default transform origin was the top-left. Now that transform origin is center, it is obvious that it was a bad idea. Task-number: QTBUG-12245 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index f4ebd13..acf9827 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -284,8 +284,8 @@ void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal perce att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); } QPointF pf = path->pointAt(percent); - item->setX(qRound(pf.x() - item->width()*item->scale()/2)); - item->setY(qRound(pf.y() - item->height()*item->scale()/2)); + item->setX(qRound(pf.x() - item->width()/2)); + item->setY(qRound(pf.y() - item->height()/2)); } void QDeclarativePathViewPrivate::regenerate() -- cgit v0.12 From 9e4fb690b864f8d0c05d70687a3498b9eb9b2ed5 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 19 Jul 2010 13:07:07 +1000 Subject: Fix Samegame Change to Behavior from Follow means that some of the previous assumptions are now incorrect. Script logic has been fixed. Task-number: QTBUG-12246 --- demos/declarative/samegame/SamegameCore/samegame.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js index 6e1b24d..aa1b359 100755 --- a/demos/declarative/samegame/SamegameCore/samegame.js +++ b/demos/declarative/samegame/SamegameCore/samegame.js @@ -110,7 +110,7 @@ function shuffleDown() }else{ if(fallDist > 0){ var obj = board[index(column,row)]; - obj.y += fallDist * gameCanvas.blockSize; + obj.y = (row+fallDist) * gameCanvas.blockSize; board[index(column,row+fallDist)] = obj; board[index(column,row)] = null; } @@ -128,7 +128,7 @@ function shuffleDown() obj = board[index(column,row)]; if(obj == null) continue; - obj.x -= fallDist * gameCanvas.blockSize; + obj.x = (column-fallDist) * gameCanvas.blockSize; board[index(column-fallDist,row)] = obj; board[index(column,row)] = null; } -- cgit v0.12 From 931222b7d665e101ada070afb51b82f9bb85db6d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Jul 2010 13:26:10 +1000 Subject: PathView doc clarification. --- doc/src/examples/qml-examples.qdoc | 9 +++++++++ doc/src/snippets/declarative/pathview/pathattributes.qml | 12 ++++++------ .../declarative/modelviews/pathview/pathview-example.qml | 9 ++++----- src/declarative/graphicsitems/qdeclarativepath.cpp | 7 +++++++ src/declarative/util/qdeclarativetransition.cpp | 2 +- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index ce53677..3fd4ea8 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -317,6 +317,15 @@ */ /*! + \title Models and Views: PathView + \example declarative/modelviews/pathview + + This example shows how to use the PathView element. + + \image qml-pathview-example.png +*/ + +/*! \title Models and Views: Object ListModel \example declarative/modelviews/objectlistmodel diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml index 8d424a8..4daee63 100644 --- a/doc/src/snippets/declarative/pathview/pathattributes.qml +++ b/doc/src/snippets/declarative/pathview/pathattributes.qml @@ -49,8 +49,8 @@ Rectangle { id: delegate Item { width: 80; height: 80 - scale: PathView.scale - opacity: PathView.opacity + scale: PathView.iconScale + opacity: PathView.iconOpacity Column { Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon } Text { text: name; font.pointSize: 16} @@ -66,11 +66,11 @@ Rectangle { delegate: delegate path: Path { startX: 120; startY: 100 - PathAttribute { name: "scale"; value: 1.0 } - PathAttribute { name: "opacity"; value: 1.0 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathAttribute { name: "iconOpacity"; value: 1.0 } PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "scale"; value: 0.3 } - PathAttribute { name: "opacity"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.3 } + PathAttribute { name: "iconOpacity"; value: 0.5 } PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } } } diff --git a/examples/declarative/modelviews/pathview/pathview-example.qml b/examples/declarative/modelviews/pathview/pathview-example.qml index 59a0acb..0a3b34c 100644 --- a/examples/declarative/modelviews/pathview/pathview-example.qml +++ b/examples/declarative/modelviews/pathview/pathview-example.qml @@ -57,10 +57,9 @@ Rectangle { Component { id: appDelegate - Item { width: 100; height: 100 - scale: PathView.scale + scale: PathView.iconScale Image { id: myIcon @@ -98,11 +97,11 @@ Rectangle { path: Path { startX: 10 startY: 50 - PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.5 } PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "scale"; value: 1.0 } + PathAttribute { name: "iconScale"; value: 1.0 } PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.5 } } } } diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index a904869..80196a1 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -533,6 +533,13 @@ void QDeclarativeCurve::setY(qreal y) /*! \qmlproperty string PathAttribute::name the name of the attribute to change. + + This attribute will be available to the delegate as PathView. + + Note that using an existing Item property name such as "opacity" as an + attribute is allowed. This is because path attributes add a new + \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} + which in no way clashes with existing properties. */ /*! diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 34e1e2b..6b7418e 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE Transition { ... } ] } - |endqml + \endqml \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} */ -- cgit v0.12 From 70d4dc02d02ea9651df197e02e249de4a55d135c Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 19 Jul 2010 14:44:51 +1000 Subject: Remove files as instructed by Legal department. --- .../qimagereader/images/pngwithcompressedtext.png | Bin 757 -> 0 bytes tests/auto/qimagereader/images/pngwithtext.png | Bin 796 -> 0 bytes tests/auto/qimagereader/tst_qimagereader.cpp | 50 --------------------- tests/auto/qimagewriter/tst_qimagewriter.cpp | 38 ---------------- .../qimagereader/images/pngwithcompressedtext.png | Bin 757 -> 0 bytes .../gui/image/qimagereader/images/pngwithtext.png | Bin 796 -> 0 bytes 6 files changed, 88 deletions(-) delete mode 100644 tests/auto/qimagereader/images/pngwithcompressedtext.png delete mode 100644 tests/auto/qimagereader/images/pngwithtext.png delete mode 100644 tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png delete mode 100644 tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png diff --git a/tests/auto/qimagereader/images/pngwithcompressedtext.png b/tests/auto/qimagereader/images/pngwithcompressedtext.png deleted file mode 100644 index 01b2270..0000000 Binary files a/tests/auto/qimagereader/images/pngwithcompressedtext.png and /dev/null differ diff --git a/tests/auto/qimagereader/images/pngwithtext.png b/tests/auto/qimagereader/images/pngwithtext.png deleted file mode 100644 index 5d93799..0000000 Binary files a/tests/auto/qimagereader/images/pngwithtext.png and /dev/null differ diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index fc2582f..37e6237 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -120,9 +120,6 @@ private slots: void supportsAnimation_data(); void supportsAnimation(); - void description_data(); - void description(); - void readFromResources_data(); void readFromResources(); @@ -1110,53 +1107,6 @@ void tst_QImageReader::readFromFileAfterJunk() } } -void tst_QImageReader::description_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("description"); - - QMap willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (gwillem@ntuvax.ntu.ac.sg)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << QString("pngwithtext.png") << willem; - QTest::newRow("PNG Compressed") << QString("pngwithcompressedtext.png") << willem; -} - -void tst_QImageReader::description() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - // Sanity check - QVERIFY(!QImage(prefix + fileName).isNull()); - - QImageReader reader(prefix + fileName); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); - - QImage image = reader.read(); - QVERIFY(!image.isNull()); - - foreach (QString key, description.keys()) - QCOMPARE(image.text(key), description.value(key)); - QCOMPARE(image.textKeys(), QStringList(description.keys())); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); -} - void tst_QImageReader::readFromResources_data() { QTest::addColumn("fileName"); diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index c4860c3..c6ec715 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -93,9 +93,6 @@ private slots: void largeTiff(); #endif - void setDescription_data(); - void setDescription(); - void writeToInvalidDevice(); void supportsOption_data(); @@ -420,41 +417,6 @@ void tst_QImageWriter::readWriteNonDestructive() QCOMPARE(image, image2); } -void tst_QImageWriter::setDescription_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("description"); - - QMap willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (willem@schaik.com)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995-96"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << prefix + QString("gen-pngwithtext.png") << willem; -} - -void tst_QImageWriter::setDescription() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - QImageWriter writer(fileName, "png"); - foreach (QString key, description.keys()) - writer.setText(key, description.value(key)); - QVERIFY(writer.write(QImage(prefix + "kollada.png"))); - - QImageReader reader(fileName); - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); -} - void tst_QImageWriter::writeToInvalidDevice() { QLatin1String fileName("/these/directories/do/not/exist/001.png"); diff --git a/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png b/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png deleted file mode 100644 index 01b2270..0000000 Binary files a/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png and /dev/null differ diff --git a/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png b/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png deleted file mode 100644 index 5d93799..0000000 Binary files a/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png and /dev/null differ -- cgit v0.12 From 8668f245b69da455ac7fe1d0a599226c1d6b9580 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 19 Jul 2010 15:16:40 +1000 Subject: Add label to explain how to exit QML demos Some people didn't figure it out intuitively, so extra help is now provided. Task-number: QTBUG-11868 --- demos/qtdemo/qmlShell.qml | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index e15d33c..e9d8d56 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -52,6 +52,7 @@ Item { //below properties are sometimes set from C++ property url qmlFile: '' property bool show: false + /* Image{ id: bg opacity: 0 @@ -60,6 +61,7 @@ Item { pixmap: bgAppPixmap effect: Blur { id: blurEffect; enabled: useBlur; blurRadius: 8;} } + */ Item{ id:embeddedViewer width: parent.width @@ -136,6 +138,32 @@ Item { onLinkActivated: Qt.openUrlExternally(link); } } + Rectangle{ + id: helpLabel + property bool timedOut: false + z: 9 + //Positioned in the top left corner + x: 8 + y: 8 + color: "white" + border.color: "black" + border.width: 1 + width: helpText.width + 16 + height: helpText.height + 8 + Text{ + id: helpText + color: "black" + anchors.centerIn: parent + text: "Click outside the example to exit it." + } + opacity: 0 + Behavior on opacity{ NumberAnimation{duration:500} } + Timer{ + id: helpTimer + interval: 5000 + onTriggered: {helpLabel.timedOut=true} + } + } Rectangle{ id: blackout //Maybe use a colorize effect instead? z: 8 anchors.fill: parent @@ -160,8 +188,8 @@ Item { opacity: 1 } PropertyChanges { - target: bg - opacity: 1 + target: helpLabel + opacity: helpLabel.timedOut?0:1 } PropertyChanges { target: blackout @@ -171,9 +199,9 @@ Item { ] transitions: [//Should not be too long, because the component has already started running Transition { from: ''; to: "show"; reversible: true - SequentialAnimation{ - PropertyAction { target: bg; property: useBlur?"y":"opacity";}//fade in blurred background only if blurred - NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500} + ParallelAnimation{ + ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} } + NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500} PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us } } -- cgit v0.12 From 75131b7a1bfeeb033ea5b8bf62d50cc3d82d757e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 19 Jul 2010 15:26:37 +1000 Subject: Remove the -use-blur option from qtdemo It relied on the now missing pixmap property. Since it isn't used, it doesn't seem worth the effort to update it to use a declarative image provider instead. --- demos/qtdemo/colors.cpp | 6 +----- demos/qtdemo/colors.h | 1 - demos/qtdemo/mainwindow.cpp | 8 -------- demos/qtdemo/menumanager.cpp | 20 -------------------- demos/qtdemo/qmlShell.qml | 22 ---------------------- 5 files changed, 1 insertion(+), 56 deletions(-) diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp index b352e3d..802d77d 100644 --- a/demos/qtdemo/colors.cpp +++ b/demos/qtdemo/colors.cpp @@ -81,7 +81,6 @@ bool Colors::noRescale = false; bool Colors::noAnimations = false; bool Colors::noBlending = false; bool Colors::noScreenSync = false; -bool Colors::noBlur = true; bool Colors::fullscreen = false; bool Colors::usePixmaps = false; bool Colors::useLoop = false; @@ -233,8 +232,6 @@ void Colors::parseArgs(int argc, char *argv[]) Colors::showFps = true; else if (s == "-no-blending") Colors::noBlending = true; - else if (s == "-use-blur") - Colors::noBlur = false; else if (s == "-no-sync") Colors::noScreenSync = true; else if (s.startsWith("-menu")) @@ -270,7 +267,7 @@ void Colors::parseArgs(int argc, char *argv[]) else if (s.startsWith("-h") || s.startsWith("-help")){ QMessageBox::warning(0, "Arguments", QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-software] [-fullscreen] [-ticker[0|1]] ") - + "[-animations[0|1]] [-no-blending] [-use-blur] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + + "[-animations[0|1]] [-no-blending] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + "[-use-window-mask] [-no-rescale] " + "[-use-pixmaps] [-show-fps] [-show-br] [-8bit[0|1]] [-menu] [-use-loop] [-use-balls] " + "[-animation-speed] [-fps] " @@ -298,7 +295,6 @@ void Colors::setLowSettings() Colors::usePixmaps = true; Colors::noAnimations = true; Colors::noBlending = true; - Colors::noBlur = true; } void Colors::detectSystemResources() diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h index 2d58058..1e0b795 100644 --- a/demos/qtdemo/colors.h +++ b/demos/qtdemo/colors.h @@ -91,7 +91,6 @@ public: static bool noAnimations; static bool noBlending; static bool noScreenSync; - static bool noBlur; static bool useLoop; static bool noWindowMask; static bool usePixmaps; diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp index 753014a..16c5bf3 100644 --- a/demos/qtdemo/mainwindow.cpp +++ b/demos/qtdemo/mainwindow.cpp @@ -310,14 +310,6 @@ void MainWindow::checkAdapt() qDebug() << "- benchmark adaption: removed ticker (fps < 30)"; } - //Note: Because we don't adapt later in the program, if blur makes FPS plummet then we won't catch it - if (!Colors::noBlur && MenuManager::instance()->declarativeEngine && this->mainSceneRoot){ - Colors::noBlur = true; - MenuManager::instance()->declarativeEngine->rootContext()->setContextProperty("useBlur", false); - if (Colors::verbose) - qDebug() << "- benchmark adaption: removed blur (fps < 30)"; - } - if (this->fpsMedian < 20){ Colors::noAnimations = true; if (Colors::verbose) diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 15561ab..7168b57 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -378,17 +378,6 @@ void MenuManager::launchQmlExample(const QString &name) return; } } - if(!Colors::noBlur){ - QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&qmlBgImage); - if(Colors::showFps) - this->window->fpsLabel->setOpacity(0); - this->window->render(&painter); - if(Colors::showFps) - this->window->fpsLabel->setOpacity(1.0); - Qt::ImageConversionFlags convFlags = Qt::AvoidDither | Qt::NoOpaqueDetection; - this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage, convFlags))); - } qmlRoot->setProperty("qmlFile", QVariant(""));//unload component qmlRoot->setProperty("show", QVariant(true)); @@ -439,17 +428,8 @@ void MenuManager::init(MainWindow *window) } // Create QML Loader - qmlRegisterType("Effects", 1, 0, "Blur"); - qmlRegisterType("Effects", 1, 0, "DropShadow"); declarativeEngine = new QDeclarativeEngine(this); - // Note that we paint the background into a static image for a theorized performance improvement when blurring - // It has not yet been determined what, if any, speed up this gives (but is left in 'cause the QML expects it now) - declarativeEngine->rootContext()->setContextProperty("useBlur", !Colors::noBlur); - QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); - qmlBgImage.fill(0); - this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage))); - QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); qmlRoot = 0; if(component.isReady()) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index e9d8d56..b5fdf39 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -40,28 +40,13 @@ ****************************************************************************/ import Qt 4.7 -import Effects 1.0 -/* Vars exposed from C++ - pixmap bgAppPixmap - bool useBlur (to turn on, pass -use-blur on the cmd line. Off by default 'cause it's too slow) -*/ Item { id: main //height and width set by program to fill window //below properties are sometimes set from C++ property url qmlFile: '' property bool show: false - /* - Image{ - id: bg - opacity: 0 - anchors.fill: parent - z: -1 - pixmap: bgAppPixmap - effect: Blur { id: blurEffect; enabled: useBlur; blurRadius: 8;} - } - */ Item{ id:embeddedViewer width: parent.width @@ -114,13 +99,6 @@ Item { anchors.fill:parent } - effect: DropShadow { - enabled: useBlur; - blurRadius: 9; - color: "#88000000"; - xOffset:0 - yOffset:0 - } } Text{ -- cgit v0.12 From 099f684de47b936268e7c052c9ac3f97ca7ad209 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 19 Jul 2010 15:28:10 +1000 Subject: Doc error fixes. --- src/declarative/graphicsitems/qdeclarativeimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- src/declarative/graphicsitems/qdeclarativetranslate.cpp | 2 +- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 90738c8..37736cc 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE \endqml \endtable - If the \l {Image::width}{width} and \l{Image::height}{height} properties are not specified, + If the \l {Item::width}{width} and \l{Item::height}{height} properties are not specified, the Image element is automatically sized to the loaded image. Image elements can be stretched and tiled using the \l fillMode property. diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index b9498f1..367a5d0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2692,7 +2692,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) } /*! - \reimp + \internal Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called during initial widget polishing. Items wishing to optimize start-up construction diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index 17daac7..16a1127 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -117,7 +117,7 @@ void QDeclarativeTranslate::setY(qreal y) } /*! - \reimp + \internal */ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const { diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 9f4df22..7c1e1fd 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -567,7 +567,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Mon, 19 Jul 2010 15:30:06 +1000 Subject: Fix ListView sections with QList QDeclarativeVisualDataModel::stringValue() did not handle QList model types. Task-number: QTBUG-12005 --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 5 +++++ .../auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml | 3 +++ .../qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index fa422fd..38bc6f5 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -577,7 +577,7 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) listItem->attached->m_prevSection = sectionAt(modelIndex-1); if (FxListItem *item = visibleItem(modelIndex+1)) listItem->attached->m_nextSection = item->attached->section(); - else + else if (modelIndex < model->count()-1) listItem->attached->m_nextSection = sectionAt(modelIndex+1); } } diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 786d6f9..cfa1c6d 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1089,6 +1089,11 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) if (d->m_visualItemModel) return d->m_visualItemModel->stringValue(index, name); + if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor) { + if (QObject *object = d->m_listAccessor->at(index).value()) + return object->property(name.toUtf8()).toString(); + } + if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate) return QString(); diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml index f5198c9..d030222 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml @@ -11,6 +11,9 @@ ListView { width: 100 color: model.modelData.color Text { objectName: "name"; text: name } + Text { objectName: "section"; text: parent.ListView.section } } } + section.property: "name" + section.criteria: ViewSection.FullString } diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 43d4d06..e0f32ea 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -179,6 +179,9 @@ void tst_qdeclarativevisualdatamodel::objectListModel() QDeclarativeText *name = findItem(contentItem, "name", 0); QCOMPARE(name->text(), QString("Item 1")); + QDeclarativeText *section = findItem(contentItem, "section", 0); + QCOMPARE(section->text(), QString("Item 1")); + dataList[0]->setProperty("name", QLatin1String("Changed")); QCOMPARE(name->text(), QString("Changed")); } -- cgit v0.12 From 568e4ab97645692250d2aa25670aebfc0915afc0 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 19 Jul 2010 19:28:36 +1000 Subject: Remove references to files removed by previous commit. --- tests/auto/qimagereader/qimagereader.qrc | 2 -- tests/auto/qimagereader/tst_qimagereader.cpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index bc48244..7f6d81f 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -38,8 +38,6 @@ images/noclearcode.bmp images/noclearcode.gif images/nontransparent.xpm - images/pngwithcompressedtext.png - images/pngwithtext.png images/runners.ppm images/teapot.ppm images/test.ppm diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 37e6237..caad070 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -1198,12 +1198,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("image.png") << QString("image.png") << QByteArray("png") << QSize(22, 22) << QString(""); - QTest::newRow("pngwithcompressedtext.png") << QString("pngwithcompressedtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); - QTest::newRow("pngwithtext.png") << QString("pngwithtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); QTest::newRow("kollada.png") << QString("kollada.png") << QByteArray("png") << QSize(436, 160) << QString(""); -- cgit v0.12 From a545e26e1183133f4a66cb9a3bcd9051e2d77894 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 19 Jul 2010 12:16:43 +0200 Subject: Make configure.exe accept -no-gif again, fix comment Reviewed-By: Jason McDonald --- configure | 2 +- tools/configure/configureapp.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index fb544bd..11496c4 100755 --- a/configure +++ b/configure @@ -3636,7 +3636,7 @@ Third Party Libraries: -no-gif ............ Do not compile GIF reading support. * -qt-gif ............ Compile GIF reading support. - See also src/gui/image/qgifhandler.h + See also src/gui/image/qgifhandler_p.h -no-libtiff ........ Do not compile TIFF support. -qt-libtiff ........ Use the libtiff bundled with Qt. diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7f2d53b..c3498e3 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -581,6 +581,8 @@ void Configure::parseCmdLine() // Image formats -------------------------------------------- else if (configCmdLine.at(i) == "-no-gif") dictionary[ "GIF" ] = "no"; + else if (configCmdLine.at(i) == "-qt-gif") + dictionary[ "GIF" ] = "yes"; else if (configCmdLine.at(i) == "-no-libtiff") { dictionary[ "TIFF"] = "no"; @@ -1741,7 +1743,7 @@ bool Configure::displayHelp() desc("ZLIB", "system", "-system-zlib", "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n"); desc("GIF", "no", "-no-gif", "Do not compile GIF reading support."); - desc("GIF", "auto", "-qt-gif", "Compile GIF reading support.\nSee also src/gui/image/qgifhandler.h\n"); + desc("GIF", "auto", "-qt-gif", "Compile GIF reading support.\nSee also src/gui/image/qgifhandler_p.h\n"); desc("LIBPNG", "no", "-no-libpng", "Do not compile PNG support."); desc("LIBPNG", "qt", "-qt-libpng", "Use the libpng bundled with Qt."); -- cgit v0.12 From 368dd3c234b9011ab8a8506b50fce6f55694199c Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 19 Jul 2010 12:16:52 +0200 Subject: Rebuilt configure.exe --- configure.exe | Bin 1318400 -> 1686528 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 0863ecc..104923b 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 8acf3098bf5d88871d866aa87fa38e6feb3a32d0 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 19 Jul 2010 13:49:33 +0200 Subject: Do image comparison with fuzz Looks like native png and jpeg libs on some devices have rounding problems, so compare the color values with a fuzz of 3. This fixes this test on Maemo 5 and 6. Reviewed-by: Benjamin Poulain --- tests/auto/qimagereader/tst_qimagereader.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index fe2a719..e9ef070 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -315,7 +315,24 @@ void tst_QImageReader::jpegRgbCmyk() QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg")); QImage image2(prefix + QLatin1String("YCbCr_cmyk.png")); - QCOMPARE(image1, image2); + // first, do some obvious tests + QCOMPARE(image1.height(), image2.height()); + QCOMPARE(image1.width(), image2.width()); + QCOMPARE(image1.format(), image2.format()); + QCOMPARE(image1.format(), QImage::Format_RGB32); + + // compare all the pixels with a slack of 3. This ignores rounding errors in libjpeg/libpng + for (int h = 0; h < image1.height(); ++h) { + const uchar *s1 = image1.constScanLine(h); + const uchar *s2 = image2.constScanLine(h); + for (int w = 0; w < image1.width() * 4; ++w) { + if (*s1 != *s2) { + QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16))); + } + s1++; + s2++; + } + } } void tst_QImageReader::setScaledSize_data() -- cgit v0.12 From 30341a6f9e57caac3ec19e02ffd67164d43c0453 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 19 Jul 2010 14:00:59 +0200 Subject: Remove some more unneeded files from libjpeg, avoiding GPL Task-number: QT-3584 Reviewed-by: Trustme --- src/3rdparty/libjpeg/ansi2knr.1 | 36 -- src/3rdparty/libjpeg/ansi2knr.c | 739 ---------------------------------------- 2 files changed, 775 deletions(-) delete mode 100644 src/3rdparty/libjpeg/ansi2knr.1 delete mode 100644 src/3rdparty/libjpeg/ansi2knr.c diff --git a/src/3rdparty/libjpeg/ansi2knr.1 b/src/3rdparty/libjpeg/ansi2knr.1 deleted file mode 100644 index f9ee5a6..0000000 --- a/src/3rdparty/libjpeg/ansi2knr.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH ANSI2KNR 1 "19 Jan 1996" -.SH NAME -ansi2knr \- convert ANSI C to Kernighan & Ritchie C -.SH SYNOPSIS -.I ansi2knr -[--varargs] input_file [output_file] -.SH DESCRIPTION -If no output_file is supplied, output goes to stdout. -.br -There are no error messages. -.sp -.I ansi2knr -recognizes function definitions by seeing a non-keyword identifier at the left -margin, followed by a left parenthesis, with a right parenthesis as the last -character on the line, and with a left brace as the first token on the -following line (ignoring possible intervening comments). It will recognize a -multi-line header provided that no intervening line ends with a left or right -brace or a semicolon. These algorithms ignore whitespace and comments, except -that the function name must be the first thing on the line. -.sp -The following constructs will confuse it: -.br - - Any other construct that starts at the left margin and follows the -above syntax (such as a macro or function call). -.br - - Some macros that tinker with the syntax of the function header. -.sp -The --varargs switch is obsolete, and is recognized only for -backwards compatibility. The present version of -.I ansi2knr -will always attempt to convert a ... argument to va_alist and va_dcl. -.SH AUTHOR -L. Peter Deutsch wrote the original ansi2knr and -continues to maintain the current version; most of the code in the current -version is his work. ansi2knr also includes contributions by Francois -Pinard and Jim Avera . diff --git a/src/3rdparty/libjpeg/ansi2knr.c b/src/3rdparty/libjpeg/ansi2knr.c deleted file mode 100644 index e84c210..0000000 --- a/src/3rdparty/libjpeg/ansi2knr.c +++ /dev/null @@ -1,739 +0,0 @@ -/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */ - -/*$Id: ansi2knr.c,v 1.14 2003/09/06 05:36:56 eggert Exp $*/ -/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - -/* -ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT, -or, if there is no file named COPYLEFT, a file named COPYING. Among other -things, the copyright notice and this notice must be preserved on all -copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* - * Usage: - ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]] - * --filename provides the file name for the #line directive in the output, - * overriding input_file (if present). - * If no input_file is supplied, input is read from stdin. - * If no output_file is supplied, output goes to stdout. - * There are no error messages. - * - * ansi2knr recognizes function definitions by seeing a non-keyword - * identifier at the left margin, followed by a left parenthesis, with a - * right parenthesis as the last character on the line, and with a left - * brace as the first token on the following line (ignoring possible - * intervening comments and/or preprocessor directives), except that a line - * consisting of only - * identifier1(identifier2) - * will not be considered a function definition unless identifier2 is - * the word "void", and a line consisting of - * identifier1(identifier2, <>) - * will not be considered a function definition. - * ansi2knr will recognize a multi-line header provided that no intervening - * line ends with a left or right brace or a semicolon. These algorithms - * ignore whitespace, comments, and preprocessor directives, except that - * the function name must be the first thing on the line. The following - * constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of function headers. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - - lpd 2000-04-12 backs out Eggert's changes because of bugs: - - concatlits didn't declare the type of its bufend argument; - - concatlits didn't recognize when it was inside a comment; - - scanstring could scan backward past the beginning of the string; when - - the check for \ + newline in scanstring was unnecessary. - - 2000-03-05 Paul Eggert - - Add support for concatenated string literals. - * ansi2knr.c (concatlits): New decl. - (main): Invoke concatlits to concatenate string literals. - (scanstring): Handle backslash-newline correctly. Work with - character constants. Fix bug when scanning backwards through - backslash-quote. Check for unterminated strings. - (convert1): Parse character constants, too. - (appendline, concatlits): New functions. - * ansi2knr.1: Document this. - - lpd 1999-08-17 added code to allow preprocessor directives - wherever comments are allowed - lpd 1999-04-12 added minor fixes from Pavel Roskin - for clean compilation with - gcc -W -Wall - lpd 1999-03-22 added hack to recognize lines consisting of - identifier1(identifier2, xxx) as *not* being procedures - lpd 1999-02-03 made indentation of preprocessor commands consistent - lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an - endless loop; quoted strings within an argument list - confused the parser - lpd 1999-01-24 added a check for write errors on the output, - suggested by Jim Meyering - lpd 1998-11-09 added further hack to recognize identifier(void) - as being a procedure - lpd 1998-10-23 added hack to recognize lines consisting of - identifier1(identifier2) as *not* being procedures - lpd 1997-12-08 made input_file optional; only closes input and/or - output file if not stdin or stdout respectively; prints - usage message on stderr rather than stdout; adds - --filename switch (changes suggested by - ) - lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with - compilers that don't understand void, as suggested by - Tom Lane - lpd 1996-01-15 changed to require that the first non-comment token - on the line following a function header be a left brace, - to reduce sensitivity to macros, as suggested by Tom Lane - - lpd 1995-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 1995-04-05 changed copyright notice to make it clear that - including ansi2knr in a program does not bring the entire - program under the GPL - lpd 1994-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 1994-10-10 removed CONFIG_BROKETS conditional - lpd 1994-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 1989-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#if STDC_HEADERS -# include -#else -/* - malloc and free should be declared in stdlib.h, - but if you've got a K&R compiler, they probably aren't. - */ -# ifdef MSDOS -# include -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* Define NULL (for *very* old compilers). */ -#ifndef NULL -# define NULL (0) -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#endif -#if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *ppdirforward(); -char *ppdirbackward(); -char *skipspace(); -char *scanstring(); -int writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in = stdin; - FILE *out = stdout; - char *filename = 0; - char *program_name = argv[0]; - char *output_name = 0; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - char *usage = - "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n"; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - int output_error; - - while ( argc > 1 && argv[1][0] == '-' ) { - if ( !strcmp(argv[1], "--varargs") ) { - convert_varargs = 1; - argc--; - argv++; - continue; - } - if ( !strcmp(argv[1], "--filename") && argc > 2 ) { - filename = argv[2]; - argc -= 2; - argv += 2; - continue; - } - fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name, - argv[1]); - fprintf(stderr, usage); - exit(1); - } - switch ( argc ) - { - default: - fprintf(stderr, usage); - exit(0); - case 3: - output_name = argv[2]; - out = fopen(output_name, "w"); - if ( out == NULL ) { - fprintf(stderr, "%s: Cannot open output file %s\n", - program_name, output_name); - exit(1); - } - /* falls through */ - case 2: - in = fopen(argv[1], "r"); - if ( in == NULL ) { - fprintf(stderr, "%s: Cannot open input file %s\n", - program_name, argv[1]); - exit(1); - } - if ( filename == 0 ) - filename = argv[1]; - /* falls through */ - case 1: - break; - } - if ( filename ) - fprintf(out, "#line 1 \"%s\"\n", filename); - buf = malloc(bufsize); - if ( buf == NULL ) - { - fprintf(stderr, "Unable to allocate read buffer!\n"); - exit(1); - } - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 2: /* a function header */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* Check for a { at the start of the next line. */ - more = ++line; -f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ - goto wl; - if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) - goto wl; - switch ( *skipspace(ppdirforward(more), 1) ) - { - case '{': - /* Definitely a function header. */ - convert1(buf, out, 0, convert_varargs); - fputs(more, out); - break; - case 0: - /* The next line was blank or a comment: */ - /* keep scanning for a non-comment. */ - line += strlen(line); - goto f; - default: - /* buf isn't a function header, but */ - /* more might be. */ - fputs(buf, out); - strcpy(buf, more); - line = buf; - goto test; - } - break; - case -1: /* maybe the start of a function */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - if ( output_name ) { - output_error = ferror(out); - output_error |= fclose(out); - } else { /* out == stdout */ - fflush(out); - output_error = ferror(out); - } - if ( output_error ) { - fprintf(stderr, "%s: error writing to %s\n", program_name, - (output_name ? output_name : "stdout")); - exit(1); - } - if ( in != stdin ) - fclose(in); - return 0; -} - -/* - * Skip forward or backward over one or more preprocessor directives. - */ -char * -ppdirforward(p) - char *p; -{ - for (; *p == '#'; ++p) { - for (; *p != '\r' && *p != '\n'; ++p) - if (*p == 0) - return p; - if (*p == '\r' && p[1] == '\n') - ++p; - } - return p; -} -char * -ppdirbackward(p, limit) - char *p; - char *limit; -{ - char *np = p; - - for (;; p = --np) { - if (*np == '\n' && np[-1] == '\r') - --np; - for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np) - if (np[-1] == 0) - return np; - if (*np != '#') - return p; - } -} - -/* - * Skip over whitespace, comments, and preprocessor directives, - * in either direction. - */ -char * -skipspace(p, dir) - char *p; - int dir; /* 1 for forward, -1 for backward */ -{ - for ( ; ; ) { - while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) { - if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* Scan over a quoted string, in either direction. */ -char * -scanstring(p, dir) - char *p; - int dir; -{ - for (p += dir; ; p += dir) - if (*p == '"' && p[-dir] != '\\') - return p + dir; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ char *p = buf; - char *bend; - char *endfn; - int contin; - - if ( !isidfirstchar(*p) ) - return 0; /* no name at left margin */ - bend = skipspace(ppdirbackward(buf + strlen(buf) - 1, buf), -1); - switch ( *bend ) - { - case ';': contin = 0 /*2*/; break; - case ')': contin = 1; break; - case '{': return 0; /* not a function */ - case '}': return 0; /* not a function */ - default: contin = -1; - } - while ( isidchar(*p) ) - p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - return 0; /* no parameters */ - /* Check that the apparent function name isn't a keyword. */ - /* We only need to check for keywords that could be followed */ - /* by a left parenthesis (which, unfortunately, is most of them). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - char **key = words; - char *kp; - unsigned len = endfn - buf; - - while ( (kp = *key) != 0 ) - { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) - return 0; /* name is a keyword */ - key++; - } - } - { - char *id = p; - int len; - /* - * Check for identifier1(identifier2) and not - * identifier1(void), or identifier1(identifier2, xxxx). - */ - - while ( isidchar(*p) ) - p++; - len = p - id; - p = skipspace(p, 1); - if (*p == ',' || - (*p == ')' && (len != 4 || strncmp(id, "void", 4))) - ) - return 0; /* not a function */ - } - /* - * If the last significant character was a ), we need to count - * parentheses, because it might be part of a formal parameter - * that is a procedure. - */ - if (contin > 0) { - int level = 0; - - for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1)) - level += (*p == '(' ? 1 : *p == ')' ? -1 : 0); - if (level > 0) - contin = -1; - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - char *p; - /* - * The breaks table contains pointers to the beginning and end - * of each argument. - */ - char **breaks; - unsigned num_breaks = 2; /* for testing */ - char **btop; - char **bp; - char **ap; - char *vararg = 0; - - /* Pre-ANSI implementations don't agree on whether strchr */ - /* is called strchr or index, so we open-code it here. */ - for ( endfn = buf; *(endfn++) != '('; ) - ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == NULL ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp = NULL; - char *end = NULL; - - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - if (p[1] == '*') - p = skipspace(p, 1) - 1; - break; - case '"': - p = scanstring(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp && rp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - case ']': /* skip array dimension(s) */ - case ')': /* skip procedure args OR name */ - { int level = 1; - while ( level ) - switch ( *--p ) - { - case ']': case ')': - level++; - break; - case '[': case '(': - level--; - break; - case '/': - if (p > buf && p[-1] == '*') - p = skipspace(p, -1) + 1; - break; - case '"': - p = scanstring(p, -1) + 1; - break; - default: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: - goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} -- cgit v0.12 From 0c57f26a32382c7431f0d536508c8e979f7e0313 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 19 Jul 2010 15:11:48 +0200 Subject: Examples: Fix compilation with namespace. --- examples/tutorials/modelview/1_readonly/modelview.h | 2 +- examples/tutorials/modelview/2_formatting/modelview.h | 2 +- examples/tutorials/modelview/3_changingmodel/modelview.h | 2 +- examples/tutorials/modelview/3_changingmodel/mymodel.h | 2 +- examples/tutorials/modelview/4_headers/modelview.h | 2 +- examples/tutorials/modelview/5_edit/modelview.h | 2 +- examples/tutorials/modelview/6_treeview/modelview.h | 3 ++- examples/tutorials/modelview/7_selections/modelview.h | 3 ++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h index 9307083..cc14d90 100755 --- a/examples/tutorials/modelview/1_readonly/modelview.h +++ b/examples/tutorials/modelview/1_readonly/modelview.h @@ -45,7 +45,7 @@ // modelview.h #include -class QTableView; //forward declaration +QT_FORWARD_DECLARE_CLASS(QTableView) class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/2_formatting/modelview.h b/examples/tutorials/modelview/2_formatting/modelview.h index 7291487..b2943ac 100755 --- a/examples/tutorials/modelview/2_formatting/modelview.h +++ b/examples/tutorials/modelview/2_formatting/modelview.h @@ -43,7 +43,7 @@ #include -class QTableView; //forward declaration +QT_FORWARD_DECLARE_CLASS(QTableView) class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.h b/examples/tutorials/modelview/3_changingmodel/modelview.h index 7291487..b2943ac 100755 --- a/examples/tutorials/modelview/3_changingmodel/modelview.h +++ b/examples/tutorials/modelview/3_changingmodel/modelview.h @@ -43,7 +43,7 @@ #include -class QTableView; //forward declaration +QT_FORWARD_DECLARE_CLASS(QTableView) class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.h b/examples/tutorials/modelview/3_changingmodel/mymodel.h index 47b026e..01ad88d 100755 --- a/examples/tutorials/modelview/3_changingmodel/mymodel.h +++ b/examples/tutorials/modelview/3_changingmodel/mymodel.h @@ -43,7 +43,7 @@ #include -class QTimer; // forward declaration +QT_FORWARD_DECLARE_CLASS(QTimer) class MyModel : public QAbstractTableModel { diff --git a/examples/tutorials/modelview/4_headers/modelview.h b/examples/tutorials/modelview/4_headers/modelview.h index 7669e35..03f99c0 100755 --- a/examples/tutorials/modelview/4_headers/modelview.h +++ b/examples/tutorials/modelview/4_headers/modelview.h @@ -43,7 +43,7 @@ #include -class QTableView; //forward declaration +QT_FORWARD_DECLARE_CLASS(QTableView) class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/modelview.h index 97c840c..069107b 100755 --- a/examples/tutorials/modelview/5_edit/modelview.h +++ b/examples/tutorials/modelview/5_edit/modelview.h @@ -43,7 +43,7 @@ #include -class QTableView; //forward declaration +QT_FORWARD_DECLARE_CLASS(QTableView) class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/modelview.h index a47111c..55f3470 100755 --- a/examples/tutorials/modelview/6_treeview/modelview.h +++ b/examples/tutorials/modelview/6_treeview/modelview.h @@ -43,10 +43,11 @@ #include +QT_BEGIN_NAMESPACE class QTreeView; //forward declaration class QStandardItemModel; class QStandardItem; - +QT_END_NAMESPACE class ModelView : public QMainWindow { diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/modelview.h index 5229ac3..d20797e 100755 --- a/examples/tutorials/modelview/7_selections/modelview.h +++ b/examples/tutorials/modelview/7_selections/modelview.h @@ -43,10 +43,11 @@ #include +QT_BEGIN_NAMESPACE class QTreeView; //forward declaration class QStandardItemModel; class QItemSelection; - +QT_END_NAMESPACE class ModelView : public QMainWindow { -- cgit v0.12 From f19a95429a5e9b760f49152ebdf9b39474750116 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 19 Jul 2010 15:59:02 +0200 Subject: Extend the detection of CPU feature for x86 Add detection of CPU extension for SSE3, SSSE3, SSE4.1, SSE4.2 and AVX. Reviewed-by: Andreas Kling --- src/corelib/tools/qsimd.cpp | 11 +++++++++++ src/corelib/tools/qsimd_p.h | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 1ef513c..aa2ee47 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -218,6 +218,17 @@ uint qDetectCPUFeatures() features |= SSE; if (result & (1u << 26)) features |= SSE2; + if (extended_result & (1u)) + features |= SSE3; + if (extended_result & (1u << 9)) + features |= SSSE3; + if (extended_result & (1u << 19)) + features |= SSE4_1; + if (extended_result & (1u << 20)) + features |= SSE4_2; + if (extended_result & (1u << 28)) + features |= AVX; + #endif // i386 #if defined(QT_HAVE_MMX) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 0ed9d5d..18394853 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -119,7 +119,12 @@ enum CPUFeatures { SSE2 = 0x20, CMOV = 0x40, IWMMXT = 0x80, - NEON = 0x100 + NEON = 0x100, + SSE3 = 0x200, + SSSE3 = 0x400, + SSE4_1 = 0x800, + SSE4_2 = 0x1000, + AVX = 0x2000 }; Q_CORE_EXPORT uint qDetectCPUFeatures(); -- cgit v0.12 From 4da1a3b63445c04d4ca4acae448e9b6b046938c3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 19 Jul 2010 17:04:06 +0200 Subject: moc: Slot with complex template default value does not compile The way we detect the end of a default argument does not take in account template parametter. It is unfortunatelly not trivial to do it properly without semantic information So we will use heuristics and if the number of < matches the number of > we consider it is a template. Or if we have a '=' we consider it is not a template. Task-number: QTBUG-12260 Reviewed-by: Roberto Raggi --- src/tools/moc/moc.cpp | 22 +++++++++++++++++++++- tests/auto/moc/tst_moc.cpp | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 10a80f3..84d1567 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1208,6 +1208,12 @@ bool Moc::until(Token target) { default: break; } } + + //when searching commas within the default argument, we should take care of template depth (anglecount) + // unfortunatelly, we do not have enough semantic information to know if '<' is the operator< or + // the begining of a template type. so we just use heuristics. + int possible = -1; + while (index < symbols.size()) { Token t = symbols.at(index++).token; switch (t) { @@ -1226,8 +1232,16 @@ bool Moc::until(Token target) { && braceCount <= 0 && brackCount <= 0 && parenCount <= 0 - && (target != RANGLE || angleCount <= 0)) + && (target != RANGLE || angleCount <= 0)) { + if (target != COMMA || angleCount <= 0) + return true; + possible = index; + } + + if (target == COMMA && t == EQ && possible != -1) { + index = possible; return true; + } if (braceCount < 0 || brackCount < 0 || parenCount < 0 || (target == RANGLE && angleCount < 0)) { @@ -1235,6 +1249,12 @@ bool Moc::until(Token target) { break; } } + + if(target == COMMA && angleCount != 0 && possible != -1) { + index = possible; + return true; + } + return false; } diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 19f3677..4fcc7bd 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -491,6 +491,7 @@ private slots: void typenameWithUnsigned(); void warnOnVirtualSignal(); void QTBUG5590_dummyProperty(); + void QTBUG12260_defaultTemplate(); signals: void sigWithUnsignedArg(unsigned foo); void sigWithSignedArg(signed foo); @@ -1340,6 +1341,20 @@ signals: void testSignal(TestTemplate2); }; +class QTBUG12260_defaultTemplate_Object : public QObject +{ Q_OBJECT +public slots: + void doSomething(QHash values = QHash()) { Q_UNUSED(values); } + void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); } +}; + + +void tst_Moc::QTBUG12260_defaultTemplate() +{ + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash)") != -1); + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1); +} + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" -- cgit v0.12 From ebf650dd893a8f6ace2252cd2a18ee895520f29d Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 19 Jul 2010 19:05:53 +0200 Subject: Check in the correct configure.exe Reviewed-By: Alessandro Portale --- configure.exe | Bin 1686528 -> 1317888 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 104923b..eea40f9 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 83d799a00dd4417f6d2efb02781e332f510dab6a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 20 Jul 2010 08:58:08 +1000 Subject: Improve QML text rendering when LCD smoothing is enabled for OS X. Text in QML is always painted into a pixmap, and with sub-pixel antialiasing enabled this produced incorrect results. This patch is a temporary fix until QTBUG-12252 and/or QTBUG-7747 can be properly addressed in a patch release. In the worst case, if using QML and QPainters are being constructed in a non-GUI thread, this patch could potentially turn off sub-pixel antialiasing for them. Task-number: QTBUG-11002 Reviewed-by: Aaron Kennedy Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../graphicsitems/qdeclarativepainteditem.cpp | 16 ++++++++++++++++ src/declarative/graphicsitems/qdeclarativetext.cpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index 3b9b8df..a6db1fa 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -90,6 +90,8 @@ QT_BEGIN_NAMESPACE static int inpaint=0; static int inpaint_clearcache=0; +extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; + /*! Marks areas of the cache that intersect with the given \a rect as dirty and in need of being refreshed. @@ -287,7 +289,14 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem QRectF target(area.x(), area.y(), area.width(), area.height()); if (!d->cachefrozen) { if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif QPainter qp(&d->imagecache[i]->image); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-area.x(), -area.y()); qp.scale(d->contentsScale,d->contentsScale); @@ -349,7 +358,14 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem if (d->fillColor.isValid()) img.fill(d->fillColor); { +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif QPainter qp(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-r.x(),-r.y()); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index ba4fa21..d63d633 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE +extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; + class QTextDocumentWithImageResources : public QTextDocument { Q_OBJECT @@ -1028,7 +1030,14 @@ QPixmap QDeclarativeTextPrivate::wrappedTextImage(bool drawStyle) QPixmap img(size); if (!size.isEmpty()) { img.fill(Qt::transparent); +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif QPainter p(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif drawWrappedText(&p, QPointF(0,0), drawStyle); } return img; @@ -1051,7 +1060,14 @@ QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle) //paint text QPixmap img(size); img.fill(Qt::transparent); +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif QPainter p(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif QAbstractTextDocumentLayout::PaintContext context; -- cgit v0.12 From 17cc89e918a969d85d2b46631ee8743288c7586d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 20 Jul 2010 10:14:38 +1000 Subject: Ensure released VisualItemModel items are removed from the scene. Also parent them back to the VIM to ensure correct destruction. Task-number: QTBUG-12261 --- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 8 +++--- .../qdeclarativerepeater/data/itemlist.qml | 29 +++++++++++++++++++--- .../tst_qdeclarativerepeater.cpp | 9 +++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index cfa1c6d..7952b97 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -77,7 +77,7 @@ public: QDeclarativeVisualItemModelPrivate() : QObjectPrivate() {} static void children_append(QDeclarativeListProperty *prop, QDeclarativeItem *item) { - item->QObject::setParent(prop->object); + QDeclarative_setParent_noEvent(item, prop->object); static_cast(prop->data)->children.append(item); static_cast(prop->data)->itemAppended(); static_cast(prop->data)->emitChildrenChanged(); @@ -185,9 +185,11 @@ QDeclarativeItem *QDeclarativeVisualItemModel::item(int index, bool) return d->children.at(index); } -QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDeclarativeItem *) +QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDeclarativeItem *item) { - // Nothing to do + if (item->scene()) + item->scene()->removeItem(item); + QDeclarative_setParent_noEvent(item, this); return 0; } diff --git a/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml index e8dd8cc..4810736 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml @@ -4,21 +4,27 @@ import Qt 4.7 Rectangle { + id: root color: "lightgray" width: 240 height: 320 + property variant itemModel: itemModel1 function checkProperties() { testObject.error = false; - if (testObject.useModel && view.model != itemModel) { + if (testObject.useModel && view.model != root.itemModel) { console.log("model property incorrect"); testObject.error = true; } } + function switchModel() { + root.itemModel = itemModel2 + } + VisualItemModel { - id: itemModel - objectName: "itemModel" + id: itemModel1 + objectName: "itemModel1" Rectangle { objectName: "item1" height: 50; width: 100; color: "#FFFEF0" @@ -36,12 +42,27 @@ Rectangle { } } + VisualItemModel { + id: itemModel2 + objectName: "itemModel2" + Rectangle { + objectName: "item4" + height: 50; width: 100; color: "#FFFEF0" + Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item5" + height: 50; width: 100; color: "#F0FFF7" + Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + } + Column { objectName: "container" Repeater { id: view objectName: "repeater" - model: testObject.useModel ? itemModel : 0 + model: testObject.useModel ? root.itemModel : 0 } } } diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 7299a43..623b3d7 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -361,6 +361,15 @@ void tst_QDeclarativeRepeater::itemModel() QVERIFY(qobject_cast(container->childItems().at(2))->objectName() == "item3"); QVERIFY(container->childItems().at(3) == repeater); + QMetaObject::invokeMethod(canvas->rootObject(), "switchModel"); + QCOMPARE(container->childItems().count(), 3); + QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item4"); + QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item5"); + QVERIFY(container->childItems().at(2) == repeater); + + testObject->setUseModel(false); + QCOMPARE(container->childItems().count(), 1); + delete testObject; delete canvas; } -- cgit v0.12 From 06ef198e0812b514c261ef8f7c82db754450f1fa Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 20 Jul 2010 11:28:36 +1000 Subject: Improve documentation on setting arbitray transform origin points transformOriginPoint is undocumented for a reason. It shouldn't be used by Item. Added some docs to assist find the right way, i.e. Scale and Rotation elements. Task-number: QTBUG-12265 --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 367a5d0..9d70beb 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1514,6 +1514,9 @@ QDeclarativeItem::~QDeclarativeItem() \endqml The default transform origin is \c Item.Center. + + To set an arbitrary transform origin point use the \l Scale or \l Rotation + transform elements. */ /*! @@ -2192,6 +2195,8 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) } \endqml \endtable + + \sa transform, Rotation */ /*! @@ -2228,6 +2233,8 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) } \endqml \endtable + + \sa transform, Scale */ /*! -- cgit v0.12 From 8e19cbbad806b710e03ff17e80646e0274cf63cc Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 19 Jul 2010 12:20:11 +1000 Subject: Change docs to show how to define enum properties --- doc/src/declarative/extending-tutorial.qdoc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index cc93e86..bc849b0 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -260,20 +260,34 @@ custom QML types may see unexpected behavior if bindings are not implemented. \example declarative/tutorials/extending/chapter4-customPropertyTypes The \c PieChart type currently has a string-type property and a color-type property. -It could have many other types of properties. For example, we could add an -integer-type property to store an identifier for each pie chart: +It could have many other types of properties. For example, it could have an +enum-type property to store a display mode for each chart: \code + // C++ class PieChart : public QDeclarativeItem { + Q_ENUMS(DisplayMode) + Q_PROPERTY(DisplayMode displayMode READ displayMode WRITE setDisplayMode) ... - Q_PROPERTY(int id READ id WRITE setId) + public: - ... - int id() const; - void setId(int id); + enum DisplayMode { + MultiLevel, + Exploded, + ThreeDimensional + }; + + void setDisplayMode(DisplayMode mode); + DisplayMode displayMode() const; ... }; + + // QML + PieChart { + ... + displayMode: PieChart.Exploded + } \endcode We can also use various other property types. QML has built-in support for the following -- cgit v0.12 From c95889b7896dc5418841ef72326d99296943e616 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 20 Jul 2010 11:40:37 +1000 Subject: fixes for dynamic object creation docs --- doc/src/declarative/dynamicobjects.qdoc | 77 ++++++++++++++--------- doc/src/snippets/declarative/componentCreation.js | 63 ++++++++++--------- doc/src/snippets/declarative/createComponent.qml | 4 +- doc/src/snippets/declarative/createQmlObject.qml | 3 +- 4 files changed, 84 insertions(+), 63 deletions(-) diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index a5e53a9..6bce4fa 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -39,31 +39,35 @@ QML also supports the dynamic creation of objects from within JavaScript code. This is useful if the existing QML elements do not fit the needs of your application, and there are no C++ components involved. -See the {declarative/toys/dynamicscene}{Dynamic Scene example} for a demonstration +See the \l {declarative/toys/dynamicscene}{Dynamic Scene example} for a demonstration of the concepts discussed on this page. \section1 Creating Objects Dynamically There are two ways to create objects dynamically from JavaScript. You can either call -\l {QML:Qt::createComponent()}{Qt.createComponent()} to create -a component which instantiates items, or use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} +\l {QML:Qt::createComponent()}{Qt.createComponent()} to dynamically create +a \l Component object, or use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} to create an item from a string of QML. -Creating a component is better if you have a predefined -item, and you want to create dynamic instances of that item; creating an item from -a string of QML is useful when the item QML itself is generated at runtime. +Creating a component is better if you have an existing component defined in a \c .qml +file, and you want to dynamically create instances of that component. Otherwise, +creating an item from a string of QML is useful when the item QML itself is generated +at runtime. -If you have a component specified in a QML file, you can dynamically load it with -the \l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. -This function takes the URL of the QML file as its only argument and returns -a component object which can be used to create and load that QML file. -Once you have a component you can use its \l {Component::createObject()}{createObject()} method to create an instance of +\section2 Creating a Component dynamically + +To dynamically load a component defined in a QML file, call the +\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. +This function takes the URL of the QML file as its only argument and creates +a \l Component object from this URL. + +Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of the component. This function takes exactly one argument, which is the parent for the new item. Since graphical items will not appear on the scene without a parent, it is recommended that you set the parent this way. However, if you wish to set -the parent later you can safely pass null to this function. +the parent later you can safely pass \c null to this function. -Here is an example. Here is a \c Sprite.qml, which defines a simple QML component: +Here is an example. First there is \c Sprite.qml, which defines a simple QML component: \snippet doc/src/snippets/declarative/Sprite.qml 0 @@ -72,35 +76,48 @@ that will create \c Sprite objects: \snippet doc/src/snippets/declarative/createComponent.qml 0 -Here is \c componentCreation.js. Remember that QML files that might be loaded -over the network cannot be expected to be ready immediately: +Here is \c componentCreation.js. Notice it checks whether the component \l{Component::status}{status} is +\c Component.Ready before calling \l {Component::createObject()}{createObject()} +in case the QML file is loaded over a network and thus is not ready immediately. -\snippet doc/src/snippets/declarative/componentCreation.js 0 +\snippet doc/src/snippets/declarative/componentCreation.js vars \codeline -\snippet doc/src/snippets/declarative/componentCreation.js 1 +\snippet doc/src/snippets/declarative/componentCreation.js func +\snippet doc/src/snippets/declarative/componentCreation.js remote +\snippet doc/src/snippets/declarative/componentCreation.js func-end +\codeline +\snippet doc/src/snippets/declarative/componentCreation.js finishCreation -If you are certain the files will be local, you could simplify to: +If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() +function and call \l {Component::createObject()}{createObject()} immediately: -\snippet doc/src/snippets/declarative/componentCreation.js 2 +\snippet doc/src/snippets/declarative/componentCreation.js func +\snippet doc/src/snippets/declarative/componentCreation.js local +\snippet doc/src/snippets/declarative/componentCreation.js func-end -Notice that once a \c Sprite object is created, its parent is set to \c appWindow (defined -in \c main.qml). After creating an item, you must set its parent to an item within the scene. -Otherwise your dynamically created item will not appear in the scene. +Notice in both instances, \l {Component::createObject()}{createObject()} is called with +\c appWindow passed as an argument so that the created object will become a child of the +\c appWindow item in \c main.qml. Otherwise, the new item will not appear in the scene. When using files with relative paths, the path should be relative to the file where \l {QML:Qt::createComponent()}{Qt.createComponent()} is executed. -If the QML component does not exist until runtime, you can create a QML item from + +\section2 Creating an object from a string of QML + +If the QML is not defined until runtime, you can create a QML item from a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: \snippet doc/src/snippets/declarative/createQmlObject.qml 0 The first argument is the string of QML to create. Just like in a new file, you will need to -import any types you wish to use. For importing files with relative paths, the path should -be relative to the file where the item in the second argument is defined. Remember to set the parent after -creating the item. The second argument is another item in the scene, and the new item is created -in the same QML Context as this item. The third argument is the file path associated with this -item, which is used for error reporting. +import any types you wish to use. The second argument is the parent item for the new item; +this should be an existing item in the scene. The third argument is the file path to associate +with the new item; this is used for error reporting. + +If the string of QML imports files using relative paths, the path should be relative +to the file in which the parent item (the second argument to the method) is defined. + \section1 Maintaining Dynamically Created Objects @@ -114,9 +131,9 @@ The actual creation context depends on how an item is created: \o If \l {QML:Qt::createComponent()}{Qt.createComponent()} is used, the creation context is the QDeclarativeContext in which this method is called \o If \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} - if called, it is the context of the item used as the second argument to this method + if called, the creation context is the context of the parent item passed to this method \o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()} - is called on that item, it is the context in which the \c Component is defined + is called on that item, the creation context is the context in which the \c Component is defined \endlist Also, note that while dynamically created objects may be used the same as other objects, they diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js index 25bc10c..c29a1f9 100644 --- a/doc/src/snippets/declarative/componentCreation.js +++ b/doc/src/snippets/declarative/componentCreation.js @@ -1,7 +1,39 @@ -//![0] +//![vars] var component; var sprite; +//![vars] +//![func] +function createSpriteObjects() { +//![func] + +//![remote] + component = Qt.createComponent("Sprite.qml"); + if (component.status == Component.Ready) + finishCreation(); + else + component.statusChanged.connect(finishCreation); +//![remote] + +//![local] + component = Qt.createComponent("Sprite.qml"); + sprite = component.createObject(appWindow); + + if (sprite == null) { + // Error Handling + console.log("Error creating object"); + } else { + sprite.x = 100; + sprite.y = 100; + // ... + } +//![local] + +//![func-end] +} +//![func-end] + +//![finishCreation] function finishCreation() { if (component.status == Component.Ready) { sprite = component.createObject(appWindow); @@ -17,31 +49,4 @@ function finishCreation() { console.log("Error loading component:", component.errorString()); } } -//![0] - -function createSpriteObjects() { - -//![1] -component = Qt.createComponent("Sprite.qml"); -if (component.status == Component.Ready) - finishCreation(); -else - component.statusChanged.connect(finishCreation); -//![1] - -//![2] -component = Qt.createComponent("Sprite.qml"); -sprite = component.createObject(appWindow); - -if (sprite == null) { - // Error Handling - console.log("Error loading component:", component.errorString()); -} else { - sprite.x = 100; - sprite.y = 100; - // ... -} -//![2] - -} - +//![finishCreation] diff --git a/doc/src/snippets/declarative/createComponent.qml b/doc/src/snippets/declarative/createComponent.qml index 8bfed07..0f9fad5 100644 --- a/doc/src/snippets/declarative/createComponent.qml +++ b/doc/src/snippets/declarative/createComponent.qml @@ -40,12 +40,12 @@ //![0] import Qt 4.7 -import "componentCreation.js" as MyModule +import "componentCreation.js" as MyScript Rectangle { id: appWindow width: 300; height: 300 - Component.onCompleted: MyModule.createSpriteObjects(); + Component.onCompleted: MyScript.createSpriteObjects(); } //![0] diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/declarative/createQmlObject.qml index 380f6f1..64dd21d 100644 --- a/doc/src/snippets/declarative/createQmlObject.qml +++ b/doc/src/snippets/declarative/createQmlObject.qml @@ -42,14 +42,13 @@ import Qt 4.7 Rectangle { id: parentItem - property QtObject newObject width: 100 height: 100 function createIt() { //![0] -newObject = Qt.createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}', +var newObject = Qt.createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}', parentItem, "dynamicSnippet1"); //![0] } -- cgit v0.12 From 5b39b47255d04675f15b242252565ec0b7e8e78e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 20 Jul 2010 11:44:05 +1000 Subject: various doc improvements for animation elements --- doc/src/snippets/declarative/behavior.qml | 59 +++++ doc/src/snippets/declarative/parallelanimation.qml | 57 +++++ doc/src/snippets/declarative/parentchange.qml | 5 +- doc/src/snippets/declarative/rotationanimation.qml | 66 ++++++ .../snippets/declarative/sequentialanimation.qml | 57 +++++ doc/src/snippets/declarative/springanimation.qml | 6 +- src/declarative/qml/qdeclarativeengine.cpp | 15 +- src/declarative/util/qdeclarativeanimation.cpp | 257 +++++++++++---------- src/declarative/util/qdeclarativebehavior.cpp | 39 ++-- .../util/qdeclarativesmoothedanimation.cpp | 31 +-- .../util/qdeclarativespringanimation.cpp | 39 ++-- src/declarative/util/qdeclarativetransition.cpp | 2 - 12 files changed, 445 insertions(+), 188 deletions(-) create mode 100644 doc/src/snippets/declarative/behavior.qml create mode 100644 doc/src/snippets/declarative/parallelanimation.qml create mode 100644 doc/src/snippets/declarative/rotationanimation.qml create mode 100644 doc/src/snippets/declarative/sequentialanimation.qml diff --git a/doc/src/snippets/declarative/behavior.qml b/doc/src/snippets/declarative/behavior.qml new file mode 100644 index 0000000..420dfc4 --- /dev/null +++ b/doc/src/snippets/declarative/behavior.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + Behavior on width { + NumberAnimation { duration: 1000 } + } + + MouseArea { + anchors.fill: parent + onClicked: rect.width = 50 + } +} +//![0] diff --git a/doc/src/snippets/declarative/parallelanimation.qml b/doc/src/snippets/declarative/parallelanimation.qml new file mode 100644 index 0000000..d823b4f --- /dev/null +++ b/doc/src/snippets/declarative/parallelanimation.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + ParallelAnimation { + running: true + NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } + NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } + } +} +//![0] + diff --git a/doc/src/snippets/declarative/parentchange.qml b/doc/src/snippets/declarative/parentchange.qml index 7f5718a..ea50832 100644 --- a/doc/src/snippets/declarative/parentchange.qml +++ b/doc/src/snippets/declarative/parentchange.qml @@ -41,9 +41,8 @@ //![0] import Qt 4.7 -Rectangle { - width: 200 - height: 100 +Item { + width: 200; height: 100 Rectangle { id: redRect diff --git a/doc/src/snippets/declarative/rotationanimation.qml b/doc/src/snippets/declarative/rotationanimation.qml new file mode 100644 index 0000000..c81395a --- /dev/null +++ b/doc/src/snippets/declarative/rotationanimation.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Item { + width: 300; height: 300 + + Rectangle { + id: rect + width: 150; height: 100; anchors.centerIn: parent + color: "red" + smooth: true + + states: State { + name: "rotated"; PropertyChanges { target: rect; rotation: 180 } + } + + transitions: Transition { + RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } + } + } + + MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" } +} +//![0] + diff --git a/doc/src/snippets/declarative/sequentialanimation.qml b/doc/src/snippets/declarative/sequentialanimation.qml new file mode 100644 index 0000000..a15f7f3 --- /dev/null +++ b/doc/src/snippets/declarative/sequentialanimation.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import Qt 4.7 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + SequentialAnimation { + running: true + NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } + NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } + } +} +//![0] + diff --git a/doc/src/snippets/declarative/springanimation.qml b/doc/src/snippets/declarative/springanimation.qml index b73a9d2..8e810e1 100644 --- a/doc/src/snippets/declarative/springanimation.qml +++ b/doc/src/snippets/declarative/springanimation.qml @@ -41,7 +41,7 @@ //![0] import Qt 4.7 -Rectangle { +Item { width: 300; height: 300 Rectangle { @@ -56,8 +56,8 @@ Rectangle { MouseArea { anchors.fill: parent onClicked: { - rect.x = mouse.x - rect.y = mouse.y + rect.x = mouse.x - rect.width/2 + rect.y = mouse.y - rect.height/2 } } } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index f2eb770..d1ba6ce 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1080,13 +1080,20 @@ Here is an example. Notice it checks whether the component \l{Component::status} \c Component.Ready before calling \l {Component::createObject()}{createObject()} in case the QML file is loaded over a network and thus is not ready immediately. -\snippet doc/src/snippets/declarative/componentCreation.js 0 +\snippet doc/src/snippets/declarative/componentCreation.js vars \codeline -\snippet doc/src/snippets/declarative/componentCreation.js 1 +\snippet doc/src/snippets/declarative/componentCreation.js func +\snippet doc/src/snippets/declarative/componentCreation.js remote +\snippet doc/src/snippets/declarative/componentCreation.js func-end +\codeline +\snippet doc/src/snippets/declarative/componentCreation.js finishCreation -If you are certain the files will be local, you could simplify to: +If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() +function and call \l {Component::createObject()}{createObject()} immediately: -\snippet doc/src/snippets/declarative/componentCreation.js 2 +\snippet doc/src/snippets/declarative/componentCreation.js func +\snippet doc/src/snippets/declarative/componentCreation.js local +\snippet doc/src/snippets/declarative/componentCreation.js func-end To create a QML object from an arbitrary string of QML (instead of a file), use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}. diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 88ec5ba..3617031 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -632,17 +632,18 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation() \qmlclass ColorAnimation QDeclarativeColorAnimation \since 4.7 \inherits PropertyAnimation - \brief The ColorAnimation element allows you to animate color changes. + \brief The ColorAnimation element animates changes in color values. - ColorAnimation defines an animation to be applied when a color value - changes. + ColorAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a color value changes. Here is a ColorAnimation applied to the \c color property of a \l Rectangle - as a property value source: + as a property value source. It animates the \c color property's value from + its current value to a value of "red", over 1000 milliseconds: \snippet doc/src/snippets/declarative/coloranimation.qml 0 - Like any other animation element, a NumberAnimation can be applied in a + Like any other animation element, a ColorAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The \l PropertyAnimation documentation shows a variety of methods for creating animations. @@ -674,11 +675,12 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation() /*! \qmlproperty color ColorAnimation::from - This property holds the starting color. + This property holds the color value at which the animation should begin. For example, the following animation is not applied until a color value has reached "#c0c0c0": + \qml Item { states: [ ... ] @@ -686,6 +688,11 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation() NumberAnimation { from: "#c0c0c0"; duration: 2000 } } } + \endqml + + If this value is not set and the ColorAnimation is defined within + a \l Transition, it defaults to the value defined in the starting + state of the \l Transition. */ QColor QDeclarativeColorAnimation::from() const { @@ -700,7 +707,12 @@ void QDeclarativeColorAnimation::setFrom(const QColor &f) /*! \qmlproperty color ColorAnimation::to - This property holds the ending color. + + This property holds the color value at which the animation should end. + + If this value is not set and the ColorAnimation is defined within + a \l Transition or \l Behavior, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ QColor QDeclarativeColorAnimation::to() const { @@ -869,18 +881,27 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation() \inherits Animation \brief The PropertyAction element allows immediate property changes during animation. - Explicitly set \c theimage.smooth=true during a transition: + PropertyAction is used to specify an immediate property change + during an animation. The property change is not animated. + + For example, to explicitly set \c {theImage.smooth = true} during a \l Transition: \code - PropertyAction { target: theimage; property: "smooth"; value: true } + transitions: Transition { + ... + PropertyAction { target: theImage; property: "smooth"; value: true } + ... + } \endcode - Set \c thewebview.url to the value set for the destination state: + Or, to set \c theWebView.url to the value set for the destination state: \code - PropertyAction { target: thewebview; property: "url" } + transitions: Transition { + ... + PropertyAction { target: theWebView; property: "url" } + ... + } \endcode - The PropertyAction is immediate - - the target property is not animated to the selected value in any way. \sa QtDeclarative */ @@ -906,14 +927,6 @@ void QDeclarativePropertyActionPrivate::init() QDeclarative_setParent_noEvent(spa, q); } -/*! - \qmlproperty Object PropertyAction::target - This property holds an explicit target object to animate. - - The exact effect of the \c target property depends on how the animation - is being used. Refer to the \l {QML Animation} documentation for details. -*/ - QObject *QDeclarativePropertyAction::target() const { Q_D(const QDeclarativePropertyAction); @@ -945,12 +958,12 @@ void QDeclarativePropertyAction::setProperty(const QString &n) } /*! + \qmlproperty Object PropertyAction::target \qmlproperty list PropertyAction::targets \qmlproperty string PropertyAction::property \qmlproperty string PropertyAction::properties - \qmlproperty Object PropertyAction::target - These properties are used as a set to determine which properties should be + These properties determine the items and their properties that are affected by this action. The details of how these properties are interpreted in different situations @@ -982,7 +995,7 @@ QDeclarativeListProperty QDeclarativePropertyAction::targets() /*! \qmlproperty list PropertyAction::exclude - This property holds the objects not to be affected by this animation. + This property holds the objects that should not be affected by this action. \sa targets */ @@ -1117,13 +1130,14 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions, \qmlclass NumberAnimation QDeclarativeNumberAnimation \since 4.7 \inherits PropertyAnimation - \brief The NumberAnimation element allows you to animate changes in properties of type qreal. + \brief The NumberAnimation element animates changes in qreal-type values. - NumberAnimation defines an animation to be applied when a numerical value - changes. + NumberAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a numerical value changes. Here is a NumberAnimation applied to the \c x property of a \l Rectangle - as a property value source: + as a property value source. It animates the \c x value from its current + value to a value of 50, over 1000 milliseconds: \snippet doc/src/snippets/declarative/numberanimation.qml 0 @@ -1174,6 +1188,7 @@ void QDeclarativeNumberAnimation::init() For example, the following animation is not applied until the \c x value has reached 100: + \qml Item { states: [ ... ] @@ -1181,8 +1196,10 @@ void QDeclarativeNumberAnimation::init() NumberAnimation { properties: "x"; from: 100; duration: 200 } } } + \endqml - If this value is not set, it defaults to the value defined in the start + If this value is not set and the NumberAnimation is defined within + a \l Transition, it defaults to the value defined in the start state of the \l Transition. */ @@ -1201,7 +1218,8 @@ void QDeclarativeNumberAnimation::setFrom(qreal f) \qmlproperty real NumberAnimation::to This property holds the ending number value. - If this value is not set, it defaults to the value defined in the end + If this value is not set and the NumberAnimation is defined within + a \l Transition or \l Behavior, it defaults to the value defined in the end state of the \l Transition or \l Behavior. */ qreal QDeclarativeNumberAnimation::to() const @@ -1221,7 +1239,10 @@ void QDeclarativeNumberAnimation::setTo(qreal t) \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation \since 4.7 \inherits PropertyAnimation - \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d. + \brief The Vector3dAnimation element animates changes in QVector3d values. + + Vector3dAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a Vector3d value changes. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1286,31 +1307,32 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t) \qmlclass RotationAnimation QDeclarativeRotationAnimation \since 4.7 \inherits PropertyAnimation - \brief The RotationAnimation element allows you to animate rotations. + \brief The RotationAnimation element animates changes in rotation values. RotationAnimation is a specialized PropertyAnimation that gives control - over the direction of rotation. By default, it will rotate in the direction + over the direction of rotation during an animation. + + By default, it rotates in the direction of the numerical change; a rotation from 0 to 240 will rotate 220 degrees clockwise, while a rotation from 240 to 0 will rotate 220 degrees - counterclockwise. + counterclockwise. The \l direction property can be set to specify the + direction in which the rotation should occur. + + In the following example we use RotationAnimation to animate the rotation + between states via the shortest path: - When used in a transition RotationAnimation will rotate all + \snippet doc/src/snippets/declarative/rotationanimation.qml 0 + + Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target} + value. As a convenience, when used in a transition, RotationAnimation will rotate all properties named "rotation" or "angle". You can override this by providing your own properties via \l {PropertyAnimation::properties}{properties} or \l {PropertyAnimation::property}{property}. - In the following example we use RotationAnimation to animate the rotation - between states via the shortest path. - \qml - states: { - State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } } - State { name: "90"; PropertyChanges { target: myItem; rotation: 90 } } - State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } } - } - transition: Transition { - RotationAnimation { direction: RotationAnimation.Shortest } - } - \endqml + Like any other animation element, a RotationAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1377,6 +1399,7 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation() For example, the following animation is not applied until the \c angle value has reached 100: + \qml Item { states: [ ... ] @@ -1384,6 +1407,7 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation() RotationAnimation { properties: "angle"; from: 100; duration: 2000 } } } + \endqml If this value is not set, it defaults to the value defined in the start state of the \l Transition. @@ -1419,7 +1443,7 @@ void QDeclarativeRotationAnimation::setTo(qreal t) /*! \qmlproperty enumeration RotationAnimation::direction - The direction in which to rotate. + This property holds the direction of the rotation. Possible values are: @@ -1512,19 +1536,26 @@ QDeclarativeListProperty QDeclarativeAnimationGro \qmlclass SequentialAnimation QDeclarativeSequentialAnimation \since 4.7 \inherits Animation - \brief The SequentialAnimation element allows you to run animations sequentially. + \brief The SequentialAnimation element allows animations to be run sequentially. - Animations controlled in SequentialAnimation will be run one after the other. + The SequentialAnimation and ParallelAnimation elements allow multiple + animations to be run together. Animations defined in a SequentialAnimation + are run one after the other, while animations defined in a ParallelAnimation + are run at the same time. - The following example chains two numeric animations together. The \c MyItem - object will animate from its current x position to 100, and then back to 0. + The following example runs two number animations in a sequence. The \l Rectangle + animates to a \c x position of 50, then to a \c y position of 50. - \code - SequentialAnimation { - NumberAnimation { target: MyItem; property: "x"; to: 100 } - NumberAnimation { target: MyItem; property: "x"; to: 0 } - } - \endcode + \snippet doc/src/snippets/declarative/sequentialanimation.qml 0 + + Animations defined within a \l Transition are automatically run in parallel, + so SequentialAnimation can be used to enclose the animations in a \l Transition + if this is the preferred behavior. + + Like any other animation element, a SequentialAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. \sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1574,19 +1605,22 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio \qmlclass ParallelAnimation QDeclarativeParallelAnimation \since 4.7 \inherits Animation - \brief The ParallelAnimation element allows you to run animations in parallel. + \brief The ParallelAnimation element allows animations to be run in parallel. - Animations contained in ParallelAnimation will be run at the same time. + The SequentialAnimation and ParallelAnimation elements allow multiple + animations to be run together. Animations defined in a SequentialAnimation + are run one after the other, while animations defined in a ParallelAnimation + are run at the same time. - The following animation demonstrates animating the \c MyItem item - to (100,100) by animating the x and y properties in parallel. + The following animation runs two number animations in parallel. The \l Rectangle + moves to (50,50) by animating its \c x and \c y properties at the same time. - \code - ParallelAnimation { - NumberAnimation { target: MyItem; property: "x"; to: 100 } - NumberAnimation { target: MyItem; property: "y"; to: 100 } - } - \endcode + \snippet doc/src/snippets/declarative/parallelanimation.qml 0 + + Like any other animation element, a ParallelAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. \sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1685,7 +1719,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int \qmlclass PropertyAnimation QDeclarativePropertyAnimation \since 4.7 \inherits Animation - \brief The PropertyAnimation element allows you to animate property changes. + \brief The PropertyAnimation element animates changes in property values. PropertyAnimation provides a way to animate changes to a property's value. @@ -2353,43 +2387,30 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions \qmlclass ParentAnimation QDeclarativeParentAnimation \since 4.7 \inherits Animation - \brief The ParentAnimation element allows you to animate parent changes. + \brief The ParentAnimation element animates changes in parent values. - ParentAnimation is used in conjunction with NumberAnimation to smoothly - animate changing an item's parent. In the following example, - ParentAnimation wraps a NumberAnimation which animates from the - current position in the old parent to the new position in the new - parent. + ParentAnimation defines an animation to applied when a ParentChange + occurs. This allows parent changes to be smoothly animated. - \qml - ... - State { - //reparent myItem to newParent. myItem's final location - //should be 10,10 in newParent. - ParentChange { - target: myItem - parent: newParent - x: 10; y: 10 - } - } - ... - Transition { - //smoothly reparent myItem and move into new position - ParentAnimation { - target: theItem - NumberAnimation { properties: "x,y" } - } - } - \endqml + For example, the following ParentChange changes \c blueRect to become + a child of \c redRect when it is clicked. The inclusion of the + ParentAnimation, which defines a NumberAnimation to be applied during + the transition, ensures the item animates smoothly as it moves to + its new parent: + + \snippet doc/src/snippets/declarative/parentanimation.qml 0 - ParentAnimation can wrap any number of animations -- those animations will - be run in parallel (like those in a ParallelAnimation group). + A ParentAnimation can contain any number of animations. These animations will + be run in parallel; to run them sequentially, define them within a + SequentialAnimation. - In some cases, such as reparenting between items with clipping, it's useful - to animate the parent change via another item with no clipping. + In some cases, such as when reparenting between items with clipping enabled, it is useful + to animate the parent change via another item that does not have clipping + enabled. Such an item can be set using the \l via property. - When used in a transition, ParentAnimation will by default animate - all ParentChanges. + By default, when used in a transition, ParentAnimation animates all parent + changes. This can be overriden by setting a specific target item using the + \l target property. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -2426,8 +2447,8 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation() \qmlproperty Item ParentAnimation::target The item to reparent. - When used in a transition, if no target is specified all - ParentChanges will be animated by the ParentAnimation. + When used in a transition, if no target is specified, all + ParentChange occurrences are animated by the ParentAnimation. */ QDeclarativeItem *QDeclarativeParentAnimation::target() const { @@ -2470,7 +2491,7 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent) /*! \qmlproperty Item ParentAnimation::via The item to reparent via. This provides a way to do an unclipped animation - when both the old parent and new parent are clipped + when both the old parent and new parent are clipped. \qml ParentAnimation { @@ -2720,28 +2741,14 @@ QAbstractAnimation *QDeclarativeParentAnimation::qtAnimation() \qmlclass AnchorAnimation QDeclarativeAnchorAnimation \since 4.7 \inherits Animation - \brief The AnchorAnimation element allows you to animate anchor changes. + \brief The AnchorAnimation element animates changes in anchor values. - AnchorAnimation will animated any changes specified by a state's AnchorChanges. - In the following snippet we animate the addition of a right anchor to our item. - \qml - Item { - id: myItem - width: 100 - } - ... - State { - AnchorChanges { - target: myItem - anchors.right: container.right - } - } - ... - Transition { - //smoothly reanchor myItem and move into new position - AnchorAnimation {} - } - \endqml + AnchorAnimation is used to animate an AnchorChange. It will anchor all + anchor changes specified in a \l State. + + In the following snippet we animate the addition of a right anchor to a \l Rectangle: + + \snippet doc/src/snippets/declarative/anchoranimation.qml 0 \sa AnchorChanges */ diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 2bb28c3..3719085 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -75,28 +75,21 @@ public: \since 4.7 \brief The Behavior element allows you to specify a default animation for a property change. - Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML. - - In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property: - \code - Rectangle { - width: 20; height: 20 - color: "#00ff00" - y: 200 // initial value - Behavior on y { - NumberAnimation { - easing.type: Easing.OutBounce - easing.amplitude: 100 - duration: 200 - } - } - } - \endcode + A Behavior defines the default animation to be applied whenever a + particular property value changes. + + For example, the following Behavior defines a NumberAnimation to be run + whenever the \l Rectangle's \c width value changes. When the MouseArea + is clicked, the \c width is changed, triggering the behavior's animation: + + \snippet doc/src/snippets/declarative/behavior.qml 0 - Currently only a single Behavior may be specified for a property; - this Behavior can be enabled and disabled via the \l{enabled} property. + To run multiple animations within a Behavior, use ParallelAnimation or + SequentialAnimation. - \sa {declarative/animation/behaviors}{Behavior example}, QtDeclarative + Note that a property cannot have more than one assigned Behavior. + + \sa {Property Behaviors}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative */ @@ -113,7 +106,7 @@ QDeclarativeBehavior::~QDeclarativeBehavior() \qmlproperty Animation Behavior::animation \default - The animation to use when the behavior is triggered. + This property holds the animation to run when the behavior is triggered. */ QDeclarativeAbstractAnimation *QDeclarativeBehavior::animation() @@ -152,7 +145,9 @@ void QDeclarativeBehavior::qtAnimationStateChanged(QAbstractAnimation::State new /*! \qmlproperty bool Behavior::enabled - Whether the Behavior will be triggered when the property it is tracking changes. + + This property holds whether the behavior will be triggered when the tracked + property changes value. By default a Behavior is enabled. */ diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index e0d1097..11c3d4b 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -253,15 +253,22 @@ void QSmoothedAnimation::init() \inherits NumberAnimation \brief The SmoothedAnimation element allows a property to smoothly track a value. - The SmoothedAnimation animates a property's value to a set target value - using an ease in/out quad easing curve. If the animation is restarted - with a different target value, the easing curves used to animate to the old - and the new target values are smoothly spliced together to avoid any obvious - visual glitches by maintaining the current velocity. - - The property animation is configured by setting the velocity at which the - animation should occur, or the duration that the animation should take. - If both a velocity and a duration are specified, the one that results in + A SmoothedAnimation animates a property's value to a set target value + using an ease in/out quad easing curve. When the target value changes, + the easing curves used to animate between the old and new target values + are smoothly spliced together to create a smooth movement to the new + target value that maintains the current velocity. + + The follow example shows one \l Rectangle tracking the position of another + using SmoothedAnimation. The green rectangle's \c x and \c y values are + bound to those of the red rectangle. Whenever these values change, the + green rectangle smoothly animates to its new position: + + \snippet doc/src/snippets/declarative/smoothedanimation.qml 0 + + A SmoothedAnimation can be configured by setting the \l velocity at which the + animation should occur, or the \l duration that the animation should take. + If both the \l velocity and \l duration are specified, the one that results in the quickest animation is chosen for each change in the target value. For example, animating from 0 to 800 will take 4 seconds if a velocity @@ -271,10 +278,6 @@ void QSmoothedAnimation::init() will take 8 seconds with a duration of 8000 set, and will take 8 seconds with both a velocity of 200 and a duration of 8000 set. - The follow example shows one rectangle tracking the position of another. - - \snippet doc/src/snippets/declarative/smoothedanimation.qml 0 - The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the value being animated is small, then the velocity will need to be adjusted appropriately. For example, the opacity of an item ranges from 0 - 1.0. @@ -287,7 +290,7 @@ void QSmoothedAnimation::init() sources. The \l PropertyAnimation documentation shows a variety of methods for creating animations. - \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} + \sa SpringAnimation, NumberAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} */ QDeclarativeSmoothedAnimation::QDeclarativeSmoothedAnimation(QObject *parent) diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp index be0af6d..8ce4832 100644 --- a/src/declarative/util/qdeclarativespringanimation.cpp +++ b/src/declarative/util/qdeclarativespringanimation.cpp @@ -215,7 +215,9 @@ void QDeclarativeSpringAnimationPrivate::updateMode() You can also limit the maximum \l velocity of the animation. The following \l Rectangle moves to the position of the mouse using a - SpringAnimation when the mouse is clicked: + SpringAnimation when the mouse is clicked. The use of the \l Behavior + on the \c x and \c y values indicates that whenever these values are + changed, a SpringAnimation should be applied. \snippet doc/src/snippets/declarative/springanimation.qml 0 @@ -224,7 +226,7 @@ void QDeclarativeSpringAnimationPrivate::updateMode() sources. The \l PropertyAnimation documentation shows a variety of methods for creating animations. - \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} + \sa SmoothedAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} */ QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent) @@ -284,8 +286,8 @@ qreal QDeclarativeSpringAnimation::from() const This property holds the value from which the animation will begin. - If not set, the animation will start regardless of the - value being tracked. + If not set, the animation will start whenever the tracked value has + changed, regardless of its value. */ void QDeclarativeSpringAnimation::setFrom(qreal value) @@ -303,7 +305,10 @@ void QDeclarativeSpringAnimation::setFrom(qreal value) /*! \qmlproperty real SpringAnimation::velocity + This property holds the maximum velocity allowed when tracking the source. + + The default value is 0 (no maximum velocity). */ qreal QDeclarativeSpringAnimation::velocity() const @@ -322,13 +327,14 @@ void QDeclarativeSpringAnimation::setVelocity(qreal velocity) /*! \qmlproperty real SpringAnimation::spring - This property holds the spring constant - The spring constant describes how strongly the target is pulled towards the - source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0 + This property describes how strongly the target is pulled towards the + source. The default value is 0 (that is, the spring-like motion is disabled). + + The useful value range is 0 - 5.0. - When a spring constant is set and the velocity property is greater than 0, - velocity limits the maximum speed. + When this property is set and the \l velocity value is greater than 0, + the \l velocity limits the maximum speed. */ qreal QDeclarativeSpringAnimation::spring() const { @@ -347,10 +353,11 @@ void QDeclarativeSpringAnimation::setSpring(qreal spring) \qmlproperty real SpringAnimation::damping This property holds the spring damping value. - This value describes how quickly a sprung follower comes to rest. + This value describes how quickly the spring-like motion comes to rest. + The default value is 0. - The useful range is 0 - 1.0. The lower the value, the faster the - follower comes to rest. + The useful value range is 0 - 1.0. The lower the value, the faster it + comes to rest. */ qreal QDeclarativeSpringAnimation::damping() const { @@ -392,7 +399,7 @@ void QDeclarativeSpringAnimation::setEpsilon(qreal epsilon) /*! \qmlproperty real SpringAnimation::modulus - This property holds the modulus value. + This property holds the modulus value. The default value is 0. Setting a \a modulus forces the target value to "wrap around" at the modulus. For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10. @@ -417,8 +424,10 @@ void QDeclarativeSpringAnimation::setModulus(qreal modulus) \qmlproperty real SpringAnimation::mass This property holds the "mass" of the property being moved. - mass is 1.0 by default. Setting a different mass changes the dynamics of - a \l spring follow. + The value is 1.0 by default. + + A greater mass causes slower movement and a greater spring-like + motion when an item comes to rest. */ qreal QDeclarativeSpringAnimation::mass() const { diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 6b7418e..6561b8c 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -66,8 +66,6 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/declarative/transition.qml 0 - Items can have multiple transitions, if - To specify multiple transitions, specify \l Item::transitions as a list: \qml -- cgit v0.12 From b2f90dedbeac285338af07fbffaec97ceaf0876f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 20 Jul 2010 12:20:21 +1000 Subject: Better defaults for MouseArea's drag. Allow essentially unbounded dragging once drag.target is set. The previous default of contraining the dragging to 0,0 (i.e. no drag) was unintuitive for learners. It's rare that unbounded is actually what you want, but it makes it much easier to get started with the element. Task-number: QTBUG-11184 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 5 +---- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9d70beb..86ef0df 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -59,16 +59,13 @@ #include #include #include +#include #include #include #include QT_BEGIN_NAMESPACE -#ifndef FLT_MAX -#define FLT_MAX 1E+37 -#endif - /*! \qmlclass Transform QGraphicsTransform \since 4.7 diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index b7b0c9e..7e4a36f 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -45,12 +45,13 @@ #include "private/qdeclarativeevents_p_p.h" #include +#include QT_BEGIN_NAMESPACE static const int PressAndHoldDelay = 800; QDeclarativeDrag::QDeclarativeDrag(QObject *parent) -: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0), +: QObject(parent), _target(0), _axis(XandYAxis), _xmin(-FLT_MAX), _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false) { } -- cgit v0.12 From 6c3cf7e2c5868bc77ffa66059889eda3132531b3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 20 Jul 2010 12:26:13 +1000 Subject: Ensure the boundingRect() of Text is correctly calculated. We need to create our cached image in boundingRect() if it doesn't already exist, to prevents painting errors. Reviewed-by: Warwick Allison --- src/declarative/graphicsitems/qdeclarativetext.cpp | 2 ++ tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index d63d633..ec8bfb5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -716,6 +716,8 @@ QRectF QDeclarativeText::boundingRect() const // Could include font max left/right bearings to either side of rectangle. if (d->cache || d->style != Normal) { + QDeclarativeTextPrivate *dd = const_cast(d); + dd->checkImgCache(); switch (d->hAlign) { case AlignLeft: x = 0; diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 80198eb..53862ec 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -246,6 +246,7 @@ void tst_qdeclarativetext::width() QDeclarativeText *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); + QVERIFY(textObject->boundingRect().width() > 0); QCOMPARE(textObject->width(), qreal(metricWidth)); QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format } -- cgit v0.12 From 2c574ed1bf9943130fb9af5435b557a47e3c462b Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 20 Jul 2010 12:35:00 +1000 Subject: Remove some files as instructed by Legal department. Task-number: QT-3613 --- .../qimagereader/images/pngwithcompressedtext.png | Bin 757 -> 0 bytes tests/auto/qimagereader/images/pngwithtext.png | Bin 796 -> 0 bytes tests/auto/qimagereader/qimagereader.qrc | 2 - tests/auto/qimagereader/tst_qimagereader.cpp | 56 --------------------- tests/auto/qimagewriter/tst_qimagewriter.cpp | 38 -------------- .../qimagereader/images/pngwithcompressedtext.png | Bin 757 -> 0 bytes .../gui/image/qimagereader/images/pngwithtext.png | Bin 796 -> 0 bytes 7 files changed, 96 deletions(-) delete mode 100644 tests/auto/qimagereader/images/pngwithcompressedtext.png delete mode 100644 tests/auto/qimagereader/images/pngwithtext.png delete mode 100644 tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png delete mode 100644 tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png diff --git a/tests/auto/qimagereader/images/pngwithcompressedtext.png b/tests/auto/qimagereader/images/pngwithcompressedtext.png deleted file mode 100644 index 01b2270..0000000 Binary files a/tests/auto/qimagereader/images/pngwithcompressedtext.png and /dev/null differ diff --git a/tests/auto/qimagereader/images/pngwithtext.png b/tests/auto/qimagereader/images/pngwithtext.png deleted file mode 100644 index 5d93799..0000000 Binary files a/tests/auto/qimagereader/images/pngwithtext.png and /dev/null differ diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index 278427b..1acc82f 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -38,8 +38,6 @@ images/noclearcode.bmp images/noclearcode.gif images/nontransparent.xpm - images/pngwithcompressedtext.png - images/pngwithtext.png images/runners.ppm images/teapot.ppm images/test.ppm diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index e9ef070..5b30b04 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -123,9 +123,6 @@ private slots: void supportsAnimation_data(); void supportsAnimation(); - void description_data(); - void description(); - void readFromResources_data(); void readFromResources(); @@ -1253,53 +1250,6 @@ void tst_QImageReader::devicePosition() } -void tst_QImageReader::description_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("description"); - - QMap willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (gwillem@ntuvax.ntu.ac.sg)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << QString("pngwithtext.png") << willem; - QTest::newRow("PNG Compressed") << QString("pngwithcompressedtext.png") << willem; -} - -void tst_QImageReader::description() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - // Sanity check - QVERIFY(!QImage(prefix + fileName).isNull()); - - QImageReader reader(prefix + fileName); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); - - QImage image = reader.read(); - QVERIFY(!image.isNull()); - - foreach (QString key, description.keys()) - QCOMPARE(image.text(key), description.value(key)); - QCOMPARE(image.textKeys(), QStringList(description.keys())); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); -} - void tst_QImageReader::readFromResources_data() { QTest::addColumn("fileName"); @@ -1405,12 +1355,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("image.png") << QString("image.png") << QByteArray("png") << QSize(22, 22) << QString(""); - QTest::newRow("pngwithcompressedtext.png") << QString("pngwithcompressedtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); - QTest::newRow("pngwithtext.png") << QString("pngwithtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); QTest::newRow("kollada.png") << QString("kollada.png") << QByteArray("png") << QSize(436, 160) << QString(""); diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index c4860c3..c6ec715 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -93,9 +93,6 @@ private slots: void largeTiff(); #endif - void setDescription_data(); - void setDescription(); - void writeToInvalidDevice(); void supportsOption_data(); @@ -420,41 +417,6 @@ void tst_QImageWriter::readWriteNonDestructive() QCOMPARE(image, image2); } -void tst_QImageWriter::setDescription_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("description"); - - QMap willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (willem@schaik.com)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995-96"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << prefix + QString("gen-pngwithtext.png") << willem; -} - -void tst_QImageWriter::setDescription() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - QImageWriter writer(fileName, "png"); - foreach (QString key, description.keys()) - writer.setText(key, description.value(key)); - QVERIFY(writer.write(QImage(prefix + "kollada.png"))); - - QImageReader reader(fileName); - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); -} - void tst_QImageWriter::writeToInvalidDevice() { QLatin1String fileName("/these/directories/do/not/exist/001.png"); diff --git a/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png b/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png deleted file mode 100644 index 01b2270..0000000 Binary files a/tests/benchmarks/gui/image/qimagereader/images/pngwithcompressedtext.png and /dev/null differ diff --git a/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png b/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png deleted file mode 100644 index 5d93799..0000000 Binary files a/tests/benchmarks/gui/image/qimagereader/images/pngwithtext.png and /dev/null differ -- cgit v0.12 From 7fb140b63f03b96064ded4ec6f2ec7c93e87b825 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 20 Jul 2010 12:45:10 +1000 Subject: Make Item::transformOriginPoint read-only Using this property on Item will break transformOrigin property. We have never documented it. It should not have been used. Now it is enforced as best we can. Task-number: QTBUG-12265 Reviewed-by: Aaron Kennedy --- src/declarative/graphicsitems/qdeclarativeitem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 4f420f8..8878fa0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -90,6 +90,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QDeclarativeListProperty transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) + Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint) // transformOriginPoint is read-only for Item Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") -- cgit v0.12 From 8669542cfb31030acd9280a3d1817a0d3c1efbbc Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 20 Jul 2010 15:19:57 +1000 Subject: Revert "Add the chart utility from qtestlib-tools." This reverts commit 453abe70fec02456aba2219025f5202060eaece1. Task-number: QT-3583 Reviewed-by: Jason McDonald --- src/testlib/qtestcase.cpp | 30 +- tools/qtestlib/chart/3rdparty/excanvas.js | 14 - tools/qtestlib/chart/3rdparty/flotr.js | 2 - tools/qtestlib/chart/3rdparty/prototype.js | 8 - tools/qtestlib/chart/benchmark_template.html | 202 ---------- tools/qtestlib/chart/chart.pro | 16 - tools/qtestlib/chart/chart.qrc | 9 - tools/qtestlib/chart/chart_template.html | 110 ------ tools/qtestlib/chart/database.cpp | 321 --------------- tools/qtestlib/chart/database.h | 99 ----- tools/qtestlib/chart/main.cpp | 82 ---- tools/qtestlib/chart/reportgenerator.cpp | 561 --------------------------- tools/qtestlib/chart/reportgenerator.h | 63 --- tools/qtestlib/qtestlib.pro | 2 +- 14 files changed, 2 insertions(+), 1517 deletions(-) delete mode 100644 tools/qtestlib/chart/3rdparty/excanvas.js delete mode 100644 tools/qtestlib/chart/3rdparty/flotr.js delete mode 100644 tools/qtestlib/chart/3rdparty/prototype.js delete mode 100644 tools/qtestlib/chart/benchmark_template.html delete mode 100644 tools/qtestlib/chart/chart.pro delete mode 100644 tools/qtestlib/chart/chart.qrc delete mode 100644 tools/qtestlib/chart/chart_template.html delete mode 100644 tools/qtestlib/chart/database.cpp delete mode 100644 tools/qtestlib/chart/database.h delete mode 100644 tools/qtestlib/chart/main.cpp delete mode 100644 tools/qtestlib/chart/reportgenerator.cpp delete mode 100644 tools/qtestlib/chart/reportgenerator.h diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 6591481..1aa2642 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -54,7 +54,6 @@ #include #include #include -#include #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qtesttable_p.h" @@ -989,9 +988,6 @@ static void qParseArgs(int argc, char *argv[]) " -iterations n : Sets the number of accumulation iterations.\n" " -median n : Sets the number of median iterations.\n" " -vb : Print out verbose benchmarking information.\n" -#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) - " -chart : Create chart based on the benchmark result.\n" -#endif "\n" " -help : This help\n"; @@ -1105,12 +1101,8 @@ static void qParseArgs(int argc, char *argv[]) } else if (strcmp(argv[i], "-vb") == 0) { QBenchmarkGlobalData::current->verboseOutput = true; -#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) } else if (strcmp(argv[i], "-chart") == 0) { - QBenchmarkGlobalData::current->createChart = true; - QTestLog::setLogMode(QTestLog::XML); - QTestLog::redirectOutput("results.xml"); -#endif + fprintf(stderr, "Warning: `-chart' option is not available\n"); } else if (strcmp(argv[i], "-qws") == 0) { // do nothing } else if (strcmp(argv[i], "-graphicssystem") == 0) { @@ -1713,26 +1705,6 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) } #endif - -#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS) - if (QBenchmarkGlobalData::current->createChart) { - QString chartLocation = QLibraryInfo::location(QLibraryInfo::BinariesPath); -#ifdef Q_OS_WIN - chartLocation += QLatin1String("/../tools/qtestlib/chart/release/chart.exe"); -#else - chartLocation += QLatin1String("/../tools/qtestlib/chart/chart"); -#endif - if (QFile::exists(chartLocation)) { - QProcess p; - p.setProcessChannelMode(QProcess::ForwardedChannels); - p.start(chartLocation, QStringList() << QLatin1String("results.xml")); - p.waitForFinished(-1); - } else { - qDebug() << QLatin1String("Could not find the chart tool in ") + chartLocation + QLatin1String(", please make sure it is compiled."); - } - } -#endif - #if defined(QTEST_NOEXITCODE) return 0; #else diff --git a/tools/qtestlib/chart/3rdparty/excanvas.js b/tools/qtestlib/chart/3rdparty/excanvas.js deleted file mode 100644 index e77763a..0000000 --- a/tools/qtestlib/chart/3rdparty/excanvas.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2006 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -if(!window.CanvasRenderingContext2D){(function(){var N=Math;var O=N.round;var L=N.sin;var U=N.cos;var A=10;var I=A/2;var G={init:function(W){var X=W||document;if(/MSIE/.test(navigator.userAgent)&&!window.opera){var V=this;X.attachEvent("onreadystatechange",function(){V.init_(X)})}},init_:function(Y){if(Y.readyState=="complete"){if(!Y.namespaces.g_vml_){Y.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml")}var X=Y.createStyleSheet();X.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}";var W=Y.getElementsByTagName("canvas");for(var V=0;V"){var V="/"+X.tagName;var W;while((W=X.nextSibling)&&W.tagName!=V){W.removeNode()}if(W){W.removeNode()}}X.parentNode.replaceChild(Y,X);return Y},initElement:function(W){W=this.fixElement_(W);W.getContext=function(){if(this.context_){return this.context_}return this.context_=new J(this)};W.attachEvent("onpropertychange",T);W.attachEvent("onresize",B);var V=W.attributes;if(V.width&&V.width.specified){W.style.width=V.width.nodeValue+"px"}else{W.width=W.clientWidth}if(V.height&&V.height.specified){W.style.height=V.height.nodeValue+"px"}else{W.height=W.clientHeight}return W}};function T(W){var V=W.srcElement;switch(W.propertyName){case"width":V.style.width=V.attributes.width.nodeValue+"px";V.getContext().clearRect();break;case"height":V.style.height=V.attributes.height.nodeValue+"px";V.getContext().clearRect();break}}function B(W){var V=W.srcElement;if(V.firstChild){V.firstChild.style.width=V.clientWidth+"px";V.firstChild.style.height=V.clientHeight+"px"}}G.init();var D=[];for(var R=0;R<16;R++){for(var Q=0;Q<16;Q++){D[R*16+Q]=R.toString(16)+Q.toString(16)}}function K(){return[[1,0,0],[0,1,0],[0,0,1]]}function E(Y,X){var W=K();for(var V=0;V<3;V++){for(var b=0;b<3;b++){var Z=0;for(var a=0;a<3;a++){Z+=Y[V][a]*X[a][b]}W[V][b]=Z}}return W}function P(W,V){V.fillStyle=W.fillStyle;V.lineCap=W.lineCap;V.lineJoin=W.lineJoin;V.lineWidth=W.lineWidth;V.miterLimit=W.miterLimit;V.shadowBlur=W.shadowBlur;V.shadowColor=W.shadowColor;V.shadowOffsetX=W.shadowOffsetX;V.shadowOffsetY=W.shadowOffsetY;V.strokeStyle=W.strokeStyle;V.arcScaleX_=W.arcScaleX_;V.arcScaleY_=W.arcScaleY_}function C(W){var Z,Y=1;W=String(W);if(W.substring(0,3)=="rgb"){var b=W.indexOf("(",3);var V=W.indexOf(")",b+1);var a=W.substring(b+1,V).split(",");Z="#";for(var X=0;X<3;X++){Z+=D[Number(a[X])]}if((a.length==4)&&(W.substr(3,1)=="a")){Y=a[3]}}else{Z=W}return[Z,Y]}function M(V){switch(V){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function J(W){this.m_=K();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=A*1;this.globalAlpha=1;this.canvas=W;var V=W.ownerDocument.createElement("div");V.style.width=W.clientWidth+"px";V.style.height=W.clientHeight+"px";V.style.overflow="hidden";V.style.position="absolute";W.appendChild(V);this.element_=V;this.arcScaleX_=1;this.arcScaleY_=1}var H=J.prototype;H.clearRect=function(){this.element_.innerHTML="";this.currentPath_=[]};H.beginPath=function(){this.currentPath_=[]};H.moveTo=function(W,V){this.currentPath_.push({type:"moveTo",x:W,y:V});this.currentX_=W;this.currentY_=V};H.lineTo=function(W,V){this.currentPath_.push({type:"lineTo",x:W,y:V});this.currentX_=W;this.currentY_=V};H.bezierCurveTo=function(X,V,a,Z,Y,W){this.currentPath_.push({type:"bezierCurveTo",cp1x:X,cp1y:V,cp2x:a,cp2y:Z,x:Y,y:W});this.currentX_=Y;this.currentY_=W};H.quadraticCurveTo=function(c,b,a,Z){var W=this.currentX_+2/3*(c-this.currentX_);var V=this.currentY_+2/3*(b-this.currentY_);var Y=W+(a-this.currentX_)/3;var X=V+(Z-this.currentY_)/3;this.bezierCurveTo(W,V,Y,X,a,Z)};H.arc=function(b,Z,a,Y,W,X){a*=A;var f=X?"at":"wa";var c=b+(U(Y)*a)-I;var e=Z+(L(Y)*a)-I;var V=b+(U(W)*a)-I;var d=Z+(L(W)*a)-I;if(c==V&&!X){c+=0.125}this.currentPath_.push({type:f,x:b,y:Z,radius:a,xStart:c,yStart:e,xEnd:V,yEnd:d})};H.rect=function(X,W,V,Y){this.moveTo(X,W);this.lineTo(X+V,W);this.lineTo(X+V,W+Y);this.lineTo(X,W+Y);this.closePath()};H.strokeRect=function(X,W,V,Y){this.beginPath();this.moveTo(X,W);this.lineTo(X+V,W);this.lineTo(X+V,W+Y);this.lineTo(X,W+Y);this.closePath();this.stroke()};H.fillRect=function(X,W,V,Y){this.beginPath();this.moveTo(X,W);this.lineTo(X+V,W);this.lineTo(X+V,W+Y);this.lineTo(X,W+Y);this.closePath();this.fill()};H.createLinearGradient=function(W,Y,V,X){var Z=new S("gradient");return Z};H.createRadialGradient=function(Y,a,X,W,Z,V){var b=new S("gradientradial");b.radius1_=X;b.radius2_=V;b.focus_.x=Y;b.focus_.y=a;return b};H.drawImage=function(n,Y){var f,c,i,u,l,j,p,x;var g=n.runtimeStyle.width;var m=n.runtimeStyle.height;n.runtimeStyle.width="auto";n.runtimeStyle.height="auto";var e=n.width;var s=n.height;n.runtimeStyle.width=g;n.runtimeStyle.height=m;if(arguments.length==3){f=arguments[1];c=arguments[2];l=j=0;p=i=e;x=u=s}else{if(arguments.length==5){f=arguments[1];c=arguments[2];i=arguments[3];u=arguments[4];l=j=0;p=e;x=s}else{if(arguments.length==9){l=arguments[1];j=arguments[2];p=arguments[3];x=arguments[4];f=arguments[5];c=arguments[6];i=arguments[7];u=arguments[8]}else{throw"Invalid number of arguments"}}}var v=this.getCoords_(f,c);var Z=p/2;var X=x/2;var t=[];var V=10;var b=10;t.push(" ','","");this.element_.insertAdjacentHTML("BeforeEnd",t.join(""))};H.stroke=function(y){var e=[];var d=false;var AB=C(y?this.fillStyle:this.strokeStyle);var u=AB[0];var Y=AB[1]*this.globalAlpha;var X=10;var j=10;e.push("v.x){v.x=AA.x}if(t.y==null||AA.yv.y){v.y=AA.y}}}e.push(' ">');if(typeof this.fillStyle=="object"){var n={x:"50%",y:"50%"};var r=(v.x-t.x);var l=(v.y-t.y);var z=(r>l)?r:l;n.x=O((this.fillStyle.focus_.x/r)*100+50)+"%";n.y=O((this.fillStyle.focus_.y/l)*100+50)+"%";var g=[];if(this.fillStyle.type_=="gradientradial"){var x=(this.fillStyle.radius1_/z*100);var m=(this.fillStyle.radius2_/z*100)-x}else{var x=0;var m=100}var V={offset:null,color:null};var Z={offset:null,color:null};this.fillStyle.colors_.sort(function(a,W){return a.offset-W.offset});for(var w=0;wV.offset||V.offset==null){V.offset=f.offset;V.color=f.color}if(f.offset')}else{if(y){e.push('')}else{e.push("')}}e.push("");this.element_.insertAdjacentHTML("beforeEnd",e.join(""))};H.fill=function(){this.stroke(true)};H.closePath=function(){this.currentPath_.push({type:"close"})};H.getCoords_=function(W,V){return{x:A*(W*this.m_[0][0]+V*this.m_[1][0]+this.m_[2][0])-I,y:A*(W*this.m_[0][1]+V*this.m_[1][1]+this.m_[2][1])-I}};H.save=function(){var V={};P(this,V);this.aStack_.push(V);this.mStack_.push(this.m_);this.m_=E(K(),this.m_)};H.restore=function(){P(this.aStack_.pop(),this);this.m_=this.mStack_.pop()};H.translate=function(X,W){var V=[[1,0,0],[0,1,0],[X,W,1]];this.m_=E(V,this.m_)};H.rotate=function(W){var Y=U(W);var X=L(W);var V=[[Y,X,0],[-X,Y,0],[0,0,1]];this.m_=E(V,this.m_)};H.scale=function(X,W){this.arcScaleX_*=X;this.arcScaleY_*=W;var V=[[X,0,0],[0,W,0],[0,0,1]];this.m_=E(V,this.m_)};H.clip=function(){};H.arcTo=function(){};H.createPattern=function(){return new F};function S(V){this.type_=V;this.radius1_=0;this.radius2_=0;this.colors_=[];this.focus_={x:0,y:0}}S.prototype.addColorStop=function(W,V){V=C(V);this.colors_.push({offset:1-W,color:V})};function F(){}G_vmlCanvasManager=G;CanvasRenderingContext2D=J;CanvasGradient=S;CanvasPattern=F})()}; \ No newline at end of file diff --git a/tools/qtestlib/chart/3rdparty/flotr.js b/tools/qtestlib/chart/3rdparty/flotr.js deleted file mode 100644 index 80bb506..0000000 --- a/tools/qtestlib/chart/3rdparty/flotr.js +++ /dev/null @@ -1,2 +0,0 @@ -//Flotr 0.1.0alpha Copyright (c) 2008 Bas Wenneker, , MIT License. -var Flotr=(function(){var C=0;function L(M){return M.collect(function(N){return(N.data)?Object.clone(N):{data:N}})}function G(P,N){var M=N||{};for(var O in P){M[O]=(typeof (P[O])=="object"&&!(P[O].constructor==Array||P[O].constructor==RegExp))?G(P[O],N[O]):M[O]=P[O]}return M}function I(Q,P,M,N){var T=(M-P)/Q;var S=H(T);var O=T/S;var R=10;if(O<1.5){R=1}else{if(O<2.25){R=2}else{if(O<3){R=2.5}else{if(O<7.5){R=5}}}}if(R==2.5&&N==0){R=2}R*=S;return R}function E(M){return M.toString()}function F(M){return"("+M.x+", "+M.y+")"}function H(M){return Math.pow(10,Math.floor(Math.log(M)/Math.LN10))}function K(O){var M;if((M=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(O))){return new B(parseInt(M[1]),parseInt(M[2]),parseInt(M[3]))}if((M=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(O))){return new B(parseInt(M[1]),parseInt(M[2]),parseInt(M[3]),parseFloat(M[4]))}if((M=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(O))){return new B(parseFloat(M[1])*2.55,parseFloat(M[2])*2.55,parseFloat(M[3])*2.55)}if((M=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(O))){return new B(parseFloat(M[1])*2.55,parseFloat(M[2])*2.55,parseFloat(M[3])*2.55,parseFloat(M[4]))}if((M=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(O))){return new B(parseInt(M[1],16),parseInt(M[2],16),parseInt(M[3],16))}if((M=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(O))){return new B(parseInt(M[1]+M[1],16),parseInt(M[2]+M[2],16),parseInt(M[3]+M[3],16))}var N=O.strip().toLowerCase();if(N=="transparent"){return new B(255,255,255,0)}M=D[N];return new B(M[0],M[1],M[2])}function A(N){var M;do{M=N.getStyle("background-color").toLowerCase();if(M!=""&&M!="transparent"){break}N=N.up(0)}while(N.nodeName.toLowerCase()!="body");if(M=="rgba(0, 0, 0, 0)"){return"transparent"}return M}function B(S,R,N,P){var Q=["r","g","b","a"];var M=4;while(-1<--M){this[Q[M]]=arguments[M]||((M==3)?1:0)}this.toString=function(){return(this.a>=1)?"rgb("+[this.r,this.g,this.b].join(",")+")":"rgba("+[this.r,this.g,this.b,this.a].join(",")+")"};this.scale=function(V,U,W,T){M=4;while(-1<--M){if(arguments[M]!=null){this[Q[M]]*=arguments[M]}}return this.normalize()};this.adjust=function(V,U,W,T){M=4;while(-1<--M){if(arguments[M]!=null){this[Q[M]]+=arguments[M]}}return this.normalize()};this.clone=function(){return new B(this.r,this.b,this.g,this.a)};var O=function(U,T,V){return Math.max(Math.min(U,V),T)};this.normalize=function(){this.r=O(parseInt(this.r),0,255);this.g=O(parseInt(this.g),0,255);this.b=O(parseInt(this.b),0,255);this.a=O(this.a,0,1);return this};this.normalize()}var D={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};function J(y,AO,p){var o,S,AL,h,AS;var z="flotr-"+C++;var R=L(AO);var N=y;var u={},c={};var l={left:0,right:0,top:0,bottom:0};var AA=0;var d=0;var AH=0;var U=0;var P=0;var AD=0;var AC=0;var AB=0;g(p);k();AN();q();AK(u,o.xaxis);Z();AK(c,o.yaxis);m(u,o.xaxis);m(c,o.yaxis);Y();AP();AQ();this.getCanvas=function(){return S};this.getPlotOffset=function(){return l};this.clearSelection=M;this.setSelection=AF;function g(AV){o=G(AV,{colors:["#00A8F0","#C0D800","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{ticks:null,noTicks:5,tickFormatter:E,tickDecimals:null,min:null,max:null,autoscaleMargin:0},yaxis:{ticks:null,noTicks:5,tickFormatter:E,tickDecimals:null,min:null,max:null,autoscaleMargin:0},points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff"},lines:{show:false,lineWidth:2,fill:false,fillColor:null},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null},grid:{color:"#545454",backgroundColor:null,tickColor:"#dddddd",labelMargin:3},selection:{mode:null,color:"#B6D9FF",fps:10},mouse:{track:null,position:"se",trackFormatter:F,margin:3,color:"#ff3f19",trackDecimals:1,sensibility:2,radius:3},shadowSize:4});var Ah=R.length;var AT=[];var AZ=[];for(var Ac=0;Ac=o.colors.length){Aa=0;++AY}}var Ad=0;for(var AX=0,Ai;AX0){u.datamin=u.datamax=R[AV].data[0][0];c.datamin=c.datamax=R[AV].data[0][1];AY=true;break}}if(!AY){return }for(var AU=0;AUu.datamax){u.datamax=AT}}if(AZc.datamax){c.datamax=AZ}}}}}function AK(AW,AY){var AV=AY.min!=null?AY.min:AW.datamin;var AT=AY.max!=null?AY.max:AW.datamax;if(AT-AV==0){var AU=(AT==0)?1:0.01;AV-=AU;AT+=AU}AW.tickSize=I(AY.noTicks,AV,AT,AY.tickDecimals);var AX;if(AY.min==null){AX=AY.autoscaleMargin;if(AX!=0){AV-=AW.tickSize*AX;if(AV<0&&AW.datamin>=0){AV=0}AV=AW.tickSize*Math.floor(AV/AW.tickSize)}}if(AY.max==null){AX=AY.autoscaleMargin;if(AX!=0){AT+=AW.tickSize*AX;if(AT>0&&AW.datamax<=0){AT=0}AT=AW.tickSize*Math.ceil(AT/AW.tickSize)}}AW.min=AV;AW.max=AT}function Z(){if(o.xaxis.max==null){var AU=u.max;for(var AT=0;ATAU){AU=u.max+R[AT].bars.barWidth}}u.max=AU}}function m(AV,AW){AV.ticks=[];if(AW.ticks){var AZ=AW.ticks;if(Object.isFunction(AZ)){AZ=AZ({min:AV.min,max:AV.max})}for(var AX=0,Aa,AY;AX1)?Ab[1]:AW.tickFormatter(Aa)}else{Aa=Ab;AY=AW.tickFormatter(Aa)}AV.ticks[AX]={v:Aa,label:AY}}}else{var AT=AV.tickSize*Math.ceil(AV.min/AV.tickSize);for(AX=0;AT+AX*AV.tickSize<=AV.max;++AX){Aa=AT+AX*AV.tickSize;var AU=AW.tickDecimals;if(AU==null){AU=1-Math.floor(Math.log(AV.tickSize)/Math.LN10)}if(AU<0){AU=0}Aa=Aa.toFixed(AU);AV.ticks.push({v:Aa,label:AW.tickFormatter(Aa)})}}}function Y(){var AX="";for(var AW=0;AWAX.length){AX=c.ticks[AW].label}}var AT=N.insert('
'+AX+"
").down(0).next(1);AA=AT.getWidth();d=AT.getHeight();AT.remove();var AY=2;if(o.points.show){AY=Math.max(AY,o.points.radius+o.points.lineWidth/2)}for(var AV=0;AV';for(var AV=0,AW=null;AV'+AW.label+""}for(var AT=0,AW=null;AT'+AW.label+""}AX+="";N.insert(AX)}function AI(AT){if(AT.lines.show||(!AT.bars.show&&!AT.points.show)){i(AT)}if(AT.bars.show){v(AT)}if(AT.points.show){w(AT)}}function i(AV){function AU(Ad,Ac){if(Ad.length<2){return }var Ab=AE(Ad[0][0]),Aa=j(Ad[0][1])+Ac;h.beginPath();h.moveTo(Ab,Aa);for(var Ae=0;Ae=Af&&Ag>c.max){if(Af>c.max){continue}AZ=(c.max-Ag)/(Af-Ag)*(AY-AZ)+AZ;Ag=c.max}else{if(Af>=Ag&&Af>c.max){if(Ag>c.max){continue}AY=(c.max-Ag)/(Af-Ag)*(AY-AZ)+AZ;Af=c.max}}if(AZ<=AY&&AZ=AY&&AZ>u.max){if(AY>u.max){continue}Ag=(u.max-AZ)/(AY-AZ)*(Af-Ag)+Ag;AZ=u.max}else{if(AY>=AZ&&AY>u.max){if(AZ>u.max){continue}Af=(u.max-AZ)/(AY-AZ)*(Af-Ag)+Ag;AY=u.max}}if(Ab!=AE(AZ)||Aa!=j(Ag)+Ac){h.moveTo(AE(AZ),j(Ag)+Ac)}Ab=AE(AY);Aa=j(Af)+Ac;h.lineTo(Ab,Aa)}h.stroke()}function AW(Ac){if(Ac.length<2){return }var AY=Math.min(Math.max(0,c.min),c.max);var Ah,Aa=0;var Ae=true;h.beginPath();for(var Ad=0;Ad=AZ&&Ab>u.max){if(AZ>u.max){continue}Ai=(u.max-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;Ab=u.max}else{if(AZ>=Ab&&AZ>u.max){if(Ab>u.max){continue}Ag=(u.max-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;AZ=u.max}}if(Ae){h.moveTo(AE(Ab),j(AY));Ae=false}if(Ai>=c.max&&Ag>=c.max){h.lineTo(AE(Ab),j(c.max));h.lineTo(AE(AZ),j(c.max));continue}else{if(Ai<=c.min&&Ag<=c.min){h.lineTo(AE(Ab),j(c.min));h.lineTo(AE(AZ),j(c.min));continue}}var Aj=Ab,Af=AZ;if(Ai<=Ag&&Ai=c.min){Ab=(c.min-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ai=c.min}else{if(Ag<=Ai&&Ag=c.min){AZ=(c.min-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ag=c.min}}if(Ai>=Ag&&Ai>c.max&&Ag<=c.max){Ab=(c.max-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ai=c.max}else{if(Ag>=Ai&&Ag>c.max&&Ai<=c.max){AZ=(c.max-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ag=c.max}}if(Ab!=Aj){Ah=(Ai<=c.min)?Ah=c.min:c.max;h.lineTo(AE(Aj),j(Ah));h.lineTo(AE(Ab),j(Ah))}h.lineTo(AE(Ab),j(Ai));h.lineTo(AE(AZ),j(Ag));if(AZ!=Af){Ah=(Ag<=c.min)?c.min:c.max;h.lineTo(AE(Af),j(Ah));h.lineTo(AE(AZ),j(Ah))}Aa=Math.max(AZ,Af)}h.lineTo(AE(Aa),j(AY));h.closePath();h.fill()}h.save();h.translate(l.left,l.top);h.lineJoin="round";var AX=AV.lines.lineWidth;var AT=AV.shadowSize;if(AT>0){h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.1)";AU(AV.data,AX/2+AT/2+h.lineWidth/2);h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.2)";AU(AV.data,AX/2+h.lineWidth/2)}h.lineWidth=AX;h.strokeStyle=AV.color;if(AV.lines.fill){h.fillStyle=AV.lines.fillColor!=null?AV.lines.fillColor:K(AV.color).scale(null,null,null,0.4).toString();AW(AV.data,0)}AU(AV.data,0);h.restore()}function w(AU){function AX(Ab,AZ,Ac){for(var Aa=0;Aau.max||Adc.max){continue}h.beginPath();h.arc(AE(AY),j(Ad),AZ,0,2*Math.PI,true);if(Ac){h.fill()}h.stroke()}}function AW(Ab,Ac,AZ){for(var Aa=0;Aau.max||Adc.max){continue}h.beginPath();h.arc(AE(AY),j(Ad)+Ac,AZ,0,Math.PI,false);h.stroke()}}h.save();h.translate(l.left,l.top);var AV=AU.lines.lineWidth;var AT=AU.shadowSize;if(AT>0){h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.1)";AW(AU.data,AT/2+h.lineWidth/2,AU.points.radius);h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.2)";AW(AU.data,h.lineWidth/2,AU.points.radius)}h.lineWidth=AU.points.lineWidth;h.strokeStyle=AU.color;h.fillStyle=AU.points.fillColor!=null?AU.points.fillColor:AU.color;AX(AU.data,AU.points.radius,AU.points.fill);h.restore()}function v(AU){function AT(Ab,Ak,AZ,Aj){if(Ab.length<2){return }for(var Ac=0;Acu.max||Aec.max){continue}if(AYu.max){Ah=u.max;Ad=false}if(AXc.max){Ae=c.max;Aa=false}if(Aj){h.beginPath();h.moveTo(AE(AY),j(AX)+AZ);h.lineTo(AE(AY),j(Ae)+AZ);h.lineTo(AE(Ah),j(Ae)+AZ);h.lineTo(AE(Ah),j(AX)+AZ);h.fill()}if(Ai||Ad||Aa){h.beginPath();h.moveTo(AE(AY),j(AX)+AZ);if(Ai){h.lineTo(AE(AY),j(Ae)+AZ)}else{h.moveTo(AE(AY),j(Ae)+AZ)}if(Aa){h.lineTo(AE(Ah),j(Ae)+AZ)}else{h.moveTo(AE(Ah),j(Ae)+AZ)}if(Ad){h.lineTo(AE(Ah),j(AX)+AZ)}else{h.moveTo(AE(Ah),j(AX)+AZ)}h.stroke()}}}h.save();h.translate(l.left,l.top);h.lineJoin="round";var AW=AU.bars.barWidth;var AV=Math.min(AU.bars.lineWidth,AW);h.lineWidth=AV;h.strokeStyle=AU.color;if(AU.bars.fill){h.fillStyle=AU.bars.fillColor!=null?AU.bars.fillColor:K(AU.color).scale(null,null,null,0.4).toString()}AT(AU.data,AW,0,AU.bars.fill);h.restore()}function AQ(){if(!o.legend.show){return }var Aa=[];var AY=false;for(var AX=0;AX":"");AY=true}var Ac=R[AX].label;if(o.legend.labelFormatter!=null){Ac=o.legend.labelFormatter(Ac)}Aa.push('
'+Ac+"")}if(AY){Aa.push("")}if(Aa.length>0){var Ad=''+Aa.join("")+"
";if(o.legend.container!=null){o.legend.container.append(Ad)}else{var Ab="";var AU=o.legend.position,AV=o.legend.margin;if(AU.charAt(0)=="n"){Ab+="top:"+(AV+l.top)+"px;"}else{if(AU.charAt(0)=="s"){Ab+="bottom:"+(AV+l.bottom)+"px;"}}if(AU.charAt(1)=="e"){Ab+="right:"+(AV+l.right)+"px;"}else{if(AU.charAt(1)=="w"){Ab+="left:"+(AV+l.bottom)+"px;"}}var AT=N.insert('
'+Ad+"
").getElementsBySelector("div.flotr-legend").first();if(o.legend.backgroundOpacity!=0){var AZ=o.legend.backgroundColor;if(AZ==null){var AW=(o.grid.backgroundColor!=null)?o.grid.backgroundColor:A(AT);AZ=K(AW).adjust(null,null,null,1).toString()}N.insert('
').select("div.flotr-legend-bg").first().setStyle({opacity:o.legend.backgroundOpacity})}}}}var AG={pageX:null,pageY:null};var b={first:{x:-1,y:-1},second:{x:-1,y:-1}};var T=null;var x=null;var t=false;var Q=null;function f(AT){if(t){t=false;return }var AU=AL.cumulativeOffset();N.fire("flotr:click",[{x:u.min+(AT.pageX-AU.left-l.left)/AC,y:c.max-(AT.pageY-AU.top-l.top)/AB}])}function e(AU){if(AU.pageX==null&&AU.clientX!=null){var AX=document.documentElement,AT=document.body;AG.pageX=AU.clientX+(AX&&AX.scrollLeft||AT.scrollLeft||0);AG.pageY=AU.clientY+(AX&&AX.scrollTop||AT.scrollTop||0)}else{AG.pageX=AU.pageX;AG.pageY=AU.pageY}var AV=AL.cumulativeOffset();var AW={x:u.min+(AU.pageX-AV.left-l.left)/AC,y:c.max-(AU.pageY-AV.top-l.top)/AB};if(o.mouse.track&&x==null){n(AW)}N.fire("flotr:mousemove",[AU,AW])}function r(AT){if(!AT.isLeftClick()){return }AM(b.first,AT);if(x!=null){clearInterval(x)}AG.pageX=null;x=setInterval(AJ,1000/o.selection.fps);$(document).observe("mouseup",O)}function a(){var AU=(b.first.x<=b.second.x)?b.first.x:b.second.x;var AT=(b.first.x<=b.second.x)?b.second.x:b.first.x;var AW=(b.first.y>=b.second.y)?b.first.y:b.second.y;var AV=(b.first.y>=b.second.y)?b.second.y:b.first.y;AU=u.min+AU/AC;AT=u.min+AT/AC;AW=c.max-AW/AB;AV=c.max-AV/AB;N.fire("flotr:select",[{x1:AU,y1:AW,x2:AT,y2:AV}])}function O(AT){$(document).stopObserving("mouseup",O);if(x!=null){clearInterval(x);x=null}AM(b.second,AT);M();if(W()||AT.isLeftClick()){X();a();t=true}Event.stop(AT)}function AM(AV,AT){var AU=$(AL).cumulativeOffset();if(o.selection.mode=="y"){AV.x=(AV==b.first)?0:P}else{AV.x=AT.pageX-AU.left-l.left;AV.x=Math.min(Math.max(0,AV.x),P)}if(o.selection.mode=="x"){AV.y=(AV==b.first)?0:AD}else{AV.y=AT.pageY-AU.top-l.top;AV.y=Math.min(Math.max(0,AV.y),AD)}}function AJ(){if(AG.pageX==null){return }AM(b.second,AG);M();if(W()){X()}}function M(){if(T==null){return }var AT=Math.min(T.first.x,T.second.x),AW=Math.min(T.first.y,T.second.y),AU=Math.abs(T.second.x-T.first.x),AV=Math.abs(T.second.y-T.first.y);AS.clearRect(AT+l.left-AS.lineWidth,AW+l.top-AS.lineWidth,AU+AS.lineWidth*2,AV+AS.lineWidth*2);T=null}function AF(AT){M();b.first.y=(o.selection.mode=="x")?0:(c.max-AT.y1)*AB;b.second.y=(o.selection.mode=="x")?AD:(c.max-AT.y2)*AB;b.first.x=(o.selection.mode=="y")?0:(AT.x1-u.min)*AC;b.second.x=(o.selection.mode=="y")?P:(AT.x2-u.min)*AC;X();a()}function X(){if(T!=null&&b.first.x==T.first.x&&b.first.y==T.first.y&&b.second.x==T.second.x&&b.second.y==T.second.y){return }AS.strokeStyle=K(o.selection.color).scale(null,null,null,0.8).toString();AS.lineWidth=1;h.lineJoin="round";AS.fillStyle=K(o.selection.color).scale(null,null,null,0.4).toString();T={first:{x:b.first.x,y:b.first.y},second:{x:b.second.x,y:b.second.y}};var AT=Math.min(b.first.x,b.second.x),AW=Math.min(b.first.y,b.second.y),AU=Math.abs(b.second.x-b.first.x),AV=Math.abs(b.second.y-b.first.y);AS.fillRect(AT+l.left,AW+l.top,AU,AV);AS.strokeRect(AT+l.left,AW+l.top,AU,AV)}function W(){var AT=5;return Math.abs(b.second.x-b.first.x)>=AT&&Math.abs(b.second.y-b.first.y)>=AT}function s(){if(Q){AS.clearRect(AE(Q.x)+l.left-o.points.radius*2,j(Q.y)+l.top-o.points.radius*2,o.points.radius*3+o.points.lineWidth*3,o.points.radius*3+o.points.lineWidth*3);Q=null}}function n(Ae){var AX={dist:Number.MAX_VALUE,x:null,y:null,mouse:null};for(var Ad=0,Ac,AZ,AV;Ad