From f5b3224cb5321b8b3ffefff13f547fbe81ea0c7c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 20 Sep 2013 13:39:08 +0200 Subject: [PATCH 01/32] qdoc: \externalpage links are fixed The problem was they were being incorrectly written to and read from the index files. Task-number: QTBUG-33510 Change-Id: Ib0b34265cd22fff5ed88ae2fd5d5d7ea58b3761d Reviewed-by: Jerome Pasion --- src/tools/qdoc/htmlgenerator.cpp | 4 +++- src/tools/qdoc/node.h | 2 ++ src/tools/qdoc/qdocindexfiles.cpp | 26 ++++++++++++++++---------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 1c28ede976..ac10bb94e3 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -3605,8 +3605,10 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative) back down into the other subdirectory. */ if (node && relative && (node != relative)) { - if (useOutputSubdirs() && node->outputSubdirectory() != relative->outputSubdirectory()) + if (useOutputSubdirs() && !node->isExternalPage() && + node->outputSubdirectory() != relative->outputSubdirectory()) { link.prepend(QString("../" + node->outputSubdirectory() + QLatin1Char('/'))); + } } return link; } diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 76e762120e..f1d9931a08 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -211,6 +211,7 @@ public: virtual bool isWrapper() const; virtual bool isReadOnly() const { return false; } virtual bool isDefault() const { return false; } + virtual bool isExternalPage() const { return false; } virtual void addMember(Node* ) { } virtual bool hasMembers() const { return false; } virtual bool hasNamespaces() const { return false; } @@ -514,6 +515,7 @@ public: virtual bool isGroup() const { return (subType() == Node::Group); } virtual bool isExample() const { return (subType() == Node::Example); } virtual bool isExampleFile() const { return (parent() && parent()->isExample()); } + virtual bool isExternalPage() const { return nodeSubtype_ == ExternalPage; } protected: SubType nodeSubtype_; diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index d8cb42513e..bef22631f0 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -499,9 +499,10 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, QString moduleName = element.attribute("module"); if (!moduleName.isEmpty()) node->setModuleName(moduleName); - if (!indexUrl.isEmpty()) { + if (node->isExternalPage()) + node->setUrl(href); + else if (!indexUrl.isEmpty()) node->setUrl(indexUrl + QLatin1Char('/') + href); - } QString since = element.attribute("since"); if (!since.isEmpty()) { @@ -776,15 +777,20 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, if (!qmlFullBaseName.isEmpty()) writer.writeAttribute("qml-base-type", qmlFullBaseName); } - QString fullName = node->fullDocumentName(); - if (fullName != objName) - writer.writeAttribute("fullname", fullName); + QString href; - if (Generator::useOutputSubdirs()) - href = node->outputSubdirectory(); - if (!href.isEmpty()) - href.append(QLatin1Char('/')); - href.append(gen_->fullDocumentLocation(node)); + if (!node->isExternalPage()) { + QString fullName = node->fullDocumentName(); + if (fullName != objName) + writer.writeAttribute("fullname", fullName); + if (Generator::useOutputSubdirs()) + href = node->outputSubdirectory(); + if (!href.isEmpty()) + href.append(QLatin1Char('/')); + href.append(gen_->fullDocumentLocation(node)); + } + else + href = node->name(); writer.writeAttribute("href", href); writer.writeAttribute("location", node->location().fileName()); From bb9cc387f09abd4ae8819f1470cb275842b85a44 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 23 Sep 2013 15:07:00 +0200 Subject: [PATCH 02/32] Fix a c&p bug in the IA2 bridge when returning the row description Unfortunately we returned the column description when the AT client asked for the row description.... Change-Id: I46bc0edb4fd0f7cc6d98d7d6e0d8ca6f77553a26 Reviewed-by: Frederik Gladhorn --- .../platforms/windows/accessible/iaccessible2.cpp | 2 +- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index a0f2c1812f..9170c774b4 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -955,7 +955,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_rowDescription(long row, BS *description = 0; if (QAccessibleTableInterface *tableIface = tableInterface()) { - const QString qtDesc = tableIface->columnDescription(row); + const QString qtDesc = tableIface->rowDescription(row); if (!qtDesc.isEmpty()) *description = QStringToBSTR(qtDesc); } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b03aafcf0d..0a705949f3 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -3481,8 +3481,13 @@ void tst_QAccessibility::bridgeTest() BSTR bstrDescription; hr = ia2Table->get_columnDescription(0, &bstrDescription); QVERIFY(SUCCEEDED(hr)); - const QString description((QChar*)bstrDescription); - QCOMPARE(description, QLatin1String("h1")); + QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("h1")); + ::SysFreeString(bstrDescription); + + hr = ia2Table->get_rowDescription(1, &bstrDescription); + QVERIFY(SUCCEEDED(hr)); + QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("v2")); + ::SysFreeString(bstrDescription); IAccessible *accTableCell = 0; hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell); From 645f9d959ff1c167f91bf041e0fa59b97fa97dd7 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Mon, 23 Sep 2013 16:41:22 +0200 Subject: [PATCH 03/32] Fixed build issue on BlackBerry BlackBerry build was missing QTzTimeZonePrivate implementation. Change-Id: Ieaf6148a67c66f330e846c93f829ca17a4494359 Reviewed-by: Mehdi Fekari Reviewed-by: Thiago Macieira Reviewed-by: Wolfgang Bremer --- src/corelib/tools/tools.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index e38bea3181..e043a4cd15 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -120,7 +120,7 @@ SOURCES += \ tools/qstring_mac.mm } else:blackberry { - SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_blackberry.cpp + SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_blackberry.cpp tools/qtimezoneprivate_tz.cpp HEADERS += tools/qlocale_blackberry.h } else:unix:SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp From 58b08ba40b849864ceb2c08f65b0be08ac6fa47a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 22 Sep 2013 19:01:49 -0700 Subject: [PATCH 04/32] Fix conversion from 8-bit to QString without proper encoding Found by ICC. Change-Id: Icd89e7df828afdb2acf2c46e00698ef04d5d94c9 Reviewed-by: Konstantin Ritt Reviewed-by: John Layt --- src/corelib/tools/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ac9639385a..d64d929d5a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4898,7 +4898,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) break; case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED - spec = QStringLiteral(" Qt::TimeZone ") + date.timeZone().id(); + spec = QStringLiteral(" Qt::TimeZone ") + QString::fromLatin1(date.timeZone().id()); break; #endif // QT_BOOTSTRAPPED case Qt::LocalTime: From c81d0586b5f22715ce66d0f14cf079424700358b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 22 Sep 2013 18:48:42 -0700 Subject: [PATCH 05/32] De-inline virtuals of some non-exported private classes in QtGui This is to work around a bug in GCC 4.7's link-time optimiser. Without it, linking QtOpenGL and QtPrintSupport fails because the compiler generates the code for the virtuals, including the virtual table, but not the methods. Change-Id: Idcecd51c32e6228e0eefe67f1bd630ea1f5d5da7 Reviewed-by: Konstantin Ritt --- src/gui/text/qfontengine.cpp | 9 +++++++++ src/gui/text/qfontengine_p.h | 4 ++-- src/widgets/widgets/qtabbar.cpp | 12 ++++++++++++ src/widgets/widgets/qtabbar_p.h | 6 ++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 810b51b9c4..b3889a02a4 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1880,4 +1880,13 @@ QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosit return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t); } +QTestFontEngine::QTestFontEngine(int size) + : QFontEngineBox(size) +{} + +QFontEngine::Type QTestFontEngine::type() const +{ + return TestFontEngine; +} + QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 1a6862898d..d3faef93bb 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -434,8 +434,8 @@ protected: class QTestFontEngine : public QFontEngineBox { public: - QTestFontEngine(int size) : QFontEngineBox(size) {} - virtual Type type() const { return TestFontEngine; } + QTestFontEngine(int size); + virtual Type type() const; }; QT_END_NAMESPACE diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index aa7677869c..94c85ff92b 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -2370,8 +2370,20 @@ void CloseButton::paintEvent(QPaintEvent *) style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); } +void QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue(const QVariant ¤t) +{ + priv->moveTab(priv->tabList.indexOf(*tab), current.toInt()); +} + +void QTabBarPrivate::Tab::TabBarAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State newState) +{ + if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab)); +} + QT_END_NAMESPACE #include "moc_qtabbar.cpp" #endif // QT_NO_TABBAR + + diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 8c6e70b8d7..b7b6998ca3 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -126,11 +126,9 @@ public: TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv) { setEasingCurve(QEasingCurve::InOutQuad); } - void updateCurrentValue(const QVariant ¤t) - { priv->moveTab(priv->tabList.indexOf(*tab), current.toInt()); } + void updateCurrentValue(const QVariant ¤t); - void updateState(State, State newState) - { if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab)); } + void updateState(State, State newState); private: //these are needed for the callbacks Tab *tab; From e43174755c2c9e525849652139dcb210153e8e98 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 22 Sep 2013 18:09:08 -0700 Subject: [PATCH 06/32] Fix warnings about conversion from const char* to QString. Change-Id: I6d3dca0688a94eb34b55efc841a75e4ebd3a2bd7 Reviewed-by: Konstantin Ritt Reviewed-by: John Layt --- src/printsupport/kernel/qcups.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index c724bde4fa..21029c09e5 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -517,15 +517,15 @@ void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerShee QStringList cupsOptions = cupsOptionsList(printer); static const char *pagesPerSheetData[] = { "1", "2", "4", "6", "9", "16", 0 }; static const char *pageLayoutData[] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl", 0}; - setCupsOption(cupsOptions, QStringLiteral("number-up"), pagesPerSheetData[pagesPerSheet]); - setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), pageLayoutData[pagesPerSheetLayout]); + setCupsOption(cupsOptions, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet])); + setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout])); setCupsOptions(printer, cupsOptions); } void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo) { QStringList cupsOptions = cupsOptionsList(printer); - setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QString("%1-%2").arg(pageFrom).arg(pageTo)); + setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo)); setCupsOptions(printer, cupsOptions); } From 373e44df12af3848cdfdd3cc54680ab51ad7b23d Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Mon, 23 Sep 2013 19:04:39 +0300 Subject: [PATCH 07/32] QFileSystemModel: Fix build when QT_NO_FILESYSTEMWATCHER is defined This class already has some guards for QT_NO_FILESYSTEMWATCHER; implement the rest. Change-Id: I97072c9cd1debb726f9d10ff49ff0c01bbb9bc6e Reviewed-by: Frederik Gladhorn --- src/widgets/dialogs/qfilesystemmodel.cpp | 47 +++++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 9c6d972baa..53dd01319f 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -201,7 +201,9 @@ bool QFileSystemModel::remove(const QModelIndex &aindex) { const QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast(d_func()); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(path); +#endif return QDir(path).removeRecursively(); } @@ -423,7 +425,9 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS return const_cast(&root); QFileSystemModelPrivate *p = const_cast(this); node = p->addNode(parent, element,info); +#ifndef QT_NO_FILESYSTEMWATCHER node->populate(fileInfoGatherer.getInfo(info)); +#endif } else { node = parent->children.value(element); } @@ -610,7 +614,9 @@ void QFileSystemModel::fetchMore(const QModelIndex &parent) if (indexNode->populatedChildren) return; indexNode->populatedChildren = true; +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.list(filePath(parent)); +#endif } /*! @@ -648,8 +654,10 @@ QVariant QFileSystemModel::myComputer(int role) const switch (role) { case Qt::DisplayRole: return d->myComputer(); +#ifndef QT_NO_FILESYSTEMWATCHER case Qt::DecorationRole: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); +#endif } return QVariant(); } @@ -683,12 +691,14 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: if (index.column() == 0) { QIcon icon = d->icon(index); +#ifndef QT_NO_FILESYSTEMWATCHER if (icon.isNull()) { if (d->node(index)->isDir()) icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder); else icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File); } +#endif // QT_NO_FILESYSTEMWATCHER return icon; } break; @@ -778,7 +788,11 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const if (!index.isValid()) return QString(); QFileSystemNode *dirNode = node(index); - if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { + if ( +#ifndef QT_NO_FILESYSTEMWATCHER + fileInfoGatherer.resolveSymlinks() && +#endif + !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { QString fullPath = QDir::fromNativeSeparators(filePath(index)); if (resolvedSymLinks.contains(fullPath)) return resolvedSymLinks[fullPath]; @@ -859,7 +873,9 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in QFileInfo info(d->rootDir, newName); oldValue->fileName = newName; oldValue->parent = parentNode; +#ifndef QT_NO_FILESYSTEMWATCHER oldValue->populate(d->fileInfoGatherer.getInfo(info)); +#endif oldValue->isVisible = true; parentNode->children.remove(oldName); @@ -1278,7 +1294,10 @@ QString QFileSystemModel::filePath(const QModelIndex &index) const Q_D(const QFileSystemModel); QString fullPath = d->filePath(index); QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index); - if (dirNode->isSymLink() && d->fileInfoGatherer.resolveSymlinks() + if (dirNode->isSymLink() +#ifndef QT_NO_FILESYSTEMWATCHER + && d->fileInfoGatherer.resolveSymlinks() +#endif && d->resolvedSymLinks.contains(fullPath) && dirNode->isDir()) { QFileInfo resolvedInfo(fullPath); @@ -1333,7 +1352,9 @@ QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &na d->addNode(parentNode, name, QFileInfo()); Q_ASSERT(parentNode->children.contains(name)); QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name]; +#ifndef QT_NO_FILESYSTEMWATCHER node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name))); +#endif d->addVisibleFiles(parentNode, QStringList(name)); return d->index(node); } @@ -1395,7 +1416,9 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath) //We remove the watcher on the previous path if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) { //This remove the watcher for the old rootPath +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(rootPath()); +#endif //This line "marks" the node as dirty, so the next fetchMore //call on the path will ask the gatherer to install a watcher again //But it doesn't re-fetch everything @@ -1449,7 +1472,9 @@ QDir QFileSystemModel::rootDirectory() const void QFileSystemModel::setIconProvider(QFileIconProvider *provider) { Q_D(QFileSystemModel); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.setIconProvider(provider); +#endif d->root.updateIcon(provider, QString()); } @@ -1458,8 +1483,12 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider) */ QFileIconProvider *QFileSystemModel::iconProvider() const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); return d->fileInfoGatherer.iconProvider(); +#else + return 0; +#endif } /*! @@ -1506,14 +1535,20 @@ QDir::Filters QFileSystemModel::filter() const */ void QFileSystemModel::setResolveSymlinks(bool enable) { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(QFileSystemModel); d->fileInfoGatherer.setResolveSymlinks(enable); +#endif } bool QFileSystemModel::resolveSymlinks() const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); return d->fileInfoGatherer.resolveSymlinks(); +#else + return false; +#endif } /*! @@ -1620,7 +1655,9 @@ bool QFileSystemModel::event(QEvent *event) { Q_D(QFileSystemModel); if (event->type() == QEvent::LanguageChange) { +#ifndef QT_NO_FILESYSTEMWATCHER d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString()); +#endif return true; } return QAbstractItemModel::event(event); @@ -1630,7 +1667,9 @@ bool QFileSystemModel::rmdir(const QModelIndex &aindex) { QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast(d_func()); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(path); +#endif return QDir().rmdir(path); } @@ -1798,6 +1837,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int */ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QList > &updates) { +#ifndef QT_NO_FILESYSTEMWATCHER Q_Q(QFileSystemModel); QVector rowsToUpdate; QStringList newFiles; @@ -1894,6 +1934,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QL forceSort = true; delayedSort(); } +#endif // !QT_NO_FILESYSTEMWATCHER } /*! @@ -1911,6 +1952,7 @@ void QFileSystemModelPrivate::init() { Q_Q(QFileSystemModel); qRegisterMetaType > >(); +#ifndef QT_NO_FILESYSTEMWATCHER q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)), q, SLOT(_q_directoryChanged(QString,QStringList))); q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList >)), @@ -1919,6 +1961,7 @@ void QFileSystemModelPrivate::init() q, SLOT(_q_resolvedName(QString,QString))); q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)), q, SIGNAL(directoryLoaded(QString))); +#endif // !QT_NO_FILESYSTEMWATCHER q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration From 505579ebe4acc7d3719683e257b0397bc6421925 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Sep 2013 17:42:06 +0200 Subject: [PATCH 08/32] Remove a Borland-related inclusion There are no calls to qSort in the file any more. Change-Id: Ifd65b543941ab90d6a1ed4e318d925bdbf3f454e Reviewed-by: Gunnar Sletta --- src/gui/image/qxpmhandler.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 3bd8ca92b4..0ff3c6239d 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -49,11 +49,6 @@ #include #include -#if defined(Q_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "qplatformdefs.h" -#endif - QT_BEGIN_NAMESPACE static quint64 xpmHash(const QString &str) From cc778e1d2108806ef5d14b87eddd3ce8999c27ee Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 09/32] Remove some qBinaryFind usages from QtGui This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I9cbb1790f94e7726e127b9ad1bd5a58c433055a8 Reviewed-by: Gunnar Sletta --- src/gui/image/qxpmhandler.cpp | 6 ++++-- src/gui/kernel/qkeysequence.cpp | 6 ++++-- src/gui/painting/qcolor_p.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 0ff3c6239d..528bd4ebb1 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -49,6 +49,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE static quint64 xpmHash(const QString &str) @@ -747,8 +749,8 @@ inline bool operator<(const XPMRGBData &data, const char *name) static inline bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb) { - const XPMRGBData *r = qBinaryFind(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space); - if (r != xpmRgbTbl + xpmRgbTblSize) { + const XPMRGBData *r = std::lower_bound(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space); + if ((r != xpmRgbTbl + xpmRgbTblSize) && !(name_no_space < *r)) { *rgb = r->value; return true; } else { diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 9464d97932..16324b3659 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -60,6 +60,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE #if defined(Q_OS_MACX) @@ -107,8 +109,8 @@ static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntrie QChar qt_macSymbolForQtKey(int key) { - const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key); - if (i == MacSpecialKeyEntriesEnd) + const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key); + if ((i == MacSpecialKeyEntriesEnd) || (key < *i)) return QChar(); ushort macSymbol = i->macSymbol; if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta) diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index b913f5338c..ca5c56e07e 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -49,6 +49,8 @@ #include "qrgb.h" #include "qstringlist.h" +#include + QT_BEGIN_NAMESPACE static inline int h2i(char hex) @@ -301,8 +303,8 @@ inline bool operator<(const RGBData &data, const char *name) static bool get_named_rgb(const char *name_no_space, QRgb *rgb) { QByteArray name = QByteArray(name_no_space).toLower(); - const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name.constData()); - if (r != rgbTbl + rgbTblSize) { + const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name.constData()); + if ((r != rgbTbl + rgbTblSize) && !(name.constData() < *r)) { *rgb = r->value; return true; } From bacbf1fcf35afcece74270fda5521d43b039ee48 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 10/32] Remove some qBinaryFind usages from QtGui This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: Iecb921cd778571d24680254566e9aa8fc8d5edff Reviewed-by: Gunnar Sletta --- src/gui/text/qcssparser.cpp | 6 ++++-- src/gui/text/qfontsubset.cpp | 4 ++-- src/gui/text/qtextengine.cpp | 5 ++++- src/gui/text/qtexthtmlparser.cpp | 10 ++++++---- src/gui/text/qtexttable.cpp | 12 +++++++----- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index b486ec05fa..7a96fbe88b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -51,6 +51,8 @@ #include #include "private/qfunctions_p.h" +#include + #ifndef QT_NO_CSSPARSER QT_BEGIN_NAMESPACE @@ -358,8 +360,8 @@ Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop, const QStrin static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues) { const QCssKnownValue *end = &start[numValues - 1]; - const QCssKnownValue *prop = qBinaryFind(start, end, name); - if (prop == end) + const QCssKnownValue *prop = std::lower_bound(start, end, name); + if ((prop == end) || (name < *prop)) return 0; return prop->id; } diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 01ae5888e2..152e15a54d 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -101,8 +101,8 @@ QByteArray QFontSubset::glyphName(unsigned short unicode, bool symbol) // map from latin1 to symbol unicode = symbol_map[unicode]; - const AGLEntry *r = qBinaryFind(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode); - if (r != unicode_to_agl_map + unicode_to_agl_map_size) + const AGLEntry *r = std::lower_bound(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode); + if ((r != unicode_to_agl_map + unicode_to_agl_map_size) && !(unicode < *r)) return glyph_names + r->index; char buffer[8]; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 241ed21a10..e571e8da8a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2969,7 +2969,10 @@ void QTextEngine::resolveAdditionalFormats() const } while (endIt != addFormatSortedByEnd.constEnd() && specialData->addFormats.at(*endIt).start + specialData->addFormats.at(*endIt).length < end) { - currentFormats.remove(qBinaryFind(currentFormats, *endIt) - currentFormats.begin()); + int *currentFormatIterator = std::lower_bound(currentFormats.begin(), currentFormats.end(), *endIt); + if (*endIt < *currentFormatIterator) + currentFormatIterator = currentFormats.end(); + currentFormats.remove(currentFormatIterator - currentFormats.begin()); ++endIt; } QTextCharFormat format; diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index e99ba49107..c177fa0810 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -55,6 +55,8 @@ #include "qfont_p.h" #include "private/qfunctions_p.h" +#include + #ifndef QT_NO_TEXTHTMLPARSER QT_BEGIN_NAMESPACE @@ -336,8 +338,8 @@ static QChar resolveEntity(const QString &entity) { const QTextHtmlEntity *start = &entities[0]; const QTextHtmlEntity *end = &entities[MAX_ENTITY]; - const QTextHtmlEntity *e = qBinaryFind(start, end, entity); - if (e == end) + const QTextHtmlEntity *e = std::lower_bound(start, end, entity); + if (e == end || (entity < *e)) return QChar(); return e->code; } @@ -456,8 +458,8 @@ static const QTextHtmlElement *lookupElementHelper(const QString &element) { const QTextHtmlElement *start = &elements[0]; const QTextHtmlElement *end = &elements[Html_NumElements]; - const QTextHtmlElement *e = qBinaryFind(start, end, element); - if (e == end) + const QTextHtmlElement *e = std::lower_bound(start, end, element); + if ((e == end) || (element < *e)) return 0; return e; } diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index a56f8060e0..879c3ddc70 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -393,10 +393,10 @@ int QTextTablePrivate::findCellIndex(int fragment) const { QFragmentFindHelper helper(pieceTable->fragmentMap().position(fragment), pieceTable->fragmentMap()); - QList::ConstIterator it = qBinaryFind(cells.begin(), cells.end(), helper); - if (it == cells.end()) + QList::ConstIterator it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper); + if ((it == cells.constEnd()) || (helper < *it)) return -1; - return it - cells.begin(); + return it - cells.constBegin(); } void QTextTablePrivate::fragmentAdded(QChar type, uint fragment) @@ -1048,8 +1048,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) // find the position at which to insert the contents of the merged cells QFragmentFindHelper helper(origCellPosition, p->fragmentMap()); - QList::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); + QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); + Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == cellFragment); const int insertCellIndex = it - d->cells.begin(); int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end); @@ -1080,8 +1081,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) if (firstCellIndex == -1) { QFragmentFindHelper helper(pos, p->fragmentMap()); - QList::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); + QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); + Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == fragment); firstCellIndex = cellIndex = it - d->cells.begin(); } From 893a9e1cf8863cd7f70c44da303de16e22b2ae93 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 11/32] Remove some qBinaryFind usages from QtWidgets This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I7e4a5a4010b0ded59dbe2cacc6afe23ae4121bfe Reviewed-by: Andreas Aardal Hanssen --- src/widgets/dialogs/qfilesystemmodel.cpp | 8 +++----- src/widgets/graphicsview/qgraphicsitemanimation.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 53dd01319f..c86c7ff931 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1689,12 +1689,10 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons std::sort(newFiles.begin(), newFiles.end()); QHash::const_iterator i = parentNode->children.constBegin(); while (i != parentNode->children.constEnd()) { - QStringList::iterator iterator; - iterator = qBinaryFind(newFiles.begin(), newFiles.end(), - i.value()->fileName); - if (iterator == newFiles.end()) { + QStringList::iterator iterator = std::lower_bound(newFiles.begin(), newFiles.end(), i.value()->fileName); + if ((iterator == newFiles.end()) || (i.value()->fileName < *iterator)) toRemove.append(i.value()->fileName); - } + ++i; } for (int i = 0 ; i < toRemove.count() ; ++i ) diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 55d7ee6d1b..5dc3e1159e 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -176,8 +176,8 @@ void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QL Pair pair(step, value); - QList::iterator result = qBinaryFind(binList->begin(), binList->end(), pair); - if (result != binList->end()) + QList::iterator result = std::lower_bound(binList->begin(), binList->end(), pair); + if ((result != binList->end()) && !(pair < *result)) result->value = value; else { *binList << pair; From b768c0c801a99be7ada0553cbf4a64aca2853444 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Sep 2013 17:42:06 +0200 Subject: [PATCH 12/32] Remove a Borland-related inclusion There are no calls to qSort in the file any more. Change-Id: I5534271a75065998d5a98147a0d19850318c940c Reviewed-by: Gunnar Sletta Reviewed-by: Konstantin Ritt --- src/gui/painting/qcolor_p.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index ca5c56e07e..3f6326fcbe 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -40,12 +40,6 @@ ****************************************************************************/ #include "qglobal.h" - -#if defined(Q_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "qplatformdefs.h" -#endif - #include "qrgb.h" #include "qstringlist.h" From 7a6a902e2d7fc6da7e91ab49d75291f905b846ce Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 13/32] Remove some qBinaryFind usages from the CUPS printing code This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I0f9c8db3ede32570a1fd6cc43a31e2fc76ab2a0a Reviewed-by: John Layt --- src/printsupport/kernel/qcups.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 21029c09e5..643ffef192 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -50,6 +50,8 @@ #endif #include +#include + QT_BEGIN_NAMESPACE extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution); @@ -659,8 +661,8 @@ inline bool operator<(const NamedPaperSize &data, const char *name) static inline QPrinter::PaperSize string2PaperSize(const char *name) { - const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); - if (r - named_sizes_map != QPrinter::NPageSize) + const NamedPaperSize *r = std::lower_bound(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); + if ((r != named_sizes_map + QPrinter::NPageSize) && !(name < *r)) return r->size; return QPrinter::Custom; } From ddefc7627d70c46dadfa934dd3754a2aff0dbfea Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 14/32] Remove qBinaryFind usages from QtCore This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I6207982c08c92f3e01fb236d2e7546a1c9acd287 Reviewed-by: Olivier Goffart --- src/corelib/animation/qvariantanimation.cpp | 4 ++-- src/corelib/codecs/qeuckrcodec.cpp | 6 ++++-- src/corelib/io/qurlidna.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index a6d013b11a..a23a6a7cda 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -310,8 +310,8 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress) QVariant QVariantAnimationPrivate::valueAt(qreal step) const { QVariantAnimation::KeyValues::const_iterator result = - qBinaryFind(keyValues.begin(), keyValues.end(), qMakePair(step, QVariant()), animationValueLessThan); - if (result != keyValues.constEnd()) + std::lower_bound(keyValues.constBegin(), keyValues.constEnd(), qMakePair(step, QVariant()), animationValueLessThan); + if (result != keyValues.constEnd() && !animationValueLessThan(qMakePair(step, QVariant()), *result)) return result->second; return QVariant(); diff --git a/src/corelib/codecs/qeuckrcodec.cpp b/src/corelib/codecs/qeuckrcodec.cpp index 20ba1e85d6..873b782378 100644 --- a/src/corelib/codecs/qeuckrcodec.cpp +++ b/src/corelib/codecs/qeuckrcodec.cpp @@ -70,6 +70,8 @@ #include "qeuckrcodec_p.h" #include "cp949codetbl_p.h" +#include + QT_BEGIN_NAMESPACE #ifndef QT_NO_BIG_CODECS @@ -3383,8 +3385,8 @@ QByteArray QCP949Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt *cursor++ = (j >> 8) | 0x80; *cursor++ = (j & 0xff) | 0x80; } else { - const unsigned short *ptr = qBinaryFind(cp949_icode_to_unicode, cp949_icode_to_unicode + 8822, ch); - if (ptr == cp949_icode_to_unicode + 8822) { + const unsigned short *ptr = std::lower_bound(cp949_icode_to_unicode, cp949_icode_to_unicode + 8822, ch); + if (ptr == cp949_icode_to_unicode + 8822 || ch < *ptr) { // Error *cursor++ = replacement; ++invalid; diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index e959faccd2..ee95e590f9 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -42,6 +42,7 @@ #include "qurl_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -1461,10 +1462,10 @@ static void mapToLowerCase(QString *str, int from) ++i; } } - const NameprepCaseFoldingEntry *entry = qBinaryFind(NameprepCaseFolding, - NameprepCaseFolding + N, - uc); - if ((entry - NameprepCaseFolding) != N) { + const NameprepCaseFoldingEntry *entry = std::lower_bound(NameprepCaseFolding, + NameprepCaseFolding + N, + uc); + if ((entry != NameprepCaseFolding + N) && !(uc < *entry)) { int l = 1; while (l < 4 && entry->mapping[l]) ++l; From be8999038ff4afdfca8fa693a7e0e3dbaae54c97 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Sep 2013 22:39:04 +0200 Subject: [PATCH 15/32] When calling setPageSizeMM then the size needs to be passed as MM This simplifies the code a bit and ensures that it is respecting what the relevant function expects the size to be as. Change-Id: Iec88fab84c27a33d6f1a9e9413ea6beb0a39c68d Reviewed-by: John Layt --- src/printsupport/kernel/qprinter.cpp | 26 ++++++++++++++++--- .../kernel/qprinter/tst_qprinter.cpp | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 3e64582b06..9751389d6f 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -127,6 +127,28 @@ Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resol return 1.0; } +/// return the QSize from the specified in unit as millimeters +Q_PRINTSUPPORT_EXPORT QSizeF qt_SizeFromUnitToMillimeter(const QSizeF &size, QPrinter::Unit unit, double resolution) +{ + switch (unit) { + case QPrinter::Millimeter: + return size; + case QPrinter::Point: + return size * 0.352777778; + case QPrinter::Inch: + return size * 25.4; + case QPrinter::Pica: + return size * 4.23333333334; + case QPrinter::Didot: + return size * 0.377; + case QPrinter::Cicero: + return size * 4.511666667; + case QPrinter::DevicePixel: + return size * (0.352777778 * 72.0 / resolution); + } + return size; +} + // not static: it's needed in qpagesetupdialog_unix.cpp Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, QPrinter::PaperSize paperSize, @@ -983,9 +1005,7 @@ void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit) Q_D(QPrinter); if (d->paintEngine->type() != QPaintEngine::Pdf) ABORT_IF_ACTIVE("QPrinter::setPaperSize"); - const qreal multiplier = qt_multiplierForUnit(unit, resolution()); - QSizeF size(paperSize.width() * multiplier * 25.4/72., paperSize.height() * multiplier * 25.4/72.); - setPageSizeMM(size); + setPageSizeMM(qt_SizeFromUnitToMillimeter(paperSize, unit, resolution())); } /*! diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 0261224543..7251cca528 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -590,6 +590,7 @@ void tst_QPrinter::setGetPaperSize() QSizeF size(500, 10); p.setPaperSize(size, QPrinter::Millimeter); QCOMPARE(p.paperSize(QPrinter::Millimeter), size); + QCOMPARE(p.pageSizeMM(), size); QSizeF ptSize = p.paperSize(QPrinter::Point); //qDebug() << ptSize; QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); From e8af66f90684946eb56ffcce9fa0c7909ba0c390 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 24 Sep 2013 00:20:56 +0200 Subject: [PATCH 16/32] Add newlines to qEmergencyOut output on stderr. qt_message, in the regular case, calls qt_message_print, which invokes the default message handler (qDefaultMessageHandler), which uses qMessageFormatString to construct a string, and then platform-dependent methods to print this out. This means that qMessageFormatString's newline is the one that separates debug messages. Unfortunately, in the emergency case, we don't have this luxury of doing formatting: so just make sure to add a newline so output is readable. Change-Id: I8f7bbceb9347b6312748f0f426feebaf04f6a226 Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 1cd11ad667..4d564b09c3 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -184,14 +184,14 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL OutputDebugStringW(emergency_bufL); # else if (qWinLogToStderr()) { - fprintf(stderr, "%s", emergency_buf); + fprintf(stderr, "%s\n", emergency_buf); fflush(stderr); } else { OutputDebugStringA(emergency_buf); } # endif #else - fprintf(stderr, "%s", emergency_buf); + fprintf(stderr, "%s\n", emergency_buf); fflush(stderr); #endif From 2ff3cbbb563f2e6176b3a153c233ae737246fe23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 23 Sep 2013 16:01:43 +0200 Subject: [PATCH 17/32] Xcode: Quote variable names with invalid characters in them Allows us to have scoped variables such as eg FOO[arch=armv7]. We could quote all variables, but Xcode doesn't, and we try to stay close to the native behavior. Change-Id: Ia6634a33e42031fe7e69c4f680803fa347e5de4a Reviewed-by: Andy Shaw --- qmake/generators/mac/pbuilder_pbx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index b8e6d05728..719507c61d 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1804,7 +1804,10 @@ ProjectBuilderMakefileGenerator::writeSettings(const QString &var, const ProStri for(int i = 0; i < indent_level; ++i) newline += "\t"; - ret += var + " = "; + static QRegExp allowedVariableCharacters("^[a-zA-Z0-9_]*$"); + ret += var.contains(allowedVariableCharacters) ? var : quotedStringLiteral(var); + + ret += " = "; if(flags & SettingsAsList) { ret += "(" + newline; From 72d6717b268e66e3ba8d222deb74513337368a60 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 23 Sep 2013 21:28:54 +0200 Subject: [PATCH 18/32] moc: Don't stumble over MSVC __declspec. Commit 310031188c6 (Fix moc stumbling over gcc __attribute__ extensions, 2012-10-01) applied similar logic for GNU style attributes. Change-Id: I550eaefd703b4e974e6ffae7716f02074c8a8823 Reviewed-by: Olivier Goffart --- src/tools/moc/main.cpp | 1 + tests/auto/tools/moc/function-with-attributes.h | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 98472792f8..3ae6445093 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -199,6 +199,7 @@ int runMoc(int argc, char **argv) dummyVariadicFunctionMacro.isVariadic = true; dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__"); pp.macros["__attribute__"] = dummyVariadicFunctionMacro; + pp.macros["__declspec"] = dummyVariadicFunctionMacro; QString filename; QString output; diff --git a/tests/auto/tools/moc/function-with-attributes.h b/tests/auto/tools/moc/function-with-attributes.h index 21a7405af7..afa02e6f3a 100644 --- a/tests/auto/tools/moc/function-with-attributes.h +++ b/tests/auto/tools/moc/function-with-attributes.h @@ -43,15 +43,22 @@ // test support for gcc attributes with functions #if defined(Q_CC_GNU) || defined(Q_MOC_RUN) -#define DEPRECATED __attribute__ ((__deprecated__)) +#define DEPRECATED1 __attribute__ ((__deprecated__)) #else -#define DEPRECATED +#define DEPRECATED1 +#endif + +#if defined(Q_CC_MSVC) || defined(Q_MOC_RUN) +#define DEPRECATED2 __declspec(deprecated) +#else +#define DEPRECATED2 #endif class FunctionWithAttributes : public QObject { Q_OBJECT public slots: - DEPRECATED void test() {} + DEPRECATED1 void test1() {} + DEPRECATED2 void test2() {} }; From e4ce1790b1a07d263dbbd22329c2b98a0322358c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 19/32] Remove some qSort usages from QTimeZone This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I974d41e986c67d1883c7d8dec879edd1fcbd08c2 Reviewed-by: John Layt --- src/corelib/tools/qtimezone.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp index f5f2b28b88..cdd0aba102 100644 --- a/src/corelib/tools/qtimezone.cpp +++ b/src/corelib/tools/qtimezone.cpp @@ -47,6 +47,8 @@ #include +#include + QT_BEGIN_NAMESPACE // Create default time zone using appropriate backend @@ -781,7 +783,7 @@ QList QTimeZone::availableTimeZoneIds() QSet set = QUtcTimeZonePrivate().availableTimeZoneIds() + global_tz->backend->availableTimeZoneIds(); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } @@ -801,7 +803,7 @@ QList QTimeZone::availableTimeZoneIds(QLocale::Country country) QSet set = QUtcTimeZonePrivate().availableTimeZoneIds(country) + global_tz->backend->availableTimeZoneIds(country); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } @@ -817,7 +819,7 @@ QList QTimeZone::availableTimeZoneIds(int offsetSeconds) QSet set = QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds) + global_tz->backend->availableTimeZoneIds(offsetSeconds); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } From 75abfa89821e0c64022d90bba227b947947169d4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 24 Sep 2013 07:58:59 +0200 Subject: [PATCH 20/32] Support logcat output from tests on Android We usually do not have a console, so print out the messages to the log as well, so that it's easier to run single tests for debugging. Change-Id: I31908977aac25a6f6716f8245206b01026234aa9 Reviewed-by: Yoann Lopes --- src/testlib/qplaintestlogger.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index a923a0d0fa..57ce5b031d 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -62,6 +62,10 @@ #include #include +#ifdef Q_OS_ANDROID +# include +#endif + QT_BEGIN_NAMESPACE namespace QTest { @@ -206,6 +210,8 @@ void QPlainTestLogger::outputMessage(const char *str) if (stream != stdout) #elif defined(Q_OS_WIN) OutputDebugStringA(str); +#elif defined(Q_OS_ANDROID) + __android_log_print(ANDROID_LOG_INFO, "QTestLib", str); #endif outputString(str); } From f3a723f2ec3a4fc59df21164f9ec2eaf1e50abc8 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 7 Jul 2012 01:19:46 +0400 Subject: [PATCH 21/32] Add QKeySequenceEdit Change-Id: I497309d3e6cbf38b298afb5ff3cb1ed6a0e82000 Reviewed-by: Marc Mutz --- src/corelib/global/qfeatures.h | 8 + src/tools/uic/qclass_lib_map.h | 1 + src/widgets/widgets/qkeysequenceedit.cpp | 333 ++++++++++++++++++ src/widgets/widgets/qkeysequenceedit.h | 90 +++++ src/widgets/widgets/qkeysequenceedit_p.h | 81 +++++ src/widgets/widgets/widgets.pri | 3 + .../widgets/qkeysequenceedit/.gitignore | 1 + .../qkeysequenceedit/qkeysequenceedit.pro | 5 + .../qkeysequenceedit/tst_qkeysequenceedit.cpp | 104 ++++++ tests/auto/widgets/widgets/widgets.pro | 1 + 10 files changed, 627 insertions(+) create mode 100644 src/widgets/widgets/qkeysequenceedit.cpp create mode 100644 src/widgets/widgets/qkeysequenceedit.h create mode 100644 src/widgets/widgets/qkeysequenceedit_p.h create mode 100644 tests/auto/widgets/widgets/qkeysequenceedit/.gitignore create mode 100644 tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro create mode 100644 tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 2cadea59c1..ba84dd109e 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -115,6 +115,9 @@ // Image Text //#define QT_NO_IMAGE_TEXT +// QKeySequenceEdit +//#define QT_NO_KEYSEQUENCEEDIT + // QLCDNumber //#define QT_NO_LCDNUMBER @@ -306,6 +309,11 @@ #define QT_NO_IMAGEFORMATPLUGIN #endif +// QKeySequenceEdit +#if !defined(QT_NO_KEYSEQUENCEEDIT) && (defined(QT_NO_SHORTCUT)) +#define QT_NO_KEYSEQUENCEEDIT +#endif + // QLocalServer #if !defined(QT_NO_LOCALSERVER) && (defined(QT_NO_TEMPORARYFILE)) #define QT_NO_LOCALSERVER diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index cedefb801a..48793e7f09 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -931,6 +931,7 @@ QT_CLASS_LIB(QFocusFrame, QtWidgets, qfocusframe.h) QT_CLASS_LIB(QFontComboBox, QtWidgets, qfontcombobox.h) QT_CLASS_LIB(QFrame, QtWidgets, qframe.h) QT_CLASS_LIB(QGroupBox, QtWidgets, qgroupbox.h) +QT_CLASS_LIB(QKeySequenceEdit, QtWidgets, qkeysequenceedit.h) QT_CLASS_LIB(QLabel, QtWidgets, qlabel.h) QT_CLASS_LIB(QLCDNumber, QtWidgets, qlcdnumber.h) QT_CLASS_LIB(QLineEdit, QtWidgets, qlineedit.h) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp new file mode 100644 index 0000000000..a71c0ada70 --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -0,0 +1,333 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qkeysequenceedit.h" +#include "qkeysequenceedit_p.h" + +#include "qboxlayout.h" +#include "qlineedit.h" + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +void QKeySequenceEditPrivate::init() +{ + Q_Q(QKeySequenceEdit); + + lineEdit = new QLineEdit(q); + keyNum = 0; + prevKey = -1; + releaseTimer = 0; + + layout = new QVBoxLayout(q); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(lineEdit); + + key[0] = key[1] = key[2] = key[3] = 0; + + lineEdit->setFocusProxy(q); + lineEdit->installEventFilter(q); + resetState(); + + q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + q->setFocusPolicy(Qt::StrongFocus); + q->setAttribute(Qt::WA_MacShowFocusRect, true); + q->setAttribute(Qt::WA_InputMethodEnabled, false); + + // TODO: add clear button +} + +int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) +{ + int result = 0; + // The shift modifier only counts when it is not used to type a symbol + // that is only reachable using the shift key anyway + if ((state & Qt::ShiftModifier) && (text.isEmpty() || + !text.at(0).isPrint() || + text.at(0).isLetterOrNumber() || + text.at(0).isSpace())) + result |= Qt::SHIFT; + + if (state & Qt::ControlModifier) + result |= Qt::CTRL; + if (state & Qt::MetaModifier) + result |= Qt::META; + if (state & Qt::AltModifier) + result |= Qt::ALT; + return result; +} + +void QKeySequenceEditPrivate::resetState() +{ + Q_Q(QKeySequenceEdit); + + if (releaseTimer) { + q->killTimer(releaseTimer); + releaseTimer = 0; + } + prevKey = -1; + lineEdit->setText(keySequence.toString(QKeySequence::NativeText)); + lineEdit->setPlaceholderText(QKeySequenceEdit::tr("Press shortcut")); +} + +void QKeySequenceEditPrivate::finishEditing() +{ + Q_Q(QKeySequenceEdit); + + resetState(); + emit q->keySequenceChanged(keySequence); + emit q->editingFinished(); +} + +/*! + \class QKeySequenceEdit + \brief The QKeySequenceEdit widget allows to input a QKeySequence. + + \inmodule QtWidgets + + \since 5.2 + + This widget lets the user choose a QKeySequence, which is usually used as + a shortcut. The recording is initiated when the widget receives the focus + and ends one second after the user releases the last key. + + \sa QKeySequenceEdit::keySequence +*/ + +/*! + Constructs a QKeySequenceEdit widget with the given \a parent. +*/ +QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) : + QWidget(*new QKeySequenceEditPrivate, parent, 0) +{ + Q_D(QKeySequenceEdit); + d->init(); +} + +/*! + Constructs a QKeySequenceEdit widget with the given \a keySequence and \a parent. +*/ +QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) : + QWidget(*new QKeySequenceEditPrivate, parent, 0) +{ + Q_D(QKeySequenceEdit); + d->init(); + setKeySequence(keySequence); +} + +/*! + \internal +*/ +QKeySequenceEdit::QKeySequenceEdit(QKeySequenceEditPrivate &dd, QWidget *parent, Qt::WindowFlags f) : + QWidget(dd, parent, f) +{ + Q_D(QKeySequenceEdit); + d->init(); +} + +/*! + Destroys the QKeySequenceEdit object. +*/ +QKeySequenceEdit::~QKeySequenceEdit() +{ +} + +/*! + \property QKeySequenceEdit::keySequence + + \brief This property contains the currently chosen key sequence. + + The shortcut can be changed by the user or via setter function. +*/ +QKeySequence QKeySequenceEdit::keySequence() const +{ + Q_D(const QKeySequenceEdit); + + return d->keySequence; +} + +void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence) +{ + Q_D(QKeySequenceEdit); + + d->resetState(); + + if (d->keySequence == keySequence) + return; + + d->keySequence = keySequence; + + d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0; + d->keyNum = keySequence.count(); + for (int i = 0; i < d->keyNum; ++i) + d->key[i] = keySequence[i]; + + d->lineEdit->setText(keySequence.toString(QKeySequence::NativeText)); + + emit keySequenceChanged(keySequence); +} + +/*! + \fn void QKeySequenceEdit::editingFinished() + + This signal is emitted when the user finishes entering the shortcut. + + \note there is a one second delay before releasing the last key and + emitting this signal. +*/ + +/*! + \brief Clears the current key sequence. +*/ +void QKeySequenceEdit::clear() +{ + Q_D(QKeySequenceEdit); + + d->resetState(); + + d->lineEdit->clear(); + d->keySequence = QKeySequence(); + d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0; + d->prevKey = -1; + emit keySequenceChanged(d->keySequence); +} + +/*! + \reimp +*/ +bool QKeySequenceEdit::event(QEvent *e) +{ + switch (e->type()) { + case QEvent::Shortcut: + return true; + case QEvent::ShortcutOverride: + e->accept(); + return true; + default : + break; + } + + return QWidget::event(e); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) +{ + Q_D(QKeySequenceEdit); + + int nextKey = e->key(); + + if (d->prevKey == -1) { + clear(); + d->prevKey = nextKey; + } + + d->lineEdit->setPlaceholderText(QString()); + if (nextKey == Qt::Key_Control + || nextKey == Qt::Key_Shift + || nextKey == Qt::Key_Meta + || nextKey == Qt::Key_Alt) { + return; + } + + QString selectedText = d->lineEdit->selectedText(); + if (!selectedText.isEmpty() && selectedText == d->lineEdit->text()) { + clear(); + if (nextKey == Qt::Key_Backspace) + return; + } + + if (d->keyNum >= QKeySequenceEditPrivate::MaxKeyCount) + return; + + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + + d->key[d->keyNum] = nextKey; + d->keyNum++; + + QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]); + d->keySequence = key; + QString text = key.toString(QKeySequence::NativeText); + if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) { + //: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..." + text = tr("%1, ...").arg(text); + } + d->lineEdit->setText(text); + e->accept(); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::keyReleaseEvent(QKeyEvent *e) +{ + Q_D(QKeySequenceEdit); + + if (d->prevKey == e->key()) { + if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) + d->releaseTimer = startTimer(1000); + else + d->finishEditing(); + } + e->accept(); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::timerEvent(QTimerEvent *e) +{ + Q_D(QKeySequenceEdit); + if (e->timerId() == d->releaseTimer) { + d->finishEditing(); + return; + } + + QWidget::timerEvent(e); +} + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h new file mode 100644 index 0000000000..9312e98d0e --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QKEYSEQUENCEEDIT_H +#define QKEYSEQUENCEEDIT_H + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +class QKeySequenceEditPrivate; +class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence RESET clear NOTIFY keySequenceChanged USER true) + +public: + explicit QKeySequenceEdit(QWidget *parent = 0); + explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = 0); + ~QKeySequenceEdit(); + + QKeySequence keySequence() const; + void setKeySequence(const QKeySequence &keySequence); + +public Q_SLOTS: + void clear(); + +Q_SIGNALS: + void editingFinished(); + void keySequenceChanged(const QKeySequence &keySequence); + +protected: + QKeySequenceEdit(QKeySequenceEditPrivate &d, QWidget *parent, Qt::WindowFlags f); + + bool event(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QKeySequenceEdit) + Q_DECLARE_PRIVATE(QKeySequenceEdit) +}; + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE + +#endif // QKEYSEQUENCEEDIT_H diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h new file mode 100644 index 0000000000..2de86b3a05 --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QKEYSEQUENCEEDIT_P_H +#define QKEYSEQUENCEEDIT_P_H + +#include "qkeysequenceedit.h" + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +class QLineEdit; +class QVBoxLayout; + +class QKeySequenceEditPrivate : public QWidgetPrivate +{ + Q_DECLARE_PUBLIC(QKeySequenceEdit) +public: + enum { MaxKeyCount = 4 }; + + void init(); + int translateModifiers(Qt::KeyboardModifiers state, const QString &text); + void resetState(); + void finishEditing(); + + QLineEdit *lineEdit; + QVBoxLayout *layout; + QKeySequence keySequence; + int keyNum; + int key[MaxKeyCount]; + int prevKey; + int releaseTimer; +}; + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE + +#endif // QKEYSEQUENCEEDIT_P_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index a35e6eb3a1..efe1dd3616 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -25,6 +25,8 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ widgets/qgroupbox.h \ + widgets/qkeysequenceedit.h \ + widgets/qkeysequenceedit_p.h \ widgets/qlabel.h \ widgets/qlabel_p.h \ widgets/qlcdnumber.h \ @@ -99,6 +101,7 @@ SOURCES += \ widgets/qfontcombobox.cpp \ widgets/qframe.cpp \ widgets/qgroupbox.cpp \ + widgets/qkeysequenceedit.cpp \ widgets/qlabel.cpp \ widgets/qlcdnumber.cpp \ widgets/qlineedit_p.cpp \ diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore b/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore new file mode 100644 index 0000000000..04dacefc29 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore @@ -0,0 +1 @@ +tst_qshortcutedit diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro b/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro new file mode 100644 index 0000000000..097cb00d11 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +CONFIG += parallel_test +TARGET = tst_qkeysequenceedit +QT += widgets testlib +SOURCES += tst_qkeysequenceedit.cpp diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp new file mode 100644 index 0000000000..8c010abfe6 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include + +Q_DECLARE_METATYPE(Qt::Key) +Q_DECLARE_METATYPE(Qt::KeyboardModifiers) + +class tst_QKeySequenceEdit : public QObject +{ + Q_OBJECT + +private slots: + void testSetters(); + void testKeys_data(); + void testKeys(); +}; + +void tst_QKeySequenceEdit::testSetters() +{ + QKeySequenceEdit edit; + QSignalSpy spy(&edit, SIGNAL(keySequenceChanged(QKeySequence))); + QCOMPARE(edit.keySequence(), QKeySequence()); + + edit.setKeySequence(QKeySequence::New); + QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New)); + + edit.clear(); + QCOMPARE(edit.keySequence(), QKeySequence()); + + QCOMPARE(spy.count(), 2); +} + +void tst_QKeySequenceEdit::testKeys_data() +{ + QTest::addColumn("key"); + QTest::addColumn("modifiers"); + QTest::addColumn("keySequence"); + + QTest::newRow("1") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ControlModifier) << QKeySequence("Ctrl+N"); + QTest::newRow("2") << Qt::Key_N << Qt::KeyboardModifiers(Qt::AltModifier) << QKeySequence("Alt+N"); + QTest::newRow("3") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ShiftModifier) << QKeySequence("Shift+N"); + QTest::newRow("4") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << QKeySequence("Ctrl+Shift+N"); +} + +void tst_QKeySequenceEdit::testKeys() +{ + QFETCH(Qt::Key, key); + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(QKeySequence, keySequence); + QKeySequenceEdit edit; + + QSignalSpy spy(&edit, SIGNAL(editingFinished())); + QTest::keyPress(&edit, key, modifiers); + QTest::keyRelease(&edit, key, modifiers); + + QCOMPARE(spy.count(), 0); + QCOMPARE(edit.keySequence(), keySequence); + QTRY_COMPARE(spy.count(), 1); +} + +QTEST_MAIN(tst_QKeySequenceEdit) +#include "tst_qkeysequenceedit.moc" diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index 12dfc8f7c8..29d1f7746c 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -17,6 +17,7 @@ SUBDIRS=\ qfocusframe \ qfontcombobox \ qgroupbox \ + qkeysequenceedit \ qlabel \ qlcdnumber \ qlineedit \ From 1ac094321cf14b7993222830371d4c4bcac62dfa Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 23 Sep 2013 20:14:14 +0200 Subject: [PATCH 22/32] Android: fixed arguments passed to the Qt application. Removed extra empty parameter. Change-Id: Iad5becf05801118d0f6d2ec2cc1ec255eaa9e872 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 244654786d..f5bfe7e029 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -204,9 +204,9 @@ public class QtNative m_displayMetricsXDpi, m_displayMetricsYDpi, m_displayMetricsScaledDensity); - if (params.length() > 0) + if (params.length() > 0 && !params.startsWith("\t")) params = "\t" + params; - startQtApplication(f.getAbsolutePath() + "\t" + params, environment); + startQtApplication(f.getAbsolutePath() + params, environment); m_started = true; } return res; From 62a85ae39e6c3191582cf060a226415959b0fd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Mon, 23 Sep 2013 17:34:25 +0100 Subject: [PATCH 23/32] Fix WinCE/MSVC2008 build. See QTBUG-33473 for a similar problem. Change-Id: Ib446618945dc1e7e1e7d43819cfae5f3c411f1bb Reviewed-by: Marc Mutz --- src/corelib/tools/qchar.cpp | 4 ++++ src/corelib/tools/qregexp.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index ff17a52a75..d99bba93ee 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1680,6 +1680,8 @@ struct UCS2Pair { ushort u2; }; +inline bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2) +{ return ligature1.u1 < ligature2.u1; } inline bool operator<(ushort u1, const UCS2Pair &ligature) { return u1 < ligature.u1; } inline bool operator<(const UCS2Pair &ligature, ushort u1) @@ -1690,6 +1692,8 @@ struct UCS2SurrogatePair { UCS2Pair p2; }; +inline bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2) +{ return QChar::surrogateToUcs4(ligature1.p1.u1, ligature1.p1.u2) < QChar::surrogateToUcs4(ligature2.p1.u1, ligature2.p1.u2); } inline bool operator<(uint u1, const UCS2SurrogatePair &ligature) { return u1 < QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2); } inline bool operator<(const UCS2SurrogatePair &ligature, uint u1) diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index c0cd419c53..ef2dba5700 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -2883,6 +2883,8 @@ static const struct CategoriesRangeMapEntry { { "YijingHexagramSymbols", 0x4DC0, 0x4DFF } }; +inline bool operator<(const CategoriesRangeMapEntry &entry1, const CategoriesRangeMapEntry &entry2) +{ return qstrcmp(entry1.name, entry2.name) < 0; } inline bool operator<(const char *name, const CategoriesRangeMapEntry &entry) { return qstrcmp(name, entry.name) < 0; } inline bool operator<(const CategoriesRangeMapEntry &entry, const char *name) From 458837ba0978acbbb8905b71ab605ef184cdf85d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2013 16:22:12 +0200 Subject: [PATCH 24/32] Remove some qBinaryFind usages from the Cocoa helpers This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I374ee2c88ee18d20fb2b295c936adaca1d696199 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 901efbfb39..197a2058af 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -325,16 +325,16 @@ QChar qt_mac_qtKey2CocoaKey(Qt::Key key) std::sort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan); } const QVector::iterator i - = qBinaryFind(rev_entries.begin(), rev_entries.end(), key); - if (i == rev_entries.end()) + = std::lower_bound(rev_entries.begin(), rev_entries.end(), key); + if ((i == rev_entries.end()) || (key < *i)) return QChar(); return i->cocoaKey; } Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode) { - const KeyPair *i = qBinaryFind(entries, end, keyCode); - if (i == end) + const KeyPair *i = std::lower_bound(entries, end, keyCode); + if ((i == end) || (keyCode < *i)) return Qt::Key(keyCode.toUpper().unicode()); return i->qtKey; } From a252f434e668acdec5b98688905d2ef75cc3eb3a Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 23 Sep 2013 14:22:59 +0200 Subject: [PATCH 25/32] qdoc: Import statement now shows correct version The Import statement shown at the top of each QML type page now always gets the version number from the QML module page for the QML type's module. Task-number: QTBUG-32153 Change-Id: I57649c07ea680806bc92ad62fb3bc4d4fb56f717 Reviewed-by: Jerome Pasion --- src/tools/qdoc/htmlgenerator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index ac10bb94e3..4a6d5ea9a8 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -1998,10 +1998,16 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) << inheritedBytext; //add the module name and version to the map + QString qmlModuleVersion; + DocNode* dn = qdb_->findQmlModule(qcn->qmlModuleName()); + if (dn) + qmlModuleVersion = dn->qmlModuleVersion(); + else + qmlModuleVersion = qcn->qmlModuleVersion(); text.clear(); text << formattingRightMap()[ATOM_FORMATTING_BOLD] << formattingLeftMap()[ATOM_FORMATTING_TELETYPE] - << "import " + qcn->qmlModuleName() + " " + qcn->qmlModuleVersion() + << "import " + qcn->qmlModuleName() + " " + qmlModuleVersion << formattingRightMap()[ATOM_FORMATTING_TELETYPE]; requisites.insert(importText, text); From 8f22ae5c1e8b11a300572f1f19d14daa4d2d6674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sun, 15 Sep 2013 21:12:24 +0100 Subject: [PATCH 26/32] Windows: Increase the max length of a system tray tooltip. It's 128 on Qt4, so lets maintain that limit. On older Windows versions (< WIN2K) 64 will be used. Change-Id: I96156c6f142e6e095227cc5a13f2b653408df968 Task-number: QTBUG-33461 Reviewed-by: Friedemann Kleint --- src/widgets/util/qsystemtrayicon_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index d273060f7b..a00b72484f 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -242,7 +242,7 @@ void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) tnd.hIcon = hIcon; const QString tip = q->toolTip(); if (!tip.isNull()) - qStringToLimitedWCharArray(tip, tnd.szTip, 64); + qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t)); } static int iconFlag( QSystemTrayIcon::MessageIcon icon ) From 413ec67fc46ad7049f870cdb8ead35149b215d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 19 Sep 2013 13:21:26 +0200 Subject: [PATCH 27/32] qmake: add $$title() function to convert strings to title case Change-Id: Ic535a8f7cc2ab7b7f1948b2d0237ebe9a71c7ec7 Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index a2ebe1e410..10ef523e15 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -91,7 +91,7 @@ enum ExpandFunc { E_INVALID = 0, E_MEMBER, E_FIRST, E_LAST, E_SIZE, E_CAT, E_FROMFILE, E_EVAL, E_LIST, E_SPRINTF, E_FORMAT_NUMBER, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, E_FIND, E_SYSTEM, E_UNIQUE, E_REVERSE, E_QUOTE, E_ESCAPE_EXPAND, - E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, + E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS, E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH, E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE @@ -134,6 +134,7 @@ void QMakeEvaluator::initFunctionStatics() { "escape_expand", E_ESCAPE_EXPAND }, { "upper", E_UPPER }, { "lower", E_LOWER }, + { "title", E_TITLE }, { "re_escape", E_RE_ESCAPE }, { "val_escape", E_VAL_ESCAPE }, { "files", E_FILES }, @@ -803,9 +804,16 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( break; case E_UPPER: case E_LOWER: + case E_TITLE: for (int i = 0; i < args.count(); ++i) { QString rstr = args.at(i).toQString(m_tmp1); - rstr = (func_t == E_UPPER) ? rstr.toUpper() : rstr.toLower(); + if (func_t == E_UPPER) { + rstr = rstr.toUpper(); + } else { + rstr = rstr.toLower(); + if (func_t == E_TITLE && rstr.length() > 0) + rstr[0] = rstr.at(0).toTitleCase(); + } ret << (rstr.isSharedWith(m_tmp1) ? args.at(i) : ProString(rstr).setSource(args.at(i))); } break; From d25eead30f08ccc0763d63bffdc83ba1e1a6cb91 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 24 Sep 2013 13:41:15 +0200 Subject: [PATCH 28/32] iOS: bugfix touch events to also work in inverted portrait/landscape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch simplifies the implementation of touch events to use a views superview for calculating global touch coordinates rather than the screen. This removes the need for taking orientation into account, and will also play better along in a mixed environment. This will also fix touch events reported for inverted orientations. Change-Id: I0c8fd8745a1f65f0f4a97447a5676a38165ed032 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index c8d0f823f6..dbeec5f5f2 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -150,9 +150,9 @@ - (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state { - QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle(); - QRect applicationRect = fromPortraitToPrimary(fromCGRect(self.window.screen.applicationFrame), screen); - + // We deliver touch events with global coordinates. But global in this respect means + // the coordinate system where this QWindow lives. And that is our superview. + CGSize parentSize = self.superview.frame.size; foreach (UITouch *uiTouch, m_activeTouches.keys()) { QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch]; if (![touches containsObject:uiTouch]) { @@ -160,15 +160,9 @@ } else { touchPoint.state = state; touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0; - - // Find the touch position relative to the window. Then calculate the screen - // position by subtracting the position of the applicationRect (since UIWindow - // does not take that into account when reporting its own frame): - QRect touchInWindow = QRect(fromCGPoint([uiTouch locationInView:nil]), QSize(0, 0)); - QRect touchInScreen = fromPortraitToPrimary(touchInWindow, screen); - QPoint touchPos = touchInScreen.topLeft() - applicationRect.topLeft(); + QPoint touchPos = fromCGPoint([uiTouch locationInView:self.superview]); touchPoint.area = QRectF(touchPos, QSize(0, 0)); - touchPoint.normalPosition = QPointF(touchPos.x() / applicationRect.width(), touchPos.y() / applicationRect.height()); + touchPoint.normalPosition = QPointF(touchPos.x() / parentSize.width, touchPos.y() / parentSize.height); } } } From 6cdd9928ab3de3c84b39b8b2d395f139fbf9aba2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 15:59:21 +0200 Subject: [PATCH 29/32] Cocoa: Use internal style mask to disable resizing popup parents Using QCocoaWindow::windowStyleMask() resets some private flags Cocoa sets when showing sheets. Task-number: QTBUG-33126 Change-Id: I34f0713f98e81e7010b0b7620ee24ea30f04dcff Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 8967445f59..05bf657c1f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -200,6 +200,7 @@ public: // for QNSView bool m_frameStrutEventsEnabled; bool m_isExposed; int m_registerTouchCount; + bool m_resizableTransientParent; static const int NoAlertRequest; NSInteger m_alertRequest; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5fc2975a9d..671214f424 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -211,6 +211,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_frameStrutEventsEnabled(false) , m_isExposed(false) , m_registerTouchCount(0) + , m_resizableTransientParent(false) , m_alertRequest(NoAlertRequest) { #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG @@ -317,12 +318,14 @@ void QCocoaWindow::setVisible(bool visible) parentCocoaWindow->m_activePopupWindow = window(); // QTBUG-30266: a window should not be resizable while a transient popup is open // Since this isn't a native popup, the window manager doesn't close the popup when you click outside + NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask]; + if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask)) #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 - && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)) + && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 + && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask) #endif - [parentCocoaWindow->m_nsWindow setStyleMask: - (parentCocoaWindow->windowStyleMask(parentCocoaWindow->m_windowFlags) & ~NSResizableWindowMask)]; + ) + [parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask]; } } @@ -398,13 +401,14 @@ void QCocoaWindow::setVisible(bool visible) [m_contentView setHidden:YES]; } if (parentCocoaWindow && window()->type() == Qt::Popup + && m_resizableTransientParent #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask) #endif ) // QTBUG-30266: a window should not be resizable while a transient popup is open - [parentCocoaWindow->m_nsWindow setStyleMask:parentCocoaWindow->windowStyleMask(parentCocoaWindow->m_windowFlags)]; + [parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask]; } } From 98c204a48616d8287ab2bdec2630ab0e4584a61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 23 Sep 2013 16:09:57 +0200 Subject: [PATCH 30/32] iOS: Resolve location of crt.o at build time, not qmake time By referring to crt.o by $(SDK) we allow Xcode to switch between the iPhoneSimulator and the iPhoneOS SDKs. Change-Id: I33d9f30b2f5a8f085dc4ddfc6e2ef228d02d639c Reviewed-by: Richard Moe Gustavsen --- mkspecs/features/ios/qt.prf | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/ios/qt.prf b/mkspecs/features/ios/qt.prf index f89cb0c287..79bc9a8f46 100644 --- a/mkspecs/features/ios/qt.prf +++ b/mkspecs/features/ios/qt.prf @@ -27,13 +27,9 @@ equals(TEMPLATE, app):contains(QT, gui(-private)?) { # get rid of this step completely and just pass -e _qtmn to the # linker, taking advantage of the new LC_MAIN load command. - # We use xcodebuild to resolve the location of the crt1 object file - # as we know that it lives in the same location as the c library. - c_library_path = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -find-library c 2>/dev/null") - - # We also know that iOS 3.1 and up uses crt1.3.1.o (technically not + # We know that iOS 3.1 and up uses crt1.3.1.o (technically not # true for simulator, but the SDK has a symlink to the correct file). - original_crt_path = $$dirname(c_library_path)/crt1.3.1.o + original_crt_path = "$(SDK_DIR)/usr/lib/crt1.3.1.o" xcode_objects_path = "$(OBJECT_FILE_DIR_$(CURRENT_VARIANT))/$(CURRENT_ARCH)" custom_crt_filename = "crt1_qt.o" From 6621188515200d6c7001b17989e54bb9f59a43c2 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Tue, 24 Sep 2013 14:10:17 +0200 Subject: [PATCH 31/32] Doc: Restore QDoc's use of the \since -one argument: assume it is the Qt version -more than one argument: copy verbatim Task-number: QTBUG-32172 Change-Id: Iaf5ec538f23abf4d1dfdf50bffcbbdede56d0b22 Reviewed-by: Lars Knoll Reviewed-by: Martin Smith --- src/tools/qdoc/generator.cpp | 13 +++---------- src/tools/qdoc/htmlgenerator.cpp | 27 ++++++--------------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 0d4e563836..549b3a3918 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -1120,17 +1120,10 @@ void Generator::generateSince(const Node *node, CodeMarker *marker) QStringList since = node->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + // Otherwise, reconstruct the string. text << " " << since.join(' '); } diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 4a6d5ea9a8..697955629e 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -1868,18 +1868,11 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) text.clear(); QStringList since = inner->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + //Otherwise, reconstruct the string. text << " " << since.join(' '); } text << Atom::ParaRight; @@ -2016,19 +2009,11 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) text.clear(); QStringList since = qcn->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + //Otherwise, reconstruct the string. text << " " << since.join(' '); } text << Atom::ParaRight; From 0b1e30aee41cbbe487cd072268cf784f8b09bcdf Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sun, 15 Sep 2013 13:55:03 +0000 Subject: [PATCH 32/32] Add shortcutsOverride in QLineEdit for used shortcuts QLineEdit uses shortcuts to QKeySequence::DeleteCompleteLine and QKeySequence::MoveToEndOfLine These shortcuts were not in the overrideShortcuts which can cause erratic behavior. Change-Id: I69e2b00e38d3f0e48a20f91f08a22b3fae9b7c48 Reviewed-by: Frederik Gladhorn --- src/widgets/widgets/qwidgetlinecontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 27048c1440..6a41144cc1 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1525,6 +1525,7 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) || ke == QKeySequence::Undo || ke == QKeySequence::MoveToNextWord || ke == QKeySequence::MoveToPreviousWord + || ke == QKeySequence::MoveToEndOfLine || ke == QKeySequence::MoveToStartOfDocument || ke == QKeySequence::MoveToEndOfDocument || ke == QKeySequence::SelectNextWord @@ -1535,7 +1536,8 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) || ke == QKeySequence::SelectEndOfBlock || ke == QKeySequence::SelectStartOfDocument || ke == QKeySequence::SelectAll - || ke == QKeySequence::SelectEndOfDocument) { + || ke == QKeySequence::SelectEndOfDocument + || ke == QKeySequence::DeleteCompleteLine) { ke->accept(); } else if (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier || ke->modifiers() == Qt::KeypadModifier) {