From c05220038d50f26cb5da03b13b82372297f99c83 Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 17:09:25 -0400 Subject: Fix portability problems in bin/createpackage.pl. * Use File::Spec functions to manipulate path components. * Keep $targetplatform lower case for case sensitive systems. Signed-off-by: axis --- bin/createpackage.pl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 4597b04..3480702 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -145,10 +145,8 @@ my $signed_sis_name = $pkgoutputbasename.".sis"; # Store some utility variables my $scriptpath = dirname(__FILE__); my $certtext = $certificate; -my $certpath = $scriptpath; -$certpath =~ s-^(.*[^\\])$-$1\\-o; # ensure path ends with a backslash -$certpath = $certpath."../"; # certificates are one step up in hierarcy -$certpath =~ s-/-\\-go; # for those working with UNIX shells +# certificates are one step up in hierarchy +my $certpath = File::Spec->catdir($scriptpath, File::Spec->updir()); # Check some pre-conditions and print error messages if needed unless (length($templatepkg) && length($platform) && length($target)) { @@ -172,14 +170,14 @@ if (length($certificate)) { } else { #If no certificate is given, check default options $certtext = "RnD"; - $certificate = $certpath."rd.cer"; - $key = $certpath."rd-key.pem"; + $certificate = File::Spec->catfile($certpath, "rd.cer"); + $key = File::Spec->catfile($certpath, "rd-key.pem"); stat($certificate); unless( -e _ ) { $certtext = "Self Signed"; - $certificate = $certpath."selfsigned.cer"; - $key = $certpath."selfsigned.key"; + $certificate = File::Spec->catfile($certpath, "selfsigned.cer"); + $key = File::Spec->catfile($certpath, "selfsigned.key"); } } -- cgit v0.12 From 131d2387436d05aec95bdddeb571930b2a55cf73 Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Thu, 17 Sep 2009 16:38:31 -0400 Subject: mkspecs: fix warning when calling qmake Signed-off-by: axis --- mkspecs/common/symbian/symbian.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 38e955a..fe698fb 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -104,7 +104,7 @@ QMAKE_STRIP = strip QMAKE_STRIPFLAGS_LIB += --strip-unneeded load(qt_config) -load(platform_paths) +load(symbian/platform_paths) MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA = "OPTION_REPLACE ARMCC --export_all_vtbl // don't use --export_all_vtbl" MMP_RULES += PAGED -- cgit v0.12 From 8c61bb163a13b1e2b78df0060103546a31c16ed6 Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 20:05:13 -0400 Subject: Make all Symbian #includes lower case. Signed-off-by: axis --- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/kernel/qdnd_s60.cpp | 2 +- src/gui/kernel/qsound_s60.cpp | 2 +- src/gui/styles/qs60style_s60.cpp | 4 ++-- src/gui/text/qfontdatabase_s60.cpp | 2 +- src/gui/text/qfontengine_s60.cpp | 4 ++-- src/gui/text/qfontengine_s60_p.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 27e8602..cdc028b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -62,7 +62,7 @@ #include "private/qsoftkeymanager_p.h" #include "apgwgnam.h" // For CApaWindowGroupName -#include // For CMdaAudioToneUtility +#include // For CMdaAudioToneUtility #if defined(Q_WS_S60) # if !defined(QT_NO_IM) diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp index 3d6ecd2..24ae7ce 100644 --- a/src/gui/kernel/qdnd_s60.cpp +++ b/src/gui/kernel/qdnd_s60.cpp @@ -52,7 +52,7 @@ #include "qdnd_p.h" #include "qt_s60_p.h" -#include +#include // pointer cursor #include #include diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp index 352580e..ee5227a 100644 --- a/src/gui/kernel/qsound_s60.cpp +++ b/src/gui/kernel/qsound_s60.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 131d8bc..4fa009c 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -58,8 +58,8 @@ #include #include #include -#include -#include +#include +#include #include #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 1a6bb11..b51d828 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -50,7 +50,7 @@ #include "qendian.h" #include #if defined(QT_NO_FREETYPE) -#include +#include #endif QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 88ae8f6..69ac7a1 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -49,8 +49,8 @@ #include #include -#include -#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 44f8122..746f929 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -56,7 +56,7 @@ #include "qconfig.h" #include "qfontengine_p.h" #include "qsize.h" -#include +#include class CFbsBitmap; class CFbsBitmapDevice; -- cgit v0.12 From d0be442d96f780465eff0be3afbf543e5d3e82ab Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 19:14:20 -0400 Subject: Add createpackage.bat equivalent for Unix systems. Signed-off-by: axis --- bin/createpackage.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 bin/createpackage.sh diff --git a/bin/createpackage.sh b/bin/createpackage.sh new file mode 100755 index 0000000..fdd4eeb --- /dev/null +++ b/bin/createpackage.sh @@ -0,0 +1,3 @@ +#!/bin/sh +scriptpath=`dirname $0` +perl $scriptpath/createpackage.pl "$@" -- cgit v0.12 From 1609689ad1b9672fd4598aa30a7429b9d37bc3ca Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 20:29:51 -0400 Subject: Linux support for platform specific commands in .pro files. Signed-off-by: axis --- projects.pro | 15 +++++++++++++-- src/s60main/s60main.pro | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/projects.pro b/projects.pro index 2a6a956..10cff2a 100644 --- a/projects.pro +++ b/projects.pro @@ -107,7 +107,8 @@ win32 { } symbian { confclean.depends += distclean - confclean.commands += \ + win32 { + confclean.commands += \ (cd src\tools\moc && $(MAKE) distclean) $$escape_expand(\n\t) \ (cd src\tools\rcc && $(MAKE) distclean) $$escape_expand(\n\t) \ (cd src\tools\uic && $(MAKE) distclean) $$escape_expand(\n\t) \ @@ -116,7 +117,17 @@ symbian { -$(DEL_FILE) mkspecs\qconfig.pri $$escape_expand(\n\t) \ -$(DEL_FILE) .qmake.cache $$escape_expand(\n\t) \ (cd qmake && $(MAKE) distclean) - + } else { + confclean.commands += \ + (cd src/tools/moc && $(MAKE) distclean) $$escape_expand(\n\t) \ + (cd src/tools/rcc && $(MAKE) distclean) $$escape_expand(\n\t) \ + (cd src/tools/uic && $(MAKE) distclean) $$escape_expand(\n\t) \ + -$(DEL_FILE) src/corelib/global/qconfig.h $$escape_expand(\n\t) \ + -$(DEL_FILE) src/corelib/global/qconfig.cpp $$escape_expand(\n\t) \ + -$(DEL_FILE) mkspecs/qconfig.pri $$escape_expand(\n\t) \ + -$(DEL_FILE) .qmake.cache $$escape_expand(\n\t) \ + (cd qmake && $(MAKE) distclean) + } } QMAKE_EXTRA_TARGETS += confclean qmakeclean.commands += (cd qmake && $(MAKE) clean) diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro index cc3c547..d6b5ac8 100644 --- a/src/s60main/s60main.pro +++ b/src/s60main/s60main.pro @@ -40,8 +40,13 @@ symbian-abld: { # abld build commands generated resources after the static library is built, and # we have dependency to resource from static lib -> resources need to be generated # explicitly before library +win32: { rsgFix2.commands = "-$(DEL_FILE) $(EPOCROOT)Epoc32\Data\z\resource\apps\s60main.rsc >NUL 2>&1" rsgFix.commands = "-$(ABLD) resource $(PLATFORM) $(CFG) 2>NUL" +} else { + rsgFix2.commands = "-$(DEL_FILE) $(EPOCROOT)epoc32/data/z/resource/apps/s60main.rsc >/dev/null 2>&1" + rsgFix.commands = "-$(ABLD) resource $(PLATFORM) $(CFG) 2>/dev/null" +} QMAKE_EXTRA_TARGETS += rsgFix rsgFix2 PRE_TARGETDEPS += rsgFix rsgFix2 } -- cgit v0.12 From d0fb8557f3fc3e7c9305662d118228ceca9df72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 13 Nov 2009 17:38:02 +0100 Subject: Character spacing when drawing a QPicture to a high DPI device. Drawing some text into a QPicture, and then drawing that QPicture to e.g. a QPrinter, would make the character spacing all wrong. The old approach that tried to fix this adjusted the DPI of the font that was used, so that the text size would be correct. It seems this is not enough, since it will lay out the text in the default resolution, and then scale that up, which may/may not introduce errors. Task-number: QTBUG-4974, 256481 Reviewed-by: Kim --- src/gui/image/qpicture.cpp | 49 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index f502827..6c5fb02 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -440,36 +440,6 @@ bool QPicture::play(QPainter *painter) return true; // no end-command } - -// -// QFakeDevice is used to create fonts with a custom DPI -// -class QFakeDevice : public QPaintDevice -{ -public: - QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } - void setDpiX(int dpi) { dpi_x = dpi; } - void setDpiY(int dpi) { dpi_y = dpi; } - QPaintEngine *paintEngine() const { return 0; } - int metric(PaintDeviceMetric m) const - { - switch(m) { - case PdmPhysicalDpiX: - case PdmDpiX: - return dpi_x; - case PdmPhysicalDpiY: - case PdmDpiY: - return dpi_y; - default: - return QPaintDevice::metric(m); - } - } - -private: - int dpi_x; - int dpi_y; -}; - /*! \internal Iterates over the internal picture data and draws the picture using @@ -679,30 +649,29 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) if (d->formatMajor >= 9) { s >> dbl; - QFont fnt(font); - if (dbl != 1.0) { - QFakeDevice fake; - fake.setDpiX(qRound(dbl*qt_defaultDpiX())); - fake.setDpiY(qRound(dbl*qt_defaultDpiY())); - fnt = QFont(font, &fake); - } + QFont fnt(font, painter->device()); + + qreal scale = painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY()); + painter->save(); + painter->scale(1/scale, 1/scale); qreal justificationWidth; s >> justificationWidth; int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight; - QSizeF size(1, 1); + QSizeF size(scale, scale); if (justificationWidth > 0) { - size.setWidth(justificationWidth); + size.setWidth(justificationWidth*scale); flags |= Qt::TextJustificationForced; flags |= Qt::AlignJustify; } QFontMetrics fm(fnt); - QPointF pt(p.x(), p.y() - fm.ascent()); + QPointF pt(p.x()*scale, p.y()*scale - fm.ascent()); qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0, str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + painter->restore(); } else { qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0, str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); -- cgit v0.12 From 415c9a230a957f17c759468c5333266968f74b96 Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 20:03:55 -0400 Subject: Add Linux host support to Symbian mkspecs. Signed-off-by: axis --- mkspecs/common/symbian/symbian.conf | 12 +++++++++--- mkspecs/features/symbian/application_icon.prf | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index fe698fb..0bd15fc 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -73,7 +73,7 @@ QMAKE_LIBS_COMPAT = QMAKE_LIBS_QT_ENTRY = -llibcrt0.lib QMAKE_LIBS_S60 = -lavkon -!isEmpty(QMAKE_SH) { +win32:!isEmpty(QMAKE_SH) | unix { QMAKE_COPY = cp QMAKE_COPY_DIR = cp -r QMAKE_MOVE = mv @@ -91,9 +91,15 @@ QMAKE_LIBS_S60 = -lavkon QMAKE_CHK_DIR_EXISTS = if not exist } +win32 { QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe +} else { +QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc +QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic +QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc +} QMAKE_IDL = midl QMAKE_LIB = ar -ru @@ -130,10 +136,10 @@ default_deployment.pkg_prerules = \ DEPLOYMENT += default_deployment -exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/Series60v5.0.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/Series60v5.0.sis) { +exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/series60v5.0.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/series60v5.0.sis) { S60_VERSION = 5.0 } else { - exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/Series60v3.2.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/Series60v3.2.sis) { + exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/series60v3.2.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/series60v3.2.sis) { S60_VERSION = 3.2 } else { S60_VERSION = 3.1 diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index b0c1bb1..a8c3acc 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -19,7 +19,7 @@ contains( CONFIG, no_icon ) { # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code symbian-abld { #Makefile: requires paths with backslash - ICON = $$replace( ICON, /, \\) + win32:ICON = $$replace(ICON, /, \\) # Extra compiler rules for mifconv mifconv.output = ${ZDIR}$$APP_RESOURCE_DIR/$${TARGET.UID3}.mif @@ -34,7 +34,7 @@ contains( CONFIG, no_icon ) { } # Rules to use generated MIF file from symbian resources RSS_RULES.number_of_icons = $$size(ICON) - RSS_RULES.icon_file = $$replace( APP_RESOURCE_DIR, /, \\\\ )\\\\$${TARGET.UID3}.mif + RSS_RULES.icon_file = APP_RESOURCE_DIR/$${TARGET.UID3}.mif + win32:RSS_RULES.icon_file = $$replace(RSS_RULES.icon_file, /, \\) } } - -- cgit v0.12 From 0d6b62e1a31f564b0ad68e3060fb3910d9025791 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 17 Nov 2009 10:28:19 +0100 Subject: Fixed indentation. --- mkspecs/common/symbian/symbian.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 0bd15fc..a9f458c 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -92,13 +92,13 @@ win32:!isEmpty(QMAKE_SH) | unix { } win32 { -QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe + QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe + QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe + QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe } else { -QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc -QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic -QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc + QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc + QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic + QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc } QMAKE_IDL = midl -- cgit v0.12 From 2d8d855de79a38e16b9229f3ef9400661e8e3259 Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Sun, 6 Sep 2009 20:39:04 -0400 Subject: qmake: add Linux host support to Symbian generator Signed-off-by: axis --- qmake/generators/makefile.cpp | 10 ++++-- .../symbian/initprojectdeploy_symbian.cpp | 10 +++--- qmake/generators/symbian/symmake.cpp | 14 +++++--- qmake/generators/symbian/symmake_abld.cpp | 42 +++++++++++++++------- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 388e64f..f9340f9 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -65,6 +65,12 @@ #include #include +#ifdef Q_OS_WIN32 +#define NO_STDERR "2> NUL" +#else +#define NO_STDERR "2>/dev/null" +#endif + QT_BEGIN_NAMESPACE // Well, Windows doesn't have this, so here's the macro @@ -1796,7 +1802,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) if(tmp_clean.indexOf("${QMAKE_") == -1) { t << "\n\t" << "-$(DEL_FILE) " << tmp_clean; if (isForSymbian()) - t << " 2> NUL"; // Eliminate unnecessary warnings + t << " " << NO_STDERR; // Eliminate unnecessary warnings wrote_clean = true; } if(!wrote_clean_cmds || !wrote_clean) { @@ -1826,7 +1832,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } if(!cleans.isEmpty()) if (isForSymbian()) - t << valGlue(cleans, "\n\t" + del_statement, " 2> NUL\n\t" + del_statement, " 2> NUL"); + t << valGlue(cleans, "\n\t" + del_statement, " " NO_STDERR "\n\t" + del_statement, " " NO_STDERR); else t << valGlue(cleans, "\n\t" + del_statement, "\n\t" + del_statement, ""); if(!wrote_clean_cmds) { diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index f27d1ba..676cea5 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -176,12 +176,12 @@ static void createPluginStub(const QFileInfo& info, QStringList& generatedDirs, QStringList& generatedFiles) { - QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR "\\")); + QDir().mkpath(PLUGIN_STUB_DIR); if (!generatedDirs.contains(PLUGIN_STUB_DIR)) generatedDirs << PLUGIN_STUB_DIR; // Plugin stubs must have different name from the actual plugins, because // the toolchain for creating ROM images cannot handle non-binary .dll files properly. - QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "\\") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); + QFile stubFile(QDir(PLUGIN_STUB_DIR).filePath(info.completeBaseName() + "." SUFFIX_QTPLUGIN)); if (stubFile.open(QIODevice::WriteOnly)) { if (!generatedFiles.contains(stubFile.fileName())) generatedFiles << stubFile.fileName(); @@ -330,12 +330,12 @@ void initProjectDeploySymbian(QMakeProject* project, if (isBinary(info)) { if (deployBinaries) { // Executables and libraries are deployed to \sys\bin - QFileInfo releasePath(epocRoot() + "epoc32\\release\\" + platform + "\\" + build + "\\"); + QFileInfo releasePath(epocRoot() + QDir::toNativeSeparators("epoc32/release/" + platform + "/" + build + "/")); if(devicePathHasDriveLetter) { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), + deploymentList.append(CopyItem(Option::fixPathToLocalOS(QDir(releasePath.absolutePath()).filePath(info.fileName()), false, true), Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); } else { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), + deploymentList.append(CopyItem(Option::fixPathToLocalOS(QDir(releasePath.absolutePath()).filePath(info.fileName()), false, true), Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); } } diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index dd1dd5f..208da59 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -50,11 +50,17 @@ #include #include +#ifdef Q_OS_WIN +#define SCRIPT_EXT ".bat" +#else +#define SCRIPT_EXT ".sh" +#endif + #define RESOURCE_DIRECTORY_MMP "/resource/apps" #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\" #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps" #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def" -#define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def" +#define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonu.def" #define BLD_INF_FILENAME_LEN (sizeof(BLD_INF_FILENAME) - 1) #define BLD_INF_RULES_BASE "BLD_INF_RULES." @@ -395,7 +401,7 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile) for (int i = 0; i < depList.size(); ++i) { t << QString("\"%1\" - \"%2\"") .arg(QString(depList.at(i).from).replace('\\','/')) - .arg(depList.at(i).to) << endl; + .arg(QString(depList.at(i).to).replace('/','\\')) << endl; } t << endl; @@ -1634,7 +1640,7 @@ void SymbianMakefileGenerator::generateCleanCommands(QTextStream& t, t << "\t-@ if EXIST \"" << QDir::toNativeSeparators(item) << "\" "; t << cmd << " " << cmdOptions << " \"" << QDir::toNativeSeparators(item) << "\"" << endl; #else - t << "\t-if test -f " << QDir::toNativeSeparators(item) << "; then "; + t << "\t-if test -e " << QDir::toNativeSeparators(item) << "; then "; t << cmd << " " << cmdOptions << " " << QDir::toNativeSeparators(item) << "; fi" << endl; #endif } @@ -1667,7 +1673,7 @@ void SymbianMakefileGenerator::writeSisTargets(QTextStream &t) t << OK_SIS_TARGET ":" << endl; - QString pkgcommand = QString("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \ + QString pkgcommand = QString("\tcreatepackage" SCRIPT_EXT " $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \ "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)") .arg(fixedTarget) .arg("pkg"); diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 4d1673b..b06db2f 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -195,16 +195,21 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; t << "MOVE = " << var("QMAKE_MOVE") << endl; +#ifdef Q_OS_WIN32 t << "XCOPY = xcopy /d /f /h /r /y /i" << endl; t << "ABLD = ABLD.BAT" << endl; +#else + t << "XCOPY = cp -u -v" << endl; + t << "ABLD = abld" << endl; +#endif t << "DEBUG_PLATFORMS = " << debugPlatforms.join(" ") << endl; t << "RELEASE_PLATFORMS = " << releasePlatforms.join(" ") << endl; t << "MAKE = make" << endl; t << endl; t << "ifeq (WINS,$(findstring WINS, $(PLATFORM)))" << endl; - t << "ZDIR=$(EPOCROOT)epoc32\\release\\$(PLATFORM)\\$(CFG)\\Z" << endl; + t << "ZDIR=$(EPOCROOT)" << QDir::toNativeSeparators("epoc32/release/$(PLATFORM)/$(CFG)/z") << endl; t << "else" << endl; - t << "ZDIR=$(EPOCROOT)epoc32\\data\\z" << endl; + t << "ZDIR=$(EPOCROOT)" << QDir::toNativeSeparators("epoc32/data/z") << endl; t << "endif" << endl; t << endl; t << "DEFINES" << '\t' << " = " @@ -304,8 +309,13 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool if (values.at(i).endsWith("/" QT_EXTRA_INCLUDE_DIR)) { QString fixedValue(QDir::toNativeSeparators(values.at(i))); dirsToClean << fixedValue; +#ifdef Q_OS_WIN32 t << "\t-@ if NOT EXIST \"" << fixedValue << "\" mkdir \"" << fixedValue << "\"" << endl; +#else + t << "\t-@ if test ! -d \"" << fixedValue << "\"; then mkdir \"" + << fixedValue << "\"" << "; fi" < NUL" gets appended to generated clean targets in makefile.cpp. t << EXTENSION_CLEAN ": " COMPILER_CLEAN_TARGET << endl; +#ifdef Q_OS_WIN32 generateCleanCommands(t, dirsToClean, var("QMAKE_DEL_DIR"), " /S /Q ", "", ""); +#else + generateCleanCommands(t, dirsToClean, "rm", " -rf ", "", ""); +#endif t << endl; t << PRE_TARGETDEPS_TARGET ":" @@ -375,7 +389,11 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool // Create execution target if (debugPlatforms.contains("winscw") && targetType == TypeExe) { t << "run:" << endl; +#ifdef Q_OS_WIN32 t << "\t-call " << epocRoot() << "epoc32\\release\\winscw\\udeb\\" << removePathSeparators(escapeFilePath(fileFixify(project->first("TARGET"))).append(".exe")) << endl << endl; +#else + t << "\t-wine " << epocRoot() << "epoc32/release/winscw/udeb/" << removePathSeparators(escapeFilePath(fileFixify(project->first("TARGET"))).append(".exe")) << endl << endl; +#endif } } @@ -423,16 +441,16 @@ bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t) void SymbianAbldMakefileGenerator::writeStoreBuildTarget(QTextStream &t) { t << STORE_BUILD_TARGET ":" << endl; - t << "\t@echo # ============================================================================== > " MAKE_CACHE_NAME << endl; - t << "\t@echo # This file is generated by make and should not be modified by the user >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # Name : " << MAKE_CACHE_NAME << " >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # Part of : " << project->values("TARGET").join(" ") << " >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # Description : This file is used to cache last build target for >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # make sis target. >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # Version : >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # >> " MAKE_CACHE_NAME << endl; - t << "\t@echo # ============================================================================== >> " MAKE_CACHE_NAME << endl; - t << "\t@echo. >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# ============================================================================== > " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# This file is generated by make and should not be modified by the user >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# Name : " << MAKE_CACHE_NAME << " >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# Part of : " << project->values("TARGET").join(" ") << " >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# Description : This file is used to cache last build target for >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# make sis target. >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# Version : >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# >> " MAKE_CACHE_NAME << endl; + t << "\t@echo \\# ============================================================================== >> " MAKE_CACHE_NAME << endl; + t << "\t@echo >> " MAKE_CACHE_NAME << endl; t << "\t@echo QT_SIS_TARGET ?= $(QT_SIS_TARGET) >> " MAKE_CACHE_NAME << endl; t << endl; -- cgit v0.12 From 78474a65e4f61e9d1ae8116d5b690cf78729aa71 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 17 Nov 2009 10:39:08 +0100 Subject: Improving parts of commit 2d8d855d. It breaks Symbian on Windows, so instead use an approach that works on all platforms. --- qmake/generators/symbian/symmake_abld.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index b06db2f..8e6c4fa 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -440,21 +440,31 @@ bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t) void SymbianAbldMakefileGenerator::writeStoreBuildTarget(QTextStream &t) { +#ifdef Q_OS_WIN +#define HASH "#" +#define EMPTYECHO "." +#else +#define HASH "\\#" +#define EMPTYECHO +#endif + t << STORE_BUILD_TARGET ":" << endl; - t << "\t@echo \\# ============================================================================== > " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# This file is generated by make and should not be modified by the user >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# Name : " << MAKE_CACHE_NAME << " >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# Part of : " << project->values("TARGET").join(" ") << " >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# Description : This file is used to cache last build target for >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# make sis target. >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# Version : >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# >> " MAKE_CACHE_NAME << endl; - t << "\t@echo \\# ============================================================================== >> " MAKE_CACHE_NAME << endl; - t << "\t@echo >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " ============================================================================== > " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " This file is generated by make and should not be modified by the user >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " Name : " << MAKE_CACHE_NAME << " >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " Part of : " << project->values("TARGET").join(" ") << " >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " Description : This file is used to cache last build target for >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " make sis target. >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " Version : >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " >> " MAKE_CACHE_NAME << endl; + t << "\t@echo " HASH " ============================================================================== >> " MAKE_CACHE_NAME << endl; + t << "\t@echo" EMPTYECHO " >> " MAKE_CACHE_NAME << endl; t << "\t@echo QT_SIS_TARGET ?= $(QT_SIS_TARGET) >> " MAKE_CACHE_NAME << endl; t << endl; generatedFiles << MAKE_CACHE_NAME; +#undef HASH +#undef EMPTYECHO } void SymbianAbldMakefileGenerator::writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension) -- cgit v0.12 From 14fcc4890cf41c17e69853ca7cafd14c947ba7b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 27 Nov 2009 19:44:10 +0100 Subject: trolltech => nokia --- tools/linguist/linguist/mainwindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/linguist/mainwindow.ui b/tools/linguist/linguist/mainwindow.ui index b182f27..108cbea 100644 --- a/tools/linguist/linguist/mainwindow.ui +++ b/tools/linguist/linguist/mainwindow.ui @@ -679,7 +679,7 @@ About Qt - Display information about the Qt toolkit by Trolltech. + Display information about the Qt toolkit by Nokia. QAction::AboutQtRole -- cgit v0.12 From 5c488b7e15dbd5ee08a909e4dcc997a58ba63a2d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 23 Nov 2009 17:04:49 +0100 Subject: Adjust documentation on QCombobox::maxVisibleItems to mention that this does not work with gtk. Also fixed the fact that it would show one item to many. Task-number: QTBUG-760 Reviewed-by: jbache --- src/gui/widgets/qcombobox.cpp | 5 +++-- tests/auto/qcombobox/tst_qcombobox.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index bd1d8ba..ea65a40 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -1265,7 +1265,8 @@ QComboBox::~QComboBox() By default, this property has a value of 10. - \note This property is ignored for non-editable comboboxes in Mac style. + \note This property is ignored for non-editable comboboxes in styles that returns + false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. */ int QComboBox::maxVisibleItems() const { @@ -2345,7 +2346,7 @@ void QComboBox::showPopup() toCheck.push(idx); #endif ++count; - if (!usePopup && count > d->maxVisibleItems) { + if (!usePopup && count >= d->maxVisibleItems) { toCheck.clear(); break; } diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index af71961..941494f 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -156,6 +156,7 @@ private slots: void resetModel(); void keyBoardNavigationWithMouse(); void task_QTBUG_1071_changingFocusEmitsActivated(); + void maxVisibleItems(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2527,5 +2528,34 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() QTRY_COMPARE(spy.count(), 1); } +void tst_QComboBox::maxVisibleItems() +{ + QComboBox comboBox; + QCOMPARE(comboBox.maxVisibleItems(), 10); //default value. + + QStringList content; + for(int i = 1; i < 50; i++) + content += QString::number(i); + + comboBox.addItems(content); + comboBox.show(); + comboBox.resize(200, comboBox.height()); + QTRY_VERIFY(comboBox.isVisible()); + + comboBox.setMaxVisibleItems(5); + QCOMPARE(comboBox.maxVisibleItems(), 5); + + comboBox.showPopup(); + QTRY_VERIFY(comboBox.view()); + QTRY_VERIFY(comboBox.view()->isVisible()); + + QAbstractItemView *v = comboBox.view(); + int itemHeight = v->visualRect(v->model()->index(0,0)).height(); + if (v->style()->styleHint(QStyle::SH_ComboBox_Popup)) + QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); + // QCombobox without a popup does not work, see QTBUG-760 +} + + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v0.12 From f3ac20ac8100142cde0accfb72eab48590303c4a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 28 Nov 2009 16:19:38 +0100 Subject: Reduce the code duplication within QMetaObject::indexOf{Signal,Slot,Method} This also change the bounds of the checked method by using the signalCount as a hint Reviewed-by: Brad --- src/corelib/kernel/qmetaobject.cpp | 66 ++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 6e6da19..ad9db09 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -482,6 +482,31 @@ int QMetaObject::classInfoCount() const return n; } +/** \internal +* helper class for indexOf{Method,Slot,Signal}, returns the relative index of the method within +* the baseObject +* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything. +*/ +template +static inline int indexOfMethodRelative(const QMetaObject **baseObject, const char *method) +{ + while (*baseObject) { + const QMetaObject *const m = *baseObject; + int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) + ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); + const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) + ? (priv(m->d.data)->signalCount - 1) : 0; + for (; i >= end; --i) { + if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) + && strcmp(method, m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) + return i; + } + *baseObject = m->d.superdata; + } + return -1; +} + + /*! \since 4.5 @@ -515,17 +540,10 @@ int QMetaObject::indexOfConstructor(const char *constructor) const */ int QMetaObject::indexOfMethod(const char *method) const { - int i = -1; const QMetaObject *m = this; - while (m && i < 0) { - for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) - if (strcmp(method, m->d.stringdata - + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { - i += m->methodOffset(); - break; - } - m = m->d.superdata; - } + int i = indexOfMethodRelative<0>(&m, method); + if (i >= 0) + i += m->methodOffset(); return i; } @@ -556,19 +574,7 @@ int QMetaObject::indexOfSignal(const char *signal) const */ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const char *signal) { - int i = -1; - while (*baseObject) { - const QMetaObject *const m = *baseObject; - for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) - if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSignal - && strcmp(signal, m->d.stringdata - + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { - break; - } - if (i >= 0) - break; - *baseObject = m->d.superdata; - } + int i = indexOfMethodRelative(baseObject, signal); #ifndef QT_NO_DEBUG const QMetaObject *m = *baseObject; if (i >= 0 && m && m->d.superdata) { @@ -592,18 +598,10 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co */ int QMetaObject::indexOfSlot(const char *slot) const { - int i = -1; const QMetaObject *m = this; - while (m && i < 0) { - for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) - if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot - && strcmp(slot, m->d.stringdata - + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { - i += m->methodOffset(); - break; - } - m = m->d.superdata; - } + int i = indexOfMethodRelative(&m, slot); + if (i >= 0) + i += m->methodOffset(); return i; } -- cgit v0.12 From b881d8fb99972f1bd04ab4c84843cc8d43ddbeed Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 17 Nov 2009 12:51:16 +0100 Subject: Fix certain type-const-ref syntax not recognized by normalizedSignature() Normally, const Type & is normalized to just Type, but this didn't work for Templateconst& or Type*const& types. This now works as expected. However, this changes the way these types are normalized, and existing code using the old syntax will break. We can prevent this breakage by also normalizing the method signature in the metaobject when looking up signals and slots in QObject::connect(). I have added an autotest for this, which includes moc output generated by Qt 4.6's moc. This means we need to bump the metaobject revision number even though we are not adding any new data (only changing the normalized strings we store). Task-number: QTBUG-2407 Task-number: QTBUG-3722 Reviewed-by: ogoffart --- src/corelib/kernel/qmetaobject.cpp | 58 ++++++--- src/corelib/kernel/qmetaobject_p.h | 24 +++- src/corelib/kernel/qobject.cpp | 36 ++++-- src/tools/moc/generator.cpp | 2 +- tests/auto/qobject/moc_oldnormalizeobject.cpp | 118 ++++++++++++++++++ tests/auto/qobject/oldnormalizeobject.h | 28 +++++ tests/auto/qobject/tst_qobject.cpp | 172 ++++++++++++++++++++++++++ tests/auto/qobject/tst_qobject.pro | 22 ++-- 8 files changed, 424 insertions(+), 36 deletions(-) create mode 100644 tests/auto/qobject/moc_oldnormalizeobject.cpp create mode 100644 tests/auto/qobject/oldnormalizeobject.h diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index ad9db09..bc1e8dcc 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -488,18 +488,30 @@ int QMetaObject::classInfoCount() const * \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything. */ template -static inline int indexOfMethodRelative(const QMetaObject **baseObject, const char *method) +static inline int indexOfMethodRelative(const QMetaObject **baseObject, + const char *method, + bool normalizeStringData) { while (*baseObject) { const QMetaObject *const m = *baseObject; int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) - ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); + ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) - ? (priv(m->d.data)->signalCount - 1) : 0; - for (; i >= end; --i) { - if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) - && strcmp(method, m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) - return i; + ? (priv(m->d.data)->signalCount - 1) : 0; + if (!normalizeStringData) { + for (; i >= end; --i) { + if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) + && strcmp(method, m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) + return i; + } + } else if (priv(m->d.data)->revision < 5) { + const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]); + const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata); + for (; i >= end; --i) { + if ((MethodType == 0|| (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) + && normalizedSignature == method) + return i; + } } *baseObject = m->d.superdata; } @@ -541,7 +553,11 @@ int QMetaObject::indexOfConstructor(const char *constructor) const int QMetaObject::indexOfMethod(const char *method) const { const QMetaObject *m = this; - int i = indexOfMethodRelative<0>(&m, method); + int i = indexOfMethodRelative<0>(&m, method, false); + if (i < 0) { + m = this; + i = indexOfMethodRelative<0>(&m, method, true); + } if (i >= 0) i += m->methodOffset(); return i; @@ -561,7 +577,11 @@ int QMetaObject::indexOfMethod(const char *method) const int QMetaObject::indexOfSignal(const char *signal) const { const QMetaObject *m = this; - int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal); + int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, false); + if (i < 0) { + m = this; + i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, true); + } if (i >= 0) i += m->methodOffset(); return i; @@ -572,9 +592,11 @@ int QMetaObject::indexOfSignal(const char *signal) const \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found */ -int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const char *signal) +int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, + const char *signal, + bool normalizeStringData) { - int i = indexOfMethodRelative(baseObject, signal); + int i = indexOfMethodRelative(baseObject, signal, normalizeStringData); #ifndef QT_NO_DEBUG const QMetaObject *m = *baseObject; if (i >= 0 && m && m->d.superdata) { @@ -587,7 +609,6 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co return i; } - /*! Finds \a slot and returns its index; otherwise returns -1. @@ -598,8 +619,17 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co */ int QMetaObject::indexOfSlot(const char *slot) const { - const QMetaObject *m = this; - int i = indexOfMethodRelative(&m, slot); + int i = QMetaObjectPrivate::indexOfSlot(this, slot, false); + if (i < 0) + i = QMetaObjectPrivate::indexOfSlot(this, slot, true); + return i; +} + +int QMetaObjectPrivate::indexOfSlot(const QMetaObject *m, + const char *slot, + bool normalizeStringData) +{ + int i = indexOfMethodRelative(&m, slot, normalizeStringData); if (i >= 0) i += m->methodOffset(); return i; diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index b5a7530..7afb70b 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -115,11 +115,17 @@ struct QMetaObjectPrivate int constructorCount, constructorData; //since revision 2 int flags; //since revision 3 int signalCount; //since revision 4 + // revision 5 introduces changes in normalized signatures, no new members static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject) { return reinterpret_cast(metaobject->d.data); } - static int indexOfSignalRelative(const QMetaObject **baseObject, const char* name); + static int indexOfSignalRelative(const QMetaObject **baseObject, + const char* name, + bool normalizeStringData); + static int indexOfSlot(const QMetaObject *m, + const char *slot, + bool normalizeStringData); static int originalClone(const QMetaObject *obj, int local_method_index); #ifndef QT_NO_QOBJECT @@ -245,6 +251,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc } while (optional[++i].keyword != 0); } + bool star = false; while (t != e) { char c = *t++; if (fixScope && c == ':' && *t == ':' ) { @@ -255,6 +262,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc --i; result.resize(i + 1); } + star = star || c == '*'; result += c; if (c == '<') { //template recursion @@ -275,6 +283,20 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc } } } + + // cv qualifers can appear after the type as well + if (t != e && (e - t >= 5 && strncmp("const", t, 5) == 0)) { + t += 5; + while (t != e && is_space(*t)) + ++t; + if (adjustConst && t != e && *t == '&') { + // treat const ref as value + ++t; + } else if (!star) { + // move const to the front (but not if const comes after a *) + result.prepend("const "); + } + } } return result; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 95602d9..52c94e9 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2522,20 +2522,25 @@ bool QObject::connect(const QObject *sender, const char *signal, const QMetaObject *smeta = sender->metaObject(); const char *signal_arg = signal; ++signal; //skip code - int signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal); + int signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false); if (signal_index < 0) { // check for normalized signatures tmp_signal_name = QMetaObject::normalizedSignature(signal - 1); signal = tmp_signal_name.constData() + 1; smeta = sender->metaObject(); - signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal); + signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false); + } + if (signal_index < 0) { + // re-use tmp_signal_name and signal from above - if (signal_index < 0) { - err_method_notfound(sender, signal_arg, "connect"); - err_info_about_objects("connect", sender, receiver); - return false; - } + smeta = sender->metaObject(); + signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, true); + } + if (signal_index < 0) { + err_method_notfound(sender, signal_arg, "connect"); + err_info_about_objects("connect", sender, receiver); + return false; } signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index); int signalOffset, methodOffset; @@ -2555,16 +2560,21 @@ bool QObject::connect(const QObject *sender, const char *signal, int method_index = -1; switch (membcode) { case QSLOT_CODE: - method_index = rmeta->indexOfSlot(method); + method_index = QMetaObjectPrivate::indexOfSlot(rmeta, method, false); break; case QSIGNAL_CODE: - method_index = rmeta->indexOfSignal(method); + method_index = QMetaObjectPrivate::indexOfSignalRelative(&rmeta, method, false); + if (method_index >= 0) + method_index += rmeta->methodOffset(); break; } if (method_index < 0) { // check for normalized methods tmp_method_name = QMetaObject::normalizedSignature(method); method = tmp_method_name.constData(); + + // rmeta may have been modified above + rmeta = receiver->metaObject(); switch (membcode) { case QSLOT_CODE: method_index = rmeta->indexOfSlot(method); @@ -2752,7 +2762,9 @@ bool QObject::disconnect(const QObject *sender, const char *signal, do { int signal_index = -1; if (signal) { - signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal); + signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, false); + if (signal_index < 0) + signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal, true); if (signal_index < 0) break; signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index); @@ -3361,7 +3373,9 @@ int QObjectPrivate::signalIndex(const char *signalName) const { Q_Q(const QObject); const QMetaObject *base = q->metaObject(); - int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName); + int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, false); + if (relative_index < 0) + relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, true); if (relative_index < 0) return relative_index; relative_index = QMetaObjectPrivate::originalClone(base, relative_index); diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 1ed6586..b99cb28 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -173,7 +173,7 @@ void Generator::generateCode() int index = 14; fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData()); fprintf(out, "\n // content:\n"); - fprintf(out, " %4d, // revision\n", 4); + fprintf(out, " %4d, // revision\n", 5); fprintf(out, " %4d, // classname\n", strreg(cdef->qualified)); fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0); index += cdef->classInfoList.count() * 2; diff --git a/tests/auto/qobject/moc_oldnormalizeobject.cpp b/tests/auto/qobject/moc_oldnormalizeobject.cpp new file mode 100644 index 0000000..4f590ae --- /dev/null +++ b/tests/auto/qobject/moc_oldnormalizeobject.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'oldnormalizeobject.h' +** +** Created: Wed Nov 18 11:43:05 2009 +** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../../../../../master/tests/auto/qobject/oldnormalizeobject.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'oldnormalizeobject.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 62 +#error "This file was generated using the moc from 4.7.0. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +static const uint qt_meta_data_OldNormalizeObject[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 6, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 3, // signalCount + + // signals: signature, parameters, type, tag, flags + 24, 20, 19, 19, 0x05, + 57, 20, 19, 19, 0x05, + 100, 20, 19, 19, 0x05, + + // slots: signature, parameters, type, tag, flags + 149, 20, 19, 19, 0x0a, + 180, 20, 19, 19, 0x0a, + 221, 20, 19, 19, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_OldNormalizeObject[] = { + "OldNormalizeObject\0\0ref\0" + "typeRefSignal(Template&)\0" + "constTypeRefSignal(Template)\0" + "typeConstRefSignal(Templateconst&)\0" + "typeRefSlot(Template&)\0" + "constTypeRefSlot(Template)\0" + "typeConstRefSlot(Templateconst&)\0" +}; + +const QMetaObject OldNormalizeObject::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_OldNormalizeObject, + qt_meta_data_OldNormalizeObject, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &OldNormalizeObject::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *OldNormalizeObject::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *OldNormalizeObject::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_OldNormalizeObject)) + return static_cast(const_cast< OldNormalizeObject*>(this)); + return QObject::qt_metacast(_clname); +} + +int OldNormalizeObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: typeRefSignal((*reinterpret_cast< Template(*)>(_a[1]))); break; + case 1: constTypeRefSignal((*reinterpret_cast< const Template(*)>(_a[1]))); break; + case 2: typeConstRefSignal((*reinterpret_cast< Templateconst(*)>(_a[1]))); break; + case 3: typeRefSlot((*reinterpret_cast< Template(*)>(_a[1]))); break; + case 4: constTypeRefSlot((*reinterpret_cast< const Template(*)>(_a[1]))); break; + case 5: typeConstRefSlot((*reinterpret_cast< Templateconst(*)>(_a[1]))); break; + default: ; + } + _id -= 6; + } + return _id; +} + +// SIGNAL 0 +void OldNormalizeObject::typeRefSignal(Template & _t1) +{ + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 0, _a); +} + +// SIGNAL 1 +void OldNormalizeObject::constTypeRefSignal(const Template & _t1) +{ + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 1, _a); +} + +// SIGNAL 2 +void OldNormalizeObject::typeConstRefSignal(Template const & _t1) +{ + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 2, _a); +} +QT_END_MOC_NAMESPACE diff --git a/tests/auto/qobject/oldnormalizeobject.h b/tests/auto/qobject/oldnormalizeobject.h new file mode 100644 index 0000000..8420a3a --- /dev/null +++ b/tests/auto/qobject/oldnormalizeobject.h @@ -0,0 +1,28 @@ +#ifndef OLDNORMALIZEOBJECT_H +#define OLDNORMALIZEOBJECT_H + +#include + +struct Struct; +class Class; +template class Template; + +// An object with old moc output that incorrectly normalizes 'T const &' in the function +// signatures +class OldNormalizeObject : public QObject +{ + /* tmake ignore Q_OBJECT */ + Q_OBJECT + +signals: + void typeRefSignal(Template &ref); + void constTypeRefSignal(const Template &ref); + void typeConstRefSignal(Template const &ref); + +public slots: + void typeRefSlot(Template &) {} + void constTypeRefSlot(const Template &) {} + void typeConstRefSlot(Template const &) {} +}; + +#endif // OLDNORMALIZEOBJECT_H diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 5035139..b296e1b 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -2017,6 +2017,7 @@ enum Enum { }; struct Struct { }; class Class { }; +template class Template { }; class NormalizeObject : public QObject { @@ -2054,6 +2055,12 @@ signals: void unsignedshortSignal(unsigned short); void unsignedcharSignal(unsigned char); + void typeRefSignal(Template &ref); + void constTypeRefSignal(const Template &ref); + void typeConstRefSignal(Template const &ref); + + void typePointerConstRefSignal(Class * const &); + public slots: void uintPointerSlot(uint *) { } void ulongPointerSlot(ulong *) { } @@ -2085,8 +2092,15 @@ public slots: void unsignedshortSlot(unsigned short) {}; void unsignedcharSlot(unsigned char) {}; + void typeRefSlot(Template &) {} + void constTypeRefSlot(const Template &) {} + void typeConstRefSlot(Template const &) {} + + void typePointerConstRefSlot(Class * const &) {} }; +#include "oldnormalizeobject.h" + void tst_QObject::normalize() { NormalizeObject object; @@ -2326,7 +2340,165 @@ void tst_QObject::normalize() SIGNAL(unsignedcharSignal(unsigned char)), SLOT(unsignedcharSlot(unsigned char)))); + // connect when original template signature and mixed usage of 'T const &', + // 'const T &', and 'T' + + QVERIFY(object.connect(&object, + SIGNAL(typeRefSignal(Template &)), + SLOT(typeRefSlot(Template &)))); + + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(object.connect(&object, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + + // same test again, this time with an object compiled with old moc output... we know that + // it is not possible to connect everything, whic is the purpose for this test + OldNormalizeObject oldobject; + + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(constTypeRefSlot(Template const &)))); + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + + // these fail in older Qt versions, but pass now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(const Template &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(constTypeRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + + // these also fail in older Qt versions, but pass now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(const Template &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(constTypeRefSlot(Template const &)))); + + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(const Template &)))); + // this fails in older versions, but passes now due to proper normalizing + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(const Template &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + QVERIFY(oldobject.connect(&oldobject, + SIGNAL(typeConstRefSignal(Template const &)), + SLOT(typeConstRefSlot(Template const &)))); + + QVERIFY(object.connect(&object, + SIGNAL(typePointerConstRefSignal(Class*const&)), + SLOT(typePointerConstRefSlot(Class*const&)))); + QVERIFY(object.connect(&object, + SIGNAL(typePointerConstRefSignal(Class*const&)), + SLOT(typePointerConstRefSlot(Class*)))); + QVERIFY(object.connect(&object, + SIGNAL(typePointerConstRefSignal(Class*)), + SLOT(typePointerConstRefSlot(Class*const&)))); + QVERIFY(object.connect(&object, + SIGNAL(typePointerConstRefSignal(Class*)), + SLOT(typePointerConstRefSlot(Class*)))); } class SiblingDeleter : public QObject diff --git a/tests/auto/qobject/tst_qobject.pro b/tests/auto/qobject/tst_qobject.pro index 003ee98..0200f3e 100644 --- a/tests/auto/qobject/tst_qobject.pro +++ b/tests/auto/qobject/tst_qobject.pro @@ -1,16 +1,20 @@ load(qttest_p4) -SOURCES += tst_qobject.cpp +SOURCES += tst_qobject.cpp -QT = core network gui -contains(QT_CONFIG, qt3support):DEFINES+=QT_HAS_QT3SUPPORT +# this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by +# moc from Qt 4.6, and should *not* be generated by the current moc +SOURCES += moc_oldnormalizeobject.cpp -wince*: { - addFiles.sources = signalbug.exe - addFiles.path = . - DEPLOYMENT += addFiles +QT = core \ + network \ + gui +contains(QT_CONFIG, qt3support):DEFINES += QT_HAS_QT3SUPPORT +wince*: { + addFiles.sources = signalbug.exe + addFiles.path = . + DEPLOYMENT += addFiles } - -symbian: { +symbian: { addFiles.sources = signalbug.exe addFiles.path = \sys\bin DEPLOYMENT += addFiles -- cgit v0.12 From 1d037c582e2a832b55614641af912517d17e7604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 2 Dec 2009 14:02:33 +0100 Subject: Revert back to using the native graphics system on Mac. The issues with raster are currently to visible and is preventing us from doing other work on Qt. --- src/gui/kernel/qapplication.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 0853b32..c675c9e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -922,14 +922,6 @@ void QApplicationPrivate::initialize() // Set up which span functions should be used in raster engine... qInitDrawhelperAsm(); - -#ifdef QT_MAC_USE_COCOA - // Use the raster graphics system by default on Cocoa, override with - // -graphicssystem native - if (graphics_system_name.isEmpty()) { - graphics_system_name = QLatin1String("raster"); - } -#endif #if !defined(Q_WS_X11) && !defined(Q_WS_QWS) // initialize the graphics system - on X11 this is initialized inside -- cgit v0.12 From ae0c72025c78e4fa4f8aa793e3b83f245a7837a7 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 1 Dec 2009 15:58:58 +0100 Subject: Added QTriangulator. Task-number: QT-2594 --- src/gui/painting/qdatabuffer_p.h | 7 + src/opengl/gl2paintengineex/qtriangulator.cpp | 2981 +++++++++++++++++++++++++ src/opengl/gl2paintengineex/qtriangulator_p.h | 98 + src/opengl/opengl.pro | 6 +- 4 files changed, 3090 insertions(+), 2 deletions(-) create mode 100644 src/opengl/gl2paintengineex/qtriangulator.cpp create mode 100644 src/opengl/gl2paintengineex/qtriangulator_p.h diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index efe238e..41203ed 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -81,7 +81,9 @@ public: inline Type &at(int i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } inline const Type &at(int i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } + inline Type &last() { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } inline const Type &last() const { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } + inline Type &first() { Q_ASSERT(!isEmpty()); return buffer[0]; } inline const Type &first() const { Q_ASSERT(!isEmpty()); return buffer[0]; } inline void add(const Type &t) { @@ -90,6 +92,11 @@ public: ++siz; } + inline void pop_back() { + Q_ASSERT(siz > 0); + --siz; + } + inline void resize(int size) { reserve(size); siz = size; diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp new file mode 100644 index 0000000..21d4b2e --- /dev/null +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -0,0 +1,2981 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtriangulator_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +//#define Q_TRIANGULATOR_DEBUG + +#define Q_FIXED_POINT_SCALE 32 + +// Quick sort. +template +static void sort(T *array, int count, LessThan lessThan) +{ + // If the number of elements fall below some threshold, use insertion sort. + const int INSERTION_SORT_LIMIT = 7; // About 7 is fastest on my computer... + if (count <= INSERTION_SORT_LIMIT) { + for (int i = 1; i < count; ++i) { + T temp = array[i]; + int j = i; + while (j > 0 && lessThan(temp, array[j - 1])) { + array[j] = array[j - 1]; + --j; + } + array[j] = temp; + } + return; + } + + int high = count - 1; + int low = 0; + int mid = high / 2; + if (lessThan(array[mid], array[low])) + qSwap(array[mid], array[low]); + if (lessThan(array[high], array[mid])) + qSwap(array[high], array[mid]); + if (lessThan(array[mid], array[low])) + qSwap(array[mid], array[low]); + + --high; + ++low; + qSwap(array[mid], array[high]); + int pivot = high; + --high; + + while (low <= high) { + while (!lessThan(array[pivot], array[low])) { + ++low; + if (low > high) + goto sort_loop_end; + } + while (!lessThan(array[high], array[pivot])) { + --high; + if (low > high) + goto sort_loop_end; + } + qSwap(array[low], array[high]); + ++low; + --high; + } +sort_loop_end: + if (low != pivot) + qSwap(array[pivot], array[low]); + sort(array, low, lessThan); + sort(array + low + 1, count - low - 1, lessThan); +} + +// Quick sort. +template +static void sort(T *array, int count) +{ + // If the number of elements fall below some threshold, use insertion sort. + const int INSERTION_SORT_LIMIT = 25; // About 25 is fastest on my computer... + if (count <= INSERTION_SORT_LIMIT) { + for (int i = 1; i < count; ++i) { + T temp = array[i]; + int j = i; + while (j > 0 && (temp < array[j - 1])) { + array[j] = array[j - 1]; + --j; + } + array[j] = temp; + } + return; + } + + int high = count - 1; + int low = 0; + int mid = high / 2; + if ((array[mid] < array[low])) + qSwap(array[mid], array[low]); + if ((array[high] < array[mid])) + qSwap(array[high], array[mid]); + if ((array[mid] < array[low])) + qSwap(array[mid], array[low]); + + --high; + ++low; + qSwap(array[mid], array[high]); + int pivot = high; + --high; + + while (low <= high) { + while (!(array[pivot] < array[low])) { + ++low; + if (low > high) + goto sort_loop_end; + } + while (!(array[high] < array[pivot])) { + --high; + if (low > high) + goto sort_loop_end; + } + qSwap(array[low], array[high]); + ++low; + --high; + } +sort_loop_end: + if (low != pivot) + qSwap(array[pivot], array[low]); + sort(array, low); + sort(array + low + 1, count - low - 1); +} + +//============================================================================// +// QFraction // +//============================================================================// + +// Fraction must be in the range [0, 1) +struct QFraction +{ + // Comparison operators must not be called on invalid fractions. + inline bool operator < (const QFraction &other) const; + inline bool operator == (const QFraction &other) const; + inline bool operator != (const QFraction &other) const {return !(*this == other);} + inline bool operator > (const QFraction &other) const {return other < *this;} + inline bool operator >= (const QFraction &other) const {return !(*this < other);} + inline bool operator <= (const QFraction &other) const {return !(*this > other);} + + inline bool isValid() const {return denominator != 0;} + + // numerator and denominator must not have common denominators. + quint64 numerator, denominator; +}; + +static inline quint64 gcd(quint64 x, quint64 y) +{ + while (y != 0) { + quint64 z = y; + y = x % y; + x = z; + } + return x; +} + +static inline int compare(quint64 a, quint64 b) +{ + return (a > b) - (a < b); +} + +// Compare a/b with c/d. +// Return negative if less, 0 if equal, positive if greater. +// a < b, c < d +static int qCompareFractions(quint64 a, quint64 b, quint64 c, quint64 d) +{ + const quint64 LIMIT = Q_UINT64_C(0x100000000); + for (;;) { + // If the products 'ad' and 'bc' fit into 64 bits, they can be directly compared. + if (b < LIMIT && d < LIMIT) + return compare(a * d, b * c); + + if (a == 0 || c == 0) + return compare(a, c); + + // a/b < c/d <=> d/c < b/a + quint64 b_div_a = b / a; + quint64 d_div_c = d / c; + if (b_div_a != d_div_c) + return compare(d_div_c, b_div_a); + + // floor(d/c) == floor(b/a) + // frac(d/c) < frac(b/a) ? + // frac(x/y) = (x%y)/y + d -= d_div_c * c; //d %= c; + b -= b_div_a * a; //b %= a; + qSwap(a, d); + qSwap(b, c); + } +} + +// Fraction must be in the range [0, 1) +// Assume input is valid. +static QFraction qFraction(quint64 n, quint64 d) { + QFraction result; + if (n == 0) { + result.numerator = 0; + result.denominator = 1; + } else { + quint64 g = gcd(n, d); + result.numerator = n / g; + result.denominator = d / g; + } + return result; +} + +inline bool QFraction::operator < (const QFraction &other) const +{ + return qCompareFractions(numerator, denominator, other.numerator, other.denominator) < 0; +} + +inline bool QFraction::operator == (const QFraction &other) const +{ + return numerator == other.numerator && denominator == other.denominator; +} + +//============================================================================// +// QPodPoint // +//============================================================================// + +struct QPodPoint +{ + inline bool operator < (const QPodPoint &other) const + { + if (y != other.y) + return y < other.y; + return x < other.x; + } + + inline bool operator > (const QPodPoint &other) const {return other < *this;} + inline bool operator <= (const QPodPoint &other) const {return !(*this > other);} + inline bool operator >= (const QPodPoint &other) const {return !(*this < other);} + inline bool operator == (const QPodPoint &other) const {return x == other.x && y == other.y;} + inline bool operator != (const QPodPoint &other) const {return x != other.x || y != other.y;} + + inline QPodPoint &operator += (const QPodPoint &other) {x += other.x; y += other.y; return *this;} + inline QPodPoint &operator -= (const QPodPoint &other) {x -= other.x; y -= other.y; return *this;} + inline QPodPoint operator + (const QPodPoint &other) const {QPodPoint result = {x + other.x, y + other.y}; return result;} + inline QPodPoint operator - (const QPodPoint &other) const {QPodPoint result = {x - other.x, y - other.y}; return result;} + + int x; + int y; +}; + +static inline qint64 qCross(const QPodPoint &u, const QPodPoint &v) +{ + return qint64(u.x) * qint64(v.y) - qint64(u.y) * qint64(v.x); +} + +static inline qint64 qDot(const QPodPoint &u, const QPodPoint &v) +{ + return qint64(u.x) * qint64(v.x) + qint64(u.y) * qint64(v.y); +} + +// Return positive value if 'p' is to the right of the line 'v1'->'v2', negative if left of the +// line and zero if exactly on the line. +// The returned value is the z-component of the qCross product between 'v2-v1' and 'p-v1', +// which is twice the signed area of the triangle 'p'->'v1'->'v2' (positive for CW order). +static inline qint64 qPointDistanceFromLine(const QPodPoint &p, const QPodPoint &v1, const QPodPoint &v2) +{ + return qCross(v2 - v1, p - v1); +} + +static inline bool qPointIsLeftOfLine(const QPodPoint &p, const QPodPoint &v1, const QPodPoint &v2) +{ + return qPointDistanceFromLine(p, v1, v2) < 0; +} + +// Return: +// -1 if u < v +// 0 if u == v +// 1 if u > v +static int comparePoints(const QPodPoint &u, const QPodPoint &v) +{ + if (u.y < v.y) + return -1; + if (u.y > v.y) + return 1; + if (u.x < v.x) + return -1; + if (u.x > v.x) + return 1; + return 0; +} + +//============================================================================// +// QIntersectionPoint // +//============================================================================// + +struct QIntersectionPoint +{ + inline bool isValid() const {return xOffset.isValid() && yOffset.isValid();} + QPodPoint round() const; + inline bool isAccurate() const {return xOffset.numerator == 0 && yOffset.numerator == 0;} + bool operator < (const QIntersectionPoint &other) const; + bool operator == (const QIntersectionPoint &other) const; + inline bool operator != (const QIntersectionPoint &other) const {return !(*this == other);} + inline bool operator > (const QIntersectionPoint &other) const {return other < *this;} + inline bool operator >= (const QIntersectionPoint &other) const {return !(*this < other);} + inline bool operator <= (const QIntersectionPoint &other) const {return !(*this > other);} + bool isOnLine(const QPodPoint &u, const QPodPoint &v) const; + + QPodPoint upperLeft; + QFraction xOffset; + QFraction yOffset; +}; + +static inline QIntersectionPoint qIntersectionPoint(const QPodPoint &point) +{ + // m_upperLeft = point, m_xOffset = 0/1, m_yOffset = 0/1. + QIntersectionPoint p = {point, {0, 1}, {0, 1}}; + return p; +} + +static inline QIntersectionPoint qIntersectionPoint(int x, int y) +{ + // m_upperLeft = (x, y), m_xOffset = 0/1, m_yOffset = 0/1. + QIntersectionPoint p = {{x, y}, {0, 1}, {0, 1}}; + return p; +} + +static QIntersectionPoint qIntersectionPoint(const QPodPoint &u1, const QPodPoint &u2, const QPodPoint &v1, const QPodPoint &v2) +{ + QIntersectionPoint result = {{0, 0}, {0, 0}, {0, 0}}; + + QPodPoint u = u2 - u1; + QPodPoint v = v2 - v1; + qint64 d1 = qCross(u, v1 - u1); + qint64 d2 = qCross(u, v2 - u1); + qint64 det = d2 - d1; + qint64 d3 = qCross(v, u1 - v1); + qint64 d4 = d3 - det; //qCross(v, u2 - v1); + + // Check that the math is correct. + Q_ASSERT(d4 == qCross(v, u2 - v1)); + + // The intersection point can be expressed as: + // v1 - v * d1/det + // v2 - v * d2/det + // u1 + u * d3/det + // u2 + u * d4/det + + // I'm only interested in lines that are crossing, so ignore parallel lines even if they overlap. + if (det == 0) + return result; + + if (det < 0) { + det = -det; + d1 = -d1; + d2 = -d2; + d3 = -d3; + d4 = -d4; + } + + // I'm only interested in lines intersecting at their interior, not at their end points. + // The lines intersect at their interior if and only if 'd1 < 0', 'd2 > 0', 'd3 < 0' and 'd4 > 0'. + if (d1 >= 0 || d2 <= 0 || d3 <= 0 || d4 >= 0) + return result; + + // Calculate the intersection point as follows: + // v1 - v * d1/det | v1 <= v2 (component-wise) + // v2 - v * d2/det | v2 < v1 (component-wise) + + // Assuming 21 bits per vector component. + // TODO: Make code path for 31 bits per vector component. + if (v.x >= 0) { + result.upperLeft.x = v1.x + (-v.x * d1) / det; + result.xOffset = qFraction(quint64(-v.x * d1) % quint64(det), quint64(det)); + } else { + result.upperLeft.x = v2.x + (-v.x * d2) / det; + result.xOffset = qFraction(quint64(-v.x * d2) % quint64(det), quint64(det)); + } + + if (v.y >= 0) { + result.upperLeft.y = v1.y + (-v.y * d1) / det; + result.yOffset = qFraction(quint64(-v.y * d1) % quint64(det), quint64(det)); + } else { + result.upperLeft.y = v2.y + (-v.y * d2) / det; + result.yOffset = qFraction(quint64(-v.y * d2) % quint64(det), quint64(det)); + } + + Q_ASSERT(result.xOffset.isValid()); + Q_ASSERT(result.yOffset.isValid()); + return result; +} + +QPodPoint QIntersectionPoint::round() const +{ + QPodPoint result = upperLeft; + if (2 * xOffset.numerator >= xOffset.denominator) + ++result.x; + if (2 * yOffset.numerator >= yOffset.denominator) + ++result.y; + return result; +} + +bool QIntersectionPoint::operator < (const QIntersectionPoint &other) const +{ + if (upperLeft.y != other.upperLeft.y) + return upperLeft.y < other.upperLeft.y; + if (yOffset != other.yOffset) + return yOffset < other.yOffset; + if (upperLeft.x != other.upperLeft.x) + return upperLeft.x < other.upperLeft.x; + return xOffset < other.xOffset; +} + +bool QIntersectionPoint::operator == (const QIntersectionPoint &other) const +{ + return upperLeft == other.upperLeft && xOffset == other.xOffset && yOffset == other.yOffset; +} + +// Returns true if this point is on the infinite line passing through 'u' and 'v'. +bool QIntersectionPoint::isOnLine(const QPodPoint &u, const QPodPoint &v) const +{ + // TODO: Make code path for coordinates with more than 21 bits. + const QPodPoint p = upperLeft - u; + const QPodPoint q = v - u; + bool isHorizontal = p.y == 0 && yOffset.numerator == 0; + bool isVertical = p.x == 0 && xOffset.numerator == 0; + if (isHorizontal && isVertical) + return true; + if (isHorizontal) + return q.y == 0; + if (q.y == 0) + return false; + if (isVertical) + return q.x == 0; + if (q.x == 0) + return false; + + // At this point, 'p+offset' and 'q' cannot lie on the x or y axis. + + if (((q.x < 0) == (q.y < 0)) != ((p.x < 0) == (p.y < 0))) + return false; // 'p + offset' and 'q' pass through different quadrants. + + // Move all coordinates into the first quadrant. + quint64 nx, ny; + if (p.x < 0) + nx = quint64(-p.x) * xOffset.denominator - xOffset.numerator; + else + nx = quint64(p.x) * xOffset.denominator + xOffset.numerator; + if (p.y < 0) + ny = quint64(-p.y) * yOffset.denominator - yOffset.numerator; + else + ny = quint64(p.y) * yOffset.denominator + yOffset.numerator; + + return qFraction(quint64(qAbs(q.x)) * xOffset.denominator, quint64(qAbs(q.y)) * yOffset.denominator) == qFraction(nx, ny); +} + +//============================================================================// +// QMaxHeap // +//============================================================================// + +template +class QMaxHeap +{ +public: + inline int size() const {return m_data.size();} + inline bool empty() const {return m_data.isEmpty();} + inline bool isEmpty() const {return m_data.isEmpty();} + void push(const T &x); + T pop(); + inline const T &top() const {return m_data.first();} +private: + static inline int parent(int i) {return (i - 1) / 2;} + static inline int left(int i) {return 2 * i + 1;} + static inline int right(int i) {return 2 * i + 2;} + + QDataBuffer m_data; +}; + +template +void QMaxHeap::push(const T &x) +{ + int current = m_data.size(); + int parent = QMaxHeap::parent(current); + m_data.add(x); + while (current != 0 && m_data.at(parent) < x) { + m_data.at(current) = m_data.at(parent); + current = parent; + parent = QMaxHeap::parent(current); + } + m_data.at(current) = x; +} + +template +T QMaxHeap::pop() +{ + T result = m_data.first(); + T back = m_data.last(); + m_data.pop_back(); + if (!m_data.isEmpty()) { + int current = 0; + for (;;) { + int left = QMaxHeap::left(current); + int right = QMaxHeap::right(current); + if (left >= m_data.size()) + break; + int greater = left; + if (right < m_data.size() && m_data.at(left) < m_data.at(right)) + greater = right; + if (m_data.at(greater) < back) + break; + m_data.at(current) = m_data.at(greater); + current = greater; + } + m_data.at(current) = back; + } + return result; +} + +//============================================================================// +// QRBTree // +//============================================================================// + +template +struct QRBTree +{ + struct Node + { + inline Node() : parent(0), left(0), right(0), red(true) { } + inline ~Node() {if (left) delete left; if (right) delete right;} + T data; + Node *parent; + Node *left; + Node *right; + bool red; + }; + + inline QRBTree() : root(0), freeList(0) { } + inline ~QRBTree(); + + inline void clear(); + + void attachBefore(Node *parent, Node *child); + void attachAfter(Node *parent, Node *child); + + inline Node *front(Node *node) const; + inline Node *back(Node *node) const; + Node *next(Node *node) const; + Node *previous(Node *node) const; + + inline void deleteNode(Node *&node); + inline Node *newNode(); + + // Return 1 if 'left' comes after 'right', 0 if equal, and -1 otherwise. + // 'left' and 'right' cannot be null. + int order(Node *left, Node *right); + inline bool verify() const; + +private: + void rotateLeft(Node *node); + void rotateRight(Node *node); + void update(Node *node); + + inline void attachLeft(Node *parent, Node *child); + inline void attachRight(Node *parent, Node *child); + + int blackDepth(Node *top) const; + bool checkRedBlackProperty(Node *top) const; + + void swapNodes(Node *n1, Node *n2); + void detach(Node *node); + + // 'node' must be black. rebalance will reduce the depth of black nodes by one in the sibling tree. + void rebalance(Node *node); + +public: + Node *root; +private: + Node *freeList; +}; + +template +inline QRBTree::~QRBTree() +{ + clear(); + while (freeList) { + // Avoid recursively calling the destructor, as this list may become large. + Node *next = freeList->right; + freeList->right = 0; + delete freeList; + freeList = next; + } +} + +template +inline void QRBTree::clear() +{ + if (root) + delete root; + root = 0; +} + +template +void QRBTree::rotateLeft(Node *node) +{ + // | | + // N B + // / \ / \ + // A B ---> N D + // / \ / \ + // C D A C + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = node->right; + node->right->parent = node->parent; + + // : + // N + // / :| + // A B + // / \ + // C D + + node->right = ref->left; + if (ref->left) + ref->left->parent = node; + + // : | + // N B + // / \ : \ + // A C D + + ref->left = node; + node->parent = ref; + + // | + // B + // / \ + // N D + // / \ + // A C +} + +template +void QRBTree::rotateRight(Node *node) +{ + // | | + // N A + // / \ / \ + // A B ---> C N + // / \ / \ + // C D D B + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = node->left; + node->left->parent = node->parent; + + node->left = ref->right; + if (ref->right) + ref->right->parent = node; + + ref->right = node; + node->parent = ref; +} + +template +void QRBTree::update(Node *node) // call this after inserting a node +{ + for (;;) { + Node *parent = node->parent; + + // if the node is the root, color it black + if (!parent) { + node->red = false; + return; + } + + // if the parent is black, the node can be left red + if (!parent->red) + return; + + // at this point, the parent is red and cannot be the root + Node *grandpa = parent->parent; + Q_ASSERT(grandpa); + + Node *uncle = (parent == grandpa->left ? grandpa->right : grandpa->left); + if (uncle && uncle->red) { + // grandpa's black, parent and uncle are red. + // let parent and uncle be black, grandpa red and recursively update grandpa. + Q_ASSERT(!grandpa->red); + parent->red = false; + uncle->red = false; + grandpa->red = true; + node = grandpa; + continue; + } + + // at this point, uncle is black + if (node == parent->right && parent == grandpa->left) + rotateLeft(node = parent); + else if (node == parent->left && parent == grandpa->right) + rotateRight(node = parent); + parent = node->parent; + + if (parent == grandpa->left) { + rotateRight(grandpa); + parent->red = false; + grandpa->red = true; + } else { + rotateLeft(grandpa); + parent->red = false; + grandpa->red = true; + } + return; + } +} + +template +inline void QRBTree::attachLeft(Node *parent, Node *child) +{ + Q_ASSERT(!parent->left); + parent->left = child; + child->parent = parent; + update(child); +} + +template +inline void QRBTree::attachRight(Node *parent, Node *child) +{ + Q_ASSERT(!parent->right); + parent->right = child; + child->parent = parent; + update(child); +} + +template +void QRBTree::attachBefore(Node *parent, Node *child) +{ + if (!root) + update(root = child); + else if (!parent) + attachRight(back(root), child); + else if (parent->left) + attachRight(back(parent->left), child); + else + attachLeft(parent, child); +} + +template +void QRBTree::attachAfter(Node *parent, Node *child) +{ + if (!root) + update(root = child); + else if (!parent) + attachLeft(front(root), child); + else if (parent->right) + attachLeft(front(parent->right), child); + else + attachRight(parent, child); +} + +template +void QRBTree::swapNodes(Node *n1, Node *n2) +{ + // Since iterators must not be invalidated, it is not sufficient to only swap the data. + if (n1->parent == n2) { + n1->parent = n2->parent; + n2->parent = n1; + } else if (n2->parent == n1) { + n2->parent = n1->parent; + n1->parent = n2; + } else { + qSwap(n1->parent, n2->parent); + } + + qSwap(n1->left, n2->left); + qSwap(n1->right, n2->right); + qSwap(n1->red, n2->red); + + if (n1->parent) { + if (n1->parent->left == n2) + n1->parent->left = n1; + else + n1->parent->right = n1; + } else { + root = n1; + } + + if (n2->parent) { + if (n2->parent->left == n1) + n2->parent->left = n2; + else + n2->parent->right = n2; + } else { + root = n2; + } + + if (n1->left) + n1->left->parent = n1; + if (n1->right) + n1->right->parent = n1; + + if (n2->left) + n2->left->parent = n2; + if (n2->right) + n2->right->parent = n2; +} + +template +void QRBTree::detach(Node *node) // call this before removing a node. +{ + if (node->right) + swapNodes(node, front(node->right)); + + Node *child = (node->left ? node->left : node->right); + + if (!node->red) { + if (child && child->red) + child->red = false; + else + rebalance(node); + } + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = child; + if (child) + child->parent = node->parent; + node->left = node->right = node->parent = 0; +} + +// 'node' must be black. rebalance will reduce the depth of black nodes by one in the sibling tree. +template +void QRBTree::rebalance(Node *node) +{ + Q_ASSERT(!node->red); + for (;;) { + if (!node->parent) + return; + + // at this point, node is not a parent, it is black, thus it must have a sibling. + Node *sibling = (node == node->parent->left ? node->parent->right : node->parent->left); + Q_ASSERT(sibling); + + if (sibling->red) { + sibling->red = false; + node->parent->red = true; + if (node == node->parent->left) + rotateLeft(node->parent); + else + rotateRight(node->parent); + sibling = (node == node->parent->left ? node->parent->right : node->parent->left); + Q_ASSERT(sibling); + } + + // at this point, the sibling is black. + Q_ASSERT(!sibling->red); + + if ((!sibling->left || !sibling->left->red) && (!sibling->right || !sibling->right->red)) { + bool parentWasRed = node->parent->red; + sibling->red = true; + node->parent->red = false; + if (parentWasRed) + return; + node = node->parent; + continue; + } + + // at this point, at least one of the sibling's children is red. + + if (node == node->parent->left) { + if (!sibling->right || !sibling->right->red) { + Q_ASSERT(sibling->left); + sibling->red = true; + sibling->left->red = false; + rotateRight(sibling); + + sibling = sibling->parent; + Q_ASSERT(sibling); + } + sibling->red = node->parent->red; + node->parent->red = false; + + Q_ASSERT(sibling->right->red); + sibling->right->red = false; + rotateLeft(node->parent); + } else { + if (!sibling->left || !sibling->left->red) { + Q_ASSERT(sibling->right); + sibling->red = true; + sibling->right->red = false; + rotateLeft(sibling); + + sibling = sibling->parent; + Q_ASSERT(sibling); + } + sibling->red = node->parent->red; + node->parent->red = false; + + Q_ASSERT(sibling->left->red); + sibling->left->red = false; + rotateRight(node->parent); + } + return; + } +} + +template +inline typename QRBTree::Node *QRBTree::front(Node *node) const +{ + while (node->left) + node = node->left; + return node; +} + +template +inline typename QRBTree::Node *QRBTree::back(Node *node) const +{ + while (node->right) + node = node->right; + return node; +} + +template +typename QRBTree::Node *QRBTree::next(Node *node) const +{ + if (node->right) + return front(node->right); + while (node->parent && node == node->parent->right) + node = node->parent; + return node->parent; +} + +template +typename QRBTree::Node *QRBTree::previous(Node *node) const +{ + if (node->left) + return back(node->left); + while (node->parent && node == node->parent->left) + node = node->parent; + return node->parent; +} + +template +int QRBTree::blackDepth(Node *top) const +{ + if (!top) + return 0; + int leftDepth = blackDepth(top->left); + int rightDepth = blackDepth(top->right); + if (leftDepth != rightDepth) + return -1; + if (!top->red) + ++leftDepth; + return leftDepth; +} + +template +bool QRBTree::checkRedBlackProperty(Node *top) const +{ + if (!top) + return true; + if (top->left && !checkRedBlackProperty(top->left)) + return false; + if (top->right && !checkRedBlackProperty(top->right)) + return false; + return !(top->red && ((top->left && top->left->red) || (top->right && top->right->red))); +} + +template +inline bool QRBTree::verify() const +{ + return checkRedBlackProperty(root) && blackDepth(root) != -1; +} + +template +inline void QRBTree::deleteNode(Node *&node) +{ + Q_ASSERT(node); + detach(node); + node->right = freeList; + freeList = node; + node = 0; +} + +template +inline typename QRBTree::Node *QRBTree::newNode() +{ + if (freeList) { + Node *node = freeList; + freeList = freeList->right; + node->parent = node->left = node->right = 0; + node->red = true; + return node; + } + return new Node; +} + +// Return 1 if 'left' comes after 'right', 0 if equal, and -1 otherwise. +// 'left' and 'right' cannot be null. +template +int QRBTree::order(Node *left, Node *right) +{ + Q_ASSERT(left && right); + if (left == right) + return 0; + + QVector leftAncestors; + QVector rightAncestors; + while (left) { + leftAncestors.push_back(left); + left = left->parent; + } + while (right) { + rightAncestors.push_back(right); + right = right->parent; + } + Q_ASSERT(leftAncestors.back() == root && rightAncestors.back() == root); + + while (!leftAncestors.empty() && !rightAncestors.empty() && leftAncestors.back() == rightAncestors.back()) { + leftAncestors.pop_back(); + rightAncestors.pop_back(); + } + + if (!leftAncestors.empty()) + return (leftAncestors.back() == leftAncestors.back()->parent->left ? -1 : 1); + + if (!rightAncestors.empty()) + return (rightAncestors.back() == rightAncestors.back()->parent->right ? -1 : 1); + + // The code should never reach this point. + Q_ASSERT(!leftAncestors.empty() || !rightAncestors.empty()); + return 0; +} + +//============================================================================// +// QInt64Hash // +//============================================================================// + +// Copied from qhash.cpp +static const uchar prime_deltas[] = { + 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, + 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 +}; + +// Copied from qhash.cpp +static inline int primeForNumBits(int numBits) +{ + return (1 << numBits) + prime_deltas[numBits]; +} + +static inline int primeForCount(int count) +{ + int low = 0; + int high = 32; + for (int i = 0; i < 5; ++i) { + int mid = (high + low) / 2; + if (count >= 1 << mid) + low = mid; + else + high = mid; + } + return primeForNumBits(high); +} + +// Hash set of quint64s. Elements cannot be removed without clearing the +// entire set. A value of -1 is used to mark unused entries. +class QInt64Set +{ +public: + inline QInt64Set(int capacity = 64); + inline ~QInt64Set() {if (m_array) delete[] m_array;} + inline bool isValid() const {return m_array;} + void insert(quint64 key); + bool contains(quint64 key) const; + inline void clear(); +private: + bool rehash(int capacity); + + static const quint64 UNUSED; + + quint64 *m_array; + int m_capacity; + int m_count; +}; + +const quint64 QInt64Set::UNUSED = quint64(-1); + +inline QInt64Set::QInt64Set(int capacity) +{ + m_capacity = primeForCount(capacity); + m_array = new quint64[m_capacity]; + if (m_array) + clear(); + else + m_capacity = 0; +} + +bool QInt64Set::rehash(int capacity) +{ + quint64 *oldArray = m_array; + int oldCapacity = m_capacity; + + m_capacity = capacity; + m_array = new quint64[m_capacity]; + if (m_array) { + clear(); + if (oldArray) { + for (int i = 0; i < oldCapacity; ++i) { + if (oldArray[i] != UNUSED) + insert(oldArray[i]); + } + delete[] oldArray; + } + return true; + } else { + m_capacity = oldCapacity; + m_array = oldArray; + return false; + } +} + +void QInt64Set::insert(quint64 key) +{ + if (m_count > 3 * m_capacity / 4) + rehash(primeForCount(2 * m_capacity)); + Q_ASSERT_X(m_array, "QInt64Hash::insert", "Hash set not allocated."); + int index = int(key % m_capacity); + for (int i = 0; i < m_capacity; ++i) { + index += i; + if (index >= m_capacity) + index -= m_capacity; + if (m_array[index] == key) + return; + if (m_array[index] == UNUSED) { + ++m_count; + m_array[index] = key; + return; + } + } + Q_ASSERT_X(0, "QInt64Hash::insert", "Hash set full."); +} + +bool QInt64Set::contains(quint64 key) const +{ + Q_ASSERT_X(m_array, "QInt64Hash::contains", "Hash set not allocated."); + int index = int(key % m_capacity); + for (int i = 0; i < m_capacity; ++i) { + index += i; + if (index >= m_capacity) + index -= m_capacity; + if (m_array[index] == key) + return true; + if (m_array[index] == UNUSED) + return false; + } + return false; +} + +inline void QInt64Set::clear() +{ + Q_ASSERT_X(m_array, "QInt64Hash::clear", "Hash set not allocated."); + for (int i = 0; i < m_capacity; ++i) + m_array[i] = UNUSED; + m_count = 0; +} + +//============================================================================// +// QRingBuffer // +//============================================================================// + +// T must be POD. +template +class QRingBuffer +{ +public: + inline QRingBuffer() : m_array(0), m_head(0), m_size(0), m_capacity(0) { } + inline ~QRingBuffer() {if (m_array) delete[] m_array;} + bool reallocate(int capacity); + inline const T &head() const {Q_ASSERT(m_size > 0); return m_array[m_head];} + inline const T &dequeue(); + inline void enqueue(const T &x); + inline bool isEmpty() const {return m_size == 0;} +private: + T *m_array; + int m_head; + int m_size; + int m_capacity; +}; + +template +bool QRingBuffer::reallocate(int capacity) +{ + T *oldArray = m_array; + m_array = new T[capacity]; + if (m_array) { + if (oldArray) { + if (m_head + m_size > m_capacity) { + memcpy(m_array, oldArray + m_head, (m_capacity - m_head) * sizeof(T)); + memcpy(m_array + (m_capacity - m_head), oldArray, (m_head + m_size - m_capacity) * sizeof(T)); + } else { + memcpy(m_array, oldArray + m_head, m_size * sizeof(T)); + } + delete[] oldArray; + } + m_capacity = capacity; + m_head = 0; + return true; + } else { + m_array = oldArray; + return false; + } +} + +template +inline const T &QRingBuffer::dequeue() +{ + Q_ASSERT(m_size > 0); + Q_ASSERT(m_array); + Q_ASSERT(m_capacity >= m_size); + int index = m_head; + if (++m_head >= m_capacity) + m_head -= m_capacity; + --m_size; + return m_array[index]; +} + +template +inline void QRingBuffer::enqueue(const T &x) +{ + if (m_size == m_capacity) + reallocate(qMax(2 * m_capacity, 64)); + int index = m_head + m_size; + if (index >= m_capacity) + index -= m_capacity; + m_array[index] = x; + ++m_size; +} + +//============================================================================// +// QTriangulator // +//============================================================================// + +class QTriangulator +{ +public: + typedef QVarLengthArray ShortArray; + + //================================// + // QTriangulator::ComplexToSimple // + //================================// + friend class ComplexToSimple; + class ComplexToSimple + { + public: + inline ComplexToSimple(QTriangulator *parent) : m_parent(parent) { } + void decompose(); + private: + struct Edge + { + inline int &upper() {return pointingUp ? to : from;} + inline int &lower() {return pointingUp ? from : to;} + inline int upper() const {return pointingUp ? to : from;} + inline int lower() const {return pointingUp ? from : to;} + + QRBTree::Node *node; + int from, to; // vertex + int next, previous; // edge + int winding; + bool mayIntersect; + bool pointingUp, originallyPointingUp; + }; + + friend class CompareEdges; + class CompareEdges + { + public: + inline CompareEdges(ComplexToSimple *parent) : m_parent(parent) { } + bool operator () (int i, int j) const; + private: + ComplexToSimple *m_parent; + }; + + struct Intersection + { + bool operator < (const Intersection &other) const {return other.intersectionPoint < intersectionPoint;} + + QIntersectionPoint intersectionPoint; + int vertex; + int leftEdge; + int rightEdge; + }; + + struct Split + { + int vertex; + int edge; + bool accurate; + }; + + struct Event + { + enum Type {Upper, Lower}; + inline bool operator < (const Event &other) const; + + QPodPoint point; + Type type; + int edge; + }; + +#ifdef Q_TRIANGULATOR_DEBUG + friend class DebugDialog; + friend class QTriangulator; + class DebugDialog : public QDialog + { + public: + DebugDialog(ComplexToSimple *parent, int currentVertex); + protected: + void paintEvent(QPaintEvent *); + void wheelEvent(QWheelEvent *); + void mouseMoveEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *); + private: + ComplexToSimple *m_parent; + QRectF m_window; + QPoint m_lastMousePos; + int m_vertex; + }; +#endif + + void initEdges(); + bool calculateIntersection(int left, int right); + bool edgeIsLeftOfEdge(int leftEdgeIndex, int rightEdgeIndex) const; + QRBTree::Node *searchEdgeLeftOf(int edgeIndex) const; + QRBTree::Node *searchEdgeLeftOf(int edgeIndex, QRBTree::Node *after) const; + QPair::Node *, QRBTree::Node *> bounds(const QPodPoint &point) const; + QPair::Node *, QRBTree::Node *> outerBounds(const QPodPoint &point) const; + void splitEdgeListRange(QRBTree::Node *leftmost, QRBTree::Node *rightmost, int vertex, const QIntersectionPoint &intersectionPoint); + void reorderEdgeListRange(QRBTree::Node *leftmost, QRBTree::Node *rightmost); + void sortEdgeList(const QPodPoint eventPoint); + void fillPriorityQueue(); + void calculateIntersections(); + int splitEdge(int splitIndex); + bool splitEdgesAtIntersections(); + void insertEdgeIntoVectorIfWanted(ShortArray &orderedEdges, int i); + void removeUnwantedEdgesAndConnect(); + void removeUnusedPoints(); + + QTriangulator *m_parent; + QDataBuffer m_edges; + QRBTree m_edgeList; + QDataBuffer m_events; + QDataBuffer m_splits; + QMaxHeap m_topIntersection; + QInt64Set m_processedEdgePairs; + int m_initialPointCount; + }; +#ifdef Q_TRIANGULATOR_DEBUG + friend class ComplexToSimple::DebugDialog; +#endif + + //=================================// + // QTriangulator::SimpleToMonotone // + //=================================// + friend class SimpleToMonotone; + class SimpleToMonotone + { + public: + inline SimpleToMonotone(QTriangulator *parent) : m_parent(parent) { } + void decompose(); + private: + enum VertexType {MergeVertex, EndVertex, RegularVertex, StartVertex, SplitVertex}; + + struct Edge + { + QRBTree::Node *node; + int helper, twin, next, previous; + quint32 from, to; + VertexType type; + bool pointingUp; + int upper() const {return (pointingUp ? to : from);} + int lower() const {return (pointingUp ? from : to);} + }; + + friend class CompareVertices; + class CompareVertices + { + public: + CompareVertices(SimpleToMonotone *parent) : m_parent(parent) { } + bool operator () (int i, int j) const; + private: + SimpleToMonotone *m_parent; + }; + + void setupDataStructures(); + void removeZeroLengthEdges(); + void fillPriorityQueue(); + bool edgeIsLeftOfEdge(int leftEdgeIndex, int rightEdgeIndex) const; + // Returns the rightmost edge not to the right of the given edge. + QRBTree::Node *searchEdgeLeftOfEdge(int edgeIndex) const; + // Returns the rightmost edge left of the given point. + QRBTree::Node *searchEdgeLeftOfPoint(int pointIndex) const; + void classifyVertex(int i); + void classifyVertices(); + bool pointIsInSector(const QPodPoint &p, const QPodPoint &v1, const QPodPoint &v2, const QPodPoint &v3); + bool pointIsInSector(int vertex, int sector); + int findSector(int edge, int vertex); + void createDiagonal(int lower, int upper); + void monotoneDecomposition(); + + QTriangulator *m_parent; + QRBTree m_edgeList; + QDataBuffer m_edges; + QDataBuffer m_upperVertex; + bool m_clockwiseOrder; + }; + + //====================================// + // QTriangulator::MonotoneToTriangles // + //====================================// + friend class MonotoneToTriangles; + class MonotoneToTriangles + { + public: + inline MonotoneToTriangles(QTriangulator *parent) : m_parent(parent) { } + void decompose(); + private: + inline quint32 indices(int index) const {return m_parent->m_indices.at(index + m_first);} + inline int next(int index) const {return (index + 1) % m_length;} + inline int previous(int index) const {return (index + m_length - 1) % m_length;} + inline bool less(int i, int j) const {return m_parent->m_vertices.at(indices(i)) < m_parent->m_vertices.at(indices(j));} + inline bool leftOfEdge(int i, int j, int k) const + { + return qPointIsLeftOfLine(m_parent->m_vertices.at(indices(i)), + m_parent->m_vertices.at(indices(j)), m_parent->m_vertices.at(indices(k))); + } + + QTriangulator *m_parent; + int m_first; + int m_length; + }; + + inline QTriangulator() { } + + // Call this only once. + void initialize(const qreal *polygon, int count, uint hint, const QTransform &matrix); + // Call this only once. + void initialize(const QVectorPath &path, const QTransform &matrix, qreal lod); + // Call this only once. + void initialize(const QPainterPath &path, const QTransform &matrix, qreal lod); + // Call either triangulate() or polyline() only once. + QTriangleSet triangulate(); + QPolylineSet polyline(); +private: + QDataBuffer m_vertices; + QVector m_indices; + uint m_hint; +}; + +//============================================================================// +// QTriangulator // +//============================================================================// + +QTriangleSet QTriangulator::triangulate() +{ + for (int i = 0; i < m_vertices.size(); ++i) { + Q_ASSERT(qAbs(m_vertices.at(i).x) < (1 << 21)); + Q_ASSERT(qAbs(m_vertices.at(i).y) < (1 << 21)); + } + + if (!(m_hint & (QVectorPath::OddEvenFill | QVectorPath::WindingFill))) + m_hint |= QVectorPath::OddEvenFill; + + if (m_hint & QVectorPath::NonConvexShapeMask) { + ComplexToSimple c2s(this); + c2s.decompose(); + SimpleToMonotone s2m(this); + s2m.decompose(); + } + MonotoneToTriangles m2t(this); + m2t.decompose(); + + QTriangleSet result; + result.indices = m_indices; + result.vertices.resize(2 * m_vertices.size()); + for (int i = 0; i < m_vertices.size(); ++i) { + result.vertices[2 * i + 0] = qreal(m_vertices.at(i).x) / Q_FIXED_POINT_SCALE; + result.vertices[2 * i + 1] = qreal(m_vertices.at(i).y) / Q_FIXED_POINT_SCALE; + } + return result; +} + +QPolylineSet QTriangulator::polyline() +{ + QPolylineSet result; + result.indices = m_indices; + result.vertices.resize(2 * m_vertices.size()); + for (int i = 0; i < m_vertices.size(); ++i) { + result.vertices[2 * i + 0] = qreal(m_vertices.at(i).x) / Q_FIXED_POINT_SCALE; + result.vertices[2 * i + 1] = qreal(m_vertices.at(i).y) / Q_FIXED_POINT_SCALE; + } + return result; +} + +void QTriangulator::initialize(const qreal *polygon, int count, uint hint, const QTransform &matrix) +{ + m_hint = hint; + m_vertices.resize(count); + m_indices.resize(count + 1); + for (int i = 0; i < count; ++i) { + qreal x, y; + matrix.map(polygon[2 * i + 0], polygon[2 * i + 1], &x, &y); + m_vertices.at(i).x = qRound(x * Q_FIXED_POINT_SCALE); + m_vertices.at(i).y = qRound(y * Q_FIXED_POINT_SCALE); + m_indices[i] = i; + } + m_indices[count] = Q_TRIANGULATE_END_OF_POLYGON; +} + +void QTriangulator::initialize(const QVectorPath &path, const QTransform &matrix, qreal lod) +{ + m_hint = path.hints(); + // Curved paths will be converted to complex polygons. + m_hint &= ~QVectorPath::CurvedShapeMask; + + const qreal *p = path.points(); + const QPainterPath::ElementType *e = path.elements(); + if (e) { + for (int i = 0; i < path.elementCount(); ++i, ++e, p += 2) { + switch (*e) { + case QPainterPath::MoveToElement: + if (!m_indices.isEmpty()) + m_indices.push_back(Q_TRIANGULATE_END_OF_POLYGON); + // Fall through. + case QPainterPath::LineToElement: + m_indices.push_back(quint32(m_vertices.size())); + m_vertices.resize(m_vertices.size() + 1); + qreal x, y; + matrix.map(p[0], p[1], &x, &y); + m_vertices.last().x = qRound(x * Q_FIXED_POINT_SCALE); + m_vertices.last().y = qRound(y * Q_FIXED_POINT_SCALE); + break; + case QPainterPath::CurveToElement: + { + qreal pts[8]; + for (int i = 0; i < 4; ++i) + matrix.map(p[2 * i - 2], p[2 * i - 1], &pts[2 * i + 0], &pts[2 * i + 1]); + for (int i = 0; i < 8; ++i) + pts[i] *= lod; + QBezier bezier = QBezier::fromPoints(QPointF(pts[0], pts[1]), QPointF(pts[2], pts[3]), QPointF(pts[4], pts[5]), QPointF(pts[6], pts[7])); + QPolygonF poly = bezier.toPolygon(); + // Skip first point, it already exists in 'm_vertices'. + for (int j = 1; j < poly.size(); ++j) { + m_indices.push_back(quint32(m_vertices.size())); + m_vertices.resize(m_vertices.size() + 1); + m_vertices.last().x = qRound(poly.at(j).x() * Q_FIXED_POINT_SCALE / lod); + m_vertices.last().y = qRound(poly.at(j).y() * Q_FIXED_POINT_SCALE / lod); + } + } + i += 2; + e += 2; + p += 4; + break; + default: + Q_ASSERT_X(0, "QTriangulator::triangulate", "Unexpected element type."); + break; + } + } + } else { + for (int i = 0; i < path.elementCount(); ++i, p += 2) { + m_indices.push_back(quint32(m_vertices.size())); + m_vertices.resize(m_vertices.size() + 1); + qreal x, y; + matrix.map(p[0], p[1], &x, &y); + m_vertices.last().x = qRound(x * Q_FIXED_POINT_SCALE); + m_vertices.last().y = qRound(y * Q_FIXED_POINT_SCALE); + } + } + m_indices.push_back(Q_TRIANGULATE_END_OF_POLYGON); +} + +void QTriangulator::initialize(const QPainterPath &path, const QTransform &matrix, qreal lod) +{ + initialize(qtVectorPathForPath(path), matrix, lod); +} + +//============================================================================// +// QTriangulator::ComplexToSimple // +//============================================================================// + +void QTriangulator::ComplexToSimple::decompose() +{ + m_initialPointCount = m_parent->m_vertices.size(); + initEdges(); + do { + calculateIntersections(); + } while (splitEdgesAtIntersections()); + + removeUnwantedEdgesAndConnect(); + removeUnusedPoints(); + + m_parent->m_indices.clear(); + QBitArray processed(m_edges.size(), false); + for (int first = 0; first < m_edges.size(); ++first) { + // If already processed, or if unused path, skip. + if (processed.at(first) || m_edges.at(first).next == -1) + continue; + + int i = first; + do { + Q_ASSERT(!processed.at(i)); + Q_ASSERT(m_edges.at(m_edges.at(i).next).previous == i); + m_parent->m_indices.push_back(m_edges.at(i).from); + processed.setBit(i); + i = m_edges.at(i).next; // CCW order + } while (i != first); + m_parent->m_indices.push_back(Q_TRIANGULATE_END_OF_POLYGON); + } +} + +void QTriangulator::ComplexToSimple::initEdges() +{ + // Initialize edge structure. + // 'next' and 'previous' are not being initialized at this point. + int first = 0; + for (int i = 0; i < m_parent->m_indices.size(); ++i) { + if (m_parent->m_indices.at(i) == Q_TRIANGULATE_END_OF_POLYGON) { + if (m_edges.size() != first) + m_edges.last().to = m_edges.at(first).from; + first = m_edges.size(); + } else { + Q_ASSERT(i + 1 < m_parent->m_indices.size()); + // {node, from, to, next, previous, winding, mayIntersect, pointingUp, originallyPointingUp} + Edge edge = {0, m_parent->m_indices.at(i), m_parent->m_indices.at(i + 1), -1, -1, 0, true, false, false}; + m_edges.add(edge); + } + } + if (first != m_edges.size()) + m_edges.last().to = m_edges.at(first).from; + for (int i = 0; i < m_edges.size(); ++i) { + m_edges.at(i).originallyPointingUp = m_edges.at(i).pointingUp = + m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from); + } +} + +// Return true if new intersection was found +bool QTriangulator::ComplexToSimple::calculateIntersection(int left, int right) +{ + const Edge &e1 = m_edges.at(left); + const Edge &e2 = m_edges.at(right); + + const QPodPoint &u1 = m_parent->m_vertices.at(e1.from); + const QPodPoint &u2 = m_parent->m_vertices.at(e1.to); + const QPodPoint &v1 = m_parent->m_vertices.at(e2.from); + const QPodPoint &v2 = m_parent->m_vertices.at(e2.to); + if (qMax(u1.x, u2.x) <= qMin(v1.x, v2.x)) + return false; + + quint64 key = (left > right ? (quint64(right) << 32) | quint64(left) : (quint64(left) << 32) | quint64(right)); + if (m_processedEdgePairs.contains(key)) + return false; + m_processedEdgePairs.insert(key); + + Intersection intersection; + intersection.leftEdge = left; + intersection.rightEdge = right; + intersection.intersectionPoint = qIntersectionPoint(u1, u2, v1, v2); + + if (!intersection.intersectionPoint.isValid()) + return false; + + Q_ASSERT(intersection.intersectionPoint.isOnLine(u1, u2)); + Q_ASSERT(intersection.intersectionPoint.isOnLine(v1, v2)); + + intersection.vertex = m_parent->m_vertices.size(); + m_topIntersection.push(intersection); + m_parent->m_vertices.add(intersection.intersectionPoint.round()); + return true; +} + +bool QTriangulator::ComplexToSimple::edgeIsLeftOfEdge(int leftEdgeIndex, int rightEdgeIndex) const +{ + const Edge &leftEdge = m_edges.at(leftEdgeIndex); + const Edge &rightEdge = m_edges.at(rightEdgeIndex); + const QPodPoint &u = m_parent->m_vertices.at(rightEdge.upper()); + const QPodPoint &l = m_parent->m_vertices.at(rightEdge.lower()); + const QPodPoint &upper = m_parent->m_vertices.at(leftEdge.upper()); + if (upper.x < qMin(l.x, u.x)) + return true; + if (upper.x > qMax(l.x, u.x)) + return false; + qint64 d = qPointDistanceFromLine(upper, l, u); + // d < 0: left, d > 0: right, d == 0: on top + if (d == 0) + d = qPointDistanceFromLine(m_parent->m_vertices.at(leftEdge.lower()), l, u); + return d < 0; +} + +QRBTree::Node *QTriangulator::ComplexToSimple::searchEdgeLeftOf(int edgeIndex) const +{ + QRBTree::Node *current = m_edgeList.root; + QRBTree::Node *result = 0; + while (current) { + if (edgeIsLeftOfEdge(edgeIndex, current->data)) { + current = current->left; + } else { + result = current; + current = current->right; + } + } + return result; +} + +QRBTree::Node *QTriangulator::ComplexToSimple::searchEdgeLeftOf(int edgeIndex, QRBTree::Node *after) const +{ + if (!m_edgeList.root) + return after; + QRBTree::Node *result = after; + QRBTree::Node *current = (after ? m_edgeList.next(after) : m_edgeList.front(m_edgeList.root)); + while (current) { + if (edgeIsLeftOfEdge(edgeIndex, current->data)) + return result; + result = current; + current = m_edgeList.next(current); + } + return result; +} + +QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple::bounds(const QPodPoint &point) const +{ + QRBTree::Node *current = m_edgeList.root; + QPair::Node *, QRBTree::Node *> result(0, 0); + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + if (d == 0) { + result.first = result.second = current; + break; + } + current = (d < 0 ? current->left : current->right); + } + if (current == 0) + return result; + + current = result.first->left; + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + Q_ASSERT(d >= 0); + if (d == 0) { + result.first = current; + current = current->left; + } else { + current = current->right; + } + } + + current = result.second->right; + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + Q_ASSERT(d <= 0); + if (d == 0) { + result.second = current; + current = current->right; + } else { + current = current->left; + } + } + + return result; +} + +QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple::outerBounds(const QPodPoint &point) const +{ + QRBTree::Node *current = m_edgeList.root; + QPair::Node *, QRBTree::Node *> result(0, 0); + + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + if (d == 0) + break; + if (d < 0) { + result.second = current; + current = current->left; + } else { + result.first = current; + current = current->right; + } + } + + if (!current) + return result; + + QRBTree::Node *mid = current; + + current = mid->left; + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + Q_ASSERT(d >= 0); + if (d == 0) { + current = current->left; + } else { + result.first = current; + current = current->right; + } + } + + current = mid->right; + while (current) { + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + int d = qPointDistanceFromLine(point, v1, v2); + Q_ASSERT(d <= 0); + if (d == 0) { + current = current->right; + } else { + result.second = current; + current = current->left; + } + } + + return result; +} + +void QTriangulator::ComplexToSimple::splitEdgeListRange(QRBTree::Node *leftmost, QRBTree::Node *rightmost, int vertex, const QIntersectionPoint &intersectionPoint) +{ + Q_ASSERT(leftmost && rightmost); + + // Split. + for (;;) { + const QPodPoint &u = m_parent->m_vertices.at(m_edges.at(leftmost->data).from); + const QPodPoint &v = m_parent->m_vertices.at(m_edges.at(leftmost->data).to); + Q_ASSERT(intersectionPoint.isOnLine(u, v)); + const Split split = {vertex, leftmost->data, intersectionPoint.isAccurate()}; + if (intersectionPoint.xOffset.numerator != 0 || intersectionPoint.yOffset.numerator != 0 || (intersectionPoint.upperLeft != u && intersectionPoint.upperLeft != v)) + m_splits.add(split); + if (leftmost == rightmost) + break; + leftmost = m_edgeList.next(leftmost); + } +} + + +void QTriangulator::ComplexToSimple::reorderEdgeListRange(QRBTree::Node *leftmost, QRBTree::Node *rightmost) +{ + Q_ASSERT(leftmost && rightmost); + + QRBTree::Node *storeLeftmost = leftmost; + QRBTree::Node *storeRightmost = rightmost; + + // Reorder. + while (leftmost != rightmost) { + Edge &left = m_edges.at(leftmost->data); + Edge &right = m_edges.at(rightmost->data); + qSwap(left.node, right.node); + qSwap(leftmost->data, rightmost->data); + leftmost = m_edgeList.next(leftmost); + if (leftmost == rightmost) + break; + rightmost = m_edgeList.previous(rightmost); + } + + rightmost = m_edgeList.next(storeRightmost); + leftmost = m_edgeList.previous(storeLeftmost); + if (leftmost) + calculateIntersection(leftmost->data, storeLeftmost->data); + if (rightmost) + calculateIntersection(storeRightmost->data, rightmost->data); +} + +void QTriangulator::ComplexToSimple::sortEdgeList(const QPodPoint eventPoint) +{ + QIntersectionPoint eventPoint2 = qIntersectionPoint(eventPoint); + while (!m_topIntersection.isEmpty() && m_topIntersection.top().intersectionPoint < eventPoint2) { + Intersection intersection = m_topIntersection.pop(); + + QIntersectionPoint currentIntersectionPoint = intersection.intersectionPoint; + int currentVertex = intersection.vertex; + + QRBTree::Node *leftmost = m_edges.at(intersection.leftEdge).node; + QRBTree::Node *rightmost = m_edges.at(intersection.rightEdge).node; + + for (;;) { + QRBTree::Node *previous = m_edgeList.previous(leftmost); + if (!previous) + break; + const Edge &edge = m_edges.at(previous->data); + const QPodPoint &u = m_parent->m_vertices.at(edge.from); + const QPodPoint &v = m_parent->m_vertices.at(edge.to); + if (!currentIntersectionPoint.isOnLine(u, v)) { + Q_ASSERT(!currentIntersectionPoint.isAccurate() || qCross(currentIntersectionPoint.upperLeft - u, v - u) != 0); + break; + } + leftmost = previous; + } + + for (;;) { + QRBTree::Node *next = m_edgeList.next(rightmost); + if (!next) + break; + const Edge &edge = m_edges.at(next->data); + const QPodPoint &u = m_parent->m_vertices.at(edge.from); + const QPodPoint &v = m_parent->m_vertices.at(edge.to); + if (!currentIntersectionPoint.isOnLine(u, v)) { + Q_ASSERT(!currentIntersectionPoint.isAccurate() || qCross(currentIntersectionPoint.upperLeft - u, v - u) != 0); + break; + } + rightmost = next; + } + + Q_ASSERT(leftmost && rightmost); + splitEdgeListRange(leftmost, rightmost, currentVertex, currentIntersectionPoint); + reorderEdgeListRange(leftmost, rightmost); + + while (!m_topIntersection.isEmpty() && m_topIntersection.top().intersectionPoint <= currentIntersectionPoint) + m_topIntersection.pop(); + +#ifdef Q_TRIANGULATOR_DEBUG + DebugDialog dialog(this, intersection.vertex); + dialog.exec(); +#endif + + } +} + +void QTriangulator::ComplexToSimple::fillPriorityQueue() +{ + m_events.reset(); + m_events.reserve(m_edges.size() * 2); + for (int i = 0; i < m_edges.size(); ++i) { + Q_ASSERT(m_edges.at(i).previous == -1 && m_edges.at(i).next == -1); + Q_ASSERT(m_edges.at(i).node == 0); + Q_ASSERT(m_edges.at(i).pointingUp == m_edges.at(i).originallyPointingUp); + Q_ASSERT(m_edges.at(i).pointingUp == (m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from))); + // Ignore zero-length edges. + if (m_parent->m_vertices.at(m_edges.at(i).to) != m_parent->m_vertices.at(m_edges.at(i).from)) { + Event upperEvent = {m_parent->m_vertices.at(m_edges.at(i).upper()), Event::Upper, i}; + Event lowerEvent = {m_parent->m_vertices.at(m_edges.at(i).lower()), Event::Lower, i}; + m_events.add(upperEvent); + m_events.add(lowerEvent); + } + } + //qSort(m_events.data(), m_events.data() + m_events.size()); + sort(m_events.data(), m_events.size()); +} + +void QTriangulator::ComplexToSimple::calculateIntersections() +{ + fillPriorityQueue(); + + Q_ASSERT(m_topIntersection.empty()); + Q_ASSERT(m_edgeList.root == 0); + + // Find all intersection points. + while (!m_events.isEmpty()) { + Event event = m_events.last(); + sortEdgeList(event.point); + + // Find all edges in the edge list that contain the current vertex and mark them to be split later. + QPair::Node *, QRBTree::Node *> range = bounds(event.point); + QRBTree::Node *leftNode = range.first ? m_edgeList.previous(range.first) : 0; + int vertex = (event.type == Event::Upper ? m_edges.at(event.edge).upper() : m_edges.at(event.edge).lower()); + QIntersectionPoint eventPoint = qIntersectionPoint(event.point); + + if (range.first != 0) { + splitEdgeListRange(range.first, range.second, vertex, eventPoint); + reorderEdgeListRange(range.first, range.second); + } + + // Handle the edges with start or end point in the current vertex. + while (!m_events.isEmpty() && m_events.last().point == event.point) { + event = m_events.last(); + m_events.pop_back(); + int i = event.edge; + + if (m_edges.at(i).node) { + // Remove edge from edge list. + Q_ASSERT(event.type == Event::Lower); + QRBTree::Node *left = m_edgeList.previous(m_edges.at(i).node); + QRBTree::Node *right = m_edgeList.next(m_edges.at(i).node); + m_edgeList.deleteNode(m_edges.at(i).node); + if (!left || !right) + continue; + calculateIntersection(left->data, right->data); + } else { + // Insert edge into edge list. + Q_ASSERT(event.type == Event::Upper); + QRBTree::Node *left = searchEdgeLeftOf(i, leftNode); + m_edgeList.attachAfter(left, m_edges.at(i).node = m_edgeList.newNode()); + m_edges.at(i).node->data = i; + QRBTree::Node *right = m_edgeList.next(m_edges.at(i).node); + if (left) + calculateIntersection(left->data, i); + if (right) + calculateIntersection(i, right->data); + } + } + while (!m_topIntersection.isEmpty() && m_topIntersection.top().intersectionPoint <= eventPoint) + m_topIntersection.pop(); +#ifdef Q_TRIANGULATOR_DEBUG + DebugDialog dialog(this, vertex); + dialog.exec(); +#endif + } + m_processedEdgePairs.clear(); +} + +// Split an edge into two pieces at the given point. +// The upper piece is pushed to the end of the 'm_edges' vector. +// The lower piece replaces the old edge. +// Return the edge whose 'from' is 'pointIndex'. +int QTriangulator::ComplexToSimple::splitEdge(int splitIndex) +{ + const Split &split = m_splits.at(splitIndex); + Edge &lowerEdge = m_edges.at(split.edge); + Q_ASSERT(lowerEdge.node == 0); + Q_ASSERT(lowerEdge.previous == -1 && lowerEdge.next == -1); + + if (lowerEdge.from == split.vertex) + return split.edge; + if (lowerEdge.to == split.vertex) + return lowerEdge.next; + + // Check that angle >= 90 degrees. + //Q_ASSERT(qDot(m_points.at(m_edges.at(edgeIndex).from) - m_points.at(pointIndex), + // m_points.at(m_edges.at(edgeIndex).to) - m_points.at(pointIndex)) <= 0); + + Edge upperEdge = lowerEdge; + upperEdge.mayIntersect |= !split.accurate; // The edge may have been split before at an inaccurate split point. + lowerEdge.mayIntersect = !split.accurate; + if (lowerEdge.pointingUp) { + lowerEdge.to = upperEdge.from = split.vertex; + m_edges.add(upperEdge); + return m_edges.size() - 1; + } else { + lowerEdge.from = upperEdge.to = split.vertex; + m_edges.add(upperEdge); + return split.edge; + } +} + +bool QTriangulator::ComplexToSimple::splitEdgesAtIntersections() +{ + for (int i = 0; i < m_edges.size(); ++i) + m_edges.at(i).mayIntersect = false; + bool checkForNewIntersections = false; + for (int i = 0; i < m_splits.size(); ++i) { + splitEdge(i); + checkForNewIntersections |= !m_splits.at(i).accurate; + } + for (int i = 0; i < m_edges.size(); ++i) { + m_edges.at(i).originallyPointingUp = m_edges.at(i).pointingUp = + m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from); + } + m_splits.reset(); + return checkForNewIntersections; +} + +void QTriangulator::ComplexToSimple::insertEdgeIntoVectorIfWanted(ShortArray &orderedEdges, int i) +{ + // Edges with zero length should not reach this part. + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(i).from) != m_parent->m_vertices.at(m_edges.at(i).to)); + + // Skip edges with unwanted winding number. + int windingNumber = m_edges.at(i).winding; + if (m_edges.at(i).originallyPointingUp) + ++windingNumber; + + // Make sure exactly one fill rule is specified. + Q_ASSERT(((m_parent->m_hint & QVectorPath::WindingFill) != 0) != ((m_parent->m_hint & QVectorPath::OddEvenFill) != 0)); + + if ((m_parent->m_hint & QVectorPath::WindingFill) && windingNumber != 0 && windingNumber != 1) + return; + + // Skip cancelling edges. + if (!orderedEdges.isEmpty()) { + int j = orderedEdges[orderedEdges.size() - 1]; + // If the last edge is already connected in one end, it should not be cancelled. + if (m_edges.at(j).next == -1 && m_edges.at(j).previous == -1 + && (m_parent->m_vertices.at(m_edges.at(i).from) == m_parent->m_vertices.at(m_edges.at(j).to)) + && (m_parent->m_vertices.at(m_edges.at(i).to) == m_parent->m_vertices.at(m_edges.at(j).from))) { + orderedEdges.removeLast(); + return; + } + } + orderedEdges.append(i); +} + +void QTriangulator::ComplexToSimple::removeUnwantedEdgesAndConnect() +{ + Q_ASSERT(m_edgeList.root == 0); + // Initialize priority queue. + fillPriorityQueue(); + + ShortArray orderedEdges; + + while (!m_events.isEmpty()) { + Event event = m_events.last(); + int edgeIndex = event.edge; + + // Check that all the edges in the list crosses the current scanline + //if (m_edgeList.root) { + // for (QRBTree::Node *node = m_edgeList.front(m_edgeList.root); node; node = m_edgeList.next(node)) { + // Q_ASSERT(event.point <= m_points.at(m_edges.at(node->data).lower())); + // } + //} + + orderedEdges.clear(); + QPair::Node *, QRBTree::Node *> b = outerBounds(event.point); + if (m_edgeList.root) { + QRBTree::Node *current = (b.first ? m_edgeList.next(b.first) : m_edgeList.front(m_edgeList.root)); + // Process edges that are going to be removed from the edge list at the current event point. + while (current != b.second) { + Q_ASSERT(current); + Q_ASSERT(m_edges.at(current->data).node == current); + Q_ASSERT(qIntersectionPoint(event.point).isOnLine(m_parent->m_vertices.at(m_edges.at(current->data).from), m_parent->m_vertices.at(m_edges.at(current->data).to))); + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(current->data).from) == event.point || m_parent->m_vertices.at(m_edges.at(current->data).to) == event.point); + insertEdgeIntoVectorIfWanted(orderedEdges, current->data); + current = m_edgeList.next(current); + } + } + + // Remove edges above the event point, insert edges below the event point. + do { + event = m_events.last(); + m_events.pop_back(); + edgeIndex = event.edge; + + // Edges with zero length should not reach this part. + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(edgeIndex).from) != m_parent->m_vertices.at(m_edges.at(edgeIndex).to)); + + if (m_edges.at(edgeIndex).node) { + Q_ASSERT(event.type == Event::Lower); + Q_ASSERT(event.point == m_parent->m_vertices.at(m_edges.at(event.edge).lower())); + m_edgeList.deleteNode(m_edges.at(edgeIndex).node); + } else { + Q_ASSERT(event.type == Event::Upper); + Q_ASSERT(event.point == m_parent->m_vertices.at(m_edges.at(event.edge).upper())); + QRBTree::Node *left = searchEdgeLeftOf(edgeIndex, b.first); + m_edgeList.attachAfter(left, m_edges.at(edgeIndex).node = m_edgeList.newNode()); + m_edges.at(edgeIndex).node->data = edgeIndex; + } + } while (!m_events.isEmpty() && m_events.last().point == event.point); + + if (m_edgeList.root) { + QRBTree::Node *current = (b.first ? m_edgeList.next(b.first) : m_edgeList.front(m_edgeList.root)); + + // Calculate winding number and turn counter-clockwise. + int currentWindingNumber = (b.first ? m_edges.at(b.first->data).winding : 0); + while (current != b.second) { + Q_ASSERT(current); + //Q_ASSERT(b.second == 0 || m_edgeList.order(current, b.second) < 0); + int i = current->data; + Q_ASSERT(m_edges.at(i).node == current); + + // Winding number. + int ccwWindingNumber = m_edges.at(i).winding = currentWindingNumber; + if (m_edges.at(i).originallyPointingUp) { + --m_edges.at(i).winding; + } else { + ++m_edges.at(i).winding; + ++ccwWindingNumber; + } + currentWindingNumber = m_edges.at(i).winding; + + // Turn counter-clockwise. + if ((ccwWindingNumber & 1) == 0) { + Q_ASSERT(m_edges.at(i).previous == -1 && m_edges.at(i).next == -1); + qSwap(m_edges.at(i).from, m_edges.at(i).to); + m_edges.at(i).pointingUp = !m_edges.at(i).pointingUp; + } + + current = m_edgeList.next(current); + } + + // Process edges that were inserted into the edge list at the current event point. + current = (b.second ? m_edgeList.previous(b.second) : m_edgeList.back(m_edgeList.root)); + while (current != b.first) { + Q_ASSERT(current); + Q_ASSERT(m_edges.at(current->data).node == current); + insertEdgeIntoVectorIfWanted(orderedEdges, current->data); + current = m_edgeList.previous(current); + } + } + if (orderedEdges.isEmpty()) + continue; + + Q_ASSERT((orderedEdges.size() & 1) == 0); + + // Connect edges. + // First make sure the first edge point towards the current point. + int i; + if (m_parent->m_vertices.at(m_edges.at(orderedEdges[0]).from) == event.point) { + i = 1; + int copy = orderedEdges[0]; // Make copy in case the append() will cause a reallocation. + orderedEdges.append(copy); + } else { + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(orderedEdges[0]).to) == event.point); + i = 0; + } + + // Remove references to duplicate points. First find the point with lowest index. + int pointIndex = INT_MAX; + for (int j = i; j < orderedEdges.size(); j += 2) { + Q_ASSERT(j + 1 < orderedEdges.size()); + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(orderedEdges[j]).to) == event.point); + Q_ASSERT(m_parent->m_vertices.at(m_edges.at(orderedEdges[j + 1]).from) == event.point); + if (m_edges.at(orderedEdges[j]).to < pointIndex) + pointIndex = m_edges.at(orderedEdges[j]).to; + if (m_edges.at(orderedEdges[j + 1]).from < pointIndex) + pointIndex = m_edges.at(orderedEdges[j + 1]).from; + } + + for (; i < orderedEdges.size(); i += 2) { + // Remove references to duplicate points by making all edges reference one common point. + m_edges.at(orderedEdges[i]).to = m_edges.at(orderedEdges[i + 1]).from = pointIndex; + + Q_ASSERT(m_edges.at(orderedEdges[i]).pointingUp || m_edges.at(orderedEdges[i]).previous != -1); + Q_ASSERT(!m_edges.at(orderedEdges[i + 1]).pointingUp || m_edges.at(orderedEdges[i + 1]).next != -1); + + m_edges.at(orderedEdges[i]).next = orderedEdges[i + 1]; + m_edges.at(orderedEdges[i + 1]).previous = orderedEdges[i]; + } + } // end while +} + +void QTriangulator::ComplexToSimple::removeUnusedPoints() { + QBitArray used(m_parent->m_vertices.size(), false); + for (int i = 0; i < m_edges.size(); ++i) { + Q_ASSERT((m_edges.at(i).previous == -1) == (m_edges.at(i).next == -1)); + if (m_edges.at(i).next != -1) + used.setBit(m_edges.at(i).from); + } + QDataBuffer newMapping(m_parent->m_vertices.size()); + newMapping.resize(m_parent->m_vertices.size()); + int count = 0; + for (int i = 0; i < m_parent->m_vertices.size(); ++i) { + if (used.at(i)) { + m_parent->m_vertices.at(count) = m_parent->m_vertices.at(i); + newMapping.at(i) = count; + ++count; + } + } + m_parent->m_vertices.resize(count); + for (int i = 0; i < m_edges.size(); ++i) { + m_edges.at(i).from = newMapping.at(m_edges.at(i).from); + m_edges.at(i).to = newMapping.at(m_edges.at(i).to); + } +} + +bool QTriangulator::ComplexToSimple::CompareEdges::operator () (int i, int j) const +{ + int cmp = comparePoints(m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(i).from), + m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(j).from)); + if (cmp == 0) { + cmp = comparePoints(m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(i).to), + m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(j).to)); + } + return cmp > 0; +} + +inline bool QTriangulator::ComplexToSimple::Event::operator < (const Event &other) const +{ + if (point == other.point) + return type < other.type; // 'Lower' has higher priority than 'Upper'. + return other.point < point; +} + +//============================================================================// +// QTriangulator::ComplexToSimple::DebugDialog // +//============================================================================// + +#ifdef Q_TRIANGULATOR_DEBUG + +QTriangulator::ComplexToSimple::DebugDialog::DebugDialog(ComplexToSimple *parent, int currentVertex) + : m_parent(parent), m_vertex(currentVertex) +{ + QDataBuffer &vertices = m_parent->m_parent->m_vertices; + if (vertices.isEmpty()) + return; + + int minX, maxX, minY, maxY; + minX = maxX = vertices.at(0).x; + minY = maxY = vertices.at(0).y; + for (int i = 1; i < vertices.size(); ++i) { + minX = qMin(minX, vertices.at(i).x); + maxX = qMax(maxX, vertices.at(i).x); + minY = qMin(minY, vertices.at(i).y); + maxY = qMax(maxY, vertices.at(i).y); + } + int w = maxX - minX; + int h = maxY - minY; + qreal border = qMin(w, h) / 10.0; + m_window = QRectF(minX - border, minY - border, (maxX - minX + 2 * border), (maxY - minY + 2 * border)); +} + +void QTriangulator::ComplexToSimple::DebugDialog::paintEvent(QPaintEvent *) +{ + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing, true); + p.fillRect(rect(), Qt::black); + QDataBuffer &vertices = m_parent->m_parent->m_vertices; + if (vertices.isEmpty()) + return; + + qreal halfPointSize = qMin(m_window.width(), m_window.height()) / 300.0; + p.setWindow(m_window.toRect()); + + p.setPen(Qt::white); + + QDataBuffer &edges = m_parent->m_edges; + for (int i = 0; i < edges.size(); ++i) { + QPodPoint u = vertices.at(edges.at(i).from); + QPodPoint v = vertices.at(edges.at(i).to); + p.drawLine(u.x, u.y, v.x, v.y); + } + + for (int i = 0; i < vertices.size(); ++i) { + QPodPoint q = vertices.at(i); + p.fillRect(QRectF(q.x - halfPointSize, q.y - halfPointSize, 2 * halfPointSize, 2 * halfPointSize), Qt::red); + } + + Qt::GlobalColor colors[6] = {Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta, Qt::yellow}; + p.setOpacity(0.5); + int count = 0; + if (m_parent->m_edgeList.root) { + QRBTree::Node *current = m_parent->m_edgeList.front(m_parent->m_edgeList.root); + while (current) { + p.setPen(colors[count++ % 6]); + QPodPoint u = vertices.at(edges.at(current->data).from); + QPodPoint v = vertices.at(edges.at(current->data).to); + p.drawLine(u.x, u.y, v.x, v.y); + current = m_parent->m_edgeList.next(current); + } + } + + p.setOpacity(1.0); + QPodPoint q = vertices.at(m_vertex); + p.fillRect(QRectF(q.x - halfPointSize, q.y - halfPointSize, 2 * halfPointSize, 2 * halfPointSize), Qt::green); + + p.setPen(Qt::gray); + QDataBuffer &splits = m_parent->m_splits; + for (int i = 0; i < splits.size(); ++i) { + QPodPoint q = vertices.at(splits.at(i).vertex); + QPodPoint u = vertices.at(edges.at(splits.at(i).edge).from) - q; + QPodPoint v = vertices.at(edges.at(splits.at(i).edge).to) - q; + qreal uLen = sqrt(qreal(qDot(u, u))); + qreal vLen = sqrt(qreal(qDot(v, v))); + if (uLen) { + u.x *= 2 * halfPointSize / uLen; + u.y *= 2 * halfPointSize / uLen; + } + if (vLen) { + v.x *= 2 * halfPointSize / vLen; + v.y *= 2 * halfPointSize / vLen; + } + u += q; + v += q; + p.drawLine(u.x, u.y, v.x, v.y); + } +} + +void QTriangulator::ComplexToSimple::DebugDialog::wheelEvent(QWheelEvent *event) +{ + qreal scale = exp(-0.001 * event->delta()); + QPointF center = m_window.center(); + QPointF delta = scale * (m_window.bottomRight() - center); + m_window = QRectF(center - delta, center + delta); + event->accept(); + update(); +} + +void QTriangulator::ComplexToSimple::DebugDialog::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton) { + QPointF delta = event->pos() - m_lastMousePos; + delta.setX(delta.x() * m_window.width() / width()); + delta.setY(delta.y() * m_window.height() / height()); + m_window.translate(-delta.x(), -delta.y()); + m_lastMousePos = event->pos(); + event->accept(); + update(); + } +} + +void QTriangulator::ComplexToSimple::DebugDialog::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + m_lastMousePos = event->pos(); + event->accept(); +} + + +#endif + +//============================================================================// +// QTriangulator::SimpleToMonotone // +//============================================================================// + +void QTriangulator::SimpleToMonotone::decompose() +{ + setupDataStructures(); + removeZeroLengthEdges(); + monotoneDecomposition(); + + m_parent->m_indices.clear(); + QBitArray processed(m_edges.size(), false); + for (int first = 0; first < m_edges.size(); ++first) { + if (processed.at(first)) + continue; + int i = first; + do { + Q_ASSERT(!processed.at(i)); + Q_ASSERT(m_edges.at(m_edges.at(i).next).previous == i); + m_parent->m_indices.push_back(m_edges.at(i).from); + processed.setBit(i); + i = m_edges.at(i).next; + } while (i != first); + if (m_parent->m_indices.size() > 0 && m_parent->m_indices.back() != Q_TRIANGULATE_END_OF_POLYGON) + m_parent->m_indices.push_back(Q_TRIANGULATE_END_OF_POLYGON); + } +} + +void QTriangulator::SimpleToMonotone::setupDataStructures() +{ + int i = 0; + Edge e; + e.node = 0; + e.twin = -1; + + while (i + 3 <= m_parent->m_indices.size()) { + int start = m_edges.size(); + + do { + e.from = m_parent->m_indices.at(i); + e.type = RegularVertex; + e.next = m_edges.size() + 1; + e.previous = m_edges.size() - 1; + m_edges.add(e); + ++i; + Q_ASSERT(i < m_parent->m_indices.size()); + } while (m_parent->m_indices.at(i) != Q_TRIANGULATE_END_OF_POLYGON); + + m_edges.last().next = start; + m_edges.at(start).previous = m_edges.size() - 1; + ++i; // Skip Q_TRIANGULATE_END_OF_POLYGON. + } + + for (i = 0; i < m_edges.size(); ++i) { + m_edges.at(i).to = m_edges.at(m_edges.at(i).next).from; + m_edges.at(i).pointingUp = m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from); + m_edges.at(i).helper = -1; // Not initialized here. + } +} + +void QTriangulator::SimpleToMonotone::removeZeroLengthEdges() +{ + for (int i = 0; i < m_edges.size(); ++i) { + if (m_parent->m_vertices.at(m_edges.at(i).from) == m_parent->m_vertices.at(m_edges.at(i).to)) { + m_edges.at(m_edges.at(i).previous).next = m_edges.at(i).next; + m_edges.at(m_edges.at(i).next).previous = m_edges.at(i).previous; + m_edges.at(m_edges.at(i).next).from = m_edges.at(i).from; + m_edges.at(i).next = -1; // Mark as removed. + } + } + + QDataBuffer newMapping(m_edges.size()); + newMapping.resize(m_edges.size()); + int count = 0; + for (int i = 0; i < m_edges.size(); ++i) { + if (m_edges.at(i).next != -1) { + m_edges.at(count) = m_edges.at(i); + newMapping.at(i) = count; + ++count; + } + } + m_edges.resize(count); + for (int i = 0; i < m_edges.size(); ++i) { + m_edges.at(i).next = newMapping.at(m_edges.at(i).next); + m_edges.at(i).previous = newMapping.at(m_edges.at(i).previous); + } +} + +void QTriangulator::SimpleToMonotone::fillPriorityQueue() +{ + m_upperVertex.reset(); + m_upperVertex.reserve(m_edges.size()); + for (int i = 0; i < m_edges.size(); ++i) + m_upperVertex.add(i); + CompareVertices cmp(this); + //qSort(m_upperVertex.data(), m_upperVertex.data() + m_upperVertex.size(), cmp); + sort(m_upperVertex.data(), m_upperVertex.size(), cmp); + //for (int i = 1; i < m_upperVertex.size(); ++i) { + // Q_ASSERT(!cmp(m_upperVertex.at(i), m_upperVertex.at(i - 1))); + //} +} + +bool QTriangulator::SimpleToMonotone::edgeIsLeftOfEdge(int leftEdgeIndex, int rightEdgeIndex) const +{ + const Edge &leftEdge = m_edges.at(leftEdgeIndex); + const Edge &rightEdge = m_edges.at(rightEdgeIndex); + const QPodPoint &u = m_parent->m_vertices.at(rightEdge.upper()); + const QPodPoint &l = m_parent->m_vertices.at(rightEdge.lower()); + qint64 d = qPointDistanceFromLine(m_parent->m_vertices.at(leftEdge.upper()), l, u); + // d < 0: left, d > 0: right, d == 0: on top + if (d == 0) + d = qPointDistanceFromLine(m_parent->m_vertices.at(leftEdge.lower()), l, u); + return d < 0; +} + +// Returns the rightmost edge not to the right of the given edge. +QRBTree::Node *QTriangulator::SimpleToMonotone::searchEdgeLeftOfEdge(int edgeIndex) const +{ + QRBTree::Node *current = m_edgeList.root; + QRBTree::Node *result = 0; + while (current) { + if (edgeIsLeftOfEdge(edgeIndex, current->data)) { + current = current->left; + } else { + result = current; + current = current->right; + } + } + return result; +} + +// Returns the rightmost edge left of the given point. +QRBTree::Node *QTriangulator::SimpleToMonotone::searchEdgeLeftOfPoint(int pointIndex) const +{ + QRBTree::Node *current = m_edgeList.root; + QRBTree::Node *result = 0; + while (current) { + const QPodPoint &p1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); + const QPodPoint &p2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); + qint64 d = qPointDistanceFromLine(m_parent->m_vertices.at(pointIndex), p1, p2); + if (d <= 0) { + current = current->left; + } else { + result = current; + current = current->right; + } + } + return result; +} + +void QTriangulator::SimpleToMonotone::classifyVertex(int i) +{ + Edge &e2 = m_edges.at(i); + const Edge &e1 = m_edges.at(e2.previous); + + bool startOrSplit = (e1.pointingUp && !e2.pointingUp); + bool endOrMerge = (!e1.pointingUp && e2.pointingUp); + + const QPodPoint &p1 = m_parent->m_vertices.at(e1.from); + const QPodPoint &p2 = m_parent->m_vertices.at(e2.from); + const QPodPoint &p3 = m_parent->m_vertices.at(e2.to); + qint64 d = qPointDistanceFromLine(p1, p2, p3); + Q_ASSERT(d != 0 || (!startOrSplit && !endOrMerge)); + + e2.type = RegularVertex; + + if (m_clockwiseOrder) { + if (startOrSplit) + e2.type = (d < 0 ? SplitVertex : StartVertex); + else if (endOrMerge) + e2.type = (d < 0 ? MergeVertex : EndVertex); + } else { + if (startOrSplit) + e2.type = (d > 0 ? SplitVertex : StartVertex); + else if (endOrMerge) + e2.type = (d > 0 ? MergeVertex : EndVertex); + } +} + +void QTriangulator::SimpleToMonotone::classifyVertices() +{ + for (int i = 0; i < m_edges.size(); ++i) + classifyVertex(i); +} + +bool QTriangulator::SimpleToMonotone::pointIsInSector(const QPodPoint &p, const QPodPoint &v1, const QPodPoint &v2, const QPodPoint &v3) +{ + bool leftOfPreviousEdge = !qPointIsLeftOfLine(p, v2, v1); + bool leftOfNextEdge = !qPointIsLeftOfLine(p, v3, v2); + + if (qPointIsLeftOfLine(v1, v2, v3)) + return leftOfPreviousEdge && leftOfNextEdge; + else + return leftOfPreviousEdge || leftOfNextEdge; +} + +bool QTriangulator::SimpleToMonotone::pointIsInSector(int vertex, int sector) +{ + const QPodPoint ¢er = m_parent->m_vertices.at(m_edges.at(sector).from); + // Handle degenerate edges. + while (m_parent->m_vertices.at(m_edges.at(vertex).from) == center) + vertex = m_edges.at(vertex).next; + int next = m_edges.at(sector).next; + while (m_parent->m_vertices.at(m_edges.at(next).from) == center) + next = m_edges.at(next).next; + int previous = m_edges.at(sector).previous; + while (m_parent->m_vertices.at(m_edges.at(previous).from) == center) + previous = m_edges.at(previous).previous; + + const QPodPoint &p = m_parent->m_vertices.at(m_edges.at(vertex).from); + const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(previous).from); + const QPodPoint &v3 = m_parent->m_vertices.at(m_edges.at(next).from); + if (m_clockwiseOrder) + return pointIsInSector(p, v3, center, v1); + else + return pointIsInSector(p, v1, center, v3); +} + +int QTriangulator::SimpleToMonotone::findSector(int edge, int vertex) +{ + while (!pointIsInSector(vertex, edge)) { + edge = m_edges.at(m_edges.at(edge).previous).twin; + Q_ASSERT(edge != -1); + } + return edge; +} + +void QTriangulator::SimpleToMonotone::createDiagonal(int lower, int upper) +{ + lower = findSector(lower, upper); + upper = findSector(upper, lower); + + int prevLower = m_edges.at(lower).previous; + int prevUpper = m_edges.at(upper).previous; + + Edge e; + + e.twin = m_edges.size() + 1; + e.next = upper; + e.previous = prevLower; + e.from = m_edges.at(lower).from; + e.to = m_edges.at(upper).from; + m_edges.at(upper).previous = m_edges.at(prevLower).next = int(m_edges.size()); + m_edges.add(e); + + e.twin = m_edges.size() - 1; + e.next = lower; + e.previous = prevUpper; + e.from = m_edges.at(upper).from; + e.to = m_edges.at(lower).from; + m_edges.at(lower).previous = m_edges.at(prevUpper).next = int(m_edges.size()); + m_edges.add(e); +} + +void QTriangulator::SimpleToMonotone::monotoneDecomposition() +{ + if (m_edges.isEmpty()) + return; + + Q_ASSERT(!m_edgeList.root); + QDataBuffer > diagonals; + + int i = 0; + for (int index = 1; index < m_edges.size(); ++index) { + if (m_parent->m_vertices.at(m_edges.at(index).from) < m_parent->m_vertices.at(m_edges.at(i).from)) + i = index; + } + Q_ASSERT(i < m_edges.size()); + int j = m_edges.at(i).previous; + Q_ASSERT(j < m_edges.size()); + m_clockwiseOrder = qPointIsLeftOfLine(m_parent->m_vertices.at(m_edges.at(i).from), + m_parent->m_vertices.at(m_edges.at(j).from), m_parent->m_vertices.at(m_edges.at(i).to)); + + classifyVertices(); + fillPriorityQueue(); + + // debug: set helpers explicitly (shouldn't be necessary) + //for (int i = 0; i < m_edges.size(); ++i) + // m_edges.at(i).helper = m_edges.at(i).upper(); + + while (!m_upperVertex.isEmpty()) { + i = m_upperVertex.last(); + Q_ASSERT(i < m_edges.size()); + m_upperVertex.pop_back(); + j = m_edges.at(i).previous; + Q_ASSERT(j < m_edges.size()); + + QRBTree::Node *leftEdgeNode = 0; + + switch (m_edges.at(i).type) { + case RegularVertex: + // If polygon interior is to the right of the vertex... + if (m_edges.at(i).pointingUp == m_clockwiseOrder) { + if (m_edges.at(i).node) { + Q_ASSERT(!m_edges.at(j).node); + if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(i).helper)); + m_edges.at(j).node = m_edges.at(i).node; + m_edges.at(i).node = 0; + m_edges.at(j).node->data = j; + m_edges.at(j).helper = i; + } else if (m_edges.at(j).node) { + Q_ASSERT(!m_edges.at(i).node); + if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(j).helper)); + m_edges.at(i).node = m_edges.at(j).node; + m_edges.at(j).node = 0; + m_edges.at(i).node->data = i; + m_edges.at(i).helper = i; + } else { + qWarning("Inconsistent polygon. (#1)"); + } + } else { + leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); + if (leftEdgeNode) { + if (m_edges.at(m_edges.at(leftEdgeNode->data).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + m_edges.at(leftEdgeNode->data).helper = i; + } else { + qWarning("Inconsistent polygon. (#2)"); + } + } + break; + case SplitVertex: + leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); + if (leftEdgeNode) { + diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + m_edges.at(leftEdgeNode->data).helper = i; + } else { + qWarning("Inconsistent polygon. (#3)"); + } + // Fall through. + case StartVertex: + if (m_clockwiseOrder) { + leftEdgeNode = searchEdgeLeftOfEdge(j); + QRBTree::Node *node = m_edgeList.newNode(); + node->data = j; + m_edges.at(j).node = node; + m_edges.at(j).helper = i; + m_edgeList.attachAfter(leftEdgeNode, node); + Q_ASSERT(m_edgeList.verify()); + } else { + leftEdgeNode = searchEdgeLeftOfEdge(i); + QRBTree::Node *node = m_edgeList.newNode(); + node->data = i; + m_edges.at(i).node = node; + m_edges.at(i).helper = i; + m_edgeList.attachAfter(leftEdgeNode, node); + Q_ASSERT(m_edgeList.verify()); + } + break; + case MergeVertex: + leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); + if (leftEdgeNode) { + if (m_edges.at(m_edges.at(leftEdgeNode->data).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + m_edges.at(leftEdgeNode->data).helper = i; + } else { + qWarning("Inconsistent polygon. (#4)"); + } + // Fall through. + case EndVertex: + if (m_clockwiseOrder) { + if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(i).helper)); + if (m_edges.at(i).node) { + m_edgeList.deleteNode(m_edges.at(i).node); + Q_ASSERT(m_edgeList.verify()); + } else { + qWarning("Inconsistent polygon. (#5)"); + } + } else { + if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) + diagonals.add(std::pair(i, m_edges.at(j).helper)); + if (m_edges.at(j).node) { + m_edgeList.deleteNode(m_edges.at(j).node); + Q_ASSERT(m_edgeList.verify()); + } else { + qWarning("Inconsistent polygon. (#6)"); + } + } + break; + } + } + + for (int i = 0; i < diagonals.size(); ++i) + createDiagonal(diagonals.at(i).first, diagonals.at(i).second); +} + +bool QTriangulator::SimpleToMonotone::CompareVertices::operator () (int i, int j) const +{ + if (m_parent->m_edges.at(i).from == m_parent->m_edges.at(j).from) + return m_parent->m_edges.at(i).type > m_parent->m_edges.at(j).type; + return m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(i).from) > + m_parent->m_parent->m_vertices.at(m_parent->m_edges.at(j).from); +} + +//============================================================================// +// QTriangulator::MonotoneToTriangles // +//============================================================================// + +void QTriangulator::MonotoneToTriangles::decompose() +{ + QVector result; + QDataBuffer stack; + m_first = 0; + // Require at least three more indices. + while (m_first + 3 <= m_parent->m_indices.size()) { + m_length = 0; + while (m_parent->m_indices.at(m_first + m_length) != Q_TRIANGULATE_END_OF_POLYGON) { + ++m_length; + Q_ASSERT(m_first + m_length < m_parent->m_indices.size()); + } + if (m_length < 3) { + m_first += m_length + 1; + continue; + } + + int minimum = 0; + while (less(next(minimum), minimum)) + minimum = next(minimum); + while (less(previous(minimum), minimum)) + minimum = previous(minimum); + + stack.reset(); + stack.add(minimum); + int left = previous(minimum); + int right = next(minimum); + bool stackIsOnLeftSide; + bool clockwiseOrder = leftOfEdge(minimum, left, right); + + if (less(left, right)) { + stack.add(left); + left = previous(left); + stackIsOnLeftSide = true; + } else { + stack.add(right); + right = next(right); + stackIsOnLeftSide = false; + } + + for (int count = 0; count + 2 < m_length; ++count) + { + Q_ASSERT(stack.size() >= 2); + if (less(left, right)) { + if (stackIsOnLeftSide == false) { + for (int i = 0; i + 1 < stack.size(); ++i) { + result.push_back(indices(stack.at(i + 1))); + result.push_back(indices(left)); + result.push_back(indices(stack.at(i))); + } + stack.first() = stack.last(); + stack.resize(1); + } else { + while (stack.size() >= 2 && (clockwiseOrder ^ !leftOfEdge(left, stack.at(stack.size() - 2), stack.last()))) { + result.push_back(indices(stack.at(stack.size() - 2))); + result.push_back(indices(left)); + result.push_back(indices(stack.last())); + stack.pop_back(); + } + } + stack.add(left); + left = previous(left); + stackIsOnLeftSide = true; + } else { + if (stackIsOnLeftSide == true) { + for (int i = 0; i + 1 < stack.size(); ++i) { + result.push_back(indices(stack.at(i))); + result.push_back(indices(right)); + result.push_back(indices(stack.at(i + 1))); + } + stack.first() = stack.last(); + stack.resize(1); + } else { + while (stack.size() >= 2 && (clockwiseOrder ^ !leftOfEdge(right, stack.last(), stack.at(stack.size() - 2)))) { + result.push_back(indices(stack.last())); + result.push_back(indices(right)); + result.push_back(indices(stack.at(stack.size() - 2))); + stack.pop_back(); + } + } + stack.add(right); + right = next(right); + stackIsOnLeftSide = false; + } + } + + m_first += m_length + 1; + } + m_parent->m_indices = result; +} + +//============================================================================// +// qTriangulate // +//============================================================================// + +QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint, const QTransform &matrix) +{ + QTriangulator triangulator; + triangulator.initialize(polygon, count, hint, matrix); + return triangulator.triangulate(); +} + +QTriangleSet qTriangulate(const QVectorPath &path, const QTransform &matrix, qreal lod) +{ + QTriangulator triangulator; + triangulator.initialize(path, matrix, lod); + return triangulator.triangulate(); +} + +QTriangleSet qTriangulate(const QPainterPath &path, const QTransform &matrix, qreal lod) +{ + QTriangulator triangulator; + triangulator.initialize(path, matrix, lod); + return triangulator.triangulate(); +} + +QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix, qreal lod) +{ + QTriangulator triangulator; + triangulator.initialize(path, matrix, lod); + return triangulator.polyline(); +} + +QPolylineSet qPolyline(const QPainterPath &path, const QTransform &matrix, qreal lod) +{ + QTriangulator triangulator; + triangulator.initialize(path, matrix, lod); + return triangulator.polyline(); +} + +QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qtriangulator_p.h b/src/opengl/gl2paintengineex/qtriangulator_p.h new file mode 100644 index 0000000..da47666 --- /dev/null +++ b/src/opengl/gl2paintengineex/qtriangulator_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTRIANGULATOR_P_H +#define QTRIANGULATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +#define Q_TRIANGULATE_END_OF_POLYGON quint32(-1) + +struct QTriangleSet +{ + inline QTriangleSet() { } + inline QTriangleSet(const QTriangleSet &other) : vertices(other.vertices), indices(other.indices) { } + QTriangleSet &operator = (const QTriangleSet &other) {vertices = other.vertices; indices = other.indices; return *this;} + + // The vertices of a triangle are given by: (x[i[n]], y[i[n]]), (x[j[n]], y[j[n]]), (x[k[n]], y[k[n]]), n = 0, 1, ... + QVector vertices; // [x[0], y[0], x[1], y[1], x[2], ...] + QVector indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...] +}; + +struct QPolylineSet +{ + inline QPolylineSet() { } + inline QPolylineSet(const QPolylineSet &other) : vertices(other.vertices), indices(other.indices) { } + QPolylineSet &operator = (const QPolylineSet &other) {vertices = other.vertices; indices = other.indices; return *this;} + + QVector vertices; // [x[0], y[0], x[1], y[1], x[2], ...] + QVector indices; + +}; + +// The vertex coordinates of the returned triangle set will be rounded to a grid with a mesh size +// of 1/32. The polygon is first transformed, then scaled by 32, the coordinates are rounded to +// integers, the polygon is triangulated, and then scaled back by 1/32. +// 'hint' should be a combination of QVectorPath::Hints. +// 'lod' is the level of detail. Default is 1. Curves are split into more lines when 'lod' is higher. +QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint = QVectorPath::PolygonHint | QVectorPath::OddEvenFill, const QTransform &matrix = QTransform()); +QTriangleSet qTriangulate(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1); +QTriangleSet qTriangulate(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1); +QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1); +QPolylineSet qPolyline(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1); + +QT_END_NAMESPACE + +#endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b2474ed..ec01db0 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -54,7 +54,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qpaintengineex_opengl2_p.h \ gl2paintengineex/qglengineshadersource_p.h \ gl2paintengineex/qglcustomshaderstage_p.h \ - gl2paintengineex/qtriangulatingstroker_p.h + gl2paintengineex/qtriangulatingstroker_p.h \ + gl2paintengineex/qtriangulator_p.h SOURCES += qglshaderprogram.cpp \ qglpixmapfilter.cpp \ @@ -67,7 +68,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qgl2pexvertexarray.cpp \ gl2paintengineex/qpaintengineex_opengl2.cpp \ gl2paintengineex/qglcustomshaderstage.cpp \ - gl2paintengineex/qtriangulatingstroker.cpp + gl2paintengineex/qtriangulatingstroker.cpp \ + gl2paintengineex/qtriangulator.cpp } -- cgit v0.12 From 0fc7c731b47d7984ab8039f70561ad559a0bd36d Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Wed, 2 Dec 2009 17:56:40 +0100 Subject: fix QKeySequence::fromString now emacs-style shortcuts are parsed correctly, like in the constructor, and they share the code too. Merge-request: 1279 Reviewed-by: Leonardo Sobral Cunha --- src/gui/kernel/qkeysequence.cpp | 36 ++++++++++++++++++++++------ src/gui/kernel/qkeysequence.h | 12 ++++++---- tests/auto/qkeysequence/tst_qkeysequence.cpp | 13 ++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index e3af683..2a53a16 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -859,6 +859,8 @@ QKeySequence::QKeySequence() Up to four key codes may be entered by separating them with commas, e.g. "Alt+X,Ctrl+S,Q". + \a key should be in NativeText format. + This constructor is typically used with \link QObject::tr() tr \endlink(), so that shortcut keys can be replaced in translations: @@ -875,6 +877,16 @@ QKeySequence::QKeySequence(const QString &key) } /*! + \since 4.x + Creates a key sequence from the \a key string based on \a format. +*/ +QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format) +{ + d = new QKeySequencePrivate(); + assign(key, format); +} + +/*! Constructs a key sequence with up to 4 keys \a k1, \a k2, \a k3 and \a k4. @@ -1053,9 +1065,24 @@ QKeySequence QKeySequence::mnemonic(const QString &text) contain up to four key codes, provided they are separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return value is the number of key codes added. + \a keys should be in NativeText format. */ int QKeySequence::assign(const QString &ks) { + return assign(ks, NativeText); +} + +/*! + \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format) + \since 4.x + + Adds the given \a keys to the key sequence (based on \a format). + \a keys may contain up to four key codes, provided they are + separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return + value is the number of key codes added. +*/ +int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format) +{ QString keyseq = ks; QString part; int n = 0; @@ -1084,7 +1111,7 @@ int QKeySequence::assign(const QString &ks) } part = keyseq.left(-1 == p ? keyseq.length() : p - diff); keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1)); - d->key[n] = decodeString(part); + d->key[n] = QKeySequencePrivate::decodeString(part, format); ++n; } return n; @@ -1555,12 +1582,7 @@ QString QKeySequence::toString(SequenceFormat format) const */ QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format) { - QStringList sl = str.split(QLatin1String(", ")); - int keys[4] = {0, 0, 0, 0}; - int total = qMin(sl.count(), 4); - for (int i = 0; i < total; ++i) - keys[i] = QKeySequencePrivate::decodeString(sl[i], format); - return QKeySequence(keys[0], keys[1], keys[2], keys[3]); + return QKeySequence(str, format); } /***************************************************************************** diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h index d41902b..591cc37 100644 --- a/src/gui/kernel/qkeysequence.h +++ b/src/gui/kernel/qkeysequence.h @@ -141,8 +141,14 @@ public: Quit }; + enum SequenceFormat { + NativeText, + PortableText + }; + QKeySequence(); QKeySequence(const QString &key); + QKeySequence(const QString &key, SequenceFormat format); QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0); QKeySequence(const QKeySequence &ks); QKeySequence(StandardKey key); @@ -160,11 +166,6 @@ public: #endif }; - enum SequenceFormat { - NativeText, - PortableText - }; - QString toString(SequenceFormat format = PortableText) const; static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText); @@ -194,6 +195,7 @@ private: static int decodeString(const QString &ks); static QString encodeString(int key); int assign(const QString &str); + int assign(const QString &str, SequenceFormat format); void setKey(int key, int index); QKeySequencePrivate *d; diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index bc9ae6c..a299d54 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -119,6 +119,7 @@ private slots: void symetricConstructors_data(); void symetricConstructors(); void checkMultipleNames(); + void checkMultipleCodes(); void mnemonic_data(); void mnemonic(); void toString_data(); @@ -265,6 +266,18 @@ void tst_QKeySequence::checkMultipleNames() QVERIFY( oldK == newK ); } +//TODO: could test third constructor, or test fromString on all constructor-data +void tst_QKeySequence::checkMultipleCodes() +{ + QKeySequence seq1("Alt+d, l"); + QKeySequence seq2 = QKeySequence::fromString("Alt+d, l"); + QVERIFY( seq1 == seq2 ); + + QKeySequence seq3("Alt+d,l"); + QKeySequence seq4 = QKeySequence::fromString("Alt+d,l"); + QVERIFY( seq3 == seq4 ); +} + /* * We must ensure that the keyBindings data is allways sorted * so that we can safely perform binary searches. -- cgit v0.12 From c0d237b7aa6e0257e3c3eee7336deaed1cf68252 Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Wed, 2 Dec 2009 20:26:38 +0100 Subject: Move data: decoding to function Merge-request: 1560 Reviewed-by: Thiago Macieira --- src/corelib/io/io.pri | 2 + src/corelib/io/qdataurl.cpp | 101 +++++++++++++++++++++++ src/corelib/io/qdataurl_p.h | 67 +++++++++++++++ src/network/access/qnetworkaccessdatabackend.cpp | 62 ++++---------- 4 files changed, 185 insertions(+), 47 deletions(-) create mode 100644 src/corelib/io/qdataurl.cpp create mode 100644 src/corelib/io/qdataurl_p.h diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 02a1586..2ed0e46 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -6,6 +6,7 @@ HEADERS += \ io/qbuffer.h \ io/qdatastream.h \ io/qdatastream_p.h \ + io/qdataurl_p.h \ io/qdebug.h \ io/qdir.h \ io/qdiriterator.h \ @@ -34,6 +35,7 @@ SOURCES += \ io/qabstractfileengine.cpp \ io/qbuffer.cpp \ io/qdatastream.cpp \ + io/qdataurl.cpp \ io/qdebug.cpp \ io/qdir.cpp \ io/qdiriterator.cpp \ diff --git a/src/corelib/io/qdataurl.cpp b/src/corelib/io/qdataurl.cpp new file mode 100644 index 0000000..9bb896e --- /dev/null +++ b/src/corelib/io/qdataurl.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformdefs.h" +#include "qurl.h" +#include "private/qdataurl_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \internal + + Decode a data: URL into its mimetype and payload. Returns a null string if + the URL could not be decoded. +*/ +Q_CORE_EXPORT QPair qDecodeDataUrl(const QUrl &uri) +{ + QString mimeType; + QByteArray payload; + + if (uri.scheme() == QLatin1String("data") && uri.host().isEmpty()) { + mimeType = QLatin1String("text/plain;charset=US-ASCII"); + + // the following would have been the correct thing, but + // reality often differs from the specification. People have + // data: URIs with ? and # + //QByteArray data = QByteArray::fromPercentEncoding(uri.encodedPath()); + QByteArray data = QByteArray::fromPercentEncoding(uri.toEncoded()); + + // remove the data: scheme + data.remove(0, 5); + + // parse it: + int pos = data.indexOf(','); + if (pos != -1) { + payload = data.mid(pos + 1); + data.truncate(pos); + data = data.trimmed(); + + // find out if the payload is encoded in Base64 + if (data.endsWith(";base64")) { + payload = QByteArray::fromBase64(payload); + data.chop(7); + } + + if (data.toLower().startsWith("charset")) { + int i = 7; // strlen("charset") + while (data.at(i) == ' ') + ++i; + if (data.at(i) == '=') + data.prepend("text/plain;"); + } + + if (!data.isEmpty()) + mimeType = QLatin1String(data.trimmed()); + + } + } + + return QPair(mimeType,payload); +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qdataurl_p.h b/src/corelib/io/qdataurl_p.h new file mode 100644 index 0000000..be5b10d --- /dev/null +++ b/src/corelib/io/qdataurl_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDATAURL_P_H +#define QDATAURL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qDecodeDataUrl. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qurl.h" +#include "QtCore/qbytearray.h" +#include "QtCore/qstring.h" +#include "QtCore/qpair.h" + +QT_BEGIN_NAMESPACE + +Q_CORE_EXPORT QPair qDecodeDataUrl(const QUrl &url); + +QT_END_NAMESPACE + +#endif // QDATAURL_P_H diff --git a/src/network/access/qnetworkaccessdatabackend.cpp b/src/network/access/qnetworkaccessdatabackend.cpp index feec5b6..cada338 100644 --- a/src/network/access/qnetworkaccessdatabackend.cpp +++ b/src/network/access/qnetworkaccessdatabackend.cpp @@ -43,6 +43,7 @@ #include "qnetworkrequest.h" #include "qnetworkreply.h" #include "qurlinfo.h" +#include "private/qdataurl_p.h" QT_BEGIN_NAMESPACE @@ -78,53 +79,20 @@ void QNetworkAccessDataBackend::open() return; } - if (uri.host().isEmpty()) { - setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/plain;charset=US-ASCII")); - - // the following would have been the correct thing, but - // reality often differs from the specification. People have - // data: URIs with ? and # - //QByteArray data = QByteArray::fromPercentEncoding(uri.encodedPath()); - QByteArray data = QByteArray::fromPercentEncoding(uri.toEncoded()); - - // remove the data: scheme - data.remove(0, 5); - - // parse it: - int pos = data.indexOf(','); - if (pos != -1) { - QByteArray payload = data.mid(pos + 1); - data.truncate(pos); - data = data.trimmed(); - - // find out if the payload is encoded in Base64 - if (data.endsWith(";base64")) { - payload = QByteArray::fromBase64(payload); - data.chop(7); - } - - if (data.toLower().startsWith("charset")) { - int i = 7; // strlen("charset") - while (data.at(i) == ' ') - ++i; - if (data.at(i) == '=') - data.prepend("text/plain;"); - } - - if (!data.isEmpty()) - setHeader(QNetworkRequest::ContentTypeHeader, data.trimmed()); - - setHeader(QNetworkRequest::ContentLengthHeader, payload.size()); - emit metaDataChanged(); - - QByteDataBuffer list; - list.append(payload); - payload.clear(); // important because of implicit sharing! - writeDownstreamData(list); - - finished(); - return; - } + QPair decoded = qDecodeDataUrl(uri); + + if (! decoded.first.isNull()) { + setHeader(QNetworkRequest::ContentTypeHeader, decoded.first); + setHeader(QNetworkRequest::ContentLengthHeader, decoded.second.size()); + emit metaDataChanged(); + + QByteDataBuffer list; + list.append(decoded.second); + decoded.second.clear(); // important because of implicit sharing! + writeDownstreamData(list); + + finished(); + return; } // something wrong with this URI -- cgit v0.12 From 2eb96bf5b68cbdcc1ebd2616b0b9e5f0f77eb257 Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Wed, 2 Dec 2009 20:26:39 +0100 Subject: Add data: URL handling to QTextDocument::loadResource Merge-request: 1560 Reviewed-by: Thiago Macieira --- src/gui/text/qtextdocument.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 523dd18..3b0a979 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -61,6 +61,7 @@ #include #include "qtextcontrol_p.h" #include "private/qtextedit_p.h" +#include "private/qdataurl_p.h" #include "qtextdocument_p.h" #include @@ -1924,6 +1925,10 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name) } #endif + // handle data: URLs + if (r.isNull() && name.scheme() == QLatin1String("data")) + r = qDecodeDataUrl(name).second; + // if resource was not loaded try to load it here if (!doc && r.isNull() && name.isRelative()) { QUrl currentURL = d->url; -- cgit v0.12 From b93000823d11575b6c30490ea97a2649a0119f86 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Dec 2009 20:37:28 +0100 Subject: Fixed typing error in a variable Merge-request: 1875 Reviewed-by: Thiago Macieira --- mkspecs/unsupported/qws/qnx-641/qmake.conf | 99 +++++++++++++++++++++++++ mkspecs/unsupported/qws/qnx-641/qplatformdefs.h | 42 +++++++++++ 2 files changed, 141 insertions(+) create mode 100644 mkspecs/unsupported/qws/qnx-641/qmake.conf create mode 100644 mkspecs/unsupported/qws/qnx-641/qplatformdefs.h diff --git a/mkspecs/unsupported/qws/qnx-641/qmake.conf b/mkspecs/unsupported/qws/qnx-641/qmake.conf new file mode 100644 index 0000000..db333b7 --- /dev/null +++ b/mkspecs/unsupported/qws/qnx-641/qmake.conf @@ -0,0 +1,99 @@ +# +# qmake configuration for qnx +# +# Written for QNX 6.4.1 without X11. +# + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release link_prl +QT += core gui +DEFINES += QT_NO_NIS QT_NO_TEXTODFWRITER QT_OPENGL + +QMAKE_CC = qcc +QMAKE_CFLAGS += -V4.3.3,gcc_ntox86_acpp-ne -pipe +QMAKE_CFLAGS_DEPS += -M +QMAKE_CFLAGS_WARN_ON += -Wall -W +QMAKE_CFLAGS_WARN_OFF += -w +QMAKE_CFLAGS_RELEASE += -O2 +QMAKE_CFLAGS_DEBUG += -g +QMAKE_CFLAGS_SHLIB += -fPIC +QMAKE_CFLAGS_STATIC_LIB += -fPIC +QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses +QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden +QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE} +QMAKE_COMPILER_DEFINES += __QNXNTO__ + +QMAKE_CXX = qcc +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS +QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB +QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB +QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden +QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + +QMAKE_LINK = qcc +QMAKE_LINK_SHLIB = qcc +QMAKE_LINK_SHLIB_CMD = $(LINK) $(LFLAGS) -o ../../lib/$(TARGET) $(OBJECTS) $(LIBS) +QMAKE_LFLAGS = -V4.3.3,gcc_ntox86 -lang-c++ -Y_acpp-ne +QMAKE_LFLAGS_RELEASE = +QMAKE_LFLAGS_DEBUG = +QMAKE_LFLAGS_SHLIB = -shared +QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB +QMAKE_LFLAGS_SONAME = -Wl,-soname, +QMAKE_LFLAGS_THREAD = +QMAKE_LN_SHLIB = -cp +QMAKE_RPATH = -Wl,-rpath, + +QMAKE_PCH_OUTPUT_EXT = .gch + +# -Bsymbolic-functions (ld) support +QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions +QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list, + +include(../../common/unix.conf) + +QMAKE_CFLAGS_THREAD = -D_REENTRANT +QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD + +QMAKE_INCDIR = +QMAKE_LIBDIR = +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] + + +QMAKE_LIBS = -lm -lz +QMAKE_LIBS_DYNLOAD = +QMAKE_LIBS_THREAD = +QMAKE_LIBS_NETWORK += -lsocket +QMAKE_LIBS_GUI += -lsocket +QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe +QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe +QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe + +QMAKE_AR = ntox86-ar cqs +QMAKE_RANLIB = + +QMAKE_TAR = tar -cf +QMAKE_GZIP = gzip -9f + +QMAKE_COPY = cp -f +QMAKE_COPY_FILE = $(COPY) +QMAKE_COPY_DIR = $(COPY) -r +QMAKE_MOVE = mv -f +QMAKE_DEL_FILE = rm -f +QMAKE_DEL_DIR = rmdir +QMAKE_CHK_DIR_EXISTS = test -d +QMAKE_MKDIR = mkdir -p +QMAKE_STRIP = strip +QMAKE_STRIPFLAGS_LIB += --strip-unneeded +QMAKE_CHK_DIR_EXISTS = test -d +QMAKE_MKDIR = mkdir -p +load(qt_config) diff --git a/mkspecs/unsupported/qws/qnx-641/qplatformdefs.h b/mkspecs/unsupported/qws/qnx-641/qplatformdefs.h new file mode 100644 index 0000000..af04086 --- /dev/null +++ b/mkspecs/unsupported/qws/qnx-641/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../../qnx-g++/qplatformdefs.h" -- cgit v0.12 From 3f18623dd8f26857d9af032c41095818f5346910 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 30 Sep 2009 21:18:23 +0300 Subject: Added QGraphicsWidget::autoFillBackground property. This add a property to QGraphicsWidget to fill its background. QWidget has the same. Merge-Request: 1656 Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsscene.cpp | 2 ++ src/gui/graphicsview/qgraphicswidget.cpp | 30 ++++++++++++++++++++++ src/gui/graphicsview/qgraphicswidget.h | 4 +++ src/gui/graphicsview/qgraphicswidget_p.h | 2 ++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 27 +++++++++++++++++++ 5 files changed, 65 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 8777cdc..82d2e2f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4187,6 +4187,8 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter, widgetItem->paintWindowFrame(painter, option, widget); if (painterStateProtection) painter->restore(); + } else if (widgetItem->autoFillBackground()) { + painter->fillRect(option->exposedRect, widgetItem->palette().window()); } widgetItem->paint(painter, option, widget); diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index fe569f4..1bb6375 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -967,6 +967,36 @@ void QGraphicsWidget::setPalette(const QPalette &palette) } /*! + \property QGraphicsWidget::autoFillBackground + \brief whether the widget background is filled automatically + \since 4.7 + + If enabled, this property will cause Qt to fill the background of the + widget before invoking the paint() method. The color used is defined by the + QPalette::Window color role from the widget's \l{QPalette}{palette}. + + In addition, Windows are always filled with QPalette::Window, unless the + WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set. + + By default, this property is false. + + \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground, +*/ +bool QGraphicsWidget::autoFillBackground() const +{ + Q_D(const QGraphicsWidget); + return d->autoFillBackground; +} +void QGraphicsWidget::setAutoFillBackground(bool enabled) +{ + Q_D(QGraphicsWidget); + if (d->autoFillBackground != enabled) { + d->autoFillBackground = enabled; + update(); + } +} + +/*! If this widget is currently managed by a layout, this function notifies the layout that the widget's size hints have changed and the layout may need to resize and reposition the widget accordingly. diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index 05d3a49..d9723f8 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -82,6 +82,7 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry) + Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground) public: QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); ~QGraphicsWidget(); @@ -103,6 +104,9 @@ public: QPalette palette() const; void setPalette(const QPalette &palette); + bool autoFillBackground() const; + void setAutoFillBackground(bool enabled); + void resize(const QSizeF &size); inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); } QSizeF size() const; diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index eb53649..d2f898e 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -80,6 +80,7 @@ public: inSetGeometry(0), polished(0), inSetPos(0), + autoFillBackground(0), focusPolicy(Qt::NoFocus), focusNext(0), focusPrev(0), @@ -172,6 +173,7 @@ public: quint32 inSetGeometry : 1; quint32 polished: 1; quint32 inSetPos : 1; + quint32 autoFillBackground : 1; // Focus Qt::FocusPolicy focusPolicy; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3303df5..47e21b8 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -163,6 +163,7 @@ private slots: void addChildInpolishEvent(); void polishEvent(); void polishEvent2(); + void autoFillBackground(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2855,6 +2856,32 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::autoFillBackground() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QCOMPARE(widget->autoFillBackground(), false); + widget->setAutoFillBackground(true); + QCOMPARE(widget->autoFillBackground(), true); + + const QColor color(Qt::red); + const QRect rect(0, 0, 1, 1); + + QGraphicsScene scene; + scene.addItem(widget); + widget->setGeometry(rect); + + QPalette palette = widget->palette(); + palette.setColor(QPalette::Window, color); + widget->setPalette(palette); + + QImage image(rect.size(), QImage::Format_RGB32); + QPainter painter; + painter.begin(&image); + scene.render(&painter, rect, rect); + painter.end(); + QCOMPARE(image.pixel(0, 0), color.rgb()); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" -- cgit v0.12 From d6c21efa5b67fc55f9edfa4aabeb48adf68ee131 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 3 Dec 2009 14:35:51 +0100 Subject: Assistant: Encapsulate accesses to help engine. Reviewed-by: kh1 --- tools/assistant/tools/assistant/assistant.pro | 7 +- .../assistant/tools/assistant/bookmarkmanager.cpp | 10 +- tools/assistant/tools/assistant/bookmarkmanager.h | 3 +- tools/assistant/tools/assistant/centralwidget.cpp | 62 +-- tools/assistant/tools/assistant/centralwidget.h | 4 +- tools/assistant/tools/assistant/contentwindow.cpp | 8 +- tools/assistant/tools/assistant/contentwindow.h | 5 +- .../tools/assistant/helpenginewrapper.cpp | 591 +++++++++++++++++++++ .../assistant/tools/assistant/helpenginewrapper.h | 212 ++++++++ tools/assistant/tools/assistant/helpviewer.cpp | 50 +- tools/assistant/tools/assistant/helpviewer.h | 10 +- tools/assistant/tools/assistant/indexwindow.cpp | 16 +- tools/assistant/tools/assistant/indexwindow.h | 4 +- tools/assistant/tools/assistant/main.cpp | 18 +- tools/assistant/tools/assistant/mainwindow.cpp | 330 ++++++------ tools/assistant/tools/assistant/mainwindow.h | 9 +- .../tools/assistant/preferencesdialog.cpp | 104 ++-- .../assistant/tools/assistant/preferencesdialog.h | 14 +- tools/assistant/tools/assistant/qtdocinstaller.cpp | 87 +-- tools/assistant/tools/assistant/qtdocinstaller.h | 23 +- tools/assistant/tools/assistant/remotecontrol.cpp | 43 +- tools/assistant/tools/assistant/remotecontrol.h | 9 +- tools/assistant/tools/assistant/tracer.h | 1 + .../assistant/tools/qcollectiongenerator/main.cpp | 3 +- .../tools/shared/collectionconfiguration.cpp | 281 ++-------- .../tools/shared/collectionconfiguration.h | 92 +--- 26 files changed, 1224 insertions(+), 772 deletions(-) create mode 100644 tools/assistant/tools/assistant/helpenginewrapper.cpp create mode 100644 tools/assistant/tools/assistant/helpenginewrapper.h diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 81677c3..ca2e52e 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -31,7 +31,9 @@ HEADERS += helpviewer.h \ aboutdialog.h \ qtdocinstaller.h \ xbelsupport.h \ - ../shared/collectionconfiguration.h + ../shared/collectionconfiguration.h \ + helpenginewrapper.h \ + tracer.h win32:HEADERS += remotecontrol_win.h SOURCES += helpviewer.cpp \ main.cpp \ @@ -50,7 +52,8 @@ SOURCES += helpviewer.cpp \ aboutdialog.cpp \ qtdocinstaller.cpp \ xbelsupport.cpp \ - ../shared/collectionconfiguration.cpp + ../shared/collectionconfiguration.cpp \ + helpenginewrapper.cpp FORMS += topicchooser.ui \ preferencesdialog.ui \ filternamedialog.ui \ diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index 3c473d7..f8cad4d 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -41,7 +41,7 @@ #include "bookmarkmanager.h" #include "centralwidget.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include #include @@ -57,7 +57,6 @@ #include #include #include -#include #include #include @@ -624,11 +623,10 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const // BookmarkManager -BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine) +BookmarkManager::BookmarkManager() : treeModel(new BookmarkModel(0, 1, this)) , listModel(new BookmarkModel(0, 1, this)) , renameItem(0) - , helpEngine(_helpEngine) { folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png")); @@ -663,7 +661,7 @@ void BookmarkManager::saveBookmarks() QDataStream stream(&bookmarks, QIODevice::WriteOnly); readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0); - CollectionConfiguration::setBookmarks(*helpEngine, bookmarks); + HelpEngineWrapper::instance().setBookmarks(bookmarks); } QStringList BookmarkManager::bookmarkFolders() const @@ -815,7 +813,7 @@ void BookmarkManager::setupBookmarkModels() QList lastDepths; QList parents; - QByteArray ba = CollectionConfiguration::bookmarks(*helpEngine); + QByteArray ba = HelpEngineWrapper::instance().bookmarks(); QDataStream stream(ba); while (!stream.atEnd()) { stream >> depth >> name >> type >> expanded; diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h index c6be134..13d4b5c 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.h +++ b/tools/assistant/tools/assistant/bookmarkmanager.h @@ -168,7 +168,7 @@ class BookmarkManager : public QObject Q_OBJECT public: - BookmarkManager(QHelpEngineCore* helpEngine); + BookmarkManager(); ~BookmarkManager(); BookmarkModel* treeBookmarkModel(); @@ -208,7 +208,6 @@ private: BookmarkModel *treeModel; BookmarkModel *listModel; QStandardItem *renameItem; - QHelpEngineCore *helpEngine; QMap map; }; diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index d1cccc1..df28d63 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "centralwidget.h" +#include "helpenginewrapper.h" #include "helpviewer.h" #include "searchwidget.h" #include "mainwindow.h" @@ -68,7 +69,6 @@ #include #include -#include #include QT_BEGIN_NAMESPACE @@ -206,14 +206,12 @@ QToolButton* FindWidget::setupToolButton(const QString &text, const QString &ico // -- -CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) +CentralWidget::CentralWidget(MainWindow *parent) : QWidget(parent) , lastTabPage(0) - , collectionFile(engine->collectionFile()) , findBar(0) , tabWidget(0) , findWidget(0) - , helpEngine(engine) , printer(0) , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) @@ -293,10 +291,6 @@ CentralWidget::~CentralWidget() delete printer; #endif - QHelpEngineCore engine(collectionFile, 0); - if (!engine.setupData()) - return; - QStringList zoomFactors; QStringList currentPages; bool searchAttached = m_searchWidget->isAttached(); @@ -310,10 +304,11 @@ CentralWidget::~CentralWidget() } } - CollectionConfiguration::setLastTabPage(engine, lastTabPage); - CollectionConfiguration::setLastShownPages(engine, currentPages); - CollectionConfiguration::setSearchWasAttached(engine, searchAttached); - CollectionConfiguration::setLastZoomFactors(engine, zoomFactors); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + helpEngine.setLastTabPage(lastTabPage); + helpEngine.setLastShownPages(currentPages); + helpEngine.setSearchWasAttached(searchAttached); + helpEngine.setLastZoomFactors(zoomFactors); } CentralWidget *CentralWidget::instance() @@ -405,7 +400,7 @@ void CentralWidget::setSource(const QUrl &url) qobject_cast(tabWidget->widget(lastTabPage)); if (!viewer && !lastViewer) { - viewer = new HelpViewer(helpEngine, this); + viewer = new HelpViewer(this); viewer->installEventFilter(this); lastTabPage = tabWidget->addTab(viewer, QString()); tabWidget->setCurrentIndex(lastTabPage); @@ -423,16 +418,13 @@ void CentralWidget::setSource(const QUrl &url) void CentralWidget::setupWidget() { - int option = CollectionConfiguration::startOption(*helpEngine); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + int option = helpEngine.startOption(); if (option != ShowLastPages) { QString homePage; - if (option == ShowHomePage) { - // TODO: Can this fall-back logic go into the wrapper class? - homePage = CollectionConfiguration::homePage(*helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*helpEngine); - } - if (option == ShowBlankPage) + if (option == ShowHomePage) + homePage = helpEngine.homePage(); + else if (option == ShowBlankPage) homePage = QLatin1String("about:blank"); setSource(homePage); } else { @@ -442,8 +434,8 @@ void CentralWidget::setupWidget() void CentralWidget::setLastShownPages() { - const QStringList lastShownPageList = - CollectionConfiguration::lastShownPages(*helpEngine); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + const QStringList lastShownPageList = helpEngine.lastShownPages(); const int pageCount = lastShownPageList.count(); if (pageCount == 0) { if (usesDefaultCollection) @@ -453,8 +445,7 @@ void CentralWidget::setLastShownPages() return; } - QStringList zoomFactors = - CollectionConfiguration::lastZoomFactors(*helpEngine); + QStringList zoomFactors = helpEngine.lastZoomFactors(); while (zoomFactors.count() < pageCount) zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); @@ -463,12 +454,10 @@ void CentralWidget::setLastShownPages() for (; it != lastShownPageList.constEnd(); ++it, ++zIt) setSourceInNewTab((*it), (*zIt).toFloat()); - int tab = CollectionConfiguration::lastTabPage(*helpEngine); + int tab = helpEngine.lastTabPage(); const bool searchIsAttached = m_searchWidget->isAttached(); - const bool searchWasAttached = - CollectionConfiguration::searchWasAttached(*helpEngine); - + const bool searchWasAttached = helpEngine.searchWasAttached(); if (searchWasAttached && !searchIsAttached) --tab; else if (!searchWasAttached && searchIsAttached) @@ -639,7 +628,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) return; #endif - viewer = new HelpViewer(helpEngine, this); + viewer = new HelpViewer(this); viewer->installEventFilter(this); viewer->setSource(url); viewer->setFocus(Qt::OtherFocusReason); @@ -663,7 +652,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) HelpViewer *CentralWidget::newEmptyTab() { - HelpViewer *viewer = new HelpViewer(helpEngine, this); + HelpViewer *viewer = new HelpViewer(this); viewer->installEventFilter(this); viewer->setFocus(Qt::OtherFocusReason); #if defined(QT_NO_WEBKIT) @@ -1005,7 +994,7 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) void CentralWidget::activateSearchWidget(bool updateLastTabPage) { if (!m_searchWidget) - createSearchWidget(helpEngine->searchEngine()); + createSearchWidget(HelpEngineWrapper::instance().searchEngine()); if (!m_searchWidget->isAttached()) { tabWidget->insertTab(0, m_searchWidget, tr("Search")); @@ -1072,7 +1061,8 @@ CentralWidget::highlightSearchTerms() if (!viewer) return; - QHelpSearchEngine *searchEngine = helpEngine->searchEngine(); + QHelpSearchEngine *searchEngine = + HelpEngineWrapper::instance().searchEngine(); QList queryList = searchEngine->query(); QStringList terms; @@ -1154,8 +1144,8 @@ QMap CentralWidget::currentSourceFileList() const void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) { - const QLatin1String key("useBrowserFont"); - if (!CollectionConfiguration::usesBrowserFont(*helpEngine)) { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.usesBrowserFont()) { *font = qApp->font(); // case for QTextBrowser and SearchWidget #if !defined(QT_NO_WEBKIT) QWebView *view = qobject_cast (viewer); @@ -1166,7 +1156,7 @@ void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) } #endif } else { - *font = CollectionConfiguration::browserFont(*helpEngine); + *font = helpEngine.browserFont(); } } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index c348abf..d90968e 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -110,7 +110,7 @@ class CentralWidget : public QWidget Q_OBJECT public: - CentralWidget(QHelpEngine *engine, MainWindow *parent); + CentralWidget(MainWindow *parent); ~CentralWidget(); void setupWidget(); @@ -201,13 +201,11 @@ private: private: int lastTabPage; - QString collectionFile; QList globalActionList; QWidget *findBar; QTabWidget *tabWidget; FindWidget *findWidget; - QHelpEngine *helpEngine; QPrinter *printer; bool usesDefaultCollection; diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 1e3953a..17b19ba 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -41,22 +41,20 @@ #include "contentwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include #include #include -#include #include QT_BEGIN_NAMESPACE -ContentWindow::ContentWindow(QHelpEngine *helpEngine) - : m_helpEngine(helpEngine) - , m_contentWidget(0) +ContentWindow::ContentWindow() + : m_contentWidget(HelpEngineWrapper::instance().contentWidget()) , m_expandDepth(-2) { - m_contentWidget = m_helpEngine->contentWidget(); m_contentWidget->viewport()->installEventFilter(this); m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index e5512f5..6395932 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -57,7 +57,7 @@ class ContentWindow : public QWidget Q_OBJECT public: - ContentWindow(QHelpEngine *helpEngine); + ContentWindow(); ~ContentWindow(); bool syncToContent(const QUrl &url); @@ -78,8 +78,7 @@ private: bool eventFilter(QObject *o, QEvent *e); bool isPdfFile(QHelpContentItem *item) const; - QHelpEngine *m_helpEngine; - QHelpContentWidget *m_contentWidget; + QHelpContentWidget * const m_contentWidget; int m_expandDepth; }; diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp new file mode 100644 index 0000000..d399d1e --- /dev/null +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -0,0 +1,591 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "helpenginewrapper.h" +#include "../shared/collectionconfiguration.h" + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace { + const QString AppFontKey(QLatin1String("appFont")); + const QString AppWritingSystemKey(QLatin1String("appWritingSystem")); + const QString BookmarksKey(QLatin1String("Bookmarks")); + const QString BrowserFontKey(QLatin1String("browserFont")); + const QString BrowserWritingSystemKey(QLatin1String("browserWritingSystem")); + const QString HomePageKey(QLatin1String("homepage")); + const QString MainWindowKey(QLatin1String("MainWindow")); + const QString MainWindowGeometryKey(QLatin1String("MainWindowGeometry")); + const QString SearchWasAttachedKey(QLatin1String("SearchWasAttached")); + const QString StartOptionKey(QLatin1String("StartOption")); + const QString UnfilteredInsertedKey(QLatin1String("UnfilteredFilterInserted")); + const QString UseAppFontKey(QLatin1String("useAppFont")); + const QString UseBrowserFontKey(QLatin1String("useBrowserFont")); + const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")). + arg(QLatin1String(QT_VERSION_STR))); +} // anonymous namespace + +HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; + +HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) +{ + /* + * Note that this Singleton cannot be static, because it has to be + * deleted before the QApplication. + */ + if (helpEngineWrapper == 0) + helpEngineWrapper = new HelpEngineWrapper(collectionFile); + return *helpEngineWrapper; +} + +void HelpEngineWrapper::removeInstance() +{ + delete helpEngineWrapper; + helpEngineWrapper = 0; +} + +HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) + : m_helpEngine(new QHelpEngine(collectionFile, this)), + m_qchWatcher(new QFileSystemWatcher(this)) +{ + connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), + this, SIGNAL(currentFilterChanged(QString))); + connect(m_helpEngine, SIGNAL(setupFinished()), + this, SIGNAL(setupFinished())); +} + +void HelpEngineWrapper::initFileSystemWatchers() +{ + foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { + const QString &docFile = m_helpEngine->documentationFileName(ns); + m_qchWatcher->addPath(docFile); + connect(m_qchWatcher, SIGNAL(fileChanged(QString)), + this, SLOT(qchFileChanged(QString))); + } + assertDocFilesWatched(); +} + +QHelpSearchEngine *HelpEngineWrapper::searchEngine() const +{ + return m_helpEngine->searchEngine(); +} + +QHelpContentModel *HelpEngineWrapper::contentModel() const +{ + return m_helpEngine->contentModel(); +} + +QHelpIndexModel *HelpEngineWrapper::indexModel() const +{ + return m_helpEngine->indexModel(); +} + +QHelpContentWidget *HelpEngineWrapper::contentWidget() +{ + return m_helpEngine->contentWidget(); +} + +QHelpIndexWidget *HelpEngineWrapper::indexWidget() +{ + return m_helpEngine->indexWidget(); +} + +const QStringList HelpEngineWrapper::registeredDocumentations() const +{ + return m_helpEngine->registeredDocumentations(); +} + +const QString HelpEngineWrapper::collectionFile() const +{ + return m_helpEngine->collectionFile(); +} + +bool HelpEngineWrapper::registerDocumentation(const QString &docFile) +{ + if (!m_helpEngine->registerDocumentation(docFile)) + return false; + m_qchWatcher->addPath(docFile); + assertDocFilesWatched(); + return true; +} + +bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) +{ + const QString &internalFile = + m_helpEngine->documentationFileName(namespaceName); + if (!m_helpEngine->unregisterDocumentation(namespaceName)) + return false; + m_qchWatcher->removePath(internalFile); + assertDocFilesWatched(); + return true; +} + +bool HelpEngineWrapper::setupData() +{ + return m_helpEngine->setupData(); +} + +bool HelpEngineWrapper::addCustomFilter(const QString &filterName, + const QStringList &attributes) +{ + return m_helpEngine->addCustomFilter(filterName, attributes); +} + +bool HelpEngineWrapper::removeCustomFilter(const QString &filterName) +{ + return m_helpEngine->removeCustomFilter(filterName); +} + +void HelpEngineWrapper::setCurrentFilter(const QString ¤tFilter) +{ + m_helpEngine->setCurrentFilter(currentFilter); +} + +const QString HelpEngineWrapper::currentFilter() const +{ + return m_helpEngine->currentFilter(); +} + +const QStringList HelpEngineWrapper::customFilters() const +{ + return m_helpEngine->customFilters(); +} + +QUrl HelpEngineWrapper::findFile(const QUrl &url) const +{ + return m_helpEngine->findFile(url); +} + +QByteArray HelpEngineWrapper::fileData(const QUrl &url) const +{ + return m_helpEngine->fileData(url); +} + +QMap HelpEngineWrapper::linksForIdentifier(const QString &id) const +{ + return m_helpEngine->linksForIdentifier(id); +} + +const QStringList HelpEngineWrapper::filterAttributes() const +{ + return m_helpEngine->filterAttributes(); +} + +const QStringList HelpEngineWrapper::filterAttributes(const QString &filterName) const +{ + return m_helpEngine->filterAttributes(filterName); +} + +QString HelpEngineWrapper::error() const +{ + return m_helpEngine->error(); +} + +bool HelpEngineWrapper::unfilteredInserted() const +{ + return m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; +} + +void HelpEngineWrapper::setUnfilteredInserted() +{ + m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); +} + +const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const +{ + return m_helpEngine->customValue(VersionKey.arg(component)).toString(). + split(CollectionConfiguration::ListSeparator); +} + +void HelpEngineWrapper::setQtDocInfo(const QString &component, + const QStringList &doc) +{ + m_helpEngine->setCustomValue(VersionKey.arg(component), + doc.join(CollectionConfiguration::ListSeparator)); +} + +const QStringList HelpEngineWrapper::lastShownPages() const +{ + return CollectionConfiguration::lastShownPages(*m_helpEngine); +} + +void HelpEngineWrapper::setLastShownPages(const QStringList &lastShownPages) +{ + CollectionConfiguration::setLastShownPages(*m_helpEngine, lastShownPages); +} + +const QStringList HelpEngineWrapper::lastZoomFactors() const +{ + return CollectionConfiguration::lastZoomFactors(*m_helpEngine); +} + +void HelpEngineWrapper::setLastZoomFactors(const QStringList &lastZoomFactors) +{ + CollectionConfiguration::setLastZoomFactors(*m_helpEngine, lastZoomFactors); +} + +const QString HelpEngineWrapper::cacheDir() const +{ + return CollectionConfiguration::cacheDir(*m_helpEngine); +} + +bool HelpEngineWrapper::cacheDirIsRelativeToCollection() const +{ + return CollectionConfiguration::cacheDirIsRelativeToCollection(*m_helpEngine); +} + +void HelpEngineWrapper::setCacheDir(const QString &cacheDir, + bool relativeToCollection) +{ + CollectionConfiguration::setCacheDir(*m_helpEngine, cacheDir, + relativeToCollection); +} + +bool HelpEngineWrapper::filterFunctionalityEnabled() const +{ + return CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setFilterFunctionalityEnabled(bool enabled) +{ + CollectionConfiguration::setFilterFunctionalityEnabled(*m_helpEngine, + enabled); +} + +bool HelpEngineWrapper::filterToolbarVisible() const +{ + return CollectionConfiguration::filterToolbarVisible(*m_helpEngine); +} + +void HelpEngineWrapper::setFilterToolbarVisible(bool visible) +{ + CollectionConfiguration::setFilterToolbarVisible(*m_helpEngine, visible); +} + +bool HelpEngineWrapper::addressBarEnabled() const +{ + return CollectionConfiguration::addressBarEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setAddressBarEnabled(bool enabled) +{ + CollectionConfiguration::setAddressBarEnabled(*m_helpEngine, enabled); +} + +bool HelpEngineWrapper::addressBarVisible() const +{ + return CollectionConfiguration::addressBarVisible(*m_helpEngine); +} + +void HelpEngineWrapper::setAddressBarVisible(bool visible) +{ + CollectionConfiguration::setAddressBarVisible(*m_helpEngine, visible); +} + +bool HelpEngineWrapper::documentationManagerEnabled() const +{ + return CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); +} + +void HelpEngineWrapper::setDocumentationManagerEnabled(bool enabled) +{ + CollectionConfiguration::setDocumentationManagerEnabled(*m_helpEngine, + enabled); +} + +const QByteArray HelpEngineWrapper::aboutMenuTexts() const +{ + return CollectionConfiguration::aboutMenuTexts(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutMenuTexts(const QByteArray &texts) +{ + CollectionConfiguration::setAboutMenuTexts(*m_helpEngine, texts); +} + +const QByteArray HelpEngineWrapper::aboutIcon() const +{ + return CollectionConfiguration::aboutIcon(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutIcon(const QByteArray &icon) +{ + CollectionConfiguration::setAboutIcon(*m_helpEngine, icon); +} + +const QByteArray HelpEngineWrapper::aboutImages() const +{ + return CollectionConfiguration::aboutImages(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutImages(const QByteArray &images) +{ + CollectionConfiguration::setAboutImages(*m_helpEngine, images); +} + +const QByteArray HelpEngineWrapper::aboutTexts() const +{ + return CollectionConfiguration::aboutTexts(*m_helpEngine); +} + +void HelpEngineWrapper::setAboutTexts(const QByteArray &texts) +{ + CollectionConfiguration::setAboutTexts(*m_helpEngine, texts); +} + +const QString HelpEngineWrapper::windowTitle() const +{ + return CollectionConfiguration::windowTitle(*m_helpEngine); +} + +void HelpEngineWrapper::setWindowTitle(const QString &windowTitle) +{ + CollectionConfiguration::setWindowTitle(*m_helpEngine, windowTitle); +} + +const QByteArray HelpEngineWrapper::applicationIcon() const +{ + return CollectionConfiguration::applicationIcon(*m_helpEngine); +} + +void HelpEngineWrapper::setApplicationIcon(const QByteArray &icon) +{ + CollectionConfiguration::setApplicationIcon(*m_helpEngine, icon); +} + +const QByteArray HelpEngineWrapper::mainWindow() const +{ + return m_helpEngine->customValue(MainWindowKey).toByteArray(); +} + +void HelpEngineWrapper::setMainWindow(const QByteArray &mainWindow) +{ + m_helpEngine->setCustomValue(MainWindowKey, mainWindow); +} + +const QByteArray HelpEngineWrapper::mainWindowGeometry() const +{ + return m_helpEngine->customValue(MainWindowGeometryKey).toByteArray(); +} + +void HelpEngineWrapper::setMainWindowGeometry(const QByteArray &geometry) +{ + m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry); +} + +const QByteArray HelpEngineWrapper::bookmarks() const +{ + return m_helpEngine->customValue(BookmarksKey).toByteArray(); +} + +void HelpEngineWrapper::setBookmarks(const QByteArray &bookmarks) +{ + m_helpEngine->setCustomValue(BookmarksKey, bookmarks); +} + +int HelpEngineWrapper::lastTabPage() const +{ + return CollectionConfiguration::lastTabPage(*m_helpEngine); +} + +void HelpEngineWrapper::setLastTabPage(int lastPage) +{ + CollectionConfiguration::setLastTabPage(*m_helpEngine, lastPage); +} + +bool HelpEngineWrapper::searchWasAttached() const +{ + return m_helpEngine->customValue(SearchWasAttachedKey).toBool(); +} + +void HelpEngineWrapper::setSearchWasAttached(bool attached) +{ + m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); +} + +int HelpEngineWrapper::startOption() const +{ + return m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt(); +} + +void HelpEngineWrapper::setStartOption(int option) +{ + m_helpEngine->setCustomValue(StartOptionKey, option); +} + +const QString HelpEngineWrapper::homePage() const +{ + const QString &homePage = m_helpEngine->customValue(HomePageKey).toString(); + if (!homePage.isEmpty()) + return homePage; + return defaultHomePage(); +} + +void HelpEngineWrapper::setHomePage(const QString &page) +{ + m_helpEngine->setCustomValue(HomePageKey, page); + +} + +const QString HelpEngineWrapper::defaultHomePage() const +{ + return CollectionConfiguration::defaultHomePage(*m_helpEngine); +} + +void HelpEngineWrapper::setDefaultHomePage(const QString &page) +{ + CollectionConfiguration::setDefaultHomePage(*m_helpEngine, page); +} + +bool HelpEngineWrapper::hasFontSettings() const +{ + return m_helpEngine->customValue(UseAppFontKey).isValid(); +} + +bool HelpEngineWrapper::usesAppFont() const +{ + return m_helpEngine->customValue(UseAppFontKey).toBool(); +} + +void HelpEngineWrapper::setUseAppFont(bool useAppFont) +{ + m_helpEngine->setCustomValue(UseAppFontKey, useAppFont); +} + +bool HelpEngineWrapper::usesBrowserFont() const +{ + return m_helpEngine->customValue(UseBrowserFontKey, false).toBool(); +} + +void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) +{ + m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont); +} + +const QFont HelpEngineWrapper::appFont() const +{ + return qVariantValue(m_helpEngine->customValue(AppFontKey)); +} + +void HelpEngineWrapper::setAppFont(const QFont &font) +{ + m_helpEngine->setCustomValue(AppFontKey, font); +} + +QFontDatabase::WritingSystem HelpEngineWrapper::appWritingSystem() const +{ + return static_cast( + m_helpEngine->customValue(AppWritingSystemKey).toInt()); +} + +void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) +{ + m_helpEngine->setCustomValue(AppWritingSystemKey, system); +} + +const QFont HelpEngineWrapper::browserFont() const +{ + return qVariantValue(m_helpEngine->customValue(BrowserFontKey)); +} + +void HelpEngineWrapper::setBrowserFont(const QFont &font) +{ + m_helpEngine->setCustomValue(BrowserFontKey, font); +} + +QFontDatabase::WritingSystem HelpEngineWrapper::browserWritingSystem() const +{ + return static_cast( + m_helpEngine->customValue(BrowserWritingSystemKey).toInt()); +} + +void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem system) +{ + m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); +} + + +void HelpEngineWrapper::assertDocFilesWatched() +{ + Q_ASSERT(m_qchWatcher->files().count() + == m_helpEngine->registeredDocumentations().count()); +} + +void HelpEngineWrapper::qchFileChanged(const QString &fileName) +{ + /* + * We don't use QHelpEngineCore::namespaceName(fileName), because the file + * may not exist anymore or contain a different namespace. + */ + QString ns; + foreach (const QString &curNs, m_helpEngine->registeredDocumentations()) { + if (m_helpEngine->documentationFileName(curNs) == fileName) { + ns = curNs; + break; + } + } + + /* + * We can't do an assertion here, because QFileSystemWatcher may send the + * signal more than once. + */ + if (ns.isEmpty()) + return; + + if (m_helpEngine->unregisterDocumentation(ns)) { + if (!QFileInfo(fileName).exists() + || !m_helpEngine->registerDocumentation(fileName)) { + m_qchWatcher->removePath(fileName); + emit documentationRemoved(ns); + } else { + emit documentationUpdated(ns); + } + m_helpEngine->setupData(); + } +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h new file mode 100644 index 0000000..1fc9eb6 --- /dev/null +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HELPENGINEWRAPPER_H +#define HELPENGINEWRAPPER_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QFileSystemWatcher; +class QHelpContentModel; +class QHelpContentWidget; +class QHelpEngine; +class QHelpEngineCore; +class QHelpIndexModel; +class QHelpIndexWidget; +class QHelpSearchEngine; + +enum { + ShowHomePage = 0, + ShowBlankPage = 1, + ShowLastPages = 2 +}; + +class HelpEngineWrapper : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(HelpEngineWrapper) +public: + static HelpEngineWrapper &instance(const QString &collectionFile = QString()); + static void removeInstance(); + + void initFileSystemWatchers(); + + // Forwarded help engine member functions, possibly enriched. + QHelpSearchEngine *searchEngine() const; + QHelpContentModel *contentModel() const; + QHelpIndexModel *indexModel() const; + QHelpContentWidget *contentWidget(); + QHelpIndexWidget *indexWidget(); + bool setupData(); + const QStringList registeredDocumentations() const; + const QString collectionFile() const; + bool registerDocumentation(const QString &docFile); + bool unregisterDocumentation(const QString &namespaceName); + bool addCustomFilter(const QString &filterName, + const QStringList &attributes); + bool removeCustomFilter(const QString &filterName); + void setCurrentFilter(const QString &filterName); + const QString currentFilter() const; + const QStringList customFilters() const; + QUrl findFile(const QUrl &url) const; + QByteArray fileData(const QUrl &url) const; + QMap linksForIdentifier(const QString &id) const; + const QStringList filterAttributes() const; + const QStringList filterAttributes(const QString &filterName) const; + QString error() const; + + // Access to a collection's custom values. + bool unfilteredInserted() const; + void setUnfilteredInserted(); + + const QStringList qtDocInfo(const QString &component) const; + void setQtDocInfo(const QString &component, const QStringList &doc); + + const QString homePage() const; + void setHomePage(const QString &page); + const QString defaultHomePage() const; + void setDefaultHomePage(const QString &page); + + int lastTabPage() const; + void setLastTabPage(int lastPage); + + // TODO: Don't allow last pages and zoom factors to be set in isolation + // Perhaps also fill up missing elements automatically or assert. + const QStringList lastShownPages() const; + void setLastShownPages(const QStringList &lastShownPages); + const QStringList lastZoomFactors() const; + void setLastZoomFactors(const QStringList &lastZoomFactors); + + const QString cacheDir() const; + bool cacheDirIsRelativeToCollection() const; + void setCacheDir(const QString &cacheDir, bool relativeToCollection); + + bool filterFunctionalityEnabled() const; + void setFilterFunctionalityEnabled(bool enabled); + + bool filterToolbarVisible() const; + void setFilterToolbarVisible(bool visible); + + bool addressBarEnabled() const; + void setAddressBarEnabled(bool enabled); + + bool addressBarVisible() const; + void setAddressBarVisible(bool visible); + + bool documentationManagerEnabled() const; + void setDocumentationManagerEnabled(bool enabled); + + const QByteArray aboutMenuTexts() const; + void setAboutMenuTexts(const QByteArray &texts); + const QByteArray aboutTexts() const; + void setAboutTexts(const QByteArray &texts); + const QByteArray aboutIcon() const; + void setAboutIcon(const QByteArray &icon); + const QByteArray aboutImages() const; + void setAboutImages(const QByteArray &images); + + const QString windowTitle() const; + void setWindowTitle(const QString &windowTitle); + + const QByteArray applicationIcon() const; + void setApplicationIcon(const QByteArray &icon); + + const QByteArray mainWindow() const; + void setMainWindow(const QByteArray &mainWindow); + const QByteArray mainWindowGeometry() const; + void setMainWindowGeometry(const QByteArray &geometry); + + const QByteArray bookmarks() const; + void setBookmarks(const QByteArray &bookmarks); + + int startOption() const; + void setStartOption(int option); + + bool searchWasAttached() const; + void setSearchWasAttached(bool attached); + + bool hasFontSettings() const; + bool usesAppFont() const; + void setUseAppFont(bool useAppFont); + bool usesBrowserFont() const; + void setUseBrowserFont(bool useBrowserFont); + const QFont appFont() const; + void setAppFont(const QFont &font); + QFontDatabase::WritingSystem appWritingSystem() const; + void setAppWritingSystem(QFontDatabase::WritingSystem system); + const QFont browserFont() const; + void setBrowserFont(const QFont &font); + QFontDatabase::WritingSystem browserWritingSystem() const; + void setBrowserWritingSystem(QFontDatabase::WritingSystem system); + +signals: + + // For asynchronous doc updates triggered by external actions. + void documentationRemoved(const QString &namespaceName); + void documentationUpdated(const QString &namespaceName); + + // Forwarded from QHelpEngineCore. + void currentFilterChanged(const QString ¤tFilter); + void setupFinished(); + +private slots: + void qchFileChanged(const QString &fileName); + +private: + HelpEngineWrapper(const QString &collectionFile); + void assertDocFilesWatched(); + + static HelpEngineWrapper *helpEngineWrapper; + QHelpEngine * const m_helpEngine; + QFileSystemWatcher * const m_qchWatcher; +}; + +QT_END_NAMESPACE + +#endif // HELPENGINEWRAPPER_H diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 2756753..5f2c02b 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -41,7 +41,7 @@ #include "helpviewer.h" #include "centralwidget.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include #include @@ -56,8 +56,6 @@ #include #include -#include - #include #include #include @@ -124,19 +122,15 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) class HelpNetworkAccessManager : public QNetworkAccessManager { public: - HelpNetworkAccessManager(QHelpEngine *engine, QObject *parent); + HelpNetworkAccessManager(QObject *parent); protected: virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0); - -private: - QHelpEngine *helpEngine; }; -HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine, - QObject *parent) - : QNetworkAccessManager(parent), helpEngine(engine) +HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent) + : QNetworkAccessManager(parent) { } @@ -158,8 +152,9 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, mimeType = QLatin1String("text/html"); } - const QByteArray &data = helpEngine->findFile(url).isValid() - ? helpEngine->fileData(url) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + const QByteArray &data = helpEngine.findFile(url).isValid() + ? helpEngine.fileData(url) : PageNotFoundMessage.arg(url.toString()).toUtf8(); return new HelpNetworkReply(request, data, mimeType); } @@ -167,7 +162,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, class HelpPage : public QWebPage { public: - HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent); + HelpPage(CentralWidget *central, QObject *parent); protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); @@ -178,7 +173,6 @@ protected: private: CentralWidget *centralWidget; - QHelpEngine *helpEngine; bool closeNewTabIfNeeded; friend class HelpViewer; @@ -186,10 +180,9 @@ private: Qt::KeyboardModifiers m_keyboardModifiers; }; -HelpPage::HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent) +HelpPage::HelpPage(CentralWidget *central, QObject *parent) : QWebPage(parent) , centralWidget(central) - , helpEngine(engine) , closeNewTabIfNeeded(false) , m_pressedButtons(Qt::NoButton) , m_keyboardModifiers(Qt::NoModifier) @@ -248,7 +241,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { - tmpFile.write(helpEngine->fileData(url)); + tmpFile.write(HelpEngineWrapper::instance().fileData(url)); tmpFile.close(); } QDesktopServices::openUrl(QUrl(tmpFile.fileName())); @@ -275,17 +268,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, return false; } -HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) +HelpViewer::HelpViewer(CentralWidget *parent) : QWebView(parent) - , helpEngine(engine) , parentWidget(parent) , loadFinished(false) + , helpEngine(HelpEngineWrapper::instance()) { setAcceptDrops(false); - setPage(new HelpPage(parent, helpEngine, this)); + setPage(new HelpPage(parent, this)); - page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this)); + page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); action->setText(tr("Open Link in New Tab")); @@ -392,13 +385,13 @@ void HelpViewer::setLoadFinished(bool ok) #else // !defined(QT_NO_WEBKIT) -HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) +HelpViewer::HelpViewer(CentralWidget *parent) : QTextBrowser(parent) , zoomCount(0) , controlPressed(false) , lastAnchor(QString()) - , helpEngine(engine) , parentWidget(parent) + , helpEngine(HelpEngineWrapper::instance()) { document()->setDocumentMargin(8); } @@ -410,7 +403,7 @@ void HelpViewer::setSource(const QUrl &url) if (launchedWithExternalApp(url)) return; - QUrl u = helpEngine->findFile(url); + QUrl u = helpEngine.findFile(url); if (u.isValid()) { QTextBrowser::setSource(u); return; @@ -472,7 +465,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url) QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { - tmpFile.write(helpEngine->fileData(url)); + tmpFile.write(helpEngine.fileData(url)); tmpFile.close(); } launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName())); @@ -493,7 +486,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name) { QByteArray ba; if (type < 4) { - ba = helpEngine->fileData(name); + ba = helpEngine.fileData(name); if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { QImage image; image.loadFromData(ba, "svg"); @@ -606,10 +599,7 @@ void HelpViewer::wheelEvent(QWheelEvent *e) void HelpViewer::home() { - QString homePage = CollectionConfiguration::homePage(*helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*helpEngine); - setSource(homePage); + setSource(helpEngine.homePage()); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 350209b..64742b5 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -53,8 +53,8 @@ QT_BEGIN_NAMESPACE -class QHelpEngine; class CentralWidget; +class HelpEngineWrapper; class QPoint; class QString; @@ -69,7 +69,7 @@ class HelpViewer : public QWebView Q_OBJECT public: - HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent); + HelpViewer(CentralWidget *parent); void setSource(const QUrl &url); inline QUrl source() const @@ -118,9 +118,9 @@ private Q_SLOTS: void setLoadFinished(bool ok); private: - QHelpEngine *helpEngine; CentralWidget* parentWidget; bool loadFinished; + HelpEngineWrapper &helpEngine; }; #else @@ -130,7 +130,7 @@ class HelpViewer : public QTextBrowser Q_OBJECT public: - HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent); + HelpViewer(CentralWidget *parent); void setSource(const QUrl &url); void resetZoom(); @@ -165,8 +165,8 @@ private: int zoomCount; bool controlPressed; QString lastAnchor; - QHelpEngine *helpEngine; CentralWidget* parentWidget; + HelpEngineWrapper &helpEngine; }; #endif diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 6d35649..757a641 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -41,6 +41,7 @@ #include "indexwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include "topicchooser.h" #include @@ -51,22 +52,19 @@ #include #include -#include #include QT_BEGIN_NAMESPACE -IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent) +IndexWindow::IndexWindow(QWidget *parent) : QWidget(parent) - , m_searchLineEdit(0) - , m_indexWidget(0) - , m_helpEngine(helpEngine) + , m_searchLineEdit(new QLineEdit) + , m_indexWidget(HelpEngineWrapper::instance().indexWidget()) { QVBoxLayout *layout = new QVBoxLayout(this); QLabel *l = new QLabel(tr("&Look for:")); layout->addWidget(l); - m_searchLineEdit = new QLineEdit(); l->setBuddy(m_searchLineEdit); connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterIndices(QString))); @@ -74,11 +72,11 @@ IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent) layout->setMargin(4); layout->addWidget(m_searchLineEdit); - m_indexWidget = m_helpEngine->indexWidget(); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); m_indexWidget->installEventFilter(this); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreationStarted()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreationStarted()), this, SLOT(disableSearchLineEdit())); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(enableSearchLineEdit())); connect(m_indexWidget, SIGNAL(linkActivated(QUrl,QString)), this, SIGNAL(linkActivated(QUrl))); diff --git a/tools/assistant/tools/assistant/indexwindow.h b/tools/assistant/tools/assistant/indexwindow.h index 5973e43..6fbb250 100644 --- a/tools/assistant/tools/assistant/indexwindow.h +++ b/tools/assistant/tools/assistant/indexwindow.h @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE class QHelpIndexWidget; -class QHelpEngine; class QModelIndex; class IndexWindow : public QWidget @@ -57,7 +56,7 @@ class IndexWindow : public QWidget Q_OBJECT public: - IndexWindow(QHelpEngine *helpEngine, QWidget *parent = 0); + IndexWindow(QWidget *parent = 0); ~IndexWindow(); void setSearchLineEditText(const QString &text); @@ -84,7 +83,6 @@ private: QLineEdit *m_searchLineEdit; QHelpIndexWidget *m_indexWidget; - QHelpEngine *m_helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index ab7168c..4d93a41 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -57,9 +57,12 @@ #include #include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include "mainwindow.h" #include "cmdlineparser.h" +// #define TRACING_REQUESTED + QT_USE_NAMESPACE #if defined(USE_STATIC_SQLITE_PLUGIN) @@ -317,8 +320,17 @@ int main(int argc, char *argv[]) qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir); a.installTranslator(&qtHelpTranslator); - MainWindow w(&cmd); - w.show(); + /* + * We need to be careful here: The main window has to be deleted before + * the help engine wrapper, which has to be deleted before the + * QApplication. + */ + int retval; + MainWindow *w = new MainWindow(&cmd); + w->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - return a.exec(); + retval = a.exec(); + delete w; + delete &HelpEngineWrapper::instance(); + return retval; } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2760f1e..226ad51 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -47,18 +47,22 @@ #include "contentwindow.h" #include "preferencesdialog.h" #include "bookmarkmanager.h" +#include "helpenginewrapper.h" #include "remotecontrol.h" #include "cmdlineparser.h" #include "aboutdialog.h" #include "searchwidget.h" #include "qtdocinstaller.h" #include "xbelsupport.h" -#include "../shared/collectionconfiguration.h" + +// #define TRACING_REQUESTED #include #include +#include #include #include +#include #include #include #include @@ -81,7 +85,7 @@ #include #include -#include +#include #include #include #include @@ -95,29 +99,31 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) , m_cmdLine(cmdLine) , m_progressWidget(0) , m_qtDocInstaller(0) - , m_qchWatcher(new QFileSystemWatcher(this)) , m_connectedInitSignals(false) { + setToolButtonStyle(Qt::ToolButtonFollowStyle); + QString collectionFile; if (usesDefaultCollection()) { MainWindow::collectionFileDirectory(true); - m_helpEngine = new QHelpEngine(MainWindow::defaultHelpCollectionFileName(), - this); + collectionFile = MainWindow::defaultHelpCollectionFileName(); } else { - m_helpEngine = new QHelpEngine(cmdLine->collectionFile(), this); + collectionFile = cmdLine->collectionFile(); } + HelpEngineWrapper &helpEngineWrapper = + HelpEngineWrapper::instance(collectionFile); - m_centralWidget = new CentralWidget(m_helpEngine, this); + m_centralWidget = new CentralWidget(this); setCentralWidget(m_centralWidget); - m_indexWindow = new IndexWindow(m_helpEngine); + m_indexWindow = new IndexWindow(this); QDockWidget *indexDock = new QDockWidget(tr("Index"), this); indexDock->setObjectName(QLatin1String("IndexWindow")); indexDock->setWidget(m_indexWindow); addDockWidget(Qt::LeftDockWidgetArea, indexDock); - m_contentWindow = new ContentWindow(m_helpEngine); + m_contentWindow = new ContentWindow; QDockWidget *contentDock = new QDockWidget(tr("Contents"), this); contentDock->setObjectName(QLatin1String("ContentWindow")); contentDock->setWidget(m_contentWindow); @@ -128,7 +134,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) bookmarkDock->setWidget(setupBookmarkWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); - QHelpSearchEngine *searchEngine = m_helpEngine->searchEngine(); + QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); @@ -153,11 +159,9 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) connect(m_bookmarkManager, SIGNAL(bookmarksChanged()), this, SLOT(updateBookmarkMenu())); - const QString windowTitle = - CollectionConfiguration::windowTitle(*m_helpEngine); + const QString windowTitle = helpEngineWrapper.windowTitle(); setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); - QByteArray iconArray = - CollectionConfiguration::applicationIcon(*m_helpEngine); + QByteArray iconArray = helpEngineWrapper.applicationIcon(); if (iconArray.size() > 0) { QPixmap pix; pix.loadFromData(iconArray); @@ -171,11 +175,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) // Show the widget here, otherwise the restore geometry and state won't work // on x11. show(); - QByteArray ba(CollectionConfiguration::mainWindow(*m_helpEngine)); + QByteArray ba(helpEngineWrapper.mainWindow()); if (!ba.isEmpty()) restoreState(ba); - ba = CollectionConfiguration::mainWindowGeometry(*m_helpEngine); + ba = helpEngineWrapper.mainWindowGeometry(); if (!ba.isEmpty()) { restoreGeometry(ba); } else { @@ -185,15 +189,13 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) resize(QSize(800, 600)); } - if (!CollectionConfiguration::hasFontSettings(*m_helpEngine)) { - CollectionConfiguration::setUseAppFont(*m_helpEngine, false); - CollectionConfiguration::setUseBrowserFont(*m_helpEngine, false); - CollectionConfiguration::setAppFont(*m_helpEngine, qApp->font()); - CollectionConfiguration::setAppWritingSystem(*m_helpEngine, - QFontDatabase::Latin); - CollectionConfiguration::setBrowserFont(*m_helpEngine, qApp->font()); - CollectionConfiguration::setBrowserWritingSystem(*m_helpEngine, - QFontDatabase::Latin); + if (!helpEngineWrapper.hasFontSettings()) { + helpEngineWrapper.setUseAppFont(false); + helpEngineWrapper.setUseBrowserFont(false); + helpEngineWrapper.setAppFont(qApp->font()); + helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); + helpEngineWrapper.setBrowserFont(qApp->font()); + helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); } else { updateApplicationFont(); } @@ -202,7 +204,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) QTimer::singleShot(0, this, SLOT(insertLastPages())); if (m_cmdLine->enableRemoteControl()) - (void)new RemoteControl(this, m_helpEngine, m_qchWatcher); + (void)new RemoteControl(this); if (m_cmdLine->contents() == CmdLineParser::Show) showContents(); @@ -233,8 +235,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); - if (m_helpEngine->customFilters().contains(curFilter)) - m_helpEngine->setCurrentFilter(curFilter); + if (helpEngineWrapper.customFilters().contains(curFilter)) + helpEngineWrapper.setCurrentFilter(curFilter); } if (usesDefaultCollection()) @@ -242,12 +244,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) else checkInitState(); - foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { - const QString &docFile = m_helpEngine->documentationFileName(ns); - m_qchWatcher->addPath(docFile); - connect(m_qchWatcher, SIGNAL(fileChanged(QString)), this, - SLOT(qchFileChanged(QString))); - } + helpEngineWrapper.initFileSystemWatchers(); + connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), + this, SLOT(documentationRemoved(QString))); + connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), + this, SLOT(documentationUpdated(QString))); } setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); } @@ -266,21 +267,20 @@ bool MainWindow::usesDefaultCollection() const void MainWindow::closeEvent(QCloseEvent *e) { m_bookmarkManager->saveBookmarks(); - CollectionConfiguration::setMainWindow(*m_helpEngine, saveState()); - CollectionConfiguration::setMainWindowGeometry(*m_helpEngine, - saveGeometry()); - + HelpEngineWrapper::instance().setMainWindow(saveState()); + HelpEngineWrapper::instance().setMainWindowGeometry(saveGeometry()); QMainWindow::closeEvent(e); } bool MainWindow::initHelpDB() { - if (!m_helpEngine->setupData()) + HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(); + if (!helpEngineWrapper.setupData()) return false; bool assistantInternalDocRegistered = false; QString intern(QLatin1String("com.trolltech.com.assistantinternal-")); - foreach (const QString &ns, m_helpEngine->registeredDocumentations()) { + foreach (const QString &ns, helpEngineWrapper.registeredDocumentations()) { if (ns.startsWith(intern)) { intern = ns; assistantInternalDocRegistered = true; @@ -288,8 +288,7 @@ bool MainWindow::initHelpDB() } } - const QString &collectionFile = m_helpEngine->collectionFile(); - + const QString &collectionFile = helpEngineWrapper.collectionFile(); QFileInfo fi(collectionFile); QString helpFile; QTextStream(&helpFile) << fi.absolutePath() << QDir::separator() @@ -306,62 +305,52 @@ bool MainWindow::initHelpDB() file.close(); } - QHelpEngineCore hc(fi.absoluteFilePath()); - hc.setupData(); - const QString internalFile = hc.documentationFileName(intern); - if (hc.unregisterDocumentation(intern)) - m_qchWatcher->removePath(internalFile); - if (hc.registerDocumentation(helpFile)) - m_qchWatcher->addPath(helpFile); + helpEngineWrapper.unregisterDocumentation(intern); + helpEngineWrapper.registerDocumentation(helpFile); needsSetup = true; } - if (!CollectionConfiguration::unfilteredInserted(*m_helpEngine)) { - { - QHelpEngineCore hc(collectionFile); - hc.setupData(); - hc.addCustomFilter(tr("Unfiltered"), QStringList()); - CollectionConfiguration::setUnfilteredInserted(hc); - } - - m_helpEngine->blockSignals(true); - m_helpEngine->setCurrentFilter(tr("Unfiltered")); - m_helpEngine->blockSignals(false); + if (!helpEngineWrapper.unfilteredInserted()) { + helpEngineWrapper.addCustomFilter(tr("Unfiltered"), QStringList()); + helpEngineWrapper.setUnfilteredInserted(); + helpEngineWrapper.setCurrentFilter(tr("Unfiltered")); needsSetup = true; } - if (needsSetup) { - m_helpEngine->setupData(); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); - } + if (needsSetup) + helpEngineWrapper.setupData(); return true; } void MainWindow::lookForNewQtDocumentation() { - m_qtDocInstaller = - new QtDocInstaller(m_helpEngine->collectionFile(), m_qchWatcher); - connect(m_qtDocInstaller, SIGNAL(errorMessage(QString)), this, - SLOT(displayInstallationError(QString))); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + QStringList docs; + docs << QLatin1String("assistant") + << QLatin1String("designer") + << QLatin1String("linguist") + << QLatin1String("qmake") + << QLatin1String("qt"); + QList qtDocInfos; + foreach (const QString &doc, docs) + qtDocInfos.append(QtDocInstaller::DocInfo(doc, helpEngine.qtDocInfo(doc))); + + m_qtDocInstaller = new QtDocInstaller(qtDocInfos); connect(m_qtDocInstaller, SIGNAL(docsInstalled(bool)), this, SLOT(qtDocumentationInstalled(bool))); - - if (CollectionConfiguration::qtDocInfo(*m_helpEngine, QLatin1String("qt")). - count() != 2) + connect(m_qtDocInstaller, SIGNAL(qchFileNotFound(QString)), this, + SLOT(resetQtDocInfo(QString))); + connect(m_qtDocInstaller, SIGNAL(registerDocumentation(QString, QString)), + this, SLOT(registerDocumentation(QString, QString))); + if (helpEngine.qtDocInfo(QLatin1String("qt")).count() != 2) statusBar()->showMessage(tr("Looking for Qt Documentation...")); m_qtDocInstaller->installDocs(); } -void MainWindow::displayInstallationError(const QString &errorMessage) -{ - QMessageBox::warning(this, tr("Qt Assistant"), errorMessage); -} - void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) { if (newDocsInstalled) - m_helpEngine->setupData(); + HelpEngineWrapper::instance().setupData(); statusBar()->clearMessage(); checkInitState(); } @@ -371,19 +360,20 @@ void MainWindow::checkInitState() if (!m_cmdLine->enableRemoteControl()) return; - if (m_helpEngine->contentModel()->isCreatingContents() - || m_helpEngine->indexModel()->isCreatingIndex()) { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (helpEngine.contentModel()->isCreatingContents() + || helpEngine.indexModel()->isCreatingIndex()) { if (!m_connectedInitSignals) { - connect(m_helpEngine->contentModel(), SIGNAL(contentsCreated()), + connect(helpEngine.contentModel(), SIGNAL(contentsCreated()), this, SLOT(checkInitState())); - connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this, + connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(checkInitState())); m_connectedInitSignals = true; } } else { if (m_connectedInitSignals) { - disconnect(m_helpEngine->contentModel(), 0, this, 0); - disconnect(m_helpEngine->indexModel(), 0, this, 0); + disconnect(helpEngine.contentModel(), 0, this, 0); + disconnect(helpEngine.indexModel(), 0, this, 0); } emit initDone(); } @@ -663,7 +653,8 @@ QMenu *MainWindow::toolBarMenu() void MainWindow::setupFilterToolbar() { - if (!CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine)) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.filterFunctionalityEnabled()) return; m_filterCombo = new QComboBox(this); @@ -676,15 +667,15 @@ void MainWindow::setupFilterToolbar() this)); filterToolBar->addWidget(m_filterCombo); - if (!CollectionConfiguration::filterToolbarVisible(*m_helpEngine)) + if (!helpEngine.filterToolbarVisible()) filterToolBar->hide(); toolBarMenu()->addAction(filterToolBar->toggleViewAction()); - connect(m_helpEngine, SIGNAL(setupFinished()), this, - SLOT(setupFilterCombo())); + connect(&helpEngine, SIGNAL(setupFinished()), this, + SLOT(setupFilterCombo()), Qt::QueuedConnection); connect(m_filterCombo, SIGNAL(activated(QString)), this, SLOT(filterDocumentation(QString))); - connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, + connect(&helpEngine, SIGNAL(currentFilterChanged(QString)), this, SLOT(currentFilterChanged(QString))); setupFilterCombo(); @@ -692,7 +683,8 @@ void MainWindow::setupFilterToolbar() void MainWindow::setupAddressToolbar() { - if (!CollectionConfiguration::addressBarEnabled(*m_helpEngine)) + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (!helpEngine.addressBarEnabled()) return; m_addressLineEdit = new QLineEdit(this); @@ -704,7 +696,7 @@ void MainWindow::setupAddressToolbar() this)); addressToolBar->addWidget(m_addressLineEdit); - if (!CollectionConfiguration::addressBarVisible(*m_helpEngine)) + if (!helpEngine.addressBarVisible()) addressToolBar->hide(); toolBarMenu()->addAction(addressToolBar->toggleViewAction()); @@ -719,30 +711,28 @@ void MainWindow::setupAddressToolbar() void MainWindow::updateAboutMenuText() { - if (m_helpEngine) { - QByteArray ba = CollectionConfiguration::aboutMenuTexts(*m_helpEngine); - if (ba.size() > 0) { - QString lang; - QString str; - QString trStr; - QString currentLang = QLocale::system().name(); - int i = currentLang.indexOf(QLatin1Char('_')); - if (i > -1) - currentLang = currentLang.left(i); - QDataStream s(&ba, QIODevice::ReadOnly); - while (!s.atEnd()) { - s >> lang; - s >> str; - if (lang == QLatin1String("default") && trStr.isEmpty()) { - trStr = str; - } else if (lang == currentLang) { - trStr = str; - break; - } + QByteArray ba = HelpEngineWrapper::instance().aboutMenuTexts(); + if (ba.size() > 0) { + QString lang; + QString str; + QString trStr; + QString currentLang = QLocale::system().name(); + int i = currentLang.indexOf(QLatin1Char('_')); + if (i > -1) + currentLang = currentLang.left(i); + QDataStream s(&ba, QIODevice::ReadOnly); + while (!s.atEnd()) { + s >> lang; + s >> str; + if (lang == QLatin1String("default") && trStr.isEmpty()) { + trStr = str; + } else if (lang == currentLang) { + trStr = str; + break; } - if (!trStr.isEmpty()) - m_aboutAction->setText(trStr); } + if (!trStr.isEmpty()) + m_aboutAction->setText(trStr); } } @@ -796,7 +786,7 @@ void MainWindow::showTopicChooser(const QMap &links, void MainWindow::showPreferences() { - PreferencesDialog dia(m_helpEngine, m_qchWatcher, this); + PreferencesDialog dia(this); connect(&dia, SIGNAL(updateApplicationFont()), this, SLOT(updateApplicationFont())); @@ -832,26 +822,25 @@ void MainWindow::addNewBookmark(const QString &title, const QString &url) void MainWindow::showAboutDialog() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QByteArray contents; - if (m_helpEngine) { - QByteArray ba = CollectionConfiguration::aboutTexts(*m_helpEngine); - if (!ba.isEmpty()) { - QString lang; - QByteArray cba; - QString currentLang = QLocale::system().name(); - int i = currentLang.indexOf(QLatin1Char('_')); - if (i > -1) - currentLang = currentLang.left(i); - QDataStream s(&ba, QIODevice::ReadOnly); - while (!s.atEnd()) { - s >> lang; - s >> cba; - if (lang == QLatin1String("default") && contents.isEmpty()) { - contents = cba; - } else if (lang == currentLang) { - contents = cba; - break; - } + QByteArray ba = helpEngine.aboutTexts(); + if (!ba.isEmpty()) { + QString lang; + QByteArray cba; + QString currentLang = QLocale::system().name(); + int i = currentLang.indexOf(QLatin1Char('_')); + if (i > -1) + currentLang = currentLang.left(i); + QDataStream s(&ba, QIODevice::ReadOnly); + while (!s.atEnd()) { + s >> lang; + s >> cba; + if (lang == QLatin1String("default") && contents.isEmpty()) { + contents = cba; + } else if (lang == currentLang) { + contents = cba; + break; } } } @@ -860,9 +849,8 @@ void MainWindow::showAboutDialog() QByteArray iconArray; if (!contents.isEmpty()) { - iconArray = CollectionConfiguration::aboutIcon(*m_helpEngine); - QByteArray resources = - CollectionConfiguration::aboutImages(*m_helpEngine); + iconArray = helpEngine.aboutIcon(); + QByteArray resources = helpEngine.aboutImages(); QPixmap pix; pix.loadFromData(iconArray); aboutDia.setText(QString::fromUtf8(contents), resources); @@ -990,20 +978,22 @@ void MainWindow::showSearchWidget() void MainWindow::updateApplicationFont() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QFont font = qApp->font(); - if (CollectionConfiguration::usesAppFont(*m_helpEngine)) - font = CollectionConfiguration::appFont(*m_helpEngine); + if (helpEngine.usesAppFont()) + font = helpEngine.appFont(); qApp->setFont(font, "QWidget"); } void MainWindow::setupFilterCombo() { + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QString curFilter = m_filterCombo->currentText(); if (curFilter.isEmpty()) - curFilter = m_helpEngine->currentFilter(); + curFilter = helpEngine.currentFilter(); m_filterCombo->clear(); - m_filterCombo->addItems(m_helpEngine->customFilters()); + m_filterCombo->addItems(helpEngine.customFilters()); int idx = m_filterCombo->findText(curFilter); if (idx < 0) idx = 0; @@ -1012,7 +1002,7 @@ void MainWindow::setupFilterCombo() void MainWindow::filterDocumentation(const QString &customFilter) { - m_helpEngine->setCurrentFilter(customFilter); + HelpEngineWrapper::instance().setCurrentFilter(customFilter); } void MainWindow::expandTOC(int depth) @@ -1055,7 +1045,7 @@ void MainWindow::indexingFinished() QWidget* MainWindow::setupBookmarkWidget() { - m_bookmarkManager = new BookmarkManager(m_helpEngine); + m_bookmarkManager = new BookmarkManager; m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, this); connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark())); return m_bookmarkWidget; @@ -1135,33 +1125,45 @@ void MainWindow::currentFilterChanged(const QString &filter) m_filterCombo->setCurrentIndex(index); } -void MainWindow::qchFileChanged(const QString &fileName) +void MainWindow::documentationRemoved(const QString &namespaceName) { - /* - * We don't use QHelpEngineCore::namespaceName(fileName), because the file - * may not exist anymore or contain a different namespace. - */ - QString ns; - foreach (const QString &curNs, m_helpEngine->registeredDocumentations()) { - if (m_helpEngine->documentationFileName(curNs) == fileName) { - ns = curNs; - break; - } - } + CentralWidget* widget = CentralWidget::instance(); + widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); +} + +void MainWindow::documentationUpdated(const QString &namespaceName) +{ + // TODO: Check whether the documents still exists and if they do, reload. + CentralWidget* widget = CentralWidget::instance(); + widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); +} - /* - * We can't do an assertion here, because QFileSystemWatcher may send the - * signal more than once. - */ +void MainWindow::resetQtDocInfo(const QString &component) +{ + HelpEngineWrapper::instance().setQtDocInfo(component, + QStringList(QDateTime().toString(Qt::ISODate))); +} + +void MainWindow::registerDocumentation(const QString &component, + const QString &absFileName) +{ + QString ns = QHelpEngineCore::namespaceName(absFileName); if (ns.isEmpty()) return; - CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(ns)); - if (m_helpEngine->unregisterDocumentation(ns) && - (!QFileInfo(fileName).exists() - || !m_helpEngine->registerDocumentation(fileName))) - m_qchWatcher->removePath(fileName); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (helpEngine.registeredDocumentations().contains(ns)) + helpEngine.unregisterDocumentation(ns); + if (!helpEngine.registerDocumentation(absFileName)) { + QMessageBox::warning(this, tr("Qt Assistant"), + tr("Could not register file '%1': %2"). + arg(absFileName).arg(helpEngine.error())); + } else { + QStringList docInfo; + docInfo << QFileInfo(absFileName).lastModified().toString(Qt::ISODate) + << absFileName; + helpEngine.setQtDocInfo(component, docInfo); + } } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 6a0ab58..65eadd7 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -117,10 +117,13 @@ private slots: void lookForNewQtDocumentation(); void indexingStarted(); void indexingFinished(); - void displayInstallationError(const QString &errorMessage); void qtDocumentationInstalled(bool newDocsInstalled); + void registerDocumentation(const QString &component, + const QString &absFileName); + void resetQtDocInfo(const QString &component); void checkInitState(); - void qchFileChanged(const QString &fileName); + void documentationRemoved(const QString &namespaceName); + void documentationUpdated(const QString &namespaceName); void updateBookmarkMenu(); void showBookmark(QAction *action); @@ -143,7 +146,6 @@ private: void hideBookmarks(); void hideSearch(); - QHelpEngine *m_helpEngine; CentralWidget *m_centralWidget; IndexWindow *m_indexWindow; ContentWindow *m_contentWindow; @@ -179,7 +181,6 @@ private: QWidget *m_progressWidget; QtDocInstaller *m_qtDocInstaller; - QFileSystemWatcher * const m_qchWatcher; bool m_connectedInitSignals; }; diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 10d6dd9..2f282b1 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -45,7 +45,7 @@ #include "fontpanel.h" #include "centralwidget.h" #include "aboutdialog.h" -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include #include @@ -62,13 +62,11 @@ QT_BEGIN_NAMESPACE -PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, - QFileSystemWatcher *qchWatcher, QWidget *parent) +PreferencesDialog::PreferencesDialog(QWidget *parent) : QDialog(parent) - , m_helpEngine(helpEngine) , m_appFontChanged(false) , m_browserFontChanged(false) - , m_qchWatcher(qchWatcher) + , helpEngine(HelpEngineWrapper::instance()) { m_ui.setupUi(this); @@ -77,10 +75,8 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); - m_hideFiltersTab = - !CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); - m_hideDocsTab = - !CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); + m_hideFiltersTab = !helpEngine.filterFunctionalityEnabled(); + m_hideDocsTab = !helpEngine.documentationManagerEnabled(); if (!m_hideFiltersTab) { m_ui.attributeWidget->header()->hide(); @@ -109,7 +105,7 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, connect(m_ui.docRemoveButton, SIGNAL(clicked()), this, SLOT(removeDocumentation())); - m_docsBackup = m_helpEngine->registeredDocumentations(); + m_docsBackup = helpEngine.registeredDocumentations(); m_ui.registeredDocsListWidget->addItems(m_docsBackup); } else { m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.docsTab)); @@ -122,21 +118,15 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, PreferencesDialog::~PreferencesDialog() { if (m_appFontChanged) { - CollectionConfiguration::setAppFont(*m_helpEngine, - m_appFontPanel->selectedFont()); - CollectionConfiguration::setUseAppFont(*m_helpEngine, - m_appFontPanel->isChecked()); - CollectionConfiguration::setAppWritingSystem(*m_helpEngine, - m_appFontPanel->writingSystem()); + helpEngine.setAppFont(m_appFontPanel->selectedFont()); + helpEngine.setUseAppFont(m_appFontPanel->isChecked()); + helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem()); } if (m_browserFontChanged) { - CollectionConfiguration::setBrowserFont(*m_helpEngine, - m_browserFontPanel->selectedFont()); - CollectionConfiguration::setUseBrowserFont(*m_helpEngine, - m_browserFontPanel->isChecked()); - CollectionConfiguration::setBrowserWritingSystem(*m_helpEngine, - m_browserFontPanel->writingSystem()); + helpEngine.setBrowserFont(m_browserFontPanel->selectedFont()); + helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked()); + helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem()); } if (m_appFontChanged || m_browserFontChanged) { @@ -147,10 +137,10 @@ PreferencesDialog::~PreferencesDialog() QString homePage = m_ui.homePageLineEdit->text(); if (homePage.isEmpty()) homePage = QLatin1String("help"); - CollectionConfiguration::setHomePage(*m_helpEngine, homePage); + helpEngine.setHomePage(homePage); int option = m_ui.helpStartComboBox->currentIndex(); - CollectionConfiguration::setStartOption(*m_helpEngine, option); + helpEngine.setStartOption(option); } void PreferencesDialog::showDialog() @@ -161,18 +151,13 @@ void PreferencesDialog::showDialog() void PreferencesDialog::updateFilterPage() { - if (!m_helpEngine) - return; - m_ui.filterWidget->clear(); m_ui.attributeWidget->clear(); - QHelpEngineCore help(m_helpEngine->collectionFile(), 0); - help.setupData(); m_filterMapBackup.clear(); - const QStringList filters = help.customFilters(); + const QStringList filters = helpEngine.customFilters(); foreach (const QString &filter, filters) { - QStringList atts = help.filterAttributes(filter); + QStringList atts = helpEngine.filterAttributes(filter); m_filterMapBackup.insert(filter, atts); if (!m_filterMap.contains(filter)) m_filterMap.insert(filter, atts); @@ -180,10 +165,10 @@ void PreferencesDialog::updateFilterPage() m_ui.filterWidget->addItems(m_filterMap.keys()); - foreach (const QString &a, help.filterAttributes()) + foreach (const QString &a, helpEngine.filterAttributes()) new QTreeWidgetItem(m_ui.attributeWidget, QStringList() << a); - if (m_filterMap.keys().count()) + if (!m_filterMap.keys().isEmpty()) m_ui.filterWidget->setCurrentRow(0); } @@ -273,14 +258,11 @@ void PreferencesDialog::addDocumentationLocal() continue; } - if (m_helpEngine->registerDocumentation(fileName)) { - m_qchWatcher->addPath(fileName); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); + if (helpEngine.registerDocumentation(fileName)) { + m_ui.registeredDocsListWidget->addItem(nameSpace); + m_regDocs.append(nameSpace); + m_unregDocs.removeAll(nameSpace); } - m_ui.registeredDocsListWidget->addItem(nameSpace); - m_regDocs.append(nameSpace); - m_unregDocs.removeAll(nameSpace); } if (!invalidFiles.isEmpty() || !alreadyRegistered.isEmpty()) { @@ -372,26 +354,21 @@ void PreferencesDialog::applyChanges() if (filtersWereChanged) { foreach (const QString &filter, m_removedFilters) - m_helpEngine->removeCustomFilter(filter); + helpEngine.removeCustomFilter(filter); QMapIterator it(m_filterMap); while (it.hasNext()) { it.next(); - m_helpEngine->addCustomFilter(it.key(), it.value()); + helpEngine.addCustomFilter(it.key(), it.value()); } } CentralWidget::instance()->closeTabs(m_TabsToClose); - foreach (const QString &doc, m_unregDocs) { - const QString docFile = m_helpEngine->documentationFileName(doc); - if (m_helpEngine->unregisterDocumentation(doc)) - m_qchWatcher->removePath(docFile); - } - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); + foreach (const QString &doc, m_unregDocs) + helpEngine.unregisterDocumentation(doc); - if (filtersWereChanged || m_regDocs.count() || m_unregDocs.count()) - m_helpEngine->setupData(); + if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty()) + helpEngine.setupData(); accept(); } @@ -411,26 +388,23 @@ void PreferencesDialog::updateFontSettingsPage() const QString customSettings(tr("Use custom settings")); m_appFontPanel->setTitle(customSettings); - QFont font = CollectionConfiguration::appFont(*m_helpEngine); + QFont font = helpEngine.appFont(); m_appFontPanel->setSelectedFont(font); - QFontDatabase::WritingSystem system = - CollectionConfiguration::appWritingSystem(*m_helpEngine); + QFontDatabase::WritingSystem system = helpEngine.appWritingSystem(); m_appFontPanel->setWritingSystem(system); - m_appFontPanel->setChecked(CollectionConfiguration:: - usesAppFont(*m_helpEngine)); + m_appFontPanel->setChecked(helpEngine.usesAppFont()); m_browserFontPanel->setTitle(customSettings); - font = CollectionConfiguration::browserFont(*m_helpEngine); + font = helpEngine.browserFont(); m_browserFontPanel->setSelectedFont(font); - system = CollectionConfiguration::browserWritingSystem(*m_helpEngine); + system = helpEngine.browserWritingSystem(); m_browserFontPanel->setWritingSystem(system); - m_browserFontPanel->setChecked(CollectionConfiguration:: - usesBrowserFont(*m_helpEngine)); + m_browserFontPanel->setChecked(helpEngine.usesBrowserFont()); connect(m_appFontPanel, SIGNAL(toggled(bool)), this, SLOT(appFontSettingToggled(bool))); @@ -476,12 +450,9 @@ void PreferencesDialog::browserFontSettingChanged(int index) void PreferencesDialog::updateOptionsPage() { - QString homePage = CollectionConfiguration::homePage(*m_helpEngine); - if (homePage.isEmpty()) - homePage = CollectionConfiguration::defaultHomePage(*m_helpEngine); - m_ui.homePageLineEdit->setText(homePage); + m_ui.homePageLineEdit->setText(helpEngine.homePage()); - int option = CollectionConfiguration::startOption(*m_helpEngine); + int option = helpEngine.startOption(); m_ui.helpStartComboBox->setCurrentIndex(option); connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage())); @@ -505,8 +476,7 @@ void PreferencesDialog::setCurrentPage() void PreferencesDialog::setDefaultPage() { - QString homePage = CollectionConfiguration::defaultHomePage(*m_helpEngine); - m_ui.homePageLineEdit->setText(homePage); + m_ui.homePageLineEdit->setText(helpEngine.defaultHomePage()); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h index 7abf431..1554a9f 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.h +++ b/tools/assistant/tools/assistant/preferencesdialog.h @@ -48,22 +48,15 @@ QT_BEGIN_NAMESPACE class FontPanel; +class HelpEngineWrapper; class QFileSystemWatcher; -class QHelpEngineCore; - -enum { - ShowHomePage = 0, - ShowBlankPage = 1, - ShowLastPages = 2 -}; class PreferencesDialog : public QDialog { Q_OBJECT public: - PreferencesDialog(QHelpEngineCore *helpEngine, - QFileSystemWatcher *qchWatcher, QWidget *parent = 0); + PreferencesDialog(QWidget *parent = 0); ~PreferencesDialog(); void showDialog(); @@ -95,7 +88,6 @@ private: void updateOptionsPage(); Ui::PreferencesDialogClass m_ui; - QHelpEngineCore *m_helpEngine; bool m_hideFiltersTab; bool m_hideDocsTab; QMap m_filterMapBackup; @@ -109,7 +101,7 @@ private: FontPanel *m_browserFontPanel; bool m_appFontChanged; bool m_browserFontChanged; - QFileSystemWatcher * const m_qchWatcher; + HelpEngineWrapper &helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/qtdocinstaller.cpp b/tools/assistant/tools/assistant/qtdocinstaller.cpp index 3f82786..3675aec 100644 --- a/tools/assistant/tools/assistant/qtdocinstaller.cpp +++ b/tools/assistant/tools/assistant/qtdocinstaller.cpp @@ -44,17 +44,14 @@ #include #include #include -#include "../shared/collectionconfiguration.h" +#include "helpenginewrapper.h" #include "qtdocinstaller.h" QT_BEGIN_NAMESPACE -QtDocInstaller::QtDocInstaller(const QString &collectionFile, - QFileSystemWatcher *qchWatcher) - : m_qchWatcher(qchWatcher) +QtDocInstaller::QtDocInstaller(const QList &docInfos) + : m_abort(false), m_docInfos(docInfos) { - m_abort = false; - m_collectionFile = collectionFile; } QtDocInstaller::~QtDocInstaller() @@ -74,87 +71,51 @@ void QtDocInstaller::installDocs() void QtDocInstaller::run() { - QHelpEngineCore *helpEngine = new QHelpEngineCore(m_collectionFile); - helpEngine->setupData(); - bool changes = false; - - QStringList docs; - docs << QLatin1String("assistant") - << QLatin1String("designer") - << QLatin1String("linguist") - << QLatin1String("qmake") - << QLatin1String("qt"); + m_qchDir = QLibraryInfo::location(QLibraryInfo::DocumentationPath) + + QDir::separator() + QLatin1String("qch"); + m_qchFiles = m_qchDir.entryList(QStringList() << QLatin1String("*.qch")); - foreach (const QString &doc, docs) { - changes |= installDoc(doc, helpEngine); + bool changes = false; + foreach (const DocInfo &docInfo, m_docInfos) { + changes |= installDoc(docInfo); m_mutex.lock(); if (m_abort) { - delete helpEngine; m_mutex.unlock(); return; } m_mutex.unlock(); } - delete helpEngine; emit docsInstalled(changes); } -bool QtDocInstaller::installDoc(const QString &name, QHelpEngineCore *helpEngine) +bool QtDocInstaller::installDoc(const DocInfo &docInfo) { - QStringList lst = CollectionConfiguration::qtDocInfo(*helpEngine, name); - + const QString &component = docInfo.first; + const QStringList &info = docInfo.second; QDateTime dt; - if (!lst.isEmpty() && !lst.first().isEmpty()) - dt = QDateTime::fromString(lst.first(), Qt::ISODate); + if (!info.isEmpty() && !info.first().isEmpty()) + dt = QDateTime::fromString(info.first(), Qt::ISODate); QString qchFile; - if (lst.count() == 2) - qchFile = lst.last(); - - QDir dir(QLibraryInfo::location(QLibraryInfo::DocumentationPath) - + QDir::separator() + QLatin1String("qch")); + if (info.count() == 2) + qchFile = info.last(); - const QStringList files = dir.entryList(QStringList() << QLatin1String("*.qch")); - if (files.isEmpty()) { - CollectionConfiguration::setQtDocInfo(*helpEngine, name, - QStringList(QDateTime().toString(Qt::ISODate))); + if (m_qchFiles.isEmpty()) { + emit qchFileNotFound(component); return false; } - foreach (const QString &f, files) { - if (f.startsWith(name)) { - QFileInfo fi(dir.absolutePath() + QDir::separator() + f); + foreach (const QString &f, m_qchFiles) { + if (f.startsWith(component)) { + QFileInfo fi(m_qchDir.absolutePath() + QDir::separator() + f); if (dt.isValid() && fi.lastModified().toTime_t() == dt.toTime_t() && qchFile == fi.absoluteFilePath()) return false; - - QString namespaceName = QHelpEngineCore::namespaceName(fi.absoluteFilePath()); - if (namespaceName.isEmpty()) - continue; - - if (helpEngine->registeredDocumentations().contains(namespaceName)) { - const QString docFile = - helpEngine->documentationFileName(namespaceName); - if (helpEngine->unregisterDocumentation(namespaceName)) - m_qchWatcher->removePath(docFile); - } - - if (!helpEngine->registerDocumentation(fi.absoluteFilePath())) { - emit errorMessage( - tr("The file %1 could not be registered successfully!\n\nReason: %2") - .arg(fi.absoluteFilePath()).arg(helpEngine->error())); - } else { - m_qchWatcher->addPath(fi.absoluteFilePath()); - } - - Q_ASSERT(m_qchWatcher->files().count() - == helpEngine->registeredDocumentations().count()); - - CollectionConfiguration::setQtDocInfo(*helpEngine, name, - QStringList() << fi.lastModified().toString(Qt::ISODate) - << fi.absoluteFilePath()); + emit registerDocumentation(component, fi.absoluteFilePath()); return true; } } + + emit qchFileNotFound(component); return false; } diff --git a/tools/assistant/tools/assistant/qtdocinstaller.h b/tools/assistant/tools/assistant/qtdocinstaller.h index 0d503fd..c64a5c3 100644 --- a/tools/assistant/tools/assistant/qtdocinstaller.h +++ b/tools/assistant/tools/assistant/qtdocinstaller.h @@ -42,36 +42,41 @@ #ifndef QTDOCINSTALLER #define QTDOCINSTALLER -#include +#include #include +#include +#include +#include QT_BEGIN_NAMESPACE -class QFileSystemWatcher; -class QHelpEngineCore; +class HelpEngineWrapper; class QtDocInstaller : public QThread { Q_OBJECT public: - QtDocInstaller(const QString &collectionFile, QFileSystemWatcher *qchWatcher); + typedef QPair DocInfo; + QtDocInstaller(const QList &docInfos); ~QtDocInstaller(); void installDocs(); signals: - void errorMessage(const QString &msg); + void qchFileNotFound(const QString &component); + void registerDocumentation(const QString &component, + const QString &absFileName); void docsInstalled(bool newDocsInstalled); private: void run(); - bool installDoc(const QString &name, - QHelpEngineCore *helpEngine); + bool installDoc(const DocInfo &docInfo); bool m_abort; - QString m_collectionFile; QMutex m_mutex; - QFileSystemWatcher * const m_qchWatcher; + QStringList m_qchFiles; + QDir m_qchDir; + QList m_docInfos; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index ef13885..f4ae3b4 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -42,6 +42,7 @@ #include "remotecontrol.h" #include "mainwindow.h" #include "centralwidget.h" +#include "helpenginewrapper.h" #include #include @@ -106,16 +107,14 @@ void StdInListenerWin::run() } #endif -RemoteControl::RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine, - QFileSystemWatcher *qchWatcher) +RemoteControl::RemoteControl(MainWindow *mainWindow) : QObject(mainWindow) , m_mainWindow(mainWindow) - , m_helpEngine(helpEngine) , m_debug(false) , m_caching(true) , m_syncContents(false) , m_expandTOC(-2) - , m_qchWatcher(qchWatcher) + , helpEngine(HelpEngineWrapper::instance()) { connect(m_mainWindow, SIGNAL(initDone()), this, SLOT(applyCache())); @@ -248,7 +247,7 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg) } else { m_mainWindow->setIndexString(arg); if (!arg.isEmpty()) - m_helpEngine->indexWidget()->activateCurrentItem(); + helpEngine.indexWidget()->activateCurrentItem(); } } @@ -258,8 +257,7 @@ void RemoteControl::handleActivateIdentifierCommand(const QString &arg) clearCache(); m_activateIdentifier = arg; } else { - const QMap &links = - m_helpEngine->linksForIdentifier(arg); + const QMap &links = helpEngine.linksForIdentifier(arg); if (!links.isEmpty()) CentralWidget::instance()->setSource(links.constBegin().value()); } @@ -282,12 +280,12 @@ void RemoteControl::handleExpandTocCommand(const QString &arg) void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) { - if (m_helpEngine->customFilters().contains(arg)) { + if (helpEngine.customFilters().contains(arg)) { if (m_caching) { clearCache(); m_currentFilter = arg; } else { - m_helpEngine->setCurrentFilter(arg); + helpEngine.setCurrentFilter(arg); } } } @@ -295,29 +293,22 @@ void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) void RemoteControl::handleRegisterCommand(const QString &arg) { const QString &absFileName = QFileInfo(arg).absoluteFilePath(); - if (m_helpEngine->registeredDocumentations(). + if (helpEngine.registeredDocumentations(). contains(QHelpEngineCore::namespaceName(absFileName))) return; - if (m_helpEngine->registerDocumentation(absFileName)) { - m_qchWatcher->addPath(absFileName); - m_helpEngine->setupData(); - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); - } + if (helpEngine.registerDocumentation(absFileName)) + helpEngine.setupData(); } void RemoteControl::handleUnregisterCommand(const QString &arg) { const QString &absFileName = QFileInfo(arg).absoluteFilePath(); const QString &ns = QHelpEngineCore::namespaceName(absFileName); - if (m_helpEngine->registeredDocumentations().contains(ns)) { + if (helpEngine.registeredDocumentations().contains(ns)) { CentralWidget* widget = CentralWidget::instance(); widget->closeTabs(widget->currentSourceFileList().keys(ns)); - const QString docFile = m_helpEngine->documentationFileName(ns); - if (m_helpEngine->unregisterDocumentation(ns)) { - m_qchWatcher->removePath(docFile); - m_helpEngine->setupData(); - } + if (helpEngine.unregisterDocumentation(ns)) + helpEngine.setupData(); } } @@ -327,14 +318,14 @@ void RemoteControl::applyCache() CentralWidget::instance()->setSource(m_setSource); } else if (!m_activateKeyword.isEmpty()) { m_mainWindow->setIndexString(m_activateKeyword); - m_helpEngine->indexWidget()->activateCurrentItem(); + helpEngine.indexWidget()->activateCurrentItem(); } else if (!m_activateIdentifier.isEmpty()) { QMap links = - m_helpEngine->linksForIdentifier(m_activateIdentifier); - if (links.count()) + helpEngine.linksForIdentifier(m_activateIdentifier); + if (!links.isEmpty()) CentralWidget::instance()->setSource(links.constBegin().value()); } else if (!m_currentFilter.isEmpty()) { - m_helpEngine->setCurrentFilter(m_currentFilter); + helpEngine.setCurrentFilter(m_currentFilter); } if (m_syncContents) diff --git a/tools/assistant/tools/assistant/remotecontrol.h b/tools/assistant/tools/assistant/remotecontrol.h index 6f7eb5f..5d74996 100644 --- a/tools/assistant/tools/assistant/remotecontrol.h +++ b/tools/assistant/tools/assistant/remotecontrol.h @@ -48,17 +48,15 @@ QT_BEGIN_NAMESPACE +class HelpEngineWrapper; class MainWindow; -class QFileSystemWatcher; -class QHelpEngine; class RemoteControl : public QObject { Q_OBJECT public: - RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine, - QFileSystemWatcher *qchWatcher); + RemoteControl(MainWindow *mainWindow); private slots: void receivedData(); @@ -81,7 +79,6 @@ private: private: MainWindow *m_mainWindow; - QHelpEngine *m_helpEngine; bool m_debug; bool m_caching; @@ -91,7 +88,7 @@ private: QString m_activateIdentifier; int m_expandTOC; QString m_currentFilter; - QFileSystemWatcher * const m_qchWatcher; + HelpEngineWrapper &helpEngine; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/tracer.h b/tools/assistant/tools/assistant/tracer.h index 913c961..3d8b647 100644 --- a/tools/assistant/tools/assistant/tracer.h +++ b/tools/assistant/tools/assistant/tracer.h @@ -65,6 +65,7 @@ private: QT_END_NAMESPACE +// #define TRACING_REQUESTED #ifdef TRACING_REQUESTED #define TRACE_OBJ Tracer traceObj__(Q_FUNC_INFO); #else diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp index 2eb2b96..467ee88 100644 --- a/tools/assistant/tools/qcollectiongenerator/main.cpp +++ b/tools/assistant/tools/qcollectiongenerator/main.cpp @@ -467,8 +467,7 @@ int main(int argc, char *argv[]) } if (!config.currentFilter().isEmpty()) { - CollectionConfiguration::setCurrentFilter(helpEngine, - config.currentFilter()); + helpEngine.setCurrentFilter(config.currentFilter()); } if (!config.cacheDirectory().isEmpty()) { diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp index d0650e4..ba643c9 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.cpp +++ b/tools/assistant/tools/shared/collectionconfiguration.cpp @@ -46,30 +46,21 @@ QT_BEGIN_NAMESPACE namespace { - const QString ListSeparator(QLatin1String("|")); - const QString AboutIconKey(QLatin1String("AboutIcon")); const QString AboutImagesKey(QLatin1String("AboutImages")); const QString AboutMenuTextsKey(QLatin1String("AboutMenuTexts")); const QString AboutTextsKey(QLatin1String("AboutTexts")); - const QString AppFontKey(QLatin1String("appFont")); const QString ApplicationIconKey(QLatin1String("ApplicationIcon")); - const QString AppWritingSystemKey(QLatin1String("appWritingSystem")); - const QString BookmarksKey(QLatin1String("Bookmarks")); - const QString BrowserFontKey(QLatin1String("browserFont")); - const QString BrowserWritingSystemKey(QLatin1String("browserWritingSystem")); const QString CacheDirKey(QLatin1String("CacheDirectory")); const QString CacheDirRelativeToCollectionKey(QLatin1String("CacheDirRelativeToCollection")); const QString CreationTimeKey(QLatin1String("CreationTime")); - const QString CurrentFilterKey(QLatin1String("CurrentFilter")); const QString DefaultHomePageKey(QLatin1String("defaultHomepage")); const QString DocUpdatePendingKey(QLatin1String("DocUpdate")); const QString EnableAddressBarKey(QLatin1String("EnableAddressBar")); const QString EnableDocManagerKey(QLatin1String("EnableDocumentationManager")); const QString EnableFilterKey(QLatin1String("EnableFilterFunctionality")); - const QString FilterToolbarHiddenKey(QLatin1String("HideFilterFunctionality")); const QString HideAddressBarKey(QLatin1String("HideAddressBar")); - const QString HomePageKey(QLatin1String("homepage")); + const QString FilterToolbarHiddenKey(QLatin1String("HideFilterFunctionality")); const QString LastPageKey(QLatin1String("LastTabPage")); const QString LastShownPagesKey(QLatin1String("LastShownPages")); const QString LastZoomFactorsKey(QLatin1String( @@ -79,19 +70,11 @@ namespace { "LastPagesZoomTextBrowser" #endif )); - const QString MainWindowKey(QLatin1String("MainWindow")); - const QString MainWindowGeometryKey(QLatin1String("MainWindowGeometry")); - const QString SearchWasAttachedKey(QLatin1String("SearchWasAttached")); - const QString StartOptionKey(QLatin1String("StartOption")); - const QString UnfilteredInsertedKey(QLatin1String("UnfilteredFilterInserted")); - const QString UseAppFontKey(QLatin1String("useAppFont")); - const QString UseBrowserFontKey(QLatin1String("useBrowserFont")); - const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")). - arg(QLatin1String(QT_VERSION_STR))); const QString WindowTitleKey(QLatin1String("WindowTitle")); } // anonymous namespace const QString CollectionConfiguration::DefaultZoomFactor(QLatin1String("0.0")); +const QString CollectionConfiguration::ListSeparator(QLatin1String("|")); uint CollectionConfiguration::creationTime(const QHelpEngineCore &helpEngine) { @@ -109,84 +92,18 @@ const QString CollectionConfiguration::windowTitle(const QHelpEngineCore &helpEn } void CollectionConfiguration::setWindowTitle(QHelpEngineCore &helpEngine, - const QString &windowTitle) + const QString &windowTitle) { helpEngine.setCustomValue(WindowTitleKey, windowTitle); } - -int CollectionConfiguration::lastTabPage(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastPageKey, 1).toInt(); -} - -void CollectionConfiguration::setLastTabPage(QHelpEngineCore &helpEngine, int lastPage) -{ - helpEngine.setCustomValue(LastPageKey, lastPage); -} - - -const QStringList CollectionConfiguration::lastShownPages(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastShownPagesKey).toString(). - split(ListSeparator, QString::SkipEmptyParts); -} - -void CollectionConfiguration::setLastShownPages(QHelpEngineCore &helpEngine, - const QStringList &lastShownPages) -{ - helpEngine. - setCustomValue(LastShownPagesKey, lastShownPages.join(ListSeparator)); -} - -const QStringList CollectionConfiguration::lastZoomFactors(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(LastZoomFactorsKey).toString(). - split(ListSeparator, QString::SkipEmptyParts); -} - -void CollectionConfiguration::setLastZoomFactors(QHelpEngineCore &helpEngine, - const QStringList &lastZoomFactors) -{ - helpEngine.setCustomValue(LastZoomFactorsKey, lastZoomFactors.join(ListSeparator)); -} - -const QString CollectionConfiguration::currentFilter(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CurrentFilterKey).toString(); -} - -void CollectionConfiguration::setCurrentFilter(QHelpEngineCore &helpEngine, - const QString ¤tFilter) -{ - helpEngine.setCustomValue(CurrentFilterKey, currentFilter); -} - -const QString CollectionConfiguration::cacheDir(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CacheDirKey).toString(); -} - -bool CollectionConfiguration::cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(CacheDirRelativeToCollectionKey).toBool(); -} - -void CollectionConfiguration::setCacheDir(QHelpEngineCore &helpEngine, - const QString &cacheDir, bool relativeToCollection) -{ - helpEngine.setCustomValue(CacheDirKey, cacheDir); - helpEngine.setCustomValue(CacheDirRelativeToCollectionKey, - relativeToCollection); -} - bool CollectionConfiguration::filterFunctionalityEnabled(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(EnableFilterKey, true).toBool(); } void CollectionConfiguration::setFilterFunctionalityEnabled(QHelpEngineCore &helpEngine, - bool enabled) + bool enabled) { helpEngine.setCustomValue(EnableFilterKey, enabled); } @@ -197,7 +114,7 @@ bool CollectionConfiguration::filterToolbarVisible(const QHelpEngineCore &helpEn } void CollectionConfiguration::setFilterToolbarVisible(QHelpEngineCore &helpEngine, - bool visible) + bool visible) { helpEngine.setCustomValue(FilterToolbarHiddenKey, !visible); } @@ -224,6 +141,24 @@ void CollectionConfiguration::setAddressBarVisible(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(HideAddressBarKey, !visible); } +const QString CollectionConfiguration::cacheDir(const QHelpEngineCore &helpEngine) +{ + return helpEngine.customValue(CacheDirKey).toString(); +} + +bool CollectionConfiguration::cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine) +{ + return helpEngine.customValue(CacheDirRelativeToCollectionKey).toBool(); +} + +void CollectionConfiguration::setCacheDir(QHelpEngineCore &helpEngine, + const QString &cacheDir, bool relativeToCollection) +{ + helpEngine.setCustomValue(CacheDirKey, cacheDir); + helpEngine.setCustomValue(CacheDirRelativeToCollectionKey, + relativeToCollection); +} + bool CollectionConfiguration::documentationManagerEnabled(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(EnableDocManagerKey, true).toBool(); @@ -302,30 +237,6 @@ void CollectionConfiguration::setDefaultHomePage(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(DefaultHomePageKey, page); } -const QString CollectionConfiguration::homePage(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(HomePageKey).toString(); -} - -void CollectionConfiguration::setHomePage(QHelpEngineCore &helpEngine, - const QString &page) -{ - helpEngine.setCustomValue(HomePageKey, page); -} - -int CollectionConfiguration::startOption(const QHelpEngineCore &helpEngine) -{ - // TODO: After moving to helpengine wrapper, put LastPages in that header file - // and use it here as default value. - return helpEngine.customValue(StartOptionKey).toInt(); -} - -void CollectionConfiguration::setStartOption(QHelpEngineCore &helpEngine, - int option) -{ - helpEngine.setCustomValue(StartOptionKey, option); -} - bool CollectionConfiguration::docUpdatePending(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(DocUpdatePendingKey, false).toBool(); @@ -337,145 +248,41 @@ void CollectionConfiguration::setDocUpdatePending(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(DocUpdatePendingKey, pending); } -const QByteArray CollectionConfiguration::bookmarks(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(BookmarksKey).toByteArray(); -} - -void CollectionConfiguration::setBookmarks(QHelpEngineCore &helpEngine, - const QByteArray &bookmarks) -{ - helpEngine.setCustomValue(BookmarksKey, bookmarks); -} - -const QByteArray CollectionConfiguration::mainWindow(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(MainWindowKey).toByteArray(); -} - -void CollectionConfiguration::setMainWindow(QHelpEngineCore &helpEngine, - const QByteArray &mainWindow) -{ - helpEngine.setCustomValue(MainWindowKey, mainWindow); -} - -const QByteArray CollectionConfiguration::mainWindowGeometry(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(MainWindowGeometryKey).toByteArray(); -} - -void CollectionConfiguration::setMainWindowGeometry(QHelpEngineCore &helpEngine, - const QByteArray &geometry) -{ - helpEngine.setCustomValue(MainWindowGeometryKey, geometry); -} - -bool CollectionConfiguration::usesAppFont(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UseAppFontKey).toBool(); -} - -void CollectionConfiguration::setUseAppFont(QHelpEngineCore &helpEngine, - bool useAppFont) -{ - helpEngine.setCustomValue(UseAppFontKey, useAppFont); -} - -bool CollectionConfiguration::usesBrowserFont(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UseBrowserFontKey, false).toBool(); -} - -void CollectionConfiguration::setUseBrowserFont(QHelpEngineCore &helpEngine, - bool useBrowserFont) -{ - helpEngine.setCustomValue(UseBrowserFontKey, useBrowserFont); -} - -const QFont CollectionConfiguration::appFont(const QHelpEngineCore &helpEngine) -{ - return qVariantValue(helpEngine.customValue(AppFontKey)); -} - -void CollectionConfiguration::setAppFont(QHelpEngineCore &helpEngine, - const QFont &font) -{ - helpEngine.setCustomValue(AppFontKey, font); -} - -QFontDatabase::WritingSystem CollectionConfiguration::appWritingSystem(const QHelpEngineCore &helpEngine) -{ - return static_cast( - helpEngine.customValue(AppWritingSystemKey).toInt()); -} - -void CollectionConfiguration::setAppWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system) -{ - helpEngine.setCustomValue(AppWritingSystemKey, system); -} - -const QFont CollectionConfiguration::browserFont(const QHelpEngineCore &helpEngine) -{ - return qVariantValue(helpEngine.customValue(BrowserFontKey)); -} - -void CollectionConfiguration::setBrowserFont(QHelpEngineCore &helpEngine, - const QFont &font) -{ - helpEngine.setCustomValue(BrowserFontKey, font); -} - -QFontDatabase::WritingSystem CollectionConfiguration::browserWritingSystem(const QHelpEngineCore &helpEngine) -{ - return static_cast( - helpEngine.customValue(BrowserWritingSystemKey).toInt()); -} - -void CollectionConfiguration::setBrowserWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system) -{ - helpEngine.setCustomValue(BrowserWritingSystemKey, system); -} - -bool CollectionConfiguration::unfilteredInserted(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(UnfilteredInsertedKey).toInt() == 1; -} - -void CollectionConfiguration::setUnfilteredInserted(QHelpEngineCore &helpEngine) +const QStringList CollectionConfiguration::lastShownPages(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(UnfilteredInsertedKey, 1); + return helpEngine.customValue(LastShownPagesKey).toString(). + split(ListSeparator, QString::SkipEmptyParts); } -const QStringList CollectionConfiguration::qtDocInfo(const QHelpEngineCore &helpEngine, - const QString &component) +void CollectionConfiguration::setLastShownPages(QHelpEngineCore &helpEngine, + const QStringList &lastShownPages) { - return helpEngine.customValue(VersionKey.arg(component)).toString(). - split(ListSeparator); + helpEngine.setCustomValue(LastShownPagesKey, + lastShownPages.join(ListSeparator)); } -void CollectionConfiguration::setQtDocInfo(QHelpEngineCore &helpEngine, - const QString &component, const QStringList &doc) +const QStringList CollectionConfiguration::lastZoomFactors(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(VersionKey.arg(component), - doc.join(ListSeparator)); + return helpEngine.customValue(LastZoomFactorsKey).toString(). + split(ListSeparator, QString::SkipEmptyParts); } -bool CollectionConfiguration::searchWasAttached(const QHelpEngineCore &helpEngine) +void CollectionConfiguration::setLastZoomFactors(QHelpEngineCore &helpEngine, + const QStringList &lastZoomFactors) { - return helpEngine.customValue(SearchWasAttachedKey).toBool(); + helpEngine.setCustomValue(LastZoomFactorsKey, + lastZoomFactors.join(ListSeparator)); } -void CollectionConfiguration::setSearchWasAttached(QHelpEngineCore &helpEngine, - bool attached) +int CollectionConfiguration::lastTabPage(const QHelpEngineCore &helpEngine) { - helpEngine.setCustomValue(SearchWasAttachedKey, attached); + return helpEngine.customValue(LastPageKey, 1).toInt(); } -bool CollectionConfiguration::hasFontSettings(const QHelpEngineCore &helpEngine) +void CollectionConfiguration::setLastTabPage(QHelpEngineCore &helpEngine, + int lastPage) { - return helpEngine.customValue(UseAppFontKey).isValid(); + helpEngine.setCustomValue(LastPageKey, lastPage); } bool CollectionConfiguration::isNewer(const QHelpEngineCore &newer, @@ -489,9 +296,7 @@ void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source, { setCreationTime(target, creationTime(source)); setWindowTitle(target, windowTitle(source)); - setLastShownPages(target, lastShownPages(source)); - setLastZoomFactors(target, lastZoomFactors(source)); - setCurrentFilter(target, currentFilter(source)); + target.setCurrentFilter(source.currentFilter()); setCacheDir(target, cacheDir(source), cacheDirIsRelativeToCollection(source)); setFilterFunctionalityEnabled(target, filterFunctionalityEnabled(source)); setFilterToolbarVisible(target, filterToolbarVisible(source)); diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h index 48d2803..4e77abe 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.h +++ b/tools/assistant/tools/shared/collectionconfiguration.h @@ -46,8 +46,6 @@ #include #include #include -#include -#include QT_BEGIN_NAMESPACE @@ -56,29 +54,18 @@ class QHelpEngineCore; class CollectionConfiguration { public: - static int lastTabPage(const QHelpEngineCore &helpEngine); - static void setLastTabPage(QHelpEngineCore &helpEngine, int lastPage); - - static const QStringList lastShownPages(const QHelpEngineCore &helpEngine); - static void setLastShownPages(QHelpEngineCore &helpEngine, - const QStringList &lastShownPages); - - - // TODO: Don't allow last pages and zoom factors to be set in isolation - // Perhaps also fill up missing elements automatically or assert. - static const QStringList lastZoomFactors(const QHelpEngineCore &helpEngine); - static void setLastZoomFactors(QHelpEngineCore &helpEngine, - const QStringList &lastZoomFactors); - - static const QString currentFilter(const QHelpEngineCore &helpEngine); - static void setCurrentFilter(QHelpEngineCore &helpEngine, - const QString ¤tFilter); + static const QString windowTitle(const QHelpEngineCore &helpEngine); + static void setWindowTitle(QHelpEngineCore &helpEngine, + const QString &windowTitle); static const QString cacheDir(const QHelpEngineCore &helpEngine); static bool cacheDirIsRelativeToCollection(const QHelpEngineCore &helpEngine); static void setCacheDir(QHelpEngineCore &helpEngine, const QString &cacheDir, bool relativeToCollection); + static uint creationTime(const QHelpEngineCore &helpEngine); + static void setCreationTime(QHelpEngineCore &helpEngine, uint time); + static bool filterFunctionalityEnabled(const QHelpEngineCore &helpEngine); static void setFilterFunctionalityEnabled(QHelpEngineCore &helpEngine, bool enabled); @@ -93,12 +80,6 @@ public: static bool addressBarVisible(const QHelpEngineCore &helpEngine); static void setAddressBarVisible(QHelpEngineCore &helpEngine, bool visible); - static uint creationTime(const QHelpEngineCore &helpEngine); - static void setCreationTime(QHelpEngineCore &helpEngine, uint time); - - static const QString windowTitle(const QHelpEngineCore &helpEngine); - static void setWindowTitle(QHelpEngineCore &helpEngine, - const QString &windowTitle); static bool documentationManagerEnabled(const QHelpEngineCore &helpEngine); static void setDocumentationManagerEnabled(QHelpEngineCore &helpEngine, @@ -108,12 +89,6 @@ public: static void setApplicationIcon(QHelpEngineCore &helpEngine, const QByteArray &icon); - static const QString homePage(const QHelpEngineCore &helpEngine); - static void setHomePage(QHelpEngineCore &helpEngine, const QString &page); - - static int startOption(const QHelpEngineCore &helpEngine); - static void setStartOption(QHelpEngineCore &helpEngine, int option); - // TODO: Encapsulate encoding from/to QByteArray here static const QByteArray aboutMenuTexts(const QHelpEngineCore &helpEngine); static void setAboutMenuTexts(QHelpEngineCore &helpEngine, @@ -139,58 +114,25 @@ public: static bool docUpdatePending(const QHelpEngineCore &helpEngine); static void setDocUpdatePending(QHelpEngineCore &helpEngine, bool pending); - // TODO: Put these GUI-specific functions in the help engine wrapper - static const QByteArray bookmarks(const QHelpEngineCore &helpEngine); - static void setBookmarks(QHelpEngineCore &helpEngine, - const QByteArray &bookmarks); - - static const QByteArray mainWindow(const QHelpEngineCore &helpEngine); - static void setMainWindow(QHelpEngineCore &helpEngine, - const QByteArray &mainWindow); - - static const QByteArray mainWindowGeometry(const QHelpEngineCore &helpEngine); - static void setMainWindowGeometry(QHelpEngineCore &helpEngine, - const QByteArray &geometry); - - static bool usesAppFont(const QHelpEngineCore &helpEngine); - static void setUseAppFont(QHelpEngineCore &helpEngine, bool useAppFont); - - static bool usesBrowserFont(const QHelpEngineCore &helpEngine); - static void setUseBrowserFont(QHelpEngineCore &helpEngine, - bool useBrowserFont); - - static const QFont appFont(const QHelpEngineCore &helpEngine); - static void setAppFont(QHelpEngineCore &helpEngine, const QFont &font); - - static QFontDatabase::WritingSystem appWritingSystem(const QHelpEngineCore &helpEngine); - static void setAppWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system); - - static const QFont browserFont(const QHelpEngineCore &helpEngine); - static void setBrowserFont(QHelpEngineCore &helpEngine, const QFont &font); - - static QFontDatabase::WritingSystem browserWritingSystem(const QHelpEngineCore &helpEngine); - static void setBrowserWritingSystem(QHelpEngineCore &helpEngine, - QFontDatabase::WritingSystem system); - - static bool unfilteredInserted(const QHelpEngineCore &helpEngine); - static void setUnfilteredInserted(QHelpEngineCore &helpEngine); - - static const QStringList qtDocInfo(const QHelpEngineCore &helpEngine, - const QString &component); - static void setQtDocInfo(QHelpEngineCore &helpEngine, - const QString &component, const QStringList &doc); + // TODO: Don't allow last pages and zoom factors to be set in isolation + // Perhaps also fill up missing elements automatically or assert. + static const QStringList lastShownPages(const QHelpEngineCore &helpEngine); + static void setLastShownPages(QHelpEngineCore &helpEngine, + const QStringList &lastShownPages); + static const QStringList lastZoomFactors(const QHelpEngineCore &helpEngine); + static void setLastZoomFactors(QHelpEngineCore &helPEngine, + const QStringList &lastZoomFactors); - static bool searchWasAttached(const QHelpEngineCore &helpEngine); - static void setSearchWasAttached(QHelpEngineCore &helpEngine, bool attached); + static int lastTabPage(const QHelpEngineCore &helpEngine); + static void setLastTabPage(QHelpEngineCore &helpEngine, int lastPage); - static bool hasFontSettings(const QHelpEngineCore &helpEngine); static bool isNewer(const QHelpEngineCore &newer, const QHelpEngineCore &older); static void copyConfiguration(const QHelpEngineCore &source, QHelpEngineCore &target); static const QString DefaultZoomFactor; + static const QString ListSeparator; }; QT_END_NAMESPACE -- cgit v0.12 From 02c1e3324ad11ab7a1f1c601ab3ffdd18f1dc5f6 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 3 Dec 2009 15:25:06 +0100 Subject: Assistant: Compile fix for namespaced Qt. --- tools/assistant/tools/assistant/xbelsupport.cpp | 4 ++++ tools/assistant/tools/assistant/xbelsupport.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tools/assistant/tools/assistant/xbelsupport.cpp b/tools/assistant/tools/assistant/xbelsupport.cpp index 545be6c..3c545ac 100644 --- a/tools/assistant/tools/assistant/xbelsupport.cpp +++ b/tools/assistant/tools/assistant/xbelsupport.cpp @@ -44,6 +44,8 @@ #include +QT_BEGIN_NAMESPACE + struct Bookmark { QString title; QString url; @@ -232,3 +234,5 @@ QStandardItem *XbelReader::createChildItem(QStandardItem *item) return childItem; } + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/xbelsupport.h b/tools/assistant/tools/assistant/xbelsupport.h index 177b04b..f3bf102 100644 --- a/tools/assistant/tools/assistant/xbelsupport.h +++ b/tools/assistant/tools/assistant/xbelsupport.h @@ -48,6 +48,8 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) QT_FORWARD_DECLARE_CLASS(QStandardItem) +QT_BEGIN_NAMESPACE + class BookmarkModel; class XbelWriter : public QXmlStreamWriter @@ -84,4 +86,6 @@ private: BookmarkModel *listModel; }; +QT_END_NAMESPACE + #endif // XBELSUPPORT_H -- cgit v0.12 From b15b08e1f09320299a13bd4344663d6efb44d53f Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 3 Dec 2009 17:09:27 +0100 Subject: Assistant: Small refactoring to prepare for upcoming functional change. Reviewed-by: kh1 --- tools/assistant/tools/assistant/main.cpp | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 4d93a41..a80b4cc 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -132,6 +132,24 @@ QString indexFilesFolder(const QString &collectionFile) return indexFilesFolder; } +/* + * Returns the expected absolute file path of the cached collection file + * correspondinging to the given collection's file. + * It may or may not exist yet. + */ +QString cachedCollectionFile(const QHelpEngineCore &collection) +{ + const QString &filePath = collection.collectionFile(); + const QString &fileName = QFileInfo(filePath).fileName(); + const QString &cacheDir = CollectionConfiguration::cacheDir(collection); + const QString &dir = !cacheDir.isEmpty() + && CollectionConfiguration::cacheDirIsRelativeToCollection(collection) + ? QFileInfo(filePath).dir().absolutePath() + + QDir::separator() + cacheDir + : MainWindow::collectionFileDirectory(false, cacheDir); + return dir + QDir::separator() + fileName; +} + } // Anonymous namespace. int main(int argc, char *argv[]) @@ -238,26 +256,14 @@ int main(int argc, char *argv[]) return -1; } - QString fileName = QFileInfo(cmdCollectionFile).fileName(); - const QString &cacheDir = CollectionConfiguration::cacheDir(caller); - const QString dir = !cacheDir.isEmpty() - && CollectionConfiguration::cacheDirIsRelativeToCollection(caller) - ? QFileInfo(cmdCollectionFile).dir().absolutePath() - + QDir::separator() + cacheDir - : MainWindow::collectionFileDirectory(false, cacheDir); - - bool collectionFileExists = true; - QFileInfo fi(dir + QDir::separator() + fileName); - if (!fi.exists()) { - collectionFileExists = false; - if (!caller.copyCollectionFile(fi.absoluteFilePath())) { + const QString &cachedCollectionFilePath = cachedCollectionFile(caller); + if (!QFileInfo(cachedCollectionFilePath).exists()) { + if (!caller.copyCollectionFile(cachedCollectionFilePath)) { cmd.showMessage(caller.error(), true); return -1; } - } - - if (collectionFileExists) { - QHelpEngineCore user(fi.absoluteFilePath()); + } else { + QHelpEngineCore user(cachedCollectionFilePath); if (user.setupData()) { // some docs might have been un/registered bool docUpdate = CollectionConfiguration::docUpdatePending(caller); @@ -290,7 +296,7 @@ int main(int argc, char *argv[]) } } } - cmd.setCollectionFile(fi.absoluteFilePath()); + cmd.setCollectionFile(cachedCollectionFilePath); } if (!cmd.currentFilter().isEmpty()) { -- cgit v0.12 From 7e80ffdf19946280fede44e39a9a740202d4e8e6 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 3 Dec 2009 18:23:08 +0100 Subject: Assistant: Another small refactoring. Reviewed-by: kh1 --- tools/assistant/tools/assistant/main.cpp | 47 ++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index a80b4cc..d009210 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -150,6 +150,38 @@ QString cachedCollectionFile(const QHelpEngineCore &collection) return dir + QDir::separator() + fileName; } +bool synchronizeDocs(const QHelpEngineCore &collection, + QHelpEngineCore &cachedCollection) +{ + const QStringList &docs = collection.registeredDocumentations(); + const QStringList &cachedDocs = cachedCollection.registeredDocumentations(); + + /* + * Step 1: Ensure that the cached collection contains all docs that + * the collection contains. + */ + foreach (const QString &doc, docs) { + if (!cachedDocs.contains(doc)) { + if (!cachedCollection.registerDocumentation( + collection.documentationFileName(doc))) + return false; + } + } + + /* + * Step 2: Ensure that the cached collection contains no docs that + * the collection doesn't contain. + */ + QLatin1String intern("com.trolltech.com.assistantinternal-"); + foreach (const QString &doc, cachedDocs) { + if (!collection.contains(doc) && !doc.startsWith(intern) + && !cachedCollection.unregisterDocumentation(doc)) + return false; + } + + return true; +} + } // Anonymous namespace. int main(int argc, char *argv[]) @@ -278,20 +310,7 @@ int main(int argc, char *argv[]) docUpdate = true; if (docUpdate) { - QStringList callerDocs = caller.registeredDocumentations(); - foreach (const QString &doc, callerDocs) { - if (!userDocs.contains(doc)) { - user.registerDocumentation( - caller.documentationFileName(doc)); - } - } - - QLatin1String intern("com.trolltech.com.assistantinternal-"); - foreach (const QString &doc, userDocs) { - if (!callerDocs.contains(doc) && !doc.startsWith(intern)) - user.unregisterDocumentation(doc); - } - + synchronizeDocs(caller, user); CollectionConfiguration::setDocUpdatePending(caller, false); } } -- cgit v0.12 From c7739f7dd55a5a88e0efb00895f63d512cb16fe5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 27 Nov 2009 14:08:24 +0100 Subject: Don't force a crash handler in QtTest. In some cases, it's best to just let the crash happen straight away. Reviewed-by: Harald Fernengel --- src/testlib/qtestcase.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 9dea6dc..7ab7201 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -846,6 +846,9 @@ namespace QTest static int mouseDelay = -1; static int eventDelay = -1; static int keyVerbose = -1; +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + static bool noCrashHandler = false; +#endif void filter_unprintable(char *str) { @@ -976,6 +979,9 @@ static void qParseArgs(int argc, char *argv[]) " -keyevent-verbose : Turn on verbose messages for keyboard simulation\n" " -maxwarnings n : Sets the maximum amount of messages to output.\n" " 0 means unlimited, default: 2000\n" +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + " -nocrashhandler : Disables the crash handler\n" +#endif "\n" " Benchmark related options:\n" #ifdef QTESTLIB_USE_VALGRIND @@ -1056,6 +1062,10 @@ static void qParseArgs(int argc, char *argv[]) } else { QTestLog::setMaxWarnings(qToInt(argv[++i])); } +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + } else if (strcmp(argv[i], "-nocrashhandler") == 0) { + QTest::noCrashHandler = true; +#endif } else if (strcmp(argv[i], "-keyevent-verbose") == 0) { QTest::keyVerbose = 1; #ifdef QTESTLIB_USE_VALGRIND @@ -1661,7 +1671,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) #endif { #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) - FatalSignalHandler handler; + if (!noCrashHandler) + FatalSignalHandler handler; #endif qInvokeTestMethods(testObject); } -- cgit v0.12 From d1a28d167295958a4404fab37d60ef530c692590 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 3 Dec 2009 20:31:00 +0100 Subject: Fix QPlainTextEdit cursorUp/Down in combination with non-visible blocks QPlainTextEdit uses QTextCursor::movePosition to reposition the cursor after pageUp/Down. If this cursor happens to be in non-visual mode (the default), it might end up on an invisible block. This results in magically unfolding sections in Qt Creator. --- src/gui/widgets/qplaintextedit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 89fe7b8..b637c19 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -906,6 +906,7 @@ void QPlainTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCurso setTopBlock(block.blockNumber(), line); if (moveCursor) { + cursor.setVisualNavigation(true); // move using movePosition to keep the cursor's x lastY += verticalOffset(); bool moved = false; -- cgit v0.12 From 0a98247f5df26d9865a03fc6e5ad1ef7b88f9803 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 8 Sep 2009 09:54:41 -0300 Subject: doc: Fix qmake-manual warn_on/warn_off references Signed-off-by: Ademar de Souza Reis Jr --- doc/src/development/qmake-manual.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 9548848..549c801 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -1977,7 +1977,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_OFF This variable is not empty if the warn_off - \l{#TEMPLATE}{TEMPLATE} option is specified. The value of this + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. @@ -1985,7 +1985,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_ON This variable is not empty if the warn_on - \l{#TEMPLATE}{TEMPLATE} option is specified. + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. -- cgit v0.12 From 8364bfd6c4be53fba4aad41d5cbbc16ca02b2597 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 15 Sep 2009 11:18:23 -0300 Subject: doc: Fix typo in QEvent::ignore() documentation Signed-off-by: Ademar de Souza Reis Jr --- src/corelib/kernel/qcoreevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 9098515..996c331 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -331,7 +331,7 @@ QEvent::~QEvent() equivalent of calling setAccepted(false). Clearing the accept parameter indicates that the event receiver - does not want the event. Unwanted events might be propgated to the + does not want the event. Unwanted events might be propagated to the parent widget. \sa accept() -- cgit v0.12 From af265e912fab8b7ed5369a4c91f5a7ffd516441b Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:19:15 -0300 Subject: examples/dbus: update dbus-chat adaptor/interface files The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/dbus-chat/chat_adaptor.cpp | 6 +++--- examples/dbus/dbus-chat/chat_adaptor.h | 27 ++++++++++++--------------- examples/dbus/dbus-chat/chat_interface.cpp | 6 +++--- examples/dbus/dbus-chat/chat_interface.h | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/examples/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp index dce5d07..9415e5a 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.cpp +++ b/examples/dbus/dbus-chat/chat_adaptor.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h index 3266cef..9f0ad24 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.h +++ b/examples/dbus/dbus-chat/chat_adaptor.h @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,20 +49,17 @@ ** ****************************************************************************/ -#ifndef CHAT_ADAPTOR_H_142741156243605 -#define CHAT_ADAPTOR_H_142741156243605 +#ifndef CHAT_ADAPTOR_H_1257535021 +#define CHAT_ADAPTOR_H_1257535021 #include #include - -QT_BEGIN_NAMESPACE class QByteArray; template class QList; template class QMap; class QString; class QStringList; class QVariant; -QT_END_NAMESPACE /* * Adaptor class for interface com.trolltech.chat @@ -72,14 +69,14 @@ class ChatAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" +" \n" " \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" " \n" " \n" "") diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp index bf652ea..3131ae9 100644 --- a/examples/dbus/dbus-chat/chat_interface.cpp +++ b/examples/dbus/dbus-chat/chat_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h index 3962a23..e2798ed 100644 --- a/examples/dbus/dbus-chat/chat_interface.h +++ b/examples/dbus/dbus-chat/chat_interface.h @@ -38,18 +38,18 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#ifndef CHAT_INTERFACE_H_143021156243606 -#define CHAT_INTERFACE_H_143021156243606 +#ifndef CHAT_INTERFACE_H_1257535021 +#define CHAT_INTERFACE_H_1257535021 #include #include -- cgit v0.12 From 9fc350e8358f55c13169a9383bd2bd85592bb231 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:49:12 -0300 Subject: examples/dbus: update remotecontrolledcar example The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/remotecontrolledcar/car/car.pro | 2 +- .../dbus/remotecontrolledcar/car/car_adaptor.cpp | 22 ++-- .../dbus/remotecontrolledcar/car/car_adaptor_p.h | 97 ------------------ examples/dbus/remotecontrolledcar/car/main.cpp | 4 +- .../controller/car_interface.cpp | 15 ++- .../controller/car_interface_p.h | 114 --------------------- .../remotecontrolledcar/controller/controller.cpp | 4 +- .../remotecontrolledcar/controller/controller.h | 5 +- .../remotecontrolledcar/controller/controller.pro | 2 +- 9 files changed, 26 insertions(+), 239 deletions(-) delete mode 100644 examples/dbus/remotecontrolledcar/car/car_adaptor_p.h delete mode 100644 examples/dbus/remotecontrolledcar/controller/car_interface_p.h diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index 9b426d3..d362dc9 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -10,7 +10,7 @@ CONFIG += qdbus # Input # DBUS_ADAPTORS += car.xml -HEADERS += car.h car_adaptor_p.h +HEADERS += car.h car_adaptor.h SOURCES += car.cpp main.cpp car_adaptor.cpp # install diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp index 58f2ef0..8654663 100644 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_adaptor.h -a :car_adaptor.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -58,40 +58,40 @@ #include /* - * Implementation of adaptor class CarAdaptor + * Implementation of adaptor class CarInterfaceAdaptor */ -CarAdaptor::CarAdaptor(QObject *parent) +CarInterfaceAdaptor::CarInterfaceAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor setAutoRelaySignals(true); } -CarAdaptor::~CarAdaptor() +CarInterfaceAdaptor::~CarInterfaceAdaptor() { // destructor } -void CarAdaptor::accelerate() +void CarInterfaceAdaptor::accelerate() { // handle method call com.trolltech.Examples.CarInterface.accelerate QMetaObject::invokeMethod(parent(), "accelerate"); } -void CarAdaptor::decelerate() +void CarInterfaceAdaptor::decelerate() { // handle method call com.trolltech.Examples.CarInterface.decelerate QMetaObject::invokeMethod(parent(), "decelerate"); } -void CarAdaptor::turnLeft() +void CarInterfaceAdaptor::turnLeft() { // handle method call com.trolltech.Examples.CarInterface.turnLeft QMetaObject::invokeMethod(parent(), "turnLeft"); } -void CarAdaptor::turnRight() +void CarInterfaceAdaptor::turnRight() { // handle method call com.trolltech.Examples.CarInterface.turnRight QMetaObject::invokeMethod(parent(), "turnRight"); diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h b/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h deleted file mode 100644 index 6d98c5b..0000000 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** This file may have been hand-edited. Look for HAND-EDIT comments -** before re-generating it. -** -****************************************************************************/ - -#ifndef CAR_ADAPTOR_P_H_1157030132 -#define CAR_ADAPTOR_P_H_1157030132 - -#include -#include - -QT_BEGIN_NAMESPACE -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; -QT_END_NAMESPACE - -/* - * Adaptor class for interface com.trolltech.Examples.CarInterface - */ -class CarAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface") - Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") -public: - CarAdaptor(QObject *parent); - virtual ~CarAdaptor(); - -public: // PROPERTIES -public Q_SLOTS: // METHODS - void accelerate(); - void decelerate(); - void turnLeft(); - void turnRight(); -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -#endif diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp index c2ef91c..456ff11 100644 --- a/examples/dbus/remotecontrolledcar/car/main.cpp +++ b/examples/dbus/remotecontrolledcar/car/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "car.h" -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) view.resize(400, 300); view.show(); - new CarAdaptor(car); + new CarInterfaceAdaptor(car); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Car", car); connection.registerService("com.trolltech.CarExample"); diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp index eeeb162..14258d6 100644 --- a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_interface.h -p :car_interface.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,18 +49,17 @@ ** ****************************************************************************/ -#include "car_interface_p.h" - +#include "car_interface.h" /* - * Implementation of interface class CarInterface + * Implementation of interface class ComTrolltechExamplesCarInterfaceInterface */ -CarInterface::CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) +ComTrolltechExamplesCarInterfaceInterface::ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } -CarInterface::~CarInterface() +ComTrolltechExamplesCarInterfaceInterface::~ComTrolltechExamplesCarInterfaceInterface() { } diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h b/examples/dbus/remotecontrolledcar/controller/car_interface_p.h deleted file mode 100644 index f7e22ac..0000000 --- a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -** -****************************************************************************/ - -#ifndef CAR_INTERFACE_P_H_1156853585 -#define CAR_INTERFACE_P_H_1156853585 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface com.trolltech.Examples.CarInterface - */ -class CarInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.trolltech.Examples.CarInterface"; } - -public: - CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~CarInterface(); - -public Q_SLOTS: // METHODS - inline QDBusReply accelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("accelerate"), argumentList); - } - - inline QDBusReply decelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("decelerate"), argumentList); - } - - inline QDBusReply turnLeft() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnLeft"), argumentList); - } - - inline QDBusReply turnRight() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnRight"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -namespace com { - namespace trolltech { - namespace Examples { - typedef ::CarInterface CarInterface; - } - } -} -#endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp index fd6aa13..a3d7c61 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.cpp +++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp @@ -42,13 +42,13 @@ #include #include "controller.h" -#include "car_interface_p.h" +#include "car_interface.h" Controller::Controller(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - car = new CarInterface("com.trolltech.CarExample", "/Car", + car = new com::trolltech::Examples::CarInterface("com.trolltech.CarExample", "/Car", QDBusConnection::sessionBus(), this); startTimer(1000); } diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h index aa4cd43..b2265d2 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.h +++ b/examples/dbus/remotecontrolledcar/controller/controller.h @@ -43,8 +43,7 @@ #define CONTROLLER_H #include "ui_controller.h" - -class CarInterface; +#include "car_interface.h" class Controller : public QWidget { @@ -64,7 +63,7 @@ private slots: private: Ui::Controller ui; - CarInterface *car; + com::trolltech::Examples::CarInterface *car; }; #endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 159e3b1..375b9d7 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -11,7 +11,7 @@ CONFIG += qdbus # Input # DBUS_INTERFACES += car.xml FORMS += controller.ui -HEADERS += car_interface_p.h controller.h +HEADERS += car_interface.h controller.h SOURCES += main.cpp car_interface.cpp controller.cpp # install -- cgit v0.12 From 7c5d48e84159abd0a72eadb2e14e4c3b1441fdfb Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 4 Dec 2009 10:40:13 +0100 Subject: Assistant: More small refactorings + compile fix. --- tools/assistant/tools/assistant/main.cpp | 86 ++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index d009210..536095c 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -150,7 +150,7 @@ QString cachedCollectionFile(const QHelpEngineCore &collection) return dir + QDir::separator() + fileName; } -bool synchronizeDocs(const QHelpEngineCore &collection, +bool synchronizeDocs(QHelpEngineCore &collection, QHelpEngineCore &cachedCollection) { const QStringList &docs = collection.registeredDocumentations(); @@ -174,7 +174,7 @@ bool synchronizeDocs(const QHelpEngineCore &collection, */ QLatin1String intern("com.trolltech.com.assistantinternal-"); foreach (const QString &doc, cachedDocs) { - if (!collection.contains(doc) && !doc.startsWith(intern) + if (!docs.contains(doc) && !doc.startsWith(intern) && !cachedCollection.unregisterDocumentation(doc)) return false; } @@ -182,28 +182,62 @@ bool synchronizeDocs(const QHelpEngineCore &collection, return true; } -} // Anonymous namespace. +bool removeSearchIndex(const QString &collectionFile) +{ + QString path = QFileInfo(collectionFile).path(); + path += QLatin1Char('/') + indexFilesFolder(collectionFile); -int main(int argc, char *argv[]) + QLocalSocket localSocket; + localSocket.connectToServer(QString(QLatin1String("QtAssistant%1")) + .arg(QLatin1String(QT_VERSION_STR))); + + QDir dir(path); // check if there is no other instance ruinning + if (!dir.exists() || localSocket.waitForConnected()) + return false; + + QStringList lst = dir.entryList(QDir::Files | QDir::Hidden); + foreach (const QString &item, lst) + dir.remove(item); + return true; +} + +bool checkForSqlite(CmdLineParser &cmd) { -#ifndef Q_OS_WIN - // First do a quick search for arguments that imply command-line mode. + QSqlDatabase db; + QStringList sqlDrivers(db.drivers()); + if (!sqlDrivers.contains(QLatin1String("QSQLITE"))) { + cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"), + true); + return false; + } + return true; +} + +bool useGui(int argc, char *argv[]) +{ + bool gui = true; +#ifndef Q_OS_WIN + // Look for arguments that imply command-line mode. const char * cmdModeArgs[] = { "-help", "-register", "-unregister", "-remove-search-index" }; - bool useGui = true; for (int i = 1; i < argc; ++i) { for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) { if(strcmp(argv[i], cmdModeArgs[j]) == 0) { - useGui = false; + gui = false; break; } } } - QApplication a(argc, argv, useGui); -#else - QApplication a(argc, argv); #endif + return gui; +} + +} // Anonymous namespace. + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv, useGui(argc, argv)); a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins")); CmdLineParser cmd(a.arguments()); @@ -247,38 +281,16 @@ int main(int argc, char *argv[]) return 0; } + // TODO: Also remove search index of cached collection file? if (cmd.removeSearchIndex()) { QString file = cmdCollectionFile; if (file.isEmpty()) file = MainWindow::defaultHelpCollectionFileName(); - QString path = QFileInfo(file).path(); - path += QLatin1Char('/') + indexFilesFolder(file); - - QLocalSocket localSocket; - localSocket.connectToServer(QString(QLatin1String("QtAssistant%1")) - .arg(QLatin1String(QT_VERSION_STR))); - - QDir dir(path); // check if there is no other instance ruinning - if (!localSocket.waitForConnected() && dir.exists()) { - QStringList lst = dir.entryList(QDir::Files | QDir::Hidden); - foreach (const QString &item, lst) - dir.remove(item); - return 0; - } else { - return -1; - } + return removeSearchIndex(file) ? 0 : EXIT_FAILURE; } - { - QSqlDatabase db; - QStringList sqlDrivers(db.drivers()); - if (sqlDrivers.isEmpty() - || !sqlDrivers.contains(QLatin1String("QSQLITE"))) { - cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"), - true); - return -1; - } - } + if (!checkForSqlite(cmd)) + return EXIT_FAILURE; if (!cmdCollectionFile.isEmpty()) { QHelpEngineCore caller(cmdCollectionFile); -- cgit v0.12 From 067cab5af9172335c07b48c42e6a665d5da9b54d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 4 Dec 2009 10:53:51 +0100 Subject: Cocoa: impl. performance boost for dnd It turns out that registering drag types for each NSView that can receive drop events is _really_ slow. And many widget in Qt subscribe for DnD (QTextEdit, QScrollArea, etc), so the result is an application that will spend startup time preparing for DnD. For some edge cases, we're talking several seconds! This patch removes this overhead by moving drag type registering out of NSView, and into NSWindow (that is, QCocoaWindow and QCocoaPanel). Task-number: QT-1586 Reviewed-by: Prasanth --- src/gui/kernel/qcocoapanel_mac_p.h | 6 ++ src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 126 +++++++++++++++++++++++ src/gui/kernel/qcocoaview_mac.mm | 68 ++---------- src/gui/kernel/qcocoaview_mac_p.h | 2 - src/gui/kernel/qcocoawindow_mac_p.h | 3 + src/gui/kernel/qnsthemeframe_mac_p.h | 2 +- src/gui/kernel/qwidget_mac.mm | 9 +- 7 files changed, 151 insertions(+), 65 deletions(-) diff --git a/src/gui/kernel/qcocoapanel_mac_p.h b/src/gui/kernel/qcocoapanel_mac_p.h index 69dca1e..f35d9fb 100644 --- a/src/gui/kernel/qcocoapanel_mac_p.h +++ b/src/gui/kernel/qcocoapanel_mac_p.h @@ -54,10 +54,16 @@ #ifdef QT_MAC_USE_COCOA #import +QT_FORWARD_DECLARE_CLASS(QStringList); + @interface QT_MANGLE_NAMESPACE(QCocoaPanel) : NSPanel { bool leftButtonIsRightButton; + QStringList *currentCustomDragTypes; } + (Class)frameViewClassForStyleMask:(NSUInteger)styleMask; +- (void)registerDragTypes; + @end #endif + diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index f347240..8dd03aa 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -54,8 +54,31 @@ QT_BEGIN_NAMESPACE extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm extern QPointer qt_button_down; //qapplication_mac.cpp +extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp + +Q_GLOBAL_STATIC(QPointer, currentDragTarget); + QT_END_NAMESPACE +- (id)initWithContentRect:(NSRect)contentRect + styleMask:(NSUInteger)windowStyle + backing:(NSBackingStoreType)bufferingType + defer:(BOOL)deferCreation +{ + self = [super initWithContentRect:contentRect styleMask:windowStyle + backing:bufferingType defer:deferCreation]; + if (self) { + currentCustomDragTypes = 0; + } + return self; +} + +- (void)dealloc +{ + delete currentCustomDragTypes; + [super dealloc]; +} + - (BOOL)canBecomeKeyWindow { QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; @@ -185,3 +208,106 @@ QT_END_NAMESPACE return [super frameViewClassForStyleMask:styleMask]; } +-(void)registerDragTypes +{ + // Calling registerForDraggedTypes below is slow, so only do + // it once for each window, or when the custom types change. + QMacCocoaAutoReleasePool pool; + const QStringList& customTypes = qEnabledDraggedTypes(); + if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) { + if (currentCustomDragTypes == 0) + currentCustomDragTypes = new QStringList(); + *currentCustomDragTypes = customTypes; + const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; + NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, + NSFilenamesPboardType, NSStringPboardType, + NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, + NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, + NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, + NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, + NSURLPboardType, NSPDFPboardType, NSVCardPboardType, + NSFilesPromisePboardType, NSInkTextPboardType, + NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; + // Add custom types supported by the application. + for (int i = 0; i < customTypes.size(); i++) { + [supportedTypes addObject:reinterpret_cast(QCFString::toCFStringRef(customTypes[i]))]; + } + [self registerForDraggedTypes:supportedTypes]; + } +} + +- (QWidget *)dragTargetHitTest:(id )sender +{ + // Do a hittest to find the NSView under the + // mouse, and return the corresponding QWidget: + NSPoint windowPoint = [sender draggingLocation]; + NSView *candidateView = [[self contentView] hitTest:windowPoint]; + if (![candidateView isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) + return 0; + return [static_cast(candidateView) qt_qwidget]; +} + +- (NSDragOperation)draggingEntered:(id )sender +{ + // The user dragged something into the window. Send a draggingEntered message + // to the QWidget under the mouse. As the drag moves over the window, and over + // different widgets, we will handle enter and leave events from within + // draggingUpdated below. The reason why we handle this ourselves rather than + // subscribing for drag events directly in QCocoaView is that calling + // registerForDraggedTypes on the views will severly degrade initialization time + // for an application that uses a lot of drag subscribing widgets. + + QWidget *target = [self dragTargetHitTest:sender]; + if (!target) + return [super draggingEntered:sender]; + if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) + return NSDragOperationNone; + + *currentDragTarget() = target; + return [reinterpret_cast((*currentDragTarget())->winId()) draggingEntered:sender]; + } + +- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender +{ + QWidget *target = [self dragTargetHitTest:sender]; + if (!target) + return [super draggingUpdated:sender]; + + if (target == *currentDragTarget()) { + // The drag continues to move over the widget that we have sendt + // a draggingEntered message to. So just update the view: + return [reinterpret_cast((*currentDragTarget())->winId()) draggingUpdated:sender]; + } else { + // The widget under the mouse has changed. + // So we need to fake enter/leave events: + if (*currentDragTarget()) + [reinterpret_cast((*currentDragTarget())->winId()) draggingExited:sender]; + if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) { + *currentDragTarget() = 0; + return NSDragOperationNone; + } + *currentDragTarget() = target; + return [reinterpret_cast((*currentDragTarget())->winId()) draggingEntered:sender]; + } +} + +- (void)draggingExited:(id < NSDraggingInfo >)sender +{ + if (*currentDragTarget()) + [reinterpret_cast((*currentDragTarget())->winId()) draggingExited:sender]; + else + [super draggingExited:sender]; + *currentDragTarget() = 0; +} + +- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender +{ + BOOL dropAccepted = NO; + if (*currentDragTarget()) + dropAccepted = [reinterpret_cast((*currentDragTarget())->winId()) performDragOperation:sender]; + else + return [super performDragOperation:sender]; + *currentDragTarget() = 0; + return dropAccepted; +} + diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index ddd8ca6..212684b 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -81,7 +81,6 @@ Q_GLOBAL_STATIC(DnDParams, qMacDnDParams); extern void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos); // qcursor_mac.mm extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm -extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp extern QPointer qt_mouseover; //qapplication_mac.mm extern QPointer qt_button_down; //qapplication_mac.cpp @@ -212,7 +211,6 @@ extern "C" { composingText = new QString(); composing = false; sendKeyEvents = true; - currentCustomTypes = 0; [self setHidden:YES]; return self; } @@ -227,34 +225,6 @@ extern "C" { object:self]; } --(void)registerDragTypes -{ - QMacCocoaAutoReleasePool pool; - // Calling registerForDraggedTypes is slow, so only do it once for each widget - // or when the custom types change. - const QStringList& customTypes = qEnabledDraggedTypes(); - if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) { - if (currentCustomTypes == 0) - currentCustomTypes = new QStringList(); - *currentCustomTypes = customTypes; - const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; - NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, - NSFilenamesPboardType, NSStringPboardType, - NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, - NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, - NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, - NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, - NSURLPboardType, NSPDFPboardType, NSVCardPboardType, - NSFilesPromisePboardType, NSInkTextPboardType, - NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; - // Add custom types supported by the application. - for (int i = 0; i < customTypes.size(); i++) { - [supportedTypes addObject:reinterpret_cast(QCFString::toCFStringRef(customTypes[i]))]; - } - [self registerForDraggedTypes:supportedTypes]; - } -} - - (void)resetCursorRects { QWidget *cursorWidget = qwidget; @@ -300,15 +270,9 @@ extern "C" { - (NSDragOperation)draggingEntered:(id )sender { - if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false) - return NSDragOperationNone; + // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly + // from Cocoa. They modify the drag target, and might fake enter/leave events. NSPoint windowPoint = [sender draggingLocation]; - if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { - // pass the drag enter event to the view underneath. - NSView *candidateView = [[[self window] contentView] hitTest:windowPoint]; - if (candidateView && candidateView != self) - return [candidateView draggingEntered:sender]; - } dragEnterSequence = [sender draggingSequenceNumber]; [self addDropData:sender]; QMimeData *mimeData = dropData; @@ -360,13 +324,9 @@ extern "C" { - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender { + // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly + // from Cocoa. They modify the drag target, and might fake enter/leave events. NSPoint windowPoint = [sender draggingLocation]; - if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { - // pass the drag move event to the view underneath. - NSView *candidateView = [[[self window] contentView] hitTest:windowPoint]; - if (candidateView && candidateView != self) - return [candidateView draggingUpdated:sender]; - } // in cases like QFocusFrame, the view under the mouse might // not have received the drag enter. Generate a synthetic // drag enter event for that view. @@ -414,14 +374,10 @@ extern "C" { - (void)draggingExited:(id < NSDraggingInfo >)sender { + // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly + // from Cocoa. They modify the drag target, and might fake enter/leave events. + Q_UNUSED(sender); dragEnterSequence = -1; - if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { - // try sending the leave event to the last view which accepted drag enter. - DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; - NSView *candidateView = [[[self window] contentView] hitTest:dndParams->activeDragEnterPos]; - if (candidateView && candidateView != self) - return [candidateView draggingExited:sender]; - } // drag enter event was rejected, so ignore the move event. if (dropData) { QDragLeaveEvent de; @@ -432,14 +388,10 @@ extern "C" { - (BOOL)performDragOperation:(id )sender { + // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly + // from Cocoa. They modify the drag target, and might fake enter/leave events. NSPoint windowPoint = [sender draggingLocation]; dragEnterSequence = -1; - if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { - // pass the drop event to the view underneath. - NSView *candidateView = [[[self window] contentView] hitTest:windowPoint]; - if (candidateView && candidateView != self) - return [candidateView performDragOperation:sender]; - } [self addDropData:sender]; NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; @@ -469,8 +421,6 @@ extern "C" { { delete composingText; [[NSNotificationCenter defaultCenter] removeObserver:self]; - delete currentCustomTypes; - [self unregisterDraggedTypes]; [super dealloc]; } diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index d549177..e6ff423 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -87,7 +87,6 @@ Q_GUI_EXPORT int composingLength; bool sendKeyEvents; QString *composingText; - QStringList *currentCustomTypes; NSInteger dragEnterSequence; } - (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate; @@ -97,7 +96,6 @@ Q_GUI_EXPORT - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender; - (void)draggingExited:(id < NSDraggingInfo >)sender; - (BOOL)performDragOperation:(id )sender; -- (void)registerDragTypes; - (void)removeDropData; - (void)addDropData:(id )sender; - (void)setSupportedActions:(NSDragOperation)actions; diff --git a/src/gui/kernel/qcocoawindow_mac_p.h b/src/gui/kernel/qcocoawindow_mac_p.h index 91c5d4e..ea3461c 100644 --- a/src/gui/kernel/qcocoawindow_mac_p.h +++ b/src/gui/kernel/qcocoawindow_mac_p.h @@ -70,9 +70,12 @@ QT_FORWARD_DECLARE_CLASS(QStringList); @interface QT_MANGLE_NAMESPACE(QCocoaWindow) : NSWindow { bool leftButtonIsRightButton; + QStringList *currentCustomDragTypes; } + (Class)frameViewClassForStyleMask:(NSUInteger)styleMask; +- (void)registerDragTypes; + @end #endif diff --git a/src/gui/kernel/qnsthemeframe_mac_p.h b/src/gui/kernel/qnsthemeframe_mac_p.h index af1406b..c8c7f4a 100644 --- a/src/gui/kernel/qnsthemeframe_mac_p.h +++ b/src/gui/kernel/qnsthemeframe_mac_p.h @@ -157,7 +157,7 @@ - (void)resetCursorRects; - (char)shouldBeTreatedAsInkEvent:fp8; - (char)_shouldBeTreatedAsInkEventInInactiveWindow:fp8; -- hitTest:(struct _NSPoint)fp8; +//- hitTest:(struct _NSPoint)fp8; // collides with hittest in qcocoasharedwindowmethods_mac_p.h - (NSRect)_leftGroupRect; - (NSRect)_rightGroupRect; - (void)_updateWidgets; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 1907cca..c75358d 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4554,9 +4554,12 @@ void QWidgetPrivate::registerDropSite(bool on) #ifndef QT_MAC_USE_COCOA SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); #else - NSView *view = qt_mac_nativeview_for(q); - if (on && [view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { - [static_cast(view) registerDragTypes]; + NSWindow *win = qt_mac_window_for(q); + if (on) { + if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaWindow) class]]) + [static_cast(win) registerDragTypes]; + else if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaPanel) class]]) + [static_cast(win) registerDragTypes]; } #endif } -- cgit v0.12 From 08de984f0ed5b6e13cd802256df859778f842bbd Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 4 Dec 2009 11:35:14 +0100 Subject: Cocoa: amend dnd optimization: 067cab5af A couple of minutes after commiting 067cab5af, I realized I need to act a bit more nice to native NSViews that also might exist in the window: Let NSWindow handle the dnd drop if the view is not a QWidget (and not also if it is a QWidget, but not subscribing to dnd) Task-number: QT-1586 --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 8dd03aa..cc5839c 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -293,21 +293,27 @@ QT_END_NAMESPACE - (void)draggingExited:(id < NSDraggingInfo >)sender { - if (*currentDragTarget()) + QWidget *target = [self dragTargetHitTest:sender]; + if (!target) + return [super draggingExited:sender]; + + if (*currentDragTarget()) { [reinterpret_cast((*currentDragTarget())->winId()) draggingExited:sender]; - else - [super draggingExited:sender]; - *currentDragTarget() = 0; + *currentDragTarget() = 0; + } } - (BOOL)performDragOperation:(id < NSDraggingInfo >)sender { - BOOL dropAccepted = NO; - if (*currentDragTarget()) - dropAccepted = [reinterpret_cast((*currentDragTarget())->winId()) performDragOperation:sender]; - else + QWidget *target = [self dragTargetHitTest:sender]; + if (!target) return [super performDragOperation:sender]; - *currentDragTarget() = 0; - return dropAccepted; + + BOOL dropResult = NO; + if (*currentDragTarget()) { + dropResult = [reinterpret_cast((*currentDragTarget())->winId()) performDragOperation:sender]; + *currentDragTarget() = 0; + } + return dropResult; } -- cgit v0.12 From cbdf3dc7508131e31f1d221e7b6f44d4714d3caa Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 4 Dec 2009 15:54:49 +0100 Subject: Fix compilation of the QObject test The hardcoded generated include patch was wrong. Also don't error if the MOC_OUTPUT_REVISION change. The file will be updated if needed if ever the test start failing. --- tests/auto/qobject/moc_oldnormalizeobject.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/auto/qobject/moc_oldnormalizeobject.cpp b/tests/auto/qobject/moc_oldnormalizeobject.cpp index 4f590ae..bde9c39 100644 --- a/tests/auto/qobject/moc_oldnormalizeobject.cpp +++ b/tests/auto/qobject/moc_oldnormalizeobject.cpp @@ -2,19 +2,14 @@ ** Meta object code from reading C++ file 'oldnormalizeobject.h' ** ** Created: Wed Nov 18 11:43:05 2009 -** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) +** by: The Qt Meta Object Compiler version 62 (Qt 4.6.0) ** -** WARNING! All changes made in this file will be lost! *****************************************************************************/ -#include "../../../../../../master/tests/auto/qobject/oldnormalizeobject.h" -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'oldnormalizeobject.h' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 62 -#error "This file was generated using the moc from 4.7.0. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif +// Yhis file was generated from moc version 4.6 to test binary compatibility +// It should *not* be generated by the current moc + +#include "oldnormalizeobject.h" QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_OldNormalizeObject[] = { -- cgit v0.12 From 35a740fa663d4669a45ada9c37c46546e59bbb82 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 7 Dec 2009 13:12:59 +0100 Subject: Cleanup, no functional change. --- tools/assistant/lib/qhelpsearchquerywidget.cpp | 53 +++++++++++++++----------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index 10d5470..4d1b336 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -41,8 +41,6 @@ #include "qhelpsearchquerywidget.h" -#include - #include #include #include @@ -101,8 +99,9 @@ private: }; QHelpSearchQueryWidgetPrivate() - : QObject(), simpleSearch(true), - searchCompleter(new CompleterModel(this), this) + : QObject() + , simpleSearch(true) + , searchCompleter(new CompleterModel(this), this) { searchButton = 0; advancedSearchWidget = 0; @@ -179,8 +178,8 @@ private: } } - void nextOrPrevQuery(int maxOrMinIndex, int addend, - QToolButton *thisButton, QToolButton *otherButton) + void nextOrPrevQuery(int maxOrMinIndex, int addend, QToolButton *thisButton, + QToolButton *otherButton) { QueryHistory *queryHist; QList lineEdits; @@ -190,7 +189,7 @@ private: } else { queryHist = &complexQueries; lineEdits << allQuery << atLeastQuery << similarQuery - << withoutQuery << exactQuery; + << withoutQuery << exactQuery; } foreach (QLineEdit *lineEdit, lineEdits) lineEdit->clear(); @@ -235,11 +234,11 @@ private: void enableOrDisableToolButtons() { - const QueryHistory &queryHist = - simpleSearch ? simpleQueries : complexQueries; + const QueryHistory &queryHist = simpleSearch ? simpleQueries + : complexQueries; prevQueryButton->setEnabled(queryHist.curQuery > 0); - nextQueryButton->setEnabled(queryHist.curQuery < - queryHist.queries.size() - 1); + nextQueryButton->setEnabled(queryHist.curQuery + < queryHist.queries.size() - 1); } private slots: @@ -263,20 +262,22 @@ private slots: QList queryList; #if !defined(QT_CLUCENE_SUPPORT) queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, - QStringList(defaultQuery->text()))); + QStringList(defaultQuery->text()))); #else if (defaultQuery->isEnabled()) { queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, - buildTermList(defaultQuery->text()))); + buildTermList(defaultQuery->text()))); } else { const QRegExp exp(QLatin1String("\\s+")); - QStringList lst = similarQuery->text().split(exp, QString::SkipEmptyParts); + QStringList lst = similarQuery->text().split(exp, + QString::SkipEmptyParts); if (!lst.isEmpty()) { QStringList fuzzy; foreach (const QString term, lst) fuzzy += buildTermList(term); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, fuzzy)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, + fuzzy)); } lst = withoutQuery->text().split(exp, QString::SkipEmptyParts); @@ -284,13 +285,15 @@ private slots: QStringList without; foreach (const QString term, lst) without.append(term); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, without)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, + without)); } if (!exactQuery->text().isEmpty()) { QString phrase = exactQuery->text().remove(QLatin1Char('\"')); phrase = phrase.simplified(); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, QStringList(phrase))); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, + QStringList(phrase))); } lst = allQuery->text().split(exp, QString::SkipEmptyParts); @@ -306,7 +309,8 @@ private slots: QStringList atLeast; foreach (const QString term, lst) atLeast += buildTermList(term); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, atLeast)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, + atLeast)); } } #endif @@ -320,8 +324,9 @@ private slots: void nextQuery() { - nextOrPrevQuery((simpleSearch ? simpleQueries : complexQueries).queries.size() - 1, - 1, nextQueryButton, prevQueryButton); + nextOrPrevQuery((simpleSearch ? simpleQueries + : complexQueries).queries.size() - 1, 1, nextQueryButton, + prevQueryButton); } void prevQuery() @@ -365,8 +370,9 @@ private: \fn void QHelpSearchQueryWidget::search() This signal is emitted when a the user has the search button invoked. - After reciving the signal you can ask the QHelpSearchQueryWidget for the build list - of QHelpSearchQuery's that you may pass to the QHelpSearchEngine's search() function. + After reciving the signal you can ask the QHelpSearchQueryWidget for the + build list of QHelpSearchQuery's that you may pass to the QHelpSearchEngine's + search() function. */ /*! @@ -494,7 +500,8 @@ QList QHelpSearchQueryWidget::query() const QList() : queryHist.queries.last(); } -/*! \reimp +/*! + \reimp */ void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent) { -- cgit v0.12 From 5cd4bad136878af59d368b1749a76b9cbbd246ec Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 7 Dec 2009 15:02:01 +0100 Subject: Fix performance issue with live resize Calling [NSView addTrackingArea] is slow. So doing this for views that are not even visible on screen is unnecesary. This patch will greatly improve the speed for some (perhaps extreme) cases. Task-number: QT-1610 Reviewed-by: MortenS --- src/gui/kernel/qcocoaview_mac.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 212684b..1039a75 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -555,6 +555,10 @@ extern "C" { - (void)updateTrackingAreas { + // [NSView addTrackingArea] is slow, so bail out early if we can: + if (NSIsEmptyRect([self visibleRect])) + return; + QMacCocoaAutoReleasePool pool; if (NSArray *trackingArray = [self trackingAreas]) { NSUInteger size = [trackingArray count]; -- cgit v0.12 From e413a4fee2c09448e9498b000a7ff88e68c823d3 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 7 Dec 2009 15:26:20 +0100 Subject: Assistant: Logical re-structuring of start-up code. Reviewed-by: kh1 --- .../tools/assistant/helpenginewrapper.cpp | 8 +- .../assistant/tools/assistant/helpenginewrapper.h | 3 +- tools/assistant/tools/assistant/main.cpp | 274 +++++++++++---------- tools/assistant/tools/assistant/mainwindow.cpp | 1 - .../tools/shared/collectionconfiguration.cpp | 23 +- .../tools/shared/collectionconfiguration.h | 11 +- 6 files changed, 172 insertions(+), 148 deletions(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index d399d1e..3835a63 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -96,6 +96,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) this, SIGNAL(currentFilterChanged(QString))); connect(m_helpEngine, SIGNAL(setupFinished()), this, SIGNAL(setupFinished())); + initFileSystemWatchers(); } void HelpEngineWrapper::initFileSystemWatchers() @@ -146,6 +147,7 @@ const QString HelpEngineWrapper::collectionFile() const bool HelpEngineWrapper::registerDocumentation(const QString &docFile) { + assertDocFilesWatched(); if (!m_helpEngine->registerDocumentation(docFile)) return false; m_qchWatcher->addPath(docFile); @@ -155,11 +157,11 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile) bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) { - const QString &internalFile = - m_helpEngine->documentationFileName(namespaceName); + assertDocFilesWatched(); + const QString &file = m_helpEngine->documentationFileName(namespaceName); if (!m_helpEngine->unregisterDocumentation(namespaceName)) return false; - m_qchWatcher->removePath(internalFile); + m_qchWatcher->removePath(file); assertDocFilesWatched(); return true; } diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index 1fc9eb6..f827d95 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -75,8 +75,6 @@ public: static HelpEngineWrapper &instance(const QString &collectionFile = QString()); static void removeInstance(); - void initFileSystemWatchers(); - // Forwarded help engine member functions, possibly enriched. QHelpSearchEngine *searchEngine() const; QHelpContentModel *contentModel() const; @@ -200,6 +198,7 @@ private slots: private: HelpEngineWrapper(const QString &collectionFile); + void initFileSystemWatchers(); void assertDocFilesWatched(); static HelpEngineWrapper *helpEngineWrapper; diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 536095c..be13b0a 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -41,11 +41,12 @@ #include #include +#include #include +#include +#include #include -#include #include -#include #include #include @@ -105,20 +106,14 @@ updateUserCollection(QHelpEngineCore& user, const QHelpEngineCore& caller) return true; } -bool -referencedHelpFilesExistAll(QHelpEngineCore& user, QStringList& nameSpaces) +void stripNonexistingDocs(QHelpEngineCore& collection) { - QFileInfo fi; - int counter = nameSpaces.count(); - for (int i = counter; --i >= 0;) { - const QString& nameSpace = nameSpaces.at(i); - fi.setFile(user.documentationFileName(nameSpace)); - if (!fi.exists() || !fi.isFile()) { - user.unregisterDocumentation(nameSpace); - nameSpaces.removeAll(nameSpace); - } + const QStringList &namespaces = collection.registeredDocumentations(); + foreach (const QString &ns, namespaces) { + QFileInfo fi(collection.documentationFileName(ns)); + if (!fi.exists() || !fi.isFile()) + collection.unregisterDocumentation(ns); } - return (counter != nameSpaces.count()) ? false : true; } QString indexFilesFolder(const QString &collectionFile) @@ -137,7 +132,7 @@ QString indexFilesFolder(const QString &collectionFile) * correspondinging to the given collection's file. * It may or may not exist yet. */ -QString cachedCollectionFile(const QHelpEngineCore &collection) +QString constructCachedCollectionFilePath(const QHelpEngineCore &collection) { const QString &filePath = collection.collectionFile(); const QString &fileName = QFileInfo(filePath).fileName(); @@ -151,33 +146,34 @@ QString cachedCollectionFile(const QHelpEngineCore &collection) } bool synchronizeDocs(QHelpEngineCore &collection, - QHelpEngineCore &cachedCollection) + QHelpEngineCore &cachedCollection, + CmdLineParser &cmd) { + const QDateTime &lastCollectionRegisterTime = + CollectionConfiguration::lastRegisterTime(collection); + if (!lastCollectionRegisterTime.isValid() || lastCollectionRegisterTime + < CollectionConfiguration::lastRegisterTime(cachedCollection)) + return true; + const QStringList &docs = collection.registeredDocumentations(); const QStringList &cachedDocs = cachedCollection.registeredDocumentations(); /* - * Step 1: Ensure that the cached collection contains all docs that - * the collection contains. + * Ensure that the cached collection contains all docs that + * the collection contains. */ foreach (const QString &doc, docs) { if (!cachedDocs.contains(doc)) { - if (!cachedCollection.registerDocumentation( - collection.documentationFileName(doc))) + const QString &docFile = collection.documentationFileName(doc); + if (!cachedCollection.registerDocumentation(docFile)) { + cmd.showMessage(QObject::tr("Error registering documentation file '%1': %2"). + arg(docFile).arg(cachedCollection.error()), true); return false; + } } } - /* - * Step 2: Ensure that the cached collection contains no docs that - * the collection doesn't contain. - */ - QLatin1String intern("com.trolltech.com.assistantinternal-"); - foreach (const QString &doc, cachedDocs) { - if (!docs.contains(doc) && !doc.startsWith(intern) - && !cachedCollection.unregisterDocumentation(doc)) - return false; - } + CollectionConfiguration::updateLastRegisterTime(cachedCollection); return true; } @@ -233,6 +229,56 @@ bool useGui(int argc, char *argv[]) return gui; } +bool registerDocumentation(QHelpEngineCore &collection, CmdLineParser &cmd, + bool printSuccess) +{ + if (!collection.registerDocumentation(cmd.helpFile())) { + cmd.showMessage( + QObject::tr("Could not register documentation file\n%1\n\nReason:\n%2") + .arg(cmd.helpFile()).arg(collection.error()), true); + return false; + } + if (printSuccess) + cmd.showMessage(QObject::tr("Documentation successfully registered."), + false); + CollectionConfiguration::updateLastRegisterTime(collection); + return true; +} + +bool unregisterDocumentation(QHelpEngineCore &collection, + const QString &namespaceName, CmdLineParser &cmd, bool printSuccess) +{ + if (!collection.unregisterDocumentation(namespaceName)) { + cmd.showMessage(QObject::tr("Could not unregister documentation" + " file\n%1\n\nReason:\n%2"). + arg(cmd.helpFile()).arg(collection.error()), true); + return false; + } + updateLastPagesOnUnregister(collection, namespaceName); + if (printSuccess) + cmd.showMessage(QObject::tr("Documentation successfully unregistered."), + false); + return true; +} + +void setupTranslations(QApplication &app) +{ + const QString& locale = QLocale::system().name(); + QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + + QTranslator translator(0); + translator.load(QLatin1String("assistant_") + locale, resourceDir); + app.installTranslator(&translator); + + QTranslator qtTranslator(0); + qtTranslator.load(QLatin1String("qt_") + locale, resourceDir); + app.installTranslator(&qtTranslator); + + QTranslator qtHelpTranslator(0); + qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir); + app.installTranslator(&qtHelpTranslator); +} + } // Anonymous namespace. int main(int argc, char *argv[]) @@ -240,6 +286,7 @@ int main(int argc, char *argv[]) QApplication a(argc, argv, useGui(argc, argv)); a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins")); + // Parse arguments. CmdLineParser cmd(a.arguments()); CmdLineParser::Result res = cmd.parse(); if (res == CmdLineParser::Help) @@ -247,126 +294,99 @@ int main(int argc, char *argv[]) else if (res == CmdLineParser::Error) return -1; - QString cmdCollectionFile = cmd.collectionFile(); + /* + * Create the collection objects that we need. We always have the + * cached collection file. Depending on whether the user specified + * one, we also may have an input collection file. + */ + const QString collectionFile = cmd.collectionFile(); + const bool collectionFileGiven = !collectionFile.isEmpty(); + QScopedPointer collection; + if (collectionFileGiven) { + collection.reset(new QHelpEngineCore(collectionFile)); + if (!collection->setupData()) { + cmd.showMessage(QObject::tr("Error reading collection file '%1': %2."). + arg(collectionFile).arg(collection->error()), true); + return EXIT_FAILURE; + } + } + const QString &cachedCollectionFile = collectionFileGiven + ? constructCachedCollectionFilePath(*collection) + : MainWindow::defaultHelpCollectionFileName(); + if (collectionFileGiven && !QFileInfo(cachedCollectionFile).exists() + && !collection->copyCollectionFile(cachedCollectionFile)) { + cmd.showMessage(QObject::tr("Error creating collection file '%1': %2."). + arg(cachedCollectionFile).arg(collection->error()), true); + return EXIT_FAILURE; + } + QHelpEngineCore cachedCollection(cachedCollectionFile); + if (!cachedCollection.setupData()) { + cmd.showMessage(QObject::tr("Error reading collection file '%1': %2"). + arg(cachedCollectionFile). + arg(cachedCollection.error()), true); + return EXIT_FAILURE; + } + + stripNonexistingDocs(cachedCollection); + if (collectionFileGiven) { + if (CollectionConfiguration::isNewer(*collection, cachedCollection)) + CollectionConfiguration::copyConfiguration(*collection, + cachedCollection); + if (!synchronizeDocs(*collection, cachedCollection, cmd)) + return EXIT_FAILURE; + } + if (cmd.registerRequest() != CmdLineParser::None) { - if (cmdCollectionFile.isEmpty()) - cmdCollectionFile = MainWindow::defaultHelpCollectionFileName(); - QHelpEngineCore help(cmdCollectionFile); - help.setupData(); + const QStringList &cachedDocs = + cachedCollection.registeredDocumentations(); + const QString &namespaceName = + QHelpEngineCore::namespaceName(cmd.helpFile()); if (cmd.registerRequest() == CmdLineParser::Register) { - if (!help.registerDocumentation(cmd.helpFile())) { - cmd.showMessage( - QObject::tr("Could not register documentation file\n%1\n\nReason:\n%2") - .arg(cmd.helpFile()).arg(help.error()), true); - return -1; - } else { - cmd.showMessage(QObject::tr("Documentation successfully registered."), - false); - } - } else { - QString nsName = QHelpEngineCore::namespaceName(cmd.helpFile()); - if (help.unregisterDocumentation(nsName)) { - updateLastPagesOnUnregister(help, nsName); - cmd.showMessage( - QObject::tr("Documentation successfully unregistered."), - false); - } else { - cmd.showMessage(QObject::tr("Could not unregister documentation" - " file\n%1\n\nReason:\n%2").arg(cmd.helpFile()). - arg(help.error()), true); - return -1; - } + if (collectionFileGiven && !registerDocumentation(*collection, cmd, true)) + return EXIT_FAILURE; + if (!cachedDocs.contains(namespaceName) + && !registerDocumentation(cachedCollection, cmd, !collectionFileGiven)) + return EXIT_FAILURE; + return EXIT_SUCCESS; + } + if (cmd.registerRequest() == CmdLineParser::Unregister) { + if (collectionFileGiven + && !unregisterDocumentation(*collection, namespaceName, cmd, true)) + return EXIT_FAILURE; + if (cachedDocs.contains(namespaceName) + && !unregisterDocumentation(cachedCollection, namespaceName, + cmd, !collectionFileGiven)) + return EXIT_FAILURE; + return EXIT_SUCCESS; } - CollectionConfiguration::setDocUpdatePending(help, true); - return 0; } - // TODO: Also remove search index of cached collection file? if (cmd.removeSearchIndex()) { - QString file = cmdCollectionFile; - if (file.isEmpty()) - file = MainWindow::defaultHelpCollectionFileName(); - return removeSearchIndex(file) ? 0 : EXIT_FAILURE; + return removeSearchIndex(cachedCollectionFile) ? EXIT_SUCCESS : EXIT_FAILURE; } if (!checkForSqlite(cmd)) return EXIT_FAILURE; - if (!cmdCollectionFile.isEmpty()) { - QHelpEngineCore caller(cmdCollectionFile); - if (!caller.setupData()) { - cmd.showMessage(QObject::tr("The specified collection file could " - "not be read!"), true); - return -1; - } - - const QString &cachedCollectionFilePath = cachedCollectionFile(caller); - if (!QFileInfo(cachedCollectionFilePath).exists()) { - if (!caller.copyCollectionFile(cachedCollectionFilePath)) { - cmd.showMessage(caller.error(), true); - return -1; - } - } else { - QHelpEngineCore user(cachedCollectionFilePath); - if (user.setupData()) { - // some docs might have been un/registered - bool docUpdate = CollectionConfiguration::docUpdatePending(caller); - - // update in case the passed collection file changed - if (updateUserCollection(user, caller)) - docUpdate = true; - - QStringList userDocs = user.registeredDocumentations(); - // update user collection file, docs might have been (re)moved - if (!referencedHelpFilesExistAll(user, userDocs)) - docUpdate = true; - - if (docUpdate) { - synchronizeDocs(caller, user); - CollectionConfiguration::setDocUpdatePending(caller, false); - } - } - } - cmd.setCollectionFile(cachedCollectionFilePath); - } - if (!cmd.currentFilter().isEmpty()) { - QString collectionFile; - if (cmdCollectionFile.isEmpty()) { - MainWindow::collectionFileDirectory(true); - cmdCollectionFile = MainWindow::defaultHelpCollectionFileName(); - } - - QHelpEngineCore user(cmdCollectionFile); - if (user.setupData()) - user.setCurrentFilter(cmd.currentFilter()); + if (collectionFileGiven) + collection->setCurrentFilter(cmd.currentFilter()); + cachedCollection.setCurrentFilter(cmd.currentFilter()); } - const QString& locale = QLocale::system().name(); - QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); - - QTranslator translator(0); - translator.load(QLatin1String("assistant_") + locale, resourceDir); - a.installTranslator(&translator); - - QTranslator qtTranslator(0); - qtTranslator.load(QLatin1String("qt_") + locale, resourceDir); - a.installTranslator(&qtTranslator); - - QTranslator qtHelpTranslator(0); - qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir); - a.installTranslator(&qtHelpTranslator); + setupTranslations(a); /* * We need to be careful here: The main window has to be deleted before * the help engine wrapper, which has to be deleted before the * QApplication. */ - int retval; + if (collectionFileGiven) + cmd.setCollectionFile(cachedCollectionFile); MainWindow *w = new MainWindow(&cmd); w->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - retval = a.exec(); + const int retval = a.exec(); delete w; delete &HelpEngineWrapper::instance(); return retval; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 226ad51..9955c65 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -244,7 +244,6 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) else checkInitState(); - helpEngineWrapper.initFileSystemWatchers(); connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), this, SLOT(documentationRemoved(QString))); connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp index ba643c9..896afaf 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.cpp +++ b/tools/assistant/tools/shared/collectionconfiguration.cpp @@ -55,13 +55,13 @@ namespace { const QString CacheDirRelativeToCollectionKey(QLatin1String("CacheDirRelativeToCollection")); const QString CreationTimeKey(QLatin1String("CreationTime")); const QString DefaultHomePageKey(QLatin1String("defaultHomepage")); - const QString DocUpdatePendingKey(QLatin1String("DocUpdate")); const QString EnableAddressBarKey(QLatin1String("EnableAddressBar")); const QString EnableDocManagerKey(QLatin1String("EnableDocumentationManager")); const QString EnableFilterKey(QLatin1String("EnableFilterFunctionality")); const QString HideAddressBarKey(QLatin1String("HideAddressBar")); const QString FilterToolbarHiddenKey(QLatin1String("HideFilterFunctionality")); const QString LastPageKey(QLatin1String("LastTabPage")); + const QString LastRegisterTime(QLatin1String("LastRegisterTime")); const QString LastShownPagesKey(QLatin1String("LastShownPages")); const QString LastZoomFactorsKey(QLatin1String( #if !defined(QT_NO_WEBKIT) @@ -237,17 +237,6 @@ void CollectionConfiguration::setDefaultHomePage(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(DefaultHomePageKey, page); } -bool CollectionConfiguration::docUpdatePending(const QHelpEngineCore &helpEngine) -{ - return helpEngine.customValue(DocUpdatePendingKey, false).toBool(); -} - -void CollectionConfiguration::setDocUpdatePending(QHelpEngineCore &helpEngine, - bool pending) -{ - helpEngine.setCustomValue(DocUpdatePendingKey, pending); -} - const QStringList CollectionConfiguration::lastShownPages(const QHelpEngineCore &helpEngine) { return helpEngine.customValue(LastShownPagesKey).toString(). @@ -285,6 +274,16 @@ void CollectionConfiguration::setLastTabPage(QHelpEngineCore &helpEngine, helpEngine.setCustomValue(LastPageKey, lastPage); } +const QDateTime CollectionConfiguration::lastRegisterTime(const QHelpEngineCore &helpEngine) +{ + return helpEngine.customValue(LastRegisterTime, QDateTime()).toDateTime(); +} + +void CollectionConfiguration::updateLastRegisterTime(QHelpEngineCore &helpEngine) +{ + helpEngine.setCustomValue(LastRegisterTime, QDateTime::currentDateTime()); +} + bool CollectionConfiguration::isNewer(const QHelpEngineCore &newer, const QHelpEngineCore &older) { diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h index 4e77abe..d897adb 100644 --- a/tools/assistant/tools/shared/collectionconfiguration.h +++ b/tools/assistant/tools/shared/collectionconfiguration.h @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -111,9 +112,6 @@ public: static void setDefaultHomePage(QHelpEngineCore &helpEngine, const QString &page); - static bool docUpdatePending(const QHelpEngineCore &helpEngine); - static void setDocUpdatePending(QHelpEngineCore &helpEngine, bool pending); - // TODO: Don't allow last pages and zoom factors to be set in isolation // Perhaps also fill up missing elements automatically or assert. static const QStringList lastShownPages(const QHelpEngineCore &helpEngine); @@ -131,6 +129,13 @@ public: static void copyConfiguration(const QHelpEngineCore &source, QHelpEngineCore &target); + /* + * Note that this only reflects register actions caused by the + * "-register" command line switch, not GUI or remote control actions. + */ + static const QDateTime lastRegisterTime(const QHelpEngineCore &helpEngine); + static void updateLastRegisterTime(QHelpEngineCore &helpEngine); + static const QString DefaultZoomFactor; static const QString ListSeparator; }; -- cgit v0.12 From 20d65deb30d3286481402880ff6f646579b687c2 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 7 Dec 2009 15:50:50 +0100 Subject: Assistant: Use tracing macro in all functions. Reviewed-by: kh1 --- tools/assistant/tools/assistant/aboutdialog.cpp | 11 +++ .../assistant/tools/assistant/bookmarkmanager.cpp | 46 +++++++++++ tools/assistant/tools/assistant/centralwidget.cpp | 68 ++++++++++++++++ tools/assistant/tools/assistant/cmdlineparser.cpp | 29 +++++++ tools/assistant/tools/assistant/contentwindow.cpp | 12 +++ .../assistant/tools/assistant/filternamedialog.cpp | 4 + .../tools/assistant/helpenginewrapper.cpp | 90 ++++++++++++++++++++++ tools/assistant/tools/assistant/helpviewer.cpp | 36 +++++++++ tools/assistant/tools/assistant/indexwindow.cpp | 10 +++ tools/assistant/tools/assistant/installdialog.cpp | 15 ++++ tools/assistant/tools/assistant/main.cpp | 14 ++++ tools/assistant/tools/assistant/mainwindow.cpp | 62 +++++++++++++++ .../tools/assistant/preferencesdialog.cpp | 21 +++++ tools/assistant/tools/assistant/qtdocinstaller.cpp | 6 ++ tools/assistant/tools/assistant/remotecontrol.cpp | 20 +++++ tools/assistant/tools/assistant/searchwidget.cpp | 14 ++++ tools/assistant/tools/assistant/topicchooser.cpp | 3 + tools/assistant/tools/assistant/xbelsupport.cpp | 11 +++ 18 files changed, 472 insertions(+) diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index d8fd37c..6afb375 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include @@ -56,6 +57,7 @@ QT_BEGIN_NAMESPACE AboutLabel::AboutLabel(QWidget *parent) : QTextBrowser(parent) { + TRACE_OBJ setFrameStyle(QFrame::NoFrame); QPalette p; p.setColor(QPalette::Base, p.color(QPalette::Background)); @@ -64,6 +66,7 @@ AboutLabel::AboutLabel(QWidget *parent) void AboutLabel::setText(const QString &text, const QByteArray &resources) { + TRACE_OBJ QDataStream in(resources); in >> m_resourceMap; @@ -72,6 +75,7 @@ void AboutLabel::setText(const QString &text, const QByteArray &resources) QSize AboutLabel::minimumSizeHint() const { + TRACE_OBJ QTextDocument *doc = document(); doc->adjustSize(); return QSize(int(doc->size().width()), int(doc->size().height())); @@ -79,6 +83,7 @@ QSize AboutLabel::minimumSizeHint() const QVariant AboutLabel::loadResource(int type, const QUrl &name) { + TRACE_OBJ if (type == 2 || type == 3) { if (m_resourceMap.contains(name.toString())) { return m_resourceMap.value(name.toString()); @@ -89,6 +94,7 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name) void AboutLabel::setSource(const QUrl &url) { + TRACE_OBJ if (url.isValid() && (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") || url.scheme() == QLatin1String("mailto") || url.path().endsWith(QLatin1String("pdf")))) { @@ -103,6 +109,7 @@ void AboutLabel::setSource(const QUrl &url) AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint|Qt::WindowTitleHint|Qt::WindowSystemMenuHint) { + TRACE_OBJ m_pixmapLabel = 0; m_aboutLabel = new AboutLabel(); @@ -121,12 +128,14 @@ AboutDialog::AboutDialog(QWidget *parent) void AboutDialog::setText(const QString &text, const QByteArray &resources) { + TRACE_OBJ m_aboutLabel->setText(text, resources); updateSize(); } void AboutDialog::setPixmap(const QPixmap &pixmap) { + TRACE_OBJ if (!m_pixmapLabel) { m_pixmapLabel = new QLabel(); m_layout->addWidget(m_pixmapLabel, 0, 0, 1, -1, Qt::AlignCenter); @@ -137,11 +146,13 @@ void AboutDialog::setPixmap(const QPixmap &pixmap) QString AboutDialog::documentTitle() const { + TRACE_OBJ return m_aboutLabel->documentTitle(); } void AboutDialog::updateSize() { + TRACE_OBJ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); int limit = qMin(screenSize.width()/2, 500); diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index f8cad4d..592c643 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "bookmarkmanager.h" #include "centralwidget.h" @@ -69,6 +70,7 @@ BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title, , m_title(title) , bookmarkManager(manager) { + TRACE_OBJ installEventFilter(this); ui.setupUi(this); @@ -114,10 +116,12 @@ BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title, BookmarkDialog::~BookmarkDialog() { + TRACE_OBJ } void BookmarkDialog::addAccepted() { + TRACE_OBJ QItemSelectionModel *model = ui.treeView->selectionModel(); const QModelIndexList &list = model->selection().indexes(); @@ -131,6 +135,7 @@ void BookmarkDialog::addAccepted() void BookmarkDialog::addNewFolder() { + TRACE_OBJ QItemSelectionModel *model = ui.treeView->selectionModel(); const QModelIndexList &list = model->selection().indexes(); @@ -156,6 +161,7 @@ void BookmarkDialog::addNewFolder() void BookmarkDialog::toolButtonClicked() { + TRACE_OBJ bool visible = !ui.treeView->isVisible(); ui.treeView->setVisible(visible); ui.newFolderButton->setVisible(visible); @@ -171,6 +177,7 @@ void BookmarkDialog::toolButtonClicked() void BookmarkDialog::itemChanged(QStandardItem *item) { + TRACE_OBJ if (renameItem != item) { renameItem = item; oldText = item->text(); @@ -191,11 +198,13 @@ void BookmarkDialog::itemChanged(QStandardItem *item) void BookmarkDialog::textChanged(const QString &string) { + TRACE_OBJ ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!string.isEmpty()); } void BookmarkDialog::selectBookmarkFolder(const QString &folderName) { + TRACE_OBJ if (folderName.isEmpty()) return; @@ -219,6 +228,7 @@ void BookmarkDialog::selectBookmarkFolder(const QString &folderName) void BookmarkDialog::customContextMenuRequested(const QPoint &point) { + TRACE_OBJ QModelIndex index = ui.treeView->indexAt(point); if (!index.isValid()) return; @@ -251,6 +261,7 @@ void BookmarkDialog::customContextMenuRequested(const QPoint &point) void BookmarkDialog::renameFolder(const QModelIndex &index, const QModelIndex &proxyIndex) { + TRACE_OBJ const BookmarkModel * const model = bookmarkManager->treeBookmarkModel(); if (QStandardItem *item = model->itemFromIndex(proxyIndex)) { item->setEditable(true); @@ -261,6 +272,7 @@ void BookmarkDialog::renameFolder(const QModelIndex &index, void BookmarkDialog::currentChanged(const QModelIndex ¤t) { + TRACE_OBJ QString text = tr("Bookmarks"); if (current.isValid()) text = current.data().toString(); @@ -269,6 +281,7 @@ void BookmarkDialog::currentChanged(const QModelIndex ¤t) bool BookmarkDialog::eventFilter(QObject *object, QEvent *e) { + TRACE_OBJ if (object == this && e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); @@ -316,16 +329,19 @@ BookmarkWidget::BookmarkWidget(BookmarkManager *manager, QWidget *parent, , removeButton(0) , bookmarkManager(manager) { + TRACE_OBJ setup(showButtons); installEventFilter(this); } BookmarkWidget::~BookmarkWidget() { + TRACE_OBJ } void BookmarkWidget::removeClicked() { + TRACE_OBJ const QModelIndex &index = treeView->currentIndex(); if (searchField->text().isEmpty()) { bookmarkManager->removeBookmarkItem(treeView, @@ -335,6 +351,7 @@ void BookmarkWidget::removeClicked() void BookmarkWidget::filterChanged() { + TRACE_OBJ bool searchBookmarks = searchField->text().isEmpty(); if (!searchBookmarks) { regExp.setPattern(searchField->text()); @@ -362,6 +379,7 @@ void BookmarkWidget::filterChanged() void BookmarkWidget::expand(const QModelIndex &index) { + TRACE_OBJ const QModelIndex &source = filterBookmarkModel->mapToSource(index); QStandardItem *item = bookmarkManager->treeBookmarkModel()->itemFromIndex(source); @@ -371,6 +389,7 @@ void BookmarkWidget::expand(const QModelIndex &index) void BookmarkWidget::activated(const QModelIndex &index) { + TRACE_OBJ if (!index.isValid()) return; @@ -381,6 +400,7 @@ void BookmarkWidget::activated(const QModelIndex &index) void BookmarkWidget::customContextMenuRequested(const QPoint &point) { + TRACE_OBJ QModelIndex index = treeView->indexAt(point); if (!index.isValid()) return; @@ -433,6 +453,7 @@ void BookmarkWidget::customContextMenuRequested(const QPoint &point) void BookmarkWidget::setup(bool showButtons) { + TRACE_OBJ regExp.setPatternSyntax(QRegExp::FixedString); regExp.setCaseSensitivity(Qt::CaseInsensitive); @@ -510,6 +531,7 @@ void BookmarkWidget::setup(bool showButtons) void BookmarkWidget::expandItems() { + TRACE_OBJ QStandardItemModel *model = bookmarkManager->treeBookmarkModel(); QListlist = model->findItems(QLatin1String("*"), Qt::MatchWildcard | Qt::MatchRecursive, 0); @@ -522,6 +544,7 @@ void BookmarkWidget::expandItems() void BookmarkWidget::focusInEvent(QFocusEvent *e) { + TRACE_OBJ if (e->reason() != Qt::MouseFocusReason) { searchField->selectAll(); searchField->setFocus(); @@ -535,6 +558,7 @@ void BookmarkWidget::focusInEvent(QFocusEvent *e) bool BookmarkWidget::eventFilter(QObject *object, QEvent *e) { + TRACE_OBJ if ((object == this) || (object == treeView->viewport())) { QModelIndex index = treeView->currentIndex(); if (e->type() == QEvent::KeyPress) { @@ -598,19 +622,23 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e) BookmarkModel::BookmarkModel(int rows, int columns, QObject *parent) : QStandardItemModel(rows, columns, parent) { + TRACE_OBJ } BookmarkModel::~BookmarkModel() { + TRACE_OBJ } Qt::DropActions BookmarkModel::supportedDropActions() const { + TRACE_OBJ return Qt::MoveAction; } Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const { + TRACE_OBJ Qt::ItemFlags defaultFlags = QStandardItemModel::flags(index); if ((!index.isValid()) // can only happen for the invisible root item || index.data(Qt::UserRole + 10).toString() == QLatin1String("Folder")) @@ -628,6 +656,7 @@ BookmarkManager::BookmarkManager() , listModel(new BookmarkModel(0, 1, this)) , renameItem(0) { + TRACE_OBJ folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png")); @@ -641,22 +670,26 @@ BookmarkManager::BookmarkManager() BookmarkManager::~BookmarkManager() { + TRACE_OBJ treeModel->clear(); listModel->clear(); } BookmarkModel* BookmarkManager::treeBookmarkModel() { + TRACE_OBJ return treeModel; } BookmarkModel* BookmarkManager::listBookmarkModel() { + TRACE_OBJ return listModel; } void BookmarkManager::saveBookmarks() { + TRACE_OBJ QByteArray bookmarks; QDataStream stream(&bookmarks, QIODevice::WriteOnly); @@ -666,6 +699,7 @@ void BookmarkManager::saveBookmarks() QStringList BookmarkManager::bookmarkFolders() const { + TRACE_OBJ QStringList folders(tr("Bookmarks")); QListlist = treeModel->findItems(QLatin1String("*"), @@ -682,6 +716,7 @@ QStringList BookmarkManager::bookmarkFolders() const QModelIndex BookmarkManager::addNewFolder(const QModelIndex &index) { + TRACE_OBJ QStandardItem *item = new QStandardItem(uniqueFolderName()); item->setEditable(false); item->setData(false, Qt::UserRole + 11); @@ -699,6 +734,7 @@ QModelIndex BookmarkManager::addNewFolder(const QModelIndex &index) void BookmarkManager::removeBookmarkItem(QTreeView *treeView, const QModelIndex &index) { + TRACE_OBJ QStandardItem *item = treeModel->itemFromIndex(index); if (item) { QString data = index.data(Qt::UserRole + 10).toString(); @@ -730,6 +766,7 @@ void BookmarkManager::removeBookmarkItem(QTreeView *treeView, void BookmarkManager::showBookmarkDialog(QWidget *parent, const QString &name, const QString &url) { + TRACE_OBJ BookmarkDialog dialog(this, name, url, parent); dialog.exec(); } @@ -737,6 +774,7 @@ void BookmarkManager::showBookmarkDialog(QWidget *parent, const QString &name, void BookmarkManager::addNewBookmark(const QModelIndex &index, const QString &name, const QString &url) { + TRACE_OBJ QStandardItem *item = new QStandardItem(name); item->setEditable(false); item->setIcon(bookmarkIcon); @@ -753,6 +791,7 @@ void BookmarkManager::addNewBookmark(const QModelIndex &index, void BookmarkManager::fillBookmarkMenu(QMenu *menu) { + TRACE_OBJ if (!menu || !treeModel) return; @@ -762,6 +801,7 @@ void BookmarkManager::fillBookmarkMenu(QMenu *menu) void BookmarkManager::fillBookmarkMenu(QMenu *menu, QStandardItem *root) { + TRACE_OBJ for (int i = 0; i < root->rowCount(); ++i) { QStandardItem *item = root->child(i); if (item && item->data(Qt::UserRole + 10) @@ -777,6 +817,7 @@ void BookmarkManager::fillBookmarkMenu(QMenu *menu, QStandardItem *root) QUrl BookmarkManager::urlForAction(QAction* action) const { + TRACE_OBJ if (map.contains(action)) { const QModelIndex &index = map.value(action); if (QStandardItem* item = treeModel->itemFromIndex(index)) @@ -787,6 +828,7 @@ QUrl BookmarkManager::urlForAction(QAction* action) const void BookmarkManager::itemChanged(QStandardItem *item) { + TRACE_OBJ if (renameItem != item) { renameItem = item; oldText = item->text(); @@ -804,6 +846,7 @@ void BookmarkManager::itemChanged(QStandardItem *item) void BookmarkManager::setupBookmarkModels() { + TRACE_OBJ treeModel->clear(); listModel->clear(); @@ -849,6 +892,7 @@ void BookmarkManager::setupBookmarkModels() QString BookmarkManager::uniqueFolderName() const { + TRACE_OBJ QString folderName = tr("New Folder"); QList list = treeModel->findItems(folderName, Qt::MatchContains | Qt::MatchRecursive, 0); @@ -868,6 +912,7 @@ QString BookmarkManager::uniqueFolderName() const void BookmarkManager::removeBookmarkFolderItems(QStandardItem *item) { + TRACE_OBJ for (int j = 0; j < item->rowCount(); ++j) { QStandardItem *child = item->child(j); if (child->rowCount() > 0) @@ -887,6 +932,7 @@ void BookmarkManager::removeBookmarkFolderItems(QStandardItem *item) void BookmarkManager::readBookmarksRecursive(const QStandardItem *item, QDataStream &stream, const qint32 depth) const { + TRACE_OBJ for (int j = 0; j < item->rowCount(); ++j) { const QStandardItem *child = item->child(j); stream << depth; diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 7117b76..8343ad1 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "centralwidget.h" #include "helpenginewrapper.h" @@ -91,6 +92,7 @@ FindWidget::FindWidget(QWidget *parent) : QWidget(parent) , appPalette(qApp->palette()) { + TRACE_OBJ QHBoxLayout *hboxLayout = new QHBoxLayout(this); QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); @@ -149,10 +151,12 @@ FindWidget::FindWidget(QWidget *parent) FindWidget::~FindWidget() { + TRACE_OBJ } void FindWidget::hideEvent(QHideEvent* event) { + TRACE_OBJ #if !defined(QT_NO_WEBKIT) // TODO: remove this once webkit supports setting the palette if (!event->spontaneous()) @@ -164,6 +168,7 @@ void FindWidget::hideEvent(QHideEvent* event) void FindWidget::showEvent(QShowEvent* event) { + TRACE_OBJ #if !defined(QT_NO_WEBKIT) // TODO: remove this once webkit supports setting the palette if (!event->spontaneous()) { @@ -181,6 +186,7 @@ void FindWidget::showEvent(QShowEvent* event) void FindWidget::updateButtons() { + TRACE_OBJ if (editFind->text().isEmpty()) { toolPrevious->setEnabled(false); toolNext->setEnabled(false); @@ -192,6 +198,7 @@ void FindWidget::updateButtons() QToolButton* FindWidget::setupToolButton(const QString &text, const QString &icon) { + TRACE_OBJ QToolButton *toolButton = new QToolButton(this); toolButton->setText(text); @@ -216,6 +223,7 @@ CentralWidget::CentralWidget(MainWindow *parent) , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) { + TRACE_OBJ globalActionList.clear(); staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); @@ -287,6 +295,7 @@ CentralWidget::CentralWidget(MainWindow *parent) CentralWidget::~CentralWidget() { + TRACE_OBJ #ifndef QT_NO_PRINTER delete printer; #endif @@ -313,11 +322,13 @@ CentralWidget::~CentralWidget() CentralWidget *CentralWidget::instance() { + TRACE_OBJ return staticCentralWidget; } void CentralWidget::newTab() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); #if !defined(QT_NO_WEBKIT) if (viewer && viewer->hasLoadFinished()) @@ -329,6 +340,7 @@ void CentralWidget::newTab() void CentralWidget::zoomIn() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->zoomIn(); @@ -339,6 +351,7 @@ void CentralWidget::zoomIn() void CentralWidget::zoomOut() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->zoomOut(); @@ -349,11 +362,13 @@ void CentralWidget::zoomOut() void CentralWidget::findNext() { + TRACE_OBJ find(findWidget->editFind->text(), true, false); } void CentralWidget::nextPage() { + TRACE_OBJ int index = tabWidget->currentIndex() + 1; if (index >= tabWidget->count()) index = 0; @@ -362,6 +377,7 @@ void CentralWidget::nextPage() void CentralWidget::resetZoom() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->resetZoom(); @@ -372,6 +388,7 @@ void CentralWidget::resetZoom() void CentralWidget::previousPage() { + TRACE_OBJ int index = tabWidget->currentIndex() -1; if (index < 0) index = tabWidget->count() -1; @@ -380,11 +397,13 @@ void CentralWidget::previousPage() void CentralWidget::findPrevious() { + TRACE_OBJ find(findWidget->editFind->text(), false, true); } void CentralWidget::closeTab() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (!viewer|| tabWidget->count() == 1) return; @@ -395,6 +414,7 @@ void CentralWidget::closeTab() void CentralWidget::setSource(const QUrl &url) { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); HelpViewer *lastViewer = qobject_cast(tabWidget->widget(lastTabPage)); @@ -418,6 +438,7 @@ void CentralWidget::setSource(const QUrl &url) void CentralWidget::setupWidget() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); int option = helpEngine.startOption(); if (option != ShowLastPages) { @@ -434,6 +455,7 @@ void CentralWidget::setupWidget() void CentralWidget::setLastShownPages() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); const QStringList lastShownPageList = helpEngine.lastShownPages(); const int pageCount = lastShownPageList.count(); @@ -467,12 +489,14 @@ void CentralWidget::setLastShownPages() bool CentralWidget::hasSelection() const { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); return viewer ? viewer->hasSelection() : false; } QUrl CentralWidget::currentSource() const { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->source(); @@ -482,6 +506,7 @@ QUrl CentralWidget::currentSource() const QString CentralWidget::currentTitle() const { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->documentTitle(); @@ -491,6 +516,7 @@ QString CentralWidget::currentTitle() const void CentralWidget::copySelection() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->copy(); @@ -498,6 +524,7 @@ void CentralWidget::copySelection() void CentralWidget::showTextSearch() { + TRACE_OBJ findBar->show(); findWidget->editFind->selectAll(); findWidget->editFind->setFocus(Qt::ShortcutFocusReason); @@ -505,6 +532,7 @@ void CentralWidget::showTextSearch() void CentralWidget::initPrinter() { + TRACE_OBJ #ifndef QT_NO_PRINTER if (!printer) printer = new QPrinter(QPrinter::HighResolution); @@ -513,6 +541,7 @@ void CentralWidget::initPrinter() void CentralWidget::print() { + TRACE_OBJ #ifndef QT_NO_PRINTER HelpViewer *viewer = currentHelpViewer(); if (!viewer) @@ -536,6 +565,7 @@ void CentralWidget::print() void CentralWidget::printPreview() { + TRACE_OBJ #ifndef QT_NO_PRINTER initPrinter(); QPrintPreviewDialog preview(printer, this); @@ -547,6 +577,7 @@ void CentralWidget::printPreview() void CentralWidget::printPreview(QPrinter *p) { + TRACE_OBJ #ifndef QT_NO_PRINTER HelpViewer *viewer = currentHelpViewer(); if (viewer) @@ -556,6 +587,7 @@ void CentralWidget::printPreview(QPrinter *p) void CentralWidget::pageSetup() { + TRACE_OBJ #ifndef QT_NO_PRINTER initPrinter(); QPageSetupDialog dlg(printer); @@ -565,11 +597,13 @@ void CentralWidget::pageSetup() bool CentralWidget::isHomeAvailable() const { + TRACE_OBJ return currentHelpViewer() ? true : false; } void CentralWidget::home() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->home(); @@ -577,6 +611,7 @@ void CentralWidget::home() bool CentralWidget::isForwardAvailable() const { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->isForwardAvailable(); @@ -586,6 +621,7 @@ bool CentralWidget::isForwardAvailable() const void CentralWidget::forward() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->forward(); @@ -593,6 +629,7 @@ void CentralWidget::forward() bool CentralWidget::isBackwardAvailable() const { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->isBackwardAvailable(); @@ -602,6 +639,7 @@ bool CentralWidget::isBackwardAvailable() const void CentralWidget::backward() { + TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->backward(); @@ -610,16 +648,19 @@ void CentralWidget::backward() QList CentralWidget::globalActions() const { + TRACE_OBJ return globalActionList; } void CentralWidget::setGlobalActions(const QList &actions) { + TRACE_OBJ globalActionList = actions; } void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) { + TRACE_OBJ HelpViewer *viewer; #if defined(QT_NO_WEBKIT) @@ -652,6 +693,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) HelpViewer *CentralWidget::newEmptyTab() { + TRACE_OBJ HelpViewer *viewer = new HelpViewer(this); viewer->installEventFilter(this); viewer->setFocus(Qt::OtherFocusReason); @@ -666,11 +708,13 @@ HelpViewer *CentralWidget::newEmptyTab() void CentralWidget::findCurrentText(const QString &text) { + TRACE_OBJ find(text, false, false); } void CentralWidget::connectSignals() { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) { connect(viewer, SIGNAL(copyAvailable(bool)), this, @@ -690,11 +734,13 @@ void CentralWidget::connectSignals() HelpViewer *CentralWidget::currentHelpViewer() const { + TRACE_OBJ return qobject_cast(tabWidget->currentWidget()); } void CentralWidget::activateTab(bool onlyHelpViewer) { + TRACE_OBJ if (currentHelpViewer()) { currentHelpViewer()->setFocus(); } else { @@ -708,6 +754,7 @@ void CentralWidget::activateTab(bool onlyHelpViewer) void CentralWidget::setTabTitle(const QUrl &url) { + TRACE_OBJ Q_UNUSED(url) #if !defined(QT_NO_WEBKIT) QTabBar *tabBar = qFindChild(tabWidget); @@ -729,6 +776,7 @@ void CentralWidget::setTabTitle(const QUrl &url) void CentralWidget::currentPageChanged(int index) { + TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); if (viewer) lastTabPage = index; @@ -744,6 +792,7 @@ void CentralWidget::currentPageChanged(int index) void CentralWidget::showTabBarContextMenu(const QPoint &point) { + TRACE_OBJ HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, point); if (!viewer) return; @@ -796,6 +845,7 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) bool CentralWidget::eventFilter(QObject *object, QEvent *e) { + TRACE_OBJ if (e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); switch (ke->key()) { @@ -851,6 +901,7 @@ bool CentralWidget::eventFilter(QObject *object, QEvent *e) void CentralWidget::keyPressEvent(QKeyEvent *e) { + TRACE_OBJ const QString &text = e->text(); if (text.startsWith(QLatin1Char('/'))) { if (!findBar->isVisible()) { @@ -867,6 +918,7 @@ void CentralWidget::keyPressEvent(QKeyEvent *e) void CentralWidget::find(const QString &ttf, bool forward, bool backward) { + TRACE_OBJ QPalette p = findWidget->editFind->palette(); p.setColor(QPalette::Active, QPalette::Base, Qt::white); @@ -915,6 +967,7 @@ void CentralWidget::find(const QString &ttf, bool forward, bool backward) bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, bool forward, bool backward) { + TRACE_OBJ if (!browser) return false; @@ -962,6 +1015,7 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, void CentralWidget::updateBrowserFont() { + TRACE_OBJ QFont font; bool searchAttached = searchWidgetAttached(); if (searchAttached) { @@ -977,6 +1031,7 @@ void CentralWidget::updateBrowserFont() void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) { + TRACE_OBJ if (m_searchWidget) return; @@ -993,6 +1048,7 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) void CentralWidget::activateSearchWidget(bool updateLastTabPage) { + TRACE_OBJ if (!m_searchWidget) createSearchWidget(HelpEngineWrapper::instance().searchEngine()); @@ -1010,6 +1066,7 @@ void CentralWidget::activateSearchWidget(bool updateLastTabPage) void CentralWidget::removeSearchWidget() { + TRACE_OBJ if (searchWidgetAttached()) { tabWidget->removeTab(0); m_searchWidget->setAttached(false); @@ -1018,6 +1075,7 @@ void CentralWidget::removeSearchWidget() int CentralWidget::availableHelpViewer() const { + TRACE_OBJ int count = tabWidget->count(); if (searchWidgetAttached()) count--; @@ -1026,6 +1084,7 @@ int CentralWidget::availableHelpViewer() const bool CentralWidget::enableTabCloseAction() const { + TRACE_OBJ int minTabCount = 1; if (searchWidgetAttached()) minTabCount = 2; @@ -1035,6 +1094,7 @@ bool CentralWidget::enableTabCloseAction() const QString CentralWidget::quoteTabTitle(const QString &title) const { + TRACE_OBJ QString s = title; return s.replace(QLatin1Char('&'), QLatin1String("&&")); } @@ -1042,6 +1102,7 @@ QString CentralWidget::quoteTabTitle(const QString &title) const void CentralWidget::setSourceFromSearch(const QUrl &url) { + TRACE_OBJ setSource(url); highlightSearchTerms(); } @@ -1049,6 +1110,7 @@ CentralWidget::setSourceFromSearch(const QUrl &url) void CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) { + TRACE_OBJ setSourceInNewTab(url); highlightSearchTerms(); } @@ -1056,6 +1118,7 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) void CentralWidget::highlightSearchTerms() { + TRACE_OBJ #if defined(QT_NO_WEBKIT) HelpViewer *viewer = currentHelpViewer(); if (!viewer) @@ -1116,6 +1179,7 @@ CentralWidget::highlightSearchTerms() void CentralWidget::closeTabs(const QList &indices) { + TRACE_OBJ QList sortedIndices = indices; qSort(sortedIndices); for (int i = sortedIndices.count(); --i >= 0;) @@ -1126,6 +1190,7 @@ void CentralWidget::closeTabs(const QList &indices) void CentralWidget::closeTabAt(int index) { + TRACE_OBJ HelpViewer *viewer = qobject_cast(tabWidget->widget(index)); tabWidget->removeTab(index); QTimer::singleShot(0, viewer, SLOT(deleteLater())); @@ -1133,6 +1198,7 @@ void CentralWidget::closeTabAt(int index) QMap CentralWidget::currentSourceFileList() const { + TRACE_OBJ QMap sourceList; for (int i = 1; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); @@ -1144,6 +1210,7 @@ QMap CentralWidget::currentSourceFileList() const void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); if (!helpEngine.usesBrowserFont()) { *font = qApp->font(); // case for QTextBrowser and SearchWidget @@ -1162,6 +1229,7 @@ void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font) { + TRACE_OBJ #if !defined(QT_NO_WEBKIT) QWebView *view = qobject_cast (widget); if (view) { diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp index b17909c..733e2ff 100644 --- a/tools/assistant/tools/assistant/cmdlineparser.cpp +++ b/tools/assistant/tools/assistant/cmdlineparser.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include #include @@ -88,6 +89,7 @@ CmdLineParser::CmdLineParser(const QStringList &arguments) m_removeSearchIndex(false), m_quiet(false) { + TRACE_OBJ for (int i = 1; i < arguments.count(); ++i) { const QString &arg = arguments.at(i); if (arg.toLower() == "-quiet") @@ -99,6 +101,7 @@ CmdLineParser::CmdLineParser(const QStringList &arguments) CmdLineParser::Result CmdLineParser::parse() { + TRACE_OBJ bool showHelp = false; while (m_error.isEmpty() && hasMoreArgs()) { @@ -141,17 +144,20 @@ CmdLineParser::Result CmdLineParser::parse() bool CmdLineParser::hasMoreArgs() const { + TRACE_OBJ return m_pos < m_arguments.count(); } const QString &CmdLineParser::nextArg() { + TRACE_OBJ Q_ASSERT(hasMoreArgs()); return m_arguments.at(m_pos++); } void CmdLineParser::handleCollectionFileOption() { + TRACE_OBJ if (hasMoreArgs()) { const QString &fileName = nextArg(); m_collectionFile = getFileName(fileName); @@ -165,6 +171,7 @@ void CmdLineParser::handleCollectionFileOption() void CmdLineParser::handleShowUrlOption() { + TRACE_OBJ if (hasMoreArgs()) { const QString &urlString = nextArg(); QUrl url(urlString); @@ -179,21 +186,25 @@ void CmdLineParser::handleShowUrlOption() void CmdLineParser::handleShowOption() { + TRACE_OBJ handleShowOrHideOrActivateOption(Show); } void CmdLineParser::handleHideOption() { + TRACE_OBJ handleShowOrHideOrActivateOption(Hide); } void CmdLineParser::handleActivateOption() { + TRACE_OBJ handleShowOrHideOrActivateOption(Activate); } void CmdLineParser::handleShowOrHideOrActivateOption(ShowState state) { + TRACE_OBJ if (hasMoreArgs()) { const QString &widget = nextArg().toLower(); if (widget == QLatin1String("contents")) @@ -213,16 +224,19 @@ void CmdLineParser::handleShowOrHideOrActivateOption(ShowState state) void CmdLineParser::handleRegisterOption() { + TRACE_OBJ handleRegisterOrUnregisterOption(Register); } void CmdLineParser::handleUnregisterOption() { + TRACE_OBJ handleRegisterOrUnregisterOption(Unregister); } void CmdLineParser::handleRegisterOrUnregisterOption(RegisterState state) { + TRACE_OBJ if (hasMoreArgs()) { const QString &fileName = nextArg(); m_helpFile = getFileName(fileName); @@ -237,6 +251,7 @@ void CmdLineParser::handleRegisterOrUnregisterOption(RegisterState state) void CmdLineParser::handleSetCurrentFilterOption() { + TRACE_OBJ if (hasMoreArgs()) m_currentFilter = nextArg(); else @@ -245,6 +260,7 @@ void CmdLineParser::handleSetCurrentFilterOption() QString CmdLineParser::getFileName(const QString &fileName) { + TRACE_OBJ QFileInfo fi(fileName); if (!fi.exists()) return QString(); @@ -253,6 +269,7 @@ QString CmdLineParser::getFileName(const QString &fileName) void CmdLineParser::showMessage(const QString &msg, bool error) { + TRACE_OBJ if (m_quiet) return; #ifdef Q_OS_WIN @@ -268,61 +285,73 @@ void CmdLineParser::showMessage(const QString &msg, bool error) void CmdLineParser::setCollectionFile(const QString &file) { + TRACE_OBJ m_collectionFile = file; } QString CmdLineParser::collectionFile() const { + TRACE_OBJ return m_collectionFile; } QUrl CmdLineParser::url() const { + TRACE_OBJ return m_url; } bool CmdLineParser::enableRemoteControl() const { + TRACE_OBJ return m_enableRemoteControl; } CmdLineParser::ShowState CmdLineParser::contents() const { + TRACE_OBJ return m_contents; } CmdLineParser::ShowState CmdLineParser::index() const { + TRACE_OBJ return m_index; } CmdLineParser::ShowState CmdLineParser::bookmarks() const { + TRACE_OBJ return m_bookmarks; } CmdLineParser::ShowState CmdLineParser::search() const { + TRACE_OBJ return m_search; } QString CmdLineParser::currentFilter() const { + TRACE_OBJ return m_currentFilter; } bool CmdLineParser::removeSearchIndex() const { + TRACE_OBJ return m_removeSearchIndex; } CmdLineParser::RegisterState CmdLineParser::registerRequest() const { + TRACE_OBJ return m_register; } QString CmdLineParser::helpFile() const { + TRACE_OBJ return m_helpFile; } diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 17b19ba..d93040a 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "contentwindow.h" #include "centralwidget.h" @@ -55,6 +56,7 @@ ContentWindow::ContentWindow() : m_contentWidget(HelpEngineWrapper::instance().contentWidget()) , m_expandDepth(-2) { + TRACE_OBJ m_contentWidget->viewport()->installEventFilter(this); m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -74,10 +76,12 @@ ContentWindow::ContentWindow() ContentWindow::~ContentWindow() { + TRACE_OBJ } bool ContentWindow::syncToContent(const QUrl& url) { + TRACE_OBJ QModelIndex idx = m_contentWidget->indexOf(url); if (!idx.isValid()) return false; @@ -87,6 +91,7 @@ bool ContentWindow::syncToContent(const QUrl& url) void ContentWindow::expandTOC() { + TRACE_OBJ Q_ASSERT(m_expandDepth >= -2); if (m_expandDepth > -2) { expandToDepth(m_expandDepth); @@ -96,6 +101,7 @@ void ContentWindow::expandTOC() void ContentWindow::expandToDepth(int depth) { + TRACE_OBJ Q_ASSERT(depth >= -2); m_expandDepth = depth; if (depth == -1) @@ -108,18 +114,21 @@ void ContentWindow::expandToDepth(int depth) void ContentWindow::focusInEvent(QFocusEvent *e) { + TRACE_OBJ if (e->reason() != Qt::MouseFocusReason) m_contentWidget->setFocus(); } void ContentWindow::keyPressEvent(QKeyEvent *e) { + TRACE_OBJ if (e->key() == Qt::Key_Escape) emit escapePressed(); } bool ContentWindow::eventFilter(QObject *o, QEvent *e) { + TRACE_OBJ if (m_contentWidget && o == m_contentWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast(e); @@ -148,6 +157,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) void ContentWindow::showContextMenu(const QPoint &pos) { + TRACE_OBJ if (!m_contentWidget->indexAt(pos).isValid()) return; @@ -173,6 +183,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) void ContentWindow::itemClicked(const QModelIndex &index) { + TRACE_OBJ QHelpContentModel *contentModel = qobject_cast(m_contentWidget->model()); @@ -185,6 +196,7 @@ void ContentWindow::itemClicked(const QModelIndex &index) bool ContentWindow::isPdfFile(QHelpContentItem *item) const { + TRACE_OBJ const QString &path = item->url().path(); return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive); } diff --git a/tools/assistant/tools/assistant/filternamedialog.cpp b/tools/assistant/tools/assistant/filternamedialog.cpp index 781171e..27b7baf 100644 --- a/tools/assistant/tools/assistant/filternamedialog.cpp +++ b/tools/assistant/tools/assistant/filternamedialog.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include @@ -48,6 +49,7 @@ QT_BEGIN_NAMESPACE FilterNameDialog::FilterNameDialog(QWidget *parent) : QDialog(parent) { + TRACE_OBJ m_ui.setupUi(this); connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); @@ -61,11 +63,13 @@ FilterNameDialog::FilterNameDialog(QWidget *parent) QString FilterNameDialog::filterName() const { + TRACE_OBJ return m_ui.lineEdit->text(); } void FilterNameDialog::updateOkButton() { + TRACE_OBJ m_ui.buttonBox->button(QDialogButtonBox::Ok) ->setDisabled(m_ui.lineEdit->text().isEmpty()); } diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 3835a63..899954c 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "helpenginewrapper.h" #include "../shared/collectionconfiguration.h" @@ -73,6 +74,7 @@ HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) { + TRACE_OBJ /* * Note that this Singleton cannot be static, because it has to be * deleted before the QApplication. @@ -84,6 +86,7 @@ HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) void HelpEngineWrapper::removeInstance() { + TRACE_OBJ delete helpEngineWrapper; helpEngineWrapper = 0; } @@ -92,6 +95,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) : m_helpEngine(new QHelpEngine(collectionFile, this)), m_qchWatcher(new QFileSystemWatcher(this)) { + TRACE_OBJ connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, SIGNAL(currentFilterChanged(QString))); connect(m_helpEngine, SIGNAL(setupFinished()), @@ -101,6 +105,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) void HelpEngineWrapper::initFileSystemWatchers() { + TRACE_OBJ foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { const QString &docFile = m_helpEngine->documentationFileName(ns); m_qchWatcher->addPath(docFile); @@ -112,41 +117,49 @@ void HelpEngineWrapper::initFileSystemWatchers() QHelpSearchEngine *HelpEngineWrapper::searchEngine() const { + TRACE_OBJ return m_helpEngine->searchEngine(); } QHelpContentModel *HelpEngineWrapper::contentModel() const { + TRACE_OBJ return m_helpEngine->contentModel(); } QHelpIndexModel *HelpEngineWrapper::indexModel() const { + TRACE_OBJ return m_helpEngine->indexModel(); } QHelpContentWidget *HelpEngineWrapper::contentWidget() { + TRACE_OBJ return m_helpEngine->contentWidget(); } QHelpIndexWidget *HelpEngineWrapper::indexWidget() { + TRACE_OBJ return m_helpEngine->indexWidget(); } const QStringList HelpEngineWrapper::registeredDocumentations() const { + TRACE_OBJ return m_helpEngine->registeredDocumentations(); } const QString HelpEngineWrapper::collectionFile() const { + TRACE_OBJ return m_helpEngine->collectionFile(); } bool HelpEngineWrapper::registerDocumentation(const QString &docFile) { + TRACE_OBJ assertDocFilesWatched(); if (!m_helpEngine->registerDocumentation(docFile)) return false; @@ -157,6 +170,7 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile) bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) { + TRACE_OBJ assertDocFilesWatched(); const QString &file = m_helpEngine->documentationFileName(namespaceName); if (!m_helpEngine->unregisterDocumentation(namespaceName)) @@ -168,77 +182,92 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) bool HelpEngineWrapper::setupData() { + TRACE_OBJ return m_helpEngine->setupData(); } bool HelpEngineWrapper::addCustomFilter(const QString &filterName, const QStringList &attributes) { + TRACE_OBJ return m_helpEngine->addCustomFilter(filterName, attributes); } bool HelpEngineWrapper::removeCustomFilter(const QString &filterName) { + TRACE_OBJ return m_helpEngine->removeCustomFilter(filterName); } void HelpEngineWrapper::setCurrentFilter(const QString ¤tFilter) { + TRACE_OBJ m_helpEngine->setCurrentFilter(currentFilter); } const QString HelpEngineWrapper::currentFilter() const { + TRACE_OBJ return m_helpEngine->currentFilter(); } const QStringList HelpEngineWrapper::customFilters() const { + TRACE_OBJ return m_helpEngine->customFilters(); } QUrl HelpEngineWrapper::findFile(const QUrl &url) const { + TRACE_OBJ return m_helpEngine->findFile(url); } QByteArray HelpEngineWrapper::fileData(const QUrl &url) const { + TRACE_OBJ return m_helpEngine->fileData(url); } QMap HelpEngineWrapper::linksForIdentifier(const QString &id) const { + TRACE_OBJ return m_helpEngine->linksForIdentifier(id); } const QStringList HelpEngineWrapper::filterAttributes() const { + TRACE_OBJ return m_helpEngine->filterAttributes(); } const QStringList HelpEngineWrapper::filterAttributes(const QString &filterName) const { + TRACE_OBJ return m_helpEngine->filterAttributes(filterName); } QString HelpEngineWrapper::error() const { + TRACE_OBJ return m_helpEngine->error(); } bool HelpEngineWrapper::unfilteredInserted() const { + TRACE_OBJ return m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; } void HelpEngineWrapper::setUnfilteredInserted() { + TRACE_OBJ m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); } const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const { + TRACE_OBJ return m_helpEngine->customValue(VersionKey.arg(component)).toString(). split(CollectionConfiguration::ListSeparator); } @@ -246,221 +275,264 @@ const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const void HelpEngineWrapper::setQtDocInfo(const QString &component, const QStringList &doc) { + TRACE_OBJ m_helpEngine->setCustomValue(VersionKey.arg(component), doc.join(CollectionConfiguration::ListSeparator)); } const QStringList HelpEngineWrapper::lastShownPages() const { + TRACE_OBJ return CollectionConfiguration::lastShownPages(*m_helpEngine); } void HelpEngineWrapper::setLastShownPages(const QStringList &lastShownPages) { + TRACE_OBJ CollectionConfiguration::setLastShownPages(*m_helpEngine, lastShownPages); } const QStringList HelpEngineWrapper::lastZoomFactors() const { + TRACE_OBJ return CollectionConfiguration::lastZoomFactors(*m_helpEngine); } void HelpEngineWrapper::setLastZoomFactors(const QStringList &lastZoomFactors) { + TRACE_OBJ CollectionConfiguration::setLastZoomFactors(*m_helpEngine, lastZoomFactors); } const QString HelpEngineWrapper::cacheDir() const { + TRACE_OBJ return CollectionConfiguration::cacheDir(*m_helpEngine); } bool HelpEngineWrapper::cacheDirIsRelativeToCollection() const { + TRACE_OBJ return CollectionConfiguration::cacheDirIsRelativeToCollection(*m_helpEngine); } void HelpEngineWrapper::setCacheDir(const QString &cacheDir, bool relativeToCollection) { + TRACE_OBJ CollectionConfiguration::setCacheDir(*m_helpEngine, cacheDir, relativeToCollection); } bool HelpEngineWrapper::filterFunctionalityEnabled() const { + TRACE_OBJ return CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); } void HelpEngineWrapper::setFilterFunctionalityEnabled(bool enabled) { + TRACE_OBJ CollectionConfiguration::setFilterFunctionalityEnabled(*m_helpEngine, enabled); } bool HelpEngineWrapper::filterToolbarVisible() const { + TRACE_OBJ return CollectionConfiguration::filterToolbarVisible(*m_helpEngine); } void HelpEngineWrapper::setFilterToolbarVisible(bool visible) { + TRACE_OBJ CollectionConfiguration::setFilterToolbarVisible(*m_helpEngine, visible); } bool HelpEngineWrapper::addressBarEnabled() const { + TRACE_OBJ return CollectionConfiguration::addressBarEnabled(*m_helpEngine); } void HelpEngineWrapper::setAddressBarEnabled(bool enabled) { + TRACE_OBJ CollectionConfiguration::setAddressBarEnabled(*m_helpEngine, enabled); } bool HelpEngineWrapper::addressBarVisible() const { + TRACE_OBJ return CollectionConfiguration::addressBarVisible(*m_helpEngine); } void HelpEngineWrapper::setAddressBarVisible(bool visible) { + TRACE_OBJ CollectionConfiguration::setAddressBarVisible(*m_helpEngine, visible); } bool HelpEngineWrapper::documentationManagerEnabled() const { + TRACE_OBJ return CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); } void HelpEngineWrapper::setDocumentationManagerEnabled(bool enabled) { + TRACE_OBJ CollectionConfiguration::setDocumentationManagerEnabled(*m_helpEngine, enabled); } const QByteArray HelpEngineWrapper::aboutMenuTexts() const { + TRACE_OBJ return CollectionConfiguration::aboutMenuTexts(*m_helpEngine); } void HelpEngineWrapper::setAboutMenuTexts(const QByteArray &texts) { + TRACE_OBJ CollectionConfiguration::setAboutMenuTexts(*m_helpEngine, texts); } const QByteArray HelpEngineWrapper::aboutIcon() const { + TRACE_OBJ return CollectionConfiguration::aboutIcon(*m_helpEngine); } void HelpEngineWrapper::setAboutIcon(const QByteArray &icon) { + TRACE_OBJ CollectionConfiguration::setAboutIcon(*m_helpEngine, icon); } const QByteArray HelpEngineWrapper::aboutImages() const { + TRACE_OBJ return CollectionConfiguration::aboutImages(*m_helpEngine); } void HelpEngineWrapper::setAboutImages(const QByteArray &images) { + TRACE_OBJ CollectionConfiguration::setAboutImages(*m_helpEngine, images); } const QByteArray HelpEngineWrapper::aboutTexts() const { + TRACE_OBJ return CollectionConfiguration::aboutTexts(*m_helpEngine); } void HelpEngineWrapper::setAboutTexts(const QByteArray &texts) { + TRACE_OBJ CollectionConfiguration::setAboutTexts(*m_helpEngine, texts); } const QString HelpEngineWrapper::windowTitle() const { + TRACE_OBJ return CollectionConfiguration::windowTitle(*m_helpEngine); } void HelpEngineWrapper::setWindowTitle(const QString &windowTitle) { + TRACE_OBJ CollectionConfiguration::setWindowTitle(*m_helpEngine, windowTitle); } const QByteArray HelpEngineWrapper::applicationIcon() const { + TRACE_OBJ return CollectionConfiguration::applicationIcon(*m_helpEngine); } void HelpEngineWrapper::setApplicationIcon(const QByteArray &icon) { + TRACE_OBJ CollectionConfiguration::setApplicationIcon(*m_helpEngine, icon); } const QByteArray HelpEngineWrapper::mainWindow() const { + TRACE_OBJ return m_helpEngine->customValue(MainWindowKey).toByteArray(); } void HelpEngineWrapper::setMainWindow(const QByteArray &mainWindow) { + TRACE_OBJ m_helpEngine->setCustomValue(MainWindowKey, mainWindow); } const QByteArray HelpEngineWrapper::mainWindowGeometry() const { + TRACE_OBJ return m_helpEngine->customValue(MainWindowGeometryKey).toByteArray(); } void HelpEngineWrapper::setMainWindowGeometry(const QByteArray &geometry) { + TRACE_OBJ m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry); } const QByteArray HelpEngineWrapper::bookmarks() const { + TRACE_OBJ return m_helpEngine->customValue(BookmarksKey).toByteArray(); } void HelpEngineWrapper::setBookmarks(const QByteArray &bookmarks) { + TRACE_OBJ m_helpEngine->setCustomValue(BookmarksKey, bookmarks); } int HelpEngineWrapper::lastTabPage() const { + TRACE_OBJ return CollectionConfiguration::lastTabPage(*m_helpEngine); } void HelpEngineWrapper::setLastTabPage(int lastPage) { + TRACE_OBJ CollectionConfiguration::setLastTabPage(*m_helpEngine, lastPage); } bool HelpEngineWrapper::searchWasAttached() const { + TRACE_OBJ return m_helpEngine->customValue(SearchWasAttachedKey).toBool(); } void HelpEngineWrapper::setSearchWasAttached(bool attached) { + TRACE_OBJ m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); } int HelpEngineWrapper::startOption() const { + TRACE_OBJ return m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt(); } void HelpEngineWrapper::setStartOption(int option) { + TRACE_OBJ m_helpEngine->setCustomValue(StartOptionKey, option); } const QString HelpEngineWrapper::homePage() const { + TRACE_OBJ const QString &homePage = m_helpEngine->customValue(HomePageKey).toString(); if (!homePage.isEmpty()) return homePage; @@ -469,96 +541,114 @@ const QString HelpEngineWrapper::homePage() const void HelpEngineWrapper::setHomePage(const QString &page) { + TRACE_OBJ m_helpEngine->setCustomValue(HomePageKey, page); } const QString HelpEngineWrapper::defaultHomePage() const { + TRACE_OBJ return CollectionConfiguration::defaultHomePage(*m_helpEngine); } void HelpEngineWrapper::setDefaultHomePage(const QString &page) { + TRACE_OBJ CollectionConfiguration::setDefaultHomePage(*m_helpEngine, page); } bool HelpEngineWrapper::hasFontSettings() const { + TRACE_OBJ return m_helpEngine->customValue(UseAppFontKey).isValid(); } bool HelpEngineWrapper::usesAppFont() const { + TRACE_OBJ return m_helpEngine->customValue(UseAppFontKey).toBool(); } void HelpEngineWrapper::setUseAppFont(bool useAppFont) { + TRACE_OBJ m_helpEngine->setCustomValue(UseAppFontKey, useAppFont); } bool HelpEngineWrapper::usesBrowserFont() const { + TRACE_OBJ return m_helpEngine->customValue(UseBrowserFontKey, false).toBool(); } void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) { + TRACE_OBJ m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont); } const QFont HelpEngineWrapper::appFont() const { + TRACE_OBJ return qVariantValue(m_helpEngine->customValue(AppFontKey)); } void HelpEngineWrapper::setAppFont(const QFont &font) { + TRACE_OBJ m_helpEngine->setCustomValue(AppFontKey, font); } QFontDatabase::WritingSystem HelpEngineWrapper::appWritingSystem() const { + TRACE_OBJ return static_cast( m_helpEngine->customValue(AppWritingSystemKey).toInt()); } void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) { + TRACE_OBJ m_helpEngine->setCustomValue(AppWritingSystemKey, system); } const QFont HelpEngineWrapper::browserFont() const { + TRACE_OBJ return qVariantValue(m_helpEngine->customValue(BrowserFontKey)); } void HelpEngineWrapper::setBrowserFont(const QFont &font) { + TRACE_OBJ m_helpEngine->setCustomValue(BrowserFontKey, font); } QFontDatabase::WritingSystem HelpEngineWrapper::browserWritingSystem() const { + TRACE_OBJ return static_cast( m_helpEngine->customValue(BrowserWritingSystemKey).toInt()); } void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem system) { + TRACE_OBJ m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); } void HelpEngineWrapper::assertDocFilesWatched() { + TRACE_OBJ Q_ASSERT(m_qchWatcher->files().count() == m_helpEngine->registeredDocumentations().count()); } void HelpEngineWrapper::qchFileChanged(const QString &fileName) { + TRACE_OBJ /* * We don't use QHelpEngineCore::namespaceName(fileName), because the file * may not exist anymore or contain a different namespace. diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 5f2c02b..99c84c5 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "helpviewer.h" #include "centralwidget.h" @@ -93,6 +94,7 @@ HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData, const QString& mimeType) : data(fileData), origLen(fileData.length()) { + TRACE_OBJ setRequest(request); setOpenMode(QIODevice::ReadOnly); @@ -104,11 +106,13 @@ HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request, void HelpNetworkReply::abort() { + TRACE_OBJ // nothing to do } qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) { + TRACE_OBJ qint64 len = qMin(qint64(data.length()), maxlen); if (len) { qMemCopy(buffer, data.constData(), len); @@ -132,11 +136,13 @@ protected: HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent) { + TRACE_OBJ } QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, const QNetworkRequest &request, QIODevice* /*outgoingData*/) { + TRACE_OBJ const QUrl& url = request.url(); QString mimeType = url.toString(); if (mimeType.endsWith(QLatin1String(".svg")) @@ -187,10 +193,12 @@ HelpPage::HelpPage(CentralWidget *central, QObject *parent) , m_pressedButtons(Qt::NoButton) , m_keyboardModifiers(Qt::NoModifier) { + TRACE_OBJ } QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { + TRACE_OBJ HelpPage* newPage = static_cast(centralWidget->newEmptyTab()->page()); if (newPage) newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; @@ -200,6 +208,7 @@ QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) static bool isLocalUrl(const QUrl &url) { + TRACE_OBJ const QString scheme = url.scheme(); if (scheme.isEmpty() || scheme == QLatin1String("file") @@ -213,6 +222,7 @@ static bool isLocalUrl(const QUrl &url) void HelpPage::triggerAction(WebAction action, bool checked) { + TRACE_OBJ switch (action) { case OpenLinkInNewWindow: closeNewTabIfNeeded = true; @@ -225,6 +235,7 @@ void HelpPage::triggerAction(WebAction action, bool checked) bool HelpPage::acceptNavigationRequest(QWebFrame *, const QNetworkRequest &request, QWebPage::NavigationType type) { + TRACE_OBJ const QUrl &url = request.url(); const bool closeNewTab = closeNewTabIfNeeded; closeNewTabIfNeeded = false; @@ -274,6 +285,7 @@ HelpViewer::HelpViewer(CentralWidget *parent) , loadFinished(false) , helpEngine(HelpEngineWrapper::instance()) { + TRACE_OBJ setAcceptDrops(false); setPage(new HelpPage(parent, this)); @@ -303,6 +315,7 @@ HelpViewer::HelpViewer(CentralWidget *parent) void HelpViewer::setSource(const QUrl &url) { + TRACE_OBJ loadFinished = false; if (url.toString() == QLatin1String("help")) { load(QUrl(QLatin1String("qthelp://com.trolltech.com." @@ -314,21 +327,25 @@ void HelpViewer::setSource(const QUrl &url) void HelpViewer::resetZoom() { + TRACE_OBJ setTextSizeMultiplier(1.0); } void HelpViewer::zoomIn(qreal range) { + TRACE_OBJ setTextSizeMultiplier(textSizeMultiplier() + range / 10.0); } void HelpViewer::zoomOut(qreal range) { + TRACE_OBJ setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - range / 10.0)); } void HelpViewer::wheelEvent(QWheelEvent *e) { + TRACE_OBJ if (e->modifiers() & Qt::ControlModifier) { const int delta = e->delta(); if (delta > 0) @@ -343,6 +360,7 @@ void HelpViewer::wheelEvent(QWheelEvent *e) void HelpViewer::mouseReleaseEvent(QMouseEvent *e) { + TRACE_OBJ if (e->button() == Qt::XButton1) { triggerPageAction(QWebPage::Back); return; @@ -358,6 +376,7 @@ void HelpViewer::mouseReleaseEvent(QMouseEvent *e) void HelpViewer::actionChanged() { + TRACE_OBJ QAction *a = qobject_cast(sender()); if (a == pageAction(QWebPage::Copy)) emit copyAvailable(a->isEnabled()); @@ -369,6 +388,7 @@ void HelpViewer::actionChanged() void HelpViewer::mousePressEvent(QMouseEvent *event) { + TRACE_OBJ HelpPage *currentPage = static_cast(page()); if (currentPage) { currentPage->m_pressedButtons = event->buttons(); @@ -379,6 +399,7 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) void HelpViewer::setLoadFinished(bool ok) { + TRACE_OBJ loadFinished = ok; emit sourceChanged(url()); } @@ -393,11 +414,13 @@ HelpViewer::HelpViewer(CentralWidget *parent) , parentWidget(parent) , helpEngine(HelpEngineWrapper::instance()) { + TRACE_OBJ document()->setDocumentMargin(8); } void HelpViewer::setSource(const QUrl &url) { + TRACE_OBJ bool help = url.toString() == QLatin1String("help"); if (url.isValid() && !help) { if (launchedWithExternalApp(url)) @@ -422,6 +445,7 @@ void HelpViewer::setSource(const QUrl &url) void HelpViewer::resetZoom() { + TRACE_OBJ if (zoomCount == 0) return; @@ -431,6 +455,7 @@ void HelpViewer::resetZoom() void HelpViewer::zoomIn(int range) { + TRACE_OBJ if (zoomCount == 10) return; @@ -440,6 +465,7 @@ void HelpViewer::zoomIn(int range) void HelpViewer::zoomOut(int range) { + TRACE_OBJ if (zoomCount == -5) return; @@ -449,6 +475,7 @@ void HelpViewer::zoomOut(int range) bool HelpViewer::launchedWithExternalApp(const QUrl &url) { + TRACE_OBJ bool isPdf = url.path().endsWith(QLatin1String(".pdf")); if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") @@ -484,6 +511,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url) QVariant HelpViewer::loadResource(int type, const QUrl &name) { + TRACE_OBJ QByteArray ba; if (type < 4) { ba = helpEngine.fileData(name); @@ -499,6 +527,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name) void HelpViewer::openLinkInNewTab() { + TRACE_OBJ if(lastAnchor.isEmpty()) return; @@ -508,12 +537,14 @@ void HelpViewer::openLinkInNewTab() void HelpViewer::openLinkInNewTab(const QString &link) { + TRACE_OBJ lastAnchor = link; openLinkInNewTab(); } bool HelpViewer::hasAnchorAt(const QPoint& pos) { + TRACE_OBJ lastAnchor = anchorAt(pos); if (lastAnchor.isEmpty()) return false; @@ -530,6 +561,7 @@ bool HelpViewer::hasAnchorAt(const QPoint& pos) void HelpViewer::contextMenuEvent(QContextMenuEvent *e) { + TRACE_OBJ QMenu menu(QLatin1String(""), 0); QUrl link; @@ -553,6 +585,7 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e) void HelpViewer::mouseReleaseEvent(QMouseEvent *e) { + TRACE_OBJ if (e->button() == Qt::XButton1) { QTextBrowser::backward(); return; @@ -575,6 +608,7 @@ void HelpViewer::mouseReleaseEvent(QMouseEvent *e) void HelpViewer::keyPressEvent(QKeyEvent *e) { + TRACE_OBJ if ((e->key() == Qt::Key_Home && e->modifiers() != Qt::NoModifier) || (e->key() == Qt::Key_End && e->modifiers() != Qt::NoModifier)) { QKeyEvent* event = new QKeyEvent(e->type(), e->key(), Qt::NoModifier, @@ -586,6 +620,7 @@ void HelpViewer::keyPressEvent(QKeyEvent *e) void HelpViewer::wheelEvent(QWheelEvent *e) { + TRACE_OBJ if (e->modifiers() == Qt::CTRL) { e->accept(); (e->delta() > 0) ? zoomIn() : zoomOut(); @@ -599,6 +634,7 @@ void HelpViewer::wheelEvent(QWheelEvent *e) void HelpViewer::home() { + TRACE_OBJ setSource(helpEngine.homePage()); } diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 78cc238..4b25846 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "indexwindow.h" #include "centralwidget.h" @@ -61,6 +62,7 @@ IndexWindow::IndexWindow(QWidget *parent) , m_searchLineEdit(new QLineEdit) , m_indexWidget(HelpEngineWrapper::instance().indexWidget()) { + TRACE_OBJ QVBoxLayout *layout = new QVBoxLayout(this); QLabel *l = new QLabel(tr("&Look for:")); layout->addWidget(l); @@ -91,10 +93,12 @@ IndexWindow::IndexWindow(QWidget *parent) IndexWindow::~IndexWindow() { + TRACE_OBJ } void IndexWindow::filterIndices(const QString &filter) { + TRACE_OBJ if (filter.contains(QLatin1Char('*'))) m_indexWidget->filterIndices(filter, filter); else @@ -103,6 +107,7 @@ void IndexWindow::filterIndices(const QString &filter) bool IndexWindow::eventFilter(QObject *obj, QEvent *e) { + TRACE_OBJ if (obj == m_searchLineEdit && e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); QModelIndex idx = m_indexWidget->currentIndex(); @@ -168,22 +173,26 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) void IndexWindow::enableSearchLineEdit() { + TRACE_OBJ m_searchLineEdit->setDisabled(false); filterIndices(m_searchLineEdit->text()); } void IndexWindow::disableSearchLineEdit() { + TRACE_OBJ m_searchLineEdit->setDisabled(true); } void IndexWindow::setSearchLineEditText(const QString &text) { + TRACE_OBJ m_searchLineEdit->setText(text); } void IndexWindow::focusInEvent(QFocusEvent *e) { + TRACE_OBJ if (e->reason() != Qt::MouseFocusReason) { m_searchLineEdit->selectAll(); m_searchLineEdit->setFocus(); @@ -192,6 +201,7 @@ void IndexWindow::focusInEvent(QFocusEvent *e) void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) { + TRACE_OBJ QHelpIndexModel *model = qobject_cast(indexWidget->model()); if (model) { QString keyword = model->data(index, Qt::DisplayRole).toString(); diff --git a/tools/assistant/tools/assistant/installdialog.cpp b/tools/assistant/tools/assistant/installdialog.cpp index ea0bd29..4a3500f 100644 --- a/tools/assistant/tools/assistant/installdialog.cpp +++ b/tools/assistant/tools/assistant/installdialog.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "installdialog.h" @@ -66,6 +67,7 @@ InstallDialog::InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent, const QString &host, int port) : QDialog(parent), m_helpEngine(helpEngine), m_host(host), m_port(port) { + TRACE_OBJ m_ui.setupUi(this); m_ui.installButton->setEnabled(false); @@ -94,15 +96,18 @@ InstallDialog::InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent, InstallDialog::~InstallDialog() { + TRACE_OBJ } QStringList InstallDialog::installedDocumentations() const { + TRACE_OBJ return m_installedDocumentations; } void InstallDialog::init() { + TRACE_OBJ m_ui.statusLabel->setText(tr("Downloading documentation info...")); m_ui.progressBar->show(); @@ -122,6 +127,7 @@ void InstallDialog::init() void InstallDialog::updateInstallButton() { + TRACE_OBJ QListWidgetItem *item = 0; for (int i=0; icount(); ++i) { item = m_ui.listWidget->item(i); @@ -136,6 +142,7 @@ void InstallDialog::updateInstallButton() void InstallDialog::updateDocItemList() { + TRACE_OBJ QStringList registeredDocs = m_helpEngine->registeredDocumentations(); QListWidgetItem *item = 0; for (int i=0; icount(); ++i) { @@ -151,6 +158,7 @@ void InstallDialog::updateDocItemList() void InstallDialog::cancelDownload() { + TRACE_OBJ m_ui.statusLabel->setText(tr("Download canceled.")); m_httpAborted = true; m_itemsToInstall.clear(); @@ -162,6 +170,7 @@ void InstallDialog::cancelDownload() void InstallDialog::install() { + TRACE_OBJ QListWidgetItem *item = 0; for (int i=0; icount(); ++i) { item = m_ui.listWidget->item(i); @@ -174,6 +183,7 @@ void InstallDialog::install() void InstallDialog::downloadNextFile() { + TRACE_OBJ if (!m_itemsToInstall.count()) { m_ui.cancelButton->setEnabled(false); m_ui.closeButton->setEnabled(true); @@ -226,6 +236,7 @@ void InstallDialog::downloadNextFile() void InstallDialog::httpRequestFinished(int requestId, bool error) { + TRACE_OBJ if (requestId == m_docInfoId && m_buffer) { m_ui.progressBar->hide(); if (error) { @@ -296,6 +307,7 @@ void InstallDialog::httpRequestFinished(int requestId, bool error) void InstallDialog::installFile(const QString &fileName) { + TRACE_OBJ if (m_helpEngine->registerDocumentation(fileName)) { m_installedDocumentations .append(QHelpEngineCore::namespaceName(fileName)); @@ -308,6 +320,7 @@ void InstallDialog::installFile(const QString &fileName) void InstallDialog::readResponseHeader(const QHttpResponseHeader &responseHeader) { + TRACE_OBJ if (responseHeader.statusCode() != 200) { QMessageBox::information(this, m_windowTitle, tr("Download failed: %1.") @@ -321,6 +334,7 @@ void InstallDialog::readResponseHeader(const QHttpResponseHeader &responseHeader void InstallDialog::updateDataReadProgress(int bytesRead, int totalBytes) { + TRACE_OBJ if (m_httpAborted) return; @@ -330,6 +344,7 @@ void InstallDialog::updateDataReadProgress(int bytesRead, int totalBytes) void InstallDialog::browseDirectories() { + TRACE_OBJ QString dir = QFileDialog::getExistingDirectory(this, m_windowTitle, m_ui.pathLineEdit->text()); if (!dir.isEmpty()) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index be13b0a..79ed2c8 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include #include @@ -76,6 +77,7 @@ namespace { void updateLastPagesOnUnregister(QHelpEngineCore& helpEngine, const QString& nsName) { + TRACE_OBJ int lastPage = CollectionConfiguration::lastTabPage(helpEngine); QStringList currentPages = CollectionConfiguration::lastShownPages(helpEngine); if (!currentPages.isEmpty()) { @@ -100,6 +102,7 @@ updateLastPagesOnUnregister(QHelpEngineCore& helpEngine, const QString& nsName) bool updateUserCollection(QHelpEngineCore& user, const QHelpEngineCore& caller) { + TRACE_OBJ if (!CollectionConfiguration::isNewer(caller, user)) return false; CollectionConfiguration::copyConfiguration(caller, user); @@ -108,6 +111,7 @@ updateUserCollection(QHelpEngineCore& user, const QHelpEngineCore& caller) void stripNonexistingDocs(QHelpEngineCore& collection) { + TRACE_OBJ const QStringList &namespaces = collection.registeredDocumentations(); foreach (const QString &ns, namespaces) { QFileInfo fi(collection.documentationFileName(ns)); @@ -118,6 +122,7 @@ void stripNonexistingDocs(QHelpEngineCore& collection) QString indexFilesFolder(const QString &collectionFile) { + TRACE_OBJ QString indexFilesFolder = QLatin1String(".fulltextsearch"); if (!collectionFile.isEmpty()) { QFileInfo fi(collectionFile); @@ -134,6 +139,7 @@ QString indexFilesFolder(const QString &collectionFile) */ QString constructCachedCollectionFilePath(const QHelpEngineCore &collection) { + TRACE_OBJ const QString &filePath = collection.collectionFile(); const QString &fileName = QFileInfo(filePath).fileName(); const QString &cacheDir = CollectionConfiguration::cacheDir(collection); @@ -149,6 +155,7 @@ bool synchronizeDocs(QHelpEngineCore &collection, QHelpEngineCore &cachedCollection, CmdLineParser &cmd) { + TRACE_OBJ const QDateTime &lastCollectionRegisterTime = CollectionConfiguration::lastRegisterTime(collection); if (!lastCollectionRegisterTime.isValid() || lastCollectionRegisterTime @@ -180,6 +187,7 @@ bool synchronizeDocs(QHelpEngineCore &collection, bool removeSearchIndex(const QString &collectionFile) { + TRACE_OBJ QString path = QFileInfo(collectionFile).path(); path += QLatin1Char('/') + indexFilesFolder(collectionFile); @@ -199,6 +207,7 @@ bool removeSearchIndex(const QString &collectionFile) bool checkForSqlite(CmdLineParser &cmd) { + TRACE_OBJ QSqlDatabase db; QStringList sqlDrivers(db.drivers()); if (!sqlDrivers.contains(QLatin1String("QSQLITE"))) { @@ -211,6 +220,7 @@ bool checkForSqlite(CmdLineParser &cmd) bool useGui(int argc, char *argv[]) { + TRACE_OBJ bool gui = true; #ifndef Q_OS_WIN // Look for arguments that imply command-line mode. @@ -232,6 +242,7 @@ bool useGui(int argc, char *argv[]) bool registerDocumentation(QHelpEngineCore &collection, CmdLineParser &cmd, bool printSuccess) { + TRACE_OBJ if (!collection.registerDocumentation(cmd.helpFile())) { cmd.showMessage( QObject::tr("Could not register documentation file\n%1\n\nReason:\n%2") @@ -248,6 +259,7 @@ bool registerDocumentation(QHelpEngineCore &collection, CmdLineParser &cmd, bool unregisterDocumentation(QHelpEngineCore &collection, const QString &namespaceName, CmdLineParser &cmd, bool printSuccess) { + TRACE_OBJ if (!collection.unregisterDocumentation(namespaceName)) { cmd.showMessage(QObject::tr("Could not unregister documentation" " file\n%1\n\nReason:\n%2"). @@ -263,6 +275,7 @@ bool unregisterDocumentation(QHelpEngineCore &collection, void setupTranslations(QApplication &app) { + TRACE_OBJ const QString& locale = QLocale::system().name(); QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); @@ -283,6 +296,7 @@ void setupTranslations(QApplication &app) int main(int argc, char *argv[]) { + TRACE_OBJ QApplication a(argc, argv, useGui(argc, argv)); a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins")); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 9955c65..ce4ab7f 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "mainwindow.h" #include "centralwidget.h" @@ -101,6 +102,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) , m_qtDocInstaller(0) , m_connectedInitSignals(false) { + TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); @@ -254,17 +256,20 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) MainWindow::~MainWindow() { + TRACE_OBJ if (m_qtDocInstaller) delete m_qtDocInstaller; } bool MainWindow::usesDefaultCollection() const { + TRACE_OBJ return m_cmdLine->collectionFile().isEmpty(); } void MainWindow::closeEvent(QCloseEvent *e) { + TRACE_OBJ m_bookmarkManager->saveBookmarks(); HelpEngineWrapper::instance().setMainWindow(saveState()); HelpEngineWrapper::instance().setMainWindowGeometry(saveGeometry()); @@ -273,6 +278,7 @@ void MainWindow::closeEvent(QCloseEvent *e) bool MainWindow::initHelpDB() { + TRACE_OBJ HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(); if (!helpEngineWrapper.setupData()) return false; @@ -323,6 +329,7 @@ bool MainWindow::initHelpDB() void MainWindow::lookForNewQtDocumentation() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QStringList docs; docs << QLatin1String("assistant") @@ -348,6 +355,7 @@ void MainWindow::lookForNewQtDocumentation() void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) { + TRACE_OBJ if (newDocsInstalled) HelpEngineWrapper::instance().setupData(); statusBar()->clearMessage(); @@ -356,6 +364,7 @@ void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) void MainWindow::checkInitState() { + TRACE_OBJ if (!m_cmdLine->enableRemoteControl()) return; @@ -380,6 +389,7 @@ void MainWindow::checkInitState() void MainWindow::updateBookmarkMenu() { + TRACE_OBJ if (m_bookmarkManager) { m_bookmarkMenu->removeAction(m_importBookmarkAction); m_bookmarkMenu->removeAction(m_exportBookmarkAction); @@ -398,6 +408,7 @@ void MainWindow::updateBookmarkMenu() void MainWindow::showBookmark(QAction *action) { + TRACE_OBJ if (m_bookmarkManager) { const QUrl &url = m_bookmarkManager->urlForAction(action); if (url.isValid()) @@ -407,6 +418,7 @@ void MainWindow::showBookmark(QAction *action) void MainWindow::insertLastPages() { + TRACE_OBJ if (m_cmdLine->url().isValid()) m_centralWidget->setSource(m_cmdLine->url()); else @@ -418,6 +430,7 @@ void MainWindow::insertLastPages() void MainWindow::setupActions() { + TRACE_OBJ QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); #ifdef Q_OS_MAC setUnifiedTitleAndToolBarOnMac(true); @@ -643,6 +656,7 @@ void MainWindow::setupActions() QMenu *MainWindow::toolBarMenu() { + TRACE_OBJ if (!m_toolBarMenu) { m_viewMenu->addSeparator(); m_toolBarMenu = m_viewMenu->addMenu(tr("Toolbars")); @@ -652,6 +666,7 @@ QMenu *MainWindow::toolBarMenu() void MainWindow::setupFilterToolbar() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); if (!helpEngine.filterFunctionalityEnabled()) return; @@ -682,6 +697,7 @@ void MainWindow::setupFilterToolbar() void MainWindow::setupAddressToolbar() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); if (!helpEngine.addressBarEnabled()) return; @@ -710,6 +726,7 @@ void MainWindow::setupAddressToolbar() void MainWindow::updateAboutMenuText() { + TRACE_OBJ QByteArray ba = HelpEngineWrapper::instance().aboutMenuTexts(); if (ba.size() > 0) { QString lang; @@ -737,27 +754,32 @@ void MainWindow::updateAboutMenuText() void MainWindow::showNewAddress() { + TRACE_OBJ showNewAddress(m_centralWidget->currentSource()); } void MainWindow::showNewAddress(const QUrl &url) { + TRACE_OBJ m_addressLineEdit->setText(url.toString()); } void MainWindow::addBookmark() { + TRACE_OBJ addNewBookmark(m_centralWidget->currentTitle(), m_centralWidget->currentSource().toString()); } void MainWindow::gotoAddress() { + TRACE_OBJ m_centralWidget->setSource(m_addressLineEdit->text()); } void MainWindow::updateNavigationItems() { + TRACE_OBJ bool hasCurrentViewer = m_centralWidget->isHomeAvailable(); m_copyAction->setEnabled(m_centralWidget->hasSelection()); m_homeAction->setEnabled(hasCurrentViewer); @@ -771,12 +793,14 @@ void MainWindow::updateNavigationItems() void MainWindow::updateTabCloseAction() { + TRACE_OBJ m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction()); } void MainWindow::showTopicChooser(const QMap &links, const QString &keyword) { + TRACE_OBJ TopicChooser tc(this, keyword, links); if (tc.exec() == QDialog::Accepted) { m_centralWidget->setSource(tc.link()); @@ -785,6 +809,7 @@ void MainWindow::showTopicChooser(const QMap &links, void MainWindow::showPreferences() { + TRACE_OBJ PreferencesDialog dia(this); connect(&dia, SIGNAL(updateApplicationFont()), this, @@ -797,6 +822,7 @@ void MainWindow::showPreferences() void MainWindow::syncContents() { + TRACE_OBJ qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); const QUrl url = m_centralWidget->currentSource(); showContents(); @@ -808,11 +834,13 @@ void MainWindow::syncContents() void MainWindow::copyAvailable(bool yes) { + TRACE_OBJ m_copyAction->setEnabled(yes); } void MainWindow::addNewBookmark(const QString &title, const QString &url) { + TRACE_OBJ if (url.isEmpty() || url == QLatin1String("about:blank")) return; @@ -821,6 +849,7 @@ void MainWindow::addNewBookmark(const QString &title, const QString &url) void MainWindow::showAboutDialog() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QByteArray contents; QByteArray ba = helpEngine.aboutTexts(); @@ -874,6 +903,7 @@ void MainWindow::showAboutDialog() void MainWindow::setContentsVisible(bool visible) { + TRACE_OBJ if (visible) showContents(); else @@ -882,16 +912,19 @@ void MainWindow::setContentsVisible(bool visible) void MainWindow::showContents() { + TRACE_OBJ activateDockWidget(m_contentWindow); } void MainWindow::hideContents() { + TRACE_OBJ m_contentWindow->parentWidget()->hide(); } void MainWindow::setIndexVisible(bool visible) { + TRACE_OBJ if (visible) showIndex(); else @@ -900,16 +933,19 @@ void MainWindow::setIndexVisible(bool visible) void MainWindow::showIndex() { + TRACE_OBJ activateDockWidget(m_indexWindow); } void MainWindow::hideIndex() { + TRACE_OBJ m_indexWindow->parentWidget()->hide(); } void MainWindow::setBookmarksVisible(bool visible) { + TRACE_OBJ if (visible) showBookmarks(); else @@ -919,16 +955,19 @@ void MainWindow::setBookmarksVisible(bool visible) void MainWindow::showBookmarks() { + TRACE_OBJ activateDockWidget(m_bookmarkWidget); } void MainWindow::hideBookmarks() { + TRACE_OBJ m_bookmarkWidget->parentWidget()->hide(); } void MainWindow::setSearchVisible(bool visible) { + TRACE_OBJ if (visible) showSearch(); else @@ -937,16 +976,19 @@ void MainWindow::setSearchVisible(bool visible) void MainWindow::showSearch() { + TRACE_OBJ m_centralWidget->activateSearchWidget(); } void MainWindow::hideSearch() { + TRACE_OBJ m_centralWidget->removeSearchWidget(); } void MainWindow::activateDockWidget(QWidget *w) { + TRACE_OBJ w->parentWidget()->show(); w->parentWidget()->raise(); w->setFocus(); @@ -954,11 +996,13 @@ void MainWindow::activateDockWidget(QWidget *w) void MainWindow::setIndexString(const QString &str) { + TRACE_OBJ m_indexWindow->setSearchLineEditText(str); } void MainWindow::activateCurrentBrowser() { + TRACE_OBJ CentralWidget *cw = CentralWidget::instance(); if (cw) { cw->activateTab(true); @@ -967,16 +1011,19 @@ void MainWindow::activateCurrentBrowser() void MainWindow::activateCurrentCentralWidgetTab() { + TRACE_OBJ m_centralWidget->activateTab(); } void MainWindow::showSearchWidget() { + TRACE_OBJ m_centralWidget->activateSearchWidget(true); } void MainWindow::updateApplicationFont() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QFont font = qApp->font(); if (helpEngine.usesAppFont()) @@ -987,6 +1034,7 @@ void MainWindow::updateApplicationFont() void MainWindow::setupFilterCombo() { + TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); QString curFilter = m_filterCombo->currentText(); if (curFilter.isEmpty()) @@ -1001,17 +1049,20 @@ void MainWindow::setupFilterCombo() void MainWindow::filterDocumentation(const QString &customFilter) { + TRACE_OBJ HelpEngineWrapper::instance().setCurrentFilter(customFilter); } void MainWindow::expandTOC(int depth) { + TRACE_OBJ Q_ASSERT(depth >= -1); m_contentWindow->expandToDepth(depth); } void MainWindow::indexingStarted() { + TRACE_OBJ if (!m_progressWidget) { m_progressWidget = new QWidget(); QLayout* hlayout = new QHBoxLayout(m_progressWidget); @@ -1037,6 +1088,7 @@ void MainWindow::indexingStarted() void MainWindow::indexingFinished() { + TRACE_OBJ statusBar()->removeWidget(m_progressWidget); delete m_progressWidget; m_progressWidget = 0; @@ -1044,6 +1096,7 @@ void MainWindow::indexingFinished() QWidget* MainWindow::setupBookmarkWidget() { + TRACE_OBJ m_bookmarkManager = new BookmarkManager; m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, this); connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark())); @@ -1052,6 +1105,7 @@ QWidget* MainWindow::setupBookmarkWidget() QString MainWindow::collectionFileDirectory(bool createDir, const QString &cacheDir) { + TRACE_OBJ QString collectionPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation); if (collectionPath.isEmpty()) { @@ -1077,6 +1131,7 @@ QString MainWindow::collectionFileDirectory(bool createDir, const QString &cache QString MainWindow::defaultHelpCollectionFileName() { + TRACE_OBJ return collectionFileDirectory() + QDir::separator() + QString(QLatin1String("qthelpcollection_%1.qhc")). arg(QLatin1String(QT_VERSION_STR)); @@ -1084,6 +1139,7 @@ QString MainWindow::defaultHelpCollectionFileName() void MainWindow::importBookmarks() { + TRACE_OBJ const QString &fileName = QFileDialog::getOpenFileName(0, tr("Open File"), QDir::currentPath(), tr("Files (*.xbel)")); @@ -1100,6 +1156,7 @@ void MainWindow::importBookmarks() void MainWindow::exportBookmarks() { + TRACE_OBJ QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"), "untitled.xbel", tr("Files (*.xbel)")); @@ -1119,6 +1176,7 @@ void MainWindow::exportBookmarks() void MainWindow::currentFilterChanged(const QString &filter) { + TRACE_OBJ const int index = m_filterCombo->findText(filter); Q_ASSERT(index != -1); m_filterCombo->setCurrentIndex(index); @@ -1126,12 +1184,14 @@ void MainWindow::currentFilterChanged(const QString &filter) void MainWindow::documentationRemoved(const QString &namespaceName) { + TRACE_OBJ CentralWidget* widget = CentralWidget::instance(); widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); } void MainWindow::documentationUpdated(const QString &namespaceName) { + TRACE_OBJ // TODO: Check whether the documents still exists and if they do, reload. CentralWidget* widget = CentralWidget::instance(); widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); @@ -1139,6 +1199,7 @@ void MainWindow::documentationUpdated(const QString &namespaceName) void MainWindow::resetQtDocInfo(const QString &component) { + TRACE_OBJ HelpEngineWrapper::instance().setQtDocInfo(component, QStringList(QDateTime().toString(Qt::ISODate))); } @@ -1146,6 +1207,7 @@ void MainWindow::resetQtDocInfo(const QString &component) void MainWindow::registerDocumentation(const QString &component, const QString &absFileName) { + TRACE_OBJ QString ns = QHelpEngineCore::namespaceName(absFileName); if (ns.isEmpty()) return; diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 2f282b1..aac26f1 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "preferencesdialog.h" #include "filternamedialog.h" @@ -68,6 +69,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) , m_browserFontChanged(false) , helpEngine(HelpEngineWrapper::instance()) { + TRACE_OBJ m_ui.setupUi(this); connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), @@ -117,6 +119,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) PreferencesDialog::~PreferencesDialog() { + TRACE_OBJ if (m_appFontChanged) { helpEngine.setAppFont(m_appFontPanel->selectedFont()); helpEngine.setUseAppFont(m_appFontPanel->isChecked()); @@ -145,12 +148,14 @@ PreferencesDialog::~PreferencesDialog() void PreferencesDialog::showDialog() { + TRACE_OBJ if (exec() != Accepted) m_appFontChanged = m_browserFontChanged = false; } void PreferencesDialog::updateFilterPage() { + TRACE_OBJ m_ui.filterWidget->clear(); m_ui.attributeWidget->clear(); @@ -174,6 +179,7 @@ void PreferencesDialog::updateFilterPage() void PreferencesDialog::updateAttributes(QListWidgetItem *item) { + TRACE_OBJ QStringList checkedList; if (item) checkedList = m_filterMap.value(item->text()); @@ -189,6 +195,7 @@ void PreferencesDialog::updateAttributes(QListWidgetItem *item) void PreferencesDialog::updateFilterMap() { + TRACE_OBJ if (!m_ui.filterWidget->currentItem()) return; QString filter = m_ui.filterWidget->currentItem()->text(); @@ -207,6 +214,7 @@ void PreferencesDialog::updateFilterMap() void PreferencesDialog::addFilter() { + TRACE_OBJ FilterNameDialog dia(this); if (dia.exec() == QDialog::Rejected) return; @@ -224,6 +232,7 @@ void PreferencesDialog::addFilter() void PreferencesDialog::removeFilter() { + TRACE_OBJ QListWidgetItem *item = m_ui.filterWidget ->takeItem(m_ui.filterWidget->currentRow()); if (!item) @@ -238,6 +247,7 @@ void PreferencesDialog::removeFilter() void PreferencesDialog::addDocumentationLocal() { + TRACE_OBJ const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Add Documentation"), QString(), tr("Qt Compressed Help Files (*.qch)")); if (fileNames.isEmpty()) @@ -291,6 +301,7 @@ void PreferencesDialog::addDocumentationLocal() void PreferencesDialog::removeDocumentation() { + TRACE_OBJ bool foundBefore = false; CentralWidget* widget = CentralWidget::instance(); QMap openedDocList = widget->currentSourceFileList(); @@ -322,6 +333,7 @@ void PreferencesDialog::removeDocumentation() void PreferencesDialog::applyChanges() { + TRACE_OBJ bool filtersWereChanged = false; if (!m_hideFiltersTab) { if (m_filterMap.count() != m_filterMapBackup.count()) { @@ -375,6 +387,7 @@ void PreferencesDialog::applyChanges() void PreferencesDialog::updateFontSettingsPage() { + TRACE_OBJ m_browserFontPanel = new FontPanel(this); m_browserFontPanel->setCheckable(true); m_ui.stackedWidget_2->insertWidget(0, m_browserFontPanel); @@ -426,30 +439,35 @@ void PreferencesDialog::updateFontSettingsPage() void PreferencesDialog::appFontSettingToggled(bool on) { + TRACE_OBJ Q_UNUSED(on) m_appFontChanged = true; } void PreferencesDialog::appFontSettingChanged(int index) { + TRACE_OBJ Q_UNUSED(index) m_appFontChanged = true; } void PreferencesDialog::browserFontSettingToggled(bool on) { + TRACE_OBJ Q_UNUSED(on) m_browserFontChanged = true; } void PreferencesDialog::browserFontSettingChanged(int index) { + TRACE_OBJ Q_UNUSED(index) m_browserFontChanged = true; } void PreferencesDialog::updateOptionsPage() { + TRACE_OBJ m_ui.homePageLineEdit->setText(helpEngine.homePage()); int option = helpEngine.startOption(); @@ -462,11 +480,13 @@ void PreferencesDialog::updateOptionsPage() void PreferencesDialog::setBlankPage() { + TRACE_OBJ m_ui.homePageLineEdit->setText(QLatin1String("about:blank")); } void PreferencesDialog::setCurrentPage() { + TRACE_OBJ QString homepage = CentralWidget::instance()->currentSource().toString(); if (homepage.isEmpty()) homepage = QLatin1String("help"); @@ -476,6 +496,7 @@ void PreferencesDialog::setCurrentPage() void PreferencesDialog::setDefaultPage() { + TRACE_OBJ m_ui.homePageLineEdit->setText(helpEngine.defaultHomePage()); } diff --git a/tools/assistant/tools/assistant/qtdocinstaller.cpp b/tools/assistant/tools/assistant/qtdocinstaller.cpp index 3675aec..44272a0 100644 --- a/tools/assistant/tools/assistant/qtdocinstaller.cpp +++ b/tools/assistant/tools/assistant/qtdocinstaller.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include #include @@ -52,10 +53,12 @@ QT_BEGIN_NAMESPACE QtDocInstaller::QtDocInstaller(const QList &docInfos) : m_abort(false), m_docInfos(docInfos) { + TRACE_OBJ } QtDocInstaller::~QtDocInstaller() { + TRACE_OBJ if (!isRunning()) return; m_mutex.lock(); @@ -66,11 +69,13 @@ QtDocInstaller::~QtDocInstaller() void QtDocInstaller::installDocs() { + TRACE_OBJ start(LowPriority); } void QtDocInstaller::run() { + TRACE_OBJ m_qchDir = QLibraryInfo::location(QLibraryInfo::DocumentationPath) + QDir::separator() + QLatin1String("qch"); m_qchFiles = m_qchDir.entryList(QStringList() << QLatin1String("*.qch")); @@ -90,6 +95,7 @@ void QtDocInstaller::run() bool QtDocInstaller::installDoc(const DocInfo &docInfo) { + TRACE_OBJ const QString &component = docInfo.first; const QStringList &info = docInfo.second; QDateTime dt; diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index f4ae3b4..f8eef4c 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "remotecontrol.h" #include "mainwindow.h" @@ -68,16 +69,19 @@ QT_BEGIN_NAMESPACE StdInListenerWin::StdInListenerWin(QObject *parent) : QThread(parent) { + TRACE_OBJ } StdInListenerWin::~StdInListenerWin() { + TRACE_OBJ terminate(); wait(); } void StdInListenerWin::run() { + TRACE_OBJ bool ok = true; char chBuf[4096]; DWORD dwRead; @@ -117,6 +121,7 @@ RemoteControl::RemoteControl(MainWindow *mainWindow) , helpEngine(HelpEngineWrapper::instance()) { + TRACE_OBJ connect(m_mainWindow, SIGNAL(initDone()), this, SLOT(applyCache())); #ifdef Q_OS_WIN StdInListenerWin *l = new StdInListenerWin(this); @@ -133,6 +138,7 @@ RemoteControl::RemoteControl(MainWindow *mainWindow) void RemoteControl::receivedData() { + TRACE_OBJ QByteArray ba; while (true) { char c = getc(stdin); @@ -148,6 +154,7 @@ void RemoteControl::receivedData() void RemoteControl::handleCommandString(const QString &cmdString) { + TRACE_OBJ QStringList cmds = cmdString.split(QLatin1Char(';')); QStringList::const_iterator it = cmds.constBegin(); while (it != cmds.constEnd()) { @@ -192,6 +199,7 @@ void RemoteControl::handleCommandString(const QString &cmdString) void RemoteControl::splitInputString(const QString &input, QString &cmd, QString &arg) { + TRACE_OBJ QString cmdLine = input.trimmed(); int i = cmdLine.indexOf(QLatin1Char(' ')); cmd = cmdLine.left(i); @@ -201,11 +209,13 @@ void RemoteControl::splitInputString(const QString &input, QString &cmd, void RemoteControl::handleDebugCommand(const QString &arg) { + TRACE_OBJ m_debug = arg == QLatin1String("on"); } void RemoteControl::handleShowOrHideCommand(const QString &arg, bool show) { + TRACE_OBJ if (arg.toLower() == QLatin1String("contents")) m_mainWindow->setContentsVisible(show); else if (arg.toLower() == QLatin1String("index")) @@ -218,6 +228,7 @@ void RemoteControl::handleShowOrHideCommand(const QString &arg, bool show) void RemoteControl::handleSetSourceCommand(const QString &arg) { + TRACE_OBJ QUrl url(arg); if (url.isValid()) { if (url.isRelative()) @@ -233,6 +244,7 @@ void RemoteControl::handleSetSourceCommand(const QString &arg) void RemoteControl::handleSyncContentsCommand() { + TRACE_OBJ if (m_caching) m_syncContents = true; else @@ -241,6 +253,7 @@ void RemoteControl::handleSyncContentsCommand() void RemoteControl::handleActivateKeywordCommand(const QString &arg) { + TRACE_OBJ if (m_caching) { clearCache(); m_activateKeyword = arg; @@ -253,6 +266,7 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg) void RemoteControl::handleActivateIdentifierCommand(const QString &arg) { + TRACE_OBJ if (m_caching) { clearCache(); m_activateIdentifier = arg; @@ -265,6 +279,7 @@ void RemoteControl::handleActivateIdentifierCommand(const QString &arg) void RemoteControl::handleExpandTocCommand(const QString &arg) { + TRACE_OBJ bool ok = false; int depth = -2; if (!arg.isEmpty()) @@ -280,6 +295,7 @@ void RemoteControl::handleExpandTocCommand(const QString &arg) void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) { + TRACE_OBJ if (helpEngine.customFilters().contains(arg)) { if (m_caching) { clearCache(); @@ -292,6 +308,7 @@ void RemoteControl::handleSetCurrentFilterCommand(const QString &arg) void RemoteControl::handleRegisterCommand(const QString &arg) { + TRACE_OBJ const QString &absFileName = QFileInfo(arg).absoluteFilePath(); if (helpEngine.registeredDocumentations(). contains(QHelpEngineCore::namespaceName(absFileName))) @@ -302,6 +319,7 @@ void RemoteControl::handleRegisterCommand(const QString &arg) void RemoteControl::handleUnregisterCommand(const QString &arg) { + TRACE_OBJ const QString &absFileName = QFileInfo(arg).absoluteFilePath(); const QString &ns = QHelpEngineCore::namespaceName(absFileName); if (helpEngine.registeredDocumentations().contains(ns)) { @@ -314,6 +332,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg) void RemoteControl::applyCache() { + TRACE_OBJ if (m_setSource.isValid()) { CentralWidget::instance()->setSource(m_setSource); } else if (!m_activateKeyword.isEmpty()) { @@ -340,6 +359,7 @@ void RemoteControl::applyCache() void RemoteControl::clearCache() { + TRACE_OBJ m_currentFilter.clear(); m_setSource.clear(); m_syncContents = false; diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp index 3b456a3..06cf4b0 100644 --- a/tools/assistant/tools/assistant/searchwidget.cpp +++ b/tools/assistant/tools/assistant/searchwidget.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "mainwindow.h" #include "searchwidget.h" @@ -65,6 +66,7 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) , attached(false) , searchEngine(engine) { + TRACE_OBJ QVBoxLayout *vLayout = new QVBoxLayout(this); resultWidget = searchEngine->resultWidget(); @@ -91,11 +93,13 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) SearchWidget::~SearchWidget() { + TRACE_OBJ // nothing todo } void SearchWidget::zoomIn() { + TRACE_OBJ QTextBrowser* browser = qFindChild(resultWidget); if (browser && zoomCount != 10) { zoomCount++; @@ -105,6 +109,7 @@ void SearchWidget::zoomIn() void SearchWidget::zoomOut() { + TRACE_OBJ QTextBrowser* browser = qFindChild(resultWidget); if (browser && zoomCount != -5) { zoomCount--; @@ -114,6 +119,7 @@ void SearchWidget::zoomOut() void SearchWidget::resetZoom() { + TRACE_OBJ if (zoomCount == 0) return; @@ -126,33 +132,39 @@ void SearchWidget::resetZoom() bool SearchWidget::isAttached() const { + TRACE_OBJ return attached; } void SearchWidget::setAttached(bool state) { + TRACE_OBJ attached = state; } void SearchWidget::search() const { + TRACE_OBJ QList query = searchEngine->queryWidget()->query(); searchEngine->search(query); } void SearchWidget::searchingStarted() { + TRACE_OBJ qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); } void SearchWidget::searchingFinished(int hits) { + TRACE_OBJ Q_UNUSED(hits) qApp->restoreOverrideCursor(); } bool SearchWidget::eventFilter(QObject* o, QEvent *e) { + TRACE_OBJ QTextBrowser* browser = qFindChild(resultWidget); if (browser && o == browser->viewport() && e->type() == QEvent::MouseButtonRelease){ @@ -171,6 +183,7 @@ bool SearchWidget::eventFilter(QObject* o, QEvent *e) void SearchWidget::keyPressEvent(QKeyEvent *keyEvent) { + TRACE_OBJ if (keyEvent->key() == Qt::Key_Escape) MainWindow::activateCurrentBrowser(); else @@ -179,6 +192,7 @@ void SearchWidget::keyPressEvent(QKeyEvent *keyEvent) void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) { + TRACE_OBJ QMenu menu; QPoint point = contextMenuEvent->globalPos(); diff --git a/tools/assistant/tools/assistant/topicchooser.cpp b/tools/assistant/tools/assistant/topicchooser.cpp index 0382fe2..803ea04 100644 --- a/tools/assistant/tools/assistant/topicchooser.cpp +++ b/tools/assistant/tools/assistant/topicchooser.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include #include @@ -50,6 +51,7 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword, const QMap &links) : QDialog(parent) { + TRACE_OBJ ui.setupUi(this); ui.label->setText(tr("Choose a topic for %1:").arg(keyword)); @@ -72,6 +74,7 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword, QUrl TopicChooser::link() const { + TRACE_OBJ QListWidgetItem *item = ui.listWidget->currentItem(); if (!item) return QUrl(); diff --git a/tools/assistant/tools/assistant/xbelsupport.cpp b/tools/assistant/tools/assistant/xbelsupport.cpp index 3c545ac..f2c0bcb 100644 --- a/tools/assistant/tools/assistant/xbelsupport.cpp +++ b/tools/assistant/tools/assistant/xbelsupport.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "tracer.h" #include "xbelsupport.h" #include "bookmarkmanager.h" @@ -56,11 +57,13 @@ XbelWriter::XbelWriter(BookmarkModel *model) : QXmlStreamWriter() , treeModel(model) { + TRACE_OBJ setAutoFormatting(true); } void XbelWriter::writeToFile(QIODevice *device) { + TRACE_OBJ setDevice(device); writeStartDocument(); @@ -77,6 +80,7 @@ void XbelWriter::writeToFile(QIODevice *device) void XbelWriter::writeData(QStandardItem *child) { + TRACE_OBJ Bookmark entry; entry.title = child->data(Qt::DisplayRole).toString(); entry.url = child->data(Qt::UserRole + 10).toString(); @@ -111,12 +115,14 @@ XbelReader::XbelReader(BookmarkModel *tree, BookmarkModel *list) , treeModel(tree) , listModel(list) { + TRACE_OBJ folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png")); } bool XbelReader::readFromFile(QIODevice *device) { + TRACE_OBJ setDevice(device); while (!atEnd()) { @@ -138,6 +144,7 @@ bool XbelReader::readFromFile(QIODevice *device) void XbelReader::readXBEL() { + TRACE_OBJ while (!atEnd()) { readNext(); @@ -157,6 +164,7 @@ void XbelReader::readXBEL() void XbelReader::readUnknownElement() { + TRACE_OBJ while (!atEnd()) { readNext(); @@ -170,6 +178,7 @@ void XbelReader::readUnknownElement() void XbelReader::readFolder(QStandardItem *item) { + TRACE_OBJ QStandardItem *folder = createChildItem(item); folder->setIcon(folderIcon); folder->setData(QLatin1String("Folder"), Qt::UserRole + 10); @@ -199,6 +208,7 @@ void XbelReader::readFolder(QStandardItem *item) void XbelReader::readBookmark(QStandardItem *item) { + TRACE_OBJ QStandardItem *bookmark = createChildItem(item); bookmark->setIcon(bookmarkIcon); bookmark->setText(QCoreApplication::tr("Unknown title")); @@ -224,6 +234,7 @@ void XbelReader::readBookmark(QStandardItem *item) QStandardItem *XbelReader::createChildItem(QStandardItem *item) { + TRACE_OBJ QStandardItem *childItem = new QStandardItem(); childItem->setEditable(false); -- cgit v0.12 From 44aa42960ad8e1df5499b515d23041bdffce6988 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 7 Dec 2009 16:34:45 +0100 Subject: Fix memory leak Merge-request: 391 Reviewed-by: Eskil Abrahamsen Blomfeldt --- examples/webkit/fancybrowser/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index cfc5500..6b3f983 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -120,6 +120,7 @@ void MainWindow::slotSourceDownloaded() textEdit->setAttribute(Qt::WA_DeleteOnClose); textEdit->show(); textEdit->setPlainText(reply->readAll()); + reply->deleteLater(); } //! [4] -- cgit v0.12 From 0c9aa0cc58e3cf3f477024b35291b407be059c01 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 7 Dec 2009 16:44:34 +0100 Subject: Assistant: Add "shared" directory to dependency list. --- tools/assistant/tools/assistant/assistant.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index ca2e52e..980f078 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -11,6 +11,7 @@ PROJECTNAME = Assistant DESTDIR = ../../../../bin target.path = $$[QT_INSTALL_BINS] INSTALLS += target +DEPENDPATH += ../shared # ## Work around a qmake issue when statically linking to # ## not-yet-installed plugins -- cgit v0.12 From e1c515f73eca4e85211fffc718b3d9e27f21eb19 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 1 Oct 2009 21:41:44 +0300 Subject: Added QToolBar::visibilityChanged(bool) signal. Reviewed-By: Thierry --- src/gui/widgets/qtoolbar.cpp | 9 +++++++++ src/gui/widgets/qtoolbar.h | 1 + tests/auto/qtoolbar/tst_qtoolbar.cpp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 58a3d28..47c4698 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -534,6 +534,14 @@ void QToolBarPrivate::plug(const QRect &r) /*! + \fn void QToolBar::visibilityChanged(bool visible) + \since 4.7 + + This signal is emitted when the toolbar becomes \a visible (or + invisible). This happens when the widget is hidden or shown. +*/ + +/*! Constructs a QToolBar with the given \a parent. */ QToolBar::QToolBar(QWidget *parent) @@ -1123,6 +1131,7 @@ bool QToolBar::event(QEvent *event) // fallthrough intended case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); + emit visibilityChanged(event->type() == QEvent::Show); #if defined(Q_WS_MAC) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore diff --git a/src/gui/widgets/qtoolbar.h b/src/gui/widgets/qtoolbar.h index a1a24f0..9712637 100644 --- a/src/gui/widgets/qtoolbar.h +++ b/src/gui/widgets/qtoolbar.h @@ -143,6 +143,7 @@ Q_SIGNALS: void iconSizeChanged(const QSize &iconSize); void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); void topLevelChanged(bool topLevel); + void visibilityChanged(bool visible); protected: void actionEvent(QActionEvent *event); diff --git a/tests/auto/qtoolbar/tst_qtoolbar.cpp b/tests/auto/qtoolbar/tst_qtoolbar.cpp index ac86fd9..93dfca5 100644 --- a/tests/auto/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/qtoolbar/tst_qtoolbar.cpp @@ -102,6 +102,7 @@ private slots: void orientationChanged(); void iconSizeChanged(); void toolButtonStyleChanged(); + void visibilityChanged(); void actionOwnership(); void widgetAction(); void accel(); @@ -998,6 +999,36 @@ void tst_QToolBar::iconSizeChanged() void tst_QToolBar::toolButtonStyleChanged() { DEPENDS_ON("toolButtonStyle()"); } +void tst_QToolBar::visibilityChanged() +{ + QMainWindow mw; + QToolBar tb; + QSignalSpy spy(&tb, SIGNAL(visibilityChanged(bool))); + + mw.addToolBar(&tb); + mw.show(); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), true); + spy.clear(); + + tb.hide(); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), false); + spy.clear(); + + tb.hide(); + QCOMPARE(spy.count(), 0); + + tb.show(); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), true); + spy.clear(); + + tb.show(); + QCOMPARE(spy.count(), 0); +} + void tst_QToolBar::actionOwnership() { { -- cgit v0.12 From d3dbb40fa67cf566288dce71834213dbe8e119e9 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 8 Dec 2009 14:51:43 +0100 Subject: Assistant: Don't re-load saved pages that don't exist anymore. Reviewed-by: kh1 --- tools/assistant/tools/assistant/centralwidget.cpp | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 8343ad1..10495ad 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -466,25 +466,27 @@ void CentralWidget::setLastShownPages() setSource(QUrl(QLatin1String("about:blank"))); return; } - QStringList zoomFactors = helpEngine.lastZoomFactors(); while (zoomFactors.count() < pageCount) zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); - QStringList::const_iterator zIt = zoomFactors.constBegin(); - QStringList::const_iterator it = lastShownPageList.constBegin(); - for (; it != lastShownPageList.constEnd(); ++it, ++zIt) - setSourceInNewTab((*it), (*zIt).toFloat()); - - int tab = helpEngine.lastTabPage(); - const bool searchIsAttached = m_searchWidget->isAttached(); const bool searchWasAttached = helpEngine.searchWasAttached(); + int tabToShow = helpEngine.lastTabPage(); if (searchWasAttached && !searchIsAttached) - --tab; + --tabToShow; else if (!searchWasAttached && searchIsAttached) - ++tab; - tabWidget->setCurrentIndex(tab); + ++tabToShow; + + for (int curTab = 0; curTab < pageCount; ++curTab) { + const QString &curFile = lastShownPageList.at(curTab); + if (helpEngine.findFile(curFile).isValid()) + setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat()); + else if (curTab + searchIsAttached <= tabToShow) + --tabToShow; + } + + tabWidget->setCurrentIndex(tabToShow); } bool CentralWidget::hasSelection() const -- cgit v0.12 From c4cd151801d4322c694609b5d12a5dd3f59422e9 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 8 Dec 2009 15:49:48 +0100 Subject: Assistant: Allow search tab to be displayed on start-up. Reviewed-by: kh1 --- tools/assistant/tools/assistant/centralwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 10495ad..d148095 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -314,7 +314,7 @@ CentralWidget::~CentralWidget() } HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - helpEngine.setLastTabPage(lastTabPage); + helpEngine.setLastTabPage(tabWidget->currentIndex()); helpEngine.setLastShownPages(currentPages); helpEngine.setSearchWasAttached(searchAttached); helpEngine.setLastZoomFactors(zoomFactors); @@ -473,7 +473,7 @@ void CentralWidget::setLastShownPages() const bool searchIsAttached = m_searchWidget->isAttached(); const bool searchWasAttached = helpEngine.searchWasAttached(); int tabToShow = helpEngine.lastTabPage(); - if (searchWasAttached && !searchIsAttached) + if (searchWasAttached && !searchIsAttached && tabToShow != 0) --tabToShow; else if (!searchWasAttached && searchIsAttached) ++tabToShow; -- cgit v0.12 From 2bfb839c3ff90b52e52ef032e513b70789139d5c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Dec 2009 16:57:41 +0100 Subject: Disable some code in normal build. Q_AUTOTEST_EXPORT is always defined. (it is defined empty if not internal build) Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a922022..7669ee1 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -882,7 +882,7 @@ QObject::~QObject() // all the signal/slots connections are still in place - if we don't // quit now, we will crash pretty soon. qWarning("Detected an unexpected exception in ~QObject while emitting destroyed()."); -#if defined(Q_AUTOTEST_EXPORT) && !defined(QT_NO_EXCEPTIONS) +#if defined(Q_BUILD_INTERNAL) && !defined(QT_NO_EXCEPTIONS) struct AutotestException : public std::exception { const char *what() const throw() { return "autotest swallow"; } -- cgit v0.12 From ccc3497c8815c1bc686a85a88ca2810f99a0c1eb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Dec 2009 16:59:00 +0100 Subject: Small optimisations in ~QObject Avoid calling signalSlotMutex while there is a very small probability that the node will be different or that the mutex are the same for two different object. Reviewed-by: brad --- src/corelib/kernel/qobject.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 7669ee1..91bf4ae 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -914,7 +914,8 @@ QObject::~QObject() // disconnect all receivers if (d->connectionLists) { ++d->connectionLists->inUse; - for (int signal = -1; signal < d->connectionLists->count(); ++signal) { + int connectionListsCount = d->connectionLists->count(); + for (int signal = -1; signal < connectionListsCount; ++signal) { QObjectPrivate::ConnectionList &connectionList = (*d->connectionLists)[signal]; @@ -951,16 +952,17 @@ QObject::~QObject() // disconnect all senders QObjectPrivate::Connection *node = d->senders; while (node) { - QMutex *m = signalSlotLock(node->sender); + QObject *sender = node->sender; + QMutex *m = signalSlotLock(sender); node->prev = &node; bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); //the node has maybe been removed while the mutex was unlocked in relock? - if (!node || signalSlotLock(node->sender) != m) { + if (!node || node->sender != sender) { m->unlock(); continue; } node->receiver = 0; - QObjectConnectionListVector *senderLists = node->sender->d_func()->connectionLists; + QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists; if (senderLists) senderLists->dirty = true; -- cgit v0.12 From 3bce78f6e143883fdba413e134504485594e73b3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Dec 2009 16:59:36 +0100 Subject: Optimize QOrderedMutexLocker try first to lock without releasing the second mutex. If it succees at first (likely), we should not have deadlock, and we do not need to unlock and relock the first mutex Should help in ~QObject Reviewed-by: brad --- src/corelib/thread/qorderedmutexlocker_p.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index c22ee5c..946d306 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -103,9 +103,11 @@ public: mtx2->lock(); return true; } - mtx1->unlock(); - mtx2->lock(); - mtx1->lock(); + if (!mtx2->tryLock()) { + mtx1->unlock(); + mtx2->lock(); + mtx1->lock(); + } return true; } -- cgit v0.12 From b81b8e43ad57183ed66086ec90cabef5906ab9a2 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 9 Dec 2009 10:59:10 +0100 Subject: Fix the int validator not handling the locale Task-number: QTBUG-3179 Reviewed-by: ogoffart --- src/corelib/tools/qlocale.cpp | 11 +++++++++-- src/gui/widgets/qvalidator.cpp | 20 ++++++++++++++++++-- src/gui/widgets/qvalidator.h | 1 + tests/auto/qintvalidator/tst_qintvalidator.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 4a66b92..c2280c6 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -4293,6 +4293,7 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte const bool scientific = numMode == DoubleScientificMode; bool lastWasE = false; + bool lastWasDigit = false; int eCnt = 0; int decPointCnt = 0; bool dec = false; @@ -4307,6 +4308,7 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte if (dec && decDigits != -1 && decDigits < ++decDigitCnt) return false; } + lastWasDigit = true; } else { switch (c) { case '.': @@ -4344,7 +4346,10 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte break; case ',': - return false; + //it can only be placed after a digit which is before the decimal point + if (!lastWasDigit || decPointCnt > 0) + return false; + break; case 'e': if (scientific) { @@ -4362,10 +4367,12 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte // If it's not a valid digit, it shall be Invalid. return false; } + lastWasDigit = false; } lastWasE = c == 'e'; - buff->append(c); + if (c != ',') + buff->append(c); } return true; diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp index 405bf04..83f603d 100644 --- a/src/gui/widgets/qvalidator.cpp +++ b/src/gui/widgets/qvalidator.cpp @@ -400,8 +400,10 @@ QValidator::State QIntValidator::validate(QString & input, int&) const qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); if (overflow || !ok) return Invalid; - if (entered >= b && entered <= t) - return Acceptable; + if (entered >= b && entered <= t) { + locale().toInt(input, &ok); + return ok ? Acceptable : Intermediate; + } if (entered >= 0) { // the -entered < b condition is necessary to allow people to type @@ -412,6 +414,20 @@ QValidator::State QIntValidator::validate(QString & input, int&) const } } +/*! \reimp */ +void QIntValidator::fixup(QString &input) const +{ + QByteArray buff; + if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) { + QLocale cl(QLocale::C); + if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) + return; + } + bool ok, overflow; + qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); + if (ok && !overflow) + input = locale().toString(entered); +} /*! Sets the range of the validator to only accept integers between \a diff --git a/src/gui/widgets/qvalidator.h b/src/gui/widgets/qvalidator.h index a0d9534..caf0c01 100644 --- a/src/gui/widgets/qvalidator.h +++ b/src/gui/widgets/qvalidator.h @@ -105,6 +105,7 @@ public: ~QIntValidator(); QValidator::State validate(QString &, int &) const; + void fixup(QString &input) const; void setBottom(int); void setTop(int); diff --git a/tests/auto/qintvalidator/tst_qintvalidator.cpp b/tests/auto/qintvalidator/tst_qintvalidator.cpp index 3e0bd14..292a0cb 100644 --- a/tests/auto/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/qintvalidator/tst_qintvalidator.cpp @@ -50,6 +50,7 @@ private slots: void validate_data(); void validate(); void validateArabic(); + void validateFrench(); }; Q_DECLARE_METATYPE(QValidator::State); @@ -182,6 +183,30 @@ void tst_QIntValidator::validateArabic() } + +void tst_QIntValidator::validateFrench() +{ + QIntValidator validator(-2000, 2000, 0); + validator.setLocale(QLocale::French); + int i; + + QString s = QLatin1String("1 "); + QCOMPARE(validator.validate(s, i), QValidator::Acceptable); + validator.fixup(s); + QCOMPARE(s, s); + + s = QLatin1String("1 000"); + QCOMPARE(validator.validate(s, i), QValidator::Acceptable); + validator.fixup(s); + QCOMPARE(s, s); + + + s = QLatin1String("1 0 00"); + QCOMPARE(validator.validate(s, i), QValidator::Intermediate); + validator.fixup(s); + QCOMPARE(s, validator.locale().toString(1000)); +} + void tst_QIntValidator::validate() { QFETCH(int, minimum); @@ -190,6 +215,7 @@ void tst_QIntValidator::validate() QFETCH(QValidator::State, state); QIntValidator iv(minimum, maximum, 0); + iv.setLocale(QLocale::C); int dummy; QCOMPARE((int)iv.validate(value, dummy), (int)state); } -- cgit v0.12 From 5b2cdd7cdeec0bb77e331d6ef78ecf3b678b0764 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 9 Dec 2009 12:23:13 +0100 Subject: Assistant: Try to reload open pages on doc file update. Reviewed-by: kh1 --- tools/assistant/tools/assistant/centralwidget.cpp | 20 ++++++++++++++++---- tools/assistant/tools/assistant/centralwidget.h | 2 +- tools/assistant/tools/assistant/mainwindow.cpp | 7 ++++--- .../assistant/tools/assistant/preferencesdialog.cpp | 2 +- tools/assistant/tools/assistant/remotecontrol.cpp | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index d148095..638b8d2 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1179,13 +1179,25 @@ CentralWidget::highlightSearchTerms() } -void CentralWidget::closeTabs(const QList &indices) +void CentralWidget::closeOrReloadTabs(const QList &indices, bool tryReload) { TRACE_OBJ QList sortedIndices = indices; qSort(sortedIndices); - for (int i = sortedIndices.count(); --i >= 0;) - closeTabAt(sortedIndices.at(i)); + for (int i = sortedIndices.count(); --i >= 0;) { + const int tab = sortedIndices.at(i); + bool close = true; + if (tryReload) { + HelpViewer *viewer = + qobject_cast(tabWidget->widget(tab)); + if (HelpEngineWrapper::instance().findFile(viewer->url()).isValid()) { + viewer->reload(); + close = false; + } + } + if (close) + closeTabAt(tab); + } if (availableHelpViewer() == 0) setSource(QUrl(QLatin1String("about:blank"))); } @@ -1202,7 +1214,7 @@ QMap CentralWidget::currentSourceFileList() const { TRACE_OBJ QMap sourceList; - for (int i = 1; i < tabWidget->count(); ++i) { + for (int i = 0; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) sourceList.insert(i, viewer->source().host()); diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index d90968e..c6e9fc8 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -135,7 +135,7 @@ public: int availableHelpViewer() const; bool enableTabCloseAction() const; - void closeTabs(const QList &indices); + void closeOrReloadTabs(const QList &indices, bool tryReload); void closeTabAt(int index); QMap currentSourceFileList() const; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index ce4ab7f..163d9b9 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -1186,15 +1186,16 @@ void MainWindow::documentationRemoved(const QString &namespaceName) { TRACE_OBJ CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); + widget->closeOrReloadTabs(widget->currentSourceFileList(). + keys(namespaceName), false); } void MainWindow::documentationUpdated(const QString &namespaceName) { TRACE_OBJ - // TODO: Check whether the documents still exists and if they do, reload. CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(namespaceName)); + widget->closeOrReloadTabs(widget->currentSourceFileList(). + keys(namespaceName), true); } void MainWindow::resetQtDocInfo(const QString &component) diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index aac26f1..7141ec5 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -374,7 +374,7 @@ void PreferencesDialog::applyChanges() } } - CentralWidget::instance()->closeTabs(m_TabsToClose); + CentralWidget::instance()->closeOrReloadTabs(m_TabsToClose, false); foreach (const QString &doc, m_unregDocs) helpEngine.unregisterDocumentation(doc); diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index f8eef4c..1f02ef9 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -324,7 +324,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg) const QString &ns = QHelpEngineCore::namespaceName(absFileName); if (helpEngine.registeredDocumentations().contains(ns)) { CentralWidget* widget = CentralWidget::instance(); - widget->closeTabs(widget->currentSourceFileList().keys(ns)); + widget->closeOrReloadTabs(widget->currentSourceFileList().keys(ns), false); if (helpEngine.unregisterDocumentation(ns)) helpEngine.setupData(); } -- cgit v0.12 From 6135da7c97830ea46ca807b7cf5944dc74fdb960 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 8 Dec 2009 11:42:57 +0100 Subject: Use realpath only on OS we know it works on. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As far as we know realpath(X,0) extenstion is only supported on Linux, Mac OS X starting with 10.6 and on Symbian. Here goes the trick: realpath() on Mac properly handles file systems case-sensitivity, meaning two files with different cases will are the same file if the file system is case insensitive (which is the default on Mac). However the QFSFileEngine will still say that the file system is case sensitive because on Mac you can have several drives with different file systems (with different case sensitivity), and QFSFileEngine doesn't allow to return different values depending on the file path, so we still say that the file system is case-sensitive, which is the safiest behavior. This changes the behavior on Mac, but changes it to be correct. Reviewed-by: Markus Goetz Reviewed-by: João Abecasis --- src/corelib/io/qfsfileengine.cpp | 12 +++++++++--- tests/auto/qfileinfo/tst_qfileinfo.cpp | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 37b0ea1..f874052 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -143,9 +143,15 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) if (path.size() == 1 && path.at(0) == QLatin1Char('/')) return path; #endif - // Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here. -#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) || defined(Q_OS_SYMBIAN) - char *ret = realpath(path.toLocal8Bit().constData(), (char*)0); +#if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN) || defined(Q_OS_MAC) + char *ret = 0; +#if defined(Q_OS_MAC) + // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) + ret = realpath(path.toLocal8Bit().constData(), (char*)0); +#else + ret = realpath(path.toLocal8Bit().constData(), (char*)0); +#endif if (ret) { QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); free(ret); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index cd58fd6..b49395f 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -826,6 +826,17 @@ void tst_QFileInfo::compare_data() QTest::addColumn("file2"); QTest::addColumn("same"); +#if defined(Q_OS_MAC) + // Since 10.6 we use realpath() in qfsfileengine, and it properly handles + // file system case sensitivity. However here in the autotest we don't + // check if the file system is case sensitive, so to make it pass in the + // default OS X installation we assume we are running on a case insensitive + // file system if on 10.6 and on a case sensitive file system if on 10.5 + bool caseSensitiveOnMac = true; + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) + caseSensitiveOnMac = false; +#endif + QTest::newRow("data0") << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") @@ -843,6 +854,8 @@ void tst_QFileInfo::compare_data() << QString::fromLatin1(SRCDIR "tst_qfileinfo.cpp") #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) << true; +#elif defined(Q_OS_MAC) + << !caseSensitiveOnMac; #else << false; #endif @@ -854,7 +867,7 @@ void tst_QFileInfo::compare() QFETCH(QString, file2); QFETCH(bool, same); QFileInfo fi1(file1), fi2(file2); - QCOMPARE(same, fi1 == fi2); + QCOMPARE(fi1 == fi2, same); } void tst_QFileInfo::consistent_data() -- cgit v0.12 From 4184664b3886ff03acc193b3302229e76fae3ad9 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 9 Dec 2009 10:43:14 +0100 Subject: Implemented getting a canonical file name on Mac OS X 10.5 Using FSRef to get a canonical file path on OS X 10.5 which doesn't support realpath(X,0) extension. Reviewed-by: Prasanth --- src/corelib/io/qfsfileengine.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index f874052..b4611f1 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -56,6 +56,9 @@ #endif #include #include +#if defined(Q_OS_MAC) +# include +#endif QT_BEGIN_NAMESPACE @@ -147,8 +150,20 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) char *ret = 0; #if defined(Q_OS_MAC) // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { ret = realpath(path.toLocal8Bit().constData(), (char*)0); + } else { + // on 10.5 we can use FSRef to resolve the file path. + FSRef fsref; + if (FSPathMakeRef((const UInt8 *)QDir::cleanPath(path).toUtf8().data(), &fsref, 0) == noErr) { + CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); + CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); + QString ret = QCFString::toQString(canonicalPath); + CFRelease(canonicalPath); + CFRelease(urlref); + return ret; + } + } #else ret = realpath(path.toLocal8Bit().constData(), (char*)0); #endif -- cgit v0.12 From fc73e6e67b4048a7fa79d041ee609bea508aff07 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 8 Dec 2009 21:19:30 +0100 Subject: Re-enabled support for the FSEvents-based QFileSystemWatcher. Also fixed it to use canonicalFilePath instead of absoluteFilePath since when we get notification from the system, it gives us the canonical path with resolved symlinks (for example when watching for /tmp, the notification that we get says that /private/tmp was modified). Reviewed-by: Prasanth --- src/corelib/io/qfilesystemwatcher.cpp | 2 +- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index d9b994e..e9f413c 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -248,7 +248,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine() eng = QDnotifyFileSystemWatcherEngine::create(); return eng; #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) -# if 0 && (defined Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +# if defined(Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) return QFSEventsFileSystemWatcherEngine::create(); else diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index be2125a..bbf7f99 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -94,7 +94,7 @@ static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInf { PathInfoList &list = pathHash[key]; list.push_back(PathInfo(path, - fileInfo.absoluteFilePath().normalized(QString::NormalizationForm_D).toUtf8())); + fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_D).toUtf8())); pathHash.insert(key, list); } @@ -206,7 +206,7 @@ QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, } else { directories->append(path); // Full file path for dirs. - QCFString cfpath(createFSStreamPath(fileInfo.absoluteFilePath())); + QCFString cfpath(createFSStreamPath(fileInfo.canonicalFilePath())); addPathToHash(dirPathInfoHash, cfpath, fileInfo, path); CFArrayAppendValue(tmpArray, cfpath); } @@ -216,7 +216,7 @@ QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, continue; } else { // Just the absolute path (minus it's filename) for files. - QCFString cfpath(createFSStreamPath(fileInfo.absolutePath())); + QCFString cfpath(createFSStreamPath(fileInfo.canonicalPath())); files->append(path); addPathToHash(filePathInfoHash, cfpath, fileInfo, path); CFArrayAppendValue(tmpArray, cfpath); @@ -293,7 +293,7 @@ QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &pat itemCount = CFArrayGetCount(tmpArray); const QString &path = paths.at(i); QFileInfo fi(path); - QCFString cfpath(createFSStreamPath(fi.absolutePath())); + QCFString cfpath(createFSStreamPath(fi.canonicalPath())); CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath); if (index != -1) { @@ -302,7 +302,7 @@ QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &pat removePathFromHash(filePathInfoHash, cfpath, path); } else { // Could be a directory we are watching instead. - QCFString cfdirpath(createFSStreamPath(fi.absoluteFilePath())); + QCFString cfdirpath(createFSStreamPath(fi.canonicalFilePath())); index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath); if (index != -1) { CFArrayRemoveValueAtIndex(tmpArray, index); -- cgit v0.12 From 445f8bbd9709b712fa253fe1833bbf9416429603 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 9 Dec 2009 15:30:10 +0100 Subject: Cocoa: scrolling viewports containing many widgets is slow One of the reasons is that [NSView resetCursorRects] is called for each view, also the ones not actually visible. And the function is slow. This patch does an early check, and bails out if this is the case. Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 1039a75..311cf24 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -227,6 +227,10 @@ extern "C" { - (void)resetCursorRects { + // [NSView addCursorRect] is slow, so bail out early if we can: + if (NSIsEmptyRect([self visibleRect])) + return; + QWidget *cursorWidget = qwidget; if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents)) -- cgit v0.12 From bc8e87016cfeb4a63151425bcd0f69f21a5fc1c1 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 9 Dec 2009 15:47:26 +0100 Subject: Assistant: Make doc file watching work for the intended use case. The QFileSystemWatcher signals the changing of a file several times, with the first one coming too early. As a result, we are likely checking a file that is not yet fully constructed. The workaround/solution is to delay reacting to the change until after the (hopefully) last signal from the QFileSystemWatcher. Reviewed-by: kh1 --- .../tools/assistant/helpenginewrapper.cpp | 53 +++++++++++++++++++++- .../assistant/tools/assistant/helpenginewrapper.h | 23 ++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 899954c..79a25ec 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -646,9 +647,28 @@ void HelpEngineWrapper::assertDocFilesWatched() == m_helpEngine->registeredDocumentations().count()); } +TimeoutForwarder::TimeoutForwarder(const QString &fileName) + : m_fileName(fileName) +{ + TRACE_OBJ +} + +void TimeoutForwarder::forward() +{ + TRACE_OBJ + HelpEngineWrapper::instance().qchFileChanged(m_fileName, true); +} + void HelpEngineWrapper::qchFileChanged(const QString &fileName) { TRACE_OBJ + qchFileChanged(fileName, false); +} + +void HelpEngineWrapper::qchFileChanged(const QString &fileName, bool fromTimeout) +{ + TRACE_OBJ + /* * We don't use QHelpEngineCore::namespaceName(fileName), because the file * may not exist anymore or contain a different namespace. @@ -665,9 +685,39 @@ void HelpEngineWrapper::qchFileChanged(const QString &fileName) * We can't do an assertion here, because QFileSystemWatcher may send the * signal more than once. */ - if (ns.isEmpty()) + if (ns.isEmpty()) { + m_recentQchUpdates.remove(fileName); + return; + } + + /* + * Since the QFileSystemWatcher typically sends the signal more than once, + * we repeatedly delay our reaction a bit until we think the last signal + * was sent. + */ + + QMap::Iterator it = m_recentQchUpdates.find(fileName); + const QDateTime &now = QDateTime::currentDateTime(); + + // Case 1: This is the first recent signal for the file. + if (it == m_recentQchUpdates.end()) { + QSharedPointer forwarder(new TimeoutForwarder(fileName)); + m_recentQchUpdates.insert(fileName, RecentSignal(now, forwarder)); + QTimer::singleShot(UpdateGracePeriod, forwarder.data(), SLOT(forward())); + return; + } + + // Case 2: The last signal for this file has not expired yet. + if (it.value().first > now.addMSecs(-UpdateGracePeriod)) { + if (!fromTimeout) + it.value().first = now; + else + QTimer::singleShot(UpdateGracePeriod, it.value().second.data(), + SLOT(forward())); return; + } + // Case 3: The last signal for this file has expired. if (m_helpEngine->unregisterDocumentation(ns)) { if (!QFileInfo(fileName).exists() || !m_helpEngine->registerDocumentation(fileName)) { @@ -678,6 +728,7 @@ void HelpEngineWrapper::qchFileChanged(const QString &fileName) } m_helpEngine->setupData(); } + m_recentQchUpdates.erase(it); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index f827d95..348479e 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -42,8 +42,11 @@ #ifndef HELPENGINEWRAPPER_H #define HELPENGINEWRAPPER_H +#include #include #include +#include +#include #include #include #include @@ -67,6 +70,20 @@ enum { ShowLastPages = 2 }; + +class TimeoutForwarder : public QObject +{ + Q_OBJECT +public: + TimeoutForwarder(const QString &fileName); +private slots: + void forward(); +private: + friend class HelpEngineWrapper; + + const QString m_fileName; +}; + class HelpEngineWrapper : public QObject { Q_OBJECT @@ -197,13 +214,19 @@ private slots: void qchFileChanged(const QString &fileName); private: + friend class TimeoutForwarder; + HelpEngineWrapper(const QString &collectionFile); void initFileSystemWatchers(); void assertDocFilesWatched(); + void qchFileChanged(const QString &fileName, bool fromTimeout); + static const int UpdateGracePeriod = 2000; static HelpEngineWrapper *helpEngineWrapper; QHelpEngine * const m_helpEngine; QFileSystemWatcher * const m_qchWatcher; + typedef QPair > RecentSignal; + QMap m_recentQchUpdates; }; QT_END_NAMESPACE -- cgit v0.12 From 9215506e6a057d8aef7415c2921214e1ba1c760d Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 10 Dec 2009 09:15:34 +0100 Subject: Prevent posted event starvation by native Windows messages Avoid live-lock if native messages are generated quickly enough by allowing posted events to be sent if more than 10ms has passed since we last sent them. This means that we can allow multiple calls to sendPostedEvents() during a single call to processEvents(), but only when the QEventLoop::EventLoopExec flag is passed to processEvents(). Task-number: QTBUG-1697 --- src/corelib/kernel/qeventdispatcher_win.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index c6eef5e..105cf28 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -341,6 +341,7 @@ public: // for controlling when to send posted events QAtomicInt serialNumber; int lastSerialNumber; + int lastMessageTime; QAtomicInt wakeUps; // timers @@ -364,7 +365,8 @@ public: }; QEventDispatcherWin32Private::QEventDispatcherWin32Private() - : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0), serialNumber(0), lastSerialNumber(0), wakeUps(0) + : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0), + serialNumber(0), lastSerialNumber(0), lastMessageTime(0), wakeUps(0) { resolveTimerAPI(); } @@ -479,6 +481,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) int localSerialNumber = d->serialNumber; if (localSerialNumber != d->lastSerialNumber) { d->lastSerialNumber = localSerialNumber; + d->lastMessageTime = GetMessageTime(); QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); } return 0; @@ -495,9 +498,10 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) if (q) { QEventDispatcherWin32Private *d = q->d_func(); int localSerialNumber = d->serialNumber; - if (HIWORD(GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER)) == 0) { - // no more input or timer events in the message queue, we can allow posted events to be - // sent now + if (HIWORD(GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER)) == 0 + || GetMessageTime() - d->lastMessageTime >= 10) { + // no more input or timer events in the message queue or more than 10ms has elapsed since + // we send posted events, we can allow posted events to be sent now (void) d->wakeUps.fetchAndStoreRelease(0); MSG *msg = (MSG *) lp; if (localSerialNumber != d->lastSerialNumber @@ -732,7 +736,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } if (haveMessage) { if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) { - if (seenWM_QT_SENDPOSTEDEVENTS) { + if (seenWM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { + // when calling processEvents() "manually", we only want to send posted + // events once needWM_QT_SENDPOSTEDEVENTS = true; continue; } -- cgit v0.12 From d7159b1aa1c24cc320a3ba013c9d0f3cf97b6684 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 10 Dec 2009 11:32:33 +0100 Subject: Mac: add support for public.vcard UTI (DnD) Added a QMacPasteboard converter for data dragged from the address book on Mac. It is an easy piece of code, and will make it easier for Mac people to work with standard Mac apps. --- src/gui/kernel/qmime_mac.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index 4d842df..c68cdde 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -154,6 +154,7 @@ CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker"); \i public.url - converts to "text/uri-list" \i public.file-url - converts to "text/uri-list" \i public.tiff - converts to "application/x-qt-image" + \i public.vcard - converts to "text/plain" \i com.apple.traditional-mac-plain-text - converts to "text/plain" \i com.apple.pict - converts to "application/x-qt-image" \endlist @@ -909,6 +910,61 @@ QList QMacPasteboardMimeUrl::convertFromMime(const QString &mime, QV return ret; } +class QMacPasteboardMimeVCard : public QMacPasteboardMime +{ +public: + QMacPasteboardMimeVCard() : QMacPasteboardMime(MIME_ALL){ } + QString convertorName(); + + QString flavorFor(const QString &mime); + QString mimeFor(QString flav); + bool canConvert(const QString &mime, QString flav); + QVariant convertToMime(const QString &mime, QList data, QString flav); + QList convertFromMime(const QString &mime, QVariant data, QString flav); +}; + +QString QMacPasteboardMimeVCard::convertorName() +{ + return QString("VCard"); +} + +bool QMacPasteboardMimeVCard::canConvert(const QString &mime, QString flav) +{ + return mimeFor(flav) == mime; +} + +QString QMacPasteboardMimeVCard::flavorFor(const QString &mime) +{ + if(mime.startsWith(QLatin1String("text/plain"))) + return QLatin1String("public.vcard"); + return QString(); +} + +QString QMacPasteboardMimeVCard::mimeFor(QString flav) +{ + if (flav == QLatin1String("public.vcard")) + return QLatin1String("text/plain"); + return QString(); +} + +QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime, QList data, QString) +{ + QByteArray cards; + if (mime == QLatin1String("text/plain")) { + for (int i=0; i QMacPasteboardMimeVCard::convertFromMime(const QString &mime, QVariant data, QString) +{ + QList ret; + if (mime == QLatin1String("text/plain")) + ret.append(data.toString().toUtf8()); + return ret; +} + #ifdef QT3_SUPPORT class QMacPasteboardMimeQt3Any : public QMacPasteboardMime { private: @@ -1116,6 +1172,7 @@ void QMacPasteboardMime::initialize() new QMacPasteboardMimeFileUri; new QMacPasteboardMimeUrl; new QMacPasteboardMimeTypeName; + new QMacPasteboardMimeVCard; //make sure our "non-standard" types are always last! --Sam new QMacPasteboardMimeAny; #ifdef QT3_SUPPORT -- cgit v0.12 From 4a982617bf6de92df118ecac024f415770a7bbb6 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 10 Dec 2009 15:20:35 +0100 Subject: Assistant: Added rebuild-search-index command line option. Reviewed-by: kh1 --- tools/assistant/tools/assistant/cmdlineparser.cpp | 10 ++++++++ tools/assistant/tools/assistant/cmdlineparser.h | 2 ++ tools/assistant/tools/assistant/main.cpp | 31 ++++++++++++++++++++--- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp index 733e2ff..a93d63f 100644 --- a/tools/assistant/tools/assistant/cmdlineparser.cpp +++ b/tools/assistant/tools/assistant/cmdlineparser.cpp @@ -72,6 +72,7 @@ const QString CmdLineParser::m_helpMessage = QLatin1String( " file.\n" "-setCurrentFilter filter Set the filter as the active filter.\n" "-remove-search-index Removes the full text search index.\n" + "-rebuild-search-index Re-builds the full text search index (potentially slow)\n." "-quiet Does not display any error or\n" " status message.\n" "-help Displays this help.\n" @@ -87,6 +88,7 @@ CmdLineParser::CmdLineParser(const QStringList &arguments) m_search(Untouched), m_register(None), m_removeSearchIndex(false), + m_rebuildSearchIndex(false), m_quiet(false) { TRACE_OBJ @@ -126,6 +128,8 @@ CmdLineParser::Result CmdLineParser::parse() handleSetCurrentFilterOption(); else if (arg == QLatin1String("-remove-search-index")) m_removeSearchIndex = true; + else if (arg == QLatin1String("-rebuild-search-index")) + m_rebuildSearchIndex = true; else if (arg == QLatin1String("-help")) showHelp = true; else @@ -343,6 +347,12 @@ bool CmdLineParser::removeSearchIndex() const return m_removeSearchIndex; } +bool CmdLineParser::rebuildSearchIndex() const +{ + TRACE_OBJ + return m_rebuildSearchIndex; +} + CmdLineParser::RegisterState CmdLineParser::registerRequest() const { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h index c1621d6..2bc7f2a 100644 --- a/tools/assistant/tools/assistant/cmdlineparser.h +++ b/tools/assistant/tools/assistant/cmdlineparser.h @@ -70,6 +70,7 @@ public: ShowState search() const; QString currentFilter() const; bool removeSearchIndex() const; + bool rebuildSearchIndex() const; RegisterState registerRequest() const; QString helpFile() const; @@ -106,6 +107,7 @@ private: RegisterState m_register; QString m_currentFilter; bool m_removeSearchIndex; + bool m_rebuildSearchIndex; bool m_quiet; QString m_error; }; diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 79ed2c8..ce85854 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -52,7 +52,8 @@ #include #include -#include +#include +#include #include @@ -205,6 +206,23 @@ bool removeSearchIndex(const QString &collectionFile) return true; } +bool rebuildSearchIndex(QCoreApplication &app, const QString &collectionFile, + CmdLineParser &cmd) +{ + TRACE_OBJ + QHelpEngine engine(collectionFile); + if (!engine.setupData()) { + cmd.showMessage(QObject::tr("Error: %1").arg(engine.error()), true); + return false; + } + + QHelpSearchEngine * const searchEngine = engine.searchEngine(); + QObject::connect(searchEngine, SIGNAL(indexingFinished()), &app, + SLOT(quit())); + searchEngine->reindexDocumentation(); + return app.exec() == 0; +} + bool checkForSqlite(CmdLineParser &cmd) { TRACE_OBJ @@ -225,7 +243,8 @@ bool useGui(int argc, char *argv[]) #ifndef Q_OS_WIN // Look for arguments that imply command-line mode. const char * cmdModeArgs[] = { - "-help", "-register", "-unregister", "-remove-search-index" + "-help", "-register", "-unregister", "-remove-search-index", + "-rebuild-search-index" }; for (int i = 1; i < argc; ++i) { for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) { @@ -376,7 +395,13 @@ int main(int argc, char *argv[]) } if (cmd.removeSearchIndex()) { - return removeSearchIndex(cachedCollectionFile) ? EXIT_SUCCESS : EXIT_FAILURE; + return removeSearchIndex(cachedCollectionFile) + ? EXIT_SUCCESS : EXIT_FAILURE; + } + + if (cmd.rebuildSearchIndex()) { + return rebuildSearchIndex(a, cachedCollectionFile, cmd) + ? EXIT_SUCCESS : EXIT_FAILURE; } if (!checkForSqlite(cmd)) -- cgit v0.12 From 46e080ba1b0b7fdb67eda60002991f6b20e0f0ab Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 Dec 2009 12:58:06 +0100 Subject: fix (internal) apidoc --- src/corelib/tools/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 33c45c4..98d88ac 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1092,7 +1092,7 @@ QString::QString(QChar ch) \internal */ -/*! \fn void QString::isDetached() const +/*! \fn bool QString::isDetached() const \internal */ -- cgit v0.12 From b6352d487491e4d25db8a008de75280a666b0fce Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 Dec 2009 15:38:17 +0100 Subject: add {QString,QByteArray,QList,QLinkedList,QHash,QMap,QVector}::isSharedWith() these functions just compare the d pointers of two objects. this can be used to verify the validity of cached data: you keep a copy of the original data in your cache. consequently, any changes to the original data must detach, so this function reflects whether the cached data is still up-to-date. of course, this is not thread safe, as the data might change right after you check it, but that's a general problem of cache coherency which needs to be handled further up the stack. the functions are internal because the other detaching-related functions are internal as well for reasons beyond me. Reviewed-by: brad --- src/corelib/tools/qbytearray.cpp | 5 +++++ src/corelib/tools/qbytearray.h | 1 + src/corelib/tools/qhash.cpp | 5 +++++ src/corelib/tools/qhash.h | 1 + src/corelib/tools/qlinkedlist.cpp | 5 +++++ src/corelib/tools/qlinkedlist.h | 1 + src/corelib/tools/qlist.cpp | 5 +++++ src/corelib/tools/qlist.h | 1 + src/corelib/tools/qmap.cpp | 5 +++++ src/corelib/tools/qmap.h | 1 + src/corelib/tools/qstring.cpp | 5 +++++ src/corelib/tools/qstring.h | 1 + src/corelib/tools/qvector.cpp | 5 +++++ src/corelib/tools/qvector.h | 1 + 14 files changed, 42 insertions(+) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index bf9b6bd..e43c2b5 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1048,6 +1048,11 @@ QByteArray &QByteArray::operator=(const char *str) \internal */ +/*! \fn bool QByteArray::isSharedWith(const QByteArray &other) + + \internal +*/ + /*! \fn char QByteArray::at(int i) const Returns the character at index position \a i in the byte array. diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 7dd6f4f..ba344cb 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -164,6 +164,7 @@ public: inline const char *constData() const; inline void detach(); bool isDetached() const; + inline bool isSharedWith(const QByteArray &other) const { return d == other.d; } void clear(); #ifdef Q_COMPILER_MANGLES_RETURN_TYPE diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index c82c389..a616ac2 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -847,6 +847,11 @@ void QHashData::checkSanity() \internal */ +/*! \fn bool QHash::isSharedWith(const QHash &other) const + + \internal +*/ + /*! \fn void QHash::clear() Removes all items from the hash. diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 2de03dc..66e9cde 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -299,6 +299,7 @@ public: inline void detach() { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QHash &other) const { return d == other.d; } void clear(); diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index 281508e..987e538 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -197,6 +197,11 @@ QLinkedListData QLinkedListData::shared_null = { \internal */ +/*! \fn bool QLinkedList::isSharedWith(const QLinkedList &other) const + + \internal +*/ + /*! \fn bool QLinkedList::isEmpty() const Returns true if the list contains no items; otherwise returns diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index e119a50..395adf2 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -93,6 +93,7 @@ public: { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QLinkedList &other) const { return d == other.d; } inline bool isEmpty() const { return d->size == 0; } diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 9b20c82..da93d5f 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -599,6 +599,11 @@ void **QListData::erase(void **xi) \internal */ +/*! \fn bool QList::isSharedWith(const QList &other) const + + \internal +*/ + /*! \fn bool QList::isEmpty() const Returns true if the list contains no items; otherwise returns diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 49b5c0d..e65ee15 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -130,6 +130,7 @@ public: inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QList &other) const { return d == other.d; } inline bool isEmpty() const { return p.isEmpty(); } diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 3b48c3f..432b5a5 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -473,6 +473,11 @@ void QMapData::dump() \internal */ +/*! \fn bool QMap::isSharedWith(const QMap &other) const + + \internal +*/ + /*! \fn void QMap::setInsertInOrder(bool sharable) \internal diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 0441107..ce97178 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -182,6 +182,7 @@ public: inline void detach() { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QMap &other) const { return d == other.d; } inline void setInsertInOrder(bool ordered) { d->insertInOrder = ordered; } void clear(); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 98d88ac..f3355df 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1097,6 +1097,11 @@ QString::QString(QChar ch) \internal */ +/*! \fn bool QString::isSharedWith(const QString &other) const + + \internal +*/ + // ### Qt 5: rename freeData() to avoid confusion. See task 197625. void QString::free(Data *d) { diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 668be35..c6fd80a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -122,6 +122,7 @@ public: inline void detach(); inline bool isDetached() const; + inline bool isSharedWith(const QString &other) const { return d == other.d; } void clear(); inline const QChar at(int i) const; diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 8bb1074..00d663b 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -392,6 +392,11 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive \internal */ +/*! \fn bool QVector::isSharedWith(const QVector &other) const + + \internal +*/ + /*! \fn T *QVector::data() Returns a pointer to the data stored in the vector. The pointer diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index e00cf3f..043617f 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -134,6 +134,7 @@ public: inline void detach() { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QVector &other) const { return d == other.d; } inline T *data() { detach(); return p->array; } inline const T *data() const { return p->array; } -- cgit v0.12 From d99a9ffed96ac26ddada3eeb61c44e6ff8b93895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 11 Dec 2009 10:32:37 +0100 Subject: Avoid crash in QObject::connect() if class has no signals If signalCount was 0, then indexOfSlotRelative would use -1 as the lookup and read unitialized memory in the loop. This would cause a crash in release on Windows. Done-with: Olivier --- src/corelib/kernel/qmetaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index bc1e8dcc..a29f4d2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -497,7 +497,7 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) - ? (priv(m->d.data)->signalCount - 1) : 0; + ? (priv(m->d.data)->signalCount) : 0; if (!normalizeStringData) { for (; i >= end; --i) { if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) -- cgit v0.12 From 9364907eb92a51d054b54fe543c62df3bd203deb Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 11:03:26 +0100 Subject: Compile on Windows CE. GetMessageTime() is not available, so 9215506e6a057d8aef7415c2921214e1ba1c760d is not possible on Windows CE --- src/corelib/kernel/qeventdispatcher_win.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 105cf28..b98d08e 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -341,7 +341,9 @@ public: // for controlling when to send posted events QAtomicInt serialNumber; int lastSerialNumber; +#ifndef Q_OS_WINCE int lastMessageTime; +#endif QAtomicInt wakeUps; // timers @@ -366,7 +368,11 @@ public: QEventDispatcherWin32Private::QEventDispatcherWin32Private() : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0), - serialNumber(0), lastSerialNumber(0), lastMessageTime(0), wakeUps(0) + serialNumber(0), lastSerialNumber(0), +#ifndef Q_OS_WINCE + lastMessageTime(0), +#endif + wakeUps(0) { resolveTimerAPI(); } @@ -481,7 +487,9 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) int localSerialNumber = d->serialNumber; if (localSerialNumber != d->lastSerialNumber) { d->lastSerialNumber = localSerialNumber; +#ifndef Q_OS_WINCE d->lastMessageTime = GetMessageTime(); +#endif QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); } return 0; @@ -499,7 +507,10 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) QEventDispatcherWin32Private *d = q->d_func(); int localSerialNumber = d->serialNumber; if (HIWORD(GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER)) == 0 - || GetMessageTime() - d->lastMessageTime >= 10) { +#ifndef Q_OS_WINCE + || GetMessageTime() - d->lastMessageTime >= 10 +#endif + ) { // no more input or timer events in the message queue or more than 10ms has elapsed since // we send posted events, we can allow posted events to be sent now (void) d->wakeUps.fetchAndStoreRelease(0); -- cgit v0.12 From 38181f227d3c35a543b1df5b5440ae3bac3b6513 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 12:01:06 +0100 Subject: Make sure posted events are always sent. Commit 9215506e6a057d8aef7415c2921214e1ba1c760d introduced one small delta that would cause a certain example to stop working. This example called update() from a paintEvent(), which now works again. --- src/corelib/kernel/qeventdispatcher_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index b98d08e..115049f 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -747,7 +747,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } if (haveMessage) { if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) { - if (seenWM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { + if (seenWM_QT_SENDPOSTEDEVENTS) { // when calling processEvents() "manually", we only want to send posted // events once needWM_QT_SENDPOSTEDEVENTS = true; -- cgit v0.12 From f2321e217976042403adfb74bffa7dceffa6febd Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 15:18:37 +0100 Subject: Don't react to X errors on displays that are not the Qt display. Even though Qt doesn't support multiple displays, it is possible for people to have code that uses multiple displays (either by using Xlib directly or when integrating with another toolkit). Task-number: QTBUG-3337 --- src/gui/kernel/qapplication_x11.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index b71ae73..eb35c10 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -614,6 +614,11 @@ static int (*original_xio_errhandler)(Display *dpy); static int qt_x_errhandler(Display *dpy, XErrorEvent *err) { + if (X11->display != dpy) { + // only handle X errors for our display + return 0; + } + switch (err->error_code) { case BadAtom: if (err->request_code == 20 /* X_GetProperty */ -- cgit v0.12 From 1908e12284e1f6f25bfb46df3ce9659c6e19a50c Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 15:37:38 +0100 Subject: QGuiEventDispatcherGlib::flush() does nothing despite documentation otherwise. The documentation for flush() is that it flushes the outgoing command queue on X11, but not when using Glib. Fix this by implementing flush() in the GUI Glib dispatcher. Task-number: QTBUG-3185 --- src/gui/kernel/qguieventdispatcher_glib.cpp | 5 +++++ src/gui/kernel/qguieventdispatcher_glib_p.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/gui/kernel/qguieventdispatcher_glib.cpp b/src/gui/kernel/qguieventdispatcher_glib.cpp index f8a638c..fc6bc54 100644 --- a/src/gui/kernel/qguieventdispatcher_glib.cpp +++ b/src/gui/kernel/qguieventdispatcher_glib.cpp @@ -214,4 +214,9 @@ void QGuiEventDispatcherGlib::startingUp() g_source_add_poll(&d->x11EventSource->source, &d->x11EventSource->pollfd); } +void QGuiEventDispatcherGlib::flush() +{ + XFlush(X11->display); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qguieventdispatcher_glib_p.h b/src/gui/kernel/qguieventdispatcher_glib_p.h index 4574df9..32fcbd3 100644 --- a/src/gui/kernel/qguieventdispatcher_glib_p.h +++ b/src/gui/kernel/qguieventdispatcher_glib_p.h @@ -71,6 +71,7 @@ public: bool processEvents(QEventLoop::ProcessEventsFlags flags); void startingUp(); + void flush(); }; QT_END_NAMESPACE -- cgit v0.12 From 454e87a57b6876b8db2180236082d7c7bc408a0e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 16:13:00 +0100 Subject: Fix normalization of Type * const After commit b881d8fb99972f1bd04ab4c84843cc8d43ddbeed, we would no longer append "const" when seeing it after a *. This commit fixes the regression. Reviewed-by: ogoffart --- src/corelib/kernel/qmetaobject_p.h | 3 +++ tests/auto/qmetaobject/tst_qmetaobject.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index 7afb70b..83ca9af 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -295,6 +295,9 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc } else if (!star) { // move const to the front (but not if const comes after a *) result.prepend("const "); + } else { + // keep const after a * + result += "const"; } } } diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index 8331ca1..fb62312 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -664,7 +664,7 @@ void tst_QMetaObject::normalizedSignature_data() QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()"; QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()"; QTest::newRow("reference") << "QString &foo()" << "QString&foo()"; - QTest::newRow("const2") << "void foo(QString const *)" << "void foo(const QString*)"; + QTest::newRow("const1") << "void foo(QString const *)" << "void foo(const QString*)"; QTest::newRow("const2") << "void foo(QString * const)" << "void foo(QString*const)"; QTest::newRow("const3") << "void foo(QString const &)" << "void foo(QString)"; QTest::newRow("const4") << "void foo(const int)" << "void foo(int)"; @@ -672,7 +672,7 @@ void tst_QMetaObject::normalizedSignature_data() << "void foo(int,int,int,int)"; QTest::newRow("const6") << "void foo(QList)" << "void foo(QList)"; QTest::newRow("const7") << "void foo(QList)" << "void foo(QList)"; - QTest::newRow("const7") << "void foo(QList)" << "void foo(QList)"; + QTest::newRow("const8") << "void foo(QList)" << "void foo(QList)"; } void tst_QMetaObject::normalizedSignature() -- cgit v0.12 From bff37a821728615d5b1c766d1fbcb80bdccfb9fd Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 14 Dec 2009 16:51:39 +0100 Subject: Assistant: Performance improvements in qhelpgenerator. - Get rid of double container lookups for conditional access. - count() == 0 => isEmpty(). Reviewed-by: kh1 --- tools/assistant/lib/qhelpgenerator.cpp | 27 +++++++++++++++------------ tools/assistant/lib/qhelpgenerator_p.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp index 1bb4cc8..8f1b780 100644 --- a/tools/assistant/lib/qhelpgenerator.cpp +++ b/tools/assistant/lib/qhelpgenerator.cpp @@ -538,7 +538,8 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa } int fileId = -1; - if (!d->fileMap.contains(fileName)) { + QMap::Iterator fileMapIt = d->fileMap.find(fileName); + if (fileMapIt == d->fileMap.end()) { fileDataList.append(qCompress(data)); fileNameData.name = fileName; @@ -552,18 +553,20 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa ++tableFileId; } else { - fileId = d->fileMap.value(fileName); + fileId = fileMapIt.value(); + QSet &fileFilterSet = d->fileFilterMap[fileId]; + QSet &tmpFileFilterSet = tmpFileFilterMap[fileId]; foreach (const int &filter, filterAtts) { - if (!d->fileFilterMap.value(fileId).contains(filter) - && !tmpFileFilterMap.value(fileId).contains(filter)) { - d->fileFilterMap[fileId].insert(filter); - tmpFileFilterMap[fileId].insert(filter); + if (!fileFilterSet.contains(filter) + && !tmpFileFilterSet.contains(filter)) { + fileFilterSet.insert(filter); + tmpFileFilterSet.insert(filter); } } } } - if (tmpFileFilterMap.count()) { + if (!tmpFileFilterMap.isEmpty()) { d->query->exec(QLatin1String("BEGIN")); QMap >::const_iterator it = tmpFileFilterMap.constBegin(); while (it != tmpFileFilterMap.constEnd()) { @@ -626,8 +629,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName, while (d->query->next()) { attributeMap.insert(d->query->value(1).toString(), d->query->value(0).toInt()); - if (idsToInsert.contains(d->query->value(1).toString())) - idsToInsert.removeAll(d->query->value(1).toString()); + idsToInsert.removeAll(d->query->value(1).toString()); } foreach (QString id, idsToInsert) { @@ -675,7 +677,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName, return true; } -bool QHelpGenerator::insertKeywords(const QList keywords, +bool QHelpGenerator::insertKeywords(const QList &keywords, const QStringList &filterAttributes) { if (!d->query) @@ -717,8 +719,9 @@ bool QHelpGenerator::insertKeywords(const QList keywords, if (fName.startsWith(QLatin1String("./"))) fName = fName.mid(2); - if (d->fileMap.contains(fName)) - fileId = d->fileMap.value(fName); + QMap::ConstIterator it = d->fileMap.find(fName); + if (it != d->fileMap.end()) + fileId = it.value(); else fileId = 1; diff --git a/tools/assistant/lib/qhelpgenerator_p.h b/tools/assistant/lib/qhelpgenerator_p.h index 77189b0..de991e7 100644 --- a/tools/assistant/lib/qhelpgenerator_p.h +++ b/tools/assistant/lib/qhelpgenerator_p.h @@ -97,7 +97,7 @@ private: const QStringList &filterAttribs, bool forceUpdate = false); bool registerVirtualFolder(const QString &folderName, const QString &ns); bool insertFilterAttributes(const QStringList &attributes); - bool insertKeywords(const QList keywords, + bool insertKeywords(const QList &keywords, const QStringList &filterAttributes); bool insertFiles(const QStringList &files, const QString &rootPath, const QStringList &filterAttributes); -- cgit v0.12 From 764c4a456526ea07ce6c264139457f0e62968731 Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 14 Dec 2009 17:13:23 +0100 Subject: QPlainTextEdit scrolling issue with folded paragraphs With Qt Creator, we could reproduce scrolling problems when paragraphs were folded away. Effectively the first "visible" block could be an invisible one, resulting in firstVisibleBlock() returning something bogus. The result were drawing errors. Reviewed-by: con --- src/gui/widgets/qplaintextedit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index b637c19..be24012 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -684,8 +684,12 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC qreal h = center ? line.naturalTextRect().center().y() : line.naturalTextRect().bottom(); + QTextBlock previousVisibleBlock = block; while (h < height && block.previous().isValid()) { - block = block.previous(); + previousVisibleBlock = block; + do { + block = block.previous(); + } while (!block.isVisible() && block.previous().isValid()); h += q->blockBoundingRect(block).height(); } @@ -699,8 +703,8 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC ++l; } - if (block.next().isValid() && l >= lineCount) { - block = block.next(); + if (l >= lineCount) { + block = previousVisibleBlock; l = 0; } setTopBlock(block.blockNumber(), l); -- cgit v0.12 From 91f03a835150984fb4a2accf1246327e3d82e1fe Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 14 Dec 2009 17:55:53 +0100 Subject: qhelpgenerator: Don't insert identical indices. Reviewed-by: kh1 --- tools/assistant/lib/qhelpgenerator.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp index 8f1b780..3adf7ac 100644 --- a/tools/assistant/lib/qhelpgenerator.cpp +++ b/tools/assistant/lib/qhelpgenerator.cpp @@ -707,7 +707,17 @@ bool QHelpGenerator::insertKeywords(const QList &keywords, int i = 0; d->query->exec(QLatin1String("BEGIN")); - foreach (QHelpDataIndexItem itm, keywords) { + QSet indices; + foreach (const QHelpDataIndexItem &itm, keywords) { + + /* + * Identical ids make no sense and just confuse the Assistant user, + * so we ignore all repetitions. + */ + if (indices.contains(itm.identifier)) + continue; + indices.insert(itm.identifier); + pos = itm.reference.indexOf(QLatin1Char('#')); fileName = itm.reference.left(pos); if (pos > -1) @@ -753,7 +763,7 @@ bool QHelpGenerator::insertKeywords(const QList &keywords, d->query->exec(QLatin1String("COMMIT")); d->query->exec(QLatin1String("SELECT COUNT(Id) FROM IndexTable")); - if (d->query->next() && d->query->value(0).toInt() >= keywords.count()) + if (d->query->next() && d->query->value(0).toInt() >= indices.count()) return true; return false; } -- cgit v0.12 From 2e0fb5914f5dcb58681ec4d5a2709e33fda80f37 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 14 Dec 2009 18:13:13 +0100 Subject: Assistant: Topic chooser links correctly to Urls with identical titles. --- tools/assistant/tools/assistant/topicchooser.cpp | 16 ++++++++-------- tools/assistant/tools/assistant/topicchooser.h | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/assistant/tools/assistant/topicchooser.cpp b/tools/assistant/tools/assistant/topicchooser.cpp index 803ea04..e860ce4 100644 --- a/tools/assistant/tools/assistant/topicchooser.cpp +++ b/tools/assistant/tools/assistant/topicchooser.cpp @@ -40,9 +40,6 @@ ****************************************************************************/ #include "tracer.h" -#include -#include - #include "topicchooser.h" QT_BEGIN_NAMESPACE @@ -55,10 +52,11 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword, ui.setupUi(this); ui.label->setText(tr("Choose a topic for %1:").arg(keyword)); - m_links = links; - QMap::const_iterator it = m_links.constBegin(); - for (; it != m_links.constEnd(); ++it) + QMap::const_iterator it = links.constBegin(); + for (; it != links.constEnd(); ++it) { ui.listWidget->addItem(it.key()); + m_links.append(it.value()); + } if (ui.listWidget->count() != 0) ui.listWidget->setCurrentRow(0); @@ -80,10 +78,12 @@ QUrl TopicChooser::link() const return QUrl(); QString title = item->text(); - if (title.isEmpty() || !m_links.contains(title)) + if (title.isEmpty()) return QUrl(); - return m_links.value(title); + const int row = ui.listWidget->row(item); + Q_ASSERT(row < m_links.count()); + return m_links.at(row); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/topicchooser.h b/tools/assistant/tools/assistant/topicchooser.h index 949c7da..d3ca96e 100644 --- a/tools/assistant/tools/assistant/topicchooser.h +++ b/tools/assistant/tools/assistant/topicchooser.h @@ -44,9 +44,10 @@ #include "ui_topicchooser.h" -#include -#include -#include +#include +#include +#include +#include #include @@ -64,7 +65,7 @@ public: private: Ui::TopicChooser ui; - QMap m_links; + QList m_links; }; QT_END_NAMESPACE -- cgit v0.12 From efa48b0a5dba8c8c93612e534d04b5b04629b75c Mon Sep 17 00:00:00 2001 From: jasplin Date: Tue, 15 Dec 2009 10:11:40 +0100 Subject: Added missing include file. --- src/network/access/qnetworkrequest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index c91c608..9a72b00 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -49,6 +49,7 @@ #include "QtCore/qdatetime.h" #include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 7cd3470c65cd17c4511d757daf1506932d77db13 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 15 Dec 2009 11:58:19 +0100 Subject: work on QStringList split/join benchmark --- tests/benchmarks/qstringlist/main.cpp | 67 ++++++++++++++++++---------- tests/benchmarks/qstringlist/qstringlist.pro | 2 + 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/tests/benchmarks/qstringlist/main.cpp b/tests/benchmarks/qstringlist/main.cpp index a2a1dd5..85bfb5f 100644 --- a/tests/benchmarks/qstringlist/main.cpp +++ b/tests/benchmarks/qstringlist/main.cpp @@ -54,17 +54,21 @@ private slots: void join() const; void join_data() const; - void split() const; + void split_qlist_qbytearray() const; + void split_qlist_qbytearray_data() const { return split_data(); } + void split_data() const; + void split_qlist_qstring() const; + void split_qlist_qstring_data() const { return split_data(); } - void split_std() const; - void split_std_data() const { return split_data(); } + void split_stdvector_stdstring() const; + void split_stdvector_stdstring_data() const { return split_data(); } - void split_stdw() const; - void split_stdw_data() const { return split_data(); } + void split_stdvector_stdwstring() const; + void split_stdvector_stdwstring_data() const { return split_data(); } - void split_ba() const; - void split_ba_data() const { return split_data(); } + void split_stdlist_stdstring() const; + void split_stdlist_stdstring_data() const { return split_data(); } private: static QStringList populateList(const int count, const QString &unit); @@ -125,27 +129,39 @@ void tst_QStringList::join_data() const << QString(); } -void tst_QStringList::split() const +void tst_QStringList::split_data() const +{ + QTest::addColumn("input"); + QString unit = QLatin1String("unit") + QString(100, QLatin1Char('s')); + //QTest::newRow("") << populateString(10, unit); + QTest::newRow("") << populateString(100, unit); + //QTest::newRow("") << populateString(100, unit); + //QTest::newRow("") << populateString(1000, unit); + //QTest::newRow("") << populateString(10000, unit); +} + +void tst_QStringList::split_qlist_qbytearray() const { QFETCH(QString, input); - const QChar splitChar = ':'; + const char splitChar = ':'; + QByteArray ba = input.toLatin1(); QBENCHMARK { - input.split(splitChar); + ba.split(splitChar); } } -void tst_QStringList::split_data() const +void tst_QStringList::split_qlist_qstring() const { - QTest::addColumn("input"); - QString unit = QLatin1String("unit"); - QTest::newRow("") << populateString(10, unit); - QTest::newRow("") << populateString(100, unit); - QTest::newRow("") << populateString(1000, unit); - QTest::newRow("") << populateString(10000, unit); + QFETCH(QString, input); + const QChar splitChar = ':'; + + QBENCHMARK { + input.split(splitChar); + } } -void tst_QStringList::split_std() const +void tst_QStringList::split_stdvector_stdstring() const { QFETCH(QString, input); const char split_char = ':'; @@ -161,7 +177,7 @@ void tst_QStringList::split_std() const } } -void tst_QStringList::split_stdw() const +void tst_QStringList::split_stdvector_stdwstring() const { QFETCH(QString, input); const wchar_t split_char = ':'; @@ -177,14 +193,19 @@ void tst_QStringList::split_stdw() const } } -void tst_QStringList::split_ba() const +void tst_QStringList::split_stdlist_stdstring() const { QFETCH(QString, input); - const char splitChar = ':'; - QByteArray ba = input.toLatin1(); + const char split_char = ':'; + std::string stdinput = input.toStdString(); QBENCHMARK { - ba.split(splitChar); + std::istringstream split(stdinput); + std::list token; + for (std::string each; + std::getline(split, each, split_char); + token.push_back(each)) + ; } } diff --git a/tests/benchmarks/qstringlist/qstringlist.pro b/tests/benchmarks/qstringlist/qstringlist.pro index f9ebd59..86c1508 100644 --- a/tests/benchmarks/qstringlist/qstringlist.pro +++ b/tests/benchmarks/qstringlist/qstringlist.pro @@ -1,4 +1,6 @@ load(qttest_p4) TARGET = tst_qstringlist +CONFIG -= debug +CONFIG += release QT -= gui SOURCES += main.cpp -- cgit v0.12 From ac41c7da1e7da954e48ebdcefb1de53ce2911e75 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 14 Dec 2009 15:54:44 +0100 Subject: Fixed QGL2PEXVertexArray to interpolate within the range [0, 1]. Because of numerical inaccuracy, the interpolation factor could exceed 1 by a small amount which would cause an assert failure. --- src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp b/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp index ee1a797..b731a9f 100644 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp +++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp @@ -145,7 +145,7 @@ void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseSc // threshold based on same algorithm as in qtriangulatingstroker.cpp int threshold = qMin(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6)); if (threshold < 3) threshold = 3; - qreal one_over_threshold_minus_1 = 1.f / (threshold - 1); + qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1); for (int t=0; t Date: Mon, 14 Dec 2009 16:33:09 +0100 Subject: Fixed integer overflow in QTriangulator. The result of a function returning qint64 was stored in an int. --- src/opengl/gl2paintengineex/qtriangulator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index 21d4b2e..6a1112b 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -1779,7 +1779,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); if (d == 0) { result.first = result.second = current; break; @@ -1793,7 +1793,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); Q_ASSERT(d >= 0); if (d == 0) { result.first = current; @@ -1807,7 +1807,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); Q_ASSERT(d <= 0); if (d == 0) { result.second = current; @@ -1828,7 +1828,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); if (d == 0) break; if (d < 0) { @@ -1849,7 +1849,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); Q_ASSERT(d >= 0); if (d == 0) { current = current->left; @@ -1863,7 +1863,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSimple while (current) { const QPodPoint &v1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &v2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); - int d = qPointDistanceFromLine(point, v1, v2); + qint64 d = qPointDistanceFromLine(point, v1, v2); Q_ASSERT(d <= 0); if (d == 0) { current = current->right; -- cgit v0.12 From c9a1070f71f18b051f574854c0cfd61f658d9b50 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 14 Dec 2009 16:36:36 +0100 Subject: Added missing OpenGL defines. --- src/opengl/qglextensions_p.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 62e216c..488e752 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -599,6 +599,20 @@ struct QGLExtensionFuncs #define GL_DECR_WRAP 0x8508 #endif +#ifndef GL_VERSION_1_5 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#endif + #ifndef GL_VERSION_2_0 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 -- cgit v0.12 From 3e9d2ca2c31626d5c9a4b16372928637c9d0610f Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 14 Dec 2009 16:46:44 +0100 Subject: Implemented caching of concave vector paths in the GL2 engine. Reviewed-by: Gunnar --- src/gui/painting/qpainterpath.cpp | 2 + .../gl2paintengineex/qpaintengineex_opengl2.cpp | 155 +++++++++++++++++---- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + 3 files changed, 132 insertions(+), 26 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 8133793..c760882 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1257,6 +1257,8 @@ Qt::FillRule QPainterPath::fillRule() const void QPainterPath::setFillRule(Qt::FillRule fillRule) { ensureData(); + if (d_func()->fillRule == fillRule) + return; detach(); d_func()->fillRule = fillRule; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fb9bcb4..8fa8171 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #include "qglgradientcache_p.h" #include "qglengineshadermanager_p.h" @@ -832,10 +833,13 @@ struct QGL2PEVectorPathCache { #ifdef QT_OPENGL_CACHE_AS_VBOS GLuint vbo; + GLuint ibo; #else float *vertices; + quint32 *indices; #endif int vertexCount; + int indexCount; GLenum primitiveType; qreal iscale; }; @@ -846,8 +850,11 @@ void qopengl2paintengine_cleanup_vectorpath(QPaintEngineEx *engine, void *data) #ifdef QT_OPENGL_CACHE_AS_VBOS QGL2PaintEngineExPrivate *d = QGL2PaintEngineExPrivate::getData((QGL2PaintEngineEx *) engine); d->unusedVBOSToClean << c->vbo; + if (c->ibo) + d->unusedIBOSToClean << c->ibo; #else qFree(c->vertices); + qFree(c->indices); #endif delete c; } @@ -863,6 +870,9 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) const QPointF* const points = reinterpret_cast(path.points()); + // ### Remove before release... + static bool do_vectorpath_cache = qgetenv("QT_OPENGL_NO_PATH_CACHE").isEmpty(); + // Check to see if there's any hints if (path.shape() == QVectorPath::RectangleHint) { QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); @@ -883,8 +893,10 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) #ifdef QT_OPENGL_CACHE_AS_VBOS glDeleteBuffers(1, &cache->vbo); cache->vbo = 0; + Q_ASSERT(cache->ibo == 0); #else qFree(cache->vertices); + Q_ASSERT(cache->indices == 0); #endif cache->vertexCount = 0; } @@ -892,6 +904,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } else { cache = new QGL2PEVectorPathCache; cache->vertexCount = 0; + cache->indexCount = 0; data = const_cast(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath); } @@ -908,9 +921,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glGenBuffers(1, &cache->vbo); glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW); + cache->ibo = 0; #else cache->vertices = (float *) qMalloc(floatSizeInBytes); memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); + cache->indices = 0; #endif } @@ -927,8 +942,6 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } else { // printf(" - Marking path as cachable...\n"); // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable - // ### Remove before release... - static bool do_vectorpath_cache = qgetenv("QT_OPENGL_NO_PATH_CACHE").isEmpty(); if (do_vectorpath_cache) path.makeCacheable(); vertexCoordinateArray.clear(); @@ -938,40 +951,126 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } } else { - // The path is too complicated & needs the stencil technique - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale, false); - fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); + QRectF bbox = path.controlPointRect(); + // If the path doesn't fit within these limits, it is possible that the triangulation will fail. + bool pathIsWithinLimits = (bbox.left() > -0x8000 * inverseScale) + && (bbox.right() < 0x8000 * inverseScale) + && (bbox.top() > -0x8000 * inverseScale) + && (bbox.bottom() < 0x8000 * inverseScale); - glStencilMask(0xff); - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); + if (path.isCacheable() && pathIsWithinLimits) { + QVectorPath::CacheEntry *data = path.lookupCacheData(q); + QGL2PEVectorPathCache *cache; + + if (data) { + cache = (QGL2PEVectorPathCache *) data->data; + // Check if scale factor is exceeded for curved paths and generate curves if so... + if (path.isCurved()) { + qreal scaleFactor = cache->iscale / inverseScale; + if (scaleFactor < 0.5 || scaleFactor > 2.0) { +#ifdef QT_OPENGL_CACHE_AS_VBOS + glDeleteBuffers(1, &cache->vbo); + glDeleteBuffers(1, &cache->ibo); + cache->vbo = cache->ibo = 0; +#else + qFree(cache->vertices); + qFree(cache->indices); +#endif + cache->vertexCount = 0; + cache->indexCount = 0; + } + } + } else { + cache = new QGL2PEVectorPathCache; + cache->vertexCount = 0; + cache->indexCount = 0; + data = const_cast(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath); + } + + // Flatten the path at the current scale factor and fill it into the cache struct. + if (!cache->vertexCount) { + QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); + cache->vertexCount = polys.vertices.size() / 2; + cache->indexCount = polys.indices.size(); + cache->primitiveType = GL_TRIANGLES; + cache->iscale = inverseScale; + +#ifdef QT_OPENGL_CACHE_AS_VBOS + glGenBuffers(1, &cache->vbo); + glGenBuffers(1, &cache->ibo); + glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint32) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW); + + QVarLengthArray vertices(polys.vertices.size()); + for (int i = 0; i < polys.vertices.size(); ++i) + vertices[i] = float(inverseScale * polys.vertices.at(i)); + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW); +#else + cache->vertices = (float *) qMalloc(sizeof(float) * polys.vertices.size()); + cache->indices = (quint32 *) qMalloc(sizeof(quint32) * polys.indices.size()); + memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size()); + for (int i = 0; i < polys.vertices.size(); ++i) + cache->vertices[i] = float(inverseScale * polys.vertices.at(i)); +#endif + } + + prepareForDraw(currentBrush->isOpaque()); + glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); +#ifdef QT_OPENGL_CACHE_AS_VBOS + glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, 0); + glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); +#else + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, cache->vertices); + glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, cache->indices); +#endif - if (q->state()->clipTestEnabled) { - // Pass when high bit is set, replace stencil value with current clip - glStencilFunc(GL_NOTEQUAL, q->state()->currentClip, GL_STENCIL_HIGH_BIT); - } else if (path.hasWindingFill()) { - // Pass when any bit is set, replace stencil value with 0 - glStencilFunc(GL_NOTEQUAL, 0, 0xff); } else { - // Pass when high bit is set, replace stencil value with 0 - glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); - } + // printf(" - Marking path as cachable...\n"); + // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable + if (do_vectorpath_cache) + path.makeCacheable(); - prepareForDraw(currentBrush->isOpaque()); + // The path is too complicated & needs the stencil technique + vertexCoordinateArray.clear(); + vertexCoordinateArray.addPath(path, inverseScale, false); - if (inRenderText) - prepareDepthRangeForRenderText(); + fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); - // Stencil the brush onto the dest buffer - composite(vertexCoordinateArray.boundingRect()); + glStencilMask(0xff); + glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - if (inRenderText) - restoreDepthRangeForRenderText(); + if (q->state()->clipTestEnabled) { + // Pass when high bit is set, replace stencil value with current clip + glStencilFunc(GL_NOTEQUAL, q->state()->currentClip, GL_STENCIL_HIGH_BIT); + } else if (path.hasWindingFill()) { + // Pass when any bit is set, replace stencil value with 0 + glStencilFunc(GL_NOTEQUAL, 0, 0xff); + } else { + // Pass when high bit is set, replace stencil value with 0 + glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); + } - glStencilMask(0); + prepareForDraw(currentBrush->isOpaque()); - updateClipScissorTest(); + if (inRenderText) + prepareDepthRangeForRenderText(); + + // Stencil the brush onto the dest buffer + composite(vertexCoordinateArray.boundingRect()); + + if (inRenderText) + restoreDepthRangeForRenderText(); + + glStencilMask(0); + + updateClipScissorTest(); + } } } @@ -1892,6 +1991,10 @@ bool QGL2PaintEngineEx::end() glDeleteBuffers(d->unusedVBOSToClean.size(), d->unusedVBOSToClean.constData()); d->unusedVBOSToClean.clear(); } + if (!d->unusedIBOSToClean.isEmpty()) { + glDeleteBuffers(d->unusedIBOSToClean.size(), d->unusedIBOSToClean.constData()); + d->unusedIBOSToClean.clear(); + } #endif return false; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 0084476..844d42b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -298,6 +298,7 @@ public: QSet pathCaches; QVector unusedVBOSToClean; + QVector unusedIBOSToClean; }; QT_END_NAMESPACE -- cgit v0.12 From da89e73abcc8f4a1d19163fd6d39bb86e1ff0b53 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 7 Aug 2009 15:26:06 +0200 Subject: qdbus: short forms to get/set properties Allow a property to be given as third parameter instead of a method. If no other parameter is given, the property value is returned; if a fourth parameter is given, the property is set to the given value. This allows the syntax qdbus service path property as a short form of qdbus service path org.freedesktop.DBus.Properties.Get property and the syntax qdbus service path property value as a short form of qdbus service path org.freedesktop.DBus.Properties.Set property value If the third parameter is neither a method nor a property, the error message for the missing method is returned. Merge-Request: 1143 Reviewed-By: Thiago Macieira --- tools/qdbus/qdbus/qdbus.cpp | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp index 2441240..e126abf 100644 --- a/tools/qdbus/qdbus/qdbus.cpp +++ b/tools/qdbus/qdbus/qdbus.cpp @@ -248,8 +248,8 @@ static QStringList readList(QStringList &args) return retval; } -static void placeCall(const QString &service, const QString &path, const QString &interface, - const QString &member, QStringList args) +static int placeCall(const QString &service, const QString &path, const QString &interface, + const QString &member, QStringList args, bool try_prop=true) { QDBusInterface iface(service, path, interface, connection); @@ -273,10 +273,22 @@ static void placeCall(const QString &service, const QString &path, const QString } if (midx == -1) { + // Failed to set property after falling back? + // Bail out without displaying an error + if (!try_prop) + return 1; + if (try_prop && args.size() == 1) { + QStringList proparg; + proparg += interface; + proparg += member; + proparg += args.first(); + if (!placeCall(service, path, "org.freedesktop.DBus.Properties", "Set", proparg, false)) + return 0; + } fprintf(stderr, "Cannot find '%s.%s' in object %s at %s\n", qPrintable(interface), qPrintable(member), qPrintable(path), qPrintable(service)); - exit(1); + return 1; } QMetaMethod mm = mo->method(midx); @@ -314,7 +326,7 @@ static void placeCall(const QString &service, const QString &path, const QString if (p.type() == QVariant::Invalid) { fprintf(stderr, "Could not convert '%s' to type '%s'.\n", qPrintable(argument), types.at(i).constData()); - exit(1); + return 1 ; } } else if (id == qMetaTypeId()) { QDBusVariant tmp(p); @@ -324,7 +336,7 @@ static void placeCall(const QString &service, const QString &path, const QString if (path.path().isNull()) { fprintf(stderr, "Cannot pass argument '%s' because it is not a valid object path.\n", qPrintable(argument)); - exit(1); + return 1; } p = qVariantFromValue(path); } else if (id == qMetaTypeId()) { @@ -332,39 +344,50 @@ static void placeCall(const QString &service, const QString &path, const QString if (sig.signature().isNull()) { fprintf(stderr, "Cannot pass argument '%s' because it is not a valid signature.\n", qPrintable(argument)); - exit(1); + return 1; } p = qVariantFromValue(sig); } else { fprintf(stderr, "Sorry, can't pass arg of type '%s'.\n", types.at(i).constData()); - exit(1); + return 1; } params += p; } if (params.count() != types.count() || !args.isEmpty()) { fprintf(stderr, "Invalid number of parameters\n"); - exit(1); + return 1; } } QDBusMessage reply = iface.callWithArgumentList(QDBus::Block, member, params); if (reply.type() == QDBusMessage::ErrorMessage) { QDBusError err = reply; + // Failed to retrieve property after falling back? + // Bail out without displaying an error + if (!try_prop) + return 1; + if (err.type() == QDBusError::UnknownMethod && try_prop) { + QStringList proparg; + proparg += interface; + proparg += member; + if (!placeCall(service, path, "org.freedesktop.DBus.Properties", "Get", proparg, false)) + return 0; + } if (err.type() == QDBusError::ServiceUnknown) fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); else printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); - exit(2); + return 2; } else if (reply.type() != QDBusMessage::ReplyMessage) { fprintf(stderr, "Invalid reply type %d\n", int(reply.type())); - exit(1); + return 1; } foreach (QVariant v, reply.arguments()) printArg(v); - exit(0); + return 0; } static bool globServices(QDBusConnectionInterface *bus, const QString &glob) @@ -483,6 +506,7 @@ int main(int argc, char **argv) exit(1); } - placeCall(service, path, interface, member, args); + int ret = placeCall(service, path, interface, member, args); + exit(ret); } -- cgit v0.12 From bba8f557f59d17e68ec0d9707e66c5324bb4bd33 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 16 Dec 2009 10:22:06 +1000 Subject: Remove obsolete code for unsupported platforms This code was apparently put in for OSX10.3. ODBC2 is over 10 years old now, and even microsoft doesn't support any fashion to link to the ansi versions of the functions. Remove the #define so that we don't have to support it any more. Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 20 -------------------- src/sql/drivers/odbc/qsql_odbc.h | 10 ---------- 2 files changed, 30 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index e686873..445570a 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -62,13 +62,6 @@ QT_BEGIN_NAMESPACE // undefine this to prevent initial check of the ODBC driver #define ODBC_CHECK_DRIVER -#if defined(Q_ODBC_VERSION_2) -//crude hack to get non-unicode capable driver managers to work -# undef UNICODE -# define SQLTCHAR SQLCHAR -# define SQL_C_WCHAR SQL_C_CHAR -#endif - // newer platform SDKs use SQLLEN instead of SQLINTEGER #if defined(WIN32) && (_MSC_VER < 1300) # define QSQLLEN SQLINTEGER @@ -287,13 +280,11 @@ static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T* p, bool isSi case SQL_TYPE_TIMESTAMP: type = QVariant::DateTime; break; -#ifndef Q_ODBC_VERSION_2 case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: type = QVariant::String; break; -#endif case SQL_CHAR: case SQL_VARCHAR: case SQL_GUID: @@ -566,10 +557,8 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) static int qGetODBCVersion(const QString &connOpts) { -#ifndef Q_ODBC_VERSION_2 if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"), Qt::CaseInsensitive)) return SQL_OV_ODBC3; -#endif return SQL_OV_ODBC2; } @@ -668,7 +657,6 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) continue; } r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACE, (SQLPOINTER) v, 0); -#ifndef Q_ODBC_VERSION_2 } else if (opt.toUpper() == QLatin1String("SQL_ATTR_CONNECTION_POOLING")) { if (val == QLatin1String("SQL_CP_OFF")) v = SQL_CP_OFF; @@ -695,7 +683,6 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) continue; } r = SQLSetConnectAttr(hDbc, SQL_ATTR_CP_MATCH, (SQLPOINTER)v, 0); -#endif } else if (opt.toUpper() == QLatin1String("SQL_ATTR_ODBC_VERSION")) { // Already handled in QODBCDriver::open() continue; @@ -1416,7 +1403,6 @@ bool QODBCResult::exec() *ind == SQL_NULL_DATA ? ind : NULL); break; case QVariant::String: -#ifndef Q_ODBC_VERSION_2 if (d->unicode) { QString str = val.toString(); str.utf16(); @@ -1453,7 +1439,6 @@ bool QODBCResult::exec() break; } else -#endif { QByteArray str = val.toString().toAscii(); if (*ind != SQL_NULL_DATA) @@ -1854,11 +1839,6 @@ void QODBCDriver::cleanup() // as two byte unicode characters void QODBCDriverPrivate::checkUnicode() { -#if defined(Q_ODBC_VERSION_2) - unicode = false; - return; -#endif - SQLRETURN r; SQLUINTEGER fFunc; diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h index 8bd7660..aa96feb 100644 --- a/src/sql/drivers/odbc/qsql_odbc.h +++ b/src/sql/drivers/odbc/qsql_odbc.h @@ -49,13 +49,6 @@ #include #endif -#if defined (Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3) -// assume we use iodbc on MACX -// comment next line out if you use a -// unicode compatible manager -# define Q_ODBC_VERSION_2 -#endif - #ifdef QT_PLUGIN #define Q_EXPORT_SQLDRIVER_ODBC #else @@ -75,10 +68,7 @@ # undef _MSC_VER #endif -#ifndef Q_ODBC_VERSION_2 #include -#endif - #include QT_BEGIN_HEADER -- cgit v0.12 From 63c8293b60bb997d370a4ec343b7f04808969393 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 16 Dec 2009 14:55:56 +0100 Subject: Assistant: Fix console output glitch. --- tools/assistant/tools/assistant/cmdlineparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp index a93d63f..2b1296c 100644 --- a/tools/assistant/tools/assistant/cmdlineparser.cpp +++ b/tools/assistant/tools/assistant/cmdlineparser.cpp @@ -72,7 +72,7 @@ const QString CmdLineParser::m_helpMessage = QLatin1String( " file.\n" "-setCurrentFilter filter Set the filter as the active filter.\n" "-remove-search-index Removes the full text search index.\n" - "-rebuild-search-index Re-builds the full text search index (potentially slow)\n." + "-rebuild-search-index Re-builds the full text search index (potentially slow).\n" "-quiet Does not display any error or\n" " status message.\n" "-help Displays this help.\n" -- cgit v0.12 From a66af3b563a90e55015f7cfe7f04f8704ee7d402 Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 17 Dec 2009 07:43:05 +0100 Subject: Added QTest::setBenchmarkResult() to public API. A benchmark result can now be registered explicitly using the QTest::setBenchmarkResult() function as an alternative to using a QBENCHMARK* macro. This gives benchmark writers the freedom to compute the benchmark result however they like and not be dependent on the automatic iteration/accumulation algorithm of a QBENCHMARK* macro. The function takes two arguments: a value and a metric. The value must be a non-negative real, while the metric is an enum type. WARNING: The set of available metrics include metrics for which a high value is considered better (i.e. faster) than a low value (one example is 'frames per second'). QTestLib currently does not distinguish between the two cases of "higher is better" and "lower is better", and leaves it to external tools (parsing the QTestLib output) to recognize them and do any necessary conversion. A tool that plots benchmark result history could e.g. convert all "higher is better" to "lower is better". For the 'frames per second' case, this would typically mean converting FPS to SPF (= 1/FPS). Reviewed-by: MortenS --- src/testlib/qbenchmark.cpp | 51 ++++++++++---------- src/testlib/qbenchmark.h | 10 ++++ src/testlib/qbenchmark_p.h | 26 +++++++---- src/testlib/qbenchmarkevent.cpp | 10 ++-- src/testlib/qbenchmarkevent_p.h | 3 +- src/testlib/qbenchmarkmeasurement.cpp | 20 +++----- src/testlib/qbenchmarkmeasurement_p.h | 10 ++-- src/testlib/qbenchmarkmetric.cpp | 87 +++++++++++++++++++++++++++++++++++ src/testlib/qbenchmarkmetric.h | 71 ++++++++++++++++++++++++++++ src/testlib/qbenchmarkmetric_p.h | 63 +++++++++++++++++++++++++ src/testlib/qbenchmarkvalgrind.cpp | 9 +--- src/testlib/qbenchmarkvalgrind_p.h | 4 +- src/testlib/qplaintestlogger.cpp | 30 ++++++++---- src/testlib/qtestcoreelement.h | 5 ++ src/testlib/qtestlogger.cpp | 4 +- src/testlib/qxmltestlogger.cpp | 3 +- src/testlib/testlib.pro | 1 + 17 files changed, 323 insertions(+), 84 deletions(-) create mode 100644 src/testlib/qbenchmarkmetric.cpp create mode 100644 src/testlib/qbenchmarkmetric.h create mode 100644 src/testlib/qbenchmarkmetric_p.h diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 3bd9054..b2f388e 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -41,6 +41,7 @@ #include "QtTest/qbenchmark.h" #include "QtTest/private/qbenchmark_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" #ifdef QT_GUI_LIB #include @@ -138,7 +139,7 @@ void QBenchmarkTestMethodData::endDataRun() int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) { - // Let the -iteration-count option override the measurer. + // Let the -iterations option override the measurer. if (QBenchmarkGlobalData::current->iterationCount != -1) { iterationCount = QBenchmarkGlobalData::current->iterationCount; } else { @@ -148,12 +149,13 @@ int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) return iterationCount; } -void QBenchmarkTestMethodData::setResult(qint64 value) +void QBenchmarkTestMethodData::setResult( + qreal value, QTest::QBenchmarkMetric metric, bool setByMacro) { bool accepted = false; // Always accept the result if the iteration count has been - // specified on the command line with -iteartion-count. + // specified on the command line with -iterations. if (QBenchmarkGlobalData::current->iterationCount != -1) accepted = true; @@ -161,7 +163,7 @@ void QBenchmarkTestMethodData::setResult(qint64 value) iterationCount = 1; accepted = true; } - + // Test the result directly without calling the measurer if the minimum time // has been specifed on the command line with -minimumvalue. else if (QBenchmarkGlobalData::current->walltimeMinimum != -1) @@ -175,8 +177,8 @@ void QBenchmarkTestMethodData::setResult(qint64 value) else iterationCount *= 2; - this->result = - QBenchmarkResult(QBenchmarkGlobalData::current->context, value, iterationCount); + this->result = QBenchmarkResult( + QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro); } /*! @@ -208,7 +210,8 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController() */ QTest::QBenchmarkIterationController::~QBenchmarkIterationController() { - QBenchmarkTestMethodData::current->setResult(QTest::endBenchmarkMeasurement()); + const qreal result = QTest::endBenchmarkMeasurement(); + QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType()); } /*! \internal @@ -259,28 +262,30 @@ void QTest::beginBenchmarkMeasurement() /*! \internal */ -qint64 QTest::endBenchmarkMeasurement() +quint64 QTest::endBenchmarkMeasurement() { // the clock is ticking before the line below, don't add code here. return QBenchmarkGlobalData::current->measurer->stop(); } -/*! \internal -*/ -void QTest::setResult(qint64 result) -{ - QBenchmarkTestMethodData::current->setResult(result); -} - -/*! \internal +/*! + Sets the benchmark result for this test function to \a result. + + Use this function if you want to report benchmark results without + using the QBENCHMARK macro. Use \a metric to specify how QTestLib + should interpret the results. + + The context for the result will be the test function name and any + data tag from the _data function. This function can only be called + once in each test function, subsequent calls will replace the + earlier reported results. + + Note that the -iterations command line argument has no effect + on test functions without the QBENCHMARK macro. */ -void QTest::setResult(const QString &tag, qint64 result) +void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric) { - QBenchmarkContext context = QBenchmarkGlobalData::current->context; - context.tag = tag; - QBenchmarkTestMethodData::current->result = - QBenchmarkResult( context, result, - QBenchmarkTestMethodData::current->iterationCount); + QBenchmarkTestMethodData::current->setResult(result, metric, false); } template @@ -298,6 +303,4 @@ Q_TYPENAME T::value_type qAverage(const T &container) return acc / count; } - QT_END_NAMESPACE - diff --git a/src/testlib/qbenchmark.h b/src/testlib/qbenchmark.h index 3fb1336..16263fe 100644 --- a/src/testlib/qbenchmark.h +++ b/src/testlib/qbenchmark.h @@ -43,6 +43,7 @@ #define QBENCHMARK_H #include +#include QT_BEGIN_HEADER @@ -75,6 +76,8 @@ public: } +// --- BEGIN public API --- + #define QBENCHMARK \ for (QTest::QBenchmarkIterationController __iteration_controller; \ __iteration_controller.isDone() == false; __iteration_controller.next()) @@ -83,6 +86,13 @@ public: for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RunOnce); \ __iteration_controller.isDone() == false; __iteration_controller.next()) +namespace QTest +{ + void Q_TESTLIB_EXPORT setBenchmarkResult(qreal result, QBenchmarkMetric metric); +} + +// --- END public API --- + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 2f0900b..e294d69 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -42,6 +42,8 @@ #ifndef QBENCHMARK_P_H #define QBENCHMARK_P_H +#include + // // W A R N I N G // ------------- @@ -68,6 +70,7 @@ #include "QtTest/private/qbenchmarkvalgrind_p.h" #endif #include "QtTest/private/qbenchmarkevent_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" QT_BEGIN_NAMESPACE @@ -92,23 +95,29 @@ class QBenchmarkResult { public: QBenchmarkContext context; - qint64 value; + qreal value; int iterations; + QTest::QBenchmarkMetric metric; + bool setByMacro; bool valid; QBenchmarkResult() : value(-1) , iterations(-1) + , setByMacro(true) , valid(false) - { } + { } - QBenchmarkResult(const QBenchmarkContext &context, const qint64 value, const int iterations) + QBenchmarkResult( + const QBenchmarkContext &context, const qreal value, const int iterations, + QTest::QBenchmarkMetric metric, bool setByMacro) : context(context) , value(value) , iterations(iterations) + , metric(metric) + , setByMacro(setByMacro) , valid(true) - { - } + { } bool operator<(const QBenchmarkResult &other) const { @@ -167,7 +176,7 @@ public: bool isBenchmark() const { return result.valid; } bool resultsAccepted() const { return resultAccepted; } int adjustIterationCount(int suggestion); - void setResult(qint64 value); + void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true); QBenchmarkResult result; bool resultAccepted; @@ -183,10 +192,7 @@ namespace QTest void setIterationCount(int count); Q_TESTLIB_EXPORT void beginBenchmarkMeasurement(); - Q_TESTLIB_EXPORT qint64 endBenchmarkMeasurement(); - - void setResult(qint64 result); - void setResult(const QString &tag, qint64 result); + Q_TESTLIB_EXPORT quint64 endBenchmarkMeasurement(); } QT_END_NAMESPACE diff --git a/src/testlib/qbenchmarkevent.cpp b/src/testlib/qbenchmarkevent.cpp index 60cd302..4f4e203 100644 --- a/src/testlib/qbenchmarkevent.cpp +++ b/src/testlib/qbenchmarkevent.cpp @@ -41,6 +41,7 @@ #include "QtTest/private/qbenchmarkevent_p.h" #include "QtTest/private/qbenchmark_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" #include QT_BEGIN_NAMESPACE @@ -91,14 +92,9 @@ int QBenchmarkEvent::adjustMedianCount(int suggestion) return 1; } -QString QBenchmarkEvent::unitText() +QTest::QBenchmarkMetric QBenchmarkEvent::metricType() { - return QLatin1String("events"); -} - -QString QBenchmarkEvent::metricText() -{ - return QLatin1String("events"); + return QTest::Events; } // This could be done in a much better way, this is just the beginning. diff --git a/src/testlib/qbenchmarkevent_p.h b/src/testlib/qbenchmarkevent_p.h index f191a0d..2d625eb 100644 --- a/src/testlib/qbenchmarkevent_p.h +++ b/src/testlib/qbenchmarkevent_p.h @@ -70,8 +70,7 @@ public: int adjustIterationCount(int suggestion); int adjustMedianCount(int suggestion); bool repeatCount() { return 1; } - QString unitText(); - QString metricText(); + QTest::QBenchmarkMetric metricType(); static bool eventCountingMechanism(void *message); static qint64 eventCounter; }; diff --git a/src/testlib/qbenchmarkmeasurement.cpp b/src/testlib/qbenchmarkmeasurement.cpp index f860454..6107b98 100644 --- a/src/testlib/qbenchmarkmeasurement.cpp +++ b/src/testlib/qbenchmarkmeasurement.cpp @@ -41,6 +41,8 @@ #include "QtTest/private/qbenchmarkmeasurement_p.h" #include "QtTest/private/qbenchmark_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" +#include "qbenchmark.h" #include QT_BEGIN_NAMESPACE @@ -77,14 +79,9 @@ int QBenchmarkTimeMeasurer::adjustMedianCount(int) return 1; } -QString QBenchmarkTimeMeasurer::unitText() +QTest::QBenchmarkMetric QBenchmarkTimeMeasurer::metricType() { - return QLatin1String("msec"); -} - -QString QBenchmarkTimeMeasurer::metricText() -{ - return QLatin1String("walltime"); + return QTest::WalltimeMilliseconds; } #ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h @@ -126,14 +123,9 @@ bool QBenchmarkTickMeasurer::needsWarmupIteration() return true; } -QString QBenchmarkTickMeasurer::unitText() -{ - return QLatin1String("ticks"); -} - -QString QBenchmarkTickMeasurer::metricText() +QTest::QBenchmarkMetric QBenchmarkTickMeasurer::metricType() { - return QLatin1String("cputicks"); + return QTest::CPUTicks; } #endif diff --git a/src/testlib/qbenchmarkmeasurement_p.h b/src/testlib/qbenchmarkmeasurement_p.h index f237034..fc4b0fe 100644 --- a/src/testlib/qbenchmarkmeasurement_p.h +++ b/src/testlib/qbenchmarkmeasurement_p.h @@ -55,6 +55,7 @@ #include #include "3rdparty/cycle_p.h" +#include "qbenchmark.h" QT_BEGIN_NAMESPACE @@ -71,8 +72,7 @@ public: virtual int adjustMedianCount(int suggestion) = 0; virtual bool repeatCount() { return 1; } virtual bool needsWarmupIteration() { return false; } - virtual QString unitText() = 0; - virtual QString metricText() = 0; + virtual QTest::QBenchmarkMetric metricType() = 0; }; class QBenchmarkTimeMeasurer : public QBenchmarkMeasurerBase @@ -84,8 +84,7 @@ public: bool isMeasurementAccepted(qint64 measurement); int adjustIterationCount(int sugestion); int adjustMedianCount(int suggestion); - QString unitText(); - QString metricText(); + QTest::QBenchmarkMetric metricType(); private: QTime time; }; @@ -102,8 +101,7 @@ public: int adjustIterationCount(int); int adjustMedianCount(int suggestion); bool needsWarmupIteration(); - QString unitText(); - QString metricText(); + QTest::QBenchmarkMetric metricType(); private: CycleCounterTicks startTicks; }; diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp new file mode 100644 index 0000000..614357c --- /dev/null +++ b/src/testlib/qbenchmarkmetric.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** + ** + ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the QtTest module of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:LGPL$ + ** No Commercial Usage + ** This file contains pre-release code and may not be distributed. + ** You may use this file in accordance with the terms and conditions + ** contained in the Technology Preview License Agreement accompanying + ** this package. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 as published by the Free Software + ** Foundation and appearing in the file LICENSE.LGPL included in the + ** packaging of this file. Please review the following information to + ** ensure the GNU Lesser General Public License version 2.1 requirements + ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, Nokia gives you certain additional + ** rights. These rights are described in the Nokia Qt LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ** If you have questions regarding the use of this file, please contact + ** Nokia at qt-info@nokia.com. + ** + ** + ** + ** + ** + ** + ** + ** + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include + +const char * QTest::benchmarkMetricName(QBenchmarkMetric metric) +{ + switch (metric) { + case FramesPerSecond: + return "FramesPerSecond"; + case BitsPerSecond: + return "BitsPerSecond"; + case BytesPerSecond: + return "BytesPerSecond"; + case WalltimeMilliseconds: + return "WalltimeMilliseconds"; + case CPUTicks: + return "CPUTicks"; + case InstructionReads: + return "InstructionReads"; + case Events: + return "Events"; + default: + return ""; + } +}; + +const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric) +{ + switch (metric) { + case FramesPerSecond: + return "fps"; + case BitsPerSecond: + return "bits/s"; + case BytesPerSecond: + return "bytes/s"; + case WalltimeMilliseconds: + return "msecs"; + case CPUTicks: + return "CPU ticks"; + case InstructionReads: + return "instruction reads"; + case Events: + return "events"; + default: + return ""; + } +} + diff --git a/src/testlib/qbenchmarkmetric.h b/src/testlib/qbenchmarkmetric.h new file mode 100644 index 0000000..302c1aa --- /dev/null +++ b/src/testlib/qbenchmarkmetric.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBENCHMARKMETRIC_H +#define QBENCHMARKMETRIC_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Test) + +namespace QTest { + +enum QBenchmarkMetric { + FramesPerSecond, + BitsPerSecond, + BytesPerSecond, + WalltimeMilliseconds, + CPUTicks, + InstructionReads, + Events +}; + +} + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QBENCHMARK_H diff --git a/src/testlib/qbenchmarkmetric_p.h b/src/testlib/qbenchmarkmetric_p.h new file mode 100644 index 0000000..c919d2e --- /dev/null +++ b/src/testlib/qbenchmarkmetric_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBENCHMARKMETRIC_P_H +#define QBENCHMARKMETRIC_P_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Test) + +namespace QTest { + const char * benchmarkMetricName(QBenchmarkMetric metric); + const char * benchmarkMetricUnit(QBenchmarkMetric metric); +} + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QBENCHMARK_H diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 88cb37f..55cd901 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -263,14 +263,9 @@ bool QBenchmarkCallgrindMeasurer::needsWarmupIteration() return true; } -QString QBenchmarkCallgrindMeasurer::unitText() +QTest::QBenchmarkMetric QBenchmarkCallgrindMeasurer::metricType() { - return QLatin1String("instr. loads"); -} - -QString QBenchmarkCallgrindMeasurer::metricText() -{ - return QLatin1String("callgrind"); + return QTest::InstructionReads; } QT_END_NAMESPACE diff --git a/src/testlib/qbenchmarkvalgrind_p.h b/src/testlib/qbenchmarkvalgrind_p.h index 14bb5a0..bdb3a5c 100644 --- a/src/testlib/qbenchmarkvalgrind_p.h +++ b/src/testlib/qbenchmarkvalgrind_p.h @@ -54,6 +54,7 @@ // #include "QtTest/private/qbenchmarkmeasurement_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" #include #include @@ -84,8 +85,7 @@ public: int adjustIterationCount(int); int adjustMedianCount(int); bool needsWarmupIteration(); - QString unitText(); - QString metricText(); + QTest::QBenchmarkMetric metricType(); }; QT_END_NAMESPACE diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 61c3728..2830556 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -44,6 +44,7 @@ #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qplaintestlogger_p.h" #include "QtTest/private/qbenchmark_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" #include #include @@ -324,7 +325,6 @@ namespace QTest { QTestResult::currentTestObjectName(), result.context.slotName.toAscii().data()); - char bufTag[1024]; bufTag[0] = 0; QByteArray tag = result.context.tag.toAscii(); @@ -340,32 +340,42 @@ namespace QTest { char fill[1024]; QTest::qt_snprintf(fill, sizeof(fill), fillFormat, ""); - - QByteArray unitText = QBenchmarkGlobalData::current->measurer->unitText().toAscii(); + const char * unitText = QTest::benchmarkMetricUnit(result.metric); qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); char resultBuffer[100] = ""; formatResult(resultBuffer, 100, valuePerIteration, countSignificantDigits(result.value)); - QByteArray iterationText = "per iteration"; - char buf2[1024]; - Q_ASSERT(result.iterations > 0); QTest::qt_snprintf( - buf2, sizeof(buf2), "%s %s %s", + buf2, sizeof(buf2), "%s %s", resultBuffer, - unitText.data(), + unitText); + + char buf2_[1024]; + QByteArray iterationText = " per iteration"; + Q_ASSERT(result.iterations > 0); + QTest::qt_snprintf( + buf2_, + sizeof(buf2_), "%s", iterationText.data()); char buf3[1024]; Q_ASSERT(result.iterations > 0); QTest::qt_snprintf( - buf3, sizeof(buf3), " (total: %s, iterations: %d)\n", + buf3, sizeof(buf3), " (total: %s, iterations: %d)", QByteArray::number(result.value).constData(), // no 64-bit qt_snprintf support result.iterations); char buf[1024]; - QTest::qt_snprintf(buf, sizeof(buf), "%s%s%s%s%s", buf1, bufTag, fill, buf2, buf3); + + if (result.setByMacro) { + QTest::qt_snprintf( + buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3); + } else { + QTest::qt_snprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2); + } + memcpy(buf, bmtag, strlen(bmtag)); outputMessage(buf); } diff --git a/src/testlib/qtestcoreelement.h b/src/testlib/qtestcoreelement.h index b5e5d0f..ceeba52 100644 --- a/src/testlib/qtestcoreelement.h +++ b/src/testlib/qtestcoreelement.h @@ -45,6 +45,8 @@ #include #include +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -93,6 +95,9 @@ void QTestCoreElement::addAttribute(const QTest::AttributeIndex att if (attribute(attributeIndex)) return; + // if (attributeIndex == QTest::AI_Metric) + // abort(); + QTestElementAttribute *testAttribute = new QTestElementAttribute; testAttribute->setPair(attributeIndex, value); testAttribute->addToList(&listOfAttributes); diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 3e89ff7..c5b8e7f 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -267,7 +267,9 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result) QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark); // printf("element %i", benchmarkElement->elementType()); - benchmarkElement->addAttribute(QTest::AI_Metric, QBenchmarkGlobalData::current->measurer->metricText().toAscii().data()); + benchmarkElement->addAttribute( + QTest::AI_Metric, + QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric)); benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toAscii().data()); benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData()); diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index fac3663..a4750ac 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -46,6 +46,7 @@ #include "QtTest/private/qxmltestlogger_p.h" #include "QtTest/private/qtestresult_p.h" #include "QtTest/private/qbenchmark_p.h" +#include "QtTest/private/qbenchmarkmetric_p.h" #include "QtTest/qtestcase.h" QT_BEGIN_NAMESPACE @@ -243,7 +244,7 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) QTestCharBuffer quotedTag; xmlQuote("edMetric, - QBenchmarkGlobalData::current->measurer->metricText().toAscii().constData()); + benchmarkMetricUnit(result.metric)); xmlQuote("edTag, result.context.tag.toAscii().constData()); QTest::qt_asprintf( diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index f68ff35..a8186d8 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -47,6 +47,7 @@ SOURCES = qtestcase.cpp \ qbenchmarkmeasurement.cpp \ qbenchmarkvalgrind.cpp \ qbenchmarkevent.cpp \ + qbenchmarkmetric.cpp \ qtestelement.cpp \ qtestelementattribute.cpp \ qtestbasicstreamer.cpp \ -- cgit v0.12 From 8cb83f37cc2e95002b44b48e851ec7672fb95df2 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 15 Dec 2009 15:35:12 +0100 Subject: Fixed memory leak in caching of concave paths in GL2 engine. Reviewed-by: Gunnar --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 39 ++++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 8fa8171..f9c41b1 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -884,6 +884,8 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) QVectorPath::CacheEntry *data = path.lookupCacheData(q); QGL2PEVectorPathCache *cache; + bool updateCache = false; + if (data) { cache = (QGL2PEVectorPathCache *) data->data; // Check if scale factor is exceeded for curved paths and generate curves if so... @@ -898,23 +900,23 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) qFree(cache->vertices); Q_ASSERT(cache->indices == 0); #endif - cache->vertexCount = 0; + updateCache = true; } } } else { cache = new QGL2PEVectorPathCache; - cache->vertexCount = 0; - cache->indexCount = 0; data = const_cast(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath); + updateCache = true; } // Flatten the path at the current scale factor and fill it into the cache struct. - if (!cache->vertexCount) { + if (updateCache) { vertexCoordinateArray.clear(); vertexCoordinateArray.addPath(path, inverseScale, false); int vertexCount = vertexCoordinateArray.vertexCount(); int floatSizeInBytes = vertexCount * 2 * sizeof(float); cache->vertexCount = vertexCount; + cache->indexCount = 0; cache->primitiveType = GL_TRIANGLE_FAN; cache->iscale = inverseScale; #ifdef QT_OPENGL_CACHE_AS_VBOS @@ -951,18 +953,22 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } } else { + bool useCache = path.isCacheable(); + if (useCache) { + QRectF bbox = path.controlPointRect(); + // If the path doesn't fit within these limits, it is possible that the triangulation will fail. + useCache &= (bbox.left() > -0x8000 * inverseScale) + && (bbox.right() < 0x8000 * inverseScale) + && (bbox.top() > -0x8000 * inverseScale) + && (bbox.bottom() < 0x8000 * inverseScale); + } - QRectF bbox = path.controlPointRect(); - // If the path doesn't fit within these limits, it is possible that the triangulation will fail. - bool pathIsWithinLimits = (bbox.left() > -0x8000 * inverseScale) - && (bbox.right() < 0x8000 * inverseScale) - && (bbox.top() > -0x8000 * inverseScale) - && (bbox.bottom() < 0x8000 * inverseScale); - - if (path.isCacheable() && pathIsWithinLimits) { + if (useCache) { QVectorPath::CacheEntry *data = path.lookupCacheData(q); QGL2PEVectorPathCache *cache; + bool updateCache = false; + if (data) { cache = (QGL2PEVectorPathCache *) data->data; // Check if scale factor is exceeded for curved paths and generate curves if so... @@ -972,24 +978,21 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) #ifdef QT_OPENGL_CACHE_AS_VBOS glDeleteBuffers(1, &cache->vbo); glDeleteBuffers(1, &cache->ibo); - cache->vbo = cache->ibo = 0; #else qFree(cache->vertices); qFree(cache->indices); #endif - cache->vertexCount = 0; - cache->indexCount = 0; + updateCache = true; } } } else { cache = new QGL2PEVectorPathCache; - cache->vertexCount = 0; - cache->indexCount = 0; data = const_cast(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath); + updateCache = true; } // Flatten the path at the current scale factor and fill it into the cache struct. - if (!cache->vertexCount) { + if (updateCache) { QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); cache->vertexCount = polys.vertices.size() / 2; cache->indexCount = polys.indices.size(); -- cgit v0.12 From d4005e273d4285d0b6a9c60f712cfd12c311c3a3 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 11 Dec 2009 20:19:53 +0100 Subject: Focus frames in mac style gets clipped. The focus frame on mac is a separate widget. The parent of the focus frame is same as the parent of the widget who has the focus. So if there is not enough room for a focus frame between the parent and the widget, it gets clipped to the parent. This parent is now changed to the nearest (in hierarchy) top level, toolbar or scrollarea-viewport. A clip area is set on the focus frame widget based on the visible region of the widget. This reduces the chances of having clipped focus frames. It is always better to leave enough margin for widgets which shows focus frames. Task-number: 6567 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Jan-Arve --- src/gui/widgets/qfocusframe.cpp | 91 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qfocusframe.cpp b/src/gui/widgets/qfocusframe.cpp index e96f50d..02f76f1 100644 --- a/src/gui/widgets/qfocusframe.cpp +++ b/src/gui/widgets/qfocusframe.cpp @@ -53,11 +53,14 @@ class QFocusFramePrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QFocusFrame) QWidget *widget; - + QWidget *frameParent; + bool showFrameAboveWidget; public: QFocusFramePrivate() { widget = 0; + frameParent = 0; sendChildEvents = false; + showFrameAboveWidget = false; } void updateSize(); void update(); @@ -66,10 +69,10 @@ public: void QFocusFramePrivate::update() { Q_Q(QFocusFrame); - q->setParent(widget->parentWidget()); + q->setParent(frameParent); updateSize(); if (q->parentWidget()->rect().intersects(q->geometry())) { - if (q->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, q)) + if (showFrameAboveWidget) q->raise(); else q->stackUnder(widget); @@ -84,7 +87,10 @@ void QFocusFramePrivate::updateSize() Q_Q(QFocusFrame); int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin), hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin); - QRect geom(widget->x()-hmargin, widget->y()-vmargin, + QPoint pos(widget->x(), widget->y()); + if (q->parentWidget() != widget->parentWidget()) + pos = widget->parentWidget()->mapTo(q->parentWidget(), pos); + QRect geom(pos.x()-hmargin, pos.y()-vmargin, widget->width()+(hmargin*2), widget->height()+(vmargin*2)); if(q->geometry() == geom) return; @@ -176,14 +182,52 @@ void QFocusFrame::setWidget(QWidget *widget) { Q_D(QFocusFrame); - if(widget == d->widget) - return; - if(d->widget) - d->widget->removeEventFilter(this); - if(widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) { + if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)) + d->showFrameAboveWidget = true; + else + d->showFrameAboveWidget = false; + + if (widget == d->widget) + return; + if (d->widget) { + // Remove event filters from the widget hierarchy. + QWidget *p = d->widget; + do { + p->removeEventFilter(this); + if (!d->showFrameAboveWidget || p == d->frameParent) + break; + p = p->parentWidget(); + }while (p); + } + if (widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) { d->widget = widget; - widget->installEventFilter(this); + d->widget->installEventFilter(this); + QWidget *p = widget->parentWidget(); + QWidget *prev = 0; + if (d->showFrameAboveWidget) { + // Find the right parent for the focus frame. + while (p) { + // Traverse the hirerarchy of the 'widget' for setting event filter. + // During this if come across toolbar or a top level, use that + // as the parent for the focus frame. If we find a scroll area + // use its viewport as the parent. + bool isScrollArea = false; + if (p->isWindow() || p->inherits("QToolBar") || (isScrollArea = p->inherits("QAbstractScrollArea"))) { + d->frameParent = p; + // The previous one in the hierarchy will be the viewport. + if (prev && isScrollArea) + d->frameParent = prev; + break; + } else { + p->installEventFilter(this); + prev = p; + p = p->parentWidget(); + } + } + } else { + d->frameParent = p; + } d->update(); } else { d->widget = 0; @@ -210,9 +254,15 @@ QFocusFrame::widget() const void QFocusFrame::paintEvent(QPaintEvent *) { + Q_D(QFocusFrame); QStylePainter p(this); QStyleOption option; initStyleOption(&option); + int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin); + int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin); + QWidgetPrivate *wd = qt_widget_private(d->widget); + QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2); + p.setClipRect(rect); p.drawControl(QStyle::CE_FocusFrame, option); } @@ -233,7 +283,13 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e) hide(); break; case QEvent::ParentChange: - d->update(); + if (d->showFrameAboveWidget) { + QWidget *w = d->widget; + setWidget(0); + setWidget(w); + } else { + d->update(); + } break; case QEvent::Show: d->update(); @@ -254,6 +310,19 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e) default: break; } + } else if (d->showFrameAboveWidget) { + // Handle changes in the parent widgets we are monitoring. + switch(e->type()) { + case QEvent::Move: + case QEvent::Resize: + d->updateSize(); + break; + case QEvent::ZOrderChange: + raise(); + break; + default: + break; + } } return false; } -- cgit v0.12 From f0c5c37ad8c2497511564d8c52dd53b2503c97c4 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 21 Dec 2009 09:50:59 +0100 Subject: Assistant: Refactor help engine wrapper. This class had a lot of implementation details in the header, which were moved to an internal private class. --- .../tools/assistant/helpenginewrapper.cpp | 292 +++++++++++++-------- .../assistant/tools/assistant/helpenginewrapper.h | 37 +-- tools/assistant/tools/assistant/main.cpp | 2 +- 3 files changed, 187 insertions(+), 144 deletions(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 79a25ec..72ba30d 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -43,8 +43,11 @@ #include "helpenginewrapper.h" #include "../shared/collectionconfiguration.h" +#include #include #include +#include +#include #include #include #include @@ -71,6 +74,49 @@ namespace { arg(QLatin1String(QT_VERSION_STR))); } // anonymous namespace +class TimeoutForwarder : public QObject +{ + Q_OBJECT +public: + TimeoutForwarder(const QString &fileName); +private slots: + void forward(); +private: + friend class HelpEngineWrapperPrivate; + + const QString m_fileName; +}; + +class HelpEngineWrapperPrivate : public QObject +{ + Q_OBJECT + friend class HelpEngineWrapper; + friend class TimeoutForwarder; +private slots: + void qchFileChanged(const QString &fileName); + +signals: + void documentationRemoved(const QString &namespaceName); + void documentationUpdated(const QString &namespaceName); + +private: + HelpEngineWrapperPrivate(const QString &collectionFile); + + friend class TimeoutForwarder; + + void initFileSystemWatchers(); + void assertDocFilesWatched(); + void qchFileChanged(const QString &fileName, bool fromTimeout); + + static const int UpdateGracePeriod = 2000; + + QHelpEngine * const m_helpEngine; + QFileSystemWatcher * const m_qchWatcher; + typedef QPair > RecentSignal; + QMap m_recentQchUpdates; + +}; + HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile) @@ -93,183 +139,179 @@ void HelpEngineWrapper::removeInstance() } HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) - : m_helpEngine(new QHelpEngine(collectionFile, this)), - m_qchWatcher(new QFileSystemWatcher(this)) + : d(new HelpEngineWrapperPrivate(collectionFile)) { TRACE_OBJ - connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), + connect(d, SIGNAL(documentationRemoved(QString)), + this, SIGNAL(documentationRemoved(QString))); + connect(d, SIGNAL(documentationUpdated(QString)), + this, SIGNAL(documentationUpdated(QString))); + connect(d->m_helpEngine, SIGNAL(currentFilterChanged(QString)), this, SIGNAL(currentFilterChanged(QString))); - connect(m_helpEngine, SIGNAL(setupFinished()), + connect(d->m_helpEngine, SIGNAL(setupFinished()), this, SIGNAL(setupFinished())); - initFileSystemWatchers(); } -void HelpEngineWrapper::initFileSystemWatchers() +HelpEngineWrapper::~HelpEngineWrapper() { TRACE_OBJ - foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { - const QString &docFile = m_helpEngine->documentationFileName(ns); - m_qchWatcher->addPath(docFile); - connect(m_qchWatcher, SIGNAL(fileChanged(QString)), - this, SLOT(qchFileChanged(QString))); - } - assertDocFilesWatched(); + delete d; } QHelpSearchEngine *HelpEngineWrapper::searchEngine() const { TRACE_OBJ - return m_helpEngine->searchEngine(); + return d->m_helpEngine->searchEngine(); } QHelpContentModel *HelpEngineWrapper::contentModel() const { TRACE_OBJ - return m_helpEngine->contentModel(); + return d->m_helpEngine->contentModel(); } QHelpIndexModel *HelpEngineWrapper::indexModel() const { TRACE_OBJ - return m_helpEngine->indexModel(); + return d->m_helpEngine->indexModel(); } QHelpContentWidget *HelpEngineWrapper::contentWidget() { TRACE_OBJ - return m_helpEngine->contentWidget(); + return d->m_helpEngine->contentWidget(); } QHelpIndexWidget *HelpEngineWrapper::indexWidget() { TRACE_OBJ - return m_helpEngine->indexWidget(); + return d->m_helpEngine->indexWidget(); } const QStringList HelpEngineWrapper::registeredDocumentations() const { TRACE_OBJ - return m_helpEngine->registeredDocumentations(); + return d->m_helpEngine->registeredDocumentations(); } const QString HelpEngineWrapper::collectionFile() const { TRACE_OBJ - return m_helpEngine->collectionFile(); + return d->m_helpEngine->collectionFile(); } bool HelpEngineWrapper::registerDocumentation(const QString &docFile) { TRACE_OBJ - assertDocFilesWatched(); - if (!m_helpEngine->registerDocumentation(docFile)) + d->assertDocFilesWatched(); + if (!d->m_helpEngine->registerDocumentation(docFile)) return false; - m_qchWatcher->addPath(docFile); - assertDocFilesWatched(); + d->m_qchWatcher->addPath(docFile); + d->assertDocFilesWatched(); return true; } bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) { TRACE_OBJ - assertDocFilesWatched(); - const QString &file = m_helpEngine->documentationFileName(namespaceName); - if (!m_helpEngine->unregisterDocumentation(namespaceName)) + d->assertDocFilesWatched(); + const QString &file = d->m_helpEngine->documentationFileName(namespaceName); + if (!d->m_helpEngine->unregisterDocumentation(namespaceName)) return false; - m_qchWatcher->removePath(file); - assertDocFilesWatched(); + d->m_qchWatcher->removePath(file); + d->assertDocFilesWatched(); return true; } bool HelpEngineWrapper::setupData() { TRACE_OBJ - return m_helpEngine->setupData(); + return d->m_helpEngine->setupData(); } bool HelpEngineWrapper::addCustomFilter(const QString &filterName, const QStringList &attributes) { TRACE_OBJ - return m_helpEngine->addCustomFilter(filterName, attributes); + return d->m_helpEngine->addCustomFilter(filterName, attributes); } bool HelpEngineWrapper::removeCustomFilter(const QString &filterName) { TRACE_OBJ - return m_helpEngine->removeCustomFilter(filterName); + return d->m_helpEngine->removeCustomFilter(filterName); } void HelpEngineWrapper::setCurrentFilter(const QString ¤tFilter) { TRACE_OBJ - m_helpEngine->setCurrentFilter(currentFilter); + d->m_helpEngine->setCurrentFilter(currentFilter); } const QString HelpEngineWrapper::currentFilter() const { TRACE_OBJ - return m_helpEngine->currentFilter(); + return d->m_helpEngine->currentFilter(); } const QStringList HelpEngineWrapper::customFilters() const { TRACE_OBJ - return m_helpEngine->customFilters(); + return d->m_helpEngine->customFilters(); } QUrl HelpEngineWrapper::findFile(const QUrl &url) const { TRACE_OBJ - return m_helpEngine->findFile(url); + return d->m_helpEngine->findFile(url); } QByteArray HelpEngineWrapper::fileData(const QUrl &url) const { TRACE_OBJ - return m_helpEngine->fileData(url); + return d->m_helpEngine->fileData(url); } QMap HelpEngineWrapper::linksForIdentifier(const QString &id) const { TRACE_OBJ - return m_helpEngine->linksForIdentifier(id); + return d->m_helpEngine->linksForIdentifier(id); } const QStringList HelpEngineWrapper::filterAttributes() const { TRACE_OBJ - return m_helpEngine->filterAttributes(); + return d->m_helpEngine->filterAttributes(); } const QStringList HelpEngineWrapper::filterAttributes(const QString &filterName) const { TRACE_OBJ - return m_helpEngine->filterAttributes(filterName); + return d->m_helpEngine->filterAttributes(filterName); } QString HelpEngineWrapper::error() const { TRACE_OBJ - return m_helpEngine->error(); + return d->m_helpEngine->error(); } bool HelpEngineWrapper::unfilteredInserted() const { TRACE_OBJ - return m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; + return d->m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1; } void HelpEngineWrapper::setUnfilteredInserted() { TRACE_OBJ - m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); + d->m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1); } const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const { TRACE_OBJ - return m_helpEngine->customValue(VersionKey.arg(component)).toString(). + return d->m_helpEngine->customValue(VersionKey.arg(component)).toString(). split(CollectionConfiguration::ListSeparator); } @@ -277,264 +319,265 @@ void HelpEngineWrapper::setQtDocInfo(const QString &component, const QStringList &doc) { TRACE_OBJ - m_helpEngine->setCustomValue(VersionKey.arg(component), + d->m_helpEngine->setCustomValue(VersionKey.arg(component), doc.join(CollectionConfiguration::ListSeparator)); } const QStringList HelpEngineWrapper::lastShownPages() const { TRACE_OBJ - return CollectionConfiguration::lastShownPages(*m_helpEngine); + return CollectionConfiguration::lastShownPages(*d->m_helpEngine); } void HelpEngineWrapper::setLastShownPages(const QStringList &lastShownPages) { TRACE_OBJ - CollectionConfiguration::setLastShownPages(*m_helpEngine, lastShownPages); + CollectionConfiguration::setLastShownPages(*d->m_helpEngine, lastShownPages); } const QStringList HelpEngineWrapper::lastZoomFactors() const { TRACE_OBJ - return CollectionConfiguration::lastZoomFactors(*m_helpEngine); + return CollectionConfiguration::lastZoomFactors(*d->m_helpEngine); } void HelpEngineWrapper::setLastZoomFactors(const QStringList &lastZoomFactors) { TRACE_OBJ - CollectionConfiguration::setLastZoomFactors(*m_helpEngine, lastZoomFactors); + CollectionConfiguration::setLastZoomFactors(*d->m_helpEngine, lastZoomFactors); } const QString HelpEngineWrapper::cacheDir() const { TRACE_OBJ - return CollectionConfiguration::cacheDir(*m_helpEngine); + return CollectionConfiguration::cacheDir(*d->m_helpEngine); } bool HelpEngineWrapper::cacheDirIsRelativeToCollection() const { TRACE_OBJ - return CollectionConfiguration::cacheDirIsRelativeToCollection(*m_helpEngine); + return CollectionConfiguration::cacheDirIsRelativeToCollection(*d->m_helpEngine); } void HelpEngineWrapper::setCacheDir(const QString &cacheDir, bool relativeToCollection) { TRACE_OBJ - CollectionConfiguration::setCacheDir(*m_helpEngine, cacheDir, + CollectionConfiguration::setCacheDir(*d->m_helpEngine, cacheDir, relativeToCollection); } bool HelpEngineWrapper::filterFunctionalityEnabled() const { TRACE_OBJ - return CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine); + return CollectionConfiguration::filterFunctionalityEnabled(*d->m_helpEngine); } void HelpEngineWrapper::setFilterFunctionalityEnabled(bool enabled) { TRACE_OBJ - CollectionConfiguration::setFilterFunctionalityEnabled(*m_helpEngine, + CollectionConfiguration::setFilterFunctionalityEnabled(*d->m_helpEngine, enabled); } bool HelpEngineWrapper::filterToolbarVisible() const { TRACE_OBJ - return CollectionConfiguration::filterToolbarVisible(*m_helpEngine); + return CollectionConfiguration::filterToolbarVisible(*d->m_helpEngine); } void HelpEngineWrapper::setFilterToolbarVisible(bool visible) { TRACE_OBJ - CollectionConfiguration::setFilterToolbarVisible(*m_helpEngine, visible); + CollectionConfiguration::setFilterToolbarVisible(*d->m_helpEngine, visible); } bool HelpEngineWrapper::addressBarEnabled() const { TRACE_OBJ - return CollectionConfiguration::addressBarEnabled(*m_helpEngine); + return CollectionConfiguration::addressBarEnabled(*d->m_helpEngine); } void HelpEngineWrapper::setAddressBarEnabled(bool enabled) { TRACE_OBJ - CollectionConfiguration::setAddressBarEnabled(*m_helpEngine, enabled); + CollectionConfiguration::setAddressBarEnabled(*d->m_helpEngine, enabled); } bool HelpEngineWrapper::addressBarVisible() const { TRACE_OBJ - return CollectionConfiguration::addressBarVisible(*m_helpEngine); + return CollectionConfiguration::addressBarVisible(*d->m_helpEngine); } void HelpEngineWrapper::setAddressBarVisible(bool visible) { TRACE_OBJ - CollectionConfiguration::setAddressBarVisible(*m_helpEngine, visible); + CollectionConfiguration::setAddressBarVisible(*d->m_helpEngine, visible); } bool HelpEngineWrapper::documentationManagerEnabled() const { TRACE_OBJ - return CollectionConfiguration::documentationManagerEnabled(*m_helpEngine); + return CollectionConfiguration::documentationManagerEnabled(*d->m_helpEngine); } void HelpEngineWrapper::setDocumentationManagerEnabled(bool enabled) { TRACE_OBJ - CollectionConfiguration::setDocumentationManagerEnabled(*m_helpEngine, + CollectionConfiguration::setDocumentationManagerEnabled(*d->m_helpEngine, enabled); } const QByteArray HelpEngineWrapper::aboutMenuTexts() const { TRACE_OBJ - return CollectionConfiguration::aboutMenuTexts(*m_helpEngine); + return CollectionConfiguration::aboutMenuTexts(*d->m_helpEngine); } void HelpEngineWrapper::setAboutMenuTexts(const QByteArray &texts) { TRACE_OBJ - CollectionConfiguration::setAboutMenuTexts(*m_helpEngine, texts); + CollectionConfiguration::setAboutMenuTexts(*d->m_helpEngine, texts); } const QByteArray HelpEngineWrapper::aboutIcon() const { TRACE_OBJ - return CollectionConfiguration::aboutIcon(*m_helpEngine); + return CollectionConfiguration::aboutIcon(*d->m_helpEngine); } void HelpEngineWrapper::setAboutIcon(const QByteArray &icon) { TRACE_OBJ - CollectionConfiguration::setAboutIcon(*m_helpEngine, icon); + CollectionConfiguration::setAboutIcon(*d->m_helpEngine, icon); } const QByteArray HelpEngineWrapper::aboutImages() const { TRACE_OBJ - return CollectionConfiguration::aboutImages(*m_helpEngine); + return CollectionConfiguration::aboutImages(*d->m_helpEngine); } void HelpEngineWrapper::setAboutImages(const QByteArray &images) { TRACE_OBJ - CollectionConfiguration::setAboutImages(*m_helpEngine, images); + CollectionConfiguration::setAboutImages(*d->m_helpEngine, images); } const QByteArray HelpEngineWrapper::aboutTexts() const { TRACE_OBJ - return CollectionConfiguration::aboutTexts(*m_helpEngine); + return CollectionConfiguration::aboutTexts(*d->m_helpEngine); } void HelpEngineWrapper::setAboutTexts(const QByteArray &texts) { TRACE_OBJ - CollectionConfiguration::setAboutTexts(*m_helpEngine, texts); + CollectionConfiguration::setAboutTexts(*d->m_helpEngine, texts); } const QString HelpEngineWrapper::windowTitle() const { TRACE_OBJ - return CollectionConfiguration::windowTitle(*m_helpEngine); + return CollectionConfiguration::windowTitle(*d->m_helpEngine); } void HelpEngineWrapper::setWindowTitle(const QString &windowTitle) { TRACE_OBJ - CollectionConfiguration::setWindowTitle(*m_helpEngine, windowTitle); + CollectionConfiguration::setWindowTitle(*d->m_helpEngine, windowTitle); } const QByteArray HelpEngineWrapper::applicationIcon() const { TRACE_OBJ - return CollectionConfiguration::applicationIcon(*m_helpEngine); + return CollectionConfiguration::applicationIcon(*d->m_helpEngine); } void HelpEngineWrapper::setApplicationIcon(const QByteArray &icon) { TRACE_OBJ - CollectionConfiguration::setApplicationIcon(*m_helpEngine, icon); + CollectionConfiguration::setApplicationIcon(*d->m_helpEngine, icon); } const QByteArray HelpEngineWrapper::mainWindow() const { TRACE_OBJ - return m_helpEngine->customValue(MainWindowKey).toByteArray(); + return d->m_helpEngine->customValue(MainWindowKey).toByteArray(); } void HelpEngineWrapper::setMainWindow(const QByteArray &mainWindow) { TRACE_OBJ - m_helpEngine->setCustomValue(MainWindowKey, mainWindow); + d->m_helpEngine->setCustomValue(MainWindowKey, mainWindow); } const QByteArray HelpEngineWrapper::mainWindowGeometry() const { TRACE_OBJ - return m_helpEngine->customValue(MainWindowGeometryKey).toByteArray(); + return d->m_helpEngine->customValue(MainWindowGeometryKey).toByteArray(); } void HelpEngineWrapper::setMainWindowGeometry(const QByteArray &geometry) { TRACE_OBJ - m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry); + d->m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry); } const QByteArray HelpEngineWrapper::bookmarks() const { TRACE_OBJ - return m_helpEngine->customValue(BookmarksKey).toByteArray(); + return d->m_helpEngine->customValue(BookmarksKey).toByteArray(); } void HelpEngineWrapper::setBookmarks(const QByteArray &bookmarks) { TRACE_OBJ - m_helpEngine->setCustomValue(BookmarksKey, bookmarks); + d->m_helpEngine->setCustomValue(BookmarksKey, bookmarks); } int HelpEngineWrapper::lastTabPage() const { TRACE_OBJ - return CollectionConfiguration::lastTabPage(*m_helpEngine); + return CollectionConfiguration::lastTabPage(*d->m_helpEngine); } void HelpEngineWrapper::setLastTabPage(int lastPage) { TRACE_OBJ - CollectionConfiguration::setLastTabPage(*m_helpEngine, lastPage); + CollectionConfiguration::setLastTabPage(*d->m_helpEngine, lastPage); } bool HelpEngineWrapper::searchWasAttached() const { TRACE_OBJ - return m_helpEngine->customValue(SearchWasAttachedKey).toBool(); + return d->m_helpEngine->customValue(SearchWasAttachedKey).toBool(); } void HelpEngineWrapper::setSearchWasAttached(bool attached) { TRACE_OBJ - m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); + d->m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); } int HelpEngineWrapper::startOption() const { TRACE_OBJ - return m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt(); + return d->m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt(); } void HelpEngineWrapper::setStartOption(int option) { TRACE_OBJ - m_helpEngine->setCustomValue(StartOptionKey, option); + d->m_helpEngine->setCustomValue(StartOptionKey, option); } const QString HelpEngineWrapper::homePage() const { TRACE_OBJ - const QString &homePage = m_helpEngine->customValue(HomePageKey).toString(); + const QString &homePage + = d->m_helpEngine->customValue(HomePageKey).toString(); if (!homePage.isEmpty()) return homePage; return defaultHomePage(); @@ -543,129 +586,151 @@ const QString HelpEngineWrapper::homePage() const void HelpEngineWrapper::setHomePage(const QString &page) { TRACE_OBJ - m_helpEngine->setCustomValue(HomePageKey, page); + d->m_helpEngine->setCustomValue(HomePageKey, page); } const QString HelpEngineWrapper::defaultHomePage() const { TRACE_OBJ - return CollectionConfiguration::defaultHomePage(*m_helpEngine); + return CollectionConfiguration::defaultHomePage(*d->m_helpEngine); } void HelpEngineWrapper::setDefaultHomePage(const QString &page) { TRACE_OBJ - CollectionConfiguration::setDefaultHomePage(*m_helpEngine, page); + CollectionConfiguration::setDefaultHomePage(*d->m_helpEngine, page); } bool HelpEngineWrapper::hasFontSettings() const { TRACE_OBJ - return m_helpEngine->customValue(UseAppFontKey).isValid(); + return d->m_helpEngine->customValue(UseAppFontKey).isValid(); } bool HelpEngineWrapper::usesAppFont() const { TRACE_OBJ - return m_helpEngine->customValue(UseAppFontKey).toBool(); + return d->m_helpEngine->customValue(UseAppFontKey).toBool(); } void HelpEngineWrapper::setUseAppFont(bool useAppFont) { TRACE_OBJ - m_helpEngine->setCustomValue(UseAppFontKey, useAppFont); + d->m_helpEngine->setCustomValue(UseAppFontKey, useAppFont); } bool HelpEngineWrapper::usesBrowserFont() const { TRACE_OBJ - return m_helpEngine->customValue(UseBrowserFontKey, false).toBool(); + return d->m_helpEngine->customValue(UseBrowserFontKey, false).toBool(); } void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) { TRACE_OBJ - m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont); + d->m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont); } const QFont HelpEngineWrapper::appFont() const { TRACE_OBJ - return qVariantValue(m_helpEngine->customValue(AppFontKey)); + return qVariantValue(d->m_helpEngine->customValue(AppFontKey)); } void HelpEngineWrapper::setAppFont(const QFont &font) { TRACE_OBJ - m_helpEngine->setCustomValue(AppFontKey, font); + d->m_helpEngine->setCustomValue(AppFontKey, font); } QFontDatabase::WritingSystem HelpEngineWrapper::appWritingSystem() const { TRACE_OBJ return static_cast( - m_helpEngine->customValue(AppWritingSystemKey).toInt()); + d->m_helpEngine->customValue(AppWritingSystemKey).toInt()); } void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) { TRACE_OBJ - m_helpEngine->setCustomValue(AppWritingSystemKey, system); + d->m_helpEngine->setCustomValue(AppWritingSystemKey, system); } const QFont HelpEngineWrapper::browserFont() const { TRACE_OBJ - return qVariantValue(m_helpEngine->customValue(BrowserFontKey)); + return qVariantValue(d->m_helpEngine->customValue(BrowserFontKey)); } void HelpEngineWrapper::setBrowserFont(const QFont &font) { TRACE_OBJ - m_helpEngine->setCustomValue(BrowserFontKey, font); + d->m_helpEngine->setCustomValue(BrowserFontKey, font); } QFontDatabase::WritingSystem HelpEngineWrapper::browserWritingSystem() const { TRACE_OBJ return static_cast( - m_helpEngine->customValue(BrowserWritingSystemKey).toInt()); + d->m_helpEngine->customValue(BrowserWritingSystemKey).toInt()); } void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem system) { TRACE_OBJ - m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); + d->m_helpEngine->setCustomValue(BrowserWritingSystemKey, system); } -void HelpEngineWrapper::assertDocFilesWatched() +TimeoutForwarder::TimeoutForwarder(const QString &fileName) + : m_fileName(fileName) { TRACE_OBJ - Q_ASSERT(m_qchWatcher->files().count() - == m_helpEngine->registeredDocumentations().count()); } -TimeoutForwarder::TimeoutForwarder(const QString &fileName) - : m_fileName(fileName) +void TimeoutForwarder::forward() { TRACE_OBJ + HelpEngineWrapper::instance().d->qchFileChanged(m_fileName, true); } -void TimeoutForwarder::forward() + +HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile) + : m_helpEngine(new QHelpEngine(collectionFile, this)), + m_qchWatcher(new QFileSystemWatcher(this)) { TRACE_OBJ - HelpEngineWrapper::instance().qchFileChanged(m_fileName, true); + initFileSystemWatchers(); +} + +void HelpEngineWrapperPrivate::initFileSystemWatchers() +{ + TRACE_OBJ + foreach(const QString &ns, m_helpEngine->registeredDocumentations()) { + const QString &docFile = m_helpEngine->documentationFileName(ns); + m_qchWatcher->addPath(docFile); + connect(m_qchWatcher, SIGNAL(fileChanged(QString)), + this, SLOT(qchFileChanged(QString))); + } + assertDocFilesWatched(); } -void HelpEngineWrapper::qchFileChanged(const QString &fileName) +void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName) { TRACE_OBJ qchFileChanged(fileName, false); } -void HelpEngineWrapper::qchFileChanged(const QString &fileName, bool fromTimeout) +void HelpEngineWrapperPrivate::assertDocFilesWatched() +{ + TRACE_OBJ + Q_ASSERT(m_qchWatcher->files().count() + == m_helpEngine->registeredDocumentations().count()); +} + +void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName, + bool fromTimeout) { TRACE_OBJ @@ -731,4 +796,7 @@ void HelpEngineWrapper::qchFileChanged(const QString &fileName, bool fromTimeout m_recentQchUpdates.erase(it); } + QT_END_NAMESPACE + +#include "helpenginewrapper.moc" diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index 348479e..ea7b762 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -42,11 +42,8 @@ #ifndef HELPENGINEWRAPPER_H #define HELPENGINEWRAPPER_H -#include #include #include -#include -#include #include #include #include @@ -58,8 +55,6 @@ QT_BEGIN_NAMESPACE class QFileSystemWatcher; class QHelpContentModel; class QHelpContentWidget; -class QHelpEngine; -class QHelpEngineCore; class QHelpIndexModel; class QHelpIndexWidget; class QHelpSearchEngine; @@ -70,24 +65,14 @@ enum { ShowLastPages = 2 }; - -class TimeoutForwarder : public QObject -{ - Q_OBJECT -public: - TimeoutForwarder(const QString &fileName); -private slots: - void forward(); -private: - friend class HelpEngineWrapper; - - const QString m_fileName; -}; +class HelpEngineWrapperPrivate; +class TimeoutForwarder; class HelpEngineWrapper : public QObject { Q_OBJECT Q_DISABLE_COPY(HelpEngineWrapper) + friend class TimeoutForwarder; public: static HelpEngineWrapper &instance(const QString &collectionFile = QString()); static void removeInstance(); @@ -210,23 +195,13 @@ signals: void currentFilterChanged(const QString ¤tFilter); void setupFinished(); -private slots: - void qchFileChanged(const QString &fileName); - private: - friend class TimeoutForwarder; - HelpEngineWrapper(const QString &collectionFile); - void initFileSystemWatchers(); - void assertDocFilesWatched(); - void qchFileChanged(const QString &fileName, bool fromTimeout); + ~HelpEngineWrapper(); - static const int UpdateGracePeriod = 2000; static HelpEngineWrapper *helpEngineWrapper; - QHelpEngine * const m_helpEngine; - QFileSystemWatcher * const m_qchWatcher; - typedef QPair > RecentSignal; - QMap m_recentQchUpdates; + + HelpEngineWrapperPrivate *d; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index ce85854..dfee0fb 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -427,6 +427,6 @@ int main(int argc, char *argv[]) a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); const int retval = a.exec(); delete w; - delete &HelpEngineWrapper::instance(); + HelpEngineWrapper::removeInstance(); return retval; } -- cgit v0.12 From 22573ddffc28135fba2dbb9eb2d50a76cae0a09c Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 21 Dec 2009 14:23:21 +0100 Subject: Fixed gradients on text when coordinate mode != logical mode. Task-number: QTBUG-6395 Reviewed-by: Samuel --- src/gui/painting/qemulationpaintengine.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 662b163..5bd3c71 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -172,6 +172,36 @@ void QEmulationPaintEngine::drawTextItem(const QPointF &p, const QTextItem &text QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); fillBGRect(rect); } + + QPainterState *s = state(); + Qt::BrushStyle style = qbrush_style(s->pen.brush()); + if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) + { + QPen savedPen = s->pen; + QGradient g = *s->pen.brush().gradient(); + + if (g.coordinateMode() > QGradient::LogicalMode) { + QTransform mat = s->pen.brush().transform(); + if (g.coordinateMode() == QGradient::StretchToDeviceMode) { + mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); + } else if (g.coordinateMode() == QGradient::ObjectBoundingMode) { + const QTextItemInt &ti = static_cast(textItem); + QRectF r(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); + mat.translate(r.x(), r.y()); + mat.scale(r.width(), r.height()); + } + g.setCoordinateMode(QGradient::LogicalMode); + QBrush brush(g); + brush.setTransform(mat); + s->pen.setBrush(brush); + penChanged(); + real_engine->drawTextItem(p, textItem); + s->pen = savedPen; + penChanged(); + return; + } + } + real_engine->drawTextItem(p, textItem); } -- cgit v0.12 From 875afab977005b03d307040fb3be15c7524a37ff Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 18 Dec 2009 11:14:29 +0100 Subject: Cocoa: added release pool Fix warning given by cocoa --- src/gui/kernel/qwidget_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 34a9eed..7bdf745 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3671,6 +3671,7 @@ void QWidgetPrivate::raise_sys() return; #if QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; if (isRealWindow()) { // Calling orderFront shows the window on Cocoa too. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { -- cgit v0.12 From 464306df827cbf3378f72f9aead0448a32ab5a21 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 9 Dec 2009 15:30:10 +0100 Subject: Cocoa: event dispatcher drops events on the floor Under some circumstances, the event dispatcher needs to stop NSApplication, let the control return back to the QEventLoop that called processEvents, which very often will just call processEvents again, which in turn will restart NSApplication. After stopping NSApplication, Cocoa seems to throw away at least some of the posted cocoa events that are still pending. This will offcourse have inpact on things like window updates etc. that never happends. This patch will be more careful about when to stop NSApplication, and delay this until the run loop has finished one more spin after interrupt has been called. The same goes for modal sessions. Introducing this delay also made it neccessary to sometimes block cocoa from updating the stacking order of the windows. Autotest: qcoreapplication, qapplication, qtimer --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 34 ++ src/gui/kernel/qeventdispatcher_mac.mm | 397 +++++++++++++---------- src/gui/kernel/qeventdispatcher_mac_p.h | 9 +- src/gui/kernel/qwidget_mac.mm | 47 ++- 4 files changed, 293 insertions(+), 194 deletions(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index cc5839c..7661b89 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm extern QPointer qt_button_down; //qapplication_mac.cpp extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp +extern bool qt_blockCocoaSettingModalWindowLevel; // qeventdispatcher_mac_p.h Q_GLOBAL_STATIC(QPointer, currentDragTarget); @@ -88,6 +89,39 @@ QT_END_NAMESPACE return !(isPopup || isToolTip); } +- (BOOL)canBecomeMainWindow +{ + QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; + + bool isToolTip = (widget->windowType() == Qt::ToolTip); + bool isPopup = (widget->windowType() == Qt::Popup); + return !(isPopup || isToolTip); +} + +- (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber +{ + if (qt_blockCocoaSettingModalWindowLevel) { + // To avoid windows popping in front while restoring modal sessions + // in the event dispatcher, we block cocoa from ordering this window + // to front. The result of not doing this can be seen if executing + // a native color dialog on top of another executing dialog. + return; + } + [super orderWindow:orderingMode relativeTo:otherWindowNumber]; +} + +- (void)setLevel:(NSInteger)windowLevel +{ + if (qt_blockCocoaSettingModalWindowLevel) { + // To avoid windows popping in front while restoring modal sessions + // in the event dispatcher, we block cocoa from ordering this window + // to front. The result of not doing this can be seen if executing + // a native color dialog on top of another executing dialog. + return; + } + [super setLevel:windowLevel]; +} + - (void)toggleToolbarShown:(id)sender { macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]); diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index e0eebfd..0b48dca 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -90,11 +90,16 @@ #ifndef QT_NO_THREAD # include "qmutex.h" +#endif QT_BEGIN_NAMESPACE QT_USE_NAMESPACE -#endif + +/***************************************************************************** + Internal variables and functions + *****************************************************************************/ +bool qt_blockCocoaSettingModalWindowLevel = false; /***************************************************************************** Externals @@ -540,6 +545,12 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherMac); d->interrupt = false; + +#ifdef QT_MAC_USE_COCOA + bool interruptLater = false; + QtMacInterruptDispatcherHelp::cancelInterruptLater(); +#endif + // In case we end up recursing while we now process events, make sure // that we send remaining posted Qt events before this call returns: wakeUp(); @@ -554,25 +565,26 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) QMacCocoaAutoReleasePool pool; NSEvent* event = 0; - // If Qt is used as a plugin, or just added into a native cocoa - // application, we should not run or stop NSApplication; - // This will be done from outside Qt. - // And if processEvents is called manually (rather than from QEventLoop), we - // cannot enter a tight loop and block the call, but instead return after one flush: + // If Qt is used as a plugin, or as an extension in a native cocoa + // application, we should not run or stop NSApplication; This will be + // done from the application itself. And if processEvents is called + // manually (rather than from a QEventLoop), we cannot enter a tight + // loop and block this call, but instead we need to return after one flush: bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning]; bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec; if (canExec_Qt && canExec_3rdParty) { // We can use exec-mode, meaning that we can stay in a tight loop until - // interrupted. This is mostly an optimization, but it also allow us - // to use [NSApp run], which is the recommended way of running applications - // in cocoa. [NSApp run] should be called at least once for any cocoa app. + // interrupted. This is mostly an optimization, but it allow us to use + // [NSApp run], which is the normal code path for cocoa applications. if (NSModalSession session = d->currentModalSession()) { QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); - while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse) + + while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) qt_mac_waitForMoreModalSessionEvents(); + if (!d->interrupt && session == d->currentModalSessionCached) { - // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event + // Someone called [NSApp stopModal:] from outside the event // dispatcher (e.g to stop a native dialog). But that call wrongly stopped // 'session' as well. As a result, we need to restart all internal sessions: d->temporarilyStopAllModalSessions(); @@ -583,54 +595,62 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) [NSApp run]; } retVal = true; - } else do { - // INVARIANT: We cannot block the thread (and run in a tight loop). - // Instead we will process all current pending events and return. - bool mustRelease = false; - - if (!(flags & QEventLoop::ExcludeUserInputEvents) && !d->queuedUserInputEvents.isEmpty()) { - // Process a pending user input event - mustRelease = true; - event = static_cast(d->queuedUserInputEvents.takeFirst()); - } else { - if (NSModalSession session = d->currentModalSession()) { - if (flags & QEventLoop::WaitForMoreEvents) - qt_mac_waitForMoreModalSessionEvents(); - NSInteger status = [NSApp runModalSession:session]; - if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) { - // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event - // dispatcher (e.g to stop a native dialog). But that call wrongly stopped - // 'session' as well. As a result, we need to restart all internal sessions: - d->temporarilyStopAllModalSessions(); - } - retVal = true; - break; + } else { + do { + // We cannot block the thread (and run in a tight loop). + // Instead we will process all current pending events and return. + bool releaseEvent = false; + + if (!(flags & QEventLoop::ExcludeUserInputEvents) + && !d->queuedUserInputEvents.isEmpty()) { + // Process a pending user input event + releaseEvent = true; + event = static_cast(d->queuedUserInputEvents.takeFirst()); } else { - event = [NSApp nextEventMatchingMask:NSAnyEventMask - untilDate:nil - inMode:NSDefaultRunLoopMode - dequeue: YES]; - - if (event != nil) { - if (flags & QEventLoop::ExcludeUserInputEvents) { - if (IsMouseOrKeyEvent(event)) { - // retain event here? - [event retain]; - d->queuedUserInputEvents.append(event); - continue; + if (NSModalSession session = d->currentModalSession()) { + if (flags & QEventLoop::WaitForMoreEvents) + qt_mac_waitForMoreModalSessionEvents(); + NSInteger status = [NSApp runModalSession:session]; + if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) { + // INVARIANT: Someone called [NSApp stopModal:] from outside the event + // dispatcher (e.g to stop a native dialog). But that call wrongly stopped + // 'session' as well. As a result, we need to restart all internal sessions: + d->temporarilyStopAllModalSessions(); + } + retVal = true; + break; + } else { + event = [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:nil + inMode:NSDefaultRunLoopMode + dequeue: YES]; + + if (event != nil) { + if (flags & QEventLoop::ExcludeUserInputEvents) { + if (IsMouseOrKeyEvent(event)) { + [event retain]; + d->queuedUserInputEvents.append(event); + continue; + } } } } } - } - if (event) { - if (!filterEvent(event) && qt_mac_send_event(flags, event, 0)) - retVal = true; - if (mustRelease) - [event release]; - } - } while(!d->interrupt && event != nil); - + if (event) { + if (!filterEvent(event) && qt_mac_send_event(flags, event, 0)) + retVal = true; + if (releaseEvent) + [event release]; + } + } while (!d->interrupt && event != nil); + + // Since the window that holds modality might have changed while processing + // events, we we need to interrupt when we return back the previous process + // event recursion to ensure that we spin the correct modal session. + // We do the interruptLater at the end of the function to ensure that we don't + // disturb the 'wait for more events' below (as deleteLater will post an event): + interruptLater = true; + } #else do { EventRef event; @@ -682,25 +702,19 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) } } + // If we're interrupted, we need to interrupt the _current_ + // recursion as well to check if it is still supposed to be + // executing. This way we wind down the stack until we land + // on a recursion that again calls processEvents (typically + // from QEventLoop), and set interrupt to false: + if (d->interrupt) + interrupt(); + #ifdef QT_MAC_USE_COCOA - // In case we _now_ process events using [NSApp run], we need to stop it to - // ensure that: - // 1. the QEventLoop that called us is still executing, or - // 2. we have a modal session that needs to be spun instead. - // In case this is a plain call to processEvents (perhaps from a loop) - // from the application (rather than from a QEventLoop), we delay the - // interrupting until we/ actually enter a lower loop level (hence the - // deffered delete of the object below): - QtMacInterruptDispatcherHelp::interruptLater(); + if (interruptLater) + QtMacInterruptDispatcherHelp::interruptLater(); #endif - if (d->interrupt) { - // We should continue to leave all recursion to processEvents until - // processEvents is called again (e.g. from a QEventLoop that - // was not yet told to quit: - interrupt(); - } - return retVal; } @@ -733,35 +747,45 @@ bool QEventDispatcherMacPrivate::blockSendPostedEvents = false; #ifdef QT_MAC_USE_COCOA QStack QEventDispatcherMacPrivate::cocoaModalSessionStack; bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false; +bool QEventDispatcherMacPrivate::modalSessionsTemporarilyStopped = false; bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false; +bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false; NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0; -int QEventDispatcherMacPrivate::activeModalSessionCount() +void QEventDispatcherMacPrivate::flushCocoaEvents() { - // Returns the number of modal sessions created - // (and not just pushed onto the stack, pending to be created) - int count = 0; - for (int i=cocoaModalSessionStack.size()-1; i>=0; --i) { - QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; - if (info.session) - ++count; + while (NSEvent *event = [NSApp nextEventMatchingMask:0 + untilDate:nil + inMode:NSDefaultRunLoopMode + dequeue: YES]) { + qt_mac_send_event(0, event, 0); } - return count; } void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions() { - // Stop all created modal session, and as such, make then - // pending again. The next call to currentModalSession will - // recreate the session on top again: + // Flush, and Stop, all created modal session, and as + // such, make them pending again. The next call to + // currentModalSession will recreate them again. The + // reason to stop all session like this is that otherwise + // a call [NSApp stop] would not stop NSApp, but rather + // the current modal session. So if we need to stop NSApp + // we need to stop all the modal session first. To avoid changing + // the stacking order of the windows while doing so, we put + // up a block that is used in QCocoaWindow and QCocoaPanel: + QBoolBlocker block1(blockSendPostedEvents, true); + QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true); + int stackSize = cocoaModalSessionStack.size(); for (int i=stackSize-1; i>=0; --i) { QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; if (info.session) { + [NSApp runModalSession:info.session]; [NSApp endModalSession:info.session]; info.session = 0; } } + modalSessionsTemporarilyStopped = true; currentModalSessionCached = 0; } @@ -775,23 +799,6 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession() if (cocoaModalSessionStack.isEmpty()) return 0; - // Since this code will end up calling our Qt event handler - // (also from beginModalSessionForWindow), we need to block - // that to avoid side effects of events beeing delivered: - QBoolBlocker block(blockSendPostedEvents, true); - - if (![NSApp isRunning]) { - // Sadly, we need to introduce this little event flush - // to stop dialogs from blinking/poping in front if a - // modal session restart was needed: - while (NSEvent *event = [NSApp nextEventMatchingMask:0 - untilDate:nil - inMode:NSDefaultRunLoopMode - dequeue: YES]) { - qt_mac_send_event(0, event, 0); - } - } - int sessionCount = cocoaModalSessionStack.size(); for (int i=0; i=0; --i) { + QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; + if (info.widget) { + currentModalSessionCached = info.session; + break; + } + cocoaModalSessionStack.remove(i); + currentModalSessionCached = 0; + if (info.session) + [NSApp endModalSession:info.session]; + } + + updateChildrenWorksWhenModal(); + cleanupModalSessionsNeeded = false; +} + void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget) { // Add a new, empty (null), NSModalSession to the stack. @@ -852,7 +903,7 @@ void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget) // is non-zero, and the session pointer is zero (it will become active upon a call to // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if // the widget pointer is zero, and the session pointer is non-zero (it will be fully - // stopped in endModalSession(). + // stopped in cleanupModalSessions()). QCocoaModalSessionInfo info = {widget, 0}; cocoaModalSessionStack.push(info); updateChildrenWorksWhenModal(); @@ -869,32 +920,16 @@ void QEventDispatcherMacPrivate::endModalSession(QWidget *widget) int stackSize = cocoaModalSessionStack.size(); for (int i=stackSize-1; i>=0; --i) { QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; - if (info.widget == widget) + if (info.widget == widget) { info.widget = 0; - } - - // Now we stop, and remove, all sessions marked as pending - // to be stopped on _top_ of the stack, if any: - bool needToInterruptEventDispatcher = false; - bool needToUpdateChildrenWorksWhenModal = false; - - for (int i=stackSize-1; i>=0; --i) { - QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; - if (info.widget) - break; - cocoaModalSessionStack.remove(i); - needToUpdateChildrenWorksWhenModal = true; - currentModalSessionCached = 0; - if (info.session) { - [NSApp endModalSession:info.session]; - needToInterruptEventDispatcher = true; + if (i == stackSize-1) { + // The top sessions ended. Interrupt the event dispatcher + // to start spinning the correct session immidiatly: + cleanupModalSessionsNeeded = true; + QEventDispatcherMac::instance()->interrupt(); + } } } - - if (needToUpdateChildrenWorksWhenModal) - updateChildrenWorksWhenModal(); - if (needToInterruptEventDispatcher) - QEventDispatcherMac::instance()->interrupt(); } #endif @@ -959,13 +994,39 @@ Boolean QEventDispatcherMacPrivate::postedEventSourceEqualCallback(const void *i inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents) { - if (blockSendPostedEvents || d->interrupt) { + if (blockSendPostedEvents) { + // We're told to not send posted events (because the event dispatcher + // is currently working on setting up the correct session to run). But + // we still need to make sure that we don't fall asleep until pending events + // are sendt, so we just signal this need, and return: CFRunLoopSourceSignal(d->postedEventsSource); - } else { - if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { - d->lastSerial = d->serialNumber; - QApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + return; + } + +#ifdef QT_MAC_USE_COCOA + if (d->cleanupModalSessionsNeeded) + d->cleanupModalSessions(); +#endif + + if (d->interrupt) { +#ifdef QT_MAC_USE_COCOA + if (d->currentExecIsNSAppRun) { + // The event dispatcher has been interrupted. But since + // [NSApplication run] is running the event loop, we + // delayed stopping it until now (to let cocoa process + // pending cocoa events first). + if (d->currentModalSessionCached) + d->temporarilyStopAllModalSessions(); + [NSApp stop:NSApp]; + d->cancelWaitForMoreEvents(); } +#endif + return; + } + + if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { + d->lastSerial = d->serialNumber; + QApplicationPrivate::sendPostedEvents(0, 0, d->threadData); } } @@ -983,6 +1044,19 @@ void QEventDispatcherMacPrivate::postedEventsSourcePerformCallback(void *info) processPostedEvents(static_cast(info), blockSendPostedEvents); } +#ifdef QT_MAC_USE_COCOA +void QEventDispatcherMacPrivate::cancelWaitForMoreEvents() +{ + // In case the event dispatcher is waiting for more + // events somewhere, we post a dummy event to wake it up: + QMacCocoaAutoReleasePool pool; + static const short NSAppShouldStopForQt = SHRT_MAX; + [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint + modifierFlags:0 timestamp:0. windowNumber:0 context:0 + subtype:NSAppShouldStopForQt data1:0 data2:0] atStart:NO]; +} +#endif + void QEventDispatcherMac::interrupt() { Q_D(QEventDispatcherMac); @@ -992,20 +1066,14 @@ void QEventDispatcherMac::interrupt() #ifndef QT_MAC_USE_COCOA CFRunLoopStop(mainRunLoop()); #else - QMacCocoaAutoReleasePool pool; - // In case we wait for more events inside - // processEvents (or NSApp run), post a dummy to wake it up: - static const short NSAppShouldStopForQt = SHRT_MAX; - [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint - modifierFlags:0 timestamp:0. windowNumber:0 context:0 - subtype:NSAppShouldStopForQt data1:0 data2:0] atStart:NO]; - - if (d->activeModalSessionCount() == 0) { - // We should only stop NSApp if we actually started it (and - // not some 3rd party application, e.g. if we are a plugin). - if (d->nsAppRunCalledByQt) - [NSApp stop:NSApp]; - } + // We do nothing more here than setting d->interrupt = true, and + // poke the event loop if it is sleeping. Actually stopping + // NSApp, or the current modal session, is done inside the send + // posted events callback. We do this to ensure that all current pending + // cocoa events gets delivered before we stop. Otherwise, if we now stop + // the last event loop recursion, cocoa will just drop pending posted + // events on the floor before we get a chance to reestablish a new session. + d->cancelWaitForMoreEvents(); #endif } @@ -1046,17 +1114,18 @@ QEventDispatcherMac::~QEventDispatcherMac() CFRelease(d->firstTimeObserver); } -///////////////////////////////////////////////////////////////////////////// - #ifdef QT_MAC_USE_COCOA QtMacInterruptDispatcherHelp* QtMacInterruptDispatcherHelp::instance = 0; QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false) { - // This is the whole point of encapsulation this code - // inside a class; we can make the code (inside destructor) - // execute on lower loop level: + // The whole point of this class is that we enable a way to interrupt + // the event dispatcher when returning back to a lower recursion level + // than where interruptLater was called. This is needed to detect if + // [NSApp run] should still be running at the recursion level it is at. + // Since the interrupt is canceled if processEvents is called before + // this object gets deleted, we also avoid interrupting unnecessary. deleteLater(); } @@ -1064,34 +1133,26 @@ QtMacInterruptDispatcherHelp::~QtMacInterruptDispatcherHelp() { if (cancelled) return; - instance = 0; - - if (QEventDispatcherMacPrivate::currentExecIsNSAppRun) { - int activeCount = QEventDispatcherMacPrivate::activeModalSessionCount(); - if (activeCount > 0) { - // The problem we now have hit: [NSApp stop] will not stop NSApp - // if a session is active; it will stop the session instead. - // So to stop NSApp, we need to temporarily stop all the - // sessions, then stop NSApp, then restart the session on top again. - // We need to do this to ensure that we're not stuck inside - // [NSApp run] when we really should be running a modal session: - QEventDispatcherMacPrivate::temporarilyStopAllModalSessions(); - } - } - // Always interrupt once more in case the modal session stack changed - // while processEvents was called manually from within the application: QEventDispatcherMac::instance()->interrupt(); } -void QtMacInterruptDispatcherHelp::interruptLater() { - if (instance) { - instance->cancelled = true; - delete instance; - } +void QtMacInterruptDispatcherHelp::cancelInterruptLater() +{ + if (!instance) + return; + instance->cancelled = true; + delete instance; + instance = 0; +} + +void QtMacInterruptDispatcherHelp::interruptLater() +{ + cancelInterruptLater(); instance = new QtMacInterruptDispatcherHelp; } #endif QT_END_NAMESPACE + diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h index dfcb91f..37ee2b1 100644 --- a/src/gui/kernel/qeventdispatcher_mac_p.h +++ b/src/gui/kernel/qeventdispatcher_mac_p.h @@ -174,13 +174,17 @@ public: static QStack cocoaModalSessionStack; static bool currentExecIsNSAppRun; static bool nsAppRunCalledByQt; + static bool cleanupModalSessionsNeeded; + static bool modalSessionsTemporarilyStopped; static NSModalSession currentModalSessionCached; - static void updateChildrenWorksWhenModal(); static NSModalSession currentModalSession(); - static int activeModalSessionCount(); + static void updateChildrenWorksWhenModal(); static void temporarilyStopAllModalSessions(); static void beginModalSession(QWidget *widget); static void endModalSession(QWidget *widget); + static void cancelWaitForMoreEvents(); + static void cleanupModalSessions(); + static void flushCocoaEvents(); #endif MacSocketHash macSockets; @@ -211,6 +215,7 @@ class QtMacInterruptDispatcherHelp : public QObject public: static void interruptLater(); + static void cancelInterruptLater(); }; #endif diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 7bdf745..63afb0d 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3309,13 +3309,23 @@ void QWidgetPrivate::show_sys() #else // sync the opacity value back (in case of a fade). [window setAlphaValue:q->windowOpacity()]; - [window makeKeyAndOrderFront:window]; - // If this window is app modal, we need to start spinning - // a modal session for it. Interrupting - // the event dispatcher will make this happend: - if (data.window_modality == Qt::ApplicationModal) - QEventDispatcherMac::instance()->interrupt(); + QWidget *top = 0; + if (QApplicationPrivate::tryModalHelper(q, &top)) { + [window makeKeyAndOrderFront:window]; + // If this window is app modal, we need to start spinning + // a modal session for it. Interrupting + // the event dispatcher will make this happend: + if (data.window_modality == Qt::ApplicationModal) + QEventDispatcherMac::instance()->interrupt(); + } else { + // The window is modally shaddowed, so we need to make + // sure that we don't pop in front of the modal window: + [window orderFront:window]; + if (NSWindow *modalWin = qt_mac_window_for(top)) + [modalWin orderFront:window]; + } + #endif if (q->windowType() == Qt::Popup) { if (q->focusWidget()) @@ -3334,8 +3344,6 @@ void QWidgetPrivate::show_sys() } else if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) { #ifndef QT_MAC_USE_COCOA qt_event_request_activate(q); -#else - [qt_mac_window_for(q) makeKeyWindow]; #endif } } else if(topData()->embedded || !q->parentWidget() || q->parentWidget()->isVisible()) { @@ -3411,12 +3419,15 @@ void QWidgetPrivate::hide_sys() } #endif } - if(q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { +#ifndef QT_MAC_USE_COCOA + // If the window we now hide was the active window, we need + // to find, and activate another window on screen. NB: Cocoa takes care of this + // logic for us (and distinquishes between main windows and key windows) + if (q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { QWidget *w = 0; if(q->parentWidget()) w = q->parentWidget()->window(); if(!w || (!w->isVisible() && !w->isMinimized())) { -#ifndef QT_MAC_USE_COCOA for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true); wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) { if((w = qt_mac_find_window(wp))) @@ -3436,24 +3447,12 @@ void QWidgetPrivate::hide_sys() break; } } -#else - NSArray *windows = [NSApp windows]; - NSUInteger totalWindows = [windows count]; - for (NSUInteger i = 0; i < totalWindows; ++i) { - OSWindowRef wp = [windows objectAtIndex:i]; - if ((w = qt_mac_find_window(wp))) - break; - } -#endif } if(w && w->isVisible() && !w->isMinimized()) { -#ifndef QT_MAC_USE_COCOA - qt_event_request_activate(w); -#else - [qt_mac_window_for(w) makeKeyWindow]; -#endif + qt_event_request_activate(w); } } +#endif } else { invalidateBuffer(q->rect()); #ifndef QT_MAC_USE_COCOA -- cgit v0.12 From ef5291b0fd521b7f22169ebc2297f720120296d6 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 22 Dec 2009 14:57:46 +0100 Subject: Doc: remove obsolete Win9x stuff from the documentation Merge-request: 1627 Reviewed-by: Joerg Bornemann --- doc/src/frameworks-technologies/activeqt-server.qdoc | 7 +------ doc/src/howtos/timers.qdoc | 2 +- doc/src/internationalization/i18n.qdoc | 3 --- doc/src/platforms/platform-notes.qdoc | 8 -------- doc/src/porting/porting4.qdoc | 9 ++++----- 5 files changed, 6 insertions(+), 23 deletions(-) diff --git a/doc/src/frameworks-technologies/activeqt-server.qdoc b/doc/src/frameworks-technologies/activeqt-server.qdoc index 89456bf..ccf8c83 100644 --- a/doc/src/frameworks-technologies/activeqt-server.qdoc +++ b/doc/src/frameworks-technologies/activeqt-server.qdoc @@ -99,10 +99,6 @@ \o Register the server \endlist - Note that the QAxServer build system is not supported on Windows 98/ME - (attaching of resources to a binary is not possible there), but a server - built on Windows NT/2000/XP will work on previous Windows versions as well. - To skip the post-processing step, also set the \c qaxserver_no_postlink configuration. @@ -413,8 +409,7 @@ \footnote OLE needs to marshal user defined types by reference (ByRef), and cannot marshal them by value (ByVal). This is why const-references and object - parameters are not supported for QRect, QSize and QPoint. Also note that - servers with this datatype require Windows 98 or DCOM 1.2 to be installed. + parameters are not supported for QRect, QSize and QPoint. \endfootnote \o [in, out] struct QRect (user defined) \row diff --git a/doc/src/howtos/timers.qdoc b/doc/src/howtos/timers.qdoc index 85902be..189f1c3 100644 --- a/doc/src/howtos/timers.qdoc +++ b/doc/src/howtos/timers.qdoc @@ -72,7 +72,7 @@ The upper limit for the interval value is determined by the number of milliseconds that can be specified in a signed integer (in practice, this is a period of just over 24 days). The accuracy - depends on the underlying operating system. Windows 98 has 55 + depends on the underlying operating system. Windows 2000 has 15 millisecond accuracy; other systems that we have tested can handle 1 millisecond intervals. diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index ecc25fe..94717db 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -512,9 +512,6 @@ Note that some Windows programs do not understand big-endian Unicode text files even though that is the order prescribed by the Unicode Standard in the absence of higher-level protocols. - \o Unlike programs written with MFC or plain winlib, Qt programs - are portable between Windows 98 and Windows NT. - \e {You do not need different binaries to support Unicode.} \endlist \section2 Mac OS X diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 85b9ff8..a1d3e9a 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -263,14 +263,6 @@ Install Qt into a subdirectory without spaces to avoid this problem. - \section2 AccelGALAXY graphic card - - When you use a NT 4.0 machine with the driver number - 4,00,1381,1000,021,4.0.0 there is a problem with drag an drop and icons. - The computer freezes, and you have to reset. The problem disappears with - the newest version of the driver, available at - \l{http://www.es.com/}{www.es.com}. - \section2 Possible GL conflict There is a known issue with running Microsoft NetMeeting, Lotus SameTime diff --git a/doc/src/porting/porting4.qdoc b/doc/src/porting/porting4.qdoc index 20fd8a6..bc49b48 100644 --- a/doc/src/porting/porting4.qdoc +++ b/doc/src/porting/porting4.qdoc @@ -3793,11 +3793,10 @@ multimedia timer API, which gives us 1 millisecond resolution for QTimer. - Note that other versions of Windows have a lower timer resolution, - and that code relying on underlying system timer restrictions - encounters no such limitations using Qt 4 (e.g., setting an - interval of 0 millisecond results in Qt occupying all of the - processor time when no GUI events need processing). + Note that Windows 2000 has a lower timer resolution, and that code relying + on underlying system timer restrictions encounters no such limitations + using Qt 4 (e.g., setting an interval of 0 millisecond results in Qt + occupying all of the processor time when no GUI events need processing). \section1 QToolBar -- cgit v0.12 From e60dbc9ca47a0e9371d619b7c5d24a4b3ec4fcd9 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 22 Dec 2009 14:57:59 +0100 Subject: fix small leftovers from the Win9x removal in the code LoadLibraryW -> LoadLibrary RegOpenKeyExW -> RegOpenKeyEx qdesktopservices_win.cpp: buffer size fixed in launchWebBrowser() Windows NT 4.0 version condition removed Merge-request: 1627 Reviewed-by: Joerg Bornemann --- bin/syncqt | 3 --- src/corelib/io/qfsfileengine_win.cpp | 15 +++++++-------- src/gui/dialogs/qfiledialog_win.cpp | 7 +------ src/gui/text/qfontdatabase_win.cpp | 1 - src/gui/util/qdesktopservices_win.cpp | 14 +++++++------- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index e19018c..13e792b 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -578,9 +578,6 @@ while ( @ARGV ) { } elsif("$arg" eq "-show") { $var = "showonly"; $val = "yes"; - } elsif("$arg" eq '*') { - # workaround for windows 9x where "%*" expands to "*" - $var = 1; } #do something diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 10a7c54..36cf67b 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -177,7 +177,7 @@ void QFSFileEnginePrivate::resolveLibs() triedResolve = true; #if !defined(Q_OS_WINCE) - HINSTANCE advapiHnd = LoadLibraryW(L"advapi32"); + HINSTANCE advapiHnd = LoadLibrary(L"advapi32"); if (advapiHnd) { ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); @@ -209,7 +209,7 @@ void QFSFileEnginePrivate::resolveLibs() ptrFreeSid(pWorld); } } - HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); + HINSTANCE userenvHnd = LoadLibrary(L"userenv"); if (userenvHnd) ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); #endif @@ -217,7 +217,6 @@ void QFSFileEnginePrivate::resolveLibs() } #endif // QT_NO_LIBRARY -// UNC functions NT typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); static PtrNetShareEnum ptrNetShareEnum = 0; typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID); @@ -241,7 +240,7 @@ bool QFSFileEnginePrivate::resolveUNCLibs() #endif triedResolve = true; #if !defined(Q_OS_WINCE) - HINSTANCE hLib = LoadLibraryW(L"Netapi32"); + HINSTANCE hLib = LoadLibrary(L"netapi32"); if (hLib) { ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); if (ptrNetShareEnum) @@ -1038,11 +1037,11 @@ QString QFSFileEngine::homePath() if (ok) { DWORD dwBufferSize = 0; // First call, to determine size of the strings (with '\0'). - ok = ::ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); + ok = ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); if (!ok && dwBufferSize != 0) { // We got the required buffer size wchar_t *userDirectory = new wchar_t[dwBufferSize]; // Second call, now we can fill the allocated buffer. - ok = ::ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); + ok = ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); if (ok) ret = QString::fromWCharArray(userDirectory); @@ -1414,7 +1413,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const QAbstractFileEngine::FileFlags ret = 0; #if !defined(QT_NO_LIBRARY) - if((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { + if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { PSID pOwner = 0; PSID pGroup = 0; PACL pDacl; @@ -1721,7 +1720,7 @@ QString QFSFileEngine::owner(FileOwner own) const { #if !defined(QT_NO_LIBRARY) Q_D(const QFSFileEngine); - if((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { + if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { PSID pOwner = 0; PSECURITY_DESCRIPTOR pSD; QString name; diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index c74f622..6128a8a 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -85,11 +85,6 @@ static const CLSID QT_CLSID_FileOpenDialog = {0xdc1c5a9c, 0xe88a, 0x4dde, {0xa5, #endif -// Don't remove the lines below! -// -// resolving the W methods manually is needed, because Windows 95 doesn't include -// these methods in Shell32.lib (not even stubs!), so you'd get an unresolved symbol -// when Qt calls getExistingDirectory(), etc. typedef LPITEMIDLIST (WINAPI *PtrSHBrowseForFolder)(BROWSEINFO*); static PtrSHBrowseForFolder ptrSHBrowseForFolder = 0; typedef BOOL (WINAPI *PtrSHGetPathFromIDList)(LPITEMIDLIST,LPWSTR); @@ -125,7 +120,7 @@ static void qt_win_resolve_libs() ptrSHGetMalloc = (PtrSHGetMalloc) lib.resolve("SHGetMalloc"); #else // CE stores them in a different lib and does not use unicode version - HINSTANCE handle = LoadLibraryW(L"Ceshell"); + HINSTANCE handle = LoadLibrary(L"Ceshell"); ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder"); ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList"); ptrSHGetMalloc = (PtrSHGetMalloc)GetProcAddress(handle, L"SHGetMalloc"); diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp index 6cde9ed..2fe1196 100644 --- a/src/gui/text/qfontdatabase_win.cpp +++ b/src/gui/text/qfontdatabase_win.cpp @@ -1101,7 +1101,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) if (AddFontResource((LPCWSTR)fnt->fileName.utf16()) == 0) return; #else - // supported from 2000 on, so no need to deal with the *A variant PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QLibrary::resolve(QLatin1String("gdi32"), "AddFontResourceExW"); if (!ptrAddFontResourceExW diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp index 39443f2..e4c99a8 100644 --- a/src/gui/util/qdesktopservices_win.cpp +++ b/src/gui/util/qdesktopservices_win.cpp @@ -97,19 +97,19 @@ static bool launchWebBrowser(const QUrl &url) if (url.scheme() == QLatin1String("mailto")) { //Retrieve the commandline for the default mail client //the default key used below is the command line for the mailto: shell command - DWORD bufferSize = 2 * MAX_PATH; + DWORD bufferSize = sizeof(wchar_t) * MAX_PATH; long returnValue = -1; QString command; HKEY handle; LONG res; - wchar_t keyValue[2 * MAX_PATH] = {0}; + wchar_t keyValue[MAX_PATH] = {0}; QString keyName(QLatin1String("mailto")); //Check if user has set preference, otherwise use default. - res = RegOpenKeyExW(HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", - 0, KEY_READ, &handle); + res = RegOpenKeyEx(HKEY_CURRENT_USER, + L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", + 0, KEY_READ, &handle); if (res == ERROR_SUCCESS) { returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast(keyValue), &bufferSize); if (!returnValue) @@ -121,8 +121,8 @@ static bool launchWebBrowser(const QUrl &url) if (res != ERROR_SUCCESS) return false; - bufferSize = 2 * MAX_PATH; - returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast(keyValue), &bufferSize); + bufferSize = sizeof(wchar_t) * MAX_PATH; + returnValue = RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast(keyValue), &bufferSize); if (!returnValue) command = QString::fromRawData((QChar*)keyValue, bufferSize); RegCloseKey(handle); -- cgit v0.12 From c5e5998bec4aafca555543d1ef3c335f7b280294 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 22 Dec 2009 14:58:03 +0100 Subject: remove obsolete QT_WA/QT_WA_INLINE macros Merge-request: 1627 Reviewed-by: Joerg Bornemann --- src/corelib/global/qglobal.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1f0b80c..5851d26 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1540,9 +1540,6 @@ inline QT3_SUPPORT bool qt_winUnicode() { return true; } inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; } #endif -#define QT_WA(unicode, ansi) unicode -#define QT_WA_INLINE(unicode, ansi) (unicode) - #endif /* Q_WS_WIN */ #ifndef Q_OUTOFLINE_TEMPLATE -- cgit v0.12 From 4376f8871b4422830e9ffb7f3acbc29766d8d218 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 23 Dec 2009 14:41:58 +0100 Subject: Revert "remove obsolete QT_WA/QT_WA_INLINE macros" To be on the safe side wrt source compatibilty, we'll postpone the QT_WA / QT_WA_INLINE removal for Qt 5. This reverts commit c5e5998bec4aafca555543d1ef3c335f7b280294. --- src/corelib/global/qglobal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5851d26..1f0b80c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1540,6 +1540,9 @@ inline QT3_SUPPORT bool qt_winUnicode() { return true; } inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; } #endif +#define QT_WA(unicode, ansi) unicode +#define QT_WA_INLINE(unicode, ansi) (unicode) + #endif /* Q_WS_WIN */ #ifndef Q_OUTOFLINE_TEMPLATE -- cgit v0.12 From e5c52134bdd24a19f2aa5c29b654ab5e6b39ec89 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 28 Dec 2009 12:21:50 +0100 Subject: Format qOpenGLVersionFlagsFromString() according to Qt coding style. --- src/opengl/qgl.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 466e851..eb14c6c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1117,25 +1117,21 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co if (parts[2].startsWith(QLatin1String("1.1"))) versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 | QGLFormat::OpenGL_ES_CommonLite_Version_1_1; - } - else { + } else { // Not -CM, must be CL, CommonLite versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_0; if (parts[2].startsWith(QLatin1String("1.1"))) versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_1; } - } - else { + } else { // OpenGL ES version 2.0 or higher versionFlags |= QGLFormat::OpenGL_ES_Version_2_0; } - } - else { + } else { // if < 3 parts to the name, it is an unrecognised OpenGL ES qWarning("Unrecognised OpenGL ES version"); } - } - else { + } else { // not ES, regular OpenGL, the version numbers are first in the string if (versionString.startsWith(QLatin1String("1."))) { switch (versionString[2].toAscii()) { @@ -1152,8 +1148,7 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co default: break; } - } - else if (versionString.startsWith(QLatin1String("2."))) { + } else if (versionString.startsWith(QLatin1String("2."))) { versionFlags |= QGLFormat::OpenGL_Version_1_1 | QGLFormat::OpenGL_Version_1_2 | QGLFormat::OpenGL_Version_1_3 | @@ -1163,19 +1158,18 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co QString minorVersion = versionString.section(QLatin1Char(' '), 0, 0).section(QLatin1Char('.'), 1, 1); if (minorVersion == QChar(QLatin1Char('1'))) versionFlags |= QGLFormat::OpenGL_Version_2_1; - } - else if (versionString.startsWith(QLatin1String("3."))) { - versionFlags |= QGLFormat::OpenGL_Version_1_1 | - QGLFormat::OpenGL_Version_1_2 | - QGLFormat::OpenGL_Version_1_3 | - QGLFormat::OpenGL_Version_1_4 | - QGLFormat::OpenGL_Version_1_5 | - QGLFormat::OpenGL_Version_2_0 | - QGLFormat::OpenGL_Version_2_1 | - QGLFormat::OpenGL_Version_3_0; - } - else + } else if (versionString.startsWith(QLatin1String("3."))) { + versionFlags |= QGLFormat::OpenGL_Version_1_1 | + QGLFormat::OpenGL_Version_1_2 | + QGLFormat::OpenGL_Version_1_3 | + QGLFormat::OpenGL_Version_1_4 | + QGLFormat::OpenGL_Version_1_5 | + QGLFormat::OpenGL_Version_2_0 | + QGLFormat::OpenGL_Version_2_1 | + QGLFormat::OpenGL_Version_3_0; + } else { qWarning("Unrecognised OpenGL version"); + } } return versionFlags; } -- cgit v0.12 From 592dc5978e5109c6c7c378623817938779c869a0 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 29 Dec 2009 14:06:18 +0100 Subject: Added support for OpenGL up to version 3.2 on Windows. Task-number: QTBUG-4438, QT-2662, QT-2663 Reviewed-by: Tom --- src/opengl/qgl.cpp | 101 ++++++++++++++++++++++++++++++- src/opengl/qgl.h | 23 ++++++- src/opengl/qgl_p.h | 18 +++++- src/opengl/qgl_win.cpp | 158 +++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 275 insertions(+), 25 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index eb14c6c..ffce551 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -227,6 +227,9 @@ bool qt_gl_preferGL2Engine() \value DirectRendering Specifies that the context is used for direct rendering to a display. \value HasOverlay Enables the use of an overlay. \value SampleBuffers Enables the use of sample buffers. + \value DeprecatedFunctions Enables the use of deprecated functionality for OpenGL 3.x + contexts. A context with deprecated functionality enabled is + called a full context in the OpenGL specification. \value SingleBuffer Specifies the use of a single buffer, as opposed to double buffers. \value NoDepthBuffer Disables the use of a depth buffer. \value ColorIndex Specifies that the context should use a color index as its pixel format. @@ -237,6 +240,9 @@ bool qt_gl_preferGL2Engine() \value IndirectRendering Specifies that the context is used for indirect rendering to a buffer. \value NoOverlay Disables the use of an overlay. \value NoSampleBuffers Disables the use of sample buffers. + \value NoDeprecatedFunctions Disables the use of deprecated functionality for OpenGL 3.x + contexts. A context with deprecated functionality disabled is + called a forward compatible context in the OpenGL specification. \sa {Sample Buffers Example} */ @@ -1082,6 +1088,84 @@ int QGLFormat::stencilBufferSize() const } /*! + \since 4.7 + + Set the OpenGL version. If a context compatible with the requested OpenGL version + cannot be created, a context compatible with version 1.x is created instead. + + \sa majorVersion(), minorVersion() +*/ +void QGLFormat::setVersion(int major, int minor) +{ + detach(); + d->majorVersion = major; + d->minorVersion = minor; +} + +/*! + \since 4.7 + + Returns the OpenGL major version. + + \sa setVersion(), minorVersion() +*/ +int QGLFormat::majorVersion() const +{ + return d->majorVersion; +} + +/*! + \since 4.7 + + Returns the OpenGL minor version. + + \sa setVersion(), majorVersion() +*/ +int QGLFormat::minorVersion() const +{ + return d->minorVersion; +} + +/*! + \enum QGLFormat::OpenGLContextProfile + \since 4.7 + + This enum describes the OpenGL context profiles that can be specified for contexts implementing + OpenGL version 3.2 or higher. These profiles are different from OpenGL ES profiles. + + \value NoProfile OpenGL version is lower than 3.2. + \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. + \value CompatibilityProfile Functionality from earlier OpenGL versions is available. +*/ + +/*! + \since 4.7 + + Set the OpenGL context profile. The profile is ignored if the requested OpenGL + version is less than 3.2. + + \sa profile() +*/ +void QGLFormat::setProfile(OpenGLContextProfile profile) +{ + detach(); + d->profile = profile; +} + +/*! + \since 4.7 + + Returns the OpenGL context profile. + + \sa setProfile() +*/ +QGLFormat::OpenGLContextProfile QGLFormat::profile() const +{ + return d->profile; +} + + +/*! \fn bool QGLFormat::hasOpenGL() Returns true if the window system has any OpenGL support; @@ -1155,8 +1239,7 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co QGLFormat::OpenGL_Version_1_4 | QGLFormat::OpenGL_Version_1_5 | QGLFormat::OpenGL_Version_2_0; - QString minorVersion = versionString.section(QLatin1Char(' '), 0, 0).section(QLatin1Char('.'), 1, 1); - if (minorVersion == QChar(QLatin1Char('1'))) + if (versionString[2].toAscii() == '1') versionFlags |= QGLFormat::OpenGL_Version_2_1; } else if (versionString.startsWith(QLatin1String("3."))) { versionFlags |= QGLFormat::OpenGL_Version_1_1 | @@ -1167,6 +1250,14 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co QGLFormat::OpenGL_Version_2_0 | QGLFormat::OpenGL_Version_2_1 | QGLFormat::OpenGL_Version_3_0; + switch (versionString[2].toAscii()) { + case '2': + versionFlags |= QGLFormat::OpenGL_Version_3_2; + case '1': + versionFlags |= QGLFormat::OpenGL_Version_3_1; + default: + break; + } } else { qWarning("Unrecognised OpenGL version"); } @@ -1201,6 +1292,12 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present. + \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. + Note that OpenGL version 3.1 or higher does not necessarily support all the features of + version 3.0 and lower. + + \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. + \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 2076c46..d2fe5fb 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -144,6 +144,7 @@ namespace QGL DirectRendering = 0x0080, HasOverlay = 0x0100, SampleBuffers = 0x0200, + DeprecatedFunctions = 0x0400, SingleBuffer = DoubleBuffer << 16, NoDepthBuffer = DepthBuffer << 16, ColorIndex = Rgba << 16, @@ -153,7 +154,8 @@ namespace QGL NoStereoBuffers = StereoBuffers << 16, IndirectRendering = DirectRendering << 16, NoOverlay = HasOverlay << 16, - NoSampleBuffers = SampleBuffers << 16 + NoSampleBuffers = SampleBuffers << 16, + NoDeprecatedFunctions = DeprecatedFunctions << 16 }; Q_DECLARE_FLAGS(FormatOptions, FormatOption) } @@ -235,7 +237,20 @@ public: static bool hasOpenGL(); static bool hasOpenGLOverlays(); - enum OpenGLVersionFlag { + void setVersion(int major, int minor); + int majorVersion() const; + int minorVersion() const; + + enum OpenGLContextProfile { + NoProfile, + CoreProfile, + CompatibilityProfile + }; + + void setProfile(OpenGLContextProfile profile); + OpenGLContextProfile profile() const; + + enum OpenGLVersionFlag { OpenGL_Version_None = 0x00000000, OpenGL_Version_1_1 = 0x00000001, OpenGL_Version_1_2 = 0x00000002, @@ -249,7 +264,9 @@ public: OpenGL_ES_Common_Version_1_1 = 0x00000200, OpenGL_ES_CommonLite_Version_1_1 = 0x00000400, OpenGL_ES_Version_2_0 = 0x00000800, - OpenGL_Version_3_0 = 0x00001000 + OpenGL_Version_3_0 = 0x00001000, + OpenGL_Version_3_1 = 0x00002000, + OpenGL_Version_3_2 = 0x00004000 }; Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 99c0f33..a075a31 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -132,11 +132,15 @@ public: QGLFormatPrivate() : ref(1) { - opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering | QGL::StencilBuffer; + opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering + | QGL::StencilBuffer | QGL::DeprecatedFunctions; pln = 0; depthSize = accumSize = stencilSize = redSize = greenSize = blueSize = alphaSize = -1; numSamples = -1; swapInterval = -1; + majorVersion = 1; + minorVersion = 0; + profile = QGLFormat::NoProfile; } QGLFormatPrivate(const QGLFormatPrivate *other) : ref(1), @@ -150,7 +154,10 @@ public: blueSize(other->blueSize), alphaSize(other->alphaSize), numSamples(other->numSamples), - swapInterval(other->swapInterval) + swapInterval(other->swapInterval), + majorVersion(other->majorVersion), + minorVersion(other->minorVersion), + profile(other->profile) { } QAtomicInt ref; @@ -165,6 +172,9 @@ public: int alphaSize; int numSamples; int swapInterval; + int majorVersion; + int minorVersion; + QGLFormat::OpenGLContextProfile profile; }; class QGLWidgetPrivate : public QWidgetPrivate @@ -277,6 +287,10 @@ public: void cleanup(); #if defined(Q_WS_WIN) + void updateFormatVersion(); +#endif + +#if defined(Q_WS_WIN) HGLRC rc; HDC dc; WId win; diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index 5b5820a..c2170e0 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -122,6 +122,30 @@ typedef bool (APIENTRY *PFNWGLCHOOSEPIXELFORMATARB)(HDC hdc, #define WGL_TYPE_COLORINDEX_ARB 0x202C #endif +#ifndef WGL_ARB_create_context +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x0002 +// Error codes returned by GetLastError(). +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#endif + QT_BEGIN_NAMESPACE class QGLCmapPrivate @@ -681,8 +705,118 @@ public: WId dmy_id; }; +static bool qgl_create_context(HDC hdc, QGLContextPrivate *d, QGLContextPrivate *shareContext) +{ + d->rc = 0; + + typedef HGLRC (APIENTRYP PFNWGLCREATECONTEXTATTRIBSARB)(HDC, HGLRC, const int *); + PFNWGLCREATECONTEXTATTRIBSARB wglCreateContextAttribsARB = + (PFNWGLCREATECONTEXTATTRIBSARB) wglGetProcAddress("wglCreateContextAttribsARB"); + if (wglCreateContextAttribsARB) { + int attributes[11]; + int attribIndex = 0; + const int major = d->reqFormat.majorVersion(); + const int minor = d->reqFormat.minorVersion(); + attributes[attribIndex++] = WGL_CONTEXT_MAJOR_VERSION_ARB; + attributes[attribIndex++] = major; + attributes[attribIndex++] = WGL_CONTEXT_MINOR_VERSION_ARB; + attributes[attribIndex++] = minor; + + if (major >= 3 && !d->reqFormat.testOption(QGL::DeprecatedFunctions)) { + attributes[attribIndex++] = WGL_CONTEXT_FLAGS_ARB; + attributes[attribIndex++] = WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + + if ((major == 3 && minor >= 2) || major > 3) { + switch (d->reqFormat.profile()) { + case QGLFormat::NoProfile: + break; + case QGLFormat::CoreProfile: + attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attributes[attribIndex++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + break; + case QGLFormat::CompatibilityProfile: + attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attributes[attribIndex++] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + break; + default: + qWarning("QGLContext::chooseContext(): Context profile not supported."); + return false; + } + } + + if (d->reqFormat.plane() != 0) { + attributes[attribIndex++] = WGL_CONTEXT_LAYER_PLANE_ARB; + attributes[attribIndex++] = d->reqFormat.plane(); + } + + attributes[attribIndex++] = 0; // Terminate list. + d->rc = wglCreateContextAttribsARB(hdc, shareContext && shareContext->valid + ? shareContext->rc : 0, attributes); + if (d->rc) { + if (shareContext) + shareContext->sharing = d->sharing = true; + return true; + } + } + + d->rc = wglCreateLayerContext(hdc, d->reqFormat.plane()); + if (d->rc && shareContext && shareContext->valid) + shareContext->sharing = d->sharing = wglShareLists(shareContext->rc, d->rc); + return d->rc != 0; +} + +void QGLContextPrivate::updateFormatVersion() +{ + const GLubyte *s = glGetString(GL_VERSION); + + if (!(s && s[0] >= '0' && s[0] <= '9' && s[1] == '.' && s[2] >= '0' && s[2] <= '9')) { + if (!s) + qWarning("QGLContext::chooseContext(): OpenGL version string is null."); + else + qWarning("QGLContext::chooseContext(): Unexpected OpenGL version string format."); + glFormat.setVersion(0, 0); + glFormat.setProfile(QGLFormat::NoProfile); + glFormat.setOption(QGL::DeprecatedFunctions); + return; + } + + int major = s[0] - '0'; + int minor = s[2] - '0'; + glFormat.setVersion(major, minor); + + if (major < 3) { + glFormat.setProfile(QGLFormat::NoProfile); + glFormat.setOption(QGL::DeprecatedFunctions); + } else { + GLint value = 0; + if (major > 3 || minor >= 2) + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value); + + switch (value) { + case WGL_CONTEXT_CORE_PROFILE_BIT_ARB: + glFormat.setProfile(QGLFormat::CoreProfile); + break; + case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: + glFormat.setProfile(QGLFormat::CompatibilityProfile); + break; + default: + glFormat.setProfile(QGLFormat::NoProfile); + break; + } + + glGetIntegerv(GL_CONTEXT_FLAGS, &value); + if (value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + glFormat.setOption(QGL::NoDeprecatedFunctions); + else + glFormat.setOption(QGL::DeprecatedFunctions); + } +} + bool QGLContext::chooseContext(const QGLContext* shareContext) { + QGLContextPrivate *share = shareContext ? const_cast(shareContext)->d_func() : 0; + Q_D(QGLContext); // workaround for matrox driver: // make a cheap call to opengl to force loading of DLL @@ -740,8 +874,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) goto end; } - d->rc = wglCreateLayerContext(myDc, d->glFormat.plane()); - if (!d->rc) { + if (!qgl_create_context(myDc, d, share)) { qwglError("QGLContext::chooseContext()", "CreateLayerContext"); result = false; goto end; @@ -791,16 +924,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) d->cmap = new QGLCmap(1 << lpfd.cColorBits); d->cmap->setEntry(lpfd.crTransparent, qRgb(1, 2, 3));//, QGLCmap::Reserved); } - - if (shareContext && shareContext->isValid()) { - QGLContext *share = const_cast(shareContext); - d->sharing = (wglShareLists(shareContext->d_func()->rc, d->rc) != 0); - share->d_func()->sharing = d->sharing; - } - - goto end; - } - { + } else { PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR realPfd; d->pixelFormatId = choosePixelFormat(&pfd, myDc); @@ -839,17 +963,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) goto end; } - if (!(d->rc = wglCreateLayerContext(myDc, 0))) { + if (!qgl_create_context(myDc, d, share)) { qwglError("QGLContext::chooseContext()", "wglCreateContext"); result = false; goto end; } - if (shareContext && shareContext->isValid()) { - d->sharing = (wglShareLists(shareContext->d_func()->rc, d->rc) != 0); - const_cast(shareContext)->d_func()->sharing = d->sharing; - } - if(!deviceIsPixmap()) { QRgb* pal = qgl_create_rgb_palette(&realPfd); if (pal) { @@ -864,6 +983,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) end: // vblanking wglMakeCurrent(myDc, d->rc); + if (d->rc) + d->updateFormatVersion(); + typedef BOOL (APIENTRYP PFNWGLSWAPINTERVALEXT) (int interval); typedef int (APIENTRYP PFNWGLGETSWAPINTERVALEXT) (void); PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXT) wglGetProcAddress("wglSwapIntervalEXT"); -- cgit v0.12 From ec452c7f31ffe53dc28763a80d517288ac3c118d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 23 Dec 2009 14:18:31 +0100 Subject: Cocoa: app menu does now show before doing qApp::exec() The reason is that we need to start [NSApplication run] before the menus get properly initialized. This patch will make the event dispatcher run nsapp once before spinning a modal session, if needed Task-number: QTBUG-6627 --- src/gui/kernel/qeventdispatcher_mac.mm | 40 +++++++++++++++++++++------------ src/gui/kernel/qeventdispatcher_mac_p.h | 4 ++-- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 0b48dca..8d2218b 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -570,8 +570,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) // done from the application itself. And if processEvents is called // manually (rather than from a QEventLoop), we cannot enter a tight // loop and block this call, but instead we need to return after one flush: - bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning]; - bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec; + const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning]; + const bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec; if (canExec_Qt && canExec_3rdParty) { // We can use exec-mode, meaning that we can stay in a tight loop until @@ -596,9 +596,10 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) } retVal = true; } else { + // We cannot block the thread (and run in a tight loop). + // Instead we will process all current pending events and return. + d->ensureNSAppInitialized(); do { - // We cannot block the thread (and run in a tight loop). - // Instead we will process all current pending events and return. bool releaseEvent = false; if (!(flags & QEventLoop::ExcludeUserInputEvents) @@ -746,20 +747,31 @@ bool QEventDispatcherMacPrivate::blockSendPostedEvents = false; #ifdef QT_MAC_USE_COCOA QStack QEventDispatcherMacPrivate::cocoaModalSessionStack; +bool QEventDispatcherMacPrivate::interrupt = false; bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false; bool QEventDispatcherMacPrivate::modalSessionsTemporarilyStopped = false; bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false; bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false; NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0; -void QEventDispatcherMacPrivate::flushCocoaEvents() +void QEventDispatcherMacPrivate::ensureNSAppInitialized() { - while (NSEvent *event = [NSApp nextEventMatchingMask:0 - untilDate:nil - inMode:NSDefaultRunLoopMode - dequeue: YES]) { - qt_mac_send_event(0, event, 0); - } + // Some elements in Cocoa require NSApplication to be running before + // they get fully initialized, in particular the menu bar. This + // function is intended for cases where a dialog is told to execute before + // QApplication::exec is called, or the application spins the events loop + // manually rather than calling QApplication:exec. + // The function makes sure that NSApplication starts running, but stops + // it again as soon as the send posted events callback is called. That way + // we let Cocoa finish the initialization it seems to need. We'll only + // apply this trick at most once for any application, and we avoid doing it + // for the common case where main just starts QApplication::exec. + if (nsAppRunCalledByQt || [NSApp isRunning]) + return; + nsAppRunCalledByQt = true; + QBoolBlocker block1(interrupt, true); + QBoolBlocker block2(currentExecIsNSAppRun, true); + [NSApp run]; } void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions() @@ -811,6 +823,8 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession() NSWindow *window = qt_mac_window_for(info.widget); if (!window) continue; + + ensureNSAppInitialized(); QBoolBlocker block1(blockSendPostedEvents, true); info.session = [NSApp beginModalSessionForWindow:window]; } @@ -826,12 +840,11 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession() // screen. To work around this, we block cocoa from changing the // stacking order of the windows, and flush out the pending events // (the block is used in QCocoaWindow and QCocoaPanel): - modalSessionsTemporarilyStopped = false; QBoolBlocker block1(blockSendPostedEvents, true); QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true); [NSApp runModalSession:currentModalSessionCached]; } - + modalSessionsTemporarilyStopped = false; return currentModalSessionCached; } @@ -935,7 +948,6 @@ void QEventDispatcherMacPrivate::endModalSession(QWidget *widget) #endif QEventDispatcherMacPrivate::QEventDispatcherMacPrivate() - : interrupt(false) { } diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h index 37ee2b1..205f564 100644 --- a/src/gui/kernel/qeventdispatcher_mac_p.h +++ b/src/gui/kernel/qeventdispatcher_mac_p.h @@ -184,7 +184,7 @@ public: static void endModalSession(QWidget *widget); static void cancelWaitForMoreEvents(); static void cleanupModalSessions(); - static void flushCocoaEvents(); + static void ensureNSAppInitialized(); #endif MacSocketHash macSockets; @@ -194,7 +194,7 @@ public: CFRunLoopObserverRef firstTimeObserver; QAtomicInt serialNumber; int lastSerial; - bool interrupt; + static bool interrupt; private: static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2); static void postedEventsSourcePerformCallback(void *info); -- cgit v0.12 From 5356d3717a9355830a13dfa0c8726f86a5f1c522 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 4 Jan 2010 10:01:27 +0100 Subject: Carbon: compile fix Oops. Broke build on carbon. --- src/gui/kernel/qeventdispatcher_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 8d2218b..ab1e2a1 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -744,10 +744,10 @@ void QEventDispatcherMac::flush() *****************************************************************************/ MacTimerHash QEventDispatcherMacPrivate::macTimerHash; bool QEventDispatcherMacPrivate::blockSendPostedEvents = false; +bool QEventDispatcherMacPrivate::interrupt = false; #ifdef QT_MAC_USE_COCOA QStack QEventDispatcherMacPrivate::cocoaModalSessionStack; -bool QEventDispatcherMacPrivate::interrupt = false; bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false; bool QEventDispatcherMacPrivate::modalSessionsTemporarilyStopped = false; bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false; -- cgit v0.12 From 81d06f72cb84485847f963ba1dfea662e51096e4 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 4 Jan 2010 10:44:03 +0100 Subject: Fixed QGLFormat::operator== to handle new fields. When I added new fields to QGLFormat in commit 592dc597, I forgot to update operator==. It has now been fixed and the auto-test updated. Reviewed-by: Trond --- src/opengl/qgl.cpp | 16 +++++++++++++--- tests/auto/qgl/tst_qgl.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ffce551..9d4b488 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1097,6 +1097,10 @@ int QGLFormat::stencilBufferSize() const */ void QGLFormat::setVersion(int major, int minor) { + if (major < 1 || minor < 0) { + qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor); + return; + } detach(); d->majorVersion = major; d->minorVersion = minor; @@ -1470,14 +1474,20 @@ void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f) bool operator==(const QGLFormat& a, const QGLFormat& b) { - return (int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize - && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize + return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts + && a.d->pln == b.d->pln + && a.d->alphaSize == b.d->alphaSize + && a.d->accumSize == b.d->accumSize + && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples - && a.d->swapInterval == b.d->swapInterval; + && a.d->swapInterval == b.d->swapInterval + && a.d->majorVersion == b.d->majorVersion + && a.d->minorVersion == b.d->minorVersion + && a.d->profile == b.d->profile); } diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 532e550..7cda35d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -425,6 +425,26 @@ void tst_QGL::getSetCheck() obj1.setPlane(TEST_INT_MAX); QCOMPARE(TEST_INT_MAX, obj1.plane()); + // int QGLFormat::major/minorVersion() + // void QGLFormat::setVersion(int, int) + QCOMPARE(obj1.majorVersion(), 1); + QCOMPARE(obj1.minorVersion(), 0); + obj1.setVersion(3, 2); + QCOMPARE(obj1.majorVersion(), 3); + QCOMPARE(obj1.minorVersion(), 2); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setVersion: Cannot set zero or negative version number 0.1"); + obj1.setVersion(0, 1); + QCOMPARE(obj1.majorVersion(), 3); + QCOMPARE(obj1.minorVersion(), 2); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setVersion: Cannot set zero or negative version number 3.-1"); + obj1.setVersion(3, -1); + QCOMPARE(obj1.majorVersion(), 3); + QCOMPARE(obj1.minorVersion(), 2); + obj1.setVersion(TEST_INT_MAX, TEST_INT_MAX - 1); + QCOMPARE(obj1.majorVersion(), TEST_INT_MAX); + QCOMPARE(obj1.minorVersion(), TEST_INT_MAX - 1); + + // operator== and operator!= for QGLFormat QGLFormat format1; QGLFormat format2; @@ -508,6 +528,27 @@ void tst_QGL::getSetCheck() QVERIFY(format1 == format2); QVERIFY(!(format1 != format2)); + format1.setVersion(3, 2); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setVersion(3, 2); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setProfile(QGLFormat::CoreProfile); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setProfile(QGLFormat::CoreProfile); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setOption(QGL::NoDeprecatedFunctions); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setOption(QGL::NoDeprecatedFunctions); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + // Copy constructor and assignment for QGLFormat. QGLFormat format3(format1); QGLFormat format4; -- cgit v0.12 From 2176a58c5312e2f994d5e345708a3b37e333d668 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 4 Jan 2010 15:45:49 +0100 Subject: Cocoa: exec() on a dialog with Qt::Tool windowflag is just a dialog. This is because a modal flag on the window wins over the type when determining window class. This fix will respect the type first, before looking at the window flag. Task-number: QTBUG-1455 Reviewed-by: Prasanth --- src/gui/kernel/qwidget_mac.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3925905..35e7505 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1888,13 +1888,15 @@ void QWidgetPrivate::determineWindowClass() wclass = kDocumentWindowClass; else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen)) wclass = kModalWindowClass; - else if(q->testAttribute(Qt::WA_ShowModal) || type == Qt::Dialog) + else if(type == Qt::Dialog) wclass = kMovableModalWindowClass; else if(type == Qt::ToolTip) wclass = kHelpWindowClass; else if(type == Qt::Tool || (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 && type == Qt::SplashScreen)) wclass = kFloatingWindowClass; + else if(q->testAttribute(Qt::WA_ShowModal)) + wclass = kMovableModalWindowClass; else wclass = kDocumentWindowClass; @@ -1998,8 +2000,6 @@ void QWidgetPrivate::determineWindowClass() for(int i = 0; tmp_wattr && known_attribs[i].name; i++) { if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) { tmp_wattr ^= known_attribs[i].tag; - qDebug("Qt: internal: * %s %s", known_attribs[i].name, - (GetAvailableWindowAttributes(wclass) & known_attribs[i].tag) ? "" : "(*)"); } } if(tmp_wattr) -- cgit v0.12 From b1b8ff495f7a33769b2aea9091622e3fa1e3344c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 5 Jan 2010 08:15:03 +0100 Subject: Don't use QPointer in objectve-c interfaces. (Constructors and destructors are not called.) --- src/gui/widgets/qcocoamenu_mac_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qcocoamenu_mac_p.h b/src/gui/widgets/qcocoamenu_mac_p.h index 3ad0ab8..57b4e17 100644 --- a/src/gui/widgets/qcocoamenu_mac_p.h +++ b/src/gui/widgets/qcocoamenu_mac_p.h @@ -52,10 +52,10 @@ #include "qmacdefines_mac.h" #ifdef QT_MAC_USE_COCOA -#include #import QT_FORWARD_DECLARE_CLASS(QMenu) +QT_FORWARD_DECLARE_CLASS(QAction) #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 @@ -72,7 +72,7 @@ QT_FORWARD_DECLARE_CLASS(QMenu) @interface QT_MANGLE_NAMESPACE(QCocoaMenu) : NSMenu { QMenu *qmenu; - QPointer previousAction; + QAction *previousAction; } - (id)initWithQMenu:(QMenu*)menu; - (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action; -- cgit v0.12 From 3d16f0d69c083e78cda0f036ceaca6031ef85b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 5 Jan 2010 14:01:02 +0100 Subject: Remove obsolete XShape configure warning. Task:QTBUG-2158 Designer no longer uses XShape for Drag and Drop. --- configure | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure b/configure index 22e6bd4..d921f70 100755 --- a/configure +++ b/configure @@ -7827,10 +7827,7 @@ if [ "$PLATFORM_X11" = "yes" ] && [ "$CFG_XSHAPE" = "no" ]; then cat < Date: Tue, 5 Jan 2010 14:04:31 +0100 Subject: Remove the entire warning, is seems it was only there for Designer. --- configure | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/configure b/configure index d921f70..7b4f832 100755 --- a/configure +++ b/configure @@ -7821,17 +7821,6 @@ done rm -f .projects .projects.3 #------------------------------------------------------------------------------- -# XShape is important, DnD in the Designer doens't work without it -#------------------------------------------------------------------------------- -if [ "$PLATFORM_X11" = "yes" ] && [ "$CFG_XSHAPE" = "no" ]; then - cat < Date: Tue, 5 Jan 2010 16:46:15 +0100 Subject: Fixed the host detection in qmake profiles. The previous tests were checking the target platform, but we need to check the host. RevBy: Trust me --- mkspecs/common/symbian/symbian.conf | 4 ++-- mkspecs/features/symbian/application_icon.prf | 2 +- projects.pro | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 40f8424..95f7dc3 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -74,7 +74,7 @@ QMAKE_LIBS_COMPAT = QMAKE_LIBS_QT_ENTRY = -llibcrt0.lib QMAKE_LIBS_S60 = -lavkon -win32:!isEmpty(QMAKE_SH) | unix { +contains(QMAKE_HOST.os, "Windows"):!isEmpty(QMAKE_SH) | unix { QMAKE_COPY = cp QMAKE_COPY_DIR = cp -r QMAKE_MOVE = mv @@ -92,7 +92,7 @@ win32:!isEmpty(QMAKE_SH) | unix { QMAKE_CHK_DIR_EXISTS = if not exist } -win32 { +contains(QMAKE_HOST.os, "Windows") { QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index 8849ea0..b790463 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -30,7 +30,7 @@ contains( CONFIG, no_icon ) { # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code symbian-abld { #Makefile: requires paths with backslash - win32:ICON = $$replace(ICON, /, \\) + contains(QMAKE_HOST.os, "Windows"):ICON = $$replace(ICON, /, \\) # Extra compiler rules for mifconv mifconv.output = ${ZDIR}$$APP_RESOURCE_DIR/$${baseTarget}.mif diff --git a/projects.pro b/projects.pro index 11cbd03..19a5ff8 100644 --- a/projects.pro +++ b/projects.pro @@ -112,7 +112,7 @@ win32 { } symbian { confclean.depends += distclean - win32 { + contains(QMAKE_HOST.os, "Windows") { confclean.commands += \ (cd src\tools\moc && $(MAKE) distclean) $$escape_expand(\n\t) \ (cd src\tools\rcc && $(MAKE) distclean) $$escape_expand(\n\t) \ -- cgit v0.12 From d149a3faca9b97ce806249bc7ef73fe2f59589d5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 6 Jan 2010 10:48:25 +0100 Subject: Don't call invalidate when resetting the QSortFilterProxyModel. The invalidate connection is made before connecting the source model, which means it gets called first. If a second proxy model is used with it, the sourceLayoutAboutToBeChanged of the second proxy is therefore called before its sourceReset slot, but after the persistent indexes of the first model have been invalidated. The invalidate call is not needed because clear_mappings is called when the source model is reset anyway. Merge-request: 416 Reviewed-by: Olivier Goffart --- src/gui/itemviews/qsortfilterproxymodel.cpp | 1 - tests/auto/modeltest/dynamictreemodel.cpp | 3 ++- tests/auto/modeltest/tst_modeltest.cpp | 30 +++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 646a3a1..0e4af53 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1481,7 +1481,6 @@ QSortFilterProxyModel::QSortFilterProxyModel(QObject *parent) d->filter_column = 0; d->filter_role = Qt::DisplayRole; d->dynamic_sortfilter = false; - connect(this, SIGNAL(modelReset()), this, SLOT(invalidate())); } /*! diff --git a/tests/auto/modeltest/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp index 24d3ab3..b572eb1 100644 --- a/tests/auto/modeltest/dynamictreemodel.cpp +++ b/tests/auto/modeltest/dynamictreemodel.cpp @@ -160,10 +160,11 @@ QVariant DynamicTreeModel::data(const QModelIndex &index, int role) const void DynamicTreeModel::clear() { + beginResetModel(); m_items.clear(); m_childItems.clear(); nextId = 1; - reset(); + endResetModel(); } diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp index 262b966..8beeb38 100644 --- a/tests/auto/modeltest/tst_modeltest.cpp +++ b/tests/auto/modeltest/tst_modeltest.cpp @@ -67,6 +67,7 @@ private slots: void standardItemModel(); void testInsertThroughProxy(); void moveSourceItems(); + void testResetThroughProxy(); }; @@ -225,8 +226,9 @@ public slots: void storePersistent() { - m_persistentSourceIndexes.clear(); - m_persistentProxyIndexes.clear(); + foreach(const QModelIndex &idx, m_persistentProxyIndexes) + Q_ASSERT(idx.isValid()); // This is called from layoutAboutToBeChanged. Persistent indexes should be valid + Q_ASSERT(m_proxy->persistent().isEmpty()); storePersistent(QModelIndex()); Q_ASSERT(!m_proxy->persistent().isEmpty()); @@ -243,6 +245,8 @@ public slots: QModelIndex updatedSource = m_persistentSourceIndexes.at(row); QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource); } + m_persistentSourceIndexes.clear(); + m_persistentProxyIndexes.clear(); } private: @@ -278,6 +282,28 @@ void tst_ModelTest::moveSourceItems() moveCommand->doCommand(); } +void tst_ModelTest::testResetThroughProxy() +{ + DynamicTreeModel *model = new DynamicTreeModel(this); + + ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this); + insertCommand->setStartRow(0); + insertCommand->setEndRow(2); + insertCommand->doCommand(); + + QPersistentModelIndex persistent = model->index(0, 0); + + AccessibleProxyModel *proxy = new AccessibleProxyModel(this); + proxy->setSourceModel(model); + + ObservingObject observer(proxy); + observer.storePersistent(); + + ModelResetCommand *resetCommand = new ModelResetCommand(model, this); + resetCommand->setNumCols(0); + resetCommand->doCommand(); +} + QTEST_MAIN(tst_ModelTest) #include "tst_modeltest.moc" -- cgit v0.12 From 7e77574fbedf0227efd33b0fab1028b7129ef908 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 Jan 2010 11:40:42 +0100 Subject: GCC doesn't like comment lines ending in \ src/opengl/gl2paintengineex/qtriangulator.cpp:655:5: warning: multi-line comment So add some padding characters to the right (can't just add spaces though). Reviewed-by: TrustMe --- src/opengl/gl2paintengineex/qtriangulator.cpp | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index 6a1112b..d8e72f3 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -650,53 +650,53 @@ inline void QRBTree::clear() template void QRBTree::rotateLeft(Node *node) { - // | | - // N B - // / \ / \ - // A B ---> N D - // / \ / \ - // C D A C + // | | // + // N B // + // / \ / \ // + // A B ---> N D // + // / \ / \ // + // C D A C // Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); ref = node->right; node->right->parent = node->parent; - // : - // N - // / :| - // A B - // / \ - // C D + // : // + // N // + // / :| // + // A B // + // / \ // + // C D // node->right = ref->left; if (ref->left) ref->left->parent = node; - // : | - // N B - // / \ : \ - // A C D + // : | // + // N B // + // / \ : \ // + // A C D // ref->left = node; node->parent = ref; - // | - // B - // / \ - // N D - // / \ - // A C + // | // + // B // + // / \ // + // N D // + // / \ // + // A C // } template void QRBTree::rotateRight(Node *node) { - // | | - // N A - // / \ / \ - // A B ---> C N - // / \ / \ - // C D D B + // | | // + // N A // + // / \ / \ // + // A B ---> C N // + // / \ / \ // + // C D D B // Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); ref = node->left; -- cgit v0.12 From 7fc53c195b3a830ff6db68bb9c4294f444e5519e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 Jan 2010 11:42:07 +0100 Subject: Change from std::pair to QPair. My Qt is built with -no-stl, so the STL headers aren't included and, thus, std::pair isn't defined. Reviewed-by: Trust Me --- src/opengl/gl2paintengineex/qtriangulator.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index d8e72f3..b60e10d 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -2707,7 +2707,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() return; Q_ASSERT(!m_edgeList.root); - QDataBuffer > diagonals; + QDataBuffer > diagonals; int i = 0; for (int index = 1; index < m_edges.size(); ++index) { @@ -2743,7 +2743,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() if (m_edges.at(i).node) { Q_ASSERT(!m_edges.at(j).node); if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(i).helper)); + diagonals.add(QPair(i, m_edges.at(i).helper)); m_edges.at(j).node = m_edges.at(i).node; m_edges.at(i).node = 0; m_edges.at(j).node->data = j; @@ -2751,7 +2751,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() } else if (m_edges.at(j).node) { Q_ASSERT(!m_edges.at(i).node); if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(j).helper)); + diagonals.add(QPair(i, m_edges.at(j).helper)); m_edges.at(i).node = m_edges.at(j).node; m_edges.at(j).node = 0; m_edges.at(i).node->data = i; @@ -2763,7 +2763,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); if (leftEdgeNode) { if (m_edges.at(m_edges.at(leftEdgeNode->data).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + diagonals.add(QPair(i, m_edges.at(leftEdgeNode->data).helper)); m_edges.at(leftEdgeNode->data).helper = i; } else { qWarning("Inconsistent polygon. (#2)"); @@ -2773,7 +2773,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() case SplitVertex: leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); if (leftEdgeNode) { - diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + diagonals.add(QPair(i, m_edges.at(leftEdgeNode->data).helper)); m_edges.at(leftEdgeNode->data).helper = i; } else { qWarning("Inconsistent polygon. (#3)"); @@ -2802,7 +2802,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() leftEdgeNode = searchEdgeLeftOfPoint(m_edges.at(i).from); if (leftEdgeNode) { if (m_edges.at(m_edges.at(leftEdgeNode->data).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(leftEdgeNode->data).helper)); + diagonals.add(QPair(i, m_edges.at(leftEdgeNode->data).helper)); m_edges.at(leftEdgeNode->data).helper = i; } else { qWarning("Inconsistent polygon. (#4)"); @@ -2811,7 +2811,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() case EndVertex: if (m_clockwiseOrder) { if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(i).helper)); + diagonals.add(QPair(i, m_edges.at(i).helper)); if (m_edges.at(i).node) { m_edgeList.deleteNode(m_edges.at(i).node); Q_ASSERT(m_edgeList.verify()); @@ -2820,7 +2820,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() } } else { if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) - diagonals.add(std::pair(i, m_edges.at(j).helper)); + diagonals.add(QPair(i, m_edges.at(j).helper)); if (m_edges.at(j).node) { m_edgeList.deleteNode(m_edges.at(j).node); Q_ASSERT(m_edgeList.verify()); -- cgit v0.12 From e2baf96da8881ed7c585e59e84efe39bbbd3d0d4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 Jan 2010 11:45:13 +0100 Subject: Fix compilation breakage caused by merge. This function was renamed in b06313579aad82f8dda64ad14384080754f2b222. Reviewed-by: TrustMe --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e679db8..98be0cb 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1014,7 +1014,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } } else { cache = new QGL2PEVectorPathCache; - data = const_cast(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath); + data = const_cast(path).addCacheData(q, cache, cleanupVectorPath); updateCache = true; } -- cgit v0.12 From e7274672bfddc6896dc7edbf57b555189e06ed55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 6 Jan 2010 12:29:32 +0100 Subject: Make Qt use Cocoa by default on Mac OS X The "-cococa" option is now deprecated, "-carbon" is added. This is mostly a behind-the-scenes change, but has some implications: If you are developing on Snow Leopard Qt vill be built in x86_64 mode by default. This can be overridden by configuring with "-arch x86" Qt for Cocoa will not build on 10.4 Tiger, nor will Cocoa-based binaries deploy back to that platform. Configure with "-carbon" if you want to target 10.4. --- configure | 75 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/configure b/configure index 7b4f832..7744d51 100755 --- a/configure +++ b/configure @@ -759,9 +759,9 @@ CFG_MAC_ARCHS= MAC_CONFIG_TEST_COMMANDLINE= # used to make the configure tests run with the correct arch's and SDK settings CFG_MAC_DWARF2=auto CFG_MAC_XARCH=auto -CFG_MAC_CARBON=yes -CFG_MAC_COCOA=auto -COMMANDLINE_MAC_COCOA=no +CFG_MAC_CARBON=no +CFG_MAC_COCOA=yes +COMMANDLINE_MAC_CARBON=no CFG_SXE=no CFG_PREFIX_INSTALL=yes CFG_SDK= @@ -921,7 +921,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -1321,13 +1321,17 @@ while [ "$#" -gt 0 ]; do fi ;; cocoa) +# do nothing - Cocoa is the default. + ;; + carbon) if [ "$PLATFORM_MAC" = "yes" ] && [ "$VAL" = "yes" ]; then - CFG_MAC_COCOA="$VAL" - COMMANDLINE_MAC_COCOA="$VAL" + CFG_MAC_CARBON="$VAL" + COMMANDLINE_MAC_CARBON="$VAL" else UNKNOWN_OPT=yes fi ;; + framework) if [ "$PLATFORM_MAC" = "yes" ]; then CFG_FRAMEWORK="$VAL" @@ -3784,10 +3788,11 @@ Qt/Mac only: -Fstring ........... Add an explicit framework path. -fw string ......... Add an explicit framework. - -cocoa ............. Build the Cocoa version of Qt. Note that -no-framework - and -static is not supported with -cocoa. Specifying - this option creates Qt binaries that requires Mac OS X - 10.5 or higher. + -cocoa ............. [Deprecated] Cocoa is now enabled by default. + + -carbon .............Build the Carbon version of Qt. 64-bit archs + are not supported by carbon and will be built + with cocoa * -framework ......... Build Qt as a series of frameworks and link tools against those frameworks. @@ -3800,8 +3805,7 @@ Qt/Mac only: -arch ....... Build Qt for Example values for : x86 ppc x86_64 ppc64 - Multiple -arch arguments can be specified, 64-bit archs - will be built with the Cocoa framework. + Multiple -arch arguments can be specified. -sdk ......... Build Qt using Apple provided SDK . This option requires gcc 4. To use a different SDK with gcc 3.3, set the SDKROOT environment variable. @@ -5942,14 +5946,14 @@ if [ "$CFG_MAC_DWARF2" = "yes" ]; then QT_CONFIG="$QT_CONFIG dwarf2" fi -# Set the default arch. -# Carbon builds: 32 bit x86/ppc. -# For "-cocoa" builds on snow leopard : compiler default (64-bit). -# For "-cocoa" builds on leopard : compiler default (32-bit). +# Set the default arch if there are no "-arch" arguments on the configure line +# For "-carbon" builds: 32 bit x86/ppc. +# For builds on snow leopard : compiler default (64-bit). +# For builds on leopard : compiler default (32-bit). if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_ARCHS" = "" ]; then source "$mactests/defaultarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" - if [ "$CFG_MAC_COCOA" != "yes" ]; then + if [ "$CFG_MAC_CARBON" = "yes" ]; then if [ "$QT_MAC_DEFAULT_ARCH" = "x86_64" ]; then CFG_MAC_ARCHS=" x86" elif [ "$QT_MAC_DEFAULT_ARCH" = "ppc64" ]; then @@ -5965,25 +5969,23 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_ARCHS" = "" ]; then fi # enable cocoa and/or carbon on Mac -if [ "$CFG_MAC_COCOA" = "yes" ]; then -# -cocoa on the command line disables carbon completely (i.e. use cocoa for 32-bit as well) - CFG_MAC_CARBON="no" -else +if [ "$CFG_MAC_CARBON" = "yes" ]; then +# -carbon on the command line disables Cocoa, except for 64b-bit archs + CFG_MAC_CARBON="YES" + CFG_MAC_COCOA="NO" +fi # check which archs are in use, enable cocoa if we find a 64-bit one - if echo "$CFG_MAC_ARCHS" | grep 64 > /dev/null 2>&1; then - CFG_MAC_COCOA="yes"; - CFG_MAC_CARBON="no"; - if echo "$CFG_MAC_ARCHS" | grep -w ppc > /dev/null 2>&1; then - CFG_MAC_CARBON="yes"; - fi - if echo "$CFG_MAC_ARCHS" | grep -w x86 > /dev/null 2>&1; then - CFG_MAC_CARBON="yes"; - fi - else -# no 64-bit archs found. - CFG_MAC_COCOA="no" +if echo "$CFG_MAC_ARCHS" | grep 64 > /dev/null 2>&1; then + CFG_MAC_COCOA="yes"; + CFG_MAC_CARBON="no"; + if echo "$CFG_MAC_ARCHS" | grep -w ppc > /dev/null 2>&1; then + CFG_MAC_CARBON="yes"; + fi + if echo "$CFG_MAC_ARCHS" | grep -w x86 > /dev/null 2>&1; then + CFG_MAC_CARBON="yes"; fi -fi; +fi + # set the global Mac deployment target. This is overridden on an arch-by-arch basis # in some cases, see code further down @@ -6579,9 +6581,8 @@ fi # On Mac, set the minimum deployment target for the different architechtures # using the Xarch compiler option when supported (10.5 and up). On 10.4 the # deployment version is set to 10.4 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET -# env. variable. "-cocoa" on the command line means Cocoa is used in 32-bit mode also, -# in this case fall back on QMAKE_MACOSX_DEPLOYMENT_TARGET which will be set to 10.5. -if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] && [ "$COMMANDLINE_MAC_COCOA" != "yes" ]; then +# env. variable. +if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] ; then if echo "$CFG_MAC_ARCHS" | grep '\' > /dev/null 2>&1; then QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4" QMakeVar add QMAKE_CXXFLAGS "-Xarch_i386 -mmacosx-version-min=10.4" -- cgit v0.12 From 6f173f9686bb3be19b26215342699705765937d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 6 Jan 2010 13:18:44 +0100 Subject: Select Carbon when building on 10.4 Tiger. Only perform the architecture check when "-carbon" has been specified on the configure line, as this is the only case where cocoa might have to be enabled on an arch by arch basis. --- configure | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 7744d51..0030c6c 100755 --- a/configure +++ b/configure @@ -5968,25 +5968,34 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_ARCHS" = "" ]; then [ "$OPT_VERBOSE" = "yes" ] && echo "Setting Mac architechture to$CFG_MAC_ARCHS." fi -# enable cocoa and/or carbon on Mac +# enable Cocoa and/or Carbon on Mac +# -carbon on the command line disables Cocoa, except for 64-bit archs if [ "$CFG_MAC_CARBON" = "yes" ]; then -# -carbon on the command line disables Cocoa, except for 64b-bit archs CFG_MAC_CARBON="YES" CFG_MAC_COCOA="NO" -fi -# check which archs are in use, enable cocoa if we find a 64-bit one -if echo "$CFG_MAC_ARCHS" | grep 64 > /dev/null 2>&1; then - CFG_MAC_COCOA="yes"; - CFG_MAC_CARBON="no"; - if echo "$CFG_MAC_ARCHS" | grep -w ppc > /dev/null 2>&1; then - CFG_MAC_CARBON="yes"; + +# check which archs are in use, enable cocoa if we find a 64-bit one + if echo "$CFG_MAC_ARCHS" | grep 64 > /dev/null 2>&1; then + CFG_MAC_COCOA="yes"; + CFG_MAC_CARBON="no"; + if echo "$CFG_MAC_ARCHS" | grep -w ppc > /dev/null 2>&1; then + CFG_MAC_CARBON="yes"; + fi + if echo "$CFG_MAC_ARCHS" | grep -w x86 > /dev/null 2>&1; then + CFG_MAC_CARBON="yes"; + fi fi - if echo "$CFG_MAC_ARCHS" | grep -w x86 > /dev/null 2>&1; then +fi + +# select Carbon on 10.4 Tiger. +if [ "$PLATFORM_MAC" = "yes" ]; then + VERSION=`uname -r | tr '.' ' ' | awk '{print $1}'` + if [ "$VERSION" == 8 ]; then + CFG_MAC_COCOA="no"; CFG_MAC_CARBON="yes"; fi fi - # set the global Mac deployment target. This is overridden on an arch-by-arch basis # in some cases, see code further down case "$PLATFORM,$CFG_MAC_COCOA" in -- cgit v0.12 From 2399046fbc9dc2c9f7250a43a83ce6f800b59922 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 6 Jan 2010 16:49:21 +0100 Subject: Fix build on other platforms than Mac $CFG_MAC_COCOA has a default value of yes now so be sure we the platform is Mac before doing anything with it. Reviewed-by:thiago --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 0030c6c..ec23103 100755 --- a/configure +++ b/configure @@ -6911,9 +6911,9 @@ if [ "$CFG_LARGEFILE" = "yes" ]; then fi # if both carbon and cocoa are specified, enable the autodetection code. -if [ "$CFG_MAC_COCOA" = "yes" -a "$CFG_MAC_CARBON" = "yes" ]; then +if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" -a "$CFG_MAC_CARBON" = "yes" ]; then echo "#define AUTODETECT_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new" -elif [ "$CFG_MAC_COCOA" = "yes" ]; then +elif [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then echo "#define QT_MAC_USE_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new" fi -- cgit v0.12 From a8e3cca9032b471c1efd018a75456ee9beb70b13 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 6 Jan 2010 16:53:29 +0100 Subject: Our variables are our variables so we prefix them. AUTODETECT_COCOA -> QT_AUTODETECT_COCOA Reviewed-by:thiago --- configure | 2 +- src/corelib/global/qglobal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ec23103..0644cc0 100755 --- a/configure +++ b/configure @@ -6912,7 +6912,7 @@ fi # if both carbon and cocoa are specified, enable the autodetection code. if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" -a "$CFG_MAC_CARBON" = "yes" ]; then - echo "#define AUTODETECT_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new" + echo "#define QT_AUTODETECT_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new" elif [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then echo "#define QT_MAC_USE_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new" fi diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1f0b80c..e285517 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -275,7 +275,7 @@ namespace QT_NAMESPACE {} # endif #endif -#ifdef AUTODETECT_COCOA +#ifdef QT_AUTODETECT_COCOA # ifdef Q_OS_MAC64 # define QT_MAC_USE_COCOA 1 # define QT_BUILD_KEY QT_BUILD_KEY_COCOA -- cgit v0.12 From 0647ea310c3880a0b1457f750dd6d092666c14de Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 6 Jan 2010 18:42:56 +0100 Subject: Qt 5 comment added for QT_WA / QT_WA_INLINE removal --- src/corelib/global/qglobal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e285517..573626d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1540,6 +1540,7 @@ inline QT3_SUPPORT bool qt_winUnicode() { return true; } inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; } #endif +// ### Qt 5: remove Win9x support macros QT_WA and QT_WA_INLINE. #define QT_WA(unicode, ansi) unicode #define QT_WA_INLINE(unicode, ansi) (unicode) -- cgit v0.12 From 58112b1e251c03b0a72511508712f9a67ce84d25 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 7 Jan 2010 08:57:54 +1000 Subject: Add QImage::constBits() and QImage::constScanLine() QImage::bits() and QImage::scanLine() can create deep copies if the QImage is not const. The constBits() and constScanLine() functions make things more explicit and less error-prone. Reviewed-by: Daniel Pope --- src/gui/image/qimage.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- src/gui/image/qimage.h | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ec8dd88..fc1107d 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1832,7 +1832,7 @@ void QImage::setColor(int i, QRgb c) qAlpha() to access the pixels. \sa bytesPerLine(), bits(), {QImage#Pixel Manipulation}{Pixel - Manipulation} + Manipulation}, constScanLine() */ uchar *QImage::scanLine(int i) { @@ -1862,6 +1862,28 @@ const uchar *QImage::scanLine(int i) const /*! + Returns a pointer to the pixel data at the scanline with index \a + i. The first scanline is at index 0. + + The scanline data is aligned on a 32-bit boundary. + + Note that QImage uses \l{Implicit Data Sharing} {implicit data + sharing}, but this function does \e not perform a deep copy of the + shared pixel data, because the returned data is const. + + \sa scanLine(), constBits() + \since 4.7 +*/ +const uchar *QImage::constScanLine(int i) const +{ + if (!d) + return 0; + + Q_ASSERT(i >= 0 && i < height()); + return d->data + i * d->bytes_per_line; +} + +/*! Returns a pointer to the first pixel data. This is equivalent to scanLine(0). @@ -1870,7 +1892,7 @@ const uchar *QImage::scanLine(int i) const data, thus ensuring that this QImage is the only one using the current return value. - \sa scanLine(), byteCount() + \sa scanLine(), byteCount(), constBits() */ uchar *QImage::bits() { @@ -1898,6 +1920,20 @@ const uchar *QImage::bits() const } +/*! + Returns a pointer to the first pixel data. + + Note that QImage uses \l{Implicit Data Sharing} {implicit data + sharing}, but this function does \e not perform a deep copy of the + shared pixel data, because the returned data is const. + + \sa bits(), constScanLine() + \since 4.7 +*/ +const uchar *QImage::constBits() const +{ + return d ? d->data : 0; +} /*! \fn void QImage::reset() diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index ce7f450..4e74c0e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -182,6 +182,7 @@ public: uchar *bits(); const uchar *bits() const; + const uchar *constBits() const; #ifdef QT_DEPRECATED QT_DEPRECATED int numBytes() const; #endif @@ -189,6 +190,7 @@ public: uchar *scanLine(int); const uchar *scanLine(int) const; + const uchar *constScanLine(int) const; int bytesPerLine() const; bool valid(int x, int y) const; -- cgit v0.12 From 4d786b6961f23af6edccf75c6b41267285fefcda Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 7 Jan 2010 10:38:52 +0100 Subject: Cocoa: problems quitting application when not using qApp::exec This problem has been around before. At that time it had to do with what part of the application received the kEAQuit apple event. In Qt-4.7 we ensure that NSApplication gets run at least once before we do any other event processing in Qt. That way the menu bar gets fully initialized. The backside of the coin is that NSApplication will not let the quit menu send a terminate action to the menu nibs file owner (qmenuloader_mac.mm) when a modal window is showing on screen. This is normally expected behaviour, but in Qt we allow the user to quit when just a single window/dialog is showing on screen. This fix remaps the quit items target from files owner to first responder. That way we can catch the terminate at the window/responder beeing that, and terminate as needed. Task-number: QTBUG-7197 Reviewed-by: Prasanth --- src/gui/kernel/kernel.pri | 1 + src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 7 +++++++ src/gui/mac/qt_menu.nib/classes.nib | 16 ++++++++-------- src/gui/mac/qt_menu.nib/info.nib | 4 ++-- src/gui/mac/qt_menu.nib/keyedobjects.nib | Bin 5567 -> 5560 bytes 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index f2bd288..30cb043 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -201,6 +201,7 @@ embedded { OBJECTIVE_HEADERS += \ qcocoawindow_mac_p.h \ + qcocoapanel_mac_p.h \ qcocoawindowdelegate_mac_p.h \ qcocoaview_mac_p.h \ qcocoaapplication_mac_p.h \ diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 7661b89..31d81d9 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -160,6 +160,13 @@ QT_END_NAMESPACE qt_dispatchTabletProximityEvent(tabletEvent); } +- (void)terminate:(id)sender +{ + // This function is called from the quit item in the + // menubar, when this window is the first responder + [NSApp terminate:sender]; +} + - (void)sendEvent:(NSEvent *)event { QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; diff --git a/src/gui/mac/qt_menu.nib/classes.nib b/src/gui/mac/qt_menu.nib/classes.nib index fed50a3..0031e0e 100644 --- a/src/gui/mac/qt_menu.nib/classes.nib +++ b/src/gui/mac/qt_menu.nib/classes.nib @@ -5,14 +5,6 @@ IBClasses - CLASS - FirstResponder - LANGUAGE - ObjC - SUPERCLASS - NSObject - - ACTIONS hide @@ -52,6 +44,14 @@ SUPERCLASS NSResponder + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + IBVersion 1 diff --git a/src/gui/mac/qt_menu.nib/info.nib b/src/gui/mac/qt_menu.nib/info.nib index 768cb8b..02e5cca 100644 --- a/src/gui/mac/qt_menu.nib/info.nib +++ b/src/gui/mac/qt_menu.nib/info.nib @@ -3,7 +3,7 @@ IBFramework Version - 670 + 672 IBOldestOS 5 IBOpenObjects @@ -11,7 +11,7 @@ 57 IBSystem Version - 9G55 + 9L31a targetFramework IBCocoaFramework diff --git a/src/gui/mac/qt_menu.nib/keyedobjects.nib b/src/gui/mac/qt_menu.nib/keyedobjects.nib index 18a6648..3edb0ed 100644 Binary files a/src/gui/mac/qt_menu.nib/keyedobjects.nib and b/src/gui/mac/qt_menu.nib/keyedobjects.nib differ -- cgit v0.12 From 5339d24dc09525a67295adf98e9042971f4a9b2e Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 7 Jan 2010 10:58:17 +0100 Subject: QMenuBar::triggered(QAction *) fires twice in Mac (carbon). The signal was being emitted both from the carbon event handler and the platform independent code of QMenu. The one in the event handler is now removed. Task-number: 6741 Reviewed-by: Richard Moe Gustavsen --- src/gui/widgets/qmenu_mac.mm | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 30bbd31..99301ee 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -231,7 +231,7 @@ bool qt_mac_activate_action(MenuRef menu, uint command, QAction::ActionEvent act //now walk up firing for each "caused" widget (like in the platform independent menu) QWidget *caused = 0; - if (GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) { + if (action_e == QAction::Hover && GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) { MenuRef caused_menu = 0; if (QMenu *qmenu2 = qobject_cast(caused)) caused_menu = qmenu2->macMenu(); @@ -244,25 +244,17 @@ bool qt_mac_activate_action(MenuRef menu, uint command, QAction::ActionEvent act QWidget *widget = 0; GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(widget), 0, &widget); if (QMenu *qmenu = qobject_cast(widget)) { - if (action_e == QAction::Trigger) { - emit qmenu->triggered(action->action); - } else if (action_e == QAction::Hover) { - action->action->showStatusText(widget); - emit qmenu->hovered(action->action); - } + action->action->showStatusText(widget); + emit qmenu->hovered(action->action); } else if (QMenuBar *qmenubar = qobject_cast(widget)) { - if (action_e == QAction::Trigger) { - emit qmenubar->triggered(action->action); - } else if (action_e == QAction::Hover) { - action->action->showStatusText(widget); - emit qmenubar->hovered(action->action); - } + action->action->showStatusText(widget); + emit qmenubar->hovered(action->action); break; //nothing more.. } //walk up if (GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, - sizeof(caused), 0, &caused) != noErr) + sizeof(caused), 0, &caused) != noErr) break; if (QMenu *qmenu2 = qobject_cast(caused)) caused_menu = qmenu2->macMenu(); -- cgit v0.12 From 63e248aae7aecce2299bfd7941bd37fdfc136dcf Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 7 Jan 2010 14:11:28 +0100 Subject: Mac style doesn't honour QStyle::State_HasFocus for non-widgets. This patch draws the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). The frame is drawn outside the rectangle passed in the option-rect. Task-number: QTBUG-5530 Reviewed-by: MortenS --- src/gui/styles/qmacstyle_mac.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 4075cf7..53740fc 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3109,6 +3109,18 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai break; case PE_PanelLineEdit: QWindowsStyle::drawPrimitive(pe, opt, p, w); + // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). + // Focus frame is drawn outside the rectangle passed in the option-rect. + if (const QStyleOptionFrame *panel = qstyleoption_cast(opt)) { + if ((opt->state & State_HasFocus) && !qobject_cast(w)) { + int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin); + int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); + QStyleOptionFrame focusFrame = *panel; + focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin); + drawControl(CE_FocusFrame, &focusFrame, p, w); + } + } + break; case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *twf -- cgit v0.12 From 9701f97b6f14e25b405adb7e82ef0ec93a6b8a0f Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 7 Jan 2010 14:22:05 +0100 Subject: Assistant: Add doucmentation for -rebuild-search-index option. Reviewed-by: David Boddie --- doc/src/development/assistant-manual.qdoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/development/assistant-manual.qdoc b/doc/src/development/assistant-manual.qdoc index fb9bbda..824169d 100644 --- a/doc/src/development/assistant-manual.qdoc +++ b/doc/src/development/assistant-manual.qdoc @@ -154,13 +154,17 @@ \row \o -unregister \o Unregisters the specified compressed help file from the given - collection file. + collection file. \row \o -remove-search-index \o Purges the help search engine's index. This option is useful in case the associated index files get corrupted. \QA will re-index the documentation at the next start-up. \row + \o -rebuild-search-index + \o Rebuilds the help search engine's index. + Note that this operation may take a while to finish. + \row \o -setCurrentFilter \o Sets the given filter as the active filter. \row -- cgit v0.12 From 59a8e0200b912481ff750401ef10c588ad9bd872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 7 Jan 2010 13:22:53 +0100 Subject: Don't use QTime::elapsed() on windows to query for the actual time. It seems that the time spent between the execution of QTime::start() and QTime::elapsed() can be higher than what QTime::elapsed() sometimes reports. (To put it differently, QTime::elapsed() was sometimes returning a time that was *less* than the actual time spent.) Note that this is *not* a bug on Windows, since GetLocalTime explicitly mentions that we should not use local system times to to relative comparisions (this is what elapsed() currently do). This is also partly reflected by the documentation of QTime::elapsed(), where it says that the result of elapsed() is undefined if the clock setting has been changed. Due to the fact mentioned in the above paragraph this is also a potential problem on other platforms (at least Linux and Mac). However, these platforms do not suffer from the immediate problem we observed on windows (that QTime::elapsed() could return a too small value), so this commit only fixes the problem on Windows (it now uses GetTickCount instead of QTime). For the other platforms the behaviour should be unchanged, since we still use QTime. This was found by running the QPauseAnimation autotest, where some tests were unstable (and failed). However, it did not fail on all windows systems. (Luckilly it failed on my Win 7 system) Reviewed-by: Leo --- src/corelib/animation/qabstractanimation.cpp | 2 +- src/corelib/animation/qabstractanimation_p.h | 62 +++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 299585a..de972d4 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -242,7 +242,7 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) animationTimer.stop(); isPauseTimerActive = false; // invalidate the start reference time - time = QTime(); + time.invalidate(); } else { restartAnimationTimer(); if (!time.isValid()) { diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 720e68d..04dd218 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -58,6 +58,10 @@ #include #include +#ifdef Q_OS_WIN +#include +#endif + #ifndef QT_NO_ANIMATION QT_BEGIN_NAMESPACE @@ -109,6 +113,61 @@ private: Q_DECLARE_PUBLIC(QAbstractAnimation) }; +class ElapsedTimer +{ +public: + ElapsedTimer() { + invalidate(); + } + + void invalidate() { + m_started = -1; + } + + bool isValid() const { + return m_started >= 0; + } + + void start() { + m_started = getTickCount_sys(); + } + + qint64 elapsed() const { + qint64 current = getTickCount_sys(); + qint64 delta = current - m_started; + if (delta < 0) + delta += getPeriod_sys(); //we wrapped around + return delta; + } + +private: + enum { + MSECS_PER_HOUR = 3600000, + MSECS_PER_MIN = 60000 + }; + + qint64 m_started; + + quint64 getPeriod_sys() const { +#ifdef Q_OS_WIN + return Q_UINT64_C(0x100000000); +#else + // fallback + return 86400 * 1000; +#endif + } + + qint64 getTickCount_sys() const { +#ifdef Q_OS_WIN + return ::GetTickCount(); +#else + // fallback + const QTime t = QTime::currentTime(); + return MSECS_PER_HOUR * t.hour() + MSECS_PER_MIN * t.minute() + 1000 * t.second() + t.msec(); +#endif + } +}; + class QUnifiedTimer : public QObject { @@ -162,7 +221,8 @@ private: // timer used to delay the check if we should start/stop the animation timer QBasicTimer startStopAnimationTimer; - QTime time; + ElapsedTimer time; + int lastTick; int timingInterval; int currentAnimationIdx; -- cgit v0.12 From 9b0502aa6abf6bb9c07f205bccdf2d9c65027bde Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 8 Jan 2010 10:18:52 +0100 Subject: Fixes: Checked QPushbutton ignores stylesheet backround: This is because the light() color of the palette is used and it was not modified. Task-number: QTBUG-7216 Reviewed-by: jbache --- src/gui/styles/qstylesheetstyle.cpp | 6 ++++ .../uiloader/baseline/css_buttons_background.ui | 39 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index aff3ac0..56cc364 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1350,6 +1350,12 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette if (br != QPalette::NoRole) p->setBrush(br, bg->brush); p->setBrush(QPalette::Window, bg->brush); + if (bg->brush.style() == Qt::SolidPattern) { + p->setBrush(QPalette::Light, bg->brush.color().lighter(115)); + p->setBrush(QPalette::Midlight, bg->brush.color().lighter(107)); + p->setBrush(QPalette::Dark, bg->brush.color().darker(150)); + p->setBrush(QPalette::Shadow, bg->brush.color().darker(300)); + } } if (!hasPalette()) diff --git a/tests/auto/uiloader/baseline/css_buttons_background.ui b/tests/auto/uiloader/baseline/css_buttons_background.ui index f1fa0bc..3d80aeb 100644 --- a/tests/auto/uiloader/baseline/css_buttons_background.ui +++ b/tests/auto/uiloader/baseline/css_buttons_background.ui @@ -89,6 +89,19 @@ color: yellow; + + + + Checked + + + true + + + true + + + @@ -149,6 +162,19 @@ color: yellow; + + + + Checked + + + true + + + true + + + @@ -209,6 +235,19 @@ color: yellow; + + + + Checked + + + true + + + true + + + -- cgit v0.12 From 71f7c1d006d0942fb91e795855bd00a35f226385 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 28 Dec 2009 13:58:25 +0100 Subject: QStyleSheetStyle: Fixed some text croped when having padding with native border. The native border width need to be taken into account in QRenderRule::boxRect() Task-number: QTBUG-6855 Reviewed-by: Benjamin Poulain (cherry picked from commit 6e90192b599cee9b903177a0978198326f667613) --- src/gui/styles/qstylesheetstyle.cpp | 2 +- tests/auto/uiloader/baseline/css_qtbug6855.ui | 57 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/auto/uiloader/baseline/css_qtbug6855.ui diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index ca6968b..56cc364 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1065,7 +1065,7 @@ QRect QRenderRule::boxRect(const QRect& cr, int flags) const r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]); } } - if (!hasNativeBorder() && (flags & Border)) { + if (hasBorder() && (flags & Border)) { const int *b = border()->borders; r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]); } diff --git a/tests/auto/uiloader/baseline/css_qtbug6855.ui b/tests/auto/uiloader/baseline/css_qtbug6855.ui new file mode 100644 index 0000000..0727f6b --- /dev/null +++ b/tests/auto/uiloader/baseline/css_qtbug6855.ui @@ -0,0 +1,57 @@ + + + Form + + + + 0 + 0 + 212 + 108 + + + + Form + + + QPushButton { padding: 20px; } + + + + + + Text not cropped + + + + + + + Qt::Horizontal + + + + 258 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 218 + + + + + + + + + -- cgit v0.12 From 319b0262418d74cc416a7dd1f620b54ba45bad22 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 8 Jan 2010 15:33:06 +0100 Subject: Obsolete QDirModel and remove it from the doc. QFileSystemModel provides the same features as QDirModel but in a efficient way so no need to keep QDirModel around. This commit mark as obsolete QDirModel. Examples has been ported to use QFileSystemModel instead. QCompleter also gain the support of QFileSystemModel to complete nicely a line edit. This commit also add a new signal in QFileSystemModel when the directory is loaded, i.e. the thread has finished to read the current dir. Task-number:QTBUG-3884 Reviewed-by:ogoffart Reviewed-by:gabi Reviewed-by:mbm --- examples/itemviews/dirview/main.cpp | 3 +- examples/tools/completer/dirmodel.cpp | 9 +++-- examples/tools/completer/dirmodel.h | 12 +++--- examples/tools/completer/mainwindow.cpp | 18 +++++---- src/gui/dialogs/qfileinfogatherer.cpp | 1 + src/gui/dialogs/qfileinfogatherer_p.h | 1 + src/gui/dialogs/qfilesystemmodel.cpp | 10 +++++ src/gui/dialogs/qfilesystemmodel.h | 1 + src/gui/itemviews/qdirmodel.cpp | 4 +- src/gui/itemviews/qfileiconprovider.cpp | 2 +- src/gui/util/qcompleter.cpp | 70 +++++++++++++++++++++++++++------ src/gui/util/qcompleter.h | 1 + src/gui/util/qcompleter_p.h | 1 + 13 files changed, 98 insertions(+), 35 deletions(-) diff --git a/examples/itemviews/dirview/main.cpp b/examples/itemviews/dirview/main.cpp index 768046a..e7e343e 100644 --- a/examples/itemviews/dirview/main.cpp +++ b/examples/itemviews/dirview/main.cpp @@ -45,7 +45,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDirModel model; + QFileSystemModel model; + model.setRootPath(""); QTreeView tree; tree.setModel(&model); diff --git a/examples/tools/completer/dirmodel.cpp b/examples/tools/completer/dirmodel.cpp index 9fd7763..1173d88 100644 --- a/examples/tools/completer/dirmodel.cpp +++ b/examples/tools/completer/dirmodel.cpp @@ -42,14 +42,14 @@ #include "dirmodel.h" //! [0] -DirModel::DirModel(QObject *parent) - : QDirModel(parent) +FileSystemModel::FileSystemModel(QObject *parent) + : QFileSystemModel(parent) { } //! [0] //! [1] -QVariant DirModel::data(const QModelIndex &index, int role) const +QVariant FileSystemModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole && index.column() == 0) { QString path = QDir::toNativeSeparators(filePath(index)); @@ -58,6 +58,7 @@ QVariant DirModel::data(const QModelIndex &index, int role) const return path; } - return QDirModel::data(index, role); + return QFileSystemModel::data(index, role); } + //! [1] diff --git a/examples/tools/completer/dirmodel.h b/examples/tools/completer/dirmodel.h index a690f6c..5f4d2a7 100644 --- a/examples/tools/completer/dirmodel.h +++ b/examples/tools/completer/dirmodel.h @@ -39,21 +39,21 @@ ** ****************************************************************************/ -#ifndef DIRMODEL_H -#define DIRMODEL_H +#ifndef FILESYSTEMMODEL_H +#define FILESYSTEMMODEL_H -#include +#include -// With a QDirModel, set on a view, you will see "Program Files" in the view +// With a QFileSystemModel, set on a view, you will see "Program Files" in the view // But with this model, you will see "C:\Program Files" in the view. // We acheive this, by having the data() return the entire file path for // the display role. Note that the Qt::EditRole over which the QCompleter // looks for matches is left unchanged //! [0] -class DirModel : public QDirModel +class FileSystemModel : public QFileSystemModel { public: - DirModel(QObject *parent = 0); + FileSystemModel(QObject *parent = 0); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; }; //! [0] diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp index 8fe8c37..e5ee68e 100644 --- a/examples/tools/completer/mainwindow.cpp +++ b/examples/tools/completer/mainwindow.cpp @@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent) modelLabel->setText(tr("Model")); modelCombo = new QComboBox; - modelCombo->addItem(tr("QDirModel")); - modelCombo->addItem(tr("QDirModel that shows full path")); + modelCombo->addItem(tr("QFileSytemModel")); + modelCombo->addItem(tr("QFileSytemModel that shows full path")); modelCombo->addItem(tr("Country list")); modelCombo->addItem(tr("Word list")); modelCombo->setCurrentIndex(0); @@ -218,17 +218,19 @@ void MainWindow::changeModel() switch (modelCombo->currentIndex()) { default: case 0: - { // Unsorted QDirModel - QDirModel *dirModel = new QDirModel(completer); - completer->setModel(dirModel); + { // Unsorted QFileSystemModel + QFileSystemModel *fsModel = new QFileSystemModel(completer); + fsModel->setRootPath(""); + completer->setModel(fsModel); contentsLabel->setText(tr("Enter file path")); } break; //! [11] //! [12] case 1: - { // DirModel that shows full paths - DirModel *dirModel = new DirModel(completer); - completer->setModel(dirModel); + { // FileSystemModel that shows full paths + FileSystemModel *fsModel = new FileSystemModel(completer); + completer->setModel(fsModel); + fsModel->setRootPath(""); contentsLabel->setText(tr("Enter file path")); } break; diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp index 2729530..bcabb20 100644 --- a/src/gui/dialogs/qfileinfogatherer.cpp +++ b/src/gui/dialogs/qfileinfogatherer.cpp @@ -354,6 +354,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil } if (!updatedFiles.isEmpty()) emit updates(path, updatedFiles); + emit directoryLoaded(path); } void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QTime &base, bool &firstTime, QList > &updatedFiles, const QString &path) { diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h index b722410..db4e1d0 100644 --- a/src/gui/dialogs/qfileinfogatherer_p.h +++ b/src/gui/dialogs/qfileinfogatherer_p.h @@ -155,6 +155,7 @@ Q_SIGNALS: void updates(const QString &directory, const QList > &updates); void newListOfFiles(const QString &directory, const QStringList &listOfFiles) const; void nameResolved(const QString &fileName, const QString &resolvedName) const; + void directoryLoaded(const QString &path); public: QFileInfoGatherer(QObject *parent = 0); diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 6ec80a9..063f979 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -150,6 +150,14 @@ QT_BEGIN_NAMESPACE */ /*! + \since 4.7 + \fn void QFileSystemModel::directoryLoaded(const QString &path) + + This signal is emitted when the gatherer thread has finished to load the \a path. + +*/ + +/*! \fn bool QFileSystemModel::remove(const QModelIndex &index) const Removes the model item \a index from the file system model and \bold{deletes the @@ -1869,6 +1877,8 @@ void QFileSystemModelPrivate::init() q, SLOT(_q_fileSystemChanged(QString,QList >))); q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)), q, SLOT(_q_resolvedName(QString,QString))); + q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)), + q, SIGNAL(directoryLoaded(QString))); q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); } diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h index 4a3c892..a41bc3f 100644 --- a/src/gui/dialogs/qfilesystemmodel.h +++ b/src/gui/dialogs/qfilesystemmodel.h @@ -70,6 +70,7 @@ class Q_GUI_EXPORT QFileSystemModel : public QAbstractItemModel Q_SIGNALS: void rootPathChanged(const QString &newPath); void fileRenamed(const QString &path, const QString &oldName, const QString &newName); + void directoryLoaded(const QString &path); public: enum Roles { diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp index 942cfd7..ddbe51c 100644 --- a/src/gui/itemviews/qdirmodel.cpp +++ b/src/gui/itemviews/qdirmodel.cpp @@ -185,12 +185,12 @@ void QDirModelPrivate::invalidate() /*! \class QDirModel - + \obsolete \brief The QDirModel class provides a data model for the local filesystem. \ingroup model-view - \note The usage of QDirModel is not recommended anymore. The + The usage of QDirModel is not recommended anymore. The QFileSystemModel class is a more performant alternative. This class provides access to the local filesystem, providing functions diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index 6316797..0241d4a 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE /*! \class QFileIconProvider - \brief The QFileIconProvider class provides file icons for the QDirModel class. + \brief The QFileIconProvider class provides file icons for the QDirModel and the QFileSystemModel classes. */ /*! diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 30bccfb..eeabc22 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -62,7 +62,7 @@ \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0 - A QDirModel can be used to provide auto completion of file names. + A QFileSystemModel can be used to provide auto completion of file names. For example: \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 1 @@ -120,7 +120,7 @@ completion is then performed one level at a time. Let's take the example of a user typing in a file system path. - The model is a (hierarchical) QDirModel. The completion + The model is a (hierarchical) QFileSystemModel. The completion occurs for every element in the path. For example, if the current text is \c C:\Wind, QCompleter might suggest \c Windows to complete the current path element. Similarly, if the current text @@ -130,12 +130,12 @@ split the path into a list of strings that are matched at each level. For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy". The default implementation of splitPath(), splits the completionPrefix - using QDir::separator() if the model is a QDirModel. + using QDir::separator() if the model is a QFileSystemModel. To provide completions, QCompleter needs to know the path from an index. This is provided by pathFromIndex(). The default implementation of pathFromIndex(), returns the data for the \l{Qt::EditRole}{edit role} - for list models and the absolute file path if the mode is a QDirModel. + for list models and the absolute file path if the mode is a QFileSystemModel. \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example} */ @@ -147,6 +147,7 @@ #include "QtGui/qscrollbar.h" #include "QtGui/qstringlistmodel.h" #include "QtGui/qdirmodel.h" +#include "QtGui/qfilesystemmodel.h" #include "QtGui/qheaderview.h" #include "QtGui/qlistview.h" #include "QtGui/qapplication.h" @@ -470,9 +471,13 @@ QMatchData QCompletionEngine::filterHistory() QAbstractItemModel *source = c->proxy->sourceModel(); if (curParts.count() <= 1 || c->proxy->showAll || !source) return QMatchData(); - bool dirModel = false; + bool isDirModel = false; + bool isFsModel = false; #ifndef QT_NO_DIRMODEL - dirModel = (qobject_cast(source) != 0); + isDirModel = (qobject_cast(source) != 0); +#endif +#ifndef QT_NO_FILESYSTEMMODEL + isFsModel = (qobject_cast(source) != 0); #endif QVector v; QIndexMapper im(v); @@ -482,7 +487,7 @@ QMatchData QCompletionEngine::filterHistory() QString str = source->index(i, c->column).data().toString(); if (str.startsWith(c->prefix, c->cs) #if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) - && (!dirModel || QDir::toNativeSeparators(str) != QDir::separator()) + && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator()) #endif ) m.indices.append(i); @@ -838,6 +843,13 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) completion += QDir::separator(); } #endif +#ifndef QT_NO_FILESYSTEMMODEL + // add a trailing separator in inline + if (mode == QCompleter::InlineCompletion) { + if (qobject_cast(proxy->sourceModel()) && QFileInfo(completion).isDir()) + completion += QDir::separator(); + } +#endif } if (highlighted) { @@ -891,6 +903,14 @@ void QCompleterPrivate::showPopup(const QRect& rect) popup->show(); } + +void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path) +{ + Q_Q(QCompleter); + Q_UNUSED(path); + q->complete(); +} + /*! Constructs a completer object with the given \a parent. */ @@ -971,7 +991,7 @@ QWidget *QCompleter::widget() const be list model or a tree model. If a model has been already previously set and it has the QCompleter as its parent, it is deleted. - For convenience, if \a model is a QDirModel, QCompleter switches its + For convenience, if \a model is a QFileSystemModel, QCompleter switches its caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive on other platforms. @@ -995,6 +1015,17 @@ void QCompleter::setModel(QAbstractItemModel *model) #endif } #endif // QT_NO_DIRMODEL +#ifndef QT_NO_FILESYSTEMMODEL + QFileSystemModel *fsModel = qobject_cast(model); + if (fsModel) { +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) + setCaseSensitivity(Qt::CaseInsensitive); +#else + setCaseSensitivity(Qt::CaseSensitive); +#endif + connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString))); + } +#endif // QT_NO_FILESYSTEMMODEL } /*! @@ -1626,10 +1657,11 @@ QAbstractItemModel *QCompleter::completionModel() const The default implementation returns the \l{Qt::EditRole}{edit role} of the item for list models. It returns the absolute file path if the model is a - QDirModel. + QFileSystemModel. \sa splitPath() */ + QString QCompleter::pathFromIndex(const QModelIndex& index) const { Q_D(const QCompleter); @@ -1639,10 +1671,15 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const QAbstractItemModel *sourceModel = d->proxy->sourceModel(); if (!sourceModel) return QString(); + bool isDirModel = false; + bool isFsModel = false; #ifndef QT_NO_DIRMODEL - QDirModel *dirModel = qobject_cast(sourceModel); - if (!dirModel) + isDirModel = qobject_cast(d->proxy->sourceModel()) != 0; +#endif +#ifndef QT_NO_FILESYSTEMMODEL + isFsModel = qobject_cast(d->proxy->sourceModel()) != 0; #endif + if (!isDirModel && !isFsModel) return sourceModel->data(index, d->role).toString(); QModelIndex idx = index; @@ -1668,7 +1705,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const in the model(). The default implementation of splitPath() splits a file system path based on - QDir::separator() when the sourceModel() is a QDirModel. + QDir::separator() when the sourceModel() is a QFileSystemModel. When used with list models, the first item in the returned list is used for matching. @@ -1678,12 +1715,19 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const QStringList QCompleter::splitPath(const QString& path) const { bool isDirModel = false; + bool isFsModel = false; #ifndef QT_NO_DIRMODEL Q_D(const QCompleter); isDirModel = qobject_cast(d->proxy->sourceModel()) != 0; #endif +#ifndef QT_NO_FILESYSTEMMODEL +#ifdef QT_NO_DIRMODEL + Q_D(const QCompleter); +#endif + isFsModel = qobject_cast(d->proxy->sourceModel()) != 0; +#endif - if (!isDirModel || path.isEmpty()) + if ((!isDirModel && !isFsModel) || path.isEmpty()) return QStringList(completionPrefix()); QString pathCopy = QDir::toNativeSeparators(path); diff --git a/src/gui/util/qcompleter.h b/src/gui/util/qcompleter.h index c6ec75d..16cdac0 100644 --- a/src/gui/util/qcompleter.h +++ b/src/gui/util/qcompleter.h @@ -159,6 +159,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_complete(QModelIndex)) Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&)) Q_PRIVATE_SLOT(d_func(), void _q_autoResizePopup()) + Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&)) }; #endif // QT_NO_COMPLETER diff --git a/src/gui/util/qcompleter_p.h b/src/gui/util/qcompleter_p.h index 107d85f..84a1a74 100644 --- a/src/gui/util/qcompleter_p.h +++ b/src/gui/util/qcompleter_p.h @@ -98,6 +98,7 @@ public: void _q_complete(QModelIndex, bool = false); void _q_completionSelected(const QItemSelection&); void _q_autoResizePopup(); + void _q_fileSystemModelDirectoryLoaded(const QString &path); void setCurrentIndex(QModelIndex, bool = true); }; -- cgit v0.12 From 158d63b56da7433ca627ad82635541c3c17c74e1 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 8 Jan 2010 16:16:00 +0100 Subject: Rename files in completer example since QDirModel is not used. Doc updated for the example. Reviewed-by:TrustMe --- doc/src/examples/completer.qdoc | 30 ++++++++-------- examples/tools/completer/completer.pro | 4 +-- examples/tools/completer/dirmodel.cpp | 64 ---------------------------------- examples/tools/completer/dirmodel.h | 61 -------------------------------- examples/tools/completer/fsmodel.cpp | 64 ++++++++++++++++++++++++++++++++++ examples/tools/completer/fsmodel.h | 61 ++++++++++++++++++++++++++++++++ 6 files changed, 142 insertions(+), 142 deletions(-) delete mode 100644 examples/tools/completer/dirmodel.cpp delete mode 100644 examples/tools/completer/dirmodel.h create mode 100644 examples/tools/completer/fsmodel.cpp create mode 100644 examples/tools/completer/fsmodel.h diff --git a/doc/src/examples/completer.qdoc b/doc/src/examples/completer.qdoc index d092027..8a743a7 100644 --- a/doc/src/examples/completer.qdoc +++ b/doc/src/examples/completer.qdoc @@ -48,7 +48,7 @@ \image completer-example.png - This example uses a custom item model, \c DirModel, and a QCompleter object. + This example uses a custom item model, \c FileSystemModel, and a QCompleter object. QCompleter is a class that provides completions based on an item model. The type of model, the completion mode, and the case sensitivity can be selected using combo boxes. @@ -61,32 +61,32 @@ \quotefile examples/tools/completer/completer.qrc - \section1 DirModel Class Definition + \section1 FileSystemModel Class Definition - The \c DirModel class is a subclass of QDirModel, which provides a data + The \c FileSystemModel class is a subclass of QFileSystemModel, which provides a data model for the local filesystem. - \snippet examples/tools/completer/dirmodel.h 0 + \snippet examples/tools/completer/fsmodel.h 0 This class only has a constructor and a \c data() function as it is only created to enable \c data() to return the entire file path for the - display role, unlike \l{QDirModel}'s \c data() function that only returns + display role, unlike \l{QFileSystemModel}'s \c data() function that only returns the folder and not the drive label. This is further explained in - \c DirModel's implementation. + \c FileSystemModel's implementation. - \section1 DirModel Class Implementation + \section1 FileSystemModel Class Implementation - The constructor for the \c DirModel class is used to pass \a parent to - QDirModel. + The constructor for the \c FileSystemModel class is used to pass \a parent to + QFileSystemModel. - \snippet examples/tools/completer/dirmodel.cpp 0 + \snippet examples/tools/completer/fsmodel.cpp 0 As mentioned earlier, the \c data() function is reimplemented in order to get it to return the entire file parth for the display role. For example, - with a QDirModel, you will see "Program Files" in the view. However, with - \c DirModel, you will see "C:\\Program Files". + with a QFileSystemModel, you will see "Program Files" in the view. However, with + \c FileSystemModel, you will see "C:\\Program Files". - \snippet examples/tools/completer/dirmodel.cpp 1 + \snippet examples/tools/completer/fsmodel.cpp 1 The screenshots below illustrate this difference: @@ -120,7 +120,7 @@ is then invoked. We set up three QComboBox objects, \c modelComb, \c modeCombo and - \c caseCombo. By default, the \c modelCombo is set to QDirModel, + \c caseCombo. By default, the \c modelCombo is set to QFileSystemModel, the \c modeCombo is set to "Filtered Popup" and the \c caseCombo is set to "Case Insensitive". @@ -202,7 +202,7 @@ model selected by the user. A \c switch statement is used to change the item model based on the index - of \c modelCombo. If \c case is 0, we use an unsorted QDirModel, providing + of \c modelCombo. If \c case is 0, we use an unsorted QFileSystemModel, providing us with a file path excluding the drive label. \snippet examples/tools/completer/mainwindow.cpp 11 diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro index 96d3734..14521b2 100644 --- a/examples/tools/completer/completer.pro +++ b/examples/tools/completer/completer.pro @@ -1,6 +1,6 @@ -HEADERS = dirmodel.h \ +HEADERS = fsmodel.h \ mainwindow.h -SOURCES = dirmodel.cpp \ +SOURCES = fsmodel.cpp \ main.cpp \ mainwindow.cpp RESOURCES = completer.qrc diff --git a/examples/tools/completer/dirmodel.cpp b/examples/tools/completer/dirmodel.cpp deleted file mode 100644 index 1173d88..0000000 --- a/examples/tools/completer/dirmodel.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "dirmodel.h" - -//! [0] -FileSystemModel::FileSystemModel(QObject *parent) - : QFileSystemModel(parent) -{ -} -//! [0] - -//! [1] -QVariant FileSystemModel::data(const QModelIndex &index, int role) const -{ - if (role == Qt::DisplayRole && index.column() == 0) { - QString path = QDir::toNativeSeparators(filePath(index)); - if (path.endsWith(QDir::separator())) - path.chop(1); - return path; - } - - return QFileSystemModel::data(index, role); -} - -//! [1] diff --git a/examples/tools/completer/dirmodel.h b/examples/tools/completer/dirmodel.h deleted file mode 100644 index 5f4d2a7..0000000 --- a/examples/tools/completer/dirmodel.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FILESYSTEMMODEL_H -#define FILESYSTEMMODEL_H - -#include - -// With a QFileSystemModel, set on a view, you will see "Program Files" in the view -// But with this model, you will see "C:\Program Files" in the view. -// We acheive this, by having the data() return the entire file path for -// the display role. Note that the Qt::EditRole over which the QCompleter -// looks for matches is left unchanged -//! [0] -class FileSystemModel : public QFileSystemModel -{ -public: - FileSystemModel(QObject *parent = 0); - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; -}; -//! [0] - -#endif diff --git a/examples/tools/completer/fsmodel.cpp b/examples/tools/completer/fsmodel.cpp new file mode 100644 index 0000000..8a50f2d --- /dev/null +++ b/examples/tools/completer/fsmodel.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fsmodel.h" + +//! [0] +FileSystemModel::FileSystemModel(QObject *parent) + : QFileSystemModel(parent) +{ +} +//! [0] + +//! [1] +QVariant FileSystemModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole && index.column() == 0) { + QString path = QDir::toNativeSeparators(filePath(index)); + if (path.endsWith(QDir::separator())) + path.chop(1); + return path; + } + + return QFileSystemModel::data(index, role); +} + +//! [1] diff --git a/examples/tools/completer/fsmodel.h b/examples/tools/completer/fsmodel.h new file mode 100644 index 0000000..5f4d2a7 --- /dev/null +++ b/examples/tools/completer/fsmodel.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FILESYSTEMMODEL_H +#define FILESYSTEMMODEL_H + +#include + +// With a QFileSystemModel, set on a view, you will see "Program Files" in the view +// But with this model, you will see "C:\Program Files" in the view. +// We acheive this, by having the data() return the entire file path for +// the display role. Note that the Qt::EditRole over which the QCompleter +// looks for matches is left unchanged +//! [0] +class FileSystemModel : public QFileSystemModel +{ +public: + FileSystemModel(QObject *parent = 0); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; +//! [0] + +#endif -- cgit v0.12 From d93b2ff9c976a2aea4fb1a7be68565ea0df81ba4 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 8 Jan 2010 15:10:31 +0100 Subject: Added new functions to QTextCodec that accept ConversionFlags. In some cases the user might want to pass initial conversion flags that should be used by the QTextEncoder and QTextDecoder, so added convenience QTextCodec::makeDecoder and makeEncoder functions that accept those flags as an argument. Task-number: QTBUG-7180 Reviewed-by: Thiago --- src/corelib/codecs/qtextcodec.cpp | 49 +++++++++++++++++++++++++++++++++++++++ src/corelib/codecs/qtextcodec.h | 11 ++++++--- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 5d62095..65152ca 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1163,6 +1163,19 @@ QTextDecoder* QTextCodec::makeDecoder() const return new QTextDecoder(this); } +/*! + Creates a QTextDecoder with a specified \a flags to decode chunks + of \c{char *} data to create chunks of Unicode data. + + The caller is responsible for deleting the returned object. + + \since 4.7 +*/ +QTextDecoder* QTextCodec::makeDecoder(QTextCodec::ConversionFlags flags) const +{ + return new QTextDecoder(this, flags); +} + /*! Creates a QTextEncoder which stores enough state to encode chunks @@ -1176,6 +1189,19 @@ QTextEncoder* QTextCodec::makeEncoder() const } /*! + Creates a QTextEncoder with a specified \a flags to encode chunks + of Unicode data as \c{char *} data. + + The caller is responsible for deleting the returned object. + + \since 4.7 +*/ +QTextEncoder* QTextCodec::makeEncoder(QTextCodec::ConversionFlags flags) const +{ + return new QTextEncoder(this, flags); +} + +/*! \fn QByteArray QTextCodec::fromUnicode(const QChar *input, int number, ConverterState *state) const @@ -1316,6 +1342,17 @@ QString QTextCodec::toUnicode(const char *chars) const */ /*! + Constructs a text encoder for the given \a codec and conversion \a flags. + + \since 4.7 +*/ +QTextEncoder::QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags) + : c(codec), state() +{ + state.flags = flags; +} + +/*! Destroys the encoder. */ QTextEncoder::~QTextEncoder() @@ -1392,6 +1429,18 @@ QByteArray QTextEncoder::fromUnicode(const QString& uc, int& lenInOut) */ /*! + Constructs a text decoder for the given \a codec and conversion \a flags. + + \since 4.7 +*/ + +QTextDecoder::QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags) + : c(codec), state() +{ + state.flags = flags; +} + +/*! Destroys the decoder. */ QTextDecoder::~QTextDecoder() diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 6170272..91bccda 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -85,9 +85,6 @@ public: static QTextCodec *codecForUtfText(const QByteArray &ba); static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec); - QTextDecoder* makeDecoder() const; - QTextEncoder* makeEncoder() const; - bool canEncode(QChar) const; bool canEncode(const QString&) const; @@ -120,6 +117,12 @@ public: QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const { return convertFromUnicode(in, length, state); } + // ### Qt 5: merge these functions. + QTextDecoder* makeDecoder() const; + QTextDecoder* makeDecoder(ConversionFlags flags) const; + QTextEncoder* makeEncoder() const; + QTextEncoder* makeEncoder(ConversionFlags flags) const; + virtual QByteArray name() const = 0; virtual QList aliases() const; virtual int mibEnum() const = 0; @@ -157,6 +160,7 @@ class Q_CORE_EXPORT QTextEncoder { Q_DISABLE_COPY(QTextEncoder) public: explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {} + QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags); ~QTextEncoder(); QByteArray fromUnicode(const QString& str); QByteArray fromUnicode(const QChar *uc, int len); @@ -173,6 +177,7 @@ class Q_CORE_EXPORT QTextDecoder { Q_DISABLE_COPY(QTextDecoder) public: explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {} + QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags); ~QTextDecoder(); QString toUnicode(const char* chars, int len); QString toUnicode(const QByteArray &ba); -- cgit v0.12 From 2f500df286afba5e64f5288fbc3d02e6e2e41211 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 8 Jan 2010 16:28:48 +0100 Subject: Use the new QTextCodec api in the QXmlStreamWriter. Instead of accesing private data, use the QTextCodec::makeEncoder() to pass the initial conversion flags to the codec. Also improved the behavior - we shouldn't add BOM in the middle of the data when dumping xml in all encodings, not only for utf8. Task-number: QTBUG-7180 Reviewed-by: Thiago Conflicts: src/corelib/xml/qxmlstream.cpp --- src/corelib/xml/qxmlstream.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index e31ed6d..f879315 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -3005,8 +3005,7 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) deleteDevice = false; #ifndef QT_NO_TEXTCODEC codec = QTextCodec::codecForMib(106); // utf8 - encoder = codec->makeEncoder(); - encoder->fromUnicode(QLatin1String("")); // no byte order mark for utf8 + encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 #endif inStartElement = inEmptyElement = false; wroteSomething = false; @@ -3280,9 +3279,7 @@ void QXmlStreamWriter::setCodec(QTextCodec *codec) if (codec) { d->codec = codec; delete d->encoder; - d->encoder = codec->makeEncoder(); - if (codec->mibEnum() == 106) - d->encoder->fromUnicode(QLatin1String("")); // no byte order mark for utf8 + d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 } } -- cgit v0.12 From cb0de81ad244aba16d6218085b39c2b15ab4aa96 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 11 Jan 2010 10:15:26 +0100 Subject: Add QT_{BEGIN,END}_NAMESPACE to qtextureglyphcache_gl.cpp. --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 047876f..8b4265d 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -42,6 +42,8 @@ #include "qtextureglyphcache_gl_p.h" #include "qpaintengineex_opengl2_p.h" +QT_BEGIN_NAMESPACE + #ifdef Q_WS_WIN extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif @@ -214,3 +216,5 @@ int QGLTextureGlyphCache::glyphMargin() const return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; #endif } + +QT_END_NAMESPACE -- cgit v0.12 From 56d0ea16af168167d840889f67948a79fac9a0d6 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 11 Jan 2010 10:35:48 +0100 Subject: Update reference to renamed file in completer example. --- examples/tools/completer/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp index e5ee68e..52e5c0c 100644 --- a/examples/tools/completer/mainwindow.cpp +++ b/examples/tools/completer/mainwindow.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "dirmodel.h" +#include "fsmodel.h" #include "mainwindow.h" //! [0] -- cgit v0.12 From e8f45c5ba8371053817f13e70d78b06f229d8666 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 11 Jan 2010 17:09:41 +0100 Subject: Autotest: add a local version of the tst_QHttp::connectionClose test Now it doesn't have to be manual any more. Reviewed-by: Trust Me --- tests/auto/qhttp/tst_qhttp.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index 92ab3d8..bfd8ae9 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -114,9 +114,6 @@ private slots: void abortInReadyRead(); void abortInResponseHeaderReceived(); void nestedEventLoop(); - - - // manual tests void connectionClose(); protected slots: @@ -175,6 +172,23 @@ private: bool proxyAuthCalled; }; +class ClosingServer: public QTcpServer +{ + Q_OBJECT +public: + ClosingServer() + { + connect(this, SIGNAL(newConnection()), SLOT(handleConnection())); + listen(); + } + +public slots: + void handleConnection() + { + delete nextPendingConnection(); + } +}; + //#define DUMP_SIGNALS const int bytesTotal_init = -10; @@ -1491,20 +1505,14 @@ void tst_QHttp::abortInResponseHeaderReceived() void tst_QHttp::connectionClose() { - // This test tries to connect to a client's server, so it is disabled. - // Every now and then, someone please run it to make sure it's not broken. - // Note: the servers might change too... - // // This was added in response to bug 176822 -#ifndef Q_OS_SYMBIAN - QSKIP("This test is manual - read comments in the source code", SkipAll); -#endif QFETCH_GLOBAL(bool, setProxy); if (setProxy) return; QHttp http; - http.setHost("www.fon.com", QHttp::ConnectionModeHttps); + ClosingServer server; + http.setHost("localhost", QHttp::ConnectionModeHttps, server.serverPort()); http.get("/login/gateway/processLogin"); // another possibility: -- cgit v0.12 From 705ebaea0d81c76c97e7230f0acbe85442981555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 12 Jan 2010 09:05:13 +0100 Subject: Add an autorelease pool to QApplication instance. This will catch releases done between creating the QApplication object and calling QApplication::exec. (The Cocoa event loop creates release pools for us when it's running.) The memory used by the objects stored in this pool won't be released until the QApplication instance is deleted at application exit. Because of this it still makes sense to still add local release pools when doing potentially large allocations. --- src/gui/kernel/qapplication_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 14d7215..fc9e1ab 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -74,6 +74,9 @@ #ifdef Q_OS_SYMBIAN #include #endif +#ifdef Q_WS_MAC +#include +#endif QT_BEGIN_NAMESPACE @@ -481,6 +484,13 @@ public: static Qt::NavigationMode navigationMode; #endif +// We need to have an autorelease pool in place in order +// to catch releases done in between creating the QApplication +// instance and calling QApplicaiton::exec(); +#if defined(QT_MAC_USE_COCOA) + QMacCocoaAutoReleasePool pool; +#endif + #if defined(Q_WS_MAC) || defined(Q_WS_X11) void _q_alertTimeOut(); QHash alertTimerHash; -- cgit v0.12 From ab2f88e3cfbf43afd536b9946a40e936c3dcee35 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 12 Jan 2010 10:00:18 +0100 Subject: Fix compilation of builds without WebKit --- tools/assistant/tools/assistant/centralwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 638b8d2..0f57628 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1190,7 +1190,7 @@ void CentralWidget::closeOrReloadTabs(const QList &indices, bool tryReload) if (tryReload) { HelpViewer *viewer = qobject_cast(tabWidget->widget(tab)); - if (HelpEngineWrapper::instance().findFile(viewer->url()).isValid()) { + if (HelpEngineWrapper::instance().findFile(viewer->source()).isValid()) { viewer->reload(); close = false; } -- cgit v0.12 From aca933dea3858c0b6db4a02063583da24e80b6c3 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 8 Jan 2010 15:32:01 +0100 Subject: Cocoa: application will not quit when using dialogs When creating a single dialog in the main function, and tell it to exec, we run a modal dialog. But there is really no other window on screen to be modal for. So in that case, since this is a rather common pattern for Qt applications, we allow users to quit the application from the dock. But this action is sendt as an apple event. And and that point in time, cocoa has the the apple event handler, and refuses to close down the application because it detects a modal window. Our solution is to install/overwrite the apple event handler for kAEQuit _after_ cocoa has finished its own installation. But in order to do this, we need to wait until [NSApplication run] has started, otherwise it will not take effect. And that is what this patch essentially does. --- src/corelib/kernel/qcoreevent.h | 1 - src/gui/kernel/qapplication_mac.mm | 21 +++++++++++++++++---- src/gui/kernel/qapplication_p.h | 3 +++ src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 7 +++++++ src/gui/kernel/qcocoapanel_mac.mm | 1 + src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 14 ++++++++++++-- src/gui/kernel/qcocoawindow_mac.mm | 1 + src/gui/kernel/qeventdispatcher_mac.mm | 3 +++ src/gui/kernel/qt_cocoa_helpers_mac.mm | 15 +++++++++++++++ src/gui/kernel/qt_cocoa_helpers_mac_p.h | 4 ++++ src/gui/statemachine/qguistatemachine.cpp | 6 ------ src/gui/widgets/qmenu_mac.mm | 4 ++-- 12 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 6427d17..ecca4e2 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -266,7 +266,6 @@ public: UngrabMouse = 187, GrabKeyboard = 188, UngrabKeyboard = 189, - CocoaRequestModal = 190, // Internal for requesting an application modal Cocoa Window MacGLClearDrawable = 191, // Internal Cocoa, the window has changed, so we must clear StateMachineSignal = 192, diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 688e51f..a815f94 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1239,10 +1239,6 @@ void qt_init(QApplicationPrivate *priv, int) [cocoaApp setMenu:[qtMenuLoader menu]]; [newDelegate setMenuLoader:qtMenuLoader]; [qtMenuLoader release]; - - NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; - [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:) - forEventClass:kInternetEventClass andEventID:kAEGetURL]; } #endif // Register for Carbon tablet proximity events on the event monitor target. @@ -2435,6 +2431,23 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event #endif } +#ifdef QT_MAC_USE_COCOA +void QApplicationPrivate::setupAppleEvents() +{ + // This function is called from the event dispatcher when NSApplication has + // finished initialization, which appears to be just after [NSApplication run] has + // started to execute. By setting up our apple events handlers this late, we override + // the ones set up by NSApplication. + QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; + NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; + [eventManager setEventHandler:newDelegate andSelector:@selector(appleEventQuit:withReplyEvent:) + forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; + [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:) + forEventClass:kInternetEventClass andEventID:kAEGetURL]; + +} +#endif + // In Carbon this is your one stop for apple events. // In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists // for the time between instantiating the NSApplication, but before the diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index fc9e1ab..2927c45 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -459,6 +459,9 @@ public: static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *); +#ifdef QT_MAC_USE_COCOA + static void setupAppleEvents(); +#endif static bool qt_mac_apply_settings(); #endif diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 304e5d3..fc2a5ab 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -317,5 +317,12 @@ static void cleanupCocoaApplicationDelegate() qt_sendSpontaneousEvent(qAppInstance(), &qtEvent); } +- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + Q_UNUSED(event); + Q_UNUSED(replyEvent); + [NSApp terminate:self]; +} + @end #endif diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm index 9154284..3d9c1b9 100644 --- a/src/gui/kernel/qcocoapanel_mac.mm +++ b/src/gui/kernel/qcocoapanel_mac.mm @@ -46,6 +46,7 @@ #import #import #import +#import #include diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 31d81d9..240cfe7 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -160,10 +160,20 @@ QT_END_NAMESPACE qt_dispatchTabletProximityEvent(tabletEvent); } +- (void)qtDispatcherToQAction:(id)sender +{ + // If this window is modal, the menu bar will be modally shaddowed. + // In that case, since the window will be in the first responder chain, + // we can still catch the trigger here and forward it to the menu bar. + // This is needed as a single modal dialog on Qt should be able to access + // the application menu (e.g. quit). + [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender]; +} + - (void)terminate:(id)sender { - // This function is called from the quit item in the - // menubar, when this window is the first responder + // This function is called from the quit item in the menubar when this window + // is in the first responder chain (see also qtDispatcherToQAction above) [NSApp terminate:sender]; } diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm index a9aa373..9250f27 100644 --- a/src/gui/kernel/qcocoawindow_mac.mm +++ b/src/gui/kernel/qcocoawindow_mac.mm @@ -46,6 +46,7 @@ #import #import #import +#import #include diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index ab1e2a1..a84eca8 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -1048,6 +1048,9 @@ void QEventDispatcherMacPrivate::firstLoopEntry(CFRunLoopObserverRef ref, { Q_UNUSED(ref); Q_UNUSED(activity); +#ifdef QT_MAC_USE_COCOA + QApplicationPrivate::setupAppleEvents(); +#endif processPostedEvents(static_cast(info), blockSendPostedEvents); } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index ef680a4..41c859a 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1278,4 +1278,19 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor) } #endif +@implementation DebugNSApplication { +} +- (void)sendEvent:(NSEvent *)event +{ + NSLog(@"NSAppDebug: sendEvent: %@", event); + return [super sendEvent:event]; +} + +- (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender +{ + NSLog(@"NSAppDebug: sendAction: %s to %@ from %@", anAction, aTarget, sender); + return [super sendAction:anAction to:aTarget from:sender]; +} +@end + QT_END_NAMESPACE diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index f11ccc5..211a407 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -181,6 +181,10 @@ inline QString qt_mac_NSStringToQString(const NSString *nsstr) inline NSString *qt_mac_QStringToNSString(const QString &qstr) { return [reinterpret_cast(QCFString::toCFStringRef(qstr)) autorelease]; } + +@interface DebugNSApplication : NSApplication {} +@end + #endif QT_END_NAMESPACE diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp index c3a9228..aeb3dbe 100644 --- a/src/gui/statemachine/qguistatemachine.cpp +++ b/src/gui/statemachine/qguistatemachine.cpp @@ -469,12 +469,6 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::UngrabKeyboard: return new QEvent(*e); -#ifdef QT_MAC_USE_COCOA - case QEvent::CocoaRequestModal: - Q_ASSERT_X(false, "cloneEvent()", "not implemented"); - break; -#endif - case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 99301ee..62a482a 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -625,7 +625,7 @@ static NSMenuItem *createNSMenuItem(const QString &title) NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:qt_mac_QStringToNSString(title) action:@selector(qtDispatcherToQAction:) keyEquivalent:@""]; - [item setTarget:getMenuLoader()]; + [item setTarget:nil]; return item; } #endif @@ -1106,7 +1106,7 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction action->menu = merge; [cmd retain]; [cmd setAction:@selector(qtDispatcherToQAction:)]; - [cmd setTarget:getMenuLoader()]; + [cmd setTarget:nil]; [action->menuItem release]; action->menuItem = cmd; QMenuMergeList *list = QMenuPrivate::mergeMenuItemsHash.value(merge); -- cgit v0.12 From 0e6abffa2843bae594195b9ba56d5c5264837288 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 12 Jan 2010 13:46:27 +0100 Subject: Cocoa: the menu bar is sometimes faulty disabled In Qt, we allow the menu bar to be enabled if we only have one exec-ing dialog on screen. That way you can reach the quit menu item to close down the application. But in order for this to work, some overhaul of qmenu_mac.mm was need to teach it these rules. --- src/gui/widgets/qmenu_mac.mm | 155 +++++++++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 49 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 62a482a..3ab6645 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1906,57 +1906,53 @@ static bool qt_mac_is_ancestor(QWidget* possibleAncestor, QWidget *child) Returns true if the entries of menuBar should be disabled, based on the modality type of modalWidget. */ -static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) +static bool qt_mac_should_disable_menu(QMenuBar *menuBar) { - if (modalWidget == 0 || menuBar == 0) + QWidget *modalWidget = qApp->activeModalWidget(); + if (!modalWidget) return false; - // If there is an application modal window on - // screen, the entries of the menubar should be disabled: + if (menuBar && menuBar == menubars()->value(modalWidget)) + // The menu bar is owned by the modal widget. + // In that case we should enable it: + return false; + + // When there is an application modal window on screen, the entries of + // the menubar should be disabled. The exception in Qt is that if the + // modal window is the only window on screen, then we enable the menu bar. QWidget *w = modalWidget; + QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); while (w) { - if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) - return true; + if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) { + for (int i=0; iparentWidget(); } // INVARIANT: modalWidget is window modal. Disable menu entries - // if the menu bar belongs to an ancestor of modalWidget: - return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); + // if the menu bar belongs to an ancestor of modalWidget. If menuBar + // is nil, we understand it as the default menu bar set by the nib: + return menuBar ? qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget) : false; } -static void cancelAllMenuTracking() +static QWidget *findWindowThatShouldDisplayMenubar() { -#ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - NSMenu *mainMenu = [NSApp mainMenu]; - [mainMenu cancelTracking]; - for (NSMenuItem *item in [mainMenu itemArray]) { - if ([item submenu]) { - [[item submenu] cancelTracking]; - } - } -#endif -} - -/*! - \internal - - This function will update the current menu bar and set it as the - active menu bar in the Menu Manager. - - \warning This function is not portable. - - \sa QMenu::macMenu(), QMenuBar::macMenu() -*/ -bool QMenuBar::macUpdateMenuBar() -{ - cancelAllMenuTracking(); - QMenuBar *mb = 0; - //find a menu bar QWidget *w = qApp->activeWindow(); - if (!w) { + // We have no active window on screen. Try to + // find a window from the list of top levels: QWidgetList tlws = QApplication::topLevelWidgets(); for(int i = 0; i < tlws.size(); ++i) { QWidget *tlw = tlws.at(i); @@ -1967,6 +1963,12 @@ bool QMenuBar::macUpdateMenuBar() } } } + return w; +} + +static QMenuBar *findMenubarForWindow(QWidget *w) +{ + QMenuBar *mb = 0; if (w) { mb = menubars()->value(w); #ifndef QT_NO_MAINWINDOW @@ -1980,11 +1982,49 @@ bool QMenuBar::macUpdateMenuBar() while(w && !mb) mb = menubars()->value((w = w->parentWidget())); } - if (!mb) + + if (!mb) { + // We could not find a menu bar for the window. Lets + // check if we have a global (parentless) menu bar instead: mb = fallback; - //now set it + } + + return mb; +} + +static void cancelAllMenuTracking() +{ +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + NSMenu *mainMenu = [NSApp mainMenu]; + [mainMenu cancelTracking]; + for (NSMenuItem *item in [mainMenu itemArray]) { + if ([item submenu]) { + [[item submenu] cancelTracking]; + } + } +#endif +} + +/*! + \internal + + This function will update the current menu bar and set it as the + active menu bar in the Menu Manager. + + \warning This function is not portable. + + \sa QMenu::macMenu(), QMenuBar::macMenu() +*/ +bool QMenuBar::macUpdateMenuBar() +{ bool ret = false; + cancelAllMenuTracking(); + QWidget *w = findWindowThatShouldDisplayMenubar(); + QMenuBar *mb = findMenubarForWindow(w); + if (mb && mb->isNativeMenuBar()) { + bool modal = QApplicationPrivate::modalState(); #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; #endif @@ -2014,16 +2054,18 @@ bool QMenuBar::macUpdateMenuBar() } } #endif - QWidget *modalWidget = qApp->activeModalWidget(); - if (mb != menubars()->value(modalWidget)) { - qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget)); - } + // Check if menu is modally shaddowed and should be disabled: + modal = qt_mac_should_disable_menu(mb); + if (mb != qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) + qt_mac_set_modal_state(menu, modal); } qt_mac_current_menubar.qmenubar = mb; - qt_mac_current_menubar.modal = QApplicationPrivate::modalState(); + qt_mac_current_menubar.modal = modal; ret = true; } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) { - const bool modal = QApplicationPrivate::modalState(); + // INVARIANT: The currently active menu bar (if any) is not native. But we do have a + // native menu bar from before. So we need to decide whether or not is should be enabled: + const bool modal = qt_mac_should_disable_menu(qt_mac_current_menubar.qmenubar); if (modal != qt_mac_current_menubar.modal) { ret = true; if (OSMenuRef menu = qt_mac_current_menubar.qmenubar->macMenu()) { @@ -2035,14 +2077,29 @@ bool QMenuBar::macUpdateMenuBar() [NSApp setMainMenu:menu]; syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar); #endif - QWidget *modalWidget = qApp->activeModalWidget(); - if (qt_mac_current_menubar.qmenubar != menubars()->value(modalWidget)) { - qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget)); - } + qt_mac_set_modal_state(menu, modal); } qt_mac_current_menubar.modal = modal; } + } else { + // INVARIANT: There is no menubar specified, so the default one with the application + // menu is shown. Check if we need to disable it because of modality. We set + // qt_mac_current_menubar.qmenubar to nil to mean the default nib loaded menu: +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + OSMenuRef menu = [loader menu]; + [loader ensureAppMenuInMenu:menu]; + [NSApp setMainMenu:menu]; + const bool modal = qt_mac_should_disable_menu(0); + if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) + qt_mac_set_modal_state(menu, modal); + qt_mac_current_menubar.qmenubar = 0; + qt_mac_current_menubar.modal = modal; + ret = true; +#endif } + if(!ret) qt_mac_clear_menubar(); return ret; -- cgit v0.12 From b958102dfa36a3554911adb8fdb21375f0ecb48c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 3 Dec 2009 09:46:12 +0100 Subject: QNAM: Add priority to the API and use it for HTTP QHttpNetworkRequest and other classes already knew about the priority. Change QNetworkRequest to export this as API. It will be used in WebKit to tag high priority html, javascript and css files as such. Reviewed-By: Markus Goetz --- src/network/access/qnetworkaccesshttpbackend.cpp | 14 ++++++++++ src/network/access/qnetworkrequest.cpp | 34 +++++++++++++++++++++++- src/network/access/qnetworkrequest.h | 9 +++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 91f9189..a42044c 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -467,10 +467,24 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, loadedFromCache = false; } +static QHttpNetworkRequest::Priority convert(const QNetworkRequest::Priority& prio) +{ + switch (prio) { + case QNetworkRequest::LowPriority: + return QHttpNetworkRequest::LowPriority; + case QNetworkRequest::HighPriority: + return QHttpNetworkRequest::HighPriority; + case QNetworkRequest::NormalPriority: + default: + return QHttpNetworkRequest::NormalPriority; + } +} + void QNetworkAccessHttpBackend::postRequest() { bool loadedFromCache = false; QHttpNetworkRequest httpRequest; + httpRequest.setPriority(convert(request().priority())); switch (operation()) { case QNetworkAccessManager::GetOperation: httpRequest.setOperation(QHttpNetworkRequest::Get); diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 923f2e3..55643e4 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -218,8 +218,9 @@ class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate { public: inline QNetworkRequestPrivate() + : priority(QNetworkRequest::NormalPriority) #ifndef QT_NO_OPENSSL - : sslConfiguration(0) + , sslConfiguration(0) #endif { qRegisterMetaType(); } ~QNetworkRequestPrivate() @@ -234,6 +235,7 @@ public: : QSharedData(other), QNetworkHeadersPrivate(other) { url = other.url; + priority = other.priority; #ifndef QT_NO_OPENSSL sslConfiguration = 0; @@ -245,12 +247,14 @@ public: inline bool operator==(const QNetworkRequestPrivate &other) const { return url == other.url && + priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes; // don't compare cookedHeaders } QUrl url; + QNetworkRequest::Priority priority; #ifndef QT_NO_OPENSSL mutable QSslConfiguration *sslConfiguration; #endif @@ -516,6 +520,34 @@ QObject *QNetworkRequest::originatingObject() const return d->originatingObject.data(); } +/*! + \since 4.7 + + Return the priority of this request. + + \sa setPriority() +*/ +QNetworkRequest::Priority QNetworkRequest::priority() const +{ + return d->priority; +} + +/*! + \since 4.7 + + Set the priority of this request. + + \note The priority is only a hint to the network access manager. + It can use it or not. Currently it is used for HTTP to + decide which request should be sent first to a server. + + \sa priority() +*/ +void QNetworkRequest::setPriority(Priority priority) +{ + d->priority = priority; +} + static QByteArray headerName(QNetworkRequest::KnownHeaders header) { switch (header) { diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index 62c6dda..6fd8dba 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -89,6 +89,12 @@ public: AlwaysCache }; + enum Priority { + HighPriority = 1, + NormalPriority = 3, + LowPriority = 5 + }; + explicit QNetworkRequest(const QUrl &url = QUrl()); QNetworkRequest(const QNetworkRequest &other); ~QNetworkRequest(); @@ -123,6 +129,9 @@ public: void setOriginatingObject(QObject *object); QObject *originatingObject() const; + Priority priority() const; + void setPriority(Priority priority); + private: QSharedDataPointer d; friend class QNetworkRequestPrivate; -- cgit v0.12 From b38da980696e69b61d2f5411ad2f2c36453ed089 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 12 Jan 2010 19:10:12 +0100 Subject: add a hash function to QUrl, and remove the xmlpatterns specific one we had a hash function defined in xmlpatterns; this commit adds a global hash function for QUrls. Beware that code that defines its own hash function for QUrls will need to #ifdef it out for 4.7. Patch-By: Warwick Allison Reviewed-by: Peter Hartmann Reviewed-by: Thiago Macieira --- src/corelib/io/qurl.h | 7 +++++++ src/xmlpatterns/type/qprimitives_p.h | 14 -------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index f76d345..bb04ad1 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -46,6 +46,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -75,6 +76,7 @@ public: RemovePath = 0x20, RemoveQuery = 0x40, RemoveFragment = 0x80, + // 0x100: private: normalized StripTrailingSlash = 0x10000 }; @@ -268,6 +270,11 @@ public: inline DataPtr &data_ptr() { return d; } }; +inline uint qHash(const QUrl &uri) +{ + return qHash(uri.toEncoded(QUrl::FormattingOption(0x100))); +} + Q_DECLARE_TYPEINFO(QUrl, Q_MOVABLE_TYPE); Q_DECLARE_SHARED(QUrl) Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions) diff --git a/src/xmlpatterns/type/qprimitives_p.h b/src/xmlpatterns/type/qprimitives_p.h index 01c04a1..d86fa4f 100644 --- a/src/xmlpatterns/type/qprimitives_p.h +++ b/src/xmlpatterns/type/qprimitives_p.h @@ -79,18 +79,6 @@ class QString; */ namespace QPatternist { - - /** - * @internal - * - * A method to allow a QHash or QSet with QUrl - * as key type. - */ - inline uint qHash(const QUrl &uri) - { - return qHash(uri.toString()); - } - /** * @defgroup Patternist_cppWXSTypes C++ Primitives for W3C XML Schema Number Types * @@ -208,8 +196,6 @@ namespace QPatternist QString Q_AUTOTEST_EXPORT escape(const QString &input); } -using QPatternist::qHash; - QT_END_NAMESPACE QT_END_HEADER -- cgit v0.12 From 737161bbec97e738d0e91cc86bd4e4033be07b97 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Jan 2010 12:31:12 +0100 Subject: Add an overload of qRegisterMetaTypeStreamOperators without the type name Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qmetatype.cpp | 7 +++++++ src/corelib/kernel/qmetatype.h | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index b1ce608..ac15e49 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -361,7 +361,14 @@ void QMetaType::registerStreamOperators(const char *typeName, SaveOperator saveO int idx = type(typeName); if (!idx) return; + registerStreamOperators(idx, saveOp, loadOp); +} +/*! \internal +*/ +void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp, + LoadOperator loadOp) +{ QVector *ct = customTypes(); if (!ct) return; diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 0277200..115411c 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -108,6 +108,8 @@ public: typedef void (*LoadOperator)(QDataStream &, void *); static void registerStreamOperators(const char *typeName, SaveOperator saveOp, LoadOperator loadOp); + static void registerStreamOperators(int type, SaveOperator saveOp, + LoadOperator loadOp); #endif static int registerType(const char *typeName, Destructor destructor, Constructor constructor); @@ -224,6 +226,24 @@ inline int qRegisterMetaType( #endif } +#ifndef QT_NO_DATASTREAM +template +inline int qRegisterMetaTypeStreamOperators() +{ + typedef void(*SavePtr)(QDataStream &, const T *); + typedef void(*LoadPtr)(QDataStream &, T *); + SavePtr sptr = qMetaTypeSaveHelper; + LoadPtr lptr = qMetaTypeLoadHelper; + + register int id = qMetaTypeId(); + QMetaType::registerStreamOperators(id, + reinterpret_cast(sptr), + reinterpret_cast(lptr)); + + return id; +} +#endif + #define Q_DECLARE_METATYPE(TYPE) \ QT_BEGIN_NAMESPACE \ template <> \ -- cgit v0.12 From 52ecdf550a57906a01580c2f811a4035414f0c8b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 13 Jan 2010 11:16:35 +0100 Subject: Cocoa: refactor code for clearing the native menu bar It turns out that some of the code executed when synching then menu bar was already implemented in the function that clears the menu bar. So this patch makes the code a bit more compact, avoiding implementing the same code twize. --- src/gui/widgets/qmenu_mac.mm | 73 ++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 3ab6645..b5ed843 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -725,32 +725,6 @@ bool qt_mac_menubar_is_open() return qt_mac_menus_open_count > 0; } -void qt_mac_clear_menubar() -{ - if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) - return; - -#ifndef QT_MAC_USE_COCOA - MenuRef clear_menu = 0; - if (CreateNewMenu(0, 0, &clear_menu) == noErr) { - SetRootMenu(clear_menu); - ReleaseMenu(clear_menu); - } else { - qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__); - } - ClearMenuBar(); - qt_mac_command_set_enabled(0, kHICommandPreferences, false); - InvalMenuBar(); -#else - QMacCocoaAutoReleasePool pool; - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); - NSMenu *menu = [loader menu]; - [loader ensureAppMenuInMenu:menu]; - [NSApp setMainMenu:menu]; -#endif -} - - QMacMenuAction::~QMacMenuAction() { #ifdef QT_MAC_USE_COCOA @@ -2006,6 +1980,36 @@ static void cancelAllMenuTracking() #endif } +void qt_mac_clear_menubar() +{ + if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) + return; + +#ifndef QT_MAC_USE_COCOA + MenuRef clear_menu = 0; + if (CreateNewMenu(0, 0, &clear_menu) == noErr) { + SetRootMenu(clear_menu); + ReleaseMenu(clear_menu); + } else { + qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__); + } + ClearMenuBar(); + qt_mac_command_set_enabled(0, kHICommandPreferences, false); + InvalMenuBar(); +#else + QMacCocoaAutoReleasePool pool; + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + NSMenu *menu = [loader menu]; + [loader ensureAppMenuInMenu:menu]; + [NSApp setMainMenu:menu]; + const bool modal = qt_mac_should_disable_menu(0); + if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) + qt_mac_set_modal_state(menu, modal); + qt_mac_current_menubar.qmenubar = 0; + qt_mac_current_menubar.modal = modal; +#endif +} + /*! \internal @@ -2081,23 +2085,6 @@ bool QMenuBar::macUpdateMenuBar() } qt_mac_current_menubar.modal = modal; } - } else { - // INVARIANT: There is no menubar specified, so the default one with the application - // menu is shown. Check if we need to disable it because of modality. We set - // qt_mac_current_menubar.qmenubar to nil to mean the default nib loaded menu: -#ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); - OSMenuRef menu = [loader menu]; - [loader ensureAppMenuInMenu:menu]; - [NSApp setMainMenu:menu]; - const bool modal = qt_mac_should_disable_menu(0); - if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) - qt_mac_set_modal_state(menu, modal); - qt_mac_current_menubar.qmenubar = 0; - qt_mac_current_menubar.modal = modal; - ret = true; -#endif } if(!ret) -- cgit v0.12 From 20e0e7a849d70139f9106f60c78fd0c736ec3c4b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 13 Jan 2010 12:25:30 +0100 Subject: Revert "Add an autorelease pool to QApplication instance." This reverts commit 705ebaea0d81c76c97e7230f0acbe85442981555. For some strange reason, the change that we revert caused a lot of problems; the menu bar stopped working, duplicating menu items etc., and modality stopped working correctly. So there is only one thing to do: revert. Rev-By: msorvig --- src/gui/kernel/qapplication_p.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2927c45..2404d91 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -74,9 +74,6 @@ #ifdef Q_OS_SYMBIAN #include #endif -#ifdef Q_WS_MAC -#include -#endif QT_BEGIN_NAMESPACE @@ -487,13 +484,6 @@ public: static Qt::NavigationMode navigationMode; #endif -// We need to have an autorelease pool in place in order -// to catch releases done in between creating the QApplication -// instance and calling QApplicaiton::exec(); -#if defined(QT_MAC_USE_COCOA) - QMacCocoaAutoReleasePool pool; -#endif - #if defined(Q_WS_MAC) || defined(Q_WS_X11) void _q_alertTimeOut(); QHash alertTimerHash; -- cgit v0.12 From fac30831e9235bb3373a0a96c40c9b653f87e34c Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 10:52:25 +0100 Subject: Use QTemporaryFile for opening documents in external applications. Reviewed-by: kh1 --- tools/assistant/tools/assistant/helpviewer.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 4ba896c..f20cbc1 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include @@ -243,19 +245,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, if (isLocalUrl(url)) { const QString& path = url.path(); if (path.endsWith(QLatin1String(".pdf"))) { - const int lastDash = path.lastIndexOf(QChar('/')); - QString fileName = QDir::tempPath() + QDir::separator(); - if (lastDash < 0) - fileName += path; - else - fileName += path.mid(lastDash + 1, path.length()); - - QFile tmpFile(QDir::cleanPath(fileName)); - if (tmpFile.open(QIODevice::ReadWrite)) { - tmpFile.write(HelpEngineWrapper::instance().fileData(url)); - tmpFile.close(); + QTemporaryFile tmpTmpFile; + if (!tmpTmpFile.open()) + return false; + const QString extension = QFileInfo(path).completeSuffix(); + QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".") + % extension); + if (actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) { + actualTmpFile.write(HelpEngineWrapper::instance().fileData(url)); + actualTmpFile.close(); + QDesktopServices::openUrl(QUrl(actualTmpFile.fileName())); } - QDesktopServices::openUrl(QUrl(tmpFile.fileName())); if (closeNewTab) QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab"); -- cgit v0.12 From 54d1ad11a4f35c0484418e5d18537daaccc2c6ab Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 11:15:08 +0100 Subject: Assistant: Open non-HTML content in external application. Task-number: QTBUG-5583 Reviewed-by: kh1 --- tools/assistant/tools/assistant/contentwindow.cpp | 12 +++--------- tools/assistant/tools/assistant/helpviewer.cpp | 16 ++++++++++++---- tools/assistant/tools/assistant/helpviewer.h | 3 +++ tools/assistant/tools/assistant/indexwindow.cpp | 3 ++- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 23bcae4..976ed7a 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -43,6 +43,7 @@ #include "contentwindow.h" #include "centralwidget.h" #include "helpenginewrapper.h" +#include "helpviewer.h" #include #include @@ -143,7 +144,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm && !isPdfFile(itm)) + if (itm && HelpViewer::canOpenPage(itm->url().path())) CentralWidget::instance()->setSourceInNewTab(itm->url()); } } else if (button == Qt::LeftButton) { @@ -169,7 +170,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) QMenu menu; QAction *curTab = menu.addAction(tr("Open Link")); QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - if (isPdfFile(itm)) + if (!HelpViewer::canOpenPage(itm->url().path())) newTab->setEnabled(false); menu.move(m_contentWidget->mapToGlobal(pos)); @@ -194,11 +195,4 @@ void ContentWindow::itemClicked(const QModelIndex &index) } } -bool ContentWindow::isPdfFile(QHelpContentItem *item) const -{ - TRACE_OBJ - const QString &path = item->url().path(); - return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive); -} - QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index f20cbc1..d92ff13 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -244,7 +244,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, if (isLocalUrl(url)) { const QString& path = url.path(); - if (path.endsWith(QLatin1String(".pdf"))) { + if (!HelpViewer::canOpenPage(path)) { QTemporaryFile tmpTmpFile; if (!tmpTmpFile.open()) return false; @@ -476,12 +476,12 @@ void HelpViewer::zoomOut(int range) bool HelpViewer::launchedWithExternalApp(const QUrl &url) { TRACE_OBJ - bool isPdf = url.path().endsWith(QLatin1String(".pdf")); + const bool canOpen = canOpenPage(url.path()); if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") - || url.scheme() == QLatin1String("mailto") || isPdf) { + || url.scheme() == QLatin1String("mailto") || !canOpen) { bool launched = false; - if (isPdf && url.scheme() == QLatin1String("qthelp")) { + if (!canOpen && url.scheme() == QLatin1String("qthelp")) { const QString& path = url.path(); const int lastDash = path.lastIndexOf(QChar('/')); QString fileName = QDir::tempPath() + QDir::separator(); @@ -638,4 +638,12 @@ void HelpViewer::home() setSource(helpEngine.homePage()); } +bool HelpViewer::canOpenPage(const QString &url) +{ + TRACE_OBJ + return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) + || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive); +} + + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index ab46208..cfe4c3e 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -97,6 +97,8 @@ public: inline qreal zoom() const { return textSizeMultiplier(); } + static bool canOpenPage(const QString &url); + public Q_SLOTS: void home(); void backward() { back(); } @@ -143,6 +145,7 @@ public: { return textCursor().hasSelection(); } bool launchedWithExternalApp(const QUrl &url); + static bool canOpenPage(const QString &url); public Q_SLOTS: void home(); diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index a61ab70..82242e5 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -43,6 +43,7 @@ #include "indexwindow.h" #include "centralwidget.h" #include "helpenginewrapper.h" +#include "helpviewer.h" #include "topicchooser.h" #include @@ -218,7 +219,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) return; } - if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive)) + if (!HelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else CentralWidget::instance()->setSourceInNewTab(url); -- cgit v0.12 From 90563926e2d68a468bb9accdbad9760da21d5ba3 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 11:37:17 +0100 Subject: Assistant: Extend 54d1ad11a4f35c0484418e5d18537daaccc2c6ab. Forgot one place. --- tools/assistant/tools/assistant/aboutdialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index ba93351..5727528 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "helpviewer.h" #include "tracer.h" #include @@ -97,7 +98,7 @@ void AboutLabel::setSource(const QUrl &url) TRACE_OBJ if (url.isValid() && (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") - || url.scheme() == QLatin1String("mailto") || url.path().endsWith(QLatin1String("pdf")))) { + || url.scheme() == QLatin1String("mailto") || !HelpViewer::canOpenPage(url.path()))) { if (!QDesktopServices::openUrl(url)) { QMessageBox::warning(this, tr("Warning"), tr("Unable to launch external application.\n"), -- cgit v0.12 From c5a226dc46110848eb874212cf4bb2257ada0c84 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 14 Jan 2010 11:33:56 +0100 Subject: Implement showing the volume name for drives on Windows. Also fix a bug with QCompleter and QFileSystemModel when the popup was shown even if there was nothing to complete. Task-number:QTBUG-5376 Reviewed-by:janarve --- src/gui/dialogs/qfilesystemmodel.cpp | 28 ++++++++++++++++++++++++++-- src/gui/dialogs/qfilesystemmodel_p.h | 4 ++++ src/gui/util/qcompleter.cpp | 13 +++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 517c3ab..ae75126 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -681,7 +681,7 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const case Qt::EditRole: case Qt::DisplayRole: switch (index.column()) { - case 0: return d->name(index); + case 0: return d->displayName(index); case 1: return d->size(index); case 2: return d->type(index); case 3: return d->time(index); @@ -797,13 +797,25 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const if (resolvedSymLinks.contains(fullPath)) return resolvedSymLinks[fullPath]; } - // ### TODO it would be nice to grab the volume name if dirNode->parent == root return dirNode->fileName; } /*! \internal */ +QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const +{ +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + QFileSystemNode *dirNode = node(index); + if (!dirNode->volumeName.isNull()) + return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')'); +#endif + return name(index); +} + +/*! + \internal +*/ QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const { if (!index.isValid()) @@ -1648,6 +1660,18 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile #ifndef QT_NO_FILESYSTEMWATCHER node->populate(info); #endif +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + //The parentNode is "" so we are listing the drives + if (parentNode->fileName.isEmpty()) { + wchar_t name[MAX_PATH + 1]; + //GetVolumeInformation requires to add trailing backslash + const QString nodeName = fileName + QLatin1String("\\"); + BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()), + name, ARRAYSIZE(name), NULL, 0, NULL, NULL, 0); + if (success && name[0]) + node->volumeName = QString::fromWCharArray(name); + } +#endif parentNode->children.insert(fileName, node); return node; } diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h index 6c85a7c..03e0bfb 100644 --- a/src/gui/dialogs/qfilesystemmodel_p.h +++ b/src/gui/dialogs/qfilesystemmodel_p.h @@ -97,6 +97,9 @@ public: } QString fileName; +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + QString volumeName; +#endif inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; } inline QString type() const { if (info) return info->displayType; return QLatin1String(""); } @@ -278,6 +281,7 @@ public: QIcon icon(const QModelIndex &index) const; QString name(const QModelIndex &index) const; + QString displayName(const QModelIndex &index) const; QString filePath(const QModelIndex &index) const; QString size(const QModelIndex &index) const; static QString size(qint64 bytes); diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 0a070b6..b7be967 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -903,12 +903,12 @@ void QCompleterPrivate::showPopup(const QRect& rect) popup->show(); } - void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path) { Q_Q(QCompleter); - Q_UNUSED(path); - q->complete(); + //the path given by QFileSystemModel does not end with / + if (q->completionPrefix() != path + QLatin1Char('/')) + q->complete(); } /*! @@ -1023,6 +1023,7 @@ void QCompleter::setModel(QAbstractItemModel *model) #else setCaseSensitivity(Qt::CaseSensitive); #endif + setCompletionRole(QFileSystemModel::FileNameRole); connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString))); } #endif // QT_NO_FILESYSTEMMODEL @@ -1685,7 +1686,11 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const QModelIndex idx = index; QStringList list; do { - QString t = sourceModel->data(idx, Qt::EditRole).toString(); + QString t; + if (isDirModel) + t = sourceModel->data(idx, Qt::EditRole).toString(); + else + t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString(); list.prepend(t); QModelIndex parent = idx.parent(); idx = parent.sibling(parent.row(), index.column()); -- cgit v0.12 From 035bb4a1363443df7bb3fd80f0b2e7d548f3d3a1 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 15:41:02 +0100 Subject: Assistant: Fix bug that can lead to infinite loop in edge cases. --- tools/assistant/lib/qhelp_global.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/assistant/lib/qhelp_global.cpp b/tools/assistant/lib/qhelp_global.cpp index e6a26c4..8e96b55 100644 --- a/tools/assistant/lib/qhelp_global.cpp +++ b/tools/assistant/lib/qhelp_global.cpp @@ -89,10 +89,11 @@ QString QHelpGlobal::codecFromHtmlData(const QByteArray &data) QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size())); int start = head.indexOf(QLatin1String(" 0) { - int end; QRegExp r(QLatin1String("charset=([^\"\\s]+)")); while (start != -1) { - end = head.indexOf(QLatin1Char('>'), start) + 1; + const int end = head.indexOf(QLatin1Char('>'), start) + 1; + if (end <= start) + break; const QString &meta = head.mid(start, end - start).toLower(); if (r.indexIn(meta) != -1) return r.cap(1); -- cgit v0.12 From 9fc2d9630169cd2466f113e259b5cae73baeb1c8 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 15:42:19 +0100 Subject: Assistant: Use isLocalUrl() to decide whether a page is internal. Reviewed-by: kh1 --- tools/assistant/tools/assistant/aboutdialog.cpp | 5 ++-- tools/assistant/tools/assistant/helpviewer.cpp | 32 +++++++++++-------------- tools/assistant/tools/assistant/helpviewer.h | 2 ++ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index 5727528..26d488d 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -96,9 +96,8 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name) void AboutLabel::setSource(const QUrl &url) { TRACE_OBJ - if (url.isValid() - && (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") - || url.scheme() == QLatin1String("mailto") || !HelpViewer::canOpenPage(url.path()))) { + if (url.isValid() && (!HelpViewer::isLocalUrl(url) + || !HelpViewer::canOpenPage(url.path()))) { if (!QDesktopServices::openUrl(url)) { QMessageBox::warning(this, tr("Warning"), tr("Unable to launch external application.\n"), diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index d92ff13..4141d64 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -208,20 +208,6 @@ QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) return newPage; } -static bool isLocalUrl(const QUrl &url) -{ - TRACE_OBJ - const QString scheme = url.scheme(); - if (scheme.isEmpty() - || scheme == QLatin1String("file") - || scheme == QLatin1String("qrc") - || scheme == QLatin1String("data") - || scheme == QLatin1String("qthelp") - || scheme == QLatin1String("about")) - return true; - return false; -} - void HelpPage::triggerAction(WebAction action, bool checked) { TRACE_OBJ @@ -242,7 +228,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, const bool closeNewTab = closeNewTabIfNeeded; closeNewTabIfNeeded = false; - if (isLocalUrl(url)) { + if (HelpViewer::isLocalUrl(url)) { const QString& path = url.path(); if (!HelpViewer::canOpenPage(path)) { QTemporaryFile tmpTmpFile; @@ -477,9 +463,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url) { TRACE_OBJ const bool canOpen = canOpenPage(url.path()); - if (url.scheme() == QLatin1String("http") - || url.scheme() == QLatin1String("ftp") - || url.scheme() == QLatin1String("mailto") || !canOpen) { + if (!isLocalUrl(url) || !canOpen) { bool launched = false; if (!canOpen && url.scheme() == QLatin1String("qthelp")) { const QString& path = url.path(); @@ -645,5 +629,17 @@ bool HelpViewer::canOpenPage(const QString &url) || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive); } +bool HelpViewer::isLocalUrl(const QUrl &url) +{ + TRACE_OBJ + const QString scheme = url.scheme(); + return scheme.isEmpty() + || scheme == QLatin1String("file") + || scheme == QLatin1String("qrc") + || scheme == QLatin1String("data") + || scheme == QLatin1String("qthelp") + || scheme == QLatin1String("about"); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index cfe4c3e..4dd8064 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -98,6 +98,7 @@ public: { return textSizeMultiplier(); } static bool canOpenPage(const QString &url); + static bool isLocalUrl(const QUrl &url); public Q_SLOTS: void home(); @@ -146,6 +147,7 @@ public: bool launchedWithExternalApp(const QUrl &url); static bool canOpenPage(const QString &url); + static bool isLocalUrl(const QUrl &url); public Q_SLOTS: void home(); -- cgit v0.12 From 6c5c2312ca5477a1ec33f43c1673ab65a0dce8bb Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 14 Jan 2010 16:17:21 +0100 Subject: Assistant: Extend list of file types to open internally. --- tools/assistant/tools/assistant/helpviewer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 4141d64..bd75f3a 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -626,7 +626,8 @@ bool HelpViewer::canOpenPage(const QString &url) { TRACE_OBJ return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) - || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive); + || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) + || url == QLatin1String("blank"); } bool HelpViewer::isLocalUrl(const QUrl &url) -- cgit v0.12 From f0d24ba1eaa1079abef3a1da641b43437dc7df66 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 15 Jan 2010 13:38:12 +1000 Subject: Added new funcs to QAudioFormat and QAudioDeviceInfo class's. QAudioFormat::setChannelCount(), channelCount() QAudioFormat::setSampleRate(), sampleRate() QAudioDeviceInfo::supportedChannelCounts(), supportedSampleRates() Changed all instances to use these new functions instead of channels(),frequency(),setFrequency(),setChannels() supportedChannels(),supportedFrequencies() Old functions still exist but are marked obsolete. Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 4 +- examples/multimedia/audiodevices/audiodevices.cpp | 16 +++--- examples/multimedia/audioinput/audioinput.cpp | 4 +- examples/multimedia/audiooutput/audiooutput.cpp | 4 +- src/multimedia/audio/qaudio_mac.cpp | 12 ++-- src/multimedia/audio/qaudiodeviceinfo.cpp | 32 ++++++++++- src/multimedia/audio/qaudiodeviceinfo.h | 2 + src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 26 ++++----- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 8 +-- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 10 ++-- src/multimedia/audio/qaudioformat.cpp | 66 +++++++++++++++++++--- src/multimedia/audio/qaudioformat.h | 6 ++ src/multimedia/audio/qaudioinput.cpp | 4 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 8 +-- src/multimedia/audio/qaudioinput_mac_p.cpp | 2 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 16 +++--- src/multimedia/audio/qaudiooutput.cpp | 4 +- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 6 +- src/multimedia/audio/qaudiooutput_mac_p.cpp | 6 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 14 ++--- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 16 +++--- tests/auto/qaudioformat/tst_qaudioformat.cpp | 10 ++-- tests/auto/qaudioinput/tst_qaudioinput.cpp | 8 +-- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 8 +-- 24 files changed, 189 insertions(+), 103 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..bf4b145 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -89,9 +89,9 @@ private: { //![1] QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); //![1] - format.setChannels(2); + format.setChannelCount(2); format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4198605..bf6d2d0 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -108,8 +108,8 @@ void AudioTest::test() } else { QAudioFormat nearest = deviceInfo.nearestFormat(settings); logOutput->append(tr("Failed")); - nearestFreq->setText(QString("%1").arg(nearest.frequency())); - nearestChannel->setText(QString("%1").arg(nearest.channels())); + nearestFreq->setText(QString("%1").arg(nearest.sampleRate())); + nearestChannel->setText(QString("%1").arg(nearest.channelCount())); nearestCodec->setText(nearest.codec()); nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); @@ -161,18 +161,18 @@ void AudioTest::deviceChanged(int idx) deviceInfo = deviceBox->itemData(idx).value(); frequencyBox->clear(); - QList freqz = deviceInfo.supportedFrequencies(); + QList freqz = deviceInfo.supportedSampleRates(); for(int i = 0; i < freqz.size(); ++i) frequencyBox->addItem(QString("%1").arg(freqz.at(i))); if(freqz.size()) - settings.setFrequency(freqz.at(0)); + settings.setSampleRate(freqz.at(0)); channelsBox->clear(); - QList chz = deviceInfo.supportedChannels(); + QList chz = deviceInfo.supportedChannelCounts(); for(int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); if(chz.size()) - settings.setChannels(chz.at(0)); + settings.setChannelCount(chz.at(0)); codecsBox->clear(); QStringList codecz = deviceInfo.supportedCodecs(); @@ -229,12 +229,12 @@ void AudioTest::deviceChanged(int idx) void AudioTest::freqChanged(int idx) { // freq has changed - settings.setFrequency(frequencyBox->itemText(idx).toInt()); + settings.setSampleRate(frequencyBox->itemText(idx).toInt()); } void AudioTest::channelChanged(int idx) { - settings.setChannels(channelsBox->itemText(idx).toInt()); + settings.setChannelCount(channelsBox->itemText(idx).toInt()); } void AudioTest::codecChanged(int idx) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 3d537a2..3349d54 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -196,8 +196,8 @@ InputTest::InputTest() pullMode = true; // AudioInfo class only supports mono S16LE samples! - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(16); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index c92bbaf..7a76c82 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -164,8 +164,8 @@ AudioTest::AudioTest() gen->start(); - settings.setFrequency(SYSTEM_FREQ); - settings.setChannels(1); + settings.setSampleRate(SYSTEM_FREQ); + settings.setChannelCount(1); settings.setSampleSize(16); settings.setCodec("audio/pcm"); settings.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 1cd9225..d876745 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -48,8 +48,8 @@ QT_BEGIN_NAMESPACE QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) { dbg.nospace() << "QAudioFormat(" << - audioFormat.frequency() << "," << - audioFormat.channels() << "," << + audioFormat.sampleRate() << "," << + audioFormat.channelCount() << "," << audioFormat.sampleSize()<< "," << audioFormat.codec() << "," << audioFormat.byteOrder() << "," << @@ -64,8 +64,8 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) { QAudioFormat audioFormat; - audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setSampleRate(sf.mSampleRate); + audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); @@ -84,9 +84,9 @@ AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& au AudioStreamBasicDescription sf; sf.mFormatFlags = kAudioFormatFlagIsPacked; - sf.mSampleRate = audioFormat.frequency(); + sf.mSampleRate = audioFormat.sampleRate(); sf.mFramesPerPacket = 1; - sf.mChannelsPerFrame = audioFormat.channels(); + sf.mChannelsPerFrame = audioFormat.channelCount(); sf.mBitsPerChannel = audioFormat.sampleSize(); sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index dce2884..45e177e 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -100,13 +100,13 @@ public: You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte - order, channel, codec, frequency, sample rate, and sample type. A + order, channel, codec, sample rate, sample size and sample type. A format is represented by the QAudioFormat class. The values supported by the the device for each of these parameters can be fetched with - supportedByteOrders(), supportedChannels(), supportedCodecs(), - supportedFrequencies(), supportedSampleSizes(), and + supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), + supportedSampleRates(), supportedSampleSizes(), and supportedSampleTypes(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with isFormatSupported(), or fetch a @@ -259,6 +259,19 @@ QStringList QAudioDeviceInfo::supportedCodecs() const } /*! + Returns a list of supported sample rates. +*/ + +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \obsolete + + Use supportedSampleRates() instead. + Returns a list of supported frequencies. */ @@ -268,6 +281,19 @@ QList QAudioDeviceInfo::supportedFrequencies() const } /*! + Returns a list of supported channel counts. +*/ + +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \obsolete + + Use supportedChannelCount() instead. + Returns a list of supported channels. */ diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 53b9904..134b688 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -84,7 +84,9 @@ public: QStringList supportedCodecs() const; QList supportedFrequencies() const; + QList supportedSampleRates() const; QList supportedChannels() const; + QList supportedChannelCounts() const; QList supportedSampleSizes() const; QList supportedByteOrders() const; QList supportedSampleTypes() const; diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index e828238..08c617b 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -78,20 +78,20 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setSampleRate(44100); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { - nearest.setFrequency(8000); - nearest.setChannels(1); + nearest.setSampleRate(8000); + nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); if(!testSettings(nearest)) { - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setSampleSize(16); nearest.setSampleType(QAudioFormat::SignedInt); } @@ -234,8 +234,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const snd_pcm_hw_params_any( handle, params ); // set the values! - snd_pcm_hw_params_set_channels(handle,params,format.channels()); - snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); + snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); switch(format.sampleSize()) { case 8: if(format.sampleType() == QAudioFormat::SignedInt) @@ -276,18 +276,18 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const } else testCodec = true; - if(err>=0 && format.channels() != -1) { - err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); + if(err>=0 && format.channelCount() != -1) { + err = snd_pcm_hw_params_test_channels(handle,params,format.channelCount()); if(err>=0) - err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); + err = snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); if(err>=0) testChannel = true; } - if(err>=0 && format.frequency() != -1) { - err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); + if(err>=0 && format.sampleRate() != -1) { + err = snd_pcm_hw_params_test_rate(handle,params,format.sampleRate(),0); if(err>=0) - err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + err = snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); if(err>=0) testFreq = true; } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ec07748..258132a 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -144,10 +144,10 @@ QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) rc.setCodec(QString::fromLatin1("audio/pcm")); - if (rc.frequency() != target.frequency()) - rc.setFrequency(target.frequency()); - if (rc.channels() != target.channels()) - rc.setChannels(target.channels()); + if (rc.sampleRate() != target.sampleRate()) + rc.setSampleRate(target.sampleRate()); + if (rc.channelCount() != target.channelCount()) + rc.setChannelCount(target.channelCount()); if (rc.sampleSize() != target.sampleSize()) rc.setSampleSize(target.sampleSize()); if (rc.byteOrder() != target.byteOrder()) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 69d5c94..f77efd0 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -95,14 +95,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat nearest; if(mode == QAudio::AudioOutput) { nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(11025); - nearest.setChannels(1); + nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); @@ -180,12 +180,12 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const if(!format.codec().startsWith(QLatin1String("audio/pcm"))) failed = true; - if(!failed && !(format.channels() == 1 || format.channels() == 2)) + if(!failed && !(format.channelCount() == 1 || format.channelCount() == 2)) failed = true; if(!failed) { - if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 || - format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000)) + if(!(format.sampleRate() == 8000 || format.sampleRate() == 11025 || format.sampleRate() == 22050 || + format.sampleRate() == 44100 || format.sampleRate() == 48000 || format.sampleRate() == 96000)) failed = true; } diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 86fe85b..e31d2ec 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -111,7 +111,7 @@ public: \o Parameter \o Description \row - \o Frequency + \o Sample Rate \o Samples per second of audio data in Hertz. \row \o Number of channels @@ -143,8 +143,8 @@ public: Values are initialized as follows: \list - \o frequency() = -1 - \o channels() = -1 + \o sampleRate() = -1 + \o channelCount() = -1 \o sampleSize() = -1 \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) \o sampleType() = QAudioFormat::Unknown @@ -227,7 +227,20 @@ bool QAudioFormat::isNull() const } /*! - Sets the frequency to \a frequency. + Sets the sample rate to \a samplerate Hertz. +*/ + +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \obsolete + + Use setSampleRate() instead. + + Sets the frequency to \a frequency Hertz. */ void QAudioFormat::setFrequency(int frequency) @@ -236,7 +249,20 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current sample rate in Hertz. +*/ + +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \obsolete + + Use sampleRate() instead. + + Returns the current frequency in Hertz. */ int QAudioFormat::frequency() const @@ -245,7 +271,20 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the channel count to \a channels. +*/ + +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \obsolete + + Use setChannelCount() instead. + + Sets the no. of channels to \a channels. */ void QAudioFormat::setChannels(int channels) @@ -254,7 +293,20 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current channel count value. +*/ + +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \obsolete + + Use channelCount() instead. + + Returns the no. of channels. */ int QAudioFormat::channels() const diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index d5841ce..f64dd7e 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,6 +76,12 @@ public: void setFrequency(int frequency); int frequency() const; + void setSampleRate(int samplerate); + int sampleRate() const; + + void setChannelCount(int channels); + int channelCount() const; + void setChannels(int channels); int channels() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 7a3be23..8f2d75b 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -85,8 +85,8 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 9eb8cfb..b6fff64 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -256,7 +256,7 @@ bool QAudioInputPrivate::open() int dir; int err=-1; int count=0; - unsigned int freakuency=settings.frequency(); + unsigned int freakuency=settings.sampleRate(); QString dev = QString(QLatin1String(m_device.constData())); if(!dev.contains(QLatin1String("default"))) { @@ -323,7 +323,7 @@ bool QAudioInputPrivate::open() } } if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() ); if ( err < 0 ) { fatal = true; errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); @@ -496,7 +496,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) errorState = QAudio::NoError; deviceState = QAudio::IdleState; } else { - totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency(); + totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; @@ -693,7 +693,7 @@ qint64 InputPrivate::readData( char* data, qint64 len) count++; } if(err > 0 && readFrames > 0) { - audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000; + audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.sampleRate()*1000; audioDevice->deviceState = QAudio::ActiveState; return err; } diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index cb05920..c88c558 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -814,7 +814,7 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::totalTime() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioInputPrivate::clock() const diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index a059e76..ca0bc24 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -217,21 +217,21 @@ bool QAudioInputPrivate::open() header = 0; if(buffer_size == 0) { // Default buffer size, 100ms, default period size is 20ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.1; period_size = buffer_size/5; } else { period_size = buffer_size/5; } #ifdef Q_OS_WINCE // For wince reduce size to 40ms for buffer size and 20ms period - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.04; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.04; period_size = buffer_size/2; #endif timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -367,8 +367,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) } else { totalTimeValue += waveBlocks[header].dwBytesRecorded - /((settings.channels()*settings.sampleSize()/8)) - *10000/settings.frequency()*100; + /((settings.channelCount()*settings.sampleSize()/8)) + *10000/settings.sampleRate()*100; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; resuming = false; @@ -381,8 +381,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) qDebug()<<"IN: "< 0) { - totalTimeValue += err*1000000/settings.frequency(); + totalTimeValue += err*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index f23db80..5bb872f 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -87,8 +87,8 @@ public: m_device(0) { m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels(); - m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency(); + m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channelCount(); + m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.sampleRate(); m_fillTimer = new QTimer(this); connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer())); @@ -546,7 +546,7 @@ int QAudioOutputPrivate::notifyInterval() const qint64 QAudioOutputPrivate::totalTime() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioOutputPrivate::clock() const diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 1810ed2..4a77386 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -205,7 +205,7 @@ bool QAudioOutputPrivate::open() #endif if(buffer_size == 0) { // Default buffer size, 200ms, default period size is 40ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.2; period_size = buffer_size/5; } else { period_size = buffer_size/5; @@ -224,9 +224,9 @@ bool QAudioOutputPrivate::open() timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -281,8 +281,8 @@ void QAudioOutputPrivate::close() return; deviceState = QAudio::StopState; - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); + int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate() + *settings.channelCount()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); Sleep(delay+10); @@ -378,8 +378,8 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) LeaveCriticalSection(&waveOutCriticalSection); #endif totalTimeValue += current->dwBufferLength - /(settings.channels()*(settings.sampleSize()/8)) - *1000000/settings.frequency();; + /(settings.channelCount()*(settings.sampleSize()/8)) + *1000000/settings.sampleRate();; waveCurrentBlock++; waveCurrentBlock %= buffer_size/period_size; current = &waveBlocks[waveCurrentBlock]; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 7b9a422..45ebc5f 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -128,7 +128,7 @@ void tst_QAudioDeviceInfo::codecs() void tst_QAudioDeviceInfo::channels() { if(available) { - QList avail = device->supportedChannels(); + QList avail = device->supportedChannelCounts(); QVERIFY(avail.size() > 0); } } @@ -160,7 +160,7 @@ void tst_QAudioDeviceInfo::sampleTypes() void tst_QAudioDeviceInfo::frequencies() { if(available) { - QList avail = device->supportedFrequencies(); + QList avail = device->supportedSampleRates(); QVERIFY(avail.size() > 0); } } @@ -169,8 +169,8 @@ void tst_QAudioDeviceInfo::isformat() { if(available) { QAudioFormat format; - format.setFrequency(44100); - format.setChannels(2); + format.setSampleRate(44100); + format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleSize(16); @@ -185,8 +185,8 @@ void tst_QAudioDeviceInfo::preferred() { if(available) { QAudioFormat format = device->preferredFormat(); - QVERIFY(format.frequency() == 44100); - QVERIFY(format.channels() == 2); + QVERIFY(format.sampleRate() == 44100); + QVERIFY(format.channelCount() == 2); } } @@ -194,9 +194,9 @@ void tst_QAudioDeviceInfo::nearest() { if(available) { QAudioFormat format1, format2; - format1.setFrequency(8000); + format1.setSampleRate(8000); format2 = device->nearestFormat(format1); - QVERIFY(format2.frequency() == 44100); + QVERIFY(format2.sampleRate() == 44100); } } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 286e63f..5d70fed 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -92,7 +92,7 @@ void tst_QAudioFormat::checkFrequency() void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; - audioFormat.setChannels(2); + audioFormat.setChannelCount(2); QVERIFY(audioFormat.channels() == 2); } @@ -135,14 +135,14 @@ void tst_QAudioFormat::checkEquality() // on filled formats audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); audioFormat1.setFrequency(8000); - audioFormat1.setChannels(1); + audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); audioFormat1.setByteOrder(QAudioFormat::LittleEndian); @@ -151,7 +151,7 @@ void tst_QAudioFormat::checkEquality() QVERIFY(audioFormat0 == audioFormat1); QVERIFY(!(audioFormat0 != audioFormat1)); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); QVERIFY(audioFormat0 != audioFormat1); QVERIFY(!(audioFormat0 == audioFormat1)); } @@ -162,7 +162,7 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat1; audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 3efc346..bb1ac70 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -68,8 +68,8 @@ private: void tst_QAudioInput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -94,8 +94,8 @@ void tst_QAudioInput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index b001af1..c3c25d3 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -71,8 +71,8 @@ private: void tst_QAudioOutput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -95,8 +95,8 @@ void tst_QAudioOutput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); -- cgit v0.12 From 2d1f2bbfa6def2afdf8cc53e4521c4c74c9b1769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 15 Jan 2010 07:40:30 +0100 Subject: Doc: Cocoa is now the default Mac port. --- doc/src/development/developing-on-mac.qdoc | 40 ++++++++++++++---------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/doc/src/development/developing-on-mac.qdoc b/doc/src/development/developing-on-mac.qdoc index b0862cf..20eefb7 100644 --- a/doc/src/development/developing-on-mac.qdoc +++ b/doc/src/development/developing-on-mac.qdoc @@ -60,26 +60,26 @@ \section1 What Versions of Mac OS X are Supported? - As of Qt 4.6, Qt supports Mac OS X versions 10.4 and up. It is usually in + As of Qt 4.7, Qt supports Mac OS X versions 10.4 and up. It is usually in the best interest of the developer and user to be running the latest updates to any version. We test internally against Mac OS X 10.4.11 as well as the updated release of Mac OS X 10.5 and Mac OS X 10.6. \section2 Carbon or Cocoa? - Historically, Qt has used the Carbon toolkit, which supports 32-bit - applications on Mac OS X 10.4 and up. Qt 4.5 and up has support for the Cocoa - toolkit, which requires 10.5 and provides 64-bit support. - - This detail is typically not important to Qt application developers. Qt is - cross-platform across Carbon and Cocoa, and Qt applications behave - the same way when configured for either one. Eventually, the Carbon - version will be discontinued. This is something to keep in mind when you - consider writing code directly against native APIs. - - The current binary for Qt is built in two flavors, 32-bit Carbon and full - universal Cocoa (32-bit and 64-bit). If you want a different setup for - Qt will use, you must build from scratch. Carbon or Cocoa is chosen when + Qt supports building in two flavors, using either the Carbon or Cocoa APIs. + Using the Cocoa toolkit, Qt requires 10.5 and provides 64-bit support. With + Carbon Qt can be developed on and deployed to 10.4, but there is no 64-bit + support. + + With Qt 4.7 we now reccommend using the Cocoa version of Qt for developement, + unless you want to target the 10.4 platform. Qt now uses Cocoa by default, + both for the binary package and when configuring from source. Download the + Carbon binarypackages or configure with "-carbon" to use that version. + + There are two versions of the Qt binary, one with x86 and x86_64 + Cocoa and another with x86 and ppc Carbon. If you want a different setup + you must build from source. Carbon or Cocoa is chosen when configuring the package for building. The configure process selects Carbon by default, to specify Cocoa use the \c{-cocoa} flag. configure for a 64-bit architecture using one of the \c{-arch} flags (see \l{universal @@ -147,13 +147,11 @@ Carbon and Cocoa both have their advantages and disadvantages. Probably the easiest way to determine is to look at the version of Mac OS X you are - targetting. If you are starting a new application and can target 10.5 and - up, then please consider Cocoa only. If you have an existing application or - need to target earlier versions of the operating system and do not need - access to 64-bit or newer Apple technologies, then Carbon is a good fit. If - your needs fall in between, you can go with a 64-bit Cocoa and 32-bit - Carbon universal application with the appropriate checks in your code to - choose the right path based on where you are running the application. + targetting. If your application can target 10.5 and up, then we reccomend + using Cocoa. If you need to target earlier versions of the operating system + and do not need access to 64-bit or newer Apple technologies, then Carbon + is a good fit. If your needs fall in between, you can go with a 64-bit Cocoa and 32-bit + Carbon universal application. For Mac OS X 10.6, Apple has started recommending developers to build their applications 64-bit. The main reason is that there is a small speed -- cgit v0.12 From 27ed53bbdcbb8ee9c9916bf90e5c9fe8157091ec Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 14 Jan 2010 13:21:21 +0100 Subject: Cococa: QDialogs stays on top when application is not active At one point in history, we decided that QDialogs should stack just above normal windows. This patch reverts this behaviour, as cocoa gets confused if we stack a dialog at this level without telling it to be modal. So instead, we let cocoa set the modal window level when we create a modal session, and also let cocoa restore the level to what it were when the sessions ends. That way, we avoid doing the work that cocoa is allready designed to do. Task-number: QTBUG-5057 Reviewed-by: msorvig --- src/gui/kernel/qwidget_mac.mm | 73 ++++++++++++++++++++++++------------------- src/gui/kernel/qwidget_p.h | 1 + 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index a8cc427..2d3c862 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2194,6 +2194,41 @@ void QWidgetPrivate::finishCreateWindow_sys_Carbon(OSWindowRef windowRef) applyMaxAndMinSizeOnWindow(); } #else // QT_MAC_USE_COCOA + +void QWidgetPrivate::setWindowLevel() +{ + Q_Q(QWidget); + const QWidget * const windowParent = q->window()->parentWidget(); + const QWidget * const primaryWindow = windowParent ? windowParent->window() : 0; + NSInteger winLevel = -1; + + if (q->windowType() == Qt::Popup) { + winLevel = NSPopUpMenuWindowLevel; + // Popup should be in at least the same level as its parent. + if (primaryWindow) { + OSWindowRef parentRef = qt_mac_window_for(primaryWindow); + winLevel = qMax([parentRef level], winLevel); + } + } else if (q->windowType() == Qt::Tool) { + winLevel = NSFloatingWindowLevel; + } else if (q->windowType() == Qt::Dialog) { + // Correct modality level (NSModalPanelWindowLevel) will be + // set by cocoa when creating a modal session later. + winLevel = NSNormalWindowLevel; + } + + // StayOnTop window should appear above Tool windows. + if (data.window_flags & Qt::WindowStaysOnTopHint) + winLevel = NSPopUpMenuWindowLevel; + // Tooltips should appear above StayOnTop windows. + if (q->windowType() == Qt::ToolTip) + winLevel = NSScreenSaverWindowLevel; + // All other types are Normal level. + if (winLevel == -1) + winLevel = NSNormalWindowLevel; + [qt_mac_window_for(q) setLevel:winLevel]; +} + void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef) { Q_Q(QWidget); @@ -2266,6 +2301,7 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); } + setWindowLevel(); macUpdateHideOnSuspend(); macUpdateOpaqueSizeGrip(); macUpdateIgnoreMouseEvents(); @@ -4697,7 +4733,7 @@ void QWidgetPrivate::setModal_sys() bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask; if (windowParent && q->windowModality() == Qt::WindowModal){ - // Window should be window-modal, which implies a sheet. + // INVARIANT: Window should be window-modal (which implies a sheet). if (!alreadySheet) { // NB: the following call will call setModal_sys recursivly: recreateMacWindow(); @@ -4714,47 +4750,20 @@ void QWidgetPrivate::setModal_sys() [static_cast(windowRef) setWorksWhenModal:YES]; } } else { - // Window shold not be window-modal, and as such, not a sheet. + // INVARIANT: Window shold _not_ be window-modal (and as such, not a sheet). + // If the window is application modal, there in no need to do much at this point. if (alreadySheet){ // NB: the following call will call setModal_sys recursivly: recreateMacWindow(); windowRef = qt_mac_window_for(q); } - if (q->windowModality() == Qt::ApplicationModal) { - [windowRef setLevel:NSModalPanelWindowLevel]; - } else if (primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { + if (q->windowModality() == Qt::NonModal + && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { // INVARIANT: Our window is a dialog that has a dialog parent that is // application modal, or . This means that q is supposed to be on top of this // dialog and not be modally shaddowed: - [windowRef setLevel:NSModalPanelWindowLevel]; if ([windowRef isKindOfClass:[NSPanel class]]) [static_cast(windowRef) setWorksWhenModal:YES]; - } else { - // INVARIANT: q should not be modal. - NSInteger winLevel = -1; - if (q->windowType() == Qt::Popup) { - winLevel = NSPopUpMenuWindowLevel; - // Popup should be in at least the same level as its parent. - if (primaryWindow) { - OSWindowRef parentRef = qt_mac_window_for(primaryWindow); - winLevel = qMax([parentRef level], winLevel); - } - } else if (q->windowType() == Qt::Tool) { - winLevel = NSFloatingWindowLevel; - } else if (q->windowType() == Qt::Dialog) { - winLevel = NSModalPanelWindowLevel; - } - - // StayOnTop window should appear above Tool windows. - if (data.window_flags & Qt::WindowStaysOnTopHint) - winLevel = NSPopUpMenuWindowLevel; - // Tooltips should appear above StayOnTop windows. - if (q->windowType() == Qt::ToolTip) - winLevel = NSScreenSaverWindowLevel; - // All other types are Normal level. - if (winLevel == -1) - winLevel = NSNormalWindowLevel; - [windowRef setLevel:winLevel]; } } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index f3edf21..318a87a 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -761,6 +761,7 @@ public: void initWindowPtr(); void finishCreateWindow_sys_Carbon(OSWindowRef windowRef); #else + void setWindowLevel(); void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef); void syncCocoaMask(); void finishCocoaMaskSetup(); -- cgit v0.12 From 7dee69caea20b189d5f4f8e27179c5abfd73a815 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 15 Jan 2010 13:19:11 +0100 Subject: Cocoa: sub-windows do not stack in front of parents Seems like this were never implemented. This patch does. Task-number: QTBUG-7375 --- src/gui/kernel/qwidget_mac.mm | 42 +++++++++++++++++++++++++++++++++++------- src/gui/kernel/qwidget_p.h | 1 + 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 2d3c862..e30bf95 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2732,6 +2732,35 @@ void QWidgetPrivate::transferChildren() } } +#ifdef QT_MAC_USE_COCOA +void QWidgetPrivate::setSubWindowStacking(bool set) +{ + Q_Q(QWidget); + if (!q->isWindow() || !q->testAttribute(Qt::WA_WState_Created)) + return; + + if (QWidget *parent = q->parentWidget()) { + if (parent->testAttribute(Qt::WA_WState_Created)) { + if (set) + [qt_mac_window_for(parent) addChildWindow:qt_mac_window_for(q) ordered:NSWindowAbove]; + else + [qt_mac_window_for(parent) removeChildWindow:qt_mac_window_for(q)]; + } + } + + QList widgets = q->findChildren(); + for (int i=0; iisWindow() && child->testAttribute(Qt::WA_WState_Created)) { + if (set) + [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove]; + else + [qt_mac_window_for(q) removeChildWindow:qt_mac_window_for(child)]; + } + } +} +#endif + void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); @@ -2883,7 +2912,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) current = current->parentWidget(); } } - invalidateBuffer(q->rect()); qt_event_request_window_change(q); } @@ -3345,6 +3373,7 @@ void QWidgetPrivate::show_sys() #else // sync the opacity value back (in case of a fade). [window setAlphaValue:q->windowOpacity()]; + setSubWindowStacking(true); QWidget *top = 0; if (QApplicationPrivate::tryModalHelper(q, &top)) { @@ -3361,7 +3390,6 @@ void QWidgetPrivate::show_sys() if (NSWindow *modalWin = qt_mac_window_for(top)) [modalWin orderFront:window]; } - #endif if (q->windowType() == Qt::Popup) { if (q->focusWidget()) @@ -3422,6 +3450,7 @@ void QWidgetPrivate::hide_sys() QMacCocoaAutoReleasePool pool; if(q->isWindow()) { + setSubWindowStacking(false); OSWindowRef window = qt_mac_window_for(q); if(qt_mac_is_macsheet(q)) { #ifndef QT_MAC_USE_COCOA @@ -4751,17 +4780,16 @@ void QWidgetPrivate::setModal_sys() } } else { // INVARIANT: Window shold _not_ be window-modal (and as such, not a sheet). - // If the window is application modal, there in no need to do much at this point. if (alreadySheet){ // NB: the following call will call setModal_sys recursivly: recreateMacWindow(); windowRef = qt_mac_window_for(q); } if (q->windowModality() == Qt::NonModal - && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { - // INVARIANT: Our window is a dialog that has a dialog parent that is - // application modal, or . This means that q is supposed to be on top of this - // dialog and not be modally shaddowed: + && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { + // INVARIANT: Our window has a parent that is application modal. + // This means that q is supposed to be on top of this window and + // not be modally shaddowed: if ([windowRef isKindOfClass:[NSPanel class]]) [static_cast(windowRef) setWorksWhenModal:YES]; } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 318a87a..4b98478 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -761,6 +761,7 @@ public: void initWindowPtr(); void finishCreateWindow_sys_Carbon(OSWindowRef windowRef); #else + void setSubWindowStacking(bool set); void setWindowLevel(); void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef); void syncCocoaMask(); -- cgit v0.12 From b4dd6ff29bc921ec81b4fd67ed44830e4d697d1d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 17:27:54 +0100 Subject: Build fix for MSVC2005 and older SDK --- src/gui/dialogs/qfiledialog_win.cpp | 28 ++------------------- src/gui/dialogs/qfiledialog_win_p.h | 49 +++++++++++++++++++++++++++++++++--- src/gui/util/qsystemtrayicon_win.cpp | 1 - 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 6128a8a..c2b6950 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -60,21 +60,6 @@ #ifdef Q_WS_WINCE #include -# ifndef BFFM_SETSELECTION -# define BFFM_SETSELECTION (WM_USER + 102) -# endif -// Windows Mobile has a broken definition for BROWSEINFO -// Only compile fix -typedef struct qt_priv_browseinfo { - HWND hwndOwner; - LPCITEMIDLIST pidlRoot; - LPWSTR pszDisplayName; - LPCWSTR lpszTitle; - UINT ulFlags; - BFFCALLBACK lpfn; - LPARAM lParam; - int iImage; -} qt_BROWSEINFO; bool qt_priv_ptr_valid = false; #else #include "qfiledialog_win_p.h" @@ -457,7 +442,7 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, // Add the filters to the file dialog. if (numFilters) { wchar_t *szData = (wchar_t*)winfilters.utf16(); - COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters]; + qt_COMDLG_FILTERSPEC *filterSpec = new qt_COMDLG_FILTERSPEC[numFilters]; for(int i = 0; itestAttribute(Qt::WA_WState_Created)); bi.hwndOwner = (parent ? parent->winId() : 0); @@ -760,7 +736,7 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) qt_win_resolve_libs(); if (ptrSHBrowseForFolder) { - LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi); + LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi); if (pItemIDList) { ptrSHGetPathFromIDList(pItemIDList, path); IMalloc *pMalloc; diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index 6d8c7c9..b55d1ff 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include +#include #include -#if !defined(QFILEDIAG_WIN_P_H) && !defined(__shobjidl_h__) +#ifndef QFILEDIAG_WIN_P_H //these are the interface declarations needed for the file dialog on Vista and up @@ -50,6 +50,8 @@ //declarations typedef DWORD SICHINTF; +typedef ULONG SFGAOF; +typedef DWORD SHCONTF; #define FOS_OVERWRITEPROMPT 0x2 #define FOS_STRICTFILETYPES 0x4 #define FOS_NOCHANGEDIR 0x8 @@ -83,6 +85,31 @@ typedef int GETPROPERTYSTOREFLAGS; #define GPS_BESTEFFORT 0x00000040 #define GPS_MASK_VALID 0x0000007F +typedef int (CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); +// message from browser +#define BFFM_INITIALIZED 1 +#define BFFM_SELCHANGED 2 +#define BFFM_ENABLEOK (WM_USER + 101) +#define BFFM_SETSELECTION (WM_USER + 103) +#define BFFM_SETSTATUSTEXT (WM_USER + 104) + +// Browsing for directory. +#define BIF_RETURNONLYFSDIRS 0x0001 +#define BIF_DONTGOBELOWDOMAIN 0x0002 +#define BIF_STATUSTEXT 0x0004 +#define BIF_RETURNFSANCESTORS 0x0008 +#define BIF_EDITBOX 0x0010 +#define BIF_VALIDATE 0x0020 +#define BIF_NEWDIALOGSTYLE 0x0040 +#define BIF_BROWSEINCLUDEURLS 0x0080 +#define BIF_UAHINT 0x0100 +#define BIF_NONEWFOLDERBUTTON 0x0200 +#define BIF_NOTRANSLATETARGETS 0x0400 +#define BIF_BROWSEFORCOMPUTER 0x1000 +#define BIF_BROWSEFORPRINTER 0x2000 +#define BIF_BROWSEINCLUDEFILES 0x4000 +#define BIF_SHAREABLE 0x8000 + //the enums typedef enum { SIATTRIBFLAGS_AND = 0x1, @@ -115,11 +142,25 @@ typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE; typedef struct { LPCWSTR pszName; LPCWSTR pszSpec; -} COMDLG_FILTERSPEC; +} qt_COMDLG_FILTERSPEC; +#ifndef PROPERTYKEY_DEFINED +#define PROPERTYKEY_DEFINED typedef struct { GUID fmtid; DWORD pid; } PROPERTYKEY; +#endif +typedef struct { + HWND hwndOwner; + LPCITEMIDLIST pidlRoot; + LPWSTR pszDisplayName; + LPCWSTR lpszTitle; + UINT ulFlags; + BFFCALLBACK lpfn; + LPARAM lParam; + int iImage; +} BROWSEINFO; + DECLARE_INTERFACE(IFileDialogEvents); DECLARE_INTERFACE_(IShellItem, IUnknown) { @@ -157,7 +198,7 @@ DECLARE_INTERFACE_(IModalWindow, IUnknown) }; DECLARE_INTERFACE_(IFileDialog, IModalWindow) { - STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE; + STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const qt_COMDLG_FILTERSPEC *rgFilterSpec) PURE; STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE; STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE; STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE; diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 474555b..51de62b 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -53,7 +53,6 @@ #include #include -#include #include #include #include -- cgit v0.12 From 5c8c51284b1119f90520b6dbad0ac23fe0487bcf Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 18:22:38 +0100 Subject: build fix for mingw --- src/gui/dialogs/qfiledialog_win_p.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index b55d1ff..ad3bc14 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #ifndef QFILEDIAG_WIN_P_H @@ -150,6 +149,15 @@ typedef struct { DWORD pid; } PROPERTYKEY; #endif + +typedef struct { + USHORT cb; + BYTE abID[1]; +} SHITEMID, *LPSHITEMID; +typedef struct { + SHITEMID mkid; +} ITEMIDLIST, *LPITEMIDLIST; +typedef const ITEMIDLIST *LPCITEMIDLIST; typedef struct { HWND hwndOwner; LPCITEMIDLIST pidlRoot; -- cgit v0.12 From 61ce98e3af8f0acdb011e87e281a1440fa7817a7 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 19 Jan 2010 11:40:32 +0100 Subject: Updated painter path caching in the GL2 engine after merge. The painter path caching needed to be updated after an optimisation (45fedfeb) in the 4.6 branch was merged into the master branch. --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 2a49d8a..5e41cc1 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -809,16 +809,15 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } prepareForDraw(currentBrush.isOpaque()); - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); #ifdef QT_OPENGL_CACHE_AS_VBOS glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, 0); + setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); #else - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, cache->vertices); + setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, cache->indices); #endif -- cgit v0.12 From b80ac6d798577286829154388ac86f4cf0845e19 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 19 Jan 2010 12:55:45 +0100 Subject: Force the creation of the default collection file directory. Fixes error message after starting on a clean working system. --- tools/assistant/tools/assistant/mainwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 4e10cba..ac33fc5 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -1132,7 +1132,8 @@ QString MainWindow::collectionFileDirectory(bool createDir, const QString &cache QString MainWindow::defaultHelpCollectionFileName() { TRACE_OBJ - return collectionFileDirectory() + QDir::separator() + + // forces creation of the default collection file path + return collectionFileDirectory(true) + QDir::separator() + QString(QLatin1String("qthelpcollection_%1.qhc")). arg(QLatin1String(QT_VERSION_STR)); } -- cgit v0.12 From 1969f1f291807210f0a1b2fd3dbabb8110b9bb52 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 19 Jan 2010 13:29:10 +0100 Subject: Changed QBrush::operator== to also compare the brush transforms. Updated documentation and autotest as well. Reviewed-by: Trond --- src/gui/painting/qbrush.cpp | 36 ++++++++++++++++++------------------ tests/auto/qbrush/tst_qbrush.cpp | 9 +++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 1a83b1d..a82d0f9 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -912,7 +912,7 @@ void QBrush::setTransform(const QTransform &matrix) otherwise returns false. Two brushes are different if they have different styles, colors or - pixmaps. + transforms or different pixmaps or gradients depending on the style. \sa operator==() */ @@ -924,7 +924,7 @@ void QBrush::setTransform(const QTransform &matrix) otherwise returns false. Two brushes are equal if they have equal styles, colors and - pixmaps. + transforms and equal pixmaps or gradients depending on the style. \sa operator!=() */ @@ -933,26 +933,26 @@ bool QBrush::operator==(const QBrush &b) const { if (b.d == d) return true; - if (b.d->style == d->style && b.d->color == d->color) { - switch (d->style) { - case Qt::TexturePattern: { - QPixmap &us = (static_cast(d.data()))->pixmap(); - QPixmap &them = (static_cast(b.d.data()))->pixmap(); + if (b.d->style != d->style || b.d->color != d->color || b.d->transform != d->transform) + return false; + switch (d->style) { + case Qt::TexturePattern: + { + const QPixmap &us = (static_cast(d.data()))->pixmap(); + const QPixmap &them = (static_cast(b.d.data()))->pixmap(); return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); } - case Qt::LinearGradientPattern: - case Qt::RadialGradientPattern: - case Qt::ConicalGradientPattern: - { - QGradientBrushData *d1 = static_cast(d.data()); - QGradientBrushData *d2 = static_cast(b.d.data()); - return d1->gradient == d2->gradient; - } - default: - return true; + case Qt::LinearGradientPattern: + case Qt::RadialGradientPattern: + case Qt::ConicalGradientPattern: + { + const QGradientBrushData *d1 = static_cast(d.data()); + const QGradientBrushData *d2 = static_cast(b.d.data()); + return d1->gradient == d2->gradient; } + default: + return true; } - return false; } /*! diff --git a/tests/auto/qbrush/tst_qbrush.cpp b/tests/auto/qbrush/tst_qbrush.cpp index bc2bc60..628e859 100644 --- a/tests/auto/qbrush/tst_qbrush.cpp +++ b/tests/auto/qbrush/tst_qbrush.cpp @@ -108,6 +108,15 @@ void tst_QBrush::operator_eq_eq_data() << false; QTest::newRow("rad vs con") << QBrush(QRadialGradient(0, 0, 0, 0, 0)) << QBrush(QConicalGradient(0, 0, 0)) << false; + + QBrush b1(lg); + QBrush b2(lg); + b1.setTransform(QTransform().scale(2, 2)); + QTest::newRow("lg with transform vs same lg") << b1 << b2 << false; + + b2.setTransform(QTransform().scale(2, 2)); + QTest::newRow("lg w/transform vs same lg w/same transform") << b1 << b2 << true; + } void tst_QBrush::operator_eq_eq() -- cgit v0.12 From 3d6cfbbc51f82a03cfa69d027defb0d0a3a9af50 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 20 Jan 2010 16:01:31 +0100 Subject: Removing unused image from git in qgraphicsitem autotest Reviewed-by: trustme --- tests/auto/qgraphicsitem/nestedClipping_reference.png | Bin 638 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/auto/qgraphicsitem/nestedClipping_reference.png diff --git a/tests/auto/qgraphicsitem/nestedClipping_reference.png b/tests/auto/qgraphicsitem/nestedClipping_reference.png deleted file mode 100644 index 3bd4fe7..0000000 Binary files a/tests/auto/qgraphicsitem/nestedClipping_reference.png and /dev/null differ -- cgit v0.12 From 01a54a8d903abddd8b1fbddb1410e56878f41b7c Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 21 Jan 2010 10:30:40 +0100 Subject: Assistant: Fix translations. --- tools/assistant/tools/assistant/main.cpp | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index d4f4afd..a13bf2e 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -292,23 +292,26 @@ bool unregisterDocumentation(QHelpEngineCore &collection, return true; } -void setupTranslations(QApplication &app) +void setupTranslation(const QString &fileName, const QString &dir) +{ + QTranslator *translator = new QTranslator(QCoreApplication::instance()); + if (translator->load(fileName, dir)) { + QCoreApplication::installTranslator(translator); + } else { + qWarning("Could not load translation file %s in directory %s.", + qPrintable(fileName), qPrintable(dir)); + } +} + +void setupTranslations() { TRACE_OBJ const QString& locale = QLocale::system().name(); - QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); - - QTranslator translator(0); - translator.load(QLatin1String("assistant_") + locale, resourceDir); - app.installTranslator(&translator); - - QTranslator qtTranslator(0); - qtTranslator.load(QLatin1String("qt_") + locale, resourceDir); - app.installTranslator(&qtTranslator); - - QTranslator qtHelpTranslator(0); - qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir); - app.installTranslator(&qtHelpTranslator); + const QString &resourceDir + = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + setupTranslation(QLatin1String("assistant_") + locale, resourceDir); + setupTranslation(QLatin1String("qt_") + locale, resourceDir); + setupTranslation(QLatin1String("qt_help_") + locale, resourceDir); } } // Anonymous namespace. @@ -413,7 +416,7 @@ int main(int argc, char *argv[]) cachedCollection.setCurrentFilter(cmd.currentFilter()); } - setupTranslations(a); + setupTranslations(); /* * We need to be careful here: The main window has to be deleted before -- cgit v0.12 From 6b92cb8ec199159d629c013fbd4b4b7ab8ad60db Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 21 Jan 2010 13:34:52 +0100 Subject: Make the animation api compile when QT_NO_THREAD is defined Task-number: QTBUG-6890 Reviewed-by: Thierry --- src/corelib/animation/qabstractanimation.cpp | 7 +++++++ src/corelib/animation/qpropertyanimation.cpp | 2 ++ src/corelib/animation/qvariantanimation.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index b7afd9f..f5a9d16 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -161,7 +161,9 @@ QT_BEGIN_NAMESPACE +#ifndef QT_NO_THREAD Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer) +#endif QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), @@ -173,12 +175,17 @@ QUnifiedTimer::QUnifiedTimer() : QUnifiedTimer *QUnifiedTimer::instance() { QUnifiedTimer *inst; +#ifndef QT_NO_THREAD if (!unifiedTimer()->hasLocalData()) { inst = new QUnifiedTimer; unifiedTimer()->setLocalData(inst); } else { inst = unifiedTimer()->localData(); } +#else + static QUnifiedTimer unifiedTimer; + inst = &unifiedTimer; +#endif return inst; } diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index eec5b30..ea807db 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -264,7 +264,9 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QPropertyAnimation *animToStop = 0; { +#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&staticMetaObject)); +#endif typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; static QPropertyAnimationHash hash; diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 115edbe..173802d 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -431,7 +431,9 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun { // will override any existing interpolators QInterpolatorVector *interpolators = registeredInterpolators(); +#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); +#endif if (int(interpolationType) >= interpolators->count()) interpolators->resize(int(interpolationType) + 1); interpolators->replace(interpolationType, func); @@ -446,7 +448,9 @@ template static inline QVariantAnimation::Interpolator castToInterpo QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int interpolationType) { QInterpolatorVector *interpolators = registeredInterpolators(); +#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); +#endif QVariantAnimation::Interpolator ret = 0; if (interpolationType < interpolators->count()) { ret = interpolators->at(interpolationType); -- cgit v0.12 From b739ad7a9f8a81d9f68be53045e3ab9e2ff48ff6 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 21 Jan 2010 14:56:14 +0100 Subject: Assistant: Simplify check for SQLITE plugin. Reviewed-by: kh1 --- tools/assistant/tools/assistant/main.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index a13bf2e..434a211 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -223,19 +223,6 @@ bool rebuildSearchIndex(QCoreApplication &app, const QString &collectionFile, return app.exec() == 0; } -bool checkForSqlite(CmdLineParser &cmd) -{ - TRACE_OBJ - QSqlDatabase db; - QStringList sqlDrivers(db.drivers()); - if (!sqlDrivers.contains(QLatin1String("QSQLITE"))) { - cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"), - true); - return false; - } - return true; -} - bool useGui(int argc, char *argv[]) { TRACE_OBJ @@ -407,8 +394,11 @@ int main(int argc, char *argv[]) ? EXIT_SUCCESS : EXIT_FAILURE; } - if (!checkForSqlite(cmd)) + if (!QSqlDatabase::isDriverAvailable(QLatin1String("QSQLITE"))) { + cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"), + true); return EXIT_FAILURE; + } if (!cmd.currentFilter().isEmpty()) { if (collectionFileGiven) -- cgit v0.12 From c74deadf4b7eeb2800b318e0952dac8f700d9236 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 21 Jan 2010 14:58:48 +0100 Subject: add QModelIndex::rowCount() and QModelIndex::ColumnCount convenience methods Merge-request: 438 Reviewed-by: Leonardo Sobral Cunha --- src/corelib/kernel/qabstractitemmodel.cpp | 22 +++++++++++++++++++++- src/corelib/kernel/qabstractitemmodel.h | 8 ++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index dbf422e..fdbc5ba 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1043,12 +1043,32 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, /*! + \since 4.7 + + \fn int QModelIndex::rowCount() const + + Returns the number of children of this model index. + + \sa columnCount(), parent(), child(), sibling(), model() +*/ + +/*! + \since 4.7 + + \fn int QModelIndex::columnCount() const + + Returns the number of columns for the children of this model index. + + \sa rowCount(), parent(), child(), sibling(), model() +*/ + +/*! \fn QModelIndex QModelIndex::parent() const Returns the parent of the model index, or QModelIndex() if it has no parent. - \sa child(), sibling(), model() + \sa child(), sibling(), rowCount(), columnCount(), model() */ /*! diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index 63d9e6f..d91c383 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -68,6 +68,8 @@ public: inline int column() const { return c; } inline void *internalPointer() const { return p; } inline qint64 internalId() const { return reinterpret_cast(p); } + inline int rowCount() const; + inline int columnCount() const; inline QModelIndex parent() const; inline QModelIndex sibling(int row, int column) const; inline QModelIndex child(int row, int column) const; @@ -385,6 +387,12 @@ inline QModelIndex::QModelIndex(int arow, int acolumn, void *adata, const QAbstractItemModel *amodel) : r(arow), c(acolumn), p(adata), m(amodel) {} +inline int QModelIndex::rowCount() const +{ return m ? m->rowCount(*this) : 0; } + +inline int QModelIndex::columnCount() const +{ return m ? m->columnCount(*this) : 0; } + inline QModelIndex QModelIndex::parent() const { return m ? m->parent(*this) : QModelIndex(); } -- cgit v0.12 From 613be7cd75663ab8227de80d75d8f01e92c5c7d2 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 21 Jan 2010 18:17:13 +0100 Subject: Use HighlightAllOccurrences to have highlighting after full text search. Also use HighlightAllOccurrences to have highlighting during type and search. Some more refactoring. Task-number: QTBUG-3335 Reviewed-by: ck --- tools/assistant/tools/assistant/centralwidget.cpp | 96 +++++++++++++++-------- tools/assistant/tools/assistant/centralwidget.h | 8 +- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index b3660da..dab1ade 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -363,7 +363,7 @@ void CentralWidget::zoomOut() void CentralWidget::findNext() { TRACE_OBJ - find(findWidget->editFind->text(), true, false); + find(findWidget->editFind->text(), true); } void CentralWidget::nextPage() @@ -398,7 +398,7 @@ void CentralWidget::previousPage() void CentralWidget::findPrevious() { TRACE_OBJ - find(findWidget->editFind->text(), false, true); + find(findWidget->editFind->text(), false); } void CentralWidget::closeTab() @@ -711,7 +711,7 @@ HelpViewer *CentralWidget::newEmptyTab() void CentralWidget::findCurrentText(const QString &text) { TRACE_OBJ - find(text, false, false); + find(text, true); } void CentralWidget::connectSignals() @@ -918,20 +918,37 @@ void CentralWidget::keyPressEvent(QKeyEvent *e) QWidget::keyPressEvent(e); } -void CentralWidget::find(const QString &ttf, bool forward, bool backward) +void CentralWidget::find(const QString &ttf, bool forward) { TRACE_OBJ QPalette p = findWidget->editFind->palette(); p.setColor(QPalette::Active, QPalette::Base, Qt::white); - if (!ttf.isEmpty()) { - HelpViewer *viewer = currentHelpViewer(); + bool found = false; - bool found = false; +#if defined(QT_NO_WEBKIT) + found = findInTextBrowser(ttf, forward); +#else + found = findInWebPage(ttf, forward); +#endif + + if (!found && !ttf.isEmpty()) + p.setColor(QPalette::Active, QPalette::Base, QColor(255, 102, 102)); + + if (!findWidget->isVisible()) + findWidget->show(); + findWidget->editFind->setPalette(p); +} + +bool CentralWidget::findInWebPage(const QString &ttf, bool forward) +{ + TRACE_OBJ #if !defined(QT_NO_WEBKIT) - if (viewer) { - QWebPage::FindFlags options; - if (backward) + if (HelpViewer *viewer = currentHelpViewer()) { + bool found = false; + QWebPage::FindFlags options; + if (!ttf.isEmpty()) { + if (!forward) options |= QWebPage::FindBackward; if (findWidget->checkCase->isChecked()) @@ -946,31 +963,28 @@ void CentralWidget::find(const QString &ttf, bool forward, bool backward) if (found) findWidget->labelWrapped->show(); } - } else if (tabWidget->currentWidget() == m_searchWidget) { - QTextBrowser *browser = qFindChild(m_searchWidget); - found = findInTextBrowser(browser, ttf, forward, backward); } -#else - QTextBrowser *browser = qobject_cast(viewer); - if (tabWidget->currentWidget() == m_searchWidget) - browser = qFindChild(m_searchWidget); - found = findInTextBrowser(browser, ttf, forward, backward); -#endif - - if (!found) - p.setColor(QPalette::Active, QPalette::Base, QColor(255, 102, 102)); + // force highlighting of all other matches, also when empty (clear) + options = QWebPage::HighlightAllOccurrences; + viewer->findText(QLatin1String(""), options); + viewer->findText(ttf, options); + return found; } - if (!findWidget->isVisible()) - findWidget->show(); - findWidget->editFind->setPalette(p); + // this needs to stay, case for active search results page + return findInTextBrowser(ttf, forward); +#endif + return false; } -bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, - bool forward, bool backward) +bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) { TRACE_OBJ - if (!browser) + QTextBrowser *browser = qobject_cast(currentHelpViewer()); + if (tabWidget->currentWidget() == m_searchWidget) + browser = qFindChild(m_searchWidget); + + if (!browser || ttf.isEmpty()) return false; QTextDocument *doc = browser->document(); @@ -986,7 +1000,7 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, QTextCursor::MoveAnchor); } - if (backward) + if (!forward) options |= QTextDocument::FindBackward; if (findWidget->checkCase->isChecked()) @@ -1106,7 +1120,12 @@ CentralWidget::setSourceFromSearch(const QUrl &url) { TRACE_OBJ setSource(url); - highlightSearchTerms(); +#if defined(QT_NO_WEBKIT) + highlightSearchTerms() +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } void @@ -1114,14 +1133,18 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) { TRACE_OBJ setSourceInNewTab(url); - highlightSearchTerms(); +#if defined(QT_NO_WEBKIT) + highlightSearchTerms() +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } void CentralWidget::highlightSearchTerms() { TRACE_OBJ -#if defined(QT_NO_WEBKIT) HelpViewer *viewer = currentHelpViewer(); if (!viewer) return; @@ -1144,6 +1167,7 @@ CentralWidget::highlightSearchTerms() } } +#if defined(QT_NO_WEBKIT) viewer->viewport()->setUpdatesEnabled(false); QTextCharFormat marker; @@ -1175,6 +1199,14 @@ CentralWidget::highlightSearchTerms() viewer->setTextCursor(firstHit); viewer->viewport()->setUpdatesEnabled(true); +#else + viewer->findText("", QWebPage::HighlightAllOccurrences); + // clears existing selections + foreach (const QString& term, terms) + viewer->findText(term, QWebPage::HighlightAllOccurrences); + + disconnect(viewer, SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); #endif } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 60caae3..c0bee81 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -184,16 +184,16 @@ private slots: void printPreview(QPrinter *printer); void setSourceFromSearch(const QUrl &url); void setSourceFromSearchInNewTab(const QUrl &url); + void highlightSearchTerms(); private: void connectSignals(); bool eventFilter(QObject *object, QEvent *e); - void find(const QString &ttf, bool forward, bool backward); - bool findInTextBrowser(QTextBrowser* browser, const QString &ttf, - bool forward, bool backward); + void find(const QString &ttf, bool forward); + bool findInWebPage(const QString &ttf, bool forward); + bool findInTextBrowser(const QString &ttf, bool forward); void initPrinter(); QString quoteTabTitle(const QString &title) const; - void highlightSearchTerms(); void setLastShownPages(); void getBrowserFontFor(QWidget* viewer, QFont *font); -- cgit v0.12 From c4dc54a048202955d68262a20e0100f9856be303 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 22 Jan 2010 11:41:32 +1000 Subject: Fixed compile when Qt is configured with -no-webkit --- tools/assistant/tools/assistant/centralwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index dab1ade..b772030 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1121,7 +1121,7 @@ CentralWidget::setSourceFromSearch(const QUrl &url) TRACE_OBJ setSource(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); @@ -1134,7 +1134,7 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) TRACE_OBJ setSourceInNewTab(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); -- cgit v0.12 From a5f0627f0d6123286ae852bbb1dc942214f3ee53 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 22 Jan 2010 12:58:47 +1000 Subject: Fixed compile for wincewm60standard-msvc2008. Includes partial revert of b4dd6ff29bc921ec81b4fd67ed44830e4d697d1d --- src/gui/dialogs/qfiledialog_win.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index f8c3b84..7938040 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -59,7 +59,23 @@ #endif #ifdef Q_WS_WINCE +#include #include +# ifndef BFFM_SETSELECTION +# define BFFM_SETSELECTION (WM_USER + 102) +# endif +// Windows Mobile has a broken definition for BROWSEINFO +// Only compile fix +typedef struct qt_priv_browseinfo { + HWND hwndOwner; + LPCITEMIDLIST pidlRoot; + LPWSTR pszDisplayName; + LPCWSTR lpszTitle; + UINT ulFlags; + BFFCALLBACK lpfn; + LPARAM lParam; + int iImage; +} qt_BROWSEINFO; bool qt_priv_ptr_valid = false; #else #include "qfiledialog_win_p.h" @@ -698,6 +714,11 @@ static int __stdcall winGetExistDirCallbackProc(HWND hwnd, return 0; } +#ifndef BIF_NEWDIALOGSTYLE +#define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize +#endif + + QString qt_win_get_existing_directory(const QFileDialogArgs &args) { QString currentDir = QDir::currentPath(); @@ -722,7 +743,11 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) path[0] = 0; tTitle = args.caption; +#if !defined(Q_WS_WINCE) BROWSEINFO bi; +#else + qt_BROWSEINFO bi; +#endif Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); bi.hwndOwner = (parent ? parent->winId() : 0); @@ -736,7 +761,7 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) qt_win_resolve_libs(); if (ptrSHBrowseForFolder) { - LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi); + LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi); if (pItemIDList) { ptrSHGetPathFromIDList(pItemIDList, path); IMalloc *pMalloc; -- cgit v0.12 From 381aa09688d0a333b3d44d5f77e098d4439d34f0 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 22 Jan 2010 13:31:35 +1000 Subject: Fixed compile. --- src/3rdparty/phonon/ds9/videorenderer_default.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.cpp b/src/3rdparty/phonon/ds9/videorenderer_default.cpp index 9d82255..0045a49 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_default.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_default.cpp @@ -32,7 +32,7 @@ namespace Phonon { namespace DS9 { - VideoRendererDefault::~VideoRendererVMR9() + VideoRendererDefault::~VideoRendererDefault() { } -- cgit v0.12 From b8a2d4f224a4e7c330cd40d66d08eba006ec32d9 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 22 Jan 2010 14:06:20 +1000 Subject: Fixed compile for wincewm60standard-msvc2008. --- src/3rdparty/phonon/ds9/videowidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index 59abb04..7b56ca4 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -24,9 +24,10 @@ along with this library. If not, see . #include "mediaobject.h" +#include "videorenderer_vmr9.h" + #ifndef Q_OS_WINCE #include "videorenderer_evr.h" -#include "videorenderer_vmr9.h" #else #include "videorenderer_default.h" #endif -- cgit v0.12 From 1a13a3c48ddbe3998edda778df53f4b1e838536f Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 22 Jan 2010 14:49:06 +1000 Subject: Fixed compile for wincewm60standard-msvc2008 (attempt 2) --- src/3rdparty/phonon/ds9/videowidget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index 7b56ca4..1eddaee 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -24,10 +24,9 @@ along with this library. If not, see . #include "mediaobject.h" -#include "videorenderer_vmr9.h" - #ifndef Q_OS_WINCE #include "videorenderer_evr.h" +#include "videorenderer_vmr9.h" #else #include "videorenderer_default.h" #endif @@ -370,7 +369,7 @@ namespace Phonon } } #else - renderer = new VideoRendererVMR9(m_widget); + renderer = new VideoRendererDefault(m_widget); if (renderer->getFilter() == 0) { //instanciating the renderer might fail m_noNativeRendererSupported = true; -- cgit v0.12 From dc8fb82e982127d3cc9086342db10866ca03ea7e Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 22 Jan 2010 09:59:53 +0100 Subject: Assistant: Fix compliation for -no-webkit. --- tools/assistant/tools/assistant/centralwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index dab1ade..076498e 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -973,6 +973,9 @@ bool CentralWidget::findInWebPage(const QString &ttf, bool forward) // this needs to stay, case for active search results page return findInTextBrowser(ttf, forward); +#else + Q_UNUSED(ttf); + Q_UNUSED(forward); #endif return false; } @@ -1121,7 +1124,7 @@ CentralWidget::setSourceFromSearch(const QUrl &url) TRACE_OBJ setSource(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); @@ -1134,7 +1137,7 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) TRACE_OBJ setSourceInNewTab(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); -- cgit v0.12 From bc842d020c9e4f992ebda385bbd695292997fed9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 17:27:54 +0100 Subject: Build fix for MSVC2005 and older SDK --- src/gui/dialogs/qfiledialog_win.cpp | 28 ++------------------- src/gui/dialogs/qfiledialog_win_p.h | 49 +++++++++++++++++++++++++++++++++--- src/gui/util/qsystemtrayicon_win.cpp | 1 - 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 4e333f2..f8c3b84 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -60,21 +60,6 @@ #ifdef Q_WS_WINCE #include -# ifndef BFFM_SETSELECTION -# define BFFM_SETSELECTION (WM_USER + 102) -# endif -// Windows Mobile has a broken definition for BROWSEINFO -// Only compile fix -typedef struct qt_priv_browseinfo { - HWND hwndOwner; - LPCITEMIDLIST pidlRoot; - LPWSTR pszDisplayName; - LPCWSTR lpszTitle; - UINT ulFlags; - BFFCALLBACK lpfn; - LPARAM lParam; - int iImage; -} qt_BROWSEINFO; bool qt_priv_ptr_valid = false; #else #include "qfiledialog_win_p.h" @@ -457,7 +442,7 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, // Add the filters to the file dialog. if (numFilters) { wchar_t *szData = (wchar_t*)winfilters.utf16(); - COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters]; + qt_COMDLG_FILTERSPEC *filterSpec = new qt_COMDLG_FILTERSPEC[numFilters]; for(int i = 0; itestAttribute(Qt::WA_WState_Created)); bi.hwndOwner = (parent ? parent->winId() : 0); @@ -760,7 +736,7 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) qt_win_resolve_libs(); if (ptrSHBrowseForFolder) { - LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi); + LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi); if (pItemIDList) { ptrSHGetPathFromIDList(pItemIDList, path); IMalloc *pMalloc; diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index 6d8c7c9..b55d1ff 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include +#include #include -#if !defined(QFILEDIAG_WIN_P_H) && !defined(__shobjidl_h__) +#ifndef QFILEDIAG_WIN_P_H //these are the interface declarations needed for the file dialog on Vista and up @@ -50,6 +50,8 @@ //declarations typedef DWORD SICHINTF; +typedef ULONG SFGAOF; +typedef DWORD SHCONTF; #define FOS_OVERWRITEPROMPT 0x2 #define FOS_STRICTFILETYPES 0x4 #define FOS_NOCHANGEDIR 0x8 @@ -83,6 +85,31 @@ typedef int GETPROPERTYSTOREFLAGS; #define GPS_BESTEFFORT 0x00000040 #define GPS_MASK_VALID 0x0000007F +typedef int (CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); +// message from browser +#define BFFM_INITIALIZED 1 +#define BFFM_SELCHANGED 2 +#define BFFM_ENABLEOK (WM_USER + 101) +#define BFFM_SETSELECTION (WM_USER + 103) +#define BFFM_SETSTATUSTEXT (WM_USER + 104) + +// Browsing for directory. +#define BIF_RETURNONLYFSDIRS 0x0001 +#define BIF_DONTGOBELOWDOMAIN 0x0002 +#define BIF_STATUSTEXT 0x0004 +#define BIF_RETURNFSANCESTORS 0x0008 +#define BIF_EDITBOX 0x0010 +#define BIF_VALIDATE 0x0020 +#define BIF_NEWDIALOGSTYLE 0x0040 +#define BIF_BROWSEINCLUDEURLS 0x0080 +#define BIF_UAHINT 0x0100 +#define BIF_NONEWFOLDERBUTTON 0x0200 +#define BIF_NOTRANSLATETARGETS 0x0400 +#define BIF_BROWSEFORCOMPUTER 0x1000 +#define BIF_BROWSEFORPRINTER 0x2000 +#define BIF_BROWSEINCLUDEFILES 0x4000 +#define BIF_SHAREABLE 0x8000 + //the enums typedef enum { SIATTRIBFLAGS_AND = 0x1, @@ -115,11 +142,25 @@ typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE; typedef struct { LPCWSTR pszName; LPCWSTR pszSpec; -} COMDLG_FILTERSPEC; +} qt_COMDLG_FILTERSPEC; +#ifndef PROPERTYKEY_DEFINED +#define PROPERTYKEY_DEFINED typedef struct { GUID fmtid; DWORD pid; } PROPERTYKEY; +#endif +typedef struct { + HWND hwndOwner; + LPCITEMIDLIST pidlRoot; + LPWSTR pszDisplayName; + LPCWSTR lpszTitle; + UINT ulFlags; + BFFCALLBACK lpfn; + LPARAM lParam; + int iImage; +} BROWSEINFO; + DECLARE_INTERFACE(IFileDialogEvents); DECLARE_INTERFACE_(IShellItem, IUnknown) { @@ -157,7 +198,7 @@ DECLARE_INTERFACE_(IModalWindow, IUnknown) }; DECLARE_INTERFACE_(IFileDialog, IModalWindow) { - STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE; + STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const qt_COMDLG_FILTERSPEC *rgFilterSpec) PURE; STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE; STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE; STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE; diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 6db158e..092909f 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -53,7 +53,6 @@ #include #include -#include #include #include #include -- cgit v0.12 From e29453ab71c3bf795dbc0cdeb1c88e28e2de1470 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 18:22:38 +0100 Subject: build fix for mingw --- src/gui/dialogs/qfiledialog_win_p.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index b55d1ff..ad3bc14 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #ifndef QFILEDIAG_WIN_P_H @@ -150,6 +149,15 @@ typedef struct { DWORD pid; } PROPERTYKEY; #endif + +typedef struct { + USHORT cb; + BYTE abID[1]; +} SHITEMID, *LPSHITEMID; +typedef struct { + SHITEMID mkid; +} ITEMIDLIST, *LPITEMIDLIST; +typedef const ITEMIDLIST *LPCITEMIDLIST; typedef struct { HWND hwndOwner; LPCITEMIDLIST pidlRoot; -- cgit v0.12 From 2f48ff8cbefc70b2eb4de1e08a9e48c917486018 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 22 Jan 2010 11:34:39 +0100 Subject: Adding a warning if the property of an animation is not writable --- src/corelib/animation/qpropertyanimation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 19b493d..37b79ba 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -118,7 +118,9 @@ void QPropertyAnimationPrivate::updateMetaProperty() propertyType = QVariant::Invalid; if (!targetValue->dynamicPropertyNames().contains(propertyName)) qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); - } + } else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) { + qWarning("QPropertyAnimation: you're trying to animate the non-writable property %s of your QObject", propertyName.constData()); + } } void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) -- cgit v0.12 From 178f722835ec0995fe211046579c50893659cc8e Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 18 Jan 2010 10:47:13 +0100 Subject: Standard dialogs example does not respect non-native flag When showing a colordialog from the example, it does not check if the 'use native dialogs' checkbox is checked. This patch makes sure it does --- examples/dialogs/standarddialogs/dialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp index 9001619..92ed334 100644 --- a/examples/dialogs/standarddialogs/dialog.cpp +++ b/examples/dialogs/standarddialogs/dialog.cpp @@ -239,7 +239,12 @@ void Dialog::setText() void Dialog::setColor() { - QColor color = QColorDialog::getColor(Qt::green, this); + QColor color; + if (native->isChecked()) + color = QColorDialog::getColor(Qt::green, this); + else + color = QColorDialog::getColor(Qt::green, this, "Select Color", QColorDialog::DontUseNativeDialog); + if (color.isValid()) { colorLabel->setText(color.name()); colorLabel->setPalette(QPalette(color)); -- cgit v0.12 From 2c3f2a0c41a9a2b8f1961197369b278d335f9cf1 Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 22 Jan 2010 13:03:18 +0100 Subject: QtHelp: Minor clean-ups. --- tools/assistant/tools/assistant/helpenginewrapper.cpp | 3 --- tools/assistant/tools/qcollectiongenerator/main.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 72ba30d..9785710 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -102,8 +102,6 @@ signals: private: HelpEngineWrapperPrivate(const QString &collectionFile); - friend class TimeoutForwarder; - void initFileSystemWatchers(); void assertDocFilesWatched(); void qchFileChanged(const QString &fileName, bool fromTimeout); @@ -114,7 +112,6 @@ private: QFileSystemWatcher * const m_qchWatcher; typedef QPair > RecentSignal; QMap m_recentQchUpdates; - }; HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0; diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp index d8150ff..f75d891 100644 --- a/tools/assistant/tools/qcollectiongenerator/main.cpp +++ b/tools/assistant/tools/qcollectiongenerator/main.cpp @@ -42,19 +42,19 @@ #include "../shared/collectionconfiguration.h" #include "../shared/helpgenerator.h" +#include +#include + #include #include #include #include #include #include - -#include -#include #include - #include + QT_USE_NAMESPACE class CollectionConfigReader : public QXmlStreamReader -- cgit v0.12 From a259511a2b76ddee2e1199802c66295b964c394e Mon Sep 17 00:00:00 2001 From: Darin Broady Date: Fri, 22 Jan 2010 15:12:01 +0100 Subject: The declaration of qt_x11Data needs to be consistent across the header and the implementation file, and this includes it's visibility. This error and patch was found while attempting to get symbol visibility to work with the SunStudio compilers (coming later). I went with the visibility setting from the implementation file (qapplication_x11.cpp) because I don't know if this variables is used outside of libQtGui.so, especially in 3rd-party code. If it's not supposed to be used outside of libQtGui.so, then the proper change would be to remove the Q_GUI_EXPORT from the definition in qapplication_x11.cpp. Merge-request: 433 Reviewed-by: Thiago Macieira --- src/gui/kernel/qt_x11_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index d110084..b2ce754 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -331,7 +331,7 @@ struct QXdndDropTransaction class QMimeData; struct QX11Data; -extern QX11Data *qt_x11Data; +extern Q_GUI_EXPORT QX11Data *qt_x11Data; enum DesktopEnvironment { DE_UNKNOWN, -- cgit v0.12 From 1ad847de17cb0e5f53bd5c62933ca887d9cdf7ef Mon Sep 17 00:00:00 2001 From: Darin Broady Date: Fri, 22 Jan 2010 15:12:02 +0100 Subject: Add the ability for the SunStudio 8+ compilers to do ELF symbol visibility. Merge-request: 433 Reviewed-by: Thiago Macieira --- config.tests/unix/fvisibility.test | 39 ++++++++++++++++++++++++++++---------- mkspecs/solaris-cc-64/qmake.conf | 2 ++ mkspecs/solaris-cc/qmake.conf | 2 ++ src/corelib/global/qglobal.h | 5 +++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/config.tests/unix/fvisibility.test b/config.tests/unix/fvisibility.test index b2bcc07..d716695 100755 --- a/config.tests/unix/fvisibility.test +++ b/config.tests/unix/fvisibility.test @@ -4,25 +4,41 @@ FVISIBILITY_SUPPORT=no COMPILER=$1 VERBOSE=$2 +CMDLINE= + + RunCompileTest() { cat >>fvisibility.c << EOF -__attribute__((visibility("default"))) void blah(); -#if !defined(__GNUC__) -# error "Visiblility support requires GCC" -#elif __GNUC__ < 4 -# error "GCC3 with backported visibility patch is known to miscompile Qt" +#if defined(__GNUC__) +# if (__GNUC__ < 4) +# error "GCC3 with backported visibility patch is known to miscompile Qt" +# endif +__attribute((visibility("default"))) void blah(); +#elif defined(__SUNPRO_CC) +# if (__SUNPRO_CC < 0x0550) +# error "SunStudio 8 or later is required for ELF visibility" +# endif +__global void blah(); +#else +# error "GCC4+ or SunStudio 8+ are required to support ELF visibility" #endif EOF if [ "$VERBOSE" = "yes" ] ; then - "$COMPILER" -c -fvisibility=hidden fvisibility.c && FVISIBILITY_SUPPORT=yes + "$COMPILER" -c $CMDLINE fvisibility.c && FVISIBILITY_SUPPORT=yes else - "$COMPILER" -c -fvisibility=hidden fvisibility.c >/dev/null 2>&1 && FVISIBILITY_SUPPORT=yes + "$COMPILER" -c $CMDLINE fvisibility.c >/dev/null 2>&1 && FVISIBILITY_SUPPORT=yes fi rm -f fvisibility.c fvisibility.o } + case "$COMPILER" in +g++) + CMDLINE="-fvisibility=hidden" + RunCompileTest + ;; + aCC*) ;; @@ -34,14 +50,17 @@ icpc) ;; *) # the compile test works for the intel compiler because it mimics gcc's behavior + CMDLINE="-fvisibility=hidden" RunCompileTest ;; esac ;; - *) - RunCompileTest - ;; +CC) + # This should be SunStudio. If not, it'll get caught. + CMDLINE="-xldscope=hidden" + RunCompileTest + ;; esac # done diff --git a/mkspecs/solaris-cc-64/qmake.conf b/mkspecs/solaris-cc-64/qmake.conf index eb594d9..d51d77a 100644 --- a/mkspecs/solaris-cc-64/qmake.conf +++ b/mkspecs/solaris-cc-64/qmake.conf @@ -41,6 +41,7 @@ QMAKE_CFLAGS_SHLIB = -KPIC QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CFLAGS_YACC = QMAKE_CFLAGS_THREAD = -mt +QMAKE_CFLAGS_HIDESYMS = -xldscope=hidden QMAKE_CXX = CC QMAKE_CXXFLAGS = $$QMAKE_CFLAGS @@ -53,6 +54,7 @@ QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD +QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS QMAKE_INCDIR = /usr/sfw/include QMAKE_LIBDIR = /usr/sfw/lib/64 diff --git a/mkspecs/solaris-cc/qmake.conf b/mkspecs/solaris-cc/qmake.conf index ad430d1..354b83c 100644 --- a/mkspecs/solaris-cc/qmake.conf +++ b/mkspecs/solaris-cc/qmake.conf @@ -24,6 +24,7 @@ QMAKE_CFLAGS_SHLIB = -KPIC QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CFLAGS_YACC = QMAKE_CFLAGS_THREAD = -mt +QMAKE_CFLAGS_HIDESYMS = -xldscope=hidden QMAKE_CXX = CC QMAKE_CXXFLAGS = $$QMAKE_CFLAGS @@ -36,6 +37,7 @@ QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD +QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS QMAKE_INCDIR = /usr/sfw/include QMAKE_LIBDIR = /usr/sfw/lib diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index c4cf3f0..b237659 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -672,8 +672,9 @@ namespace QT_NAMESPACE {} # define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) -// using CC 5.9: Warning: attribute visibility is unsupported and will be skipped.. -//# define Q_DECL_EXPORT __attribute__((__visibility__("default"))) +# endif +# if __SUNPRO_CC >= 0x550 +# define Q_DECL_EXPORT __global # endif # if __SUNPRO_CC < 0x5a0 # define Q_NO_TEMPLATE_FRIENDS -- cgit v0.12 From 91eec1a5c15d53b9f66349430187785dd03d5ddd Mon Sep 17 00:00:00 2001 From: Darin Broady Date: Fri, 22 Jan 2010 15:12:03 +0100 Subject: Support both gcc & g++ as a valid GCC compiler. Merge-request: 433 Reviewed-by: Thiago Macieira --- config.tests/unix/fvisibility.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.tests/unix/fvisibility.test b/config.tests/unix/fvisibility.test index d716695..99e6fbe 100755 --- a/config.tests/unix/fvisibility.test +++ b/config.tests/unix/fvisibility.test @@ -34,7 +34,7 @@ EOF case "$COMPILER" in -g++) +gcc|g++) CMDLINE="-fvisibility=hidden" RunCompileTest ;; -- cgit v0.12 From 08ff927d675532e4b8b9fef616194dfd0200b7c7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 22 Jan 2010 16:38:57 +0100 Subject: Build fix for wince --- src/gui/dialogs/qfiledialog_win.cpp | 2 +- src/gui/dialogs/qfiledialog_win_p.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index f8c3b84..3bfeb03 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -53,6 +53,7 @@ #include #include #include +#include "qfiledialog_win_p.h" #ifndef QT_NO_THREAD # include @@ -62,7 +63,6 @@ #include bool qt_priv_ptr_valid = false; #else -#include "qfiledialog_win_p.h" //we have to declare them here because they're not present for all SDK/compilers static const IID QT_IID_IFileOpenDialog = {0xd57c7288, 0xd4ad, 0x4768, {0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60} }; static const IID QT_IID_IShellItem = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe} }; diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index ad3bc14..39e6f5d 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -41,6 +41,7 @@ #include #ifndef QFILEDIAG_WIN_P_H +#define QFILEDIAG_WIN_P_H //these are the interface declarations needed for the file dialog on Vista and up -- cgit v0.12 From 44232675a87c766b48d8f3d70d04dee6538a6caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 14 Jan 2010 18:52:38 +0100 Subject: Refactor common X/Open LFS support out of individual qplatformdefs.h Reviewed-by: Thiago Macieira --- mkspecs/aix-g++-64/qplatformdefs.h | 43 +--------- mkspecs/aix-g++/qplatformdefs.h | 43 +--------- mkspecs/aix-xlc-64/qplatformdefs.h | 43 +--------- mkspecs/aix-xlc/qplatformdefs.h | 43 +--------- mkspecs/common/symbian/qplatformdefs.h | 44 +--------- mkspecs/common/xopen-lfs/qplatformdefs.h | 97 ++++++++++++++++++++++ mkspecs/hpux-acc-64/qplatformdefs.h | 44 +--------- mkspecs/hpux-acc-o64/qplatformdefs.h | 43 +--------- mkspecs/hpux-acc/qplatformdefs.h | 44 +--------- mkspecs/hpux-g++-64/qplatformdefs.h | 43 +--------- mkspecs/hpux-g++/qplatformdefs.h | 43 +--------- mkspecs/hpuxi-acc-32/qplatformdefs.h | 44 +--------- mkspecs/hpuxi-acc-64/qplatformdefs.h | 44 +--------- mkspecs/hpuxi-g++-64/qplatformdefs.h | 44 +--------- mkspecs/irix-cc-64/qplatformdefs.h | 43 +--------- mkspecs/irix-cc/qplatformdefs.h | 43 +--------- mkspecs/irix-g++/qplatformdefs.h | 43 +--------- mkspecs/linux-cxx/qplatformdefs.h | 43 +--------- mkspecs/linux-ecc-64/qplatformdefs.h | 43 +--------- mkspecs/linux-g++/qplatformdefs.h | 43 +--------- mkspecs/linux-kcc/qplatformdefs.h | 43 +--------- mkspecs/linux-llvm/qplatformdefs.h | 43 +--------- mkspecs/linux-lsb-g++/qplatformdefs.h | 44 +--------- mkspecs/linux-pgcc/qplatformdefs.h | 43 +--------- mkspecs/solaris-cc-64/qplatformdefs.h | 43 +--------- mkspecs/solaris-cc/qplatformdefs.h | 43 +--------- mkspecs/solaris-g++-64/qplatformdefs.h | 43 +--------- mkspecs/solaris-g++/qplatformdefs.h | 43 +--------- mkspecs/unsupported/qnx-g++/qplatformdefs.h | 43 +--------- .../vxworks-simpentium-g++/qplatformdefs.h | 45 +--------- 30 files changed, 142 insertions(+), 1211 deletions(-) create mode 100644 mkspecs/common/xopen-lfs/qplatformdefs.h diff --git a/mkspecs/aix-g++-64/qplatformdefs.h b/mkspecs/aix-g++-64/qplatformdefs.h index ecc2cf0..0a2ef22 100644 --- a/mkspecs/aix-g++-64/qplatformdefs.h +++ b/mkspecs/aix-g++-64/qplatformdefs.h @@ -81,47 +81,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -138,7 +98,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/aix-g++/qplatformdefs.h b/mkspecs/aix-g++/qplatformdefs.h index ecc2cf0..0a2ef22 100644 --- a/mkspecs/aix-g++/qplatformdefs.h +++ b/mkspecs/aix-g++/qplatformdefs.h @@ -81,47 +81,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -138,7 +98,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/aix-xlc-64/qplatformdefs.h b/mkspecs/aix-xlc-64/qplatformdefs.h index 2ed0879..c28f04a 100644 --- a/mkspecs/aix-xlc-64/qplatformdefs.h +++ b/mkspecs/aix-xlc-64/qplatformdefs.h @@ -77,47 +77,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -134,7 +94,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/aix-xlc/qplatformdefs.h b/mkspecs/aix-xlc/qplatformdefs.h index 435fc40..f789fda 100644 --- a/mkspecs/aix-xlc/qplatformdefs.h +++ b/mkspecs/aix-xlc/qplatformdefs.h @@ -77,47 +77,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -134,7 +94,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/common/symbian/qplatformdefs.h b/mkspecs/common/symbian/qplatformdefs.h index c8a336b..4d95fae 100644 --- a/mkspecs/common/symbian/qplatformdefs.h +++ b/mkspecs/common/symbian/qplatformdefs.h @@ -84,47 +84,10 @@ #endif #include -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -141,7 +104,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/common/xopen-lfs/qplatformdefs.h b/mkspecs/common/xopen-lfs/qplatformdefs.h new file mode 100644 index 0000000..2599d62 --- /dev/null +++ b/mkspecs/common/xopen-lfs/qplatformdefs.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_XOPEN_LFS_QPLATFORMDEFS_H +#define Q_XOPEN_LFS_QPLATFORMDEFS_H + +#ifdef QT_LARGEFILE_SUPPORT + +#define QT_STATBUF struct stat64 +#define QT_STATBUF4TSTAT struct stat64 +#define QT_FPOS_T fpos64_t +#define QT_OFF_T off64_t + +#define QT_STAT ::stat64 +#define QT_LSTAT ::lstat64 +#define QT_TRUNCATE ::truncate64 + +#define QT_OPEN ::open64 +#define QT_LSEEK ::lseek64 +#define QT_FSTAT ::fstat64 +#define QT_FTRUNCATE ::ftruncate64 + +#define QT_FOPEN ::fopen64 +#define QT_FSEEK ::fseeko64 +#define QT_FTELL ::ftello64 +#define QT_FGETPOS ::fgetpos64 +#define QT_FSETPOS ::fsetpos64 + +#define QT_MMAP ::mmap64 + +#else // !QT_LARGEFILE_SUPPORT + +#define QT_STATBUF struct stat +#define QT_STATBUF4TSTAT struct stat +#define QT_FPOS_T fpos_t +#define QT_OFF_T long + +#define QT_STAT ::stat +#define QT_LSTAT ::lstat +#define QT_TRUNCATE ::truncate + +#define QT_OPEN ::open +#define QT_LSEEK ::lseek +#define QT_FSTAT ::fstat +#define QT_FTRUNCATE ::ftruncate + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos + +#define QT_MMAP ::mmap + +#endif // QT_LARGEFILE_SUPPORT + +#define QT_OPEN_LARGEFILE O_LARGEFILE + +#endif // include guard diff --git a/mkspecs/hpux-acc-64/qplatformdefs.h b/mkspecs/hpux-acc-64/qplatformdefs.h index 50da616..933ffb7 100644 --- a/mkspecs/hpux-acc-64/qplatformdefs.h +++ b/mkspecs/hpux-acc-64/qplatformdefs.h @@ -76,47 +76,10 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -133,7 +96,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpux-acc-o64/qplatformdefs.h b/mkspecs/hpux-acc-o64/qplatformdefs.h index 1aee3f9..397d9aa 100644 --- a/mkspecs/hpux-acc-o64/qplatformdefs.h +++ b/mkspecs/hpux-acc-o64/qplatformdefs.h @@ -77,47 +77,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -134,7 +94,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpux-acc/qplatformdefs.h b/mkspecs/hpux-acc/qplatformdefs.h index 475c85a..bec30bd 100644 --- a/mkspecs/hpux-acc/qplatformdefs.h +++ b/mkspecs/hpux-acc/qplatformdefs.h @@ -79,47 +79,10 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -136,7 +99,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpux-g++-64/qplatformdefs.h b/mkspecs/hpux-g++-64/qplatformdefs.h index 6082632..54e3058 100644 --- a/mkspecs/hpux-g++-64/qplatformdefs.h +++ b/mkspecs/hpux-g++-64/qplatformdefs.h @@ -76,47 +76,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -133,7 +93,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpux-g++/qplatformdefs.h b/mkspecs/hpux-g++/qplatformdefs.h index 161474e..bb165f9 100644 --- a/mkspecs/hpux-g++/qplatformdefs.h +++ b/mkspecs/hpux-g++/qplatformdefs.h @@ -78,47 +78,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -135,7 +95,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpuxi-acc-32/qplatformdefs.h b/mkspecs/hpuxi-acc-32/qplatformdefs.h index 04ce3cd..7afb0fe 100644 --- a/mkspecs/hpuxi-acc-32/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-32/qplatformdefs.h @@ -77,47 +77,10 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -134,7 +97,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpuxi-acc-64/qplatformdefs.h b/mkspecs/hpuxi-acc-64/qplatformdefs.h index 04ce3cd..7afb0fe 100644 --- a/mkspecs/hpuxi-acc-64/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-64/qplatformdefs.h @@ -77,47 +77,10 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -134,7 +97,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/hpuxi-g++-64/qplatformdefs.h b/mkspecs/hpuxi-g++-64/qplatformdefs.h index ba62e24..62c977f 100644 --- a/mkspecs/hpuxi-g++-64/qplatformdefs.h +++ b/mkspecs/hpuxi-g++-64/qplatformdefs.h @@ -76,47 +76,10 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -133,7 +96,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/irix-cc-64/qplatformdefs.h b/mkspecs/irix-cc-64/qplatformdefs.h index f1078df..bcd8742 100644 --- a/mkspecs/irix-cc-64/qplatformdefs.h +++ b/mkspecs/irix-cc-64/qplatformdefs.h @@ -75,47 +75,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -132,7 +92,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/irix-cc/qplatformdefs.h b/mkspecs/irix-cc/qplatformdefs.h index f1078df..bcd8742 100644 --- a/mkspecs/irix-cc/qplatformdefs.h +++ b/mkspecs/irix-cc/qplatformdefs.h @@ -75,47 +75,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -132,7 +92,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/irix-g++/qplatformdefs.h b/mkspecs/irix-g++/qplatformdefs.h index 49d0bfb..2d85b4f 100644 --- a/mkspecs/irix-g++/qplatformdefs.h +++ b/mkspecs/irix-g++/qplatformdefs.h @@ -75,47 +75,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -132,7 +92,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-cxx/qplatformdefs.h b/mkspecs/linux-cxx/qplatformdefs.h index 11b5ac0..a708a81 100644 --- a/mkspecs/linux-cxx/qplatformdefs.h +++ b/mkspecs/linux-cxx/qplatformdefs.h @@ -82,47 +82,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -139,7 +99,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-ecc-64/qplatformdefs.h b/mkspecs/linux-ecc-64/qplatformdefs.h index 11b5ac0..a708a81 100644 --- a/mkspecs/linux-ecc-64/qplatformdefs.h +++ b/mkspecs/linux-ecc-64/qplatformdefs.h @@ -82,47 +82,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -139,7 +99,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-g++/qplatformdefs.h b/mkspecs/linux-g++/qplatformdefs.h index a879279..09697e2 100644 --- a/mkspecs/linux-g++/qplatformdefs.h +++ b/mkspecs/linux-g++/qplatformdefs.h @@ -81,47 +81,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -138,7 +98,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-kcc/qplatformdefs.h b/mkspecs/linux-kcc/qplatformdefs.h index 30b3c25..9150292 100644 --- a/mkspecs/linux-kcc/qplatformdefs.h +++ b/mkspecs/linux-kcc/qplatformdefs.h @@ -85,47 +85,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -142,7 +102,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-llvm/qplatformdefs.h b/mkspecs/linux-llvm/qplatformdefs.h index 8e59249..ea1a0da 100644 --- a/mkspecs/linux-llvm/qplatformdefs.h +++ b/mkspecs/linux-llvm/qplatformdefs.h @@ -82,47 +82,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -139,7 +99,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-lsb-g++/qplatformdefs.h b/mkspecs/linux-lsb-g++/qplatformdefs.h index ce0b461..7731c38 100644 --- a/mkspecs/linux-lsb-g++/qplatformdefs.h +++ b/mkspecs/linux-lsb-g++/qplatformdefs.h @@ -86,47 +86,10 @@ // LSB 3.1 defines htonl and friends here #include -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -144,7 +107,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE 0 #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/linux-pgcc/qplatformdefs.h b/mkspecs/linux-pgcc/qplatformdefs.h index 11b5ac0..a708a81 100644 --- a/mkspecs/linux-pgcc/qplatformdefs.h +++ b/mkspecs/linux-pgcc/qplatformdefs.h @@ -82,47 +82,7 @@ #include #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -139,7 +99,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/solaris-cc-64/qplatformdefs.h b/mkspecs/solaris-cc-64/qplatformdefs.h index 8de7c20..d791e97 100644 --- a/mkspecs/solaris-cc-64/qplatformdefs.h +++ b/mkspecs/solaris-cc-64/qplatformdefs.h @@ -83,47 +83,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) { return ::connect(s, addr, addrlen); } -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -140,7 +100,6 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/solaris-cc/qplatformdefs.h b/mkspecs/solaris-cc/qplatformdefs.h index 128cd8f..04be413 100644 --- a/mkspecs/solaris-cc/qplatformdefs.h +++ b/mkspecs/solaris-cc/qplatformdefs.h @@ -91,47 +91,7 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) { return ::connect(s, addr, addrlen); } -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -148,7 +108,6 @@ static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T a #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/solaris-g++-64/qplatformdefs.h b/mkspecs/solaris-g++-64/qplatformdefs.h index d7aebaf..f9c21d7 100644 --- a/mkspecs/solaris-g++-64/qplatformdefs.h +++ b/mkspecs/solaris-g++-64/qplatformdefs.h @@ -100,47 +100,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr # undef bind #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -157,7 +117,6 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/solaris-g++/qplatformdefs.h b/mkspecs/solaris-g++/qplatformdefs.h index 9984a38..6438e7c 100644 --- a/mkspecs/solaris-g++/qplatformdefs.h +++ b/mkspecs/solaris-g++/qplatformdefs.h @@ -104,47 +104,7 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr # undef bind #endif -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#include "../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -161,7 +121,6 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/unsupported/qnx-g++/qplatformdefs.h b/mkspecs/unsupported/qnx-g++/qplatformdefs.h index 9fe67dd..d86ce26 100644 --- a/mkspecs/unsupported/qnx-g++/qplatformdefs.h +++ b/mkspecs/unsupported/qnx-g++/qplatformdefs.h @@ -81,47 +81,7 @@ // for htonl #include -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T off_t -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif +#include "../../common/xopen-lfs/qplatformdefs.h" #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -138,7 +98,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR ::mkdir #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR diff --git a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h index 33ffd96..47a24a4 100644 --- a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h @@ -47,48 +47,10 @@ #include "qglobal.h" #include "qfunctions_vxworks.h" +#include "../../common/xopen-lfs/qplatformdefs.h" -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::stat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::stat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif +#undef QT_LSTAT +#define QT_LSTAT QT_STAT #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR @@ -106,7 +68,6 @@ #define QT_CHDIR ::chdir #define QT_MKDIR(dir, perm) ::mkdir(dir) #define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE #define QT_OPEN_RDONLY O_RDONLY #define QT_OPEN_WRONLY O_WRONLY #define QT_OPEN_RDWR O_RDWR -- cgit v0.12 From 784946b8ea8b932924a831504387661d66170ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 15 Jan 2010 12:26:17 +0100 Subject: Refactor common C89 support out of individual qplatformdefs.h Reviewed-by: Thiago Macieira --- mkspecs/common/c89/qplatformdefs.h | 56 ++++++++++++++++++++++++++++++++++ mkspecs/cygwin-g++/qplatformdefs.h | 9 +----- mkspecs/darwin-g++/qplatformdefs.h | 13 +++++--- mkspecs/freebsd-g++/qplatformdefs.h | 13 +++++--- mkspecs/hurd-g++/qplatformdefs.h | 13 +++++--- mkspecs/lynxos-g++/qplatformdefs.h | 13 +++++--- mkspecs/macx-g++/qplatformdefs.h | 13 +++++--- mkspecs/macx-g++40/qplatformdefs.h | 13 +++++--- mkspecs/macx-g++42/qplatformdefs.h | 13 +++++--- mkspecs/macx-llvm/qplatformdefs.h | 13 +++++--- mkspecs/macx-pbuilder/qplatformdefs.h | 13 +++++--- mkspecs/macx-xcode/qplatformdefs.h | 13 +++++--- mkspecs/macx-xlc/qplatformdefs.h | 13 +++++--- mkspecs/netbsd-g++/qplatformdefs.h | 13 +++++--- mkspecs/openbsd-g++/qplatformdefs.h | 13 +++++--- mkspecs/sco-cc/qplatformdefs.h | 13 +++++--- mkspecs/sco-g++/qplatformdefs.h | 13 +++++--- mkspecs/tru64-cxx/qplatformdefs.h | 12 +++----- mkspecs/tru64-g++/qplatformdefs.h | 12 +++----- mkspecs/unixware-cc/qplatformdefs.h | 12 +++----- mkspecs/unixware-g++/qplatformdefs.h | 12 +++----- mkspecs/win32-borland/qplatformdefs.h | 17 ++++------- mkspecs/win32-g++/qplatformdefs.h | 17 ++++------- mkspecs/win32-icc/qplatformdefs.h | 18 +++++------ mkspecs/win32-msvc.net/qplatformdefs.h | 17 +++-------- mkspecs/win32-msvc/qplatformdefs.h | 16 ++-------- mkspecs/win32-msvc2005/qplatformdefs.h | 17 ++++------- 27 files changed, 231 insertions(+), 179 deletions(-) create mode 100644 mkspecs/common/c89/qplatformdefs.h diff --git a/mkspecs/common/c89/qplatformdefs.h b/mkspecs/common/c89/qplatformdefs.h new file mode 100644 index 0000000..c6a8e14 --- /dev/null +++ b/mkspecs/common/c89/qplatformdefs.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_C89_QPLATFORMDEFS_H +#define Q_C89_QPLATFORMDEFS_H + +// #include + +#define QT_FPOS_T fpos_t +#define QT_OFF_T long + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos + +#endif // include guard diff --git a/mkspecs/cygwin-g++/qplatformdefs.h b/mkspecs/cygwin-g++/qplatformdefs.h index 9b3be62..2927945 100644 --- a/mkspecs/cygwin-g++/qplatformdefs.h +++ b/mkspecs/cygwin-g++/qplatformdefs.h @@ -81,6 +81,7 @@ //#include #include +#include "../common/c89/qplatformdefs.h" #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat @@ -113,15 +114,7 @@ #define QT_OPEN_CREAT O_CREAT #define QT_OPEN_TRUNC O_TRUNC #define QT_OPEN_APPEND O_APPEND -#define QT_FOPEN ::fopen -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos #define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long #define QT_SIGNAL_RETTYPE void #define QT_SIGNAL_ARGS int diff --git a/mkspecs/darwin-g++/qplatformdefs.h b/mkspecs/darwin-g++/qplatformdefs.h index 5aea69f..4a378ba 100644 --- a/mkspecs/darwin-g++/qplatformdefs.h +++ b/mkspecs/darwin-g++/qplatformdefs.h @@ -74,15 +74,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/freebsd-g++/qplatformdefs.h b/mkspecs/freebsd-g++/qplatformdefs.h index b5d1b2f..d9c6903 100644 --- a/mkspecs/freebsd-g++/qplatformdefs.h +++ b/mkspecs/freebsd-g++/qplatformdefs.h @@ -76,15 +76,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/hurd-g++/qplatformdefs.h b/mkspecs/hurd-g++/qplatformdefs.h index 68ee2d8..41ced99 100644 --- a/mkspecs/hurd-g++/qplatformdefs.h +++ b/mkspecs/hurd-g++/qplatformdefs.h @@ -82,15 +82,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/lynxos-g++/qplatformdefs.h b/mkspecs/lynxos-g++/qplatformdefs.h index bdb492e..93ed4d5 100644 --- a/mkspecs/lynxos-g++/qplatformdefs.h +++ b/mkspecs/lynxos-g++/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-g++/qplatformdefs.h b/mkspecs/macx-g++/qplatformdefs.h index 03bdce9..890e4bb 100644 --- a/mkspecs/macx-g++/qplatformdefs.h +++ b/mkspecs/macx-g++/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h index 03bdce9..890e4bb 100644 --- a/mkspecs/macx-g++40/qplatformdefs.h +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-g++42/qplatformdefs.h b/mkspecs/macx-g++42/qplatformdefs.h index 03bdce9..890e4bb 100644 --- a/mkspecs/macx-g++42/qplatformdefs.h +++ b/mkspecs/macx-g++42/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-llvm/qplatformdefs.h b/mkspecs/macx-llvm/qplatformdefs.h index 03bdce9..890e4bb 100644 --- a/mkspecs/macx-llvm/qplatformdefs.h +++ b/mkspecs/macx-llvm/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-pbuilder/qplatformdefs.h b/mkspecs/macx-pbuilder/qplatformdefs.h index c8e49af..7a04926 100644 --- a/mkspecs/macx-pbuilder/qplatformdefs.h +++ b/mkspecs/macx-pbuilder/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-xcode/qplatformdefs.h b/mkspecs/macx-xcode/qplatformdefs.h index 03bdce9..890e4bb 100644 --- a/mkspecs/macx-xcode/qplatformdefs.h +++ b/mkspecs/macx-xcode/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/macx-xlc/qplatformdefs.h b/mkspecs/macx-xlc/qplatformdefs.h index 43c3158..b78d523 100644 --- a/mkspecs/macx-xlc/qplatformdefs.h +++ b/mkspecs/macx-xlc/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/netbsd-g++/qplatformdefs.h b/mkspecs/netbsd-g++/qplatformdefs.h index f455a86..7816703 100644 --- a/mkspecs/netbsd-g++/qplatformdefs.h +++ b/mkspecs/netbsd-g++/qplatformdefs.h @@ -75,15 +75,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/openbsd-g++/qplatformdefs.h b/mkspecs/openbsd-g++/qplatformdefs.h index 0a9ea21..db957c2 100644 --- a/mkspecs/openbsd-g++/qplatformdefs.h +++ b/mkspecs/openbsd-g++/qplatformdefs.h @@ -76,15 +76,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/sco-cc/qplatformdefs.h b/mkspecs/sco-cc/qplatformdefs.h index b5427c9..df12900 100644 --- a/mkspecs/sco-cc/qplatformdefs.h +++ b/mkspecs/sco-cc/qplatformdefs.h @@ -76,15 +76,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/sco-g++/qplatformdefs.h b/mkspecs/sco-g++/qplatformdefs.h index 058ab78..fe3c1ee 100644 --- a/mkspecs/sco-g++/qplatformdefs.h +++ b/mkspecs/sco-g++/qplatformdefs.h @@ -80,15 +80,18 @@ #include #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko #define QT_FTELL ::ftello -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/tru64-cxx/qplatformdefs.h b/mkspecs/tru64-cxx/qplatformdefs.h index 54fb139..dc18e1d 100644 --- a/mkspecs/tru64-cxx/qplatformdefs.h +++ b/mkspecs/tru64-cxx/qplatformdefs.h @@ -78,15 +78,13 @@ #include #endif -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t +#include "../common/c89/qplatformdefs.h" + +#undef QT_OFF_T #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/tru64-g++/qplatformdefs.h b/mkspecs/tru64-g++/qplatformdefs.h index 44c23f1..485879e 100644 --- a/mkspecs/tru64-g++/qplatformdefs.h +++ b/mkspecs/tru64-g++/qplatformdefs.h @@ -78,15 +78,13 @@ #include #endif -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t +#include "../common/c89/qplatformdefs.h" + +#undef QT_OFF_T #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/unixware-cc/qplatformdefs.h b/mkspecs/unixware-cc/qplatformdefs.h index e314713..cdcd3a3 100644 --- a/mkspecs/unixware-cc/qplatformdefs.h +++ b/mkspecs/unixware-cc/qplatformdefs.h @@ -76,15 +76,13 @@ #include #endif -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t +#include "../common/c89/qplatformdefs.h" + +#undef QT_OFF_T #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/unixware-g++/qplatformdefs.h b/mkspecs/unixware-g++/qplatformdefs.h index e314713..cdcd3a3 100644 --- a/mkspecs/unixware-g++/qplatformdefs.h +++ b/mkspecs/unixware-g++/qplatformdefs.h @@ -76,15 +76,13 @@ #include #endif -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t +#include "../common/c89/qplatformdefs.h" + +#undef QT_OFF_T #define QT_OFF_T off_t +#define QT_MMAP ::mmap + #define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat #define QT_STAT ::stat diff --git a/mkspecs/win32-borland/qplatformdefs.h b/mkspecs/win32-borland/qplatformdefs.h index 4efae9a..d8fa4c2 100644 --- a/mkspecs/win32-borland/qplatformdefs.h +++ b/mkspecs/win32-borland/qplatformdefs.h @@ -96,21 +96,16 @@ # define QT_STAT_LNK _S_IFLNK #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + #ifdef QT_LARGEFILE_SUPPORT +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::_fseeki64 #define QT_FTELL ::_ftelli64 -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#ifdef QT_LARGEFILE_SUPPORT #define QT_OFF_T __int64 -#else -#define QT_OFF_T long #endif #define QT_FILENO _fileno diff --git a/mkspecs/win32-g++/qplatformdefs.h b/mkspecs/win32-g++/qplatformdefs.h index 12828d1..36333b6 100644 --- a/mkspecs/win32-g++/qplatformdefs.h +++ b/mkspecs/win32-g++/qplatformdefs.h @@ -133,21 +133,16 @@ typedef enum { # define QT_OPEN_BINARY _O_BINARY #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + #ifdef QT_LARGEFILE_SUPPORT +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::fseeko64 #define QT_FTELL ::ftello64 -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#ifdef QT_LARGEFILE_SUPPORT #define QT_OFF_T off64_t -#else -#define QT_OFF_T long #endif #define QT_SIGNAL_ARGS int diff --git a/mkspecs/win32-icc/qplatformdefs.h b/mkspecs/win32-icc/qplatformdefs.h index 6abfef2..833846f 100644 --- a/mkspecs/win32-icc/qplatformdefs.h +++ b/mkspecs/win32-icc/qplatformdefs.h @@ -113,21 +113,19 @@ # define QT_OPEN_BINARY _O_BINARY #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + #if defined(QT_LARGEFILE_SUPPORT) && _MSC_VER > 1310 +#undef QT_FSEEK +#undef QT_FTELL + #define QT_FSEEK ::_fseeki64 #define QT_FTELL ::_ftelli64 -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell #endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#ifdef QT_LARGEFILE_SUPPORT + +#if defined(QT_LARGEFILE_SUPPORT) +#undef QT_OFF_T #define QT_OFF_T __int64 -#else -#define QT_OFF_T long #endif #define QT_SIGNAL_ARGS int diff --git a/mkspecs/win32-msvc.net/qplatformdefs.h b/mkspecs/win32-msvc.net/qplatformdefs.h index dcfaec5..05584c9 100644 --- a/mkspecs/win32-msvc.net/qplatformdefs.h +++ b/mkspecs/win32-msvc.net/qplatformdefs.h @@ -113,23 +113,16 @@ # define QT_OPEN_BINARY _O_BINARY #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + #ifdef QT_LARGEFILE_SUPPORT +#undef QT_FTELL +#undef QT_OFF_T + // 64-bit versions of fseek/ftell not always available. E.g., when linking // dynamically to CRT (/MT) -#define QT_FSEEK ::fseek #define QT_FTELL (QT_OFF_T)::ftell -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#ifdef QT_LARGEFILE_SUPPORT #define QT_OFF_T __int64 -#else -#define QT_OFF_T long #endif #define QT_SIGNAL_ARGS int diff --git a/mkspecs/win32-msvc/qplatformdefs.h b/mkspecs/win32-msvc/qplatformdefs.h index 5dee28c..abb5894 100644 --- a/mkspecs/win32-msvc/qplatformdefs.h +++ b/mkspecs/win32-msvc/qplatformdefs.h @@ -113,21 +113,11 @@ # define QT_OPEN_BINARY _O_BINARY #endif -#define QT_FOPEN ::fopen -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t +#include "../common/c89/qplatformdefs.h" + #ifdef QT_LARGEFILE_SUPPORT +#undef QT_OFF_T #define QT_OFF_T __int64 -#else -#define QT_OFF_T long #endif #define QT_SIGNAL_ARGS int diff --git a/mkspecs/win32-msvc2005/qplatformdefs.h b/mkspecs/win32-msvc2005/qplatformdefs.h index b87ea48..33360b7 100644 --- a/mkspecs/win32-msvc2005/qplatformdefs.h +++ b/mkspecs/win32-msvc2005/qplatformdefs.h @@ -113,21 +113,16 @@ # define QT_OPEN_BINARY _O_BINARY #endif -#define QT_FOPEN ::fopen +#include "../common/c89/qplatformdefs.h" + #ifdef QT_LARGEFILE_SUPPORT +#undef QT_FSEEK +#undef QT_FTELL +#undef QT_OFF_T + #define QT_FSEEK ::_fseeki64 #define QT_FTELL ::_ftelli64 -#else -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#endif -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#ifdef QT_LARGEFILE_SUPPORT #define QT_OFF_T __int64 -#else -#define QT_OFF_T long #endif #define QT_SIGNAL_ARGS int -- cgit v0.12 From 0f8519368e2cfdaddb49cea60096fd03df69fd62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 15 Jan 2010 18:05:06 +0100 Subject: Refactor common POSIX support out of individual qplatformdefs.h POSIX header incorporates previously refactored X/Open LFS extensions. Reviewed-by: Thiago Macieira --- mkspecs/aix-g++-64/qplatformdefs.h | 37 +----- mkspecs/aix-g++/qplatformdefs.h | 37 +----- mkspecs/aix-xlc-64/qplatformdefs.h | 31 +---- mkspecs/aix-xlc/qplatformdefs.h | 37 +----- mkspecs/common/posix/qplatformdefs.h | 144 +++++++++++++++++++++ mkspecs/common/symbian/qplatformdefs.h | 39 +----- mkspecs/common/xopen-lfs/qplatformdefs.h | 97 -------------- mkspecs/cygwin-g++/qplatformdefs.h | 43 +----- mkspecs/darwin-g++/qplatformdefs.h | 49 +------ mkspecs/freebsd-g++/qplatformdefs.h | 54 +------- mkspecs/hpux-acc-64/qplatformdefs.h | 35 +---- mkspecs/hpux-acc-o64/qplatformdefs.h | 33 +---- mkspecs/hpux-acc/qplatformdefs.h | 35 +---- mkspecs/hpux-g++-64/qplatformdefs.h | 32 +---- mkspecs/hpux-g++/qplatformdefs.h | 33 +---- mkspecs/hpuxi-acc-32/qplatformdefs.h | 34 +---- mkspecs/hpuxi-acc-64/qplatformdefs.h | 34 +---- mkspecs/hpuxi-g++-64/qplatformdefs.h | 34 +---- mkspecs/hurd-g++/qplatformdefs.h | 49 +------ mkspecs/irix-cc-64/qplatformdefs.h | 34 +---- mkspecs/irix-cc/qplatformdefs.h | 34 +---- mkspecs/irix-g++/qplatformdefs.h | 46 ++----- mkspecs/linux-cxx/qplatformdefs.h | 36 +----- mkspecs/linux-ecc-64/qplatformdefs.h | 36 +----- mkspecs/linux-g++/qplatformdefs.h | 34 +---- mkspecs/linux-kcc/qplatformdefs.h | 36 +----- mkspecs/linux-llvm/qplatformdefs.h | 34 +---- mkspecs/linux-lsb-g++/qplatformdefs.h | 43 ++---- mkspecs/linux-pgcc/qplatformdefs.h | 36 +----- mkspecs/lynxos-g++/qplatformdefs.h | 55 +------- mkspecs/macx-g++/qplatformdefs.h | 57 ++------ mkspecs/macx-g++40/qplatformdefs.h | 57 ++------ mkspecs/macx-g++42/qplatformdefs.h | 57 ++------ mkspecs/macx-llvm/qplatformdefs.h | 57 ++------ mkspecs/macx-pbuilder/qplatformdefs.h | 58 ++------- mkspecs/macx-xcode/qplatformdefs.h | 57 ++------ mkspecs/macx-xlc/qplatformdefs.h | 51 +------- mkspecs/netbsd-g++/qplatformdefs.h | 54 +------- mkspecs/openbsd-g++/qplatformdefs.h | 54 +------- mkspecs/sco-cc/qplatformdefs.h | 50 +------ mkspecs/sco-g++/qplatformdefs.h | 50 +------ mkspecs/solaris-cc-64/qplatformdefs.h | 35 +---- mkspecs/solaris-cc/qplatformdefs.h | 42 ++---- mkspecs/solaris-g++-64/qplatformdefs.h | 39 +----- mkspecs/solaris-g++/qplatformdefs.h | 38 ++---- mkspecs/tru64-cxx/qplatformdefs.h | 56 ++------ mkspecs/tru64-g++/qplatformdefs.h | 56 ++------ mkspecs/unixware-cc/qplatformdefs.h | 45 +------ mkspecs/unixware-g++/qplatformdefs.h | 45 +------ mkspecs/unsupported/qnx-g++/qplatformdefs.h | 31 +---- .../vxworks-simpentium-g++/qplatformdefs.h | 38 ++---- 51 files changed, 456 insertions(+), 1882 deletions(-) create mode 100644 mkspecs/common/posix/qplatformdefs.h delete mode 100644 mkspecs/common/xopen-lfs/qplatformdefs.h diff --git a/mkspecs/aix-g++-64/qplatformdefs.h b/mkspecs/aix-g++-64/qplatformdefs.h index 0a2ef22..4421ba4 100644 --- a/mkspecs/aix-g++-64/qplatformdefs.h +++ b/mkspecs/aix-g++-64/qplatformdefs.h @@ -81,45 +81,22 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #ifdef _AIX43 // AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #elif _AIX42 // AIX 4.2 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else // AIX 4.1 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t // override -#define QT_SOCKOPTLEN_T int +#define QT_SOCKOPTLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) diff --git a/mkspecs/aix-g++/qplatformdefs.h b/mkspecs/aix-g++/qplatformdefs.h index 0a2ef22..4421ba4 100644 --- a/mkspecs/aix-g++/qplatformdefs.h +++ b/mkspecs/aix-g++/qplatformdefs.h @@ -81,45 +81,22 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #ifdef _AIX43 // AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #elif _AIX42 // AIX 4.2 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else // AIX 4.1 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t // override -#define QT_SOCKOPTLEN_T int +#define QT_SOCKOPTLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) diff --git a/mkspecs/aix-xlc-64/qplatformdefs.h b/mkspecs/aix-xlc-64/qplatformdefs.h index c28f04a..a52b3d3 100644 --- a/mkspecs/aix-xlc-64/qplatformdefs.h +++ b/mkspecs/aix-xlc-64/qplatformdefs.h @@ -77,36 +77,11 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" +// QT_SOCKLEN_T // Only AIX 4.3 and better support 64-bit -#define QT_SOCKLEN_T socklen_t #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) // Only AIX 4.3 and better support 64-bit diff --git a/mkspecs/aix-xlc/qplatformdefs.h b/mkspecs/aix-xlc/qplatformdefs.h index f789fda..97cd0a1 100644 --- a/mkspecs/aix-xlc/qplatformdefs.h +++ b/mkspecs/aix-xlc/qplatformdefs.h @@ -77,45 +77,22 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #ifdef _AIX43 // AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #elif _AIX42 // AIX 4.2 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else // AIX 4.1 -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t // override -#define QT_SOCKOPTLEN_T int +#define QT_SOCKOPTLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) diff --git a/mkspecs/common/posix/qplatformdefs.h b/mkspecs/common/posix/qplatformdefs.h new file mode 100644 index 0000000..fe50de2 --- /dev/null +++ b/mkspecs/common/posix/qplatformdefs.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_POSIX_QPLATFORMDEFS_H +#define Q_POSIX_QPLATFORMDEFS_H + +#include + +#include +#include +#include + +#if defined(QT_USE_XOPEN_LFS_EXTENSIONS) && defined(QT_LARGEFILE_SUPPORT) + +#define QT_STATBUF struct stat64 +#define QT_FPOS_T fpos64_t +#define QT_OFF_T off64_t + +#define QT_STAT ::stat64 +#define QT_LSTAT ::lstat64 +#define QT_TRUNCATE ::truncate64 + +// File I/O +#define QT_OPEN ::open64 +#define QT_LSEEK ::lseek64 +#define QT_FSTAT ::fstat64 +#define QT_FTRUNCATE ::ftruncate64 + +// Standard C89 +#define QT_FOPEN ::fopen64 +#define QT_FSEEK ::fseeko64 +#define QT_FTELL ::ftello64 +#define QT_FGETPOS ::fgetpos64 +#define QT_FSETPOS ::fsetpos64 + +#define QT_MMAP ::mmap64 + +#else // !defined(QT_USE_XOPEN_LFS_EXTENSIONS) || !defined(QT_LARGEFILE_SUPPORT) + +#include "../c89/qplatformdefs.h" + +#define QT_STATBUF struct stat + +#define QT_STAT ::stat +#define QT_LSTAT ::lstat +#define QT_TRUNCATE ::truncate + +// File I/O +#define QT_OPEN ::open +#define QT_LSEEK ::lseek +#define QT_FSTAT ::fstat +#define QT_FTRUNCATE ::ftruncate + +// Posix extensions to C89 +#if !defined(QT_USE_XOPEN_LFS_EXTENSIONS) && !defined(QT_NO_USE_FSEEKO) +#undef QT_OFF_T +#undef QT_FSEEK +#undef QT_FTELL + +#define QT_OFF_T off_t + +#define QT_FSEEK ::fseeko +#define QT_FTELL ::ftello +#endif + +#define QT_MMAP ::mmap + +#endif // !defined (QT_USE_XOPEN_LFS_EXTENSIONS) || !defined(QT_LARGEFILE_SUPPORT) + +#define QT_STAT_MASK S_IFMT +#define QT_STAT_REG S_IFREG +#define QT_STAT_DIR S_IFDIR +#define QT_STAT_LNK S_IFLNK + +#define QT_ACCESS ::access +#define QT_GETCWD ::getcwd +#define QT_CHDIR ::chdir +#define QT_MKDIR ::mkdir +#define QT_RMDIR ::rmdir + +// File I/O +#define QT_CLOSE ::close +#define QT_READ ::read +#define QT_WRITE ::write + +#define QT_OPEN_LARGEFILE O_LARGEFILE +#define QT_OPEN_RDONLY O_RDONLY +#define QT_OPEN_WRONLY O_WRONLY +#define QT_OPEN_RDWR O_RDWR +#define QT_OPEN_CREAT O_CREAT +#define QT_OPEN_TRUNC O_TRUNC +#define QT_OPEN_APPEND O_APPEND + +// Posix extensions to C89 +#define QT_FILENO fileno + +#define QT_SOCKLEN_T socklen_t + +#define QT_SOCKET_CONNECT ::connect +#define QT_SOCKET_BIND ::bind + +#define QT_SIGNAL_RETTYPE void +#define QT_SIGNAL_ARGS int +#define QT_SIGNAL_IGNORE SIG_IGN + +#endif // include guard diff --git a/mkspecs/common/symbian/qplatformdefs.h b/mkspecs/common/symbian/qplatformdefs.h index 4d95fae..38a1314 100644 --- a/mkspecs/common/symbian/qplatformdefs.h +++ b/mkspecs/common/symbian/qplatformdefs.h @@ -84,48 +84,23 @@ #endif #include -#include "../xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T + +#define QT_OPEN_LARGEFILE 0 #if (defined(__GLIBC__) && (__GLIBC__ >= 2)) || defined(Q_OS_SYMBIAN) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif - #if defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 1999) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/common/xopen-lfs/qplatformdefs.h b/mkspecs/common/xopen-lfs/qplatformdefs.h deleted file mode 100644 index 2599d62..0000000 --- a/mkspecs/common/xopen-lfs/qplatformdefs.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the qmake spec of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef Q_XOPEN_LFS_QPLATFORMDEFS_H -#define Q_XOPEN_LFS_QPLATFORMDEFS_H - -#ifdef QT_LARGEFILE_SUPPORT - -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t - -#define QT_STAT ::stat64 -#define QT_LSTAT ::lstat64 -#define QT_TRUNCATE ::truncate64 - -#define QT_OPEN ::open64 -#define QT_LSEEK ::lseek64 -#define QT_FSTAT ::fstat64 -#define QT_FTRUNCATE ::ftruncate64 - -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 - -#define QT_MMAP ::mmap64 - -#else // !QT_LARGEFILE_SUPPORT - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_STAT ::stat -#define QT_LSTAT ::lstat -#define QT_TRUNCATE ::truncate - -#define QT_OPEN ::open -#define QT_LSEEK ::lseek -#define QT_FSTAT ::fstat -#define QT_FTRUNCATE ::ftruncate - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos - -#define QT_MMAP ::mmap - -#endif // QT_LARGEFILE_SUPPORT - -#define QT_OPEN_LARGEFILE O_LARGEFILE - -#endif // include guard diff --git a/mkspecs/cygwin-g++/qplatformdefs.h b/mkspecs/cygwin-g++/qplatformdefs.h index 2927945..b64e126 100644 --- a/mkspecs/cygwin-g++/qplatformdefs.h +++ b/mkspecs/cygwin-g++/qplatformdefs.h @@ -81,51 +81,16 @@ //#include #include -#include "../common/c89/qplatformdefs.h" +#define QT_NO_USE_FSEEKO +#include "../common/posix/qplatformdefs.h" + +#undef QT_OPEN_LARGEFILE -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND -#define QT_MMAP ::mmap - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T socklen_t #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/darwin-g++/qplatformdefs.h b/mkspecs/darwin-g++/qplatformdefs.h index 4a378ba..2ee0698 100644 --- a/mkspecs/darwin-g++/qplatformdefs.h +++ b/mkspecs/darwin-g++/qplatformdefs.h @@ -74,55 +74,12 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir +#undef QT_OPEN_LARGEFILE #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN -#define QT_SOCKLEN_T socklen_t +#define QT_STATBUF4TSTAT struct stat #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/freebsd-g++/qplatformdefs.h b/mkspecs/freebsd-g++/qplatformdefs.h index d9c6903..c0b7da6 100644 --- a/mkspecs/freebsd-g++/qplatformdefs.h +++ b/mkspecs/freebsd-g++/qplatformdefs.h @@ -76,62 +76,23 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN #if !defined(__DragonFly__) && (__FreeBSD_version < 400000) // FreeBSD 1.0 - 3.5.1 -# define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #else // FreeBSD 4.0 and better -# define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #endif +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf @@ -146,5 +107,4 @@ #define QT_AOUT_UNDERSCORE #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpux-acc-64/qplatformdefs.h b/mkspecs/hpux-acc-64/qplatformdefs.h index 933ffb7..f9789a8 100644 --- a/mkspecs/hpux-acc-64/qplatformdefs.h +++ b/mkspecs/hpux-acc-64/qplatformdefs.h @@ -76,38 +76,13 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#undef QT_SOCKLEN_T +#define QT_OPEN_LARGEFILE 0 +#define QT_SOCKLEN_T int #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpux-acc-o64/qplatformdefs.h b/mkspecs/hpux-acc-o64/qplatformdefs.h index 397d9aa..5237806 100644 --- a/mkspecs/hpux-acc-o64/qplatformdefs.h +++ b/mkspecs/hpux-acc-o64/qplatformdefs.h @@ -77,35 +77,10 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" +#undef QT_SOCKLEN_T +#define QT_SOCKLEN_T int #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpux-acc/qplatformdefs.h b/mkspecs/hpux-acc/qplatformdefs.h index bec30bd..9ce08c6 100644 --- a/mkspecs/hpux-acc/qplatformdefs.h +++ b/mkspecs/hpux-acc/qplatformdefs.h @@ -79,38 +79,14 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T -#define QT_SOCKLEN_T int +#define QT_OPEN_LARGEFILE 0 +#define QT_SOCKLEN_T int // presence of _XOPEN_UNIX can be used to detect HP-UX 10 or higher #if !defined(_XOPEN_UNIX) @@ -118,5 +94,4 @@ #define select(a,b,c,d,e) select((a), (int *)(b), (int *)(c), (int *)(d), (e)) #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpux-g++-64/qplatformdefs.h b/mkspecs/hpux-g++-64/qplatformdefs.h index 54e3058..f3fbda5 100644 --- a/mkspecs/hpux-g++-64/qplatformdefs.h +++ b/mkspecs/hpux-g++-64/qplatformdefs.h @@ -76,35 +76,7 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T socklen_t - +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpux-g++/qplatformdefs.h b/mkspecs/hpux-g++/qplatformdefs.h index bb165f9..38e9408 100644 --- a/mkspecs/hpux-g++/qplatformdefs.h +++ b/mkspecs/hpux-g++/qplatformdefs.h @@ -78,35 +78,11 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#undef QT_SOCKLEN_T +#define QT_SOCKLEN_T int // presence of _XOPEN_UNIX can be used to detect HP-UX 10 or higher #if !defined(_XOPEN_UNIX) @@ -114,5 +90,4 @@ #define select(a,b,c,d,e) select((a), (int *)(b), (int *)(c), (int *)(d), (e)) #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpuxi-acc-32/qplatformdefs.h b/mkspecs/hpuxi-acc-32/qplatformdefs.h index 7afb0fe..a0d2464 100644 --- a/mkspecs/hpuxi-acc-32/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-32/qplatformdefs.h @@ -77,37 +77,13 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 +#undef QT_SOCKLEN_T -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#define QT_OPEN_LARGEFILE 0 +#define QT_SOCKLEN_T int #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpuxi-acc-64/qplatformdefs.h b/mkspecs/hpuxi-acc-64/qplatformdefs.h index 7afb0fe..a0d2464 100644 --- a/mkspecs/hpuxi-acc-64/qplatformdefs.h +++ b/mkspecs/hpuxi-acc-64/qplatformdefs.h @@ -77,37 +77,13 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 +#undef QT_SOCKLEN_T -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#define QT_OPEN_LARGEFILE 0 +#define QT_SOCKLEN_T int #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hpuxi-g++-64/qplatformdefs.h b/mkspecs/hpuxi-g++-64/qplatformdefs.h index 62c977f..288a331 100644 --- a/mkspecs/hpuxi-g++-64/qplatformdefs.h +++ b/mkspecs/hpuxi-g++-64/qplatformdefs.h @@ -76,37 +76,13 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE -#define QT_OPEN_LARGEFILE 0 +#undef QT_SOCKLEN_T -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int +#define QT_OPEN_LARGEFILE 0 +#define QT_SOCKLEN_T int #endif // QPLATFORMDEFS_H diff --git a/mkspecs/hurd-g++/qplatformdefs.h b/mkspecs/hurd-g++/qplatformdefs.h index 41ced99..b439e6b 100644 --- a/mkspecs/hurd-g++/qplatformdefs.h +++ b/mkspecs/hurd-g++/qplatformdefs.h @@ -82,60 +82,13 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T socklen_t #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/irix-cc-64/qplatformdefs.h b/mkspecs/irix-cc-64/qplatformdefs.h index bcd8742..c95c2e5 100644 --- a/mkspecs/irix-cc-64/qplatformdefs.h +++ b/mkspecs/irix-cc-64/qplatformdefs.h @@ -75,38 +75,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif // Irix 6.5 and better @@ -115,5 +92,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/irix-cc/qplatformdefs.h b/mkspecs/irix-cc/qplatformdefs.h index bcd8742..c95c2e5 100644 --- a/mkspecs/irix-cc/qplatformdefs.h +++ b/mkspecs/irix-cc/qplatformdefs.h @@ -75,38 +75,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif // Irix 6.5 and better @@ -115,5 +92,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/irix-g++/qplatformdefs.h b/mkspecs/irix-g++/qplatformdefs.h index 2d85b4f..be7fb69 100644 --- a/mkspecs/irix-g++/qplatformdefs.h +++ b/mkspecs/irix-g++/qplatformdefs.h @@ -75,42 +75,22 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#if defined(_LANGUAGE_C_PLUS_PLUS) || !defined(_SGIAPI) -#define QT_SIGNAL_ARGS int +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_ARGS + +#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) +#define QT_SOCKLEN_T size_t #else -#define QT_SIGNAL_ARGS void +#define QT_SOCKLEN_T int #endif -#define QT_SIGNAL_IGNORE SIG_IGN -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) -#define QT_SOCKLEN_T size_t +#if defined(_LANGUAGE_C_PLUS_PLUS) || !defined(_SGIAPI) +#define QT_SIGNAL_ARGS int #else -#define QT_SOCKLEN_T int +#define QT_SIGNAL_ARGS void #endif // Irix 6.5 and better @@ -119,6 +99,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H - diff --git a/mkspecs/linux-cxx/qplatformdefs.h b/mkspecs/linux-cxx/qplatformdefs.h index a708a81..578e63a 100644 --- a/mkspecs/linux-cxx/qplatformdefs.h +++ b/mkspecs/linux-cxx/qplatformdefs.h @@ -82,38 +82,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -121,5 +98,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-ecc-64/qplatformdefs.h b/mkspecs/linux-ecc-64/qplatformdefs.h index a708a81..578e63a 100644 --- a/mkspecs/linux-ecc-64/qplatformdefs.h +++ b/mkspecs/linux-ecc-64/qplatformdefs.h @@ -82,38 +82,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -121,5 +98,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-g++/qplatformdefs.h b/mkspecs/linux-g++/qplatformdefs.h index 09697e2..23816b1 100644 --- a/mkspecs/linux-g++/qplatformdefs.h +++ b/mkspecs/linux-g++/qplatformdefs.h @@ -81,38 +81,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -120,5 +97,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-kcc/qplatformdefs.h b/mkspecs/linux-kcc/qplatformdefs.h index 9150292..3a37ab9 100644 --- a/mkspecs/linux-kcc/qplatformdefs.h +++ b/mkspecs/linux-kcc/qplatformdefs.h @@ -85,38 +85,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -124,5 +101,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-llvm/qplatformdefs.h b/mkspecs/linux-llvm/qplatformdefs.h index ea1a0da..a38c86c 100644 --- a/mkspecs/linux-llvm/qplatformdefs.h +++ b/mkspecs/linux-llvm/qplatformdefs.h @@ -82,38 +82,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -121,5 +98,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-lsb-g++/qplatformdefs.h b/mkspecs/linux-lsb-g++/qplatformdefs.h index 7731c38..e2a138a 100644 --- a/mkspecs/linux-lsb-g++/qplatformdefs.h +++ b/mkspecs/linux-lsb-g++/qplatformdefs.h @@ -86,52 +86,27 @@ // LSB 3.1 defines htonl and friends here #include -#include "../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" #undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T + #define QT_OPEN_LARGEFILE 0 -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#if defined(__GLIBC__) && (__GLIBC__ >= 2) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif #ifndef SIOCGIFBRDADDR # define SIOCGIFBRDADDR 0x8919 #endif -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t -#else -#define QT_SOCKLEN_T int -#endif - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/linux-pgcc/qplatformdefs.h b/mkspecs/linux-pgcc/qplatformdefs.h index a708a81..578e63a 100644 --- a/mkspecs/linux-pgcc/qplatformdefs.h +++ b/mkspecs/linux-pgcc/qplatformdefs.h @@ -82,38 +82,15 @@ #include #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) @@ -121,5 +98,4 @@ #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/lynxos-g++/qplatformdefs.h b/mkspecs/lynxos-g++/qplatformdefs.h index 93ed4d5..4d3965d 100644 --- a/mkspecs/lynxos-g++/qplatformdefs.h +++ b/mkspecs/lynxos-g++/qplatformdefs.h @@ -75,64 +75,21 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS void -#define QT_SIGNAL_IGNORE SIG_IGN +#undef QT_SOCKLEN_T #if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_STATBUF4TSTAT struct stat + #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-g++/qplatformdefs.h b/mkspecs/macx-g++/qplatformdefs.h index 890e4bb..5aef821 100644 --- a/mkspecs/macx-g++/qplatformdefs.h +++ b/mkspecs/macx-g++/qplatformdefs.h @@ -75,62 +75,25 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h index 890e4bb..5aef821 100644 --- a/mkspecs/macx-g++40/qplatformdefs.h +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -75,62 +75,25 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-g++42/qplatformdefs.h b/mkspecs/macx-g++42/qplatformdefs.h index 890e4bb..5aef821 100644 --- a/mkspecs/macx-g++42/qplatformdefs.h +++ b/mkspecs/macx-g++42/qplatformdefs.h @@ -75,62 +75,25 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-llvm/qplatformdefs.h b/mkspecs/macx-llvm/qplatformdefs.h index 890e4bb..5aef821 100644 --- a/mkspecs/macx-llvm/qplatformdefs.h +++ b/mkspecs/macx-llvm/qplatformdefs.h @@ -75,62 +75,25 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-pbuilder/qplatformdefs.h b/mkspecs/macx-pbuilder/qplatformdefs.h index 7a04926..256dba6 100644 --- a/mkspecs/macx-pbuilder/qplatformdefs.h +++ b/mkspecs/macx-pbuilder/qplatformdefs.h @@ -75,62 +75,22 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-xcode/qplatformdefs.h b/mkspecs/macx-xcode/qplatformdefs.h index 890e4bb..5aef821 100644 --- a/mkspecs/macx-xcode/qplatformdefs.h +++ b/mkspecs/macx-xcode/qplatformdefs.h @@ -75,62 +75,25 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_OPEN_LARGEFILE +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #else -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#define QT_STATBUF4TSTAT struct stat + #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/macx-xlc/qplatformdefs.h b/mkspecs/macx-xlc/qplatformdefs.h index b78d523..380c217 100644 --- a/mkspecs/macx-xlc/qplatformdefs.h +++ b/mkspecs/macx-xlc/qplatformdefs.h @@ -75,58 +75,17 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_SOCKLEN_T +#undef QT_SIGNAL_IGNORE -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t +#define QT_SOCKLEN_T int +#define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE (void (*)(int))1 - -#define QT_SOCKLEN_T int #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/netbsd-g++/qplatformdefs.h b/mkspecs/netbsd-g++/qplatformdefs.h index 7816703..53be833 100644 --- a/mkspecs/netbsd-g++/qplatformdefs.h +++ b/mkspecs/netbsd-g++/qplatformdefs.h @@ -75,57 +75,16 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir +#undef QT_OPEN_LARGEFILE #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +// QT_SOCKLEN_T +// NetBSD 1.0 - 1.3.3 int +// NetBSD 1.4 - 1.5 socklen_t -// NetBSD 1.0 - 1.3.3 int -// NetBSD 1.4 - 1.5 socklen_t -#define QT_SOCKLEN_T socklen_t +#define QT_STATBUF4TSTAT struct stat #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf @@ -135,5 +94,4 @@ #define QT_AOUT_UNDERSCORE #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/openbsd-g++/qplatformdefs.h b/mkspecs/openbsd-g++/qplatformdefs.h index db957c2..f5adf6f 100644 --- a/mkspecs/openbsd-g++/qplatformdefs.h +++ b/mkspecs/openbsd-g++/qplatformdefs.h @@ -76,57 +76,16 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T - -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir +#undef QT_OPEN_LARGEFILE #define QT_OPEN_LARGEFILE 0 -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +// QT_SOCKLEN_T +// OpenBSD 2.2 - 2.4 int +// OpenBSD 2.5 - 2.8 socklen_t -// OpenBSD 2.2 - 2.4 int -// OpenBSD 2.5 - 2.8 socklen_t -#define QT_SOCKLEN_T socklen_t +#define QT_STATBUF4TSTAT struct stat #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf @@ -151,5 +110,4 @@ #define QT_AOUT_UNDERSCORE #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/sco-cc/qplatformdefs.h b/mkspecs/sco-cc/qplatformdefs.h index df12900..2ae4b48 100644 --- a/mkspecs/sco-cc/qplatformdefs.h +++ b/mkspecs/sco-cc/qplatformdefs.h @@ -76,58 +76,14 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_SOCKLEN_T +#define QT_SOCKLEN_T size_t -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T size_t #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/sco-g++/qplatformdefs.h b/mkspecs/sco-g++/qplatformdefs.h index fe3c1ee..c62fe93 100644 --- a/mkspecs/sco-g++/qplatformdefs.h +++ b/mkspecs/sco-g++/qplatformdefs.h @@ -80,58 +80,14 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#include "../common/posix/qplatformdefs.h" -#undef QT_FSEEK -#undef QT_FTELL -#undef QT_OFF_T +#undef QT_SOCKLEN_T +#define QT_SOCKLEN_T int -#define QT_FSEEK ::fseeko -#define QT_FTELL ::ftello -#define QT_OFF_T off_t - -#define QT_MMAP ::mmap - -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T int #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/solaris-cc-64/qplatformdefs.h b/mkspecs/solaris-cc-64/qplatformdefs.h index d791e97..d01c48c 100644 --- a/mkspecs/solaris-cc-64/qplatformdefs.h +++ b/mkspecs/solaris-cc-64/qplatformdefs.h @@ -76,41 +76,16 @@ #include #endif -// On 64-bit platforms sockets use socklen_t -#define QT_SOCKLEN_T socklen_t +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKET_CONNECT +#define QT_SOCKET_CONNECT qt_socket_connect // Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) { return ::connect(s, addr, addrlen); } -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT qt_socket_connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - // Only Solaris 7 and better support 64-bit #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/solaris-cc/qplatformdefs.h b/mkspecs/solaris-cc/qplatformdefs.h index 04be413..678d076 100644 --- a/mkspecs/solaris-cc/qplatformdefs.h +++ b/mkspecs/solaris-cc/qplatformdefs.h @@ -76,49 +76,29 @@ #include #endif +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T +#undef QT_SOCKET_CONNECT + +#define QT_SOCKET_CONNECT qt_socket_connect + #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) && (_XOPEN_VERSION-0 >= 500) // Solaris 7 and better with specific feature test macros -#define QT_SOCKLEN_T socklen_t +#define QT_SOCKLEN_T socklen_t #elif defined(_XOPEN_SOURCE_EXTENDED) && (_XOPEN_VERSION-0 >= 4) // Solaris 2.6 and better with specific feature test macros -#define QT_SOCKLEN_T size_t +#define QT_SOCKLEN_T size_t #else // always this case in practice -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T int #endif // Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) { return ::connect(s, addr, addrlen); } -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT qt_socket_connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - #if !defined(_XOPEN_UNIX) // Solaris 2.5.1 // Function usleep() is defined in C library but not declared in header files diff --git a/mkspecs/solaris-g++-64/qplatformdefs.h b/mkspecs/solaris-g++-64/qplatformdefs.h index f9c21d7..bce0d5b 100644 --- a/mkspecs/solaris-g++-64/qplatformdefs.h +++ b/mkspecs/solaris-g++-64/qplatformdefs.h @@ -79,12 +79,11 @@ #include #endif -// On 64-bit platforms sockets use socklen_t -#define QT_SOCKLEN_T socklen_t +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" -// Only Solaris 7 and better support 64-bit -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf +#undef QT_SOCKET_CONNECT +#define QT_SOCKET_CONNECT qt_socket_connect // Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) @@ -100,32 +99,8 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr # undef bind #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT qt_socket_connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN +// Only Solaris 7 and better support 64-bit +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf #endif // QPLATFORMDEFS_H diff --git a/mkspecs/solaris-g++/qplatformdefs.h b/mkspecs/solaris-g++/qplatformdefs.h index 6438e7c..5732388 100644 --- a/mkspecs/solaris-g++/qplatformdefs.h +++ b/mkspecs/solaris-g++/qplatformdefs.h @@ -79,6 +79,16 @@ #include #endif +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T +#undef QT_SOCKET_CONNECT +#undef QT_SOCKET_BIND + +#define QT_SOCKET_CONNECT qt_socket_connect +#define QT_SOCKET_BIND qt_socket_bind + #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) && (_XOPEN_VERSION-0 >= 500) // Solaris 7 and better with specific feature test macros #define QT_SOCKLEN_T socklen_t @@ -104,34 +114,6 @@ static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addr # undef bind #endif -#include "../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT qt_socket_connect -#define QT_SOCKET_BIND qt_socket_bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - #if !defined(_XOPEN_UNIX) // Solaris 2.5.1 // Function usleep() is defined in C library but not declared in header files diff --git a/mkspecs/tru64-cxx/qplatformdefs.h b/mkspecs/tru64-cxx/qplatformdefs.h index dc18e1d..15b83aa 100644 --- a/mkspecs/tru64-cxx/qplatformdefs.h +++ b/mkspecs/tru64-cxx/qplatformdefs.h @@ -78,48 +78,23 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#define QT_NO_USE_FSEEKO +#include "../common/posix/qplatformdefs.h" #undef QT_OFF_T +#undef QT_SOCKLEN_T + #define QT_OFF_T off_t -#define QT_MMAP ::mmap +#if defined(_POSIX_PII_SOCKET) +#define QT_SOCKLEN_T socklen_t +#elif defined(_XOPEN_SOURCE_EXTENDED) +#define QT_SOCKLEN_T size_t +#else +#define QT_SOCKLEN_T int +#endif -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN #if defined(_XOPEN_SOURCE) && defined(_OSF_SOURCE) // Not available in the header file of Tru64 4.0F. @@ -127,19 +102,10 @@ extern "C" int usleep(useconds_t); #endif -#if defined(_POSIX_PII_SOCKET) -#define QT_SOCKLEN_T socklen_t -#elif defined(_XOPEN_SOURCE_EXTENDED) -#define QT_SOCKLEN_T size_t -#else -#define QT_SOCKLEN_T int -#endif - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 400) // Tru64 5.0 and better #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/tru64-g++/qplatformdefs.h b/mkspecs/tru64-g++/qplatformdefs.h index 485879e..15b83aa 100644 --- a/mkspecs/tru64-g++/qplatformdefs.h +++ b/mkspecs/tru64-g++/qplatformdefs.h @@ -78,48 +78,23 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#define QT_NO_USE_FSEEKO +#include "../common/posix/qplatformdefs.h" #undef QT_OFF_T +#undef QT_SOCKLEN_T + #define QT_OFF_T off_t -#define QT_MMAP ::mmap +#if defined(_POSIX_PII_SOCKET) +#define QT_SOCKLEN_T socklen_t +#elif defined(_XOPEN_SOURCE_EXTENDED) +#define QT_SOCKLEN_T size_t +#else +#define QT_SOCKLEN_T int +#endif -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN #if defined(_XOPEN_SOURCE) && defined(_OSF_SOURCE) // Not available in the header file of Tru64 4.0F. @@ -127,19 +102,10 @@ extern "C" int usleep(useconds_t); #endif -#if defined(_POSIX_PII_SOCKET) -# define QT_SOCKLEN_T socklen_t -#elif defined(_XOPEN_SOURCE_EXTENDED) -# define QT_SOCKLEN_T size_t -#else -# define QT_SOCKLEN_T int -#endif - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 400) // Tru64 5.0 and better #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf #endif - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/unixware-cc/qplatformdefs.h b/mkspecs/unixware-cc/qplatformdefs.h index cdcd3a3..4ad4d6c 100644 --- a/mkspecs/unixware-cc/qplatformdefs.h +++ b/mkspecs/unixware-cc/qplatformdefs.h @@ -76,53 +76,18 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#define QT_NO_USE_FSEEKO +#include "../common/posix/qplatformdefs.h" #undef QT_OFF_T -#define QT_OFF_T off_t +#undef QT_SOCKLEN_T -#define QT_MMAP ::mmap +#define QT_OFF_T off_t +#define QT_SOCKLEN_T size_t -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T size_t #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/unixware-g++/qplatformdefs.h b/mkspecs/unixware-g++/qplatformdefs.h index cdcd3a3..4ad4d6c 100644 --- a/mkspecs/unixware-g++/qplatformdefs.h +++ b/mkspecs/unixware-g++/qplatformdefs.h @@ -76,53 +76,18 @@ #include #endif -#include "../common/c89/qplatformdefs.h" +#define QT_NO_USE_FSEEKO +#include "../common/posix/qplatformdefs.h" #undef QT_OFF_T -#define QT_OFF_T off_t +#undef QT_SOCKLEN_T -#define QT_MMAP ::mmap +#define QT_OFF_T off_t +#define QT_SOCKLEN_T size_t -#define QT_STATBUF struct stat #define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_OPEN ::open -#define QT_CLOSE ::close -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T size_t #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H diff --git a/mkspecs/unsupported/qnx-g++/qplatformdefs.h b/mkspecs/unsupported/qnx-g++/qplatformdefs.h index d86ce26..b5bcee8 100644 --- a/mkspecs/unsupported/qnx-g++/qplatformdefs.h +++ b/mkspecs/unsupported/qnx-g++/qplatformdefs.h @@ -81,35 +81,8 @@ // for htonl #include -#include "../../common/xopen-lfs/qplatformdefs.h" - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#define QT_SOCKLEN_T socklen_t +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../../common/posix/qplatformdefs.h" #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h index 47a24a4..b183684 100644 --- a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h @@ -47,45 +47,29 @@ #include "qglobal.h" #include "qfunctions_vxworks.h" -#include "../../common/xopen-lfs/qplatformdefs.h" +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../../common/posix/qplatformdefs.h" #undef QT_LSTAT +#undef QT_MKDIR +#undef QT_READ +#undef QT_WRITE +#undef QT_SOCKLEN_T +#undef QT_SOCKET_CONNECT + #define QT_LSTAT QT_STAT +#define QT_MKDIR(dir, perm) ::mkdir(dir) -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT(sd, to, tolen) \ - ::connect(sd, (struct sockaddr *) to, tolen) -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close #define QT_READ(fd, buf, len) ::read(fd, (char*) buf, len) #define QT_WRITE(fd, buf, len) ::write(fd, (char*) buf, len) -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR(dir, perm) ::mkdir(dir) -#define QT_RMDIR ::rmdir -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN // there IS a socklen_t in sys/socket.h (unsigned int), // but sockLib.h uses int in all function declaration... -//#define QT_SOCKLEN_T socklen_t #define QT_SOCKLEN_T int +#define QT_SOCKET_CONNECT(sd, to, tolen) \ + ::connect(sd, (struct sockaddr *) to, tolen) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf - #endif // QPLATFORMDEFS_H -- cgit v0.12 From 31d18e089691c7ffb9c9c48579f1004eded9fc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 15 Jan 2010 18:10:46 +0100 Subject: Dropping windows #define from qplatformheaders for *nix platforms. QT_STATBUF4TSTAT was meant for the windows-specific _tstat function, taking a _TCHAR* path argument. Reviewed-by: Thiago Macieira --- mkspecs/cygwin-g++/qplatformdefs.h | 2 -- mkspecs/darwin-g++/qplatformdefs.h | 2 -- mkspecs/freebsd-g++/qplatformdefs.h | 2 -- mkspecs/hurd-g++/qplatformdefs.h | 2 -- mkspecs/lynxos-g++/qplatformdefs.h | 2 -- mkspecs/macx-g++/qplatformdefs.h | 2 -- mkspecs/macx-g++40/qplatformdefs.h | 2 -- mkspecs/macx-g++42/qplatformdefs.h | 2 -- mkspecs/macx-llvm/qplatformdefs.h | 2 -- mkspecs/macx-pbuilder/qplatformdefs.h | 2 -- mkspecs/macx-xcode/qplatformdefs.h | 2 -- mkspecs/macx-xlc/qplatformdefs.h | 2 -- mkspecs/netbsd-g++/qplatformdefs.h | 2 -- mkspecs/openbsd-g++/qplatformdefs.h | 2 -- mkspecs/sco-cc/qplatformdefs.h | 2 -- mkspecs/sco-g++/qplatformdefs.h | 2 -- mkspecs/tru64-cxx/qplatformdefs.h | 2 -- mkspecs/tru64-g++/qplatformdefs.h | 2 -- mkspecs/unixware-cc/qplatformdefs.h | 2 -- mkspecs/unixware-g++/qplatformdefs.h | 2 -- 20 files changed, 40 deletions(-) diff --git a/mkspecs/cygwin-g++/qplatformdefs.h b/mkspecs/cygwin-g++/qplatformdefs.h index b64e126..a6f57d2 100644 --- a/mkspecs/cygwin-g++/qplatformdefs.h +++ b/mkspecs/cygwin-g++/qplatformdefs.h @@ -86,8 +86,6 @@ #undef QT_OPEN_LARGEFILE -#define QT_STATBUF4TSTAT struct stat - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/darwin-g++/qplatformdefs.h b/mkspecs/darwin-g++/qplatformdefs.h index 2ee0698..7a67339 100644 --- a/mkspecs/darwin-g++/qplatformdefs.h +++ b/mkspecs/darwin-g++/qplatformdefs.h @@ -79,8 +79,6 @@ #undef QT_OPEN_LARGEFILE #define QT_OPEN_LARGEFILE 0 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/freebsd-g++/qplatformdefs.h b/mkspecs/freebsd-g++/qplatformdefs.h index c0b7da6..5afb965 100644 --- a/mkspecs/freebsd-g++/qplatformdefs.h +++ b/mkspecs/freebsd-g++/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SOCKLEN_T socklen_t #endif -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/hurd-g++/qplatformdefs.h b/mkspecs/hurd-g++/qplatformdefs.h index b439e6b..b734a68 100644 --- a/mkspecs/hurd-g++/qplatformdefs.h +++ b/mkspecs/hurd-g++/qplatformdefs.h @@ -84,8 +84,6 @@ #include "../common/posix/qplatformdefs.h" -#define QT_STATBUF4TSTAT struct stat - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/lynxos-g++/qplatformdefs.h b/mkspecs/lynxos-g++/qplatformdefs.h index 4d3965d..cac71d1 100644 --- a/mkspecs/lynxos-g++/qplatformdefs.h +++ b/mkspecs/lynxos-g++/qplatformdefs.h @@ -85,8 +85,6 @@ #define QT_SOCKLEN_T int #endif -#define QT_STATBUF4TSTAT struct stat - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-g++/qplatformdefs.h b/mkspecs/macx-g++/qplatformdefs.h index 5aef821..99d64ef 100644 --- a/mkspecs/macx-g++/qplatformdefs.h +++ b/mkspecs/macx-g++/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h index 5aef821..99d64ef 100644 --- a/mkspecs/macx-g++40/qplatformdefs.h +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-g++42/qplatformdefs.h b/mkspecs/macx-g++42/qplatformdefs.h index 5aef821..99d64ef 100644 --- a/mkspecs/macx-g++42/qplatformdefs.h +++ b/mkspecs/macx-g++42/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-llvm/qplatformdefs.h b/mkspecs/macx-llvm/qplatformdefs.h index 5aef821..99d64ef 100644 --- a/mkspecs/macx-llvm/qplatformdefs.h +++ b/mkspecs/macx-llvm/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-pbuilder/qplatformdefs.h b/mkspecs/macx-pbuilder/qplatformdefs.h index 256dba6..66afad2 100644 --- a/mkspecs/macx-pbuilder/qplatformdefs.h +++ b/mkspecs/macx-pbuilder/qplatformdefs.h @@ -88,8 +88,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-xcode/qplatformdefs.h b/mkspecs/macx-xcode/qplatformdefs.h index 5aef821..99d64ef 100644 --- a/mkspecs/macx-xcode/qplatformdefs.h +++ b/mkspecs/macx-xcode/qplatformdefs.h @@ -91,8 +91,6 @@ #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/macx-xlc/qplatformdefs.h b/mkspecs/macx-xlc/qplatformdefs.h index 380c217..b830041 100644 --- a/mkspecs/macx-xlc/qplatformdefs.h +++ b/mkspecs/macx-xlc/qplatformdefs.h @@ -83,8 +83,6 @@ #define QT_SOCKLEN_T int #define QT_SIGNAL_IGNORE (void (*)(int))1 -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/netbsd-g++/qplatformdefs.h b/mkspecs/netbsd-g++/qplatformdefs.h index 53be833..2ce5b4a 100644 --- a/mkspecs/netbsd-g++/qplatformdefs.h +++ b/mkspecs/netbsd-g++/qplatformdefs.h @@ -84,8 +84,6 @@ // NetBSD 1.0 - 1.3.3 int // NetBSD 1.4 - 1.5 socklen_t -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/openbsd-g++/qplatformdefs.h b/mkspecs/openbsd-g++/qplatformdefs.h index f5adf6f..b3a9ad5 100644 --- a/mkspecs/openbsd-g++/qplatformdefs.h +++ b/mkspecs/openbsd-g++/qplatformdefs.h @@ -85,8 +85,6 @@ // OpenBSD 2.2 - 2.4 int // OpenBSD 2.5 - 2.8 socklen_t -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/sco-cc/qplatformdefs.h b/mkspecs/sco-cc/qplatformdefs.h index 2ae4b48..078cb45 100644 --- a/mkspecs/sco-cc/qplatformdefs.h +++ b/mkspecs/sco-cc/qplatformdefs.h @@ -81,8 +81,6 @@ #undef QT_SOCKLEN_T #define QT_SOCKLEN_T size_t -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/sco-g++/qplatformdefs.h b/mkspecs/sco-g++/qplatformdefs.h index c62fe93..a09f77d 100644 --- a/mkspecs/sco-g++/qplatformdefs.h +++ b/mkspecs/sco-g++/qplatformdefs.h @@ -85,8 +85,6 @@ #undef QT_SOCKLEN_T #define QT_SOCKLEN_T int -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/tru64-cxx/qplatformdefs.h b/mkspecs/tru64-cxx/qplatformdefs.h index 15b83aa..ed07d5b 100644 --- a/mkspecs/tru64-cxx/qplatformdefs.h +++ b/mkspecs/tru64-cxx/qplatformdefs.h @@ -94,8 +94,6 @@ #define QT_SOCKLEN_T int #endif -#define QT_STATBUF4TSTAT struct stat - #if defined(_XOPEN_SOURCE) && defined(_OSF_SOURCE) // Not available in the header file of Tru64 4.0F. // Fixed in the header of Tru64 5.0A so we copy/paste from there... diff --git a/mkspecs/tru64-g++/qplatformdefs.h b/mkspecs/tru64-g++/qplatformdefs.h index 15b83aa..ed07d5b 100644 --- a/mkspecs/tru64-g++/qplatformdefs.h +++ b/mkspecs/tru64-g++/qplatformdefs.h @@ -94,8 +94,6 @@ #define QT_SOCKLEN_T int #endif -#define QT_STATBUF4TSTAT struct stat - #if defined(_XOPEN_SOURCE) && defined(_OSF_SOURCE) // Not available in the header file of Tru64 4.0F. // Fixed in the header of Tru64 5.0A so we copy/paste from there... diff --git a/mkspecs/unixware-cc/qplatformdefs.h b/mkspecs/unixware-cc/qplatformdefs.h index 4ad4d6c..3a26042 100644 --- a/mkspecs/unixware-cc/qplatformdefs.h +++ b/mkspecs/unixware-cc/qplatformdefs.h @@ -85,8 +85,6 @@ #define QT_OFF_T off_t #define QT_SOCKLEN_T size_t -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf diff --git a/mkspecs/unixware-g++/qplatformdefs.h b/mkspecs/unixware-g++/qplatformdefs.h index 4ad4d6c..3a26042 100644 --- a/mkspecs/unixware-g++/qplatformdefs.h +++ b/mkspecs/unixware-g++/qplatformdefs.h @@ -85,8 +85,6 @@ #define QT_OFF_T off_t #define QT_SOCKLEN_T size_t -#define QT_STATBUF4TSTAT struct stat - #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf -- cgit v0.12 From 2547e8d27fc7d651d21ba3805918ee3681f03f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 22 Jan 2010 11:31:31 +0100 Subject: Merged qplatformdefs.h for AIX I don't think the differences warranted having to maintain 3 slightly differing copies. "Old" locations changed to a forwarding header to the merged one. Differences and how they were resolved in the merged file: - comment on a workaround for a potential issue when using g++ => comment kept - #ifdef's for xlc-64 had been simplified, because it is only supported on AIX 4.3 and above => versioned #ifdefs should still work on 64-bit platforms, so that was preferred; comment left for future reference - use of different condition in #if clause: (_XOPEN_SOURCE-0 >= 500) => verbosity preferred, since it is probably a workaround for a preprocessor or #define bug. Reviewed-by: Thiago Macieira --- mkspecs/aix-g++-64/qplatformdefs.h | 63 +-------------------- mkspecs/aix-g++/qplatformdefs.h | 63 +-------------------- mkspecs/aix-xlc-64/qplatformdefs.h | 47 +--------------- mkspecs/aix-xlc/qplatformdefs.h | 59 +------------------- mkspecs/common/aix/qplatformdefs.h | 110 +++++++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 228 deletions(-) create mode 100644 mkspecs/common/aix/qplatformdefs.h diff --git a/mkspecs/aix-g++-64/qplatformdefs.h b/mkspecs/aix-g++-64/qplatformdefs.h index 4421ba4..d32f994 100644 --- a/mkspecs/aix-g++-64/qplatformdefs.h +++ b/mkspecs/aix-g++-64/qplatformdefs.h @@ -42,67 +42,6 @@ #ifndef QPLATFORMDEFS_H #define QPLATFORMDEFS_H -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - - -// uncomment if you have problems with because your gcc -// hasn't been built on exactly the same OS version your are using now. -// typedef int crid_t; -// typedef unsigned int class_id_t; -#include -#include -#include -#include -#include -#include -#include -#include // AIX X11 headers define FD_ZERO using bzero() - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#define QT_USE_XOPEN_LFS_EXTENSIONS -#include "../common/posix/qplatformdefs.h" - -#undef QT_SOCKLEN_T - -#ifdef _AIX43 -// AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t -#elif _AIX42 -// AIX 4.2 -#define QT_SOCKLEN_T size_t -#else -// AIX 4.1 -#define QT_SOCKLEN_T size_t -// override -#define QT_SOCKOPTLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -// AIX 4.3 and better -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif +#include "../common/aix/qplatformdefs.h" #endif // QPLATFORMDEFS_H diff --git a/mkspecs/aix-g++/qplatformdefs.h b/mkspecs/aix-g++/qplatformdefs.h index 4421ba4..d32f994 100644 --- a/mkspecs/aix-g++/qplatformdefs.h +++ b/mkspecs/aix-g++/qplatformdefs.h @@ -42,67 +42,6 @@ #ifndef QPLATFORMDEFS_H #define QPLATFORMDEFS_H -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - - -// uncomment if you have problems with because your gcc -// hasn't been built on exactly the same OS version your are using now. -// typedef int crid_t; -// typedef unsigned int class_id_t; -#include -#include -#include -#include -#include -#include -#include -#include // AIX X11 headers define FD_ZERO using bzero() - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#define QT_USE_XOPEN_LFS_EXTENSIONS -#include "../common/posix/qplatformdefs.h" - -#undef QT_SOCKLEN_T - -#ifdef _AIX43 -// AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t -#elif _AIX42 -// AIX 4.2 -#define QT_SOCKLEN_T size_t -#else -// AIX 4.1 -#define QT_SOCKLEN_T size_t -// override -#define QT_SOCKOPTLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -// AIX 4.3 and better -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif +#include "../common/aix/qplatformdefs.h" #endif // QPLATFORMDEFS_H diff --git a/mkspecs/aix-xlc-64/qplatformdefs.h b/mkspecs/aix-xlc-64/qplatformdefs.h index a52b3d3..d32f994 100644 --- a/mkspecs/aix-xlc-64/qplatformdefs.h +++ b/mkspecs/aix-xlc-64/qplatformdefs.h @@ -42,51 +42,6 @@ #ifndef QPLATFORMDEFS_H #define QPLATFORMDEFS_H -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - - -#include -#include -#include -#include -#include -#include -#include -#include // AIX X11 headers define FD_ZERO using bzero() - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#define QT_USE_XOPEN_LFS_EXTENSIONS -#include "../common/posix/qplatformdefs.h" - -// QT_SOCKLEN_T -// Only AIX 4.3 and better support 64-bit - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -// Only AIX 4.3 and better support 64-bit -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif +#include "../common/aix/qplatformdefs.h" #endif // QPLATFORMDEFS_H diff --git a/mkspecs/aix-xlc/qplatformdefs.h b/mkspecs/aix-xlc/qplatformdefs.h index 97cd0a1..d32f994 100644 --- a/mkspecs/aix-xlc/qplatformdefs.h +++ b/mkspecs/aix-xlc/qplatformdefs.h @@ -42,63 +42,6 @@ #ifndef QPLATFORMDEFS_H #define QPLATFORMDEFS_H -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - - -#include -#include -#include -#include -#include -#include -#include -#include // AIX X11 headers define FD_ZERO using bzero() - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#define QT_USE_XOPEN_LFS_EXTENSIONS -#include "../common/posix/qplatformdefs.h" - -#undef QT_SOCKLEN_T - -#ifdef _AIX43 -// AIX 4.3 and better -#define QT_SOCKLEN_T socklen_t -#elif _AIX42 -// AIX 4.2 -#define QT_SOCKLEN_T size_t -#else -// AIX 4.1 -#define QT_SOCKLEN_T size_t -// override -#define QT_SOCKOPTLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) -// AIX 4.3 and better -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif +#include "../common/aix/qplatformdefs.h" #endif // QPLATFORMDEFS_H diff --git a/mkspecs/common/aix/qplatformdefs.h b/mkspecs/common/aix/qplatformdefs.h new file mode 100644 index 0000000..57c5a76 --- /dev/null +++ b/mkspecs/common/aix/qplatformdefs.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_AIX_QPLATFORMDEFS_H +#define Q_AIX_QPLATFORMDEFS_H + +// Get Qt defines/settings + +#include "qglobal.h" + +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +#include + + +// We are hot - unistd.h should have turned on the specific APIs we requested + + +// uncomment if you have problems with because your gcc +// hasn't been built on exactly the same OS version your are using now. +// typedef int crid_t; +// typedef unsigned int class_id_t; +#include +#include +#include +#include +#include +#include +#include +#include // AIX X11 headers define FD_ZERO using bzero() + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef QT_NO_IPV6IFNAME +#include +#endif + +// Only AIX 4.3 and better support 64-bit + +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T + +#ifdef _AIX43 +// AIX 4.3 and better +#define QT_SOCKLEN_T socklen_t +#elif _AIX42 +// AIX 4.2 +#define QT_SOCKLEN_T size_t +#else +// AIX 4.1 +#define QT_SOCKLEN_T size_t +// override +#define QT_SOCKOPTLEN_T int +#endif + +#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) +// AIX 4.3 and better +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf +#endif + +#endif // include guard -- cgit v0.12 From 5a850d6acbbd7cdd813c4babfedf39a9df44b9aa Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 25 Jan 2010 10:03:56 +0100 Subject: build fix for phonon on wince --- src/3rdparty/phonon/ds9/videorenderer_default.cpp | 2 +- src/3rdparty/phonon/ds9/videowidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.cpp b/src/3rdparty/phonon/ds9/videorenderer_default.cpp index 9d82255..0045a49 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_default.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_default.cpp @@ -32,7 +32,7 @@ namespace Phonon { namespace DS9 { - VideoRendererDefault::~VideoRendererVMR9() + VideoRendererDefault::~VideoRendererDefault() { } diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index 59abb04..1eddaee 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -369,7 +369,7 @@ namespace Phonon } } #else - renderer = new VideoRendererVMR9(m_widget); + renderer = new VideoRendererDefault(m_widget); if (renderer->getFilter() == 0) { //instanciating the renderer might fail m_noNativeRendererSupported = true; -- cgit v0.12 From b6a2ce7b02951aab761ddc8ffa022bbd8f19fa83 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 26 Jan 2010 09:29:49 +0100 Subject: Carbon: fix build breakage on carbon Just forgot an ifdef... --- src/gui/kernel/qwidget_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index d52ac77..20c0cde 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3463,7 +3463,9 @@ void QWidgetPrivate::hide_sys() QMacCocoaAutoReleasePool pool; if(q->isWindow()) { +#ifdef QT_MAC_USE_COCOA setSubWindowStacking(false); +#endif OSWindowRef window = qt_mac_window_for(q); if(qt_mac_is_macsheet(q)) { #ifndef QT_MAC_USE_COCOA -- cgit v0.12 From 7ad08868de4b3e481a51a3431504fcf42a4bbf6d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 26 Jan 2010 13:42:48 +0100 Subject: Cocoa: qfiledialog test spits out memory warnings We need an auto release pool! --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e0dcaef..13c25fd 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -143,6 +143,9 @@ extern QPointer qt_button_down; //qapplication_mac.cpp void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif OSWindowRef wnd = static_cast(window); if (wnd) { QWidget *widget; -- cgit v0.12 From d5a512b40190d4986be23bbebd2cbb53919e48ae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:14:30 +0100 Subject: Add proper license headers to these files. This makes the headers:licenseCheck test pass. --- src/testlib/qbenchmarkmetric.cpp | 78 ++++++++++++++++----------------- tests/auto/qobject/oldnormalizeobject.h | 41 +++++++++++++++++ tests/benchmarks/qvector/outofline.cpp | 40 +++++++++++++++++ 3 files changed, 120 insertions(+), 39 deletions(-) diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp index 614357c..75297c4 100644 --- a/src/testlib/qbenchmarkmetric.cpp +++ b/src/testlib/qbenchmarkmetric.cpp @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - ** All rights reserved. - ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the QtTest module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ - ** No Commercial Usage - ** This file contains pre-release code and may not be distributed. - ** You may use this file in accordance with the terms and conditions - ** contained in the Technology Preview License Agreement accompanying - ** this package. - ** - ** GNU Lesser General Public License Usage - ** Alternatively, this file may be used under the terms of the GNU Lesser - ** General Public License version 2.1 as published by the Free Software - ** Foundation and appearing in the file LICENSE.LGPL included in the - ** packaging of this file. Please review the following information to - ** ensure the GNU Lesser General Public License version 2.1 requirements - ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. - ** - ** In addition, as a special exception, Nokia gives you certain additional - ** rights. These rights are described in the Nokia Qt LGPL Exception - ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. - ** - ** If you have questions regarding the use of this file, please contact - ** Nokia at qt-info@nokia.com. - ** - ** - ** - ** - ** - ** - ** - ** - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/tests/auto/qobject/oldnormalizeobject.h b/tests/auto/qobject/oldnormalizeobject.h index 8420a3a..3adf04d 100644 --- a/tests/auto/qobject/oldnormalizeobject.h +++ b/tests/auto/qobject/oldnormalizeobject.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef OLDNORMALIZEOBJECT_H #define OLDNORMALIZEOBJECT_H diff --git a/tests/benchmarks/qvector/outofline.cpp b/tests/benchmarks/qvector/outofline.cpp index d1d72b0..e8d036e 100644 --- a/tests/benchmarks/qvector/outofline.cpp +++ b/tests/benchmarks/qvector/outofline.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include -- cgit v0.12 From 7b306a0534e4c1db40fbcf77612fd88ac672b6f7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:17:01 +0100 Subject: Remove the tests/auto/networkdata dir, since this causes the maketestselftest test fail --- tests/auto/networkdata/README | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/auto/networkdata/README diff --git a/tests/auto/networkdata/README b/tests/auto/networkdata/README deleted file mode 100644 index e8748cc..0000000 --- a/tests/auto/networkdata/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains network test data -- cgit v0.12 From 2b13dc93d406040d5f62ca57b44969b484370f87 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 26 Jan 2010 15:05:25 +0100 Subject: Fix compile on MSVC 2003. ARRAYSIZE macro doesn't exit. Reviewed-by:Jan-Arve --- src/gui/dialogs/qfilesystemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index ae75126..0e1837b 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1667,7 +1667,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile //GetVolumeInformation requires to add trailing backslash const QString nodeName = fileName + QLatin1String("\\"); BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()), - name, ARRAYSIZE(name), NULL, 0, NULL, NULL, 0); + name, MAX_PATH + 1, NULL, 0, NULL, NULL, 0); if (success && name[0]) node->volumeName = QString::fromWCharArray(name); } -- cgit v0.12 From c06c254cf208840f14c9e562cae976f1a61f0879 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 26 Jan 2010 16:00:02 +0100 Subject: Fixed compile of QTriangulator on Solaris. Reviewed-by: Trond --- src/opengl/gl2paintengineex/qtriangulator.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index b60e10d..115f31b 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -361,14 +361,14 @@ struct QIntersectionPoint static inline QIntersectionPoint qIntersectionPoint(const QPodPoint &point) { - // m_upperLeft = point, m_xOffset = 0/1, m_yOffset = 0/1. - QIntersectionPoint p = {point, {0, 1}, {0, 1}}; + // upperLeft = point, xOffset = 0/1, yOffset = 0/1. + QIntersectionPoint p = {{point.x, point.y}, {0, 1}, {0, 1}}; return p; } static inline QIntersectionPoint qIntersectionPoint(int x, int y) { - // m_upperLeft = (x, y), m_xOffset = 0/1, m_yOffset = 0/1. + // upperLeft = (x, y), xOffset = 0/1, yOffset = 0/1. QIntersectionPoint p = {{x, y}, {0, 1}, {0, 1}}; return p; } @@ -1988,8 +1988,10 @@ void QTriangulator::ComplexToSimple::fillPriorityQueue() Q_ASSERT(m_edges.at(i).pointingUp == (m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from))); // Ignore zero-length edges. if (m_parent->m_vertices.at(m_edges.at(i).to) != m_parent->m_vertices.at(m_edges.at(i).from)) { - Event upperEvent = {m_parent->m_vertices.at(m_edges.at(i).upper()), Event::Upper, i}; - Event lowerEvent = {m_parent->m_vertices.at(m_edges.at(i).lower()), Event::Lower, i}; + QPodPoint upper = m_parent->m_vertices.at(m_edges.at(i).upper()); + QPodPoint lower = m_parent->m_vertices.at(m_edges.at(i).lower()); + Event upperEvent = {{upper.x, upper.y}, Event::Upper, i}; + Event lowerEvent = {{lower.x, lower.y}, Event::Lower, i}; m_events.add(upperEvent); m_events.add(lowerEvent); } -- cgit v0.12 From c3619bce443e73430b1b8aa7ab4c0e712375b53b Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:46 +0100 Subject: fix regression introduced in 44766d2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit null fileNames returned by fileEngine must be cached too Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index e90529e..6eb864e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -132,6 +132,8 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const if(data->cache_enabled && !data->fileNames[(int)name].isNull()) return data->fileNames[(int)name]; QString ret = data->fileEngine->fileName(name); + if (ret.isNull()) + ret = QLatin1String(""); if(data->cache_enabled) data->fileNames[(int)name] = ret; return ret; -- cgit v0.12 From 95f0dbd76f419ebc80e27f184d5e1199e91de4b7 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:47 +0100 Subject: QFileInfoPrivate::Data: don't call clear() from constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit causes Refresh of file engine's internal cache, since `fileEngine' member is set before clear() is called. Initialize members with default values instead. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 065f860..7f8ab4e 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -81,12 +81,14 @@ public: CachedSize =0x08 }; struct Data { inline Data() - : ref(1), fileEngine(0), cache_enabled(1), fileSize(0) - { clear(); } + : ref(1), fileEngine(0), + cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + {} inline Data(const Data ©) : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), cache_enabled(copy.cache_enabled), fileSize(copy.fileSize) - { clear(); } + fileName(copy.fileName), + cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) + {} inline ~Data() { delete fileEngine; } inline void clearFlags() { fileFlags = 0; -- cgit v0.12 From 3a5eb87965b60a3e249a16dc48cb06f4759dfb1b Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:48 +0100 Subject: QFileInfo: Don't re-stat files, when in caching mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Separated testing for permissions flags, in order to speedup QFileInfo on Windows with qt_ntfs_permission_lookup flag turned on (especially on network shares). In QFileInfoPrivate::getFileFlags, avoid multiple calls to the engine, by concatenating all requests. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 74 +++++++++++++++++++++++++------------------- src/corelib/io/qfileinfo_p.h | 2 +- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 6eb864e..2260036 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -81,7 +81,8 @@ void QFileInfoPrivate::initFileEngine(const QString &file) bool QFileInfoPrivate::hasAccess(Access access) const { - if (!(getFileFlags(QAbstractFileEngine::FileInfoAll) & QAbstractFileEngine::LocalDiskFlag)) { + if (!(getFileFlags(QAbstractFileEngine::PermsMask + | QAbstractFileEngine::LocalDiskFlag) & QAbstractFileEngine::LocalDiskFlag)) { switch (access) { case ReadAccess: return getFileFlags(QAbstractFileEngine::ReadUserPerm); @@ -141,51 +142,62 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { - // We split the testing into tests for for LinkType, BundleType and the rest. + // We split the testing into tests for for LinkType, BundleType, PermsMask + // and the rest. + // Tests for file permissions on Windows can be slow, expecially on network + // paths and NTFS drives. // In order to determine if a file is a symlink or not, we have to lstat(). // If we're not interested in that information, we might as well avoid one // extra syscall. Bundle detecton on Mac can be slow, expecially on network // paths, so we separate out that as well. - QAbstractFileEngine::FileFlags flags; - if (!data->getCachedFlag(CachedFileFlags)) { - QAbstractFileEngine::FileFlags req = QAbstractFileEngine::FileInfoAll; - req &= (~QAbstractFileEngine::LinkType); - req &= (~QAbstractFileEngine::BundleType); + QAbstractFileEngine::FileFlags req = 0; + uint cachedFlags = 0; - flags = data->fileEngine->fileFlags(req); - data->setCachedFlag(CachedFileFlags); - data->fileFlags |= uint(flags); - } else { - flags = QAbstractFileEngine::FileFlags(data->fileFlags & request); - } + if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { + if (!data->getCachedFlag(CachedFileFlags)) { + req |= QAbstractFileEngine::FlagsMask; + req |= QAbstractFileEngine::TypesMask; + req &= (~QAbstractFileEngine::LinkType); + req &= (~QAbstractFileEngine::BundleType); - if (request & QAbstractFileEngine::LinkType) { - if (!data->getCachedFlag(CachedLinkTypeFlag)) { - QAbstractFileEngine::FileFlags linkflag; - linkflag = data->fileEngine->fileFlags(QAbstractFileEngine::LinkType); + cachedFlags |= CachedFileFlags; + + if (request & QAbstractFileEngine::LinkType) { + if (!data->getCachedFlag(CachedLinkTypeFlag)) { + req |= QAbstractFileEngine::LinkType; + cachedFlags |= CachedLinkTypeFlag; + } + } - data->setCachedFlag(CachedLinkTypeFlag); - data->fileFlags |= uint(linkflag); - flags |= linkflag; + if (request & QAbstractFileEngine::BundleType) { + if (!data->getCachedFlag(CachedBundleTypeFlag)) { + req |= QAbstractFileEngine::BundleType; + cachedFlags |= CachedBundleTypeFlag; + } + } } } - if (request & QAbstractFileEngine::BundleType) { - if (!data->getCachedFlag(CachedBundleTypeFlag)) { - QAbstractFileEngine::FileFlags bundleflag; - bundleflag = data->fileEngine->fileFlags(QAbstractFileEngine::BundleType); - - data->setCachedFlag(CachedBundleTypeFlag); - data->fileFlags |= uint(bundleflag); - flags |= bundleflag; + if (request & QAbstractFileEngine::PermsMask) { + if (!data->getCachedFlag(CachedPerms)) { + req |= QAbstractFileEngine::PermsMask; + cachedFlags |= CachedPerms; } } - // no else branch - // if we had it cached, it was caught in the previous else branch + if (req) { + if (data->cache_enabled) + req &= (~QAbstractFileEngine::Refresh); + else + req |= QAbstractFileEngine::Refresh; + + QAbstractFileEngine::FileFlags flags = data->fileEngine->fileFlags(req); + data->fileFlags |= uint(flags); + data->setCachedFlag(cachedFlags); + } - return flags & request; + return data->fileFlags & request; } QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 7f8ab4e..8e00909 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -78,7 +78,7 @@ public: enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, - CachedSize =0x08 }; + CachedSize =0x08, CachedPerms=0x80 }; struct Data { inline Data() : ref(1), fileEngine(0), -- cgit v0.12 From d48fdf76f721b97e427073c665102e1b42398883 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:48 +0100 Subject: Simplify QFileInfoPrivate::getFileTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove repeated code; improve readability Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 2260036..6616066 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -204,25 +204,18 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) { if (!data->cache_enabled) data->clearFlags(); - if(request == QAbstractFileEngine::CreationTime) { - if(data->getCachedFlag(CachedCTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedCTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); + uint cf; + if (request == QAbstractFileEngine::CreationTime) + cf = CachedCTime; + else if (request == QAbstractFileEngine::ModificationTime) + cf = CachedMTime; + else + cf = CachedATime; + if (!data->getCachedFlag(cf)) { + data->fileTimes[request] = data->fileEngine->fileTime(request); + data->setCachedFlag(cf); } - if(request == QAbstractFileEngine::ModificationTime) { - if(data->getCachedFlag(CachedMTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedMTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - if(request == QAbstractFileEngine::AccessTime) { - if(data->getCachedFlag(CachedATime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedATime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - return data->fileTimes[0]; //cannot really happen + return data->fileTimes[request]; } //************* QFileInfo -- cgit v0.12 From fbd0b8c0f6dce834b241f6beb755d2c2cb013305 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:49 +0100 Subject: qfileinfo_p.h: removed unnecessary dependency on QFSFileEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved includes into proper place. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 3 --- src/corelib/io/qfileinfo_p.h | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 6616066..f4e92a5 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -41,11 +41,8 @@ #include "qplatformdefs.h" #include "qfileinfo.h" -#include "qdatetime.h" -#include "qabstractfileengine.h" #include "qfsfileengine_p.h" #include "qglobal.h" -#include "qatomic.h" #include "qhash.h" #include "qdir.h" #include "qfileinfo_p.h" diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 8e00909..bf02aaa 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -54,6 +54,9 @@ // #include "qfileinfo.h" +#include "qabstractfileengine.h" +#include "qdatetime.h" +#include "qatomic.h" QT_BEGIN_NAMESPACE @@ -94,7 +97,7 @@ public: fileFlags = 0; cachedFlags = 0; if (fileEngine) - (void)fileEngine->fileFlags(QFSFileEngine::Refresh); + (void)fileEngine->fileFlags(QAbstractFileEngine::Refresh); } inline void clear() { clearFlags(); -- cgit v0.12 From 3c8ac0ee7f09bbef4dc56a05de538df1aa16a596 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:50 +0100 Subject: QFileInfo: Implement additional caching of FileOwner strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduce overhead of the uid/gid to user/group name conversion by caching results from QAbstractFileEngine::owner(). Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 16 ++++++++++++++-- src/corelib/io/qfileinfo_p.h | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index f4e92a5..d827f57 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -137,6 +137,18 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const return ret; } +QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const +{ + if (data->cache_enabled && !data->fileOwners[(int)own].isNull()) + return data->fileOwners[(int)own]; + QString ret = data->fileEngine->owner(own); + if (ret.isNull()) + ret = QLatin1String(""); + if (data->cache_enabled) + data->fileOwners[(int)own] = ret; + return ret; +} + uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { // We split the testing into tests for for LinkType, BundleType, PermsMask @@ -1089,7 +1101,7 @@ QString QFileInfo::owner() const Q_D(const QFileInfo); if(!d->data->fileEngine) return QLatin1String(""); - return d->data->fileEngine->owner(QAbstractFileEngine::OwnerUser); + return d->getFileOwner(QAbstractFileEngine::OwnerUser); } /*! @@ -1125,7 +1137,7 @@ QString QFileInfo::group() const Q_D(const QFileInfo); if(!d->data->fileEngine) return QLatin1String(""); - return d->data->fileEngine->owner(QAbstractFileEngine::OwnerGroup); + return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } /*! diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index bf02aaa..d97a0cf 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -78,6 +78,7 @@ public: uint getFileFlags(QAbstractFileEngine::FileFlags) const; QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; QString getFileName(QAbstractFileEngine::FileName) const; + QString getFileOwner(QAbstractFileEngine::FileOwner own) const; enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, @@ -103,12 +104,15 @@ public: clearFlags(); for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i) fileNames[i].clear(); + fileOwners[1].clear(); + fileOwners[0].clear(); } mutable QAtomicInt ref; QAbstractFileEngine *fileEngine; mutable QString fileName; mutable QString fileNames[QAbstractFileEngine::NFileNames]; + mutable QString fileOwners[2]; mutable uint cachedFlags : 31; mutable uint cache_enabled : 1; -- cgit v0.12 From bde7b69f2f69bbb2cf9eecb5e3ad3501c1f2c62e Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:50 +0100 Subject: cleanups & styling fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `if(' -> `if (' `for(' -> `for (' remove needless qhash.h include Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 93 ++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index d827f57..616f6f9 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -43,7 +43,6 @@ #include "qfileinfo.h" #include "qfsfileengine_p.h" #include "qglobal.h" -#include "qhash.h" #include "qdir.h" #include "qfileinfo_p.h" @@ -51,7 +50,7 @@ QT_BEGIN_NAMESPACE QFileInfoPrivate::QFileInfoPrivate(const QFileInfo *copy) { - if(copy) { + if (copy) { copy->d_func()->data->ref.ref(); data = copy->d_func()->data; } else { @@ -127,12 +126,12 @@ void QFileInfoPrivate::detach() QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const { - if(data->cache_enabled && !data->fileNames[(int)name].isNull()) + if (data->cache_enabled && !data->fileNames[(int)name].isNull()) return data->fileNames[(int)name]; QString ret = data->fileEngine->fileName(name); if (ret.isNull()) ret = QLatin1String(""); - if(data->cache_enabled) + if (data->cache_enabled) data->fileNames[(int)name] = ret; return ret; } @@ -411,19 +410,19 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const Q_D(const QFileInfo); // ### Qt 5: understand long and short file names on Windows // ### (GetFullPathName()). - if(fileinfo.d_func()->data == d->data) + if (fileinfo.d_func()->data == d->data) return true; - if(!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine) + if (!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine) return false; - if(d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive()) + if (d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive()) return false; - if(fileinfo.size() == size()) { //if the size isn't the same... + if (fileinfo.size() == size()) { //if the size isn't the same... QString file1 = canonicalFilePath(), file2 = fileinfo.canonicalFilePath(); - if(file1.length() == file2.length()) { - if(!fileinfo.d_func()->data->fileEngine->caseSensitive()) { - for(int i = 0; i < file1.length(); i++) { - if(file1.at(i).toLower() != file2.at(i).toLower()) + if (file1.length() == file2.length()) { + if (!fileinfo.d_func()->data->fileEngine->caseSensitive()) { + for (int i = 0; i < file1.length(); i++) { + if (file1.at(i).toLower() != file2.at(i).toLower()) return false; } return true; @@ -544,7 +543,7 @@ void QFileInfo::setFile(const QDir &dir, const QString &file) QString QFileInfo::absoluteFilePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::AbsoluteName); } @@ -562,7 +561,7 @@ QString QFileInfo::absoluteFilePath() const QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalName); } @@ -611,7 +610,7 @@ QString QFileInfo::absolutePath() const QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalPathName); } @@ -630,7 +629,7 @@ QString QFileInfo::canonicalPath() const QString QFileInfo::path() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::PathName); } @@ -655,7 +654,7 @@ QString QFileInfo::path() const bool QFileInfo::isRelative() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return true; return d->data->fileEngine->isRelativePath(); } @@ -672,7 +671,7 @@ bool QFileInfo::isRelative() const bool QFileInfo::makeAbsolute() { Q_D(QFileInfo); - if(!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) + if (!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) return false; QString absFileName = d->getFileName(QAbstractFileEngine::AbsoluteName); d->initFileEngine(absFileName); @@ -689,7 +688,7 @@ bool QFileInfo::makeAbsolute() bool QFileInfo::exists() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::ExistsFlag); } @@ -718,7 +717,7 @@ void QFileInfo::refresh() QString QFileInfo::filePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::DefaultName); } @@ -738,7 +737,7 @@ QString QFileInfo::filePath() const QString QFileInfo::fileName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName); } @@ -759,7 +758,7 @@ QString QFileInfo::fileName() const QString QFileInfo::bundleName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BundleName); } @@ -784,7 +783,7 @@ QString QFileInfo::bundleName() const QString QFileInfo::baseName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); } @@ -804,7 +803,7 @@ QString QFileInfo::baseName() const QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString name = d->getFileName(QAbstractFileEngine::BaseName); int index = name.lastIndexOf(QLatin1Char('.')); @@ -826,7 +825,7 @@ QString QFileInfo::completeBaseName() const QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int firstDot = fileName.indexOf(QLatin1Char('.')); @@ -854,7 +853,7 @@ QString QFileInfo::completeSuffix() const QString QFileInfo::suffix() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int lastDot = fileName.lastIndexOf(QLatin1Char('.')); @@ -907,7 +906,7 @@ QDir QFileInfo::absoluteDir() const */ QDir QFileInfo::dir(bool absPath) const { - if(absPath) + if (absPath) return absoluteDir(); return dir(); } @@ -922,7 +921,7 @@ QDir QFileInfo::dir(bool absPath) const bool QFileInfo::isReadable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::ReadAccess); } @@ -936,7 +935,7 @@ bool QFileInfo::isReadable() const bool QFileInfo::isWritable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::WriteAccess); } @@ -950,7 +949,7 @@ bool QFileInfo::isWritable() const bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::ExecuteAccess); } @@ -964,7 +963,7 @@ bool QFileInfo::isExecutable() const bool QFileInfo::isHidden() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::HiddenFlag); } @@ -980,7 +979,7 @@ bool QFileInfo::isHidden() const bool QFileInfo::isFile() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::FileType); } @@ -995,7 +994,7 @@ bool QFileInfo::isFile() const bool QFileInfo::isDir() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -1012,7 +1011,7 @@ bool QFileInfo::isDir() const bool QFileInfo::isBundle() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::BundleType); } @@ -1038,7 +1037,7 @@ bool QFileInfo::isBundle() const bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::LinkType); } @@ -1080,7 +1079,7 @@ bool QFileInfo::isRoot() const QString QFileInfo::readLink() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::LinkName); } @@ -1099,7 +1098,7 @@ QString QFileInfo::readLink() const QString QFileInfo::owner() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -1116,7 +1115,7 @@ QString QFileInfo::owner() const uint QFileInfo::ownerId() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); } @@ -1135,7 +1134,7 @@ uint QFileInfo::ownerId() const QString QFileInfo::group() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } @@ -1152,7 +1151,7 @@ QString QFileInfo::group() const uint QFileInfo::groupId() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); } @@ -1174,7 +1173,7 @@ uint QFileInfo::groupId() const bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } @@ -1187,7 +1186,7 @@ bool QFileInfo::permission(QFile::Permissions permissions) const QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1203,9 +1202,9 @@ QFile::Permissions QFileInfo::permissions() const qint64 QFileInfo::size() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; - if(!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) { + if (!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) { d->data->setCachedFlag(QFileInfoPrivate::CachedSize); d->data->fileSize = d->data->fileEngine->size(); } @@ -1229,7 +1228,7 @@ qint64 QFileInfo::size() const QDateTime QFileInfo::created() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::CreationTime); } @@ -1243,7 +1242,7 @@ QDateTime QFileInfo::created() const QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::ModificationTime); } @@ -1260,7 +1259,7 @@ QDateTime QFileInfo::lastModified() const QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::AccessTime); } -- cgit v0.12 From a9d351f72582c06a979874619003da36214b010f Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:51 +0100 Subject: Whitespace cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 86 ++++++++++---------------------------------- 1 file changed, 18 insertions(+), 68 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 616f6f9..21ff708 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -320,7 +320,6 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) \sa setFile() */ - QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) { } @@ -331,7 +330,6 @@ QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) \sa setFile(), isRelative(), QDir::setCurrent(), QDir::isRelativePath() */ - QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(file); @@ -346,7 +344,6 @@ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ - QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(file.fileName()); @@ -364,7 +361,6 @@ QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ - QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(dir.filePath(file)); @@ -373,7 +369,6 @@ QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfo /*! Constructs a new QFileInfo that is a copy of the given \a fileinfo. */ - QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fileinfo)) { @@ -383,7 +378,6 @@ QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fi Destroys the QFileInfo and frees its resources. */ - QFileInfo::~QFileInfo() { } @@ -456,7 +450,6 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) /*! Makes a copy of the given \a fileinfo and assigns it to this QFileInfo. */ - QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) { Q_D(QFileInfo); @@ -479,7 +472,6 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) \sa isRelative(), QDir::setCurrent(), QDir::isRelativePath() */ - void QFileInfo::setFile(const QString &file) { *this = QFileInfo(file); @@ -496,7 +488,6 @@ void QFileInfo::setFile(const QString &file) \sa isRelative() */ - void QFileInfo::setFile(const QFile &file) { *this = QFileInfo(file.fileName()); @@ -513,7 +504,6 @@ void QFileInfo::setFile(const QFile &file) \sa isRelative() */ - void QFileInfo::setFile(const QDir &dir, const QString &file) { *this = QFileInfo(dir.filePath(file)); @@ -549,15 +539,14 @@ QString QFileInfo::absoluteFilePath() const } /*! - Returns the canonical path including the file name, i.e. an absolute - path without symbolic links or redundant "." or ".." elements. + Returns the canonical path including the file name, i.e. an absolute + path without symbolic links or redundant "." or ".." elements. - If the file does not exist, canonicalFilePath() returns an empty - string. + If the file does not exist, canonicalFilePath() returns an empty + string. - \sa filePath(), absoluteFilePath(), dir() + \sa filePath(), absoluteFilePath(), dir() */ - QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); @@ -584,7 +573,6 @@ QString QFileInfo::canonicalFilePath() const \sa absoluteFilePath(), path(), canonicalPath(), fileName(), isRelative() */ - QString QFileInfo::absolutePath() const { Q_D(const QFileInfo); @@ -606,7 +594,6 @@ QString QFileInfo::absolutePath() const \sa path(), absolutePath() */ - QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); @@ -615,7 +602,6 @@ QString QFileInfo::canonicalPath() const return d->getFileName(QAbstractFileEngine::CanonicalPathName); } - /*! Returns the file's path. This doesn't include the file name. @@ -625,7 +611,6 @@ QString QFileInfo::canonicalPath() const \sa filePath(), absolutePath(), canonicalPath(), dir(), fileName(), isRelative() */ - QString QFileInfo::path() const { Q_D(const QFileInfo); @@ -650,7 +635,6 @@ QString QFileInfo::path() const \sa isAbsolute() */ - bool QFileInfo::isRelative() const { Q_D(const QFileInfo); @@ -659,7 +643,6 @@ bool QFileInfo::isRelative() const return d->data->fileEngine->isRelativePath(); } - /*! Converts the file's path to an absolute path if it is not already in that form. Returns true to indicate that the path was converted; otherwise returns false @@ -667,7 +650,6 @@ bool QFileInfo::isRelative() const \sa filePath(), isRelative() */ - bool QFileInfo::makeAbsolute() { Q_D(QFileInfo); @@ -684,7 +666,6 @@ bool QFileInfo::makeAbsolute() \note If the file is a symlink that points to a non existing file, false is returned. */ - bool QFileInfo::exists() const { Q_D(const QFileInfo); @@ -700,7 +681,6 @@ bool QFileInfo::exists() const \note On Windows CE, there might be a delay for the file system driver to detect changes on the file. */ - void QFileInfo::refresh() { Q_D(QFileInfo); @@ -713,7 +693,6 @@ void QFileInfo::refresh() \sa absoluteFilePath(), canonicalFilePath(), isRelative() */ - QString QFileInfo::filePath() const { Q_D(const QFileInfo); @@ -733,7 +712,6 @@ QString QFileInfo::filePath() const \sa isRelative(), filePath(), baseName(), extension() */ - QString QFileInfo::fileName() const { Q_D(const QFileInfo); @@ -754,7 +732,6 @@ QString QFileInfo::fileName() const \sa isBundle(), filePath(), baseName(), extension() */ - QString QFileInfo::bundleName() const { Q_D(const QFileInfo); @@ -779,7 +756,6 @@ QString QFileInfo::bundleName() const \sa fileName(), suffix(), completeSuffix(), completeBaseName() */ - QString QFileInfo::baseName() const { Q_D(const QFileInfo); @@ -799,7 +775,6 @@ QString QFileInfo::baseName() const \sa fileName(), suffix(), completeSuffix(), baseName() */ - QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); @@ -821,7 +796,6 @@ QString QFileInfo::completeBaseName() const \sa fileName(), suffix(), baseName(), completeBaseName() */ - QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); @@ -849,7 +823,6 @@ QString QFileInfo::completeSuffix() const \sa fileName(), completeSuffix(), baseName(), completeBaseName() */ - QString QFileInfo::suffix() const { Q_D(const QFileInfo); @@ -864,24 +837,23 @@ QString QFileInfo::suffix() const /*! - Returns the path of the object's parent directory as a QDir object. + Returns the path of the object's parent directory as a QDir object. - \bold{Note:} The QDir returned always corresponds to the object's - parent directory, even if the QFileInfo represents a directory. + \bold{Note:} The QDir returned always corresponds to the object's + parent directory, even if the QFileInfo represents a directory. - For each of the follwing, dir() returns a QDir for - \c{"~/examples/191697"}. + For each of the follwing, dir() returns a QDir for + \c{"~/examples/191697"}. - \snippet doc/src/snippets/fileinfo/main.cpp 0 + \snippet doc/src/snippets/fileinfo/main.cpp 0 - For each of the follwing, dir() returns a QDir for - \c{"."}. + For each of the follwing, dir() returns a QDir for + \c{"."}. - \snippet doc/src/snippets/fileinfo/main.cpp 1 + \snippet doc/src/snippets/fileinfo/main.cpp 1 - \sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir() + \sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir() */ - QDir QFileInfo::dir() const { // ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do? @@ -893,7 +865,6 @@ QDir QFileInfo::dir() const \sa dir(), filePath(), fileName(), isRelative() */ - QDir QFileInfo::absoluteDir() const { return QDir(absolutePath()); @@ -917,7 +888,6 @@ QDir QFileInfo::dir(bool absPath) const \sa isWritable(), isExecutable(), permission() */ - bool QFileInfo::isReadable() const { Q_D(const QFileInfo); @@ -931,7 +901,6 @@ bool QFileInfo::isReadable() const \sa isReadable(), isExecutable(), permission() */ - bool QFileInfo::isWritable() const { Q_D(const QFileInfo); @@ -945,7 +914,6 @@ bool QFileInfo::isWritable() const \sa isReadable(), isWritable(), permission() */ - bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); @@ -975,7 +943,6 @@ bool QFileInfo::isHidden() const \sa isDir(), isSymLink(), isBundle() */ - bool QFileInfo::isFile() const { Q_D(const QFileInfo); @@ -990,7 +957,6 @@ bool QFileInfo::isFile() const \sa isFile(), isSymLink(), isBundle() */ - bool QFileInfo::isDir() const { Q_D(const QFileInfo); @@ -1007,7 +973,6 @@ bool QFileInfo::isDir() const \sa isDir(), isSymLink(), isFile() */ - bool QFileInfo::isBundle() const { Q_D(const QFileInfo); @@ -1033,7 +998,6 @@ bool QFileInfo::isBundle() const \sa isFile(), isDir(), symLinkTarget() */ - bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); @@ -1043,11 +1007,10 @@ bool QFileInfo::isSymLink() const } /*! - Returns true if the object points to a directory or to a symbolic - link to a directory, and that directory is the root directory; otherwise - returns false. + Returns true if the object points to a directory or to a symbolic + link to a directory, and that directory is the root directory; otherwise + returns false. */ - bool QFileInfo::isRoot() const { Q_D(const QFileInfo); @@ -1094,7 +1057,6 @@ QString QFileInfo::readLink() const \sa ownerId(), group(), groupId() */ - QString QFileInfo::owner() const { Q_D(const QFileInfo); @@ -1111,7 +1073,6 @@ QString QFileInfo::owner() const \sa owner(), group(), groupId() */ - uint QFileInfo::ownerId() const { Q_D(const QFileInfo); @@ -1130,7 +1091,6 @@ uint QFileInfo::ownerId() const \sa groupId(), owner(), ownerId() */ - QString QFileInfo::group() const { Q_D(const QFileInfo); @@ -1147,7 +1107,6 @@ QString QFileInfo::group() const \sa group(), owner(), ownerId() */ - uint QFileInfo::groupId() const { Q_D(const QFileInfo); @@ -1169,7 +1128,6 @@ uint QFileInfo::groupId() const \sa isReadable(), isWritable(), isExecutable() */ - bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); @@ -1182,7 +1140,6 @@ bool QFileInfo::permission(QFile::Permissions permissions) const Returns the complete OR-ed together combination of QFile::Permissions for the file. */ - QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); @@ -1198,7 +1155,6 @@ QFile::Permissions QFileInfo::permissions() const \sa exists() */ - qint64 QFileInfo::size() const { Q_D(const QFileInfo); @@ -1224,7 +1180,6 @@ qint64 QFileInfo::size() const \sa lastModified() lastRead() */ - QDateTime QFileInfo::created() const { Q_D(const QFileInfo); @@ -1238,7 +1193,6 @@ QDateTime QFileInfo::created() const \sa created() lastRead() */ - QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); @@ -1255,7 +1209,6 @@ QDateTime QFileInfo::lastModified() const \sa created() lastModified() */ - QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); @@ -1267,7 +1220,6 @@ QDateTime QFileInfo::lastRead() const /*! \internal Detaches all internal data. */ - void QFileInfo::detach() { Q_D(QFileInfo); @@ -1279,7 +1231,6 @@ void QFileInfo::detach() \sa setCaching(), refresh() */ - bool QFileInfo::caching() const { Q_D(const QFileInfo); @@ -1298,7 +1249,6 @@ bool QFileInfo::caching() const \sa refresh(), caching() */ - void QFileInfo::setCaching(bool enable) { Q_D(QFileInfo); -- cgit v0.12 From 8de4f6f16ec2b5b3e92e25aafd2649f076c0b31b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:50:18 +0100 Subject: Remove test binary left behind --- tests/auto/selftests/xunit/tst_xunit | Bin 11624 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 tests/auto/selftests/xunit/tst_xunit diff --git a/tests/auto/selftests/xunit/tst_xunit b/tests/auto/selftests/xunit/tst_xunit deleted file mode 100755 index 31d03a8..0000000 Binary files a/tests/auto/selftests/xunit/tst_xunit and /dev/null differ -- cgit v0.12 From 7461ed5227e3002c4a6f74d458aa0255b7c1217d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 17:32:25 +0100 Subject: Optimise QStringList::join by pre-allocating the final size. This avoids a number of reallocations due to appending. This patch was contributed to us. Task-number: QTBUG-3242 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringlist.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 4b0f488..e9bdf57 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -404,7 +404,17 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r */ QString QtPrivate::QStringList_join(const QStringList *that, const QString &sep) { + int totalLength = 0; + const int size = that->size(); + + for (int i = 0; i < size; ++i) + totalLength += that->at(i).size(); + + if(size > 0) + totalLength += sep.size() * (size - 1); + QString res; + res.reserve(totalLength); for (int i = 0; i < that->size(); ++i) { if (i) res += sep; -- cgit v0.12 From abeeac820a1da1e1d32768904fa70e048a836c3f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:42:05 +0100 Subject: Make indexOfMethod not crash when going through a metaobject with methodCount == 0. Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qmetaobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index d391893..be1b2ae 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -492,10 +492,14 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, const char *method, bool normalizeStringData) { - while (*baseObject) { + const QMetaObject *m; + for (m = *baseObject; m; m = *baseObject = m->d.superdata) { const QMetaObject *const m = *baseObject; int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); + if (i < 0) + continue; + const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount) : 0; if (!normalizeStringData) { @@ -513,7 +517,6 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, return i; } } - *baseObject = m->d.superdata; } return -1; } -- cgit v0.12 From 97f7c9afb295140a7d979203f41d91082ee73cd9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 15:40:55 +0100 Subject: Fix crash handler regression introduced by c7739f7dd. The crash handler is removed when the FatalSignalHandler object goes out of scope, which it did right inside that if. Reviewed-By: Harald Fernengel --- src/testlib/qtestcase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 98e9787..40daecb 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1671,8 +1671,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) #endif { #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + QScopedPointer handler; if (!noCrashHandler) - FatalSignalHandler handler; + handler.reset(new FatalSignalHandler); #endif qInvokeTestMethods(testObject); } -- cgit v0.12 From b88141c7505e10ffaa25cc20b444da8e2cc6d9c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 15:30:06 +0100 Subject: BenchLib: update the result format and self-test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since BenchLib now uses floating point for its calculations, we should format both the value per-iteration and the total the same way. Otherwise, it would output something like "2e+08" for the total. Reviewed-by: Morten Sørvig --- src/testlib/qplaintestlogger.cpp | 3 ++- tests/auto/selftests/expected_benchlibcallgrind.txt | 2 +- tests/auto/selftests/tst_selftests.cpp | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e244690..46431a8 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -362,9 +362,10 @@ namespace QTest { char buf3[1024]; Q_ASSERT(result.iterations > 0); + formatResult(resultBuffer, 100, result.value, countSignificantDigits(result.value)); QTest::qt_snprintf( buf3, sizeof(buf3), " (total: %s, iterations: %d)", - QByteArray::number(result.value).constData(), // no 64-bit qt_snprintf support + resultBuffer, result.iterations); char buf[1024]; diff --git a/tests/auto/selftests/expected_benchlibcallgrind.txt b/tests/auto/selftests/expected_benchlibcallgrind.txt index caf2424..f172711 100644 --- a/tests/auto/selftests/expected_benchlibcallgrind.txt +++ b/tests/auto/selftests/expected_benchlibcallgrind.txt @@ -2,7 +2,7 @@ Config: Using QTest library 4.5.0, Qt 4.5.0 PASS : tst_BenchlibCallgrind::initTestCase() RESULT : tst_BenchlibCallgrind::twoHundredMillionInstructions(): - 200,000,000 instr. loads per iteration (total: 200000000, iterations: 1) + 200,000,000 instruction reads per iteration (total: 200000000, iterations: 1) PASS : tst_BenchlibCallgrind::twoHundredMillionInstructions() PASS : tst_BenchlibCallgrind::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 89ece0f..6608439 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -97,7 +97,7 @@ inline bool qCompare if (r1.unit == "msec") { variance = 0.1; } - else if (r1.unit == "instr. loads") { + else if (r1.unit == "instruction reads") { variance = 0.001; } else if (r1.unit == "ticks") { @@ -434,7 +434,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) /* This code avoids using a QRegExp because QRegExp might be broken. */ - /* Sample format: 4,000 msec per iteration (total: 4000, iterations: 1) */ + /* Sample format: 4,000 msec per iteration (total: 4,000, iterations: 1) */ QString sFirstNumber; while (!remaining.isEmpty() && !remaining.at(0).isSpace()) { @@ -468,7 +468,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(periterbit)-1); - /* Remaining: 4000, iterations: 1) */ + /* Remaining: 4,000, iterations: 1) */ static const char itersbit[] = ", iterations: "; QString sTotal; while (!remaining.startsWith(itersbit) && !remaining.isEmpty()) { @@ -482,9 +482,12 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(itersbit)-1); - qint64 total = sTotal.toLongLong(&ok); + /* 4,000 -> 4000 */ + sTotal.remove(','); + + double total = sTotal.toDouble(&ok); if (!ok) { - if (error) *error = sTotal + " (total) is not a valid integer"; + if (error) *error = sTotal + " (total) is not a valid number"; return out; } -- cgit v0.12 From 2877e3510db0cceeb4483b032fcc8f3bd61d28d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 27 Jan 2010 18:15:06 +0100 Subject: Fix regressions introduced in 3a5eb87965b60a3e249a16dc48cb06f4759dfb1b Caching of LinkType and BundleType is independent of other file flags. --- src/corelib/io/qfileinfo.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 21ff708..625098e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -170,19 +170,19 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons req &= (~QAbstractFileEngine::BundleType); cachedFlags |= CachedFileFlags; + } - if (request & QAbstractFileEngine::LinkType) { - if (!data->getCachedFlag(CachedLinkTypeFlag)) { - req |= QAbstractFileEngine::LinkType; - cachedFlags |= CachedLinkTypeFlag; - } + if (request & QAbstractFileEngine::LinkType) { + if (!data->getCachedFlag(CachedLinkTypeFlag)) { + req |= QAbstractFileEngine::LinkType; + cachedFlags |= CachedLinkTypeFlag; } + } - if (request & QAbstractFileEngine::BundleType) { - if (!data->getCachedFlag(CachedBundleTypeFlag)) { - req |= QAbstractFileEngine::BundleType; - cachedFlags |= CachedBundleTypeFlag; - } + if (request & QAbstractFileEngine::BundleType) { + if (!data->getCachedFlag(CachedBundleTypeFlag)) { + req |= QAbstractFileEngine::BundleType; + cachedFlags |= CachedBundleTypeFlag; } } } -- cgit v0.12 From 21e0423a5c9ecd9da8e141dcfba25e60b55f7fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 27 Jan 2010 20:26:26 +0100 Subject: Fix QDirIterator auto test The test depended on being run inside the source directory, because of a dummy file hierarchy present there. With these changes the needed hierarchy is generated on the fly and cleaned up at the end of the test. Also removed garbage at the end of tst_QDirIterator::stopLinkLoop. Cleanup is done in test destructor. --- tests/auto/qdiriterator/entrylist/directory/dummy | 0 tests/auto/qdiriterator/entrylist/file | 0 tests/auto/qdiriterator/foo/bar/readme.txt | 0 .../qdiriterator/recursiveDirs/dir1/aPage.html | 8 -- .../qdiriterator/recursiveDirs/dir1/textFileB.txt | 1 - .../auto/qdiriterator/recursiveDirs/textFileA.txt | 1 - tests/auto/qdiriterator/tst_qdiriterator.cpp | 129 ++++++++++++--------- 7 files changed, 76 insertions(+), 63 deletions(-) delete mode 100644 tests/auto/qdiriterator/entrylist/directory/dummy delete mode 100644 tests/auto/qdiriterator/entrylist/file delete mode 100644 tests/auto/qdiriterator/foo/bar/readme.txt delete mode 100644 tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html delete mode 100644 tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt delete mode 100644 tests/auto/qdiriterator/recursiveDirs/textFileA.txt diff --git a/tests/auto/qdiriterator/entrylist/directory/dummy b/tests/auto/qdiriterator/entrylist/directory/dummy deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/entrylist/file b/tests/auto/qdiriterator/entrylist/file deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/foo/bar/readme.txt b/tests/auto/qdiriterator/foo/bar/readme.txt deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html b/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html deleted file mode 100644 index 51a2261..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html +++ /dev/null @@ -1,8 +0,0 @@ - - - A title - - -

Some text

- - diff --git a/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt b/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt deleted file mode 100644 index 5b1dd02..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt +++ /dev/null @@ -1 +0,0 @@ -Some Text diff --git a/tests/auto/qdiriterator/recursiveDirs/textFileA.txt b/tests/auto/qdiriterator/recursiveDirs/textFileA.txt deleted file mode 100644 index 5b1dd02..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/textFileA.txt +++ /dev/null @@ -1 +0,0 @@ -Some Text diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index 6cdd1f7..f6fce32 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -71,6 +71,39 @@ public: tst_QDirIterator(); virtual ~tst_QDirIterator(); +private: // convenience functions + QStringList createdDirectories; + QStringList createdFiles; + + QDir currentDir; + bool createDirectory(const QString &dirName) + { + if (currentDir.mkdir(dirName)) { + createdDirectories.prepend(dirName); + return true; + } + return false; + } + + bool createFile(const QString &fileName) + { + QFile file(fileName); + if (file.open(QIODevice::WriteOnly)) { + createdFiles << fileName; + return true; + } + return false; + } + + bool createLink(const QString &destination, const QString &linkName) + { + if (QFile::link(destination, linkName)) { + createdFiles << linkName; + return true; + } + return false; + } + private slots: void iterateRelativeDirectory_data(); void iterateRelativeDirectory(); @@ -96,41 +129,47 @@ tst_QDirIterator::tst_QDirIterator() QFile::remove("entrylist/directory/entrylist3.lnk"); QFile::remove("entrylist/directory/entrylist4.lnk"); + createDirectory("entrylist"); + createDirectory("entrylist/directory"); + createFile("entrylist/file"); + createFile("entrylist/writable"); + createFile("entrylist/directory/dummy"); + + createDirectory("recursiveDirs"); + createDirectory("recursiveDirs/dir1"); + createFile("recursiveDirs/textFileA.txt"); + createFile("recursiveDirs/dir1/aPage.html"); + createFile("recursiveDirs/dir1/textFileB.txt"); + + createDirectory("foo"); + createDirectory("foo/bar"); + createFile("foo/bar/readme.txt"); + #ifndef Q_NO_SYMLINKS # if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // ### Sadly, this is a platform difference right now. - QFile::link("entrylist/file", "entrylist/linktofile.lnk"); + createLink("entrylist/file", "entrylist/linktofile.lnk"); # ifndef Q_NO_SYMLINKS_TO_DIRS - QFile::link("entrylist/directory", "entrylist/linktodirectory.lnk"); + createLink("entrylist/directory", "entrylist/linktodirectory.lnk"); # endif - QFile::link("entrylist/nothing", "entrylist/brokenlink.lnk"); + createLink("entrylist/nothing", "entrylist/brokenlink.lnk"); # else - QFile::link("file", "entrylist/linktofile.lnk"); + createLink("file", "entrylist/linktofile.lnk"); # ifndef Q_NO_SYMLINKS_TO_DIRS - QFile::link("directory", "entrylist/linktodirectory.lnk"); + createLink("directory", "entrylist/linktodirectory.lnk"); # endif - QFile::link("nothing", "entrylist/brokenlink.lnk"); + createLink("nothing", "entrylist/brokenlink.lnk"); # endif #endif - QFile("entrylist/writable").open(QIODevice::ReadWrite); } tst_QDirIterator::~tst_QDirIterator() { - QFile::remove("entrylist/directory"); - QFile::remove("entrylist/linktofile.lnk"); - QFile::remove("entrylist/linktodirectory.lnk"); - QFile::remove("entrylist/brokenlink.lnk"); - QFile::remove("entrylist/brokenlink"); - QFile::remove("entrylist/writable"); - QFile::remove("entrylist/entrylist1.lnk"); - QFile::remove("entrylist/entrylist2.lnk"); - QFile::remove("entrylist/entrylist3.lnk"); - QFile::remove("entrylist/entrylist4.lnk"); - QFile::remove("entrylist/directory/entrylist1.lnk"); - QFile::remove("entrylist/directory/entrylist2.lnk"); - QFile::remove("entrylist/directory/entrylist3.lnk"); - QFile::remove("entrylist/directory/entrylist4.lnk"); + Q_FOREACH(QString fileName, createdFiles) + QFile::remove(fileName); + + Q_FOREACH(QString dirName, createdDirectories) + currentDir.rmdir(dirName); } void tst_QDirIterator::iterateRelativeDirectory_data() @@ -298,23 +337,23 @@ void tst_QDirIterator::stopLinkLoop() { #ifdef Q_OS_WIN // ### Sadly, this is a platform difference right now. - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link("entrylist/.", "entrylist/entrylist2.lnk"); - QFile::link("entrylist/../entrylist/.", "entrylist/entrylist3.lnk"); - QFile::link("entrylist/..", "entrylist/entrylist4.lnk"); - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); - QFile::link("entrylist/.", "entrylist/directory/entrylist2.lnk"); - QFile::link("entrylist/../directory/.", "entrylist/directory/entrylist3.lnk"); - QFile::link("entrylist/..", "entrylist/directory/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); + createLink("entrylist/.", "entrylist/entrylist2.lnk"); + createLink("entrylist/../entrylist/.", "entrylist/entrylist3.lnk"); + createLink("entrylist/..", "entrylist/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); + createLink("entrylist/.", "entrylist/directory/entrylist2.lnk"); + createLink("entrylist/../directory/.", "entrylist/directory/entrylist3.lnk"); + createLink("entrylist/..", "entrylist/directory/entrylist4.lnk"); #else - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link(".", "entrylist/entrylist2.lnk"); - QFile::link("../entrylist/.", "entrylist/entrylist3.lnk"); - QFile::link("..", "entrylist/entrylist4.lnk"); - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); - QFile::link(".", "entrylist/directory/entrylist2.lnk"); - QFile::link("../directory/.", "entrylist/directory/entrylist3.lnk"); - QFile::link("..", "entrylist/directory/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); + createLink(".", "entrylist/entrylist2.lnk"); + createLink("../entrylist/.", "entrylist/entrylist3.lnk"); + createLink("..", "entrylist/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); + createLink(".", "entrylist/directory/entrylist2.lnk"); + createLink("../directory/.", "entrylist/directory/entrylist3.lnk"); + createLink("..", "entrylist/directory/entrylist4.lnk"); #endif QDirIterator it(QLatin1String("entrylist"), QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); @@ -325,22 +364,6 @@ void tst_QDirIterator::stopLinkLoop() QVERIFY(max); // The goal of this test is only to ensure that the test above don't malfunction - -#ifdef Q_OS_WIN - // ### Sadly, this is a platform difference right now. - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link("../../entrylist/.", "entrylist/entrylist2.lnk"); - QFile::link("entrylist/..", "entrylist/entrylist3.lnk"); -#else - QFile::remove("entrylist/entrylist1.lnk"); - QFile::remove("entrylist/entrylist2.lnk"); - QFile::remove("entrylist/entrylist3.lnk"); - QFile::remove("entrylist/entrylist4.lnk"); - QFile::remove("entrylist/directory/entrylist1.lnk"); - QFile::remove("entrylist/directory/entrylist2.lnk"); - QFile::remove("entrylist/directory/entrylist3.lnk"); - QFile::remove("entrylist/directory/entrylist4.lnk"); -#endif } class EngineWithNoIterator : public QFSFileEngine -- cgit v0.12 From e60ea3cef1dec60b0f00ddc8fa48ed639ea06ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 28 Jan 2010 11:01:57 +0100 Subject: Fix breakage introduced in 21e0423a5c9ecd9da8e141dcfba25e60b55f7fe5 Turns out two of the files removed were still required by the resource compiler. --- tests/auto/qdiriterator/entrylist/directory/dummy | 0 tests/auto/qdiriterator/entrylist/file | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/auto/qdiriterator/entrylist/directory/dummy create mode 100644 tests/auto/qdiriterator/entrylist/file diff --git a/tests/auto/qdiriterator/entrylist/directory/dummy b/tests/auto/qdiriterator/entrylist/directory/dummy new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/qdiriterator/entrylist/file b/tests/auto/qdiriterator/entrylist/file new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 5ed327e29906717d3b95b910e147de6314512a61 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 28 Jan 2010 10:40:41 +0100 Subject: Cocoa: implement usage of override cursors This have never worked in the Cocoa port, it seems. This patch gives it a try. Reviewed-by: msorvig --- src/gui/kernel/qapplication_mac.mm | 38 ++++++++++++++++++++++++++++++++-- src/gui/kernel/qapplication_p.h | 3 +++ src/gui/kernel/qeventdispatcher_mac.mm | 2 +- src/gui/kernel/qwidget_mac.mm | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index e72194e..961a3f6 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1337,12 +1337,39 @@ void QApplication::setMainWidget(QWidget *mainWidget) /***************************************************************************** QApplication cursor stack *****************************************************************************/ +#ifdef QT_MAC_USE_COCOA +void QApplicationPrivate::disableUsageOfCursorRects(bool disable) +{ + // In Cocoa there are two competing ways of setting the cursor; either + // by using cursor rects (see qcocoaview_mac.mm), or by pushing/popping + // the cursor manually. When we use override cursors, it makes most sense + // to use the latter. But then we need to tell cocoa to stop using the + // first approach so it doesn't change the cursor back when hovering over + // a cursor rect: + QWidgetList topLevels = qApp->topLevelWidgets(); + for (int i=0; ioverrideCursor()) + [static_cast(qt_mac_nsCursorForQCursor(*override)) set]; +} +#endif + void QApplication::setOverrideCursor(const QCursor &cursor) { qApp->d_func()->cursor_list.prepend(cursor); #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; + if (qApp->d_func()->cursor_list.size() == 1) + qApp->d_func()->disableUsageOfCursorRects(true); [static_cast(qt_mac_nsCursorForQCursor(cursor)) push]; #else if (qApp && qApp->activeWindow()) @@ -1359,6 +1386,8 @@ void QApplication::restoreOverrideCursor() #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; [NSCursor pop]; + if (qApp->d_func()->cursor_list.isEmpty()) + qApp->d_func()->disableUsageOfCursorRects(false); #else if (qApp && qApp->activeWindow()) { const QCursor def(Qt::ArrowCursor); @@ -2432,6 +2461,12 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event } #ifdef QT_MAC_USE_COCOA +void QApplicationPrivate::qt_initAfterNSAppStarted() +{ + setupAppleEvents(); + updateOverrideCursor(); +} + void QApplicationPrivate::setupAppleEvents() { // This function is called from the event dispatcher when NSApplication has @@ -2444,7 +2479,6 @@ void QApplicationPrivate::setupAppleEvents() forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; - } #endif @@ -2995,7 +3029,7 @@ void onApplicationWindowChangedActivation(QWidget *widget, bool activated) } QMenuBar::macUpdateMenuBar(); - + QApplicationPrivate::updateOverrideCursor(); #else Q_UNUSED(widget); Q_UNUSED(activated); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a796048..59565d4 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -458,7 +458,10 @@ public: static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *); #ifdef QT_MAC_USE_COCOA + static void qt_initAfterNSAppStarted(); static void setupAppleEvents(); + static void updateOverrideCursor(); + static void disableUsageOfCursorRects(bool disable); #endif static bool qt_mac_apply_settings(); #endif diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 84d37ae..2a1da41 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -1049,7 +1049,7 @@ void QEventDispatcherMacPrivate::firstLoopEntry(CFRunLoopObserverRef ref, Q_UNUSED(ref); Q_UNUSED(activity); #ifdef QT_MAC_USE_COCOA - QApplicationPrivate::setupAppleEvents(); + QApplicationPrivate::qt_initAfterNSAppStarted(); #endif processPostedEvents(static_cast(info), blockSendPostedEvents); } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 20c0cde..5b5ab40 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2311,6 +2311,9 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); } + if (qApp->overrideCursor()) + [windowRef disableCursorRects]; + setWindowLevel(); macUpdateHideOnSuspend(); macUpdateOpaqueSizeGrip(); -- cgit v0.12 From 6f260fe99f742949bbfcfcf3eebc19486bd09a1e Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 28 Jan 2010 11:18:03 +0100 Subject: Add new QMetaObject test for signal lookup. --- tests/benchmarks/qmetaobject/main.cpp | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/benchmarks/qmetaobject/main.cpp b/tests/benchmarks/qmetaobject/main.cpp index c375a16..eef6020 100644 --- a/tests/benchmarks/qmetaobject/main.cpp +++ b/tests/benchmarks/qmetaobject/main.cpp @@ -42,6 +42,84 @@ #include #include +class LotsOfSignals : public QObject +{ + Q_OBJECT +public: + LotsOfSignals() {} + +signals: + void extraSignal1(); + void extraSignal2(); + void extraSignal3(); + void extraSignal4(); + void extraSignal5(); + void extraSignal6(); + void extraSignal7(); + void extraSignal8(); + void extraSignal9(); + void extraSignal10(); + void extraSignal12(); + void extraSignal13(); + void extraSignal14(); + void extraSignal15(); + void extraSignal16(); + void extraSignal17(); + void extraSignal18(); + void extraSignal19(); + void extraSignal20(); + void extraSignal21(); + void extraSignal22(); + void extraSignal23(); + void extraSignal24(); + void extraSignal25(); + void extraSignal26(); + void extraSignal27(); + void extraSignal28(); + void extraSignal29(); + void extraSignal30(); + void extraSignal31(); + void extraSignal32(); + void extraSignal33(); + void extraSignal34(); + void extraSignal35(); + void extraSignal36(); + void extraSignal37(); + void extraSignal38(); + void extraSignal39(); + void extraSignal40(); + void extraSignal41(); + void extraSignal42(); + void extraSignal43(); + void extraSignal44(); + void extraSignal45(); + void extraSignal46(); + void extraSignal47(); + void extraSignal48(); + void extraSignal49(); + void extraSignal50(); + void extraSignal51(); + void extraSignal52(); + void extraSignal53(); + void extraSignal54(); + void extraSignal55(); + void extraSignal56(); + void extraSignal57(); + void extraSignal58(); + void extraSignal59(); + void extraSignal60(); + void extraSignal61(); + void extraSignal62(); + void extraSignal63(); + void extraSignal64(); + void extraSignal65(); + void extraSignal66(); + void extraSignal67(); + void extraSignal68(); + void extraSignal69(); + void extraSignal70(); +}; + class tst_qmetaobject: public QObject { Q_OBJECT @@ -57,6 +135,9 @@ private slots: void indexOfSignal(); void indexOfSlot_data(); void indexOfSlot(); + + void unconnected_data(); + void unconnected(); }; void tst_qmetaobject::initTestCase() @@ -154,6 +235,30 @@ void tst_qmetaobject::indexOfSlot() } } +void tst_qmetaobject::unconnected_data() +{ + QTest::addColumn("signal_index"); + QTest::newRow("signal--9") << 9; + QTest::newRow("signal--32") << 32; + QTest::newRow("signal--33") << 33; + QTest::newRow("signal--64") << 64; + QTest::newRow("signal--65") << 65; + QTest::newRow("signal--70") << 70; +} + +void tst_qmetaobject::unconnected() +{ + LotsOfSignals *obj = new LotsOfSignals; + QFETCH(int, signal_index); + QVERIFY(obj->metaObject()->methodCount() == 73); + void *v; + QBENCHMARK { + //+1 because QObject has one slot + QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, signal_index+1, &v); + } + delete obj; +} + QTEST_MAIN(tst_qmetaobject) #include "main.moc" -- cgit v0.12 From c58ac55bbe65866db85ba1338642c00fe5cc2a70 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 28 Jan 2010 15:38:55 +0100 Subject: Fix header labels on mac with rtl The removed code simply reduces the size of the rect when running with RightToLeft without compensating anywhere else. It seems to be a leftover from a previously removed piece of code. Reviewed-by: richard Task-number: QTBUG-6882 --- src/gui/styles/qmacstyle_mac.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 083f730..2313ac5 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4320,8 +4320,6 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, rect.setY(0); rect.setHeight(widget->height()); } - if (opt->direction == Qt::RightToLeft) - rect.adjust(15, 0, -20, 0); } break; case SE_ProgressBarGroove: -- cgit v0.12 From f842ec12706b70f94ab5f634dc2aa025ba2cf3f2 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 29 Jan 2010 10:49:14 +0100 Subject: Carbon: crash problem in QWidgetPrivate::hide_sys The crash occurs because we at one point try to assign a widget that is marked as 'about to be deleted' to a QPointer, after clearguards has been called. The correct fix is to avoid such an assignment in the first place. Task-number: QTBUG-4227 Reviewed-by: Prasanth --- src/gui/kernel/qwidget_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5b5ab40..b942bdd 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3579,6 +3579,8 @@ void QWidgetPrivate::hide_sys() if (!QWidget::mouseGrabber()){ QWidget *enterWidget = QApplication::widgetAt(QCursor::pos()); + if (enterWidget->data->in_destructor) + enterWidget = 0; QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover); qt_mouseover = enterWidget; } -- cgit v0.12 From ebf9c943b789bb4ce1e1222ed17cc37bd0b1f1fe Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 29 Jan 2010 11:47:02 +0100 Subject: Carbon: crash problem in QWidgetPrivate::hide_sys, v2 See change: f842ec12706. Needed some ekstra checks for the cocoa port as well. Task-number: QTBUG-4227 Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 2 ++ src/gui/kernel/qwidget_mac.mm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index b4bb8bf..8c5d166 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -602,6 +602,8 @@ extern "C" { - (void)mouseEntered:(NSEvent *)event { + if (qwidgetprivate->data.in_destructor) + return; QEvent enterEvent(QEvent::Enter); NSPoint windowPoint = [event locationInWindow]; NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint]; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b942bdd..3ff46f5 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3579,7 +3579,7 @@ void QWidgetPrivate::hide_sys() if (!QWidget::mouseGrabber()){ QWidget *enterWidget = QApplication::widgetAt(QCursor::pos()); - if (enterWidget->data->in_destructor) + if (enterWidget && enterWidget->data->in_destructor) enterWidget = 0; QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover); qt_mouseover = enterWidget; -- cgit v0.12 From 0b7474c8ef9167bef92f8a09e8a818334822aa36 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:37 +0100 Subject: Fix QDir::operator[] documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index dc7f17e..eb5f3de 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1260,13 +1260,10 @@ uint QDir::count() const /*! Returns the file name at position \a pos in the list of file names. Equivalent to entryList().at(index). - - Returns an empty string if \a pos is out of range or if the - entryList() function failed. + \a pos must be a valid index position in the list (i.e., 0 <= pos < count()). \sa count(), entryList() */ - QString QDir::operator[](int pos) const { Q_D(const QDir); -- cgit v0.12 From 2964718224c0ed356511335742368d4fc421c6bd Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:38 +0100 Subject: QDir::entry(Info)List(): really use cached data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test conditions for using cached file lists were wrong and preventing list reuse unless no filters or sorting flags were previously set. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index eb5f3de..6b79cae 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1353,10 +1353,12 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, #endif if (sort == NoSort) sort = d->data->sort; - if (filters == NoFilter && sort == NoSort && nameFilters == d->data->nameFilters) { + + if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { d->updateFileLists(); return d->data->files; } + QFileInfoList l; QDirIterator it(d->data->path, nameFilters, filters); while (it.hasNext()) { @@ -1398,10 +1400,12 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter #endif if (sort == NoSort) sort = d->data->sort; - if (filters == NoFilter && sort == NoSort && nameFilters == d->data->nameFilters) { + + if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { d->updateFileLists(); return d->data->fileInfos; } + QFileInfoList l; QDirIterator it(d->data->path, nameFilters, filters); while (it.hasNext()) { -- cgit v0.12 From c43400792b637c744ca840a4ecb339ffdb27c604 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:39 +0100 Subject: QDir::cleanPath: strip trailing slash for "/:/" on non-win platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 9 ++++++--- tests/auto/qdir/tst_qdir.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 6b79cae..f465e73 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2193,9 +2193,12 @@ QString QDir::cleanPath(const QString &path) ret = QString(out, used); // Strip away last slash except for root directories - if (ret.endsWith(QLatin1Char('/')) - && !(ret.size() == 1 || (ret.size() == 3 && ret.at(1) == QLatin1Char(':')))) - ret = ret.left(ret.length() - 1); + if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { +#ifdef Q_OS_WIN + if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) +#endif + ret.chop(1); + } return ret; } diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index c7f9b6b..1d909c9 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -982,6 +982,13 @@ tst_QDir::cleanPath_data() QTest::newRow("data7") << ".//file1.txt" << "file1.txt"; QTest::newRow("data8") << "/foo/bar/..//file1.txt" << "/foo/file1.txt"; QTest::newRow("data9") << "//" << "/"; +#if !defined(Q_OS_WINCE) +#if defined Q_OS_WIN + QTest::newRow("data10") << "c:\\" << "c:/"; +#else + QTest::newRow("data10") << "/:/" << "/:"; +#endif +#endif } -- cgit v0.12 From 57f72b0c2c2f717b267518da7f03dd08576c4df4 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:39 +0100 Subject: QDirPrivate::Data: remove needless clear()-s in constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize members with default values in constructor, instead. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index f465e73..3a04920 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -120,12 +120,12 @@ private: struct Data { inline Data() - : ref(1), fileEngine(0) - { clear(); } + : ref(1), fileEngine(0), listsDirty(1) + {} inline Data(const Data ©) : ref(1), path(copy.path), nameFilters(copy.nameFilters), sort(copy.sort), - filters(copy.filters), fileEngine(0) - { clear(); } + filters(copy.filters), fileEngine(0), listsDirty(1) + {} inline ~Data() { delete fileEngine; } @@ -181,7 +181,6 @@ QDirPrivate::QDirPrivate(QDir *qq, const QDir *copy) : q_ptr(qq) data = copy->d_func()->data; } else { data = new QDirPrivate::Data; - data->clear(); } } -- cgit v0.12 From b915461519f1a4b7da8920203529e315eee39323 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:40 +0100 Subject: optimize QDir::cd() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already create a file engine for testing if dir exists. We can also use it as source for current QDir. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3a04920..eb02e6c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -929,14 +929,13 @@ bool QDir::cd(const QString &dirName) } } } - { - QFileInfo fi(newPath); - if (!(fi.exists() && fi.isDir())) - return false; - } - d->setPath(newPath); - refresh(); + QDir dir(*this); + dir.setPath(newPath); + if (!dir.exists()) + return false; + + *this = dir; return true; } -- cgit v0.12 From 9d713d7e73a88fe8328b55d2ab9af8c215dcb89d Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:41 +0100 Subject: QDirPrivate::setPath: always initialize the file engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QDir::isRelativePath() would construct a temporary file engine just to check if we could reuse the existing one. This was also making assumptions about the inner workings of the engine, that might not be valid outside QFSFileEngine. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index eb02e6c..06ea95a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -147,7 +147,6 @@ private: } *data; inline void setPath(const QString &p) { - detach(false); QString path = p; if ((path.endsWith(QLatin1Char('/')) || path.endsWith(QLatin1Char('\\'))) && path.length() > 1) { @@ -156,12 +155,9 @@ private: #endif path.truncate(path.length() - 1); } - if(!data->fileEngine || !QDir::isRelativePath(path)) - path = initFileEngine(path); - data->fileEngine->setFileName(path); + // set the path to be the qt friendly version so then we can operate on it using just / - data->path = data->fileEngine->fileName(QAbstractFileEngine::DefaultName); - data->clear(); + data->path = initFileEngine(path); } inline void reset() { detach(); @@ -318,12 +314,11 @@ inline void QDirPrivate::updateFileLists() const } } -QString QDirPrivate::initFileEngine(const QString &path) +inline QString QDirPrivate::initFileEngine(const QString &path) { detach(false); - delete data->fileEngine; - data->fileEngine = 0; data->clear(); + delete data->fileEngine; data->fileEngine = QAbstractFileEngine::create(path); return data->fileEngine->fileName(QAbstractFileEngine::DefaultName); } -- cgit v0.12 From 585ac6cf9da5896753d33090320ebcc9c97cdda5 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:42 +0100 Subject: QDir: clear internal file lists cache early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the cache was invalidated (setPath, refresh, detach, etc.) then there is no sense to keep it any longer. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 06ea95a..61f048a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -131,6 +131,8 @@ private: inline void clear() { listsDirty = 1; + files.clear(); + fileInfos.clear(); } mutable QAtomicInt ref; @@ -269,10 +271,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, QStringList *names, QFileInfoList *infos) const { - if(names) - names->clear(); - if(infos) - infos->clear(); + // names and infos are always empty lists or 0 here int n = l.size(); if(n > 0) { if (n == 1 || (sort & QDir::SortByMask) == QDir::Unsorted) { -- cgit v0.12 From 5d8e2a668d497e81c812328f045d73c7f24efc70 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:43 +0100 Subject: QDirPrivate: remove unused q_ptr and Q_DECLARE_PUBLIC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update constructor signatures; both private and protected members became public. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 61f048a..d7fb03b 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -83,12 +83,10 @@ static QString driveSpec(const QString &path) //************* QDirPrivate class QDirPrivate { - QDir *q_ptr; - Q_DECLARE_PUBLIC(QDir) - friend struct QScopedPointerDeleter; -protected: - QDirPrivate(QDir*, const QDir *copy=0); + +public: + QDirPrivate(const QDir *copy = 0); ~QDirPrivate(); QString initFileEngine(const QString &file); @@ -96,7 +94,6 @@ protected: void updateFileLists() const; void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *) const; -private: #ifdef QT3_SUPPORT QChar filterSepChar; bool matchAllDirs; @@ -168,10 +165,9 @@ private: void detach(bool createFileEngine = true); }; -QDirPrivate::QDirPrivate(QDir *qq, const QDir *copy) : q_ptr(qq) +QDirPrivate::QDirPrivate(const QDir *copy) #ifdef QT3_SUPPORT - , filterSepChar(0) - , matchAllDirs(false) + : filterSepChar(0), matchAllDirs(false) #endif { if(copy) { @@ -187,7 +183,6 @@ QDirPrivate::~QDirPrivate() if (!data->ref.deref()) delete data; data = 0; - q_ptr = 0; } /* For sorting */ @@ -514,7 +509,7 @@ void QDirPrivate::detach(bool createFileEngine) \sa currentPath() */ -QDir::QDir(const QString &path) : d_ptr(new QDirPrivate(this)) +QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) { Q_D(QDir); d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); @@ -543,7 +538,7 @@ QDir::QDir(const QString &path) : d_ptr(new QDirPrivate(this)) */ QDir::QDir(const QString &path, const QString &nameFilter, - SortFlags sort, Filters filters) : d_ptr(new QDirPrivate(this)) + SortFlags sort, Filters filters) : d_ptr(new QDirPrivate) { Q_D(QDir); d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); @@ -571,7 +566,7 @@ QDir::QDir(const QString &path, const QString &nameFilter, \sa operator=() */ -QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(this, &dir)) +QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(&dir)) { } -- cgit v0.12 From 6d2288d4b8d6ffe7eb7cef9a0677be2ad3f45341 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:43 +0100 Subject: code cleanup and styling fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove trailing whitespaces * tabs -> whitespaces * "if(" -> "if (" * "while(" -> "while (" * "for(" -> "for (" * "for (int i.*; i++)" -> "for (int i.*; ++i)" /* looks better ;) */ * minor doc fixes Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 262 +++++++++++++++++++----------------------------- src/corelib/io/qdir.h | 5 +- 2 files changed, 108 insertions(+), 159 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index d7fb03b..0b6ad08 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -52,13 +52,13 @@ #include "qregexp.h" #include "qvector.h" #include "qalgorithms.h" +#include "qvarlengtharray.h" + #ifdef QT_BUILD_CORE_LIB -# include "qresource.h" +# include "qresource.h" +# include "private/qcoreglobaldata_p.h" #endif -#include "qvarlengtharray.h" - -#include "private/qcoreglobaldata_p.h" #include QT_BEGIN_NAMESPACE @@ -106,11 +106,11 @@ public: sep = QChar(QLatin1Char(' ')); return sep; } - static inline QStringList splitFilters(const QString &nameFilter, QChar sep=0) { - if(sep == 0) + static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) { + if (sep == 0) sep = getFilterSepChar(nameFilter); QStringList ret = nameFilter.split(sep); - for(int i = 0; i < ret.count(); i++) + for (int i = 0; i < ret.count(); ++i) ret[i] = ret[i].trimmed(); return ret; } @@ -170,7 +170,7 @@ QDirPrivate::QDirPrivate(const QDir *copy) : filterSepChar(0), matchAllDirs(false) #endif { - if(copy) { + if (copy) { copy->d_func()->data->ref.ref(); data = copy->d_func()->data; } else { @@ -186,14 +186,16 @@ QDirPrivate::~QDirPrivate() } /* For sorting */ -struct QDirSortItem { +struct QDirSortItem +{ mutable QString filename_cache; mutable QString suffix_cache; QFileInfo item; }; -class QDirSortItemComparator { +class QDirSortItemComparator +{ int qt_cmp_si_sort_flags; public: QDirSortItemComparator(int flags) : qt_cmp_si_sort_flags(flags) {} @@ -232,7 +234,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt f2->suffix_cache = ic ? f2->item.suffix().toLower() : f2->item.suffix(); - r = qt_cmp_si_sort_flags & QDir::LocaleAware + r = qt_cmp_si_sort_flags & QDir::LocaleAware ? f1->suffix_cache.localeAwareCompare(f2->suffix_cache) : f1->suffix_cache.compare(f2->suffix_cache); } @@ -252,7 +254,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt f2->filename_cache = ic ? f2->item.fileName().toLower() : f2->item.fileName(); - r = qt_cmp_si_sort_flags & QDir::LocaleAware + r = qt_cmp_si_sort_flags & QDir::LocaleAware ? f1->filename_cache.localeAwareCompare(f2->filename_cache) : f1->filename_cache.compare(f2->filename_cache); } @@ -268,11 +270,11 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, { // names and infos are always empty lists or 0 here int n = l.size(); - if(n > 0) { + if (n > 0) { if (n == 1 || (sort & QDir::SortByMask) == QDir::Unsorted) { - if(infos) + if (infos) *infos = l; - if(names) { + if (names) { for (int i = 0; i < n; ++i) names->append(l.at(i).fileName()); } @@ -280,13 +282,13 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, QScopedArrayPointer si(new QDirSortItem[n]); for (int i = 0; i < n; ++i) si[i].item = l.at(i); - qSort(si.data(), si.data()+n, QDirSortItemComparator(sort)); + qSort(si.data(), si.data() + n, QDirSortItemComparator(sort)); // put them back in the list(s) - if(infos) { + if (infos) { for (int i = 0; i < n; ++i) infos->append(si[i].item); } - if(names) { + if (names) { for (int i = 0; i < n; ++i) names->append(si[i].item.fileName()); } @@ -296,7 +298,7 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, inline void QDirPrivate::updateFileLists() const { - if(data->listsDirty) { + if (data->listsDirty) { QFileInfoList l; QDirIterator it(data->path, data->nameFilters, data->filters); while (it.hasNext()) { @@ -508,7 +510,6 @@ void QDirPrivate::detach(bool createFileEngine) \sa currentPath() */ - QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) { Q_D(QDir); @@ -536,7 +537,6 @@ QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting() */ - QDir::QDir(const QString &path, const QString &nameFilter, SortFlags sort, Filters filters) : d_ptr(new QDirPrivate) { @@ -544,10 +544,10 @@ QDir::QDir(const QString &path, const QString &nameFilter, d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); d->data->nameFilters = QDir::nameFiltersFromString(nameFilter); bool empty = d->data->nameFilters.isEmpty(); - if(!empty) { + if (!empty) { empty = true; - for(int i = 0; i < d->data->nameFilters.size(); ++i) { - if(!d->data->nameFilters.at(i).isEmpty()) { + for (int i = 0; i < d->data->nameFilters.size(); ++i) { + if (!d->data->nameFilters.at(i).isEmpty()) { empty = false; break; } @@ -565,7 +565,6 @@ QDir::QDir(const QString &path, const QString &nameFilter, \sa operator=() */ - QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(&dir)) { } @@ -574,7 +573,6 @@ QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(&dir)) Destroys the QDir object frees up its resources. This has no effect on the underlying directory in the file system. */ - QDir::~QDir() { } @@ -595,7 +593,6 @@ QDir::~QDir() \sa path(), absolutePath(), exists(), cleanPath(), dirName(), absoluteFilePath(), isRelative(), makeAbsolute() */ - void QDir::setPath(const QString &path) { Q_D(QDir); @@ -612,7 +609,6 @@ void QDir::setPath(const QString &path) \sa setPath(), absolutePath(), exists(), cleanPath(), dirName(), absoluteFilePath(), toNativeSeparators(), makeAbsolute() */ - QString QDir::path() const { Q_D(const QDir); @@ -627,7 +623,6 @@ QString QDir::path() const \sa setPath(), canonicalPath(), exists(), cleanPath(), dirName(), absoluteFilePath() */ - QString QDir::absolutePath() const { Q_D(const QDir); @@ -637,7 +632,6 @@ QString QDir::absolutePath() const return cleanPath(ret); } - /*! Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements. @@ -654,12 +648,11 @@ QString QDir::absolutePath() const \sa path(), absolutePath(), exists(), cleanPath(), dirName(), absoluteFilePath() */ - QString QDir::canonicalPath() const { Q_D(const QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return cleanPath(d->data->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); } @@ -675,7 +668,6 @@ QString QDir::canonicalPath() const \sa path(), filePath(), absolutePath(), absoluteFilePath() */ - QString QDir::dirName() const { Q_D(const QDir); @@ -694,7 +686,6 @@ QString QDir::dirName() const \sa dirName() absoluteFilePath(), isRelative(), canonicalPath() */ - QString QDir::filePath(const QString &fileName) const { Q_D(const QDir); @@ -702,7 +693,7 @@ QString QDir::filePath(const QString &fileName) const return QString(fileName); QString ret = d->data->path; - if(!fileName.isEmpty()) { + if (!fileName.isEmpty()) { if (!ret.isEmpty() && ret[(int)ret.length()-1] != QLatin1Char('/') && fileName[0] != QLatin1Char('/')) ret += QLatin1Char('/'); ret += fileName; @@ -718,13 +709,12 @@ QString QDir::filePath(const QString &fileName) const \sa relativeFilePath() filePath() canonicalPath() */ - QString QDir::absoluteFilePath(const QString &fileName) const { Q_D(const QDir); if (isAbsolutePath(fileName)) return fileName; - if(!d->data->fileEngine) + if (!d->data->fileEngine) return fileName; QString ret; @@ -732,7 +722,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const if (isRelativePath(d->data->path)) //get pwd ret = QFSFileEngine::currentPath(fileName); #endif - if(!d->data->path.isEmpty() && d->data->path != QLatin1String(".")) { + if (!d->data->path.isEmpty() && d->data->path != QLatin1String(".")) { if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) ret += QLatin1Char('/'); ret += d->data->path; @@ -752,7 +742,6 @@ QString QDir::absoluteFilePath(const QString &fileName) const \sa absoluteFilePath() filePath() canonicalPath() */ - QString QDir::relativeFilePath(const QString &fileName) const { QString dir = absolutePath(); @@ -839,7 +828,7 @@ QString QDir::toNativeSeparators(const QString &pathName) { QString n(pathName); #if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) - for (int i=0; i<(int)n.length(); i++) { + for (int i = 0; i < (int)n.length(); ++i) { if (n[i] == QLatin1Char('/')) n[i] = QLatin1Char('\\'); } @@ -863,7 +852,7 @@ QString QDir::fromNativeSeparators(const QString &pathName) { QString n(pathName); #if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) - for (int i=0; i<(int)n.length(); i++) { + for (int i = 0; i < (int)n.length(); ++i) { if (n[i] == QLatin1Char('\\')) n[i] = QLatin1Char('/'); } @@ -882,7 +871,6 @@ QString QDir::fromNativeSeparators(const QString &pathName) \sa cdUp(), isReadable(), exists(), path() */ - bool QDir::cd(const QString &dirName) { Q_D(QDir); @@ -938,7 +926,6 @@ bool QDir::cd(const QString &dirName) \sa cd(), isReadable(), exists(), path() */ - bool QDir::cdUp() { return cd(QString::fromLatin1("..")); @@ -947,7 +934,6 @@ bool QDir::cdUp() /*! Returns the string list set by setNameFilters() */ - QStringList QDir::nameFilters() const { Q_D(const QDir); @@ -970,10 +956,10 @@ QStringList QDir::nameFilters() const \sa nameFilters(), setFilter() */ - void QDir::setNameFilters(const QStringList &nameFilters) { Q_D(QDir); + d->detach(); d->data->nameFilters = nameFilters; } @@ -988,7 +974,6 @@ void QDir::setNameFilters(const QStringList &nameFilters) \sa {The Qt Resource System}, QResource::addSearchPath() */ - void QDir::addResourceSearchPath(const QString &path) { #ifdef QT_BUILD_CORE_LIB @@ -1026,7 +1011,7 @@ void QDir::setSearchPaths(const QString &prefix, const QStringList &searchPaths) return; } - for (int i = 0; i < prefix.count(); i++) { + for (int i = 0; i < prefix.count(); ++i) { if (!prefix.at(i).isLetterOrNumber()) { qWarning("QDir::setSearchPaths: Prefix can only contain letters or numbers"); return; @@ -1076,7 +1061,6 @@ QStringList QDir::searchPaths(const QString &prefix) /*! Returns the value set by setFilter() */ - QDir::Filters QDir::filter() const { Q_D(const QDir); @@ -1158,7 +1142,6 @@ QDir::Filters QDir::filter() const \sa filter(), setNameFilters() */ - void QDir::setFilter(Filters filters) { Q_D(QDir); @@ -1172,7 +1155,6 @@ void QDir::setFilter(Filters filters) \sa setSorting() SortFlag */ - QDir::SortFlags QDir::sorting() const { Q_D(const QDir); @@ -1218,7 +1200,6 @@ QDir::SortFlags QDir::sorting() const \sa sorting() SortFlag */ - void QDir::setSorting(SortFlags sort) { Q_D(QDir); @@ -1227,7 +1208,6 @@ void QDir::setSorting(SortFlags sort) d->data->sort = sort; } - /*! Returns the total number of directories and files in the directory. @@ -1235,7 +1215,6 @@ void QDir::setSorting(SortFlags sort) \sa operator[](), entryList() */ - uint QDir::count() const { Q_D(const QDir); @@ -1278,7 +1257,6 @@ QString QDir::operator[](int pos) const \sa entryInfoList(), setNameFilters(), setSorting(), setFilter() */ - QStringList QDir::entryList(Filters filters, SortFlags sort) const { Q_D(const QDir); @@ -1326,7 +1304,6 @@ QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const \sa entryInfoList(), setNameFilters(), setSorting(), setFilter() */ - QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, SortFlags sort) const { @@ -1373,7 +1350,6 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, \sa entryList(), setNameFilters(), setSorting(), setFilter(), isReadable(), exists() */ - QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filters, SortFlags sort) const { @@ -1411,7 +1387,6 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter \sa rmdir() */ - bool QDir::mkdir(const QString &dirName) const { Q_D(const QDir); @@ -1420,7 +1395,7 @@ bool QDir::mkdir(const QString &dirName) const qWarning("QDir::mkdir: Empty or null file name(s)"); return false; } - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QString fn = filePath(dirName); @@ -1436,7 +1411,6 @@ bool QDir::mkdir(const QString &dirName) const \sa mkdir() */ - bool QDir::rmdir(const QString &dirName) const { Q_D(const QDir); @@ -1445,7 +1419,7 @@ bool QDir::rmdir(const QString &dirName) const qWarning("QDir::rmdir: Empty or null file name(s)"); return false; } - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QString fn = filePath(dirName); @@ -1462,7 +1436,6 @@ bool QDir::rmdir(const QString &dirName) const \sa rmpath() */ - bool QDir::mkpath(const QString &dirPath) const { Q_D(const QDir); @@ -1471,7 +1444,7 @@ bool QDir::mkpath(const QString &dirPath) const qWarning("QDir::mkpath: Empty or null file name(s)"); return false; } - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QString fn = filePath(dirPath); @@ -1497,7 +1470,7 @@ bool QDir::rmpath(const QString &dirPath) const qWarning("QDir::rmpath: Empty or null file name(s)"); return false; } - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QString fn = filePath(dirPath); @@ -1513,17 +1486,16 @@ bool QDir::rmpath(const QString &dirPath) const \sa QFileInfo::isReadable() */ - - bool QDir::isReadable() const { Q_D(const QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; - const QAbstractFileEngine::FileFlags info = d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType - |QAbstractFileEngine::PermsMask); - if(!(info & QAbstractFileEngine::DirectoryType)) + const QAbstractFileEngine::FileFlags info = + d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + | QAbstractFileEngine::PermsMask); + if (!(info & QAbstractFileEngine::DirectoryType)) return false; return info & QAbstractFileEngine::ReadUserPerm; } @@ -1539,19 +1511,17 @@ bool QDir::isReadable() const \sa QFileInfo::exists(), QFile::exists() */ - bool QDir::exists() const { Q_D(const QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; const QAbstractFileEngine::FileFlags info = - d->data->fileEngine->fileFlags( - QAbstractFileEngine::DirectoryType - | QAbstractFileEngine::ExistsFlag - | QAbstractFileEngine::Refresh); - if(!(info & QAbstractFileEngine::DirectoryType)) + d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + | QAbstractFileEngine::ExistsFlag + | QAbstractFileEngine::Refresh); + if (!(info & QAbstractFileEngine::DirectoryType)) return false; return info & QAbstractFileEngine::ExistsFlag; } @@ -1568,12 +1538,11 @@ bool QDir::exists() const \sa root(), rootPath() */ - bool QDir::isRoot() const { Q_D(const QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return true; return d->data->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; } @@ -1603,12 +1572,11 @@ bool QDir::isRoot() const \sa makeAbsolute() isAbsolute() isAbsolutePath() cleanPath() */ - bool QDir::isRelative() const { Q_D(const QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->data->fileEngine->isRelativePath(); } @@ -1621,20 +1589,19 @@ bool QDir::isRelative() const \sa isAbsolute() isAbsolutePath() isRelative() cleanPath() */ - bool QDir::makeAbsolute() // ### What do the return values signify? { Q_D(QDir); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QString absolutePath = d->data->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); - if(QDir::isRelativePath(absolutePath)) + if (QDir::isRelativePath(absolutePath)) return false; d->detach(); d->data->path = absolutePath; d->data->fileEngine->setFileName(absolutePath); - if(!(d->data->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) + if (!(d->data->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; return true; } @@ -1648,22 +1615,21 @@ bool QDir::makeAbsolute() // ### What do the return values signify? \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 10 */ - bool QDir::operator==(const QDir &dir) const { const QDirPrivate *d = d_func(); const QDirPrivate *other = dir.d_func(); - if(d->data == other->data) + if (d->data == other->data) return true; Q_ASSERT(d->data->fileEngine && other->data->fileEngine); - if(d->data->fileEngine->caseSensitive() != other->data->fileEngine->caseSensitive()) + if (d->data->fileEngine->caseSensitive() != other->data->fileEngine->caseSensitive()) return false; - if(d->data->filters == other->data->filters + if (d->data->filters == other->data->filters && d->data->sort == other->data->sort && d->data->nameFilters == other->data->nameFilters) { QString dir1 = absolutePath(), dir2 = dir.absolutePath(); - if(!other->data->fileEngine->caseSensitive()) + if (!other->data->fileEngine->caseSensitive()) return (dir1.toLower() == dir2.toLower()); return (dir1 == dir2); @@ -1676,7 +1642,6 @@ bool QDir::operator==(const QDir &dir) const Makes a copy of the \a dir object and assigns it to this QDir object. */ - QDir &QDir::operator=(const QDir &dir) { if (this == &dir) @@ -1695,7 +1660,6 @@ QDir &QDir::operator=(const QDir &dir) Use setPath() instead. */ - QDir &QDir::operator=(const QString &path) { Q_D(QDir); @@ -1716,14 +1680,12 @@ QDir &QDir::operator=(const QString &path) \snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 11 */ - /*! Removes the file, \a fileName. Returns true if the file is removed successfully; otherwise returns false. */ - bool QDir::remove(const QString &fileName) { if (fileName.isEmpty()) { @@ -1745,7 +1707,6 @@ bool QDir::remove(const QString &fileName) fail. For example, on at least one file system rename() fails if \a newName points to an open file. */ - bool QDir::rename(const QString &oldName, const QString &newName) { Q_D(QDir); @@ -1754,11 +1715,11 @@ bool QDir::rename(const QString &oldName, const QString &newName) qWarning("QDir::rename: Empty or null file name(s)"); return false; } - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; QFile file(filePath(oldName)); - if(!file.exists()) + if (!file.exists()) return false; return file.rename(filePath(newName)); } @@ -1773,7 +1734,6 @@ bool QDir::rename(const QString &oldName, const QString &newName) \sa QFileInfo::exists(), QFile::exists() */ - bool QDir::exists(const QString &name) const { if (name.isEmpty()) { @@ -1793,7 +1753,6 @@ bool QDir::exists(const QString &name) const \sa root(), rootPath() */ - QFileInfoList QDir::drives() { #ifdef QT_NO_FSFILEENGINE @@ -1813,7 +1772,6 @@ QFileInfoList QDir::drives() user using their operating system's separator use toNativeSeparators(). */ - QChar QDir::separator() { #if defined (Q_FS_FAT) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) @@ -1832,9 +1790,8 @@ QChar QDir::separator() Returns true if the directory was successfully changed; otherwise returns false. - \sa current() currentPath() home() root() temp() + \sa current(), currentPath(), home(), root(), temp() */ - bool QDir::setCurrent(const QString &path) { #ifdef QT_NO_FSFILEENGINE @@ -1853,13 +1810,13 @@ bool QDir::setCurrent(const QString &path) The directory is constructed using the absolute path of the current directory, ensuring that its path() will be the same as its absolutePath(). - \sa currentPath(), home(), root(), temp() + \sa currentPath(), setCurrent(), home(), root(), temp() */ /*! Returns the absolute path of the application's current directory. - \sa current(), homePath(), rootPath(), tempPath() + \sa current(), setCurrent(), homePath(), rootPath(), tempPath() */ QString QDir::currentPath() { @@ -1876,7 +1833,7 @@ QString QDir::currentPath() Use currentPath() instead. - \sa currentPath() + \sa currentPath(), setCurrent() */ /*! @@ -1933,14 +1890,14 @@ QString QDir::homePath() } /*! - \fn QString QDir::homeDirPath() + \fn QString QDir::homeDirPath() - Returns the absolute path of the user's home directory. + Returns the absolute path of the user's home directory. - Use homePath() instead. + Use homePath() instead. - \sa homePath() - */ + \sa homePath() +*/ /*! \fn QDir QDir::temp() @@ -2006,13 +1963,13 @@ QString QDir::rootPath() } /*! - \fn QString QDir::rootDirPath() + \fn QString QDir::rootDirPath() - Returns the absolute path of the root directory. + Returns the absolute path of the root directory. - Use rootPath() instead. + Use rootPath() instead. - \sa rootPath() + \sa rootPath() */ #ifndef QT_NO_REGEXP @@ -2025,11 +1982,9 @@ QString QDir::rootPath() \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList() */ - - bool QDir::match(const QStringList &filters, const QString &fileName) { - for(QStringList::ConstIterator sit = filters.begin(); sit != filters.end(); ++sit) { + for (QStringList::ConstIterator sit = filters.begin(); sit != filters.end(); ++sit) { QRegExp rx(*sit, Qt::CaseInsensitive, QRegExp::Wildcard); if (rx.exactMatch(fileName)) return true; @@ -2045,12 +2000,11 @@ bool QDir::match(const QStringList &filters, const QString &fileName) \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList() */ - bool QDir::match(const QString &filter, const QString &fileName) { return match(nameFiltersFromString(filter), fileName); } -#endif +#endif // QT_NO_REGEXP /*! Removes all multiple directory separators "/" and resolves any @@ -2063,15 +2017,14 @@ bool QDir::match(const QString &filter, const QString &fileName) \sa absolutePath() canonicalPath() */ - QString QDir::cleanPath(const QString &path) { if (path.isEmpty()) return path; QString name = path; QChar dir_separator = separator(); - if(dir_separator != QLatin1Char('/')) - name.replace(dir_separator, QLatin1Char('/')); + if (dir_separator != QLatin1Char('/')) + name.replace(dir_separator, QLatin1Char('/')); int used = 0, levels = 0; const int len = name.length(); @@ -2079,27 +2032,27 @@ QString QDir::cleanPath(const QString &path) QChar *out = outVector.data(); const QChar *p = name.unicode(); - for(int i = 0, last = -1, iwrite = 0; i < len; i++) { - if(p[i] == QLatin1Char('/')) { - while(i < len-1 && p[i+1] == QLatin1Char('/')) { + for (int i = 0, last = -1, iwrite = 0; i < len; ++i) { + if (p[i] == QLatin1Char('/')) { + while (i < len-1 && p[i+1] == QLatin1Char('/')) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) //allow unc paths - if(!i) + if (!i) break; #endif i++; } bool eaten = false; - if(i < len - 1 && p[i+1] == QLatin1Char('.')) { + if (i < len - 1 && p[i+1] == QLatin1Char('.')) { int dotcount = 1; - if(i < len - 2 && p[i+2] == QLatin1Char('.')) + if (i < len - 2 && p[i+2] == QLatin1Char('.')) dotcount++; - if(i == len - dotcount - 1) { - if(dotcount == 1) { + if (i == len - dotcount - 1) { + if (dotcount == 1) { break; - } else if(levels) { - if(last == -1) { - for(int i2 = iwrite-1; i2 >= 0; i2--) { - if(out[i2] == QLatin1Char('/')) { + } else if (levels) { + if (last == -1) { + for (int i2 = iwrite-1; i2 >= 0; i2--) { + if (out[i2] == QLatin1Char('/')) { last = i2; break; } @@ -2108,11 +2061,11 @@ QString QDir::cleanPath(const QString &path) used -= iwrite - last - 1; break; } - } else if(p[i+dotcount+1] == QLatin1Char('/')) { - if(dotcount == 2 && levels) { - if(last == -1 || iwrite - last == 1) { - for(int i2 = (last == -1) ? (iwrite-1) : (last-1); i2 >= 0; i2--) { - if(out[i2] == QLatin1Char('/')) { + } else if (p[i+dotcount+1] == QLatin1Char('/')) { + if (dotcount == 2 && levels) { + if (last == -1 || iwrite - last == 1) { + for (int i2 = (last == -1) ? (iwrite-1) : (last-1); i2 >= 0; i2--) { + if (out[i2] == QLatin1Char('/')) { eaten = true; last = i2; break; @@ -2121,7 +2074,7 @@ QString QDir::cleanPath(const QString &path) } else { eaten = true; } - if(eaten) { + if (eaten) { levels--; used -= iwrite - last; iwrite = last; @@ -2133,38 +2086,38 @@ QString QDir::cleanPath(const QString &path) iwrite = qMax(0, last); last = -1; ++i; - } else if(dotcount == 1) { + } else if (dotcount == 1) { eaten = true; } - if(eaten) + if (eaten) i += dotcount; } else { levels++; } - } else if(last != -1 && iwrite - last == 1) { + } else if (last != -1 && iwrite - last == 1) { #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) eaten = (iwrite > 2); #else eaten = true; #endif last = -1; - } else if(last != -1 && i == len-1) { + } else if (last != -1 && i == len-1) { eaten = true; } else { levels++; } - if(!eaten) + if (!eaten) last = i - (i - iwrite); else continue; - } else if(!i && p[i] == QLatin1Char('.')) { + } else if (!i && p[i] == QLatin1Char('.')) { int dotcount = 1; - if(len >= 1 && p[1] == QLatin1Char('.')) + if (len >= 1 && p[1] == QLatin1Char('.')) dotcount++; - if(len >= dotcount && p[dotcount] == QLatin1Char('/')) { - if(dotcount == 1) { + if (len >= dotcount && p[dotcount] == QLatin1Char('/')) { + if (dotcount == 1) { i++; - while(i+1 < len-1 && p[i+1] == QLatin1Char('/')) + while (i+1 < len-1 && p[i+1] == QLatin1Char('/')) i++; continue; } @@ -2196,7 +2149,6 @@ QString QDir::cleanPath(const QString &path) \sa isRelative() isAbsolutePath() makeAbsolute() */ - bool QDir::isRelativePath(const QString &path) { return QFileInfo(path).isRelative(); @@ -2205,7 +2157,6 @@ bool QDir::isRelativePath(const QString &path) /*! Refreshes the directory information. */ - void QDir::refresh() const { Q_D(const QDir); @@ -2220,7 +2171,6 @@ void QDir::refresh() const there is more than one filter, each pair of filters is separated by a space or by a semicolon.) */ - QStringList QDir::nameFiltersFromString(const QString &nameFilter) { return QDirPrivate::splitFilters(nameFilter); @@ -2412,7 +2362,8 @@ void QDir::setNameFilter(const QString &nameFilter) Use QDir::SortFlags instead. */ -#endif +#endif // QT3_SUPPORT + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, QDir::Filters filters) { @@ -2475,9 +2426,6 @@ QDebug operator<<(QDebug debug, const QDir &dir) << ')'; return debug.space(); } - - - -#endif +#endif // QT_NO_DEBUG_STREAM QT_END_NAMESPACE diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 6be4922..186dd2f 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -83,7 +83,7 @@ public: Modified = 0x080, Hidden = 0x100, System = 0x200, - + AccessMask = 0x3F0, AllDirs = 0x400, @@ -215,6 +215,7 @@ public: static bool match(const QStringList &filters, const QString &fileName); static bool match(const QString &filter, const QString &fileName); #endif + static QString cleanPath(const QString &path); void refresh() const; @@ -246,7 +247,7 @@ public: inline QT3_SUPPORT static QString homeDirPath() { return homePath(); } inline QT3_SUPPORT static QString rootDirPath() { return rootPath(); } inline QT3_SUPPORT static QString cleanDirPath(const QString &name) { return cleanPath(name); } -#endif +#endif // QT3_SUPPORT }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters) -- cgit v0.12 From 6d8ea540bd123270f0010eb5fa5e68a510ca89e7 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:44 +0100 Subject: nano-optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 0b6ad08..250e5e5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1692,8 +1692,7 @@ bool QDir::remove(const QString &fileName) qWarning("QDir::remove: Empty or null file name"); return false; } - QString p = filePath(fileName); - return QFile::remove(p); + return QFile::remove(filePath(fileName)); } /*! @@ -1740,8 +1739,7 @@ bool QDir::exists(const QString &name) const qWarning("QDir::exists: Empty or null file name"); return false; } - QString tmp = filePath(name); - return QFile::exists(tmp); + return QFile::exists(filePath(name)); } /*! @@ -1984,7 +1982,7 @@ QString QDir::rootPath() */ bool QDir::match(const QStringList &filters, const QString &fileName) { - for (QStringList::ConstIterator sit = filters.begin(); sit != filters.end(); ++sit) { + for (QStringList::ConstIterator sit = filters.constBegin(); sit != filters.constEnd(); ++sit) { QRegExp rx(*sit, Qt::CaseInsensitive, QRegExp::Wildcard); if (rx.exactMatch(fileName)) return true; @@ -2126,12 +2124,8 @@ QString QDir::cleanPath(const QString &path) out[iwrite++] = p[i]; used++; } - QString ret; - if(used == len) - ret = name; - else - ret = QString(out, used); + QString ret = (used == len ? name : QString(out, used)); // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { #ifdef Q_OS_WIN -- cgit v0.12 From 1492a2edf269b368abd2af9f8ffb474489609b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 21 Jan 2010 19:48:33 +0100 Subject: Use X/Open LFS extensions for 64-bit support on directory iteration This boils down to using readdir64(_r) and struct dirent64 where available. I assumed these are available in the same platforms other such extensions are already being used. AIX uses the additional type DIR64 and opendir64/closedir64 to manipulate it. Task-number: QTBUG-2781 Reviewed-by: Thiago Macieira --- mkspecs/common/aix/qplatformdefs.h | 10 ++++++++++ mkspecs/common/posix/qplatformdefs.h | 16 ++++++++++++++++ src/corelib/io/qfilesystemwatcher_dnotify.cpp | 13 +++++++------ src/corelib/io/qfsfileengine_iterator_unix.cpp | 20 ++++++++++---------- src/gui/embedded/qscreen_qws.cpp | 21 +++++++++++---------- 5 files changed, 54 insertions(+), 26 deletions(-) diff --git a/mkspecs/common/aix/qplatformdefs.h b/mkspecs/common/aix/qplatformdefs.h index 57c5a76..b3abf68 100644 --- a/mkspecs/common/aix/qplatformdefs.h +++ b/mkspecs/common/aix/qplatformdefs.h @@ -101,6 +101,16 @@ #define QT_SOCKOPTLEN_T int #endif +#ifdef QT_LARGEFILE_SUPPORT +#undef QT_DIR +#undef QT_OPENDIR +#undef QT_CLOSEDIR + +#define QT_DIR DIR64 +#define QT_OPENDIR ::opendir64 +#define QT_CLOSEDIR ::closedir64 +#endif + #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) // AIX 4.3 and better #define QT_SNPRINTF ::snprintf diff --git a/mkspecs/common/posix/qplatformdefs.h b/mkspecs/common/posix/qplatformdefs.h index fe50de2..e29bc6f 100644 --- a/mkspecs/common/posix/qplatformdefs.h +++ b/mkspecs/common/posix/qplatformdefs.h @@ -132,6 +132,22 @@ // Posix extensions to C89 #define QT_FILENO fileno +// Directory iteration +#define QT_DIR DIR + +#define QT_OPENDIR ::opendir +#define QT_CLOSEDIR ::closedir + +#if defined(QT_USE_XOPEN_LFS_EXTENSIONS) && defined(QT_LARGEFILE_SUPPORT) +#define QT_DIRENT struct dirent64 +#define QT_READDIR ::readdir64 +#define QT_READDIR_R ::readdir64_r +#else +#define QT_DIRENT struct dirent +#define QT_READDIR ::readdir +#define QT_READDIR_R ::readdir_r +#endif + #define QT_SOCKLEN_T socklen_t #define QT_SOCKET_CONNECT ::connect diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index 1a218c7..82470c8 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qplatformdefs.h" #include "qfilesystemwatcher.h" #include "qfilesystemwatcher_dnotify_p.h" @@ -255,16 +256,16 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, if(fd == 0) { - DIR *d = ::opendir(path.toUtf8().constData()); + QT_DIR *d = QT_OPENDIR(path.toUtf8().constData()); if(!d) continue; // Could not open directory - DIR *parent = 0; + QT_DIR *parent = 0; QDir parentDir(path); if(!parentDir.isRoot()) { parentDir.cdUp(); - parent = ::opendir(parentDir.path().toUtf8().constData()); + parent = QT_OPENDIR(parentDir.path().toUtf8().constData()); if(!parent) { - ::closedir(d); + QT_CLOSEDIR(d); continue; } } @@ -272,8 +273,8 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, fd = qt_safe_dup(::dirfd(d)); int parentFd = parent ? qt_safe_dup(::dirfd(parent)) : 0; - ::closedir(d); - if(parent) ::closedir(parent); + QT_CLOSEDIR(d); + if(parent) QT_CLOSEDIR(parent); Q_ASSERT(fd); if(::fcntl(fd, F_SETSIG, SIGIO) || diff --git a/src/corelib/io/qfsfileengine_iterator_unix.cpp b/src/corelib/io/qfsfileengine_iterator_unix.cpp index b68b1a1..bfdb03e 100644 --- a/src/corelib/io/qfsfileengine_iterator_unix.cpp +++ b/src/corelib/io/qfsfileengine_iterator_unix.cpp @@ -58,13 +58,13 @@ public: #endif {} - DIR *dir; - dirent *dirEntry; + QT_DIR *dir; + QT_DIRENT *dirEntry; bool done; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) // for readdir_r - dirent *mt_file; + QT_DIRENT *mt_file; #endif }; @@ -76,14 +76,14 @@ void QFSFileEngineIterator::advance() return; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0) + if (QT_READDIR_R(platform->dir, platform->mt_file, &platform->dirEntry) != 0) platform->done = true; #else // ### add local lock to prevent breaking reentrancy - platform->dirEntry = ::readdir(platform->dir); + platform->dirEntry = QT_READDIR(platform->dir); #endif // _POSIX_THREAD_SAFE_FUNCTIONS if (!platform->dirEntry) { - ::closedir(platform->dir); + QT_CLOSEDIR(platform->dir); platform->dir = 0; platform->done = true; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) @@ -101,7 +101,7 @@ void QFSFileEngineIterator::newPlatformSpecifics() void QFSFileEngineIterator::deletePlatformSpecifics() { if (platform->dir) { - ::closedir(platform->dir); + QT_CLOSEDIR(platform->dir); #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) delete [] platform->mt_file; platform->mt_file = 0; @@ -115,18 +115,18 @@ bool QFSFileEngineIterator::hasNext() const { if (!platform->done && !platform->dir) { QFSFileEngineIterator *that = const_cast(this); - if ((that->platform->dir = ::opendir(QFile::encodeName(path()).data())) == 0) { + if ((that->platform->dir = QT_OPENDIR(QFile::encodeName(path()).data())) == 0) { that->platform->done = true; } else { // ### Race condition; we should use fpathconf and dirfd(). long maxPathName = ::pathconf(QFile::encodeName(path()).data(), _PC_NAME_MAX); if ((int) maxPathName == -1) maxPathName = FILENAME_MAX; - maxPathName += sizeof(dirent) + 1; + maxPathName += sizeof(QT_DIRENT) + 1; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) if (that->platform->mt_file) delete [] that->platform->mt_file; - that->platform->mt_file = (dirent *)new char[maxPathName]; + that->platform->mt_file = (QT_DIRENT *)new char[maxPathName]; #endif that->advance(); diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 8eb8123..65a3fb5 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qplatformdefs.h" #include "qscreen_qws.h" #include "qcolormap.h" @@ -3223,13 +3224,13 @@ QScreen * qt_probe_bus() return qt_dodriver("unaccel.so",0,0); } - DIR * dirptr=opendir("/proc/bus/pci"); + QT_DIR *dirptr = QT_OPENDIR("/proc/bus/pci"); if(!dirptr) return qt_dodriver("unaccel.so",0,0); - DIR * dirptr2; - dirent * cards; + QT_DIR * dirptr2; + QT_DIRENT *cards; - dirent * busses=readdir(dirptr); + QT_DIRENT *busses = QT_READDIR(dirptr); while(busses) { if(busses->d_name[0]!='.') { @@ -3237,9 +3238,9 @@ QScreen * qt_probe_bus() strcpy(buf,"/proc/bus/pci/"); qstrcpy(buf+14,busses->d_name); int p=strlen(buf); - dirptr2=opendir(buf); + dirptr2 = QT_OPENDIR(buf); if(dirptr2) { - cards=readdir(dirptr2); + cards = QT_READDIR(dirptr2); while(cards) { if(cards->d_name[0]!='.') { buf[p]='/'; @@ -3248,14 +3249,14 @@ QScreen * qt_probe_bus() if(ret) return ret; } - cards=readdir(dirptr2); + cards = QT_READDIR(dirptr2); } - closedir(dirptr2); + QT_CLOSEDIR(dirptr2); } } - busses=readdir(dirptr); + busses = QT_READDIR(dirptr); } - closedir(dirptr); + QT_CLOSEDIR(dirptr); return qt_dodriver("unaccel.so",0,0); } -- cgit v0.12 From c035b7edbdf053a5e230c30d2605a416cd4d86df Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 8 Sep 2009 09:54:41 -0300 Subject: doc: Fix qmake-manual warn_on/warn_off references Signed-off-by: Ademar de Souza Reis Jr --- doc/src/development/qmake-manual.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index d7aa0db..3d5c792 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -1977,7 +1977,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_OFF This variable is not empty if the warn_off - \l{#TEMPLATE}{TEMPLATE} option is specified. The value of this + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. @@ -1985,7 +1985,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_ON This variable is not empty if the warn_on - \l{#TEMPLATE}{TEMPLATE} option is specified. + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. -- cgit v0.12 From d64ff88040586c42d73bd58204e517b2a11fd648 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 15 Sep 2009 11:18:23 -0300 Subject: doc: Fix typo in QEvent::ignore() documentation Signed-off-by: Ademar de Souza Reis Jr --- src/corelib/kernel/qcoreevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 3f69b4f..d177b26 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -331,7 +331,7 @@ QEvent::~QEvent() equivalent of calling setAccepted(false). Clearing the accept parameter indicates that the event receiver - does not want the event. Unwanted events might be propgated to the + does not want the event. Unwanted events might be propagated to the parent widget. \sa accept() -- cgit v0.12 From a1973962379345988f0a3686153f70397ce3eb99 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:19:15 -0300 Subject: examples/dbus: update dbus-chat adaptor/interface files The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/dbus-chat/chat_adaptor.cpp | 6 +++--- examples/dbus/dbus-chat/chat_adaptor.h | 27 ++++++++++++--------------- examples/dbus/dbus-chat/chat_interface.cpp | 6 +++--- examples/dbus/dbus-chat/chat_interface.h | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/examples/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp index dc07e1c..c093c70 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.cpp +++ b/examples/dbus/dbus-chat/chat_adaptor.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h index b1e66ad..de5c4a2 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.h +++ b/examples/dbus/dbus-chat/chat_adaptor.h @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,20 +49,17 @@ ** ****************************************************************************/ -#ifndef CHAT_ADAPTOR_H_142741156243605 -#define CHAT_ADAPTOR_H_142741156243605 +#ifndef CHAT_ADAPTOR_H_1257535021 +#define CHAT_ADAPTOR_H_1257535021 #include #include - -QT_BEGIN_NAMESPACE class QByteArray; template class QList; template class QMap; class QString; class QStringList; class QVariant; -QT_END_NAMESPACE /* * Adaptor class for interface com.trolltech.chat @@ -72,14 +69,14 @@ class ChatAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" +" \n" " \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" " \n" " \n" "") diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp index f187ee0..d591053 100644 --- a/examples/dbus/dbus-chat/chat_interface.cpp +++ b/examples/dbus/dbus-chat/chat_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h index 3bf427b..2f695b5 100644 --- a/examples/dbus/dbus-chat/chat_interface.h +++ b/examples/dbus/dbus-chat/chat_interface.h @@ -38,18 +38,18 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#ifndef CHAT_INTERFACE_H_143021156243606 -#define CHAT_INTERFACE_H_143021156243606 +#ifndef CHAT_INTERFACE_H_1257535021 +#define CHAT_INTERFACE_H_1257535021 #include #include -- cgit v0.12 From 8993ed377456b57a516c5e1407b716a7e330fe18 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:49:12 -0300 Subject: examples/dbus: update remotecontrolledcar example The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/remotecontrolledcar/car/car.pro | 2 +- .../dbus/remotecontrolledcar/car/car_adaptor.cpp | 22 ++-- .../dbus/remotecontrolledcar/car/car_adaptor_p.h | 97 ------------------ examples/dbus/remotecontrolledcar/car/main.cpp | 4 +- .../controller/car_interface.cpp | 15 ++- .../controller/car_interface_p.h | 114 --------------------- .../remotecontrolledcar/controller/controller.cpp | 4 +- .../remotecontrolledcar/controller/controller.h | 5 +- .../remotecontrolledcar/controller/controller.pro | 2 +- 9 files changed, 26 insertions(+), 239 deletions(-) delete mode 100644 examples/dbus/remotecontrolledcar/car/car_adaptor_p.h delete mode 100644 examples/dbus/remotecontrolledcar/controller/car_interface_p.h diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index 9b426d3..d362dc9 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -10,7 +10,7 @@ CONFIG += qdbus # Input # DBUS_ADAPTORS += car.xml -HEADERS += car.h car_adaptor_p.h +HEADERS += car.h car_adaptor.h SOURCES += car.cpp main.cpp car_adaptor.cpp # install diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp index bd4832e..80249a4 100644 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_adaptor.h -a :car_adaptor.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -58,40 +58,40 @@ #include /* - * Implementation of adaptor class CarAdaptor + * Implementation of adaptor class CarInterfaceAdaptor */ -CarAdaptor::CarAdaptor(QObject *parent) +CarInterfaceAdaptor::CarInterfaceAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor setAutoRelaySignals(true); } -CarAdaptor::~CarAdaptor() +CarInterfaceAdaptor::~CarInterfaceAdaptor() { // destructor } -void CarAdaptor::accelerate() +void CarInterfaceAdaptor::accelerate() { // handle method call com.trolltech.Examples.CarInterface.accelerate QMetaObject::invokeMethod(parent(), "accelerate"); } -void CarAdaptor::decelerate() +void CarInterfaceAdaptor::decelerate() { // handle method call com.trolltech.Examples.CarInterface.decelerate QMetaObject::invokeMethod(parent(), "decelerate"); } -void CarAdaptor::turnLeft() +void CarInterfaceAdaptor::turnLeft() { // handle method call com.trolltech.Examples.CarInterface.turnLeft QMetaObject::invokeMethod(parent(), "turnLeft"); } -void CarAdaptor::turnRight() +void CarInterfaceAdaptor::turnRight() { // handle method call com.trolltech.Examples.CarInterface.turnRight QMetaObject::invokeMethod(parent(), "turnRight"); diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h b/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h deleted file mode 100644 index 5f769cd..0000000 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** This file may have been hand-edited. Look for HAND-EDIT comments -** before re-generating it. -** -****************************************************************************/ - -#ifndef CAR_ADAPTOR_P_H_1157030132 -#define CAR_ADAPTOR_P_H_1157030132 - -#include -#include - -QT_BEGIN_NAMESPACE -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; -QT_END_NAMESPACE - -/* - * Adaptor class for interface com.trolltech.Examples.CarInterface - */ -class CarAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface") - Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") -public: - CarAdaptor(QObject *parent); - virtual ~CarAdaptor(); - -public: // PROPERTIES -public Q_SLOTS: // METHODS - void accelerate(); - void decelerate(); - void turnLeft(); - void turnRight(); -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -#endif diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp index 85b206c..eab82a7 100644 --- a/examples/dbus/remotecontrolledcar/car/main.cpp +++ b/examples/dbus/remotecontrolledcar/car/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "car.h" -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) view.resize(400, 300); view.show(); - new CarAdaptor(car); + new CarInterfaceAdaptor(car); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Car", car); connection.registerService("com.trolltech.CarExample"); diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp index 01be1bf..4fc29b2 100644 --- a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_interface.h -p :car_interface.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,18 +49,17 @@ ** ****************************************************************************/ -#include "car_interface_p.h" - +#include "car_interface.h" /* - * Implementation of interface class CarInterface + * Implementation of interface class ComTrolltechExamplesCarInterfaceInterface */ -CarInterface::CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) +ComTrolltechExamplesCarInterfaceInterface::ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } -CarInterface::~CarInterface() +ComTrolltechExamplesCarInterfaceInterface::~ComTrolltechExamplesCarInterfaceInterface() { } diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h b/examples/dbus/remotecontrolledcar/controller/car_interface_p.h deleted file mode 100644 index 8a5a907..0000000 --- a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -** -****************************************************************************/ - -#ifndef CAR_INTERFACE_P_H_1156853585 -#define CAR_INTERFACE_P_H_1156853585 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface com.trolltech.Examples.CarInterface - */ -class CarInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.trolltech.Examples.CarInterface"; } - -public: - CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~CarInterface(); - -public Q_SLOTS: // METHODS - inline QDBusReply accelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("accelerate"), argumentList); - } - - inline QDBusReply decelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("decelerate"), argumentList); - } - - inline QDBusReply turnLeft() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnLeft"), argumentList); - } - - inline QDBusReply turnRight() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnRight"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -namespace com { - namespace trolltech { - namespace Examples { - typedef ::CarInterface CarInterface; - } - } -} -#endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp index 00a8875..5fca9e3 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.cpp +++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp @@ -42,13 +42,13 @@ #include #include "controller.h" -#include "car_interface_p.h" +#include "car_interface.h" Controller::Controller(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - car = new CarInterface("com.trolltech.CarExample", "/Car", + car = new com::trolltech::Examples::CarInterface("com.trolltech.CarExample", "/Car", QDBusConnection::sessionBus(), this); startTimer(1000); } diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h index 07a1355..caadff9 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.h +++ b/examples/dbus/remotecontrolledcar/controller/controller.h @@ -43,8 +43,7 @@ #define CONTROLLER_H #include "ui_controller.h" - -class CarInterface; +#include "car_interface.h" class Controller : public QWidget { @@ -64,7 +63,7 @@ private slots: private: Ui::Controller ui; - CarInterface *car; + com::trolltech::Examples::CarInterface *car; }; #endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 159e3b1..375b9d7 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -11,7 +11,7 @@ CONFIG += qdbus # Input # DBUS_INTERFACES += car.xml FORMS += controller.ui -HEADERS += car_interface_p.h controller.h +HEADERS += car_interface.h controller.h SOURCES += main.cpp car_interface.cpp controller.cpp # install -- cgit v0.12 From 9a6f11ab7651b6c66771033245906f43a0e651b3 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 29 Jan 2010 10:53:48 -0300 Subject: Fix build due to missing auto-generated files on dbus example Breakage introduced by my previous commit: a1c6fdf0fe5a51b5955ea3fc5f6c3eceee24e0f8 Signed-off-by: Ademar de Souza Reis Jr --- .../dbus/remotecontrolledcar/car/car_adaptor.h | 94 +++++++++++++++++ .../remotecontrolledcar/controller/car_interface.h | 114 +++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 examples/dbus/remotecontrolledcar/car/car_adaptor.h create mode 100644 examples/dbus/remotecontrolledcar/controller/car_interface.h diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.h b/examples/dbus/remotecontrolledcar/car/car_adaptor.h new file mode 100644 index 0000000..d109883 --- /dev/null +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a car_adaptor.h: car.xml +** +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** This is an auto-generated file. +** This file may have been hand-edited. Look for HAND-EDIT comments +** before re-generating it. +** +****************************************************************************/ + +#ifndef CAR_ADAPTOR_H_1264773009 +#define CAR_ADAPTOR_H_1264773009 + +#include +#include +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; + +/* + * Adaptor class for interface com.trolltech.Examples.CarInterface + */ +class CarInterfaceAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + CarInterfaceAdaptor(QObject *parent); + virtual ~CarInterfaceAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + void accelerate(); + void decelerate(); + void turnLeft(); + void turnRight(); +Q_SIGNALS: // SIGNALS + void crashed(); +}; + +#endif diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.h b/examples/dbus/remotecontrolledcar/controller/car_interface.h new file mode 100644 index 0000000..c2d281a --- /dev/null +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p car_interface.h: car.xml +** +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** This is an auto-generated file. +** Do not edit! All changes made to it will be lost. +** +****************************************************************************/ + +#ifndef CAR_INTERFACE_H_1264772826 +#define CAR_INTERFACE_H_1264772826 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.trolltech.Examples.CarInterface + */ +class ComTrolltechExamplesCarInterfaceInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.trolltech.Examples.CarInterface"; } + +public: + ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~ComTrolltechExamplesCarInterfaceInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> accelerate() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("accelerate"), argumentList); + } + + inline QDBusPendingReply<> decelerate() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("decelerate"), argumentList); + } + + inline QDBusPendingReply<> turnLeft() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("turnLeft"), argumentList); + } + + inline QDBusPendingReply<> turnRight() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("turnRight"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void crashed(); +}; + +namespace com { + namespace trolltech { + namespace Examples { + typedef ::ComTrolltechExamplesCarInterfaceInterface CarInterface; + } + } +} +#endif -- cgit v0.12