From 83b5ae49a1778a815a98dd7094822588e82aef3c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 2 Nov 2009 11:51:53 +0100 Subject: QNetworkReply autotests: move performance tests to benchmarks Move the performance tests from tests/auto/qnetworkreply to tests/benchmarks/qnetworkreply, because they belong there and they were crashing from time to time. Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 479 ------------------- .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 530 +++++++++++++++++++++ 2 files changed, 530 insertions(+), 479 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 7adb67f..0b61dcd 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -227,12 +227,6 @@ private Q_SLOTS: void rateControl_data(); void rateControl(); - void downloadPerformance(); - void uploadPerformance(); - void performanceControlRate(); - void httpUploadPerformance(); - void httpDownloadPerformance_data(); - void httpDownloadPerformance(); void downloadProgress_data(); void downloadProgress(); @@ -413,93 +407,6 @@ public slots: } }; -class FixedSizeDataGenerator : public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - FixedSizeDataGenerator(qint64 size) : state(Idle) - { open(ReadOnly | Unbuffered); - toBeGeneratedTotalCount = toBeGeneratedCount = size; - } - - virtual qint64 bytesAvailable() const - { - return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0; - } - - virtual bool isSequential() const{ - return false; - } - - virtual bool reset() const{ - return false; - } - - qint64 size() const { - return toBeGeneratedTotalCount; - } - -public slots: - void start() { state = Started; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - memset(data, '@', maxlen); - - if (toBeGeneratedCount <= 0) { - return -1; - } - - qint64 n = qMin(maxlen, toBeGeneratedCount); - toBeGeneratedCount -= n; - - if (toBeGeneratedCount <= 0) { - // make sure this is a queued connection! - emit readChannelFinished(); - } - - return n; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } - - qint64 toBeGeneratedCount; - qint64 toBeGeneratedTotalCount; -}; - - -class DataGenerator: public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - DataGenerator() : state(Idle) - { open(ReadOnly); } - - virtual bool isSequential() const { return true; } - virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; } - -public slots: - void start() { state = Started; emit readyRead(); } - void stop() { state = Stopped; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - if (state == Stopped) - return -1; // EOF - - // return as many bytes as are wanted - memset(data, '@', maxlen); - return maxlen; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } -}; - - class SocketPair: public QObject { @@ -692,255 +599,6 @@ protected: } }; -class TimedSender: public QThread -{ - Q_OBJECT - qint64 totalBytes; - QSemaphore ready; - QByteArray dataToSend; - QTcpSocket *client; - int timeout; - int port; -public: - int transferRate; - TimedSender(int ms) - : totalBytes(0), timeout(ms), port(-1), transferRate(-1) - { - dataToSend = QByteArray(16*1024, '@'); - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -private slots: - void writeMore() - { - while (client->bytesToWrite() < 128 * 1024) { - writePacket(dataToSend); - } - } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - writeMore(); - connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection); - - QEventLoop eventLoop; - QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); - - // wait for the connection to shut down - client->disconnectFromHost(); - if (!client->waitForDisconnected(10000)) - return; - - transferRate = totalBytes * 1000 / timer.elapsed(); - qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in" - << timer.elapsed() << "ms"; - } - - void writePacket(const QByteArray &array) - { - client->write(array); - totalBytes += array.size(); - } -}; - -class ThreadedDataReader: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReader() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class ThreadedDataReaderHttpServer: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReaderHttpServer() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - client->write("HTTP/1.0 200 OK\r\n"); - client->write("Content-length: 0\r\n"); - client->write("\r\n"); - client->flush(); - - QCoreApplication::processEvents(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class HttpDownloadPerformanceClient : QObject { - Q_OBJECT; - QIODevice *device; - public: - HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ - connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - } - - public slots: - void readyReadSlot() { - device->readAll(); - } - -}; - -class HttpDownloadPerformanceServer : QObject { - Q_OBJECT; - qint64 dataSize; - qint64 dataSent; - QTcpServer server; - QTcpSocket *client; - bool serverSendsContentLength; - bool chunkedEncoding; - -public: - HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { - server.listen(); - connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); - } - - int serverPort() { - return server.serverPort(); - } - -public slots: - - void newConnectionSlot() { - client = server.nextPendingConnection(); - client->setParent(this); - connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); - } - - void readyReadSlot() { - client->readAll(); - client->write("HTTP/1.0 200 OK\n"); - if (serverSendsContentLength) - client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); - if (chunkedEncoding) - client->write(QString("Transfer-Encoding: chunked\n").toAscii()); - client->write("Connection: close\n\n"); - } - - void bytesWrittenSlot(qint64 amount) { - Q_UNUSED(amount); - if (dataSent == dataSize && client) { - // close eventually - - // chunked encoding: we have to send a last "empty" chunk - if (chunkedEncoding) - client->write(QString("0\r\n\r\n").toAscii()); - - client->disconnectFromHost(); - server.close(); - client = 0; - return; - } - - // send data - if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { - qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); - QByteArray data(amount, '@'); - - if (chunkedEncoding) { - client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); - client->write(data.constData(), amount); - client->write(QString("\r\n").toAscii()); - } else { - client->write(data.constData(), amount); - } - - dataSent += amount; - } - } -}; - tst_QNetworkReply::tst_QNetworkReply() { @@ -3311,7 +2969,6 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() server.close(); } - void tst_QNetworkReply::rateControl_data() { QTest::addColumn("rate"); @@ -3365,142 +3022,6 @@ void tst_QNetworkReply::rateControl() QVERIFY(sender.transferRate <= maxRate); } -void tst_QNetworkReply::downloadPerformance() -{ - // unlike the above function, this one tries to send as fast as possible - // and measures how fast it was. - TimedSender sender(5000); - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.get(request); - DataReader reader(reply, false); - - QTime loopTime; - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::uploadPerformance() -{ - ThreadedDataReader reader; - DataGenerator generator; - - - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.put(request, &generator); - generator.start(); - connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTimer::singleShot(5000, &generator, SLOT(stop())); - - QTestEventLoop::instance().enterLoop(30); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); -} - -void tst_QNetworkReply::httpUploadPerformance() -{ -#ifdef Q_OS_SYMBIAN - // SHow some mercy for non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - ThreadedDataReaderHttpServer reader; - FixedSizeDataGenerator generator(UploadSize); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1")); - request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize); - - QNetworkReplyPtr reply = manager.put(request, &generator); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QTime time; - generator.start(); - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; - - reader.exit(); - reader.wait(); -} - - -void tst_QNetworkReply::performanceControlRate() -{ - // this is a control comparison for the other two above - // it does the same thing, but instead bypasses the QNetworkAccess system - qDebug() << "The following are the maximum transfer rates that we can get in this system" - " (bypassing QNetworkAccess)"; - - TimedSender sender(5000); - QTcpSocket sink; - sink.connectToHost("127.0.0.1", sender.serverPort()); - DataReader reader(&sink, false); - - QTime loopTime; - connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::httpDownloadPerformance_data() -{ - QTest::addColumn("serverSendsContentLength"); - QTest::addColumn("chunkedEncoding"); - - QTest::newRow("Server sends no Content-Length") << false << false; - QTest::newRow("Server sends Content-Length") << true << false; - QTest::newRow("Server uses chunked encoding") << false << true; - -} - -void tst_QNetworkReply::httpDownloadPerformance() -{ - QFETCH(bool, serverSendsContentLength); - QFETCH(bool, chunkedEncoding); -#ifdef Q_OS_SYMBIAN - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReplyPtr reply = manager.get(request); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - HttpDownloadPerformanceClient client(reply); - - QTime time; - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; -} - void tst_QNetworkReply::downloadProgress_data() { QTest::addColumn("loopCount"); diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 993db52..1d50013 100644 --- a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -46,11 +46,397 @@ #include #include #include +#include +#include #include "../../auto/network-settings.h" + +class TimedSender: public QThread +{ + Q_OBJECT + qint64 totalBytes; + QSemaphore ready; + QByteArray dataToSend; + QTcpSocket *client; + int timeout; + int port; +public: + int transferRate; + TimedSender(int ms) + : totalBytes(0), timeout(ms), port(-1), transferRate(-1) + { + dataToSend = QByteArray(16*1024, '@'); + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +private slots: + void writeMore() + { + while (client->bytesToWrite() < 128 * 1024) { + writePacket(dataToSend); + } + } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + + writeMore(); + connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection); + + QEventLoop eventLoop; + QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); + + // wait for the connection to shut down + client->disconnectFromHost(); + if (!client->waitForDisconnected(10000)) + return; + + transferRate = totalBytes * 1000 / timer.elapsed(); + qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in" + << timer.elapsed() << "ms"; + } + + void writePacket(const QByteArray &array) + { + client->write(array); + totalBytes += array.size(); + } +}; + + +class QNetworkReplyPtr: public QSharedPointer +{ +public: + inline QNetworkReplyPtr(QNetworkReply *ptr = 0) + : QSharedPointer(ptr) + { } + + inline operator QNetworkReply *() const { return data(); } +}; + + +class DataReader: public QObject +{ + Q_OBJECT +public: + qint64 totalBytes; + QByteArray data; + QIODevice *device; + bool accumulate; + DataReader(QIODevice *dev, bool acc = true) : totalBytes(0), device(dev), accumulate(acc) + { + connect(device, SIGNAL(readyRead()), SLOT(doRead())); + } + +public slots: + void doRead() + { + QByteArray buffer; + buffer.resize(device->bytesAvailable()); + qint64 bytesRead = device->read(buffer.data(), device->bytesAvailable()); + if (bytesRead == -1) { + QTestEventLoop::instance().exitLoop(); + return; + } + buffer.truncate(bytesRead); + totalBytes += bytesRead; + + if (accumulate) + data += buffer; + } +}; + +class ThreadedDataReader: public QThread +{ + Q_OBJECT + // used to make the constructor only return after the tcp server started listening + QSemaphore ready; + QTcpSocket *client; + int timeout; + int port; +public: + qint64 transferRate; + ThreadedDataReader() + : port(-1), transferRate(-1) + { + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + + QEventLoop eventLoop; + DataReader reader(client, false); + QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + qint64 elapsed = timer.elapsed(); + + transferRate = reader.totalBytes * 1000 / elapsed; + qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; + } +}; + +class DataGenerator: public QIODevice +{ + Q_OBJECT + enum { Idle, Started, Stopped } state; +public: + DataGenerator() : state(Idle) + { open(ReadOnly); } + + virtual bool isSequential() const { return true; } + virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; } + +public slots: + void start() { state = Started; emit readyRead(); } + void stop() { state = Stopped; emit readyRead(); } + +protected: + virtual qint64 readData(char *data, qint64 maxlen) + { + if (state == Stopped) + return -1; // EOF + + // return as many bytes as are wanted + memset(data, '@', maxlen); + return maxlen; + } + virtual qint64 writeData(const char *, qint64) + { return -1; } +}; + +class ThreadedDataReaderHttpServer: public QThread +{ + Q_OBJECT + // used to make the constructor only return after the tcp server started listening + QSemaphore ready; + QTcpSocket *client; + int timeout; + int port; +public: + qint64 transferRate; + ThreadedDataReaderHttpServer() + : port(-1), transferRate(-1) + { + start(); + ready.acquire(); + } + + inline int serverPort() const { return port; } + +protected: + void run() + { + QTcpServer server; + server.listen(); + port = server.serverPort(); + ready.release(); + + server.waitForNewConnection(-1); + client = server.nextPendingConnection(); + client->write("HTTP/1.0 200 OK\r\n"); + client->write("Content-length: 0\r\n"); + client->write("\r\n"); + client->flush(); + + QCoreApplication::processEvents(); + + QEventLoop eventLoop; + DataReader reader(client, false); + QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); + + QTime timer; + timer.start(); + eventLoop.exec(); + qint64 elapsed = timer.elapsed(); + + transferRate = reader.totalBytes * 1000 / elapsed; + qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; + } +}; + + +class FixedSizeDataGenerator : public QIODevice +{ + Q_OBJECT + enum { Idle, Started, Stopped } state; +public: + FixedSizeDataGenerator(qint64 size) : state(Idle) + { open(ReadOnly | Unbuffered); + toBeGeneratedTotalCount = toBeGeneratedCount = size; + } + + virtual qint64 bytesAvailable() const + { + return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0; + } + + virtual bool isSequential() const{ + return false; + } + + virtual bool reset() const{ + return false; + } + + qint64 size() const { + return toBeGeneratedTotalCount; + } + +public slots: + void start() { state = Started; emit readyRead(); } + +protected: + virtual qint64 readData(char *data, qint64 maxlen) + { + memset(data, '@', maxlen); + + if (toBeGeneratedCount <= 0) { + return -1; + } + + qint64 n = qMin(maxlen, toBeGeneratedCount); + toBeGeneratedCount -= n; + + if (toBeGeneratedCount <= 0) { + // make sure this is a queued connection! + emit readChannelFinished(); + } + + return n; + } + virtual qint64 writeData(const char *, qint64) + { return -1; } + + qint64 toBeGeneratedCount; + qint64 toBeGeneratedTotalCount; +}; + +class HttpDownloadPerformanceServer : QObject { + Q_OBJECT; + qint64 dataSize; + qint64 dataSent; + QTcpServer server; + QTcpSocket *client; + bool serverSendsContentLength; + bool chunkedEncoding; + +public: + HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), + client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + server.listen(); + connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); + } + + int serverPort() { + return server.serverPort(); + } + +public slots: + + void newConnectionSlot() { + client = server.nextPendingConnection(); + client->setParent(this); + connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); + } + + void readyReadSlot() { + client->readAll(); + client->write("HTTP/1.0 200 OK\n"); + if (serverSendsContentLength) + client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); + if (chunkedEncoding) + client->write(QString("Transfer-Encoding: chunked\n").toAscii()); + client->write("Connection: close\n\n"); + } + + void bytesWrittenSlot(qint64 amount) { + Q_UNUSED(amount); + if (dataSent == dataSize && client) { + // close eventually + + // chunked encoding: we have to send a last "empty" chunk + if (chunkedEncoding) + client->write(QString("0\r\n\r\n").toAscii()); + + client->disconnectFromHost(); + server.close(); + client = 0; + return; + } + + // send data + if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { + qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); + QByteArray data(amount, '@'); + + if (chunkedEncoding) { + client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); + client->write(data.constData(), amount); + client->write(QString("\r\n").toAscii()); + } else { + client->write(data.constData(), amount); + } + + dataSent += amount; + } + } +}; + +class HttpDownloadPerformanceClient : QObject { + Q_OBJECT; + QIODevice *device; + public: + HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ + connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + } + + public slots: + void readyReadSlot() { + device->readAll(); + } + +}; + + + + class tst_qnetworkreply : public QObject { Q_OBJECT + + QNetworkAccessManager manager; private slots: void httpLatency(); @@ -58,6 +444,14 @@ private slots: void echoPerformance_data(); void echoPerformance(); #endif + + void downloadPerformance(); + void uploadPerformance(); + void performanceControlRate(); + void httpUploadPerformance(); + void httpDownloadPerformance_data(); + void httpDownloadPerformance(); + }; void tst_qnetworkreply::httpLatency() @@ -107,6 +501,142 @@ void tst_qnetworkreply::echoPerformance() } #endif +void tst_qnetworkreply::downloadPerformance() +{ + // unlike the above function, this one tries to send as fast as possible + // and measures how fast it was. + TimedSender sender(5000); + QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); + QNetworkReplyPtr reply = manager.get(request); + DataReader reader(reply, false); + + QTime loopTime; + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + loopTime.start(); + QTestEventLoop::instance().enterLoop(40); + int elapsedTime = loopTime.elapsed(); + sender.wait(); + + qint64 receivedBytes = reader.totalBytes; + qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" + << elapsedTime << "ms"; +} + +void tst_qnetworkreply::uploadPerformance() +{ + ThreadedDataReader reader; + DataGenerator generator; + + + QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); + QNetworkReplyPtr reply = manager.put(request, &generator); + generator.start(); + connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTimer::singleShot(5000, &generator, SLOT(stop())); + + QTestEventLoop::instance().enterLoop(30); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); +} + +void tst_qnetworkreply::httpUploadPerformance() +{ +#ifdef Q_OS_SYMBIAN + // SHow some mercy for non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else + enum {UploadSize = 128*1024*1024}; // 128 MB +#endif + ThreadedDataReaderHttpServer reader; + FixedSizeDataGenerator generator(UploadSize); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1")); + request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize); + + QNetworkReplyPtr reply = manager.put(request, &generator); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTime time; + generator.start(); + time.start(); + QTestEventLoop::instance().enterLoop(40); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; + + reader.exit(); + reader.wait(); +} + + +void tst_qnetworkreply::performanceControlRate() +{ + // this is a control comparison for the other two above + // it does the same thing, but instead bypasses the QNetworkAccess system + qDebug() << "The following are the maximum transfer rates that we can get in this system" + " (bypassing QNetworkAccess)"; + + TimedSender sender(5000); + QTcpSocket sink; + sink.connectToHost("127.0.0.1", sender.serverPort()); + DataReader reader(&sink, false); + + QTime loopTime; + connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); + loopTime.start(); + QTestEventLoop::instance().enterLoop(40); + int elapsedTime = loopTime.elapsed(); + sender.wait(); + + qint64 receivedBytes = reader.totalBytes; + qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" + << elapsedTime << "ms"; +} + +void tst_qnetworkreply::httpDownloadPerformance_data() +{ + QTest::addColumn("serverSendsContentLength"); + QTest::addColumn("chunkedEncoding"); + + QTest::newRow("Server sends no Content-Length") << false << false; + QTest::newRow("Server sends Content-Length") << true << false; + QTest::newRow("Server uses chunked encoding") << false << true; + +} + +void tst_qnetworkreply::httpDownloadPerformance() +{ + QFETCH(bool, serverSendsContentLength); + QFETCH(bool, chunkedEncoding); +#ifdef Q_OS_SYMBIAN + // Show some mercy to non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else + enum {UploadSize = 128*1024*1024}; // 128 MB +#endif + HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + HttpDownloadPerformanceClient client(reply); + + QTime time; + time.start(); + QTestEventLoop::instance().enterLoop(40); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; +} + QTEST_MAIN(tst_qnetworkreply) #include "tst_qnetworkreply.moc" -- cgit v0.12 From b22f7a8af0a781885a64d0cd1001192c99872aef Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 29 Oct 2009 17:55:06 +0100 Subject: QLocalSocket test: stabilize test by calling waitFor... function ... to make sure bytes are availabe to read Reviewed-by: Aleksandar Sasha Babic --- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index ab7b0ac..5ead049 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -587,14 +587,16 @@ void tst_QLocalSocket::readBufferOverflow() char buffer[dataBufferSize]; memset(buffer, 0, dataBufferSize); serverSocket->write(buffer, dataBufferSize); - serverSocket->flush(); + serverSocket->waitForBytesWritten(); + // wait until the first 128 bytes are ready to read QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); -#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN) - QTest::qWait(250); -#endif + // wait until the second 128 bytes are ready to read + QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); + // no more bytes available + QVERIFY(client.bytesAvailable() == 0); } // QLocalSocket/Server can take a name or path, check that it works as expected -- cgit v0.12 From 135710b1fa38f72a934c542d196af9eff066d908 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 4 Nov 2009 11:44:23 +0100 Subject: QHostInfo: do not wait forever on cleanup patch by Warwick Allison. On cleanup in QHostInfoAgent, we were waiting forever for the thread to terminate, which did not always succeed due to a Linux kernel bug. Now, we just wait for some time and then return anyway. Reviewed-by: Marius Storm-Olsen Task-number: QTBUG-5296 --- src/network/kernel/qhostinfo_p.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 64c5152..afd3570 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -161,9 +161,11 @@ public Q_SLOTS: cond.wakeOne(); } #ifndef QT_NO_THREAD - if (!wait(QHOSTINFO_THREAD_WAIT)) + if (!wait(QHOSTINFO_THREAD_WAIT)) { terminate(); - wait(); + // Don't wait forever; see QTBUG-5296. + wait(QHOSTINFO_THREAD_WAIT); + } #endif } -- cgit v0.12 From 030b19f36e82cc005d21fab56e26c8b76c811ae7 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 4 Nov 2009 15:01:49 +0100 Subject: Add src/tools/tools.pro, and use when building host tools for xcompiling Configure.exe would simply initiate a build for each of the tools in order. However, this would break certain distributed build systems, since they would return right away after initiating the make. Thus, sometimes moc et al. would try to link before bootstrap lib was built. Reviewed-by: Jason McDonald --- configure.exe | Bin 2170880 -> 1172992 bytes src/src.pro | 31 ++--------------- src/tools/tools.pro | 71 +++++++++++++++++++++++++++++++++++++++ tools/configure/configureapp.cpp | 5 +-- 4 files changed, 75 insertions(+), 32 deletions(-) create mode 100644 src/tools/tools.pro diff --git a/configure.exe b/configure.exe index dabf10c..04aefde 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/src/src.pro b/src/src.pro index 238f534..77605a8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,17 +8,12 @@ wince*:{ } else:symbian { SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib src_s60installs } else { - SRC_SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic src_corelib src_xml src_network src_gui src_sql src_testlib + include(tools/tools.pro) + SRC_SUBDIRS += src_corelib src_xml src_network src_gui src_sql src_testlib !vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus - !cross_compile { - contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3 - } -} -win32:{ - SRC_SUBDIRS += src_activeqt - !wince*: SRC_SUBDIRS += src_tools_idc } +win32:SRC_SUBDIRS += src_activeqt contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg @@ -40,14 +35,6 @@ src_s60installs.subdir = $$QT_SOURCE_TREE/src/s60installs src_s60installs.target = sub-s60installs src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain src_winmain.target = sub-winmain -src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap -src_tools_bootstrap.target = sub-tools-bootstrap -src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc -src_tools_moc.target = sub-moc -src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc -src_tools_rcc.target = sub-rcc -src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic -src_tools_uic.target = sub-uic src_corelib.subdir = $$QT_SOURCE_TREE/src/corelib src_corelib.target = sub-corelib src_xml.subdir = $$QT_SOURCE_TREE/src/xml @@ -78,12 +65,8 @@ src_phonon.subdir = $$QT_SOURCE_TREE/src/phonon src_phonon.target = sub-phonon src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia src_multimedia.target = sub-multimedia -src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3 -src_tools_uic3.target = sub-uic3 src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt src_activeqt.target = sub-activeqt -src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc -src_tools_idc.target = sub-idc src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins src_plugins.target = sub-plugins src_testlib.subdir = $$QT_SOURCE_TREE/src/testlib @@ -95,9 +78,6 @@ src_webkit.target = sub-webkit #CONFIG += ordered !wince*:!symbian:!ordered { - src_tools_moc.depends = src_tools_bootstrap - src_tools_rcc.depends = src_tools_bootstrap - src_tools_uic.depends = src_tools_bootstrap src_corelib.depends = src_tools_moc src_tools_rcc src_gui.depends = src_corelib src_tools_uic embedded: src_gui.depends += src_network @@ -115,8 +95,6 @@ src_webkit.target = sub-webkit src_qt3support.depends = src_gui src_xml src_network src_sql src_phonon.depends = src_gui src_multimedia.depends = src_gui - src_tools_uic3.depends = src_qt3support src_xml - src_tools_idc.depends = src_corelib src_tools_activeqt.depends = src_tools_idc src_gui src_plugins.depends = src_gui src_sql src_svg contains(QT_CONFIG, webkit) { @@ -141,8 +119,6 @@ sub_src_target.recurse_target = QMAKE_EXTRA_TARGETS += sub_src_target # This gives us a top level debug/release -EXTRA_DEBUG_TARGETS = -EXTRA_RELEASE_TARGETS = for(subname, SRC_SUBDIRS) { subdir = $$subname !isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir) @@ -184,4 +160,3 @@ QMAKE_EXTRA_TARGETS += debug release } SUBDIRS += $$SRC_SUBDIRS - diff --git a/src/tools/tools.pro b/src/tools/tools.pro new file mode 100644 index 0000000..798bd0b --- /dev/null +++ b/src/tools/tools.pro @@ -0,0 +1,71 @@ +TEMPLATE = subdirs + +TOOLS_SUBDIRS = src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic +!cross_compile { + contains(QT_CONFIG, qt3support): TOOLS_SUBDIRS += src_tools_uic3 + win32:!wince*: TOOLS_SUBDIRS += src_tools_idc +} + +# Set subdir and respective target name +src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap +src_tools_bootstrap.target = sub-tools-bootstrap +src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc +src_tools_moc.target = sub-moc +src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc +src_tools_rcc.target = sub-rcc +src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic +src_tools_uic.target = sub-uic +src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3 +src_tools_uic3.target = sub-uic3 +src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc +src_tools_idc.target = sub-idc + +# Set dependencies for each subdir +src_tools_moc.depends = src_tools_bootstrap +src_tools_rcc.depends = src_tools_bootstrap +src_tools_uic.depends = src_tools_bootstrap +src_tools_idc.depends = src_corelib # defined in parent pro, in any, if not ignored +src_tools_uic3.depends = src_qt3support src_xml # defined in parent pro, in any, if not ignored + +# Special handling, depending on type of project, if it used debug/release or only has one configuration +EXTRA_DEBUG_TARGETS = +EXTRA_RELEASE_TARGETS = +!symbian { + for(subname, TOOLS_SUBDIRS) { + subdir = $$subname + !isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir) + subpro = $$subdir/$${basename(subdir)}.pro + !exists($$subpro):next() + subtarget = $$replace(subdir, [^A-Za-z0-9], _) + reg_src = $$replace(QT_SOURCE_TREE, \\\\, \\\\) + subdir = $$replace(subdir, $$reg_src, $$QT_BUILD_TREE) + subdir = $$replace(subdir, /, $$QMAKE_DIR_SEP) + subdir = $$replace(subdir, \\\\, $$QMAKE_DIR_SEP) + SUB_TEMPLATE = $$list($$fromfile($$subpro, TEMPLATE)) + !isEqual(subname, src_tools_bootstrap):if(isEqual($$SUB_TEMPLATE, lib) | isEqual($$SUB_TEMPLATE, subdirs) | isEqual(subname, src_tools_idc) | isEqual(subname, src_tools_uic3)):!separate_debug_info { + #debug + eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS) + eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) debug)) + EXTRA_DEBUG_TARGETS += debug-$${subtarget} + QMAKE_EXTRA_TARGETS += debug-$${subtarget} + #release + eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS) + eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) release)) + EXTRA_RELEASE_TARGETS += release-$${subtarget} + QMAKE_EXTRA_TARGETS += release-$${subtarget} + } else { #do not have a real debug target/release + #debug + eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS) + eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first)) + EXTRA_DEBUG_TARGETS += debug-$${subtarget} + QMAKE_EXTRA_TARGETS += debug-$${subtarget} + #release + eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS) + eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first)) + EXTRA_RELEASE_TARGETS += release-$${subtarget} + QMAKE_EXTRA_TARGETS += release-$${subtarget} + } + } +} + +SUBDIRS += $$TOOLS_SUBDIRS diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index f75b51b..5e11534 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3379,10 +3379,7 @@ void Configure::buildHostTools() QString pwd = QDir::currentPath(); QStringList hostToolsDirs; hostToolsDirs - << "src/tools/bootstrap" - << "src/tools/moc" - << "src/tools/rcc" - << "src/tools/uic"; + << "src/tools"; if(dictionary["XQMAKESPEC"].startsWith("wince")) hostToolsDirs << "tools/checksdk"; -- cgit v0.12 From d1ffc7422e71e42a329f7a9c78b6e584109169f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 4 Nov 2009 13:42:08 +0100 Subject: Extending tst_QFile::writeLargeDataBlock test To test not only native, but fd and FILE* backends as well. Moved expensive generation of large block into a separate function that caches the result. Reviewed-by: Peter Hartmann --- tests/auto/qfile/tst_qfile.cpp | 164 +++++++++++++++++++++++++++++++++-------- 1 file changed, 134 insertions(+), 30 deletions(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 19fbecd..338ab9c 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -79,6 +79,10 @@ # define SRCDIR "" #endif +#ifndef QT_OPEN_BINARY +#define QT_OPEN_BINARY 0 +#endif + Q_DECLARE_METATYPE(QFile::FileError) //TESTED_CLASS= @@ -196,6 +200,81 @@ public: // disabled this test for the moment... it hangs void invalidFile_data(); void invalidFile(); + +private: + enum FileType { OpenQFile, OpenFd, OpenStream }; + + bool openFd(QFile &file, QIODevice::OpenMode mode) + { + int fdMode = QT_OPEN_LARGEFILE | QT_OPEN_BINARY; + + // File will be truncated if in Write mode. + if (mode & QIODevice::WriteOnly) + fdMode |= QT_OPEN_WRONLY | QT_OPEN_TRUNC; + if (mode & QIODevice::ReadOnly) + fdMode |= QT_OPEN_RDONLY; + + fd_ = QT_OPEN(qPrintable(file.fileName()), fdMode); + + return (-1 != fd_) && file.open(fd_, mode); + } + + bool openStream(QFile &file, QIODevice::OpenMode mode) + { + char const *streamMode = ""; + + // File will be truncated if in Write mode. + if (mode & QIODevice::WriteOnly) + streamMode = "wb+"; + else if (mode & QIODevice::ReadOnly) + streamMode = "rb"; + + stream_ = QT_FOPEN(qPrintable(file.fileName()), streamMode); + + return stream_ && file.open(stream_, mode); + } + + bool openFile(QFile &file, QIODevice::OpenMode mode, FileType type = OpenQFile) + { + if (mode & QIODevice::WriteOnly && !file.exists()) + { + // Make sure the file exists + QFile createFile(file.fileName()); + if (!createFile.open(QIODevice::ReadWrite)) + return false; + } + + // Note: openFd and openStream will truncate the file if write mode. + switch (type) + { + case OpenQFile: + return file.open(mode); + + case OpenFd: + return openFd(file, mode); + + case OpenStream: + return openStream(file, mode); + } + + return false; + } + + void closeFile(QFile &file) + { + file.close(); + + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); + + fd_ = -1; + stream_ = 0; + } + + int fd_; + FILE *stream_; }; tst_QFile::tst_QFile() @@ -211,6 +290,8 @@ void tst_QFile::init() { // TODO: Add initialization code here. // This will be executed immediately before each test is run. + fd_ = -1; + stream_ = 0; } void tst_QFile::cleanup() @@ -239,6 +320,11 @@ void tst_QFile::cleanup() QFile::remove("existing-file.txt"); QFile::remove("file-renamed-once.txt"); QFile::remove("file-renamed-twice.txt"); + + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); } void tst_QFile::initTestCase() @@ -1909,53 +1995,71 @@ void tst_QFile::fullDisk() void tst_QFile::writeLargeDataBlock_data() { QTest::addColumn("fileName"); + QTest::addColumn("type"); + + QTest::newRow("localfile-QFile") << "./largeblockfile.txt" << (int)OpenQFile; + QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd; + QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream; - QTest::newRow("localfile") << QString("./largeblockfile.txt"); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Some semi-randomness to avoid collisions. QTest::newRow("unc file") << QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt") .arg(QHostInfo::localHostName()) - .arg(QTime::currentTime().msec()); + .arg(QTime::currentTime().msec()) << (int)OpenQFile; #endif } -void tst_QFile::writeLargeDataBlock() +static QByteArray getLargeDataBlock() { - QFETCH(QString, fileName); + static QByteArray array; - // Generate a 64MB array with well defined contents. - QByteArray array; + if (array.isNull()) + { #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) - int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space + int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space #else - int resizeSize = 64 * 1024 * 1024; + int resizeSize = 64 * 1024 * 1024; #endif - array.resize(resizeSize); - for (int i = 0; i < array.size(); ++i) - array[i] = uchar(i); + array.resize(resizeSize); + for (int i = 0; i < array.size(); ++i) + array[i] = uchar(i); + } - // Remove and open the target file - QFile file(fileName); - file.remove(); - if (file.open(QFile::WriteOnly)) { - QCOMPARE(file.write(array), qint64(array.size())); - file.close(); - QVERIFY(file.open(QFile::ReadOnly)); - array.clear(); - array = file.readAll(); - file.remove(); - } else { - QFAIL(qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName))); + return array; +} + +void tst_QFile::writeLargeDataBlock() +{ + QFETCH(QString, fileName); + QFETCH( int, type ); + + QByteArray const originalData = getLargeDataBlock(); + + { + QFile file(fileName); + + QVERIFY2( openFile(file, QIODevice::WriteOnly, (FileType)type), + qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName)) ); + QCOMPARE( file.write(originalData), (qint64)originalData.size() ); + QVERIFY( file.flush() ); + + closeFile(file); } - // Check that we got the right content - QCOMPARE(array.size(), resizeSize); - for (int i = 0; i < array.size(); ++i) { - if (array[i] != char(i)) { - QFAIL(qPrintable(QString("Wrong contents! Char at %1 = %2, expected %3") - .arg(i).arg(int(uchar(array[i]))).arg(int(uchar(i))))); - } + + QByteArray readData; + + { + QFile file(fileName); + + QVERIFY2( openFile(file, QIODevice::ReadOnly, (FileType)type), + qPrintable(QString("Couldn't open file for reading: [%1]").arg(fileName)) ); + readData = file.readAll(); + closeFile(file); } + + QCOMPARE( readData, originalData ); + QVERIFY( QFile::remove(fileName) ); } void tst_QFile::readFromWriteOnlyFile() -- cgit v0.12 From c08e708037d33271825ce6a6a1ac640e96b70c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 4 Nov 2009 16:30:38 +0100 Subject: Remove 4k-chunking in QFSFileEngine::read/writeFdFh This was a serious performance issue on Symbian and not necessarily optimal on other platforms. For the time being, we'll allow the OS to read/write as much as it can. Otherwise cleaned up the code, adding checks for invalid len arguments. Task-number: QT-2347 Reviewed-by: Peter Hartmann --- src/corelib/io/qfsfileengine.cpp | 163 +++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 85 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index fb096a7..7ea1815 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -622,71 +622,55 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) { Q_Q(QFSFileEngine); - // Buffered stdlib mode. + if (len < 0 || len != qint64(size_t(len))) { + q->setError(QFile::ReadError, qt_error_string(EINVAL)); + return -1; + } + + qint64 readBytes = 0; + bool eof = false; + if (fh) { - qint64 readBytes = 0; - qint64 read = 0; - int retry = 0; + // Buffered stdlib mode. - // Read in blocks of 4k to avoid platform limitations (Windows - // commonly bails out if you read or write too large blocks at once). - qint64 bytesToRead; + size_t result; + bool retry = true; do { - if (retry == 1) - retry = 2; - - bytesToRead = qMin(4096, len - read); - do { - readBytes = fread(data + read, 1, size_t(bytesToRead), fh); - } while (readBytes == 0 && !feof(fh) && errno == EINTR); - - if (readBytes > 0) { - read += readBytes; - } else if (!retry && feof(fh)) { - // Synchronize and try again (just once though). - if (++retry == 1) - QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); + result = fread(data + readBytes, 1, size_t(len - readBytes), fh); + eof = feof(fh); + if (retry && eof && result == 0) { + // On Mac OS, this is needed, e.g., if a file was written to + // through another stream since our last read. See test + // tst_QFile::appendAndRead + QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream. + retry = false; + continue; } - } while (retry == 1 || (readBytes == bytesToRead && read < len)); + readBytes += result; + } while (!eof && (result == 0 ? errno == EINTR : readBytes < len)); - // Return the number of bytes read, or if nothing was read, return -1 - // if an error occurred, or 0 if we detected EOF. - if (read == 0) { - q->setError(QFile::ReadError, qt_error_string(int(errno))); - if (!feof(fh)) - read = -1; - } - return read; - } + } else if (fd != -1) { + // Unbuffered stdio mode. - // Unbuffered stdio mode. - qint64 ret = 0; - if (len) { +#ifdef Q_OS_WIN int result; - qint64 read = 0; - errno = 0; - - // Read in blocks of 4k to avoid platform limitations (Windows - // commonly bails out if you read or write too large blocks at once). +#else + ssize_t result; +#endif do { - qint64 bytesToRead = qMin(4096, len - read); - do { - result = QT_READ(fd, data + read, int(bytesToRead)); - } while (result == -1 && errno == EINTR); - if (result > 0) - read += result; - } while (result > 0 && read < len); - - // Return the number of bytes read, or if nothing was read, return -1 - // if an error occurred. - if (read > 0) { - ret += read; - } else if (read == 0 && result < 0) { - ret = -1; - q->setError(QFile::ReadError, qt_error_string(errno)); - } + result = QT_READ(fd, data + readBytes, size_t(len - readBytes)); + } while ((result == -1 && errno == EINTR) + || (result > 0 && (readBytes += result) < len)); + + eof = !(result == -1); } - return ret; + + if (!eof && readBytes == 0) { + readBytes = -1; + q->setError(QFile::ReadError, qt_error_string(errno)); + } + + return readBytes; } /*! @@ -766,36 +750,45 @@ qint64 QFSFileEngine::write(const char *data, qint64 len) qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len) { Q_Q(QFSFileEngine); - qint64 result; - qint64 written = 0; - do { - // Write blocks of 4k to avoid platform limitations (Windows commonly - // bails out if you read or write too large blocks at once). - qint64 bytesToWrite = qMin(4096, len - written); - if (fh) { - do { - // Buffered stdlib mode. - result = qint64(fwrite(data + written, 1, size_t(bytesToWrite), fh)); - } while (result == 0 && errno == EINTR); - if (bytesToWrite > 0 && result == 0) - result = -1; - } else { - do { - // Unbuffered stdio mode. - result = QT_WRITE(fd, data + written, bytesToWrite); - } while (result == -1 && errno == EINTR); - } - if (result > 0) - written += qint64(result); - } while (written < len && result > 0); - - // If we read anything, return that with success. Otherwise, set an error, - // and return the last return value. - if (result > 0) - return written; - q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno)); - return result; + if (len < 0 || len != qint64(size_t(len))) { + q->setError(QFile::WriteError, qt_error_string(EINVAL)); + return -1; + } + + qint64 writtenBytes = 0; + + if (fh) { + // Buffered stdlib mode. + + size_t result; + bool eof; + do { + result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh); + writtenBytes += result; + eof = feof(fh); + } while (!eof && (result == 0 ? errno == EINTR : writtenBytes < len)); + + } else if (fd != -1) { + // Unbuffered stdio mode. + +#ifdef Q_OS_WIN + int result; +#else + ssize_t result; +#endif + do { + result = QT_WRITE(fd, data + writtenBytes, size_t(len - writtenBytes)); + } while ((result == -1 && errno == EINTR) + || (result > 0 && (writtenBytes += result) < len)); + } + + if (writtenBytes == 0) { + writtenBytes = -1; + q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno)); + } + + return writtenBytes; } /*! -- cgit v0.12 From 5989d15f73da71b69a27129349a07a15954a8853 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 5 Nov 2009 14:18:38 +1000 Subject: Changes to low-level audio API. QAudioFormat::isNull() -> QAudioFormat::isValid() (inverse logic) QAudio::SuspendState -> QAudio::SuspendedState QAudio::StopState -> QAudio::StoppedState QAudioDeviceInfo::deviceList() -> QAudioDeviceInfo::availableDevices() clock() -> elapsedUSecs() totalTime() -> processedUSecs() QIODevice* start(QIODevice*) -> void start(QIODevice*), QIODevice* start() Reviewed-by:Justin McPherson --- examples/multimedia/audiodevices/audiodevices.cpp | 2 +- examples/multimedia/audioinput/audioinput.cpp | 10 ++-- examples/multimedia/audiooutput/audiooutput.cpp | 12 ++--- src/multimedia/audio/qaudio.cpp | 24 ++++----- src/multimedia/audio/qaudio.h | 2 +- src/multimedia/audio/qaudiodevicefactory.cpp | 22 ++++---- src/multimedia/audio/qaudiodevicefactory_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo.cpp | 8 +-- src/multimedia/audio/qaudiodeviceinfo.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 6 +-- src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 3 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 2 +- src/multimedia/audio/qaudioengine.cpp | 8 +-- src/multimedia/audio/qaudioengine.h | 8 +-- src/multimedia/audio/qaudioengineplugin.h | 4 +- src/multimedia/audio/qaudioformat.cpp | 13 ++--- src/multimedia/audio/qaudioformat.h | 2 +- src/multimedia/audio/qaudioinput.cpp | 63 ++++++++++++---------- src/multimedia/audio/qaudioinput.h | 8 +-- src/multimedia/audio/qaudioinput_alsa_p.cpp | 28 +++++----- src/multimedia/audio/qaudioinput_alsa_p.h | 4 +- src/multimedia/audio/qaudioinput_mac_p.cpp | 24 ++++----- src/multimedia/audio/qaudioinput_mac_p.h | 4 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 36 ++++++------- src/multimedia/audio/qaudioinput_win32_p.h | 4 +- src/multimedia/audio/qaudiooutput.cpp | 52 ++++++++++-------- src/multimedia/audio/qaudiooutput.h | 8 +-- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 32 +++++------ src/multimedia/audio/qaudiooutput_alsa_p.h | 4 +- src/multimedia/audio/qaudiooutput_mac_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_mac_p.h | 4 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_win32_p.h | 4 +- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 6 +-- tests/auto/qaudioformat/tst_qaudioformat.cpp | 15 +++--- tests/auto/qaudioinput/tst_qaudioinput.cpp | 14 ++--- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 18 +++---- 40 files changed, 267 insertions(+), 249 deletions(-) diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4198605..e205e03 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -148,7 +148,7 @@ void AudioTest::modeChanged(int idx) mode=QAudio::AudioOutput; deviceBox->clear(); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(mode)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); } diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 3d537a2..62afd73 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -170,7 +170,7 @@ InputTest::InputTest() layout->addWidget(canvas); deviceBox = new QComboBox(this); - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) { deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); } @@ -216,7 +216,7 @@ InputTest::~InputTest() {} void InputTest::status() { - qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"bytesReady = "<bytesReady()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); } void InputTest::readMore() @@ -239,7 +239,7 @@ void InputTest::toggleMode() if (pullMode) { button->setText(tr("Click for Pull Mode")); - input = audioInput->start(0); + input = audioInput->start(); connect(input,SIGNAL(readyRead()),SLOT(readMore())); pullMode = false; } else { @@ -252,7 +252,7 @@ void InputTest::toggleMode() void InputTest::toggleSuspend() { // toggle suspend/resume - if(audioInput->state() == QAudio::SuspendState) { + if(audioInput->state() == QAudio::SuspendedState) { qWarning()<<"status: Suspended, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); @@ -260,7 +260,7 @@ void InputTest::toggleSuspend() qWarning()<<"status: Active, suspend()"; audioInput->suspend(); button2->setText("Click To Resume"); - } else if (audioInput->state() == QAudio::StopState) { + } else if (audioInput->state() == QAudio::StoppedState) { qWarning()<<"status: Stopped, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index c92bbaf..244840d 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -134,7 +134,7 @@ AudioTest::AudioTest() QVBoxLayout* layout = new QVBoxLayout; deviceBox = new QComboBox(this); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -200,7 +200,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::status() { - qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"byteFree = "<bytesFree()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); } void AudioTest::writeMore() @@ -208,7 +208,7 @@ void AudioTest::writeMore() if(!audioOutput) return; - if(audioOutput->state() == QAudio::StopState) + if(audioOutput->state() == QAudio::StoppedState) return; int l; @@ -234,7 +234,7 @@ void AudioTest::toggle() if (pullMode) { button->setText("Click for Pull Mode"); - output = audioOutput->start(0); + output = audioOutput->start(); pullMode = false; timer->start(20); } else { @@ -247,7 +247,7 @@ void AudioTest::toggle() void AudioTest::togglePlay() { // toggle suspend/resume - if(audioOutput->state() == QAudio::SuspendState) { + if(audioOutput->state() == QAudio::SuspendedState) { qWarning()<<"status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); @@ -255,7 +255,7 @@ void AudioTest::togglePlay() qWarning()<<"status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); - } else if (audioOutput->state() == QAudio::StopState) { + } else if (audioOutput->state() == QAudio::StoppedState) { qWarning()<<"status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index 04378d4..b687f34 100644 --- a/src/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp @@ -71,23 +71,23 @@ public: /*! \enum QAudio::Error - \value NoError No errors have occurred - \value OpenError An error opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. + \value NoError No errors have occurred + \value OpenError An error opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. */ /*! \enum QAudio::State - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StopState The audio device is closed, not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendedState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StoppedState The audio device is closed, not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. */ /*! diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h index a66f0b1..531e1a7 100644 --- a/src/multimedia/audio/qaudio.h +++ b/src/multimedia/audio/qaudio.h @@ -56,7 +56,7 @@ QT_MODULE(Multimedia) namespace QAudio { enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; - enum State { ActiveState, SuspendState, StopState, IdleState }; + enum State { ActiveState, SuspendedState, StoppedState, IdleState }; enum Mode { AudioInput, AudioOutput }; } diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 8804fb6..89e4394 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -94,10 +94,10 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 totalTime() const { return 0; } - qint64 clock() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StopState; } + QAudio::State state() const { return QAudio::StoppedState; } QAudioFormat format() const { return QAudioFormat(); } }; @@ -115,18 +115,18 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 totalTime() const { return 0; } - qint64 clock() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StopState; } + QAudio::State state() const { return QAudio::StoppedState; } QAudioFormat format() const { return QAudioFormat(); } }; -QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) +QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList devices; #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode)) + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif QFactoryLoader* l = loader(); @@ -134,7 +134,7 @@ QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) foreach (QString const& key, l->keys()) { QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); if (plugin) { - foreach (QByteArray const& handle, plugin->deviceList(mode)) + foreach (QByteArray const& handle, plugin->availableDevices(mode)) devices << QAudioDeviceInfo(key, handle, mode); } @@ -149,7 +149,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->deviceList(QAudio::AudioInput); + QList list = plugin->availableDevices(QAudio::AudioInput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } @@ -164,7 +164,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->deviceList(QAudio::AudioOutput); + QList list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h index 008e4a8..2466455 100644 --- a/src/multimedia/audio/qaudiodevicefactory_p.h +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -72,7 +72,7 @@ class QAbstractAudioDeviceInfo; class QAudioDeviceFactory { public: - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index dce2884..5e3adcb 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -121,7 +121,7 @@ public: classes that communicate with the device--such as QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and - deviceList() let you get a list of all available + availableDevices() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by the QAudio::Mode enum. The QAudioDeviceInfo returned are only valid for the QAudio::Mode. @@ -129,7 +129,7 @@ public: For instance: \code - foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) qDebug() << "Device name: " << deviceInfo.deviceName(); \endcode @@ -327,9 +327,9 @@ QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() Returns a list of audio devices that support \a mode. */ -QList QAudioDeviceInfo::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) { - return QAudioDeviceFactory::deviceList(mode); + return QAudioDeviceFactory::availableDevices(mode); } diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 53b9904..5c7cb98 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -92,7 +92,7 @@ public: static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); private: QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index e828238..5de6c70 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -382,7 +382,7 @@ void QAudioDeviceInfoInternal::updateLists() close(); } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { QList devices; QByteArray filter; @@ -444,7 +444,7 @@ QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { - QList devices = deviceList(QAudio::AudioInput); + QList devices = availableDevices(QAudio::AudioInput); if(devices.size() == 0) return QByteArray(); @@ -453,7 +453,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice() QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { - QList devices = deviceList(QAudio::AudioOutput); + QList devices = availableDevices(QAudio::AudioOutput); if(devices.size() == 0) return QByteArray(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 10078ca..5a807af 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -92,7 +92,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode); + static QList availableDevices(QAudio::Mode); private: bool open(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ec07748..8905119 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() return get_device_info(audioDevice, QAudio::AudioOutput); } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { QList devices; diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h index 60532a8..0fd3ef5 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -87,7 +87,7 @@ public: static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); }; QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 69d5c94..33af022 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -103,6 +103,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } else { nearest.setFrequency(11025); nearest.setChannels(1); + nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); @@ -333,7 +334,7 @@ void QAudioDeviceInfoInternal::updateLists() } } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { Q_UNUSED(mode) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h index 0d2ee29..e191b6f 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -93,7 +93,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode); + static QList availableDevices(QAudio::Mode); private: QAudio::Mode mode; diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp index c6e9d97..88e3804 100644 --- a/src/multimedia/audio/qaudioengine.cpp +++ b/src/multimedia/audio/qaudioengine.cpp @@ -189,12 +189,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioOutput::totalTime() const + \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioOutput::clock() const + \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ @@ -304,12 +304,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioInput::totalTime() const + \fn virtual qint64 QAbstractAudioInput::processedUSecs() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioInput::clock() const + \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h index 57a9ae6..f9e80c1 100644 --- a/src/multimedia/audio/qaudioengine.h +++ b/src/multimedia/audio/qaudioengine.h @@ -86,8 +86,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 totalTime() const = 0; - virtual qint64 clock() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; @@ -113,8 +113,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 totalTime() const = 0; - virtual qint64 clock() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h index fe30e0d..82dfa15 100644 --- a/src/multimedia/audio/qaudioengineplugin.h +++ b/src/multimedia/audio/qaudioengineplugin.h @@ -60,7 +60,7 @@ QT_MODULE(Multimedia) struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface { - virtual QList deviceList(QAudio::Mode) const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; @@ -80,7 +80,7 @@ public: ~QAudioEnginePlugin(); virtual QStringList keys() const = 0; - virtual QList deviceList(QAudio::Mode) const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 86fe85b..b2bbe14 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -38,7 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#include #include @@ -214,16 +214,13 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const } /*! - Returns true if any of the parameters are invalid. + Returns true if all of the parameters are valid. */ -bool QAudioFormat::isNull() const +bool QAudioFormat::isValid() const { - return d->frequency == -1 && d->channels == -1 && - d->sampleSize == -1 && - d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) && - d->sampleType == QAudioFormat::Unknown && - d->codec.isNull(); + return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && + d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); } /*! diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index d5841ce..7e92c2f 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -71,7 +71,7 @@ public: bool operator==(const QAudioFormat &other) const; bool operator!=(const QAudioFormat &other) const; - bool isNull() const; + bool isValid() const; void setFrequency(int frequency); int frequency() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 7a3be23..e794eaf 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -121,15 +121,15 @@ QT_BEGIN_NAMESPACE when the state changes (stateChanged()). QAudioInput provides several ways of measuring the time that has - passed since the start() of the recording. The \c totalTime() + passed since the start() of the recording. The \c processedUSecs() function returns the length of the stream in microseconds written, i.e., it leaves out the times the audio input was suspended or idle. - The clock() function returns the time elapsed since start() was called regardless of + The elapsedUSecs() function returns the time elapsed since start() was called regardless of which states the QAudioInput has been in. If an error should occur, you can fetch its reason with error(). The possible error reasons are described by the QAudio::Error - enum. The QAudioInput will enter the \l{QAudio::}{StopState} when + enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when an error is encountered. Connect to the stateChanged() signal to handle the error: @@ -176,37 +176,44 @@ QAudioInput::~QAudioInput() } /*! - Uses the \a device as the QIODevice to transfer data. - If \a device is null then the class creates an internal QIODevice. + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transfered without any extra code. + All that is required is to open the QIODevice. + + \sa QIODevice +*/ + +void QAudioInput::start(QIODevice* device) +{ + /* + -If currently not StoppedState, stop + -If previous start was push mode, delete internal QIODevice. + -open audio input. + If ok, NoError and ActiveState, else OpenError and StoppedState. + -emit stateChanged() + */ + d->start(device); +} + +/*! Returns a pointer to the QIODevice being used to handle the data transfer. This QIODevice can be used to read() audio data directly. - Passing a QIODevice allows the data to be transfered without any extra code. - All that is required is to open the QIODevice. \sa QIODevice */ -QIODevice* QAudioInput::start(QIODevice* device) +QIODevice* QAudioInput::start() { /* - PULL MODE (valid QIODevice) - -If currently not StopState, stop - -If previous start was push mode, delete internal QIODevice. - -open audio input. - If ok, NoError and ActiveState, else OpenError and StopState. - -emit stateChanged() - -return device - - PUSH MODE (device = 0) - -If currently not StopState, stop + -If currently not StoppedState, stop -If no internal QIODevice, create one. -open audio input. - -If ok, NoError and IdleState, else OpenError and StopState + -If ok, NoError and IdleState, else OpenError and StoppedState -emit stateChanged() -return internal QIODevice */ - return d->start(device); + return d->start(0); } /*! @@ -225,8 +232,8 @@ QAudioFormat QAudioInput::format() const void QAudioInput::stop() { /* - -If StopState, return - -set to StopState + -If StoppedState, return + -set to StoppedState -detach from audio device -emit stateChanged() */ @@ -255,7 +262,7 @@ void QAudioInput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendState + -set NoError and SuspendedState -emit stateChanged() */ d->suspend(); @@ -268,7 +275,7 @@ void QAudioInput::suspend() void QAudioInput::resume() { /* - -If SuspendState, return + -If SuspendedState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -357,9 +364,9 @@ int QAudioInput::notifyInterval() const was called in microseconds. */ -qint64 QAudioInput::totalTime() const +qint64 QAudioInput::processedUSecs() const { - return d->totalTime(); + return d->processedUSecs(); } /*! @@ -367,9 +374,9 @@ qint64 QAudioInput::totalTime() const Suspend states. */ -qint64 QAudioInput::clock() const +qint64 QAudioInput::elapsedUSecs() const { - return d->clock(); + return d->elapsedUSecs(); } /*! diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h index c8094f5..bf93a27 100644 --- a/src/multimedia/audio/qaudioinput.h +++ b/src/multimedia/audio/qaudioinput.h @@ -71,7 +71,9 @@ public: QAudioFormat format() const; - QIODevice* start(QIODevice *device = 0); + void start(QIODevice *device); + QIODevice* start(); + void stop(); void reset(); void suspend(); @@ -86,8 +88,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 9eb8cfb..8a8f0db 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -75,7 +75,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -206,7 +206,7 @@ int QAudioInputPrivate::setFormat() QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -234,10 +234,10 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; close(); emit stateChanged(deviceState); @@ -283,7 +283,7 @@ bool QAudioInputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -367,7 +367,7 @@ bool QAudioInputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -490,7 +490,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(l < 0) { close(); errorState = QAudio::IOError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } else if(l == 0) { errorState = QAudio::NoError; @@ -508,7 +508,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { int err = 0; if(handle) { @@ -558,7 +558,7 @@ int QAudioInputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioInputPrivate::totalTime() const +qint64 QAudioInputPrivate::processedUSecs() const { return totalTimeValue; } @@ -567,14 +567,14 @@ void QAudioInputPrivate::suspend() { if(deviceState == QAudio::ActiveState||resuming) { timer->stop(); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; emit stateChanged(deviceState); } } void QAudioInputPrivate::userFeed() { - if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -606,12 +606,12 @@ bool QAudioInputPrivate::deviceReady() return true; } -qint64 QAudioInputPrivate::clock() const +qint64 QAudioInputPrivate::elapsedUSecs() const { if(!handle) return 0; - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h index 2ed7453..67d5cf5 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.h +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index cb05920..d63045f 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -526,7 +526,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; intervalTimer = new QTimer(this); intervalTimer->setInterval(1000); @@ -708,7 +708,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; } @@ -736,12 +736,12 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); audioBuffer->flush(true); errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -749,11 +749,11 @@ void QAudioInputPrivate::stop() void QAudioInputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -765,7 +765,7 @@ void QAudioInputPrivate::suspend() audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::SuspendState; + stateCode = QAudio::SuspendedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -773,7 +773,7 @@ void QAudioInputPrivate::suspend() void QAudioInputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendState) { + if (stateCode == QAudio::SuspendedState) { audioThreadStart(); errorCode = QAudio::NoError; @@ -812,14 +812,14 @@ int QAudioInputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioInputPrivate::totalTime() const +qint64 QAudioInputPrivate::processedUSecs() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioInputPrivate::clock() const +qint64 QAudioInputPrivate::elapsedUSecs() const { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -875,7 +875,7 @@ void QAudioInputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index a080648..2dbb808 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -129,8 +129,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index a059e76..31f6e25 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor totalTimeValue = 0; intervalTime = 1000; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -173,7 +173,7 @@ QAudioFormat QAudioInputPrivate::format() const QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -201,7 +201,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; close(); @@ -260,7 +260,7 @@ bool QAudioInputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to open audio device"); return false; @@ -269,7 +269,7 @@ bool QAudioInputPrivate::open() if(waveBlocks == 0) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to allocate blocks. open failed"); return false; @@ -286,7 +286,7 @@ bool QAudioInputPrivate::open() if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",i,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -295,7 +295,7 @@ bool QAudioInputPrivate::open() if(result) { qWarning("QAudioInput: failed to start audio input"); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -309,12 +309,12 @@ bool QAudioInputPrivate::open() void QAudioInputPrivate::close() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; waveInReset(hWaveIn); waveInClose(hWaveIn); - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; int count = 0; while(!finished && count < 100) { @@ -400,14 +400,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR)); if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } header++; @@ -435,14 +435,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { deviceState = QAudio::ActiveState; for(int i=0; istart(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to write() audio data directly. - PUSH MODE (device = 0) - -If currently not StopState, stop. + \sa QIODevice +*/ + +QIODevice* QAudioOutput::start() +{ + /* + -If currently not StoppedState, stop. -If no internal QIODevice, create one. -open audio output. - -If ok, NoError and IdleState, else OpenError and StopState + -If ok, NoError and IdleState, else OpenError and StoppedState -emit stateChanged() -return internal QIODevice */ - return d->start(device); + return d->start(0); } /*! @@ -227,8 +233,8 @@ QIODevice* QAudioOutput::start(QIODevice* device) void QAudioOutput::stop() { /* - -If StopState, return - -set to StopState + -If StoppedState, return + -set to StoppedState -detach from audio device -emit stateChanged() */ @@ -257,7 +263,7 @@ void QAudioOutput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendState + -set NoError and SuspendedState -emit stateChanged() */ d->suspend(); @@ -270,7 +276,7 @@ void QAudioOutput::suspend() void QAudioOutput::resume() { /* - -If SuspendState, return + -If SuspendedState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -358,9 +364,9 @@ int QAudioOutput::notifyInterval() const was called in microseconds. */ -qint64 QAudioOutput::totalTime() const +qint64 QAudioOutput::processedUSecs() const { - return d->totalTime(); + return d->processedUSecs(); } /*! @@ -368,9 +374,9 @@ qint64 QAudioOutput::totalTime() const Suspend states. */ -qint64 QAudioOutput::clock() const +qint64 QAudioOutput::elapsedUSecs() const { - return d->clock(); + return d->elapsedUSecs(); } /*! diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h index bb3496e..38bab8e 100644 --- a/src/multimedia/audio/qaudiooutput.h +++ b/src/multimedia/audio/qaudiooutput.h @@ -71,7 +71,9 @@ public: QAudioFormat format() const; - QIODevice* start(QIODevice *device = 0); + void start(QIODevice *device); + QIODevice* start(); + void stop(); void reset(); void suspend(); @@ -86,8 +88,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 689da89..e9784d2 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -77,7 +77,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -215,8 +215,8 @@ int QAudioOutputPrivate::setFormat() QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) - deviceState = QAudio::StopState; + if(deviceState != QAudio::StoppedState) + deviceState = QAudio::StoppedState; errorState = QAudio::NoError; @@ -256,9 +256,9 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; close(); emit stateChanged(deviceState); } @@ -304,7 +304,7 @@ bool QAudioOutputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; return false; } snd_pcm_nonblock( handle, 0 ); @@ -387,7 +387,7 @@ bool QAudioOutputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) if(err < 0) { close(); errorState = QAudio::FatalError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } return 0; @@ -507,7 +507,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) buffer_size = value; } @@ -529,14 +529,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalTimeValue; } void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { int err = 0; if(handle) { @@ -571,7 +571,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { timer->stop(); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -579,7 +579,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::userFeed() { - if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -658,12 +658,12 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { if(!handle) return 0; - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h index 298e89e..619ecef 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.h +++ b/src/multimedia/audio/qaudiooutput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index f23db80..e0651bf 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -288,7 +288,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; audioThreadState = Stopped; intervalTimer = new QTimer(this); @@ -436,7 +436,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; } @@ -468,10 +468,10 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadDrain(); - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -480,10 +480,10 @@ void QAudioOutputPrivate::stop() void QAudioOutputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -495,7 +495,7 @@ void QAudioOutputPrivate::suspend() if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { audioThreadStop(); - stateCode = QAudio::SuspendState; + stateCode = QAudio::SuspendedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -504,7 +504,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendState) { + if (stateCode == QAudio::SuspendedState) { audioThreadStart(); stateCode = QAudio::ActiveState; @@ -525,7 +525,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int bs) { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) internalBufferSize = bs; } @@ -544,14 +544,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -614,7 +614,7 @@ void QAudioOutputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h index 04b3239..76d06a9 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.h +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -128,8 +128,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 1810ed2..2cfc472 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; finished = false; @@ -157,7 +157,7 @@ QAudioFormat QAudioOutputPrivate::format() const QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -187,7 +187,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; close(); if(!pullMode && audioSource) { @@ -255,7 +255,7 @@ bool QAudioOutputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioOutput: open error"); return false; @@ -277,10 +277,10 @@ bool QAudioOutputPrivate::open() void QAudioOutputPrivate::close() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; int delay = (buffer_size-bytesFree())*1000/(settings.frequency() *settings.channels()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); @@ -308,7 +308,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) buffer_size = value; } @@ -330,7 +330,7 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalTimeValue; } @@ -390,7 +390,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { deviceState = QAudio::ActiveState; errorState = QAudio::NoError; waveOutRestart(hWaveOut); @@ -403,7 +403,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState) { waveOutPause(hWaveOut); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -417,7 +417,7 @@ void QAudioOutputPrivate::feedback() #endif bytesAvailable = bytesFree(); - if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState)) { + if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) { if(bytesAvailable >= period_size) QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); } @@ -491,9 +491,9 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; return timeStampOpened.elapsed()*1000; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index bcf8e1e..f90b8c2 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -90,8 +90,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 7b9a422..715f219 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -77,7 +77,7 @@ private: void tst_QAudioDeviceInfo::initTestCase() { // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -90,7 +90,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput() { // Only perform tests if audio input device exists! bool storeAvailable = available; - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -111,7 +111,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultOutput() void tst_QAudioDeviceInfo::outputList() { if(available) { - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); QVERIFY(devices.size() > 0); device = new QAudioDeviceInfo(devices.at(0)); } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 286e63f..0778a8e 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -69,17 +69,20 @@ private slots: void tst_QAudioFormat::checkNull() { - // Default constructed QAudioFormat is null. + // Default constructed QAudioFormat is invalid. QAudioFormat audioFormat0; - QVERIFY(audioFormat0.isNull()); + QVERIFY(!audioFormat0.isValid()); - // Null is transferred + // validity is transferred QAudioFormat audioFormat1(audioFormat0); - QVERIFY(audioFormat1.isNull()); + QVERIFY(!audioFormat1.isValid()); - // Null is voided on activity audioFormat0.setFrequency(44100); - QVERIFY(!audioFormat0.isNull()); + audioFormat0.setChannels(2); + audioFormat0.setSampleSize(16); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setSampleType(QAudioFormat::SignedInt); + QVERIFY(audioFormat0.isValid()); } void tst_QAudioFormat::checkFrequency() diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 3efc346..744ce38 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -76,7 +76,7 @@ void tst_QAudioInput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio input device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -137,16 +137,16 @@ void tst_QAudioInput::pullFile() QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State))); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->state() == QAudio::StoppedState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->elapsedUSecs() == 0); audio->start(&filename); QTest::qWait(20); // Check state and periodSize() are valid non-zero values. QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); + QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); QVERIFY(audio->periodSize() > 0); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState @@ -154,12 +154,12 @@ void tst_QAudioInput::pullFile() QTest::qWait(5000); QVERIFY(readSignal.count() > 0); - QVERIFY(audio->totalTime() > 0); + QVERIFY(audio->processedUSecs() > 0); audio->stop(); QTest::qWait(20); - QVERIFY(audio->state() == QAudio::StopState); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->elapsedUSecs() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index b001af1..26694cc 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -79,7 +79,7 @@ void tst_QAudioOutput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -140,9 +140,9 @@ void tst_QAudioOutput::pullFile() audio->setNotifyInterval(100); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->state() == QAudio::StoppedState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->elapsedUSecs() == 0); audio->start(&file); QTest::qWait(20); // wait 20ms @@ -150,12 +150,12 @@ void tst_QAudioOutput::pullFile() QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); QVERIFY(audio->periodSize() > 0); - QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); + QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState // Wait until finished... QTestEventLoop::instance().enterLoop(1); - QCOMPARE(audio->totalTime(), qint64(692250)); + QCOMPARE(audio->processedUSecs(), qint64(692250)); #ifdef Q_OS_WINCE // 4.wav is a little less than 700ms, so notify should fire 4 times on Wince! @@ -166,8 +166,8 @@ void tst_QAudioOutput::pullFile() #endif audio->stop(); QTest::qWait(20); // wait 20ms - QVERIFY(audio->state() == QAudio::StopState); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->elapsedUSecs() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); @@ -184,7 +184,7 @@ void tst_QAudioOutput::pushFile() const qint64 fileSize = file.size(); - QIODevice* feed = audio->start(0); + QIODevice* feed = audio->start(); char* buffer = new char[fileSize]; file.read(buffer, fileSize); @@ -199,7 +199,7 @@ void tst_QAudioOutput::pushFile() QTestEventLoop::instance().enterLoop(1); QVERIFY(written == fileSize); - QVERIFY(audio->totalTime() == 692250); + QVERIFY(audio->processedUSecs() == 692250); audio->stop(); file.close(); -- cgit v0.12 From 5d7f0a4dc479faee5dccae7ba826e96e7528607a Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 5 Nov 2009 09:13:54 +0100 Subject: Ensure IDC and UIC3 dependencies are correct After the refactoring to src/tools/tools.pro the dependencies for IDC and UIC3 ended up being incorrect, due to the eval rules later in that file. This patch adds IDC and UIC3 to SRC_SUBDIRS after Qt3Support, and before ActiveQt, so the dependencies remain correct as before the refactoring. The added condition of src/tools/tools.pro ensures that we add the tools to the Makefile in src/tools, should we decide to generate it, and compile from there. Reviewed-by: Jason McDonald --- src/src.pro | 4 +++- src/tools/tools.pro | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/src.pro b/src/src.pro index 77605a8..28dc5be 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,9 +8,9 @@ wince*:{ } else:symbian { SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib src_s60installs } else { - include(tools/tools.pro) SRC_SUBDIRS += src_corelib src_xml src_network src_gui src_sql src_testlib !vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support + include(tools/tools.pro) contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus } win32:SRC_SUBDIRS += src_activeqt @@ -93,6 +93,8 @@ src_webkit.target = sub-webkit src_sql.depends = src_corelib src_testlib.depends = src_corelib src_qt3support.depends = src_gui src_xml src_network src_sql + src_tools_idc.depends = src_corelib # target defined in tools.pro + src_tools_uic3.depends = src_qt3support src_xml # target defined in tools.pro src_phonon.depends = src_gui src_multimedia.depends = src_gui src_tools_activeqt.depends = src_tools_idc src_gui diff --git a/src/tools/tools.pro b/src/tools/tools.pro index 798bd0b..7c8fb47 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -2,8 +2,8 @@ TEMPLATE = subdirs TOOLS_SUBDIRS = src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic !cross_compile { - contains(QT_CONFIG, qt3support): TOOLS_SUBDIRS += src_tools_uic3 - win32:!wince*: TOOLS_SUBDIRS += src_tools_idc + contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3 + win32:!wince*: SRC_SUBDIRS += src_tools_idc } # Set subdir and respective target name @@ -24,8 +24,6 @@ src_tools_idc.target = sub-idc src_tools_moc.depends = src_tools_bootstrap src_tools_rcc.depends = src_tools_bootstrap src_tools_uic.depends = src_tools_bootstrap -src_tools_idc.depends = src_corelib # defined in parent pro, in any, if not ignored -src_tools_uic3.depends = src_qt3support src_xml # defined in parent pro, in any, if not ignored # Special handling, depending on type of project, if it used debug/release or only has one configuration EXTRA_DEBUG_TARGETS = @@ -68,4 +66,5 @@ EXTRA_RELEASE_TARGETS = } } -SUBDIRS += $$TOOLS_SUBDIRS +SUBDIRS = $$TOOLS_SUBDIRS $$SUBDIRS +isEqual(TARGET,tools): SUBDIRS += $$SRC_SUBDIRS -- cgit v0.12 From b65fd82299689a1f353e16caa7d1c896b838762a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 5 Nov 2009 14:20:12 +0100 Subject: Removing semi-colon at the end of namespace ... was breaking symbian-abld build. --- src/xmlpatterns/api/qxmlquery.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmlpatterns/api/qxmlquery.h b/src/xmlpatterns/api/qxmlquery.h index abfddc0..37e4fe1 100644 --- a/src/xmlpatterns/api/qxmlquery.h +++ b/src/xmlpatterns/api/qxmlquery.h @@ -74,7 +74,7 @@ namespace QPatternist class XsdSchemaParser; class XsdValidatingInstanceReader; class VariableLoader; -}; +} class Q_XMLPATTERNS_EXPORT QXmlQuery { -- cgit v0.12 From 6cd1a36774605afaa37d8e3edf870f9133e1cf3e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 4 Nov 2009 13:09:30 +0100 Subject: compilefixes for qfeatures Reviewed-by: Maurice --- src/gui/kernel/qsoftkeymanager.cpp | 4 ++++ src/gui/kernel/qwidget_win.cpp | 14 ++++++++++++-- src/gui/styles/qwindowsmobilestyle.cpp | 7 ++++++- src/gui/styles/qwindowsmobilestyle_p.h | 4 ++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 21795b4..e970d2f 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -137,12 +137,14 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act */ QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget) { +#ifndef QT_NO_ACTION QScopedPointer action(createAction(standardKey, actionWidget)); connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent())); connect(action.data(), SIGNAL(destroyed(QObject*)), QSoftKeyManager::instance(), SLOT(cleanupHash(QObject*))); QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key); return action.take(); +#endif //QT_NO_ACTION } void QSoftKeyManager::cleanupHash(QObject* obj) @@ -175,6 +177,7 @@ void QSoftKeyManager::updateSoftKeys() bool QSoftKeyManager::event(QEvent *e) { +#ifndef QT_NO_ACTION if (e->type() == QEvent::UpdateSoftKeys) { QList softKeys; QWidget *source = QApplication::focusWidget(); @@ -201,6 +204,7 @@ bool QSoftKeyManager::event(QEvent *e) QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys); return true; } +#endif //QT_NO_ACTION return false; } diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 22a94b9..2bdaddb 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -677,7 +677,11 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const QWidget *parentWindow = window(); QWExtra *extra = parentWindow->d_func()->extra; if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId() - || (extra && extra->proxyWidget)) { + || (extra +#ifndef QT_NO_GRAPHICSVIEW + && extra->proxyWidget +#endif //QT_NO_GRAPHICSVIEW + )) { if (extra && extra->topextra && extra->topextra->embedded) { QPoint pt = mapTo(parentWindow, pos); POINT p = {pt.x(), pt.y()}; @@ -704,7 +708,11 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const QWidget *parentWindow = window(); QWExtra *extra = parentWindow->d_func()->extra; if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId() - || (extra && extra->proxyWidget)) { + || (extra +#ifndef QT_NO_GRAPHICSVIEW + && extra->proxyWidget +#endif //QT_NO_GRAPHICSVIEW + )) { if (extra && extra->topextra && extra->topextra->embedded) { POINT p = {pos.x(), pos.y()}; ScreenToClient(parentWindow->effectiveWinId(), &p); @@ -2042,6 +2050,7 @@ void QWidgetPrivate::winSetupGestures() bool needv = false; bool singleFingerPanEnabled = false; +#ifndef QT_NO_SCROLLAREA if (QAbstractScrollArea *asa = qobject_cast(q->parent())) { QScrollBar *hbar = asa->horizontalScrollBar(); QScrollBar *vbar = asa->verticalScrollBar(); @@ -2055,6 +2064,7 @@ void QWidgetPrivate::winSetupGestures() if (!winid) winid = q->winId(); // enforces the native winid on the viewport } +#endif //QT_NO_SCROLLAREA if (winid && qAppPriv->SetGestureConfig) { GESTURECONFIG gc[1]; memset(gc, 0, sizeof(gc)); diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 7ed187f..c543006 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -4121,6 +4121,7 @@ void QWindowsMobileStylePrivate::setupWindowsMobileStyle65() void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOptionTab *tab) { +#ifndef QT_NO_TABBAR #ifdef Q_WS_WINCE_WM if (wm65) { tintImagesButton(tab->palette.button().color()); @@ -4207,6 +4208,7 @@ void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOp } } painter->restore(); +#endif //QT_NO_TABBAR } void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItemV4 *option, QRect rect) @@ -4412,7 +4414,7 @@ void QWindowsMobileStylePrivate::drawScrollbarHandleUp(QPainter *p, QStyleOption void QWindowsMobileStylePrivate::drawScrollbarHandleDown(QPainter *p, QStyleOptionSlider *opt, bool completeFrame, bool secondScrollBar) { - +#ifndef QT_NO_SCROLLBAR #ifdef Q_WS_WINCE_WM if (wm65) { tintImagesHigh(opt->palette.highlight().color()); @@ -4469,10 +4471,12 @@ void QWindowsMobileStylePrivate::drawScrollbarHandleDown(QPainter *p, QStyleOpti arrowOpt.rect.adjust(1, 0, 1, 0); q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &arrowOpt, p, 0); } +#endif //QT_NO_SCROLLBAR } void QWindowsMobileStylePrivate::drawScrollbarGroove(QPainter *p,const QStyleOptionSlider *opt) { +#ifndef QT_NO_SCROLLBAR #ifdef Q_OS_WINCE_WM if (wm65) { p->fillRect(opt->rect, QColor(231, 231, 231)); @@ -4498,6 +4502,7 @@ void QWindowsMobileStylePrivate::drawScrollbarGroove(QPainter *p,const QStyleOpt fill = opt->palette.light(); } p->fillRect(opt->rect, fill); +#endif //QT_NO_SCROLLBAR } QWindowsMobileStyle::QWindowsMobileStyle(QWindowsMobileStylePrivate &dd) : QWindowsStyle(dd) { diff --git a/src/gui/styles/qwindowsmobilestyle_p.h b/src/gui/styles/qwindowsmobilestyle_p.h index 1e8c7ff..139a4ab 100644 --- a/src/gui/styles/qwindowsmobilestyle_p.h +++ b/src/gui/styles/qwindowsmobilestyle_p.h @@ -60,6 +60,10 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_STYLE_WINDOWSMOBILE +class QStyleOptionTab; +class QStyleOptionSlider; +class QStyleOptionViewItemV4; + class QWindowsMobileStylePrivate : public QWindowsStylePrivate { Q_DECLARE_PUBLIC(QWindowsMobileStyle) -- cgit v0.12 From a48ab815b5b6f6a20d4c8a2dba41e6dfc6a54073 Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Fri, 6 Nov 2009 16:16:35 +1000 Subject: cetest crashes and no helpful debugging provided Unguarded use of QList::first() leads to Q_ASSERT() if the list is empty Add support for a "-d" option to project file print parser debugging Do not make use of QMAKESPEC variables in .qmake.cache instead determine the current default if mkspec was not passed to cetest Task-number: QTBUG-5490 Reviewed-by: Lincoln Ramsay Joerg Bornemann --- tools/qtestlib/wince/cetest/main.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tools/qtestlib/wince/cetest/main.cpp b/tools/qtestlib/wince/cetest/main.cpp index e00c0e7..763439a 100644 --- a/tools/qtestlib/wince/cetest/main.cpp +++ b/tools/qtestlib/wince/cetest/main.cpp @@ -129,6 +129,7 @@ void usage() " -conf : Specify location of qt.conf file\n" " -f : Specify project file\n" " -cache : Specify .qmake.cache file to use\n" + " -d : Increase qmake debugging \n" " -timeout : Specify a timeout value after which the test will be terminated\n" " -1 specifies waiting forever (default)\n" " 0 specifies starting the process detached\n" @@ -216,6 +217,8 @@ int main(int argc, char **argv) return -1; } cacheFile = arguments.at(i); + } else if (arguments.at(i).toLower() == QLatin1String("-d")) { + Option::debug_level++; } else if (arguments.at(i).toLower() == QLatin1String("-timeout")) { if (++i == arguments.size()) { cout << "Error: No timeout value specified!" << endl; @@ -235,13 +238,22 @@ int main(int argc, char **argv) return -1; } debugOutput(QString::fromLatin1("Using Project File:").append(proFile),1); + }else { + if (!QFileInfo(proFile).exists()) { + cout << "Error: Project file does not exist " << qPrintable(proFile) << endl; + return -1; + } } Option::before_user_vars.append("CONFIG+=build_pass"); - // read target and deployment rules - int qmakeArgc = 1; - char* qmakeArgv[] = { "qmake.exe" }; + // read target and deployment rules passing the .pro to use instead of + // relying on qmake guessing the .pro to use + int qmakeArgc = 2; + QByteArray ba(QFile::encodeName(proFile)); + char* proFileEncodedName = ba.data(); + char* qmakeArgv[2] = { "qmake.exe", proFileEncodedName }; + Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING; Option::output_dir = qmake_getpwd(); if (!cacheFile.isEmpty()) @@ -267,6 +279,24 @@ int main(int argc, char **argv) else TestConfiguration::testDebug = false; + // determine what is the real mkspec to use if the default mkspec is being used + if (Option::mkfile::qmakespec.endsWith("/default")) + project.values("QMAKESPEC") = project.values("QMAKESPEC_ORIGINAL"); + else + project.values("QMAKESPEC") = QStringList() << Option::mkfile::qmakespec; + + // ensure that QMAKESPEC is non-empty .. to meet requirements of QList::at() + if (project.values("QMAKESPEC").isEmpty()){ + cout << "Error: QMAKESPEC not set after parsing " << qPrintable(proFile) << endl; + return -1; + } + + // ensure that QT_CE_C_RUNTIME is non-empty .. to meet requirements of QList::at() + if (project.values("QT_CE_C_RUNTIME").isEmpty()){ + cout << "Error: QT_CE_C_RUNTIME not defined in mkspec/qconfig.pri " << qPrintable(project.values("QMAKESPEC").join(" ")); + return -1; + } + QString destDir = project.values("DESTDIR").join(" "); if (!destDir.isEmpty()) { if (QDir::isRelativePath(destDir)) { -- cgit v0.12 From e3d3973d761248da23343be47e1be6777e9e84f0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Nov 2009 12:06:22 +0100 Subject: fixes button size for Windows mobile style The old button sizes were just to big. For example the trivialwizard example had a minimal width that was much too wide for the screen. Task-number: QTBUG-3613 Reviewed-by: thartman --- src/gui/styles/qwindowsmobilestyle.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index c543006..86ba947 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -6330,16 +6330,20 @@ QSize QWindowsMobileStyle::sizeFromContents(ContentsType type, const QStyleOptio switch (type) { case CT_PushButton: if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); + newSize = QCommonStyle::sizeFromContents(type, option, size, widget); int w = newSize.width(), h = newSize.height(); int defwidth = 0; if (button->features & QStyleOptionButton::AutoDefaultButton) defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, button, widget); - if (w < 75 + defwidth && button->icon.isNull()) - w = 75 + defwidth; - if (h < 23 + defwidth) - h = 23 + defwidth; + + int minwidth = int(QStyleHelper::dpiScaled(55.0f)); + int minheight = int(QStyleHelper::dpiScaled(19.0f)); + + if (w < minwidth + defwidth && button->icon.isNull()) + w = minwidth + defwidth; + if (h < minheight + defwidth) + h = minheight + defwidth; newSize = QSize(w + 4, h + 4); } break; -- cgit v0.12 From 85a7c3477742516e1b89d527eccf702ffaca767f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Nov 2009 12:12:09 +0100 Subject: fix QWizard issues on Windows CE Was reproducable with the example in \examples\dialogs\trivialwizard You could not push the navigation buttons using the stylus. Task-number: QTBUG-3613 Reviewed-by: thartman --- src/gui/kernel/qwidget_win.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 2bdaddb..b7ba273 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1339,8 +1339,15 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isResize && !q->testAttribute(Qt::WA_StaticContents) && q->internalWinId()) ValidateRgn(q->internalWinId(), 0); +#ifdef Q_WS_WINCE + // On Windows CE we can't just fiddle around with the window state. + // Too much magic in setWindowState. + if (isResize && q->isMaximized()) + q->setWindowState(q->windowState() & ~Qt::WindowMaximized); +#else if (isResize) data.window_state &= ~Qt::WindowMaximized; +#endif if (data.window_state & Qt::WindowFullScreen) { QTLWExtra *top = topData(); -- cgit v0.12 From 15a21652d178e4a298bb522d777602620cbd9938 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 5 Nov 2009 13:13:26 +0100 Subject: API review: Add convenience functions using QMargins We added the class QMargins, so we should use it wherever we deal with margins, as a convenience to the users. Reviewed-by: Andreas Aardal Hanssen --- src/gui/kernel/qlayout.cpp | 32 ++++++++++++++++++++++++++++++++ src/gui/kernel/qlayout.h | 3 +++ src/gui/widgets/qabstractscrollarea.cpp | 17 +++++++++++++++++ src/gui/widgets/qabstractscrollarea.h | 2 ++ src/gui/widgets/qlineedit.cpp | 23 +++++++++++++++++++++++ src/gui/widgets/qlineedit.h | 3 +++ 6 files changed, 80 insertions(+) diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index 70cd5a5..5d44b3d 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -496,6 +496,21 @@ void QLayout::setContentsMargins(int left, int top, int right, int bottom) } /*! + \since 4.6 + + Sets the \a margins to use around the layout. + + By default, QLayout uses the values provided by the style. On + most platforms, the margin is 11 pixels in all directions. + + \sa contentsMargins() +*/ +void QLayout::setContentsMargins(const QMargins &margins) +{ + setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); +} + +/*! \since 4.3 Extracts the left, top, right, and bottom margins used around the @@ -521,6 +536,23 @@ void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \since 4.6 + + Returns the margins used around the layout. + + By default, QLayout uses the values provided by the style. On + most platforms, the margin is 11 pixels in all directions. + + \sa setContentsMargins() +*/ +QMargins QLayout::contentsMargins() const +{ + int left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + return QMargins(left, top, right, bottom); +} + +/*! \since 4.3 Returns the layout's geometry() rectangle, but taking into account the diff --git a/src/gui/kernel/qlayout.h b/src/gui/kernel/qlayout.h index 83cbab6..2f30294 100644 --- a/src/gui/kernel/qlayout.h +++ b/src/gui/kernel/qlayout.h @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -122,7 +123,9 @@ public: void setSpacing(int); void setContentsMargins(int left, int top, int right, int bottom); + void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; + QMargins contentsMargins() const; QRect contentsRect() const; bool setAlignment(QWidget *w, Qt::Alignment alignment); diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 7d81d5a..48099ef 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -51,6 +51,7 @@ #include "qdebug.h" #include "qboxlayout.h" #include "qpainter.h" +#include "qmargins.h" #include "qabstractscrollarea_p.h" #include @@ -868,6 +869,22 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b } /*! + \since 4.6 + Sets \a margins around the scrolling area. This is useful for + applications such as spreadsheets with "locked" rows and columns. + The marginal space is is left blank; put widgets in the unused + area. + + By default all margins are zero. + +*/ +void QAbstractScrollArea::setViewportMargins(const QMargins &margins) +{ + setViewportMargins(margins.left(), margins.top(), + margins.right(), margins.bottom()); +} + +/*! \fn bool QAbstractScrollArea::event(QEvent *event) \reimp diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h index b3a1861..18d1e96 100644 --- a/src/gui/widgets/qabstractscrollarea.h +++ b/src/gui/widgets/qabstractscrollarea.h @@ -52,6 +52,7 @@ QT_MODULE(Gui) #ifndef QT_NO_SCROLLAREA +class QMargins; class QScrollBar; class QAbstractScrollAreaPrivate; @@ -95,6 +96,7 @@ protected Q_SLOTS: protected: QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0); void setViewportMargins(int left, int top, int right, int bottom); + void setViewportMargins(const QMargins &margins); bool event(QEvent *); virtual bool viewportEvent(QEvent *); diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index e4252b5..f5dbe1c 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1102,6 +1102,17 @@ void QLineEdit::setTextMargins(int left, int top, int right, int bottom) } /*! + \since 4.6 + Sets the \a margins around the text inside the frame. + + See also textMargins(). +*/ +void QLineEdit::setTextMargins(const QMargins &margins) +{ + setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); +} + +/*! Returns the widget's text margins for \a left, \a top, \a right, and \a bottom. \since 4.5 @@ -1121,6 +1132,18 @@ void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) con } /*! + \since 4.6 + Returns the widget's text margins. + + \sa setTextMargins() +*/ +QMargins QLineEdit::textMargins() const +{ + Q_D(const QLineEdit); + return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); +} + +/*! \property QLineEdit::inputMask \brief The validation input mask diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 214509a..ac918c7 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -158,7 +159,9 @@ public: bool hasAcceptableInput() const; void setTextMargins(int left, int top, int right, int bottom); + void setTextMargins(const QMargins &margins); void getTextMargins(int *left, int *top, int *right, int *bottom) const; + QMargins textMargins() const; public Q_SLOTS: void setText(const QString &); -- cgit v0.12 From 863369deceeb254ea71724a247953fd0760ae30b Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 5 Nov 2009 14:26:32 +0100 Subject: API review: QMatrix::det() -> QMatrix::determinant(), matching math3d After an API review of the new math3d classes, the full name was considered better than the short version. Therefore we obsolete the short function, and introduce the longer version. Reviewed-by: Andreas Aardal Hanssen --- src/gui/painting/qmatrix.cpp | 18 ++++++++++++++---- src/gui/painting/qmatrix.h | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 88b2b7a..17b7241 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE which returns true if the matrix is non-singular (i.e. AB = BA = I). The inverted() function returns an inverted copy of \e this matrix if it is invertible (otherwise it returns the identity - matrix). In addition, QMatrix provides the det() function + matrix). In addition, QMatrix provides the determinant() function returning the matrix's determinant. Finally, the QMatrix class supports matrix multiplication, and @@ -959,9 +959,19 @@ QMatrix &QMatrix::rotate(qreal a) */ /*! + \obsolete \fn qreal QMatrix::det() const Returns the matrix's determinant. + + \sa determinant() +*/ + +/*! + \since 4.6 + \fn qreal QMatrix::determinant() const + + Returns the matrix's determinant. */ /*! @@ -985,8 +995,8 @@ QMatrix &QMatrix::rotate(qreal a) QMatrix QMatrix::inverted(bool *invertible) const { - qreal determinant = det(); - if (determinant == 0.0) { + qreal dtr = determinant(); + if (dtr == 0.0) { if (invertible) *invertible = false; // singular matrix return QMatrix(true); @@ -994,7 +1004,7 @@ QMatrix QMatrix::inverted(bool *invertible) const else { // invertible matrix if (invertible) *invertible = true; - qreal dinv = 1.0/determinant; + qreal dinv = 1.0/dtr; return QMatrix((_m22*dinv), (-_m12*dinv), (-_m21*dinv), (_m11*dinv), ((_m21*_dy - _m22*_dx)*dinv), diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index 8887f0e..152b3c9 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -101,7 +101,8 @@ public: QMatrix &rotate(qreal a); bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } - qreal det() const { return _m11*_m22 - _m12*_m21; } + qreal determinant() const { return _m11*_m22 - _m12*_m21; } + QT_DEPRECATED qreal det() const { return _m11*_m22 - _m12*_m21; } QMatrix inverted(bool *invertible = 0) const; -- cgit v0.12 From 98e0b95581f46b94773a55195e0e67a466c333ed Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 5 Nov 2009 15:18:35 +0100 Subject: API review: QRegExp::numCaptures() -> QRegExp::captureCount() QRegExp::numCaptures() is marked as obsolete. Replaced all usage in Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- examples/tools/regexp/regexpdialog.cpp | 4 ++-- src/corelib/tools/qregexp.cpp | 18 +++++++++++--- src/corelib/tools/qregexp.h | 3 ++- src/corelib/tools/qstring.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 2 +- src/testlib/qbenchmarkvalgrind.cpp | 2 +- src/xmlpatterns/functions/qpatternmatchingfns.cpp | 2 +- src/xmlpatterns/functions/qpatternplatform_p.h | 2 +- tests/auto/qregexp/tst_qregexp.cpp | 28 +++++++++++----------- tests/auto/qscriptengine/tst_qscriptengine.cpp | 2 +- tests/auto/qtextdocument/tst_qtextdocument.cpp | 10 ++++---- .../designer/src/designer/qdesigner_formwindow.cpp | 2 +- tools/makeqpf/mainwindow.cpp | 2 +- 13 files changed, 46 insertions(+), 33 deletions(-) diff --git a/examples/tools/regexp/regexpdialog.cpp b/examples/tools/regexp/regexpdialog.cpp index 08c7a97..3becc2b 100644 --- a/examples/tools/regexp/regexpdialog.cpp +++ b/examples/tools/regexp/regexpdialog.cpp @@ -180,8 +180,8 @@ void RegExpDialog::refresh() indexEdit->setText(QString::number(rx.indexIn(text))); matchedLengthEdit->setText(QString::number(rx.matchedLength())); for (int i = 0; i < MaxCaptures; ++i) { - captureLabels[i]->setEnabled(i <= rx.numCaptures()); - captureEdits[i]->setEnabled(i <= rx.numCaptures()); + captureLabels[i]->setEnabled(i <= rx.captureCount()); + captureEdits[i]->setEnabled(i <= rx.captureCount()); captureEdits[i]->setText(rx.cap(i)); } diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 1f23211..3ca8ab9 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -1083,7 +1083,7 @@ public: bool isValid() const { return valid; } const QString &errorString() const { return yyError; } - int numCaptures() const { return officialncap; } + int captureCount() const { return officialncap; } int createState(QChar ch); int createState(const QRegExpCharClass &cc); @@ -1378,7 +1378,7 @@ void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng) #else int newSlideTabSize = 0; #endif - int numCaptures = eng->numCaptures(); + int numCaptures = eng->captureCount(); int newCapturedSize = 2 + 2 * numCaptures; bigArray = q_check_ptr((int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int))); @@ -4168,12 +4168,24 @@ int QRegExp::matchedLength() const #ifndef QT_NO_REGEXP_CAPTURE /*! + \obsolete Returns the number of captures contained in the regular expression. + + \sa captureCount() */ int QRegExp::numCaptures() const { + return captureCount(); +} + +/*! + \since 4.6 + Returns the number of captures contained in the regular expression. + */ +int QRegExp::captureCount() const +{ prepareEngine(priv); - return priv->eng->numCaptures(); + return priv->eng->captureCount(); } /*! diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index 1a7cf53..2bad40e 100644 --- a/src/corelib/tools/qregexp.h +++ b/src/corelib/tools/qregexp.h @@ -119,7 +119,8 @@ public: #endif int matchedLength() const; #ifndef QT_NO_REGEXP_CAPTURE - int numCaptures() const; + QT_DEPRECATED int numCaptures() const; + int captureCount() const; QStringList capturedTexts() const; QStringList capturedTexts(); QString cap(int nth = 0) const; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 55ad28d..f7321ef 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2681,7 +2681,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after) realloc(); int index = 0; - int numCaptures = rx2.numCaptures(); + int numCaptures = rx2.captureCount(); int al = after.length(); QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 449bc0d..7ddd992 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1066,7 +1066,7 @@ static inline QColor colorFromName(const QString &name) QRegExp rx("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])"); rx.setCaseSensitivity(Qt::CaseInsensitive); if (rx.exactMatch(name)) { - Q_ASSERT(rx.numCaptures() == 4); + Q_ASSERT(rx.captureCount() == 4); int ints[4]; int i; for (i=0; i<4; ++i) { diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 3398737..88cb37f 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -114,7 +114,7 @@ qint64 QBenchmarkValgrindUtils::extractResult(const QString &fileName) while (!file.atEnd()) { const QString line(QLatin1String(file.readLine())); if (rxValue.indexIn(line) != -1) { - Q_ASSERT(rxValue.numCaptures() == 1); + Q_ASSERT(rxValue.captureCount() == 1); bool ok; val = rxValue.cap(1).toLongLong(&ok); Q_ASSERT(ok); diff --git a/src/xmlpatterns/functions/qpatternmatchingfns.cpp b/src/xmlpatterns/functions/qpatternmatchingfns.cpp index cb421cb..a7275f6 100644 --- a/src/xmlpatterns/functions/qpatternmatchingfns.cpp +++ b/src/xmlpatterns/functions/qpatternmatchingfns.cpp @@ -82,7 +82,7 @@ Item ReplaceFN::evaluateSingleton(const DynamicContext::Ptr &context) const if(arg) input = arg.stringValue(); - const QString replacement(m_replacementString.isNull() ? parseReplacement(regexp.numCaptures(), context) + const QString replacement(m_replacementString.isNull() ? parseReplacement(regexp.captureCount(), context) : m_replacementString); diff --git a/src/xmlpatterns/functions/qpatternplatform_p.h b/src/xmlpatterns/functions/qpatternplatform_p.h index e007381..a85cd0c 100644 --- a/src/xmlpatterns/functions/qpatternplatform_p.h +++ b/src/xmlpatterns/functions/qpatternplatform_p.h @@ -180,7 +180,7 @@ namespace QPatternist inline int PatternPlatform::captureCount() const { if(m_compiledParts.testFlag(PatternPrecompiled)) - return m_pattern.numCaptures(); + return m_pattern.captureCount(); else return -1; } diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp index 86d831e..e305386 100644 --- a/tests/auto/qregexp/tst_qregexp.cpp +++ b/tests/auto/qregexp/tst_qregexp.cpp @@ -628,7 +628,7 @@ void tst_QRegExp::capturedTexts() QRegExp rx7("([A-Za-z_])([A-Za-z_0-9]*)"); rx7.setCaseSensitivity(Qt::CaseSensitive); rx7.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx7.numCaptures(), 2); + QCOMPARE(rx7.captureCount(), 2); int pos = rx7.indexIn("(10 + delta4) * 32"); QCOMPARE(pos, 6); @@ -1177,36 +1177,36 @@ void tst_QRegExp::prepareEngineOptimization() QCOMPARE(rx1.capturedTexts(), QStringList() << "" << "" << "" << ""); QCOMPARE(rx1.matchedLength(), -1); QCOMPARE(rx1.matchedLength(), -1); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.exactMatch("foo"), true); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); QCOMPARE(rx1.exactMatch("foo"), true); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); QRegExp rx2 = rx1; - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); - QCOMPARE(rx2.numCaptures(), 3); + QCOMPARE(rx2.captureCount(), 3); QCOMPARE(rx2.matchedLength(), 3); QCOMPARE(rx2.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx2.pos(3), 2); QCOMPARE(rx1.exactMatch("fo"), true); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 2); QCOMPARE(rx1.capturedTexts(), QStringList() << "fo" << "f" << "o" << ""); QCOMPARE(rx1.pos(2), 1); @@ -1245,25 +1245,25 @@ void tst_QRegExp::prepareEngineOptimization() rx11.setPatternSyntax(QRegExp::Wildcard); QVERIFY(!rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPatternSyntax(QRegExp::RegExp); QVERIFY(!rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPattern("(foo)"); QVERIFY(rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), -1); QCOMPARE(rx11.indexIn("ofoo"), 1); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), 3); rx11.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), 3); /* @@ -1278,11 +1278,11 @@ void tst_QRegExp::prepareEngineOptimization() QCOMPARE(rx11.matchedLength(), 3); rx11.setPatternSyntax(QRegExp::Wildcard); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), -1); } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 804534f..8eaad78 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -4485,7 +4485,7 @@ void tst_QScriptEngine::qRegExpInport() QScriptValue result = func.call(QScriptValue(), QScriptValueList() << string << rexp); rx.indexIn(string); - for (int i = 0; i <= rx.numCaptures(); i++) { + for (int i = 0; i <= rx.captureCount(); i++) { QCOMPARE(result.property(i).toString(), rx.cap(i)); } } diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 5237438..1d54409 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -1721,21 +1721,21 @@ void tst_QTextDocument::capitalizationHtmlInExport() const QString smallcaps = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("font-variant:small-caps;")); cf.setFontCapitalization(QFont::AllUppercase); cursor.mergeCharFormat(cf); const QString uppercase = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("text-transform:uppercase;")); cf.setFontCapitalization(QFont::AllLowercase); cursor.mergeCharFormat(cf); const QString lowercase = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("text-transform:lowercase;")); doc->setHtml(smallcaps); @@ -1761,14 +1761,14 @@ void tst_QTextDocument::wordspacingHtmlExport() cursor.mergeCharFormat(cf); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:4px;")); cf.setFontWordSpacing(-8.5); cursor.mergeCharFormat(cf); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:-8.5px;")); } diff --git a/tools/designer/src/designer/qdesigner_formwindow.cpp b/tools/designer/src/designer/qdesigner_formwindow.cpp index b2af257..05937cd 100644 --- a/tools/designer/src/designer/qdesigner_formwindow.cpp +++ b/tools/designer/src/designer/qdesigner_formwindow.cpp @@ -182,7 +182,7 @@ int QDesignerFormWindow::getNumberOfUntitledWindows() const if (rx.indexIn(title) != -1) { if (maxUntitled == 0) ++maxUntitled; - if (rx.numCaptures() > 1) { + if (rx.captureCount() > 1) { const QString numberCapture = rx.cap(2); if (!numberCapture.isEmpty()) maxUntitled = qMax(numberCapture.toInt(), maxUntitled); diff --git a/tools/makeqpf/mainwindow.cpp b/tools/makeqpf/mainwindow.cpp index 8fa372b..45ea0a3 100644 --- a/tools/makeqpf/mainwindow.cpp +++ b/tools/makeqpf/mainwindow.cpp @@ -269,7 +269,7 @@ void MainWindow::populateCharacterRanges() if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) continue; - if (!rangeExpr.exactMatch(line) || rangeExpr.numCaptures() != 3) + if (!rangeExpr.exactMatch(line) || rangeExpr.captureCount() != 3) continue; QPF::CharacterRange range; -- cgit v0.12 From e53c26b52c890f242491e0dfed4201313d98f720 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 09:33:33 +0100 Subject: API review: Rename functions numColors(), setNumColors() and numBytes() QPaintDevice and QImage used the functions numColors(), setNumColors(), and numBytes(). However, this is not consistent with the rest of the Qt API which uses *Count() and set*Count(). Removed all usage of these functions inside Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- demos/composition/composition.cpp | 2 +- .../WebCore/platform/qt/PlatformScreenQt.cpp | 2 +- src/gui/embedded/qwscursor_qws.cpp | 2 +- src/gui/image/qbmphandler.cpp | 22 ++-- src/gui/image/qimage.cpp | 134 +++++++++++++-------- src/gui/image/qimage.h | 9 +- src/gui/image/qpixmap_mac.cpp | 14 +-- src/gui/image/qpixmap_qws.cpp | 2 +- src/gui/image/qpixmap_raster.cpp | 2 +- src/gui/image/qpixmap_s60.cpp | 8 +- src/gui/image/qpixmap_x11.cpp | 22 ++-- src/gui/image/qpixmapdata.cpp | 2 +- src/gui/image/qpixmapdata_p.h | 3 +- src/gui/image/qpnghandler.cpp | 12 +- src/gui/image/qppmhandler.cpp | 6 +- src/gui/image/qxbmhandler.cpp | 2 +- src/gui/image/qxpmhandler.cpp | 2 +- src/gui/itemviews/qitemdelegate.cpp | 2 +- src/gui/kernel/qcursor_win.cpp | 8 +- src/gui/kernel/qwidget_x11.cpp | 2 +- src/gui/painting/qpaintdevice.h | 3 +- src/gui/painting/qpaintengine_mac.cpp | 2 +- src/gui/styles/qs60style.cpp | 2 +- src/gui/text/qfontengine_qpf.cpp | 4 +- src/multimedia/video/qimagevideobuffer.cpp | 2 +- src/opengl/qgl.cpp | 2 +- src/opengl/qpixmapdata_gl.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 6 +- src/plugins/imageformats/gif/qgifhandler.cpp | 4 +- src/plugins/imageformats/ico/qicohandler.cpp | 4 +- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 6 +- src/qt3support/painting/q3paintdevicemetrics.h | 2 +- src/tools/uic3/embed.cpp | 4 +- tests/arthur/common/paintcommands.cpp | 16 +-- tests/arthur/common/paintcommands.h | 2 +- tests/auto/qdatastream/tst_qdatastream.cpp | 2 +- tests/auto/qimage/tst_qimage.cpp | 24 ++-- tests/auto/qimagewriter/tst_qimagewriter.cpp | 2 +- tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 2 +- tests/auto/qpainter/tst_qpainter.cpp | 4 +- tests/auto/qpixmap/tst_qpixmap.cpp | 6 +- tools/makeqpf/qpf2.cpp | 4 +- tools/qvfb/qvfbview.cpp | 6 +- 44 files changed, 207 insertions(+), 164 deletions(-) diff --git a/demos/composition/composition.cpp b/demos/composition/composition.cpp index 24e9187..1025d3c 100644 --- a/demos/composition/composition.cpp +++ b/demos/composition/composition.cpp @@ -457,7 +457,7 @@ void CompositionRenderer::paint(QPainter *painter) #ifdef Q_WS_QWS m_buffer = m_base_buffer; #else - memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.numBytes()); + memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.byteCount()); #endif { diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp index 8221760..442ffa3 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp @@ -72,7 +72,7 @@ int screenDepthPerComponent(Widget* w) bool screenIsMonochrome(Widget* w) { - return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2; + return QApplication::desktop()->screen(screenNumber(w))->colorCount() < 2; } FloatRect screenRect(Widget* w) diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp index 07271e1..7d5a3d1 100644 --- a/src/gui/embedded/qwscursor_qws.cpp +++ b/src/gui/embedded/qwscursor_qws.cpp @@ -534,7 +534,7 @@ void QWSCursor::set(const uchar *data, const uchar *mask, if (!width || !height || !data || !mask || cursor.isNull()) return; - cursor.setNumColors(3); + cursor.setColorCount(3); cursor.setColor(0, 0xff000000); cursor.setColor(1, 0xffffffff); cursor.setColor(2, 0x00000000); diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 4b6fcba..f3eb7c3 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels { int i; - if (image->depth() == 1 && image->numColors() == 2) { + if (image->depth() == 1 && image->colorCount() == 2) { register uint *p = (uint *)image->bits(); - int nbytes = image->numBytes(); + int nbytes = image->byteCount(); for (i=0; iisWritable()) return false; - if (image.depth() == 8 && image.numColors() <= 16) { + if (image.depth() == 8 && image.colorCount() <= 16) { bpl_bmp = (((bpl+1)/2+3)/4)*4; nbits = 4; } else if (image.depth() == 32) { @@ -554,23 +554,23 @@ bool qt_write_dib(QDataStream &s, QImage image) bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX() : 2834; // 72 dpi default bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; - bi.biClrUsed = image.numColors(); - bi.biClrImportant = image.numColors(); + bi.biClrUsed = image.colorCount(); + bi.biClrImportant = image.colorCount(); s << bi; // write info header if (s.status() != QDataStream::Ok) return false; if (image.depth() != 32) { // write color table - uchar *color_table = new uchar[4*image.numColors()]; + uchar *color_table = new uchar[4*image.colorCount()]; uchar *rgb = color_table; QVector c = image.colorTable(); - for (int i=0; iwrite((char *)color_table, 4*image.numColors()) == -1) { + if (d->write((char *)color_table, 4*image.colorCount()) == -1) { delete [] color_table; return false; } @@ -754,7 +754,7 @@ bool QBmpHandler::write(const QImage &img) int bpl = image.bytesPerLine(); // Code partially repeated in qt_write_dib - if (image.depth() == 8 && image.numColors() <= 16) { + if (image.depth() == 8 && image.colorCount() <= 16) { bpl_bmp = (((bpl+1)/2+3)/4)*4; } else if (image.depth() == 32) { bpl_bmp = ((image.width()*24+31)/32)*4; @@ -771,7 +771,7 @@ bool QBmpHandler::write(const QImage &img) // write file header bf.bfReserved1 = 0; bf.bfReserved2 = 0; - bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors() * 4; + bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4; bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); s << bf; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 21ca1e3..6d96d7a 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -449,7 +449,7 @@ bool QImageData::checkForAlphaPixels() const to the pixel() function. The pixel() function returns the color as a QRgb value indepedent of the image's format. - In case of monochrome and 8-bit images, the numColors() and + In case of monochrome and 8-bit images, the colorCount() and colorTable() functions provide information about the color components used to store the image data: The colorTable() function returns the image's entire color table. To obtain a single entry, @@ -484,7 +484,7 @@ bool QImageData::checkForAlphaPixels() const depths are 1 (monochrome), 8 and 32 (for more information see the \l {QImage#Image Formats}{Image Formats} section). - The format(), bytesPerLine(), and numBytes() functions provide + The format(), bytesPerLine(), and byteCount() functions provide low-level information about the data stored in the image. The cacheKey() function returns a number that uniquely @@ -623,7 +623,7 @@ bool QImageData::checkForAlphaPixels() const \o Sets the color table used to translate color indexes. Only monochrome and 8-bit formats. \row - \o setNumColors() + \o setColorCount() \o Resizes the color table. Only monochrome and 8-bit formats. \endtable @@ -906,7 +906,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. */ QImage::QImage(uchar* data, int width, int height, Format format) : QPaintDevice() @@ -928,7 +928,7 @@ QImage::QImage(uchar* data, int width, int height, Format format) If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. Unlike the similar QImage constructor that takes a non-const data buffer, this version will never alter the contents of the buffer. For example, @@ -954,7 +954,7 @@ QImage::QImage(const uchar* data, int width, int height, Format format) If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. */ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format) :QPaintDevice() @@ -974,7 +974,7 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form If \a format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with - setNumColors() or setColorTable() before the image is used. + setColorCount() or setColorTable() before the image is used. Unlike the similar QImage constructor that takes a non-const data buffer, this version will never alter the contents of the buffer. For example, @@ -1126,7 +1126,7 @@ QImage::QImage(const QImage &image) Use the constructor that accepts a width, a height and a format (i.e. specifying the depth and bit order), in combination with the - setNumColors() function, instead. + setColorCount() function, instead. \oldcode QImage image(width, height, depth, numColors); @@ -1135,15 +1135,15 @@ QImage::QImage(const QImage &image) // For 8 bit images the default number of colors is 256. If // another number of colors is required it can be specified - // using the setNumColors() function. - image.setNumColors(numColors); + // using the setColorCount() function. + image.setColorCount(numColors); \endcode */ -QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) +QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder) : QPaintDevice() { - d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors); + d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount); } /*! @@ -1152,7 +1152,7 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) Use the constructor that accepts a size and a format (i.e. specifying the depth and bit order), in combination with the - setNumColors() function, instead. + setColorCount() function, instead. \oldcode QSize mySize(width, height); @@ -1163,8 +1163,8 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder) // For 8 bit images the default number of colors is 256. If // another number of colors is required it can be specified - // using the setNumColors() function. - image.setNumColors(numColors); + // using the setColorCount() function. + image.setColorCount(numColors); \endcode */ QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder) @@ -1232,7 +1232,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int for (int i = 0; i < numColors; ++i) d->colortable[i] = colortable[i]; } else if (numColors) { - setNumColors(numColors); + setColorCount(numColors); } } @@ -1283,7 +1283,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colort for (int i = 0; i < numColors; ++i) d->colortable[i] = colortable[i]; } else if (numColors) { - setNumColors(numColors); + setColorCount(numColors); } } #endif // Q_WS_QWS @@ -1592,17 +1592,31 @@ int QImage::depth() const } /*! + \obsolete \fn int QImage::numColors() const Returns the size of the color table for the image. - Notice that numColors() returns 0 for 32-bpp images because these + \sa setColorCount() +*/ +int QImage::numColors() const +{ + return d ? d->colortable.size() : 0; +} + +/*! + \since 4.6 + \fn int QImage::colorCount() const + + Returns the size of the color table for the image. + + Notice that colorCount() returns 0 for 32-bpp images because these images do not use color tables, but instead encode pixel values as ARGB quadruplets. - \sa setNumColors(), {QImage#Image Information}{Image Information} + \sa setColorCount(), {QImage#Image Information}{Image Information} */ -int QImage::numColors() const +int QImage::colorCount() const { return d ? d->colortable.size() : 0; } @@ -1711,7 +1725,7 @@ void QImage::setColorTable(const QVector colors) Returns a list of the colors contained in the image's color table, or an empty list if the image does not have a color table - \sa setColorTable(), numColors(), color() + \sa setColorTable(), colorCount(), color() */ QVector QImage::colorTable() const { @@ -1720,12 +1734,24 @@ QVector QImage::colorTable() const /*! + \obsolete + Returns the number of bytes occupied by the image data. + + \sa byteCount() +*/ +int QImage::numBytes() const +{ + return d ? d->nbytes : 0; +} + +/*! + \since 4.6 Returns the number of bytes occupied by the image data. \sa bytesPerLine(), bits(), {QImage#Image Information}{Image Information} */ -int QImage::numBytes() const +int QImage::byteCount() const { return d ? d->nbytes : 0; } @@ -1733,7 +1759,7 @@ int QImage::numBytes() const /*! Returns the number of bytes per image scanline. - This is equivalent to numBytes()/ height(). + This is equivalent to byteCount() / height(). \sa scanLine() */ @@ -1756,7 +1782,7 @@ int QImage::bytesPerLine() const */ QRgb QImage::color(int i) const { - Q_ASSERT(i < numColors()); + Q_ASSERT(i < colorCount()); return d ? d->colortable.at(i) : QRgb(uint(-1)); } @@ -1767,9 +1793,9 @@ QRgb QImage::color(int i) const given to \a colorValue. The color value is an ARGB quadruplet. If \a index is outside the current size of the color table, it is - expanded with setNumColors(). + expanded with setColorCount(). - \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel + \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel Manipulation} */ void QImage::setColor(int i, QRgb c) @@ -1787,7 +1813,7 @@ void QImage::setColor(int i, QRgb c) return; if (i >= d->colortable.size()) - setNumColors(i+1); + setColorCount(i+1); d->colortable[i] = c; d->has_alpha_clut |= (qAlpha(c) != 255); } @@ -1844,7 +1870,7 @@ const uchar *QImage::scanLine(int i) const data, thus ensuring that this QImage is the only one using the current return value. - \sa scanLine(), numBytes() + \sa scanLine(), byteCount() */ uchar *QImage::bits() { @@ -2025,8 +2051,21 @@ void QImage::invertPixels(InvertMode mode) #endif /*! + \obsolete Resizes the color table to contain \a numColors entries. + \sa setColorCount() +*/ + +void QImage::setNumColors(int numColors) +{ + setColorCount(numColors); +} + +/*! + \since 4.6 + Resizes the color table to contain \a colorCount entries. + If the color table is expanded, all the extra colors will be set to transparent (i.e qRgba(0, 0, 0, 0)). @@ -2034,14 +2073,14 @@ void QImage::invertPixels(InvertMode mode) have entries for all the pixel/index values present in the image, otherwise the results are undefined. - \sa numColors(), colorTable(), setColor(), {QImage#Image + \sa colorsCount(), colorTable(), setColor(), {QImage#Image Transformations}{Image Transformations} */ -void QImage::setNumColors(int numColors) +void QImage::setColorCount(int colorCount) { if (!d) { - qWarning("QImage::setNumColors: null image"); + qWarning("QImage::setColorCount: null image"); return; } @@ -2051,17 +2090,16 @@ void QImage::setNumColors(int numColors) if (!d) return; - if (numColors == d->colortable.size()) + if (colorCount == d->colortable.size()) return; - if (numColors <= 0) { // use no color table + if (colorCount <= 0) { // use no color table d->colortable = QVector(); return; } int nc = d->colortable.size(); - d->colortable.resize(numColors); - for (int i = nc; i < numColors; ++i) + d->colortable.resize(colorCount); + for (int i = nc; i < colorCount; ++i) d->colortable[i] = 0; - } /*! @@ -3674,7 +3712,7 @@ QRgb QImage::pixel(int x, int y) const otherwise the parameter must be a QRgb value. If \a position is not a valid coordinate pair in the image, or if - \a index_or_rgb >= numColors() in the case of monochrome and + \a index_or_rgb >= colorCount() in the case of monochrome and 8-bit images, the result is undefined. \warning This function is expensive due to the call of the internal @@ -3835,7 +3873,7 @@ bool QImage::allGray() const } else { if (d->colortable.isEmpty()) return true; - for (int i = 0; i < numColors(); i++) + for (int i = 0; i < colorCount(); i++) if (!qIsGray(d->colortable.at(i))) return false; } @@ -3862,7 +3900,7 @@ bool QImage::isGrayscale() const case 16: return allGray(); case 8: { - for (int i = 0; i < numColors(); i++) + for (int i = 0; i < colorCount(); i++) if (d->colortable.at(i) != qRgb(i,i,i)) return false; return true; @@ -4128,7 +4166,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const int w = width(); int h = height(); QImage m(w, h, Format_MonoLSB); - m.setNumColors(2); + m.setColorCount(2); m.setColor(0, QColor(Qt::color0).rgba()); m.setColor(1, QColor(Qt::color1).rgba()); m.fill(0xff); @@ -5703,7 +5741,7 @@ QImage QImage::alphaChannel() const int h = d->height; QImage image(w, h, Format_Indexed8); - image.setNumColors(256); + image.setColorCount(256); // set up gray scale table. for (int i=0; i<256; ++i) @@ -5833,7 +5871,7 @@ static QImage smoothScaled(const QImage &source, int w, int h) { static QImage rotated90(const QImage &image) { QImage out(image.height(), image.width(), image.format()); - if (image.numColors() > 0) + if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); int h = image.height(); @@ -5872,7 +5910,7 @@ static QImage rotated90(const QImage &image) { break; default: for (int y=0; y 0) + if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); int h = image.height(); @@ -5931,7 +5969,7 @@ static QImage rotated270(const QImage &image) { break; default: for (int y=0; ycolortable.size() < 256) { // colors are left in the color table, so pick that one as transparent dImage.d->colortable.append(0x0); - memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.numBytes()); + memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount()); } else { - memset(dImage.bits(), 0, dImage.numBytes()); + memset(dImage.bits(), 0, dImage.byteCount()); } break; case 1: case 16: case 24: case 32: - memset(dImage.bits(), 0x00, dImage.numBytes()); + memset(dImage.bits(), 0x00, dImage.byteCount()); break; } diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 1ac56a7..d8809ef 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -165,18 +165,21 @@ public: QRect rect() const; int depth() const; - int numColors() const; + QT_DEPRECATED int numColors() const; + int colorCount() const; QRgb color(int i) const; void setColor(int i, QRgb c); - void setNumColors(int); + QT_DEPRECATED void setNumColors(int); + void setColorCount(int); bool allGray() const; bool isGrayscale() const; uchar *bits(); const uchar *bits() const; - int numBytes() const; + QT_DEPRECATED int numBytes() const; + int byteCount() const; uchar *scanLine(int); const uchar *scanLine(int) const; diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 9209d45..6175931 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -248,7 +248,7 @@ void QMacPixmapData::fromImage(const QImage &img, } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) { conv8 = d == 1; // native depth wanted } else if (d == 1) { - if (image.numColors() == 2) { + if (image.colorCount() == 2) { QRgb c0 = image.color(0); // Auto: convert to best QRgb c1 = image.color(1); conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255); @@ -339,7 +339,7 @@ void QMacPixmapData::fromImage(const QImage &img, bool alphamap = image.depth() == 32; if (sfmt == QImage::Format_Indexed8) { const QVector rgb = image.colorTable(); - for (int i = 0, count = image.numColors(); i < count; ++i) { + for (int i = 0, count = image.colorCount(); i < count; ++i) { const int alpha = qAlpha(rgb[i]); if (alpha != 0xff) { alphamap = true; @@ -355,13 +355,13 @@ void QMacPixmapData::fromImage(const QImage &img, int get_index(QImage * qi,QRgb mycol) { int loopc; - for(loopc=0;loopcnumColors();loopc++) { + for(loopc=0;loopccolorCount();loopc++) { if(qi->color(loopc)==mycol) return loopc; } - qi->setNumColors(qi->numColors()+1); - qi->setColor(qi->numColors(),mycol); - return qi->numColors(); + qi->setColorCount(qi->colorCount()+1); + qi->setColor(qi->colorCount(),mycol); + return qi->colorCount(); } QImage QMacPixmapData::toImage() const @@ -376,7 +376,7 @@ QImage QMacPixmapData::toImage() const const uint sbpr = bytesPerRow; if (format == QImage::Format_MonoLSB) { image.fill(0); - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); for (int y = 0; y < h; ++y) { diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index a8516a5..9a52f3f 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -126,7 +126,7 @@ int QPixmap::numCols() const { if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); - return d->image.numColors(); + return d->image.colorCount(); } return 0; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index fc76dc3..1b01e6f 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -119,7 +119,7 @@ void QRasterPixmapData::resize(int width, int height) is_null = (w <= 0 || h <= 0); if (pixelType() == BitmapType && !image.isNull()) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index cd8a4d4..f7a880c 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -443,7 +443,7 @@ void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap) // Create default palette if needed if (cfbsBitmap->DisplayMode() == EGray2) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); @@ -526,13 +526,13 @@ void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags const uchar *sptr = const_cast(sourceImage).bits(); symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); - Mem::Copy(dptr, sptr, sourceImage.numBytes()); + Mem::Copy(dptr, sptr, sourceImage.byteCount()); symbianBitmapDataAccess->endDataAccess(cfbsBitmap); UPDATE_BUFFER(); if (destFormat == QImage::Format_MonoLSB) { - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } else { @@ -835,7 +835,7 @@ void* QS60PixmapData::toNativeType(NativeType type) symbianBitmapDataAccess->beginDataAccess(newBitmap); uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, source.numBytes()); + Mem::Copy(dptr, sptr, source.byteCount()); symbianBitmapDataAccess->endDataAccess(newBitmap); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index c735031..3f297df 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -464,7 +464,7 @@ void QX11PixmapData::fromImage(const QImage &img, } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) { conv8 = (d == 1); // native depth wanted } else if (d == 1) { - if (image.numColors() == 2) { + if (image.colorCount() == 2) { QRgb c0 = image.color(0); // Auto: convert to best QRgb c1 = image.color(1); conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255); @@ -489,7 +489,7 @@ void QX11PixmapData::fromImage(const QImage &img, Visual *visual = (Visual *)xinfo.visual(); XImage *xi = 0; bool trucol = (visual->c_class >= TrueColor); - int nbytes = image.numBytes(); + int nbytes = image.byteCount(); uchar *newbits= 0; #ifndef QT_NO_XRENDER @@ -631,7 +631,7 @@ void QX11PixmapData::fromImage(const QImage &img, if (d8) { // setup pixel translation QVector ctable = cimage.colorTable(); - for (int i=0; i < cimage.numColors(); i++) { + for (int i=0; i < cimage.colorCount(); i++) { int r = qRed (ctable[i]); int g = qGreen(ctable[i]); int b = qBlue (ctable[i]); @@ -957,8 +957,8 @@ void QX11PixmapData::fromImage(const QImage &img, if (d == 8 && !trucol) { // 8 bit pixmap int pop[256]; // pixel popularity - if (image.numColors() == 0) - image.setNumColors(1); + if (image.colorCount() == 0) + image.setColorCount(1); const QImage &cimage = image; memset(pop, 0, sizeof(int)*256); // reset popularity array @@ -988,11 +988,11 @@ void QX11PixmapData::fromImage(const QImage &img, int mindist; }; int ncols = 0; - for (int i=0; i< cimage.numColors(); i++) { // compute number of colors + for (int i=0; i< cimage.colorCount(); i++) { // compute number of colors if (pop[i] > 0) ncols++; } - for (int i = cimage.numColors(); i < 256; i++) // ignore out-of-range pixels + for (int i = cimage.colorCount(); i < 256; i++) // ignore out-of-range pixels pop[i] = 0; // works since we make sure above to have at least @@ -1651,7 +1651,7 @@ QImage QX11PixmapData::toImage() const } if (d == 1) { // bitmap - image.setNumColors(2); + image.setColorCount(2); image.setColor(0, qRgb(255,255,255)); image.setColor(1, qRgb(0,0,0)); } else if (!trucol) { // pixmap with colormap @@ -1707,10 +1707,10 @@ QImage QX11PixmapData::toImage() const int trans; if (ncols < 256) { trans = ncols++; - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table image.setColor(trans, 0x00000000); } else { - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table // oh dear... no spare "transparent" pixel. // use first pixel in image (as good as any). trans = image.scanLine(0)[0]; @@ -1733,7 +1733,7 @@ QImage QX11PixmapData::toImage() const } } } else { - image.setNumColors(ncols); // create color table + image.setColorCount(ncols); // create color table } QVector colors = QColormap::instance(xinfo.screen()).colormap(); int j = 0; diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 10194e4..38f6b5d 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -201,7 +201,7 @@ QBitmap QPixmapData::mask() const if (mask.isNull()) // allocation failed return QBitmap(); - mask.setNumColors(2); + mask.setColorCount(2); mask.setColor(0, QColor(Qt::color0).rgba()); mask.setColor(1, QColor(Qt::color1).rgba()); diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index d1bb92a..41e2923 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -113,7 +113,8 @@ public: inline int width() const { return w; } inline int height() const { return h; } - inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } + QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } + inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } inline int depth() const { return d; } inline bool isNull() const { return is_null; } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 44d689d..14c863b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -171,7 +171,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - image.setNumColors(2); + image.setColorCount(2); image.setColor(1, qRgb(0,0,0)); image.setColor(0, qRgb(255,255,255)); } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { @@ -199,7 +199,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - image.setNumColors(ncols); + image.setColorCount(ncols); for (int i=0; inum_palette); + image.setColorCount(info_ptr->num_palette); int i = 0; if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { while (i < info_ptr->num_trans) { @@ -508,7 +508,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage) // sanity check palette entries if (color_type == PNG_COLOR_TYPE_PALETTE && outImage->format() == QImage::Format_Indexed8) { - int color_table_size = outImage->numColors(); + int color_table_size = outImage->colorCount(); for (int y=0; y<(int)height; ++y) { uchar *p = outImage->scanLine(y); uchar *end = p + width; @@ -762,9 +762,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in, png_colorp palette = 0; png_bytep copy_trans = 0; - if (image.numColors()) { + if (image.colorCount()) { // Paletted - int num_palette = image.numColors(); + int num_palette = image.colorCount(); palette = new png_color[num_palette]; png_set_PLTE(png_ptr, info_ptr, palette, num_palette); int* trans = new int[num_palette]; diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 28e4a2a..8ec9efb 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -242,11 +242,11 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q } if (nbits == 1) { // bitmap - outImage->setNumColors(2); + outImage->setColorCount(2); outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(1, qRgb(0,0,0)); // black } else if (nbits == 8) { // graymap - outImage->setNumColors(maxc+1); + outImage->setColorCount(maxc+1); for (int i=0; i<=maxc; i++) outImage->setColor(i, qRgb(i*255/maxc,i*255/maxc,i*255/maxc)); } @@ -287,7 +287,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy } } - if (image.depth() == 1 && image.numColors() == 2) { + if (image.depth() == 1 && image.colorCount() == 2) { if (qGray(image.color(0)) < qGray(image.color(1))) { // 0=dark/black, 1=light/white - invert image.detach(); diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 1c74351..0d76ea0 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -135,7 +135,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) return false; } - outImage->setNumColors(2); + outImage->setColorCount(2); outImage->setColor(0, qRgb(255,255,255)); // white outImage->setColor(1, qRgb(0,0,0)); // black diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 4bdd16e..ac4711a 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -895,7 +895,7 @@ static bool read_xpm_body( if (image.isNull()) return false; } - image.setNumColors(ncols); + image.setColorCount(ncols); } QMap colorMap; diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 3b3036d..3e00dba 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1059,7 +1059,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, painter.end(); QPixmap selected = QPixmap(QPixmap::fromImage(img)); - int n = (img.numBytes() >> 10) + 1; + int n = (img.byteCount() >> 10) + 1; if (QPixmapCache::cacheLimit() < n) QPixmapCache::setCacheLimit(n); diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index 26cde1a..a4e7b1f 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -153,8 +153,8 @@ static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy) bool invb, invm; bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); - invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); - invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); + invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); + invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); int sysW = GetSystemMetrics(SM_CXCURSOR); int sysH = GetSystemMetrics(SM_CYCURSOR); @@ -396,8 +396,8 @@ void QCursorData::update() } else { bbits = bm->toImage().convertToFormat(QImage::Format_Mono); mbits = bmm->toImage().convertToFormat(QImage::Format_Mono); - invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); - invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); + invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); + invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); } int n = qMax(1, bbits.width() / 8); int h = bbits.height(); diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 28676da..7461637 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1445,7 +1445,7 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) icon_data[pos++] = image.width(); icon_data[pos++] = image.height(); if (sizeof(long) == sizeof(quint32)) { - memcpy(icon_data.data() + pos, image.scanLine(0), image.numBytes()); + memcpy(icon_data.data() + pos, image.scanLine(0), image.byteCount()); } else { for (int y = 0; y < image.height(); ++y) { uint *scanLine = reinterpret_cast(image.scanLine(y)); diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index c8e86b8..9148e4b 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -96,7 +96,8 @@ public: int logicalDpiY() const { return metric(PdmDpiY); } int physicalDpiX() const { return metric(PdmPhysicalDpiX); } int physicalDpiY() const { return metric(PdmPhysicalDpiY); } - int numColors() const { return metric(PdmNumColors); } + QT_DEPRECATED int numColors() const { return metric(PdmNumColors); } + int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } protected: diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index e686373..c1b887c 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -1023,7 +1023,7 @@ CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imag #endif QCFType dataProvider = CGDataProviderCreateWithData(image, static_cast(image)->bits(), - image->numBytes(), + image->byteCount(), drawImageReleaseData); if (imagePtr) *imagePtr = image; diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 350a8e6..7457654 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -433,7 +433,7 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const return Qt::black; const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); - const int pixels = frameImage.numBytes()/sizeof(QRgb); + const int pixels = frameImage.byteCount()/sizeof(QRgb); int estimatedRed = 0; int estimatedGreen = 0; diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index 94974fc..f978bd8 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -938,7 +938,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) g.advance = qRound(metrics.xoff); QT_WRITE(fd, &g, sizeof(g)); - QT_WRITE(fd, img.bits(), img.numBytes()); + QT_WRITE(fd, img.bits(), img.byteCount()); glyphPos = oldSize - glyphDataOffset; #if 0 && defined(DEBUG_FONTENGINE) @@ -948,7 +948,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) quint32 *gmap = (quint32 *)(fontData + glyphMapOffset); gmap[glyph] = qToBigEndian(glyphPos); - glyphDataSize = glyphPos + sizeof(g) + img.numBytes(); + glyphDataSize = glyphPos + sizeof(g) + img.byteCount(); quint32 *blockSizePtr = (quint32 *)(fontData + glyphDataOffset - 4); *blockSizePtr = qToBigEndian(glyphDataSize); } diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp index bfeb2a0..e57adb6 100644 --- a/src/multimedia/video/qimagevideobuffer.cpp +++ b/src/multimedia/video/qimagevideobuffer.cpp @@ -85,7 +85,7 @@ uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) d->mapMode = mode; if (numBytes) - *numBytes = d->image.numBytes(); + *numBytes = d->image.byteCount(); if (bytesPerLine) *bytesPerLine = d->image.bytesPerLine(); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ad177dc..8063fc8 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4078,7 +4078,7 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha) glReadPixels(0, 0, w, h, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, res.bits()); const QVector pal = QColormap::instance().colormap(); if (pal.size()) { - res.setNumColors(pal.size()); + res.setColorCount(pal.size()); for (int i = 0; i < pal.size(); i++) res.setColor(i, pal.at(i).rgb()); } diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 5ca37ef..fb55097 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -452,7 +452,7 @@ QImage QGLPixmapData::fillImage(const QColor &color) const if (pixelType() == BitmapType) { img = QImage(w, h, QImage::Format_MonoLSB); - img.setNumColors(2); + img.setColorCount(2); img.setColor(0, QColor(Qt::color0).rgba()); img.setColor(1, QColor(Qt::color1).rgba()); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index cb4fb88..daefa21 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -176,7 +176,7 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const return QDirectFBScreen::depth(imageFormat); case QPaintDevice::PdmNumColors: { if (!lockedImage.isNull()) - return lockedImage.numColors(); + return lockedImage.colorCount(); DFBResult result; IDirectFBPalette *palette = 0; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 7ddd992..b6faf8b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -214,7 +214,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage: const int height = image.height(); const int bplQt = image.bytesPerLine(); if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) { - memcpy(mem, image.bits(), image.numBytes()); + memcpy(mem, image.bits(), image.byteCount()); } else { for (int i=0; i= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; if (image->isNull()) { (*image) = QImage(swidth, sheight, format); - memset(image->bits(), 0, image->numBytes()); + memset(image->bits(), 0, image->byteCount()); // ### size of the upcoming frame, should rather // be known before decoding it. @@ -393,7 +393,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), QImage::Format_RGB32); - memset(image->bits(), 0, image->numBytes()); + memset(image->bits(), 0, image->byteCount()); } for (int ln=0; lnread((char*)rgb, 4) != 4) { @@ -574,7 +574,7 @@ QImage ICOReader::iconAt(int index) if (!image.isNull()) { QImage mask(image.width(), image.height(), QImage::Format_Mono); if (!mask.isNull()) { - mask.setNumColors(2); + mask.setColorCount(2); mask.setColor(0, qRgba(255,255,255,0xff)); mask.setColor(1, qRgba(0 ,0 ,0 ,0xff)); read1BitBMP(mask); diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 3b23e56..6b2f885 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -741,7 +741,7 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info, *dest = QImage(size, format); if (format == QImage::Format_Indexed8) { - dest->setNumColors(256); + dest->setColorCount(256); for (int i = 0; i < 256; i++) dest->setColor(i, qRgb(i,i,i)); } @@ -851,7 +851,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage, } else if (cinfo.output_components == 1) { if (outImage->size() != QSize(sWidth, sHeight) || outImage->format() != QImage::Format_Indexed8) *outImage = QImage(sWidth, sHeight, QImage::Format_Indexed8); - outImage->setNumColors(256); + outImage->setColorCount(256); for (int i = 0; i < 256; ++i) outImage->setColor(i, qRgb(i,i,i)); } else { @@ -1054,7 +1054,7 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s case QImage::Format_MonoLSB: case QImage::Format_Indexed8: gray = true; - for (int i = image.numColors(); gray && i--;) { + for (int i = image.colorCount(); gray && i--;) { gray = gray & (qRed(cmap[i]) == qGreen(cmap[i]) && qRed(cmap[i]) == qBlue(cmap[i])); } diff --git a/src/qt3support/painting/q3paintdevicemetrics.h b/src/qt3support/painting/q3paintdevicemetrics.h index 830dd90..4f1603b 100644 --- a/src/qt3support/painting/q3paintdevicemetrics.h +++ b/src/qt3support/painting/q3paintdevicemetrics.h @@ -63,7 +63,7 @@ public: int logicalDpiY() const { return pdev->logicalDpiY(); } int physicalDpiX() const { return pdev->physicalDpiX(); } int physicalDpiY() const { return pdev->physicalDpiY(); } - int numColors() const { return pdev->numColors(); } + int numColors() const { return pdev->colorCount(); } int depth() const { return pdev->depth(); } private: diff --git a/src/tools/uic3/embed.cpp b/src/tools/uic3/embed.cpp index d699623..2eb4dd5 100644 --- a/src/tools/uic3/embed.cpp +++ b/src/tools/uic3/embed.cpp @@ -177,7 +177,7 @@ void Ui3Reader::embed(const char *project, const QStringList &images) e->width = img.width(); e->height = img.height(); e->depth = img.depth(); - e->numColors = img.numColors(); + e->numColors = img.colorCount(); e->colorTable = new QRgb[e->numColors]; e->alpha = img.hasAlphaBuffer(); QVector ct = img.colorTable(); @@ -195,7 +195,7 @@ void Ui3Reader::embed(const char *project, const QStringList &images) #ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION e->compressed = #endif - embedData( out, img.bits(), img.numBytes() ); + embedData( out, img.bits(), img.byteCount() ); out << "\n};\n\n"; if ( e->numColors ) { out << s.sprintf( "static const QRgb %s_ctable[] = {", diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index 44deb0e..feabaed 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -587,10 +587,10 @@ void PaintCommands::staticInit() "^image_setColor\\s+([\\w.:\\/]*)\\s+([0-9]*)\\s+#([0-9]*)$", "image_setColor ", "image_setColor myImage 0 black"); - DECL_PAINTCOMMAND("image_setNumColors", command_image_setNumColors, - "^image_setNumColors\\s+([\\w.:\\/]*)\\s+([0-9]*)$", - "image_setNumColors ", - "image_setNumColors myImage 128"); + DECL_PAINTCOMMAND("image_setColorCount", command_image_setColorCount, + "^image_setColorCount\\s+([\\w.:\\/]*)\\s+([0-9]*)$", + "image_setColorCount ", + "image_setColorCount myImage 128"); DECL_PAINTCOMMANDSECTION("transformations"); DECL_PAINTCOMMAND("resetMatrix", command_resetMatrix, @@ -2245,7 +2245,7 @@ void PaintCommands::command_image_load(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_image_setNumColors(QRegExp re) +void PaintCommands::command_image_setColorCount(QRegExp re) { QStringList caps = re.capturedTexts(); @@ -2253,10 +2253,10 @@ void PaintCommands::command_image_setNumColors(QRegExp re) int count = convertToInt(caps.at(2)); if (m_verboseMode) - printf(" -(lance) image_setNumColors(%s), %d -> %d\n", - qPrintable(name), m_imageMap[name].numColors(), count); + printf(" -(lance) image_setColorCount(%s), %d -> %d\n", + qPrintable(name), m_imageMap[name].colorCount(), count); - m_imageMap[name].setNumColors(count); + m_imageMap[name].setColorCount(count); } /***************************************************************************************************/ diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index ba91a92..e2c4d67 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -239,7 +239,7 @@ private: void command_image_convertToFormat(QRegExp re); void command_image_load(QRegExp re); void command_image_setColor(QRegExp re); - void command_image_setNumColors(QRegExp re); + void command_image_setColorCount(QRegExp re); // commands: transformation void command_resetMatrix(QRegExp re); diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index 56fc53a..7535645 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -1461,7 +1461,7 @@ void tst_QDataStream::readQImage(QDataStream *s) QVERIFY(d12.width() == ref.width()); QVERIFY(d12.height() == ref.height()); QVERIFY(d12.depth() == ref.depth()); - QVERIFY(d12.numColors() == ref.numColors()); + QVERIFY(d12.colorCount() == ref.colorCount()); #ifdef QT3_SUPPORT QVERIFY(d12.hasAlphaBuffer() == ref.hasAlphaBuffer()); #else diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index e15ae8a..da4e85d 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -104,7 +104,7 @@ private slots: void setPixel_data(); void setPixel(); - void setNumColors(); + void setColorCount(); void setColor(); void rasterClipping(); @@ -155,7 +155,7 @@ void tst_QImage::create() #endif //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian); QImage image(7000000, 7000000, QImage::Format_Indexed8); - image.setNumColors(256); + image.setColorCount(256); cr = !image.isNull(); #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) } catch (...) { @@ -242,7 +242,7 @@ void tst_QImage::convertBitOrder() QSKIP("Qt compiled without Qt3Support", SkipAll); #else QImage i(9,5,1,2,QImage::LittleEndian); - qMemSet(i.bits(), 0, i.numBytes()); + qMemSet(i.bits(), 0, i.byteCount()); i.setDotsPerMeterX(9); i.setDotsPerMeterY(5); @@ -258,7 +258,7 @@ void tst_QImage::convertBitOrder() QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY()); QVERIFY(i.depth() == ni.depth()); QVERIFY(i.size() == ni.size()); - QVERIFY(i.numColors() == ni.numColors()); + QVERIFY(i.colorCount() == ni.colorCount()); #endif } @@ -365,7 +365,7 @@ void tst_QImage::setAlphaChannel() QImage alphaChannel; if (gray) { alphaChannel = QImage(width, height, QImage::Format_Indexed8); - alphaChannel.setNumColors(256); + alphaChannel.setColorCount(256); for (int i=0; i<256; ++i) alphaChannel.setColor(i, qRgb(i, i, i)); alphaChannel.fill(alpha); @@ -927,7 +927,7 @@ void tst_QImage::rotate() original.fill(qRgb(255,255,255)); if (format == QImage::Format_Indexed8) { - original.setNumColors(256); + original.setColorCount(256); for (int i = 0; i < 255; ++i) original.setColor(i, qRgb(0, i, i)); } @@ -1196,23 +1196,23 @@ void tst_QImage::convertToFormatPreserveText() } #endif // QT_NO_IMAGE_TEXT -void tst_QImage::setNumColors() +void tst_QImage::setColorCount() { QImage img(0, 0, QImage::Format_Indexed8); - QTest::ignoreMessage(QtWarningMsg, "QImage::setNumColors: null image"); - img.setNumColors(256); - QCOMPARE(img.numColors(), 0); + QTest::ignoreMessage(QtWarningMsg, "QImage::setColorCount: null image"); + img.setColorCount(256); + QCOMPARE(img.colorCount(), 0); } void tst_QImage::setColor() { QImage img(0, 0, QImage::Format_Indexed8); img.setColor(0, qRgba(18, 219, 108, 128)); - QCOMPARE(img.numColors(), 0); + QCOMPARE(img.colorCount(), 0); QImage img2(1, 1, QImage::Format_Indexed8); img2.setColor(0, qRgba(18, 219, 108, 128)); - QCOMPARE(img2.numColors(), 1); + QCOMPARE(img2.colorCount(), 1); } /* Just some sanity checking that we don't draw outside the buffer of diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index 584a060..ab5572d 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -546,7 +546,7 @@ void tst_QImageWriter::saveWithNoFormat() QFETCH(QImageWriter::ImageWriterError, error); QImage niceImage(64, 64, QImage::Format_ARGB32); - qMemSet(niceImage.bits(), 0, niceImage.numBytes()); + qMemSet(niceImage.bits(), 0, niceImage.byteCount()); QImageWriter writer(fileName /* , 0 - no format! */); if (error != 0) { diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 426887d..a2770d4 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -877,7 +877,7 @@ void tst_QItemDelegate::decoration() } case QVariant::Image: { QImage img(size, QImage::Format_Mono); - qMemSet(img.bits(), 0, img.numBytes()); + qMemSet(img.bits(), 0, img.byteCount()); value = img; break; } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 4d2c626..003a494 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -2918,7 +2918,7 @@ void tst_QPainter::monoImages() QImage img(2, 2, format); - if (img.numColors() > 0) { + if (img.colorCount() > 0) { img.setColor(0, QColor(colorPairs[j][0]).rgba()); img.setColor(1, QColor(colorPairs[j][1]).rgba()); } @@ -2940,7 +2940,7 @@ void tst_QPainter::monoImages() // should not change the image QCOMPARE(original, img); - if (img.numColors() == 0) + if (img.colorCount() == 0) continue; for (int k = 0; k < 2; ++k) { diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8e02c74..d7f042e 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -293,7 +293,7 @@ void tst_QPixmap::setAlphaChannel() QRgb expected = alpha == 0 ? 0 : qRgba(red, green, blue, alpha); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { - if (result.numColors() > 0) { + if (result.colorCount() > 0) { ok &= result.pixelIndex(x, y) == expected; } else { ok &= result.pixel(x, y) == expected; @@ -330,7 +330,7 @@ void tst_QPixmap::fromImage() QImage image(37, 16, format); - if (image.numColors() == 2) { + if (image.colorCount() == 2) { image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } @@ -731,7 +731,7 @@ void tst_QPixmap::testMetrics() void tst_QPixmap::createMaskFromColor() { QImage image(3, 3, QImage::Format_Indexed8); - image.setNumColors(10); + image.setColorCount(10); image.setColor(0, 0xffffffff); image.setColor(1, 0xff000000); image.setColor(2, 0xffff0000); diff --git a/tools/makeqpf/qpf2.cpp b/tools/makeqpf/qpf2.cpp index 23006f0..a0af1a0 100644 --- a/tools/makeqpf/qpf2.cpp +++ b/tools/makeqpf/qpf2.cpp @@ -519,7 +519,7 @@ void QPF::addGlyphs(QFontEngine *fe, const QList &ranges) glyph_metrics_t metrics = fe->boundingBox(glyphIndex); const quint32 oldSize = glyphs.size(); - glyphs.resize(glyphs.size() + sizeof(QFontEngineQPF::Glyph) + img.numBytes()); + glyphs.resize(glyphs.size() + sizeof(QFontEngineQPF::Glyph) + img.byteCount()); uchar *data = reinterpret_cast(glyphs.data() + oldSize); uchar *gmapPtr = reinterpret_cast(gmap.data() + glyphIndex * sizeof(quint32)); @@ -543,7 +543,7 @@ void QPF::addGlyphs(QFontEngine *fe, const QList &ranges) ; } - qMemCopy(data, img.bits(), img.numBytes()); + qMemCopy(data, img.bits(), img.byteCount()); } } } diff --git a/tools/qvfb/qvfbview.cpp b/tools/qvfb/qvfbview.cpp index 8cab641..69817bd 100644 --- a/tools/qvfb/qvfbview.cpp +++ b/tools/qvfb/qvfbview.cpp @@ -596,7 +596,7 @@ QImage QVFbView::getBuffer(const QRect &r, int &leading) const r.width(), r.height(), mView->linestep(), QImage::Format_Indexed8); img.setColorTable(mView->clut()); - if (img.numColors() <= 0) + if (img.colorCount() <= 0) img = QImage(); break; } @@ -613,10 +613,10 @@ QImage QVFbView::getBuffer(const QRect &r, int &leading) const if ( img.format() != QImage::Format_ARGB32_Premultiplied ) img = img.convertToFormat(QImage::Format_RGB32); - // NOTE: calling bits() may change numBytes(), so do not + // NOTE: calling bits() may change byteCount(), so do not // pass them as parameters (which are evaluated right-to-left). QRgb *b = (QRgb*)img.bits(); - int n = img.numBytes()/4; + int n = img.byteCount()/4; dim(b,n,brightness); } } -- cgit v0.12 From a2c08390e3ea2aefdc9b3284498137e1fd4b8b13 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Nov 2009 15:50:00 +0100 Subject: my changes for 4.6.0 --- dist/changes-4.6.0 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index a42b213..a03ed43 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -217,6 +217,10 @@ QtGui - On Windows CE the link time code geration has been disabled by default to be consistent with win32-msvc200x. + + - The default button size has been reduced in the Windows mobile style. + + - [QTBUG-3613] QWizard issues have been fixed on Windows mobile. - Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES @@ -225,7 +229,6 @@ QtGui - KDE Integration: Improved the integration into KDE desktop (loading of KDE palette, usage of KColorDialog and KFileDialog) using the GuiPlatformPlugin - - Phonon on Windows * Now much more reliable when reading a file through a QIODevice. * If Video Mixing Renderer 9 is not available, falls back to software -- cgit v0.12 From b87cc5edbf3100da062f20eefbc1fdb737b74118 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 6 Nov 2009 15:17:05 +0100 Subject: Corrects bug in fancybrowser example where image rotation did not work. This is actually only a workaround of what seems to be a QtWebKit bug. See QTBUG-4649. Reviewed-by: Jedrzej Nowacki --- examples/webkit/fancybrowser/mainwindow.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index a3293b8..11fac91 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -150,12 +150,11 @@ void MainWindow::highlightAllLinks() //! [8] void MainWindow::rotateImages(bool toggle) { - QString code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s') } )"; - view->page()->mainFrame()->evaluateJavaScript(code); + QString code; if (toggle) - code = "$('img').each( function () { $(this).css('-webkit-transform', 'rotate(180deg)') } )"; + code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(180deg)') } )"; else - code = "$('img').each( function () { $(this).css('-webkit-transform', 'rotate(0deg)') } )"; + code = "$('img').each( function () { $(this).css('-webkit-transition', '-webkit-transform 2s'); $(this).css('-webkit-transform', 'rotate(0deg)') } )"; view->page()->mainFrame()->evaluateJavaScript(code); } //! [8] -- cgit v0.12 From 8d4f3c94411d21f0b7d851b56f951ad54d64340f Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 10:36:38 +0100 Subject: API review: Rename numCols() -> colorCount() The name numCols is ambiguous, as sometimes it's refering to the number of columns, and sometimes the number of colors. It also does not match the typical Qt naming convention *Count(). Reviewed-by: Tom Cooksey Reviewed-by: Andreas Aardal Hanssen --- src/gui/embedded/qscreen_qws.cpp | 14 +++++++++++--- src/gui/embedded/qscreen_qws.h | 3 ++- src/gui/image/qpixmap.cpp | 7 +++++++ src/gui/image/qpixmap.h | 3 ++- src/gui/image/qpixmap_qws.cpp | 5 +++++ src/gui/painting/qcolormap_qws.cpp | 2 +- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 911a77e..0dbfd05 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -1385,7 +1385,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const QScreen provides several functions to retrieve information about the color palette: The clut() function returns a pointer to the - color lookup table (i.e. its color palette). Use the numCols() + color lookup table (i.e. its color palette). Use the colorCount() function to determine the number of entries in this table, and the alloc() function to retrieve the palette index of the color that is the closest match to a given RGB value. @@ -1998,12 +1998,20 @@ QImage::Format QScreenPrivate::preferredImageFormat() const i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory. - \sa alloc(), depth(), numCols() + \sa alloc(), depth(), colorCount() */ /*! + \obsolete \fn int QScreen::numCols() + \sa colorCount() +*/ + +/*! + \since 4.6 + \fn int QScreen::colorCount() + Returns the number of entries in the screen's color lookup table (i.e. its color palette). A pointer to the color table can be retrieved using the clut() function. @@ -2103,7 +2111,7 @@ void QScreen::setPixelFormat(QImage::Format format) i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory. - \sa clut(), numCols() + \sa clut(), colorCount() */ int QScreen::alloc(unsigned int r,unsigned int g,unsigned int b) diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index d20d709..b3246f9 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -243,7 +243,8 @@ public: int totalSize() const { return mapsize; } QRgb * clut() { return screenclut; } - int numCols() { return screencols; } + QT_DEPRECATED int numCols() { return screencols; } + int colorCount() { return screencols; } virtual QSize mapToDevice(const QSize &) const; virtual QSize mapFromDevice(const QSize &) const; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index dfeea76..985a20b 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -2150,6 +2150,13 @@ QPixmapData* QPixmap::pixmapData() const */ /*! \fn int QPixmap::numCols() const + \obsolete + \internal + \sa colorCount() +*/ + +/*! \fn int QPixmap::colorCount() const + \since 4.6 \internal */ diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index d11bd03..d95b4ee 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -185,7 +185,8 @@ public: const uchar *qwsBits() const; int qwsBytesPerLine() const; QRgb *clut() const; - int numCols() const; + QT_DEPRECATED int numCols() const; + int colorCount() const; #elif defined(Q_WS_MAC) Qt::HANDLE macQDHandle() const; Qt::HANDLE macQDAlphaHandle() const; diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index 9a52f3f..69626ed 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -124,6 +124,11 @@ QRgb* QPixmap::clut() const int QPixmap::numCols() const { + return colorCount(); +} + +int QPixmap::colorCount() const +{ if (data && data->classId() == QPixmapData::RasterClass) { const QRasterPixmapData *d = static_cast(data.data()); return d->image.colorCount(); diff --git a/src/gui/painting/qcolormap_qws.cpp b/src/gui/painting/qcolormap_qws.cpp index ce4cd09..bc97b08 100644 --- a/src/gui/painting/qcolormap_qws.cpp +++ b/src/gui/painting/qcolormap_qws.cpp @@ -170,7 +170,7 @@ const QColor QColormap::colorAt(uint pixel) const (pixel & green_mask) >> green_shift, (pixel & blue_mask)); } - Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette"); + Q_ASSERT_X(int(pixel) < qt_screen->colorCount(), "QColormap::colorAt", "pixel out of bounds of palette"); return QColor(qt_screen->clut()[pixel]); } -- cgit v0.12 From f8f589b00248d1c56db696b16576486525893e8d Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 6 Nov 2009 17:06:13 +0100 Subject: Fixed -xsync configure option handling. Reviewed-by: trustme --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index aab520e..683b7a0 100755 --- a/configure +++ b/configure @@ -914,7 +914,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; -- cgit v0.12 From 69f0cfbb9c609ac922a6d45a7ef3d75b59d23c25 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 6 Nov 2009 17:19:40 +0100 Subject: Dont create native winid when not required. When Windows doesn't support native gestures, we shouldn't create a native winid. Also, there is no reason to create winid on all ancestors. Reviewed-by: Trond --- src/gui/kernel/qwidget_win.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 22a94b9..95ef1cf 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2033,9 +2033,12 @@ void QWidgetPrivate::registerTouchWindow() void QWidgetPrivate::winSetupGestures() { Q_Q(QWidget); - if (!q || !q->isVisible()) + if (!q || !q->isVisible() || !nativeGesturePanEnabled) return; + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv->SetGestureConfig) + return; WId winid = q->internalWinId(); bool needh = false; @@ -2052,10 +2055,12 @@ void QWidgetPrivate::winSetupGestures() needv = (vbarpolicy == Qt::ScrollBarAlwaysOn || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; - if (!winid) + if (!winid) { + q->setAttribute(Qt::WA_DontCreateNativeAncestors); winid = q->winId(); // enforces the native winid on the viewport + } } - if (winid && qAppPriv->SetGestureConfig) { + if (winid) { GESTURECONFIG gc[1]; memset(gc, 0, sizeof(gc)); gc[0].dwID = GID_PAN; -- cgit v0.12 From d672ff5ddc23fe7c332d17b32378a00e21fad7b3 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 6 Nov 2009 17:26:43 +0100 Subject: Added a -no-native-gestures option for configure.exe The option allows to disable native Windows7 gestures since they require the creation of the native window handle. This partially disabled alien widgets concept and make window resizing slower and more flickery. Reviewed-by: Espen Riskedal --- src/gui/kernel/qapplication_win.cpp | 2 ++ src/gui/kernel/qgesturemanager.cpp | 4 +++- src/gui/kernel/qstandardgestures.cpp | 3 +-- src/gui/kernel/qwidget_win.cpp | 2 ++ src/gui/kernel/qwinnativepangesturerecognizer_win.cpp | 4 ++++ src/gui/kernel/qwinnativepangesturerecognizer_win_p.h | 4 ++++ tools/configure/configureapp.cpp | 11 +++++++++++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 387c29b..05e75a2 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -832,6 +832,7 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo; priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments; #elif !defined(Q_WS_WINCE) + #if !defined(QT_NO_NATIVE_GESTURES) priv->GetGestureInfo = (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"), "GetGestureInfo"); @@ -847,6 +848,7 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureConfig = (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"), "GetGestureConfig"); + #endif // QT_NO_NATIVE_GESTURES priv->BeginPanningFeedback = (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), "BeginPanningFeedback"); diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 375116f..2a6e286 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -52,7 +52,7 @@ #ifdef Q_WS_MAC #include "qmacgesturerecognizer_mac_p.h" #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES) #include "qwinnativepangesturerecognizer_win_p.h" #endif @@ -94,7 +94,9 @@ QGestureManager::QGestureManager(QObject *parent) registerGestureRecognizer(new QTapGestureRecognizer); #endif #if defined(Q_OS_WIN) + #if !defined(QT_NO_NATIVE_GESTURES) registerGestureRecognizer(new QWinNativePanGestureRecognizer); + #endif #else registerGestureRecognizer(new QTapAndHoldGestureRecognizer); #endif diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 0ea4764..6b0441b 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -56,7 +56,7 @@ QPanGestureRecognizer::QPanGestureRecognizer() QGesture *QPanGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES) // for scroll areas on Windows we want to use native gestures instead if (!qobject_cast(target->parent())) static_cast(target)->setAttribute(Qt::WA_AcceptTouchEvents); @@ -77,7 +77,6 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, const QTouchEvent *ev = static_cast(event); QGestureRecognizer::Result result; - switch (event->type()) { case QEvent::TouchBegin: { result = QGestureRecognizer::MayBeGesture; diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 95ef1cf..87f1cad 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2032,6 +2032,7 @@ void QWidgetPrivate::registerTouchWindow() void QWidgetPrivate::winSetupGestures() { +#if !defined(QT_NO_NATIVE_GESTURES) Q_Q(QWidget); if (!q || !q->isVisible() || !nativeGesturePanEnabled) return; @@ -2080,6 +2081,7 @@ void QWidgetPrivate::winSetupGestures() qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0])); } +#endif } QT_END_NAMESPACE diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp index 5fceb13..7dff543 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_NATIVE_GESTURES) + QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer() { } @@ -122,4 +124,6 @@ void QWinNativePanGestureRecognizer::reset(QGesture *state) QGestureRecognizer::reset(state); } +#endif // QT_NO_NATIVE_GESTURES + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h index 8fb0d50..7d53ed2 100644 --- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h +++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_NATIVE_GESTURES) + class QWinNativePanGestureRecognizer : public QGestureRecognizer { public: @@ -67,6 +69,8 @@ public: void reset(QGesture *state); }; +#endif // QT_NO_NATIVE_GESTURES + QT_END_NAMESPACE #endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index d8c2abd..265bc5c 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -351,6 +351,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "INCREDIBUILD_XGE" ] = "auto"; dictionary[ "LTCG" ] = "no"; + dictionary[ "NATIVE_GESTURES" ] = "yes"; } Configure::~Configure() @@ -796,6 +797,10 @@ void Configure::parseCmdLine() dictionary[ "INCREDIBUILD_XGE" ] = "no"; else if( configCmdLine.at(i) == "-incredibuild-xge" ) dictionary[ "INCREDIBUILD_XGE" ] = "yes"; + else if( configCmdLine.at(i) == "-native-gestures" ) + dictionary[ "NATIVE_GESTURES" ] = "yes"; + else if( configCmdLine.at(i) == "-no-native-gestures" ) + dictionary[ "NATIVE_GESTURES" ] = "no"; #if !defined(EVAL) // Others --------------------------------------------------- else if (configCmdLine.at(i) == "-fpu" ) @@ -1774,6 +1779,8 @@ bool Configure::displayHelp() desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' '); desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile", ' '); desc("STYLE_S60" , "yes", "", " s60\n", ' '); + desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7."); + desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7."); /* We do not support -qconfig on Windows yet @@ -2521,6 +2528,9 @@ void Configure::generateOutputVars() if (dictionary["DECLARATIVE"] == "yes") qtConfig += "declarative"; + if( dictionary[ "NATIVE_GESTURES" ] == "yes" ) + qtConfig += "native-gestures"; + // We currently have no switch for QtSvg, so add it unconditionally. qtConfig += "svg"; @@ -2897,6 +2907,7 @@ void Configure::generateConfigfiles() if(dictionary["SCRIPTTOOLS"] == "no") qconfigList += "QT_NO_SCRIPTTOOLS"; if(dictionary["FREETYPE"] == "no") qconfigList += "QT_NO_FREETYPE"; if(dictionary["S60"] == "no") qconfigList += "QT_NO_S60"; + if(dictionary["NATIVE_GESTURES"] == "no") qconfigList += "QT_NO_NATIVE_GESTURES"; if(dictionary["OPENGL_ES_CM"] == "yes" || dictionary["OPENGL_ES_CL"] == "yes" || -- cgit v0.12 From 0d92333ec537821876f2d3365e3c1780cfb3c2ea Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 6 Nov 2009 19:29:52 +0100 Subject: Fixes compilation warning in qbrush Reviewed-by: Andreas --- src/gui/painting/qbrush.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 6f5d892..afe9986 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -970,7 +970,7 @@ bool QBrush::operator==(const QBrush &b) const QDebug operator<<(QDebug dbg, const QBrush &b) { #ifndef Q_BROKEN_DEBUG_STREAM - char *BRUSH_STYLES[] = { + const char *BRUSH_STYLES[] = { "NoBrush", "SolidPattern", "Dense1Pattern", -- cgit v0.12 From 338fe3c15e90d62606806b0845bb621dd05153ae Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 6 Nov 2009 19:30:20 +0100 Subject: Improved xsync feature testing. Make sure we actually call any XSync function to test if those functions are available on the platform. On HPUX there is something wrong since X11 header files contain required function declarations, however we cannot link to them. Reviewed-by: Andreas --- config.tests/x11/xsync/xsync.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.tests/x11/xsync/xsync.cpp b/config.tests/x11/xsync/xsync.cpp index a7175de..ed3ecf5 100644 --- a/config.tests/x11/xsync/xsync.cpp +++ b/config.tests/x11/xsync/xsync.cpp @@ -48,5 +48,7 @@ int main(int, char **) XSyncValue value; (void*)&XSyncIntToValue; (void*)&XSyncCreateCounter; - return 0; + int a, b; + Status ret = XSyncInitialize(NULL, &a, &b); + return ret; } -- cgit v0.12 From d4b0fa0b4fd566a8afa268b29fc5b9b08bd503ee Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Nov 2009 21:13:43 +0100 Subject: changes-4.6.0 updated --- dist/changes-4.6.0 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index a03ed43..a3af04e 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -221,6 +221,17 @@ QtGui - The default button size has been reduced in the Windows mobile style. - [QTBUG-3613] QWizard issues have been fixed on Windows mobile. + + - [254673] Restoring minimzed widgets fixed for Windows mobile and + Windows CE. + + - [255242] Seeking within large files (bigger than 0x80000000 bytes) fixed + on Windows CE. + + - [257352] When configuring Qt for Windows CE, configure points the user to + setcepaths, when its done. + + - [259850] Added a makespec template for Windows CE 6. - Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES -- cgit v0.12 From 79864599ec3a1ce5a5ede84ea2d3d7ba437a3257 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Nov 2009 22:39:24 +0100 Subject: don't construct a new message for look-up purposes only --- tools/linguist/lupdate/merge.cpp | 8 +++++--- tools/linguist/shared/translator.cpp | 8 -------- tools/linguist/shared/translator.h | 2 -- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index b5f77cd..cffbfa3 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -351,8 +351,9 @@ Translator merge(const Translator &tor, const Translator &virginTor, if (!mv.isNull()) m.setComment(mv.comment()); } else { - TranslatorMessage mv = virginTor.find(m.context(), m.sourceText(), m.comment()); - if (mv.isNull()) { + TranslatorMessage mv; + int mvi = virginTor.messages().indexOf(m); + if (mvi < 0) { if (!(options & HeuristicSimilarText)) { newType = TranslatorMessage::Obsolete; if (m.type() != TranslatorMessage::Obsolete) @@ -402,6 +403,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, } } } else { + mv = virginTor.message(mvi); switch (m.type()) { case TranslatorMessage::Finished: default: @@ -446,7 +448,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, if (tor.contains(mv.context())) continue; } else { - if (tor.contains(mv.context(), mv.sourceText(), mv.comment())) + if (tor.messages().contains(mv)) continue; if (options & HeuristicSimilarText) { TranslatorMessage m = tor.find(mv.context(), mv.comment(), mv.allReferences()); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index cd670cc..3b7ee9a 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -319,14 +319,6 @@ bool Translator::contains(const QString &context, } TranslatorMessage Translator::find(const QString &context, - const QString &sourceText, const QString &comment) const -{ - TranslatorMessage needle(context, sourceText, comment, QString(), QString(), 0); - int index = m_messages.indexOf(needle); - return index == -1 ? TranslatorMessage() : m_messages.at(index); -} - -TranslatorMessage Translator::find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const { if (!refs.isEmpty()) { diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index ef81d2a..6db6f3a 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -115,8 +115,6 @@ public: bool contains(const QString &context, const QString &sourceText, const QString &comment) const; - TranslatorMessage find(const QString &context, - const QString &sourceText, const QString &comment) const; TranslatorMessage find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const; -- cgit v0.12 From ffa332a3c8eef08695791b9fdccfd2677ec325fc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Nov 2009 20:01:22 +0100 Subject: cut code dupe ... ... with gotos :) --- tools/linguist/lupdate/merge.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index cffbfa3..1ae4cfb 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -355,6 +355,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, int mvi = virginTor.messages().indexOf(m); if (mvi < 0) { if (!(options & HeuristicSimilarText)) { + makeObsolete: newType = TranslatorMessage::Obsolete; if (m.type() != TranslatorMessage::Obsolete) obsoleted++; @@ -363,10 +364,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, mv = virginTor.find(m.context(), m.comment(), m.allReferences()); if (mv.isNull()) { // did not find it in the virgin, mark it as obsolete - newType = TranslatorMessage::Obsolete; - if (m.type() != TranslatorMessage::Obsolete) - obsoleted++; - m.clearReferences(); + goto makeObsolete; } else { // Do not just accept it if its on the same line number, // but different source text. @@ -388,17 +386,11 @@ Translator merge(const Translator &tor, const Translator &virginTor, m.setExtra(QLatin1String("po-old_msgid_plural"), oldpluralsource); m.unsetExtra(QLatin1String("po-msgid_plural")); } - m.setReferences(mv.allReferences()); // Update secondary references - m.setPlural(mv.isPlural()); - m.setUtf8(mv.isUtf8()); - m.setExtraComment(mv.extraComment()); + goto copyAttribs; // Update secondary references } else { // The virgin and vernacular sourceTexts are so // different that we could not find it. - newType = TranslatorMessage::Obsolete; - if (m.type() != TranslatorMessage::Obsolete) - obsoleted++; - m.clearReferences(); + goto makeObsolete; } } } @@ -428,6 +420,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, // This should also enable us to read a file that does not // have the element. // why not use operator=()? Because it overwrites e.g. userData. + copyAttribs: m.setReferences(mv.allReferences()); m.setPlural(mv.isPlural()); m.setUtf8(mv.isUtf8()); -- cgit v0.12 From cfb02f6e1434b0d9ebf9d65cc5048036418bb64d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Nov 2009 22:47:54 +0100 Subject: remove unused TranslatorMessage::operator<() it was once needed for QMap, but we don't use that any more --- tools/linguist/shared/translatormessage.cpp | 11 ----------- tools/linguist/shared/translatormessage.h | 1 - 2 files changed, 12 deletions(-) diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp index db6f333..0e7cb18 100644 --- a/tools/linguist/shared/translatormessage.cpp +++ b/tools/linguist/shared/translatormessage.cpp @@ -156,17 +156,6 @@ bool TranslatorMessage::operator==(const TranslatorMessage& m) const } -bool TranslatorMessage::operator<(const TranslatorMessage& m) const -{ - if (m_context != m.m_context) - return m_context < m.m_context; - if (m_sourcetext != m.m_sourcetext) - return m_sourcetext < m.m_sourcetext; - if (m_comment != m.m_comment) - return m_comment < m.m_comment; - return m_id < m.m_id; -} - int qHash(const TranslatorMessage &msg) { return diff --git a/tools/linguist/shared/translatormessage.h b/tools/linguist/shared/translatormessage.h index 675bba7..fb3cc4b 100644 --- a/tools/linguist/shared/translatormessage.h +++ b/tools/linguist/shared/translatormessage.h @@ -110,7 +110,6 @@ public: } bool operator==(const TranslatorMessage& m) const; - bool operator<(const TranslatorMessage& m) const; QString fileName() const { return m_fileName; } void setFileName(const QString &fileName) { m_fileName = fileName; } -- cgit v0.12 From 60b6fcdd18c4a21df086a0965bd2d536a39d2094 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 16:37:33 +0100 Subject: do not consider plural source in comparisons two messages with identical singular but different plural sources simply make no sense. this should be quite a bit faster, as it saves lots of QHash lookups. --- tools/linguist/shared/translatormessage.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp index 0e7cb18..876b129 100644 --- a/tools/linguist/shared/translatormessage.cpp +++ b/tools/linguist/shared/translatormessage.cpp @@ -145,12 +145,9 @@ bool TranslatorMessage::needs8Bit() const bool TranslatorMessage::operator==(const TranslatorMessage& m) const { - static QString msgIdPlural = QLatin1String("po-msgid_plural"); - // Special treatment for context comments (empty source). return (m_context == m.m_context) && m_sourcetext == m.m_sourcetext - && m_extra[msgIdPlural] == m.m_extra[msgIdPlural] && m_id == m.m_id && (m_sourcetext.isEmpty() || m_comment == m.m_comment); } @@ -161,7 +158,6 @@ int qHash(const TranslatorMessage &msg) return qHash(msg.context()) ^ qHash(msg.sourceText()) ^ - qHash(msg.extra(QLatin1String("po-msgid_plural"))) ^ qHash(msg.comment()) ^ qHash(msg.id()); } -- cgit v0.12 From 60acaf5ec7edcd1baf4dd8f80cf93b3e2cb520e4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 21:05:18 +0100 Subject: use right method to record new messages consistent with all other source parsers --- tools/linguist/lupdate/qscript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 4600656..6c94588 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -776,7 +776,7 @@ static void recordMessage( fileName, lineNo, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); - tor->replace(msg); + tor->extend(msg); } -- cgit v0.12 From 92e9a481518d1c13df32bc2f1a9c8a0ba0b8961a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 21:07:15 +0100 Subject: eliminate Translator::replace() --- tools/linguist/lupdate/merge.cpp | 10 +++------- tools/linguist/shared/translator.cpp | 9 --------- tools/linguist/shared/translator.h | 1 - 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index 1ae4cfb..6b8d4bb 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -247,10 +247,8 @@ int applyNumberHeuristic(Translator &tor) t = translated.find(zeroKey((*u).sourceText())); if (t != translated.end() && !t.key().isEmpty() && t->sourceText() != u->sourceText()) { - TranslatorMessage m = *u; - m.setTranslation(translationAttempt(t->translation(), t->sourceText(), - u->sourceText())); - tor.replace(m); + u->setTranslation(translationAttempt(t->translation(), t->sourceText(), + u->sourceText())); inserted++; } } @@ -305,9 +303,7 @@ int applySameTextHeuristic(Translator &tor) QString key = u->sourceText(); t = translated.find(key); if (t != translated.end()) { - TranslatorMessage m = *u; - m.setTranslations(t->translations()); - tor.replace(m); + u->setTranslations(t->translations()); ++inserted; } } diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 3b7ee9a..92ecf07 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -80,15 +80,6 @@ QList &Translator::registeredFileFormats() return theFormats; } -void Translator::replace(const TranslatorMessage &msg) -{ - int index = m_messages.indexOf(msg); - if (index == -1) - m_messages.append(msg); - else - m_messages[index] = msg; -} - void Translator::replaceSorted(const TranslatorMessage &msg) { int index = m_messages.indexOf(msg); diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 6db6f3a..c51993d 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -122,7 +122,6 @@ public: bool contains(const QString &context) const; TranslatorMessage find(const QString &context) const; - void replace(const TranslatorMessage &msg); void replaceSorted(const TranslatorMessage &msg); void extend(const TranslatorMessage &msg); // Only for single-location messages void append(const TranslatorMessage &msg); -- cgit v0.12 From e9a0d840133f53e2a2fb138b9042000c883d0283 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 21:14:15 +0100 Subject: eliminate Translator::contains() replace the one use case with something more efficient --- tools/linguist/shared/qm.cpp | 12 +++++++++++- tools/linguist/shared/translator.cpp | 7 ------- tools/linguist/shared/translator.h | 3 --- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 5965aac..99aedef 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -685,6 +685,16 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) +static bool containsStripped(const Translator &translator, const TranslatorMessage &msg) +{ + foreach (const TranslatorMessage &tmsg, translator.messages()) + if (tmsg.sourceText() == msg.sourceText() + && tmsg.context() == msg.context() + && tmsg.comment().isEmpty()) + return true; + return false; +} + static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd) { Releaser releaser; @@ -741,7 +751,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData bool forceComment = msg.comment().isEmpty() || msg.context().isEmpty() - || translator.contains(msg.context(), msg.sourceText(), QString()); + || containsStripped(translator, msg); releaser.insert(msg, tlns, forceComment); } } diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 92ecf07..a35666d 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -302,13 +302,6 @@ bool Translator::release(QFile *iod, ConversionData &cd) const return false; } -bool Translator::contains(const QString &context, - const QString &sourceText, const QString &comment) const -{ - return m_messages.contains(TranslatorMessage(context, sourceText, comment, - QString(), QString(), 0)); -} - TranslatorMessage Translator::find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const { diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index c51993d..a44d53c 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -113,9 +113,6 @@ public: bool save(const QString &filename, ConversionData &err, const QString &format /*= "auto"*/) const; bool release(QFile *iod, ConversionData &cd) const; - bool contains(const QString &context, const QString &sourceText, - const QString &comment) const; - TranslatorMessage find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const; -- cgit v0.12 From 1bf836526332626825c21e7e62305d2019c65701 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 14:23:19 +0100 Subject: improve ordered message insertion in a ts file, the top level categorization are the contexts, so it makes no sense to make messages adjoint by file when the context is different. a more clever algorithm which tries to order the entire contexts is conceivable. that would be advantageous for files which use multiple contexts subsequentially if each context appears in only one file. --- tools/linguist/shared/translator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index a35666d..8ff6719 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -136,7 +136,7 @@ void Translator::appendSorted(const TranslatorMessage &msg) int prevLine = 0; int curIdx = 0; foreach (const TranslatorMessage &mit, m_messages) { - bool sameFile = mit.fileName() == msg.fileName(); + bool sameFile = mit.fileName() == msg.fileName() && mit.context() == msg.context(); int curLine; if (sameFile && (curLine = mit.lineNumber()) >= prevLine) { if (msgLine >= prevLine && msgLine < curLine) { -- cgit v0.12 From d4f08b8f15607ac2859c079e94bf8d02a9b8380c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 22:14:16 +0100 Subject: eliminate TranslatorMessagePtr from the Translator api --- tools/linguist/lconvert/main.cpp | 4 +-- tools/linguist/linguist/messagemodel.cpp | 13 +++++---- tools/linguist/lrelease/main.cpp | 2 +- tools/linguist/shared/translator.cpp | 47 ++++++++++++++++++++++++------- tools/linguist/shared/translator.h | 7 +++-- tools/linguist/shared/translatormessage.h | 26 ----------------- 6 files changed, 51 insertions(+), 48 deletions(-) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 6f5f86a..7807761 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) qWarning() << qPrintable(cd.error()); return 2; } - Translator::reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); + tr.reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); for (int i = 1; i < inFiles.size(); ++i) { Translator tr2; @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) qWarning() << qPrintable(cd.error()); return 2; } - Translator::reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); + tr2.reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); for (int j = 0; j < tr2.messageCount(); ++j) tr.replaceSorted(tr2.message(j)); } diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index e6bb9af..8966624 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -209,19 +209,20 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent return false; } - QSet dupes = tor.resolveDuplicates(); - if (!dupes.isEmpty()) { + Translator::Duplicates dupes = tor.resolveDuplicates(); + if (!dupes.byContents.isEmpty()) { QString err = tr("Duplicate messages found in '%1':").arg(Qt::escape(fileName)); int numdups = 0; - foreach (const TranslatorMessagePtr &msg, dupes) { + foreach (int j, dupes.byContents) { + const TranslatorMessage &msg = tor.message(j); if (++numdups >= 5) { err += tr("

[more duplicates omitted]"); break; } err += tr("

* Context: %1
* Source: %2") - .arg(Qt::escape(msg->context()), Qt::escape(msg->sourceText())); - if (!msg->comment().isEmpty()) - err += tr("
* Comment: %3").arg(Qt::escape(msg->comment())); + .arg(Qt::escape(msg.context()), Qt::escape(msg.sourceText())); + if (!msg.comment().isEmpty()) + err += tr("
* Comment: %3").arg(Qt::escape(msg.comment())); } QMessageBox::warning(parent, QObject::tr("Qt Linguist"), err); } diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index ecaed27..742c2e6 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -105,7 +105,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo static bool releaseTranslator(Translator &tor, const QString &qmFileName, ConversionData &cd, bool removeIdentical) { - Translator::reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose()); + tor.reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose()); if (cd.isVerbose()) printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName)); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 8ff6719..5bdd133 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -411,9 +411,35 @@ void Translator::dropUiLines() } } -QSet Translator::resolveDuplicates() +struct TranslatorMessagePtr { + TranslatorMessagePtr(const TranslatorMessage &tm) + { + ptr = &tm; + } + + inline const TranslatorMessage *operator->() const + { + return ptr; + } + + const TranslatorMessage *ptr; +}; + +Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); + +inline int qHash(TranslatorMessagePtr tmp) +{ + return qHash(*tmp.ptr); +} + +inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) +{ + return *tmp1.ptr == *tmp2.ptr; +} + +Translator::Duplicates Translator::resolveDuplicates() { - QSet dups; + Duplicates dups; QHash refs; for (int i = 0; i < m_messages.count();) { const TranslatorMessage &msg = m_messages.at(i); @@ -426,7 +452,7 @@ QSet Translator::resolveDuplicates() omsg.setNonUtf8(true); } else { // Duplicate - dups.insert(omsg); + dups.byContents.insert(*it); } if (!omsg.isTranslated() && msg.isTranslated()) omsg.setTranslations(msg.translations()); @@ -439,21 +465,22 @@ QSet Translator::resolveDuplicates() return dups; } -void Translator::reportDuplicates(const QSet &dupes, +void Translator::reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose) { - if (!dupes.isEmpty()) { + if (!dupes.byContents.isEmpty()) { if (!verbose) { qWarning("Warning: dropping duplicate messages in '%s'\n(try -verbose for more info).", qPrintable(fileName)); } else { qWarning("Warning: dropping duplicate messages in '%s':", qPrintable(fileName)); - foreach (const TranslatorMessagePtr &msg, dupes) { + foreach (int j, dupes.byContents) { + const TranslatorMessage &msg = message(j); qWarning("\n* Context: %s\n* Source: %s", - qPrintable(msg->context()), - qPrintable(msg->sourceText())); - if (!msg->comment().isEmpty()) - qWarning("* Comment: %s", qPrintable(msg->comment())); + qPrintable(msg.context()), + qPrintable(msg.sourceText())); + if (!msg.comment().isEmpty()) + qWarning("* Comment: %s", qPrintable(msg.comment())); } qWarning(); } diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index a44d53c..654c6ab 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -132,9 +132,10 @@ public: void dropTranslations(); void dropUiLines(); void makeFileNamesAbsolute(const QDir &originalPath); - QSet resolveDuplicates(); - static void reportDuplicates(const QSet &dupes, - const QString &fileName, bool verbose); + + struct Duplicates { QSet byContents; }; + Duplicates resolveDuplicates(); + void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); QByteArray codecName() const { return m_codecName; } diff --git a/tools/linguist/shared/translatormessage.h b/tools/linguist/shared/translatormessage.h index fb3cc4b..2eb6e5e 100644 --- a/tools/linguist/shared/translatormessage.h +++ b/tools/linguist/shared/translatormessage.h @@ -178,32 +178,6 @@ Q_DECLARE_TYPEINFO(TranslatorMessage, Q_MOVABLE_TYPE); int qHash(const TranslatorMessage &msg); -struct TranslatorMessagePtr { - TranslatorMessagePtr(const TranslatorMessage &tm) - { - ptr = &tm; - } - - inline const TranslatorMessage *operator->() const - { - return ptr; - } - - const TranslatorMessage *ptr; -}; - -Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); - -inline int qHash(TranslatorMessagePtr tmp) -{ - return qHash(*tmp.ptr); -} - -inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) -{ - return *tmp1.ptr == *tmp2.ptr; -} - QT_END_NAMESPACE #endif // QT_NO_TRANSLATION -- cgit v0.12 From 44cc160733a70f5dc613faed2051005de7e48f04 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 22:04:57 +0100 Subject: kill TranslatorMessage::operator==() and qHash(TranslatorMessage) preparation work ... --- tools/linguist/lupdate/merge.cpp | 4 ++-- tools/linguist/shared/translator.cpp | 28 ++++++++++++++++++++++++---- tools/linguist/shared/translator.h | 1 + tools/linguist/shared/translatormessage.cpp | 19 ------------------- tools/linguist/shared/translatormessage.h | 4 ---- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index 6b8d4bb..13ba4ae 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -348,7 +348,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, m.setComment(mv.comment()); } else { TranslatorMessage mv; - int mvi = virginTor.messages().indexOf(m); + int mvi = virginTor.find(m); if (mvi < 0) { if (!(options & HeuristicSimilarText)) { makeObsolete: @@ -437,7 +437,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, if (tor.contains(mv.context())) continue; } else { - if (tor.messages().contains(mv)) + if (tor.find(mv) >= 0) continue; if (options & HeuristicSimilarText) { TranslatorMessage m = tor.find(mv.context(), mv.comment(), mv.allReferences()); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 5bdd133..0a59668 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -82,7 +82,7 @@ QList &Translator::registeredFileFormats() void Translator::replaceSorted(const TranslatorMessage &msg) { - int index = m_messages.indexOf(msg); + int index = find(msg); if (index == -1) appendSorted(msg); else @@ -91,7 +91,7 @@ void Translator::replaceSorted(const TranslatorMessage &msg) void Translator::extend(const TranslatorMessage &msg) { - int index = m_messages.indexOf(msg); + int index = find(msg); if (index == -1) { m_messages.append(msg); } else { @@ -302,6 +302,18 @@ bool Translator::release(QFile *iod, ConversionData &cd) const return false; } +int Translator::find(const TranslatorMessage &msg) const +{ + for (int i = 0; i < m_messages.count(); ++i) { + const TranslatorMessage &tmsg = m_messages.at(i); + if (msg.context() == tmsg.context() + && msg.sourceText() == tmsg.sourceText() + && msg.comment() == tmsg.comment()) + return i; + } + return -1; +} + TranslatorMessage Translator::find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const { @@ -429,12 +441,20 @@ Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); inline int qHash(TranslatorMessagePtr tmp) { - return qHash(*tmp.ptr); + return + qHash(tmp->context()) ^ + qHash(tmp->sourceText()) ^ + qHash(tmp->comment()) ^ + qHash(tmp->id()); } inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) { - return *tmp1.ptr == *tmp2.ptr; + // Special treatment for context comments (empty source). + return (tmp1->context() == tmp2->context()) + && tmp1->sourceText() == tmp2->sourceText() + && tmp1->id() == tmp2->id() + && (tmp1->sourceText().isEmpty() || tmp1->comment() == tmp2->comment()); } Translator::Duplicates Translator::resolveDuplicates() diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 654c6ab..b957fa2 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -113,6 +113,7 @@ public: bool save(const QString &filename, ConversionData &err, const QString &format /*= "auto"*/) const; bool release(QFile *iod, ConversionData &cd) const; + int find(const TranslatorMessage &msg) const; TranslatorMessage find(const QString &context, const QString &comment, const TranslatorMessage::References &refs) const; diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp index 876b129..5151ebd 100644 --- a/tools/linguist/shared/translatormessage.cpp +++ b/tools/linguist/shared/translatormessage.cpp @@ -143,25 +143,6 @@ bool TranslatorMessage::needs8Bit() const } -bool TranslatorMessage::operator==(const TranslatorMessage& m) const -{ - // Special treatment for context comments (empty source). - return (m_context == m.m_context) - && m_sourcetext == m.m_sourcetext - && m_id == m.m_id - && (m_sourcetext.isEmpty() || m_comment == m.m_comment); -} - - -int qHash(const TranslatorMessage &msg) -{ - return - qHash(msg.context()) ^ - qHash(msg.sourceText()) ^ - qHash(msg.comment()) ^ - qHash(msg.id()); -} - bool TranslatorMessage::hasExtra(const QString &key) const { return m_extra.contains(key); diff --git a/tools/linguist/shared/translatormessage.h b/tools/linguist/shared/translatormessage.h index 2eb6e5e..60b60c5 100644 --- a/tools/linguist/shared/translatormessage.h +++ b/tools/linguist/shared/translatormessage.h @@ -109,8 +109,6 @@ public: return false; } - bool operator==(const TranslatorMessage& m) const; - QString fileName() const { return m_fileName; } void setFileName(const QString &fileName) { m_fileName = fileName; } int lineNumber() const { return m_lineNumber; } @@ -176,8 +174,6 @@ private: Q_DECLARE_TYPEINFO(TranslatorMessage, Q_MOVABLE_TYPE); -int qHash(const TranslatorMessage &msg); - QT_END_NAMESPACE #endif // QT_NO_TRANSLATION -- cgit v0.12 From a66698f947e8ded2e020defa626b154aca1fde9f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 6 Nov 2009 22:40:23 +0100 Subject: handle messages with ids (more) correctly when comparing two messages which both have ids, compare only the ids. this affects finding/reporting duplicates and merging. --- .../lupdate/testdata/good/mergecpp/finddialog.cpp | 13 +- .../testdata/good/mergecpp/project.ts.before | 18 +++ .../testdata/good/mergecpp/project.ts.result | 19 +++ .../good/mergecpp_noobsolete/finddialog.cpp | 3 + .../good/mergecpp_noobsolete/project.ts.before | 13 ++ .../good/mergecpp_noobsolete/project.ts.result | 8 ++ .../testdata/good/mergecpp_obsolete/finddialog.cpp | 3 + .../good/mergecpp_obsolete/project.ts.before | 13 ++ .../good/mergecpp_obsolete/project.ts.result | 12 ++ tools/linguist/linguist/messagemodel.cpp | 10 +- tools/linguist/lupdate/merge.cpp | 44 ++++--- tools/linguist/shared/translator.cpp | 134 +++++++++++++++------ tools/linguist/shared/translator.h | 2 +- 13 files changed, 239 insertions(+), 53 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp index 53eba32..f27e1f0 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp @@ -63,5 +63,16 @@ void FindDialog::reset() { tr("%n item(s)", "merge from singular to plural form", 4); tr("%n item(s)", "merge from a finished singular form to an unfinished plural form", 4); -} + + + //% "Hello" + qtTrId("xx_hello"); + + //% "New world" + qtTrId("xx_world"); + + + //= new_id + tr("this is just some text"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before index d06252c..ad2f65f 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before @@ -1,6 +1,19 @@ + + + + Hello + Hallo + + + + World + Welt + + + FindDialog @@ -44,5 +57,10 @@ + + + this is just some text + Unfertige Uebersetzung + diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result index be4e02e..e9abf89 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result @@ -2,6 +2,20 @@ + + + + Hello + Hallo + + + + New world + World + Welt + + + FindDialog @@ -45,5 +59,10 @@ + + + this is just some text + Unfertige Uebersetzung + diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp index e1464a2..9abb367 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp @@ -148,4 +148,7 @@ void FindDialog::doFind(bool forward) bool FindDialog::hasFindExpression() const { // statusMessage(tr( "Should be obsolete" )); + + //% "This is some random text" + qtTrId("keep_id") } diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before index 834f512..feab169 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before @@ -1,6 +1,19 @@ + + + + This is some random text + + + + + Should be obsolete, too + SHOULD BE OBSOLETE AS WELL + + + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result index b328e90..ee3d0f6 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result @@ -2,6 +2,14 @@ + + + + This is some random text + + + + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp index 7b28c75..cc3af48 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp @@ -150,6 +150,9 @@ void FindDialog::doFind(bool forward) bool FindDialog::hasFindExpression() const { + //% "This is some random text" + qtTrId("keep_id") + return !findExpr.isEmpty(); } diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before index 1fa0fd3..2bc6049 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before @@ -1,6 +1,19 @@ + + + + This is some random text + + + + + Should be obsolete, too + SHOULD BE OBSOLETE AS WELL + + + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result index cfd11b1..f442cbc 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result @@ -2,6 +2,18 @@ + + + + This is some random text + + + + Should be obsolete, too + SHOULD BE OBSOLETE AS WELL + + + FindDialog Enter the text you are looking for. diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 8966624..024fd91 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -210,9 +210,16 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent } Translator::Duplicates dupes = tor.resolveDuplicates(); - if (!dupes.byContents.isEmpty()) { + if (!dupes.byId.isEmpty() || !dupes.byContents.isEmpty()) { QString err = tr("Duplicate messages found in '%1':").arg(Qt::escape(fileName)); int numdups = 0; + foreach (int i, dupes.byId) { + if (++numdups >= 5) { + err += tr("

[more duplicates omitted]"); + goto doWarn; + } + err += tr("

* ID: %1").arg(Qt::escape(tor.message(i).id())); + } foreach (int j, dupes.byContents) { const TranslatorMessage &msg = tor.message(j); if (++numdups >= 5) { @@ -224,6 +231,7 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent if (!msg.comment().isEmpty()) err += tr("
* Comment: %3").arg(Qt::escape(msg.comment())); } + doWarn: QMessageBox::warning(parent, QObject::tr("Qt Linguist"), err); } diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index 13ba4ae..a721439 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -375,6 +375,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, ++similarTextHeuristicCount; neww++; + outdateSource: m.setOldSourceText(m.sourceText()); m.setSourceText(mv.sourceText()); const QString &oldpluralsource = m.extra(QLatin1String("po-msgid_plural")); @@ -392,23 +393,35 @@ Translator merge(const Translator &tor, const Translator &virginTor, } } else { mv = virginTor.message(mvi); - switch (m.type()) { - case TranslatorMessage::Finished: - default: - if (m.isPlural() == mv.isPlural()) { - newType = TranslatorMessage::Finished; - } else { - newType = TranslatorMessage::Unfinished; - } + if (!mv.id().isEmpty() + && (mv.context() != m.context() + || mv.sourceText() != m.sourceText() + || mv.comment() != m.comment())) { known++; - break; - case TranslatorMessage::Unfinished: newType = TranslatorMessage::Unfinished; - known++; - break; - case TranslatorMessage::Obsolete: - newType = TranslatorMessage::Unfinished; - neww++; + m.setContext(mv.context()); + m.setComment(mv.comment()); + if (mv.sourceText() != m.sourceText()) + goto outdateSource; + } else { + switch (m.type()) { + case TranslatorMessage::Finished: + default: + if (m.isPlural() == mv.isPlural()) { + newType = TranslatorMessage::Finished; + } else { + newType = TranslatorMessage::Unfinished; + } + known++; + break; + case TranslatorMessage::Unfinished: + newType = TranslatorMessage::Unfinished; + known++; + break; + case TranslatorMessage::Obsolete: + newType = TranslatorMessage::Unfinished; + neww++; + } } // Always get the filename and linenumber info from the @@ -421,6 +434,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, m.setPlural(mv.isPlural()); m.setUtf8(mv.isUtf8()); m.setExtraComment(mv.extraComment()); + m.setId(mv.id()); } } diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 0a59668..77faabd 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -306,10 +306,15 @@ int Translator::find(const TranslatorMessage &msg) const { for (int i = 0; i < m_messages.count(); ++i) { const TranslatorMessage &tmsg = m_messages.at(i); - if (msg.context() == tmsg.context() - && msg.sourceText() == tmsg.sourceText() - && msg.comment() == tmsg.comment()) - return i; + if (msg.id().isEmpty() || tmsg.id().isEmpty()) { + if (msg.context() == tmsg.context() + && msg.sourceText() == tmsg.sourceText() + && msg.comment() == tmsg.comment()) + return i; + } else { + if (msg.id() == tmsg.id()) + return i; + } } return -1; } @@ -423,8 +428,34 @@ void Translator::dropUiLines() } } -struct TranslatorMessagePtr { - TranslatorMessagePtr(const TranslatorMessage &tm) +struct TranslatorMessageIdPtr { + explicit TranslatorMessageIdPtr(const TranslatorMessage &tm) + { + ptr = &tm; + } + + inline const TranslatorMessage *operator->() const + { + return ptr; + } + + const TranslatorMessage *ptr; +}; + +Q_DECLARE_TYPEINFO(TranslatorMessageIdPtr, Q_MOVABLE_TYPE); + +inline int qHash(TranslatorMessageIdPtr tmp) +{ + return qHash(tmp->id()); +} + +inline bool operator==(TranslatorMessageIdPtr tmp1, TranslatorMessageIdPtr tmp2) +{ + return tmp1->id() == tmp2->id(); +} + +struct TranslatorMessageContentPtr { + explicit TranslatorMessageContentPtr(const TranslatorMessage &tm) { ptr = &tm; } @@ -437,50 +468,81 @@ struct TranslatorMessagePtr { const TranslatorMessage *ptr; }; -Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(TranslatorMessageContentPtr, Q_MOVABLE_TYPE); -inline int qHash(TranslatorMessagePtr tmp) +inline int qHash(TranslatorMessageContentPtr tmp) { - return - qHash(tmp->context()) ^ - qHash(tmp->sourceText()) ^ - qHash(tmp->comment()) ^ - qHash(tmp->id()); + int hash = qHash(tmp->context()) ^ qHash(tmp->sourceText()); + if (!tmp->sourceText().isEmpty()) + // Special treatment for context comments (empty source). + hash ^= qHash(tmp->comment()); + return hash; } -inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) +inline bool operator==(TranslatorMessageContentPtr tmp1, TranslatorMessageContentPtr tmp2) { + if (tmp1->context() != tmp2->context() || tmp1->sourceText() != tmp2->sourceText()) + return false; // Special treatment for context comments (empty source). - return (tmp1->context() == tmp2->context()) - && tmp1->sourceText() == tmp2->sourceText() - && tmp1->id() == tmp2->id() - && (tmp1->sourceText().isEmpty() || tmp1->comment() == tmp2->comment()); + if (tmp1->sourceText().isEmpty()) + return true; + return tmp1->comment() == tmp2->comment(); } Translator::Duplicates Translator::resolveDuplicates() { Duplicates dups; - QHash refs; + QHash idRefs; + QHash contentRefs; for (int i = 0; i < m_messages.count();) { const TranslatorMessage &msg = m_messages.at(i); - QHash::ConstIterator it = refs.constFind(msg); - if (it != refs.constEnd()) { - TranslatorMessage &omsg = m_messages[*it]; - if (omsg.isUtf8() != msg.isUtf8() && !omsg.isNonUtf8()) { - // Dual-encoded message - omsg.setUtf8(true); - omsg.setNonUtf8(true); - } else { - // Duplicate - dups.byContents.insert(*it); + TranslatorMessage *omsg; + int oi; + QSet *pDup; + if (!msg.id().isEmpty()) { + QHash::ConstIterator it = + idRefs.constFind(TranslatorMessageIdPtr(msg)); + if (it != idRefs.constEnd()) { + oi = *it; + omsg = &m_messages[oi]; + pDup = &dups.byId; + goto gotDupe; + } + } + { + QHash::ConstIterator it = + contentRefs.constFind(TranslatorMessageContentPtr(msg)); + if (it != contentRefs.constEnd()) { + oi = *it; + omsg = &m_messages[oi]; + if (msg.id().isEmpty() || omsg->id().isEmpty()) { + if (!msg.id().isEmpty() && omsg->id().isEmpty()) { + omsg->setId(msg.id()); + idRefs[TranslatorMessageIdPtr(*omsg)] = oi; + } + pDup = &dups.byContents; + goto gotDupe; + } + // This is really a content dupe, but with two distinct IDs. } - if (!omsg.isTranslated() && msg.isTranslated()) - omsg.setTranslations(msg.translations()); - m_messages.removeAt(i); + } + if (!msg.id().isEmpty()) + idRefs[TranslatorMessageIdPtr(msg)] = i; + contentRefs[TranslatorMessageContentPtr(msg)] = i; + ++i; + continue; + gotDupe: + if (omsg->isUtf8() != msg.isUtf8() && !omsg->isNonUtf8()) { + // Dual-encoded message + omsg->setUtf8(true); + omsg->setNonUtf8(true); } else { - refs[msg] = i; - ++i; + // Duplicate + pDup->insert(oi); } + if (!omsg->isTranslated() && msg.isTranslated()) + omsg->setTranslations(msg.translations()); + m_messages.removeAt(i); } return dups; } @@ -488,12 +550,14 @@ Translator::Duplicates Translator::resolveDuplicates() void Translator::reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose) { - if (!dupes.byContents.isEmpty()) { + if (!dupes.byId.isEmpty() || !dupes.byContents.isEmpty()) { if (!verbose) { qWarning("Warning: dropping duplicate messages in '%s'\n(try -verbose for more info).", qPrintable(fileName)); } else { qWarning("Warning: dropping duplicate messages in '%s':", qPrintable(fileName)); + foreach (int i, dupes.byId) + qWarning("\n* ID: %s", qPrintable(message(i).id())); foreach (int j, dupes.byContents) { const TranslatorMessage &msg = message(j); qWarning("\n* Context: %s\n* Source: %s", diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index b957fa2..eec704a 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -134,7 +134,7 @@ public: void dropUiLines(); void makeFileNamesAbsolute(const QDir &originalPath); - struct Duplicates { QSet byContents; }; + struct Duplicates { QSet byId, byContents; }; Duplicates resolveDuplicates(); void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); -- cgit v0.12 From 0a1db39ba70060f305e5694d1a12dd3c2e5bca4c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Nov 2009 15:19:02 +0100 Subject: record id-based messages even if they have an empty source this makes sense if one uses lupdate only for validation purposes, i.e. to find out if the code uses only ids which are defined in some external specification. --- .../lupdate/testdata/good/mergecpp/finddialog.cpp | 4 ++++ .../testdata/good/mergecpp/project.ts.before | 4 ++++ .../testdata/good/mergecpp/project.ts.result | 6 +++++ .../lupdate/testdata/good/parsecpp/main.cpp | 5 +++++ .../testdata/good/parsecpp/project.ts.result | 6 +++++ tools/linguist/lupdate/cpp.cpp | 26 +++++++++------------- tools/linguist/lupdate/merge.cpp | 6 ++--- tools/linguist/shared/translator.cpp | 4 ++-- 8 files changed, 41 insertions(+), 20 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp index f27e1f0..5bd7a0a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp @@ -75,4 +75,8 @@ void FindDialog::reset() //= new_id tr("this is just some text"); + + + //: A message without source string + qtTrId("qtn_virtual"); } diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before index ad2f65f..379cce4 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before @@ -12,6 +12,10 @@ World Welt + + + A message without source string + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result index e9abf89..de43266 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result @@ -14,6 +14,12 @@ World Welt + + + + A message without source string + + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index e243e66..386d9b7 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -247,3 +247,8 @@ class YetAnotherTest : QObject { tr("nothing"); } }; + + + +//: This is a message without a source string +QString test = qtTrId("yet_another_id"); diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 26e5a65..6d50c21 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -18,6 +18,12 @@ backslashed \ stuff. thing + + + + This is a message without a source string + + Dialog2 diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index fb95a95..443abd0 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1883,22 +1883,18 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) case Tok_trid: if (!tor) goto case_default; - if (sourcetext.isEmpty()) { - yyTok = getToken(); - } else { - if (!msgid.isEmpty()) - qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n", - qPrintable(yyFileName), yyLineNo); - //utf8 = false; // Maybe use //%% or something like that - line = yyLineNo; - yyTok = getToken(); - if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) { - bool plural = match(Tok_Comma); - recordMessage(line, QString(), sourcetext, QString(), extracomment, - msgid, extra, false, plural); - } - sourcetext.clear(); + if (!msgid.isEmpty()) + qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n", + qPrintable(yyFileName), yyLineNo); + //utf8 = false; // Maybe use //%% or something like that + line = yyLineNo; + yyTok = getToken(); + if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) { + bool plural = match(Tok_Comma); + recordMessage(line, QString(), sourcetext, QString(), extracomment, + msgid, extra, false, plural); } + sourcetext.clear(); extracomment.clear(); msgid.clear(); extra.clear(); diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp index a721439..fa0dd3d 100644 --- a/tools/linguist/lupdate/merge.cpp +++ b/tools/linguist/lupdate/merge.cpp @@ -341,7 +341,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, foreach (TranslatorMessage m, tor.messages()) { TranslatorMessage::Type newType = TranslatorMessage::Finished; - if (m.sourceText().isEmpty()) { + if (m.sourceText().isEmpty() && m.id().isEmpty()) { // context/file comment TranslatorMessage mv = virginTor.find(m.context()); if (!mv.isNull()) @@ -447,7 +447,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, vernacular translator. */ foreach (const TranslatorMessage &mv, virginTor.messages()) { - if (mv.sourceText().isEmpty()) { + if (mv.sourceText().isEmpty() && mv.id().isEmpty()) { if (tor.contains(mv.context())) continue; } else { @@ -465,7 +465,7 @@ Translator merge(const Translator &tor, const Translator &virginTor, outTor.append(mv); else outTor.appendSorted(mv); - if (!mv.sourceText().isEmpty()) + if (!mv.sourceText().isEmpty() || !mv.id().isEmpty()) ++neww; } diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 77faabd..bc27daf 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -337,7 +337,7 @@ TranslatorMessage Translator::find(const QString &context, bool Translator::contains(const QString &context) const { foreach (const TranslatorMessage &msg, m_messages) - if (msg.context() == context && msg.sourceText().isEmpty()) + if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty()) return true; return false; } @@ -345,7 +345,7 @@ bool Translator::contains(const QString &context) const TranslatorMessage Translator::find(const QString &context) const { foreach (const TranslatorMessage &msg, m_messages) - if (msg.context() == context && msg.sourceText().isEmpty()) + if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty()) return msg; return TranslatorMessage(); } -- cgit v0.12 From f55c317e377aaf0b3e24904e88dc1c4a6e15a20a Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Mon, 9 Nov 2009 14:26:02 +1000 Subject: Fixed runtime error in QAudioInput::bytesReady() function If bytesReady() was called before start(), Div by Zero. Added check for this condition. Task-number:QTBUG-5300 Reviewed-by:Justin McPherson --- src/multimedia/audio/qaudioinput_win32_p.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 31f6e25..b7f9ffd 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -333,6 +333,9 @@ void QAudioInputPrivate::close() int QAudioInputPrivate::bytesReady() const { + if(period_size == 0 || buffer_size == 0) + return 0; + int buf = ((buffer_size/period_size)-waveFreeBlockCount)*period_size; if(buf < 0) buf = 0; -- cgit v0.12 From 8437faaadab1d7bf8861e1d6575f4e1bff04b005 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 6 Nov 2009 15:59:55 +1000 Subject: Crash on bug QTBUG-5493 --- tests/auto/qpainter/tst_qpainter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 4d2c626..02c73c0 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -101,6 +101,8 @@ private slots: void saveAndRestore_data(); void saveAndRestore(); + void drawBorderPixmap(); + void drawLine_data(); void drawLine(); void drawLine_clipped(); @@ -973,6 +975,18 @@ void tst_QPainter::initFrom() delete widget; } +void tst_QPainter::drawBorderPixmap() +{ + QPixmap src(79,79); + src.fill(Qt::transparent); + + QImage pm(200,200,QImage::Format_RGB32); + QPainter p(&pm); + p.setTransform(QTransform(-1,0,0,-1,173.5,153.5)); + qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39), + QTileRules(Qt::StretchTile,Qt::StretchTile), 0); +} + void tst_QPainter::drawLine_data() { QTest::addColumn("line"); -- cgit v0.12 From bbbdf511be4afdb08d2a4d7c365a84adde7ae324 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 9 Nov 2009 18:10:23 +1000 Subject: More inDestructor checks. Declarative tripped these (crashes). Reviewed-by:Aaron Kennedy --- src/gui/graphicsview/qgraphicsitem.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index a236b14..723e496 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3349,6 +3349,9 @@ QPointF QGraphicsItem::pos() const */ void QGraphicsItem::setX(qreal x) { + if (d_ptr->inDestructor) + return; + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); } @@ -3370,6 +3373,9 @@ void QGraphicsItem::setX(qreal x) */ void QGraphicsItem::setY(qreal y) { + if (d_ptr->inDestructor) + return; + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); } @@ -3435,6 +3441,9 @@ void QGraphicsItem::setPos(const QPointF &pos) if (d_ptr->pos == pos) return; + if (d_ptr->inDestructor) + return; + // Update and repositition. if (!(d_ptr->flags & ItemSendsGeometryChanges)) { d_ptr->setPosHelper(pos); -- cgit v0.12 From b0ea2ae80f473d1698f518ed6324a8d328e8c67f Mon Sep 17 00:00:00 2001 From: jasplin Date: Mon, 9 Nov 2009 09:59:33 +0100 Subject: My changes. --- dist/changes-4.6.0 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 8d1ae19..d301186 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -37,6 +37,8 @@ information about a particular change. - Add 800x480 screen mode to qvfb configuration dialog. + - Improved support for input methods in graphics view. + Third party components ---------------------- @@ -114,6 +116,7 @@ QtGui * Introduced activation support. * Introduced QGraphicsItem::stackBefore() * Cached items are now always invalidated when update() is called. + * Added input hints. - QGraphicsLayout * Introduced QGraphicsLayout::addChildLayoutItem() @@ -149,6 +152,7 @@ QtGui - QGraphicsWidget * Now inherits from QGraphicsObject instead * Interactive resizing of top level windows now respects height-for-width constraints. + * Reduced memory footprint. - QHeaderView * [208320] Make sure the sort indicator s taken into account for the size hint @@ -164,6 +168,9 @@ QtGui - QColumnView * [246999] Fixed view not updating when the model is changed dynamically + - QLineEdit + * [248948] Clear selection when redoing a delete operation. + - QListView * [243335] Fixed the visualRect to return correct values when the widget is not yet show @@ -203,6 +210,7 @@ QtGui - QSpinBox * [259226] Fixed setting a stylesheet on a QSpinBox to change the arrow possition + * [255051] Fixed sizeHint update bug. - QStandardItemModel * [255652] Fixed crash while using takeRow with a QSortFilterProxyModel @@ -236,6 +244,10 @@ QtGui * New qt_paint_device_metric() function to replace the friend declarations for window surface classes that need to access metric(). + - QPushButton + * [255581] Fixed sizeHint recalculation bug. + + QtOpenGL - QGLFormat -- cgit v0.12 From 8d6870b2b2a1b58d0b0a11d8863e6981c0b62b1c Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 9 Nov 2009 11:14:59 +0100 Subject: Updated change log --- dist/changes-4.6.0 | 162 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 71 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index d301186..eadc5c9 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -247,6 +247,8 @@ QtGui - QPushButton * [255581] Fixed sizeHint recalculation bug. + - QApplication + * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). QtOpenGL @@ -285,66 +287,8 @@ QtOpenGL - Added community supported Qt ports for QNX and VxWorks. See platform notes in the Qt documentation for details. - - Significant external contribution from Milan Burda for planned removal - of (non-unicode) Windows 9x/ME support. - - - QRegion is no longer a GDI object by default. This means it is no - longer subject to gui-thread only nor does it potentially impact - the 10.000 GDI object limit per process. By explicitly calling - .handle() a GDI object will be created and memory managed by - QRegion. The native handle is for reading out only. Any GDI calls - made on the HRGN handle will not affect the QRegion. - - - [259221] QFileInfo::symLinkTarget() now supports NTFS symbolic links - thanks to Konstantin Ritt (merge request 1217). - - - The reading code of QLocalSocket on Windows has been rewritten to improve - reading performance. - - - On Windows CE the link time code geration has been disabled by default to - be consistent with win32-msvc200x. - - - The default button size has been reduced in the Windows mobile style. - - - [QTBUG-3613] QWizard issues have been fixed on Windows mobile. - - - [254673] Restoring minimzed widgets fixed for Windows mobile and - Windows CE. - - - [255242] Seeking within large files (bigger than 0x80000000 bytes) fixed - on Windows CE. - - - [257352] When configuring Qt for Windows CE, configure points the user to - setcepaths, when its done. - - - [259850] Added a makespec template for Windows CE 6. - - - Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and - QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES - specific libraries. - - - Compilation fixes for OpenGL/ES 1.0 and OpenGL/ES 1.1 Common Lite. - - - EGL and OpenGL/ES - * Protect the use of version-specific EGL symbols with #ifdef's. - * Make sure an EGL context is current when resolving GL extensions. - * Introduce "lazyDoneCurrent" for optimizing context switching in - paint engines. - * Separate EGLSurface from QEglContext so that the same context can - be used with multiple surfaces. - * Move common functions from system-specific files to qgl_egl.cpp. - * Fix a memory leak of EGLSurface's in QGLContext. - * Fix detection of pbuffers on OpenGL/ES systems. - * EGL_SAMPLES was being set to the wrong value for multisampled surfaces. - - - PowerVR - * Make the code better at detecting MBX vs SGX header files. - * Fix 32-bit screen support - some code was still assuming 16-bit. - * Stop GL window surfaces double-flushing their contents. - * Remove surface holder, which never worked all that well. - * Implement screen rotations. - - - Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. +Qt for Linux/X11 +---------------- - KDE Integration: Improved the integration into KDE desktop (loading of KDE palette, usage of KColorDialog and KFileDialog) using the GuiPlatformPlugin @@ -352,9 +296,6 @@ QtOpenGL - Fixed pasting the clipboard content to non-Qt application on X11 when the requested format is image/ppm. Patch by Ritt.K - - On Windows when a file cannot be accessed (stat()ed), we are now restoring - the error mode to the original value. - - On X11 Qt now supports the _NET_WM_SYNC protocol. - On X11 Qt now supports the SAVE_TARGET protocol that allows to keep @@ -363,14 +304,55 @@ QtOpenGL - [QTBUG-4652] On X11 clipboard content can be properly retrieved even when an application asks the unsupported target. This fixes copying and pasting data when using Synergy. + - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. + - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. - - [QTBUG-4418] Fixed maximizing and restoring a window on Mac. +Qt for Windows +-------------- - - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. + - Significant external contribution from Milan Burda for planned removal + of (non-unicode) Windows 9x/ME support. - - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. + - QRegion is no longer a GDI object by default. This means it is no + longer subject to gui-thread only nor does it potentially impact + the 10.000 GDI object limit per process. By explicitly calling + .handle() a GDI object will be created and memory managed by + QRegion. The native handle is for reading out only. Any GDI calls + made on the HRGN handle will not affect the QRegion. + + - The reading code of QLocalSocket on Windows has been rewritten to improve + reading performance. + + - On Windows when a file cannot be accessed (stat()ed), we are now restoring + the error mode to the original value. + + - [259221] QFileInfo::symLinkTarget() now supports NTFS symbolic links + thanks to Konstantin Ritt (merge request 1217). + - [251554] Fixed openUrl("mailto:") with Thunderbird on Windows. + - [254501] QDestopServices now supports cyrillic file names. + - Fixed an issue which prevents moving fixed size windows using titlebar. + - [258087] Fixed an issue on Vista which returns incorrect file paths when using + QFileDialog::getOpenFileNames() + - [253763] Fixed a focus issue when using out-of-process ActiveQt controls. + - [255912] Mouse move events will not be delivered to a blocked widget. + - [225588] Enabled IME reconversion support. + + - Phonon on Windows + * Now much more reliable when reading a file through a QIODevice. + * If Video Mixing Renderer 9 is not available, falls back to software + rendering. + * Fixed a flicker issue when switching source with a transition time of 0 + +Qt for Mac OS X +--------------- - Add support for GetURL events on Mac OS X + - [123740] Fixed an issue with dead keys on Mac (cocoa) on French keyboard layout. + - [252088] Drag Leave events will be delivered correctly on Cocoa. + - [257661] Cocoa now uses the correct line ending for clipboard plain text. + - [258438] Enabled Emacs style keyboard shortcuts. + - [258173] Fixed an issue which caused "whatsthis" pointer to flicked on Cocoa. + - [QTBUG-4418] Fixed maximizing and restoring a window on Mac. General changes on Mac OS X: - Mac OS X version support: Support for 10.3(Panther) has been dropped, support for @@ -387,11 +369,49 @@ General changes on Mac OS X: - Building for ppc64 is no longer supported by the gcc tool chain. - Building for ppc is still supported. - - Phonon on Windows - * Now much more reliable when reading a file through a QIODevice. - * If Video Mixing Renderer 9 is not available, falls back to software - rendering. - * Fixed a flicker issue when switching source with a transition time of 0 +Qt for Embedded Linux +--------------------- + +- Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and + QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES + specific libraries. + +- Compilation fixes for OpenGL/ES 1.0 and OpenGL/ES 1.1 Common Lite. + +- EGL and OpenGL/ES + * Protect the use of version-specific EGL symbols with #ifdef's. + * Make sure an EGL context is current when resolving GL extensions. + * Introduce "lazyDoneCurrent" for optimizing context switching in + paint engines. + * Separate EGLSurface from QEglContext so that the same context can + be used with multiple surfaces. + * Move common functions from system-specific files to qgl_egl.cpp. + * Fix a memory leak of EGLSurface's in QGLContext. + * Fix detection of pbuffers on OpenGL/ES systems. + * EGL_SAMPLES was being set to the wrong value for multisampled surfaces. + +- PowerVR + * Make the code better at detecting MBX vs SGX header files. + * Fix 32-bit screen support - some code was still assuming 16-bit. + * Stop GL window surfaces double-flushing their contents. + * Remove surface holder, which never worked all that well. + * Implement screen rotations. + +- Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. + +Qt for Windows CE +----------------- + - On Windows CE the link time code generation has been disabled by default to + be consistent with win32-msvc200x. + - The default button size has been reduced in the Windows mobile style. + - [QTBUG-3613] QWizard issues have been fixed on Windows mobile. + - [254673] Restoring minimized widgets fixed for Windows mobile and + Windows CE. + - [255242] Seeking within large files (bigger than 0x80000000 bytes) fixed + on Windows CE. + - [257352] When configuring Qt for Windows CE, configure points the user to + setcepaths, when its done. + - [259850] Added a makespec template for Windows CE 6. **************************************************************************** * Tools * -- cgit v0.12 From fa7f6e542b8381dd3af525507cd6e0a3ee43b813 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Nov 2009 11:20:06 +0100 Subject: Doc: typo fixed Reviewed-by: TrustMe --- src/gui/kernel/qaction.cpp | 2 +- src/gui/kernel/qwidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 5f5650f..6f3cbaf 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -286,7 +286,7 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Actions with a softkey role defined are only visible in the softkey bar when the widget containing the action has focus. If no widget currently has focus, the softkey framework will traverse up the - widget parent heirarchy looking for a widget containing softkey actions. + widget parent hierarchy looking for a widget containing softkey actions. */ /*! diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 271b939..f856b13 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -900,7 +900,7 @@ void QWidget::setAutoFillBackground(bool enabled) passing a \c QAction with a softkey role set on it. When the widget containing the softkey actions has focus, its softkeys should appear in the user interface. Softkeys are discovered by traversing the widget - heirarchy so it is possible to define a single set of softkeys that are + hierarchy so it is possible to define a single set of softkeys that are present at all times by calling addAction() for a given top level widget. On some platforms, this concept overlaps with \c QMenuBar such that if no -- cgit v0.12 From 0fa5e302d2a4b7b79342f58905812f8ef3bd54b1 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 9 Nov 2009 11:43:34 +0100 Subject: Assistant: Fix bugs related to setting the current filter remotely. 1. Filter combo box now gets updated on remote setCurrentFilter. 2. Argument to remote setCurrentFilter now gets checked. If there is no such filter, we reject it. --- tools/assistant/tools/assistant/mainwindow.cpp | 21 +++++++++++---------- tools/assistant/tools/assistant/mainwindow.h | 1 + tools/assistant/tools/assistant/remotecontrol.cpp | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index de3f695..c56e7e4 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -227,16 +227,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); - m_helpEngine->setCurrentFilter(curFilter); - if (m_filterCombo) { - int idx = m_filterCombo->findText(curFilter); - if (idx >= 0) { - bool blocked = m_filterCombo->signalsBlocked(); - m_filterCombo->blockSignals(true); - m_filterCombo->setCurrentIndex(idx); - m_filterCombo->blockSignals(blocked); - } - } + if (m_helpEngine->customFilters().contains(curFilter)) + m_helpEngine->setCurrentFilter(curFilter); } if (usesDefaultCollection()) @@ -664,6 +656,8 @@ void MainWindow::setupFilterToolbar() SLOT(setupFilterCombo())); connect(m_filterCombo, SIGNAL(activated(QString)), this, SLOT(filterDocumentation(QString))); + connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, + SLOT(currentFilterChanged(QString))); setupFilterCombo(); } @@ -1041,4 +1035,11 @@ QString MainWindow::defaultHelpCollectionFileName() arg(QLatin1String(QT_VERSION_STR)); } +void MainWindow::currentFilterChanged(const QString &filter) +{ + const int index = m_filterCombo->findText(filter); + Q_ASSERT(index != -1); + m_filterCombo->setCurrentIndex(index); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 6b858e9..7559fe4 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -95,6 +95,7 @@ public slots: void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); + void currentFilterChanged(const QString &filter); private slots: void insertLastPages(); diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index be1c197..474a681 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -237,6 +237,8 @@ void RemoteControl::handleCommandString(const QString &cmdString) else m_mainWindow->expandTOC(depth); } else if (cmd == QLatin1String("setcurrentfilter")) { + if (!m_helpEngine->customFilters().contains(arg)) + return; if (m_caching) { clearCache(); m_currentFilter = arg; -- cgit v0.12 From 46a9b3e8e627b63b6d2ffe89311c00b2a1a5434d Mon Sep 17 00:00:00 2001 From: kh1 Date: Fri, 6 Nov 2009 12:15:14 +0100 Subject: Fix some warnings. Reviewed-by: ck --- tools/assistant/tools/assistant/helpviewer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index c888a5f..3547652 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -133,10 +133,9 @@ HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine, { } -QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op, - const QNetworkRequest &request, QIODevice *outgoingData) +QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, + const QNetworkRequest &request, QIODevice* /*outgoingData*/) { - const QString& scheme = request.url().scheme(); const QUrl& url = request.url(); QString mimeType = url.toString(); if (mimeType.endsWith(QLatin1String(".svg")) -- cgit v0.12 From b183a1d916b42e174da1d4ee71d387b6b8c48f72 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 9 Nov 2009 11:50:10 +0100 Subject: Fix Assistant losing font settings across invocations. Task-number: QTBUG-5333 Reviewed-by: ck --- tools/assistant/tools/assistant/centralwidget.cpp | 120 +++++++++++----------- tools/assistant/tools/assistant/centralwidget.h | 9 +- 2 files changed, 67 insertions(+), 62 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 62b4736..67d803d 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -666,34 +666,16 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) tabWidget->setCurrentIndex(tabWidget->addTab(viewer, quoteTabTitle(viewer->documentTitle()))); - QFont font = qApp->font(); - bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool(); - if (userFont) { - font = qVariantValue(helpEngine->customValue( - QLatin1String("browserFont"))); - } - -#if !defined(QT_NO_WEBKIT) - QWebSettings *settings = QWebSettings::globalSettings(); - if (!userFont) { - int fontSize = settings->fontSize(QWebSettings::DefaultFontSize); - QString fontFamily = settings->fontFamily(QWebSettings::StandardFont); - font = QFont(fontFamily, fontSize); - } + QFont font; + getBrowserFontFor(viewer, &font); - QWebView *view = qobject_cast (viewer); - if (view) { - settings = view->settings(); - settings->setFontFamily(QWebSettings::StandardFont, font.family()); - settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); - } else if (viewer) { - viewer->setFont(font); - } - viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); -#else +#if defined(QT_NO_WEBKIT) font.setPointSize((int)(font.pointSize() + zoom)); - viewer->setFont(font); + setBrowserFontFor(viewer, font); viewer->setZoom((int)zoom); +#else + setBrowserFontFor(viewer, font); + viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); #endif connectSignals(); @@ -1011,41 +993,17 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, void CentralWidget::updateBrowserFont() { - QFont font = qApp->font(); - bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool(); - if (userFont) { - font = qVariantValue(helpEngine->customValue( - QLatin1String("browserFont"))); - } - -#if !defined(QT_NO_WEBKIT) - QWebSettings *settings = QWebSettings::globalSettings(); - if (!userFont) { - int fontSize = settings->fontSize(QWebSettings::DefaultFontSize); - QString fontFamily = settings->fontFamily(QWebSettings::StandardFont); - font = QFont(fontFamily, fontSize); + QFont font; + bool searchAttached = searchWidgetAttached(); + if (searchAttached) { + getBrowserFontFor(m_searchWidget, &font); + setBrowserFontFor(m_searchWidget, font); } -#endif - QWidget *widget = 0; - for (int i = 0; i < tabWidget->count(); ++i) { - widget = tabWidget->widget(i); -#if !defined(QT_NO_WEBKIT) - QWebView *view = qobject_cast (widget); - if (view) { - settings = view->settings(); - settings->setFontFamily(QWebSettings::StandardFont, font.family()); - settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); - } else if (widget) { - if (!userFont) - font = qApp->font(); - widget->setFont(font); - } -#else - if (widget && widget->font() != font) - widget->setFont(font); -#endif - } + int i = searchAttached ? 1 : 0; + getBrowserFontFor(tabWidget->widget(i), &font); + for (i; i < tabWidget->count(); ++i) + setBrowserFontFor(tabWidget->widget(i), font); } void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) @@ -1058,6 +1016,10 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) SLOT(setSourceFromSearch(QUrl))); connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, SLOT(setSourceFromSearchInNewTab(QUrl))); + + QFont font; + getBrowserFontFor(m_searchWidget, &font); + setBrowserFontFor(m_searchWidget, font); } void CentralWidget::activateSearchWidget(bool updateLastTabPage) @@ -1079,7 +1041,7 @@ void CentralWidget::activateSearchWidget(bool updateLastTabPage) void CentralWidget::removeSearchWidget() { - if (m_searchWidget && m_searchWidget->isAttached()) { + if (searchWidgetAttached()) { tabWidget->removeTab(0); m_searchWidget->setAttached(false); } @@ -1088,7 +1050,7 @@ void CentralWidget::removeSearchWidget() int CentralWidget::availableHelpViewer() const { int count = tabWidget->count(); - if (m_searchWidget && m_searchWidget->isAttached()) + if (searchWidgetAttached()) count--; return count; } @@ -1096,7 +1058,7 @@ int CentralWidget::availableHelpViewer() const bool CentralWidget::enableTabCloseAction() const { int minTabCount = 1; - if (m_searchWidget && m_searchWidget->isAttached()) + if (searchWidgetAttached()) minTabCount = 2; return (tabWidget->count() > minTabCount); @@ -1199,4 +1161,40 @@ QMap CentralWidget::currentSourceFileList() const return sourceList; } +void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) +{ + const QLatin1String key("useBrowserFont"); + if (!helpEngine->customValue(key, false).toBool()) { + *font = qApp->font(); // case for QTextBrowser and SearchWidget +#if !defined(QT_NO_WEBKIT) + QWebView *view = qobject_cast (viewer); + if (view) { + QWebSettings *settings = QWebSettings::globalSettings(); + *font = QFont(settings->fontFamily(QWebSettings::StandardFont), + settings->fontSize(QWebSettings::DefaultFontSize)); + } +#endif + } else { + *font = qVariantValue(helpEngine->customValue( + QLatin1String("browserFont"))); + } +} + +void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font) +{ +#if !defined(QT_NO_WEBKIT) + QWebView *view = qobject_cast (widget); + if (view) { + QWebSettings *settings = view->settings(); + settings->setFontFamily(QWebSettings::StandardFont, font.family()); + settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); + } else if (widget && widget->font() != font) { + widget->setFont(font); + } +#else + if (widget && widget->font() != font) + widget->setFont(font); +#endif +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 7ae8ee5..8c186f0 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -48,6 +48,8 @@ #include +#include "searchwidget.h" + QT_BEGIN_NAMESPACE class QEvent; @@ -65,7 +67,6 @@ class CentralWidget; class PrintHelper; class MainWindow; -class SearchWidget; class QHelpSearchEngine; class FindWidget : public QWidget @@ -123,6 +124,9 @@ public: HelpViewer *currentHelpViewer() const; void activateTab(bool onlyHelpViewer = false); + bool searchWidgetAttached() const { + return m_searchWidget && m_searchWidget->isAttached(); + } void createSearchWidget(QHelpSearchEngine *searchEngine); void activateSearchWidget(bool updateLastTabPage = false); void removeSearchWidget(); @@ -190,6 +194,9 @@ private: void highlightSearchTerms(); void setLastShownPages(); + void getBrowserFontFor(QWidget* viewer, QFont *font); + void setBrowserFontFor(QWidget *widget, const QFont &font); + private: int lastTabPage; QString collectionFile; -- cgit v0.12 From 1c182e05bb1f5b4cf5b84ad69aafbe31928513a3 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 9 Nov 2009 11:43:39 +0100 Subject: My changes for 4.6.0 --- dist/changes-4.6.0 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index eadc5c9..5f73661 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -95,6 +95,9 @@ QtCore * Improved reading utf8/utf16/utf32 data by correctly skipping the ByteOrderMark when reading data by one character at a time. +- QXmlStreamWriter + * [256468] fix comment indentation + QtGui - QGraphicsAnchorLayout * Support for expanding size policy has been removed. (The Qt 4.6 Beta had support for it). @@ -250,6 +253,27 @@ QtGui - QApplication * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). +QtNetwork + +- QAbstractSocket + * only disconnect from host when all bytes have been written + +- QLocalServer + * fix timeout when waiting for a connection on Unix + +- QNetworkAcessManager + * [242916] add possibility to send HTTP DELETE requests + +- QNetworkReply + * [257322] add possibility to ignore specific SSL errors + +- QSslCertificate + * [251830] fix version() and serialNumber() methods + +- QSslSocket + * [257322] add possibility to ignore specific SSL errors + * Fix build with openssl 1.0.0 betas + QtOpenGL - QGLFormat @@ -280,6 +304,11 @@ QtOpenGL - QGLGradientCache * [249919] Clean up the gradient cache in the right context. +QtXml + +- QDomDocument + * set the codec to UTF-8 if codec not present or unknown + **************************************************************************** * Platform Specific Changes * **************************************************************************** -- cgit v0.12 From 9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 11:37:33 +0100 Subject: API review: Rename numDigits() and setNumDigits() QLCDNumber doesn't follow the API convention of *Count and set*Count(). Introduce properly named functions, and obsolete the old ones. Reviewed-by: Andreas Aardal Hanssen --- src/gui/widgets/qlcdnumber.cpp | 41 +++++++++++++++++------- src/gui/widgets/qlcdnumber.h | 7 ++-- src/plugins/accessible/widgets/simplewidgets.cpp | 2 +- tests/auto/qlcdnumber/tst_qlcdnumber.cpp | 16 ++++----- 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp index 9f9e353..f33a98f 100644 --- a/src/gui/widgets/qlcdnumber.cpp +++ b/src/gui/widgets/qlcdnumber.cpp @@ -85,7 +85,7 @@ public: decimal point with setSmallDecimalPoint(). QLCDNumber emits the overflow() signal when it is asked to display - something beyond its range. The range is set by setNumDigits(), + something beyond its range. The range is set by setDigitCount(), but setSmallDecimalPoint() also influences it. If the display is set to hexadecimal, octal or binary, the integer equivalent of the value is displayed. @@ -160,7 +160,7 @@ public: This signal is emitted whenever the QLCDNumber is asked to display a too-large number or a too-long string. - It is never emitted by setNumDigits(). + It is never emitted by setDigitCount(). */ @@ -345,7 +345,7 @@ static const char *getSegments(char ch) // gets list of segments f The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) @@ -367,7 +367,7 @@ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) @@ -387,7 +387,7 @@ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent) @@ -407,7 +407,7 @@ QLCDNumber::QLCDNumber(QWidget *parent) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent) @@ -426,7 +426,7 @@ void QLCDNumberPrivate::init() val = 0; base = QLCDNumber::Dec; smallPoint = false; - q->setNumDigits(ndigits); + q->setDigitCount(ndigits); q->setSegmentStyle(QLCDNumber::Filled); q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); } @@ -441,8 +441,21 @@ QLCDNumber::~QLCDNumber() /*! + \obsolete \property QLCDNumber::numDigits \brief the current number of digits displayed + \sa setDigitCount +*/ + +void QLCDNumber::setNumDigits(int numDigits) +{ + setDigitCount(numDigits); +} + +/*! + \since 4.6 + \property QLCDNumber::digitCount + \brief the current number of digits displayed Corresponds to the current number of digits. If \l QLCDNumber::smallDecimalPoint is false, the decimal point occupies @@ -453,7 +466,7 @@ QLCDNumber::~QLCDNumber() \sa smallDecimalPoint */ -void QLCDNumber::setNumDigits(int numDigits) +void QLCDNumber::setDigitCount(int numDigits) { Q_D(QLCDNumber); if (numDigits > 99) { @@ -508,13 +521,19 @@ int QLCDNumber::numDigits() const return d->ndigits; } +int QLCDNumber::digitCount() const +{ + Q_D(const QLCDNumber); + return d->ndigits; +} + /*! \overload Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(int num) const @@ -530,7 +549,7 @@ bool QLCDNumber::checkOverflow(int num) const Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(double num) const @@ -1256,7 +1275,7 @@ QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const */ QSize QLCDNumber::sizeHint() const { - return QSize(10 + 9 * (numDigits() + (smallDecimalPoint() ? 0 : 1)), 23); + return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); } /*! \reimp */ diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h index 9753f31..e65637d 100644 --- a/src/gui/widgets/qlcdnumber.h +++ b/src/gui/widgets/qlcdnumber.h @@ -60,6 +60,7 @@ class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget Q_ENUMS(Mode SegmentStyle) Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint) Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits) + Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount) Q_PROPERTY(Mode mode READ mode WRITE setMode) Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle) Q_PROPERTY(double value READ value WRITE display) @@ -82,8 +83,10 @@ public: bool smallDecimalPoint() const; - int numDigits() const; - void setNumDigits(int nDigits); + QT_DEPRECATED int numDigits() const; + QT_DEPRECATED void setNumDigits(int nDigits); + int digitCount() const; + void setDigitCount(int nDigits); bool checkOverflow(double num) const; bool checkOverflow(int num) const; diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 1d801e4..014d487 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -528,7 +528,7 @@ QString QAccessibleDisplay::text(Text t, int child) const #ifndef QT_NO_LCDNUMBER } else if (qobject_cast(object())) { QLCDNumber *l = qobject_cast(object()); - if (l->numDigits()) + if (l->digitCount()) str = QString::number(l->value()); else str = QString::number(l->intValue()); diff --git a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp index c18ce24..3f52c70 100644 --- a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp +++ b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp @@ -74,14 +74,14 @@ tst_QLCDNumber::~tst_QLCDNumber() void tst_QLCDNumber::getSetCheck() { QLCDNumber obj1; - // int QLCDNumber::numDigits() - // void QLCDNumber::setNumDigits(int) - obj1.setNumDigits(0); - QCOMPARE(0, obj1.numDigits()); - obj1.setNumDigits(INT_MIN); - QCOMPARE(0, obj1.numDigits()); // Range<0, 99> - obj1.setNumDigits(INT_MAX); - QCOMPARE(99, obj1.numDigits()); // Range<0, 99> + // int QLCDNumber::digitCount() + // void QLCDNumber::setDigitCount(int) + obj1.setDigitCount(0); + QCOMPARE(0, obj1.digitCount()); + obj1.setDigitCount(INT_MIN); + QCOMPARE(0, obj1.digitCount()); // Range<0, 99> + obj1.setDigitCount(INT_MAX); + QCOMPARE(99, obj1.digitCount()); // Range<0, 99> } QTEST_MAIN(tst_QLCDNumber) -- cgit v0.12 From 195f4b98fbf31a92e27be4533fc2ccae99372b82 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 11:43:08 +0100 Subject: API review: Rename numPages() -> pageCount() QPrintPreviewWidget wasn't following the Qt API naming convention of *Count()/set*Count(). Introduce proper function, and obsolete the old. Removed all usage of the old function in Qt. Reviewed-by: Andreas Aardal Hanssen --- src/gui/dialogs/qprintpreviewdialog.cpp | 6 +++--- src/gui/widgets/qprintpreviewwidget.cpp | 12 ++++++++++++ src/gui/widgets/qprintpreviewwidget.h | 3 ++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp index 4cb0c93..1f0b51d 100644 --- a/src/gui/dialogs/qprintpreviewdialog.cpp +++ b/src/gui/dialogs/qprintpreviewdialog.cpp @@ -446,7 +446,7 @@ void QPrintPreviewDialogPrivate::setFitting(bool on) void QPrintPreviewDialogPrivate::updateNavActions() { int curPage = preview->currentPage(); - int numPages = preview->numPages(); + int numPages = preview->pageCount(); nextPageAction->setEnabled(curPage < numPages); prevPageAction->setEnabled(curPage > 1); firstPageAction->setEnabled(curPage > 1); @@ -458,7 +458,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel() { Q_Q(QPrintPreviewDialog); - int numPages = preview->numPages(); + int numPages = preview->pageCount(); int maxChars = QString::number(numPages).length(); pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages)); int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars)); @@ -515,7 +515,7 @@ void QPrintPreviewDialogPrivate::_q_navigate(QAction* action) else if (action == firstPageAction) preview->setCurrentPage(1); else if (action == lastPageAction) - preview->setCurrentPage(preview->numPages()); + preview->setCurrentPage(preview->pageCount()); updateNavActions(); } diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp index d92b1ea..0074c91 100644 --- a/src/gui/widgets/qprintpreviewwidget.cpp +++ b/src/gui/widgets/qprintpreviewwidget.cpp @@ -663,7 +663,9 @@ void QPrintPreviewWidget::setZoomFactor(qreal factor) } /*! + \obsolete Returns the number of pages in the preview. + \sa pageCount() */ int QPrintPreviewWidget::numPages() const { @@ -672,6 +674,16 @@ int QPrintPreviewWidget::numPages() const } /*! + \since 4.6 + Returns the number of pages in the preview. +*/ +int QPrintPreviewWidget::pageCount() const +{ + Q_D(const QPrintPreviewWidget); + return d->pages.size(); +} + +/*! Returns the currently viewed page in the preview. */ int QPrintPreviewWidget::currentPage() const diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h index 2823873..08e596d 100644 --- a/src/gui/widgets/qprintpreviewwidget.h +++ b/src/gui/widgets/qprintpreviewwidget.h @@ -82,7 +82,8 @@ public: ViewMode viewMode() const; ZoomMode zoomMode() const; int currentPage() const; - int numPages() const; + QT_DEPRECATED int numPages() const; + int pageCount() const; void setVisible(bool visible); public Q_SLOTS: -- cgit v0.12 From 4ad31892d735e6f1a7afffbf0bf8028663855adb Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 12:04:15 +0100 Subject: API review: Rename numRects() -> rectCount() QRegion::numRects() is marked obsolete. Removed all usage of the old function inside Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- src/gui/embedded/qscreen_qws.cpp | 4 ++-- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- src/gui/graphicsview/qgraphicsview.cpp | 2 +- src/gui/painting/qpaintengine_raster.cpp | 4 ++-- src/gui/painting/qpaintengineex.cpp | 2 +- src/gui/painting/qregion.cpp | 20 +++++++++++++++++--- src/gui/painting/qregion.h | 3 ++- src/gui/painting/qtransform.cpp | 2 +- src/gui/painting/qwindowsurface_raster.cpp | 6 +++--- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 2 +- src/openvg/qpaintengine_vg.cpp | 16 ++++++++-------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 6 +++--- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 2 +- .../powervr/pvreglscreen/pvreglwindowsurface.cpp | 2 +- tests/auto/qregion/tst_qregion.cpp | 20 ++++++++++---------- 16 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f0393a7..18b2c34 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -120,7 +120,7 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) TRACE("rect %d %d - %d %d", event->rect().left(), event->rect().top(), event->rect().right(), event->rect().bottom()); - TRACE("regions %d", event->region().numRects()); + TRACE("regions %d", event->region().rectCount()); TRACE("type %d", event->type()); // Do nothing diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 0dbfd05..ae5570f 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -600,7 +600,7 @@ static void blit_template(QScreen *screen, const QImage &image, const int screenStride = screen->linestep(); const int imageStride = image.bytesPerLine(); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { const QRect r = region.boundingRect(); const SRC *src = reinterpret_cast(image.scanLine(r.y())) + r.x(); @@ -2463,7 +2463,7 @@ void QScreen::exposeRegion(QRegion r, int windowIndex) delete blendBuffer; } - if (r.numRects() == 1) { + if (r.rectCount() == 1) { setDirty(r.boundingRect()); } else { const QVector rects = r.rects(); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index dc036f8..e28ab61 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4149,7 +4149,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & QRect br = pixmapExposed.boundingRect(); // Don't use subpixmap if we get a full update. - if (pixmapExposed.isEmpty() || (pixmapExposed.numRects() == 1 && br.contains(pix->rect()))) { + if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) { pix->fill(Qt::transparent); pixmapPainter.begin(pix); } else { diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index c88f678..a880402 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -978,7 +978,7 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg // Step 2) If the expose region is a simple rect and the view is only // translated or scaled, search for items using // QGraphicsScene::items(QRectF). - bool simpleRectLookup = exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale; + bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale; if (simpleRectLookup) { return scene->items(exposedRegionSceneBounds, Qt::IntersectsItemBoundingRect, diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8d0b961..3f33319 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1362,7 +1362,7 @@ void QRasterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) Q_D(QRasterPaintEngine); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { clip(region.boundingRect(), op); return; } @@ -4536,7 +4536,7 @@ void QClipData::setClipRect(const QRect &rect) */ void QClipData::setClipRegion(const QRegion ®ion) { - if (region.numRects() == 1) { + if (region.rectCount() == 1) { setClipRect(region.rects().at(0)); return; } diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 1fb8aab..7d1c109 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -602,7 +602,7 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op) void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) { - if (region.numRects() == 1) + if (region.rectCount() == 1) clip(region.boundingRect(), op); QVector rects = region.rects(); diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index b48b024..9d1d965 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -690,7 +690,7 @@ bool QRegion::intersects(const QRegion ®ion) const if (!rect_intersects(boundingRect(), region.boundingRect())) return false; - if (numRects() == 1 && region.numRects() == 1) + if (rectCount() == 1 && region.rectCount() == 1) return true; const QVector myRects = rects(); @@ -717,7 +717,7 @@ bool QRegion::intersects(const QRect &rect) const const QRect r = rect.normalized(); if (!rect_intersects(boundingRect(), r)) return false; - if (numRects() == 1) + if (rectCount() == 1) return true; const QVector myRects = rects(); @@ -739,6 +739,7 @@ QRegion QRegion::intersect(const QRect &r) const #endif /*! + \obsolete \fn int QRegion::numRects() const \since 4.4 @@ -746,6 +747,13 @@ QRegion QRegion::intersect(const QRect &r) const */ /*! + \fn int QRegion::rectCount() const + \since 4.6 + + Returns the number of rectangles that will be returned in rects(). +*/ + +/*! \fn bool QRegion::isEmpty() const Returns true if the region is empty; otherwise returns false. An @@ -1027,7 +1035,7 @@ void addSegmentsToPath(Segment *segment, QPainterPath &path) Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) { QPainterPath result; - if (region.numRects() == 1) { + if (region.rectCount() == 1) { result.addRect(region.boundingRect()); return result; } @@ -4317,6 +4325,12 @@ int QRegion::numRects() const return (d->qt_rgn ? d->qt_rgn->numRects : 0); } +int QRegion::rectCount() const +{ + return (d->qt_rgn ? d->qt_rgn->numRects : 0); +} + + bool QRegion::operator==(const QRegion &r) const { if (!d->qt_rgn) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 7e459ed..2a1be86 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -116,7 +116,8 @@ public: QRect boundingRect() const; QVector rects() const; void setRects(const QRect *rect, int num); - int numRects() const; + QT_DEPRECATED int numRects() const; + int rectCount() const; const QRegion operator|(const QRegion &r) const; const QRegion operator+(const QRegion &r) const; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 1bd5842..45db80a 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1421,7 +1421,7 @@ QRegion QTransform::map(const QRegion &r) const return copy; } - if (t == TxScale && r.numRects() == 1) + if (t == TxScale && r.rectCount() == 1) return QRegion(mapRect(r.boundingRect())); QPainterPath p = map(qt_regionToPath(r)); diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index d412040..5060f95 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -140,7 +140,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi // Not ready for painting yet, bail out. This can happen in // QWidget::create_sys() - if (!d->image || rgn.numRects() == 0) + if (!d->image || rgn.rectCount() == 0) return; #ifdef Q_WS_WIN @@ -203,7 +203,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi wrgn.translate(-wOffset); QRect wbr = wrgn.boundingRect(); - if (wrgn.numRects() != 1) { + if (wrgn.rectCount() != 1) { int num; XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num); XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded); @@ -242,7 +242,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } } - if (wrgn.numRects() != 1) + if (wrgn.rectCount() != 1) XSetClipMask(X11->display, d_ptr->gc, XNone); #endif // FALCON diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 8228c7e..8c5bf0e 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -2107,7 +2107,7 @@ void QGL2PaintEngineExPrivate::systemStateChanged() q->state()->rectangleClip = use_system_clip ? systemClip.boundingRect() : QRect(0, 0, width, height); updateClipScissorTest(); - if (systemClip.numRects() == 1) { + if (systemClip.rectCount() == 1) { if (systemClip.boundingRect() == QRect(0, 0, width, height)) use_system_clip = false; #ifndef QT_GL_NO_SCISSOR_TEST diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 047d9d8..75b7fa5 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1753,13 +1753,13 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) // QRegion copy on the heap for the test if we can. QRegion clip = d->systemClip; // Reference-counted, no alloc. QRect clipRect; - if (clip.numRects() == 1) { + if (clip.rectCount() == 1) { clipRect = clip.boundingRect().intersected(r); } else if (clip.isEmpty()) { clipRect = r; } else { clip = clip.intersect(r); - if (clip.numRects() != 1) { + if (clip.rectCount() != 1) { d->maskValid = false; d->maskIsSet = false; d->maskRect = QRect(); @@ -1810,7 +1810,7 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) Q_D(QVGPaintEngine); // Use the QRect case if the region consists of a single rectangle. - if (region.numRects() == 1) { + if (region.rectCount() == 1) { clip(region.boundingRect(), op); return; } @@ -1853,7 +1853,7 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) clip = r; else clip = clip.intersect(r); - if (clip.numRects() == 1) { + if (clip.rectCount() == 1) { d->maskValid = false; d->maskIsSet = false; d->maskRect = clip.boundingRect(); @@ -1871,7 +1871,7 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) case Qt::IntersectClip: { - if (region.numRects() != 1) { + if (region.rectCount() != 1) { // If there is more than one rectangle, then intersecting // the rectangles one by one in modifyMask() will not give // the desired result. So fall back to path-based clipping. @@ -2148,7 +2148,7 @@ QRegion QVGPaintEngine::defaultClipRegion() bool QVGPaintEngine::isDefaultClipRegion(const QRegion& region) { - if (region.numRects() != 1) + if (region.rectCount() != 1) return false; QPaintDevice *pdev = paintDevice(); @@ -3544,7 +3544,7 @@ void QVGCompositionHelper::fillBackground d->clearColor = color; d->clearOpacity = 1.0f; } - if (region.numRects() == 1) { + if (region.rectCount() == 1) { QRect r = region.boundingRect(); vgClear(r.x(), screenSize.height() - r.y() - r.height(), r.width(), r.height()); @@ -3569,7 +3569,7 @@ void QVGCompositionHelper::fillBackground d->ensureBrush(brush); d->setFillRule(VG_EVEN_ODD); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { fillBackgroundRect(region.boundingRect(), d); } else { const QVector rects = region.rects(); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index b6faf8b..eb771ba 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1564,7 +1564,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int) primary->SetColor(primary, 0xff, 0xff, 0xff, cmd.windowOpacity); } const QRegion ®ion = cmd.source; - const int rectCount = region.numRects(); + const int rectCount = region.rectCount(); DFBRectangle source; if (rectCount == 1) { ::initParameters(source, region.boundingRect(), cmd.windowPosition); @@ -1619,7 +1619,7 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) d_ptr->primarySurface->SetColor(d_ptr->primarySurface, color.red(), color.green(), color.blue(), color.alpha()); - const int n = region.numRects(); + const int n = region.rectCount(); if (n == 1) { const QRect r = region.boundingRect(); d_ptr->primarySurface->FillRectangle(d_ptr->primarySurface, r.x(), r.y(), r.width(), r.height()); @@ -1680,7 +1680,7 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags if (!(flipFlags & DSFLIP_BLIT)) { surface->Flip(surface, 0, flipFlags); } else { - if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.numRects() > 1) { + if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.rectCount() > 1) { const QVector rects = region.rects(); const DFBSurfaceFlipFlags nonWaitFlags = flipFlags & ~DSFLIP_WAIT; for (int i=0; iSetBlittingFlags(dfbSurface, DSBLIT_NOFX); - if (region.numRects() == 1) { + if (region.rectCount() == 1) { scrollSurface(dfbSurface, region.boundingRect(), dx, dy); } else { const QVector rects = region.rects(); diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp index 4a3787f..51a6c4e 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp @@ -199,7 +199,7 @@ void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id) if (region.isEmpty()) { pvrQwsClearVisibleRegion(drawable); - } else if (region.numRects() == 1) { + } else if (region.rectCount() == 1) { QRect rect = region.boundingRect(); PvrQwsRect pvrRect; pvrRect.x = rect.x(); diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp index e5a3151..582b5e8 100644 --- a/tests/auto/qregion/tst_qregion.cpp +++ b/tests/auto/qregion/tst_qregion.cpp @@ -88,8 +88,8 @@ private slots: void operator_xor_data(); void operator_xor(); - void numRects_data(); - void numRects(); + void rectCount_data(); + void rectCount(); void isEmpty_data(); void isEmpty(); @@ -554,7 +554,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(r1 + r2, expected); - if (r2.numRects() == 1) { + if (r2.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r1 + QRect(r2)" << (r1 + r2.boundingRect()); qDebug() << "expected" << expected; @@ -567,7 +567,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(r2 + r1, expected); - if (r1.numRects() == 1) { + if (r1.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r2 + QRect(r1)" << (r2 + r1.boundingRect()); qDebug() << "expected" << expected; @@ -582,7 +582,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(result1, expected); - if (r2.numRects() == 1) { + if (r2.rectCount() == 1) { result1 = r1; result1 += r2.boundingRect(); if (result1 != expected) { @@ -599,7 +599,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(result2, expected); - if (r1.numRects() == 1) { + if (r1.rectCount() == 1) { result2 = r2; result2 += r1.boundingRect(); if (result2 != expected) { @@ -802,7 +802,7 @@ void tst_QRegion::operator_xor() QCOMPARE(dest, expected); } -void tst_QRegion::numRects_data() +void tst_QRegion::rectCount_data() { QTest::addColumn("region"); QTest::addColumn("expected"); @@ -818,12 +818,12 @@ void tst_QRegion::numRects_data() QTest::newRow("2 rects") << dest << rects.size(); } -void tst_QRegion::numRects() +void tst_QRegion::rectCount() { QFETCH(QRegion, region); QFETCH(int, expected); - QCOMPARE(region.numRects(), expected); + QCOMPARE(region.rectCount(), expected); } void tst_QRegion::isEmpty_data() @@ -850,7 +850,7 @@ void tst_QRegion::isEmpty() QVERIFY(region.isEmpty()); QCOMPARE(region, QRegion()); - QCOMPARE(region.numRects(), 0); + QCOMPARE(region.rectCount(), 0); QCOMPARE(region.boundingRect(), QRect()); QVERIFY(region.rects().isEmpty()); } -- cgit v0.12 From a2a3adf7de2ffc9784fea177a43f3124862a992a Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 12:58:19 +0100 Subject: API review: *Count() are not plural Obsolete the plural version, and replace its usage in Qt. Reviewed-by: Andreas Aardal Hanssen --- tools/assistant/lib/qhelpsearchengine.cpp | 18 ++++++++++++++---- tools/assistant/lib/qhelpsearchengine.h | 3 ++- tools/assistant/lib/qhelpsearchindexreader.cpp | 2 +- tools/assistant/lib/qhelpsearchindexreader_p.h | 2 +- tools/assistant/lib/qhelpsearchresultwidget.cpp | 10 +++++----- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchengine.cpp b/tools/assistant/lib/qhelpsearchengine.cpp index cb18142..893495d 100644 --- a/tools/assistant/lib/qhelpsearchengine.cpp +++ b/tools/assistant/lib/qhelpsearchengine.cpp @@ -95,12 +95,11 @@ private: delete indexWriter; } - - int hitsCount() const + int hitCount() const { int count = 0; if (indexReader) - count = indexReader->hitsCount(); + count = indexReader->hitCount(); return count; } @@ -366,11 +365,22 @@ QHelpSearchResultWidget* QHelpSearchEngine::resultWidget() } /*! + \obsolete Returns the amount of hits the search engine found. + \sa hitCount() */ int QHelpSearchEngine::hitsCount() const { - return d->hitsCount(); + return d->hitCount(); +} + +/*! + \since 4.6 + Returns the amount of hits the search engine found. +*/ +int QHelpSearchEngine::hitCount() const +{ + return d->hitCount(); } /*! diff --git a/tools/assistant/lib/qhelpsearchengine.h b/tools/assistant/lib/qhelpsearchengine.h index 1d53411..21f04c5 100644 --- a/tools/assistant/lib/qhelpsearchengine.h +++ b/tools/assistant/lib/qhelpsearchengine.h @@ -86,7 +86,8 @@ public: QHelpSearchQueryWidget* queryWidget(); QHelpSearchResultWidget* resultWidget(); - int hitsCount() const; + QT_DEPRECATED int hitsCount() const; + int hitCount() const; typedef QPair SearchHit; QList hits(int start, int end) const; diff --git a/tools/assistant/lib/qhelpsearchindexreader.cpp b/tools/assistant/lib/qhelpsearchindexreader.cpp index 20d181b..b134605 100644 --- a/tools/assistant/lib/qhelpsearchindexreader.cpp +++ b/tools/assistant/lib/qhelpsearchindexreader.cpp @@ -83,7 +83,7 @@ void QHelpSearchIndexReader::search(const QString &collectionFile, const QString start(QThread::NormalPriority); } -int QHelpSearchIndexReader::hitsCount() const +int QHelpSearchIndexReader::hitCount() const { QMutexLocker lock(&mutex); return hitList.count(); diff --git a/tools/assistant/lib/qhelpsearchindexreader_p.h b/tools/assistant/lib/qhelpsearchindexreader_p.h index 31c392f..adbcdc2 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_p.h +++ b/tools/assistant/lib/qhelpsearchindexreader_p.h @@ -81,7 +81,7 @@ public: void search(const QString &collectionFile, const QString &indexFilesFolder, const QList &queryList); - int hitsCount() const; + int hitCount() const; QList hits(int start, int end) const; signals: diff --git a/tools/assistant/lib/qhelpsearchresultwidget.cpp b/tools/assistant/lib/qhelpsearchresultwidget.cpp index a2f0021..c0d17dd 100644 --- a/tools/assistant/lib/qhelpsearchresultwidget.cpp +++ b/tools/assistant/lib/qhelpsearchresultwidget.cpp @@ -169,13 +169,13 @@ private slots: void showNextResultPage() { if (!searchEngine.isNull() - && resultLastToShow < searchEngine->hitsCount()) { + && resultLastToShow < searchEngine->hitCount()) { resultLastToShow += 20; resultFirstToShow += 20; resultTextBrowser->showResultPage(searchEngine->hits(resultFirstToShow, resultLastToShow), isIndexing); - if (resultLastToShow >= searchEngine->hitsCount()) + if (resultLastToShow >= searchEngine->hitCount()) updateNextButtonState(false); } updateHitRange(); @@ -184,7 +184,7 @@ private slots: void showLastResultPage() { if (!searchEngine.isNull()) { - resultLastToShow = searchEngine->hitsCount(); + resultLastToShow = searchEngine->hitCount(); resultFirstToShow = resultLastToShow - (resultLastToShow % 20); if (resultFirstToShow == resultLastToShow) @@ -214,7 +214,7 @@ private slots: { if (!searchEngine.isNull()) { int count = resultLastToShow % 20; - if (count == 0 || resultLastToShow != searchEngine->hitsCount()) + if (count == 0 || resultLastToShow != searchEngine->hitCount()) count = 20; resultLastToShow -= count; @@ -298,7 +298,7 @@ private: int count = 0; if (!searchEngine.isNull()) { - count = searchEngine->hitsCount(); + count = searchEngine->hitCount(); if (count > 0) { first = resultFirstToShow +1; last = resultLastToShow > count ? count : resultLastToShow; -- cgit v0.12 From 9b7a5241a287b71c1ab4a9cd9cd3d89c03136ced Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 9 Nov 2009 11:20:15 +0100 Subject: Default to X11 instead of QWS for commercial builds Reviewed-by: Thiago Reviewed-by: Jason McDonald --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index aab520e..a89db59 100755 --- a/configure +++ b/configure @@ -362,7 +362,7 @@ elif [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" elif [ $COMMERCIAL_USER = "yes" ]; then # one of commercial editions [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes - [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=yes + [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=no # read in the license file if [ -f "$LICENSE_FILE" ]; then -- cgit v0.12 From d6a23684c8546fcd20ac032aa01985ca7ac69128 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 9 Nov 2009 12:28:58 +0100 Subject: Fixed pan gesture handlers in standard Qt widgets. Reviewed-by: Richard --- src/gui/widgets/qabstractscrollarea.cpp | 2 +- src/gui/widgets/qplaintextedit.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 7d81d5a..1a4ee2b 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -946,7 +946,7 @@ bool QAbstractScrollArea::event(QEvent *e) if (g) { QScrollBar *hBar = horizontalScrollBar(); QScrollBar *vBar = verticalScrollBar(); - QPointF delta = g->lastOffset(); + QPointF delta = g->delta(); if (!delta.isNull()) { if (QApplication::isRightToLeft()) delta.rx() *= -1; diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 0de7421..18adc6c 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1465,7 +1465,7 @@ bool QPlainTextEdit::event(QEvent *e) // QPlainTextEdit scrolls by lines only in vertical direction QFontMetrics fm(document()->defaultFont()); int lineHeight = fm.height(); - int newX = hBar->value() - g->lastOffset().x(); + int newX = hBar->value() - g->delta().x(); int newY = d->originalOffsetY - offset.y()/lineHeight; hBar->setValue(newX); vBar->setValue(newY); -- cgit v0.12 From e07878a9bcccbf063650272329c0aca14290b8e3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Nov 2009 12:47:40 +0100 Subject: Compile in 64bit with debug --- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 3ef37f9..5f50c85 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -267,7 +267,7 @@ inline QString AnchorVertex::toString() const const AnchorVertexPair *vp = static_cast(this); return QString::fromAscii("(%1, %2)").arg(vp->m_first->toString()).arg(vp->m_second->toString()); } else if (!m_item) { - return QString::fromAscii("NULL_%1").arg(int(this)); + return QString::fromAscii("NULL_%1").arg(quintptr(this)); } QString edge; switch (m_edge) { -- cgit v0.12 From a7577f8c3ae3a025384d8d19fdf3575ef141a70b Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 9 Nov 2009 13:02:51 +0100 Subject: =?UTF-8?q?=FF=FEd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/src/examples/googlesuggest.qdoc | 148 ++++++++++++++++++++++- doc/src/images/googlesuggest-example.png | Bin 18809 -> 9006 bytes examples/network/googlesuggest/googlesuggest.cpp | 58 +++++---- examples/network/googlesuggest/googlesuggest.h | 6 +- examples/network/googlesuggest/searchbox.cpp | 7 +- examples/network/googlesuggest/searchbox.h | 2 + 6 files changed, 191 insertions(+), 30 deletions(-) diff --git a/doc/src/examples/googlesuggest.qdoc b/doc/src/examples/googlesuggest.qdoc index bec242d..f3693e9 100644 --- a/doc/src/examples/googlesuggest.qdoc +++ b/doc/src/examples/googlesuggest.qdoc @@ -43,10 +43,152 @@ \example network/googlesuggest \title Google Suggest Example - The Google Suggest example shows how to use the network access manager - to get the list of suggested search terms from Google. + The Google Suggest example demonstrates how to use the QNetworkAccessManager + class to obtain a list of suggestions from the Google search engine as the + user types into a QLineEdit. \image googlesuggest-example.png - \note The Google Suggest suggestion service is a registered trademark of Google Inc. + The application makes use of the \c get function in +QNetworkAccessManager to post a request and obtain the result of the search +query sent to the Google search engine. The results returned are listed as +clickable links appearing below the search box as a drop-down menu. + +The widget is built up by a QLineEdit as the search box, and a QTreeView +used as a popup menu below the search box. + +\section1 GSuggestCompletion Class Declaration + +This class implements an event filter and a number of functions to display +the search results and to determent when and how to perform the search. + +\snippet examples/network/googlesuggest/googlesuggest.h 1 + +The class connects to a QLineEdit and uses a QTreeWidget to display the +results. A QTimer controls the start of the network requests that are +executed using a QNetworkAccessManager. + +\section1 GSuggestCompletion Class Implementation + +We start by defining a constant containing the URL to be used in the Google +queries. This is the basis for the query. The letters typed into the search +box will be added to the query to perform the search itself. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 1 + +In the constructor, we set the parent of this GSuggestCompletion instance +to be the QLineEdit passed in. For simplicity, the QLineEdit is also stored +in the explicit \c editor member variable. + +We then create a QTreeWidget as a toplevel widget and configure the various +properties to give it the look of a popup widget. + +The popup will be populated by the results returned from Google. We set +the number of columns to be two, since we want to display both the +suggested search term and the number of hits it will trigger in the search +engine. + +Furthermore, we install the GSuggestCompletion instance as an event filter +on the QTreeWidget, and connect the \c itemClicked() signal with the \c +doneCompletion() slot. + +A single-shot QTimer is used to start the request when the user has stopped +typing for 500 ms. + +Finally, we connect the networkManagers \c finished() signal with the \c +handleNetworkData() slot to handle the incoming data. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 2 + +Since the QTreeWidget popup has been instantiated as a toplevel widget, the +destructor has to delete it explicitly from memory to avoid a memory leak. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 3 + +The event filter handles mouse press and key press events that are +delivered to the popup. For mouse press events we just hide the popup and +return focus to the editor widget, and then return true to prevent further +event processing. + +Key event handling is implemented so that Enter and Return execute the +selected link, while the Escape key hides the popup. Sine we want to be +able to navigate the list of suggestions using the different navigation +keys on the keyboard we let Qt continue regular event processing for those +by returning false from the eventFilter reimplementation. + +For all other keys, the event will be passed on to the editor widget and the +popup is hidden. This way the user's typing will not be interrupted by the +popping up of the completion list. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 4 + +The \c showCompletion() function populates the QTreeWidget with the results +returned from the query. It takes two QStringLists, one with the suggested +search terms and the other with the corresponding number of hits. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 5 + +A QTreeWidgetItem is created for each index in the list and inserted into +the QTreeWidget. Finally, we adjust position and size of the popup to make +sure that it pops up in the correct position below the editor, and show it. + +The \c doneCompletion() function, which is called by the event filter when +either Enter or Return keys are pressed, stops the timer to prevent further +requests and passes the text of the selected item to the editor. We then +make the \c editor QLineEdit emit the returnPressed() signal, to which the +application can connect to open the respective web page. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 6 + +The \c autoSuggest() slot is called when the timer times out, and uses the +text in the editor to build the complete search query. The query is then +passed to the QNetworkAccessManager's \c get() function to start the +request. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 7 + +The function \c preventSuggest() stops the timer to prevent further +requests from being started. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 8 + +When the network request is finished, the QNetworkAccessManager delivers the +data received from the server through the networkReply object. + +\snippet examples/network/googlesuggest/googlesuggest.cpp 9 + +To extract the data from the reply we use the \c readAll() function, which +is inherited from QIODevice and returns a QByteArray. Since this data is +encoded in XML we can use a QXmlStreamReader to traverse the data and +extract the search result as QStrings, which we can stream into two +QStringLists used to populate the popup. + +Finally, we schedule the QNetworkReply object for deletion using the \c +deleteLater function. + +\section1 SearchBox Class Declaration + +The SearchBox class inherits QLineEdit and adds the protected slot \c +doSearch(). + +A \c GSuggestCompletion member provides the SearchBox with the request +functionality and the suggestions returned from the Google search engine. + +\snippet examples/network/googlesuggest/searchbox.h 1 + +\section1 SearchBox Class Implementation + +The search box constructor instantiates the GSuggestCompletion object and +connects the returnPressed() signal to the doSearch() slot. + +\snippet examples/network/googlesuggest/searchbox.cpp 1 + +The function \c doSearch() stops the completer from sending any further +queries to the search engine. + +Further, the function extracts the selected search phrase and opens it in +the default web browser using QDesktopServices. + +\snippet examples/network/googlesuggest/searchbox.cpp 2 + */ diff --git a/doc/src/images/googlesuggest-example.png b/doc/src/images/googlesuggest-example.png index 4ef072a..477d444 100644 Binary files a/doc/src/images/googlesuggest-example.png and b/doc/src/images/googlesuggest-example.png differ diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp index e1588a6..a1075ec 100644 --- a/examples/network/googlesuggest/googlesuggest.cpp +++ b/examples/network/googlesuggest/googlesuggest.cpp @@ -39,17 +39,22 @@ ** ****************************************************************************/ -#include -#include -#include +//! [1] #include "googlesuggest.h" #define GSUGGEST_URL "http://google.com/complete/search?output=toolbar&q=%1" +//! [1] +//! [2] GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), editor(parent) { popup = new QTreeWidget; + popup->setWindowFlags(Qt::Popup); + popup->setFocusPolicy(Qt::NoFocus); + popup->setFocusProxy(parent); + popup->setMouseTracking(true); + popup->setColumnCount(2); popup->setUniformRowHeights(true); popup->setRootIsDecorated(false); @@ -57,18 +62,13 @@ GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), edit popup->setSelectionBehavior(QTreeWidget::SelectRows); popup->setFrameStyle(QFrame::Box | QFrame::Plain); popup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - popup->header()->hide(); + popup->installEventFilter(this); - popup->setMouseTracking(true); connect(popup, SIGNAL(itemClicked(QTreeWidgetItem*, int)), SLOT(doneCompletion())); - popup->setWindowFlags(Qt::Popup); - popup->setFocusPolicy(Qt::NoFocus); - popup->setFocusProxy(parent); - timer = new QTimer(this); timer->setSingleShot(true); timer->setInterval(500); @@ -79,12 +79,16 @@ GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), edit this, SLOT(handleNetworkData(QNetworkReply*))); } +//! [2] +//! [3] GSuggestCompletion::~GSuggestCompletion() { delete popup; } +//! [3] +//! [4] bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev) { if (obj != popup) @@ -131,9 +135,12 @@ bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev) return false; } +//! [4] +//! [5] void GSuggestCompletion::showCompletion(const QStringList &choices, const QStringList &hits) { + if (choices.isEmpty() || choices.count() != hits.count()) return; @@ -163,7 +170,9 @@ void GSuggestCompletion::showCompletion(const QStringList &choices, const QStrin popup->setFocus(); popup->show(); } +//! [5] +//! [6] void GSuggestCompletion::doneCompletion() { timer->stop(); @@ -172,26 +181,28 @@ void GSuggestCompletion::doneCompletion() QTreeWidgetItem *item = popup->currentItem(); if (item) { editor->setText(item->text(0)); - QKeyEvent *e; - e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); - QApplication::postEvent(editor, e); - e = new QKeyEvent(QEvent::KeyRelease, Qt::Key_Enter, Qt::NoModifier); - QApplication::postEvent(editor, e); + QMetaObject::invokeMethod(editor, "returnPressed"); } } +//! [6] -void GSuggestCompletion::preventSuggest() -{ - timer->stop(); -} - +//! [7] void GSuggestCompletion::autoSuggest() { QString str = editor->text(); QString url = QString(GSUGGEST_URL).arg(str); networkManager.get(QNetworkRequest(QString(url))); } +//! [7] + +//! [8] +void GSuggestCompletion::preventSuggest() +{ + timer->stop(); +} +//! [8] +//! [9] void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) { QUrl url = networkReply->url(); @@ -199,20 +210,20 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) QStringList choices; QStringList hits; - QString response(networkReply->readAll()); + QByteArray response(networkReply->readAll()); QXmlStreamReader xml(response); while (!xml.atEnd()) { xml.readNext(); - if (xml.isStartElement()) { + if (xml.tokenType() == QXmlStreamReader::StartElement) if (xml.name() == "suggestion") { QStringRef str = xml.attributes().value("data"); choices << str.toString(); } - else if (xml.name() == "num_queries") { + if (xml.tokenType() == QXmlStreamReader::StartElement) + if (xml.name() == "num_queries") { QStringRef str = xml.attributes().value("int"); hits << str.toString(); } - } } showCompletion(choices, hits); @@ -220,3 +231,4 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) networkReply->deleteLater(); } +//! [9] \ No newline at end of file diff --git a/examples/network/googlesuggest/googlesuggest.h b/examples/network/googlesuggest/googlesuggest.h index 2a3c878..c33df36 100644 --- a/examples/network/googlesuggest/googlesuggest.h +++ b/examples/network/googlesuggest/googlesuggest.h @@ -42,8 +42,9 @@ #ifndef GOOGLESUGGEST_H #define GOOGLESUGGEST_H +#include +#include #include -#include QT_BEGIN_NAMESPACE class QLineEdit; @@ -52,6 +53,7 @@ class QTimer; class QTreeWidget; QT_END_NAMESPACE +//! [1] class GSuggestCompletion : public QObject { Q_OBJECT @@ -75,6 +77,6 @@ private: QTimer *timer; QNetworkAccessManager networkManager; }; - +//! [1] #endif // GOOGLESUGGEST_H diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp index 21599e0..ae08a75 100644 --- a/examples/network/googlesuggest/searchbox.cpp +++ b/examples/network/googlesuggest/searchbox.cpp @@ -47,12 +47,12 @@ #define GSEARCH_URL "http://www.google.com/search?q=%1" - +//! [1] SearchBox::SearchBox(QWidget *parent): QLineEdit(parent) { completer = new GSuggestCompletion(this); - connect(this, SIGNAL(returnPressed()), SLOT(doSearch())); + connect(this, SIGNAL(returnPressed()),this, SLOT(doSearch())); setWindowTitle("Search with Google"); @@ -60,10 +60,13 @@ SearchBox::SearchBox(QWidget *parent): QLineEdit(parent) resize(400, height()); setFocus(); } +//! [1] +//! [2] void SearchBox::doSearch() { completer->preventSuggest(); QString url = QString(GSEARCH_URL).arg(text()); QDesktopServices::openUrl(QUrl(url)); } +//! [2] \ No newline at end of file diff --git a/examples/network/googlesuggest/searchbox.h b/examples/network/googlesuggest/searchbox.h index 4b03dba..ec18bb0 100644 --- a/examples/network/googlesuggest/searchbox.h +++ b/examples/network/googlesuggest/searchbox.h @@ -42,6 +42,7 @@ #ifndef SEARCHBOX_H #define SEARCHBOX_H +//! [1] #include class GSuggestCompletion; @@ -58,6 +59,7 @@ protected slots: private: GSuggestCompletion *completer; +//! [1] }; -- cgit v0.12 From 9fbcda80c8857202db01f58a9568e16604518b88 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 9 Nov 2009 13:06:06 +0100 Subject: My relevant changes-4.6.0 updates Reviewed-by: TrustMe --- dist/changes-4.6.0 | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 5f73661..f90777d 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -61,6 +61,9 @@ Third party components QtCore + - QByteArray + * New overloads for QByteArray::insert() and QByteArray::prepend() + - QObject * [259514] fixed a possible dead-lock in the destructor @@ -255,24 +258,39 @@ QtGui QtNetwork -- QAbstractSocket + - QAbstractSocket * only disconnect from host when all bytes have been written + * New setSocketOption method. + + - QHttp + * Do not buffer the complete POST data anymore when HTTPS is used. + * QHttp is now obsolete and replaced by QNetworkAccessManager. -- QLocalServer + - QLocalServer * fix timeout when waiting for a connection on Unix -- QNetworkAcessManager + - QNativeSocketEngine + * Do not set the OS socket send and receive buffer size. The OS + should auto tune these values for us. + + - QNetworkAcessManager * [242916] add possibility to send HTTP DELETE requests + * Connection count per HTTP server increased to 6 on Desktop, 3 on Symbian. + * Optional HTTP pipelining support. + * General HTTP performance improvements. -- QNetworkReply + - QNetworkReply * [257322] add possibility to ignore specific SSL errors + * New isFinished() method. -- QSslCertificate + - QSslCertificate * [251830] fix version() and serialNumber() methods -- QSslSocket + - QSslSocket * [257322] add possibility to ignore specific SSL errors * Fix build with openssl 1.0.0 betas + * Trigger a SSL transmission when reading from the socket. In certain + cases the connection stalled when a buffer limit was used. QtOpenGL -- cgit v0.12 From c457aebbba18c5431915a664a02264fae96cc848 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 9 Nov 2009 13:34:44 +0100 Subject: Doc: updated documentation for Google Suggest Example Documented the Google Suggest Example. Adding descriptions and screenshot. and correcting indent Task-number: QT-700 Rev-by: Volker Hilsheimer --- doc/src/examples/googlesuggest.qdoc | 192 ++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/doc/src/examples/googlesuggest.qdoc b/doc/src/examples/googlesuggest.qdoc index f3693e9..ab8ab57 100644 --- a/doc/src/examples/googlesuggest.qdoc +++ b/doc/src/examples/googlesuggest.qdoc @@ -50,145 +50,145 @@ \image googlesuggest-example.png The application makes use of the \c get function in -QNetworkAccessManager to post a request and obtain the result of the search -query sent to the Google search engine. The results returned are listed as -clickable links appearing below the search box as a drop-down menu. + QNetworkAccessManager to post a request and obtain the result of the search + query sent to the Google search engine. The results returned are listed as + clickable links appearing below the search box as a drop-down menu. -The widget is built up by a QLineEdit as the search box, and a QTreeView -used as a popup menu below the search box. + The widget is built up by a QLineEdit as the search box, and a QTreeView + used as a popup menu below the search box. -\section1 GSuggestCompletion Class Declaration + \section1 GSuggestCompletion Class Declaration -This class implements an event filter and a number of functions to display -the search results and to determent when and how to perform the search. + This class implements an event filter and a number of functions to display + the search results and to determent when and how to perform the search. -\snippet examples/network/googlesuggest/googlesuggest.h 1 + \snippet examples/network/googlesuggest/googlesuggest.h 1 -The class connects to a QLineEdit and uses a QTreeWidget to display the -results. A QTimer controls the start of the network requests that are -executed using a QNetworkAccessManager. + The class connects to a QLineEdit and uses a QTreeWidget to display the + results. A QTimer controls the start of the network requests that are + executed using a QNetworkAccessManager. -\section1 GSuggestCompletion Class Implementation + \section1 GSuggestCompletion Class Implementation -We start by defining a constant containing the URL to be used in the Google -queries. This is the basis for the query. The letters typed into the search -box will be added to the query to perform the search itself. + We start by defining a constant containing the URL to be used in the Google + queries. This is the basis for the query. The letters typed into the search + box will be added to the query to perform the search itself. -\snippet examples/network/googlesuggest/googlesuggest.cpp 1 + \snippet examples/network/googlesuggest/googlesuggest.cpp 1 -In the constructor, we set the parent of this GSuggestCompletion instance -to be the QLineEdit passed in. For simplicity, the QLineEdit is also stored -in the explicit \c editor member variable. + In the constructor, we set the parent of this GSuggestCompletion instance + to be the QLineEdit passed in. For simplicity, the QLineEdit is also stored + in the explicit \c editor member variable. -We then create a QTreeWidget as a toplevel widget and configure the various -properties to give it the look of a popup widget. + We then create a QTreeWidget as a toplevel widget and configure the various + properties to give it the look of a popup widget. -The popup will be populated by the results returned from Google. We set -the number of columns to be two, since we want to display both the -suggested search term and the number of hits it will trigger in the search -engine. + The popup will be populated by the results returned from Google. We set + the number of columns to be two, since we want to display both the + suggested search term and the number of hits it will trigger in the search + engine. -Furthermore, we install the GSuggestCompletion instance as an event filter -on the QTreeWidget, and connect the \c itemClicked() signal with the \c -doneCompletion() slot. + Furthermore, we install the GSuggestCompletion instance as an event filter + on the QTreeWidget, and connect the \c itemClicked() signal with the \c + doneCompletion() slot. -A single-shot QTimer is used to start the request when the user has stopped -typing for 500 ms. + A single-shot QTimer is used to start the request when the user has stopped + typing for 500 ms. -Finally, we connect the networkManagers \c finished() signal with the \c -handleNetworkData() slot to handle the incoming data. + Finally, we connect the networkManagers \c finished() signal with the \c + handleNetworkData() slot to handle the incoming data. -\snippet examples/network/googlesuggest/googlesuggest.cpp 2 + \snippet examples/network/googlesuggest/googlesuggest.cpp 2 -Since the QTreeWidget popup has been instantiated as a toplevel widget, the -destructor has to delete it explicitly from memory to avoid a memory leak. + Since the QTreeWidget popup has been instantiated as a toplevel widget, the + destructor has to delete it explicitly from memory to avoid a memory leak. -\snippet examples/network/googlesuggest/googlesuggest.cpp 3 + \snippet examples/network/googlesuggest/googlesuggest.cpp 3 -The event filter handles mouse press and key press events that are -delivered to the popup. For mouse press events we just hide the popup and -return focus to the editor widget, and then return true to prevent further -event processing. + The event filter handles mouse press and key press events that are + delivered to the popup. For mouse press events we just hide the popup and + return focus to the editor widget, and then return true to prevent further + event processing. -Key event handling is implemented so that Enter and Return execute the -selected link, while the Escape key hides the popup. Sine we want to be -able to navigate the list of suggestions using the different navigation -keys on the keyboard we let Qt continue regular event processing for those -by returning false from the eventFilter reimplementation. + Key event handling is implemented so that Enter and Return execute the + selected link, while the Escape key hides the popup. Sine we want to be + able to navigate the list of suggestions using the different navigation + keys on the keyboard we let Qt continue regular event processing for those + by returning false from the eventFilter reimplementation. -For all other keys, the event will be passed on to the editor widget and the -popup is hidden. This way the user's typing will not be interrupted by the -popping up of the completion list. + For all other keys, the event will be passed on to the editor widget and the + popup is hidden. This way the user's typing will not be interrupted by the + popping up of the completion list. -\snippet examples/network/googlesuggest/googlesuggest.cpp 4 + \snippet examples/network/googlesuggest/googlesuggest.cpp 4 -The \c showCompletion() function populates the QTreeWidget with the results -returned from the query. It takes two QStringLists, one with the suggested -search terms and the other with the corresponding number of hits. + The \c showCompletion() function populates the QTreeWidget with the results + returned from the query. It takes two QStringLists, one with the suggested + search terms and the other with the corresponding number of hits. -\snippet examples/network/googlesuggest/googlesuggest.cpp 5 + \snippet examples/network/googlesuggest/googlesuggest.cpp 5 -A QTreeWidgetItem is created for each index in the list and inserted into -the QTreeWidget. Finally, we adjust position and size of the popup to make -sure that it pops up in the correct position below the editor, and show it. + A QTreeWidgetItem is created for each index in the list and inserted into + the QTreeWidget. Finally, we adjust position and size of the popup to make + sure that it pops up in the correct position below the editor, and show it. -The \c doneCompletion() function, which is called by the event filter when -either Enter or Return keys are pressed, stops the timer to prevent further -requests and passes the text of the selected item to the editor. We then -make the \c editor QLineEdit emit the returnPressed() signal, to which the -application can connect to open the respective web page. + The \c doneCompletion() function, which is called by the event filter when + either Enter or Return keys are pressed, stops the timer to prevent further + requests and passes the text of the selected item to the editor. We then + make the \c editor QLineEdit emit the returnPressed() signal, to which the + application can connect to open the respective web page. -\snippet examples/network/googlesuggest/googlesuggest.cpp 6 + \snippet examples/network/googlesuggest/googlesuggest.cpp 6 -The \c autoSuggest() slot is called when the timer times out, and uses the -text in the editor to build the complete search query. The query is then -passed to the QNetworkAccessManager's \c get() function to start the -request. + The \c autoSuggest() slot is called when the timer times out, and uses the + text in the editor to build the complete search query. The query is then + passed to the QNetworkAccessManager's \c get() function to start the + request. -\snippet examples/network/googlesuggest/googlesuggest.cpp 7 + \snippet examples/network/googlesuggest/googlesuggest.cpp 7 -The function \c preventSuggest() stops the timer to prevent further -requests from being started. + The function \c preventSuggest() stops the timer to prevent further + requests from being started. -\snippet examples/network/googlesuggest/googlesuggest.cpp 8 + \snippet examples/network/googlesuggest/googlesuggest.cpp 8 -When the network request is finished, the QNetworkAccessManager delivers the -data received from the server through the networkReply object. + When the network request is finished, the QNetworkAccessManager delivers the + data received from the server through the networkReply object. -\snippet examples/network/googlesuggest/googlesuggest.cpp 9 + \snippet examples/network/googlesuggest/googlesuggest.cpp 9 -To extract the data from the reply we use the \c readAll() function, which -is inherited from QIODevice and returns a QByteArray. Since this data is -encoded in XML we can use a QXmlStreamReader to traverse the data and -extract the search result as QStrings, which we can stream into two -QStringLists used to populate the popup. + To extract the data from the reply we use the \c readAll() function, which + is inherited from QIODevice and returns a QByteArray. Since this data is + encoded in XML we can use a QXmlStreamReader to traverse the data and + extract the search result as QStrings, which we can stream into two + QStringLists used to populate the popup. -Finally, we schedule the QNetworkReply object for deletion using the \c -deleteLater function. + Finally, we schedule the QNetworkReply object for deletion using the \c + deleteLater function. -\section1 SearchBox Class Declaration + \section1 SearchBox Class Declaration -The SearchBox class inherits QLineEdit and adds the protected slot \c -doSearch(). + The SearchBox class inherits QLineEdit and adds the protected slot \c + doSearch(). -A \c GSuggestCompletion member provides the SearchBox with the request -functionality and the suggestions returned from the Google search engine. + A \c GSuggestCompletion member provides the SearchBox with the request + functionality and the suggestions returned from the Google search engine. -\snippet examples/network/googlesuggest/searchbox.h 1 + \snippet examples/network/googlesuggest/searchbox.h 1 -\section1 SearchBox Class Implementation + \section1 SearchBox Class Implementation -The search box constructor instantiates the GSuggestCompletion object and -connects the returnPressed() signal to the doSearch() slot. + The search box constructor instantiates the GSuggestCompletion object and + connects the returnPressed() signal to the doSearch() slot. -\snippet examples/network/googlesuggest/searchbox.cpp 1 + \snippet examples/network/googlesuggest/searchbox.cpp 1 -The function \c doSearch() stops the completer from sending any further -queries to the search engine. + The function \c doSearch() stops the completer from sending any further + queries to the search engine. -Further, the function extracts the selected search phrase and opens it in -the default web browser using QDesktopServices. + Further, the function extracts the selected search phrase and opens it + in the default web browser using QDesktopServices. -\snippet examples/network/googlesuggest/searchbox.cpp 2 + \snippet examples/network/googlesuggest/searchbox.cpp 2 */ -- cgit v0.12 From f3ec877e6a606304ce766aebbb6886887ded37a2 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 10 Nov 2009 00:23:18 +1000 Subject: Update INSTALL and README + friends for the everywhere package Make INSTALL and README more generic, avoid repeating stuff that's already in the product docs, and move the Windows Signing stuff into the product docs. Task-number: QTBUG-5453 Reviewed-by: Espen Riskedal --- INSTALL | 156 ++----------------------- README.s60 | 184 ------------------------------ README.wince | 44 ------- dist/README | 33 +++--- doc/src/getting-started/installation.qdoc | 5 +- doc/src/platforms/wince-signing.qdoc | 96 ++++++++++++++++ 6 files changed, 127 insertions(+), 391 deletions(-) delete mode 100644 README.s60 delete mode 100644 README.wince create mode 100644 doc/src/platforms/wince-signing.qdoc diff --git a/INSTALL b/INSTALL index 092dea0..b62f21d 100644 --- a/INSTALL +++ b/INSTALL @@ -1,148 +1,14 @@ INSTALLING Qt Source Package Version %VERSION%. -1. If you have the commercial edition of Qt, install your license - file as $HOME/.qt-license if you are on Unix. If you are on - Windows, copy the license file into your home directory - (this may be known as the userprofile environment variable) and - rename it to .qt-license. For example on Windows XP, - %USERPROFILE% should be something like C:\Documents and - Settings\username. +For full installation instructions for each supported platform, please +see http://qt.nokia.com/doc/%VERSION%/installation.html, the file +doc/html/installation.html in this package, or follow one of the following +links: + +Embedded Linux: http://qt.nokia.com/doc/%VERSION%/qt-embedded-install.html +Mac OS X: http://qt.nokia.com/doc/%VERSION%/install-mac.html +Windows: http://qt.nokia.com/doc/%VERSION%/install-win.html +Windows CE: http://qt.nokia.com/doc/%VERSION%/install-wince.html +X11 Platforms: http://qt.nokia.com/doc/%VERSION%/install-x11.html +Symbian Platform: http://qt.nokia.com/doc/%VERSION%/install-symbian.html - For the open source version you do not need a license file. - -2. Unpack the archive if you have not done so already: - - On Unix (X11 and Mac): - cd /tmp - gunzip %DISTNAME%.tar.gz # uncompress the archive - tar xvf %DISTNAME%.tar # unpack it - - This creates the directory /tmp/%DISTNAME% containing the files - from the archive. We only support the GNU version of the tar - archiving utility. Note that on some systems it is called gtar. - - On Windows, uncompress the files into the directory you want Qt - installed, e.g. C:\Qt\%VERSION%. - - NOTE: The install path must not contain any spaces. - -4. Environment variables - - In order to build and use Qt, the PATH environment variable needs - to be extended to locate qmake, moc and other Qt tools - - On Windows, this is done by adding C:\Qt\%VERSION%\bin - to the PATH variable. On Unix, this is done by adding - /tmp/%DISTNAME%. - - For newer versions of Windows, PATH can be extended through - "Control Panel->System->Advanced->Environment variables" and for - older versions by editing C:\autoexec.bat. - - In .profile (if your Unix shell is bash), add the following lines: - - PATH=/usr/local/Trolltech/Qt-%VERSION%/bin:$PATH - export PATH - - In .login (in case your Unix shell is csh or tcsh), add the following line: - - setenv PATH /usr/local/Trolltech/Qt-%VERSION%/bin:$PATH - - If you use a different Unix shell, please modify your environment - variables accordingly. - - For some X11 compilers that do not support rpath you must also - extended the LD_LIBRARY_PATH environment variable to include - /usr/local/Trolltech/Qt-%VERSION%/lib. On Linux or Mac with GCC - this step is not needed. - -4. Building - -4.1 Building on Unix - - To configure the Qt library for your machine type, run the - ./configure script in the package directory. - - By default, Qt is configured for installation in the - /usr/local/Trolltech/Qt-%VERSION% directory, but this can be - changed by using the -prefix option. - - cd /tmp/%DISTNAME% - ./configure - - Type "./configure -help" to get a list of all available options. - - To create the library and compile all the demos, examples, tools, - and tutorials, type: - - make - - If you did not configure Qt using the -prefix-install option, - you need to install the library, demos, examples, tools, and - tutorials in the appropriate place. To do this, type: - - su -c "make install" - - and enter the root password. On some systems, you have to use the - sudo command as follows: - - sudo make install - - and enter your password, this requires that you have administrator access - to your machine. - - Note that on some systems the make utility is named differently, - e.g. gmake. The configure script tells you which make utility to - use. - - If you need to reconfigure and rebuild Qt from the same location, - ensure that all traces of the previous configuration are removed - by entering the build directory and typing - - make confclean - - before running the configure script again. - -4.2 Building on Windows - - To configure the Qt library for your machine type: - - C: - cd \Qt\%VERSION% - configure - - Type "configure -help" to get a list of all available options. - - If you are using the "-direct3d" option, make sure that you have - the Direct3D SDK installed, and that you have run the - %DXSDK_DIR%\Utilities\Bin\dx_setenv.cmd command, before attempting - to run configure. - - The actual commands needed to build Qt depends on your development - system. For Microsoft Visual Studio to create the library and - compile all the demos, examples, tools and tutorials type: - - nmake - - If you need to reconfigure and rebuild Qt from the same location, - ensure that all traces of the previous configuration are removed - by entering the build directory and typing - - nmake confclean - - before running the configure script again. - -5. That's all. Qt is now installed. - - If you are new to Qt, we suggest that you take a look at the demos - and examples to see Qt in action. Run the Qt Examples and Demos - either by typing 'qtdemo' on the command line or through the - desktop's Start menu. - - You might also want to try the following links: - - http://qt.nokia.com/doc/%VERSION%/how-to-learn-qt.html - http://qt.nokia.com/doc/%VERSION%/tutorial.html - http://qt.nokia.com/developer - - We hope you will enjoy using Qt. Good luck! diff --git a/README.s60 b/README.s60 deleted file mode 100644 index 2137135..0000000 --- a/README.s60 +++ /dev/null @@ -1,184 +0,0 @@ -This is Qt version %VERSION%. - -Qt is a comprehensive cross-platform C++ application framework. With -this pre-release you can make advanced graphical applications and -utilize TCP/IP connections. More specifically, these modules are now -available for S60: - -QtCore - http://doc.trolltech.com/4.6-snapshot/qtcore.html -QtGui - http://doc.trolltech.com/4.6-snapshot/qtgui.html -QtNetwork - http://doc.trolltech.com/4.6-snapshot/qtnetwork.html -QtScript - http://doc.trolltech.com/4.6-snapshot/qtscript.html -QtSql - http://doc.trolltech.com/4.6-snapshot/qtsql.html -QtSvg - http://doc.trolltech.com/4.6-snapshot/qtsvg.html -QtTest - http://doc.trolltech.com/4.6-snapshot/qttest.html -QtWebKit - http://doc.trolltech.com/4.6-snapshot/qtwebkit.html -QtXml - http://doc.trolltech.com/4.6-snapshot/qtxml.html -Phonon - http://doc.trolltech.com/4.6-snapshot/phonon-module.html - -INSTALLING Qt - -Follow the instructions in the INSTALL file. - -REFERENCE DOCUMENTATION - -The Qt reference documentation is available locally in Qt's doc/html -directory or at http://doc.trolltech.com/4.6-snapshot/index.html - -SUPPORTED PLATFORMS - -For this release, the following platforms have been tested: - - S60 3.1, 3.2 and 5.0 - -with these compilers: - - WINSCW (Emulator, X86) - RVCT (Hardware, ARM) - GCCE (Hardware, ARM)* - -The current version of GCCE cannot compile the Qt libraries -themselves as it has issues with global static data in DLLs. -However, we supply precompiled Qt libraries compiled with RVCT -that can be used instead. This makes it possible to write and -compile Qt applications using GCCE by linking to these -precompiled binaries. For more information on this issue see: -http://www3.symbian.com/faq.nsf/0/B8542F039C193CCC802573DA0011DFA7 - -HOW TO REPORT A BUG - -We have set up a special mailinglist for feedback on the S60 port. -Bug-reports, feedback or questions all go to this list. -Please go to http://pepper.troll.no/s60prereleases/ -for details on how to subscribe to the list. - -Before posting, please consult the FAQ and the list of known issues: -http://labs.trolltech.com/page/QtforS60FAQ -http://labs.trolltech.com/page/QtforS60KnownIssues - -Always include the following information in your bug report: the name -and version number of your compiler; the name and version number of -your operating system; the version of Qt you are using, and what -configure options it was compiled with. - -If the problem you are reporting is only visible at run-time, try to -create a small test program that shows the problem when run. Often, -such a program can be created with some minor changes to one of the -many example programs in Qt's examples directory. - - - INSTALLING Qt for S60 Version %VERSION% - -1. Install needed IDE and SDKs - - Make sure you have the following installed: - - - Carbide.c++ v2.0.0 or higher: - http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/ - - Note: It may be necessary to update the Carbide compiler. - See http://pepper.troll.no/s60prereleases/patches/ for instructions - how to check your compiler version and how to patch it, if needed. - - - S60 Platform SDK 3rd Edition FP1 or higher: - http://www.forum.nokia.com/main/resources/tools_and_sdks/S60SDK/ - - - Open C/C++ v1.6.0 or higher. Install this to all S60 SDKs you plan to use Qt with: - http://www.forum.nokia.com/main/resources/technologies/openc_cpp/ - - - Building Qt tools requires a windows compiler, e.g. MinGW 3.4.5 or higher. - http://www.mingw.org/ - - - Building Qt libraries for real device requires RVCT 2.2 [build 686] or later: - http://www.arm.com/products/DevTools/RVCT.html - - Make sure you have the following packages installed on any device you want to use to - run Qt applications. These packages can be found under nokia_plugin directory in any - S60 SDK where you have installed Open C/C++: - - - nokia_plugin\openc\s60opencsis\pips_s60_.sis - - nokia_plugin\openc\s60opencsis\openc_ssl_s60_.sis - - nokia_plugin\opencpp\s60opencppsis\stdcpp_s60_.sis - - These instructions assume the above tools are installed and - that the enviroment variables for your compiler are set correctly. - - Note: Users of S60 Platform SDK 3rd Edition FP1 also need special updates: - http://pepper.troll.no/s60prereleases/patches/ - -2. Install Qt - - Uncompress the package into the directory you want Qt installed, - e.g. C:\Qt\%VERSION%. - - Note: Qt must be installed on the same drive as the S60 SDK you are - using, and the install path must not contain any whitespaces. - -3. Environment variables - - In order to build and use Qt, the PATH environment variable needs - to be extended: - - PATH - to locate qmake, moc and other Qt tools - - This is done by adding c:\Qt\%VERSION%\bin to the PATH variable. - - On Windows the PATH can be extended by navigating to - "Control Panel->System->Advanced->Environment variables". - - In addition, you must configure the environment for use with the S60 - emulator. This is done by locating the Carbide.c++ submenu on the Start - menu, and choosing "Configure environment for WINSCW command line". - -4. Configure Qt - - To configure Qt for S60, do: - - cd \Qt\%VERSION% - configure -platform win32-g++ -xplatform symbian-abld - - For other options, type "configure -help" to get a list of all available - options. - -5. Build Qt - - To build Qt for the emulator, type: - - make debug-winscw - - To build Qt for the device, type: - - make release-armv5 - - Congratulations, Qt is now ready to use. - -6. Running Qt demos - - We've included a subset of the Qt demos in this package for you to try out. - An excellent starting point is the "fluidlauncher" demo. To run the demo on - a real device, you first have to install the Qt libraries on the device: - - cd src\s60installs - createpackage -i Qt_for_S60_template.pkg release-armv5 - - Note: You will need to supply certificate that allows installation of - binaries with "All -Tcb" capability to your device. - - Similarly, install fluidlauncher to the device: - - cd embedded\fluidlauncher - createpackage -i fluidlauncher_template.pkg release-armv5 - - This will create a self-signed fluidlauncher_release-armv5.sis and install it to your device. - - To run the demos on the emulator simply navigate to the directory of the demo and run: - - make run - - Or, if you need to supply arguments to the program, navigate to - %EPOCROOT%\Epoc32\release\winscw\udeb\ and start any of the Qt demos located there, - for example: - - wiggly.exe -small-screen - - We hope you will enjoy using Qt. diff --git a/README.wince b/README.wince deleted file mode 100644 index 27dfd60..0000000 --- a/README.wince +++ /dev/null @@ -1,44 +0,0 @@ - Signing on Windows CE. - -Windows CE provides a security mechanism to ask the user to confirm -that he wants to use an application/library, which is unknown to the -system. This process gets repeated for each dependency of an -application, meaning each library the application links to, which is -not recognized yet. - -To simplify this process you can use signatures and certificates. A -certificate gets installed on the device and each file which is -signed with the according certificate can be launched without the -security warning. - -In case you want to use signatures for your project written in Qt, -configure provides the -signature option. You need to specify the -location of the .pfx file and qmake adds the signing step to the -build rules. - -If you need to select a separate signature for a specific project, -or you only want to sign this single project, you can use the -"SIGNATURE_FILE = foo.pfx" rule inside the project file. - -The above decribed rules apply for command line makefiles as well as -Visual Studio projects generated by qmake. - -Microsoft usually ships development signatures inside the SDK packages. -You can find them in the Tools subdirectory of the SDK root folder. - -Example: - -1. calling configure with signing enabled: -configure.exe -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005 --signature C:\some\path\SDKSamplePrivDeveloper.pfx - -2. using pro file to specify signature -[inside .pro file] -... -TARGET = foo - -wince*: { - SIGNATURE_FILE = somepath\customSignature.pfx -} -... - diff --git a/dist/README b/dist/README index 05475e7..1c52eb3 100644 --- a/dist/README +++ b/dist/README @@ -19,17 +19,22 @@ On Mac OS X, the binary package requires Mac OS X 10.4.x (Tiger) or later and GCC 4.0.1 to develop applications. Its applications will run on Mac OS X 10.3.9 and above. -If you have a source package (a .tar.gz, .tar.bz2, or .zip file), -follow the instructions in the INSTALL file. +If you have a source package (a .tar.gz, or .zip file), follow the +instructions in the INSTALL file. DEMOS AND EXAMPLES Once Qt is installed, we suggest that you take a look at the demos and -examples to see Qt in action. Run the Qt Examples and Demos either by +examples to see Qt in action. + +For desktop computers, run the Qt Examples and Demos either by typing 'qtdemo' on the command line or through the desktop's Start menu. On Mac OS X, you can find it in /Developers/Applications/Qt. +For embedded devices, launch the Qt 'fluidlauncher' demo, either through +the platforms filebrowser or the built in menu system. + REFERENCE DOCUMENTATION @@ -43,7 +48,7 @@ documentation is available at http://qt.nokia.com/doc/. SUPPORTED PLATFORMS For a complete list of supported platforms, see -http://qt.nokia.com/doc/latest/supported-platforms.html. +http://qt.nokia.com/doc/%VERSION%/supported-platforms.html. COMMERCIAL EDITIONS @@ -56,16 +61,18 @@ the QtCore, QtGui (except QGraphicsView), QtTest, QtDBus and Qt3Support modules. For a full listing of the contents of each module, please refer to -http://qt.nokia.com/doc/latest/modules.html +http://qt.nokia.com/doc/%VERSION%/modules.html HOW TO REPORT A BUG If you think you have found a bug in Qt, we would like to hear about -it so that we can fix it. Before reporting a bug, please check -http://qt.nokia.com/developer/faqs/ and -http://qt.nokia.com/products/appdev/platform/platforms/ to see if -the issue is already known. +it so that we can fix it. The Qt bug tracking system is open to the +public at http://bugreports.qt.nokia.com/. + +Before reporting a bug, please use the bug-tracker's search functions +and consult http://qt.nokia.com/developer/faqs/ to see if the issue is +already known. Always include the following information in your bug report: the name and version number of your compiler; the name and version number of @@ -74,11 +81,9 @@ configure options it was compiled with. If the problem you are reporting is only visible at run-time, try to create a small test program that shows the problem when run. Often, -such a program can be created with some minor changes to one of the -many example programs in Qt's examples directory. Please submit the -bug report using the Task Tracker on the Qt website: - -http://qt.nokia.com/developer/task-tracker +such a program can be created with some minor changes to one of the many +example programs in Qt's examples directory, or to the autotests that +are available in the public source repository on http://qt.gitorious.org/. Qt is a trademark of Nokia Corporation and/or its subsidiary(-ies). diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index 1eefed3..c8e225c 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -39,10 +39,6 @@ ** ****************************************************************************/ -/**************************************************************************** -** Please remember to update the corresponding INSTALL files. -****************************************************************************/ - /*! \group installation \title Installation @@ -484,6 +480,7 @@ in the \l{Qt for Windows CE Requirements} document. \o \l{Windows CE - Introduction to using Qt} \o \l{Windows CE - Working with Custom SDKs} \o \l{Windows CE - Using shadow builds} + \o \l{Windows CE - Signing} \endlist Information on feature and performance tuning for embedded builds can diff --git a/doc/src/platforms/wince-signing.qdoc b/doc/src/platforms/wince-signing.qdoc new file mode 100644 index 0000000..fa383b3 --- /dev/null +++ b/doc/src/platforms/wince-signing.qdoc @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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: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$ +** +****************************************************************************/ + +/*! + \page windowsce-signing.html + \ingroup qtce + \title Windows CE - Signing + \brief How to sign Qt projects for use with Windows CE. + + \section1 Signing on Windows CE + +Windows CE provides a security mechanism to ask the user to confirm +that they want to use an application/library that is unknown to the +system. This process gets repeated for each dependency of an +application, meaning each library the application links to, which is +not recognized yet. + +To simplify this process you can use signatures and certificates. A +certificate gets installed on the device and each file which is +signed with the according certificate can be launched without the +security warning. + +If you want to use signatures for your project written in Qt, +configure provides the \c -signature option. You need to specify the +location of the .pfx file and qmake adds the signing step to the +build rules. + +If you need to select a separate signature for a specific project, +or you only want to sign a single project, you can use the +"SIGNATURE_FILE = foo.pfx" rule inside the project file. + +The above described rules apply for command line makefiles as well as +Visual Studio projects generated by qmake. + +Microsoft usually ships development signatures inside the SDK packages. +You can find them in the Tools subdirectory of the SDK root folder. + +Example: + +\list +\o Calling configure with signing enabled: +\code +configure.exe -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005 -signature C:\some\path\SDKSamplePrivDeveloper.pfx +\endcode + +\o Using pro file to specify signature +\code +... +TARGET = foo + +wince*: { + SIGNATURE_FILE = somepath\customSignature.pfx +} +... +\endcode +\endlist + +*/ -- cgit v0.12 From 4454669fc238171239f8a2f202ec7e26e7409776 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 6 Nov 2009 13:35:46 +0100 Subject: QNetworkCookie: Add the dot prefix of the domain while adding to the jar instead than when parsing the cookie header. This corrects the bug QT-2379, happening in the following sequence: parseCookie -> setCookieUrl -> toRawForm -> parseCookie where a default domain would now also have a dot prefix, and shouldn't. QT-2379 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 8 ++--- src/network/access/qnetworkcookiejar.cpp | 7 ++++ tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 39 +++++++++------------- .../qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 18 ++++++++-- 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 73a8703..7dfb7af 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -984,14 +984,14 @@ QList QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; + QString maybeLeadingDot; if (rawDomain.startsWith('.')) { + maybeLeadingDot = QLatin1Char('.'); rawDomain = rawDomain.mid(1); } + QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain))); - // always add the dot, there are some servers that forget the - // leading dot. This is actually forbidden according to RFC 2109, - // but all browsers accept it anyway so we do that as well - cookie.setDomain(QLatin1Char('.') + normalizedDomain); + cookie.setDomain(maybeLeadingDot + normalizedDomain); } else if (field.first == "max-age") { bool ok = false; int secs = field.second.toInt(&ok); diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 8430966..19f7217 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -198,6 +198,13 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis if (cookie.domain().isEmpty()) { cookie.setDomain(defaultDomain); } else { + // Ensure the domain starts with a dot if its field was not empty + // in the HTTP header. There are some servers that forget the + // leading dot and this is actually forbidden according to RFC 2109, + // but all browsers accept it anyway so we do that as well. + if (!cookie.domain().startsWith(QLatin1Char('.'))) + cookie.setDomain(QLatin1Char('.') + cookie.domain()); + QString domain = cookie.domain(); if (!(isParentDomain(domain, defaultDomain) || isParentDomain(defaultDomain, domain))) { diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 3c4ddd4..94857d7 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); - cookie.setDomain(".qt.nokia.com"); + cookie.setDomain("qt.nokia.com"); QTest::newRow("plain-domain1") << "a=b;domain=qt.nokia.com" << cookie; QTest::newRow("plain-domain2") << "a=b; domain=qt.nokia.com " << cookie; QTest::newRow("plain-domain3") << "a=b;domain=QT.NOKIA.COM" << cookie; @@ -247,32 +247,25 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-domain4") << "a=b; Domain = .QT.NOKIA.COM" << cookie; cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); - QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie; - QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie; - QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie; - QTest::newRow("idn-domain4") << "a=b;domain=D\303\230GN\303\205PENT.troll.NO" << cookie; - QTest::newRow("idn-domain5") << "a=b;domain = D\303\230GN\303\205PENT.troll.NO" << cookie; - - cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); - QTest::newRow("dot-idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie; - QTest::newRow("dot-idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie; - QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; - QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; + QTest::newRow("idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie; + QTest::newRow("idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie; + QTest::newRow("idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; + QTest::newRow("idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; cookie.setDomain(".qt.nokia.com"); cookie.setPath("/"); - QTest::newRow("two-fields") << "a=b;domain=qt.nokia.com;path=/" << cookie; - QTest::newRow("two-fields2") << "a=b; domain=qt.nokia.com; path=/" << cookie; - QTest::newRow("two-fields3") << "a=b; domain=qt.nokia.com ; path=/ " << cookie; - QTest::newRow("two-fields4") << "a=b;path=/; domain=qt.nokia.com" << cookie; - QTest::newRow("two-fields5") << "a=b; path=/ ; domain=qt.nokia.com" << cookie; - QTest::newRow("two-fields6") << "a=b; path= / ; domain =qt.nokia.com" << cookie; + QTest::newRow("two-fields") << "a=b;domain=.qt.nokia.com;path=/" << cookie; + QTest::newRow("two-fields2") << "a=b; domain=.qt.nokia.com; path=/" << cookie; + QTest::newRow("two-fields3") << "a=b; domain=.qt.nokia.com ; path=/ " << cookie; + QTest::newRow("two-fields4") << "a=b;path=/; domain=.qt.nokia.com" << cookie; + QTest::newRow("two-fields5") << "a=b; path=/ ; domain=.qt.nokia.com" << cookie; + QTest::newRow("two-fields6") << "a=b; path= / ; domain =.qt.nokia.com" << cookie; cookie.setSecure(true); - QTest::newRow("three-fields") << "a=b;domain=qt.nokia.com;path=/;secure" << cookie; - QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=qt.nokia.com" << cookie; - QTest::newRow("three-fields3") << "a=b;secure;domain=qt.nokia.com; path=/" << cookie; - QTest::newRow("three-fields4") << "a = b;secure;domain=qt.nokia.com; path=/" << cookie; + QTest::newRow("three-fields") << "a=b;domain=.qt.nokia.com;path=/;secure" << cookie; + QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=.qt.nokia.com" << cookie; + QTest::newRow("three-fields3") << "a=b;secure;domain=.qt.nokia.com; path=/" << cookie; + QTest::newRow("three-fields4") << "a = b;secure;domain=.qt.nokia.com; path=/" << cookie; cookie = QNetworkCookie(); cookie.setName("a"); @@ -664,7 +657,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() cookie.setName("baz"); cookie.setDomain(".qt.nokia.com"); list.prepend(cookie); - QTest::newRow("complex-2") << "baz=bar; path=/; domain=qt.nokia.com, c=d,a=,foo=bar; path=/" << list; + QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list; // cookies obtained from the network: cookie = QNetworkCookie("id", "51706646077999719"); diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 9b9c56a..ff7e78e 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -120,7 +120,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setName("a"); cookie.setPath("/"); - cookie.setDomain("www.foo.tld"); + cookie.setDomain(".foo.tld"); result += cookie; QTest::newRow("just-add") << preset << cookie << "http://www.foo.tld" << result << true; @@ -148,6 +148,20 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setPath("/"); QTest::newRow("diff-path-order") << preset << cookie << "http://www.foo.tld" << result << true; + preset.clear(); + result.clear(); + QNetworkCookie finalCookie = cookie; + cookie.setDomain("foo.tld"); + finalCookie.setDomain(".foo.tld"); + result += finalCookie; + QTest::newRow("should-add-dot-prefix") << preset << cookie << "http://www.foo.tld" << result << true; + + result.clear(); + cookie.setDomain(""); + finalCookie.setDomain("www.foo.tld"); + result += finalCookie; + QTest::newRow("should-set-default-domain") << preset << cookie << "http://www.foo.tld" << result << true; + // security test: result.clear(); preset.clear(); @@ -159,7 +173,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false; // setting the defaults: - QNetworkCookie finalCookie = cookie; + finalCookie = cookie; finalCookie.setPath("/something/"); cookie.setPath(""); cookie.setDomain(""); -- cgit v0.12 From 10e3bb5c7b88c26cc96d08f887a4457643276d89 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 9 Nov 2009 16:21:40 +0100 Subject: Assistant: Add missing initialization of member variable. Reviewed-by: kh1 --- tools/assistant/tools/assistant/bookmarkmanager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index 9cccd82..511a56e 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -621,6 +621,7 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine) : treeModel(new BookmarkModel(0, 1, this)) , listModel(new BookmarkModel(0, 1, this)) + , renameItem(0) , helpEngine(_helpEngine) { folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); -- cgit v0.12 From b770abdd564f28a8d9dde816f72f73e6b15984af Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 9 Nov 2009 16:24:17 +0100 Subject: Dont set DontCreateNativeAncestors attribute. This fixes painting artifacts on dock widgets. It would be nice to use this attribute again once the painting is fixed. Reviewed-by: trustme --- src/gui/kernel/qwidget_win.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 566e18c..fde0d45 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -2073,7 +2073,6 @@ void QWidgetPrivate::winSetupGestures() (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; if (!winid) { - q->setAttribute(Qt::WA_DontCreateNativeAncestors); winid = q->winId(); // enforces the native winid on the viewport } } -- cgit v0.12 From af0c43f19218996bab844da4dd6f298d405ebcee Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 9 Nov 2009 16:51:05 +0100 Subject: Code in gui/* should be completely namespaced And not rely on random QT_USE_NAMESPACE being pulled in from *.moc files. --- src/gui/kernel/qwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 271b939..2d2aa2e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11781,10 +11781,6 @@ void QWidget::ungrabGesture(Qt::GestureType gesture) } -QT_END_NAMESPACE - -#include "moc_qwidget.cpp" - /*! \typedef WId \relates QWidget @@ -12101,3 +12097,8 @@ void QWidgetPrivate::_q_delayedDestroy(WId winId) delete winId; } #endif + +QT_END_NAMESPACE + +#include "moc_qwidget.cpp" + -- cgit v0.12 From 19f8781c17019048693ec32833af49ce00be4c72 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 9 Nov 2009 17:52:57 +0100 Subject: Move QCustomScopedPointer to a private header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API is internal, so it should live in its private header. The class was introduced during the lifetime of 4.6 (not in 4.5), so the move is binary compatible. Task-number: QTBUG-5617 Reviewed-by: João Abecasis --- src/corelib/io/qsettings_p.h | 1 + src/corelib/tools/qscopedpointer.h | 84 ------------ src/corelib/tools/qscopedpointer_p.h | 151 +++++++++++++++++++++ src/corelib/tools/tools.pri | 3 +- .../qscriptdebuggerconsolecommandgroupdata_p.h | 2 +- src/scripttools/debugging/qscriptdebuggervalue_p.h | 2 +- .../debugging/qscriptdebuggervalueproperty_p.h | 2 +- src/scripttools/debugging/qscriptscriptdata_p.h | 2 +- src/scripttools/debugging/qscriptvalueproperty_p.h | 2 +- 9 files changed, 159 insertions(+), 90 deletions(-) create mode 100644 src/corelib/tools/qscopedpointer_p.h diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index bcd8744..5ad72e4 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -62,6 +62,7 @@ #ifndef QT_NO_QOBJECT #include "private/qobject_p.h" #endif +#include "private/qscopedpointer_p.h" #ifdef Q_OS_WIN #include "QtCore/qt_windows.h" diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 7cbdb6c..2dedcc5 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -217,90 +217,6 @@ private: Q_DISABLE_COPY(QScopedArrayPointer) }; -/* Internal helper class - exposes the data through data_ptr (legacy from QShared). - Required for some internal Qt classes, do not use otherwise. */ -template > -class QCustomScopedPointer : public QScopedPointer -{ -public: - explicit inline QCustomScopedPointer(T *p = 0) - : QScopedPointer(p) - { - } - - inline T *&data_ptr() - { - return this->d; - } - - inline bool operator==(const QCustomScopedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QCustomScopedPointer &other) const - { - return this->d != other.d; - } - -private: - Q_DISABLE_COPY(QCustomScopedPointer) -}; - -/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */ -template -class QScopedPointerSharedDeleter -{ -public: - static inline void cleanup(T *d) - { - if (d && !d->ref.deref()) - delete d; - } -}; - -/* Internal. - This class is basically a scoped pointer pointing to a ref-counted object - */ -template -class QScopedSharedPointer : public QCustomScopedPointer > -{ -public: - explicit inline QScopedSharedPointer(T *p = 0) - : QCustomScopedPointer >(p) - { - } - - inline void detach() - { - qAtomicDetach(this->d); - } - - inline void assign(T *other) - { - if (this->d == other) - return; - if (other) - other->ref.ref(); - T *oldD = this->d; - this->d = other; - QScopedPointerSharedDeleter::cleanup(oldD); - } - - inline bool operator==(const QScopedSharedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedSharedPointer &other) const - { - return this->d != other.d; - } - -private: - Q_DISABLE_COPY(QScopedSharedPointer) -}; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h new file mode 100644 index 0000000..fb627a4 --- /dev/null +++ b/src/corelib/tools/qscopedpointer_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#ifndef QSCOPEDPOINTER_P_H +#define QSCOPEDPOINTER_P_H + +#include "QtCore/qscopedpointer.h" + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE +QT_MODULE(Core) + + +/* Internal helper class - exposes the data through data_ptr (legacy from QShared). + Required for some internal Qt classes, do not use otherwise. */ +template > +class QCustomScopedPointer : public QScopedPointer +{ +public: + explicit inline QCustomScopedPointer(T *p = 0) + : QScopedPointer(p) + { + } + + inline T *&data_ptr() + { + return this->d; + } + + inline bool operator==(const QCustomScopedPointer &other) const + { + return this->d == other.d; + } + + inline bool operator!=(const QCustomScopedPointer &other) const + { + return this->d != other.d; + } + +private: + Q_DISABLE_COPY(QCustomScopedPointer) +}; + +/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */ +template +class QScopedPointerSharedDeleter +{ +public: + static inline void cleanup(T *d) + { + if (d && !d->ref.deref()) + delete d; + } +}; + +/* Internal. + This class is basically a scoped pointer pointing to a ref-counted object + */ +template +class QScopedSharedPointer : public QCustomScopedPointer > +{ +public: + explicit inline QScopedSharedPointer(T *p = 0) + : QCustomScopedPointer >(p) + { + } + + inline void detach() + { + qAtomicDetach(this->d); + } + + inline void assign(T *other) + { + if (this->d == other) + return; + if (other) + other->ref.ref(); + T *oldD = this->d; + this->d = other; + QScopedPointerSharedDeleter::cleanup(oldD); + } + + inline bool operator==(const QScopedSharedPointer &other) const + { + return this->d == other.d; + } + + inline bool operator!=(const QScopedSharedPointer &other) const + { + return this->d != other.d; + } + +private: + Q_DISABLE_COPY(QScopedSharedPointer) +}; + + +QT_END_NAMESPACE +QT_END_HEADER + +#endif diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 007b763..3406e41 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -44,7 +44,8 @@ HEADERS += \ tools/qunicodetables_p.h \ tools/qvarlengtharray.h \ tools/qvector.h \ - tools/qscopedpointer.h + tools/qscopedpointer.h \ + tools/qscopedpointer_p.h SOURCES += \ diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h index 4a9447a..2513a8c 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h +++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h @@ -54,7 +54,7 @@ // #include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/scripttools/debugging/qscriptdebuggervalue_p.h b/src/scripttools/debugging/qscriptdebuggervalue_p.h index 2f1da1e..452f7ea 100644 --- a/src/scripttools/debugging/qscriptdebuggervalue_p.h +++ b/src/scripttools/debugging/qscriptdebuggervalue_p.h @@ -54,7 +54,7 @@ // #include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h index 2ec6124..b130307 100644 --- a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h +++ b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h @@ -55,7 +55,7 @@ #include #include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/scripttools/debugging/qscriptscriptdata_p.h b/src/scripttools/debugging/qscriptscriptdata_p.h index 5006c19..f42ffa5 100644 --- a/src/scripttools/debugging/qscriptscriptdata_p.h +++ b/src/scripttools/debugging/qscriptscriptdata_p.h @@ -54,7 +54,7 @@ // #include -#include +#include #include #include diff --git a/src/scripttools/debugging/qscriptvalueproperty_p.h b/src/scripttools/debugging/qscriptvalueproperty_p.h index 61b239d..ca290a1 100644 --- a/src/scripttools/debugging/qscriptvalueproperty_p.h +++ b/src/scripttools/debugging/qscriptvalueproperty_p.h @@ -55,7 +55,7 @@ #include #include -#include +#include #include QT_BEGIN_NAMESPACE -- cgit v0.12 From 9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Mon, 9 Nov 2009 13:56:46 +1000 Subject: Don't reset view if a query fails. The view of a table gets reset if for example a query fails. However this also resets and removes the Header views of the table. A better solution visually is to keep them displayed. Task-number: QTBUG-3162 --- src/sql/models/qsqlquerymodel.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp index 1719239..319055e 100644 --- a/src/sql/models/qsqlquerymodel.cpp +++ b/src/sql/models/qsqlquerymodel.cpp @@ -314,6 +314,7 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query) QSqlRecord newRec = query.record(); bool columnsChanged = (newRec != d->rec); bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize); + bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid(); if (d->colOffsets.size() != newRec.count() || columnsChanged) d->initColOffsets(newRec.count()); @@ -328,13 +329,13 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query) d->error = QSqlError(); d->query = query; d->rec = newRec; - + if (mustClearModel) endRemoveRows(); - - d->atEnd = false; - if (columnsChanged) + d->atEnd = false; + + if (columnsChanged && hasNewData) reset(); if (!query.isActive() || query.isForwardOnly()) { -- cgit v0.12 From 74d3a4bf9654c8bbe9139951cc5c9352015438a6 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 10 Nov 2009 13:07:46 +1000 Subject: Changes to low-level audio API. QAudioFormat::isNull() -> QAudioFormat::isValid() (inverse logic) QAudio::SuspendState -> QAudio::SuspendedState QAudio::StopState -> QAudio::StoppedState QAudioDeviceInfo::deviceList() -> QAudioDeviceInfo::availableDevices() clock() -> elapsedUSecs() totalTime() -> processedUSecs() QIODevice* start(QIODevice*) -> void start(QIODevice*), QIODevice* start() Reviewed-by:Justin McPherson --- examples/multimedia/audiodevices/audiodevices.cpp | 2 +- examples/multimedia/audioinput/audioinput.cpp | 10 ++-- examples/multimedia/audiooutput/audiooutput.cpp | 12 ++--- src/multimedia/audio/qaudio.cpp | 24 ++++----- src/multimedia/audio/qaudio.h | 2 +- src/multimedia/audio/qaudiodevicefactory.cpp | 22 ++++---- src/multimedia/audio/qaudiodevicefactory_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo.cpp | 8 +-- src/multimedia/audio/qaudiodeviceinfo.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 6 +-- src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 3 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 2 +- src/multimedia/audio/qaudioengine.cpp | 8 +-- src/multimedia/audio/qaudioengine.h | 8 +-- src/multimedia/audio/qaudioengineplugin.h | 4 +- src/multimedia/audio/qaudioformat.cpp | 13 +++-- src/multimedia/audio/qaudioformat.h | 2 +- src/multimedia/audio/qaudioinput.cpp | 63 ++++++++++------------ src/multimedia/audio/qaudioinput.h | 8 ++- src/multimedia/audio/qaudioinput_alsa_p.cpp | 28 +++++----- src/multimedia/audio/qaudioinput_alsa_p.h | 4 +- src/multimedia/audio/qaudioinput_mac_p.cpp | 24 ++++----- src/multimedia/audio/qaudioinput_mac_p.h | 4 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 39 +++++++------- src/multimedia/audio/qaudioinput_win32_p.h | 4 +- src/multimedia/audio/qaudiooutput.cpp | 52 ++++++++---------- src/multimedia/audio/qaudiooutput.h | 8 ++- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 32 +++++------ src/multimedia/audio/qaudiooutput_alsa_p.h | 4 +- src/multimedia/audio/qaudiooutput_mac_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_mac_p.h | 4 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_win32_p.h | 4 +- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 6 +-- tests/auto/qaudioformat/tst_qaudioformat.cpp | 15 +++--- tests/auto/qaudioinput/tst_qaudioinput.cpp | 14 ++--- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 18 +++---- 40 files changed, 249 insertions(+), 270 deletions(-) diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index e205e03..4198605 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -148,7 +148,7 @@ void AudioTest::modeChanged(int idx) mode=QAudio::AudioOutput; deviceBox->clear(); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(mode)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); } diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 62afd73..3d537a2 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -170,7 +170,7 @@ InputTest::InputTest() layout->addWidget(canvas); deviceBox = new QComboBox(this); - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) { deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); } @@ -216,7 +216,7 @@ InputTest::~InputTest() {} void InputTest::status() { - qWarning()<<"bytesReady = "<bytesReady()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); + qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; } void InputTest::readMore() @@ -239,7 +239,7 @@ void InputTest::toggleMode() if (pullMode) { button->setText(tr("Click for Pull Mode")); - input = audioInput->start(); + input = audioInput->start(0); connect(input,SIGNAL(readyRead()),SLOT(readMore())); pullMode = false; } else { @@ -252,7 +252,7 @@ void InputTest::toggleMode() void InputTest::toggleSuspend() { // toggle suspend/resume - if(audioInput->state() == QAudio::SuspendedState) { + if(audioInput->state() == QAudio::SuspendState) { qWarning()<<"status: Suspended, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); @@ -260,7 +260,7 @@ void InputTest::toggleSuspend() qWarning()<<"status: Active, suspend()"; audioInput->suspend(); button2->setText("Click To Resume"); - } else if (audioInput->state() == QAudio::StoppedState) { + } else if (audioInput->state() == QAudio::StopState) { qWarning()<<"status: Stopped, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 244840d..c92bbaf 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -134,7 +134,7 @@ AudioTest::AudioTest() QVBoxLayout* layout = new QVBoxLayout; deviceBox = new QComboBox(this); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -200,7 +200,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::status() { - qWarning()<<"byteFree = "<bytesFree()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); + qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; } void AudioTest::writeMore() @@ -208,7 +208,7 @@ void AudioTest::writeMore() if(!audioOutput) return; - if(audioOutput->state() == QAudio::StoppedState) + if(audioOutput->state() == QAudio::StopState) return; int l; @@ -234,7 +234,7 @@ void AudioTest::toggle() if (pullMode) { button->setText("Click for Pull Mode"); - output = audioOutput->start(); + output = audioOutput->start(0); pullMode = false; timer->start(20); } else { @@ -247,7 +247,7 @@ void AudioTest::toggle() void AudioTest::togglePlay() { // toggle suspend/resume - if(audioOutput->state() == QAudio::SuspendedState) { + if(audioOutput->state() == QAudio::SuspendState) { qWarning()<<"status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); @@ -255,7 +255,7 @@ void AudioTest::togglePlay() qWarning()<<"status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); - } else if (audioOutput->state() == QAudio::StoppedState) { + } else if (audioOutput->state() == QAudio::StopState) { qWarning()<<"status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index b687f34..04378d4 100644 --- a/src/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp @@ -71,23 +71,23 @@ public: /*! \enum QAudio::Error - \value NoError No errors have occurred - \value OpenError An error opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. + \value NoError No errors have occurred + \value OpenError An error opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. */ /*! \enum QAudio::State - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendedState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StoppedState The audio device is closed, not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StopState The audio device is closed, not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. */ /*! diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h index 531e1a7..a66f0b1 100644 --- a/src/multimedia/audio/qaudio.h +++ b/src/multimedia/audio/qaudio.h @@ -56,7 +56,7 @@ QT_MODULE(Multimedia) namespace QAudio { enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; - enum State { ActiveState, SuspendedState, StoppedState, IdleState }; + enum State { ActiveState, SuspendState, StopState, IdleState }; enum Mode { AudioInput, AudioOutput }; } diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 89e4394..8804fb6 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -94,10 +94,10 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } + qint64 totalTime() const { return 0; } + qint64 clock() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } + QAudio::State state() const { return QAudio::StopState; } QAudioFormat format() const { return QAudioFormat(); } }; @@ -115,18 +115,18 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } + qint64 totalTime() const { return 0; } + qint64 clock() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } + QAudio::State state() const { return QAudio::StopState; } QAudioFormat format() const { return QAudioFormat(); } }; -QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) +QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) { QList devices; #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif QFactoryLoader* l = loader(); @@ -134,7 +134,7 @@ QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) foreach (QString const& key, l->keys()) { QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); if (plugin) { - foreach (QByteArray const& handle, plugin->availableDevices(mode)) + foreach (QByteArray const& handle, plugin->deviceList(mode)) devices << QAudioDeviceInfo(key, handle, mode); } @@ -149,7 +149,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioInput); + QList list = plugin->deviceList(QAudio::AudioInput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } @@ -164,7 +164,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioOutput); + QList list = plugin->deviceList(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h index 2466455..008e4a8 100644 --- a/src/multimedia/audio/qaudiodevicefactory_p.h +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -72,7 +72,7 @@ class QAbstractAudioDeviceInfo; class QAudioDeviceFactory { public: - static QList availableDevices(QAudio::Mode mode); + static QList deviceList(QAudio::Mode mode); static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index 5e3adcb..dce2884 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -121,7 +121,7 @@ public: classes that communicate with the device--such as QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and - availableDevices() let you get a list of all available + deviceList() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by the QAudio::Mode enum. The QAudioDeviceInfo returned are only valid for the QAudio::Mode. @@ -129,7 +129,7 @@ public: For instance: \code - foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) qDebug() << "Device name: " << deviceInfo.deviceName(); \endcode @@ -327,9 +327,9 @@ QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() Returns a list of audio devices that support \a mode. */ -QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) +QList QAudioDeviceInfo::deviceList(QAudio::Mode mode) { - return QAudioDeviceFactory::availableDevices(mode); + return QAudioDeviceFactory::deviceList(mode); } diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 5c7cb98..53b9904 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -92,7 +92,7 @@ public: static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); - static QList availableDevices(QAudio::Mode mode); + static QList deviceList(QAudio::Mode mode); private: QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 5de6c70..e828238 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -382,7 +382,7 @@ void QAudioDeviceInfoInternal::updateLists() close(); } -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { QList devices; QByteArray filter; @@ -444,7 +444,7 @@ QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { - QList devices = availableDevices(QAudio::AudioInput); + QList devices = deviceList(QAudio::AudioInput); if(devices.size() == 0) return QByteArray(); @@ -453,7 +453,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice() QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { - QList devices = availableDevices(QAudio::AudioOutput); + QList devices = deviceList(QAudio::AudioOutput); if(devices.size() == 0) return QByteArray(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 5a807af..10078ca 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -92,7 +92,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); + static QList deviceList(QAudio::Mode); private: bool open(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index 8905119..ec07748 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() return get_device_info(audioDevice, QAudio::AudioOutput); } -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { QList devices; diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h index 0fd3ef5..60532a8 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -87,7 +87,7 @@ public: static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode mode); + static QList deviceList(QAudio::Mode mode); }; QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 33af022..69d5c94 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -103,7 +103,6 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } else { nearest.setFrequency(11025); nearest.setChannels(1); - nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); @@ -334,7 +333,7 @@ void QAudioDeviceInfoInternal::updateLists() } } -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { Q_UNUSED(mode) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h index e191b6f..0d2ee29 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -93,7 +93,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); + static QList deviceList(QAudio::Mode); private: QAudio::Mode mode; diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp index 88e3804..c6e9d97 100644 --- a/src/multimedia/audio/qaudioengine.cpp +++ b/src/multimedia/audio/qaudioengine.cpp @@ -189,12 +189,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const + \fn virtual qint64 QAbstractAudioOutput::totalTime() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const + \fn virtual qint64 QAbstractAudioOutput::clock() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ @@ -304,12 +304,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioInput::processedUSecs() const + \fn virtual qint64 QAbstractAudioInput::totalTime() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const + \fn virtual qint64 QAbstractAudioInput::clock() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h index f9e80c1..57a9ae6 100644 --- a/src/multimedia/audio/qaudioengine.h +++ b/src/multimedia/audio/qaudioengine.h @@ -86,8 +86,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; + virtual qint64 totalTime() const = 0; + virtual qint64 clock() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; @@ -113,8 +113,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; + virtual qint64 totalTime() const = 0; + virtual qint64 clock() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h index 82dfa15..fe30e0d 100644 --- a/src/multimedia/audio/qaudioengineplugin.h +++ b/src/multimedia/audio/qaudioengineplugin.h @@ -60,7 +60,7 @@ QT_MODULE(Multimedia) struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface { - virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QList deviceList(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; @@ -80,7 +80,7 @@ public: ~QAudioEnginePlugin(); virtual QStringList keys() const = 0; - virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QList deviceList(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b2bbe14..86fe85b 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -38,7 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include + #include @@ -214,13 +214,16 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const } /*! - Returns true if all of the parameters are valid. + Returns true if any of the parameters are invalid. */ -bool QAudioFormat::isValid() const +bool QAudioFormat::isNull() const { - return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && - d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); + return d->frequency == -1 && d->channels == -1 && + d->sampleSize == -1 && + d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) && + d->sampleType == QAudioFormat::Unknown && + d->codec.isNull(); } /*! diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 7e92c2f..d5841ce 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -71,7 +71,7 @@ public: bool operator==(const QAudioFormat &other) const; bool operator!=(const QAudioFormat &other) const; - bool isValid() const; + bool isNull() const; void setFrequency(int frequency); int frequency() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index e794eaf..7a3be23 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -121,15 +121,15 @@ QT_BEGIN_NAMESPACE when the state changes (stateChanged()). QAudioInput provides several ways of measuring the time that has - passed since the start() of the recording. The \c processedUSecs() + passed since the start() of the recording. The \c totalTime() function returns the length of the stream in microseconds written, i.e., it leaves out the times the audio input was suspended or idle. - The elapsedUSecs() function returns the time elapsed since start() was called regardless of + The clock() function returns the time elapsed since start() was called regardless of which states the QAudioInput has been in. If an error should occur, you can fetch its reason with error(). The possible error reasons are described by the QAudio::Error - enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when + enum. The QAudioInput will enter the \l{QAudio::}{StopState} when an error is encountered. Connect to the stateChanged() signal to handle the error: @@ -176,44 +176,37 @@ QAudioInput::~QAudioInput() } /*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transfered without any extra code. - All that is required is to open the QIODevice. - - \sa QIODevice -*/ - -void QAudioInput::start(QIODevice* device) -{ - /* - -If currently not StoppedState, stop - -If previous start was push mode, delete internal QIODevice. - -open audio input. - If ok, NoError and ActiveState, else OpenError and StoppedState. - -emit stateChanged() - */ - d->start(device); -} - -/*! + Uses the \a device as the QIODevice to transfer data. + If \a device is null then the class creates an internal QIODevice. Returns a pointer to the QIODevice being used to handle the data transfer. This QIODevice can be used to read() audio data directly. + Passing a QIODevice allows the data to be transfered without any extra code. + All that is required is to open the QIODevice. \sa QIODevice */ -QIODevice* QAudioInput::start() +QIODevice* QAudioInput::start(QIODevice* device) { /* - -If currently not StoppedState, stop + PULL MODE (valid QIODevice) + -If currently not StopState, stop + -If previous start was push mode, delete internal QIODevice. + -open audio input. + If ok, NoError and ActiveState, else OpenError and StopState. + -emit stateChanged() + -return device + + PUSH MODE (device = 0) + -If currently not StopState, stop -If no internal QIODevice, create one. -open audio input. - -If ok, NoError and IdleState, else OpenError and StoppedState + -If ok, NoError and IdleState, else OpenError and StopState -emit stateChanged() -return internal QIODevice */ - return d->start(0); + return d->start(device); } /*! @@ -232,8 +225,8 @@ QAudioFormat QAudioInput::format() const void QAudioInput::stop() { /* - -If StoppedState, return - -set to StoppedState + -If StopState, return + -set to StopState -detach from audio device -emit stateChanged() */ @@ -262,7 +255,7 @@ void QAudioInput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendedState + -set NoError and SuspendState -emit stateChanged() */ d->suspend(); @@ -275,7 +268,7 @@ void QAudioInput::suspend() void QAudioInput::resume() { /* - -If SuspendedState, return + -If SuspendState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -364,9 +357,9 @@ int QAudioInput::notifyInterval() const was called in microseconds. */ -qint64 QAudioInput::processedUSecs() const +qint64 QAudioInput::totalTime() const { - return d->processedUSecs(); + return d->totalTime(); } /*! @@ -374,9 +367,9 @@ qint64 QAudioInput::processedUSecs() const Suspend states. */ -qint64 QAudioInput::elapsedUSecs() const +qint64 QAudioInput::clock() const { - return d->elapsedUSecs(); + return d->clock(); } /*! diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h index bf93a27..c8094f5 100644 --- a/src/multimedia/audio/qaudioinput.h +++ b/src/multimedia/audio/qaudioinput.h @@ -71,9 +71,7 @@ public: QAudioFormat format() const; - void start(QIODevice *device); - QIODevice* start(); - + QIODevice* start(QIODevice *device = 0); void stop(); void reset(); void suspend(); @@ -88,8 +86,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 8a8f0db..9eb8cfb 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -75,7 +75,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; audioSource = 0; pullMode = true; resuming = false; @@ -206,7 +206,7 @@ int QAudioInputPrivate::setFormat() QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StoppedState) + if(deviceState != QAudio::StopState) close(); if(!pullMode && audioSource) { @@ -234,10 +234,10 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; close(); emit stateChanged(deviceState); @@ -283,7 +283,7 @@ bool QAudioInputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); return false; } @@ -367,7 +367,7 @@ bool QAudioInputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -490,7 +490,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(l < 0) { close(); errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); } else if(l == 0) { errorState = QAudio::NoError; @@ -508,7 +508,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendedState) { + if(deviceState == QAudio::SuspendState) { int err = 0; if(handle) { @@ -558,7 +558,7 @@ int QAudioInputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioInputPrivate::processedUSecs() const +qint64 QAudioInputPrivate::totalTime() const { return totalTimeValue; } @@ -567,14 +567,14 @@ void QAudioInputPrivate::suspend() { if(deviceState == QAudio::ActiveState||resuming) { timer->stop(); - deviceState = QAudio::SuspendedState; + deviceState = QAudio::SuspendState; emit stateChanged(deviceState); } } void QAudioInputPrivate::userFeed() { - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -606,12 +606,12 @@ bool QAudioInputPrivate::deviceReady() return true; } -qint64 QAudioInputPrivate::elapsedUSecs() const +qint64 QAudioInputPrivate::clock() const { if(!handle) return 0; - if (deviceState == QAudio::StoppedState) + if (deviceState == QAudio::StopState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h index 67d5cf5..2ed7453 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.h +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index d63045f..cb05920 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -526,7 +526,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; intervalTimer = new QTimer(this); intervalTimer->setInterval(1000); @@ -708,7 +708,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; errorCode = QAudio::OpenError; return audioIO; } @@ -736,12 +736,12 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { + if (stateCode != QAudio::StopState) { audioThreadStop(); audioBuffer->flush(true); errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -749,11 +749,11 @@ void QAudioInputPrivate::stop() void QAudioInputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { + if (stateCode != QAudio::StopState) { audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -765,7 +765,7 @@ void QAudioInputPrivate::suspend() audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::SuspendedState; + stateCode = QAudio::SuspendState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -773,7 +773,7 @@ void QAudioInputPrivate::suspend() void QAudioInputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { + if (stateCode == QAudio::SuspendState) { audioThreadStart(); errorCode = QAudio::NoError; @@ -812,14 +812,14 @@ int QAudioInputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioInputPrivate::processedUSecs() const +qint64 QAudioInputPrivate::totalTime() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioInputPrivate::elapsedUSecs() const +qint64 QAudioInputPrivate::clock() const { - if (stateCode == QAudio::StoppedState) + if (stateCode == QAudio::StopState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -875,7 +875,7 @@ void QAudioInputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index 2dbb808..a080648 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -129,8 +129,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index b7f9ffd..a059e76 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor totalTimeValue = 0; intervalTime = 1000; errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; audioSource = 0; pullMode = true; resuming = false; @@ -173,7 +173,7 @@ QAudioFormat QAudioInputPrivate::format() const QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StoppedState) + if(deviceState != QAudio::StopState) close(); if(!pullMode && audioSource) { @@ -201,7 +201,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; close(); @@ -260,7 +260,7 @@ bool QAudioInputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to open audio device"); return false; @@ -269,7 +269,7 @@ bool QAudioInputPrivate::open() if(waveBlocks == 0) { errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to allocate blocks. open failed"); return false; @@ -286,7 +286,7 @@ bool QAudioInputPrivate::open() if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",i,result); errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); return false; } @@ -295,7 +295,7 @@ bool QAudioInputPrivate::open() if(result) { qWarning("QAudioInput: failed to start audio input"); errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); return false; } @@ -309,12 +309,12 @@ bool QAudioInputPrivate::open() void QAudioInputPrivate::close() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; waveInReset(hWaveIn); waveInClose(hWaveIn); - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; int count = 0; while(!finished && count < 100) { @@ -333,9 +333,6 @@ void QAudioInputPrivate::close() int QAudioInputPrivate::bytesReady() const { - if(period_size == 0 || buffer_size == 0) - return 0; - int buf = ((buffer_size/period_size)-waveFreeBlockCount)*period_size; if(buf < 0) buf = 0; @@ -403,14 +400,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); } result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR)); if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); } header++; @@ -438,14 +435,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendedState) { + if(deviceState == QAudio::SuspendState) { deviceState = QAudio::ActiveState; for(int i=0; istart(device); -} - -/*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to write() audio data directly. + -return device - \sa QIODevice -*/ - -QIODevice* QAudioOutput::start() -{ - /* - -If currently not StoppedState, stop. + PUSH MODE (device = 0) + -If currently not StopState, stop. -If no internal QIODevice, create one. -open audio output. - -If ok, NoError and IdleState, else OpenError and StoppedState + -If ok, NoError and IdleState, else OpenError and StopState -emit stateChanged() -return internal QIODevice */ - return d->start(0); + return d->start(device); } /*! @@ -233,8 +227,8 @@ QIODevice* QAudioOutput::start() void QAudioOutput::stop() { /* - -If StoppedState, return - -set to StoppedState + -If StopState, return + -set to StopState -detach from audio device -emit stateChanged() */ @@ -263,7 +257,7 @@ void QAudioOutput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendedState + -set NoError and SuspendState -emit stateChanged() */ d->suspend(); @@ -276,7 +270,7 @@ void QAudioOutput::suspend() void QAudioOutput::resume() { /* - -If SuspendedState, return + -If SuspendState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -364,9 +358,9 @@ int QAudioOutput::notifyInterval() const was called in microseconds. */ -qint64 QAudioOutput::processedUSecs() const +qint64 QAudioOutput::totalTime() const { - return d->processedUSecs(); + return d->totalTime(); } /*! @@ -374,9 +368,9 @@ qint64 QAudioOutput::processedUSecs() const Suspend states. */ -qint64 QAudioOutput::elapsedUSecs() const +qint64 QAudioOutput::clock() const { - return d->elapsedUSecs(); + return d->clock(); } /*! diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h index 38bab8e..bb3496e 100644 --- a/src/multimedia/audio/qaudiooutput.h +++ b/src/multimedia/audio/qaudiooutput.h @@ -71,9 +71,7 @@ public: QAudioFormat format() const; - void start(QIODevice *device); - QIODevice* start(); - + QIODevice* start(QIODevice *device = 0); void stop(); void reset(); void suspend(); @@ -88,8 +86,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index e9784d2..689da89 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -77,7 +77,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; audioSource = 0; pullMode = true; resuming = false; @@ -215,8 +215,8 @@ int QAudioOutputPrivate::setFormat() QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StoppedState) - deviceState = QAudio::StoppedState; + if(deviceState != QAudio::StopState) + deviceState = QAudio::StopState; errorState = QAudio::NoError; @@ -256,9 +256,9 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; close(); emit stateChanged(deviceState); } @@ -304,7 +304,7 @@ bool QAudioOutputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; return false; } snd_pcm_nonblock( handle, 0 ); @@ -387,7 +387,7 @@ bool QAudioOutputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) if(err < 0) { close(); errorState = QAudio::FatalError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); } return 0; @@ -507,7 +507,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) buffer_size = value; } @@ -529,14 +529,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::processedUSecs() const +qint64 QAudioOutputPrivate::totalTime() const { return totalTimeValue; } void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendedState) { + if(deviceState == QAudio::SuspendState) { int err = 0; if(handle) { @@ -571,7 +571,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { timer->stop(); - deviceState = QAudio::SuspendedState; + deviceState = QAudio::SuspendState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -579,7 +579,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::userFeed() { - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -658,12 +658,12 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::elapsedUSecs() const +qint64 QAudioOutputPrivate::clock() const { if(!handle) return 0; - if (deviceState == QAudio::StoppedState) + if (deviceState == QAudio::StopState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h index 619ecef..298e89e 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.h +++ b/src/multimedia/audio/qaudiooutput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index e0651bf..f23db80 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -288,7 +288,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; audioThreadState = Stopped; intervalTimer = new QTimer(this); @@ -436,7 +436,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; errorCode = QAudio::OpenError; return audioIO; } @@ -468,10 +468,10 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { + if (stateCode != QAudio::StopState) { audioThreadDrain(); - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -480,10 +480,10 @@ void QAudioOutputPrivate::stop() void QAudioOutputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { + if (stateCode != QAudio::StopState) { audioThreadStop(); - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -495,7 +495,7 @@ void QAudioOutputPrivate::suspend() if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { audioThreadStop(); - stateCode = QAudio::SuspendedState; + stateCode = QAudio::SuspendState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -504,7 +504,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { + if (stateCode == QAudio::SuspendState) { audioThreadStart(); stateCode = QAudio::ActiveState; @@ -525,7 +525,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int bs) { - if (stateCode == QAudio::StoppedState) + if (stateCode == QAudio::StopState) internalBufferSize = bs; } @@ -544,14 +544,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioOutputPrivate::processedUSecs() const +qint64 QAudioOutputPrivate::totalTime() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioOutputPrivate::elapsedUSecs() const +qint64 QAudioOutputPrivate::clock() const { - if (stateCode == QAudio::StoppedState) + if (stateCode == QAudio::StopState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -614,7 +614,7 @@ void QAudioOutputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; + stateCode = QAudio::StopState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h index 76d06a9..04b3239 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.h +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -128,8 +128,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 2cfc472..1810ed2 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; audioSource = 0; pullMode = true; finished = false; @@ -157,7 +157,7 @@ QAudioFormat QAudioOutputPrivate::format() const QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StoppedState) + if(deviceState != QAudio::StopState) close(); if(!pullMode && audioSource) { @@ -187,7 +187,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; close(); if(!pullMode && audioSource) { @@ -255,7 +255,7 @@ bool QAudioOutputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; emit stateChanged(deviceState); qWarning("QAudioOutput: open error"); return false; @@ -277,10 +277,10 @@ bool QAudioOutputPrivate::open() void QAudioOutputPrivate::close() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) return; - deviceState = QAudio::StoppedState; + deviceState = QAudio::StopState; int delay = (buffer_size-bytesFree())*1000/(settings.frequency() *settings.channels()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); @@ -308,7 +308,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StopState) buffer_size = value; } @@ -330,7 +330,7 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::processedUSecs() const +qint64 QAudioOutputPrivate::totalTime() const { return totalTimeValue; } @@ -390,7 +390,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendedState) { + if(deviceState == QAudio::SuspendState) { deviceState = QAudio::ActiveState; errorState = QAudio::NoError; waveOutRestart(hWaveOut); @@ -403,7 +403,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState) { waveOutPause(hWaveOut); - deviceState = QAudio::SuspendedState; + deviceState = QAudio::SuspendState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -417,7 +417,7 @@ void QAudioOutputPrivate::feedback() #endif bytesAvailable = bytesFree(); - if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) { + if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState)) { if(bytesAvailable >= period_size) QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); } @@ -491,9 +491,9 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::elapsedUSecs() const +qint64 QAudioOutputPrivate::clock() const { - if (deviceState == QAudio::StoppedState) + if (deviceState == QAudio::StopState) return 0; return timeStampOpened.elapsed()*1000; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index f90b8c2..bcf8e1e 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -90,8 +90,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; + qint64 totalTime() const; + qint64 clock() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 715f219..7b9a422 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -77,7 +77,7 @@ private: void tst_QAudioDeviceInfo::initTestCase() { // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -90,7 +90,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput() { // Only perform tests if audio input device exists! bool storeAvailable = available; - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -111,7 +111,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultOutput() void tst_QAudioDeviceInfo::outputList() { if(available) { - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); QVERIFY(devices.size() > 0); device = new QAudioDeviceInfo(devices.at(0)); } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 0778a8e..286e63f 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -69,20 +69,17 @@ private slots: void tst_QAudioFormat::checkNull() { - // Default constructed QAudioFormat is invalid. + // Default constructed QAudioFormat is null. QAudioFormat audioFormat0; - QVERIFY(!audioFormat0.isValid()); + QVERIFY(audioFormat0.isNull()); - // validity is transferred + // Null is transferred QAudioFormat audioFormat1(audioFormat0); - QVERIFY(!audioFormat1.isValid()); + QVERIFY(audioFormat1.isNull()); + // Null is voided on activity audioFormat0.setFrequency(44100); - audioFormat0.setChannels(2); - audioFormat0.setSampleSize(16); - audioFormat0.setCodec("audio/pcm"); - audioFormat0.setSampleType(QAudioFormat::SignedInt); - QVERIFY(audioFormat0.isValid()); + QVERIFY(!audioFormat0.isNull()); } void tst_QAudioFormat::checkFrequency() diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 744ce38..3efc346 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -76,7 +76,7 @@ void tst_QAudioInput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio input device exists! - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -137,16 +137,16 @@ void tst_QAudioInput::pullFile() QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State))); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->state() == QAudio::StopState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->elapsedUSecs() == 0); + QVERIFY(audio->clock() == 0); audio->start(&filename); QTest::qWait(20); // Check state and periodSize() are valid non-zero values. QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); + QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); QVERIFY(audio->periodSize() > 0); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState @@ -154,12 +154,12 @@ void tst_QAudioInput::pullFile() QTest::qWait(5000); QVERIFY(readSignal.count() > 0); - QVERIFY(audio->processedUSecs() > 0); + QVERIFY(audio->totalTime() > 0); audio->stop(); QTest::qWait(20); - QVERIFY(audio->state() == QAudio::StoppedState); - QVERIFY(audio->elapsedUSecs() == 0); + QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->clock() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index 26694cc..b001af1 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -79,7 +79,7 @@ void tst_QAudioOutput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -140,9 +140,9 @@ void tst_QAudioOutput::pullFile() audio->setNotifyInterval(100); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->state() == QAudio::StopState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->elapsedUSecs() == 0); + QVERIFY(audio->clock() == 0); audio->start(&file); QTest::qWait(20); // wait 20ms @@ -150,12 +150,12 @@ void tst_QAudioOutput::pullFile() QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); QVERIFY(audio->periodSize() > 0); - QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); + QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState // Wait until finished... QTestEventLoop::instance().enterLoop(1); - QCOMPARE(audio->processedUSecs(), qint64(692250)); + QCOMPARE(audio->totalTime(), qint64(692250)); #ifdef Q_OS_WINCE // 4.wav is a little less than 700ms, so notify should fire 4 times on Wince! @@ -166,8 +166,8 @@ void tst_QAudioOutput::pullFile() #endif audio->stop(); QTest::qWait(20); // wait 20ms - QVERIFY(audio->state() == QAudio::StoppedState); - QVERIFY(audio->elapsedUSecs() == 0); + QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->clock() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); @@ -184,7 +184,7 @@ void tst_QAudioOutput::pushFile() const qint64 fileSize = file.size(); - QIODevice* feed = audio->start(); + QIODevice* feed = audio->start(0); char* buffer = new char[fileSize]; file.read(buffer, fileSize); @@ -199,7 +199,7 @@ void tst_QAudioOutput::pushFile() QTestEventLoop::instance().enterLoop(1); QVERIFY(written == fileSize); - QVERIFY(audio->processedUSecs() == 692250); + QVERIFY(audio->totalTime() == 692250); audio->stop(); file.close(); -- cgit v0.12 From 8d7c74f560c263b3933b21d780c6a1980425a4ba Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 9 Nov 2009 11:33:14 +1000 Subject: During a GC mark the scope chain of QScriptContexts It appears that simply being in the scope chain of an existant frame isn't sufficient to be marked. This can lead to a QScriptContext scope chain that contains a JSObject that has been collected. For example, this code: QScriptContext *ctxt = engine->pushContext(); ctxt.pushScope(engine->newObject()); previouslyCreatedFunctionObject.call(); // causes a GC can lead to the object added to the scope chain to have become invalid. This leads to hilarity later on. Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 2b60a46..f41b4e2 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1093,6 +1093,8 @@ void QScriptEnginePrivate::setContextFlags(JSC::ExecState *exec, uint flags) void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) { + Q_Q(QScriptEngine); + markStack.append(originalGlobalObject()); markStack.append(globalObject()); if (originalGlobalObjectProxy) @@ -1130,6 +1132,22 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) markStack.append((*it)->prototype); } } + + { + QScriptContext *context = q->currentContext(); + + while (context) { + JSC::ScopeChainNode *node = frameForContext(context)->scopeChain(); + JSC::ScopeChainIterator it(node); + for (it = node->begin(); it != node->end(); ++it) { + JSC::JSObject *object = *it; + if (object) + markStack.append(object); + } + + context = context->parentContext(); + } + } } bool QScriptEnginePrivate::isCollecting() const -- cgit v0.12 From 283491506c1a13f43206ccdf0fe542594dd130e8 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 30 Oct 2009 10:50:34 +0100 Subject: added missing include for template instantiation (in qDeleteAll) (cherry picked from commit d01db18696a7729b0d54af76f5224aed6750f3bb) --- src/script/api/qscriptengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 3f438da..7db61e1 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -56,6 +56,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -67,7 +68,6 @@ class QDateTime; class QScriptClass; class QScriptEngineAgent; class QScriptEnginePrivate; -class QScriptProgram; #ifndef QT_NO_QOBJECT -- cgit v0.12 From f155b637f1f4f6181f893e4debef2adb64312ca8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 9 Nov 2009 11:58:49 +1000 Subject: Add QScriptDeclarativeClass QScriptDeclarativeClass is a private, but exported, class used by the declarativeui module. It is very similar to QScriptClass, but slightly faster and provides a couple of "backdoor" extension mechanisms used by declarative. Reviewed-by: Warwick Allison --- src/script/api/qscriptengine.cpp | 12 +- src/script/api/qscriptengine_p.h | 2 +- src/script/api/qscriptvalue.cpp | 5 + src/script/bridge/bridge.pri | 8 +- src/script/bridge/qscriptdeclarativeclass.cpp | 356 +++++++++++++++++++++++++ src/script/bridge/qscriptdeclarativeclass_p.h | 129 +++++++++ src/script/bridge/qscriptdeclarativeobject.cpp | 192 +++++++++++++ src/script/bridge/qscriptdeclarativeobject_p.h | 125 +++++++++ src/script/bridge/qscriptobject_p.h | 3 +- 9 files changed, 826 insertions(+), 6 deletions(-) create mode 100644 src/script/bridge/qscriptdeclarativeclass.cpp create mode 100644 src/script/bridge/qscriptdeclarativeclass_p.h create mode 100644 src/script/bridge/qscriptdeclarativeobject.cpp create mode 100644 src/script/bridge/qscriptdeclarativeobject_p.h diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index f41b4e2..216f325 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2299,7 +2299,8 @@ QScriptContext *QScriptEngine::pushContext() return the new top frame. (might be the same as exec if a new stackframe was not needed) or 0 if stack overflow */ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSValue _thisObject, - const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor) + const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor, + bool clearScopeChain) { JSC::JSValue thisObject = _thisObject; if (calledAsConstructor) { @@ -2333,7 +2334,14 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV for (it = args.begin(); it != args.end(); ++it) newCallFrame[++dst] = *it; newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize; - newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee); + + if (!clearScopeChain) { + newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee); + } else { + JSC::JSObject *jscObject = originalGlobalObject(); + JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), jscObject); + newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee); + } } else { setContextFlags(newCallFrame, flags); #if ENABLE(JIT) diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index d12b0f4..e7cdcda 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -174,7 +174,7 @@ public: static JSC::Register *thisRegisterForFrame(JSC::ExecState *frame); JSC::CallFrame *pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList& args, - JSC::JSObject *callee, bool calledAsConstructor = false); + JSC::JSObject *callee, bool calledAsConstructor = false, bool clearScopeChain = false); void popContext(); void mark(JSC::MarkStack& markStack); diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 52a1e6d..d6cbb41 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -71,6 +71,7 @@ #include "bridge/qscriptclassobject_p.h" #include "bridge/qscriptvariant_p.h" #include "bridge/qscriptqobject_p.h" +#include "bridge/qscriptdeclarativeclass_p.h" /*! \since 4.3 @@ -1496,6 +1497,8 @@ QVariant QScriptValue::toVariant() const #endif else if (isArray()) return QScriptEnginePrivate::variantListFromArray(*this); + else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this)) + return dc->toVariant(QScriptDeclarativeClass::object(*this)); // try to convert to primitive JSC::ExecState *exec = d->engine->currentFrame; JSC::JSValue savedException; @@ -1586,6 +1589,8 @@ QObject *QScriptValue::toQObject() const if (isQObject()) { QScriptObject *object = static_cast(JSC::asObject(d->jscValue)); return static_cast(object->delegate())->value(); + } else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this)) { + return dc->toQObject(QScriptDeclarativeClass::object(*this)); } else if (isVariant()) { QVariant var = toVariant(); int type = var.userType(); diff --git a/src/script/bridge/bridge.pri b/src/script/bridge/bridge.pri index 666a07e..09e2dfb 100644 --- a/src/script/bridge/bridge.pri +++ b/src/script/bridge/bridge.pri @@ -5,7 +5,9 @@ SOURCES += \ $$PWD/qscriptvariant.cpp \ $$PWD/qscriptqobject.cpp \ $$PWD/qscriptglobalobject.cpp \ - $$PWD/qscriptactivationobject.cpp + $$PWD/qscriptactivationobject.cpp \ + $$PWD/qscriptdeclarativeobject.cpp \ + $$PWD/qscriptdeclarativeclass.cpp HEADERS += \ $$PWD/qscriptfunction_p.h \ @@ -14,4 +16,6 @@ HEADERS += \ $$PWD/qscriptvariant_p.h \ $$PWD/qscriptqobject_p.h \ $$PWD/qscriptglobalobject_p.h \ - $$PWD/qscriptactivationobject_p.h + $$PWD/qscriptactivationobject_p.h \ + $$PWD/qscriptdeclarativeobject_p.h \ + $$PWD/qscriptdeclarativeclass_p.h diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp new file mode 100644 index 0000000..b5d9bf5 --- /dev/null +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -0,0 +1,356 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#include "qscriptdeclarativeclass_p.h" +#include "qscriptdeclarativeobject_p.h" +#include "qscriptobject_p.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier() +{ + new (&d) JSC::Identifier(); +} + +QScriptDeclarativeClass::PersistentIdentifier::~PersistentIdentifier() +{ + ((JSC::Identifier &)d).JSC::Identifier::~Identifier(); +} + +QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier(const PersistentIdentifier &other) +{ + identifier = other.identifier; + new (&d) JSC::Identifier((JSC::Identifier &)(other.d)); +} + +QScriptDeclarativeClass::PersistentIdentifier & +QScriptDeclarativeClass::PersistentIdentifier::operator=(const PersistentIdentifier &other) +{ + identifier = other.identifier; + ((JSC::Identifier &)d) = (JSC::Identifier &)(other.d); + return *this; +} + +QScriptDeclarativeClass::QScriptDeclarativeClass(QScriptEngine *engine) +: d_ptr(new QScriptDeclarativeClassPrivate) +{ + Q_ASSERT(sizeof(void*) == sizeof(JSC::Identifier)); + d_ptr->q_ptr = this; + d_ptr->engine = engine; +} + +QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine, + QScriptDeclarativeClass *scriptClass, + Object *object) +{ + Q_ASSERT(engine); + Q_ASSERT(scriptClass); + + QScriptEnginePrivate *p = static_cast(QObjectPrivate::get(engine)); + + JSC::ExecState* exec = p->currentFrame; + QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure); + result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object)); + return p->scriptValueFromJSCValue(result); +} + +QScriptDeclarativeClass *QScriptDeclarativeClass::scriptClass(const QScriptValue &v) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info)) + return 0; + QScriptObject *scriptObject = static_cast(JSC::asObject(d->jscValue)); + QScriptObjectDelegate *delegate = scriptObject->delegate(); + if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject)) + return 0; + return static_cast(delegate)->scriptClass(); +} + +QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info)) + return 0; + QScriptObject *scriptObject = static_cast(JSC::asObject(d->jscValue)); + QScriptObjectDelegate *delegate = scriptObject->delegate(); + if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject)) + return 0; + return static_cast(delegate)->object(); +} + +QScriptValue QScriptDeclarativeClass::function(const QScriptValue &v, const Identifier &name) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + + if (!d->isObject()) + return QScriptValue(); + + JSC::ExecState *exec = d->engine->currentFrame; + JSC::JSObject *object = d->jscValue.getObject(); + JSC::PropertySlot slot(const_cast(object)); + JSC::JSValue result; + + JSC::Identifier id(exec, (JSC::UString::Rep *)name); + + if (const_cast(object)->getOwnPropertySlot(exec, id, slot)) { + result = slot.getValue(exec, id); + if (QScript::isFunction(result)) + return d->engine->scriptValueFromJSCValue(result); + } + + return QScriptValue(); +} + +QScriptValue QScriptDeclarativeClass::property(const QScriptValue &v, const Identifier &name) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + + if (!d->isObject()) + return QScriptValue(); + + JSC::ExecState *exec = d->engine->currentFrame; + JSC::JSObject *object = d->jscValue.getObject(); + JSC::PropertySlot slot(const_cast(object)); + JSC::JSValue result; + + JSC::Identifier id(exec, (JSC::UString::Rep *)name); + + if (const_cast(object)->getOwnPropertySlot(exec, id, slot)) { + result = slot.getValue(exec, id); + return d->engine->scriptValueFromJSCValue(result); + } + + return QScriptValue(); +} + +/* +Returns the scope chain entry at \a index. If index is less than 0, returns +entries starting at the end. For example, scopeChainValue(context, -1) will return +the value last in the scope chain. +*/ +QScriptValue QScriptDeclarativeClass::scopeChainValue(QScriptContext *context, int index) +{ + context->activationObject(); //ensure the creation of the normal scope for native context + const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(context); + QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); + + JSC::ScopeChainNode *node = frame->scopeChain(); + JSC::ScopeChainIterator it(node); + + if (index < 0) { + int count = 0; + for (it = node->begin(); it != node->end(); ++it) + ++count; + + index = qAbs(index); + if (index > count) + return QScriptValue(); + else + index = count - index; + } + + for (it = node->begin(); it != node->end(); ++it) { + + if (index == 0) { + + JSC::JSObject *object = *it; + if (!object) return QScriptValue(); + + if (object->inherits(&QScript::QScriptActivationObject::info) + && (static_cast(object)->delegate() != 0)) { + // Return the object that property access is being delegated to + object = static_cast(object)->delegate(); + } + return engine->scriptValueFromJSCValue(object); + + } else { + --index; + } + + } + + return QScriptValue(); +} + +/*! + Enters a new execution context and returns the associated + QScriptContext object. + + Once you are done with the context, you should call popContext() to + restore the old context. + + By default, the `this' object of the new context is the Global Object. + The context's \l{QScriptContext::callee()}{callee}() will be invalid. + + Unlike pushContext(), the default scope chain is reset to include + only the global object and the QScriptContext's activation object. + + \sa QScriptEngine::popContext() +*/ +QScriptContext * QScriptDeclarativeClass::pushCleanContext(QScriptEngine *engine) +{ + if (!engine) + return 0; + + QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine); + + JSC::CallFrame* newFrame = d->pushContext(d->currentFrame, + d->currentFrame->globalData().dynamicGlobalObject, + JSC::ArgList(), /*callee = */0, false, true); + + if (engine->agent()) + engine->agent()->contextPush(); + + return d->contextForFrame(newFrame); +} + +QScriptDeclarativeClass::~QScriptDeclarativeClass() +{ +} + +QScriptEngine *QScriptDeclarativeClass::engine() const +{ + return d_ptr->engine; +} + +QScriptDeclarativeClass::PersistentIdentifier +QScriptDeclarativeClass::createPersistentIdentifier(const QString &str) +{ + QScriptEnginePrivate *p = + static_cast(QObjectPrivate::get(d_ptr->engine)); + JSC::ExecState* exec = p->currentFrame; + + PersistentIdentifier rv(true); + new (&rv.d) JSC::Identifier(exec, (UChar *)str.constData(), str.size()); + rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep(); + return rv; +} + +QScriptDeclarativeClass::PersistentIdentifier +QScriptDeclarativeClass::createPersistentIdentifier(const Identifier &id) +{ + QScriptEnginePrivate *p = + static_cast(QObjectPrivate::get(d_ptr->engine)); + JSC::ExecState* exec = p->currentFrame; + + PersistentIdentifier rv(true); + new (&rv.d) JSC::Identifier(exec, (JSC::UString::Rep *)id); + rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep(); + return rv; +} + +QString QScriptDeclarativeClass::toString(const Identifier &identifier) +{ + JSC::UString::Rep *r = (JSC::UString::Rep *)identifier; + return QString((QChar *)r->data(), r->size()); +} + +quint32 QScriptDeclarativeClass::toArrayIndex(const Identifier &identifier, bool *ok) +{ + JSC::UString::Rep *r = (JSC::UString::Rep *)identifier; + JSC::UString s(r); + return s.toArrayIndex(ok); +} + +QScriptClass::QueryFlags +QScriptDeclarativeClass::queryProperty(Object *object, const Identifier &name, + QScriptClass::QueryFlags flags) +{ + Q_UNUSED(object); + Q_UNUSED(name); + Q_UNUSED(flags); + return 0; +} + +QScriptValue QScriptDeclarativeClass::property(Object *object, const Identifier &name) +{ + Q_UNUSED(object); + Q_UNUSED(name); + return QScriptValue(); +} + +void QScriptDeclarativeClass::setProperty(Object *object, const Identifier &name, + const QScriptValue &value) +{ + Q_UNUSED(object); + Q_UNUSED(name); + Q_UNUSED(value); +} + +QScriptValue::PropertyFlags +QScriptDeclarativeClass::propertyFlags(Object *object, const Identifier &name) +{ + Q_UNUSED(object); + Q_UNUSED(name); + return 0; +} + +QStringList QScriptDeclarativeClass::propertyNames(Object *object) +{ + Q_UNUSED(object); + return QStringList(); +} + +QObject *QScriptDeclarativeClass::toQObject(Object *, bool *ok) +{ + if (ok) *ok = false; + return 0; +} + +QVariant QScriptDeclarativeClass::toVariant(Object *, bool *ok) +{ + if (ok) *ok = false; + return QVariant(); +} + +QScriptContext *QScriptDeclarativeClass::context() const +{ + return d_ptr->context; +} + diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h new file mode 100644 index 0000000..d0e653d --- /dev/null +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#ifndef QSCRIPTDECLARATIVECLASS_P_H +#define QSCRIPTDECLARATIVECLASS_P_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 + +QT_BEGIN_NAMESPACE + +class QScriptDeclarativeClassPrivate; +class PersistentIdentifierPrivate; +class QScriptContext; +class Q_SCRIPT_EXPORT QScriptDeclarativeClass +{ +public: + typedef void* Identifier; + + struct Object { virtual ~Object() {} }; + + static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *); + static QScriptDeclarativeClass *scriptClass(const QScriptValue &); + static Object *object(const QScriptValue &); + + static QScriptValue function(const QScriptValue &, const Identifier &); + static QScriptValue property(const QScriptValue &, const Identifier &); + + static QScriptValue scopeChainValue(QScriptContext *, int index); + static QScriptContext *pushCleanContext(QScriptEngine *); + + class Q_SCRIPT_EXPORT PersistentIdentifier + { + public: + Identifier identifier; + + PersistentIdentifier(); + ~PersistentIdentifier(); + PersistentIdentifier(const PersistentIdentifier &other); + PersistentIdentifier &operator=(const PersistentIdentifier &other); + + private: + friend class QScriptDeclarativeClass; + PersistentIdentifier(bool) : identifier(0), d(0) {} + void *d; + }; + + QScriptDeclarativeClass(QScriptEngine *engine); + virtual ~QScriptDeclarativeClass(); + + QScriptEngine *engine() const; + + PersistentIdentifier createPersistentIdentifier(const QString &); + PersistentIdentifier createPersistentIdentifier(const Identifier &); + + QString toString(const Identifier &); + quint32 toArrayIndex(const Identifier &, bool *ok); + + virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, + QScriptClass::QueryFlags flags); + + virtual QScriptValue property(Object *, const Identifier &); + virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); + virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &); + + virtual QStringList propertyNames(Object *); + + virtual QObject *toQObject(Object *, bool *ok = 0); + virtual QVariant toVariant(Object *, bool *ok = 0); + + QScriptContext *context() const; +protected: + friend class QScriptDeclarativeClassPrivate; + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/script/bridge/qscriptdeclarativeobject.cpp b/src/script/bridge/qscriptdeclarativeobject.cpp new file mode 100644 index 0000000..1af632d --- /dev/null +++ b/src/script/bridge/qscriptdeclarativeobject.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#include "config.h" +#include "qscriptdeclarativeobject_p.h" + +#include "../api/qscriptengine.h" +#include "../api/qscriptengine_p.h" +#include "../api/qscriptcontext.h" +#include "../api/qscriptcontext_p.h" +#include "../api/qscriptclass.h" +#include "../api/qscriptclasspropertyiterator.h" + +#include "Error.h" +#include "PropertyNameArray.h" + +#include + +Q_DECLARE_METATYPE(QScriptContext*) +Q_DECLARE_METATYPE(QScriptValue) +Q_DECLARE_METATYPE(QScriptValueList) + +QT_BEGIN_NAMESPACE + +namespace QScript +{ + +DeclarativeObjectDelegate::DeclarativeObjectDelegate(QScriptDeclarativeClass *c, + QScriptDeclarativeClass::Object *o) +: m_class(c), m_object(o) +{ +} + +DeclarativeObjectDelegate::~DeclarativeObjectDelegate() +{ + delete m_object; +} + +QScriptObjectDelegate::Type DeclarativeObjectDelegate::type() const +{ + return DeclarativeClassObject; +} + +bool DeclarativeObjectDelegate::getOwnPropertySlot(QScriptObject* object, + JSC::ExecState *exec, + const JSC::Identifier &propertyName, + JSC::PropertySlot &slot) +{ + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep(); + + QScriptDeclarativeClassPrivate *p = QScriptDeclarativeClassPrivate::get(m_class); + p->context = reinterpret_cast(exec); + QScriptClass::QueryFlags flags = + m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess); + if (flags & QScriptClass::HandlesReadAccess) { + QScriptValue value = m_class->property(m_object, identifier); + p->context = 0; + slot.setValue(engine->scriptValueToJSCValue(value)); + return true; + } + p->context = 0; + + return QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot); +} + +void DeclarativeObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, + const JSC::Identifier &propertyName, + JSC::JSValue value, JSC::PutPropertySlot &slot) +{ + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep(); + + QScriptDeclarativeClassPrivate *p = QScriptDeclarativeClassPrivate::get(m_class); + p->context = reinterpret_cast(exec); + QScriptClass::QueryFlags flags = + m_class->queryProperty(m_object, identifier, QScriptClass::HandlesWriteAccess); + if (flags & QScriptClass::HandlesWriteAccess) { + m_class->setProperty(m_object, identifier, engine->scriptValueFromJSCValue(value)); + p->context = 0; + return; + } + p->context = 0; + + QScriptObjectDelegate::put(object, exec, propertyName, value, slot); +} + +bool DeclarativeObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState *exec, + const JSC::Identifier &propertyName, + bool checkDontDelete) +{ + return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete); +} + +bool DeclarativeObjectDelegate::getPropertyAttributes(const QScriptObject* object, + JSC::ExecState *exec, + const JSC::Identifier &propertyName, + unsigned &attribs) const +{ + QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep(); + + QScriptClass::QueryFlags flags = + m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess); + if (flags & QScriptClass::HandlesReadAccess) { + QScriptValue::PropertyFlags flags = m_class->propertyFlags(m_object, identifier); + attribs = 0; + if (flags & QScriptValue::ReadOnly) + attribs |= JSC::ReadOnly; + if (flags & QScriptValue::SkipInEnumeration) + attribs |= JSC::DontEnum; + if (flags & QScriptValue::Undeletable) + attribs |= JSC::DontDelete; + if (flags & QScriptValue::PropertyGetter) + attribs |= JSC::Getter; + if (flags & QScriptValue::PropertySetter) + attribs |= JSC::Setter; + attribs |= flags & QScriptValue::UserRange; + return true; + } + return QScriptObjectDelegate::getPropertyAttributes(object, exec, propertyName, attribs); +} + +void DeclarativeObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState *exec, + JSC::PropertyNameArray &propertyNames, + bool includeNonEnumerable) +{ + QStringList properties = m_class->propertyNames(m_object); + for (int ii = 0; ii < properties.count(); ++ii) { + const QString &name = properties.at(ii); + propertyNames.add(JSC::Identifier(exec, name)); + } + + QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, includeNonEnumerable); +} + +JSC::CallType DeclarativeObjectDelegate::getCallData(QScriptObject *object, JSC::CallData &callData) +{ + return QScriptObjectDelegate::getCallData(object, callData); +} + +JSC::ConstructType DeclarativeObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData &constructData) +{ + return QScriptObjectDelegate::getConstructData(object, constructData); +} + +bool DeclarativeObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exec, + JSC::JSValue value, JSC::JSValue proto) +{ + return QScriptObjectDelegate::hasInstance(object, exec, value, proto); +} + +} // namespace QScript + +QT_END_NAMESPACE diff --git a/src/script/bridge/qscriptdeclarativeobject_p.h b/src/script/bridge/qscriptdeclarativeobject_p.h new file mode 100644 index 0000000..73e5527 --- /dev/null +++ b/src/script/bridge/qscriptdeclarativeobject_p.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#ifndef QSCRIPTDECLARATIVEOBJECT_P_H +#define QSCRIPTDECLARATIVEOBJECT_P_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 "config.h" +#include "qscriptobject_p.h" +#include "qscriptdeclarativeclass_p.h" + +QT_BEGIN_NAMESPACE + +class QScriptClass; + +class QScriptDeclarativeClassPrivate +{ +public: + QScriptDeclarativeClassPrivate() : engine(0), q_ptr(0), context(0) {} + + QScriptEngine *engine; + QScriptDeclarativeClass *q_ptr; + QScriptContext *context; + + static QScriptDeclarativeClassPrivate *get(QScriptDeclarativeClass *c) { + return c->d_ptr.data(); + } +}; + +namespace QScript +{ + +class DeclarativeObjectDelegate : public QScriptObjectDelegate +{ +public: + DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o); + ~DeclarativeObjectDelegate(); + + virtual Type type() const; + + QScriptDeclarativeClass *scriptClass() const { return m_class; } + QScriptDeclarativeClass::Object *object() const { return m_object; } + + virtual bool getOwnPropertySlot(QScriptObject*, JSC::ExecState*, + const JSC::Identifier& propertyName, + JSC::PropertySlot&); + virtual void put(QScriptObject*, JSC::ExecState* exec, + const JSC::Identifier& propertyName, + JSC::JSValue, JSC::PutPropertySlot&); + virtual bool deleteProperty(QScriptObject*, JSC::ExecState*, + const JSC::Identifier& propertyName, + bool checkDontDelete = true); + virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, + const JSC::Identifier&, + unsigned&) const; + virtual void getOwnPropertyNames(QScriptObject*, JSC::ExecState*, + JSC::PropertyNameArray&, + bool includeNonEnumerable = false); + + virtual JSC::CallType getCallData(QScriptObject*, JSC::CallData&); + virtual JSC::ConstructType getConstructData(QScriptObject*, JSC::ConstructData&); + + virtual bool hasInstance(QScriptObject*, JSC::ExecState*, + JSC::JSValue value, JSC::JSValue proto); + +private: + QScriptDeclarativeClass *m_class; + QScriptDeclarativeClass::Object *m_object; +}; + +} // namespace QScript + +QT_END_NAMESPACE + +#endif diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h index 9dd9d88..0992eec 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -127,7 +127,8 @@ public: enum Type { QtObject, Variant, - ClassObject + ClassObject, + DeclarativeClassObject }; QScriptObjectDelegate(); -- cgit v0.12 From 75fb85bbf1b2dc473f99da72124daa65c5839e01 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 5 Nov 2009 14:18:38 +1000 Subject: Changes to low-level audio API. QAudioFormat::isNull() -> QAudioFormat::isValid() (inverse logic) QAudio::SuspendState -> QAudio::SuspendedState QAudio::StopState -> QAudio::StoppedState QAudioDeviceInfo::deviceList() -> QAudioDeviceInfo::availableDevices() clock() -> elapsedUSecs() totalTime() -> processedUSecs() QIODevice* start(QIODevice*) -> void start(QIODevice*), QIODevice* start() Reviewed-by:Justin McPherson --- examples/multimedia/audiodevices/audiodevices.cpp | 2 +- examples/multimedia/audioinput/audioinput.cpp | 10 ++-- examples/multimedia/audiooutput/audiooutput.cpp | 12 ++--- src/multimedia/audio/qaudio.cpp | 24 ++++----- src/multimedia/audio/qaudio.h | 2 +- src/multimedia/audio/qaudiodevicefactory.cpp | 22 ++++---- src/multimedia/audio/qaudiodevicefactory_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo.cpp | 8 +-- src/multimedia/audio/qaudiodeviceinfo.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 6 +-- src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 2 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 3 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 2 +- src/multimedia/audio/qaudioengine.cpp | 8 +-- src/multimedia/audio/qaudioengine.h | 8 +-- src/multimedia/audio/qaudioengineplugin.h | 4 +- src/multimedia/audio/qaudioformat.cpp | 13 ++--- src/multimedia/audio/qaudioformat.h | 2 +- src/multimedia/audio/qaudioinput.cpp | 63 ++++++++++++---------- src/multimedia/audio/qaudioinput.h | 8 +-- src/multimedia/audio/qaudioinput_alsa_p.cpp | 28 +++++----- src/multimedia/audio/qaudioinput_alsa_p.h | 4 +- src/multimedia/audio/qaudioinput_mac_p.cpp | 24 ++++----- src/multimedia/audio/qaudioinput_mac_p.h | 4 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 36 ++++++------- src/multimedia/audio/qaudioinput_win32_p.h | 4 +- src/multimedia/audio/qaudiooutput.cpp | 52 ++++++++++-------- src/multimedia/audio/qaudiooutput.h | 8 +-- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 32 +++++------ src/multimedia/audio/qaudiooutput_alsa_p.h | 4 +- src/multimedia/audio/qaudiooutput_mac_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_mac_p.h | 4 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 26 ++++----- src/multimedia/audio/qaudiooutput_win32_p.h | 4 +- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 6 +-- tests/auto/qaudioformat/tst_qaudioformat.cpp | 15 +++--- tests/auto/qaudioinput/tst_qaudioinput.cpp | 14 ++--- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 18 +++---- 40 files changed, 267 insertions(+), 249 deletions(-) diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4198605..e205e03 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -148,7 +148,7 @@ void AudioTest::modeChanged(int idx) mode=QAudio::AudioOutput; deviceBox->clear(); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(mode)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); } diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 3d537a2..62afd73 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -170,7 +170,7 @@ InputTest::InputTest() layout->addWidget(canvas); deviceBox = new QComboBox(this); - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) { deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); } @@ -216,7 +216,7 @@ InputTest::~InputTest() {} void InputTest::status() { - qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"bytesReady = "<bytesReady()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); } void InputTest::readMore() @@ -239,7 +239,7 @@ void InputTest::toggleMode() if (pullMode) { button->setText(tr("Click for Pull Mode")); - input = audioInput->start(0); + input = audioInput->start(); connect(input,SIGNAL(readyRead()),SLOT(readMore())); pullMode = false; } else { @@ -252,7 +252,7 @@ void InputTest::toggleMode() void InputTest::toggleSuspend() { // toggle suspend/resume - if(audioInput->state() == QAudio::SuspendState) { + if(audioInput->state() == QAudio::SuspendedState) { qWarning()<<"status: Suspended, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); @@ -260,7 +260,7 @@ void InputTest::toggleSuspend() qWarning()<<"status: Active, suspend()"; audioInput->suspend(); button2->setText("Click To Resume"); - } else if (audioInput->state() == QAudio::StopState) { + } else if (audioInput->state() == QAudio::StoppedState) { qWarning()<<"status: Stopped, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index c92bbaf..244840d 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -134,7 +134,7 @@ AudioTest::AudioTest() QVBoxLayout* layout = new QVBoxLayout; deviceBox = new QComboBox(this); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -200,7 +200,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::status() { - qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"byteFree = "<bytesFree()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); } void AudioTest::writeMore() @@ -208,7 +208,7 @@ void AudioTest::writeMore() if(!audioOutput) return; - if(audioOutput->state() == QAudio::StopState) + if(audioOutput->state() == QAudio::StoppedState) return; int l; @@ -234,7 +234,7 @@ void AudioTest::toggle() if (pullMode) { button->setText("Click for Pull Mode"); - output = audioOutput->start(0); + output = audioOutput->start(); pullMode = false; timer->start(20); } else { @@ -247,7 +247,7 @@ void AudioTest::toggle() void AudioTest::togglePlay() { // toggle suspend/resume - if(audioOutput->state() == QAudio::SuspendState) { + if(audioOutput->state() == QAudio::SuspendedState) { qWarning()<<"status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); @@ -255,7 +255,7 @@ void AudioTest::togglePlay() qWarning()<<"status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); - } else if (audioOutput->state() == QAudio::StopState) { + } else if (audioOutput->state() == QAudio::StoppedState) { qWarning()<<"status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index 04378d4..b687f34 100644 --- a/src/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp @@ -71,23 +71,23 @@ public: /*! \enum QAudio::Error - \value NoError No errors have occurred - \value OpenError An error opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. + \value NoError No errors have occurred + \value OpenError An error opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. */ /*! \enum QAudio::State - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StopState The audio device is closed, not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendedState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StoppedState The audio device is closed, not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. */ /*! diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h index a66f0b1..531e1a7 100644 --- a/src/multimedia/audio/qaudio.h +++ b/src/multimedia/audio/qaudio.h @@ -56,7 +56,7 @@ QT_MODULE(Multimedia) namespace QAudio { enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; - enum State { ActiveState, SuspendState, StopState, IdleState }; + enum State { ActiveState, SuspendedState, StoppedState, IdleState }; enum Mode { AudioInput, AudioOutput }; } diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 8804fb6..89e4394 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -94,10 +94,10 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 totalTime() const { return 0; } - qint64 clock() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StopState; } + QAudio::State state() const { return QAudio::StoppedState; } QAudioFormat format() const { return QAudioFormat(); } }; @@ -115,18 +115,18 @@ public: int bufferSize() const { return 0; } void setNotifyInterval(int ) {} int notifyInterval() const { return 0; } - qint64 totalTime() const { return 0; } - qint64 clock() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StopState; } + QAudio::State state() const { return QAudio::StoppedState; } QAudioFormat format() const { return QAudioFormat(); } }; -QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) +QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList devices; #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode)) + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif QFactoryLoader* l = loader(); @@ -134,7 +134,7 @@ QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) foreach (QString const& key, l->keys()) { QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); if (plugin) { - foreach (QByteArray const& handle, plugin->deviceList(mode)) + foreach (QByteArray const& handle, plugin->availableDevices(mode)) devices << QAudioDeviceInfo(key, handle, mode); } @@ -149,7 +149,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->deviceList(QAudio::AudioInput); + QList list = plugin->availableDevices(QAudio::AudioInput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } @@ -164,7 +164,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); if (plugin) { - QList list = plugin->deviceList(QAudio::AudioOutput); + QList list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h index 008e4a8..2466455 100644 --- a/src/multimedia/audio/qaudiodevicefactory_p.h +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -72,7 +72,7 @@ class QAbstractAudioDeviceInfo; class QAudioDeviceFactory { public: - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index dce2884..5e3adcb 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -121,7 +121,7 @@ public: classes that communicate with the device--such as QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and - deviceList() let you get a list of all available + availableDevices() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by the QAudio::Mode enum. The QAudioDeviceInfo returned are only valid for the QAudio::Mode. @@ -129,7 +129,7 @@ public: For instance: \code - foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) qDebug() << "Device name: " << deviceInfo.deviceName(); \endcode @@ -327,9 +327,9 @@ QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() Returns a list of audio devices that support \a mode. */ -QList QAudioDeviceInfo::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) { - return QAudioDeviceFactory::deviceList(mode); + return QAudioDeviceFactory::availableDevices(mode); } diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 53b9904..5c7cb98 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -92,7 +92,7 @@ public: static QAudioDeviceInfo defaultInputDevice(); static QAudioDeviceInfo defaultOutputDevice(); - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); private: QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index e828238..5de6c70 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -382,7 +382,7 @@ void QAudioDeviceInfoInternal::updateLists() close(); } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { QList devices; QByteArray filter; @@ -444,7 +444,7 @@ QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { - QList devices = deviceList(QAudio::AudioInput); + QList devices = availableDevices(QAudio::AudioInput); if(devices.size() == 0) return QByteArray(); @@ -453,7 +453,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice() QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { - QList devices = deviceList(QAudio::AudioOutput); + QList devices = availableDevices(QAudio::AudioOutput); if(devices.size() == 0) return QByteArray(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 10078ca..5a807af 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -92,7 +92,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode); + static QList availableDevices(QAudio::Mode); private: bool open(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ec07748..8905119 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() return get_device_info(audioDevice, QAudio::AudioOutput); } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { QList devices; diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h index 60532a8..0fd3ef5 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -87,7 +87,7 @@ public: static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode mode); + static QList availableDevices(QAudio::Mode mode); }; QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 69d5c94..33af022 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -103,6 +103,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } else { nearest.setFrequency(11025); nearest.setChannels(1); + nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); @@ -333,7 +334,7 @@ void QAudioDeviceInfoInternal::updateLists() } } -QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { Q_UNUSED(mode) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h index 0d2ee29..e191b6f 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -93,7 +93,7 @@ public: QList sampleTypeList(); static QByteArray defaultInputDevice(); static QByteArray defaultOutputDevice(); - static QList deviceList(QAudio::Mode); + static QList availableDevices(QAudio::Mode); private: QAudio::Mode mode; diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp index c6e9d97..88e3804 100644 --- a/src/multimedia/audio/qaudioengine.cpp +++ b/src/multimedia/audio/qaudioengine.cpp @@ -189,12 +189,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioOutput::totalTime() const + \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioOutput::clock() const + \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ @@ -304,12 +304,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn virtual qint64 QAbstractAudioInput::totalTime() const + \fn virtual qint64 QAbstractAudioInput::processedUSecs() const Returns the amount of audio data processed since start() was called in milliseconds. */ /*! - \fn virtual qint64 QAbstractAudioInput::clock() const + \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const Returns the milliseconds since start() was called, including time in Idle and suspend states. */ diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h index 57a9ae6..f9e80c1 100644 --- a/src/multimedia/audio/qaudioengine.h +++ b/src/multimedia/audio/qaudioengine.h @@ -86,8 +86,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 totalTime() const = 0; - virtual qint64 clock() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; @@ -113,8 +113,8 @@ public: virtual int bufferSize() const = 0; virtual void setNotifyInterval(int milliSeconds) = 0; virtual int notifyInterval() const = 0; - virtual qint64 totalTime() const = 0; - virtual qint64 clock() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; virtual QAudio::Error error() const = 0; virtual QAudio::State state() const = 0; virtual QAudioFormat format() const = 0; diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h index fe30e0d..82dfa15 100644 --- a/src/multimedia/audio/qaudioengineplugin.h +++ b/src/multimedia/audio/qaudioengineplugin.h @@ -60,7 +60,7 @@ QT_MODULE(Multimedia) struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface { - virtual QList deviceList(QAudio::Mode) const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; @@ -80,7 +80,7 @@ public: ~QAudioEnginePlugin(); virtual QStringList keys() const = 0; - virtual QList deviceList(QAudio::Mode) const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 86fe85b..b2bbe14 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -38,7 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#include #include @@ -214,16 +214,13 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const } /*! - Returns true if any of the parameters are invalid. + Returns true if all of the parameters are valid. */ -bool QAudioFormat::isNull() const +bool QAudioFormat::isValid() const { - return d->frequency == -1 && d->channels == -1 && - d->sampleSize == -1 && - d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) && - d->sampleType == QAudioFormat::Unknown && - d->codec.isNull(); + return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && + d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); } /*! diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index d5841ce..7e92c2f 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -71,7 +71,7 @@ public: bool operator==(const QAudioFormat &other) const; bool operator!=(const QAudioFormat &other) const; - bool isNull() const; + bool isValid() const; void setFrequency(int frequency); int frequency() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 7a3be23..e794eaf 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -121,15 +121,15 @@ QT_BEGIN_NAMESPACE when the state changes (stateChanged()). QAudioInput provides several ways of measuring the time that has - passed since the start() of the recording. The \c totalTime() + passed since the start() of the recording. The \c processedUSecs() function returns the length of the stream in microseconds written, i.e., it leaves out the times the audio input was suspended or idle. - The clock() function returns the time elapsed since start() was called regardless of + The elapsedUSecs() function returns the time elapsed since start() was called regardless of which states the QAudioInput has been in. If an error should occur, you can fetch its reason with error(). The possible error reasons are described by the QAudio::Error - enum. The QAudioInput will enter the \l{QAudio::}{StopState} when + enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when an error is encountered. Connect to the stateChanged() signal to handle the error: @@ -176,37 +176,44 @@ QAudioInput::~QAudioInput() } /*! - Uses the \a device as the QIODevice to transfer data. - If \a device is null then the class creates an internal QIODevice. + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transfered without any extra code. + All that is required is to open the QIODevice. + + \sa QIODevice +*/ + +void QAudioInput::start(QIODevice* device) +{ + /* + -If currently not StoppedState, stop + -If previous start was push mode, delete internal QIODevice. + -open audio input. + If ok, NoError and ActiveState, else OpenError and StoppedState. + -emit stateChanged() + */ + d->start(device); +} + +/*! Returns a pointer to the QIODevice being used to handle the data transfer. This QIODevice can be used to read() audio data directly. - Passing a QIODevice allows the data to be transfered without any extra code. - All that is required is to open the QIODevice. \sa QIODevice */ -QIODevice* QAudioInput::start(QIODevice* device) +QIODevice* QAudioInput::start() { /* - PULL MODE (valid QIODevice) - -If currently not StopState, stop - -If previous start was push mode, delete internal QIODevice. - -open audio input. - If ok, NoError and ActiveState, else OpenError and StopState. - -emit stateChanged() - -return device - - PUSH MODE (device = 0) - -If currently not StopState, stop + -If currently not StoppedState, stop -If no internal QIODevice, create one. -open audio input. - -If ok, NoError and IdleState, else OpenError and StopState + -If ok, NoError and IdleState, else OpenError and StoppedState -emit stateChanged() -return internal QIODevice */ - return d->start(device); + return d->start(0); } /*! @@ -225,8 +232,8 @@ QAudioFormat QAudioInput::format() const void QAudioInput::stop() { /* - -If StopState, return - -set to StopState + -If StoppedState, return + -set to StoppedState -detach from audio device -emit stateChanged() */ @@ -255,7 +262,7 @@ void QAudioInput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendState + -set NoError and SuspendedState -emit stateChanged() */ d->suspend(); @@ -268,7 +275,7 @@ void QAudioInput::suspend() void QAudioInput::resume() { /* - -If SuspendState, return + -If SuspendedState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -357,9 +364,9 @@ int QAudioInput::notifyInterval() const was called in microseconds. */ -qint64 QAudioInput::totalTime() const +qint64 QAudioInput::processedUSecs() const { - return d->totalTime(); + return d->processedUSecs(); } /*! @@ -367,9 +374,9 @@ qint64 QAudioInput::totalTime() const Suspend states. */ -qint64 QAudioInput::clock() const +qint64 QAudioInput::elapsedUSecs() const { - return d->clock(); + return d->elapsedUSecs(); } /*! diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h index c8094f5..bf93a27 100644 --- a/src/multimedia/audio/qaudioinput.h +++ b/src/multimedia/audio/qaudioinput.h @@ -71,7 +71,9 @@ public: QAudioFormat format() const; - QIODevice* start(QIODevice *device = 0); + void start(QIODevice *device); + QIODevice* start(); + void stop(); void reset(); void suspend(); @@ -86,8 +88,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 9eb8cfb..8a8f0db 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -75,7 +75,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -206,7 +206,7 @@ int QAudioInputPrivate::setFormat() QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -234,10 +234,10 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; close(); emit stateChanged(deviceState); @@ -283,7 +283,7 @@ bool QAudioInputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -367,7 +367,7 @@ bool QAudioInputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -490,7 +490,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(l < 0) { close(); errorState = QAudio::IOError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } else if(l == 0) { errorState = QAudio::NoError; @@ -508,7 +508,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { int err = 0; if(handle) { @@ -558,7 +558,7 @@ int QAudioInputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioInputPrivate::totalTime() const +qint64 QAudioInputPrivate::processedUSecs() const { return totalTimeValue; } @@ -567,14 +567,14 @@ void QAudioInputPrivate::suspend() { if(deviceState == QAudio::ActiveState||resuming) { timer->stop(); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; emit stateChanged(deviceState); } } void QAudioInputPrivate::userFeed() { - if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -606,12 +606,12 @@ bool QAudioInputPrivate::deviceReady() return true; } -qint64 QAudioInputPrivate::clock() const +qint64 QAudioInputPrivate::elapsedUSecs() const { if(!handle) return 0; - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h index 2ed7453..67d5cf5 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.h +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index cb05920..d63045f 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -526,7 +526,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; intervalTimer = new QTimer(this); intervalTimer->setInterval(1000); @@ -708,7 +708,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; } @@ -736,12 +736,12 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); audioBuffer->flush(true); errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -749,11 +749,11 @@ void QAudioInputPrivate::stop() void QAudioInputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -765,7 +765,7 @@ void QAudioInputPrivate::suspend() audioThreadStop(); errorCode = QAudio::NoError; - stateCode = QAudio::SuspendState; + stateCode = QAudio::SuspendedState; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } } @@ -773,7 +773,7 @@ void QAudioInputPrivate::suspend() void QAudioInputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendState) { + if (stateCode == QAudio::SuspendedState) { audioThreadStart(); errorCode = QAudio::NoError; @@ -812,14 +812,14 @@ int QAudioInputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioInputPrivate::totalTime() const +qint64 QAudioInputPrivate::processedUSecs() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioInputPrivate::clock() const +qint64 QAudioInputPrivate::elapsedUSecs() const { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -875,7 +875,7 @@ void QAudioInputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index a080648..2dbb808 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -129,8 +129,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index a059e76..31f6e25 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor totalTimeValue = 0; intervalTime = 1000; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -173,7 +173,7 @@ QAudioFormat QAudioInputPrivate::format() const QIODevice* QAudioInputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -201,7 +201,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) void QAudioInputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; close(); @@ -260,7 +260,7 @@ bool QAudioInputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to open audio device"); return false; @@ -269,7 +269,7 @@ bool QAudioInputPrivate::open() if(waveBlocks == 0) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioInput: failed to allocate blocks. open failed"); return false; @@ -286,7 +286,7 @@ bool QAudioInputPrivate::open() if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",i,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -295,7 +295,7 @@ bool QAudioInputPrivate::open() if(result) { qWarning("QAudioInput: failed to start audio input"); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } @@ -309,12 +309,12 @@ bool QAudioInputPrivate::open() void QAudioInputPrivate::close() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; waveInReset(hWaveIn); waveInClose(hWaveIn); - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; int count = 0; while(!finished && count < 100) { @@ -400,14 +400,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR)); if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",header,result); errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } header++; @@ -435,14 +435,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) void QAudioInputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { deviceState = QAudio::ActiveState; for(int i=0; istart(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to write() audio data directly. - PUSH MODE (device = 0) - -If currently not StopState, stop. + \sa QIODevice +*/ + +QIODevice* QAudioOutput::start() +{ + /* + -If currently not StoppedState, stop. -If no internal QIODevice, create one. -open audio output. - -If ok, NoError and IdleState, else OpenError and StopState + -If ok, NoError and IdleState, else OpenError and StoppedState -emit stateChanged() -return internal QIODevice */ - return d->start(device); + return d->start(0); } /*! @@ -227,8 +233,8 @@ QIODevice* QAudioOutput::start(QIODevice* device) void QAudioOutput::stop() { /* - -If StopState, return - -set to StopState + -If StoppedState, return + -set to StoppedState -detach from audio device -emit stateChanged() */ @@ -257,7 +263,7 @@ void QAudioOutput::suspend() /* -If not ActiveState|IdleState, return -stop processing audio, saving all buffered audio data - -set NoError and SuspendState + -set NoError and SuspendedState -emit stateChanged() */ d->suspend(); @@ -270,7 +276,7 @@ void QAudioOutput::suspend() void QAudioOutput::resume() { /* - -If SuspendState, return + -If SuspendedState, return -resume audio -(PULL MODE): set ActiveState, NoError -(PUSH MODE): set IdleState, NoError @@ -358,9 +364,9 @@ int QAudioOutput::notifyInterval() const was called in microseconds. */ -qint64 QAudioOutput::totalTime() const +qint64 QAudioOutput::processedUSecs() const { - return d->totalTime(); + return d->processedUSecs(); } /*! @@ -368,9 +374,9 @@ qint64 QAudioOutput::totalTime() const Suspend states. */ -qint64 QAudioOutput::clock() const +qint64 QAudioOutput::elapsedUSecs() const { - return d->clock(); + return d->elapsedUSecs(); } /*! diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h index bb3496e..38bab8e 100644 --- a/src/multimedia/audio/qaudiooutput.h +++ b/src/multimedia/audio/qaudiooutput.h @@ -71,7 +71,9 @@ public: QAudioFormat format() const; - QIODevice* start(QIODevice *device = 0); + void start(QIODevice *device); + QIODevice* start(); + void stop(); void reset(); void suspend(); @@ -86,8 +88,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 689da89..e9784d2 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -77,7 +77,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; resuming = false; @@ -215,8 +215,8 @@ int QAudioOutputPrivate::setFormat() QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) - deviceState = QAudio::StopState; + if(deviceState != QAudio::StoppedState) + deviceState = QAudio::StoppedState; errorState = QAudio::NoError; @@ -256,9 +256,9 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; close(); emit stateChanged(deviceState); } @@ -304,7 +304,7 @@ bool QAudioOutputPrivate::open() } if (( err < 0)||(handle == 0)) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; return false; } snd_pcm_nonblock( handle, 0 ); @@ -387,7 +387,7 @@ bool QAudioOutputPrivate::open() if( err < 0) { qWarning()<stop(); if ( handle ) { @@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) if(err < 0) { close(); errorState = QAudio::FatalError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); } return 0; @@ -507,7 +507,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) buffer_size = value; } @@ -529,14 +529,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalTimeValue; } void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { int err = 0; if(handle) { @@ -571,7 +571,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { timer->stop(); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -579,7 +579,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::userFeed() { - if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return; #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); @@ -658,12 +658,12 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { if(!handle) return 0; - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h index 298e89e..619ecef 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.h +++ b/src/multimedia/audio/qaudiooutput_alsa_p.h @@ -91,8 +91,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index f23db80..e0651bf 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -288,7 +288,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF internalBufferSize = default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; audioThreadState = Stopped; intervalTimer = new QTimer(this); @@ -436,7 +436,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) QIODevice* op = device; if (!open()) { - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; } @@ -468,10 +468,10 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadDrain(); - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -480,10 +480,10 @@ void QAudioOutputPrivate::stop() void QAudioOutputPrivate::reset() { QMutexLocker lock(&mutex); - if (stateCode != QAudio::StopState) { + if (stateCode != QAudio::StoppedState) { audioThreadStop(); - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -495,7 +495,7 @@ void QAudioOutputPrivate::suspend() if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { audioThreadStop(); - stateCode = QAudio::SuspendState; + stateCode = QAudio::SuspendedState; errorCode = QAudio::NoError; QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); } @@ -504,7 +504,7 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::resume() { QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendState) { + if (stateCode == QAudio::SuspendedState) { audioThreadStart(); stateCode = QAudio::ActiveState; @@ -525,7 +525,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int bs) { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) internalBufferSize = bs; } @@ -544,14 +544,14 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTimer->interval(); } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalFrames * 1000000 / audioFormat.frequency(); } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { - if (stateCode == QAudio::StopState) + if (stateCode == QAudio::StoppedState) return 0; return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); @@ -614,7 +614,7 @@ void QAudioOutputPrivate::audioDeviceError() audioDeviceStop(); errorCode = QAudio::IOError; - stateCode = QAudio::StopState; + stateCode = QAudio::StoppedState; QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); } } diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h index 04b3239..76d06a9 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.h +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -128,8 +128,8 @@ public: void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 1810ed2..2cfc472 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -71,7 +71,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF intervalTime = 1000; audioBuffer = 0; errorState = QAudio::NoError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; audioSource = 0; pullMode = true; finished = false; @@ -157,7 +157,7 @@ QAudioFormat QAudioOutputPrivate::format() const QIODevice* QAudioOutputPrivate::start(QIODevice* device) { - if(deviceState != QAudio::StopState) + if(deviceState != QAudio::StoppedState) close(); if(!pullMode && audioSource) { @@ -187,7 +187,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) void QAudioOutputPrivate::stop() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; close(); if(!pullMode && audioSource) { @@ -255,7 +255,7 @@ bool QAudioOutputPrivate::open() (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioOutput: open error"); return false; @@ -277,10 +277,10 @@ bool QAudioOutputPrivate::open() void QAudioOutputPrivate::close() { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) return; - deviceState = QAudio::StopState; + deviceState = QAudio::StoppedState; int delay = (buffer_size-bytesFree())*1000/(settings.frequency() *settings.channels()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); @@ -308,7 +308,7 @@ int QAudioOutputPrivate::periodSize() const void QAudioOutputPrivate::setBufferSize(int value) { - if(deviceState == QAudio::StopState) + if(deviceState == QAudio::StoppedState) buffer_size = value; } @@ -330,7 +330,7 @@ int QAudioOutputPrivate::notifyInterval() const return intervalTime; } -qint64 QAudioOutputPrivate::totalTime() const +qint64 QAudioOutputPrivate::processedUSecs() const { return totalTimeValue; } @@ -390,7 +390,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) void QAudioOutputPrivate::resume() { - if(deviceState == QAudio::SuspendState) { + if(deviceState == QAudio::SuspendedState) { deviceState = QAudio::ActiveState; errorState = QAudio::NoError; waveOutRestart(hWaveOut); @@ -403,7 +403,7 @@ void QAudioOutputPrivate::suspend() { if(deviceState == QAudio::ActiveState) { waveOutPause(hWaveOut); - deviceState = QAudio::SuspendState; + deviceState = QAudio::SuspendedState; errorState = QAudio::NoError; emit stateChanged(deviceState); } @@ -417,7 +417,7 @@ void QAudioOutputPrivate::feedback() #endif bytesAvailable = bytesFree(); - if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState)) { + if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) { if(bytesAvailable >= period_size) QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); } @@ -491,9 +491,9 @@ bool QAudioOutputPrivate::deviceReady() return true; } -qint64 QAudioOutputPrivate::clock() const +qint64 QAudioOutputPrivate::elapsedUSecs() const { - if (deviceState == QAudio::StopState) + if (deviceState == QAudio::StoppedState) return 0; return timeStampOpened.elapsed()*1000; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index bcf8e1e..f90b8c2 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -90,8 +90,8 @@ public: int bufferSize() const; void setNotifyInterval(int milliSeconds); int notifyInterval() const; - qint64 totalTime() const; - qint64 clock() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; QAudio::Error error() const; QAudio::State state() const; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 7b9a422..715f219 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -77,7 +77,7 @@ private: void tst_QAudioDeviceInfo::initTestCase() { // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -90,7 +90,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput() { // Only perform tests if audio input device exists! bool storeAvailable = available; - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -111,7 +111,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultOutput() void tst_QAudioDeviceInfo::outputList() { if(available) { - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); QVERIFY(devices.size() > 0); device = new QAudioDeviceInfo(devices.at(0)); } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 286e63f..0778a8e 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -69,17 +69,20 @@ private slots: void tst_QAudioFormat::checkNull() { - // Default constructed QAudioFormat is null. + // Default constructed QAudioFormat is invalid. QAudioFormat audioFormat0; - QVERIFY(audioFormat0.isNull()); + QVERIFY(!audioFormat0.isValid()); - // Null is transferred + // validity is transferred QAudioFormat audioFormat1(audioFormat0); - QVERIFY(audioFormat1.isNull()); + QVERIFY(!audioFormat1.isValid()); - // Null is voided on activity audioFormat0.setFrequency(44100); - QVERIFY(!audioFormat0.isNull()); + audioFormat0.setChannels(2); + audioFormat0.setSampleSize(16); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setSampleType(QAudioFormat::SignedInt); + QVERIFY(audioFormat0.isValid()); } void tst_QAudioFormat::checkFrequency() diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 3efc346..744ce38 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -76,7 +76,7 @@ void tst_QAudioInput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio input device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -137,16 +137,16 @@ void tst_QAudioInput::pullFile() QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State))); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->state() == QAudio::StoppedState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->elapsedUSecs() == 0); audio->start(&filename); QTest::qWait(20); // Check state and periodSize() are valid non-zero values. QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); + QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); QVERIFY(audio->periodSize() > 0); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState @@ -154,12 +154,12 @@ void tst_QAudioInput::pullFile() QTest::qWait(5000); QVERIFY(readSignal.count() > 0); - QVERIFY(audio->totalTime() > 0); + QVERIFY(audio->processedUSecs() > 0); audio->stop(); QTest::qWait(20); - QVERIFY(audio->state() == QAudio::StopState); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->elapsedUSecs() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index b001af1..26694cc 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -79,7 +79,7 @@ void tst_QAudioOutput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio output device exists! - QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -140,9 +140,9 @@ void tst_QAudioOutput::pullFile() audio->setNotifyInterval(100); // Always have default states, before start - QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->state() == QAudio::StoppedState); QVERIFY(audio->error() == QAudio::NoError); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->elapsedUSecs() == 0); audio->start(&file); QTest::qWait(20); // wait 20ms @@ -150,12 +150,12 @@ void tst_QAudioOutput::pullFile() QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); QVERIFY(audio->periodSize() > 0); - QVERIFY(audio->clock() > 10000 && audio->clock() < 800000); + QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState // Wait until finished... QTestEventLoop::instance().enterLoop(1); - QCOMPARE(audio->totalTime(), qint64(692250)); + QCOMPARE(audio->processedUSecs(), qint64(692250)); #ifdef Q_OS_WINCE // 4.wav is a little less than 700ms, so notify should fire 4 times on Wince! @@ -166,8 +166,8 @@ void tst_QAudioOutput::pullFile() #endif audio->stop(); QTest::qWait(20); // wait 20ms - QVERIFY(audio->state() == QAudio::StopState); - QVERIFY(audio->clock() == 0); + QVERIFY(audio->state() == QAudio::StoppedState); + QVERIFY(audio->elapsedUSecs() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); @@ -184,7 +184,7 @@ void tst_QAudioOutput::pushFile() const qint64 fileSize = file.size(); - QIODevice* feed = audio->start(0); + QIODevice* feed = audio->start(); char* buffer = new char[fileSize]; file.read(buffer, fileSize); @@ -199,7 +199,7 @@ void tst_QAudioOutput::pushFile() QTestEventLoop::instance().enterLoop(1); QVERIFY(written == fileSize); - QVERIFY(audio->totalTime() == 692250); + QVERIFY(audio->processedUSecs() == 692250); audio->stop(); file.close(); -- cgit v0.12 From ca199c62e0a0da82ac086eea1462073d519ea7e9 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Mon, 9 Nov 2009 14:26:02 +1000 Subject: Fixed runtime error in QAudioInput::bytesReady() function If bytesReady() was called before start(), Div by Zero. Added check for this condition. Task-number:QTBUG-5300 Reviewed-by:Justin McPherson --- src/multimedia/audio/qaudioinput_win32_p.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 31f6e25..b7f9ffd 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -333,6 +333,9 @@ void QAudioInputPrivate::close() int QAudioInputPrivate::bytesReady() const { + if(period_size == 0 || buffer_size == 0) + return 0; + int buf = ((buffer_size/period_size)-waveFreeBlockCount)*period_size; if(buf < 0) buf = 0; -- cgit v0.12 From df64570cb5f65c348816e0bfb6d818642f04e468 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 10 Nov 2009 14:09:39 +1000 Subject: update dist/changes-4.6.0 --- dist/changes-4.6.0 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index f90777d..fb1f6af 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -322,6 +322,31 @@ QtOpenGL - QGLGradientCache * [249919] Clean up the gradient cache in the right context. +QtSql + * [QTBUG-5179] Fixed Floating point number truncation in qsqlpsql plugin. + * [QTBUG-551] Fixed Oracle batchExec using strings as out params. + * Updated sqlite to 3.6.19 + readded our patches. + * [QTBUG-3736] ODBC: Retrieved in ascii, should be stored in ascii. + * Fixed issue with multiple lookups to same table/field in QSqlRelationalTableModel + * Updated documentation of setForwardOnly + * [QT-754] TDS: Fixed improper formatting of date values + * TDS: Fixed missing field/table name escaping. + * ODBC: Fixed setForwardOnly not being reset on when the query is reset. + * [QTBUG-4510] Add reconnection option to the mysql driver. + * [222678] Fixed QSqlTableModel: trying to delete the wrong row. + * Interbase: Fixed crash when calling numRows on unknown query type. + * DB2: Don't return an error when the table is just empty. + * [17327] Added OCI support for synonyms to tables created by another user. + * [176267] Fixed mysql driver not knowing the difference between tables and views. + * Fixed determination of end of ODBC string on deficient drivers. + * Added ability to open sqlite databases readonly. + * Fixed race condition on reopening an ODBC connection. + * Fixed invalid use of statics in the defaultCasing code. + * Fixed proper quoting under odbc. + * [252450 & 246125] Fixed failed queries due to MySql driver auto-preparing. + * QSqlDatabase now has a database level precisionPolicy. Queries now default to this. + * Add proper iODBC linking support. + QtXml - QDomDocument -- cgit v0.12 From eba8efb5b91baea88ca94da181fd746c6e9252ec Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Tue, 10 Nov 2009 14:22:39 +1000 Subject: update changelog --- dist/changes-4.6.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index fb1f6af..2d4e154 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -323,6 +323,9 @@ QtOpenGL * [249919] Clean up the gradient cache in the right context. QtSql + * [QTBUG-3162] Views for Sql table models should not reset state on failed queries. + * [QTBUG-5251] Fix retrieval of SQL 'TIME' information for PostgreSQL. + * Better error checking for in case of failed query. * [QTBUG-5179] Fixed Floating point number truncation in qsqlpsql plugin. * [QTBUG-551] Fixed Oracle batchExec using strings as out params. * Updated sqlite to 3.6.19 + readded our patches. -- cgit v0.12 From 5d6d088bd777c429f691c53b0310952e39a66e83 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 10 Nov 2009 14:41:27 +1000 Subject: Update change log with multimedia changes. --- dist/changes-4.6.0 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 2d4e154..dcf62e3 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -39,6 +39,12 @@ information about a particular change. - Improved support for input methods in graphics view. + - QAudioInput, QAudioOutput + * New audio input and output classes. + + - QAbstractVideoSurface, QVideoFrame + * New abstract video output classes. + Third party components ---------------------- -- cgit v0.12 From 6da8c83d8b5465cf9b767f288d3ebfa0727085c2 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Tue, 10 Nov 2009 07:40:26 +0100 Subject: Fix failing sub-src target sub-src was iterating over SRC_SUBDIRS and not SUBDIRS. So, when the tools were refactored out to handle distributed builds of host tools with Electric Cloud, these tools were not included in the iteration. Adding $$TOOLS_SUBDIRS to the recurse fixes this. Also avoid setting dependencies for non-ordered builds Reviewed-by: Jason McDonald --- src/src.pro | 2 +- src/tools/tools.pro | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/src.pro b/src/src.pro index 7cab6c9..8dec49b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -120,7 +120,7 @@ src_declarative.target = sub-declarative !symbian { # This creates a sub-src rule sub_src_target.CONFIG = recursive -sub_src_target.recurse = $$SRC_SUBDIRS +sub_src_target.recurse = $$TOOLS_SUBDIRS $$SRC_SUBDIRS sub_src_target.target = sub-src sub_src_target.recurse_target = QMAKE_EXTRA_TARGETS += sub_src_target diff --git a/src/tools/tools.pro b/src/tools/tools.pro index 7c8fb47..25527e3 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -20,10 +20,12 @@ src_tools_uic3.target = sub-uic3 src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc src_tools_idc.target = sub-idc -# Set dependencies for each subdir -src_tools_moc.depends = src_tools_bootstrap -src_tools_rcc.depends = src_tools_bootstrap -src_tools_uic.depends = src_tools_bootstrap +!wince*:!symbian:!ordered { + # Set dependencies for each subdir + src_tools_moc.depends = src_tools_bootstrap + src_tools_rcc.depends = src_tools_bootstrap + src_tools_uic.depends = src_tools_bootstrap +} # Special handling, depending on type of project, if it used debug/release or only has one configuration EXTRA_DEBUG_TARGETS = -- cgit v0.12 From 91ad55af99b54b7a5cfdf08984ece030fd70692c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 10 Nov 2009 08:52:00 +0100 Subject: Updated changelog with my changes --- dist/changes-4.6.0 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index dcf62e3..4635813 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -328,6 +328,21 @@ QtOpenGL - QGLGradientCache * [249919] Clean up the gradient cache in the right context. + - OpenGL (ES) 2.0 Paint Engine + * Re-written the OpenGL (ES) 2.0 Paint Engine's shader manager to use new + shader API and to allow custom code from E.g. Pixmap Filters to be + instered into the fragment "pipeline". + * Fixed conical gradients. + + - Cleaned up usage of OpenGL extensions. QtOpenGL now uses the OpenGL 2.0 + names of methods rather than using the EXT postfix. However, when resolving + extensions, QtOpenGL will also try postfixing EXT if the OpenGL 2.0 name is + not found. + + - Fix QGLWidget::showFullscreen() on EGL platforms + + - Added lots of OpenGL autotests. + QtSql * [QTBUG-3162] Views for Sql table models should not reset state on failed queries. * [QTBUG-5251] Fix retrieval of SQL 'TIME' information for PostgreSQL. @@ -388,6 +403,23 @@ Qt for Linux/X11 - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. + - Improved EGL integration on X11 (including better visual selection). + + - Support Qt::WA_TranslucentBackground on top-level QGLWidgets on X11, both + (EGL & glX). This allows OpenGL (& ES) rendering to semi-transparent widgets + if a compositing window manager is running. + + - Support OpenGL texture_from_pixmap extension on X11 (EGL & glX) when + calling QPainter::drawPixmap() with the OpenGL paint engine, or calling + QGLContext::bindTexture() on an X11 QPixmap. If the + GLX_EXT_texture_from_pixmap or EGL_NOKIA_texture_from_pixmap extensions are + present, Qt will attempt to use glXBindTexImageEXT or eglBindTexImage to + bind the pixmap to a texture, rather than copying the pixel data. + + - Add new experimental QX11GLPixmapData backend for QPixmap. This pixmap + backend uses regular X11 pixmaps to store the image data, however it uses + OpenGL to render into them. + Qt for Windows -------------- @@ -682,3 +714,4 @@ Qt for Windows CE - Refactoring in OpenGL examples to improve portability and utilize the Animation framework for animation. The hellogl and overpainting examples now compile on OpenGL/ES 1.1. Also common code is factored. + -- cgit v0.12 From 38dd2ed2b03656283a3c6170eda6d445ff1241f4 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 10 Nov 2009 09:48:47 +0100 Subject: QNAM HTTP Code: Start authorization header with capital letter HTTP header names are case insensitive, but stick to what all browsers etc. use to work around buggy servers. Task-number: QTBUG-5618 Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1124337..8dd7a00 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -372,7 +372,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); - request.setHeaderField("authorization", response); + request.setHeaderField("Authorization", response); } } } @@ -381,7 +381,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); - request.setHeaderField("proxy-authorization", response); + request.setHeaderField("Proxy-Authorization", response); } } } -- cgit v0.12 From 45c197899b7444230c7eefbb6f208eb237b07ed2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 10 Nov 2009 10:04:06 +0100 Subject: My changes for 4.6.0 --- dist/changes-4.6.0 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 4635813..895421d 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -512,6 +512,16 @@ Qt for Embedded Linux - Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. +- Send enter/leave events also to child widgets + +- Fix crash when instantiating multiple QApplications + +- Optimize software cursor by using native image format instead of 8-bit + +- [255828] Avoid window decoration flicker on show + +- [255495] Fix blend function crash on AVR32 + Qt for Windows CE ----------------- - On Windows CE the link time code generation has been disabled by default to -- cgit v0.12 From d5db58127b16f3c2508975661ee7328f569b9518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 6 Nov 2009 16:09:39 +0100 Subject: Make QScopedPointer::operator== and != non-member Non-member operator allows implicit conversions on both arguments. A single operator is enough to support QScopedArrayPointer, QCustomScopedPointer and QScopedSharedPointer since equality semantics don't change and the deleter is managed in the base class. Reviewed-by: Marius Storm-Olsen --- src/corelib/tools/qscopedpointer.h | 52 +++++++++----------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 7cbdb6c..b433723 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -113,16 +113,6 @@ public: return d; } - inline bool operator==(const QScopedPointer &other) const - { - return d == other.d; - } - - inline bool operator!=(const QScopedPointer &other) const - { - return d != other.d; - } - inline bool operator!() const { return !d; @@ -181,6 +171,18 @@ private: }; template +inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) +{ + return lhs.data() == rhs.data(); +} + +template +inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) +{ + return lhs.data() != rhs.data(); +} + +template Q_INLINE_TEMPLATE void qSwap(QScopedPointer &p1, QScopedPointer &p2) { p1.swap(p2); } @@ -203,16 +205,6 @@ public: return this->d[i]; } - inline bool operator==(const QScopedArrayPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedArrayPointer &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QScopedArrayPointer) }; @@ -233,16 +225,6 @@ public: return this->d; } - inline bool operator==(const QCustomScopedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QCustomScopedPointer &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QCustomScopedPointer) }; @@ -287,16 +269,6 @@ public: QScopedPointerSharedDeleter::cleanup(oldD); } - inline bool operator==(const QScopedSharedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedSharedPointer &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QScopedSharedPointer) }; -- cgit v0.12 From 7bfdec392df263b15fb5661ab7d4f66f1cd8fbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 6 Nov 2009 17:35:10 +0100 Subject: Extending QScopedPointer test case ... to also test QScopedArrayPointer, QCustomScopedPointer and QScopedSharedPointer. Added one level of indirection to comparison test case to avoid double-delete in case of test failure. The test also tests other aspects of Q*Scoped*Pointer behavior. Reviewed-by: Olivier Goffart --- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 156 ++++++++++++++++++++--- 1 file changed, 139 insertions(+), 17 deletions(-) diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index aeead15..f319891 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -313,30 +313,152 @@ void tst_QScopedPointer::objectSize() QCOMPARE(sizeof(QScopedPointer), sizeof(void *)); } -void tst_QScopedPointer::comparison() +struct RefCounted { - int *a = new int(42); - int *b = new int(43); + RefCounted() + : ref(0) + { + instanceCount.ref(); + } + + RefCounted(RefCounted const &other) + : ref(0) + { + instanceCount.ref(); + } + + ~RefCounted() + { + QVERIFY( ref == 0 ); + instanceCount.deref(); + } + + RefCounted &operator=(RefCounted const &) + { + } + + QAtomicInt ref; + + static QAtomicInt instanceCount; +}; - QScopedPointer pa(a); - QScopedPointer pa2(a); - QScopedPointer pb(b); +QAtomicInt RefCounted::instanceCount = 0; +template +void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b) +{ // test equality on equal pointers - QVERIFY(pa == pa2); - QVERIFY(pa2 == pa); + QVERIFY(a1 == a2); + QVERIFY(a2 == a1); + + // test inequality on equal pointers + QVERIFY(!(a1 != a2)); + QVERIFY(!(a2 != a1)); + + // test equality on unequal pointers + QVERIFY(!(a1 == b)); + QVERIFY(!(a2 == b)); + QVERIFY(!(b == a1)); + QVERIFY(!(b == a2)); + + // test inequality on unequal pointers + QVERIFY(b != a1); + QVERIFY(b != a2); + QVERIFY(a1 != b); + QVERIFY(a2 != b); +} + +void tst_QScopedPointer::comparison() +{ + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + QScopedPointer pa1(a); + QScopedPointer pa2(a); + QScopedPointer pb(b); + + scopedPointerComparisonTest(pa1, pa1, pb); + scopedPointerComparisonTest(pa2, pa2, pb); + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } - // test unequality on equal pointers - QVERIFY(!(pa != pa2)); - QVERIFY(!(pa2 != pa)); + QCOMPARE( int(RefCounted::instanceCount), 0 ); - // test on unequal pointers - QVERIFY(!(pa == pb)); - QVERIFY(!(pb == pa)); - QVERIFY(pb != pa); - QVERIFY(pa != pb); + { + RefCounted *a = new RefCounted[42]; + RefCounted *b = new RefCounted[43]; + + QCOMPARE( int(RefCounted::instanceCount), 85 ); + + QScopedArrayPointer pa1(a); + QScopedArrayPointer pa2(a); + QScopedArrayPointer pb(b); + + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 85 ); + } + + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + // QCustomScopedPointer is an internal helper class -- it is unsupported! + + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + QCustomScopedPointer pa1(a); + QCustomScopedPointer pa2(a); + QCustomScopedPointer pb(b); + + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } + + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + // QScopedSharedPointer is an internal helper class -- it is unsupported! + + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + a->ref.ref(); + QScopedSharedPointer pa1(a); + a->ref.ref(); + QScopedSharedPointer pa2(a); + b->ref.ref(); + QScopedSharedPointer pb(b); + + + QCOMPARE( int(a->ref), 2 ); + QCOMPARE( int(b->ref), 1 ); + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + scopedPointerComparisonTest(pa1, pa2, pb); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } - pa2.take(); + QCOMPARE( int(RefCounted::instanceCount), 0 ); } QTEST_MAIN(tst_QScopedPointer) -- cgit v0.12 From d15d7385cb6cfb453ab08d6d7154b66c3fb087ee Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Mon, 9 Nov 2009 18:38:17 +0100 Subject: Updated WebKit from /home/jturcott/dev/webkit/ to qtwebkit/qtwebkit-4.6 ( 363898ca378e2198b855ca2f8921c5e4f898c5e2 ) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-11-09 Benjamin Poulain Reviewed by Kenneth Rohde Christiansen. https://bugs.webkit.org/show_bug.cgi?id=30772 Add a non-const iterator to QWebElementCollection. Move the two attributes of the iterator to private. * Api/qwebelement.h: (const_iterator::begin): (const_iterator::end): (const_iterator::constBegin): (const_iterator::constEnd): (const_iterator::iterator::iterator): (const_iterator::iterator::operator*): (const_iterator::iterator::operator==): (const_iterator::iterator::operator!=): (const_iterator::iterator::operator<): (const_iterator::iterator::operator<=): (const_iterator::iterator::operator>): (const_iterator::iterator::operator>=): (const_iterator::iterator::operator++): (const_iterator::iterator::operator--): (const_iterator::iterator::operator+=): (const_iterator::iterator::operator-=): (const_iterator::iterator::operator+): (const_iterator::iterator::operator-): * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::nonConstIterator): (tst_QWebElement::constIterator): 2009-11-09 Laszlo Gombos Reviewed by Kenneth Christiansen. [Qt] Remove the sessionStorage setting (per Page) https://bugs.webkit.org/show_bug.cgi?id=31249 This setting allows to run sessionStorage on/off on a per page basis. Remove this prematurely exposed API. * Api/qwebsettings.cpp: (QWebSettingsPrivate::apply): (QWebSettings::QWebSettings): * tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::database): (tst_QWebPage::testOptionalJSObjects): 2009-11-09 Jocelyn Turcotte Reviewed by Simon Hausmann. [Qt] Remove the QWebPage:webInspectorTriggered signal. User customization of the communication between QWebPage and QWebInspector will be properly designed in the next version. https://bugs.webkit.org/show_bug.cgi?id=30773 * Api/qwebinspector.cpp: * Api/qwebpage.cpp: (QWebPagePrivate::getOrCreateInspector): (QWebPage::triggerAction): * Api/qwebpage.h: * QtLauncher/main.cpp: (MainWindow::MainWindow): 2009-11-05 Simon Hausmann Reviewed by Tor Arne Vestbø. Added a missing re-implementation of QGraphicsItem::inputMethodQuery(). * Api/qgraphicswebview.cpp: (QGraphicsWebView::inputMethodQuery): * Api/qgraphicswebview.h: 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Provide a dummy re-implementation of QGraphicsLayoutItem::sizeHint(), similar to QWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebView::sizeHint): * Api/qgraphicswebview.h: 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Removed zoomFactoryChanged() signal and added linkClicked() to QGraphicsWebView, for consistency with QWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebView::setPage): (QGraphicsWebView::setZoomFactor): * Api/qgraphicswebview.h: 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Added QGraphicsWebView::findText() for convenience and consistency with QWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebView::findText): * Api/qgraphicswebview.h: 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Added QGraphicsWebView::pageAction() and triggerPageAction(), for consistency with QWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebView::pageAction): (QGraphicsWebView::triggerPageAction): * Api/qgraphicswebview.h: 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Removed QGraphicsWebView::toHtml() after API review. That's consistent with QWebView and also based on the assumption that toHtml() is called less frequently than setHtml(). * Api/qgraphicswebview.cpp: * Api/qgraphicswebview.h: * tests/qgraphicswebview/tst_qgraphicswebview.cpp: (tst_QGraphicsWebView::qgraphicswebview): 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Removed the interactive property of QGraphicsWebView. There are clearly use-cases for this feature, but it will require more work to make this fully work with an enum to have fine-grained control over the interactivity levels. For now it is easy to achieve in user-code what the boolean property did. * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): (QGraphicsWebView::hoverMoveEvent): (QGraphicsWebView::mouseMoveEvent): (QGraphicsWebView::mousePressEvent): (QGraphicsWebView::mouseReleaseEvent): (QGraphicsWebView::mouseDoubleClickEvent): (QGraphicsWebView::keyPressEvent): (QGraphicsWebView::keyReleaseEvent): (QGraphicsWebView::dragLeaveEvent): (QGraphicsWebView::dragMoveEvent): (QGraphicsWebView::dropEvent): (QGraphicsWebView::wheelEvent): (QGraphicsWebView::inputMethodEvent): * Api/qgraphicswebview.h: * tests/qgraphicswebview/tst_qgraphicswebview.cpp: (tst_QGraphicsWebView::qgraphicswebview): 2009-11-04 Simon Hausmann Reviewed by Tor Arne Vestbø. Make the QGraphicsWebView constructor explicit. * Api/qgraphicswebview.h: 2009-11-05 Simon Hausmann Last Qt 4.5 build fix (*sigh*) * tests/qwebpage/tst_qwebpage.cpp: (inputMethodHints): inputMethodHints() is only used for Qt 4.6, so guard the whole function. 2009-11-05 Simon Hausmann Another prospective build fix against Qt 4.5 (build bot) Don't compile & run the QGraphicsWebView portion of the input methods auto test with Qt 4.5. * tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::inputMethods_data): (inputMethodHints): (inputMethodEnabled): (tst_QWebPage::inputMethods): 2009-11-05 Simon Hausmann Prospective build fix against Qt 4.5 (build bot) * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::setInputMethodEnabled): Guard the use of Qt 4.6 specific API with #ifdefs. 2009-11-01 Simon Hausmann Reviewed by Kenneth Christiansen. [Qt] Fix enabling of input method support on QGraphicsWebView. https://bugs.webkit.org/show_bug.cgi?id=30605 Instead of setting the unsupported widget attribute on the QGraphicsWidget in setInputMethodEnabled() set the ItemAcceptsInputMethod GraphicsItem flag directly. Changed the existing input method auto test to run once on a QWebView and once on a QGraphicsWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::setInputMethodEnabled): * tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::inputMethods_data): (inputMethodHints): (inputMethodEnabled): (tst_QWebPage::inputMethods): 2009-11-04 Simon Hausmann Reviewed by Kenneth Christiansen. Added QGraphicsWebView::modified property, for consistency with QWebView. * Api/qgraphicswebview.cpp: (QGraphicsWebView::isModified): * Api/qgraphicswebview.h: * tests/qgraphicswebview/tst_qgraphicswebview.cpp: (tst_QGraphicsWebView::qgraphicswebview): 2009-11-04 Simon Hausmann Reviewed by Kenneth Christiansen. Removed status and progress properties of QGraphicsWebView. Added loadProgress and statusBarMessage signals instead, after API review. * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): (QGraphicsWebView::setPage): * Api/qgraphicswebview.h: * tests/qgraphicswebview/tst_qgraphicswebview.cpp: (tst_QGraphicsWebView::qgraphicswebview): --- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 40 +-- .../webkit/JavaScriptCore/runtime/Collector.cpp | 8 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 18 ++ src/3rdparty/webkit/WebCore/WebCore.pro | 15 -- src/3rdparty/webkit/WebCore/platform/FileSystem.h | 11 - .../platform/network/qt/ResourceHandleQt.cpp | 17 ++ .../WebCore/platform/qt/PlatformScreenQt.cpp | 2 +- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 286 ++++++++------------- .../webkit/WebKit/qt/Api/qgraphicswebview.h | 34 ++- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h | 71 +++-- .../webkit/WebKit/qt/Api/qwebinspector.cpp | 6 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 41 +-- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h | 1 - src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp | 7 - src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h | 1 - src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 4 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 252 ++++++++++++++++++ .../qgraphicswebview/tst_qgraphicswebview.cpp | 6 +- .../qt/tests/qwebelement/tst_qwebelement.cpp | 33 +++ .../webkit/WebKit/qt/tests/qwebframe/qwebframe.pro | 2 +- .../WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 4 - .../webkit/WebKit/qt/tests/qwebpage/qwebpage.pro | 2 +- .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 125 ++++++--- 24 files changed, 598 insertions(+), 390 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 470ed0b..c999618 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -75,25 +75,12 @@ namespace JSC { #define THUMB_FUNC_PARAM(name) #endif -#if PLATFORM(LINUX) && (PLATFORM(X86_64) || PLATFORM(X86)) +#if PLATFORM(LINUX) && PLATFORM(X86_64) #define SYMBOL_STRING_RELOCATION(name) #name "@plt" #else #define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name) #endif -#if PLATFORM(DARWIN) - // Mach-O platform -#define HIDE_SYMBOL(name) ".private_extern _" #name -#elif PLATFORM(AIX) - // IBM's own file format -#define HIDE_SYMBOL(name) ".lglobl " #name -#elif PLATFORM(LINUX) || PLATFORM(FREEBSD) || PLATFORM(OPENBSD) || PLATFORM(SOLARIS) || (PLATFORM(HPUX) && PLATFORM(IA64)) || PLATFORM(SYMBIAN) || PLATFORM(NETBSD) - // ELF platform -#define HIDE_SYMBOL(name) ".hidden " #name -#else -#define HIDE_SYMBOL(name) -#endif - #if USE(JSVALUE32_64) #if COMPILER(GCC) && PLATFORM(X86) @@ -106,9 +93,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -129,7 +114,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -145,7 +129,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x3c, %esp" "\n" "popl %ebx" "\n" @@ -170,7 +153,6 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_ asm volatile ( ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -197,7 +179,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -213,7 +194,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x48, %rsp" "\n" "popq %rbx" "\n" @@ -235,7 +215,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -262,7 +241,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -368,9 +346,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -391,7 +367,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -407,7 +382,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x1c, %esp" "\n" "popl %ebx" "\n" @@ -430,9 +404,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -466,7 +438,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -482,7 +453,6 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x78, %rsp" "\n" "popq %rbx" "\n" @@ -504,7 +474,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -531,7 +500,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -549,7 +517,6 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" @@ -564,9 +531,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #elif COMPILER(GCC) && PLATFORM(ARM_TRADITIONAL) asm volatile ( -".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "stmdb sp!, {r1-r3}" "\n" "stmdb sp!, {r4-r8, lr}" "\n" @@ -583,14 +548,12 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "mov r0, sp" "\n" "bl " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" // Both has the same return sequence ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "add sp, sp, #36" "\n" "ldmia sp!, {r4-r8, lr}" "\n" @@ -925,7 +888,6 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD ".text" "\n" \ ".align 2" "\n" \ ".globl " SYMBOL_STRING(cti_##op) "\n" \ - HIDE_SYMBOL(cti_##op) "\n" \ ".thumb" "\n" \ ".thumb_func " THUMB_FUNC_PARAM(cti_##op) "\n" \ SYMBOL_STRING(cti_##op) ":" "\n" \ diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp index 8b647a0..b885049 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp @@ -240,9 +240,7 @@ void Heap::destroy() template NEVER_INLINE CollectorBlock* Heap::allocateBlock() { - // Disable the use of vm_map for the Qt build on Darwin, because when compiled on 10.4 - // it crashes on 10.5 -#if PLATFORM(DARWIN) && !PLATFORM(QT) +#if PLATFORM(DARWIN) vm_address_t address = 0; // FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: . vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); @@ -334,9 +332,7 @@ NEVER_INLINE void Heap::freeBlock(size_t block) NEVER_INLINE void Heap::freeBlock(CollectorBlock* block) { - // Disable the use of vm_deallocate for the Qt build on Darwin, because when compiled on 10.4 - // it crashes on 10.5 -#if PLATFORM(DARWIN) && !PLATFORM(QT) +#if PLATFORM(DARWIN) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif PLATFORM(SYMBIAN) userChunk->Free(reinterpret_cast(block)); diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 810781f..ae1c3b6 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 - 16aab1b39e14195abdc2100265da2e45b96b739f + 363898ca378e2198b855ca2f8921c5e4f898c5e2 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 1dfc2f9..be07193 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2009-11-09 Yael Aharon + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Pass credentials provided by XMLHTTPRequest to the network request. + https://bugs.webkit.org/show_bug.cgi?id=31208 + + After r42483, the credentials are no longer passed to the network request + in the URL of the request. + Pass the credentials from XMLHTTPRequest to the network request, the same + way that other ports do. + + After this patch LayoutTests/http/xmlhttprequest/basic-auth.html passes. + + * platform/network/qt/ResourceHandleQt.cpp: + (WebCore::ResourceHandle::start): + (WebCore::ResourceHandle::loadResourceSynchronously): + 2009-11-03 Simon Hausmann Unreviewed build fix for WebInspector with Qt build. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 4e84a80..60e414f 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -3381,18 +3381,3 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4 plugins/win/PaintHooks.asm } } - -# Temporary workaround to pick up the DEF file from the same place as all the others -symbian { - shared { - contains(MMP_RULES, defBlock) { - MMP_RULES -= defBlock - - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ../../../s60installs/bwins/$${TARGET}.def" \ - "$${LITERAL_HASH}elif defined EABI" \ - "DEFFILE ../../../s60installs/eabi/$${TARGET}.def" \ - "$${LITERAL_HASH}endif" - } - } -} diff --git a/src/3rdparty/webkit/WebCore/platform/FileSystem.h b/src/3rdparty/webkit/WebCore/platform/FileSystem.h index 791198d..9952b39 100644 --- a/src/3rdparty/webkit/WebCore/platform/FileSystem.h +++ b/src/3rdparty/webkit/WebCore/platform/FileSystem.h @@ -98,17 +98,6 @@ struct PlatformModuleVersion { { } - bool operator != (const PlatformModuleVersion& rhs) const - { - return mostSig != rhs.mostSig && leastSig != rhs.leastSig; - } - - - bool operator > (const PlatformModuleVersion& rhs) const - { - return mostSig > rhs.mostSig && leastSig > rhs.leastSig; - } - }; #else typedef unsigned PlatformModuleVersion; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp index f4c30c9..b3844bf 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp @@ -131,6 +131,15 @@ bool ResourceHandle::start(Frame* frame) if (!page) return false; + if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) { + // If credentials were specified for this request, add them to the url, + // so that they will be passed to QNetworkRequest. + KURL urlWithCredentials(d->m_request.url()); + urlWithCredentials.setUser(d->m_user); + urlWithCredentials.setPass(d->m_pass); + d->m_request.setURL(urlWithCredentials); + } + getInternal()->m_frame = static_cast(frame->loader()->client())->webFrame(); #if QT_VERSION < 0x040400 return QWebNetworkManager::self()->add(this, getInternal()->m_frame->page()->d->networkInterface); @@ -204,6 +213,14 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, S } #else ResourceHandleInternal *d = handle.getInternal(); + if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) { + // If credentials were specified for this request, add them to the url, + // so that they will be passed to QNetworkRequest. + KURL urlWithCredentials(d->m_request.url()); + urlWithCredentials.setUser(d->m_user); + urlWithCredentials.setPass(d->m_pass); + d->m_request.setURL(urlWithCredentials); + } d->m_frame = static_cast(frame->loader()->client())->webFrame(); d->m_job = new QNetworkReplyHandler(&handle, QNetworkReplyHandler::LoadNormal); #endif diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp index 442ffa3..8221760 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp @@ -72,7 +72,7 @@ int screenDepthPerComponent(Widget* w) bool screenIsMonochrome(Widget* w) { - return QApplication::desktop()->screen(screenNumber(w))->colorCount() < 2; + return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2; } FloatRect screenRect(Widget* w) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp index b22109b..0365181 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -39,8 +39,6 @@ public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) : q(parent) , page(0) - , interactive(true) - , progress(1.0) {} virtual void scroll(int dx, int dy, const QRect&); @@ -61,28 +59,12 @@ public: virtual QObject* pluginParent() const; - void _q_doLoadProgress(int progress); void _q_doLoadFinished(bool success); - void _q_setStatusBarMessage(const QString& message); QGraphicsWebView* q; QWebPage* page; - - QString statusBarMessage; - bool interactive; - qreal progress; }; -void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress) -{ - if (qFuzzyCompare(this->progress, qreal(progress / 100.))) - return; - - this->progress = progress / 100.; - - emit q->progressChanged(this->progress); -} - void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) { // If the page had no title, still make sure it gets the signal @@ -105,8 +87,11 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) { - q->setAttribute(Qt::WA_InputMethodEnabled, enable); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); +#endif } + #if QT_VERSION >= 0x040600 void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) { @@ -156,109 +141,19 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const return q; } -void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s) -{ - statusBarMessage = s; - emit q->statusChanged(); -} - /*! \class QGraphicsWebView - \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. + \brief The QGraphicsWebView class allows web content to be added to a GraphicsView. \since 4.6 - An instance of this class renders Web content from a URL or supplied as data, using - features of the QtWebKit module. - - If the width and height of the item is not set, they will dynamically adjust to - a size appropriate for the content. This width may be large (e.g., 980 pixels or - more) for typical online Web pages. - - \section1 Browser Features - - Many of the functions, signals and properties provided by QWebView are also available - for this item, making it simple to adapt existing code to use QGraphicsWebView instead - of QWebView. - - The item uses a QWebPage object to perform the rendering of Web content, and this can - be obtained with the page() function, enabling the document itself to be accessed and - modified. - - As with QWebView, the item records the browsing history using a QWebHistory object, - accessible using the history() function. The QWebSettings object that defines the - configuration of the browser can be obtained with the settings() function, enabling - features like plugin support to be customized for each item. + A WebGraphicsItem renders web content based on a URL or set data. - \sa QWebView, QGraphicsTextItem + If the width and height of the item is not set, they will + dynamically adjust to a size appropriate for the content. + This width may be large (eg. 980) for typical online web pages. */ /*! - \fn void QGraphicsWebView::titleChanged(const QString &title) - - This signal is emitted whenever the \a title of the main frame changes. - - \sa title() -*/ - -/*! - \fn void QGraphicsWebView::urlChanged(const QUrl &url) - - This signal is emitted when the \a url of the view changes. - - \sa url(), load() -*/ - -/*! - \fn void QGraphicsWebView::statusChanged() - - This signal is emitted when the status bar text is changed by the page. -*/ - -/*! - \fn void QGraphicsWebView::iconChanged() - - This signal is emitted whenever the icon of the page is loaded or changes. - - In order for icons to be loaded, you will need to set an icon database path - using QWebSettings::setIconDatabasePath(). - - \sa icon(), QWebSettings::setIconDatabasePath() -*/ - -/*! - \fn void QGraphicsWebView::loadStarted() - - This signal is emitted when a new load of the page is started. - - \sa progressChanged(), loadFinished() -*/ - -/*! - \fn void QGraphicsWebView::loadFinished(bool ok) - - This signal is emitted when a load of the page is finished. - \a ok will indicate whether the load was successful or any error occurred. - - \sa loadStarted() -*/ - -/*! - \fn void QGraphicsWebView::progressChanged(qreal progress) - - This signal is emitted every time an element in the web page - completes loading and the overall loading progress advances. - - This signal tracks the progress of all child frames. - - The current value is provided by \a progress and scales from 0.0 to 1.0, - which is the default range of QProgressBar. - - \sa loadStarted(), loadFinished() -*/ - - - -/*! Constructs an empty QGraphicsWebView with parent \a parent. \sa load() @@ -275,7 +170,7 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) } /*! - Destroys the item. + Destroys the web graphicsitem. */ QGraphicsWebView::~QGraphicsWebView() { @@ -356,6 +251,24 @@ QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant& /*! \reimp */ +QSizeF QGraphicsWebView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const +{ + if (which == Qt::PreferredSize) + return QSizeF(800, 600); // ### + return QGraphicsWidget::sizeHint(which, constraint); +} + +/*! \reimp +*/ +QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const +{ + if (d->page) + return d->page->inputMethodQuery(query); + return QVariant(); +} + +/*! \reimp +*/ bool QGraphicsWebView::event(QEvent* event) { // Re-implemented in order to allows fixing event-related bugs in patch releases. @@ -438,11 +351,13 @@ void QGraphicsWebView::setPage(QWebPage* page) connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); connect(d->page, SIGNAL(loadProgress(int)), - this, SLOT(_q_doLoadProgress(int))); + this, SIGNAL(loadProgress(int))); connect(d->page, SIGNAL(loadFinished(bool)), this, SLOT(_q_doLoadFinished(bool))); connect(d->page, SIGNAL(statusBarMessage(const QString&)), - this, SLOT(_q_setStatusBarMessage(const QString&))); + this, SIGNAL(statusBarMessage(const QString&))); + connect(d->page, SIGNAL(linkClicked(const QUrl &)), + this, SIGNAL(linkClicked(const QUrl &))); } /*! @@ -513,7 +428,6 @@ void QGraphicsWebView::setZoomFactor(qreal factor) return; page()->mainFrame()->setZoomFactor(factor); - emit zoomFactorChanged(); } qreal QGraphicsWebView::zoomFactor() const @@ -550,21 +464,6 @@ void QGraphicsWebView::setGeometry(const QRectF& rect) } /*! - \property QGraphicsWebView::status - \brief the load status message. - - Provides the latest status message set during the load of a URL. - Commonly shown by Status Bar widgets. - - \sa statusChanged() -*/ - -QString QGraphicsWebView::status() const -{ - return d->statusBarMessage; -} - -/*! Convenience slot that stops loading the document. \sa reload(), loadFinished() @@ -611,15 +510,6 @@ void QGraphicsWebView::reload() } /*! - \property QGraphicsWebView::progress - \brief the progress of loading the current URL, from 0 to 1. -*/ -qreal QGraphicsWebView::progress() const -{ - return d->progress; -} - -/*! Loads the specified \a url and displays it. \note The view remains the same until enough data has arrived to display the new \a url. @@ -651,15 +541,14 @@ void QGraphicsWebView::load(const QNetworkRequest& request, } /*! - \property QGraphicsWebView::html - This property provides an HTML interface to the text in the webview. + Sets the content of the web view to the specified \a html. - When setting this property, external objects such as stylesheets or images - referenced in the HTML document are located relative to \a baseUrl. + External objects such as stylesheets or images referenced in the HTML + document are located relative to \a baseUrl. The \a html is loaded immediately; external objects are loaded asynchronously. - When using these methods, WebKit assumes that external resources such as + When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. Alternatively, the @@ -672,11 +561,6 @@ void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl) page()->mainFrame()->setHtml(html, baseUrl); } -QString QGraphicsWebView::toHtml() const -{ - return page()->mainFrame()->toHtml(); -} - /*! Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce @@ -706,22 +590,19 @@ QWebHistory* QGraphicsWebView::history() const } /*! - \property QGraphicsWebView::interactive - \brief controls whether the item responds to mouse and key events. -*/ + \property QGraphicsWebView::modified + \brief whether the document was modified by the user -bool QGraphicsWebView::isInteractive() const -{ - return d->interactive; -} + Parts of HTML documents can be editable for example through the + \c{contenteditable} attribute on HTML elements. -void QGraphicsWebView::setInteractive(bool allowed) + By default, this property is false. +*/ +bool QGraphicsWebView::isModified() const { - if (d->interactive == allowed) - return; - - d->interactive = allowed; - emit interactivityChanged(); + if (d->page) + return d->page->isModified(); + return false; } /*! @@ -738,11 +619,53 @@ QWebSettings* QGraphicsWebView::settings() const return page()->settings(); } +/*! + Returns a pointer to a QAction that encapsulates the specified web action \a action. +*/ +QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const +{ + return page()->action(action); +} + +/*! + Triggers the specified \a action. If it is a checkable action the specified + \a checked state is assumed. + + \sa pageAction() +*/ +void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action, bool checked) +{ + page()->triggerAction(action, checked); +} + +/*! + Finds the specified string, \a subString, in the page, using the given \a options. + + If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences + that exist in the page. All subsequent calls will extend the highlight, rather than + replace it, with occurrences of the new string. + + If the HighlightAllOccurrences flag is not passed, the function will select an occurrence + and all subsequent calls will replace the current occurrence with the next one. + + To clear the selection, just pass an empty string. + + Returns true if \a subString was found; otherwise returns false. + + \sa selectedText(), selectionChanged() +*/ +bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags options) +{ + if (d->page) + return d->page->findText(subString, options); + return false; +} + /*! \reimp */ void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); QMouseEvent me = QMouseEvent(QEvent::MouseMove, ev->pos().toPoint(), Qt::NoButton, @@ -766,7 +689,7 @@ void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) */ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -780,7 +703,7 @@ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -794,7 +717,7 @@ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -808,7 +731,7 @@ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -822,7 +745,7 @@ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -833,7 +756,7 @@ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) */ void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -889,7 +812,7 @@ void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -907,7 +830,7 @@ void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -925,7 +848,7 @@ void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -956,7 +879,7 @@ void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) */ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -971,11 +894,20 @@ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) */ void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) QGraphicsItem::inputMethodEvent(ev); } +/*! + \fn void QGraphicsWebView::linkClicked(const QUrl &url) + + This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy + property is set to delegate the link handling for the specified \a url. + + \sa QWebPage::linkDelegationPolicy() +*/ + #include "moc_qgraphicswebview.cpp" diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h index 43cf59a..f3afb4c 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h @@ -21,6 +21,7 @@ #define QGraphicsWebView_h #include "qwebkitglobal.h" +#include "qwebpage.h" #include #include #include @@ -39,17 +40,14 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget { Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) - Q_PROPERTY(QString status READ status NOTIFY statusChanged) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) - Q_PROPERTY(QString html READ toHtml WRITE setHtml) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged) + Q_PROPERTY(bool modified READ isModified) public: - QGraphicsWebView(QGraphicsItem* parent = 0); + explicit QGraphicsWebView(QGraphicsItem* parent = 0); ~QGraphicsWebView(); QWebPage* page() const; @@ -64,15 +62,11 @@ public: qreal zoomFactor() const; void setZoomFactor(qreal); - bool isInteractive() const; - void setInteractive(bool); - - qreal progress() const; + bool isModified() const; void load(const QUrl &url); void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); - QString toHtml() const; void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); // FIXME: Consider rename to setHtml? void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); @@ -80,7 +74,10 @@ public: QWebHistory* history() const; QWebSettings* settings() const; - QString status() const; + QAction* pageAction(QWebPage::WebAction action) const; + void triggerPageAction(QWebPage::WebAction action, bool checked = false); + + bool findText(const QString& subString, QWebPage::FindFlags options = 0); virtual void setGeometry(const QRectF& rect); virtual void updateGeometry(); @@ -88,6 +85,10 @@ public: virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); virtual bool event(QEvent*); + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const; + + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + public Q_SLOTS: void stop(); void back(); @@ -98,13 +99,12 @@ Q_SIGNALS: void loadStarted(); void loadFinished(bool); - void progressChanged(qreal); - void interactivityChanged(); + void loadProgress(int progress); void urlChanged(const QUrl&); void titleChanged(const QString&); void iconChanged(); - void statusChanged(); - void zoomFactorChanged(); + void statusBarMessage(const QString& message); + void linkClicked(const QUrl&); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent*); @@ -133,9 +133,7 @@ protected: virtual bool sceneEvent(QEvent*); private: - Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress)) Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) - Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message)) QGraphicsWebViewPrivate* const d; friend class QGraphicsWebViewPrivate; diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h index a18d262..9cb1ea1 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h @@ -177,6 +177,7 @@ public: int count() const; QWebElement at(int i) const; + inline QWebElement operator[](int i) const { return at(i); } inline QWebElement first() const { return at(0); } inline QWebElement last() const { return at(count() - 1); } @@ -185,39 +186,69 @@ public: class const_iterator { public: - int i; - const QWebElementCollection *s; - - inline const_iterator(const QWebElementCollection *collection, int index) : i(index), s(collection) {} - inline const_iterator(const const_iterator &o) : i(o.i), s(o.s) {} + inline const_iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline const_iterator(const const_iterator& o) : i(o.i), collection(o.collection) {} - inline const QWebElement operator*() const { return s->at(i); } + inline const QWebElement operator*() const { return collection->at(i); } - inline bool operator==(const const_iterator& o) const { return i == o.i && s == o.s; } - inline bool operator!=(const const_iterator& o) const { return i != o.i || s != o.s; } + inline bool operator==(const const_iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const const_iterator& o) const { return i != o.i || collection != o.collection; } inline bool operator<(const const_iterator& o) const { return i < o.i; } inline bool operator<=(const const_iterator& o) const { return i <= o.i; } inline bool operator>(const const_iterator& o) const { return i > o.i; } inline bool operator>=(const const_iterator& o) const { return i >= o.i; } - inline const_iterator &operator++() { ++i; return *this; } - inline const_iterator operator++(int) { const_iterator n(s, i); ++i; return n; } - inline const_iterator &operator--() { i--; return *this; } - inline const_iterator operator--(int) { const_iterator n(s, i); i--; return n; } - inline const_iterator &operator+=(int j) { i += j; return *this; } - inline const_iterator &operator-=(int j) { i -= j; return *this; } - inline const_iterator operator+(int j) const { return const_iterator(s, i + j); } - inline const_iterator operator-(int j) const { return const_iterator(s, i - j); } + inline const_iterator& operator++() { ++i; return *this; } + inline const_iterator operator++(int) { const_iterator n(collection, i); ++i; return n; } + inline const_iterator& operator--() { i--; return *this; } + inline const_iterator operator--(int) { const_iterator n(collection, i); i--; return n; } + inline const_iterator& operator+=(int j) { i += j; return *this; } + inline const_iterator& operator-=(int j) { i -= j; return *this; } + inline const_iterator operator+(int j) const { return const_iterator(collection, i + j); } + inline const_iterator operator-(int j) const { return const_iterator(collection, i - j); } inline int operator-(const_iterator j) const { return i - j.i; } private: - inline const_iterator() : i(0), s(0) {} + int i; + const QWebElementCollection* const collection; }; friend class const_iterator; - inline const_iterator begin() const { return const_iterator(this, 0); } - inline const_iterator end() const { return const_iterator(this, count()); } - inline QWebElement operator[](int i) const { return at(i); } + inline const_iterator begin() const { return constBegin(); } + inline const_iterator end() const { return constEnd(); } + inline const_iterator constBegin() const { return const_iterator(this, 0); } + inline const_iterator constEnd() const { return const_iterator(this, count()); }; + + class iterator { + public: + inline iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline iterator(const iterator& o) : i(o.i), collection(o.collection) {} + + inline QWebElement operator*() const { return collection->at(i); } + + inline bool operator==(const iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const iterator& o) const { return i != o.i || collection != o.collection; } + inline bool operator<(const iterator& o) const { return i < o.i; } + inline bool operator<=(const iterator& o) const { return i <= o.i; } + inline bool operator>(const iterator& o) const { return i > o.i; } + inline bool operator>=(const iterator& o) const { return i >= o.i; } + + inline iterator& operator++() { ++i; return *this; } + inline iterator operator++(int) { iterator n(collection, i); ++i; return n; } + inline iterator& operator--() { i--; return *this; } + inline iterator operator--(int) { iterator n(collection, i); i--; return n; } + inline iterator& operator+=(int j) { i += j; return *this; } + inline iterator& operator-=(int j) { i -= j; return *this; } + inline iterator operator+(int j) const { return iterator(collection, i + j); } + inline iterator operator-(int j) const { return iterator(collection, i - j); } + inline int operator-(iterator j) const { return i - j.i; } + private: + int i; + const QWebElementCollection* const collection; + }; + friend class iterator; + inline iterator begin() { return iterator(this, 0); } + inline iterator end() { return iterator(this, count()); } private: QExplicitlySharedDataPointer d; }; diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp index 409e1a0..f43cbbf 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp @@ -50,6 +50,7 @@ \section1 Resources + This class acts mostly as a container and a controller for the inspector. Most of the resources needed by the inspector are owned by the associated QWebPage and are allocated the first time that: \list @@ -57,11 +58,6 @@ \o the QWebInspector is shown. \endlist - This class acts mostly as a container and a controller for the inspector. - You can defer the creation and association of the QWebInspector until - the first emission of QWebPage::webInspectorTriggered() to save additional - resources. - \section1 Inspector configuration persistence The inspector allows the user to configure some options through its diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index a1e131a..8499e10 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1471,8 +1471,6 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector() if (!inspector) { QWebInspector* insp = new QWebInspector; insp->setPage(q); - insp->connect(q, SIGNAL(webInspectorTriggered(const QWebElement&)), SLOT(show())); - insp->show(); // The inspector is expected to be shown on inspection inspectorIsInternalOnly = true; Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q) @@ -2018,11 +2016,9 @@ void QWebPage::triggerAction(WebAction action, bool) editor->setBaseWritingDirection(RightToLeftWritingDirection); break; case InspectElement: { - QWebElement inspectedElement(QWebElement::enclosingElement(d->hitTestResult.d->innerNonSharedNode.get())); - emit webInspectorTriggered(inspectedElement); - if (!d->hitTestResult.isNull()) { d->getOrCreateInspector(); // Make sure the inspector is created + d->inspector->show(); // The inspector is expected to be shown on inspection d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); } break; @@ -2763,17 +2759,6 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. - \omitvalue ErrorPageExtension (introduced in Qt 4.6) -*/ - -/*! - \enum QWebPage::ErrorDomain - \since 4.6 - \internal - - \value QtNetwork - \value Http - \value WebKit */ /*! @@ -2824,12 +2809,6 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) */ /*! - \fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn() - - Constructs a new error page object. -*/ - -/*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 \brief The ChooseMultipleFilesExtensionOption class describes the option @@ -3440,24 +3419,6 @@ quint64 QWebPage::bytesReceived() const */ /*! - \fn void QWebPage::webInspectorTriggered(const QWebElement& inspectedElement); - \since 4.6 - - This signal is emitted when the user triggered an inspection through the - context menu. If a QWebInspector is associated to this page, it should be - visible to the user after this signal has been emitted. - - If still no QWebInspector is associated to this QWebPage after the emission - of this signal, a privately owned inspector will be shown to the user. - - \note \a inspectedElement contains the QWebElement under the context menu. - It is not garanteed to be the same as the focused element in the web - inspector. - - \sa QWebInspector -*/ - -/*! \fn void QWebPage::toolBarVisibilityChangeRequested(bool visible) This signal is emitted whenever the visibility of the toolbar in a web browser diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h index f39209c..8c455b1 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h @@ -329,7 +329,6 @@ Q_SIGNALS: void windowCloseRequested(); void printRequested(QWebFrame *frame); void linkClicked(const QUrl &url); - void webInspectorTriggered(const QWebElement& inspectedElement); void toolBarVisibilityChangeRequested(bool visible); void statusBarVisibilityChangeRequested(bool visible); diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index 3052056..ff86e1f 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -206,10 +206,6 @@ void QWebSettingsPrivate::apply() value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls, global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls)); settings->setAllowUniversalAccessFromFileURLs(value); - - value = attributes.value(QWebSettings::SessionStorageEnabled, - global->attributes.value(QWebSettings::SessionStorageEnabled)); - settings->setSessionStorageEnabled(value); } else { QList settings = *::allSettings(); for (int i = 0; i < settings.count(); ++i) @@ -351,8 +347,6 @@ QWebSettings* QWebSettings::globalSettings() \value LocalStorageEnabled Specifies whether support for the HTML 5 local storage feature is enabled or not. Disabled by default. \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls. - \value SessionStorageEnabled Specifies whether support for the HTML 5 - session storage feature is enabled or not. Enabled by default. */ /*! @@ -383,7 +377,6 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false); d->attributes.insert(QWebSettings::LocalStorageEnabled, false); d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false); - d->attributes.insert(QWebSettings::SessionStorageEnabled, true); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); d->printingMinimumShrinkFactor = 0.0f; diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h index c958ae7..3b6d1a7 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h @@ -67,7 +67,6 @@ public: LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, - SessionStorageEnabled, DnsPrefetchEnabled }; enum WebGraphic { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp index 55ce1f7..12b20ab 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp @@ -70,7 +70,7 @@ void QWebViewPrivate::_q_pageDestroyed() It can be used in various applications to display web content live from the Internet. - The image below shows QWebView previewed in \QD with a Nokia website. + The image below shows QWebView previewed in \QD with the Trolltech website. \image qwebview-url.png @@ -974,7 +974,7 @@ void QWebView::changeEvent(QEvent *e) /*! \fn void QWebView::statusBarMessage(const QString& text) - This signal is emitted when the status bar \a text is changed by the page. + This signal is emitted when the statusbar \a text is changed by the page. */ /*! diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 84c5d43..296e06c 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,255 @@ +2009-11-09 Benjamin Poulain + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=30772 + Add a non-const iterator to QWebElementCollection. + Move the two attributes of the iterator to private. + + * Api/qwebelement.h: + (const_iterator::begin): + (const_iterator::end): + (const_iterator::constBegin): + (const_iterator::constEnd): + (const_iterator::iterator::iterator): + (const_iterator::iterator::operator*): + (const_iterator::iterator::operator==): + (const_iterator::iterator::operator!=): + (const_iterator::iterator::operator<): + (const_iterator::iterator::operator<=): + (const_iterator::iterator::operator>): + (const_iterator::iterator::operator>=): + (const_iterator::iterator::operator++): + (const_iterator::iterator::operator--): + (const_iterator::iterator::operator+=): + (const_iterator::iterator::operator-=): + (const_iterator::iterator::operator+): + (const_iterator::iterator::operator-): + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::nonConstIterator): + (tst_QWebElement::constIterator): + +2009-11-09 Laszlo Gombos + + Reviewed by Kenneth Christiansen. + + [Qt] Remove the sessionStorage setting (per Page) + https://bugs.webkit.org/show_bug.cgi?id=31249 + + This setting allows to run sessionStorage on/off on a per page + basis. Remove this prematurely exposed API. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::QWebSettings): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::database): + (tst_QWebPage::testOptionalJSObjects): + +2009-11-09 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Remove the QWebPage:webInspectorTriggered signal. + User customization of the communication between QWebPage + and QWebInspector will be properly designed in the next version. + https://bugs.webkit.org/show_bug.cgi?id=30773 + + * Api/qwebinspector.cpp: + * Api/qwebpage.cpp: + (QWebPagePrivate::getOrCreateInspector): + (QWebPage::triggerAction): + * Api/qwebpage.h: + * QtLauncher/main.cpp: + (MainWindow::MainWindow): + +2009-11-05 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Added a missing re-implementation of QGraphicsItem::inputMethodQuery(). + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::inputMethodQuery): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Provide a dummy re-implementation of QGraphicsLayoutItem::sizeHint(), + similar to QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::sizeHint): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Removed zoomFactoryChanged() signal and added + linkClicked() to QGraphicsWebView, for consistency with + QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::setPage): + (QGraphicsWebView::setZoomFactor): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::findText() for convenience and consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::findText): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::pageAction() and triggerPageAction(), for + consistency with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::pageAction): + (QGraphicsWebView::triggerPageAction): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Removed QGraphicsWebView::toHtml() after API review. + + That's consistent with QWebView and also based on the assumption that + toHtml() is called less frequently than setHtml(). + + * Api/qgraphicswebview.cpp: + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Removed the interactive property of QGraphicsWebView. + + There are clearly use-cases for this feature, but it will require + more work to make this fully work with an enum to have fine-grained + control over the interactivity levels. For now it is easy to achieve + in user-code what the boolean property did. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::hoverMoveEvent): + (QGraphicsWebView::mouseMoveEvent): + (QGraphicsWebView::mousePressEvent): + (QGraphicsWebView::mouseReleaseEvent): + (QGraphicsWebView::mouseDoubleClickEvent): + (QGraphicsWebView::keyPressEvent): + (QGraphicsWebView::keyReleaseEvent): + (QGraphicsWebView::dragLeaveEvent): + (QGraphicsWebView::dragMoveEvent): + (QGraphicsWebView::dropEvent): + (QGraphicsWebView::wheelEvent): + (QGraphicsWebView::inputMethodEvent): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + Make the QGraphicsWebView constructor explicit. + + * Api/qgraphicswebview.h: + +2009-11-05 Simon Hausmann + + Last Qt 4.5 build fix (*sigh*) + + * tests/qwebpage/tst_qwebpage.cpp: + (inputMethodHints): inputMethodHints() is only used for + Qt 4.6, so guard the whole function. + +2009-11-05 Simon Hausmann + + Another prospective build fix against Qt 4.5 (build bot) + + Don't compile & run the QGraphicsWebView portion of the + input methods auto test with Qt 4.5. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-05 Simon Hausmann + + Prospective build fix against Qt 4.5 (build bot) + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): Guard the + use of Qt 4.6 specific API with #ifdefs. + +2009-11-01 Simon Hausmann + + Reviewed by Kenneth Christiansen. + + [Qt] Fix enabling of input method support on QGraphicsWebView. + https://bugs.webkit.org/show_bug.cgi?id=30605 + + Instead of setting the unsupported widget attribute on the + QGraphicsWidget in setInputMethodEnabled() set the + ItemAcceptsInputMethod GraphicsItem flag directly. + + Changed the existing input method auto test to run once + on a QWebView and once on a QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-04 Simon Hausmann + + Reviewed by Kenneth Christiansen. + + Added QGraphicsWebView::modified property, for consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::isModified): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann + + Reviewed by Kenneth Christiansen. + + Removed status and progress properties of QGraphicsWebView. + Added loadProgress and statusBarMessage signals instead, + after API review. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::setPage): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + 2009-11-04 Yael Aharon Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 4bdb7f5..a52e167 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -63,21 +63,17 @@ void tst_QGraphicsWebView::qgraphicswebview() item.title(); item.icon(); item.zoomFactor(); - item.isInteractive(); - item.progress(); - item.toHtml(); item.history(); item.settings(); - item.status(); item.page(); item.setPage(0); item.page(); item.setUrl(QUrl()); item.setZoomFactor(0); - item.setInteractive(true); item.load(QUrl()); item.setHtml(QString()); item.setContent(QByteArray()); + item.isModified(); } class WebPage : public QWebPage diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp index cf83fe8..117393a 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp @@ -71,6 +71,8 @@ private slots: void classes(); void namespaceURI(); void iteration(); + void nonConstIterator(); + void constIterator(); void foreachManipulation(); void emptyCollection(); void appendCollection(); @@ -305,6 +307,37 @@ void tst_QWebElement::iteration() QCOMPARE(paras.at(1), paras.last()); } +void tst_QWebElement::nonConstIterator() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + (*it).encloseWith("
"); + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + +void tst_QWebElement::constIterator() +{ + QString html = "

first para

second para

"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + const QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::const_iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + void tst_QWebElement::foreachManipulation() { QString html = "

first para

second para

"; diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro index b8734cd..0e540e5 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebframe.cpp RESOURCES += qwebframe.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\" +DEFINES += SRCDIR=\\\"$$PWD/resources\\\" symbian { TARGET.UID3 = 0xA000E53D diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 6f07e90..7cc62b0 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -38,10 +38,6 @@ #endif #include "../util.h" -#if defined(Q_OS_SYMBIAN) -# define SRCDIR "" -#endif - //TESTED_CLASS= //TESTED_FILES= diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro index 7853b28..6b28efd 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebpage.cpp RESOURCES += tst_qwebpage.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" +DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { TARGET.UID3 = 0xA000E53E diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 3eead92..87077e0 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -21,6 +21,9 @@ #include +#include +#include +#include #include #include #include @@ -37,10 +40,6 @@ #include #include -#if defined(Q_OS_SYMBIAN) -# define SRCDIR "" -#endif - // Will try to wait for the condition while allowing event processing #define QTRY_COMPARE(__expr, __expected) \ do { \ @@ -124,6 +123,7 @@ private slots: void testOptionalJSObjects(); void testEnablePersistentStorage(); void consoleOutput(); + void inputMethods_data(); void inputMethods(); void defaultTextEncoding(); void errorPageExtension(); @@ -456,7 +456,6 @@ void tst_QWebPage::database() QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024); m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - m_page->settings()->setAttribute(QWebSettings::SessionStorageEnabled, true); m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); QString dbFileName = path + "Databases.db"; @@ -1268,28 +1267,87 @@ void tst_QWebPage::frameAt() frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); } +void tst_QWebPage::inputMethods_data() +{ + QTest::addColumn("viewType"); + QTest::newRow("QWebView") << "QWebView"; +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QTest::newRow("QGraphicsWebView") << "QGraphicsWebView"; +#endif +} + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) +static Qt::InputMethodHints inputMethodHints(QObject* object) +{ + if (QGraphicsObject* o = qobject_cast(object)) + return o->inputMethodHints(); + if (QWidget* w = qobject_cast(object)) + return w->inputMethodHints(); + return Qt::InputMethodHints(); +} +#endif + +static bool inputMethodEnabled(QObject* object) +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + if (QGraphicsObject* o = qobject_cast(object)) + return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; +#endif + if (QWidget* w = qobject_cast(object)) + return w->testAttribute(Qt::WA_InputMethodEnabled); + return false; +} + void tst_QWebPage::inputMethods() { - m_view->page()->mainFrame()->setHtml("" \ + QFETCH(QString, viewType); + QWebPage* page = new QWebPage; + QObject* view = 0; + QObject* container = 0; + if (viewType == "QWebView") { + QWebView* wv = new QWebView; + wv->setPage(page); + view = wv; + container = view; + } +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + else if (viewType == "QGraphicsWebView") { + QGraphicsWebView* wv = new QGraphicsWebView; + wv->setPage(page); + view = wv; + + QGraphicsView* gv = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(gv); + gv->setScene(scene); + scene->addItem(wv); + wv->setGeometry(QRect(0, 0, 500, 500)); + + container = gv; + } +#endif + else + QVERIFY2(false, "Unknown view type"); + + page->mainFrame()->setHtml("" \ "
" \ "" \ ""); - m_view->page()->mainFrame()->setFocus(); + page->mainFrame()->setFocus(); - QWebElementCollection inputs = m_view->page()->mainFrame()->documentElement().findAll("input"); + QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input"); QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpres); + page->event(&evpres); QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrel); + page->event(&evrel); //ImMicroFocus - QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus); + QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); QRect focusRect = variant.toRect(); QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); //ImFont - variant = m_view->page()->inputMethodQuery(Qt::ImFont); + variant = page->inputMethodQuery(Qt::ImFont); QFont font = variant.value(); QCOMPARE(QString("-webkit-serif"), font.family()); @@ -1298,45 +1356,45 @@ void tst_QWebPage::inputMethods() //Insert text. { QInputMethodEvent eventText("QtWebKit", inputAttributes); - QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged())); - m_view->page()->event(&eventText); + QSignalSpy signalSpy(page, SIGNAL(microFocusChanged())); + page->event(&eventText); QCOMPARE(signalSpy.count(), 0); } { QInputMethodEvent eventText("", inputAttributes); eventText.setCommitString(QString("QtWebKit"), 0, 0); - m_view->page()->event(&eventText); + page->event(&eventText); } #if QT_VERSION >= 0x040600 //ImMaximumTextLength - variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength); + variant = page->inputMethodQuery(Qt::ImMaximumTextLength); QCOMPARE(20, variant.toInt()); //Set selection inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant()); QInputMethodEvent eventSelection("",inputAttributes); - m_view->page()->event(&eventSelection); + page->event(&eventSelection); //ImAnchorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition); + variant = page->inputMethodQuery(Qt::ImAnchorPosition); int anchorPosition = variant.toInt(); QCOMPARE(anchorPosition, 3); //ImCursorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition); + variant = page->inputMethodQuery(Qt::ImCursorPosition); int cursorPosition = variant.toInt(); QCOMPARE(cursorPosition, 5); //ImCurrentSelection - variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection); + variant = page->inputMethodQuery(Qt::ImCurrentSelection); QString selectionValue = variant.value(); QCOMPARE(selectionValue, QString("eb")); #endif //ImSurroundingText - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); QString value = variant.value(); QCOMPARE(value, QString("QtWebKit")); @@ -1347,29 +1405,31 @@ void tst_QWebPage::inputMethods() QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); attributes.append(newSelection); QInputMethodEvent event("composition", attributes); - m_view->page()->event(&event); + page->event(&event); } // A ongoing composition should not change the surrounding text before it is committed. - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); value = variant.value(); QCOMPARE(value, QString("QtWebKit")); #endif //ImhHiddenText QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpresPassword); + page->event(&evpresPassword); QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrelPassword); + page->event(&evrelPassword); - QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(inputMethodEnabled(view)); #if QT_VERSION >= 0x040600 - QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText); + QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); - m_view->page()->event(&evpres); - m_view->page()->event(&evrel); - QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText)); + page->event(&evpres); + page->event(&evrel); + QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); #endif + + delete container; } // import a little DRT helper function to trigger the garbage collector @@ -1444,11 +1504,6 @@ void tst_QWebPage::testOptionalJSObjects() QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true), true); QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false); QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true); - - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", true), true); - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", false), true); } void tst_QWebPage::testEnablePersistentStorage() -- cgit v0.12 From 5786450e3078c6b24f92859349fcd4231426e62d Mon Sep 17 00:00:00 2001 From: Liang QI Date: Tue, 3 Nov 2009 12:05:50 +0100 Subject: Re-apply change 29afcb69d6023aba012051bd2a026b57b3689732 by Liang QI Re-apply change 1db4a133a9d35e00bad50541fb8d64079a7debea by Liang QI Fix tst_qwebpage and tst_qwebframe compilation on Symbian. RevBy: TrustMe --- src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro | 2 +- src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 4 ++++ src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro | 2 +- src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro index 0e540e5..b8734cd 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebframe.cpp RESOURCES += qwebframe.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/resources\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\" symbian { TARGET.UID3 = 0xA000E53D diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 7cc62b0..6f07e90 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -38,6 +38,10 @@ #endif #include "../util.h" +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro index 6b28efd..7853b28 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebpage.cpp RESOURCES += tst_qwebpage.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { TARGET.UID3 = 0xA000E53E diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 87077e0..93a1784 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -40,6 +40,10 @@ #include #include +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + // Will try to wait for the condition while allowing event processing #define QTRY_COMPARE(__expr, __expected) \ do { \ -- cgit v0.12 From 4261c163c17cd47a84f4d27bc82a6971c277d478 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 13 Oct 2009 11:34:27 +0200 Subject: Re-apply change fdb9419f23d1cd2a9ddfc1f7e2fb58f6e845483b by Jocelyn Turcotte Re-apply change 2fbc823bb66db6ef6f6acc74d2baa96ebe1dec81 by Jocelyn Turcotte Re-apply change 6125aabeccb01a07c706fe4227279eb827e8e890 by Jocelyn Turcotte Re-apply change 6b8ac349b9a477863a8c8388dcc0658f3284bc54 by Jocelyn Turcotte Re-applying commit ee0a43fee20cc398b505eb65218ebed56dfc8f39 by Simon Hausmann Fix crash of QtScript on Mac OS X When compiling on 10.4 but running on 10.5 the flags passed to vm_map cause it to crash. For now fall back to the use of mmap() as allocator instead. Reviewed-by: Kent Hansen --- src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp index b885049..8b647a0 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp @@ -240,7 +240,9 @@ void Heap::destroy() template NEVER_INLINE CollectorBlock* Heap::allocateBlock() { -#if PLATFORM(DARWIN) + // Disable the use of vm_map for the Qt build on Darwin, because when compiled on 10.4 + // it crashes on 10.5 +#if PLATFORM(DARWIN) && !PLATFORM(QT) vm_address_t address = 0; // FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: . vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); @@ -332,7 +334,9 @@ NEVER_INLINE void Heap::freeBlock(size_t block) NEVER_INLINE void Heap::freeBlock(CollectorBlock* block) { -#if PLATFORM(DARWIN) + // Disable the use of vm_deallocate for the Qt build on Darwin, because when compiled on 10.4 + // it crashes on 10.5 +#if PLATFORM(DARWIN) && !PLATFORM(QT) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif PLATFORM(SYMBIAN) userChunk->Free(reinterpret_cast(block)); -- cgit v0.12 From 85a4a5bdbebee299482c525750aa179c2cff6ef2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 16 Oct 2009 14:30:39 +0200 Subject: Re-apply change b065fda13c29110fc81f77c9bbf1069d562b4d67 by Martin Smith Re-apply change 422c747c5108f9f0c544b5dd0789df32aa498fb7 by Martin Smith Re-apply change cef1901dbd96be81fc4139b50b094dfae5223e6f by Martin Smith Re-apply change 0f8bff1970d4b0f10e98ce7d6ab341620f4ce76b by Martin Smith doc: Changed Trolltech to Nokia --- src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp index 12b20ab..6623f24 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp @@ -70,7 +70,7 @@ void QWebViewPrivate::_q_pageDestroyed() It can be used in various applications to display web content live from the Internet. - The image below shows QWebView previewed in \QD with the Trolltech website. + The image below shows QWebView previewed in \QD with a Nokia website. \image qwebview-url.png -- cgit v0.12 From d0c5bcf3b5793e73a059dea083b0f9ea0b16bfb3 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 23 Oct 2009 14:51:48 +0200 Subject: Re-apply change 62ed4c43c8c2fe3457de6d7570c2ae4a09a5ecf0 by David Boddie Re-apply change 914de965a8380e7620209c7b26e984ed9fbccc57 by David Boddie Re-apply change 37dc859e7e2e0f135e4c40bc7f6f824fcdb21e86 by David Boddie Doc: Fixed and synchronized QWebView related documentation. Reviewed-by: Trust Me --- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 96 ++++++++++++++++++++-- src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 2 +- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp index 0365181..38d8c47 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -143,17 +143,101 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const /*! \class QGraphicsWebView - \brief The QGraphicsWebView class allows web content to be added to a GraphicsView. + \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. \since 4.6 - A WebGraphicsItem renders web content based on a URL or set data. + An instance of this class renders Web content from a URL or supplied as data, using + features of the QtWebKit module. - If the width and height of the item is not set, they will - dynamically adjust to a size appropriate for the content. - This width may be large (eg. 980) for typical online web pages. + If the width and height of the item is not set, they will dynamically adjust to + a size appropriate for the content. This width may be large (e.g., 980 pixels or + more) for typical online Web pages. + + \section1 Browser Features + + Many of the functions, signals and properties provided by QWebView are also available + for this item, making it simple to adapt existing code to use QGraphicsWebView instead + of QWebView. + + The item uses a QWebPage object to perform the rendering of Web content, and this can + be obtained with the page() function, enabling the document itself to be accessed and + modified. + + As with QWebView, the item records the browsing history using a QWebHistory object, + accessible using the history() function. The QWebSettings object that defines the + configuration of the browser can be obtained with the settings() function, enabling + features like plugin support to be customized for each item. + + \sa QWebView, QGraphicsTextItem +*/ + +/*! + \fn void QGraphicsWebView::titleChanged(const QString &title) + + This signal is emitted whenever the \a title of the main frame changes. + + \sa title() +*/ + +/*! + \fn void QGraphicsWebView::urlChanged(const QUrl &url) + + This signal is emitted when the \a url of the view changes. + + \sa url(), load() +*/ + +/*! + \fn void QGraphicsWebView::statusChanged() + + This signal is emitted when the status bar text is changed by the page. +*/ + +/*! + \fn void QGraphicsWebView::iconChanged() + + This signal is emitted whenever the icon of the page is loaded or changes. + + In order for icons to be loaded, you will need to set an icon database path + using QWebSettings::setIconDatabasePath(). + + \sa icon(), QWebSettings::setIconDatabasePath() +*/ + +/*! + \fn void QGraphicsWebView::loadStarted() + + This signal is emitted when a new load of the page is started. + + \sa progressChanged(), loadFinished() +*/ + +/*! + \fn void QGraphicsWebView::loadFinished(bool ok) + + This signal is emitted when a load of the page is finished. + \a ok will indicate whether the load was successful or any error occurred. + + \sa loadStarted() */ /*! + \fn void QGraphicsWebView::progressChanged(qreal progress) + + This signal is emitted every time an element in the web page + completes loading and the overall loading progress advances. + + This signal tracks the progress of all child frames. + + The current value is provided by \a progress and scales from 0.0 to 1.0, + which is the default range of QProgressBar. + + \sa loadStarted(), loadFinished() +*/ + + + +/*! Constructs an empty QGraphicsWebView with parent \a parent. \sa load() @@ -170,7 +254,7 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) } /*! - Destroys the web graphicsitem. + Destroys the item. */ QGraphicsWebView::~QGraphicsWebView() { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp index 6623f24..55ce1f7 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp @@ -974,7 +974,7 @@ void QWebView::changeEvent(QEvent *e) /*! \fn void QWebView::statusBarMessage(const QString& text) - This signal is emitted when the statusbar \a text is changed by the page. + This signal is emitted when the status bar \a text is changed by the page. */ /*! -- cgit v0.12 From d09f0e3949d4e705ef60516a9ccfacad736dff43 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 10:56:57 +0100 Subject: Re-apply change 16d98a3fa8e5cf5f41e35e257b8791ce030a4ce1 by Thiago Macieira Re-apply change cbb2efb13cdf05aabc245e2b0157883146cf069d by Thiago Macieira Re-apply change 3f7a99565de7ed17d7ac4c0a25b02997b094b1a9 by Thiago Macieira Fix linking of WebKit on Linux 32-bit. It was missing the ".text" directive at the top of the file, indicating that code would follow. Without it, the assembler created "NOTYPE" symbols, which would result in linker errors. --- src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index c999618..9fa898a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -75,7 +75,7 @@ namespace JSC { #define THUMB_FUNC_PARAM(name) #endif -#if PLATFORM(LINUX) && PLATFORM(X86_64) +#if PLATFORM(LINUX) && (PLATFORM(X86_64) || PLATFORM(X86)) #define SYMBOL_STRING_RELOCATION(name) #name "@plt" #else #define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name) @@ -93,6 +93,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline); asm volatile ( +".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" -- cgit v0.12 From a6123418522a3865d462cb64022f567462603af1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2009 11:04:21 +0100 Subject: Re-apply change 0951f86be22633e1ff763de935f9c35a20f8a575 by Thiago Macieira Re-apply change 7293097060383bcb75ee9f3e6a270de3b5bee2dc by Thiago Macieira Re-apply change e2ef97128c006ac2a5c99c67bb54eebaa3b45720 by Thiago Macieira Implement symbol hiding for JSC's JIT functions. These functions are implemented directly in assembly, so they need the proper directives to enable/disable visibility. On ELF systems, it's .hidden, whereas on Mach-O systems (Mac) it's .private_extern. On Windows, it's not necessary since you have to explicitly export. I also implemented the AIX idiom, though it's unlikely anyone will implement AIX/POWER JIT. That leaves only HP-UX on PA-RISC unimplemented, from the platforms that Qt supports. It's also unlikely that we'll imlpement JIT for it. Reviewed-by: Kent Hansen (this commit was 26d0990c66068bfc92a2ec77512b26d4a0c11b02, but was lost during a WebKit update) --- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 9fa898a..470ed0b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -81,6 +81,19 @@ namespace JSC { #define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name) #endif +#if PLATFORM(DARWIN) + // Mach-O platform +#define HIDE_SYMBOL(name) ".private_extern _" #name +#elif PLATFORM(AIX) + // IBM's own file format +#define HIDE_SYMBOL(name) ".lglobl " #name +#elif PLATFORM(LINUX) || PLATFORM(FREEBSD) || PLATFORM(OPENBSD) || PLATFORM(SOLARIS) || (PLATFORM(HPUX) && PLATFORM(IA64)) || PLATFORM(SYMBIAN) || PLATFORM(NETBSD) + // ELF platform +#define HIDE_SYMBOL(name) ".hidden " #name +#else +#define HIDE_SYMBOL(name) +#endif + #if USE(JSVALUE32_64) #if COMPILER(GCC) && PLATFORM(X86) @@ -95,6 +108,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_ asm volatile ( ".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -115,6 +129,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -130,6 +145,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x3c, %esp" "\n" "popl %ebx" "\n" @@ -154,6 +170,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_ asm volatile ( ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -180,6 +197,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -195,6 +213,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x48, %rsp" "\n" "popq %rbx" "\n" @@ -216,6 +235,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -242,6 +262,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -347,7 +368,9 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( +".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -368,6 +391,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -383,6 +407,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x1c, %esp" "\n" "popl %ebx" "\n" @@ -405,7 +430,9 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline); asm volatile ( +".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -439,6 +466,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" @@ -454,6 +482,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x78, %rsp" "\n" "popq %rbx" "\n" @@ -475,6 +504,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -501,6 +531,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -518,6 +549,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" ".thumb" "\n" ".thumb_func " THUMB_FUNC_PARAM(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" @@ -532,7 +564,9 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #elif COMPILER(GCC) && PLATFORM(ARM_TRADITIONAL) asm volatile ( +".text\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "stmdb sp!, {r1-r3}" "\n" "stmdb sp!, {r4-r8, lr}" "\n" @@ -549,12 +583,14 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "mov r0, sp" "\n" "bl " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" // Both has the same return sequence ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "add sp, sp, #36" "\n" "ldmia sp!, {r4-r8, lr}" "\n" @@ -889,6 +925,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD ".text" "\n" \ ".align 2" "\n" \ ".globl " SYMBOL_STRING(cti_##op) "\n" \ + HIDE_SYMBOL(cti_##op) "\n" \ ".thumb" "\n" \ ".thumb_func " THUMB_FUNC_PARAM(cti_##op) "\n" \ SYMBOL_STRING(cti_##op) ":" "\n" \ -- cgit v0.12 From 8474d7e594f5b70ca88ef0188969298ed771e875 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 26 Oct 2009 17:35:17 +0100 Subject: Re-apply change 4f62d29e8ae464c223af5bc08ae219d9b198da63 by David Boddie Re-apply change b4be512bffba65bf4577a2b8275d7c38ce5501a1 by David Boddie Re-apply change 6f36d0aafaccbb9affe8ac1b82c225d985aa7491 by David Boddie Doc: Added internal or hidden placeholder documentation. Reviewed-by: Trust Me To-be-completed-by: QtWebKit developers --- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 8499e10..d4a491b 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -2759,6 +2759,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. + \omitvalue ErrorPageExtension (introduced in Qt 4.6) +*/ + +/*! + \enum QWebPage::ErrorDomain + \since 4.6 + \internal + + \value QtNetwork + \value Http + \value WebKit */ /*! @@ -2809,6 +2820,12 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) */ /*! + \fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn() + + Constructs a new error page object. +*/ + +/*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 \brief The ChooseMultipleFilesExtensionOption class describes the option -- cgit v0.12 From ad79d84b8da174ecdd5d0b617504481add81430f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 28 Oct 2009 08:52:30 +0100 Subject: Re-apply change 914d5847532a85a564a5df4a2bc8bdccb0f91abb by Shane Kearns Re-apply change cadd19cd98b9a6ff7ff8755f7774027400aadb0f by Shane Kearns Re-apply change 6bc9ef388590b4bfb281d2e1510dc7c3d1837349 by Shane Kearns Fix to 8e0fbc2caa3edefb78d6667721235b783bc1a850 This version of the fix will set the def file only if defblock is enabled in qbase.pri. That means that def files don't get turned on for webkit but not for the whole project (avoids build failures in the continuous integration system when other teams change the exported symbols) Reviewed-by: Jason Barron --- src/3rdparty/webkit/WebCore/WebCore.pro | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 60e414f..4e84a80 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -3381,3 +3381,18 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4 plugins/win/PaintHooks.asm } } + +# Temporary workaround to pick up the DEF file from the same place as all the others +symbian { + shared { + contains(MMP_RULES, defBlock) { + MMP_RULES -= defBlock + + MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ + "DEFFILE ../../../s60installs/bwins/$${TARGET}.def" \ + "$${LITERAL_HASH}elif defined EABI" \ + "DEFFILE ../../../s60installs/eabi/$${TARGET}.def" \ + "$${LITERAL_HASH}endif" + } + } +} -- cgit v0.12 From 9e06a5883b7e719417ecb3f8f5188e2a3b1bc953 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 27 Oct 2009 16:19:19 +0100 Subject: Re-apply change 2a9596d85a6c44fe1eba98447ab95ca913f10e29 by Joerg Bornemann Re-apply change 62923e7edacf6a1d28accaff70cbdc0176890d62 by Joerg Bornemann Re-apply change fa1856bcb2eff41dadf0900202dd43f44ddb2343 by Joerg Bornemann WebKit compile fix for Windows CE Not sure if this is right fix. We could also disable PLUGIN_PACKAGE_SIMPLE_HASH. But this is automatically enabled when NETSCAPE_PLUGIN_API is disabled. Reviewed-by: thartman --- src/3rdparty/webkit/WebCore/platform/FileSystem.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/3rdparty/webkit/WebCore/platform/FileSystem.h b/src/3rdparty/webkit/WebCore/platform/FileSystem.h index 9952b39..791198d 100644 --- a/src/3rdparty/webkit/WebCore/platform/FileSystem.h +++ b/src/3rdparty/webkit/WebCore/platform/FileSystem.h @@ -98,6 +98,17 @@ struct PlatformModuleVersion { { } + bool operator != (const PlatformModuleVersion& rhs) const + { + return mostSig != rhs.mostSig && leastSig != rhs.leastSig; + } + + + bool operator > (const PlatformModuleVersion& rhs) const + { + return mostSig > rhs.mostSig && leastSig > rhs.leastSig; + } + }; #else typedef unsigned PlatformModuleVersion; -- cgit v0.12 From d6c9a246b6fcfdc8e1f972d6a91da2c642ef3fc2 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 09:33:33 +0100 Subject: Re-apply change e53c26b52c890f242491e0dfed4201313d98f720 by Marius Storm-Olsen API review: Rename functions numColors(), setNumColors() and numBytes() QPaintDevice and QImage used the functions numColors(), setNumColors(), and numBytes(). However, this is not consistent with the rest of the Qt API which uses *Count() and set*Count(). Removed all usage of these functions inside Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp index 8221760..442ffa3 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp @@ -72,7 +72,7 @@ int screenDepthPerComponent(Widget* w) bool screenIsMonochrome(Widget* w) { - return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2; + return QApplication::desktop()->screen(screenNumber(w))->colorCount() < 2; } FloatRect screenRect(Widget* w) -- cgit v0.12 From 08cb0e0b2d2b1f1f7ef4a0884e602323cf053d00 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 10 Nov 2009 10:35:17 +0100 Subject: Richards changes into the changelog --- dist/changes-4.6.0 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 895421d..b26a3f9 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -482,6 +482,23 @@ General changes on Mac OS X: - Building for ppc64 is no longer supported by the gcc tool chain. - Building for ppc is still supported. +Cocoa: +- Fixed stacking order of modal dialogs so that they never rearrange level, or + hide in the background. +- Fixed problem with plugins written with Qt that closes down the native application + when hiding a modal dialog. +- Fixed problem that native applications cannot quit when using plugins written with + Qt from a native application. +- Fixed problem that the menubar is not restored correctly when using plugins written + with Qt from a native application. +- The event dispatcher now integrates better with native applications that spins the + event loop them selves. +- Using Qt::AA_MacPluginApplication will now disable the use of native menubars on mac. +- Sliders and scroll views in Qt now uses pixel scrolling for mouse devices + that supports this. +- Wheel events can now contain a delta with a value as low as 1 for mouse devices that + uses pixel scrolling. + Qt for Embedded Linux --------------------- -- cgit v0.12 From 6255f2b8baaf002772e1f547ce477dfd81500b25 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 10 Nov 2009 10:49:59 +0100 Subject: Updated changelog with my changes --- dist/changes-4.6.0 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index b26a3f9..ae4c9be 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -99,6 +99,9 @@ QtCore * Improved performance of plugin loading by reusing the plugin cache instead of loading it every time. + - QRegExp + * New pattern syntax "QRegExp::WildcardUnix" with wildcard characters escaping + - QTextStream * [221316] Fixed crash on large input. * Improved reading utf8/utf16/utf32 data by correctly skipping the @@ -111,6 +114,9 @@ QtGui - QGraphicsAnchorLayout * Support for expanding size policy has been removed. (The Qt 4.6 Beta had support for it). + - QCalendarWidget + * [252943] QCalendarWidget::setDateTextFormat() reset the format if the date is invalid. + - QCompleter * [246056] Fixed a possible assertion when setting the completer prefix @@ -376,6 +382,12 @@ QtXml - QDomDocument * set the codec to UTF-8 if codec not present or unknown +Qt Plugins + + - Tiff plugin + * [258526] Rotate the image if the tiff file contains an orientation tag + * [254317] Add support for mono and indexed format + **************************************************************************** * Platform Specific Changes * **************************************************************************** @@ -420,6 +432,9 @@ Qt for Linux/X11 backend uses regular X11 pixmaps to store the image data, however it uses OpenGL to render into them. + - Tablet: Disable event compression of events of type QTabletEvent when the + current event is accepted by the receiver. + Qt for Windows -------------- -- cgit v0.12 From c52ca357a323ab6671cae130e7013b35023f5a67 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Nov 2009 11:01:10 +0100 Subject: Changelog: My changes. Also reorganise some things I saw wrong. --- dist/changes-4.6.0 | 73 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index ae4c9be..91a7cc6 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -22,6 +22,9 @@ information about a particular change. - QtDBus * The minimum required version of the D-Bus reference library is now 0.93. + * Support for reading and writing of custom property types added. + * Support for getting return arguments in remote method invocation + via QMetaMethod::invokeMethod. - [MR#1742] Added new multimedia keys to the Qt::Key enum. @@ -54,17 +57,6 @@ Third party components * Library * **************************************************************************** - * [245219] Added QXmlQuery::setFocus(const QString &focus); - - - QGraphicsBlurEffect - * Since the 4.6 beta Qt::RenderHint has been moved to - QGraphicsBlurEffect::BlurHint. - - * Input contexts are not activated for disabled widgets anymore. - - * [250555] Data copied from Mozilla Firefox can now be pasted correctly to - a Qt application. - QtCore - QByteArray @@ -102,14 +94,31 @@ QtCore - QRegExp * New pattern syntax "QRegExp::WildcardUnix" with wildcard characters escaping -- QTextStream + - QSharedPointer + * Added support for creating the object along the internal private + data in one single memory allocation. (QSharedPointer::create) + * Fixed a bug where, in a race condition, QSharedPointer could + track a pointer that was being deleted. + + - QTextStream * [221316] Fixed crash on large input. * Improved reading utf8/utf16/utf32 data by correctly skipping the ByteOrderMark when reading data by one character at a time. -- QXmlStreamWriter + - QUrl + * Made QUrl hostname parser a lot stricter, requiring compliance + to STD3 to validate, thus preventing invalid hostnames from + being accepted. See below in "Important Behavior Changes". + + - QXmlStreamWriter * [256468] fix comment indentation + - QWeakPointer + * Added support for tracking QObject-derived classes that aren't + attached to a QSharedPointer. + * Added QWeakPointer::data which allows you to obtain the pointer + being tracked (without protection). + QtGui - QGraphicsAnchorLayout * Support for expanding size policy has been removed. (The Qt 4.6 Beta had support for it). @@ -123,6 +132,15 @@ QtGui - QFontDialog * [256466] fixed the dialog not always returning the selected style. + - QGraphicsBlurEffect + * Since the 4.6 beta Qt::RenderHint has been moved to + QGraphicsBlurEffect::BlurHint. + + * Input contexts are not activated for disabled widgets anymore. + + * [250555] Data copied from Mozilla Firefox can now be pasted correctly to + a Qt application. + - QGraphicsItem * Fixed bug and improved accuracy of QGraphicsItem::childrenBoundingRect(). * Many optimizations. @@ -266,7 +284,13 @@ QtGui * [255581] Fixed sizeHint recalculation bug. - QApplication - * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). + * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). + +QtDBus + + - QDBusConnection + * Made sending of invalid/incomplete messages consistently fail + with error (no more assertions). QtNetwork @@ -379,9 +403,14 @@ QtSql QtXml -- QDomDocument + - QDomDocument * set the codec to UTF-8 if codec not present or unknown +QtXmlPatterns + + - QXmlQuery + * [245219] Added QXmlQuery::setFocus(const QString &focus); + Qt Plugins - Tiff plugin @@ -395,6 +424,20 @@ Qt Plugins - Added community supported Qt ports for QNX and VxWorks. See platform notes in the Qt documentation for details. + - Improved support for AIX using IBM's Visual Age C/C++ compiler + version 7 (xlC). + + - Improved support for Solaris using Sun Studio 12 (CC 5.9). + +Qt for Unix (X11 and Mac OS X) +------------------------------ + + - Added support for thread-safe FD_CLOEXEC file-descriptor creation + where supported by the operating system (currently only Linux). + + - Ensured that system calls where EINTR is a possible result are + properly restarted. + Qt for Linux/X11 ---------------- -- cgit v0.12 From c7de6ce2e06a2479ec9cb88559482021b8919076 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 10 Nov 2009 11:07:44 +0100 Subject: Added my changes to changes-4.6.0. --- dist/changes-4.6.0 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 91a7cc6..daea2a6 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -240,6 +240,7 @@ QtGui - QPixmap * Optimized width(), height(), isNull() and depth(). + * [QTBUG-2832] Fixed bug where calling fill on pixmap with active painter could crash. - QRegion * Minor optimizations. @@ -266,6 +267,10 @@ QtGui - QSplitter * [206494] Added ability to style pressed slided with stylesheet + - QStroker + * [QTBUG-5212] Fixed bug where thick strokes around small shapes could + cause holes in the stroke. + - QWidget * [201649] Added QWidget::previousInFocusChain * [254563] Fixed a crash when setting a focus in a widget tree that @@ -280,9 +285,19 @@ QtGui * New qt_paint_device_metric() function to replace the friend declarations for window surface classes that need to access metric(). + - QPainterPath + * [QTBUG-1537] Fixed bug where the points of a rounded rectangle were added + in counter-clockwise order instead of clockwise order like other shapes. + + - QPen + * [QTBUG-2738] Made QPen::setDashOffset() work with non-custom dashed lines. + - QPushButton * [255581] Fixed sizeHint recalculation bug. + - QRasterPaintEngine + * [QTBUG-4210] Fixed bug where bitmaps were painted black instead of in pen colour. + - QApplication * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). @@ -401,6 +416,14 @@ QtSql * QSqlDatabase now has a database level precisionPolicy. Queries now default to this. * Add proper iODBC linking support. +QtSvg + - QSvgHandler + * [245602] Fixed gradient and solid-color referencing. + * [202426] Made stroke attribute inheritance work with 'use' tags. + * [250618] Fixed gradient on strokes. + - QSvgPaintEngine + * [257052] Changed drawImage() to ignore aspect ratio. + QtXml - QDomDocument -- cgit v0.12 From 451e7fcad72366cf40bcb00931b86aafba1b983f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 10 Nov 2009 11:12:31 +0100 Subject: Add some of my changes to changes-4.6.0 Update changes-4.6.0 with relevant changes. Reviewed-by: Trond Conflicts: dist/changes-4.6.0 --- dist/changes-4.6.0 | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index daea2a6..03ee4a4 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -307,6 +307,41 @@ QtDBus * Made sending of invalid/incomplete messages consistently fail with error (no more assertions). + - QPlainTextEdit + * Fixed crash when clicking on a text edit which was smaller than the + height of the font used. + + - QPrinter + * [QTBUG-4497] Removed redundant SetPen command in the postscript code + when reusing a QPrinter object. + + - QTextLayout + * [QTBUG-4468] Count tabs as multiple characters when applying a fixed + column width. + * [176401] Take into account the negative right bearing of the last + character in an item of text if the glyph extends beyond its ascent. + + - QTextDocument + * [207189] Support setting font size using short hand syntax in the + CSS "font" property. + * [201228] Remove implicit margin on bullet lists when exporting to + HTML. + * [240086] Fixed bug which caused floating objects which span several + pages to float into the second page of the document even when it's + the only existing object, causing the document to contain a blank + first page. + * [240325] Even when wrap mode is set to Qt::TextWordWrap, the layout + would sometimes break outside word boundaries when floating objects + affected the width available to the text. This has been fixed. + + - QFontEngine + * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which + also contain a regular unicode table for exactly the symbol range of + code points. + + - QFontMetrics + * [176401] Account for right bearing in bounding rect. + QtNetwork - QAbstractSocket @@ -480,6 +515,9 @@ Qt for Linux/X11 when using Synergy. - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. + + - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small + it was unreadable when printed or presented in a print preview widget. - Improved EGL integration on X11 (including better visual selection). @@ -537,6 +575,11 @@ Qt for Windows rendering. * Fixed a flicker issue when switching source with a transition time of 0 + - [QTBUG-4445] Fixed bug on Windows that caused problems when printing + text where several characters were represented by a single glyph, e.g. + a double 't' with the Calibri font. + + Qt for Mac OS X --------------- @@ -633,7 +676,7 @@ Qt for Windows CE - [257352] When configuring Qt for Windows CE, configure points the user to setcepaths, when its done. - [259850] Added a makespec template for Windows CE 6. - + **************************************************************************** * Tools * **************************************************************************** -- cgit v0.12 From bd8fa6425a43cbc375564cc1b022fe47402d251f Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 10 Nov 2009 11:40:24 +0100 Subject: Added my changelog entries. --- dist/changes-4.6.0 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 03ee4a4..c0ce2af 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -129,6 +129,9 @@ QtGui - QCompleter * [246056] Fixed a possible assertion when setting the completer prefix + - QEvent + * Introduced RequestSoftwareInputPanel and CloseSoftwareInputPanel events. + - QFontDialog * [256466] fixed the dialog not always returning the selected style. @@ -206,6 +209,7 @@ QtGui - QLineEdit * [248948] Clear selection when redoing a delete operation. + * [QTBUG-5261] Fixed: Erasing characters from textedits does not update the text - QListView * [243335] Fixed the visualRect to return correct values when the widget is not yet show @@ -272,6 +276,7 @@ QtGui cause holes in the stroke. - QWidget + * Added inputMethodHints property. * [201649] Added QWidget::previousInFocusChain * [254563] Fixed a crash when setting a focus in a widget tree that contains invisible widgets -- cgit v0.12 From c2a1e160bd0cee91789ebce877018a459aa14b8c Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 10 Nov 2009 11:52:19 +0100 Subject: Added my changes in Qt 4.6.0 to the change log. --- dist/changes-4.6.0 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index c0ce2af..c008f31 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -457,10 +457,13 @@ QtSql * Add proper iODBC linking support. QtSvg + - QSvgHandler - * [245602] Fixed gradient and solid-color referencing. - * [202426] Made stroke attribute inheritance work with 'use' tags. + * [245602] [204686] Fixed gradient and solid-color referencing. + * [202426] Made attribute inheritance work with 'use' tags. * [250618] Fixed gradient on strokes. + * [254040] Added support for 'vector-effect'. + - QSvgPaintEngine * [257052] Changed drawImage() to ignore aspect ratio. -- cgit v0.12 From ee9b774ae230d3fce0f33510f421e8e772536c1d Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 10 Nov 2009 12:05:07 +0100 Subject: Add my changes to the 4.6.0 changelog. --- dist/changes-4.6.0 | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index c008f31..f457e63 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -119,9 +119,42 @@ QtCore * Added QWeakPointer::data which allows you to obtain the pointer being tracked (without protection). + - QUuid + * [QTBUG-3543] Fixed a bug in createUuid() which caused multiple + threads to generate the identical UUID sequences + + - QEventDispatcherGlib (internal class) + * Fix a regression introduced in 4.5.3 that would cause timers to not + be delivered. + + - QEventDispatcherUNIX (internal class) + * Improve detection of monotonic clock support to include + non-POSIX.1-2001 compliant systems. + * [250681] Fix time change detection on UNIX systems without + monotonic timers. + + - QEventDispatcherWin32 (internal class) + * Changed the threshold for using multimedia timers to 20ms (was 10ms). + * Changed the way Qt's posted events are sent by the event + dispatcher. The are now driven on top of a Windows message + instead of an explicit call in processEvents(). This means that + posted events are sent even when a Windows modal message loop is + running (for example, when the user is moving a window or when a + native modal dialog is visible). + * Fixed a bug that would allow the same timer id to be used by + multiple QTimer instances. + + - QTextCodec + * Instantiate the CP949 codec when building with -no-iconv. + + - QThread + * [249997] Document that QThread priority has no effect on Linux. + QtGui -- QGraphicsAnchorLayout - * Support for expanding size policy has been removed. (The Qt 4.6 Beta had support for it). + + - QGraphicsAnchorLayout + * Support for expanding size policy has been removed. (The Qt 4.6 + Beta had support for it). - QCalendarWidget * [252943] QCalendarWidget::setDateTextFormat() reset the format if the date is invalid. @@ -152,6 +185,7 @@ QtGui * Introduced QGraphicsItem::focusProxy(), focus proxy support * Introduced QGraphicsItem::ItemNegativeZStacksBehindParent * Introduced QGraphicsItem::ItemIsPanel, light-weight window support + * Introduced modality support for QGraphicsItem panels. * Introduced activation support. * Introduced QGraphicsItem::stackBefore() * Cached items are now always invalidated when update() is called. @@ -347,6 +381,10 @@ QtDBus - QFontMetrics * [176401] Account for right bearing in bounding rect. + - QPlastiqueStyle + * [QTBUG-3555] Fixed a bug in the Plastique style that would cause an + ASSERT failure in QFont when the application font has a pixel size set. + QtNetwork - QAbstractSocket @@ -547,6 +585,21 @@ Qt for Linux/X11 - Tablet: Disable event compression of events of type QTabletEvent when the current event is accepted by the receiver. + - [QTBUG-4242] Fixed a bug that allowed the user to close a window + event though the program is using the QEventLoop::ExcludeUserInputEvents + flag. + + - [255559] Fixed generation of XdndLeave events to include the + correct source id. + + - [258319] Avoid division by zero on some Xlib/Xserver implementations. + + - Fixed the default QWidget size on X servers with Xinerama to give widgets + a default size that should fit on a single screen. + + - Support _NET_WORKAREA on X servers with Xinerama (previously this property + was ignored). + Qt for Windows -------------- @@ -587,6 +640,7 @@ Qt for Windows text where several characters were represented by a single glyph, e.g. a double 't' with the Calibri font. + - Added QSysInfo::WV_WINDOWS7 and QSysInfo::WV_6_1 Qt for Mac OS X --------------- -- cgit v0.12 From f80c224ddd3c3c4a408c8f88e6cf5114ee107c89 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 2 Nov 2009 18:41:06 +0100 Subject: fix WebKit build on Windows CE 6 Again, we have fun with the C time functions on Windows CE. On Windows CE 5: the functions are declared but not defined. On Windows CE 6: the functions are neither declared nor defined. Reviewed-by: Simon Hausmann --- src/3rdparty/ce-compat/ce_time.c | 677 +++++++++++++++++++++ src/3rdparty/ce-compat/ce_time.cpp | 677 --------------------- src/3rdparty/ce-compat/ce_time.h | 13 +- .../JavaScriptCore/JavaScriptCore.pri | 3 +- .../javascriptcore/JavaScriptCore/wtf/Platform.h | 4 + .../webkit/JavaScriptCore/JavaScriptCore.pri | 3 +- src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 4 + 7 files changed, 700 insertions(+), 681 deletions(-) create mode 100644 src/3rdparty/ce-compat/ce_time.c delete mode 100644 src/3rdparty/ce-compat/ce_time.cpp diff --git a/src/3rdparty/ce-compat/ce_time.c b/src/3rdparty/ce-compat/ce_time.c new file mode 100644 index 0000000..92efae0 --- /dev/null +++ b/src/3rdparty/ce-compat/ce_time.c @@ -0,0 +1,677 @@ +// +// strftime.c +// +// Date to string conversion +// +// Copyright (C) 2002 Michael Ringgaard. 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. +// 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. +// 3. Neither the name of the project 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. +// + +///////////////////////////////////////////////////////////////////////////////////////////// +// // +// time() // +// // +///////////////////////////////////////////////////////////////////////////////////////////// + + +#include +#include +#include "ce_time.h" + +time_t +time(time_t* timer) +{ + SYSTEMTIME systime; + struct tm tmtime; + time_t tt; + + GetLocalTime(&systime); + + tmtime.tm_year = systime.wYear-1900; + tmtime.tm_mon = systime.wMonth-1; + tmtime.tm_mday = systime.wDay; + tmtime.tm_wday = systime.wDayOfWeek; + tmtime.tm_hour = systime.wHour; + tmtime.tm_min = systime.wMinute; + tmtime.tm_sec = systime.wSecond; + + tt = mktime(&tmtime); + + if(timer) + *timer = tt; + + return tt; +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +// // +// mktime() // +// // +///////////////////////////////////////////////////////////////////////////////////////////// + +static int month_to_day[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + +time_t mktime(struct tm *t) +{ + short month, year; + time_t result; + + month = t->tm_mon; + year = t->tm_year + month / 12 + 1900; + month %= 12; + if (month < 0) + { + year -= 1; + month += 12; + } + result = (year - 1970) * 365 + (year - 1969) / 4 + month_to_day[month]; + result = (year - 1970) * 365 + month_to_day[month]; + if (month <= 1) + year -= 1; + result += (year - 1968) / 4; + result -= (year - 1900) / 100; + result += (year - 1600) / 400; + result += t->tm_mday; + result -= 1; + result *= 24; + result += t->tm_hour; + result *= 60; + result += t->tm_min; + result *= 60; + result += t->tm_sec; + return(result); +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +// // +// strftime() - taken from OpenBSD // +// // +///////////////////////////////////////////////////////////////////////////////////////////// + +#define IN_NONE 0 +#define IN_SOME 1 +#define IN_THIS 2 +#define IN_ALL 3 +#define CHAR_BIT 8 + +#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) +#define TYPE_SIGNED(type) (((type) -1) < 0) + +#define INT_STRLEN_MAXIMUM(type) \ + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +#define MONSPERYEAR 12 +#define DAYSPERWEEK 7 +#define TM_YEAR_BASE 1900 +#define HOURSPERDAY 24 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 + +static char wildabbr[] = "WILDABBR"; + +static char * tzname[2] = { + wildabbr, + wildabbr +}; + + +#define Locale (&C_time_locale) + +struct lc_time_T { + const char * mon[MONSPERYEAR]; + const char * month[MONSPERYEAR]; + const char * wday[DAYSPERWEEK]; + const char * weekday[DAYSPERWEEK]; + const char * X_fmt; + const char * x_fmt; + const char * c_fmt; + const char * am; + const char * pm; + const char * date_fmt; +}; + +static const struct lc_time_T C_time_locale = { + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }, { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }, { + "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat" + }, { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }, + + /* X_fmt */ + "%H:%M:%S", + + /* + ** x_fmt + ** C99 requires this format. + ** Using just numbers (as here) makes Quakers happier; + ** it's also compatible with SVR4. + */ + "%m/%d/%y", + + /* + ** c_fmt + ** C99 requires this format. + ** Previously this code used "%D %X", but we now conform to C99. + ** Note that + ** "%a %b %d %H:%M:%S %Y" + ** is used by Solaris 2.3. + */ + "%a %b %e %T %Y", + + /* am */ + "AM", + + /* pm */ + "PM", + + /* date_fmt */ + "%a %b %e %H:%M:%S %Z %Y" +}; + + +static char * +_add(const char * str, char * pt, const char * const ptlim) +{ + while (pt < ptlim && (*pt = *str++) != '\0') + ++pt; + return pt; +} + + +static char * +_conv(const int n, const char * const format, char * const pt, const char * const ptlim) +{ + char buf[INT_STRLEN_MAXIMUM(int) + 1]; + + (void) _snprintf(buf, sizeof buf, format, n); + return _add(buf, pt, ptlim); +} + + +static char * +_fmt(const char * format, const struct tm * const t, char * pt, const char * const ptlim, int * warnp) +{ + for ( ; *format; ++format) { + if (*format == '%') { +label: + switch (*++format) { + case '\0': + --format; + break; + case 'A': + pt = _add((t->tm_wday < 0 || + t->tm_wday >= DAYSPERWEEK) ? + "?" : Locale->weekday[t->tm_wday], + pt, ptlim); + continue; + case 'a': + pt = _add((t->tm_wday < 0 || + t->tm_wday >= DAYSPERWEEK) ? + "?" : Locale->wday[t->tm_wday], + pt, ptlim); + continue; + case 'B': + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? + "?" : Locale->month[t->tm_mon], + pt, ptlim); + continue; + case 'b': + case 'h': + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? + "?" : Locale->mon[t->tm_mon], + pt, ptlim); + continue; + case 'C': + /* + ** %C used to do a... + ** _fmt("%a %b %e %X %Y", t); + ** ...whereas now POSIX 1003.2 calls for + ** something completely different. + ** (ado, 1993-05-24) + */ + pt = _conv((t->tm_year + TM_YEAR_BASE) / 100, + "%02d", pt, ptlim); + continue; + case 'c': + { + int warn2 = IN_SOME; + + pt = _fmt(Locale->c_fmt, t, pt, ptlim, warnp); + if (warn2 == IN_ALL) + warn2 = IN_THIS; + if (warn2 > *warnp) + *warnp = warn2; + } + continue; + case 'D': + pt = _fmt("%m/%d/%y", t, pt, ptlim, warnp); + continue; + case 'd': + pt = _conv(t->tm_mday, "%02d", pt, ptlim); + continue; + case 'E': + case 'O': + /* + ** C99 locale modifiers. + ** The sequences + ** %Ec %EC %Ex %EX %Ey %EY + ** %Od %oe %OH %OI %Om %OM + ** %OS %Ou %OU %OV %Ow %OW %Oy + ** are supposed to provide alternate + ** representations. + */ + goto label; + case 'e': + pt = _conv(t->tm_mday, "%2d", pt, ptlim); + continue; + case 'F': + pt = _fmt("%Y-%m-%d", t, pt, ptlim, warnp); + continue; + case 'H': + pt = _conv(t->tm_hour, "%02d", pt, ptlim); + continue; + case 'I': + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%02d", pt, ptlim); + continue; + case 'j': + pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); + continue; + case 'k': + /* + ** This used to be... + ** _conv(t->tm_hour % 12 ? + ** t->tm_hour % 12 : 12, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbins' + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 1993-05-24) + */ + pt = _conv(t->tm_hour, "%2d", pt, ptlim); + continue; +#ifdef KITCHEN_SINK + case 'K': + /* + ** After all this time, still unclaimed! + */ + pt = _add("kitchen sink", pt, ptlim); + continue; +#endif /* defined KITCHEN_SINK */ + case 'l': + /* + ** This used to be... + ** _conv(t->tm_hour, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbin's + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 1993-05-24) + */ + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%2d", pt, ptlim); + continue; + case 'M': + pt = _conv(t->tm_min, "%02d", pt, ptlim); + continue; + case 'm': + pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); + continue; + case 'n': + pt = _add("\n", pt, ptlim); + continue; + case 'p': + pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ? + Locale->pm : + Locale->am, + pt, ptlim); + continue; + case 'R': + pt = _fmt("%H:%M", t, pt, ptlim, warnp); + continue; + case 'r': + pt = _fmt("%I:%M:%S %p", t, pt, ptlim, warnp); + continue; + case 'S': + pt = _conv(t->tm_sec, "%02d", pt, ptlim); + continue; + case 's': + { + struct tm tm; + char buf[INT_STRLEN_MAXIMUM( + time_t) + 1]; + time_t mkt; + + tm = *t; + mkt = mktime(&tm); + if (TYPE_SIGNED(time_t)) + (void) _snprintf(buf, sizeof buf, + "%ld", (long) mkt); + else (void) _snprintf(buf, sizeof buf, + "%lu", (unsigned long) mkt); + pt = _add(buf, pt, ptlim); + } + continue; + case 'T': + pt = _fmt("%H:%M:%S", t, pt, ptlim, warnp); + continue; + case 't': + pt = _add("\t", pt, ptlim); + continue; + case 'U': + pt = _conv((t->tm_yday + DAYSPERWEEK - + t->tm_wday) / DAYSPERWEEK, + "%02d", pt, ptlim); + continue; + case 'u': + /* + ** From Arnold Robbins' strftime version 3.0: + ** "ISO 8601: Weekday as a decimal number + ** [1 (Monday) - 7]" + ** (ado, 1993-05-24) + */ + pt = _conv((t->tm_wday == 0) ? + DAYSPERWEEK : t->tm_wday, + "%d", pt, ptlim); + continue; + case 'V': /* ISO 8601 week number */ + case 'G': /* ISO 8601 year (four digits) */ + case 'g': /* ISO 8601 year (two digits) */ + { + int year; + int yday; + int wday; + int w; + + year = t->tm_year + TM_YEAR_BASE; + yday = t->tm_yday; + wday = t->tm_wday; + for ( ; ; ) { + int len; + int bot; + int top; + + len = isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + /* + ** What yday (-3 ... 3) does + ** the ISO year begin on? + */ + bot = ((yday + 11 - wday) % + DAYSPERWEEK) - 3; + /* + ** What yday does the NEXT + ** ISO year begin on? + */ + top = bot - + (len % DAYSPERWEEK); + if (top < -3) + top += DAYSPERWEEK; + top += len; + if (yday >= top) { + ++year; + w = 1; + break; + } + if (yday >= bot) { + w = 1 + ((yday - bot) / + DAYSPERWEEK); + break; + } + --year; + yday += isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + } + if (*format == 'V') + pt = _conv(w, "%02d", + pt, ptlim); + else if (*format == 'g') { + *warnp = IN_ALL; + pt = _conv(year % 100, "%02d", + pt, ptlim); + } else pt = _conv(year, "%04d", + pt, ptlim); + } + continue; + case 'v': + pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp); + continue; + case 'W': + pt = _conv((t->tm_yday + DAYSPERWEEK - + (t->tm_wday ? + (t->tm_wday - 1) : + (DAYSPERWEEK - 1))) / DAYSPERWEEK, + "%02d", pt, ptlim); + continue; + case 'w': + pt = _conv(t->tm_wday, "%d", pt, ptlim); + continue; + case 'X': + pt = _fmt(Locale->X_fmt, t, pt, ptlim, warnp); + continue; + case 'x': + { + int warn2 = IN_SOME; + + pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2); + if (warn2 == IN_ALL) + warn2 = IN_THIS; + if (warn2 > *warnp) + *warnp = warn2; + } + continue; + case 'y': + *warnp = IN_ALL; + pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, + "%02d", pt, ptlim); + continue; + case 'Y': + pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d", + pt, ptlim); + continue; + case 'Z': + if (t->tm_isdst >= 0) + pt = _add(tzname[t->tm_isdst != 0], + pt, ptlim); + /* + ** C99 says that %Z must be replaced by the + ** empty string if the time zone is not + ** determinable. + */ + continue; + case 'z': + { + int diff; + char const * sign; + + if (t->tm_isdst < 0) + continue; + continue; + if (diff < 0) { + sign = "-"; + diff = -diff; + } else sign = "+"; + pt = _add(sign, pt, ptlim); + diff /= 60; + pt = _conv((diff/60)*100 + diff%60, + "%04d", pt, ptlim); + } + continue; + case '+': + pt = _fmt(Locale->date_fmt, t, pt, ptlim, + warnp); + continue; + case '%': + default: + break; + } + } + if (pt == ptlim) + break; + *pt++ = *format; + } + return pt; +} + + +size_t +strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t) +{ + char * p; + int warn; + + //tzset(); + + warn = IN_NONE; + p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, &warn); + + if (p == s + maxsize) { + if (maxsize > 0) + s[maxsize - 1] = '\0'; + return 0; + } + *p = '\0'; + return p - s; +} + + + +///////////////////////////////////////////////////////////////////////////////////////////// +// // +// gmtime() // +// // +///////////////////////////////////////////////////////////////////////////////////////////// + + + +static struct tm mytm; + +static int DMonth[13] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 }; +static int monthCodes[12] = { 6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; + + +static int +calcDayOfWeek(const struct tm* nTM) +{ + int day; + + day = (nTM->tm_year%100); + day += day/4; + day += monthCodes[nTM->tm_mon]; + day += nTM->tm_mday; + while(day>=7) + day -= 7; + + return day; +} + + +static struct tm * +gmtime(const time_t *timer) +{ + unsigned long x = *timer; + int imin, ihrs, iday, iyrs; + int sec, min, hrs, day, mon, yrs; + int lday, qday, jday, mday; + + + imin = x / 60; // whole minutes since 1/1/70 + sec = x - (60 * imin); // leftover seconds + ihrs = imin / 60; // whole hours since 1/1/70 + min = imin - 60 * ihrs; // leftover minutes + iday = ihrs / 24; // whole days since 1/1/70 + hrs = ihrs - 24 * iday; // leftover hours + iday = iday + 365 + 366; // whole days since 1/1/68 + lday = iday / (( 4* 365) + 1); // quadyr = 4 yr period = 1461 days + qday = iday % (( 4 * 365) + 1); // days since current quadyr began + if(qday >= (31 + 29)) // if past feb 29 then + lday = lday + 1; // add this quadyr’s leap day to the + // # of quadyrs (leap days) since 68 + iyrs = (iday - lday) / 365; // whole years since 1968 + jday = iday - (iyrs * 365) - lday; // days since 1 /1 of current year. + if(qday <= 365 && qday >= 60) // if past 2/29 and a leap year then + jday = jday + 1; // add a leap day to the # of whole + // days since 1/1 of current year + yrs = iyrs + 1968; // compute year + mon = 13; // estimate month ( +1) + mday = 366; // max days since 1/1 is 365 + while(jday < mday) // mday = # of days passed from 1/1 + { // until first day of current month + mon = mon - 1; // mon = month (estimated) + mday = DMonth[mon]; // # elapsed days at first of ”mon” + if((mon > 2) && (yrs % 4) == 0) // if past 2/29 and leap year then + mday = mday + 1; // add leap day + // compute month by decrementing + } // month until found + + day = jday - mday + 1; // compute day of month + + mytm.tm_sec = sec; + mytm.tm_min = min; + mytm.tm_hour = hrs; + mytm.tm_mday = day; + mytm.tm_mon = mon; + mytm.tm_year = yrs - 1900; + + mytm.tm_wday = calcDayOfWeek(&mytm); + mytm.tm_yday = jday; + mytm.tm_isdst = 0; + + return &mytm; +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +// // +// localtime() - simply using gmtime() // +// // +///////////////////////////////////////////////////////////////////////////////////////////// + + +struct tm * +localtime(const time_t *timer) +{ + return gmtime(timer); +} diff --git a/src/3rdparty/ce-compat/ce_time.cpp b/src/3rdparty/ce-compat/ce_time.cpp deleted file mode 100644 index 92efae0..0000000 --- a/src/3rdparty/ce-compat/ce_time.cpp +++ /dev/null @@ -1,677 +0,0 @@ -// -// strftime.c -// -// Date to string conversion -// -// Copyright (C) 2002 Michael Ringgaard. 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. -// 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. -// 3. Neither the name of the project 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. -// - -///////////////////////////////////////////////////////////////////////////////////////////// -// // -// time() // -// // -///////////////////////////////////////////////////////////////////////////////////////////// - - -#include -#include -#include "ce_time.h" - -time_t -time(time_t* timer) -{ - SYSTEMTIME systime; - struct tm tmtime; - time_t tt; - - GetLocalTime(&systime); - - tmtime.tm_year = systime.wYear-1900; - tmtime.tm_mon = systime.wMonth-1; - tmtime.tm_mday = systime.wDay; - tmtime.tm_wday = systime.wDayOfWeek; - tmtime.tm_hour = systime.wHour; - tmtime.tm_min = systime.wMinute; - tmtime.tm_sec = systime.wSecond; - - tt = mktime(&tmtime); - - if(timer) - *timer = tt; - - return tt; -} - - -///////////////////////////////////////////////////////////////////////////////////////////// -// // -// mktime() // -// // -///////////////////////////////////////////////////////////////////////////////////////////// - -static int month_to_day[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - -time_t mktime(struct tm *t) -{ - short month, year; - time_t result; - - month = t->tm_mon; - year = t->tm_year + month / 12 + 1900; - month %= 12; - if (month < 0) - { - year -= 1; - month += 12; - } - result = (year - 1970) * 365 + (year - 1969) / 4 + month_to_day[month]; - result = (year - 1970) * 365 + month_to_day[month]; - if (month <= 1) - year -= 1; - result += (year - 1968) / 4; - result -= (year - 1900) / 100; - result += (year - 1600) / 400; - result += t->tm_mday; - result -= 1; - result *= 24; - result += t->tm_hour; - result *= 60; - result += t->tm_min; - result *= 60; - result += t->tm_sec; - return(result); -} - - -///////////////////////////////////////////////////////////////////////////////////////////// -// // -// strftime() - taken from OpenBSD // -// // -///////////////////////////////////////////////////////////////////////////////////////////// - -#define IN_NONE 0 -#define IN_SOME 1 -#define IN_THIS 2 -#define IN_ALL 3 -#define CHAR_BIT 8 - -#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) -#define TYPE_SIGNED(type) (((type) -1) < 0) - -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) - -#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) - -#define MONSPERYEAR 12 -#define DAYSPERWEEK 7 -#define TM_YEAR_BASE 1900 -#define HOURSPERDAY 24 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 - -static char wildabbr[] = "WILDABBR"; - -static char * tzname[2] = { - wildabbr, - wildabbr -}; - - -#define Locale (&C_time_locale) - -struct lc_time_T { - const char * mon[MONSPERYEAR]; - const char * month[MONSPERYEAR]; - const char * wday[DAYSPERWEEK]; - const char * weekday[DAYSPERWEEK]; - const char * X_fmt; - const char * x_fmt; - const char * c_fmt; - const char * am; - const char * pm; - const char * date_fmt; -}; - -static const struct lc_time_T C_time_locale = { - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }, { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - }, { - "Sun", "Mon", "Tue", "Wed", - "Thu", "Fri", "Sat" - }, { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" - }, - - /* X_fmt */ - "%H:%M:%S", - - /* - ** x_fmt - ** C99 requires this format. - ** Using just numbers (as here) makes Quakers happier; - ** it's also compatible with SVR4. - */ - "%m/%d/%y", - - /* - ** c_fmt - ** C99 requires this format. - ** Previously this code used "%D %X", but we now conform to C99. - ** Note that - ** "%a %b %d %H:%M:%S %Y" - ** is used by Solaris 2.3. - */ - "%a %b %e %T %Y", - - /* am */ - "AM", - - /* pm */ - "PM", - - /* date_fmt */ - "%a %b %e %H:%M:%S %Z %Y" -}; - - -static char * -_add(const char * str, char * pt, const char * const ptlim) -{ - while (pt < ptlim && (*pt = *str++) != '\0') - ++pt; - return pt; -} - - -static char * -_conv(const int n, const char * const format, char * const pt, const char * const ptlim) -{ - char buf[INT_STRLEN_MAXIMUM(int) + 1]; - - (void) _snprintf(buf, sizeof buf, format, n); - return _add(buf, pt, ptlim); -} - - -static char * -_fmt(const char * format, const struct tm * const t, char * pt, const char * const ptlim, int * warnp) -{ - for ( ; *format; ++format) { - if (*format == '%') { -label: - switch (*++format) { - case '\0': - --format; - break; - case 'A': - pt = _add((t->tm_wday < 0 || - t->tm_wday >= DAYSPERWEEK) ? - "?" : Locale->weekday[t->tm_wday], - pt, ptlim); - continue; - case 'a': - pt = _add((t->tm_wday < 0 || - t->tm_wday >= DAYSPERWEEK) ? - "?" : Locale->wday[t->tm_wday], - pt, ptlim); - continue; - case 'B': - pt = _add((t->tm_mon < 0 || - t->tm_mon >= MONSPERYEAR) ? - "?" : Locale->month[t->tm_mon], - pt, ptlim); - continue; - case 'b': - case 'h': - pt = _add((t->tm_mon < 0 || - t->tm_mon >= MONSPERYEAR) ? - "?" : Locale->mon[t->tm_mon], - pt, ptlim); - continue; - case 'C': - /* - ** %C used to do a... - ** _fmt("%a %b %e %X %Y", t); - ** ...whereas now POSIX 1003.2 calls for - ** something completely different. - ** (ado, 1993-05-24) - */ - pt = _conv((t->tm_year + TM_YEAR_BASE) / 100, - "%02d", pt, ptlim); - continue; - case 'c': - { - int warn2 = IN_SOME; - - pt = _fmt(Locale->c_fmt, t, pt, ptlim, warnp); - if (warn2 == IN_ALL) - warn2 = IN_THIS; - if (warn2 > *warnp) - *warnp = warn2; - } - continue; - case 'D': - pt = _fmt("%m/%d/%y", t, pt, ptlim, warnp); - continue; - case 'd': - pt = _conv(t->tm_mday, "%02d", pt, ptlim); - continue; - case 'E': - case 'O': - /* - ** C99 locale modifiers. - ** The sequences - ** %Ec %EC %Ex %EX %Ey %EY - ** %Od %oe %OH %OI %Om %OM - ** %OS %Ou %OU %OV %Ow %OW %Oy - ** are supposed to provide alternate - ** representations. - */ - goto label; - case 'e': - pt = _conv(t->tm_mday, "%2d", pt, ptlim); - continue; - case 'F': - pt = _fmt("%Y-%m-%d", t, pt, ptlim, warnp); - continue; - case 'H': - pt = _conv(t->tm_hour, "%02d", pt, ptlim); - continue; - case 'I': - pt = _conv((t->tm_hour % 12) ? - (t->tm_hour % 12) : 12, - "%02d", pt, ptlim); - continue; - case 'j': - pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); - continue; - case 'k': - /* - ** This used to be... - ** _conv(t->tm_hour % 12 ? - ** t->tm_hour % 12 : 12, 2, ' '); - ** ...and has been changed to the below to - ** match SunOS 4.1.1 and Arnold Robbins' - ** strftime version 3.0. That is, "%k" and - ** "%l" have been swapped. - ** (ado, 1993-05-24) - */ - pt = _conv(t->tm_hour, "%2d", pt, ptlim); - continue; -#ifdef KITCHEN_SINK - case 'K': - /* - ** After all this time, still unclaimed! - */ - pt = _add("kitchen sink", pt, ptlim); - continue; -#endif /* defined KITCHEN_SINK */ - case 'l': - /* - ** This used to be... - ** _conv(t->tm_hour, 2, ' '); - ** ...and has been changed to the below to - ** match SunOS 4.1.1 and Arnold Robbin's - ** strftime version 3.0. That is, "%k" and - ** "%l" have been swapped. - ** (ado, 1993-05-24) - */ - pt = _conv((t->tm_hour % 12) ? - (t->tm_hour % 12) : 12, - "%2d", pt, ptlim); - continue; - case 'M': - pt = _conv(t->tm_min, "%02d", pt, ptlim); - continue; - case 'm': - pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); - continue; - case 'n': - pt = _add("\n", pt, ptlim); - continue; - case 'p': - pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ? - Locale->pm : - Locale->am, - pt, ptlim); - continue; - case 'R': - pt = _fmt("%H:%M", t, pt, ptlim, warnp); - continue; - case 'r': - pt = _fmt("%I:%M:%S %p", t, pt, ptlim, warnp); - continue; - case 'S': - pt = _conv(t->tm_sec, "%02d", pt, ptlim); - continue; - case 's': - { - struct tm tm; - char buf[INT_STRLEN_MAXIMUM( - time_t) + 1]; - time_t mkt; - - tm = *t; - mkt = mktime(&tm); - if (TYPE_SIGNED(time_t)) - (void) _snprintf(buf, sizeof buf, - "%ld", (long) mkt); - else (void) _snprintf(buf, sizeof buf, - "%lu", (unsigned long) mkt); - pt = _add(buf, pt, ptlim); - } - continue; - case 'T': - pt = _fmt("%H:%M:%S", t, pt, ptlim, warnp); - continue; - case 't': - pt = _add("\t", pt, ptlim); - continue; - case 'U': - pt = _conv((t->tm_yday + DAYSPERWEEK - - t->tm_wday) / DAYSPERWEEK, - "%02d", pt, ptlim); - continue; - case 'u': - /* - ** From Arnold Robbins' strftime version 3.0: - ** "ISO 8601: Weekday as a decimal number - ** [1 (Monday) - 7]" - ** (ado, 1993-05-24) - */ - pt = _conv((t->tm_wday == 0) ? - DAYSPERWEEK : t->tm_wday, - "%d", pt, ptlim); - continue; - case 'V': /* ISO 8601 week number */ - case 'G': /* ISO 8601 year (four digits) */ - case 'g': /* ISO 8601 year (two digits) */ - { - int year; - int yday; - int wday; - int w; - - year = t->tm_year + TM_YEAR_BASE; - yday = t->tm_yday; - wday = t->tm_wday; - for ( ; ; ) { - int len; - int bot; - int top; - - len = isleap(year) ? - DAYSPERLYEAR : - DAYSPERNYEAR; - /* - ** What yday (-3 ... 3) does - ** the ISO year begin on? - */ - bot = ((yday + 11 - wday) % - DAYSPERWEEK) - 3; - /* - ** What yday does the NEXT - ** ISO year begin on? - */ - top = bot - - (len % DAYSPERWEEK); - if (top < -3) - top += DAYSPERWEEK; - top += len; - if (yday >= top) { - ++year; - w = 1; - break; - } - if (yday >= bot) { - w = 1 + ((yday - bot) / - DAYSPERWEEK); - break; - } - --year; - yday += isleap(year) ? - DAYSPERLYEAR : - DAYSPERNYEAR; - } - if (*format == 'V') - pt = _conv(w, "%02d", - pt, ptlim); - else if (*format == 'g') { - *warnp = IN_ALL; - pt = _conv(year % 100, "%02d", - pt, ptlim); - } else pt = _conv(year, "%04d", - pt, ptlim); - } - continue; - case 'v': - pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp); - continue; - case 'W': - pt = _conv((t->tm_yday + DAYSPERWEEK - - (t->tm_wday ? - (t->tm_wday - 1) : - (DAYSPERWEEK - 1))) / DAYSPERWEEK, - "%02d", pt, ptlim); - continue; - case 'w': - pt = _conv(t->tm_wday, "%d", pt, ptlim); - continue; - case 'X': - pt = _fmt(Locale->X_fmt, t, pt, ptlim, warnp); - continue; - case 'x': - { - int warn2 = IN_SOME; - - pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2); - if (warn2 == IN_ALL) - warn2 = IN_THIS; - if (warn2 > *warnp) - *warnp = warn2; - } - continue; - case 'y': - *warnp = IN_ALL; - pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, - "%02d", pt, ptlim); - continue; - case 'Y': - pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d", - pt, ptlim); - continue; - case 'Z': - if (t->tm_isdst >= 0) - pt = _add(tzname[t->tm_isdst != 0], - pt, ptlim); - /* - ** C99 says that %Z must be replaced by the - ** empty string if the time zone is not - ** determinable. - */ - continue; - case 'z': - { - int diff; - char const * sign; - - if (t->tm_isdst < 0) - continue; - continue; - if (diff < 0) { - sign = "-"; - diff = -diff; - } else sign = "+"; - pt = _add(sign, pt, ptlim); - diff /= 60; - pt = _conv((diff/60)*100 + diff%60, - "%04d", pt, ptlim); - } - continue; - case '+': - pt = _fmt(Locale->date_fmt, t, pt, ptlim, - warnp); - continue; - case '%': - default: - break; - } - } - if (pt == ptlim) - break; - *pt++ = *format; - } - return pt; -} - - -size_t -strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t) -{ - char * p; - int warn; - - //tzset(); - - warn = IN_NONE; - p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, &warn); - - if (p == s + maxsize) { - if (maxsize > 0) - s[maxsize - 1] = '\0'; - return 0; - } - *p = '\0'; - return p - s; -} - - - -///////////////////////////////////////////////////////////////////////////////////////////// -// // -// gmtime() // -// // -///////////////////////////////////////////////////////////////////////////////////////////// - - - -static struct tm mytm; - -static int DMonth[13] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 }; -static int monthCodes[12] = { 6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; - - -static int -calcDayOfWeek(const struct tm* nTM) -{ - int day; - - day = (nTM->tm_year%100); - day += day/4; - day += monthCodes[nTM->tm_mon]; - day += nTM->tm_mday; - while(day>=7) - day -= 7; - - return day; -} - - -static struct tm * -gmtime(const time_t *timer) -{ - unsigned long x = *timer; - int imin, ihrs, iday, iyrs; - int sec, min, hrs, day, mon, yrs; - int lday, qday, jday, mday; - - - imin = x / 60; // whole minutes since 1/1/70 - sec = x - (60 * imin); // leftover seconds - ihrs = imin / 60; // whole hours since 1/1/70 - min = imin - 60 * ihrs; // leftover minutes - iday = ihrs / 24; // whole days since 1/1/70 - hrs = ihrs - 24 * iday; // leftover hours - iday = iday + 365 + 366; // whole days since 1/1/68 - lday = iday / (( 4* 365) + 1); // quadyr = 4 yr period = 1461 days - qday = iday % (( 4 * 365) + 1); // days since current quadyr began - if(qday >= (31 + 29)) // if past feb 29 then - lday = lday + 1; // add this quadyr’s leap day to the - // # of quadyrs (leap days) since 68 - iyrs = (iday - lday) / 365; // whole years since 1968 - jday = iday - (iyrs * 365) - lday; // days since 1 /1 of current year. - if(qday <= 365 && qday >= 60) // if past 2/29 and a leap year then - jday = jday + 1; // add a leap day to the # of whole - // days since 1/1 of current year - yrs = iyrs + 1968; // compute year - mon = 13; // estimate month ( +1) - mday = 366; // max days since 1/1 is 365 - while(jday < mday) // mday = # of days passed from 1/1 - { // until first day of current month - mon = mon - 1; // mon = month (estimated) - mday = DMonth[mon]; // # elapsed days at first of ”mon” - if((mon > 2) && (yrs % 4) == 0) // if past 2/29 and leap year then - mday = mday + 1; // add leap day - // compute month by decrementing - } // month until found - - day = jday - mday + 1; // compute day of month - - mytm.tm_sec = sec; - mytm.tm_min = min; - mytm.tm_hour = hrs; - mytm.tm_mday = day; - mytm.tm_mon = mon; - mytm.tm_year = yrs - 1900; - - mytm.tm_wday = calcDayOfWeek(&mytm); - mytm.tm_yday = jday; - mytm.tm_isdst = 0; - - return &mytm; -} - - -///////////////////////////////////////////////////////////////////////////////////////////// -// // -// localtime() - simply using gmtime() // -// // -///////////////////////////////////////////////////////////////////////////////////////////// - - -struct tm * -localtime(const time_t *timer) -{ - return gmtime(timer); -} diff --git a/src/3rdparty/ce-compat/ce_time.h b/src/3rdparty/ce-compat/ce_time.h index 9d946e8..07ca094 100644 --- a/src/3rdparty/ce-compat/ce_time.h +++ b/src/3rdparty/ce-compat/ce_time.h @@ -2,15 +2,24 @@ #define __CE_TIME_H__ #if defined(_WIN32_WCE) && _WIN32_WCE >= 0x600 -// we need to prototype the time functions for Windows CE >= 6.0 +/* we need to prototype the time functions for Windows CE >= 6.0 */ #include +#ifdef __cplusplus +extern "C" { +#endif + struct tm; time_t time(time_t* timer); time_t mktime(struct tm *t); size_t strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t); struct tm *localtime(const time_t *timer); -#endif +#ifdef __cplusplus +} /* closing brace for extern "C" */ #endif + +#endif /* defined(_WIN32_WCE) && _WIN32_WCE >= 0x600 */ + +#endif /* !defined(__CE_TIME_H__) */ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri index 2330de1..ea6e5ab 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri @@ -59,7 +59,8 @@ win32-* { } wince* { - SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.cpp + INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/ce-compat + SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c DEFINES += WINCEBASIC } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h index 73212db..fa7a006 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h @@ -367,6 +367,10 @@ # endif #endif +#if PLATFORM(WINCE) && PLATFORM(QT) +# include +#endif + /* Compiler */ /* COMPILER(MSVC) */ diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index eb26664..8bd4225 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -61,7 +61,8 @@ win32-* { } wince* { - SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.cpp + INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/ce-compat + SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c DEFINES += WINCEBASIC } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 7632435..ddc287f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -372,6 +372,10 @@ # endif #endif +#if PLATFORM(WINCE) && PLATFORM(QT) +# include +#endif + /* Compiler */ /* COMPILER(MSVC) */ -- cgit v0.12 From 99f4379d397eacbdcffc40d6906175aa04d78456 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Nov 2009 12:20:54 +0100 Subject: Changelog: part 2 --- dist/changes-4.6.0 | 66 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index f457e63..e6f8f68 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -62,28 +62,11 @@ QtCore - QByteArray * New overloads for QByteArray::insert() and QByteArray::prepend() - - QObject - * [259514] fixed a possible dead-lock in the destructor - - - QVariant - * Many optimisations - * Added QVariant::toFloat() and QVariant::toReal() - * Added QVariant(float) constructor - * qvariant_cast and qVariantFromValue are now - identify functions - * Added support for math3d types. - - - Qt::escape - * now escape the double quote (") - - - QScopedPointer - * New pointer class for cleaning up objects when leaving the - current scope - - QFile * Make QFile::resize() more robust when operating on buffered files - QObject + * [259514] fixed a possible dead-lock in the destructor * Added the possibility to pass the flag Qt::UniqueConnection to QObject::connect * Fixed race conditions that occured when moving object to threads while connecting @@ -91,9 +74,17 @@ QtCore * Improved performance of plugin loading by reusing the plugin cache instead of loading it every time. + - QProcessEnvironment + * New class; support for easy access to key/value pairs in the + process environment + - QRegExp * New pattern syntax "QRegExp::WildcardUnix" with wildcard characters escaping + - QScopedPointer + * New pointer class for cleaning up objects when leaving the + current scope + - QSharedPointer * Added support for creating the object along the internal private data in one single memory allocation. (QSharedPointer::create) @@ -110,6 +101,14 @@ QtCore to STD3 to validate, thus preventing invalid hostnames from being accepted. See below in "Important Behavior Changes". + - QVariant + * Many optimisations + * Added QVariant::toFloat() and QVariant::toReal() + * Added QVariant(float) constructor + * qvariant_cast and qVariantFromValue are now + identify functions + * Added support for math3d types. + - QXmlStreamWriter * [256468] fix comment indentation @@ -118,6 +117,7 @@ QtCore attached to a QSharedPointer. * Added QWeakPointer::data which allows you to obtain the pointer being tracked (without protection). + * Added operator-> like the above data(), but requires a #define. - QUuid * [QTBUG-3543] Fixed a bug in createUuid() which caused multiple @@ -152,6 +152,9 @@ QtCore QtGui + - Qt::escape + * now escape the double quote (") + - QGraphicsAnchorLayout * Support for expanding size policy has been removed. (The Qt 4.6 Beta had support for it). @@ -340,13 +343,7 @@ QtGui - QApplication * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). -QtDBus - - - QDBusConnection - * Made sending of invalid/incomplete messages consistently fail - with error (no more assertions). - - - QPlainTextEdit + - QPlainTextEdit * Fixed crash when clicking on a text edit which was smaller than the height of the font used. @@ -385,6 +382,18 @@ QtDBus * [QTBUG-3555] Fixed a bug in the Plastique style that would cause an ASSERT failure in QFont when the application font has a pixel size set. +QtDBus + + - QDBusConnection + * Made sending of invalid/incomplete messages consistently fail + with error (no more assertions). + * [249528/QTBUG-3833] Added an overload of connect() that allows + one to specify strings for matching arguments. + + - QDBusServiceWatcher + * New class; supports efficiently watching for a service to be + created, deleted or change owners + QtNetwork - QAbstractSocket @@ -928,3 +937,10 @@ Qt for Windows CE Animation framework for animation. The hellogl and overpainting examples now compile on OpenGL/ES 1.1. Also common code is factored. +- qmake no longer adds Qt internal dependencies to the linker when Qt + is built in shared mode (not static). This means that applications + that made use of platform-specific API may need to adjust the LIBS + variable in their .pro files to match: + + X11: LIBS += -lX11 + Mac: LIBS += -framework AppKit -framework Carbon -- cgit v0.12 From 86048e1a09fce11f557d0e8b117229a754ee9098 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 Nov 2009 13:00:22 +0100 Subject: Designer: Use toolbar in Signal/Slot editor as in the other tool windows. Reviewed-by: Jarek Kobus Task-number: QTCREATORBUG-239 --- .../signalsloteditor/signalsloteditorwindow.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 7ab7cb4..e36e828 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -73,6 +73,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -724,20 +725,20 @@ SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *cor QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); - layout->addWidget(m_view); + layout->setSpacing(0); - QHBoxLayout *layout2 = new QHBoxLayout; - layout2->setMargin(3); - layout->addLayout(layout2); - layout2->addStretch(); + QToolBar *toolBar = new QToolBar; + toolBar->setIconSize(QSize(22, 22)); + m_add_button->setIcon(createIconSet(QLatin1String("plus.png"))); + connect(m_add_button, SIGNAL(clicked()), this, SLOT(addConnection())); + toolBar->addWidget(m_add_button); m_remove_button->setIcon(createIconSet(QLatin1String("minus.png"))); connect(m_remove_button, SIGNAL(clicked()), this, SLOT(removeConnection())); - layout2->addWidget(m_remove_button); + toolBar->addWidget(m_remove_button); - m_add_button->setIcon(createIconSet(QLatin1String("plus.png"))); - connect(m_add_button, SIGNAL(clicked()), this, SLOT(addConnection())); - layout2->addWidget(m_add_button); + layout->addWidget(toolBar); + layout->addWidget(m_view); connect(core->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), -- cgit v0.12 From 0e98dcbdd3b3324745aa84e073dcc3a269b3dde4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 10 Nov 2009 13:22:45 +0100 Subject: Doc: fix typo in link --- doc/src/platforms/supported-platforms.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index 302ecb4..232eca6 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -86,7 +86,7 @@ \row \o Apple Mac OS X 10.5 "Leopard" x86_64 (Carbon, Cocoa 32 and 64bit) \o As provided by Apple \row \o Embedded Linux QWS (ARM) - \o gcc (\l{http:\\www.codesourcery.com}{Codesourcery version)} + \o gcc (\l{http://www.codesourcery.com}{Codesourcery version)} \row \o Windows CE 5.0 (ARMv4i, x86, MIPS) \o MSVC 2005 WinCE 5.0 Standard (x86, pocket, smart, mipsii) \row \o Symbian (S60 3.1, 3.2 and 5.0) -- cgit v0.12 From 945e079e60506e88435802d0a764c8b4121ad16f Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 10 Nov 2009 12:47:44 +0100 Subject: BT: JavaScriptCore makes applications crash on leopard JavaScriptCore checks the Mac OS version when building, and uses symbols only defined in i e.g.snow leopard when building on snow leopard. This means that if you build Qt on snow leopard and later move it to leopard, applications will crash looking for a missing symbol (pthread_setname_np in particular). In Qt, we garuantee that you can run your applications on 10.4 and up for Carbon, and 10.5 and up for Cocoa. So using compile time checks this way is not a proper soulution. Result: In Qt, never use symbols not defined on all supported OS versions, or at least implement run-time checks. Rev-By: Simon Hausmann Rev-By: Tor Arne Rev-By: MortenS --- src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h | 2 +- src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h index fa7a006..2a407d4 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h @@ -565,7 +565,7 @@ #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIMEB_H 1 -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) && !PLATFORM(QT) #define HAVE_MADV_FREE_REUSE 1 #define HAVE_MADV_FREE 1 #define HAVE_PTHREAD_SETNAME_NP 1 diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index ddc287f..7bfde5b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -560,7 +560,7 @@ #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIMEB_H 1 -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) && !PLATFORM(QT) #define HAVE_MADV_FREE_REUSE 1 #define HAVE_MADV_FREE 1 #define HAVE_PTHREAD_SETNAME_NP 1 -- cgit v0.12 From 578a65013ac3b4203f2fa2d0bb50dd9119f613de Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 10 Nov 2009 13:35:21 +0100 Subject: Add my changes to the 4.6.0 changelog --- dist/changes-4.6.0 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index e6f8f68..70dcdf3 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -230,6 +230,9 @@ QtGui * Interactive resizing of top level windows now respects height-for-width constraints. * Reduced memory footprint. + - QAbstractItemView + * [256502] Fixes selectionModel::hasSelection return value after model::reset + - QHeaderView * [208320] Make sure the sort indicator s taken into account for the size hint * [255574] Make sure the sizehint for the section depend on visible sections @@ -276,6 +279,9 @@ QtGui to be slightly clipped. * [241383] Added ability to style the close tab button with style sheet + - QImageReader + * [255627] Fix floating point exception in QImageReader::setScaledSize(QSize(0, 0)) + - QComboBox * [220195] Fixed keyboard search when current index is -1 @@ -928,10 +934,11 @@ Qt for Windows CE * currentLoopTime() returns the time inside the current loop * stateChanged signal sends the new state as first parameter and old state as the second - * QAnimationGroup::clearAnimations() has been renames to clear() - * QAnimationGroup::insertAnimationAt() has been renames to insertAnimation() - * QAnimationGroup::takeAnimationAt() has been renames to takeAnimation() - * QSequentialAnimationGroup::insertPauseAt() has been renames to insertPause() + * QAnimationGroup::clearAnimations() has been renamed to clear() + * QAnimationGroup::insertAnimationAt() has been renamed to insertAnimation() + * QAnimationGroup::takeAnimationAt() has been renamed to takeAnimation() + * QSequentialAnimationGroup::insertPauseAt() has been renamed to insertPause() + * [QT-941] Avoids timer ticks when there are only pause animations running - Refactoring in OpenGL examples to improve portability and utilize the Animation framework for animation. The hellogl and overpainting examples -- cgit v0.12 From dc551cdc3422631baab50860c1a46711e3079f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 10 Nov 2009 13:04:54 +0100 Subject: Some 4.6.0 changes. --- dist/changes-4.6.0 | 58 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 70dcdf3..7666f69 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -350,23 +350,23 @@ QtGui * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). - QPlainTextEdit - * Fixed crash when clicking on a text edit which was smaller than the + * Fixed crash when clicking on a text edit which was smaller than the height of the font used. - - - QPrinter - * [QTBUG-4497] Removed redundant SetPen command in the postscript code + + - QPrinter + * [QTBUG-4497] Removed redundant SetPen command in the postscript code when reusing a QPrinter object. - QTextLayout * [QTBUG-4468] Count tabs as multiple characters when applying a fixed column width. - * [176401] Take into account the negative right bearing of the last + * [176401] Take into account the negative right bearing of the last character in an item of text if the glyph extends beyond its ascent. - + - QTextDocument - * [207189] Support setting font size using short hand syntax in the + * [207189] Support setting font size using short hand syntax in the CSS "font" property. - * [201228] Remove implicit margin on bullet lists when exporting to + * [201228] Remove implicit margin on bullet lists when exporting to HTML. * [240086] Fixed bug which caused floating objects which span several pages to float into the second page of the document even when it's @@ -375,13 +375,13 @@ QtGui * [240325] Even when wrap mode is set to Qt::TextWordWrap, the layout would sometimes break outside word boundaries when floating objects affected the width available to the text. This has been fixed. - - - QFontEngine - * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which + + - QFontEngine + * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which also contain a regular unicode table for exactly the symbol range of code points. - - - QFontMetrics + + - QFontMetrics * [176401] Account for right bearing in bounding rect. - QPlastiqueStyle @@ -400,6 +400,9 @@ QtDBus * New class; supports efficiently watching for a service to be created, deleted or change owners + - QPrintPreviewDialog now uses a QMainWindow with a proper QToolBar, instead + of a plain layout. + QtNetwork - QAbstractSocket @@ -472,6 +475,9 @@ QtOpenGL instered into the fragment "pipeline". * Fixed conical gradients. + - Added a static function, QGL::setPreferredPaintEngine(), to allow users + to set the preferred GL paint engine. + - Cleaned up usage of OpenGL extensions. QtOpenGL now uses the OpenGL 2.0 names of methods rather than using the EXT postfix. However, when resolving extensions, QtOpenGL will also try postfixing EXT if the OpenGL 2.0 name is @@ -516,7 +522,7 @@ QtSvg * [202426] Made attribute inheritance work with 'use' tags. * [250618] Fixed gradient on strokes. * [254040] Added support for 'vector-effect'. - + - QSvgPaintEngine * [257052] Changed drawImage() to ignore aspect ratio. @@ -576,19 +582,19 @@ Qt for Linux/X11 when using Synergy. - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. - - - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small - it was unreadable when printed or presented in a print preview widget. + + - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small + it was unreadable when printed or presented in a print preview widget. - Improved EGL integration on X11 (including better visual selection). - - Support Qt::WA_TranslucentBackground on top-level QGLWidgets on X11, both + - Support Qt::WA_TranslucentBackground on top-level QGLWidgets on X11, both (EGL & glX). This allows OpenGL (& ES) rendering to semi-transparent widgets if a compositing window manager is running. - Support OpenGL texture_from_pixmap extension on X11 (EGL & glX) when calling QPainter::drawPixmap() with the OpenGL paint engine, or calling - QGLContext::bindTexture() on an X11 QPixmap. If the + QGLContext::bindTexture() on an X11 QPixmap. If the GLX_EXT_texture_from_pixmap or EGL_NOKIA_texture_from_pixmap extensions are present, Qt will attempt to use glXBindTexImageEXT or eglBindTexImage to bind the pixmap to a texture, rather than copying the pixel data. @@ -651,12 +657,15 @@ Qt for Windows rendering. * Fixed a flicker issue when switching source with a transition time of 0 - - [QTBUG-4445] Fixed bug on Windows that caused problems when printing - text where several characters were represented by a single glyph, e.g. + - [QTBUG-4445] Fixed bug on Windows that caused problems when printing + text where several characters were represented by a single glyph, e.g. a double 't' with the Calibri font. - + - Added QSysInfo::WV_WINDOWS7 and QSysInfo::WV_6_1 + - Changed QPrintDialog under Windows to use PrintDlgEx, instead of the old + deprecated PrintDlg call. + Qt for Mac OS X --------------- @@ -667,6 +676,8 @@ Qt for Mac OS X - [258438] Enabled Emacs style keyboard shortcuts. - [258173] Fixed an issue which caused "whatsthis" pointer to flicked on Cocoa. - [QTBUG-4418] Fixed maximizing and restoring a window on Mac. + - Fixed some warnings that might get printed when reparenting QGLWidget on Cocoa. + General changes on Mac OS X: - Mac OS X version support: Support for 10.3(Panther) has been dropped, support for @@ -753,7 +764,8 @@ Qt for Windows CE - [257352] When configuring Qt for Windows CE, configure points the user to setcepaths, when its done. - [259850] Added a makespec template for Windows CE 6. - + - Fixed the hardcoded GL library names for Windows CE. + **************************************************************************** * Tools * **************************************************************************** -- cgit v0.12 From 637d6b26d778189a767e28b80aa316cf327e67a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 10 Nov 2009 13:35:42 +0100 Subject: Improvements to graphics effects API after review round. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Get rid of QGraphicsEffectSource from the public API, instead add convenience functions in QGraphicsEffect. This way we commit to less API, and are free to introduce a customizable QGraphicsEffectSource in a future release. * Move PixmapPadMode into QGraphicsEffect and tweak the names of the enum values. * Make QGraphicsBlurEffect::BlurHint into a bit flag, for extensibility. Reviewed-by: Bjørn Erik Nilsen --- .../code/src_gui_effects_qgraphicseffect.cpp | 12 +- examples/effects/blurpicker/blureffect.cpp | 4 +- examples/effects/blurpicker/blureffect.h | 2 +- examples/effects/customshader/blureffect.cpp | 4 +- examples/effects/customshader/blureffect.h | 2 +- src/gui/effects/qgraphicseffect.cpp | 233 +++++++++++++-------- src/gui/effects/qgraphicseffect.h | 90 ++++---- src/gui/effects/qgraphicseffect_p.h | 41 +++- src/gui/graphicsview/qgraphicsitem.cpp | 6 +- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- src/gui/image/qpixmapfilter.cpp | 22 +- src/gui/image/qpixmapfilter_p.h | 4 +- src/gui/kernel/qwidget.cpp | 10 +- src/gui/kernel/qwidget_p.h | 2 +- src/opengl/qglpixmapfilter.cpp | 46 ++-- src/opengl/qgraphicsshadereffect.cpp | 10 +- src/opengl/qgraphicsshadereffect_p.h | 2 +- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 9 +- 19 files changed, 286 insertions(+), 217 deletions(-) diff --git a/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp index 35689f4..5ef6609 100644 --- a/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp +++ b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp @@ -40,11 +40,11 @@ ****************************************************************************/ //! [0] -MyGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +MyGraphicsOpacityEffect::draw(QPainter *painter) { // Fully opaque; draw directly without going through a pixmap. if (qFuzzyCompare(m_opacity, 1)) { - source->draw(painter); + drawSource(painter); return; } ... @@ -52,18 +52,18 @@ MyGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) //! [0] //! [1] -MyGraphicsEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +MyGraphicsEffect::draw(QPainter *painter) { ... QPoint offset; - if (source->isPixmap()) { + if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); ... painter->drawPixmap(offset, pixmap); } else { // Draw pixmap in device coordinates to avoid pixmap scaling; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); painter->setWorldTransform(QTransform()); ... painter->drawPixmap(offset, pixmap); diff --git a/examples/effects/blurpicker/blureffect.cpp b/examples/effects/blurpicker/blureffect.cpp index 9046cbd..956637d 100644 --- a/examples/effects/blurpicker/blureffect.cpp +++ b/examples/effects/blurpicker/blureffect.cpp @@ -62,8 +62,8 @@ QRectF BlurEffect::boundingRect() const return QGraphicsBlurEffect::boundingRect(); } -void BlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void BlurEffect::draw(QPainter *painter) { adjustForItem(); - QGraphicsBlurEffect::draw(painter, source); + QGraphicsBlurEffect::draw(painter); } diff --git a/examples/effects/blurpicker/blureffect.h b/examples/effects/blurpicker/blureffect.h index 6cfa55a..3d1d433 100644 --- a/examples/effects/blurpicker/blureffect.h +++ b/examples/effects/blurpicker/blureffect.h @@ -54,7 +54,7 @@ public: QRectF boundingRect() const; - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: void adjustForItem(); diff --git a/examples/effects/customshader/blureffect.cpp b/examples/effects/customshader/blureffect.cpp index 9046cbd..956637d 100644 --- a/examples/effects/customshader/blureffect.cpp +++ b/examples/effects/customshader/blureffect.cpp @@ -62,8 +62,8 @@ QRectF BlurEffect::boundingRect() const return QGraphicsBlurEffect::boundingRect(); } -void BlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void BlurEffect::draw(QPainter *painter) { adjustForItem(); - QGraphicsBlurEffect::draw(painter, source); + QGraphicsBlurEffect::draw(painter); } diff --git a/examples/effects/customshader/blureffect.h b/examples/effects/customshader/blureffect.h index 6cfa55a..3d1d433 100644 --- a/examples/effects/customshader/blureffect.h +++ b/examples/effects/customshader/blureffect.h @@ -54,7 +54,7 @@ public: QRectF boundingRect() const; - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: void adjustForItem(); diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 568ff73..13f42c5 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -76,24 +76,21 @@ To create your own custom effect, create a subclass of QGraphicsEffect (or any other existing effects) and reimplement the virtual function draw(). This function is called whenever the effect needs to redraw. The draw() - function accepts two arguments: the painter and a pointer to the source - (QGraphicsEffectSource). The source provides extra context information, - such as a pointer to the item that is rendering the effect, any cached - pixmap data, or the device rectangle bounds. For more information, refer to - the documenation for draw(). To obtain a pointer to the current source, - simply call source(). + function takes the painter with which to draw as an argument. For more + information, refer to the documenation for draw(). In the draw() function + you can call sourcePixmap() to get a pixmap of the graphics effect source + which you can then process. If your effect changes, use update() to request for a redraw. If your custom effect changes the bounding rectangle of the source, e.g., a radial glow effect may need to apply an extra margin, you can reimplement the - virtual boundingRectFor() function, and call updateBoundingRect() to notify - the framework whenever this rectangle changes. The virtual - sourceBoundingRectChanged() function is called to notify the effects that - the source's bounding rectangle has changed - e.g., if the source is a + virtual boundingRectFor() function, and call updateBoundingRect() + to notify the framework whenever this rectangle changes. The virtual + sourceChanged() function is called to notify the effects that + the source has changed in some way - e.g., if the source is a QGraphicsRectItem and its rectangle parameters have changed. - \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect(), - QGraphicsEffectSource + \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() */ #include "qgraphicseffect_p.h" @@ -112,10 +109,10 @@ QT_BEGIN_NAMESPACE /*! + \internal \class QGraphicsEffectSource \brief The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on. - \since 4.6 When a QGraphicsEffect is installed on a QGraphicsItem, for example, this class will act as a wrapper around QGraphicsItem. Then, calling update() is @@ -154,20 +151,13 @@ QGraphicsEffectSource::~QGraphicsEffectSource() {} /*! - Returns the bounds of the current painter's device. - - This function is useful when you want to draw something in device - coordinates and ensure the size of the pixmap is not bigger than the size - of the device. - - Calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns - a pixmap which is bound to the device's size. + Returns the bounding rectangle of the source mapped to the given \a system. - \sa pixmap() + \sa draw() */ -QRect QGraphicsEffectSource::deviceRect() const +QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const { - return d_func()->deviceRect(); + return d_func()->boundingRect(system); } /*! @@ -175,9 +165,12 @@ QRect QGraphicsEffectSource::deviceRect() const \sa draw() */ -QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const +QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const { - return d_func()->boundingRect(system); + Q_D(const QGraphicsEffect); + if (d->source) + return d->source->boundingRect(system); + return QRectF(); } /*! @@ -218,10 +211,6 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const This function should only be called from QGraphicsEffect::draw(). - For example: - - \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0 - \sa QGraphicsEffect::draw() */ void QGraphicsEffectSource::draw(QPainter *painter) @@ -246,6 +235,24 @@ void QGraphicsEffectSource::draw(QPainter *painter) } /*! + Draws the source directly using the given \a painter. + + This function should only be called from QGraphicsEffect::draw(). + + For example: + + \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0 + + \sa QGraphicsEffect::draw() +*/ +void QGraphicsEffect::drawSource(QPainter *painter) +{ + Q_D(const QGraphicsEffect); + if (d->source) + d->source->draw(painter); +} + +/*! Schedules a redraw of the source. Call this function whenever the source needs to be redrawn. @@ -271,6 +278,19 @@ bool QGraphicsEffectSource::isPixmap() const } /*! + Returns true if the source effectively is a pixmap, e.g., a + QGraphicsPixmapItem. + + This function is useful for optimization purposes. For instance, there's no + point in drawing the source in device coordinates to avoid pixmap scaling + if this function returns true - the source pixmap will be scaled anyways. +*/ +bool QGraphicsEffect::sourceIsPixmap() const +{ + return source() ? source()->isPixmap() : false; +} + +/*! Returns a pixmap with the source painted into it. The \a system specifies which coordinate system to be used for the source. @@ -283,15 +303,15 @@ bool QGraphicsEffectSource::isPixmap() const The returned pixmap is bound to the current painter's device rectangle when \a system is Qt::DeviceCoordinates. - \sa QGraphicsEffect::draw(), boundingRect(), deviceRect() + \sa QGraphicsEffect::draw(), boundingRect() */ -QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, PixmapPadMode mode) const +QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const { Q_D(const QGraphicsEffectSource); // Shortcut, no cache for childless pixmap items... const QGraphicsItem *item = graphicsItem(); - if (system == Qt::LogicalCoordinates && mode == NoExpandPadMode && item && isPixmap()) { + if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) { return ((QGraphicsPixmapItem *) item)->pixmap(); } @@ -320,6 +340,27 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse return pm; } +/*! + Returns a pixmap with the source painted into it. + + The \a system specifies which coordinate system to be used for the source. + The optional \a offset parameter returns the offset where the pixmap should + be painted at using the current painter. For control on how the pixmap is + padded use the \a mode parameter. + + The returned pixmap is clipped to the current painter's device rectangle when + \a system is Qt::DeviceCoordinates. + + \sa draw(), boundingRect() +*/ +QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const +{ + Q_D(const QGraphicsEffect); + if (d->source) + return d->source->pixmap(system, offset, mode); + return QPixmap(); +} + QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() { invalidateCache(); @@ -327,7 +368,7 @@ QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() void QGraphicsEffectSourcePrivate::invalidateCache(bool effectRectChanged) const { - if (effectRectChanged && m_cachedMode != QGraphicsEffectSource::ExpandToEffectRectPadMode) + if (effectRectChanged && m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect) return; QPixmapCache::remove(m_cacheKey); } @@ -359,9 +400,9 @@ QGraphicsEffect::~QGraphicsEffect() } /*! - Returns the bounding rectangle for this effect, i.e., the bounding - rectangle of the source, adjusted by any margins applied by the effect - itself. + Returns the effective bounding rectangle for this effect, i.e., the + bounding rectangle of the source, adjusted by any margins applied by + the effect itself. \sa boundingRectFor(), updateBoundingRect() */ @@ -374,12 +415,13 @@ QRectF QGraphicsEffect::boundingRect() const } /*! - Returns the bounding rectangle for this effect, given the provided source - \a rect. When writing you own custom effect, you must call - updateBoundingRect() whenever any parameters are changed that may cause - this this function to return a different value. + Returns the effective bounding rectangle for this effect, given the + provided \a rect in the source's coordinate space. When writing + you own custom effect, you must call updateBoundingRect() whenever any + parameters are changed that may cause this this function to return a + different value. - \sa boundingRect() + \sa sourceBoundingRect() */ QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const { @@ -445,6 +487,8 @@ void QGraphicsEffect::update() } /*! + \internal + Returns a pointer to the source, which provides extra context information that can be useful for the effect. @@ -464,7 +508,7 @@ QGraphicsEffectSource *QGraphicsEffect::source() const This function will call update() if this is necessary. - \sa boundingRectFor(), boundingRect() + \sa boundingRectFor(), boundingRect(), sourceBoundingRect() */ void QGraphicsEffect::updateBoundingRect() { @@ -476,15 +520,13 @@ void QGraphicsEffect::updateBoundingRect() } /*! - \fn virtual void QGraphicsEffect::draw(QPainter *painter, - QGraphicsEffectSource *source) = 0 + \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0 This pure virtual function draws the effect and is called whenever the - source() needs to be drawn. + source needs to be drawn. Reimplement this function in a QGraphicsEffect subclass to provide the - effect's drawing implementation, using \a painter. The \a source parameter - is provided for convenience; its value is the same as source(). + effect's drawing implementation, using \a painter. For example: @@ -492,8 +534,6 @@ void QGraphicsEffect::updateBoundingRect() This function should not be called explicitly by the user, since it is meant for reimplementation purposes only. - - \sa QGraphicsEffectSource */ /*! @@ -509,6 +549,20 @@ void QGraphicsEffect::updateBoundingRect() */ /*! + \enum QGraphicsEffect::PixmapPadMode + + This enum describes how the pixmap returned from sourcePixmap should be + padded. + + \value NoPad The pixmap should not receive any additional + padding. + \value PadToTransparentBorder The pixmap should be padded + to ensure it has a completely transparent border. + \value PadToEffectiveBoundingRect The pixmap should be padded to + match the effective bounding rectangle of the effect. +*/ + +/*! This virtual function is called by QGraphicsEffect to notify the effect that the source has changed. If the effect applies any cache, then this cache must be purged in order to reflect the new appearance of the source. @@ -615,26 +669,25 @@ void QGraphicsColorizeEffect::setStrength(qreal strength) /*! \reimp */ -void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsColorizeEffect::draw(QPainter *painter) { Q_D(QGraphicsColorizeEffect); if (!d->opaque) { - source->draw(painter); + drawSource(painter); return; } QPoint offset; - if (source->isPixmap()) { + if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset, - QGraphicsEffectSource::NoExpandPadMode); + const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); d->filter->draw(painter, offset, pixmap); return; } // Draw pixmap in deviceCoordinates to avoid pixmap scaling. - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -649,7 +702,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou A blur effect blurs the source. This effect is useful for reducing details, such as when the source loses focus and you want to draw attention to other elements. The level of detail can be modified using the setBlurRadius() - function. Use setBlurHint() to choose the quality or performance blur hints. + function. Use setBlurHints() to choose the blur hints. By default, the blur radius is 5 pixels. @@ -666,15 +719,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou blur effects are applied. The hints might not have an effect in all the paint engines. - \value QualityHint Indicates that rendering quality is the most important factor, - at the potential cost of lower performance. - \value PerformanceHint Indicates that rendering performance is the most important factor, at the potential cost of lower quality. + \value QualityHint Indicates that rendering quality is the most important factor, + at the potential cost of lower performance. + \value AnimationHint Indicates that the blur radius is going to be animated, hinting - that the implementation can keep a cache of blurred verisons of the source pixmap. - Do not use this hint if the source item is going to be dynamically changing. + that the implementation can keep a cache of blurred verisons of the source. + Do not use this hint if the source is going to be dynamically changing. + + \sa blurHints(), setBlurHints() */ @@ -686,7 +741,7 @@ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) { Q_D(QGraphicsBlurEffect); - d->filter->setBlurHint(QGraphicsBlurEffect::PerformanceHint); + d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint); } /*! @@ -730,7 +785,7 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius) */ /*! - \property QGraphicsBlurEffect::blurHint + \property QGraphicsBlurEffect::blurHints \brief the blur hint of the effect. Use the PerformanceHint hint to say that you want a faster blur, @@ -739,27 +794,27 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius) By default, the blur hint is PerformanceHint. */ -QGraphicsBlurEffect::BlurHint QGraphicsBlurEffect::blurHint() const +QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const { Q_D(const QGraphicsBlurEffect); - return d->filter->blurHint(); + return d->filter->blurHints(); } -void QGraphicsBlurEffect::setBlurHint(QGraphicsBlurEffect::BlurHint hint) +void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints) { Q_D(QGraphicsBlurEffect); - if (d->filter->blurHint() == hint) + if (d->filter->blurHints() == hints) return; - d->filter->setBlurHint(hint); - emit blurHintChanged(hint); + d->filter->setBlurHints(hints); + emit blurHintsChanged(hints); } /*! - \fn void QGraphicsBlurEffect::blurHintChanged(QGraphicsBlurEffect::BlurHint hint) + \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints) - This signal is emitted whenever the effect's blur hint changes. - The \a hint parameter holds the effect's new blur hint. + This signal is emitted whenever the effect's blur hints changes. + The \a hints parameter holds the effect's new blur hints. */ /*! @@ -774,21 +829,21 @@ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const /*! \reimp */ -void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsBlurEffect::draw(QPainter *painter) { Q_D(QGraphicsBlurEffect); if (d->filter->radius() <= 0) { - source->draw(painter); + drawSource(painter); return; } - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + PixmapPadMode mode = PadToEffectiveBoundingRect; if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + mode = PadToTransparentBorder; // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -963,21 +1018,21 @@ QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const /*! \reimp */ -void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsDropShadowEffect::draw(QPainter *painter) { Q_D(QGraphicsDropShadowEffect); if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) { - source->draw(painter); + drawSource(painter); return; } - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode; + PixmapPadMode mode = PadToEffectiveBoundingRect; if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode; + mode = PadToTransparentBorder; // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -1100,7 +1155,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) /*! \reimp */ -void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsOpacityEffect::draw(QPainter *painter) { Q_D(QGraphicsOpacityEffect); @@ -1110,18 +1165,16 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour // Opaque; draw directly without going through a pixmap. if (d->isFullyOpaque && !d->hasOpacityMask) { - source->draw(painter); + drawSource(painter); return; } - QPoint offset; - Qt::CoordinateSystem system = source->isPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; - QPixmap pixmap = source->pixmap(system, &offset, QGraphicsEffectSource::NoExpandPadMode); + Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; + QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad); if (pixmap.isNull()) return; - painter->save(); painter->setOpacity(d->opacity); @@ -1133,7 +1186,7 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour QTransform worldTransform = painter->worldTransform(); worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y()); pixmapPainter.setWorldTransform(worldTransform); - pixmapPainter.fillRect(source->boundingRect(), d->opacityMask); + pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask); } else { pixmapPainter.translate(-offset); pixmapPainter.fillRect(pixmap.rect(), d->opacityMask); diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 5c73f4b..2257f01 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -60,46 +60,7 @@ class QStyleOption; class QPainter; class QPixmap; -class QGraphicsEffectSourcePrivate; -class Q_GUI_EXPORT QGraphicsEffectSource : public QObject -{ - Q_OBJECT -public: - enum PixmapPadMode { - NoExpandPadMode, - ExpandToTransparentBorderPadMode, - ExpandToEffectRectPadMode - }; - - ~QGraphicsEffectSource(); - const QGraphicsItem *graphicsItem() const; - const QWidget *widget() const; - const QStyleOption *styleOption() const; - - bool isPixmap() const; - void draw(QPainter *painter); - void update(); - - QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; - QRect deviceRect() const; - QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, - QPoint *offset = 0, - PixmapPadMode mode = ExpandToEffectRectPadMode) const; - -protected: - QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); - -private: - Q_DECLARE_PRIVATE(QGraphicsEffectSource) - Q_DISABLE_COPY(QGraphicsEffectSource) - friend class QGraphicsEffect; - friend class QGraphicsEffectPrivate; - friend class QGraphicsScenePrivate; - friend class QGraphicsItem; - friend class QGraphicsItemPrivate; - friend class QWidget; - friend class QWidgetPrivate; -}; +class QGraphicsEffectSource; class QGraphicsEffectPrivate; class Q_GUI_EXPORT QGraphicsEffect : public QObject @@ -116,14 +77,18 @@ public: }; Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) + enum PixmapPadMode { + NoPad, + PadToTransparentBorder, + PadToEffectiveBoundingRect + }; + QGraphicsEffect(QObject *parent = 0); virtual ~QGraphicsEffect(); - virtual QRectF boundingRectFor(const QRectF &rect) const; + virtual QRectF boundingRectFor(const QRectF &sourceRect) const; QRectF boundingRect() const; - QGraphicsEffectSource *source() const; - bool isEnabled() const; public Q_SLOTS: @@ -135,10 +100,17 @@ Q_SIGNALS: protected: QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0); - virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0; + virtual void draw(QPainter *painter) = 0; virtual void sourceChanged(ChangeFlags flags); void updateBoundingRect(); + bool sourceIsPixmap() const; + QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const; + void drawSource(QPainter *painter); + QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, + QPoint *offset = 0, + PixmapPadMode mode = PadToEffectiveBoundingRect) const; + private: Q_DECLARE_PRIVATE(QGraphicsEffect) Q_DISABLE_COPY(QGraphicsEffect) @@ -147,6 +119,10 @@ private: friend class QGraphicsScenePrivate; friend class QWidget; friend class QWidgetPrivate; + +public: + QGraphicsEffectSource *source() const; // internal + }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) @@ -172,7 +148,7 @@ Q_SIGNALS: void strengthChanged(qreal strength); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsColorizeEffect) @@ -183,38 +159,42 @@ class QGraphicsBlurEffectPrivate; class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT + Q_FLAGS(BlurHint BlurHints) Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) - Q_PROPERTY(BlurHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) + Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged) public: enum BlurHint { - QualityHint, - PerformanceHint, - AnimationHint + PerformanceHint = 0x00, + QualityHint = 0x01, + AnimationHint = 0x02 }; + Q_DECLARE_FLAGS(BlurHints, BlurHint) QGraphicsBlurEffect(QObject *parent = 0); ~QGraphicsBlurEffect(); QRectF boundingRectFor(const QRectF &rect) const; qreal blurRadius() const; - BlurHint blurHint() const; + BlurHints blurHints() const; public Q_SLOTS: void setBlurRadius(qreal blurRadius); - void setBlurHint(BlurHint hint); + void setBlurHints(BlurHints hints); Q_SIGNALS: void blurRadiusChanged(qreal blurRadius); - void blurHintChanged(BlurHint hint); + void blurHintsChanged(BlurHints hints); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsBlurEffect) Q_DISABLE_COPY(QGraphicsBlurEffect) }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints) + class QGraphicsDropShadowEffectPrivate; class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect { @@ -264,7 +244,7 @@ Q_SIGNALS: void colorChanged(const QColor &color); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect) @@ -293,7 +273,7 @@ Q_SIGNALS: void opacityMaskChanged(const QBrush &mask); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); private: Q_DECLARE_PRIVATE(QGraphicsOpacityEffect) diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index d94d08d..c67052e 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -63,6 +63,41 @@ #ifndef QT_NO_GRAPHICSEFFECT QT_BEGIN_NAMESPACE +class QGraphicsEffectSourcePrivate; +class Q_AUTOTEST_EXPORT QGraphicsEffectSource : public QObject +{ + Q_OBJECT +public: + ~QGraphicsEffectSource(); + const QGraphicsItem *graphicsItem() const; + const QWidget *widget() const; + const QStyleOption *styleOption() const; + + bool isPixmap() const; + void draw(QPainter *painter); + void update(); + + QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; + QRect deviceRect() const; + QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, + QPoint *offset = 0, + QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const; + +protected: + QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); + +private: + Q_DECLARE_PRIVATE(QGraphicsEffectSource) + Q_DISABLE_COPY(QGraphicsEffectSource) + friend class QGraphicsEffect; + friend class QGraphicsEffectPrivate; + friend class QGraphicsScenePrivate; + friend class QGraphicsItem; + friend class QGraphicsItemPrivate; + friend class QWidget; + friend class QWidgetPrivate; +}; + class QGraphicsEffectSourcePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsEffectSource) @@ -70,7 +105,7 @@ public: QGraphicsEffectSourcePrivate() : QObjectPrivate() , m_cachedSystem(Qt::DeviceCoordinates) - , m_cachedMode(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + , m_cachedMode(QGraphicsEffect::PadToTransparentBorder) {} virtual ~QGraphicsEffectSourcePrivate(); @@ -84,7 +119,7 @@ public: virtual void update() = 0; virtual bool isPixmap() const = 0; virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, - QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0; + QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0; virtual void effectBoundingRectChanged() = 0; void invalidateCache(bool effectRectChanged = false) const; @@ -94,7 +129,7 @@ public: private: mutable Qt::CoordinateSystem m_cachedSystem; - mutable QGraphicsEffectSource::PixmapPadMode m_cachedMode; + mutable QGraphicsEffect::PixmapPadMode m_cachedMode; mutable QPoint m_cachedOffset; mutable QPixmapCache::Key m_cacheKey; }; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 723e496..9d495e9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10812,7 +10812,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) } QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const + QGraphicsEffect::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!info && deviceCoordinates) { @@ -10828,9 +10828,9 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP const QRectF sourceRect = boundingRect(system); QRect effectRect; - if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + } else if (mode == QGraphicsEffect::PadToTransparentBorder) { // adjust by 1.5 to account for cosmetic pens effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect(); } else { diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index afc2198..75c8246 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -633,7 +633,7 @@ public: void draw(QPainter *); QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const; + QGraphicsEffect::PixmapPadMode mode) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 2748ab6..13f31b8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4656,7 +4656,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * sourced->lastEffectTransform = painter->worldTransform(); sourced->invalidateCache(); } - item->d_ptr->graphicsEffect->draw(painter, source); + item->d_ptr->graphicsEffect->draw(painter); painter->setWorldTransform(restoreTransform); sourced->info = 0; } else diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index d83ef2c..c0b840a 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -490,7 +490,7 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q which is applied when \l{QPixmapFilter::}{draw()} is called. The filter lets you specialize the radius of the blur as well - as hint as to whether to prefer performance or quality. + as hints as to whether to prefer performance or quality. By default, the blur effect is produced by applying an exponential filter generated from the specified blurRadius(). Paint engines @@ -505,10 +505,10 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate { public: - QPixmapBlurFilterPrivate() : radius(5), hint(QGraphicsBlurEffect::PerformanceHint) {} + QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {} qreal radius; - QGraphicsBlurEffect::BlurHint hint; + QGraphicsBlurEffect::BlurHints hints; }; @@ -554,9 +554,9 @@ qreal QPixmapBlurFilter::radius() const } /*! - Setting the blur hint to PerformanceHint causes the implementation + Setting the blur hints to PerformanceHint causes the implementation to trade off visual quality to blur the image faster. Setting the - blur hint to QualityHint causes the implementation to improve + blur hints to QualityHint causes the implementation to improve visual quality at the expense of speed. AnimationHint causes the implementation to optimize for animating @@ -568,21 +568,21 @@ qreal QPixmapBlurFilter::radius() const \internal */ -void QPixmapBlurFilter::setBlurHint(QGraphicsBlurEffect::BlurHint hint) +void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints) { Q_D(QPixmapBlurFilter); - d->hint = hint; + d->hints = hints; } /*! - Gets the blur hint of the blur filter. + Gets the blur hints of the blur filter. \internal */ -QGraphicsBlurEffect::BlurHint QPixmapBlurFilter::blurHint() const +QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const { Q_D(const QPixmapBlurFilter); - return d->hint; + return d->hints; } /*! @@ -685,7 +685,7 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap QPixmapBlurFilter *blurFilter = static_cast(filter); if (blurFilter) { blurFilter->setRadius(d->radius); - blurFilter->setBlurHint(d->hint); + blurFilter->setBlurHints(d->hints); blurFilter->draw(painter, p, src, srcRect); return; } diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h index 2573fc7..46e744e 100644 --- a/src/gui/image/qpixmapfilter_p.h +++ b/src/gui/image/qpixmapfilter_p.h @@ -132,10 +132,10 @@ public: ~QPixmapBlurFilter(); void setRadius(qreal radius); - void setBlurHint(QGraphicsBlurEffect::BlurHint hint); + void setBlurHints(QGraphicsBlurEffect::BlurHints hints); qreal radius() const; - QGraphicsBlurEffect::BlurHint blurHint() const; + QGraphicsBlurEffect::BlurHints blurHints() const; QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index f856b13..e764774 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5238,7 +5238,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QPainter p(pdev); p.translate(offset); context.painter = &p; - graphicsEffect->draw(&p, source); + graphicsEffect->draw(&p); paintEngine->d_func()->systemClip = QRegion(); } else { context.painter = sharedPainter; @@ -5248,7 +5248,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } sharedPainter->save(); sharedPainter->translate(offset); - graphicsEffect->draw(sharedPainter, source); + graphicsEffect->draw(sharedPainter); sharedPainter->restore(); } sourced->context = 0; @@ -5470,7 +5470,7 @@ void QWidgetEffectSourcePrivate::draw(QPainter *painter) } QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const + QGraphicsEffect::PixmapPadMode mode) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); if (!context && deviceCoordinates) { @@ -5491,10 +5491,10 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * QRect effectRect; - if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) { + } else if (mode == QGraphicsEffect::PadToTransparentBorder) { effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); } else { diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 151b90a..df28bac 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -824,7 +824,7 @@ public: QRectF boundingRect(Qt::CoordinateSystem system) const; void draw(QPainter *p); QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, - QGraphicsEffectSource::PixmapPadMode mode) const; + QGraphicsEffect::PixmapPadMode mode) const; QWidget *m_widget; QWidgetPaintContext *context; diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 0eaab28..fcb0ea2 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -102,7 +102,7 @@ private: class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter { public: - QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint); + QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHints hints); void setUniforms(QGLShaderProgram *program); @@ -123,13 +123,13 @@ private: mutable bool m_haveCached; mutable int m_cachedRadius; - mutable QGraphicsBlurEffect::BlurHint m_hint; + mutable QGraphicsBlurEffect::BlurHints m_hints; }; class QGLPixmapDropShadowFilter : public QGLCustomShaderStage, public QGLPixmapFilter { public: - QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint); + QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHints hints); void setUniforms(QGLShaderProgram *program); @@ -143,7 +143,7 @@ private: mutable bool m_haveCached; mutable int m_cachedRadius; - mutable QGraphicsBlurEffect::BlurHint m_hint; + mutable QGraphicsBlurEffect::BlurHints m_hints; }; extern QGLWidget *qt_gl_share_widget(); @@ -159,19 +159,19 @@ QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *pr case QPixmapFilter::BlurFilter: { const QPixmapBlurFilter *proto = static_cast(prototype); - if (proto->blurHint() == QGraphicsBlurEffect::AnimationHint) { + if (proto->blurHints() & QGraphicsBlurEffect::AnimationHint) { if (!d->animationBlurFilter) - d->animationBlurFilter.reset(new QGLPixmapBlurFilter(proto->blurHint())); + d->animationBlurFilter.reset(new QGLPixmapBlurFilter(proto->blurHints())); return d->animationBlurFilter.data(); } - if (proto->blurHint() == QGraphicsBlurEffect::PerformanceHint || proto->radius() <= 5) { - if (!d->fastBlurFilter) - d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint)); - return d->fastBlurFilter.data(); + if ((proto->blurHints() & QGraphicsBlurEffect::QualityHint) && proto->radius() > 5) { + if (!d->blurFilter) + d->blurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::QualityHint)); + return d->blurFilter.data(); } - if (!d->blurFilter) - d->blurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::QualityHint)); - return d->blurFilter.data(); + if (!d->fastBlurFilter) + d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint)); + return d->fastBlurFilter.data(); } case QPixmapFilter::DropShadowFilter: { @@ -316,11 +316,11 @@ static const char *qt_gl_texture_sampling_helper = " return texture2D(src, srcCoords).a;\n" "}\n"; -QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint) +QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHints hints) : m_animatedBlur(false) , m_haveCached(false) , m_cachedRadius(0) - , m_hint(hint) + , m_hints(hints) { } @@ -503,7 +503,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QGLContext *ctx = const_cast(QGLContext::currentContext()); QGLBlurTextureCache *blurTextureCache = QGLBlurTextureCache::cacheForContext(ctx); - if (m_hint == QGraphicsBlurEffect::AnimationHint && blurTextureCache->fitsInCache(src)) { + if ((m_hints & QGraphicsBlurEffect::AnimationHint) && blurTextureCache->fitsInCache(src)) { QRect targetRect = src.rect().adjusted(-qMaxCachedBlurLevel, -qMaxCachedBlurLevel, qMaxCachedBlurLevel, qMaxCachedBlurLevel); // ensure even dimensions (going to divide by two) targetRect.setWidth((targetRect.width() + 1) & ~1); @@ -514,7 +514,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const info = blurTextureCache->takeBlurTextureInfo(src); } else { m_animatedBlur = false; - m_hint = QGraphicsBlurEffect::QualityHint; + m_hints = QGraphicsBlurEffect::QualityHint; m_singlePass = false; QGLFramebufferObjectFormat format; @@ -594,7 +594,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const if (!m_haveCached || !m_animatedBlur) { m_haveCached = true; m_animatedBlur = true; - m_hint = QGraphicsBlurEffect::AnimationHint; + m_hints = QGraphicsBlurEffect::AnimationHint; filter->setSource(qt_gl_interpolate_filter); } @@ -653,7 +653,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const int actualRadius = qRound(radius()); int filterRadius = actualRadius; int fastRadii[] = { 1, 2, 3, 5, 8, 15, 25 }; - if (m_hint != QGraphicsBlurEffect::QualityHint) { + if (!(m_hints & QGraphicsBlurEffect::QualityHint)) { uint i = 0; for (; i < (sizeof(fastRadii)/sizeof(*fastRadii))-1; ++i) { if (fastRadii[i+1] > filterRadius) @@ -762,7 +762,7 @@ void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program) return; } - if (m_hint == QGraphicsBlurEffect::QualityHint) { + if (m_hints & QGraphicsBlurEffect::QualityHint) { if (m_singlePass) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); else if (m_horizontalBlur) @@ -912,10 +912,10 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool singlePa return source; } -QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint) +QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHints hints) : m_haveCached(false) , m_cachedRadius(0) - , m_hint(hint) + , m_hints(hints) { } @@ -1018,7 +1018,7 @@ void QGLPixmapDropShadowFilter::setUniforms(QGLShaderProgram *program) alpha); } - if (m_hint == QGraphicsBlurEffect::QualityHint) { + if (m_hints & QGraphicsBlurEffect::QualityHint) { if (m_singlePass) program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height()); else if (m_horizontalBlur) diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index 1c02fd0..4d7a69c 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -241,7 +241,7 @@ void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) /*# \reimp */ -void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +void QGraphicsShaderEffect::draw(QPainter *painter) { Q_D(QGraphicsShaderEffect); @@ -256,13 +256,13 @@ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *sourc bool usingShader = d->customShaderStage->setOnPainter(painter); QPoint offset; - if (source->isPixmap()) { + if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); painter->drawPixmap(offset, pixmap); } else { // Draw pixmap in device coordinates to avoid pixmap scaling. - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); painter->drawPixmap(offset, pixmap); @@ -273,7 +273,7 @@ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *sourc if (usingShader) d->customShaderStage->removeFromPainter(painter); #else - source->draw(painter); + drawSource(painter); #endif } diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h index de7f00c..de65ebb 100644 --- a/src/opengl/qgraphicsshadereffect_p.h +++ b/src/opengl/qgraphicsshadereffect_p.h @@ -76,7 +76,7 @@ public: void setPixelShaderFragment(const QByteArray& code); protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); + void draw(QPainter *painter); void setUniformsDirty(); virtual void setUniforms(QGLShaderProgram *program); diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index b40cf43..d216924 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -49,6 +49,7 @@ #include #include "../../shared/util.h" +#include //TESTED_CLASS= //TESTED_FILES= @@ -131,16 +132,16 @@ public: int margin() const { return m_margin; } - void draw(QPainter *painter, QGraphicsEffectSource *source) + void draw(QPainter *painter) { ++numRepaints; if (doNothingInDraw) return; - m_source = source; + m_source = source(); m_painter = painter; - m_styleOption = source->styleOption(); + m_styleOption = source()->styleOption(); m_opacity = painter->opacity(); - source->draw(painter); + drawSource(painter); } void sourceChanged(QGraphicsEffect::ChangeFlags flags) -- cgit v0.12 From 47bc34f413d9a0c6efac6ca3eead95eed7da2e40 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 10 Nov 2009 14:17:43 +0100 Subject: My change --- dist/changes-4.6.0 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7666f69..794e905 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -785,6 +785,10 @@ Qt for Windows CE - It is now possible to further specify the kind of custom widget string properties using XML tags. +-uic + + - [260784] Generated code for retranslateUi doesn't cause compiler warnings anymore + - uic3 - [128859] Fixed code generation of QLabel's wordWrap property. -- cgit v0.12 From 092359242623018f3314c76821973778f8eb6b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 10 Nov 2009 15:59:31 +0100 Subject: Add my changes to the 4.6.0 changelog --- dist/changes-4.6.0 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 794e905..5b63c16 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -751,6 +751,10 @@ Qt for Embedded Linux - [255495] Fix blend function crash on AVR32 +- Fix qconfig configurations + +- Add powerpc mkspec and remove "empty" ppc mkspec + Qt for Windows CE ----------------- - On Windows CE the link time code generation has been disabled by default to -- cgit v0.12 From 60377a2ccb25e8b9b51d1100e7ff1a0bb42b82c6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 10 Nov 2009 16:13:48 +0100 Subject: Doc: remove graphics for effects that are no longer in scope. --- doc/src/images/graphicseffect-bloom.png | Bin 79982 -> 0 bytes doc/src/images/graphicseffect-effects.png | Bin 486123 -> 0 bytes doc/src/images/graphicseffect-grayscale.png | Bin 58121 -> 0 bytes doc/src/images/graphicseffect-pixelize.png | Bin 26390 -> 0 bytes doc/src/qt4-intro.qdoc | 8 ++++---- src/gui/effects/qgraphicseffect.cpp | 12 +++++++++++- 6 files changed, 15 insertions(+), 5 deletions(-) delete mode 100644 doc/src/images/graphicseffect-bloom.png delete mode 100644 doc/src/images/graphicseffect-effects.png delete mode 100644 doc/src/images/graphicseffect-grayscale.png delete mode 100644 doc/src/images/graphicseffect-pixelize.png diff --git a/doc/src/images/graphicseffect-bloom.png b/doc/src/images/graphicseffect-bloom.png deleted file mode 100644 index dace7eb..0000000 Binary files a/doc/src/images/graphicseffect-bloom.png and /dev/null differ diff --git a/doc/src/images/graphicseffect-effects.png b/doc/src/images/graphicseffect-effects.png deleted file mode 100644 index 609bef9..0000000 Binary files a/doc/src/images/graphicseffect-effects.png and /dev/null differ diff --git a/doc/src/images/graphicseffect-grayscale.png b/doc/src/images/graphicseffect-grayscale.png deleted file mode 100644 index 8b6e5c6..0000000 Binary files a/doc/src/images/graphicseffect-grayscale.png and /dev/null differ diff --git a/doc/src/images/graphicseffect-pixelize.png b/doc/src/images/graphicseffect-pixelize.png deleted file mode 100644 index 57a0057..0000000 Binary files a/doc/src/images/graphicseffect-pixelize.png and /dev/null differ diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 4911426..8154921 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -614,13 +614,13 @@ \table \row - \o - \o \img graphicseffect-plain.png - \o + \o{2,1} \img graphicseffect-plain.png \row \o \img graphicseffect-blur.png \o \img graphicseffect-colorize.png - \o \img graphicseffect-bloom.png + \row + \o \img graphicseffect-opacity.png + \o \img graphicseffect-drop-shadow.png \endtable See the QGraphicsEffect class documentation for more information. diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 13f42c5..3fca319 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -67,7 +67,17 @@ \o QGraphicsOpacityEffect - renders the item with an opacity \endlist - \img graphicseffect-effects.png + \table + \row + \o{2,1} \img graphicseffect-plain.png + \row + \o \img graphicseffect-blur.png + \o \img graphicseffect-colorize.png + \row + \o \img graphicseffect-opacity.png + \o \img graphicseffect-drop-shadow.png + \endtable + \img graphicseffect-widget.png For more information on how to use each effect, refer to the specific -- cgit v0.12 From ace072c2ae78c7d13ebf60f094319f2b9f5e51db Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Tue, 10 Nov 2009 16:57:47 +0100 Subject: Document change of qdoc3 binary location. Reviewed-by: TrustMe --- dist/changes-4.6.0 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 5b63c16..f7c2b87 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -789,7 +789,7 @@ Qt for Windows CE - It is now possible to further specify the kind of custom widget string properties using XML tags. --uic +- uic - [260784] Generated code for retranslateUi doesn't cause compiler warnings anymore @@ -798,8 +798,13 @@ Qt for Windows CE - [128859] Fixed code generation of QLabel's wordWrap property. - lupdate + - Fixed a bug in the java source code parser. +- qdoc3 + + - Changed qdoc3 binary to be in bin/ instead of a platform specific location. + **************************************************************************** * DirectFB * **************************************************************************** -- cgit v0.12 From 2e44d75036c2439a51be45a9691b68199322e80e Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 6 Nov 2009 16:58:15 +0100 Subject: french translation of qt_help --- tools/assistant/translations/qt_help.pro | 3 +- tools/linguist/phrasebooks/french.qph | 20 ++ translations/qt_help_fr.ts | 375 +++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 translations/qt_help_fr.ts diff --git a/tools/assistant/translations/qt_help.pro b/tools/assistant/translations/qt_help.pro index 0133ea4..db54ae6 100644 --- a/tools/assistant/translations/qt_help.pro +++ b/tools/assistant/translations/qt_help.pro @@ -47,4 +47,5 @@ TRANSLATIONS = \ $$TR_DIR/qt_help_pl.ts \ $$TR_DIR/qt_help_ru.ts \ $$TR_DIR/qt_help_zh_CN.ts \ - $$TR_DIR/qt_help_zh_TW.ts + $$TR_DIR/qt_help_zh_TW.ts \ + $$TR_DIR/qt_help_fr.ts diff --git a/tools/linguist/phrasebooks/french.qph b/tools/linguist/phrasebooks/french.qph index 9440345..a34effe 100644 --- a/tools/linguist/phrasebooks/french.qph +++ b/tools/linguist/phrasebooks/french.qph @@ -1346,4 +1346,24 @@ Select All Sélectionner tout + + Cannot create directory: %1 + Impossible de créer le répertoire : %1 + + + &Case sensitive + &Sensible à la casse + + + Whole &words + M&ots complets + + + Title: + Titre : + + + Fonts + Polices + diff --git a/translations/qt_help_fr.ts b/translations/qt_help_fr.ts new file mode 100644 index 0000000..632561a --- /dev/null +++ b/translations/qt_help_fr.ts @@ -0,0 +1,375 @@ + + + + + QCLuceneResultWidget + + + Search Results + Résultats de la recherche + + + + Note: + Note : + + + + The search results may not be complete since the documentation is still being indexed! + Les résultats de la recherche risquent d'être incomplets car l'indexation de la documentation est en cours ! + + + + Your search did not match any documents. + Votre recherche ne correspond à aucun document. + + + + (The reason for this might be that the documentation is still being indexed.) + (Il est possible que cela soit dû au fait que la documentation est en cours d'indexation.) + + + + QHelpCollectionHandler + + + The collection file '%1' is not set up yet! + Le fichier de collection '%1' n'est pas encore paramétré ! + + + + Cannot load sqlite database driver! + driver ? + Chargement du pilote de base de donnée sqlite impossible ! + + + + + Cannot open collection file: %1 + collection ? + Impossible d'ouvrir le fichier collection : %1 + + + + Cannot create tables in file %1! + Impossible de créer les tables dans le fichier : %1! + + + + The collection file '%1' already exists! + Le fichier collection '%1' existe déjà ! + + + + Cannot create directory: %1 + Impossible de créer le répertoire : %1 + + + + Cannot copy collection file: %1 + Impossible de copier le fichier collection : %1 + + + + Unknown filter '%1'! + Filtre '%1' inconnu ! + + + + Cannot register filter %1! + Impossible d'enregistrer le filtre %1 ! + + + + Cannot open documentation file %1! + Impossible d'ouvrir le fichier de documentation %1 ! + + + + Invalid documentation file '%1'! + fichier de documentation invalide : '%1' ! + + + + The namespace %1 was not registered! + L'espace de noms '%1' n'est pas référencé ! + + + + Namespace %1 already exists! + L'espace de noms %1 existe déjà ! + + + + Cannot register namespace '%1'! + Impossible d'enregistrer l'espace de noms '%1' ! + + + + Cannot open database '%1' to optimize! + Impossible d'ouvrir la base de données à optimiser '%1' ! + + + + QHelpDBReader + + + Cannot open database '%1' '%2': %3 + The placeholders are: %1 - The name of the database which cannot be opened %2 - The unique id for the connection %3 - The actual error string + Impossible d'ouvrir la base de données '%1' '%2' : %3 + + + + QHelpEngineCore + + + The specified namespace does not exist! + L'espace de noms spécifié n'existe pas ! + + + + QHelpEngineCorePrivate + + + Cannot open documentation file %1: %2! + Impossible d'ouvrir le fichier de documentation %1 : %2 ! + + + + QHelpGenerator + + + Invalid help data! + Données d'aide invalides ! + + + + No output file name specified! + Aucun nom de fichier de sortie spécifié ! + + + + The file %1 cannot be overwritten! + Le fichier %1 ne peut être écrasé ! + + + + Building up file structure... + Construction de la structure de fichiers en cours… + + + + Cannot open data base file %1! + Impossible d'ouvrir le fichier de base de données %1 ! + + + + Cannot register namespace %1! + Impossible d'enregistrer l'espace de noms %1 ! + + + + Insert custom filters... + Insérer des filtres personnalisés… + + + + Insert help data for filter section (%1 of %2)... + ??? + Insertion des données d'aide pour la section filtre (%1 de %2)… + + + + Documentation successfully generated. + Documentation générée. + + + + Some tables already exist! + Certaines tables existent déjà ! + + + + Cannot create tables! + Impossible de créer les tables ! + + + + Cannot register virtual folder! + Impossible d'enregistrer le dossier virtuel ! + + + + Insert files... + Insertion des fichiers... + + + + The referenced file %1 must be inside or within a subdirectory of (%2). Skipping it. + Le fichier référencé %1 doit être dans le dossier (%2) ou un de ses sous-dossiers. Fichier non pris en compte. + + + + The file %1 does not exist! Skipping it. + Le fichier %1 n'existe pas ! Fichier non pris en compte. + + + + Cannot open file %1! Skipping it. + Impossible d'ouvrir le fichier %1 ! Fichier non pris en compte. + + + + The filter %1 is already registered! + Le filtre %1 est déjà enregistré ! + + + + Cannot register filter %1! + Impossible d'enregistrer le filtre %1 ! + + + + Insert indices... + Insertion des index… + + + + Insert contents... + insertion des contenus… + + + + Cannot insert contents! + Impossible d'insérer les contenus ! + + + + Cannot register contents! + Impossible de référencer les contenus ! + + + + QHelpSearchQueryWidget + + + Search for: + Rechercher : + + + + Previous search + Recherche précédente + + + + Next search + Recherche suivante + + + + Search + Recherche + + + + Advanced search + Recherche avancée + + + + words <B>similar</B> to: + mots <B>semblables</B> à : + + + + <B>without</B> the words: + <B>Sans</B> les mots : + + + + with <B>exact phrase</B>: + avec la <B>phrase exacte</B> : + + + + with <B>all</B> of the words: + Avec <B>tous</B> les mots : + + + + with <B>at least one</B> of the words: + avec <B>au moins un</B> des mots : + + + + QHelpSearchResultWidget + + + 0 - 0 of 0 Hits + 0 - 0 de 0 résultats + + + + QHelpSearchResultWidgetPrivate + + + %1 - %2 of %3 Hits + %1 - %2 de %3 résultats + + + + QObject + + + Untitled + Sans titre + + + + Unknown token. + contexte peu clair... + Identificateur inconnu. + + + + Unknown token. Expected "QtHelpProject"! + Identificateur inconnu. "QtHelpProject" attendu ! + + + + Error in line %1: %2 + Erreur à la ligne %1 : %2 + + + + A virtual folder must not contain a '/' character! + Un dossier virtuel ne doit pas contenir le caractère '/' ! + + + + A namespace must not contain a '/' character! + Un espace de noms ne doit pas contenir le caractère '/' ! + + + + Missing namespace in QtHelpProject. + Espace de noms manquant dans QtHelpProject. + + + + Missing virtual folder in QtHelpProject + Dossier virtuel manquant dans QtHelpProject + + + + Missing attribute in keyword at line %1. + Attribut manquant pour le mot clé à la ligne %1. + + + + The input file %1 could not be opened! + Le fichier source %1 n'a pas pu être ouvert ! + + + -- cgit v0.12 From cfbfbc4a36db8cca70ac00df06f3307cf456e512 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 10 Nov 2009 17:18:33 +0100 Subject: linguist changes --- dist/changes-4.6.0 | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index f7c2b87..d008e88 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -797,14 +797,44 @@ Qt for Windows CE - [128859] Fixed code generation of QLabel's wordWrap property. - - lupdate - - - Fixed a bug in the java source code parser. - - qdoc3 - Changed qdoc3 binary to be in bin/ instead of a platform specific location. +- Linguist + + - Linguist GUI: Experimental support for editing multi-length strings + + - lupdate is now again the only tool which can parse program code + + - lupdate + + * Actually guess the target language from the file name + * Make -{source,target}-language actually override values from files + * C++ parser + - Properly support "using namespace", etc. + - Remove the obsolete TRANSLATOR hack relating to "using namespace" + - Support attaching meta data to translatable messages + - Actually use the argument of Q_DECLARE_TR_FUNCTIONS + - Optimizations + - Bug fixes and robustness improvements + + - lrelease + + * Add -markuntranslated option + + - both lupdate & lrelease + + * Accuracy improvements of the qmake .pro file parser + * Support for ID-based translations. Somewhat experimental. + + - lconvert + + * Add --sort-contexts option + * Add --locations option (complementing lupdate) + * Add --no-ui-lines option (complementing lupdate) + + **************************************************************************** * DirectFB * **************************************************************************** -- cgit v0.12 From 6370b79729fd24892e13393e0add2d1940ca0c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 10 Nov 2009 15:54:52 +0100 Subject: Added some changes to changes-4.6.0. --- dist/changes-4.6.0 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index d008e88..54b48fa 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -34,6 +34,9 @@ information about a particular change. - QGLShaderProgram, QGLShader * New classes for using shader programs written in the GL Shading Language. + - QGraphicsEffect + * New classes for applying graphics effects to graphics items and widgets. + - Boxes demo ported to use new 3D math and shader program classes. - OpenVG graphics system added. @@ -323,6 +326,8 @@ QtGui * [201649] Added QWidget::previousInFocusChain * [254563] Fixed a crash when setting a focus in a widget tree that contains invisible widgets + * [QTBUG-5012] Fixed uninitialized background when using + QWidget::render with Qt::WA_NoSystemBackground and window opacity set. - QFontEngineQPF * Make alphaMapForGlyph() generate the correct color table for @@ -333,6 +338,11 @@ QtGui * New qt_paint_device_metric() function to replace the friend declarations for window surface classes that need to access metric(). + - QPainter + * [QTBUG-1666] Made QPainter::drawText() respect Qt::TextDontClip flag + also in vertical direction. + * [254658] Improved clipping performance in OpenGL paint engine. + - QPainterPath * [QTBUG-1537] Fixed bug where the points of a rounded rectangle were added in counter-clockwise order instead of clockwise order like other shapes. @@ -588,6 +598,9 @@ Qt for Linux/X11 - Improved EGL integration on X11 (including better visual selection). + - Made Qt::WA_TranslucentBackground work in combination with native + child widgets. + - Support Qt::WA_TranslucentBackground on top-level QGLWidgets on X11, both (EGL & glX). This allows OpenGL (& ES) rendering to semi-transparent widgets if a compositing window manager is running. -- cgit v0.12 From 75715c8e9322f2a144ecd2f0d89751a88287d753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 10 Nov 2009 17:43:03 +0100 Subject: Removed mention of purged graphics effects from the documentation. --- doc/src/qt4-intro.qdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 8154921..2f74451 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -608,9 +608,9 @@ \section1 Graphics Effects Effects can be used to alter the appearance of UI elements such as - \l{QGraphicsItem}s and \l{QWidget}s. A range of standard effects such - as blurring, colorizing or blooming is provided, and it is possible to - implement custom effects. + \l{QGraphicsItem}s and \l{QWidget}s. A couple of standard effects such + as blurring, colorizing and drop shadow are provided, and it is + possible to implement custom effects. \table \row -- cgit v0.12 From 744f74c9f401734eb84ddba4751e5a54e0efffc8 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 10 Nov 2009 17:47:59 +0200 Subject: Changelog update Changelog update contains all major changes in QtWebkit, QtScript and brief information about the state machine framework. Reviewed-by: Simon Hausmann --- dist/changes-4.6.0 | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 54b48fa..06fe500 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -51,6 +51,8 @@ information about a particular change. - QAbstractVideoSurface, QVideoFrame * New abstract video output classes. + - New state machine framework added to QtCore + Third party components ---------------------- @@ -197,7 +199,7 @@ QtGui * Cached items are now always invalidated when update() is called. * Added input hints. -- QGraphicsLayout + - QGraphicsLayout * Introduced QGraphicsLayout::addChildLayoutItem() - QGraphicsObject @@ -497,6 +499,11 @@ QtOpenGL - Added lots of OpenGL autotests. +QtScript + * A lot of internal changes and optimizations. + * Improved ECMA script compliance. + * New method, QScriptString::toArrayIndex(), for converting QScriptString to a QtScript array index. + QtSql * [QTBUG-3162] Views for Sql table models should not reset state on failed queries. * [QTBUG-5251] Fix retrieval of SQL 'TIME' information for PostgreSQL. @@ -536,6 +543,35 @@ QtSvg - QSvgPaintEngine * [257052] Changed drawImage() to ignore aspect ratio. +QtWebKit + - Many bug fixes. + + - QWebElement + * New class; introduced to implement DOM like operations on a web page. + + - QWebFrame + * New properties for an URL and a focus management. + * New signals delivering current loading status. + + - QWebInspector + * New class for embedding the WebInspector as a QWidget + + - QWebHistory + * Streaming operators for saving and restoring QWebHistory's state. + + - QWebPage + * New property; preferredContentsSize for setting layout of the page in the viewport. + * New slot; shouldInterruptJavaScript, called when JavaScript program is running too long. + + - QWebSecurityOrigin: + * New functions for defining local URL schemes. + + - QWebSettings + * New options for text encoding, printing shrink factor and off-line web application cache (HTML5). + + - QWebView + * Support for render hints. + QtXml - QDomDocument @@ -1012,6 +1048,9 @@ Qt for Windows CE Animation framework for animation. The hellogl and overpainting examples now compile on OpenGL/ES 1.1. Also common code is factored. +- Changed QWebFrame::setHtml() and setContent() to not affect the back/forward + and the session history. + - qmake no longer adds Qt internal dependencies to the linker when Qt is built in shared mode (not static). This means that applications that made use of platform-specific API may need to adjust the LIBS -- cgit v0.12 From d752092080c4094bb4736108cff95a4b08abd750 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 10 Nov 2009 14:27:24 +0100 Subject: Removed unused public Api from QS60Style QS60Style::setStyleProperty() and QS60Style::styleProperty() were intended as generic property setter/getters, but are not needed anymore. Reviewed-by: Sami Merila modified: src/gui/styles/qs60style.cpp modified: src/gui/styles/qs60style.h modified: src/gui/styles/qs60style_p.h modified: src/gui/styles/qs60style_s60.cpp modified: src/gui/styles/qs60style_simulated.cpp modified: src/s60installs/eabi/QtGuiu.def --- src/gui/styles/qs60style.cpp | 44 ---------------------------------- src/gui/styles/qs60style.h | 4 ---- src/gui/styles/qs60style_p.h | 8 ------- src/gui/styles/qs60style_s60.cpp | 17 ------------- src/gui/styles/qs60style_simulated.cpp | 10 -------- src/s60installs/eabi/QtGuiu.def | 4 ++-- 6 files changed, 2 insertions(+), 85 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b5e92c7..02ffb29 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -301,32 +301,6 @@ short QS60StylePrivate::pixelMetric(int metric) return returnValue; } -void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) -{ - if (name == propertyKeyCurrentlayout) { - static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList(); - const QString layout = value.toString(); - Q_ASSERT(layouts.contains(layout)); - const int layoutIndex = layouts.indexOf(layout); - setCurrentLayout(layoutIndex); - QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight); - clearCaches(); - refreshUI(); - } -} - -QVariant QS60StylePrivate::styleProperty(const char *name) const -{ - if (name == propertyKeyLayouts) { - static QStringList layouts; - if (layouts.isEmpty()) - for (int i = 0; i < m_numberOfLayouts; i++) - layouts.append(QLatin1String(m_layoutHeaders[i].layoutName)); - return layouts; - } - return QVariant(); -} - QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) { QColor retColor (color); @@ -2873,24 +2847,6 @@ void QS60Style::unpolish(QApplication *application) } /*! - Sets the style property \a name to the \a value. - */ -void QS60Style::setStyleProperty(const char *name, const QVariant &value) -{ - Q_D(QS60Style); - d->setStyleProperty_specific(name, value); -} - -/*! - Returns the value of style property \a name. - */ -QVariant QS60Style::styleProperty(const char *name) const -{ - Q_D(const QS60Style); - return d->styleProperty_specific(name); -} - -/*! \reimp */ bool QS60Style::event(QEvent *e) diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index ab10792..885ea40 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -79,10 +79,6 @@ public: #ifndef Q_NO_USING_KEYWORD using QCommonStyle::polish; #endif - - void setStyleProperty(const char *name, const QVariant &value); - QVariant styleProperty(const char *name) const; - bool event(QEvent *e); #ifndef Q_WS_S60 diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 46547bf..b9789b9 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -388,14 +388,6 @@ public: // draws a specific skin part static void drawSkinPart(QS60StyleEnums::SkinParts part, QPainter *painter, const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); - // sets style property - void setStyleProperty(const char *name, const QVariant &value); - // sets specific style property - void setStyleProperty_specific(const char *name, const QVariant &value); - // gets style property - QVariant styleProperty(const char *name) const; - // gets specific style property - QVariant styleProperty_specific(const char *name) const; // gets pixel metrics value static short pixelMetric(int metric); // gets color. 'index' is NOT 0-based. diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index c2a207c..b5f2d1c 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1014,23 +1014,6 @@ QS60StylePrivate::QS60StylePrivate() setActiveLayout(); } -void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) -{ - if (QLatin1String(name) == QLatin1String("foo")) { - // BaR - } else { - setStyleProperty(name, value); - } -} - -QVariant QS60StylePrivate::styleProperty_specific(const char *name) const -{ - if (QLatin1String(name) == QLatin1String("foo")) - return QLatin1String("Bar"); - else - return styleProperty(name); -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 706b4e9..4317483 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -308,16 +308,6 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, return result; } -void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) -{ - setStyleProperty(name, value); -} - -QVariant QS60StylePrivate::styleProperty_specific(const char *name) const -{ - return styleProperty(name); -} - QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 5d66fb7..3a46700 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -7006,7 +7006,7 @@ EXPORTS _ZN9QPolygonFC2ERK8QPolygon @ 7005 NONAME _ZN9QS60Style11qt_metacallEN11QMetaObject4CallEiPPv @ 7006 NONAME _ZN9QS60Style11qt_metacastEPKc @ 7007 NONAME - _ZN9QS60Style16setStylePropertyEPKcRK8QVariant @ 7008 NONAME + _ZN9QS60Style16setStylePropertyEPKcRK8QVariant @ 7008 NONAME ABSENT _ZN9QS60Style16staticMetaObjectE @ 7009 NONAME DATA 16 _ZN9QS60Style19getStaticMetaObjectEv @ 7010 NONAME _ZN9QS60Style5eventEP6QEvent @ 7011 NONAME @@ -10445,7 +10445,7 @@ EXPORTS _ZNK9QS60Style11drawControlEN6QStyle14ControlElementEPK12QStyleOptionP8QPainterPK7QWidget @ 10444 NONAME _ZNK9QS60Style11pixelMetricEN6QStyle11PixelMetricEPK12QStyleOptionPK7QWidget @ 10445 NONAME _ZNK9QS60Style13drawPrimitiveEN6QStyle16PrimitiveElementEPK12QStyleOptionP8QPainterPK7QWidget @ 10446 NONAME - _ZNK9QS60Style13stylePropertyEPKc @ 10447 NONAME + _ZNK9QS60Style13stylePropertyEPKc @ 10447 NONAME ABSENT _ZNK9QS60Style14subControlRectEN6QStyle14ComplexControlEPK19QStyleOptionComplexNS0_10SubControlEPK7QWidget @ 10448 NONAME _ZNK9QS60Style14subElementRectEN6QStyle10SubElementEPK12QStyleOptionPK7QWidget @ 10449 NONAME _ZNK9QS60Style16sizeFromContentsEN6QStyle12ContentsTypeEPK12QStyleOptionRK5QSizePK7QWidget @ 10450 NONAME -- cgit v0.12 From 7005ca9f0f6b1e535ad2b26d3fcf46dffacc3f13 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 10 Nov 2009 18:08:21 +0100 Subject: Qt covers BC break in Symbian Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()' that returns a private data member. The header will change between minor SDK versions, thus break BC. But Qt has to build on any SDK version and run on other versions of Symbian OS. Also Qt does not want to deliver that BC to Qt based apps. This hack performs the needed pointer arithmetic to get the right COpenFont* pointer, no matter if the 'Flexible Memory Model' is already supported or not. The author is not proud of this commit. Task-number: QT-2250 Reviewed-by: Iain Reviewed-by: Shane Kearns modified: src/gui/text/qfontdatabase_s60.cpp --- src/gui/text/qfontdatabase_s60.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 1a6bb11..ca5be0e 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -136,6 +136,23 @@ QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() m_heap->Close(); } +#ifndef FNTSTORE_H_INLINES_SUPPORT_FMM +/* + Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()' + that returns a private data member. The header will change between SDKs. But Qt has + to build on any SDK version and run on other versions of Symbian OS. + This function performs the needed pointer arithmetic to get the right COpenFont* +*/ +COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) +{ + const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private + const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont); + return (valueIOpenFont & 1) ? + (COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset + (COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer +} +#endif // FNTSTORE_H_INLINES_SUPPORT_FMM + const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const { if (!m_extensions.contains(typeface)) { @@ -144,8 +161,14 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c spec.iHeight = 1; const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); Q_ASSERT(err == KErrNone && font); - CBitmapFont *bitmapFont = static_cast(font); - m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont())); + const CBitmapFont *bitmapFont = static_cast(font); + COpenFont *openFont = +#ifdef FNTSTORE_H_INLINES_SUPPORT_FMM + bitmapFont->openFont(); +#else + OpenFontFromBitmapFont(bitmapFont); +#endif // FNTSTORE_H_INLINES_SUPPORT_FMM + m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont)); } return m_extensions.value(typeface); } -- cgit v0.12 From f890cb88c75efdc92f513e47ee4df35c87886476 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 10 Nov 2009 18:58:05 +0100 Subject: qfontcombobox auto test added to tests/auto/auto.pro Reviewed-by: TrustMe --- tests/auto/auto.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 1ec4c16..46f26f8 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -135,6 +135,7 @@ SUBDIRS += \ qfocusevent \ qfocusframe \ qfont \ + qfontcombobox \ qfontdatabase \ qfontdialog \ qfontmetrics \ -- cgit v0.12 From be8746da74abb213d25fa8aa51a296d193bd9be0 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Tue, 10 Nov 2009 20:42:56 +0100 Subject: exporting QGraphicsEffectSource is required Q3MainWindow and Q3TitleBar depend on it. Reviewed-By: dt Reviewed-By: Alessandro Portale --- src/gui/effects/qgraphicseffect_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index c67052e..0011eef 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class QGraphicsEffectSourcePrivate; -class Q_AUTOTEST_EXPORT QGraphicsEffectSource : public QObject +class Q_GUI_EXPORT QGraphicsEffectSource : public QObject { Q_OBJECT public: -- cgit v0.12 From 543cceb53795a1af8a3515a18025998f24ff4ca0 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 10 Nov 2009 22:02:21 +0100 Subject: =?UTF-8?q?Documentation:=20Adding=20comments=20to=20QHoverEvent?= =?UTF-8?q?=20class=20Explaining=20the=20difference=20between=20hover=20ev?= =?UTF-8?q?ents=20and=20enter/leave/move=20events=20Task-number:=20QT-1116?= =?UTF-8?q?=20Reviewed-by:=20Bj=C3=B8rn=20Erik=20Nilsen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/src/images/hoverevents.png | Bin 0 -> 3210 bytes src/gui/kernel/qevent.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 doc/src/images/hoverevents.png diff --git a/doc/src/images/hoverevents.png b/doc/src/images/hoverevents.png new file mode 100644 index 0000000..ccc079b Binary files /dev/null and b/doc/src/images/hoverevents.png differ diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ff97405..c4a25e1 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -399,6 +399,40 @@ QMouseEventEx::~QMouseEventEx() The function pos() gives the current cursor position, while oldPos() gives the old mouse position. + + There are a few similarities between the events QEvent::HoverEnter + and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave. + However, they are slightly different because we do an update() in the event + handler of HoverEnter and HoverLeave. + + QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us + consider a top-level window A containing a child B which in turn contains a + child C (all with mouse tracking enabled): + + \image hoverEvents.png + + Now, if you move the cursor from the top to the bottom in the middle of A, + you will get the following QEvent::MouseMove events: + + \list 1 + \o A::MouseMove + \o B::MouseMove + \o C::MouseMove + \endlist + + You will get the same events for QEvent::HoverMove, except that the event + always propagates to the top-level regardless whether the event is accepted + or not. It will only stop propagating with the Qt::WA_NoMousePropagation + attribute. + + In this case the events will occur in the following way: + + \list 1 + \o A::HoverMove + \o A::HoverMove, B::HoverMove + \o A::HoverMove, B::HoverMove, C::HoverMove + \endlist + */ /*! -- cgit v0.12 From 0cceb16fd915a5f9d7d05d38c6508025999c187d Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 10 Nov 2009 23:33:18 +0100 Subject: QWS keymap changes Reviewed-by: TrustMe --- dist/changes-4.6.0 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 06fe500..02dc2a3 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -788,6 +788,12 @@ Qt for Embedded Linux * Remove surface holder, which never worked all that well. * Implement screen rotations. +- Mouse and keyboard drivers + * Removed obsolete drivers (vr41xx, yopy, sl5000, bus mouse). + * Added a new LinuxInput driver for both mouse and keyboard. + * Added keymap support for QWS via standard Linux .kmap files. + (complete with dead-keys, compose-key and LED handling) + - Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. - Send enter/leave events also to child widgets -- cgit v0.12 From 4f434ffe541f2e98d6c47fd48a588807f1a231e9 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 11 Nov 2009 12:13:50 +1000 Subject: Document changes for Ian Walters. --- dist/changes-4.6.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 02dc2a3..94be8f0 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -53,6 +53,9 @@ information about a particular change. - New state machine framework added to QtCore + - QContiguousCache + * New class for efficiently caching items within a scrolling view. + Third party components ---------------------- -- cgit v0.12 From 975c439ef2068a48994da07b827ce835c002bfee Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 11 Nov 2009 13:16:26 +1000 Subject: First pass review of changes file. Cleanup descriptions + reformat to 80 columns. Reviewed-by: Trust Me --- dist/changes-4.6.0 | 638 ++++++++++++++++++++++++++++------------------------- 1 file changed, 337 insertions(+), 301 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 02dc2a3..08ca066 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -8,9 +8,12 @@ The Qt version 4.6 series is binary compatible with the 4.5.x series. Applications compiled for 4.5 will continue to run with 4.6. Some of the changes listed in this file include issue tracking numbers -corresponding to tasks in the Task Tracker: +corresponding to tasks in the Qt Bug Tracker, the (now obsolete) Task +Tracker, or the Merge Request queue of the public source repository. - http://qt.nokia.com/developer/task-tracker +Qt Bug Tracker: http://bugreports.qt.nokia.com +Task Tracker: http://qt.nokia.com/developer/task-tracker +Merge Request: http://qt.gitorious.org Each of these identifiers can be entered in the task tracker to obtain more information about a particular change. @@ -41,7 +44,7 @@ information about a particular change. - OpenVG graphics system added. - - Add 800x480 screen mode to qvfb configuration dialog. + - Added 800x480 screen mode to qvfb configuration dialog. - Improved support for input methods in graphics view. @@ -51,12 +54,18 @@ information about a particular change. - QAbstractVideoSurface, QVideoFrame * New abstract video output classes. - - New state machine framework added to QtCore + - New state machine framework added to QtCore. + Third party components ---------------------- - - Updated FreeType to version 2.3.9 + - Updated FreeType to version 2.3.9. + + - Updated harfbuzz to the latest version from fd.org. + + - Updated sqlite to version 3.6.19. + **************************************************************************** * Library * @@ -65,36 +74,39 @@ Third party components QtCore - QByteArray - * New overloads for QByteArray::insert() and QByteArray::prepend() + * New overloads for QByteArray::insert() and QByteArray::prepend(). - QFile - * Make QFile::resize() more robust when operating on buffered files + * Make QFile::resize() more robust when operating on buffered files. - QObject - * [259514] fixed a possible dead-lock in the destructor - * Added the possibility to pass the flag Qt::UniqueConnection to QObject::connect - * Fixed race conditions that occured when moving object to threads while connecting + * [259514] fixed a possible dead-lock in the destructor. + * Added the possibility to pass the flag Qt::UniqueConnection to + QObject::connect. + * Fixed race conditions that occured when moving object to threads + while connecting. - QPluginLoader - * Improved performance of plugin loading by reusing the plugin cache instead of loading - it every time. + * Improved performance of plugin loading by reusing the plugin cache + instead of loading it every time. - QProcessEnvironment - * New class; support for easy access to key/value pairs in the - process environment + * New class; support for easy access to key/value pairs in the process + environment. - QRegExp - * New pattern syntax "QRegExp::WildcardUnix" with wildcard characters escaping + * New pattern syntax "QRegExp::WildcardUnix" with wildcard character + escaping. - QScopedPointer - * New pointer class for cleaning up objects when leaving the - current scope + * New pointer class for cleaning up objects when leaving the current + scope. - QSharedPointer - * Added support for creating the object along the internal private + * Added support for creating the object along with the internal private data in one single memory allocation. (QSharedPointer::create) - * Fixed a bug where, in a race condition, QSharedPointer could - track a pointer that was being deleted. + * Fixed a bug where, in a race condition, QSharedPointer could track a + pointer that was being deleted. - QTextStream * [221316] Fixed crash on large input. @@ -107,15 +119,15 @@ QtCore being accepted. See below in "Important Behavior Changes". - QVariant - * Many optimisations - * Added QVariant::toFloat() and QVariant::toReal() - * Added QVariant(float) constructor + * Many optimisations. + * Added QVariant::toFloat() and QVariant::toReal(). + * Added QVariant(float) constructor. * qvariant_cast and qVariantFromValue are now - identify functions + identity functions. * Added support for math3d types. - QXmlStreamWriter - * [256468] fix comment indentation + * [256468] Fixed comment indentation. - QWeakPointer * Added support for tracking QObject-derived classes that aren't @@ -126,7 +138,7 @@ QtCore - QUuid * [QTBUG-3543] Fixed a bug in createUuid() which caused multiple - threads to generate the identical UUID sequences + threads to generate the identical UUID sequences. - QEventDispatcherGlib (internal class) * Fix a regression introduced in 4.5.3 that would cause timers to not @@ -135,19 +147,19 @@ QtCore - QEventDispatcherUNIX (internal class) * Improve detection of monotonic clock support to include non-POSIX.1-2001 compliant systems. - * [250681] Fix time change detection on UNIX systems without - monotonic timers. + * [250681] Fix time change detection on UNIX systems without monotonic + timers. - QEventDispatcherWin32 (internal class) * Changed the threshold for using multimedia timers to 20ms (was 10ms). * Changed the way Qt's posted events are sent by the event - dispatcher. The are now driven on top of a Windows message + dispatcher. They are now driven on top of a Windows message instead of an explicit call in processEvents(). This means that posted events are sent even when a Windows modal message loop is running (for example, when the user is moving a window or when a native modal dialog is visible). - * Fixed a bug that would allow the same timer id to be used by - multiple QTimer instances. + * Fixed a bug that would allow the same timer id to be used by multiple + QTimer instances. - QTextCodec * Instantiate the CP949 codec when building with -no-iconv. @@ -158,166 +170,183 @@ QtCore QtGui - Qt::escape - * now escape the double quote (") + * Now escape the double quote ("). - QGraphicsAnchorLayout - * Support for expanding size policy has been removed. (The Qt 4.6 - Beta had support for it). + * Support for expanding size policy has been removed. (The Qt 4.6 Beta + had support for it). - QCalendarWidget - * [252943] QCalendarWidget::setDateTextFormat() reset the format if the date is invalid. + * [252943] QCalendarWidget::setDateTextFormat() reset the format if the + date is invalid. - QCompleter - * [246056] Fixed a possible assertion when setting the completer prefix + * [246056] Fixed a possible assertion when setting the completer prefix. - QEvent * Introduced RequestSoftwareInputPanel and CloseSoftwareInputPanel events. - QFontDialog - * [256466] fixed the dialog not always returning the selected style. + * [256466] Fixed the dialog not always returning the selected style. - QGraphicsBlurEffect - * Since the 4.6 beta Qt::RenderHint has been moved to + * Since the 4.6 Beta, Qt::RenderHint has been moved to QGraphicsBlurEffect::BlurHint. - * Input contexts are not activated for disabled widgets anymore. - * [250555] Data copied from Mozilla Firefox can now be pasted correctly to a Qt application. - QGraphicsItem - * Fixed bug and improved accuracy of QGraphicsItem::childrenBoundingRect(). * Many optimizations. - * Introduced QGraphicsItem::ItemHasNoContents - * Introduced QGraphicsItem::ItemSendsGeometryChanges (see Behavioral Changes) - * Introduced QGraphicsItem::focusProxy(), focus proxy support - * Introduced QGraphicsItem::ItemNegativeZStacksBehindParent - * Introduced QGraphicsItem::ItemIsPanel, light-weight window support + * Fixed bug and improved accuracy of QGraphicsItem::childrenBoundingRect(). + * Introduced QGraphicsItem::ItemHasNoContents. + * Introduced QGraphicsItem::ItemSendsGeometryChanges (see Behavioral + Changes). + * Introduced QGraphicsItem::focusProxy(), focus proxy support. + * Introduced QGraphicsItem::ItemNegativeZStacksBehindParent. + * Introduced QGraphicsItem::ItemIsPanel, light-weight window support. * Introduced modality support for QGraphicsItem panels. * Introduced activation support. - * Introduced QGraphicsItem::stackBefore() + * Introduced QGraphicsItem::stackBefore(). * Cached items are now always invalidated when update() is called. * Added input hints. + * Added a new set of properties to set a transformation on an item. - QGraphicsLayout - * Introduced QGraphicsLayout::addChildLayoutItem() + * Introduced QGraphicsLayout::addChildLayoutItem(). - QGraphicsObject - * New class; inherits QGraphicsItem and adds notification signals and property declarations. + * New class; inherits QGraphicsItem and adds notification signals and + property declarations. - QGraphicsProxyWidget - * [251407] Fixed window flag handling. Now QGraphicsProxyWidget's flags win. - * Fix Qt::ClickFocus policy + * [251407] Fixed window flag handling. Now QGraphicsProxyWidget's flags + win. + * Fix Qt::ClickFocus policy. - QGraphicsScene + * Many optimizations. * [245317] Fixes to mouse grabbing behavior. * Fixed delivery of double-click events after explicit grab and then ungrab. - * Rewrote the internal rendering to use a recursive instead of an iterative approach. - * Many optimizations. + * Rewrote the internal rendering to use a recursive instead of an iterative + approach. * Ensure hover enter events are delivered when an item is pressed. * Introduced activation support. * Fixed bugs in initial focus support. - QGraphicsTextItem - * Now inherits from QGraphicsObject instead + * Now inherits from QGraphicsObject instead. - QGraphicsTransform * New class; eases animation of transformations for QGraphicsItem. - QGraphicsView - * Fix mapToScene(QRect) to avoid extra unnecessary adjustments. * Many optimizations. - * Introduced QGraphicsView::isTransformed() - * [QTBUG-4151] Items with parent that sets ItemClipsChildrenToShape were sometimes invisible. + * Fix mapToScene(QRect) to avoid extra unnecessary adjustments. + * Introduced QGraphicsView::isTransformed(). + * [QTBUG-4151] Items with parent that sets ItemClipsChildrenToShape were + sometimes invisible. - QGraphicsWidget - * Now inherits from QGraphicsObject instead - * Interactive resizing of top level windows now respects height-for-width constraints. + * Now inherits from QGraphicsObject instead. + * Interactive resizing of top level windows now respects height-for-width + constraints. * Reduced memory footprint. - QAbstractItemView - * [256502] Fixes selectionModel::hasSelection return value after model::reset + * [256502] Fixes selectionModel::hasSelection return value after + model::reset. - QHeaderView - * [208320] Make sure the sort indicator s taken into account for the size hint - * [255574] Make sure the sizehint for the section depend on visible sections + * [208320] Make sure the sort indicator is taken into account for the size + hint. + * [255574] Make sure the size hint for the section depends on visible + sections. - QMainWindow - * [226060] Adding actions to a toolbar would always make the next toolbar move + * [226060] Adding actions to a toolbar would always make the next toolbar + move. - QMenuBar - * [260873] Fix mouse interaction while undocking a widget from the main window - * dock areas don't get a splitter if their dock widgets are not resizable + * [260873] Fix mouse interaction while undocking a widget from the main + window + * Dock areas didn't get a splitter if their dock widgets were not + resizable. - QColumnView - * [246999] Fixed view not updating when the model is changed dynamically + * [246999] Fixed view not updating when the model changed dynamically. - QLineEdit * [248948] Clear selection when redoing a delete operation. - * [QTBUG-5261] Fixed: Erasing characters from textedits does not update the text + * [QTBUG-5261] Fixed bug where erasing characters from a textedit did not + update the text. - QListView - * [243335] Fixed the visualRect to return correct values when the widget is not yet show + * [243335] Fixed the visualRect to return correct values when the widget is + not yet shown. - QTreeView - * [234930] Be able to use :has-children and :has-sibillings in a stylesheet - * [252616] Set QStyleOptionViewItemV4::OnlyOne flag when painting spanning columns - * [245654] Fixed expandAll when deleting and recreating a mode for the tree - * [239271] Fixed missing update when adding a row when the first column is hidden - * [258225] Fixed scrollTo with center and bottom + * [234930] Be able to use :has-children and :has-sibillings in a stylesheet. + * [252616] Set QStyleOptionViewItemV4::OnlyOne flag when painting spanning + columns. + * [245654] Fixed expandAll when deleting and recreating a mode for the tree. + * [239271] Fixed missing update when adding a row when the first column is + hidden. + * [258225] Fixed scrollTo with center and bottom. - QTreeWidget - * [253109] Shows the widget when calling setItemWidget + * [253109] Shows the widget when calling setItemWidget. - QTableView - * [191545] Selections work more similarly to well-known spreadsheets - * [234926] Fixed sorting after changing QTableView header + * [191545] Selections work more similarly to well-known spreadsheets. + * [234926] Fixed sorting after changing QTableView header. * [244651] [245327] [250193] [QTBUG-5062] Spans get plenty of love with - speed-up, support for rows/columns insertion/removal, and better keyboard - navigation + performance improvements, support for row/column insertioa and removal, + and better keyboard navigation. - QTableWidget * [234641] Fixed takeItem to cause the view to be updated. - QTabBar - * [196326] Fixed having a stylesheet on a QTabBar resulted in some tab names - to be slightly clipped. + * [196326] Fixed having a stylesheet on a QTabBar resulted in some tab + names being slightly clipped. * [241383] Added ability to style the close tab button with style sheet - QImageReader - * [255627] Fix floating point exception in QImageReader::setScaledSize(QSize(0, 0)) + * [255627] Fix floating point exception in + QImageReader::setScaledSize(QSize(0, 0)). - QComboBox - * [220195] Fixed keyboard search when current index is -1 + * [220195] Fixed keyboard search when current index is -1. - QPixmap * Optimized width(), height(), isNull() and depth(). - * [QTBUG-2832] Fixed bug where calling fill on pixmap with active painter could crash. + * [QTBUG-2832] Fixed bug where calling fill on pixmap with active painter + could crash. - QRegion * Minor optimizations. - QSpinBox - * [259226] Fixed setting a stylesheet on a QSpinBox to change the arrow possition + * [259226] Fixed setting a stylesheet on a QSpinBox to change the arrow + position. * [255051] Fixed sizeHint update bug. - QStandardItemModel - * [255652] Fixed crash while using takeRow with a QSortFilterProxyModel + * [255652] Fixed crash while using takeRow with a QSortFilterProxyModel. - QToolTip - * Fixed a bug where tooltips were not shown in popups. (Windows only). - - - QGraphicsItem - * Added a new set of properties to set a transformation on a item + * Fixed a bug where tooltips were not shown in popups (Windows only). - QMenu - * [252610] Fixed position of the shortcut text while setting a stylesheet on menu items + * [252610] Fixed position of the shortcut text while setting a stylesheet + on menu items - QSortFilterProxyModel * [251296] Fixed bugs in which filtered items could not be filtered. - QSplitter - * [206494] Added ability to style pressed slided with stylesheet + * [206494] Added ability to style pressed slider with stylesheet. - QStroker * [QTBUG-5212] Fixed bug where thick strokes around small shapes could @@ -325,11 +354,11 @@ QtGui - QWidget * Added inputMethodHints property. - * [201649] Added QWidget::previousInFocusChain - * [254563] Fixed a crash when setting a focus in a widget tree that - contains invisible widgets - * [QTBUG-5012] Fixed uninitialized background when using - QWidget::render with Qt::WA_NoSystemBackground and window opacity set. + * [201649] Added QWidget::previousInFocusChain. + * [254563] Fixed a crash when setting focus in a widget tree that + contains invisible widgets. + * [QTBUG-5012] Fixed uninitialized background when using QWidget::render + with Qt::WA_NoSystemBackground and window opacity set. - QFontEngineQPF * Make alphaMapForGlyph() generate the correct color table for @@ -337,8 +366,8 @@ QtGui boxes" problem in OpenGL1 paint engine. - QPaintDevice - * New qt_paint_device_metric() function to replace the friend - declarations for window surface classes that need to access metric(). + * New qt_paint_device_metric() function to replace the friend declarations + for window surface classes that need to access metric(). - QPainter * [QTBUG-1666] Made QPainter::drawText() respect Qt::TextDontClip flag @@ -356,7 +385,8 @@ QtGui * [255581] Fixed sizeHint recalculation bug. - QRasterPaintEngine - * [QTBUG-4210] Fixed bug where bitmaps were painted black instead of in pen colour. + * [QTBUG-4210] Fixed bug where bitmaps were painted black instead of in pen + colour. - QApplication * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). @@ -366,27 +396,26 @@ QtGui height of the font used. - QPrinter - * [QTBUG-4497] Removed redundant SetPen command in the postscript code - when reusing a QPrinter object. + * [QTBUG-4497] Removed redundant SetPen command in the postscript code when + reusing a QPrinter object. - QTextLayout * [QTBUG-4468] Count tabs as multiple characters when applying a fixed column width. - * [176401] Take into account the negative right bearing of the last + * [176401] Take into account the negative right bearing of the last character in an item of text if the glyph extends beyond its ascent. - QTextDocument * [207189] Support setting font size using short hand syntax in the CSS "font" property. - * [201228] Remove implicit margin on bullet lists when exporting to - HTML. - * [240086] Fixed bug which caused floating objects which span several + * [201228] Remove implicit margin on bullet lists when exporting to HTML. + * [240086] Fixed bug which caused floating objects which span several pages to float into the second page of the document even when it's the only existing object, causing the document to contain a blank first page. - * [240325] Even when wrap mode is set to Qt::TextWordWrap, the layout + * [240325] Even with wrap mode set to Qt::TextWordWrap, the layout would sometimes break outside word boundaries when floating objects - affected the width available to the text. This has been fixed. + affected the width available to the text. - QFontEngine * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which @@ -400,25 +429,25 @@ QtGui * [QTBUG-3555] Fixed a bug in the Plastique style that would cause an ASSERT failure in QFont when the application font has a pixel size set. + - QPrintPreviewDialog now uses a QMainWindow with a proper QToolBar, instead + of a plain layout. + QtDBus - QDBusConnection - * Made sending of invalid/incomplete messages consistently fail - with error (no more assertions). - * [249528/QTBUG-3833] Added an overload of connect() that allows - one to specify strings for matching arguments. + * Made sending of invalid/incomplete messages consistently fail with error + (no more assertions). + * [249528/QTBUG-3833] Added an overload of connect() that allows one to + specify strings for matching arguments. - QDBusServiceWatcher - * New class; supports efficiently watching for a service to be - created, deleted or change owners - - - QPrintPreviewDialog now uses a QMainWindow with a proper QToolBar, instead - of a plain layout. + * New class; supports efficiently watching for a service to be created, + deleted or to change owners. QtNetwork - QAbstractSocket - * only disconnect from host when all bytes have been written + * Only disconnect from host when all bytes have been written. * New setSocketOption method. - QHttp @@ -426,28 +455,28 @@ QtNetwork * QHttp is now obsolete and replaced by QNetworkAccessManager. - QLocalServer - * fix timeout when waiting for a connection on Unix + * Fix timeout when waiting for a connection on Unix. - QNativeSocketEngine * Do not set the OS socket send and receive buffer size. The OS should auto tune these values for us. - QNetworkAcessManager - * [242916] add possibility to send HTTP DELETE requests + * [242916] Add possibility to send HTTP DELETE requests. * Connection count per HTTP server increased to 6 on Desktop, 3 on Symbian. * Optional HTTP pipelining support. * General HTTP performance improvements. - QNetworkReply - * [257322] add possibility to ignore specific SSL errors + * [257322] Add possibility to ignore specific SSL errors. * New isFinished() method. - QSslCertificate - * [251830] fix version() and serialNumber() methods + * [251830] Fix version() and serialNumber() methods. - QSslSocket - * [257322] add possibility to ignore specific SSL errors - * Fix build with openssl 1.0.0 betas + * [257322] Add possibility to ignore specific SSL errors. + * Fix build with openssl 1.0.0 betas. * Trigger a SSL transmission when reading from the socket. In certain cases the connection stalled when a buffer limit was used. @@ -495,42 +524,49 @@ QtOpenGL extensions, QtOpenGL will also try postfixing EXT if the OpenGL 2.0 name is not found. - - Fix QGLWidget::showFullscreen() on EGL platforms + - Fix QGLWidget::showFullscreen() on EGL platforms. - Added lots of OpenGL autotests. QtScript - * A lot of internal changes and optimizations. - * Improved ECMA script compliance. - * New method, QScriptString::toArrayIndex(), for converting QScriptString to a QtScript array index. + + - Many optimizations. + - Improved ECMA script compliance. + - New method, QScriptString::toArrayIndex(), for converting QScriptString + to a QtScript array index. QtSql - * [QTBUG-3162] Views for Sql table models should not reset state on failed queries. - * [QTBUG-5251] Fix retrieval of SQL 'TIME' information for PostgreSQL. - * Better error checking for in case of failed query. - * [QTBUG-5179] Fixed Floating point number truncation in qsqlpsql plugin. - * [QTBUG-551] Fixed Oracle batchExec using strings as out params. - * Updated sqlite to 3.6.19 + readded our patches. - * [QTBUG-3736] ODBC: Retrieved in ascii, should be stored in ascii. - * Fixed issue with multiple lookups to same table/field in QSqlRelationalTableModel - * Updated documentation of setForwardOnly - * [QT-754] TDS: Fixed improper formatting of date values - * TDS: Fixed missing field/table name escaping. - * ODBC: Fixed setForwardOnly not being reset on when the query is reset. - * [QTBUG-4510] Add reconnection option to the mysql driver. - * [222678] Fixed QSqlTableModel: trying to delete the wrong row. - * Interbase: Fixed crash when calling numRows on unknown query type. - * DB2: Don't return an error when the table is just empty. - * [17327] Added OCI support for synonyms to tables created by another user. - * [176267] Fixed mysql driver not knowing the difference between tables and views. - * Fixed determination of end of ODBC string on deficient drivers. - * Added ability to open sqlite databases readonly. - * Fixed race condition on reopening an ODBC connection. - * Fixed invalid use of statics in the defaultCasing code. - * Fixed proper quoting under odbc. - * [252450 & 246125] Fixed failed queries due to MySql driver auto-preparing. - * QSqlDatabase now has a database level precisionPolicy. Queries now default to this. - * Add proper iODBC linking support. + + - [QTBUG-3162] Views for Sql table models should not reset state on failed + queries. + - [QTBUG-5251] Fix retrieval of SQL 'TIME' information for PostgreSQL. + - Better error checking in case of failed query. + - [QTBUG-5179] Fixed floating point number truncation in qsqlpsql plugin. + - [QTBUG-551] Fixed Oracle batchExec using strings as out params. + - Updated sqlite to 3.6.19 + readded our patches. + - [QTBUG-3736] ODBC: Retrieved in ascii, should be stored in ascii. + - Fixed issue with multiple lookups to same table/field in + QSqlRelationalTableModel. + - Updated documentation of setForwardOnly. + - [QT-754] TDS: Fixed improper formatting of date values. + - TDS: Fixed missing field/table name escaping. + - ODBC: Fixed setForwardOnly not being reset on when the query is reset. + - [QTBUG-4510] Add reconnection option to the mysql driver. + - [222678] Fixed QSqlTableModel: trying to delete the wrong row. + - Interbase: Fixed crash when calling numRows on unknown query type. + - DB2: Don't return an error when the table is just empty. + - [17327] Added OCI support for synonyms to tables created by another user. + - [176267] Fixed mysql driver not knowing the difference between tables and + views. + - Fixed determination of end of ODBC string on deficient drivers. + - Added ability to open sqlite databases readonly. + - Fixed race condition on reopening an ODBC connection. + - Fixed invalid use of statics in the defaultCasing code. + - Fixed proper quoting under odbc. + - [252450 & 246125] Fixed failed queries due to MySql driver auto-preparing. + - QSqlDatabase now has a database level precisionPolicy. Queries now default + to this. + - Add proper iODBC linking support. QtSvg @@ -544,6 +580,7 @@ QtSvg * [257052] Changed drawImage() to ignore aspect ratio. QtWebKit + - Many bug fixes. - QWebElement @@ -560,14 +597,17 @@ QtWebKit * Streaming operators for saving and restoring QWebHistory's state. - QWebPage - * New property; preferredContentsSize for setting layout of the page in the viewport. - * New slot; shouldInterruptJavaScript, called when JavaScript program is running too long. + * New property; preferredContentsSize for setting layout of the page in the + viewport. + * New slot; shouldInterruptJavaScript, called when JavaScript program is + running too long. - QWebSecurityOrigin: * New functions for defining local URL schemes. - QWebSettings - * New options for text encoding, printing shrink factor and off-line web application cache (HTML5). + * New options for text encoding, printing shrink factor and off-line web + application cache (HTML5). - QWebView * Support for render hints. @@ -575,19 +615,20 @@ QtWebKit QtXml - QDomDocument - * set the codec to UTF-8 if codec not present or unknown + * Set the codec to UTF-8 if codec not present or unknown. QtXmlPatterns - QXmlQuery - * [245219] Added QXmlQuery::setFocus(const QString &focus); + * [245219] Added QXmlQuery::setFocus(const QString &focus). Qt Plugins - Tiff plugin - * [258526] Rotate the image if the tiff file contains an orientation tag + * [258526] Rotate the image if the tiff file contains an orientation tag. * [254317] Add support for mono and indexed format + **************************************************************************** * Platform Specific Changes * **************************************************************************** @@ -616,17 +657,19 @@ Qt for Linux/X11 palette, usage of KColorDialog and KFileDialog) using the GuiPlatformPlugin - Fixed pasting the clipboard content to non-Qt application on X11 when the - requested format is image/ppm. Patch by Ritt.K + requested format is image/ppm. - - On X11 Qt now supports the _NET_WM_SYNC protocol. + - On X11, Qt now supports the _NET_WM_SYNC protocol. - - On X11 Qt now supports the SAVE_TARGET protocol that allows to keep + - On X11, Qt now supports the SAVE_TARGET protocol that allows to keep clipboard contents if the application that owns the clipboards exits - - [QTBUG-4652] On X11 clipboard content can be properly retrieved even when an - application asks the unsupported target. This fixes copying and pasting data - when using Synergy. + - [QTBUG-4652] On X11, clipboard content can be properly retrieved even when + an application asks for the unsupported target. This fixes copying and + pasting data when using Synergy. + - [MR#797] Fixed a crash when using QX11EmbedContainer/Widget on x86_64. + - [MR#1111] Emit workAreaResized when _NET_WORKAREA is changed on X11. - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small @@ -659,8 +702,8 @@ Qt for Linux/X11 event though the program is using the QEventLoop::ExcludeUserInputEvents flag. - - [255559] Fixed generation of XdndLeave events to include the - correct source id. + - [255559] Fixed generation of XdndLeave events to include the correct + source id. - [258319] Avoid division by zero on some Xlib/Xserver implementations. @@ -694,8 +737,8 @@ Qt for Windows - [251554] Fixed openUrl("mailto:") with Thunderbird on Windows. - [254501] QDestopServices now supports cyrillic file names. - Fixed an issue which prevents moving fixed size windows using titlebar. - - [258087] Fixed an issue on Vista which returns incorrect file paths when using - QFileDialog::getOpenFileNames() + - [258087] Fixed an issue on Vista which returns incorrect file paths when + using QFileDialog::getOpenFileNames() - [253763] Fixed a focus issue when using out-of-process ActiveQt controls. - [255912] Mouse move events will not be delivered to a blocked widget. - [225588] Enabled IME reconversion support. @@ -704,13 +747,13 @@ Qt for Windows * Now much more reliable when reading a file through a QIODevice. * If Video Mixing Renderer 9 is not available, falls back to software rendering. - * Fixed a flicker issue when switching source with a transition time of 0 + * Fixed a flicker issue when switching source with a transition time of 0. - [QTBUG-4445] Fixed bug on Windows that caused problems when printing text where several characters were represented by a single glyph, e.g. a double 't' with the Calibri font. - - Added QSysInfo::WV_WINDOWS7 and QSysInfo::WV_6_1 + - Added QSysInfo::WV_WINDOWS7 and QSysInfo::WV_6_1. - Changed QPrintDialog under Windows to use PrintDlgEx, instead of the old deprecated PrintDlg call. @@ -718,58 +761,61 @@ Qt for Windows Qt for Mac OS X --------------- - - Add support for GetURL events on Mac OS X - - [123740] Fixed an issue with dead keys on Mac (cocoa) on French keyboard layout. - - [252088] Drag Leave events will be delivered correctly on Cocoa. - - [257661] Cocoa now uses the correct line ending for clipboard plain text. - - [258438] Enabled Emacs style keyboard shortcuts. - - [258173] Fixed an issue which caused "whatsthis" pointer to flicked on Cocoa. - - [QTBUG-4418] Fixed maximizing and restoring a window on Mac. - - Fixed some warnings that might get printed when reparenting QGLWidget on Cocoa. - - -General changes on Mac OS X: - - Mac OS X version support: Support for 10.3(Panther) has been dropped, support for - 10.6(Snow Leopard) has been added. - - The Cocoa port now supports static linking. - - The Cocoa port now supports the Qt3Support library (with the exception of Q3FileDialog) - to ease the transition from Carbon to Cocoa. - - The Cocoa binary packages are now Intel only (universal i386 and x86_64). - - Snow Leopard notes: - - Gcc 4.2 is used by default. Configure with -platform macx-g++40 to select 4.0. - - Using the 10.4u SDK requires gcc 4.0. - - Configuring for the Cocoa port (-cocoa) produces 64-bit binaries by default. - Use the -arch flags to override. - - Building for ppc64 is no longer supported by the gcc tool chain. - - Building for ppc is still supported. - -Cocoa: -- Fixed stacking order of modal dialogs so that they never rearrange level, or - hide in the background. -- Fixed problem with plugins written with Qt that closes down the native application - when hiding a modal dialog. -- Fixed problem that native applications cannot quit when using plugins written with - Qt from a native application. -- Fixed problem that the menubar is not restored correctly when using plugins written - with Qt from a native application. -- The event dispatcher now integrates better with native applications that spins the - event loop them selves. -- Using Qt::AA_MacPluginApplication will now disable the use of native menubars on mac. -- Sliders and scroll views in Qt now uses pixel scrolling for mouse devices - that supports this. -- Wheel events can now contain a delta with a value as low as 1 for mouse devices that - uses pixel scrolling. + - General changes on Mac OS X: + * Mac OS X version support: Support for 10.3(Panther) has been dropped and + support for 10.6(Snow Leopard) has been added. + * The Cocoa port now supports static linking. + * The Cocoa port now supports the Qt3Support library (with the exception of + Q3FileDialog) to ease the transition from Carbon to Cocoa. + * The Cocoa binary packages are now Intel only (universal i386 and x86_64). + * Snow Leopard notes: + - Gcc 4.2 is used by default. Configure with -platform macx-g++40 to + select 4.0. + - Using the 10.4u SDK requires gcc 4.0. + - Configuring for the Cocoa port (-cocoa) produces 64-bit binaries by + default. Use the -arch flags to override. + - Building for ppc64 is no longer supported by the gcc tool chain. + - Building for ppc is still supported. + * Added support for GetURL events on Mac OS X. + + - General bug fixes: + * [123740] Fixed an issue with dead keys on Mac (cocoa) on French keyboard + layout. + * [258438] Enabled Emacs style keyboard shortcuts. + * [QTBUG-4418] Fixed maximizing and restoring a window. + + - Cocoa bug fixes: + * [252088] Drag Leave events will be delivered correctly on Cocoa. + * [257661] Cocoa now uses the correct line ending for clipboard plain text. + * [258173] Fixed an issue which caused "whatsthis" pointer to flicker. + * Fixed some warnings that might get printed when reparenting QGLWidget. + * Fixed stacking order of modal dialogs so that they never rearrange level, + or hide in the background. + * Fixed problem with plugins written with Qt that closes down the native + application when hiding a modal dialog. + * Fixed problem that native applications cannot quit when using plugins + written with Qt from a native application. + * Fixed problem that the menubar is not restored correctly when using + plugins written with Qt from a native application. + * The event dispatcher now integrates better with native applications that + spin the event loop themselves. + * Using Qt::AA_MacPluginApplication will now disable the use of native + menubars on Mac. + * Sliders and scroll views in Qt now use pixel scrolling for mouse devices + that support this. + * Wheel events can now contain a delta with a value as low as 1 for mouse + devices that use pixel scrolling. Qt for Embedded Linux --------------------- -- Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and - QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES - specific libraries. + - Added QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES1CL and + QMAKE_LIBS_OPENGL_ES2 qmake variables for specifying OpenGL ES + specific libraries. -- Compilation fixes for OpenGL/ES 1.0 and OpenGL/ES 1.1 Common Lite. + - Compilation fixes for OpenGL/ES 1.0 and OpenGL/ES 1.1 Common Lite. -- EGL and OpenGL/ES + - EGL and OpenGL/ES * Protect the use of version-specific EGL symbols with #ifdef's. * Make sure an EGL context is current when resolving GL extensions. * Introduce "lazyDoneCurrent" for optimizing context switching in @@ -781,37 +827,38 @@ Qt for Embedded Linux * Fix detection of pbuffers on OpenGL/ES systems. * EGL_SAMPLES was being set to the wrong value for multisampled surfaces. -- PowerVR + - PowerVR * Make the code better at detecting MBX vs SGX header files. * Fix 32-bit screen support - some code was still assuming 16-bit. * Stop GL window surfaces double-flushing their contents. * Remove surface holder, which never worked all that well. * Implement screen rotations. -- Mouse and keyboard drivers + - Mouse and keyboard drivers * Removed obsolete drivers (vr41xx, yopy, sl5000, bus mouse). * Added a new LinuxInput driver for both mouse and keyboard. * Added keymap support for QWS via standard Linux .kmap files. - (complete with dead-keys, compose-key and LED handling) + (complete with dead-keys, compose-key and LED handling). -- Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. + - Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. -- Send enter/leave events also to child widgets + - Send enter/leave events also to child widgets. -- Fix crash when instantiating multiple QApplications + - Fix crash when instantiating multiple QApplications. -- Optimize software cursor by using native image format instead of 8-bit + - Optimize software cursor by using native image format instead of 8-bit. -- [255828] Avoid window decoration flicker on show + - [255828] Avoid window decoration flicker on show. -- [255495] Fix blend function crash on AVR32 + - [255495] Fix blend function crash on AVR32. -- Fix qconfig configurations + - Fix qconfig configurations. -- Add powerpc mkspec and remove "empty" ppc mkspec + - Add powerpc mkspec and remove "empty" ppc mkspec . Qt for Windows CE ----------------- + - On Windows CE the link time code generation has been disabled by default to be consistent with win32-msvc200x. - The default button size has been reduced in the Windows mobile style. @@ -829,65 +876,52 @@ Qt for Windows CE * Tools * **************************************************************************** -- Designer - - - [233683] Promoted Widgets are now stored correctly in scratchpad. - - [249823] Added search functionality to the resource browser. - - [254282] Enabled the use of promoted widgets in form templates. - - [254824] Made it possible to override the createAction()/createWidget() - functions of QUiLoader. - - [256332] Enabled deleting all pages of a QTabWidget or QStackedWidget. - - [259238] Fixed menubar/menu editing in right-to-left mode. - - [259918] Fixed setting of object names for container pages not to use - localized strings. - - [260658] Fixed saving of alpha values set in the palette editor. - - It is now possible to further specify the kind of custom widget - string properties using XML tags. - -- uic - - - [260784] Generated code for retranslateUi doesn't cause compiler warnings anymore - -- uic3 - - - [128859] Fixed code generation of QLabel's wordWrap property. - -- qdoc3 - - - Changed qdoc3 binary to be in bin/ instead of a platform specific location. - -- Linguist - - - Linguist GUI: Experimental support for editing multi-length strings - - - lupdate is now again the only tool which can parse program code - - - lupdate - - * Actually guess the target language from the file name - * Make -{source,target}-language actually override values from files - * C++ parser - - Properly support "using namespace", etc. - - Remove the obsolete TRANSLATOR hack relating to "using namespace" - - Support attaching meta data to translatable messages - - Actually use the argument of Q_DECLARE_TR_FUNCTIONS - - Optimizations - - Bug fixes and robustness improvements - - - lrelease - - * Add -markuntranslated option - - - both lupdate & lrelease - - * Accuracy improvements of the qmake .pro file parser - * Support for ID-based translations. Somewhat experimental. - - - lconvert - - * Add --sort-contexts option - * Add --locations option (complementing lupdate) - * Add --no-ui-lines option (complementing lupdate) + - Designer + * [233683] Promoted Widgets are now stored correctly in scratchpad. + * [249823] Added search functionality to the resource browser. + * [254282] Enabled the use of promoted widgets in form templates. + * [254824] Made it possible to override the createAction()/createWidget() + functions of QUiLoader. + * [256332] Enabled deleting all pages of a QTabWidget or QStackedWidget. + * [259238] Fixed menubar/menu editing in right-to-left mode. + * [259918] Fixed setting of object names for container pages not to use + localized strings. + * [260658] Fixed saving of alpha values set in the palette editor. + * It is now possible to further specify the kind of custom widget string + properties using XML tags. + + - uic + * [260784] Generated code for retranslateUi doesn't cause compiler warnings + anymore. + + - uic3 + * [128859] Fixed code generation of QLabel's wordWrap property. + + - qdoc3 + * Changed qdoc3 binary to be in bin/ instead of a platform specific location. + + - Linguist + * Linguist GUI: Experimental support for editing multi-length strings. + * lupdate is now again the only tool which can parse program code. + * lupdate + - Actually guess the target language from the file name. + - Make -{source,target}-language actually override values from files. + - C++ parser + * Properly support "using namespace", etc. + * Remove the obsolete TRANSLATOR hack relating to "using namespace". + * Support attaching meta data to translatable message. + * Actually use the argument of Q_DECLARE_TR_FUNCTION. + * Optimization. + * Bug fixes and robustness improvements. + * lrelease + - Add -markuntranslated option. + * Both lupdate & lrelease + - Accuracy improvements of the qmake .pro file parser. + - Support for ID-based translations. Somewhat experimental. + * lconvert + - Add --sort-contexts option. + - Add --locations option (complementing lupdate). + - Add --no-ui-lines option (complementing lupdate). **************************************************************************** @@ -930,9 +964,7 @@ Qt for Windows CE most boards and loading these images will generally require an image conversion anyway. - - Fix a bug regarding QGraphicsProxyWidgets - - - Fix a crash when resizing windows + - Fix a crash when resizing windows. - Compile with versions < 1.0. We still recommend using newer versions. @@ -995,7 +1027,7 @@ Qt for Windows CE - QDesktopWidget on X11 no longer emits the resized(int) signal when screens are added or removed. This was not done on other platforms. Use the - screenCountChanged signal instead + screenCountChanged signal instead. - QUrl's parser is more strict when for hostnames in URLs. QUrl now enforces STD 3 rules: @@ -1011,7 +1043,7 @@ Qt for Windows CE before, but weren't interpreted as such. - The Unix configure-time check for STL is stricter now in Qt - 4.6.0. This means some legacy STL implementations may fail to pass + 4.6. This means some legacy STL implementations may fail to pass the test and, therefore, Qt will automatically disable STL support. This is a binary-compatible change: existing code will continue to @@ -1040,15 +1072,18 @@ Qt for Windows CE if those are set. This matches the behavior on the other platforms. - The Animation Framework - * currentTime() now returns the complete current time including previous loops - * currentLoopTime() returns the time inside the current loop - * stateChanged signal sends the new state as first parameter and old state as - the second - * QAnimationGroup::clearAnimations() has been renamed to clear() - * QAnimationGroup::insertAnimationAt() has been renamed to insertAnimation() - * QAnimationGroup::takeAnimationAt() has been renamed to takeAnimation() - * QSequentialAnimationGroup::insertPauseAt() has been renamed to insertPause() - * [QT-941] Avoids timer ticks when there are only pause animations running + * currentTime() now returns the complete current time including previous + loops. + * currentLoopTime() returns the time inside the current loop. + * stateChanged signal sends the new state as first parameter and old state + as the second. + * QAnimationGroup::clearAnimations() has been renamed to clear(). + * QAnimationGroup::insertAnimationAt() has been renamed to + insertAnimation(). + * QAnimationGroup::takeAnimationAt() has been renamed to takeAnimation(). + * QSequentialAnimationGroup::insertPauseAt() has been renamed to + insertPause(). + * [QT-941] Avoids timer ticks when there are only pause animations running. - Refactoring in OpenGL examples to improve portability and utilize the Animation framework for animation. The hellogl and overpainting examples @@ -1064,3 +1099,4 @@ Qt for Windows CE X11: LIBS += -lX11 Mac: LIBS += -framework AppKit -framework Carbon + -- cgit v0.12 From a7d24a1010f4426ca267dfed20b4afc46fb454ba Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 11 Nov 2009 13:32:45 +1000 Subject: Sort sections in changes file so things are easier to find. Reviewed-by: Trust Me --- dist/changes-4.6.0 | 318 ++++++++++++++++++++++++++--------------------------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index fee8729..12803b8 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -79,6 +79,27 @@ QtCore - QByteArray * New overloads for QByteArray::insert() and QByteArray::prepend(). + - QEventDispatcherGlib (internal class) + * Fix a regression introduced in 4.5.3 that would cause timers to not + be delivered. + + - QEventDispatcherUNIX (internal class) + * Improve detection of monotonic clock support to include + non-POSIX.1-2001 compliant systems. + * [250681] Fix time change detection on UNIX systems without monotonic + timers. + + - QEventDispatcherWin32 (internal class) + * Changed the threshold for using multimedia timers to 20ms (was 10ms). + * Changed the way Qt's posted events are sent by the event + dispatcher. They are now driven on top of a Windows message + instead of an explicit call in processEvents(). This means that + posted events are sent even when a Windows modal message loop is + running (for example, when the user is moving a window or when a + native modal dialog is visible). + * Fixed a bug that would allow the same timer id to be used by multiple + QTimer instances. + - QFile * Make QFile::resize() more robust when operating on buffered files. @@ -111,16 +132,26 @@ QtCore * Fixed a bug where, in a race condition, QSharedPointer could track a pointer that was being deleted. + - QTextCodec + * Instantiate the CP949 codec when building with -no-iconv. + - QTextStream * [221316] Fixed crash on large input. * Improved reading utf8/utf16/utf32 data by correctly skipping the ByteOrderMark when reading data by one character at a time. + - QThread + * [249997] Document that QThread priority has no effect on Linux. + - QUrl * Made QUrl hostname parser a lot stricter, requiring compliance to STD3 to validate, thus preventing invalid hostnames from being accepted. See below in "Important Behavior Changes". + - QUuid + * [QTBUG-3543] Fixed a bug in createUuid() which caused multiple + threads to generate the identical UUID sequences. + - QVariant * Many optimisations. * Added QVariant::toFloat() and QVariant::toReal(). @@ -129,9 +160,6 @@ QtCore identity functions. * Added support for math3d types. - - QXmlStreamWriter - * [256468] Fixed comment indentation. - - QWeakPointer * Added support for tracking QObject-derived classes that aren't attached to a QSharedPointer. @@ -139,50 +167,31 @@ QtCore being tracked (without protection). * Added operator-> like the above data(), but requires a #define. - - QUuid - * [QTBUG-3543] Fixed a bug in createUuid() which caused multiple - threads to generate the identical UUID sequences. - - - QEventDispatcherGlib (internal class) - * Fix a regression introduced in 4.5.3 that would cause timers to not - be delivered. - - - QEventDispatcherUNIX (internal class) - * Improve detection of monotonic clock support to include - non-POSIX.1-2001 compliant systems. - * [250681] Fix time change detection on UNIX systems without monotonic - timers. - - - QEventDispatcherWin32 (internal class) - * Changed the threshold for using multimedia timers to 20ms (was 10ms). - * Changed the way Qt's posted events are sent by the event - dispatcher. They are now driven on top of a Windows message - instead of an explicit call in processEvents(). This means that - posted events are sent even when a Windows modal message loop is - running (for example, when the user is moving a window or when a - native modal dialog is visible). - * Fixed a bug that would allow the same timer id to be used by multiple - QTimer instances. - - - QTextCodec - * Instantiate the CP949 codec when building with -no-iconv. - - - QThread - * [249997] Document that QThread priority has no effect on Linux. + - QXmlStreamWriter + * [256468] Fixed comment indentation. QtGui - Qt::escape * Now escape the double quote ("). - - QGraphicsAnchorLayout - * Support for expanding size policy has been removed. (The Qt 4.6 Beta - had support for it). + - QAbstractItemView + * [256502] Fixes selectionModel::hasSelection return value after + model::reset. + + - QApplication + * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). - QCalendarWidget * [252943] QCalendarWidget::setDateTextFormat() reset the format if the date is invalid. + - QColumnView + * [246999] Fixed view not updating when the model changed dynamically. + + - QComboBox + * [220195] Fixed keyboard search when current index is -1. + - QCompleter * [246056] Fixed a possible assertion when setting the completer prefix. @@ -192,6 +201,23 @@ QtGui - QFontDialog * [256466] Fixed the dialog not always returning the selected style. + - QFontEngine + * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which + also contain a regular unicode table for exactly the symbol range of + code points. + + - QFontEngineQPF + * Make alphaMapForGlyph() generate the correct color table for + Indexed8 and Mono glyph images. Fixed the "all glyphs are white + boxes" problem in OpenGL1 paint engine. + + - QFontMetrics + * [176401] Account for right bearing in bounding rect. + + - QGraphicsAnchorLayout + * Support for expanding size policy has been removed. (The Qt 4.6 Beta + had support for it). + - QGraphicsBlurEffect * Since the 4.6 Beta, Qt::RenderHint has been moved to QGraphicsBlurEffect::BlurHint. @@ -256,28 +282,15 @@ QtGui constraints. * Reduced memory footprint. - - QAbstractItemView - * [256502] Fixes selectionModel::hasSelection return value after - model::reset. - - QHeaderView * [208320] Make sure the sort indicator is taken into account for the size hint. * [255574] Make sure the size hint for the section depends on visible sections. - - QMainWindow - * [226060] Adding actions to a toolbar would always make the next toolbar - move. - - - QMenuBar - * [260873] Fix mouse interaction while undocking a widget from the main - window - * Dock areas didn't get a splitter if their dock widgets were not - resizable. - - - QColumnView - * [246999] Fixed view not updating when the model changed dynamically. + - QImageReader + * [255627] Fix floating point exception in + QImageReader::setScaledSize(QSize(0, 0)). - QLineEdit * [248948] Clear selection when redoing a delete operation. @@ -288,85 +301,19 @@ QtGui * [243335] Fixed the visualRect to return correct values when the widget is not yet shown. - - QTreeView - * [234930] Be able to use :has-children and :has-sibillings in a stylesheet. - * [252616] Set QStyleOptionViewItemV4::OnlyOne flag when painting spanning - columns. - * [245654] Fixed expandAll when deleting and recreating a mode for the tree. - * [239271] Fixed missing update when adding a row when the first column is - hidden. - * [258225] Fixed scrollTo with center and bottom. - - - QTreeWidget - * [253109] Shows the widget when calling setItemWidget. - - - QTableView - * [191545] Selections work more similarly to well-known spreadsheets. - * [234926] Fixed sorting after changing QTableView header. - * [244651] [245327] [250193] [QTBUG-5062] Spans get plenty of love with - performance improvements, support for row/column insertioa and removal, - and better keyboard navigation. - - - QTableWidget - * [234641] Fixed takeItem to cause the view to be updated. - - - QTabBar - * [196326] Fixed having a stylesheet on a QTabBar resulted in some tab - names being slightly clipped. - * [241383] Added ability to style the close tab button with style sheet - - - QImageReader - * [255627] Fix floating point exception in - QImageReader::setScaledSize(QSize(0, 0)). - - - QComboBox - * [220195] Fixed keyboard search when current index is -1. - - - QPixmap - * Optimized width(), height(), isNull() and depth(). - * [QTBUG-2832] Fixed bug where calling fill on pixmap with active painter - could crash. - - - QRegion - * Minor optimizations. - - - QSpinBox - * [259226] Fixed setting a stylesheet on a QSpinBox to change the arrow - position. - * [255051] Fixed sizeHint update bug. - - - QStandardItemModel - * [255652] Fixed crash while using takeRow with a QSortFilterProxyModel. - - - QToolTip - * Fixed a bug where tooltips were not shown in popups (Windows only). + - QMainWindow + * [226060] Adding actions to a toolbar would always make the next toolbar + move. - QMenu * [252610] Fixed position of the shortcut text while setting a stylesheet on menu items - - QSortFilterProxyModel - * [251296] Fixed bugs in which filtered items could not be filtered. - - - QSplitter - * [206494] Added ability to style pressed slider with stylesheet. - - - QStroker - * [QTBUG-5212] Fixed bug where thick strokes around small shapes could - cause holes in the stroke. - - - QWidget - * Added inputMethodHints property. - * [201649] Added QWidget::previousInFocusChain. - * [254563] Fixed a crash when setting focus in a widget tree that - contains invisible widgets. - * [QTBUG-5012] Fixed uninitialized background when using QWidget::render - with Qt::WA_NoSystemBackground and window opacity set. - - - QFontEngineQPF - * Make alphaMapForGlyph() generate the correct color table for - Indexed8 and Mono glyph images. Fixed the "all glyphs are white - boxes" problem in OpenGL1 paint engine. + - QMenuBar + * [260873] Fix mouse interaction while undocking a widget from the main + window + * Dock areas didn't get a splitter if their dock widgets were not + resizable. - QPaintDevice * New qt_paint_device_metric() function to replace the friend declarations @@ -384,6 +331,26 @@ QtGui - QPen * [QTBUG-2738] Made QPen::setDashOffset() work with non-custom dashed lines. + - QPixmap + * Optimized width(), height(), isNull() and depth(). + * [QTBUG-2832] Fixed bug where calling fill on pixmap with active painter + could crash. + + - QPlainTextEdit + * Fixed crash when clicking on a text edit which was smaller than the + height of the font used. + + - QPlastiqueStyle + * [QTBUG-3555] Fixed a bug in the Plastique style that would cause an + ASSERT failure in QFont when the application font has a pixel size set. + + - QPrinter + * [QTBUG-4497] Removed redundant SetPen command in the postscript code when + reusing a QPrinter object. + + - QPrintPreviewDialog now uses a QMainWindow with a proper QToolBar, instead + of a plain layout. + - QPushButton * [255581] Fixed sizeHint recalculation bug. @@ -391,22 +358,41 @@ QtGui * [QTBUG-4210] Fixed bug where bitmaps were painted black instead of in pen colour. - - QApplication - * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). + - QRegion + * Minor optimizations. - - QPlainTextEdit - * Fixed crash when clicking on a text edit which was smaller than the - height of the font used. + - QSortFilterProxyModel + * [251296] Fixed bugs in which filtered items could not be filtered. - - QPrinter - * [QTBUG-4497] Removed redundant SetPen command in the postscript code when - reusing a QPrinter object. + - QSplitter + * [206494] Added ability to style pressed slider with stylesheet. - - QTextLayout - * [QTBUG-4468] Count tabs as multiple characters when applying a fixed - column width. - * [176401] Take into account the negative right bearing of the last - character in an item of text if the glyph extends beyond its ascent. + - QSpinBox + * [259226] Fixed setting a stylesheet on a QSpinBox to change the arrow + position. + * [255051] Fixed sizeHint update bug. + + - QStandardItemModel + * [255652] Fixed crash while using takeRow with a QSortFilterProxyModel. + + - QStroker + * [QTBUG-5212] Fixed bug where thick strokes around small shapes could + cause holes in the stroke. + + - QTabBar + * [196326] Fixed having a stylesheet on a QTabBar resulted in some tab + names being slightly clipped. + * [241383] Added ability to style the close tab button with style sheet + + - QTableView + * [191545] Selections work more similarly to well-known spreadsheets. + * [234926] Fixed sorting after changing QTableView header. + * [244651] [245327] [250193] [QTBUG-5062] Spans get plenty of love with + performance improvements, support for row/column insertioa and removal, + and better keyboard navigation. + + - QTableWidget + * [234641] Fixed takeItem to cause the view to be updated. - QTextDocument * [207189] Support setting font size using short hand syntax in the @@ -420,20 +406,34 @@ QtGui would sometimes break outside word boundaries when floating objects affected the width available to the text. - - QFontEngine - * [QTBUG-2354] Support certain 'Microsoft' platform symbol fonts which - also contain a regular unicode table for exactly the symbol range of - code points. + - QTextLayout + * [QTBUG-4468] Count tabs as multiple characters when applying a fixed + column width. + * [176401] Take into account the negative right bearing of the last + character in an item of text if the glyph extends beyond its ascent. - - QFontMetrics - * [176401] Account for right bearing in bounding rect. + - QToolTip + * Fixed a bug where tooltips were not shown in popups (Windows only). - - QPlastiqueStyle - * [QTBUG-3555] Fixed a bug in the Plastique style that would cause an - ASSERT failure in QFont when the application font has a pixel size set. + - QTreeView + * [234930] Be able to use :has-children and :has-sibillings in a stylesheet. + * [252616] Set QStyleOptionViewItemV4::OnlyOne flag when painting spanning + columns. + * [245654] Fixed expandAll when deleting and recreating a mode for the tree. + * [239271] Fixed missing update when adding a row when the first column is + hidden. + * [258225] Fixed scrollTo with center and bottom. - - QPrintPreviewDialog now uses a QMainWindow with a proper QToolBar, instead - of a plain layout. + - QTreeWidget + * [253109] Shows the widget when calling setItemWidget. + + - QWidget + * Added inputMethodHints property. + * [201649] Added QWidget::previousInFocusChain. + * [254563] Fixed a crash when setting focus in a widget tree that + contains invisible widgets. + * [QTBUG-5012] Fixed uninitialized background when using QWidget::render + with Qt::WA_NoSystemBackground and window opacity set. QtDBus @@ -485,15 +485,20 @@ QtNetwork QtOpenGL + - QGLColormap + * setEntry() was inserting entries instead of replacing them. + * Clarified documentation for isEmpty(). + + - QGLContext + * Fix RGB565 mode in bindTexture(). + * Map mipmaps work on OpenGL/ES 2.0 systems in bindTexture(). + * Improve performance of QGLContext::currentContext(). + - QGLFormat * Increase unit test coverage and fix some long-standing issues. * Improve performance of code that tests QGLFormat options. * operator==() now tests for equality on all fields. - - QGLColormap - * setEntry() was inserting entries instead of replacing them. - * Clarified documentation for isEmpty(). - - QGLFramebufferObject * Add support for the ARB_framebuffer_object, OES_framebuffer_object, and OES_packed_depth_stencil extensions. @@ -505,11 +510,6 @@ QtOpenGL - Improvements to context sharing and object cleanup logic. - - QGLContext - * Fix RGB565 mode in bindTexture(). - * Map mipmaps work on OpenGL/ES 2.0 systems in bindTexture(). - * Improve performance of QGLContext::currentContext(). - - QGLGradientCache * [249919] Clean up the gradient cache in the right context. -- cgit v0.12 From 62487172ed3822d863553a7b7b50bcdbf05923a6 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 11 Nov 2009 13:39:27 +1000 Subject: Correct URL format. Reviewed-by: Trust Me --- doc/src/platforms/supported-platforms.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index 232eca6..560ddfe 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -86,7 +86,7 @@ \row \o Apple Mac OS X 10.5 "Leopard" x86_64 (Carbon, Cocoa 32 and 64bit) \o As provided by Apple \row \o Embedded Linux QWS (ARM) - \o gcc (\l{http://www.codesourcery.com}{Codesourcery version)} + \o gcc (\l{http://www.codesourcery.com/}{Codesourcery version)} \row \o Windows CE 5.0 (ARMv4i, x86, MIPS) \o MSVC 2005 WinCE 5.0 Standard (x86, pocket, smart, mipsii) \row \o Symbian (S60 3.1, 3.2 and 5.0) @@ -125,7 +125,7 @@ \row \o Linux \o Intel Compiler \row \o Embedded Linux QWS (Mips, PowerPC) - \o gcc (\l{http:\\www.codesourcery.com}{Codesourcery version)} + \o gcc (\l{http://www.codesourcery.com/}{Codesourcery version)} \row \o Embedded Linux X11 (ARM) \o gcc (\l{http://www.scratchbox.org/}{Scratchbox)} \row \o Windows CE 6.0 (ARMv4i, x86, MIPS) -- cgit v0.12 From 1a36403e3c21a60f81cd0244b84f21223b4216e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 11 Nov 2009 10:15:12 +0100 Subject: Fixed QGraphicsEffectSource autotest after graphics effect API changes. --- .../tst_qgraphicseffectsource.cpp | 50 +++++++++------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 55294d5..9991ab4 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -46,6 +46,8 @@ #include #include +#include + //TESTED_CLASS= //TESTED_FILES= @@ -54,13 +56,12 @@ class CustomItem : public QGraphicsRectItem public: CustomItem(qreal x, qreal y, qreal width, qreal height) : QGraphicsRectItem(x, y, width, height), numRepaints(0), - m_painter(0), m_styleOption(0) + m_painter(0) {} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { m_painter = painter; - m_styleOption = option; ++numRepaints; QGraphicsRectItem::paint(painter, option, widget); } @@ -69,12 +70,10 @@ public: { numRepaints = 0; m_painter = 0; - m_styleOption = 0; } int numRepaints; QPainter *m_painter; - const QStyleOption *m_styleOption; }; class CustomEffect : public QGraphicsEffect @@ -84,7 +83,7 @@ public: : QGraphicsEffect(), numRepaints(0), m_margin(10), m_sourceChanged(false), m_sourceBoundingRectChanged(false), doNothingInDraw(false), storeDeviceDependentStuff(false), - m_painter(0), m_styleOption(0), m_source(0) + m_painter(0), m_source(0) {} QRectF boundingRectFor(const QRectF &rect) const @@ -96,7 +95,6 @@ public: m_sourceChanged = false; m_sourceBoundingRectChanged = false; m_painter = 0; - m_styleOption = 0; m_source = 0; deviceCoordinatesPixmap = QPixmap(); deviceRect = QRect(); @@ -112,20 +110,19 @@ public: int margin() const { return m_margin; } - void draw(QPainter *painter, QGraphicsEffectSource *source) + void draw(QPainter *painter) { ++numRepaints; if (storeDeviceDependentStuff) { - deviceCoordinatesPixmap = source->pixmap(Qt::DeviceCoordinates); - deviceRect = source->deviceRect(); - sourceDeviceBoundingRect = source->boundingRect(Qt::DeviceCoordinates); + deviceCoordinatesPixmap = source()->pixmap(Qt::DeviceCoordinates); + deviceRect = QRect(0, 0, painter->device()->width(), painter->device()->height()); + sourceDeviceBoundingRect = source()->boundingRect(Qt::DeviceCoordinates); } if (doNothingInDraw) return; - m_source = source; + m_source = source(); m_painter = painter; - m_styleOption = source->styleOption(); - source->draw(painter); + source()->draw(painter); } void sourceChanged() @@ -141,7 +138,6 @@ public: bool doNothingInDraw; bool storeDeviceDependentStuff; QPainter *m_painter; - const QStyleOption *m_styleOption; QGraphicsEffectSource *m_source; QPixmap deviceCoordinatesPixmap; QRect deviceRect; @@ -227,8 +223,6 @@ void tst_QGraphicsEffectSource::styleOption() QTest::qWait(50); QCOMPARE(item->numRepaints, 1); QCOMPARE(effect->numRepaints, 1); - QVERIFY(effect->m_styleOption); - QCOMPARE(effect->m_styleOption, item->m_styleOption); } void tst_QGraphicsEffectSource::isPixmap() @@ -291,10 +285,6 @@ void tst_QGraphicsEffectSource::boundingRect() void tst_QGraphicsEffectSource::deviceRect() { - QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context"); - QCOMPARE(effect->source()->deviceRect(), QRect()); - - // We can at least check that the rect was correct in QGraphicsEffect::draw. effect->storeDeviceDependentStuff = true; effect->source()->update(); QTest::qWait(50); @@ -332,13 +322,13 @@ public: return src.adjusted(-10, -10, 10, 10); } - void draw(QPainter *, QGraphicsEffectSource *source) { - pix = source->pixmap(coordinateMode, &offset, padMode); + void draw(QPainter *) { + pix = source()->pixmap(coordinateMode, &offset, padMode); } QPixmap pix; QPoint offset; - QGraphicsEffectSource::PixmapPadMode padMode; + QGraphicsEffect::PixmapPadMode padMode; Qt::CoordinateSystem coordinateMode; }; @@ -351,32 +341,32 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::addColumn("ulPixel"); QTest::newRow("log,nopad") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::NoExpandPadMode) + << int(QGraphicsEffect::NoPad) << QSize(10, 10) << QPoint(0, 0) << 0xffff0000u; QTest::newRow("log,transparent") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << int(QGraphicsEffect::PadToTransparentBorder) << QSize(14, 14) << QPoint(-2, -2) << 0x00000000u; QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << int(QGraphicsEffect::PadToEffectiveBoundingRect) << QSize(30, 30) << QPoint(-10, -10) << 0x00000000u; QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::NoExpandPadMode) + << int(QGraphicsEffect::NoPad) << QSize(20, 20) << QPoint(40, 40) << 0xffff0000u; QTest::newRow("dev,transparent") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << int(QGraphicsEffect::PadToTransparentBorder) << QSize(24, 24) << QPoint(38, 38) << 0x00000000u; QTest::newRow("dev,effectrect") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << int(QGraphicsEffect::PadToEffectiveBoundingRect) << QSize(40, 40) << QPoint(30, 30) << 0x00000000u; @@ -404,7 +394,7 @@ void tst_QGraphicsEffectSource::pixmapPadding() QFETCH(QSize, size); QFETCH(uint, ulPixel); - effect->padMode = (QGraphicsEffectSource::PixmapPadMode) padMode; + effect->padMode = (QGraphicsEffect::PixmapPadMode) padMode; effect->coordinateMode = (Qt::CoordinateSystem) coordinateMode; scene->render(&dummyPainter, scene->itemsBoundingRect(), scene->itemsBoundingRect()); -- cgit v0.12 From 95db13345cd7b6b7cac8725fe2879aaf80233818 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 Nov 2009 10:22:39 +0100 Subject: Autotest: fix compiling after qscopedpointer.h changed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QCustomScopedPointer was moved to a private header since it's only a helper class. QScopedSharedPointer wasn't necessary since it can be replaced with QSharedDataPointer neatly. Reviewed-by: Jesper Thomschütz --- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 31 +++--------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index f319891..ddd5579 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -413,27 +413,6 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); { - // QCustomScopedPointer is an internal helper class -- it is unsupported! - - RefCounted *a = new RefCounted; - RefCounted *b = new RefCounted; - - QCOMPARE( int(RefCounted::instanceCount), 2 ); - - QCustomScopedPointer pa1(a); - QCustomScopedPointer pa2(a); - QCustomScopedPointer pb(b); - - scopedPointerComparisonTest(pa1, pa2, pb); - - pa2.take(); - - QCOMPARE( int(RefCounted::instanceCount), 2 ); - } - - QCOMPARE( int(RefCounted::instanceCount), 0 ); - - { // QScopedSharedPointer is an internal helper class -- it is unsupported! RefCounted *a = new RefCounted; @@ -441,13 +420,9 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 2 ); - a->ref.ref(); - QScopedSharedPointer pa1(a); - a->ref.ref(); - QScopedSharedPointer pa2(a); - b->ref.ref(); - QScopedSharedPointer pb(b); - + QSharedDataPointer pa1(a); + QSharedDataPointer pa2(a); + QSharedDataPointer pb(b); QCOMPARE( int(a->ref), 2 ); QCOMPARE( int(b->ref), 1 ); -- cgit v0.12