From 4ac64f787a2d02b89312f2d20ef0b7bac590940d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 5 Feb 2010 19:31:33 +0100 Subject: add qt5 todo Reviewed-by: mariusSO --- src/corelib/tools/qstring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 5e3b0fd..702a21a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -595,7 +595,7 @@ private: struct Data { QBasicAtomicInt ref; int alloc, size; - ushort *data; + ushort *data; // QT5: put that after the bit field to fill alignment gap; don't use sizeof any more then ushort clean : 1; ushort simpletext : 1; ushort righttoleft : 1; -- cgit v0.12 From 167c864121eb36aa3ec8b1e869f95257cb4c3bcd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 8 Dec 2009 20:04:43 +0100 Subject: simplify no need to recalculate a value which we have an own variable for Reviewed-By: mariusSO --- qmake/property.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/property.cpp b/qmake/property.cpp index 34368cd..cab034f 100644 --- a/qmake/property.cpp +++ b/qmake/property.cpp @@ -104,7 +104,7 @@ QMakeProperty::value(QString v, bool just_check) else if(v == "QT_INSTALL_DEMOS") return QLibraryInfo::location(QLibraryInfo::DemosPath); else if(v == "QMAKE_MKSPECS") - return qmake_mkspec_paths().join(Option::target_mode == Option::TARG_WIN_MODE ? ";" : ":"); + return qmake_mkspec_paths().join(Option::dirlist_sep); else if(v == "QMAKE_VERSION") return qmake_version(); #ifdef QT_VERSION_STR -- cgit v0.12 From de8bbaab5b8d85243d3d18c642faef3a826ca672 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 17 Dec 2009 11:52:42 +0100 Subject: remove the most blatant tmake compat paths Reviewed-By: mariusSO --- qmake/generators/makefile.cpp | 2 -- qmake/generators/win32/msvc_vcproj.cpp | 3 +-- qmake/project.cpp | 9 +-------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index b0a8011..991e1ec 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2681,8 +2681,6 @@ MakefileGenerator::writeMakeQmake(QTextStream &t) if(!specdir().isEmpty()) { if(exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf"))) t << escapeDependencyPath(specdir() + Option::dir_sep + "qmake.conf") << " "; - else if(exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"tmake.conf"))) - t << escapeDependencyPath(specdir() + Option::dir_sep + "tmake.conf") << " "; } const QStringList &included = project->values("QMAKE_INTERNAL_INCLUDED_FILES"); t << escapeDependencyPaths(included).join(" \\\n\t\t") << "\n\t" diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 47986f5..3536a02 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1721,8 +1721,7 @@ QString VcprojGenerator::findTemplate(QString file) !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2002/" + file))) && !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2003/" + file))) && !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2005/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2008/" + file))) && - !exists((ret = (QString(qgetenv("HOME")) + "/.tmake/" + file)))) + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2008/" + file)))) return ""; debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.toLatin1().constData()); return ret; diff --git a/qmake/project.cpp b/qmake/project.cpp index 4ce8ba4..04951c3 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -183,9 +183,7 @@ static QString remove_quotes(const QString &arg) static QString varMap(const QString &x) { QString ret(x); - if(ret.startsWith("TMAKE")) //tmake no more! - ret = "QMAKE" + ret.mid(5); - else if(ret == "INTERFACES") + if(ret == "INTERFACES") ret = "FORMS"; else if(ret == "QMAKE_POST_BUILD") ret = "QMAKE_POST_LINK"; @@ -1456,9 +1454,6 @@ QMakeProject::read(uchar cmd) while(qmakespec.endsWith(QString(QChar(QDir::separator())))) qmakespec.truncate(qmakespec.length()-1); QString spec = qmakespec + QDir::separator() + "qmake.conf"; - if(!QFile::exists(spec) && - QFile::exists(qmakespec + QDir::separator() + "tmake.conf")) - spec = qmakespec + QDir::separator() + "tmake.conf"; debug_msg(1, "QMAKESPEC conf: reading %s", spec.toLatin1().constData()); if(!read(spec, base_vars)) { fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.toLatin1().constData()); @@ -3080,8 +3075,6 @@ QStringList &QMakeProject::values(const QString &_var, QMap Date: Wed, 9 Dec 2009 10:17:48 +0100 Subject: remove remainder of mac9 mode Reviewed-by: mariusSO --- qmake/generators/makefile.cpp | 4 +--- qmake/generators/unix/unixmake.cpp | 6 ++---- qmake/option.cpp | 7 +------ qmake/option.h | 2 +- qmake/project.cpp | 11 +---------- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 991e1ec..ae43e2b 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2164,9 +2164,7 @@ QString MakefileGenerator::buildArgs(const QString &outdir) ret += " -nodependheuristics"; if(!Option::mkfile::qmakespec_commandline.isEmpty()) ret += " -spec " + specdir(outdir); - if(Option::target_mode == Option::TARG_MAC9_MODE) - ret += " -mac9"; - else if(Option::target_mode == Option::TARG_MACX_MODE) + if(Option::target_mode == Option::TARG_MACX_MODE) ret += " -macx"; else if(Option::target_mode == Option::TARG_UNIX_MODE) ret += " -unix"; diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index f51c046..b2f0db1 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -778,10 +778,8 @@ UnixMakefileGenerator::defaultInstall(const QString &t) uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); if(!links.isEmpty()) { for(int i = 0; i < links.size(); ++i) { - if(Option::target_mode == Option::TARG_WIN_MODE || - Option::target_mode == Option::TARG_MAC9_MODE) { - } else if(Option::target_mode == Option::TARG_UNIX_MODE || - Option::target_mode == Option::TARG_MACX_MODE) { + if(Option::target_mode == Option::TARG_UNIX_MODE || + Option::target_mode == Option::TARG_MACX_MODE) { QString link = Option::fixPathToTargetOS(destdir + links[i], false); int lslash = link.lastIndexOf(Option::dir_sep); if(lslash != -1) diff --git a/qmake/option.cpp b/qmake/option.cpp index 5e06721..18f0541 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -250,8 +250,6 @@ Option::parseCommandLine(int argc, char **argv, int skip) Option::user_template = argv[++x]; } else if(opt == "tp" || opt == "template_prefix") { Option::user_template_prefix = argv[++x]; - } else if(opt == "mac9") { - Option::target_mode = TARG_MAC9_MODE; } else if(opt == "macx") { Option::target_mode = TARG_MACX_MODE; } else if(opt == "unix") { @@ -532,10 +530,7 @@ Option::init(int argc, char **argv) Option::obj_ext = ".obj"; Option::res_ext = ".res"; } else { - if(Option::target_mode == Option::TARG_MAC9_MODE) - Option::dir_sep = ":"; - else - Option::dir_sep = "/"; + Option::dir_sep = "/"; Option::obj_ext = ".o"; } Option::qmake_abslocation = Option::fixPathToTargetOS(Option::qmake_abslocation); diff --git a/qmake/option.h b/qmake/option.h index fe9a4ef..514e442 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -150,7 +150,7 @@ struct Option static int warn_level; static bool recursive; static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs; - enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE }; + enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE }; static TARG_MODE target_mode; static QString user_template, user_template_prefix; static QStringList shellPath; diff --git a/qmake/project.cpp b/qmake/project.cpp index 04951c3..8871152 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -610,10 +610,6 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0) concat << base_concat + QDir::separator() + "win32"; break; } - case Option::TARG_MAC9_MODE: - concat << base_concat + QDir::separator() + "mac"; - concat << base_concat + QDir::separator() + "mac9"; - break; } concat << base_concat; } @@ -1612,12 +1608,7 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QMap Date: Wed, 9 Dec 2009 10:21:45 +0100 Subject: remove weird -tp ce matching line nobody can say anything about Reviewed-by: mariusSO --- qmake/generators/metamakefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 4151193..8dde309 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -466,7 +466,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) mkfile = new NmakeMakefileGenerator; } else if(gen == "MSVC.NET") { // Visual Studio >= v7.0 - if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1 || proj->first("TEMPLATE").indexOf(QRegExp("^ce.*")) != -1) + if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1) mkfile = new VcprojGenerator; else mkfile = new NmakeMakefileGenerator; -- cgit v0.12 From 99f390f9b784aa7e34f3e46f30a38280af66bba8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 15 Dec 2009 11:44:10 +0100 Subject: purge msvc6 suppport from qmake. qt doesn't support it for quite a while now. Acked-by: mariusSO --- mkspecs/win32-icc/qmake.conf | 2 +- mkspecs/win32-msvc/features/incremental.prf | 2 - mkspecs/win32-msvc/features/incremental_off.prf | 2 - mkspecs/win32-msvc/qmake.conf | 86 -- mkspecs/win32-msvc/qplatformdefs.h | 138 --- qmake/Makefile.unix | 5 +- qmake/Makefile.win32 | 6 +- qmake/Makefile.win32-g++ | 5 +- qmake/Makefile.win32-g++-sh | 5 +- qmake/generators/metamakefile.cpp | 8 - qmake/generators/win32/msvc_dsp.cpp | 1207 ----------------------- qmake/generators/win32/msvc_dsp.h | 122 --- qmake/qmake.pri | 4 +- 13 files changed, 7 insertions(+), 1585 deletions(-) delete mode 100644 mkspecs/win32-msvc/features/incremental.prf delete mode 100644 mkspecs/win32-msvc/features/incremental_off.prf delete mode 100644 mkspecs/win32-msvc/qmake.conf delete mode 100644 mkspecs/win32-msvc/qplatformdefs.h delete mode 100644 qmake/generators/win32/msvc_dsp.cpp delete mode 100644 qmake/generators/win32/msvc_dsp.h diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf index 78c947d..fcc7691 100644 --- a/mkspecs/win32-icc/qmake.conf +++ b/mkspecs/win32-icc/qmake.conf @@ -4,7 +4,7 @@ # Written for Intel C++ # -MAKEFILE_GENERATOR = MSVC +MAKEFILE_GENERATOR = MSVC.NET TEMPLATE = app CONFIG += qt warn_on release incremental flat link_prl copy_dir_files debug_and_release debug_and_release_target QT += core gui diff --git a/mkspecs/win32-msvc/features/incremental.prf b/mkspecs/win32-msvc/features/incremental.prf deleted file mode 100644 index 67596ca..0000000 --- a/mkspecs/win32-msvc/features/incremental.prf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG -= incremental_off -QMAKE_LFLAGS_DEBUG += /incremental:yes diff --git a/mkspecs/win32-msvc/features/incremental_off.prf b/mkspecs/win32-msvc/features/incremental_off.prf deleted file mode 100644 index 9b6d19e..0000000 --- a/mkspecs/win32-msvc/features/incremental_off.prf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG -= incremental -QMAKE_LFLAGS += /incremental:no diff --git a/mkspecs/win32-msvc/qmake.conf b/mkspecs/win32-msvc/qmake.conf deleted file mode 100644 index 64ab84a..0000000 --- a/mkspecs/win32-msvc/qmake.conf +++ /dev/null @@ -1,86 +0,0 @@ -# -# qmake configuration for win32-msvc -# -# Written for Microsoft C++ -# - -MAKEFILE_GENERATOR = MSVC -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header copy_dir_files no_delete_multiple_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1200 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O1 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -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_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -GX -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -GX -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:console -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:windows -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS = -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib advapi32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib delayimp.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -DSP_EXTENSION = .dsp -load(qt_config) diff --git a/mkspecs/win32-msvc/qplatformdefs.h b/mkspecs/win32-msvc/qplatformdefs.h deleted file mode 100644 index abb5894..0000000 --- a/mkspecs/win32-msvc/qplatformdefs.h +++ /dev/null @@ -1,138 +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 QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct _stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stat // non-ANSI defs -#define QT_STAT ::_stat -#define QT_FSTAT ::_fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO _fileno -#define QT_OPEN ::_open -#define QT_CLOSE ::_close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::_lseek -#define QT_TSTAT ::_tstat -#endif -#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 -#if defined(O_TEXT) -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY -#endif - -#include "../common/c89/qplatformdefs.h" - -#ifdef QT_LARGEFILE_SUPPORT -#undef QT_OFF_T -#define QT_OFF_T __int64 -#endif - -#define QT_SIGNAL_ARGS int - -#if defined(_MSC_VER) && _MSC_VER < 1400 -# define QT_VSNPRINTF ::_vsnprintf -#endif -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - - -#endif // QPLATFORMDEFS_H diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index fcf43c8..5e3190d 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -9,7 +9,7 @@ LFLAGS = @QMAKE_LFLAGS@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ mingw_make.o option.o winmakefile.o projectgenerator.o \ meta.o makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ - borland_bmake.o msvc_dsp.o msvc_vcproj.o msvc_nmake.o msvc_objectmodel.o \ + borland_bmake.o msvc_vcproj.o msvc_nmake.o msvc_objectmodel.o \ symmake.o initprojectdeploy_symbian.o symmake_abld.o symmake_sbsv2.o #qt code @@ -266,9 +266,6 @@ msvc_nmake.o: generators/win32/msvc_nmake.cpp pbuilder_pbx.o: generators/mac/pbuilder_pbx.cpp $(CXX) -c -o $@ $(CXXFLAGS) generators/mac/pbuilder_pbx.cpp -msvc_dsp.o: generators/win32/msvc_dsp.cpp - $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_dsp.cpp - symmake.o: generators/symbian/symmake.cpp $(CXX) -c -o $@ $(CXXFLAGS) generators/symbian/symmake.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index e6bbcd5..1f3092a 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -73,7 +73,7 @@ ADDCLEAN = qmake.tds OBJS = project.obj main.obj makefile.obj unixmake.obj unixmake2.obj mingw_make.obj \ option.obj winmakefile.obj projectgenerator.obj property.obj meta.obj \ makefiledeps.obj metamakefile.obj xmloutput.obj pbuilder_pbx.obj \ - borland_bmake.obj msvc_nmake.obj msvc_dsp.obj msvc_vcproj.obj \ + borland_bmake.obj msvc_nmake.obj msvc_vcproj.obj \ msvc_objectmodel.obj symmake.obj initprojectdeploy_symbian.obj \ symmake_abld.obj symmake_sbsv2.obj @@ -191,7 +191,6 @@ clean:: -del xmloutput.obj -del borland_bmake.obj -del msvc_nmake.obj - -del msvc_dsp.obj -del msvc_vcproj.obj -del msvc_objectmodel.obj -del symmake.obj @@ -376,9 +375,6 @@ mingw_make.obj: $(SOURCE_PATH)/qmake/generators/win32/mingw_make.cpp msvc_nmake.obj: $(SOURCE_PATH)/qmake/generators/win32/msvc_nmake.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_nmake.cpp -msvc_dsp.obj: $(SOURCE_PATH)/qmake/generators/win32/msvc_dsp.cpp - $(CXX) $(CXXFLAGS) generators/win32/msvc_dsp.cpp - msvc_vcproj.obj: $(SOURCE_PATH)/qmake/generators/win32/msvc_vcproj.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_vcproj.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index ade379b..41a1d8c 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -36,7 +36,7 @@ ADDCLEAN = OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ option.o winmakefile.o projectgenerator.o property.o meta.o \ makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ - borland_bmake.o msvc_nmake.o msvc_dsp.o msvc_vcproj.o \ + borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ symmake_abld.o symmake_sbsv2.o @@ -257,9 +257,6 @@ mingw_make.o: $(SOURCE_PATH)/qmake/generators/win32/mingw_make.cpp msvc_nmake.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_nmake.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_nmake.cpp -msvc_dsp.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_dsp.cpp - $(CXX) $(CXXFLAGS) generators/win32/msvc_dsp.cpp - msvc_vcproj.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_vcproj.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_vcproj.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 8d2723c..0b08320 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -36,7 +36,7 @@ ADDCLEAN = OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ option.o winmakefile.o projectgenerator.o property.o meta.o \ makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ - borland_bmake.o msvc_nmake.o msvc_dsp.o msvc_vcproj.o \ + borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ symmake_abld.o symmake_sbsv2.o @@ -256,9 +256,6 @@ mingw_make.o: $(SOURCE_PATH)/qmake/generators/win32/mingw_make.cpp msvc_nmake.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_nmake.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_nmake.cpp -msvc_dsp.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_dsp.cpp - $(CXX) $(CXXFLAGS) generators/win32/msvc_dsp.cpp - msvc_vcproj.o: $(SOURCE_PATH)/qmake/generators/win32/msvc_vcproj.cpp $(CXX) $(CXXFLAGS) generators/win32/msvc_vcproj.cpp diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 8dde309..f48491c 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -432,7 +432,6 @@ QT_BEGIN_INCLUDE_NAMESPACE #include "pbuilder_pbx.h" #include "msvc_nmake.h" #include "borland_bmake.h" -#include "msvc_dsp.h" #include "msvc_vcproj.h" #include "symmake_abld.h" #include "symmake_sbsv2.h" @@ -458,14 +457,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) mkfile = new MingwMakefileGenerator; } else if(gen == "PROJECTBUILDER" || gen == "XCODE") { mkfile = new ProjectBuilderMakefileGenerator; - } else if(gen == "MSVC") { - // Visual Studio =< v6.0 - if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1) - mkfile = new DspMakefileGenerator; - else - mkfile = new NmakeMakefileGenerator; } else if(gen == "MSVC.NET") { - // Visual Studio >= v7.0 if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1) mkfile = new VcprojGenerator; else diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp deleted file mode 100644 index 9c8dd1d..0000000 --- a/qmake/generators/win32/msvc_dsp.cpp +++ /dev/null @@ -1,1207 +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 application 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 "msvc_dsp.h" -#include "option.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -DspMakefileGenerator::DspMakefileGenerator() : Win32MakefileGenerator(), init_flag(false) -{ -} - -bool DspMakefileGenerator::writeMakefile(QTextStream &t) -{ - if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) { - /* for now just dump, I need to generated an empty dsp or something.. */ - fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", - var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData()); - return true; - } - - // Generate workspace file - if(project->first("TEMPLATE") == "vcsubdirs") { - if (!project->isActiveConfig("build_pass")) { - debug_msg(1, "Generator: MSVC: Writing workspave file"); - writeSubDirs(t); - } else { - debug_msg(1, "Generator: MSVC: Not writing workspace file for build_pass configs"); - } - return true; - } else if (project->first("TEMPLATE") == "vcapp" || project->first("TEMPLATE") == "vclib") { - if(!project->isActiveConfig("build_pass")) - return writeDspParts(t); - return true; - } - return project->isActiveConfig("build_pass"); -} - -bool DspMakefileGenerator::hasBuiltinCompiler(const QString &filename) const -{ - for (int i = 0; i < Option::cpp_ext.count(); ++i) - if (filename.endsWith(Option::cpp_ext.at(i))) - return true; - for (int i = 0; i < Option::c_ext.count(); ++i) - if (filename.endsWith(Option::c_ext.at(i))) - return true; - return false; -} - -QString DspMakefileGenerator::replaceExtraCompilerVariables(const QString &var, const QStringList &in, const QStringList &out) -{ - QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out); - ret.replace("$(DEFINES)", varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") + - varGlue("DEFINES"," -D"," -D","")); - - QString incpath = this->var("MSVCDSP_INCPATH"); - incpath.replace("/I", "-I"); - ret.replace("$(INCPATH)", incpath); - return ret; -} - - -// if config is part of a multibuild thenthe gule (this) has the correct MSVCDSP_PROJECT -QString DspMakefileGenerator::configName(DspMakefileGenerator * config) -{ - return var("MSVCDSP_PROJECT") + config->var("MSVCDSP_CONFIG_NAME"); -} - -bool DspMakefileGenerator::writeDspHeader(QTextStream &t) -{ - DspMakefileGenerator * config = this; - if (mergedProjects.count()) - config = mergedProjects.at(0); - - t << "# Microsoft Developer Studio Project File - Name=\"" << var("MSVCDSP_PROJECT") << "\" - Package Owner=<4>" << endl; - t << "# Microsoft Developer Studio Generated Build File, Format Version 6.00" << endl; - t << "# ** DO NOT EDIT **" << endl; - t << endl; - t << "# TARGTYPE \"Win32 (x86) " << var("MSVCDSP_TARGETTYPE") << "\" " << var("MSVCDSP_DSPTYPE") << endl; - t << endl; - t << "CFG=\"" << configName(config) << "\"" << endl; - t << "!MESSAGE This is not a valid makefile. To build this project using NMAKE," << endl; - t << "!MESSAGE use the Export Makefile command and run" << endl; - t << "!MESSAGE " << endl; - t << "!MESSAGE NMAKE /f " << escapeFilePath(var("TARGET")) << ".mak." << endl; - t << "!MESSAGE " << endl; - t << "!MESSAGE You can specify a configuration when running NMAKE" << endl; - t << "!MESSAGE by defining the macro CFG on the command line. For example:" << endl; - t << "!MESSAGE " << endl; - t << "!MESSAGE NMAKE /f " << escapeFilePath(var("TARGET")) << ".mak CFG=\"" << configName(config) << "\"" << endl; - t << "!MESSAGE " << endl; - t << "!MESSAGE Possible choices for configuration are:" << endl; - t << "!MESSAGE " << endl; - if (mergedProjects.count()) { - for (int i = 0; i < mergedProjects.count(); ++i) { - DspMakefileGenerator * config = mergedProjects.at(i); - t << "!MESSAGE \"" << configName(config) << "\" (based on \"Win32 (x86) " << config->var("MSVCDSP_TARGETTYPE") << "\")" << endl; - } - } else { - t << "!MESSAGE \"" << configName(config) << "\" (based on \"Win32 (x86) " << config->var("MSVCDSP_TARGETTYPE") << "\")" << endl; - } - t << "!MESSAGE " << endl; - t << endl; - t << "# Begin Project" << endl; - t << "# PROP AllowPerConfigDependencies 0" << endl; - t << "# PROP Scc_ProjName \"\"" << endl; - t << "# PROP Scc_LocalPath \"\"" << endl; - t << "CPP=" << config->var("QMAKE_CC") << endl; - t << "MTL=" << config->var("QMAKE_IDL") << endl; - t << "RSC=" << config->var("QMAKE_RC") << endl; - t << "BSC32=bscmake.exe" << endl; - - return true; -} - - -bool DspMakefileGenerator::writeDspParts(QTextStream &t) -{ - //bool staticLibTarget = var("MSVCDSP_DSPTYPE") == "0x0104"; - - writeDspHeader(t); - writeDspConfig(t, this); - t << endl; - t << "# Begin Target" << endl; - t << endl; - t << "# Name \"" << configName(this) << "\"" << endl; - t << endl; - - - QStringList listNames = QString("SOURCES|DEF_FILE").split("|"); - QStringList allListNames = listNames; - writeFileGroup(t, listNames, "Source Files", "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"); - listNames = QStringList("HEADERS"); - allListNames += listNames; - writeFileGroup(t, QStringList("HEADERS"), "Header Files", "h;hpp;hxx;hm;inl"); - listNames = QString("FORMS|INTERFACES|FORMS3").split("|"); - allListNames += listNames; - writeFileGroup(t, listNames, "Form Files", "ui"); - listNames = QStringList("IMAGES"); - allListNames += listNames; - writeFileGroup(t, QStringList("IMAGES"), "Image Files", ""); - listNames = QString("RC_FILE|RESOURCES").split("|"); - allListNames += listNames; - writeFileGroup(t, listNames, "Resources", "rc;qrc"); - listNames = QStringList("TRANSLATIONS"); - allListNames += listNames; - writeFileGroup(t, listNames, "Translations", "ts;xlf"); - listNames = QStringList("LEXSOURCES"); - allListNames += listNames; - writeFileGroup(t, listNames, "Lexables", "l"); - listNames = QStringList("YACCSOURCES"); - allListNames += listNames; - writeFileGroup(t, listNames, "Yaccables", "y"); - listNames = QStringList("TYPELIBS"); - allListNames += listNames; - writeFileGroup(t, listNames, "Type Libraries", "tlb;olb"); - - if (!project->isEmpty("QMAKE_EXTRA_COMPILERS")) { - const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); - for (QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { - const QStringList &inputs = project->values((*it)+".input"); - for (QStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) { - if (!allListNames.contains((*input)) && *input != "UIC3_HEADERS") - writeFileGroup(t, QStringList((*input)), (*input) + " Files", ""); - } - } - } - - project->values("SWAPPED_BUILD_STEPS") = swappedBuildSteps.keys(); - - writeFileGroup(t, QString("GENERATED_SOURCES|GENERATED_FILES|SWAPPED_BUILD_STEPS").split("|"), "Generated", ""); - - t << "# End Target" << endl; - t << "# End Project" << endl; - return true; -} - -void -DspMakefileGenerator::init() -{ - if(init_flag) - return; - QStringList::Iterator it; - init_flag = true; - - platform = "Win32"; - if(!project->values("QMAKE_PLATFORM").isEmpty()) - platform = varGlue("QMAKE_PLATFORM", "", " ", ""); - - // this should probably not be here, but I'm using it to wrap the .t files - if(project->first("TEMPLATE") == "vcapp") - project->values("QMAKE_APP_FLAG").append("1"); - else if(project->first("TEMPLATE") == "vclib") - project->values("QMAKE_LIB_FLAG").append("1"); - - if(project->values("QMAKESPEC").isEmpty()) - project->values("QMAKESPEC").append(qgetenv("QMAKESPEC")); - - project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); - processVars(); - - if(!project->values("VERSION").isEmpty()) { - QString version = project->values("VERSION").first(); - int firstDot = version.indexOf("."); - QString major = version.left(firstDot); - QString minor = version.right(version.length() - firstDot - 1); - minor.replace(".", ""); - project->values("MSVCDSP_LFLAGS").append("/VERSION:" + major + "." + minor); - } - - QString msvcdsp_project; - if(!project->isEmpty("TARGET")) { - project->values("TARGET") = unescapeFilePaths(project->values("TARGET")); - msvcdsp_project = project->first("TARGET"); - } - - MakefileGenerator::init(); - - if(msvcdsp_project.isEmpty()) - msvcdsp_project = Option::output.fileName(); - - msvcdsp_project = msvcdsp_project.right(msvcdsp_project.length() - msvcdsp_project.lastIndexOf("\\") - 1); - int dotFind = msvcdsp_project.lastIndexOf("."); - if(dotFind != -1) - msvcdsp_project = msvcdsp_project.left(dotFind); - msvcdsp_project.replace("-", ""); - - project->values("MSVCDSP_PROJECT").append(msvcdsp_project); - - QStringList &proj = project->values("MSVCDSP_PROJECT"); - - for(QStringList::Iterator it = proj.begin(); it != proj.end(); ++it) - (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); - - if(!project->values("QMAKE_APP_FLAG").isEmpty()) { - if(project->isActiveConfig("console")) { - project->values("MSVCDSP_TARGETTYPE").append("Console Application"); - project->values("MSVCDSP_DSPTYPE").append("0x0103"); - project->values("MSVCDSP_DEFINES").append(" /D \"_CONSOLE\" "); - } else { - project->values("MSVCDSP_TARGETTYPE").append("Application"); - project->values("MSVCDSP_DSPTYPE").append("0x0101"); - project->values("MSVCDSP_DEFINES").append(" /D \"_WINDOWS\" "); - } - } else { - if(project->isActiveConfig("dll")) { - project->values("MSVCDSP_TARGETTYPE").append("Dynamic-Link Library"); - project->values("MSVCDSP_DSPTYPE").append("0x0102"); - project->values("MSVCDSP_DEFINES").append(" /D \"_USRDLL\" "); - } else { - project->values("MSVCDSP_TARGETTYPE").append("Static Library"); - project->values("MSVCDSP_DSPTYPE").append("0x0104"); - project->values("MSVCDSP_DEFINES").append(" /D \"_LIB\" "); - } - } - - project->values("MSVCDSP_LFLAGS") += project->values("QMAKE_LFLAGS"); - - if(!project->values("QMAKE_LIBDIR").isEmpty()) - project->values("MSVCDSP_LFLAGS").append(valGlue( - escapeFilePaths(project->values("QMAKE_LIBDIR")), - "/LIBPATH:"," /LIBPATH:","")); - - project->values("MSVCDSP_DEFINES").append(varGlue("DEFINES","/D ","" " /D ","")); - project->values("MSVCDSP_DEFINES").append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); - project->values("MSVCDSP_DEFINES").append(" /D \"WIN32\" "); - - QStringList &libs = project->values("QMAKE_LIBS"); - for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { - project->values("MSVCDSP_LIBS").append(" " + escapeFilePath(*libit)); - } - - QStringList &incs = project->values("INCLUDEPATH"); - for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { - QString inc = (*incit); - project->values("MSVCDSP_INCPATH").append("/I" + escapeFilePath(inc)); - } - project->values("MSVCDSP_INCPATH").append("/I" + escapeFilePath(specdir())); - - QString dest; - QString preLinkStep; - QString postLinkStep; - QString copyDllStep; - - if(!project->values("QMAKE_PRE_LINK").isEmpty()) - preLinkStep += var("QMAKE_PRE_LINK"); - - if(!project->values("QMAKE_POST_LINK").isEmpty()) - postLinkStep += var("QMAKE_POST_LINK"); - - // don't destroy the target, it is used by prl writer. - if(!project->values("DESTDIR").isEmpty()) { - dest = project->first("DESTDIR"); - project->values("DESTDIR").first() = dest; - dest = project->values("TARGET").first() + project->first("TARGET_EXT"); - dest.prepend(project->first("DESTDIR")); - Option::fixPathToTargetOS(dest); - dest = escapeFilePath(dest); - - project->values("MSVCDSP_TARGET").append( - QString("/out:") + dest); - if(project->isActiveConfig("dll")) { - QString imp = dest; - imp.replace(".dll", ".lib"); - project->values("MSVCDSP_TARGET").append(QString(" /implib:") + escapeFilePath(imp)); - } - } - - if(project->isActiveConfig("dll") && !project->values("DLLDESTDIR").isEmpty()) { - QStringList dlldirs = project->values("DLLDESTDIR"); - if(dlldirs.count()) - copyDllStep += "\t"; - for(QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) { - copyDllStep += "copy \"$(TargetPath)\" " + escapeFilePath(Option::fixPathToTargetOS(*dlldir)) + "\t"; - } - } - - if(!preLinkStep.isEmpty()) { - project->values("MSVCDSP_PRE_LINK").append( - "# Begin Special Build Tool\n" - "SOURCE=$(InputPath)\n" - "PreLink_Desc=Post Build Step\n" - "PreLink_Cmds=" + preLinkStep + "\n" - "# End Special Build Tool\n"); - } - - if(!postLinkStep.isEmpty() || !copyDllStep.isEmpty()) { - project->values("MSVCDSP_POST_LINK").append( - "# Begin Special Build Tool\n" - "SOURCE=$(InputPath)\n" - "PostBuild_Desc=Post Build Step\n" - "PostBuild_Cmds=" + postLinkStep + copyDllStep + "\n" - "# End Special Build Tool\n"); - } - - QStringList &formList = project->values("FORMS"); - for(QStringList::ConstIterator hit = formList.begin(); hit != formList.end(); ++hit) { - if(exists(*hit + ".h")) - project->values("SOURCES").append(*hit + ".h"); - } - QStringList &form3List = project->values("FORMS3"); - for(QStringList::ConstIterator hit = form3List.begin(); hit != form3List.end(); ++hit) { - if(exists(*hit + ".h")) - project->values("SOURCES").append(*hit + ".h"); - } - - project->values("QMAKE_INTERNAL_PRL_LIBS") << "MSVCDSP_LIBS"; - - // Move some files around //### is this compat? - if (!project->values("IMAGES").isEmpty()) { - QString imageFactory(project->first("QMAKE_IMAGE_COLLECTION")); - project->values("GENERATED_SOURCES") += imageFactory; - project->values("SOURCES").removeAll(imageFactory); - } - - // Setup PCH variables - precompH = project->first("PRECOMPILED_HEADER"); - namePCH = fileInfo(precompH).fileName(); - usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); - if (usePCH) { - // Created files - precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext; - precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch"; - - // Add PRECOMPILED_HEADER to HEADERS - if (!project->values("HEADERS").contains(precompH)) - project->values("HEADERS") += precompH; - // Add precompile compiler options - project->values("PRECOMPILED_FLAGS") = QStringList("/Fp" + precompPch + " /Yu" + escapeFilePath(namePCH) + " /FI" + escapeFilePath(namePCH) + " "); - // Return to variable pool - project->values("PRECOMPILED_OBJECT") = QStringList(precompObj); - project->values("PRECOMPILED_PCH") = QStringList(precompPch); - } - - QString buildName; - if (!var("BUILD_NAME").isEmpty()) - buildName = var("BUILD_NAME"); - else if (project->isActiveConfig("debug")) - buildName = "Debug"; - else - buildName = "Release"; - - project->values("MSVCDSP_CONFIG_NAME") = QStringList(" - " + platform + " " + buildName); -} - -void DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) -{ - if(var == "QMAKE_PRL_DEFINES") { - QStringList &out = project->values("MSVCDSP_DEFINES"); - for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { - if(out.indexOf((*it)) == -1) - out.append((" /D \"" + *it + "\"")); - } - } else { - MakefileGenerator::processPrlVariable(var, l); - } -} - -bool DspMakefileGenerator::openOutput(QFile &file, const QString &build) const -{ - QString outdir; - if(!file.fileName().isEmpty()) { - if(QDir::isRelativePath(file.fileName())) - file.setFileName(Option::output_dir + "/" + file.fileName()); //pwd when qmake was run - QFileInfo fi(fileInfo(file.fileName())); - if(fi.isDir()) - outdir = file.fileName() + QDir::separator(); - } - - if(!outdir.isEmpty() || file.fileName().isEmpty()) { - QString ext = project->first("DSP_EXTENSION"); - if(project->first("TEMPLATE") == "vcsubdirs") { - if (!project->first("DSW_EXTENSION").isEmpty()) - ext = project->first("DSW_EXTENSION"); - else - ext = ".dsw"; - } - QString outputName = unescapeFilePath(project->first("QMAKE_DSP_PROJECT_NAME")); - if (!project->first("MAKEFILE").isEmpty()) - outputName = unescapeFilePath(project->first("MAKEFILE")); - if (outputName.isEmpty()) - outputName = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); - file.setFileName(outdir + outputName + ext); - } - - if(QDir::isRelativePath(file.fileName())) { - QString ofile = Option::fixPathToLocalOS(file.fileName()); - int slashfind = ofile.lastIndexOf(Option::dir_sep); - if(slashfind == -1) { - ofile = ofile.replace(QRegExp("-"), "_"); - } else { - int hypenfind = ofile.indexOf('-', slashfind); - while (hypenfind != -1 && slashfind < hypenfind) { - ofile = ofile.replace(hypenfind, 1, "_"); - hypenfind = ofile.indexOf('-', hypenfind + 1); - } - } - file.setFileName(Option::fixPathToLocalOS(qmake_getpwd() + Option::dir_sep + ofile)); - } - return Win32MakefileGenerator::openOutput(file, build); -} - -bool DspMakefileGenerator::mergeBuildProject(MakefileGenerator *other) -{ - - mergedProjects.prepend(static_cast(other)); - return true; -} - -bool DspMakefileGenerator::writeProjectMakefile() -{ - bool ret = true; - - QTextStream t(&Option::output); - // Check if all requirements are fulfilled - if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) { - fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", - var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData()); - return true; - } - - // Generate project file - if(project->first("TEMPLATE") == "vcapp" || - project->first("TEMPLATE") == "vclib") { - if (!mergedProjects.count()) { - warn_msg(WarnLogic, "Generator: MSVC DSP: no single configuration created, cannot output project!"); - return false; - } - debug_msg(1, "Generator: MSVC 6: Writing project file"); - - writeDspHeader(t); - for (int i = 0; i < mergedProjects.count(); ++i) { - DspMakefileGenerator* config = mergedProjects.at(i); - t << endl; - if (i == 0) - t << "!IF"; - else - t << "!ELSEIF"; - t << " \"$(CFG)\" == \"" << configName(config) << "\"" << endl; - t << endl; - writeDspConfig(t, config); - } - t << endl; - t << "!ENDIF " << endl; - t << endl; - t << "# Begin Target" << endl; - t << endl; - for (int i = 0; i < mergedProjects.count(); ++i) - t << "# Name \"" << configName(mergedProjects.at(i)) << "\"" << endl; - t << endl; - - QMap< QString, QSet > files; - - // merge source files - for (int i = 0; i < mergedProjects.count(); ++i) { - - DspMakefileGenerator* config = mergedProjects.at(i); - - files["DEF_FILE"] += config->project->values("DEF_FILE").toSet(); - files["SOURCES"] += config->project->values("SOURCES").toSet(); - files["HEADERS"] += config->project->values("HEADERS").toSet(); - files["INTERFACES"] += config->project->values("INTERFACES").toSet(); - files["FORMS"] += config->project->values("FORMS").toSet(); - files["FORMS"] += config->project->values("FORMS3").toSet(); - files["IMAGES"] += config->project->values("IMAGES").toSet(); - files["RC_FILE"] += config->project->values("RC_FILE").toSet(); - files["RESOURCES"] += config->project->values("RESOURCES").toSet(); - files["TRANSLATIONS"] += config->project->values("TRANSLATIONS").toSet(); - files["LEXSOURCES"] += config->project->values("LEXSOURCES").toSet(); - files["YACCSOURCES"] += config->project->values("YACCSOURCES").toSet(); - files["TYPELIBS"] += config->project->values("TYPELIBS").toSet(); - - if (!config->project->isEmpty("QMAKE_EXTRA_COMPILERS")) { - const QStringList &quc = config->project->values("QMAKE_EXTRA_COMPILERS"); - for (QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { - const QStringList &inputs = project->values((*it)+".input"); - for (QStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) { - if (*input != "UIC3_HEADERS") - files[(*input)] += config->project->values((*input)).toSet(); - } - } - } - } - - QStringList keys = files.keys(); - for (int k = 0; k < keys.size(); ++k) - project->values(keys.at(k)) = QList::fromSet(files[keys.at(k)]); - - QStringList listNames = QString("SOURCES|DEF_FILE").split("|"); - QStringList allListNames = listNames; - writeFileGroup(t, listNames, "Source Files", "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"); - listNames = QStringList("HEADERS"); - allListNames += listNames; - writeFileGroup(t, listNames, "Header Files", "h;hpp;hxx;hm;inl"); - listNames = QString("FORMS|INTERFACES|FORMS3").split("|"); - allListNames += listNames; - writeFileGroup(t, listNames, "Form Files", "ui"); - listNames = QStringList("IMAGES"); - allListNames += listNames; - writeFileGroup(t, listNames, "Image Files", ""); - listNames = QString("RC_FILE|RESOURCES").split("|"); - allListNames += listNames; - writeFileGroup(t, listNames, "Resources", "rc;qrc"); - listNames = QStringList("TRANSLATIONS"); - allListNames += listNames; - writeFileGroup(t, listNames, "Translations", "ts;xlf"); - listNames = QStringList("LEXSOURCES"); - allListNames += listNames; - writeFileGroup(t, listNames, "Lexables", "l"); - listNames = QStringList("YACCSOURCES"); - allListNames += listNames; - writeFileGroup(t, listNames, "Yaccables", "y"); - listNames = QStringList("TYPELIBS"); - allListNames += listNames; - writeFileGroup(t, listNames, "Type Libraries", "tlb;olb"); - - for (int l = 0; l < allListNames.size(); ++l) - keys.removeAll(allListNames.at(l)); - - for (int k = 0; k < keys.size(); ++k) - writeFileGroup(t, QStringList(keys.at(k)), keys.at(k) + " Files", ""); - - // done last as generated may have changed when creating build rules for the above - for (int i = 0; i < mergedProjects.count(); ++i) { - - DspMakefileGenerator* config = mergedProjects.at(i); - - config->project->values("SWAPPED_BUILD_STEPS") = config->swappedBuildSteps.keys(); - files["SWAPPED_BUILD_STEPS"] += config->project->values("SWAPPED_BUILD_STEPS").toSet(); - - files["GENERATED_SOURCES"] += config->project->values("GENERATED_SOURCES").toSet(); - files["GENERATED_FILES"] += config->project->values("GENERATED_FILES").toSet(); - } - - project->values("SWAPPED_BUILD_STEPS") = QList::fromSet(files["SWAPPED_BUILD_STEPS"]); - project->values("GENERATED_SOURCES") = QList::fromSet(files["GENERATED_SOURCES"]); - project->values("GENERATED_FILES") = QList::fromSet(files["GENERATED_FILES"]); - - writeFileGroup(t, QString("GENERATED_SOURCES|GENERATED_FILES|SWAPPED_BUILD_STEPS").split("|"), "Generated", ""); - t << endl; - t << "# End Target" << endl; - t << "# End Project" << endl; - }else if(project->first("TEMPLATE") == "vcsubdirs") { - ret = writeMakefile(t); - } - - return ret; -} - -const char _dswHeader60[] = "Microsoft Developer Studio Workspace File, Format Version 6.00\n"; -const char _dswWarning[] = "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n"; -const char _dswDevider[] = "###############################################################################\n"; -const char _dswProjectName[] = "Project: \"%1\"=%2 - Package Owner=<4>\n"; // %1 = project name, %2 = project path -const char _dswPackage5Start[] = "Package=<5>\n{{{\n"; -const char _dswPackage5Stop[] = "}}}\n"; -const char _dswPackage4Start[] = "Package=<4>\n{{{\n"; -const char _dswPackage4Stop[] = "}}}\n"; -const char _dswProjectDep[] = " Begin Project Dependency\n Project_Dep_Name %1\n End Project Dependency\n"; // %1 = project name -const char _dswGlobal[] = "Global:\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<3>\n{{{\n}}}\n\n"; - - -struct WorkspaceDepend { - QString dspProjectFile, orig_target, target; - QStringList dependencies; -}; - -void DspMakefileGenerator::writeSubDirs(QTextStream &t) -{ - // Output headers - t << _dswHeader60; - t << _dswWarning; - t << endl; - - QHash workspace_depends; - QList workspace_cleanup; - QStringList subdirs = project->values("SUBDIRS"); - QString oldpwd = qmake_getpwd(); - - // Make sure that all temp projects are configured - // for release so that the depends are created - // without the debug dxxx.lib name mangling - QStringList old_after_vars = Option::after_user_vars; - Option::after_user_vars.append("CONFIG+=release"); - - for(int i = 0; i < subdirs.size(); ++i) { - QString tmp = subdirs.at(i); - if(!project->isEmpty(tmp + ".file")) { - if(!project->isEmpty(tmp + ".subdir")) - warn_msg(WarnLogic, "Cannot assign both file and subdir for subdir %s", - tmp.toLatin1().constData()); - tmp = project->first(tmp + ".file"); - } else if(!project->isEmpty(tmp + ".subdir")) { - tmp = project->first(tmp + ".subdir"); - } - - QFileInfo fi(fileInfo(Option::fixPathToLocalOS(tmp, true))); - if(fi.exists()) { - if(fi.isDir()) { - QString profile = tmp; - if(!profile.endsWith(Option::dir_sep)) - profile += Option::dir_sep; - profile += fi.baseName() + Option::pro_ext; - subdirs.append(profile); - } else { - QMakeProject tmp_proj; - QString dir = fi.path(), fn = fi.fileName(); - if(!dir.isEmpty()) { - if(!qmake_setpwd(dir)) - fprintf(stderr, "Cannot find directory: %s\n", dir.toLatin1().constData()); - } - if(tmp_proj.read(fn)) { - // Check if all requirements are fulfilled - if(!tmp_proj.variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { - fprintf(stderr, "Project file(%s) not added to Workspace because all requirements not met:\n\t%s\n", - fn.toLatin1().constData(), tmp_proj.values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData()); - continue; - } - if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { - QStringList tmp_proj_subdirs = tmp_proj.variables()["SUBDIRS"]; - for(int x = 0; x < tmp_proj_subdirs.size(); ++x) { - QString tmpdir = tmp_proj_subdirs.at(x); - if(!tmp_proj.isEmpty(tmpdir + ".file")) { - if(!tmp_proj.isEmpty(tmpdir + ".subdir")) - warn_msg(WarnLogic, "Cannot assign both file and subdir for subdir %s", - tmpdir.toLatin1().constData()); - tmpdir = tmp_proj.first(tmpdir + ".file"); - } else if(!tmp_proj.isEmpty(tmpdir + ".subdir")) { - tmpdir = tmp_proj.first(tmpdir + ".subdir"); - } - subdirs += fileFixify(tmpdir); - } - } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") { - // Initialize a 'fake' project to get the correct variables - // and to be able to extract all the dependencies - DspMakefileGenerator tmp_dsp; - tmp_dsp.setNoIO(true); - tmp_dsp.setProjectFile(&tmp_proj); - if(Option::debug_level) { - QMap &vars = tmp_proj.variables(); - for(QMap::Iterator it = vars.begin(); - it != vars.end(); ++it) { - if(it.key().left(1) != "." && !it.value().isEmpty()) - debug_msg(1, "%s: %s === %s", fn.toLatin1().constData(), it.key().toLatin1().constData(), - it.value().join(" :: ").toLatin1().constData()); - } - } - - // We assume project filename is [QMAKE_ORIG_TARGET].vcproj - QString dsp = unescapeFilePath(tmp_dsp.project->first("MSVCDSP_PROJECT") + project->first("DSP_EXTENSION")); - - // If file doesn't exsist, then maybe the users configuration - // doesn't allow it to be created. Skip to next... - if(!exists(qmake_getpwd() + Option::dir_sep + dsp)) { - warn_msg(WarnLogic, "Ignored (not found) '%s'", QString(qmake_getpwd() + Option::dir_sep + dsp).toLatin1().constData()); - goto nextfile; // # Dirty! - } - - WorkspaceDepend *newDep = new WorkspaceDepend; - newDep->dspProjectFile = fileFixify(dsp); - newDep->orig_target = unescapeFilePath(tmp_proj.first("QMAKE_ORIG_TARGET")); - newDep->target = tmp_proj.first("MSVCDSP_PROJECT").section(Option::dir_sep, -1) + tmp_proj.first("TARGET_EXT"); - - // We want to store it as the .lib name. - if(newDep->target.endsWith(".dll")) - newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; - - // All projects having mocable sourcefiles are dependent on moc.exe - if(tmp_proj.variables()["CONFIG"].contains("moc")) - newDep->dependencies << "moc.exe"; - - // All extra compilers which has valid input are considered dependencies - const QStringList &quc = tmp_proj.variables()["QMAKE_EXTRA_COMPILERS"]; - for(QStringList::ConstIterator it = quc.constBegin(); it != quc.constEnd(); ++it) { - const QStringList &invar = tmp_proj.variables().value((*it) + ".input"); - for(QStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) { - const QStringList fileList = tmp_proj.variables().value(*iit); - if (!fileList.isEmpty()) { - QString dep = tmp_proj.first((*it) + ".commands").section('/', -1).section('\\', -1); - if (!newDep->dependencies.contains(dep)) - newDep->dependencies << dep; - } - } - } - - // Add all unknown libs to the deps - QStringList where("QMAKE_LIBS"); - if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) - where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; - - for(QStringList::iterator wit = where.begin(); - wit != where.end(); ++wit) { - QStringList &l = tmp_proj.variables()[(*wit)]; - for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { - QString opt = (*it).trimmed(); - if(!opt.startsWith("/") && // Not a switch - opt != newDep->target && // Not self - opt != "opengl32.lib" && // We don't care about these libs - opt != "glu32.lib" && // to make depgen alittle faster - opt != "kernel32.lib" && - opt != "user32.lib" && - opt != "gdi32.lib" && - opt != "comdlg32.lib" && - opt != "advapi32.lib" && - opt != "shell32.lib" && - opt != "ole32.lib" && - opt != "oleaut32.lib" && - opt != "uuid.lib" && - opt != "imm32.lib" && - opt != "winmm.lib" && - opt != "wsock32.lib" && - opt != "ws2_32.lib" && - opt != "winspool.lib" && - opt != "delayimp.lib") - { - newDep->dependencies << opt.section(Option::dir_sep, -1); - } - } - } - workspace_cleanup.append(newDep); - workspace_depends.insert(newDep->target, newDep); - - debug_msg(1, "Generator: MSVC: Added project (name:'%s' path:'%s' deps:'%s')", - qPrintable(newDep->target) , qPrintable(newDep->dspProjectFile), - qPrintable(newDep->dependencies.join(";"))); - } - } -nextfile: - qmake_setpwd(oldpwd); - } - } - } - - // Restore previous after_user_var options - Option::after_user_vars = old_after_vars; - - // Output all projects - QString dswProjectName = QLatin1String(_dswProjectName); - QString dswProjectDep = QLatin1String(_dswProjectDep); - for(QList::Iterator it = workspace_cleanup.begin(); it != workspace_cleanup.end(); ++it) { - t << _dswDevider; - t << endl; - t << dswProjectName.arg((*it)->orig_target).arg((*it)->dspProjectFile); - t << endl; - t << _dswPackage5Start; - t << _dswPackage5Stop; - t << endl; - t << _dswPackage4Start; - - // Output project dependencies - for(QStringList::iterator dit = (*it)->dependencies.begin(); dit != (*it)->dependencies.end(); ++dit) { - if(WorkspaceDepend *vc = workspace_depends[*dit]) - t << dswProjectDep.arg(vc->orig_target); - } - - t << _dswPackage4Stop; - } - - // Output global part - t << _dswDevider << endl; - t << _dswGlobal; - t << _dswDevider; - t << endl << endl; -} - -class FolderGroup -{ -public: - QString name; - QString filter; - QMap subFolders; - QMap files; - - void insertStructured(const QString &file, const QString &fileListName) - { - QStringList path = QFileInfo(file).path().split("/"); - if (!path.isEmpty() && path.at(0) == ".") - path.takeAt(0); - FolderGroup *currentFolder = this; - for (int i = 0; i < path.size(); i++) { - if (currentFolder->subFolders.contains(path.at(i))) { - currentFolder = currentFolder->subFolders.value(path.at(i)); - } else { - FolderGroup *newFolder = new FolderGroup; - newFolder->name = path.at(i); - currentFolder->subFolders.insert(path.at(i), newFolder); - currentFolder = newFolder; - } - } - currentFolder->files.insert(file, fileListName); - } - - void insertFlat(const QString &file, const QString &fileListName) - { - files.insert(file, fileListName); - } - - ~FolderGroup() - { - qDeleteAll(subFolders.values()); - } -}; - -bool DspMakefileGenerator::writeFileGroup(QTextStream &t, const QStringList &listNames, const QString &group, const QString &filter) -{ - FolderGroup root; - root.name = group; - root.filter = filter; - - for (int i = 0; i < listNames.count(); ++i) { - QStringList list = project->values(listNames.at(i)); - for (int j = 0; j < list.count(); ++j) { - const QString name = list.at(j); - if (name.isEmpty()) - continue; - if (project->isActiveConfig("flat")) - root.insertFlat(name, listNames.at(i)); - else - root.insertStructured(name, listNames.at(i)); - } - } - - if (root.files.isEmpty() && root.subFolders.isEmpty()) - return true; - - writeSubFileGroup(t, &root); - - return true; -} - -void DspMakefileGenerator::writeSubFileGroup(QTextStream &t, FolderGroup *folder) -{ - t << "# Begin Group \"" << folder->name << "\"" << endl; - t << "# PROP Default_Filter \"" << folder->filter << "\"" << endl; - QMap::const_iterator folderIt = folder->subFolders.begin(); - while (folderIt != folder->subFolders.end()) { - writeSubFileGroup(t, folderIt.value()); - ++folderIt; - } - QMap::const_iterator it = folder->files.begin(); - while (it != folder->files.end()) { - t << "# Begin Source File" << endl; - t << "SOURCE=" << escapeFilePath(it.key()) << endl; - writeBuildstepForFile(t, it.key(), it.value()); - t << "# End Source File" << endl; - t << endl; - ++it; - } - t << "# End Group" << endl; - t << endl; -} - -bool DspMakefileGenerator::writeBuildstepForFile(QTextStream &t, const QString &file, const QString &listName) -{ - - if (!mergedProjects.count()) { - t << writeBuildstepForFileForConfig(file, listName, this); - return true; - } - - //only add special build rules when needed - - QStringList specialBuilds; - int i = 0; - for (i = 0; i < mergedProjects.count(); ++i) - specialBuilds += writeBuildstepForFileForConfig(file, listName, mergedProjects.at(i)); - - // no special build just return - if (specialBuilds.join("").isEmpty()) - return true; - - for (i = 0; i < mergedProjects.count(); ++i) { - if (i == 0) - t << "!IF"; - else - t << "!ELSEIF"; - t << " \"$(CFG)\" == \"" << configName(mergedProjects.at(i)) << "\"" << endl; - t << endl; - t << specialBuilds.at(i); - t << endl; - } - - t << "!ENDIF" << endl; - - return true; -} - -bool DspMakefileGenerator::writeDspConfig(QTextStream &t, DspMakefileGenerator *config) -{ - - bool isDebug = config->project->isActiveConfig("debug"); - bool staticLibTarget = config->var("MSVCDSP_DSPTYPE") == "0x0104"; - - QString outDir = Option::fixPathToTargetOS(config->project->first("DESTDIR")); - while (outDir.endsWith(Option::dir_sep)) - outDir.chop(1); - outDir = config->escapeFilePath(outDir); - - QString intDir = config->project->first("OBJECTS_DIR"); - while (intDir.endsWith(Option::dir_sep)) - intDir.chop(1); - intDir = config->escapeFilePath(intDir); - - t << "# PROP BASE Use_MFC 0" << endl; - t << "# PROP BASE Use_Debug_Libraries " << (isDebug ? "1" : "0") << endl; - t << "# PROP BASE Output_Dir " << outDir << endl; - t << "# PROP BASE Intermediate_Dir " << intDir << endl; - t << "# PROP BASE Target_Dir \"\"" << endl; - t << "# PROP Use_MFC 0" << endl; - t << "# PROP Use_Debug_Libraries " << (isDebug ? "1" : "0") << endl; - - t << "# PROP Output_Dir " << outDir << endl; - t << "# PROP Intermediate_Dir " << intDir << endl; - if (config->project->isActiveConfig("dll") || config->project->isActiveConfig("plugin")) - t << "# PROP Ignore_Export_Lib 1" << endl; - t << "# PROP Target_Dir \"\"" << endl; - t << "# ADD CPP " << config->var("MSVCDSP_INCPATH") << " /c /FD " << config->var("QMAKE_CXXFLAGS") << " " << config->var("MSVCDSP_DEFINES") << " " << config->var("PRECOMPILED_FLAGS") << endl; - t << "# ADD MTL /nologo /mktyplib203 /win32 /D " << (isDebug ? "\"_DEBUG\"" : "\"NDEBUG\"") << endl; - t << "# ADD RSC /l 0x409 /d " << (isDebug ? "\"_DEBUG\"" : "\"NDEBUG\"") << endl; - t << "# ADD BSC32 /nologo" << endl; - if (staticLibTarget) { - t << "LIB32=" << config->var("QMAKE_LIB") << endl; - t << "# ADD LIB32 " << config->var("MSVCDSP_TARGET") << " " << config->var("PRECOMPILED_OBJECT") << endl; - } else { - t << "LINK32=" << config->var("QMAKE_LINK") << endl; - t << "# ADD LINK32 " << config->var("MSVCDSP_LFLAGS") << " " << config->var("MSVCDSP_LIBS") << " " << config->var("MSVCDSP_TARGET") << " " << config->var("PRECOMPILED_OBJECT") << endl; - } - - if (!config->project->values("MSVCDSP_PRE_LINK").isEmpty()) - t << config->project->values("MSVCDSP_PRE_LINK").first(); - - if (!config->project->values("MSVCDSP_POST_LINK").isEmpty()) - t << config->project->values("MSVCDSP_POST_LINK").first(); - - return true; -} - -QString DspMakefileGenerator::writeBuildstepForFileForConfig(const QString &file, const QString &listName, DspMakefileGenerator *config) -{ - QString ret; - QTextStream t(&ret); - - // exclude from build - if (!config->project->values(listName).contains(file)) { - t << "# PROP Exclude_From_Build 1" << endl; - return ret; - } - - if (config->usePCH) { - bool c_file = false; - for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { - if (file.endsWith(*it)) { - c_file = true; - break; - } - } - if(c_file) { - t << "# SUBTRACT CPP /FI" << config->escapeFilePath(config->namePCH) << " /Yu" << config->escapeFilePath(config->namePCH) << " /Fp" << endl; - return ret; - } else if (config->precompH.endsWith(file)) { - // ### dependency list quickly becomes too long for VS to grok... - t << "USERDEP_" << file << "=" << config->valGlue(config->escapeFilePaths(config->findDependencies(config->precompH)), "", "\t", "") << endl; - t << endl; - t << "# Begin Custom Build - Creating precompiled header from " << file << "..." << endl; - t << "InputPath=.\\" << config->escapeFilePath(file) << endl << endl; - t << config->precompPch + ": $(SOURCE) \"$(IntDir)\" \"$(OUTDIR)\"" << endl; - t << "\t" << config->var("QMAKE_CC") << " /TP /W3 /FD /c /Yc /Fp" << config->precompPch << " /Fo" << config->precompObj << " /Fd\"$(IntDir)\\\\\" " << file << " "; - t << config->var("MSVCDSP_INCPATH") << " " << config->var("MSVCDSP_DEFINES") << " " << config->var("QMAKE_CXXFLAGS") << endl; - t << "# End Custom Build" << endl << endl; - return ret; - } - } - - QString fileBase = QFileInfo(file).completeBaseName(); - - bool hasBuiltin = config->hasBuiltinCompiler(file); - BuildStep allSteps; - - if (!config->swappedBuildSteps.contains(file)) { - QStringList compilers = config->project->values("QMAKE_EXTRA_COMPILERS"); - for (int i = 0; i < compilers.count(); ++i) { - QString compiler = compilers.at(i); - if (config->project->values(compiler + ".input").isEmpty()) - continue; - QString input = config->project->values(compiler + ".input").first(); - QStringList inputList = config->project->values(input); - if (!inputList.contains(file)) - continue; - - QStringList compilerCommands = config->project->values(compiler + ".commands"); - QStringList compilerOutput = config->project->values(compiler + ".output"); - if (compilerCommands.isEmpty() || compilerOutput.isEmpty()) - continue; - - QStringList compilerName = config->project->values(compiler + ".name"); - if (compilerName.isEmpty()) - compilerName << compiler; - QStringList compilerDepends = config->project->values(compiler + ".depends"); - QString compilerDependsCommand = config->project->values(compiler + ".depend_command").join(" "); - if (!compilerDependsCommand.isEmpty()) { - if(!config->canExecute(compilerDependsCommand)) - compilerDependsCommand = QString(); - } - QStringList compilerConfig = config->project->values(compiler + ".CONFIG"); - - if (!config->verifyExtraCompiler(compiler, file)) - continue; - - bool combineAll = compilerConfig.contains("combine"); - if (combineAll && inputList.first() != file) - continue; - - QString fileIn("$(InputPath)"); - - if (combineAll && !inputList.isEmpty()) { - fileIn = inputList.join(" "); - compilerDepends += inputList; - } - - QString fileOut = compilerOutput.first(); - QString fileOutBase = QFileInfo(fileOut).completeBaseName(); - fileOut.replace("${QMAKE_FILE_IN}", fileIn); - fileOut.replace("${QMAKE_FILE_BASE}", fileBase); - fileOut.replace("${QMAKE_FILE_OUT_BASE}", fileOutBase); - fileOut.replace('/', '\\'); - - BuildStep step; - for (int i2 = 0; i2 < compilerDepends.count(); ++i2) { - QString dependency = compilerDepends.at(i2); - dependency.replace("${QMAKE_FILE_IN}", fileIn); - dependency.replace("${QMAKE_FILE_BASE}", fileBase); - dependency.replace("${QMAKE_FILE_OUT_BASE}", fileOutBase); - dependency.replace('/', '\\'); - if (!step.deps.contains(dependency, Qt::CaseInsensitive)) - step.deps << dependency; - } - // depends command - if (!compilerDependsCommand.isEmpty() && config->doDepends()) { - char buff[256]; - QString dep_cmd = config->replaceExtraCompilerVariables(compilerDependsCommand, file, - fileOut); - dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false); - if(config->canExecute(dep_cmd)) { - if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } - QT_PCLOSE(proc); - if(!indeps.isEmpty()) - step.deps += config->fileFixify(indeps.replace('\n', ' ').simplified().split(' ')); - } - } - } - - - QString mappedFile; - if (hasBuiltin) { - mappedFile = fileOut; - fileOut = fileIn; - fileIn = file; - } - - step.buildStep += " \\\n\t"; - QString command(compilerCommands.join(" ")); - // Replace any newlines with proper line-continuance - command.replace("\n", " \\\n\t"); - // Might be a macro, and not a valid filename, so the replaceExtraCompilerVariables() would eat it - command.replace("${QMAKE_FILE_IN}", config->escapeFilePath(fileIn)); - command.replace("${QMAKE_FILE_BASE}", config->escapeFilePath(fileBase)); - command.replace("${QMAKE_FILE_OUT_BASE}", config->escapeFilePath(fileOutBase)); - command.replace("${QMAKE_FILE_OUT}", config->escapeFilePath(fileOut)); - - command = config->replaceExtraCompilerVariables(command, fileIn, fileOut); - - step.buildName = compilerName.first(); - step.buildStep += command; - step.buildOutputs += fileOut; - - if (hasBuiltin) { - step.deps << fileIn; - config->swappedBuildSteps[mappedFile] = step; - } else { - allSteps << step; - } - } - } else { - allSteps << config->swappedBuildSteps.value(file); - } - - if (allSteps.buildStep.isEmpty()) - return ret; - - int i; - QStringList dependencyList; - // remove dependencies that are also output - for (i = 0; i < 1; ++i) { - QStringList buildOutput(allSteps.buildOutputs.at(i)); - - for (int i2 = 0; i2 < allSteps.deps.count(); ++i2) { - QString dependency = allSteps.deps.at(i2); - if (!buildOutput.contains(dependency) && !dependencyList.contains(dependency)) - dependencyList << dependency; - } - } - QString allDependencies = config->valGlue(dependencyList, "", "\t", ""); - t << "USERDEP_" << file << "=" << allDependencies << endl; - t << "# PROP Ignore_Default_Tool 1" << endl; - t << "# Begin Custom Build - Running " << allSteps.buildName << " on " << file << endl; - t << "InputPath=" << file << endl; - t << "BuildCmds= " << allSteps.buildStep << endl; - for (i = 0; i < allSteps.buildOutputs.count(); ++i) { - t << config->escapeFilePath(allSteps.buildOutputs.at(i)) - << " : $(SOURCE) $(INTDIR) $(OUTDIR)\n\t$(BuildCmds)\n"; - } - t << endl; - t << "# End Custom Build" << endl; - - return ret; -} - -QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h deleted file mode 100644 index f3e2435..0000000 --- a/qmake/generators/win32/msvc_dsp.h +++ /dev/null @@ -1,122 +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 application 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 MSVC_DSP_H -#define MSVC_DSP_H - -#include "winmakefile.h" - -QT_BEGIN_NAMESPACE - -class FolderGroup; - -class DspMakefileGenerator : public Win32MakefileGenerator -{ - bool init_flag; - bool writeDspHeader(QTextStream &); - bool writeDspParts(QTextStream &); - bool writeFileGroup(QTextStream &t, const QStringList &listNames, const QString &group, const QString &filter); - void writeSubFileGroup(QTextStream &t, FolderGroup *folder); - bool writeBuildstepForFile(QTextStream &t, const QString &file, const QString &listName); - static bool writeDspConfig(QTextStream &t, DspMakefileGenerator *config); - static QString writeBuildstepForFileForConfig(const QString &file, const QString &listName, DspMakefileGenerator *config); - QString configName(DspMakefileGenerator * config); - - bool writeMakefile(QTextStream &); - bool writeProjectMakefile(); - void writeSubDirs(QTextStream &t); - void init(); - -public: - DspMakefileGenerator(); - ~DspMakefileGenerator(); - - bool openOutput(QFile &file, const QString &build) const; - bool hasBuiltinCompiler(const QString &filename) const; - -protected: - virtual bool doDepends() const { return false; } //never necesary - virtual void processSources() { filterIncludedFiles("SOURCES"); filterIncludedFiles("GENERATED_SOURCES"); } - virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &); - inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out) - { return MakefileGenerator::replaceExtraCompilerVariables(val, in, out); } - virtual bool supportsMetaBuild() { return true; } - virtual bool supportsMergedBuilds() { return true; } - virtual bool mergeBuildProject(MakefileGenerator *other); - virtual void processPrlVariable(const QString &, const QStringList &); - virtual bool findLibraries(); - - bool usePCH; - QString precompH, namePCH, - precompObj, precompPch; - - QString platform; - - struct BuildStep { - BuildStep() {} - BuildStep &operator<<(const BuildStep &other) { - deps << other.deps; - buildStep += other.buildStep; - buildName += other.buildName; - buildOutputs += other.buildOutputs; - return *this; - } - - QStringList deps; - QString buildStep; - QString buildName; - QStringList buildOutputs; - }; - QMap swappedBuildSteps; - - // Holds all configurations for glue (merged) project - QList mergedProjects; -}; - -inline DspMakefileGenerator::~DspMakefileGenerator() -{ } - -inline bool DspMakefileGenerator::findLibraries() -{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } - -QT_END_NAMESPACE - -#endif // MSVC_DSP_H diff --git a/qmake/qmake.pri b/qmake/qmake.pri index efe4f36..17d9518 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -12,7 +12,7 @@ SOURCES += project.cpp property.cpp main.cpp generators/makefile.cpp \ generators/makefiledeps.cpp generators/metamakefile.cpp generators/mac/pbuilder_pbx.cpp \ generators/xmloutput.cpp generators/win32/borland_bmake.cpp \ generators/win32/msvc_nmake.cpp generators/projectgenerator.cpp \ - generators/win32/msvc_dsp.cpp generators/win32/msvc_vcproj.cpp \ + generators/win32/msvc_vcproj.cpp \ generators/win32/msvc_objectmodel.cpp \ generators/symbian/symmake.cpp \ generators/symbian/symmake_abld.cpp \ @@ -24,7 +24,7 @@ HEADERS += project.h property.h generators/makefile.h \ generators/win32/winmakefile.h generators/projectgenerator.h \ generators/makefiledeps.h generators/metamakefile.h generators/mac/pbuilder_pbx.h \ generators/xmloutput.h generators/win32/borland_bmake.h generators/win32/msvc_nmake.h \ - generators/win32/msvc_dsp.h generators/win32/msvc_vcproj.h \ + generators/win32/msvc_vcproj.h \ generators/win32/mingw_make.h generators/win32/msvc_objectmodel.h \ generators/symbian/symmake.h \ generators/symbian/symmake_abld.h \ -- cgit v0.12 From 2887c85fe54b891a820812fd018f965e74e3463d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 9 Dec 2009 10:47:59 +0100 Subject: purge msvc.net and msvc2002 makespecs. unsupported for a while now. Suggested-by: mariusSO --- mkspecs/win32-msvc.net/qmake.conf | 89 --------------------- mkspecs/win32-msvc.net/qplatformdefs.h | 140 --------------------------------- mkspecs/win32-msvc2002/qmake.conf | 88 --------------------- mkspecs/win32-msvc2002/qplatformdefs.h | 42 ---------- 4 files changed, 359 deletions(-) delete mode 100644 mkspecs/win32-msvc.net/qmake.conf delete mode 100644 mkspecs/win32-msvc.net/qplatformdefs.h delete mode 100644 mkspecs/win32-msvc2002/qmake.conf delete mode 100644 mkspecs/win32-msvc2002/qplatformdefs.h diff --git a/mkspecs/win32-msvc.net/qmake.conf b/mkspecs/win32-msvc.net/qmake.conf deleted file mode 100644 index 89fa00d..0000000 --- a/mkspecs/win32-msvc.net/qmake.conf +++ /dev/null @@ -1,89 +0,0 @@ -# -# qmake configuration for win32-msvc.net (used by 2002 & 2003 before, but now deprecated. Use win32-msvc2002 or win32-msvc2003 instead) -# -# Written for Microsoft C++.NET -# -!build_pass:message("The mkspec/win32-msvc.net is now deprecated, use win32-msvc2002 or win32-msvc2003") - -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1300 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm300 -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib advapi32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib - -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/mkspecs/win32-msvc.net/qplatformdefs.h b/mkspecs/win32-msvc.net/qplatformdefs.h deleted file mode 100644 index 05584c9..0000000 --- a/mkspecs/win32-msvc.net/qplatformdefs.h +++ /dev/null @@ -1,140 +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 QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct _stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stat // non-ANSI defs -#define QT_STAT ::_stat -#define QT_FSTAT ::_fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO _fileno -#define QT_OPEN ::_open -#define QT_CLOSE ::_close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::_lseek -#define QT_TSTAT ::_tstat -#endif -#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 -#if defined(O_TEXT) -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY -#endif - -#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_FTELL (QT_OFF_T)::ftell -#define QT_OFF_T __int64 -#endif - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF ::_vsnprintf -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/win32-msvc2002/qmake.conf b/mkspecs/win32-msvc2002/qmake.conf deleted file mode 100644 index 13fbfb0..0000000 --- a/mkspecs/win32-msvc2002/qmake.conf +++ /dev/null @@ -1,88 +0,0 @@ -# -# qmake configuration for win32-msvc2002 -# -# Written for Microsoft C++.NET -# - -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1300 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm300 -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib advapi32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib - -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/mkspecs/win32-msvc2002/qplatformdefs.h b/mkspecs/win32-msvc2002/qplatformdefs.h deleted file mode 100644 index 6d71abf..0000000 --- a/mkspecs/win32-msvc2002/qplatformdefs.h +++ /dev/null @@ -1,42 +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$ -** -****************************************************************************/ - -#include "../win32-msvc.net/qplatformdefs.h" -- cgit v0.12 From 123ccf7a63e2908c0a4f7035a6e1802dca73f217 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 8 Feb 2010 14:34:57 +0100 Subject: fix host platform conditional Reviewed-by: mariusSO --- 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 6913dc9..7360d74 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -75,7 +75,7 @@ QMAKE_LIBS_COMPAT = QMAKE_LIBS_QT_ENTRY = -llibcrt0.lib QMAKE_LIBS_S60 = -lavkon -contains(QMAKE_HOST.os, "Windows"):!isEmpty(QMAKE_SH) | unix { +!contains(QMAKE_HOST.os, "Windows")|!isEmpty(QMAKE_SH) { QMAKE_COPY = cp QMAKE_COPY_DIR = cp -r QMAKE_MOVE = mv -- cgit v0.12 From 8e7fe402ab07c016fd0ba7d9fae395e532b4dfc5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 9 Dec 2009 14:44:36 +0100 Subject: move $(DEL_FILE) 2> NUL redirection into .conf file littering generic makefile generator code with it is both plain ugly and unnecessary. Reviewed-by: mariusSO --- mkspecs/common/symbian/symbian.conf | 2 +- qmake/generators/makefile.cpp | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 7360d74..f1a6788 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -87,7 +87,7 @@ QMAKE_LIBS_S60 = -lavkon QMAKE_COPY = copy /y QMAKE_COPY_DIR = xcopy /s /q /y /i QMAKE_MOVE = move - QMAKE_DEL_FILE = del + QMAKE_DEL_FILE = del 2> NUL QMAKE_MKDIR = mkdir QMAKE_DEL_DIR = rmdir QMAKE_CHK_DIR_EXISTS = if not exist diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index ae43e2b..ec712a0 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -65,12 +65,6 @@ #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 @@ -1814,8 +1808,6 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) tmp_clean = tmp_out; if(tmp_clean.indexOf("${QMAKE_") == -1) { t << "\n\t" << "-$(DEL_FILE) " << tmp_clean; - if (isForSymbian()) - t << " " << NO_STDERR; // Eliminate unnecessary warnings wrote_clean = true; } if(!wrote_clean_cmds || !wrote_clean) { @@ -1843,12 +1835,8 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) cleans.append(files); } } - if(!cleans.isEmpty()) { - if (isForSymbian()) - 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(!cleans.isEmpty()) + t << valGlue(cleans, "\n\t" + del_statement, "\n\t" + del_statement, ""); if(!wrote_clean_cmds) { for(QStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, (*input), -- cgit v0.12 From 742933c308b4ce4008599f484cd94cf283a92007 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 8 Feb 2010 14:28:56 +0100 Subject: use variables from the spec instead of hard-coding platform ifdefs Reviewed-by: mariusSO --- qmake/generators/symbian/symmake_abld.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 26dd3fd..c7d9e7a 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -303,19 +303,16 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool // generate command lines like this ... // -@ if NOT EXIST ".\somedir" mkdir ".\somedir" QStringList dirsToClean; + QString dirExists = var("QMAKE_CHK_DIR_EXISTS"); + QString mkdir = var("QMAKE_MKDIR"); for (QMap::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) { QStringList values = it.value(); for (int i = 0; i < values.size(); ++i) { 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" < Date: Mon, 8 Feb 2010 14:29:39 +0100 Subject: add QMAKE_DEL_TREE (aka. rm -rf) to avoid more hard-coded platform ifdefs Reviewed-by: mariusSO --- mkspecs/common/symbian/symbian.conf | 2 ++ qmake/generators/symbian/symmake_abld.cpp | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index f1a6788..aab766d 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -82,6 +82,7 @@ QMAKE_LIBS_S60 = -lavkon QMAKE_DEL_FILE = rm -f QMAKE_MKDIR = mkdir QMAKE_DEL_DIR = rmdir + QMAKE_DEL_TREE = rmdir /s /q QMAKE_CHK_DIR_EXISTS = test -d } else { QMAKE_COPY = copy /y @@ -90,6 +91,7 @@ QMAKE_LIBS_S60 = -lavkon QMAKE_DEL_FILE = del 2> NUL QMAKE_MKDIR = mkdir QMAKE_DEL_DIR = rmdir + QMAKE_DEL_TREE = rm -rf QMAKE_CHK_DIR_EXISTS = if not exist } diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index c7d9e7a..a3a504f 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -321,11 +321,7 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool // Note: EXTENSION_CLEAN will get called many times when doing reallyclean // This is why the "2> 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 + generateCleanCommands(t, dirsToClean, var("QMAKE_DEL_TREE"), "", "", ""); t << endl; t << PRE_TARGETDEPS_TARGET ":" -- cgit v0.12 From ffeeac8031d3ac561a8bfb424323ae2c81f82b28 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 11 Feb 2010 11:37:38 +0100 Subject: Move the QWebView based help viewer into it's own source files. --- tools/assistant/tools/assistant/aboutdialog.cpp | 1 + tools/assistant/tools/assistant/assistant.pro | 2 + tools/assistant/tools/assistant/centralwidget.cpp | 2 + tools/assistant/tools/assistant/contentwindow.cpp | 1 + tools/assistant/tools/assistant/helpviewer.cpp | 386 ++------------------ tools/assistant/tools/assistant/helpviewer.h | 83 +---- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 397 +++++++++++++++++++++ tools/assistant/tools/assistant/helpviewer_qwv.h | 121 +++++++ tools/assistant/tools/assistant/indexwindow.cpp | 1 + 9 files changed, 560 insertions(+), 434 deletions(-) create mode 100644 tools/assistant/tools/assistant/helpviewer_qwv.cpp create mode 100644 tools/assistant/tools/assistant/helpviewer_qwv.h diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index 26d488d..c4f5fd2 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include "helpviewer.h" +#include "helpviewer_qwv.h" #include "tracer.h" #include diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index edaf076..2ae03d4 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -28,6 +28,7 @@ HEADERS += aboutdialog.h \ findwidget.h \ filternamedialog.h \ helpenginewrapper.h \ + helpviewer_qwv.h \ helpviewer.h \ indexwindow.h \ installdialog.h \ @@ -54,6 +55,7 @@ SOURCES += aboutdialog.cpp \ findwidget.cpp \ filternamedialog.cpp \ helpenginewrapper.cpp \ + helpviewer_qwv.cpp \ helpviewer.cpp \ indexwindow.cpp \ installdialog.cpp \ diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 03af06c..41b0df4 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -44,6 +44,7 @@ #include "findwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "helpviewer_qwv.h" #include "searchwidget.h" #include "mainwindow.h" #include "../shared/collectionconfiguration.h" @@ -57,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 976ed7a..bfb88c7 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "helpviewer_qwv.h" #include #include diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 8e4d3ed..0f198ac 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -38,361 +38,54 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "helpviewer.h" +#include "helpviewer_qwv.h" + #include "centralwidget.h" #include "helpenginewrapper.h" +#include "tracer.h" #include -#include -#include -#include #include -#include -#include +#include #include -#include #include #include #include #include -#include -#include -#include - QT_BEGIN_NAMESPACE -namespace { - const QString PageNotFoundMessage = - QCoreApplication::translate("HelpViewer", - "Error 404...


" - "

The page could not be found


'%1'

"); -} - -#if !defined(QT_NO_WEBKIT) - -class HelpNetworkReply : public QNetworkReply -{ -public: - HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData, - const QString &mimeType); - - virtual void abort(); - - virtual qint64 bytesAvailable() const - { return data.length() + QNetworkReply::bytesAvailable(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen); - -private: - QByteArray data; - qint64 origLen; -}; - -HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request, - const QByteArray &fileData, const QString& mimeType) - : data(fileData), origLen(fileData.length()) -{ - TRACE_OBJ - setRequest(request); - setOpenMode(QIODevice::ReadOnly); - - setHeader(QNetworkRequest::ContentTypeHeader, mimeType); - setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen)); - QTimer::singleShot(0, this, SIGNAL(metaDataChanged())); - QTimer::singleShot(0, this, SIGNAL(readyRead())); -} - -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); - data.remove(0, len); - } - if (!data.length()) - QTimer::singleShot(0, this, SIGNAL(finished())); - return len; -} - -class HelpNetworkAccessManager : public QNetworkAccessManager -{ -public: - HelpNetworkAccessManager(QObject *parent); - -protected: - virtual QNetworkReply *createRequest(Operation op, - const QNetworkRequest &request, QIODevice *outgoingData = 0); -}; - -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")) - || mimeType.endsWith(QLatin1String(".svgz"))) { - mimeType = QLatin1String("image/svg+xml"); - } else if (mimeType.endsWith(QLatin1String(".css"))) { - mimeType = QLatin1String("text/css"); - } else if (mimeType.endsWith(QLatin1String(".js"))) { - mimeType = QLatin1String("text/javascript"); - } else if (mimeType.endsWith(QLatin1String(".txt"))) { - mimeType = QLatin1String("text/plain"); - } else { - mimeType = QLatin1String("text/html"); - } - - 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); -} - -class HelpPage : public QWebPage -{ -public: - HelpPage(CentralWidget *central, QObject *parent); - -protected: - virtual QWebPage *createWindow(QWebPage::WebWindowType); - virtual void triggerAction(WebAction action, bool checked = false); - - virtual bool acceptNavigationRequest(QWebFrame *frame, - const QNetworkRequest &request, NavigationType type); - -private: - CentralWidget *centralWidget; - bool closeNewTabIfNeeded; - - friend class HelpViewer; - Qt::MouseButtons m_pressedButtons; - Qt::KeyboardModifiers m_keyboardModifiers; -}; - -HelpPage::HelpPage(CentralWidget *central, QObject *parent) - : QWebPage(parent) - , centralWidget(central) - , closeNewTabIfNeeded(false) - , 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; - closeNewTabIfNeeded = false; - return newPage; -} - -void HelpPage::triggerAction(WebAction action, bool checked) -{ - TRACE_OBJ - switch (action) { - case OpenLinkInNewWindow: - closeNewTabIfNeeded = true; - default: // fall through - QWebPage::triggerAction(action, checked); - break; - } -} - -bool HelpPage::acceptNavigationRequest(QWebFrame *, - const QNetworkRequest &request, QWebPage::NavigationType type) -{ - TRACE_OBJ - const QUrl &url = request.url(); - const bool closeNewTab = closeNewTabIfNeeded; - closeNewTabIfNeeded = false; - - if (HelpViewer::isLocalUrl(url)) { - const QString& path = url.path(); - if (!HelpViewer::canOpenPage(path)) { - 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())); - } - - if (closeNewTab) - QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab"); - return false; - } - - if (type == QWebPage::NavigationTypeLinkClicked - && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) { - HelpViewer* viewer = centralWidget->newEmptyTab(); - if (viewer) - CentralWidget::instance()->setSource(url); - m_pressedButtons = Qt::NoButton; - m_keyboardModifiers = Qt::NoModifier; - return false; - } - return true; - } - - QDesktopServices::openUrl(url); - return false; -} - -HelpViewer::HelpViewer(CentralWidget *parent) - : QWebView(parent) - , parentWidget(parent) - , loadFinished(false) - , helpEngine(HelpEngineWrapper::instance()) -{ - TRACE_OBJ - setAcceptDrops(false); - - setPage(new HelpPage(parent, this)); - - page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); - - QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); - action->setText(tr("Open Link in New Tab")); - if (!parent) - action->setVisible(false); - - pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); - pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); - pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false); - - connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this, - SLOT(actionChanged())); - connect(pageAction(QWebPage::Back), SIGNAL(changed()), this, - SLOT(actionChanged())); - connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this, - SLOT(actionChanged())); - connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, - SIGNAL(highlighted(QString))); - connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); - connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); -} - -void HelpViewer::setSource(const QUrl &url) -{ - TRACE_OBJ - loadFinished = false; - if (url.toString() == QLatin1String("help")) { - load(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal-1.0.0/assistant/assistant.html"))); - } else { - load(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) - zoomIn(delta / 120); - else if (delta < 0) - zoomOut(-delta / 120); - e->accept(); - return; - } - QWebView::wheelEvent(e); -} - -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +bool HelpViewer::canOpenPage(const QString &url) { TRACE_OBJ - if (e->button() == Qt::XButton1) { - triggerPageAction(QWebPage::Back); - return; - } - - if (e->button() == Qt::XButton2) { - triggerPageAction(QWebPage::Forward); - return; - } - - QWebView::mouseReleaseEvent(e); + return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) + || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) + || url == QLatin1String("blank"); } -void HelpViewer::actionChanged() +bool HelpViewer::isLocalUrl(const QUrl &url) { TRACE_OBJ - QAction *a = qobject_cast(sender()); - if (a == pageAction(QWebPage::Copy)) - emit copyAvailable(a->isEnabled()); - else if (a == pageAction(QWebPage::Back)) - emit backwardAvailable(a->isEnabled()); - else if (a == pageAction(QWebPage::Forward)) - emit forwardAvailable(a->isEnabled()); + const QString scheme = url.scheme(); + return scheme.isEmpty() + || scheme == QLatin1String("file") + || scheme == QLatin1String("qrc") + || scheme == QLatin1String("data") + || scheme == QLatin1String("qthelp") + || scheme == QLatin1String("about"); } -void HelpViewer::mousePressEvent(QMouseEvent *event) -{ - TRACE_OBJ - HelpPage *currentPage = static_cast(page()); - if (currentPage) { - currentPage->m_pressedButtons = event->buttons(); - currentPage->m_keyboardModifiers = event->modifiers(); - } - QWebView::mousePressEvent(event); -} +#if defined(QT_NO_WEBKIT) -void HelpViewer::setLoadFinished(bool ok) -{ - TRACE_OBJ - loadFinished = ok; - emit sourceChanged(url()); +namespace { +const QString PageNotFoundMessage = + QCoreApplication::translate("HelpViewer", "Error 404...


The page could not be found


'%1'" + "

"); } -#else // !defined(QT_NO_WEBKIT) - HelpViewer::HelpViewer(CentralWidget *parent) : QTextBrowser(parent) , zoomCount(0) @@ -603,6 +296,12 @@ void HelpViewer::keyPressEvent(QKeyEvent *e) QTextBrowser::keyPressEvent(e); } +void HelpViewer::home() +{ + TRACE_OBJ + setSource(helpEngine.homePage()); +} + void HelpViewer::wheelEvent(QWheelEvent *e) { TRACE_OBJ @@ -615,33 +314,6 @@ void HelpViewer::wheelEvent(QWheelEvent *e) } } -#endif // !defined(QT_NO_WEBKIT) - -void HelpViewer::home() -{ - TRACE_OBJ - setSource(helpEngine.homePage()); -} - -bool HelpViewer::canOpenPage(const QString &url) -{ - TRACE_OBJ - return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) - || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) - || url == QLatin1String("blank"); -} - -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"); -} - +#endif QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 4dd8064..da992fa 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -44,89 +44,18 @@ #include #include -#include -#include -#if !defined(QT_NO_WEBKIT) -#include -#endif +#if defined(QT_NO_WEBKIT) + +#include QT_BEGIN_NAMESPACE class CentralWidget; class HelpEngineWrapper; - -class QPoint; -class QString; +class QContextMenuEvent; class QKeyEvent; class QMouseEvent; -class QContextMenuEvent; - -#if !defined(QT_NO_WEBKIT) - -class HelpViewer : public QWebView -{ - Q_OBJECT - -public: - HelpViewer(CentralWidget *parent); - void setSource(const QUrl &url); - - inline QUrl source() const - { return url(); } - - inline QString documentTitle() const - { return title(); } - - inline bool hasSelection() const - { return !selectedText().isEmpty(); } // ### this is suboptimal - - void resetZoom(); - void zoomIn(qreal range = 1); - void zoomOut(qreal range = 1); - - inline void copy() - { return triggerPageAction(QWebPage::Copy); } - - inline bool isForwardAvailable() const - { return pageAction(QWebPage::Forward)->isEnabled(); } - inline bool isBackwardAvailable() const - { return pageAction(QWebPage::Back)->isEnabled(); } - inline bool hasLoadFinished() const - { return loadFinished; } - inline qreal zoom() const - { return textSizeMultiplier(); } - - static bool canOpenPage(const QString &url); - static bool isLocalUrl(const QUrl &url); - -public Q_SLOTS: - void home(); - void backward() { back(); } - -Q_SIGNALS: - void copyAvailable(bool enabled); - void forwardAvailable(bool enabled); - void backwardAvailable(bool enabled); - void highlighted(const QString &); - void sourceChanged(const QUrl &); - -protected: - virtual void wheelEvent(QWheelEvent *); - void mouseReleaseEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *event); - -private Q_SLOTS: - void actionChanged(); - void setLoadFinished(bool ok); - -private: - CentralWidget* parentWidget; - bool loadFinished; - HelpEngineWrapper &helpEngine; -}; - -#else class HelpViewer : public QTextBrowser { @@ -156,7 +85,7 @@ protected: void wheelEvent(QWheelEvent *e); private: - QVariant loadResource(int type, const QUrl &name); + QVariant loadResource(int type, const QUrl &name); void openLinkInNewTab(const QString &link); bool hasAnchorAt(const QPoint& pos); void contextMenuEvent(QContextMenuEvent *e); @@ -178,4 +107,4 @@ private: QT_END_NAMESPACE -#endif +#endif // HELPVIEWER_H diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp new file mode 100644 index 0000000..cd6c89b --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -0,0 +1,397 @@ +/**************************************************************************** +** +** 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 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 "helpviewer.h" +#include "helpviewer_qwv.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#include "tracer.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_WEBKIT) + +namespace { +const QString PageNotFoundMessage = + QCoreApplication::translate("HelpViewer", "Error 404...


The page could not be found


'%1'" + "

"); +} + +class HelpNetworkReply : public QNetworkReply +{ +public: + HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData, + const QString &mimeType); + + virtual void abort(); + + virtual qint64 bytesAvailable() const + { return data.length() + QNetworkReply::bytesAvailable(); } + +protected: + virtual qint64 readData(char *data, qint64 maxlen); + +private: + QByteArray data; + qint64 origLen; +}; + +HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request, + const QByteArray &fileData, const QString& mimeType) + : data(fileData), origLen(fileData.length()) +{ + TRACE_OBJ + setRequest(request); + setOpenMode(QIODevice::ReadOnly); + + setHeader(QNetworkRequest::ContentTypeHeader, mimeType); + setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen)); + QTimer::singleShot(0, this, SIGNAL(metaDataChanged())); + QTimer::singleShot(0, this, SIGNAL(readyRead())); +} + +void HelpNetworkReply::abort() +{ + TRACE_OBJ +} + +qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) +{ + TRACE_OBJ + qint64 len = qMin(qint64(data.length()), maxlen); + if (len) { + qMemCopy(buffer, data.constData(), len); + data.remove(0, len); + } + if (!data.length()) + QTimer::singleShot(0, this, SIGNAL(finished())); + return len; +} + +class HelpNetworkAccessManager : public QNetworkAccessManager +{ +public: + HelpNetworkAccessManager(QObject *parent); + +protected: + virtual QNetworkReply *createRequest(Operation op, + const QNetworkRequest &request, QIODevice *outgoingData = 0); +}; + +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")) + || mimeType.endsWith(QLatin1String(".svgz"))) { + mimeType = QLatin1String("image/svg+xml"); + } else if (mimeType.endsWith(QLatin1String(".css"))) { + mimeType = QLatin1String("text/css"); + } else if (mimeType.endsWith(QLatin1String(".js"))) { + mimeType = QLatin1String("text/javascript"); + } else if (mimeType.endsWith(QLatin1String(".txt"))) { + mimeType = QLatin1String("text/plain"); + } else { + mimeType = QLatin1String("text/html"); + } + + 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); +} + +class HelpPage : public QWebPage +{ +public: + HelpPage(CentralWidget *central, QObject *parent); + +protected: + virtual QWebPage *createWindow(QWebPage::WebWindowType); + virtual void triggerAction(WebAction action, bool checked = false); + + virtual bool acceptNavigationRequest(QWebFrame *frame, + const QNetworkRequest &request, NavigationType type); + +private: + CentralWidget *centralWidget; + bool closeNewTabIfNeeded; + + friend class HelpViewer; + Qt::MouseButtons m_pressedButtons; + Qt::KeyboardModifiers m_keyboardModifiers; +}; + +HelpPage::HelpPage(CentralWidget *central, QObject *parent) + : QWebPage(parent) + , centralWidget(central) + , closeNewTabIfNeeded(false) + , 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; + closeNewTabIfNeeded = false; + return newPage; +} + +void HelpPage::triggerAction(WebAction action, bool checked) +{ + TRACE_OBJ + switch (action) { + case OpenLinkInNewWindow: + closeNewTabIfNeeded = true; + default: // fall through + QWebPage::triggerAction(action, checked); + break; + } +} + +bool HelpPage::acceptNavigationRequest(QWebFrame *, + const QNetworkRequest &request, QWebPage::NavigationType type) +{ + TRACE_OBJ + const QUrl &url = request.url(); + const bool closeNewTab = closeNewTabIfNeeded; + closeNewTabIfNeeded = false; + + if (HelpViewer::isLocalUrl(url)) { + const QString& path = url.path(); + if (!HelpViewer::canOpenPage(path)) { + 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())); + } + + if (closeNewTab) + QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab"); + return false; + } + + if (type == QWebPage::NavigationTypeLinkClicked + && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { + HelpViewer* viewer = centralWidget->newEmptyTab(); + if (viewer) + CentralWidget::instance()->setSource(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + return false; + } + return true; + } + + QDesktopServices::openUrl(url); + return false; +} + +HelpViewer::HelpViewer(CentralWidget *parent) + : QWebView(parent) + , parentWidget(parent) + , loadFinished(false) + , helpEngine(HelpEngineWrapper::instance()) +{ + TRACE_OBJ + setAcceptDrops(false); + + setPage(new HelpPage(parent, this)); + + page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); + + QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); + action->setText(tr("Open Link in New Tab")); + if (!parent) + action->setVisible(false); + + pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); + pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); + pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false); + + connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this, + SLOT(actionChanged())); + connect(pageAction(QWebPage::Back), SIGNAL(changed()), this, + SLOT(actionChanged())); + connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this, + SLOT(actionChanged())); + connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, + SIGNAL(highlighted(QString))); + connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); +} + +void HelpViewer::setSource(const QUrl &url) +{ + TRACE_OBJ + loadFinished = false; + if (url.toString() == QLatin1String("help")) { + load(QUrl(QLatin1String("qthelp://com.trolltech.com." + "assistantinternal-1.0.0/assistant/assistant.html"))); + } else { + load(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::home() +{ + TRACE_OBJ + setSource(helpEngine.homePage()); +} + +void HelpViewer::wheelEvent(QWheelEvent *e) +{ + TRACE_OBJ + if (e->modifiers() & Qt::ControlModifier) { + const int delta = e->delta(); + if (delta > 0) + zoomIn(delta / 120); + else if (delta < 0) + zoomOut(-delta / 120); + e->accept(); + return; + } + QWebView::wheelEvent(e); +} + +void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +{ + TRACE_OBJ + if (e->button() == Qt::XButton1) { + triggerPageAction(QWebPage::Back); + return; + } + + if (e->button() == Qt::XButton2) { + triggerPageAction(QWebPage::Forward); + return; + } + + QWebView::mouseReleaseEvent(e); +} + +void HelpViewer::actionChanged() +{ + TRACE_OBJ + QAction *a = qobject_cast(sender()); + if (a == pageAction(QWebPage::Copy)) + emit copyAvailable(a->isEnabled()); + else if (a == pageAction(QWebPage::Back)) + emit backwardAvailable(a->isEnabled()); + else if (a == pageAction(QWebPage::Forward)) + emit forwardAvailable(a->isEnabled()); +} + +void HelpViewer::mousePressEvent(QMouseEvent *event) +{ + TRACE_OBJ + HelpPage *currentPage = static_cast(page()); + if (currentPage) { + currentPage->m_pressedButtons = event->buttons(); + currentPage->m_keyboardModifiers = event->modifiers(); + } + QWebView::mousePressEvent(event); +} + +void HelpViewer::setLoadFinished(bool ok) +{ + TRACE_OBJ + loadFinished = ok; + emit sourceChanged(url()); +} + +#endif + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h new file mode 100644 index 0000000..a78bd57 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** 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 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 HELPVIEWERQWV_H +#define HELPVIEWERQWV_H + +#if !defined(QT_NO_WEBKIT) + +#include +#include + +QT_BEGIN_NAMESPACE + +class CentralWidget; +class HelpEngineWrapper; +class QMouseEvent; + +class HelpViewer : public QWebView +{ + Q_OBJECT + +public: + HelpViewer(CentralWidget *parent); + void setSource(const QUrl &url); + + inline QUrl source() const + { return url(); } + + inline QString documentTitle() const + { return title(); } + + inline bool hasSelection() const + { return !selectedText().isEmpty(); } // ### this is suboptimal + + void resetZoom(); + void zoomIn(qreal range = 1); + void zoomOut(qreal range = 1); + + inline void copy() + { return triggerPageAction(QWebPage::Copy); } + + inline bool isForwardAvailable() const + { return pageAction(QWebPage::Forward)->isEnabled(); } + inline bool isBackwardAvailable() const + { return pageAction(QWebPage::Back)->isEnabled(); } + inline bool hasLoadFinished() const + { return loadFinished; } + inline qreal zoom() const + { return textSizeMultiplier(); } + + static bool canOpenPage(const QString &url); + static bool isLocalUrl(const QUrl &url); + +public Q_SLOTS: + void home(); + void backward() { back(); } + +Q_SIGNALS: + void copyAvailable(bool enabled); + void forwardAvailable(bool enabled); + void backwardAvailable(bool enabled); + void highlighted(const QString &); + void sourceChanged(const QUrl &); + +protected: + virtual void wheelEvent(QWheelEvent *); + void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *event); + +private Q_SLOTS: + void actionChanged(); + void setLoadFinished(bool ok); + +private: + CentralWidget* parentWidget; + bool loadFinished; + HelpEngineWrapper &helpEngine; +}; + +#endif + +QT_END_NAMESPACE + +#endif // HELPVIEWERQWV_H diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 82242e5..1879db7 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "helpviewer_qwv.h" #include "topicchooser.h" #include -- cgit v0.12 From 03faf2750e02f78c5f3fd1589da00a6bcfa20e53 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 11 Feb 2010 12:13:14 +0100 Subject: Some more refactoring. Move the QTextBrowser based help viewer into it's own source files and introduce a common base clase that currently only contains the statics, but more to come for common stuff. Review: ck --- tools/assistant/tools/assistant/aboutdialog.cpp | 32 +-- tools/assistant/tools/assistant/assistant.pro | 6 +- tools/assistant/tools/assistant/centralwidget.cpp | 4 +- tools/assistant/tools/assistant/contentwindow.cpp | 5 +- tools/assistant/tools/assistant/helpviewer.cpp | 271 ++----------------- tools/assistant/tools/assistant/helpviewer.h | 61 +---- tools/assistant/tools/assistant/helpviewer_qtb.cpp | 292 +++++++++++++++++++++ tools/assistant/tools/assistant/helpviewer_qtb.h | 109 ++++++++ tools/assistant/tools/assistant/helpviewer_qwv.cpp | 23 +- tools/assistant/tools/assistant/helpviewer_qwv.h | 13 +- tools/assistant/tools/assistant/indexwindow.cpp | 3 +- tools/assistant/tools/assistant/mainwindow.cpp | 1 - 12 files changed, 462 insertions(+), 358 deletions(-) create mode 100644 tools/assistant/tools/assistant/helpviewer_qtb.cpp create mode 100644 tools/assistant/tools/assistant/helpviewer_qtb.h diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index c4f5fd2..a9bc352 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ #include "helpviewer.h" -#include "helpviewer_qwv.h" #include "tracer.h" #include @@ -71,7 +70,7 @@ void AboutLabel::setText(const QString &text, const QByteArray &resources) TRACE_OBJ QDataStream in(resources); in >> m_resourceMap; - + QTextBrowser::setText(text); } @@ -97,34 +96,34 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name) void AboutLabel::setSource(const QUrl &url) { TRACE_OBJ - if (url.isValid() && (!HelpViewer::isLocalUrl(url) - || !HelpViewer::canOpenPage(url.path()))) { + if (url.isValid() && (!AbstractHelpViewer::isLocalUrl(url) + || !AbstractHelpViewer::canOpenPage(url.path()))) { if (!QDesktopServices::openUrl(url)) { QMessageBox::warning(this, tr("Warning"), - tr("Unable to launch external application.\n"), - tr("OK")); + tr("Unable to launch external application.\n"), tr("OK")); } } } AboutDialog::AboutDialog(QWidget *parent) - : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint|Qt::WindowTitleHint|Qt::WindowSystemMenuHint) + : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | + Qt::WindowTitleHint|Qt::WindowSystemMenuHint) { TRACE_OBJ m_pixmapLabel = 0; m_aboutLabel = new AboutLabel(); - + m_closeButton = new QPushButton(); m_closeButton->setText(tr("&Close")); - connect(m_closeButton, SIGNAL(clicked()), - this, SLOT(close())); + connect(m_closeButton, SIGNAL(clicked()), this, SLOT(close())); m_layout = new QGridLayout(this); m_layout->addWidget(m_aboutLabel, 1, 0, 1, -1); - m_layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1, 1, 1); + m_layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, + QSizePolicy::Fixed), 2, 1, 1, 1); m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 0, 1, 1); m_layout->addWidget(m_closeButton, 3, 1, 1, 1); - m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 2, 1, 1); + m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 2, 1, 1); } void AboutDialog::setText(const QString &text, const QByteArray &resources) @@ -154,7 +153,8 @@ QString AboutDialog::documentTitle() const void AboutDialog::updateSize() { TRACE_OBJ - QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); + QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()) + .size(); int limit = qMin(screenSize.width()/2, 500); #ifdef Q_WS_MAC @@ -166,7 +166,7 @@ void AboutDialog::updateSize() if (width > limit) width = limit; - + QFontMetrics fm(qApp->font("QWorkspaceTitleBar")); int windowTitleWidth = qMin(fm.width(windowTitle()) + 50, limit); if (windowTitleWidth > width) @@ -174,8 +174,8 @@ void AboutDialog::updateSize() layout()->activate(); int height = (layout()->hasHeightForWidth()) - ? layout()->totalHeightForWidth(width) - : layout()->totalMinimumSize().height(); + ? layout()->totalHeightForWidth(width) + : layout()->totalMinimumSize().height(); setFixedSize(width, height); QCoreApplication::removePostedEvents(this, QEvent::LayoutRequest); } diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 2ae03d4..0733128 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -28,8 +28,9 @@ HEADERS += aboutdialog.h \ findwidget.h \ filternamedialog.h \ helpenginewrapper.h \ - helpviewer_qwv.h \ helpviewer.h \ + helpviewer_qtb.h \ + helpviewer_qwv.h \ indexwindow.h \ installdialog.h \ mainwindow.h \ @@ -55,8 +56,9 @@ SOURCES += aboutdialog.cpp \ findwidget.cpp \ filternamedialog.cpp \ helpenginewrapper.cpp \ - helpviewer_qwv.cpp \ helpviewer.cpp \ + helpviewer_qtb.cpp \ + helpviewer_qwv.cpp \ indexwindow.cpp \ installdialog.cpp \ main.cpp \ diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 41b0df4..c780df6 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -43,7 +43,7 @@ #include "centralwidget.h" #include "findwidget.h" #include "helpenginewrapper.h" -#include "helpviewer.h" +#include "helpviewer_qtb.h" #include "helpviewer_qwv.h" #include "searchwidget.h" #include "mainwindow.h" @@ -82,10 +82,8 @@ namespace { CentralWidget *staticCentralWidget = 0; } - // -- CentralWidget - CentralWidget::CentralWidget(MainWindow *parent) : QWidget(parent) , lastTabPage(0) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index bfb88c7..e0347c8 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -44,7 +44,6 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" -#include "helpviewer_qwv.h" #include #include @@ -145,7 +144,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm && HelpViewer::canOpenPage(itm->url().path())) + if (itm && AbstractHelpViewer::canOpenPage(itm->url().path())) CentralWidget::instance()->setSourceInNewTab(itm->url()); } } else if (button == Qt::LeftButton) { @@ -171,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 (!HelpViewer::canOpenPage(itm->url().path())) + if (!AbstractHelpViewer::canOpenPage(itm->url().path())) newTab->setEnabled(false); menu.move(m_contentWidget->mapToGlobal(pos)); diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 0f198ac..8597f6b 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -39,281 +39,44 @@ ** ****************************************************************************/ #include "helpviewer.h" -#include "helpviewer_qwv.h" - -#include "centralwidget.h" -#include "helpenginewrapper.h" #include "tracer.h" -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include QT_BEGIN_NAMESPACE -bool HelpViewer::canOpenPage(const QString &url) -{ - TRACE_OBJ - return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) - || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) - || url == QLatin1String("blank"); -} - -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"); -} - -#if defined(QT_NO_WEBKIT) - -namespace { -const QString PageNotFoundMessage = +QString AbstractHelpViewer::PageNotFoundMessage = QCoreApplication::translate("HelpViewer", "Error 404...


The page could not be found


'%1'" "

"); -} - -HelpViewer::HelpViewer(CentralWidget *parent) - : QTextBrowser(parent) - , zoomCount(0) - , controlPressed(false) - , lastAnchor(QString()) - , 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)) - return; - - QUrl u = helpEngine.findFile(url); - if (u.isValid()) { - QTextBrowser::setSource(u); - return; - } - } - - if (help) { - QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal-1.0.0/assistant/assistant.html"))); - } else { - QTextBrowser::setSource(url); - setHtml(PageNotFoundMessage.arg(url.toString())); - emit sourceChanged(url); - } -} - -void HelpViewer::resetZoom() -{ - TRACE_OBJ - if (zoomCount == 0) - return; - - QTextBrowser::zoomOut(zoomCount); - zoomCount = 0; -} - -void HelpViewer::zoomIn(int range) -{ - TRACE_OBJ - if (zoomCount == 10) - return; - - QTextBrowser::zoomIn(range); - zoomCount++; -} - -void HelpViewer::zoomOut(int range) -{ - TRACE_OBJ - if (zoomCount == -5) - return; - - QTextBrowser::zoomOut(range); - zoomCount--; -} -bool HelpViewer::launchedWithExternalApp(const QUrl &url) +AbstractHelpViewer::AbstractHelpViewer() { - TRACE_OBJ - const bool canOpen = canOpenPage(url.path()); - if (!isLocalUrl(url) || !canOpen) { - bool launched = false; - if (!canOpen && url.scheme() == QLatin1String("qthelp")) { - const QString& path = url.path(); - 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(helpEngine.fileData(url)); - tmpFile.close(); - } - launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName())); - } else { - launched = QDesktopServices::openUrl(url); - } - - if (!launched) { - QMessageBox::information(this, tr("Help"), - tr("Unable to launch external application.\n"), tr("OK")); - } - return true; - } - return false; -} - -QVariant HelpViewer::loadResource(int type, const QUrl &name) -{ - TRACE_OBJ - QByteArray ba; - if (type < 4) { - ba = helpEngine.fileData(name); - if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { - QImage image; - image.loadFromData(ba, "svg"); - if (!image.isNull()) - return image; - } - } - return ba; -} - -void HelpViewer::openLinkInNewTab() -{ - TRACE_OBJ - if(lastAnchor.isEmpty()) - return; - - parentWidget->setSourceInNewTab(QUrl(lastAnchor)); - lastAnchor.clear(); -} - -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; - - lastAnchor = source().resolved(lastAnchor).toString(); - if (lastAnchor.at(0) == QLatin1Char('#')) { - QString src = source().toString(); - int hsh = src.indexOf(QLatin1Char('#')); - lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor; - } - - return true; -} - -void HelpViewer::contextMenuEvent(QContextMenuEvent *e) -{ - TRACE_OBJ - QMenu menu(QLatin1String(""), 0); - - QUrl link; - QAction *copyAnchorAction = 0; - if (hasAnchorAt(e->pos())) { - link = anchorAt(e->pos()); - if (link.isRelative()) - link = source().resolved(link); - copyAnchorAction = menu.addAction(tr("Copy &Link Location")); - copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); - - menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this, - SLOT(openLinkInNewTab())); - menu.addSeparator(); - } - menu.addActions(parentWidget->globalActions()); - QAction *action = menu.exec(e->globalPos()); - if (action == copyAnchorAction) - QApplication::clipboard()->setText(link.toString()); } -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +AbstractHelpViewer::~AbstractHelpViewer() { - TRACE_OBJ - if (e->button() == Qt::XButton1) { - QTextBrowser::backward(); - return; - } - - if (e->button() == Qt::XButton2) { - QTextBrowser::forward(); - return; - } - - controlPressed = e->modifiers() & Qt::ControlModifier; - if ((controlPressed && hasAnchorAt(e->pos())) || - (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) { - openLinkInNewTab(); - return; - } - - QTextBrowser::mouseReleaseEvent(e); } -void HelpViewer::keyPressEvent(QKeyEvent *e) +bool AbstractHelpViewer::isLocalUrl(const QUrl &url) { 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, - e->text(), e->isAutoRepeat(), e->count()); - e = event; - } - QTextBrowser::keyPressEvent(e); -} - -void HelpViewer::home() -{ - TRACE_OBJ - setSource(helpEngine.homePage()); + const QString &scheme = url.scheme(); + return scheme.isEmpty() + || scheme == QLatin1String("file") + || scheme == QLatin1String("qrc") + || scheme == QLatin1String("data") + || scheme == QLatin1String("qthelp") + || scheme == QLatin1String("about"); } -void HelpViewer::wheelEvent(QWheelEvent *e) +bool AbstractHelpViewer::canOpenPage(const QString &url) { TRACE_OBJ - if (e->modifiers() == Qt::CTRL) { - e->accept(); - (e->delta() > 0) ? zoomIn() : zoomOut(); - } else { - e->ignore(); - QTextBrowser::wheelEvent(e); - } + return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) + || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) + || url == QLatin1String("blank"); } -#endif - QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index da992fa..276cd1f 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -38,73 +38,26 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - #ifndef HELPVIEWER_H #define HELPVIEWER_H -#include -#include - -#if defined(QT_NO_WEBKIT) - -#include +#include QT_BEGIN_NAMESPACE -class CentralWidget; -class HelpEngineWrapper; -class QContextMenuEvent; -class QKeyEvent; -class QMouseEvent; +class QUrl; -class HelpViewer : public QTextBrowser +class AbstractHelpViewer { - Q_OBJECT - public: - HelpViewer(CentralWidget *parent); - void setSource(const QUrl &url); + AbstractHelpViewer(); + ~AbstractHelpViewer(); - void resetZoom(); - void zoomIn(int range = 1); - void zoomOut(int range = 1); - int zoom() const { return zoomCount; } - void setZoom(int zoom) { zoomCount = zoom; } - - inline bool hasSelection() const - { return textCursor().hasSelection(); } - - bool launchedWithExternalApp(const QUrl &url); - static bool canOpenPage(const QString &url); + static QString PageNotFoundMessage; static bool isLocalUrl(const QUrl &url); - -public Q_SLOTS: - void home(); - -protected: - void wheelEvent(QWheelEvent *e); - -private: - QVariant loadResource(int type, const QUrl &name); - void openLinkInNewTab(const QString &link); - bool hasAnchorAt(const QPoint& pos); - void contextMenuEvent(QContextMenuEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - -private slots: - void openLinkInNewTab(); - -private: - int zoomCount; - bool controlPressed; - QString lastAnchor; - CentralWidget* parentWidget; - HelpEngineWrapper &helpEngine; + static bool canOpenPage(const QString &url); }; -#endif - QT_END_NAMESPACE #endif // HELPVIEWER_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp new file mode 100644 index 0000000..dc35878 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ +#if defined(QT_NO_WEBKIT) + +#include "helpviewer_qtb.h" +#include "helpviewer_qwv.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#include "tracer.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +HelpViewer::HelpViewer(CentralWidget *parent) + : QTextBrowser(parent) + , zoomCount(0) + , controlPressed(false) + , lastAnchor(QString()) + , 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)) + return; + + QUrl u = helpEngine.findFile(url); + if (u.isValid()) { + QTextBrowser::setSource(u); + return; + } + } + + if (help) { + QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com." + "assistantinternal-1.0.0/assistant/assistant.html"))); + } else { + QTextBrowser::setSource(url); + setHtml(PageNotFoundMessage.arg(url.toString())); + emit sourceChanged(url); + } +} + +void HelpViewer::resetZoom() +{ + TRACE_OBJ + if (zoomCount == 0) + return; + + QTextBrowser::zoomOut(zoomCount); + zoomCount = 0; +} + +void HelpViewer::zoomIn(int range) +{ + TRACE_OBJ + if (zoomCount == 10) + return; + + QTextBrowser::zoomIn(range); + zoomCount++; +} + +void HelpViewer::zoomOut(int range) +{ + TRACE_OBJ + if (zoomCount == -5) + return; + + QTextBrowser::zoomOut(range); + zoomCount--; +} + +bool HelpViewer::launchedWithExternalApp(const QUrl &url) +{ + TRACE_OBJ + const bool canOpen = canOpenPage(url.path()); + if (!isLocalUrl(url) || !canOpen) { + bool launched = false; + if (!canOpen && url.scheme() == QLatin1String("qthelp")) { + const QString& path = url.path(); + 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(helpEngine.fileData(url)); + tmpFile.close(); + } + launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName())); + } else { + launched = QDesktopServices::openUrl(url); + } + + if (!launched) { + QMessageBox::information(this, tr("Help"), + tr("Unable to launch external application.\n"), tr("OK")); + } + return true; + } + return false; +} + +QVariant HelpViewer::loadResource(int type, const QUrl &name) +{ + TRACE_OBJ + QByteArray ba; + if (type < 4) { + ba = helpEngine.fileData(name); + if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { + QImage image; + image.loadFromData(ba, "svg"); + if (!image.isNull()) + return image; + } + } + return ba; +} + +void HelpViewer::openLinkInNewTab() +{ + TRACE_OBJ + if(lastAnchor.isEmpty()) + return; + + parentWidget->setSourceInNewTab(QUrl(lastAnchor)); + lastAnchor.clear(); +} + +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; + + lastAnchor = source().resolved(lastAnchor).toString(); + if (lastAnchor.at(0) == QLatin1Char('#')) { + QString src = source().toString(); + int hsh = src.indexOf(QLatin1Char('#')); + lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor; + } + + return true; +} + +void HelpViewer::contextMenuEvent(QContextMenuEvent *e) +{ + TRACE_OBJ + QMenu menu(QLatin1String(""), 0); + + QUrl link; + QAction *copyAnchorAction = 0; + if (hasAnchorAt(e->pos())) { + link = anchorAt(e->pos()); + if (link.isRelative()) + link = source().resolved(link); + copyAnchorAction = menu.addAction(tr("Copy &Link Location")); + copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); + + menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this, + SLOT(openLinkInNewTab())); + menu.addSeparator(); + } + menu.addActions(parentWidget->globalActions()); + QAction *action = menu.exec(e->globalPos()); + if (action == copyAnchorAction) + QApplication::clipboard()->setText(link.toString()); +} + +void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +{ + TRACE_OBJ + if (e->button() == Qt::XButton1) { + QTextBrowser::backward(); + return; + } + + if (e->button() == Qt::XButton2) { + QTextBrowser::forward(); + return; + } + + controlPressed = e->modifiers() & Qt::ControlModifier; + if ((controlPressed && hasAnchorAt(e->pos())) || + (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) { + openLinkInNewTab(); + return; + } + + QTextBrowser::mouseReleaseEvent(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, + e->text(), e->isAutoRepeat(), e->count()); + e = event; + } + QTextBrowser::keyPressEvent(e); +} + +void HelpViewer::home() +{ + TRACE_OBJ + setSource(helpEngine.homePage()); +} + +void HelpViewer::wheelEvent(QWheelEvent *e) +{ + TRACE_OBJ + if (e->modifiers() == Qt::CTRL) { + e->accept(); + (e->delta() > 0) ? zoomIn() : zoomOut(); + } else { + e->ignore(); + QTextBrowser::wheelEvent(e); + } +} + +QT_END_NAMESPACE + +#endif // QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h new file mode 100644 index 0000000..09f5370 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ +#if defined(QT_NO_WEBKIT) + +#ifndef HELPVIEWERQTB_H +#define HELPVIEWERQTB_H + +#include "helpviewer.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class CentralWidget; +class HelpEngineWrapper; +class QContextMenuEvent; +class QKeyEvent; +class QMouseEvent; + +class HelpViewer : public QTextBrowser, public AbstractHelpViewer +{ + Q_OBJECT + +public: + HelpViewer(CentralWidget *parent); + void setSource(const QUrl &url); + + void resetZoom(); + void zoomIn(int range = 1); + void zoomOut(int range = 1); + int zoom() const { return zoomCount; } + void setZoom(int zoom) { zoomCount = zoom; } + + inline bool hasSelection() const + { return textCursor().hasSelection(); } + + bool launchedWithExternalApp(const QUrl &url); + +public Q_SLOTS: + void home(); + +protected: + void wheelEvent(QWheelEvent *e); + +private: + QVariant loadResource(int type, const QUrl &name); + void openLinkInNewTab(const QString &link); + bool hasAnchorAt(const QPoint& pos); + void contextMenuEvent(QContextMenuEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *e); + +private slots: + void openLinkInNewTab(); + +private: + int zoomCount; + bool controlPressed; + QString lastAnchor; + CentralWidget* parentWidget; + HelpEngineWrapper &helpEngine; +}; + +QT_END_NAMESPACE + +#endif // HELPVIEWERQTB_H + +#endif // QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index cd6c89b..d2e0019 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -38,14 +38,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "helpviewer.h" +#if !defined(QT_NO_WEBKIT) + #include "helpviewer_qwv.h" #include "centralwidget.h" #include "helpenginewrapper.h" #include "tracer.h" -#include #include #include #include @@ -61,15 +61,6 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_WEBKIT) - -namespace { -const QString PageNotFoundMessage = - QCoreApplication::translate("HelpViewer", "Error 404...


The page could not be found


'%1'" - "

"); -} - class HelpNetworkReply : public QNetworkReply { public: @@ -159,7 +150,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); const QByteArray &data = helpEngine.findFile(url).isValid() ? helpEngine.fileData(url) - : PageNotFoundMessage.arg(url.toString()).toUtf8(); + : AbstractHelpViewer::PageNotFoundMessage.arg(url.toString()).toUtf8(); return new HelpNetworkReply(request, data, mimeType); } @@ -224,9 +215,9 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, const bool closeNewTab = closeNewTabIfNeeded; closeNewTabIfNeeded = false; - if (HelpViewer::isLocalUrl(url)) { + if (AbstractHelpViewer::isLocalUrl(url)) { const QString& path = url.path(); - if (!HelpViewer::canOpenPage(path)) { + if (!AbstractHelpViewer::canOpenPage(path)) { QTemporaryFile tmpTmpFile; if (!tmpTmpFile.open()) return false; @@ -392,6 +383,6 @@ void HelpViewer::setLoadFinished(bool ok) emit sourceChanged(url()); } -#endif - QT_END_NAMESPACE + +#endif // !QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index a78bd57..4daa869 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -38,10 +38,12 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#if !defined(QT_NO_WEBKIT) + #ifndef HELPVIEWERQWV_H #define HELPVIEWERQWV_H -#if !defined(QT_NO_WEBKIT) +#include "helpviewer.h" #include #include @@ -52,7 +54,7 @@ class CentralWidget; class HelpEngineWrapper; class QMouseEvent; -class HelpViewer : public QWebView +class HelpViewer : public QWebView, public AbstractHelpViewer { Q_OBJECT @@ -85,9 +87,6 @@ public: inline qreal zoom() const { return textSizeMultiplier(); } - static bool canOpenPage(const QString &url); - static bool isLocalUrl(const QUrl &url); - public Q_SLOTS: void home(); void backward() { back(); } @@ -114,8 +113,8 @@ private: HelpEngineWrapper &helpEngine; }; -#endif - QT_END_NAMESPACE #endif // HELPVIEWERQWV_H + +#endif // !QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 1879db7..63ddbe4 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -44,7 +44,6 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" -#include "helpviewer_qwv.h" #include "topicchooser.h" #include @@ -220,7 +219,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) return; } - if (!HelpViewer::canOpenPage(url.path())) + if (!AbstractHelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else CentralWidget::instance()->setSourceInNewTab(url); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2ff6b5e..086f9eb 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -44,7 +44,6 @@ #include "bookmarkmanager.h" #include "centralwidget.h" -#include "helpviewer.h" #include "indexwindow.h" #include "topicchooser.h" #include "contentwindow.h" -- cgit v0.12 From 0ff252da26185709cbeeabddd07e6d9ab83de4a4 Mon Sep 17 00:00:00 2001 From: kh1 Date: Fri, 12 Feb 2010 16:33:04 +0100 Subject: Refactor font and zoom handling, reduces clutter in central widget. Reviewed-by: ck --- tools/assistant/tools/assistant/bookmarkdialog.cpp | 8 +- tools/assistant/tools/assistant/centralwidget.cpp | 98 ++++++------------ tools/assistant/tools/assistant/centralwidget.h | 5 +- tools/assistant/tools/assistant/helpviewer.h | 11 ++ tools/assistant/tools/assistant/helpviewer_qtb.cpp | 111 ++++++++++++++------- tools/assistant/tools/assistant/helpviewer_qtb.h | 21 ++-- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 71 ++++++++----- tools/assistant/tools/assistant/helpviewer_qwv.h | 22 ++-- tools/assistant/tools/assistant/mainwindow.cpp | 6 +- .../tools/assistant/preferencesdialog.cpp | 26 +++-- 10 files changed, 212 insertions(+), 167 deletions(-) diff --git a/tools/assistant/tools/assistant/bookmarkdialog.cpp b/tools/assistant/tools/assistant/bookmarkdialog.cpp index f081c15..c053b62 100644 --- a/tools/assistant/tools/assistant/bookmarkdialog.cpp +++ b/tools/assistant/tools/assistant/bookmarkdialog.cpp @@ -38,12 +38,12 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "bookmarkdialog.h" #include "bookmarkfiltermodel.h" #include "bookmarkitem.h" #include "bookmarkmodel.h" +#include "helpenginewrapper.h" +#include "tracer.h" #include #include @@ -94,6 +94,10 @@ BookmarkDialog::BookmarkDialog(BookmarkModel *sourceModel, const QString &title, ui.bookmarkFolders->setCurrentIndex(0); ui.treeView->setCurrentIndex(ui.treeView->indexAt(QPoint(2, 2))); + + const HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + if (helpEngine.usesAppFont()) + setFont(helpEngine.appFont()); } BookmarkDialog::~BookmarkDialog() diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index c780df6..dd91326 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -72,6 +72,7 @@ namespace { HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, const QPoint &point) { + TRACE_OBJ QTabBar *tabBar = qFindChild(widget); for (int i = 0; i < tabBar->count(); ++i) { if (tabBar->tabRect(i).contains(point)) @@ -174,7 +175,7 @@ CentralWidget::~CentralWidget() HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { currentPages << viewer->source().toString(); - zoomFactors << QString::number(viewer->zoom()); + zoomFactors << QString::number(viewer->scale()); } } @@ -208,7 +209,7 @@ void CentralWidget::zoomIn() TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) - viewer->zoomIn(); + viewer->scaleUp(); if (tabWidget->currentWidget() == m_searchWidget) m_searchWidget->zoomIn(); @@ -219,7 +220,7 @@ void CentralWidget::zoomOut() TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); if (viewer) - viewer->zoomOut(); + viewer->scaleDown(); if (tabWidget->currentWidget() == m_searchWidget) m_searchWidget->zoomOut(); @@ -237,9 +238,8 @@ void CentralWidget::nextPage() void CentralWidget::resetZoom() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->resetZoom(); + if (HelpViewer *viewer = currentHelpViewer()) + viewer->resetScale(); if (tabWidget->currentWidget() == m_searchWidget) m_searchWidget->resetZoom(); @@ -522,25 +522,12 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) return; #endif - viewer = new HelpViewer(this); + viewer = new HelpViewer(this, zoom); viewer->installEventFilter(this); viewer->setSource(url); viewer->setFocus(Qt::OtherFocusReason); tabWidget->setCurrentIndex(tabWidget->addTab(viewer, quoteTabTitle(viewer->documentTitle()))); - - QFont font; - getBrowserFontFor(viewer, &font); - -#if defined(QT_NO_WEBKIT) - font.setPointSize((int)(font.pointSize() + zoom)); - setBrowserFontFor(viewer, font); - viewer->setZoom((int)zoom); -#else - setBrowserFontFor(viewer, font); - viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); -#endif - connectSignals(); } @@ -579,7 +566,13 @@ void CentralWidget::connectSignals() } } -HelpViewer *CentralWidget::currentHelpViewer() const +HelpViewer* CentralWidget::viewerAt(int index) const +{ + TRACE_OBJ + return qobject_cast(tabWidget->widget(index)); +} + +HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ return qobject_cast(tabWidget->currentWidget()); @@ -755,6 +748,7 @@ void CentralWidget::keyPressEvent(QKeyEvent *e) void CentralWidget::findNext() { + TRACE_OBJ find(findWidget->text(), true); } @@ -876,21 +870,24 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) void CentralWidget::updateBrowserFont() { TRACE_OBJ - QFont font; - bool searchAttached = searchWidgetAttached(); + const bool searchAttached = searchWidgetAttached(); if (searchAttached) { - getBrowserFontFor(m_searchWidget, &font); - setBrowserFontFor(m_searchWidget, font); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + m_searchWidget->setFont(helpEngine.usesBrowserFont() + ? helpEngine.browserFont() : qApp->font()); } - int i = searchAttached ? 1 : 0; - getBrowserFontFor(tabWidget->widget(i), &font); - for ( ; i < tabWidget->count(); ++i) - setBrowserFontFor(tabWidget->widget(i), font); + const int count = tabWidget->count(); + if (HelpViewer* viewer = viewerAt(count - 1)) { + const QFont &font = viewer->viewerFont(); + for (int i = searchAttached ? 1 : 0; i < count; ++i) + viewerAt(i)->setViewerFont(font); + } } bool CentralWidget::searchWidgetAttached() const { + TRACE_OBJ return m_searchWidget && m_searchWidget->isAttached(); } @@ -906,9 +903,9 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, SLOT(setSourceFromSearchInNewTab(QUrl))); - QFont font; - getBrowserFontFor(m_searchWidget, &font); - setBrowserFontFor(m_searchWidget, font); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font() + : helpEngine.browserFont()); } void CentralWidget::activateSearchWidget(bool updateLastTabPage) @@ -1103,41 +1100,4 @@ QMap CentralWidget::currentSourceFileList() const return sourceList; } -void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font) -{ - TRACE_OBJ - 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); - if (view) { - QWebSettings *settings = QWebSettings::globalSettings(); - *font = QFont(settings->fontFamily(QWebSettings::StandardFont), - settings->fontSize(QWebSettings::DefaultFontSize)); - } -#endif - } else { - *font = helpEngine.browserFont(); - } -} - -void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font) -{ - TRACE_OBJ -#if !defined(QT_NO_WEBKIT) - QWebView *view = qobject_cast (widget); - if (view) { - QWebSettings *settings = view->settings(); - settings->setFontFamily(QWebSettings::StandardFont, font.family()); - settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); - } else if (widget && widget->font() != font) { - widget->setFont(font); - } -#else - if (widget && widget->font() != font) - widget->setFont(font); -#endif -} - QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 6c3e93c..f286ff7 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -70,6 +70,8 @@ public: bool isBackwardAvailable() const; QList globalActions() const; void setGlobalActions(const QList &actions); + + HelpViewer *viewerAt(int index) const; HelpViewer *currentHelpViewer() const; bool searchWidgetAttached() const; @@ -143,9 +145,6 @@ private: QString quoteTabTitle(const QString &title) const; void setLastShownPages(); - void getBrowserFontFor(QWidget* viewer, QFont *font); - void setBrowserFontFor(QWidget *widget, const QFont &font); - private: int lastTabPage; QList globalActionList; diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 276cd1f..fe860fd 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -43,6 +43,8 @@ #include +#include + QT_BEGIN_NAMESPACE class QUrl; @@ -53,6 +55,15 @@ public: AbstractHelpViewer(); ~AbstractHelpViewer(); + virtual QFont viewerFont() const = 0; + virtual void setViewerFont(const QFont &font) = 0; + + virtual void scaleUp() = 0; + virtual void scaleDown() = 0; + + virtual void resetScale() = 0; + virtual qreal scale() const = 0; + static QString PageNotFoundMessage; static bool isLocalUrl(const QUrl &url); static bool canOpenPage(const QString &url); diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index dc35878..3aafe67 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -59,16 +59,78 @@ QT_BEGIN_NAMESPACE -HelpViewer::HelpViewer(CentralWidget *parent) +HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) : QTextBrowser(parent) - , zoomCount(0) + , zoomCount(zoom) , controlPressed(false) , lastAnchor(QString()) , parentWidget(parent) , helpEngine(HelpEngineWrapper::instance()) + , forceFont(false) { TRACE_OBJ - document()->setDocumentMargin(8); + installEventFilter(this); + document()->setDocumentMargin(8); + + QFont font = viewerFont(); + font.setPointSize(int(font.pointSize() + zoom)); + setViewerFont(font); +} + +HelpViewer::~HelpViewer() +{ + TRACE_OBJ +} + +QFont HelpViewer::viewerFont() const +{ + TRACE_OBJ + if (HelpEngineWrapper::instance().usesBrowserFont()) + return helpEngine.browserFont(); + return qApp->font(); +} + +void HelpViewer::setViewerFont(const QFont &newFont) +{ + TRACE_OBJ + if (font() != newFont) { + forceFont = true; + setFont(newFont); + forceFont = false; + } +} + +void HelpViewer::scaleUp() +{ + TRACE_OBJ + if (zoomCount < 10) { + ++zoomCount; + forceFont = true; + zoomIn(); + forceFont = false; + } +} + +void HelpViewer::scaleDown() +{ + TRACE_OBJ + if (zoomCount > -5) { + --zoomCount; + forceFont = true; + zoomOut(); + forceFont = false; + } +} + +void HelpViewer::resetScale() +{ + TRACE_OBJ + if (zoomCount != 0) { + forceFont = true; + zoomOut(zoomCount); + forceFont = false; + } + zoomCount = 0; } void HelpViewer::setSource(const QUrl &url) @@ -96,36 +158,6 @@ void HelpViewer::setSource(const QUrl &url) } } -void HelpViewer::resetZoom() -{ - TRACE_OBJ - if (zoomCount == 0) - return; - - QTextBrowser::zoomOut(zoomCount); - zoomCount = 0; -} - -void HelpViewer::zoomIn(int range) -{ - TRACE_OBJ - if (zoomCount == 10) - return; - - QTextBrowser::zoomIn(range); - zoomCount++; -} - -void HelpViewer::zoomOut(int range) -{ - TRACE_OBJ - if (zoomCount == -5) - return; - - QTextBrowser::zoomOut(range); - zoomCount--; -} - bool HelpViewer::launchedWithExternalApp(const QUrl &url) { TRACE_OBJ @@ -278,15 +310,22 @@ void HelpViewer::home() void HelpViewer::wheelEvent(QWheelEvent *e) { TRACE_OBJ - if (e->modifiers() == Qt::CTRL) { + if (e->modifiers() == Qt::ControlModifier) { e->accept(); - (e->delta() > 0) ? zoomIn() : zoomOut(); + e->delta() > 0 ? scaleUp() : scaleDown(); } else { - e->ignore(); QTextBrowser::wheelEvent(e); } } +bool HelpViewer::eventFilter(QObject *obj, QEvent *event) +{ + TRACE_OBJ + if (event->type() == QEvent::FontChange && !forceFont) + return true; + return QTextBrowser::eventFilter(obj, event); +} + QT_END_NAMESPACE #endif // QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h index 09f5370..e927b34 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -63,14 +63,18 @@ class HelpViewer : public QTextBrowser, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent); - void setSource(const QUrl &url); + HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); - void resetZoom(); - void zoomIn(int range = 1); - void zoomOut(int range = 1); - int zoom() const { return zoomCount; } - void setZoom(int zoom) { zoomCount = zoom; } + void scaleUp(); + void scaleDown(); + void resetScale(); + qreal scale() const { return zoomCount; } + + void setSource(const QUrl &url); inline bool hasSelection() const { return textCursor().hasSelection(); } @@ -82,6 +86,7 @@ public Q_SLOTS: protected: void wheelEvent(QWheelEvent *e); + bool eventFilter(QObject *obj, QEvent *event); private: QVariant loadResource(int type, const QUrl &name); @@ -100,6 +105,8 @@ private: QString lastAnchor; CentralWidget* parentWidget; HelpEngineWrapper &helpEngine; + + bool forceFont; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index d2e0019..4857e00 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -252,7 +252,9 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, return false; } -HelpViewer::HelpViewer(CentralWidget *parent) +// -- HelpViewer + +HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) : QWebView(parent) , parentWidget(parent) , loadFinished(false) @@ -284,36 +286,63 @@ HelpViewer::HelpViewer(CentralWidget *parent) SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); + + setFont(viewerFont()); + setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); } -void HelpViewer::setSource(const QUrl &url) +HelpViewer::~HelpViewer() { TRACE_OBJ - loadFinished = false; - if (url.toString() == QLatin1String("help")) { - load(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal-1.0.0/assistant/assistant.html"))); - } else { - load(url); - } } -void HelpViewer::resetZoom() +QFont HelpViewer::viewerFont() const { TRACE_OBJ - setTextSizeMultiplier(1.0); + if (helpEngine.usesBrowserFont()) + return helpEngine.browserFont(); + + QWebSettings *webSettings = QWebSettings::globalSettings(); + return QFont(webSettings->fontFamily(QWebSettings::StandardFont), + webSettings->fontSize(QWebSettings::DefaultFontSize)); } -void HelpViewer::zoomIn(qreal range) +void HelpViewer::setViewerFont(const QFont &font) { TRACE_OBJ - setTextSizeMultiplier(textSizeMultiplier() + range / 10.0); + QWebSettings *webSettings = settings(); + webSettings->setFontFamily(QWebSettings::StandardFont, font.family()); + webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); } -void HelpViewer::zoomOut(qreal range) +void HelpViewer::scaleUp() { TRACE_OBJ - setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - range / 10.0)); + setTextSizeMultiplier(textSizeMultiplier() + 0.1); +} + +void HelpViewer::scaleDown() +{ + TRACE_OBJ + setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - 0.1)); +} + +void HelpViewer::resetScale() +{ + TRACE_OBJ + setTextSizeMultiplier(1.0); +} + +void HelpViewer::setSource(const QUrl &url) +{ + TRACE_OBJ + loadFinished = false; + if (url.toString() == QLatin1String("help")) { + load(QUrl(QLatin1String("qthelp://com.trolltech.com." + "assistantinternal-1.0.0/assistant/assistant.html"))); + } else { + load(url); + } } void HelpViewer::home() @@ -325,16 +354,12 @@ void HelpViewer::home() void HelpViewer::wheelEvent(QWheelEvent *e) { TRACE_OBJ - if (e->modifiers() & Qt::ControlModifier) { - const int delta = e->delta(); - if (delta > 0) - zoomIn(delta / 120); - else if (delta < 0) - zoomOut(-delta / 120); + if (e->modifiers()& Qt::ControlModifier) { e->accept(); - return; + e->delta() > 0 ? scaleUp() : scaleDown(); + } else { + QWebView::wheelEvent(e); } - QWebView::wheelEvent(e); } void HelpViewer::mouseReleaseEvent(QMouseEvent *e) diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index 4daa869..3f2e537 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -59,11 +59,19 @@ class HelpViewer : public QWebView, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent); - void setSource(const QUrl &url); + HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); - inline QUrl source() const - { return url(); } + void scaleUp(); + void scaleDown(); + void resetScale(); + qreal scale() const { return textSizeMultiplier(); } + + void setSource(const QUrl &url); + inline QUrl source() const { return url(); } inline QString documentTitle() const { return title(); } @@ -71,10 +79,6 @@ public: inline bool hasSelection() const { return !selectedText().isEmpty(); } // ### this is suboptimal - void resetZoom(); - void zoomIn(qreal range = 1); - void zoomOut(qreal range = 1); - inline void copy() { return triggerPageAction(QWebPage::Copy); } @@ -84,8 +88,6 @@ public: { return pageAction(QWebPage::Back)->isEnabled(); } inline bool hasLoadFinished() const { return loadFinished; } - inline qreal zoom() const - { return textSizeMultiplier(); } public Q_SLOTS: void home(); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 086f9eb..4115d39 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -759,12 +759,10 @@ void MainWindow::showPreferences() { TRACE_OBJ PreferencesDialog dia(this); - connect(&dia, SIGNAL(updateApplicationFont()), this, SLOT(updateApplicationFont())); connect(&dia, SIGNAL(updateBrowserFont()), m_centralWidget, SLOT(updateBrowserFont())); - dia.showDialog(); } @@ -969,7 +967,9 @@ void MainWindow::updateApplicationFont() if (helpEngine.usesAppFont()) font = helpEngine.appFont(); - qApp->setFont(font, "QWidget"); + const QWidgetList &widgets = qApp->allWidgets(); + foreach (QWidget* widget, widgets) + widget->setFont(font); } void MainWindow::setupFilterCombo() diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index f0ef054..0e1d719 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -38,26 +38,24 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "preferencesdialog.h" + +#include "centralwidget.h" #include "filternamedialog.h" -#include "installdialog.h" #include "fontpanel.h" -#include "centralwidget.h" -#include "aboutdialog.h" #include "helpenginewrapper.h" +#include "installdialog.h" +#include "tracer.h" #include #include -#include +#include #include -#include -#include #include -#include -#include +#include +#include +#include #include @@ -115,6 +113,9 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) updateFontSettingsPage(); updateOptionsPage(); + + if (helpEngine.usesAppFont()) + setFont(helpEngine.appFont()); } PreferencesDialog::~PreferencesDialog() @@ -124,16 +125,13 @@ PreferencesDialog::~PreferencesDialog() helpEngine.setAppFont(m_appFontPanel->selectedFont()); helpEngine.setUseAppFont(m_appFontPanel->isChecked()); helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem()); + emit updateApplicationFont(); } if (m_browserFontChanged) { helpEngine.setBrowserFont(m_browserFontPanel->selectedFont()); helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked()); helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem()); - } - - if (m_appFontChanged || m_browserFontChanged) { - emit updateApplicationFont(); emit updateBrowserFont(); } -- cgit v0.12 From ba1d67e35a8493a5a035f4f26970799e50661a36 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 12 Feb 2010 19:33:01 +0100 Subject: Fix scrolling backwards when pathItemCount != model.count Also fixes -Scrolling backwards when model.count != 0 mod pathItemCount -A minor typo in a comment Task-number: QTBUG-6865 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qmlgraphicspathview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 85e87eb..6718d25 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -910,11 +910,16 @@ void QmlGraphicsPathViewPrivate::snapToCurrent() //Rounds is the number of times round to make the current item visible int rounds = itemIndex / items.count(); - int otherWayRounds = (model->count() - (itemIndex)) / items.count() + 1; + int otherWayRounds = (model->count() - (itemIndex)) / items.count(); if (otherWayRounds < rounds) rounds = -otherWayRounds; itemIndex += pathOffset; + if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){ + //When model.count() is not a multiple of pathItemCount we need to manually + //fix the index so that going backwards one step works correctly. + itemIndex = itemIndex - model->count() + items.count(); + } itemIndex %= items.count(); qreal targetOffset = qmlMod(100 + (snapPos*100) - 100.0 * itemIndex / items.count(), qreal(100.0)); @@ -928,7 +933,7 @@ void QmlGraphicsPathViewPrivate::snapToCurrent() moveOffset.setValue(_offset); if (rounds!=0){ - //Compensate if the targetOffset would bring the target it from off the screen + //Compensate if the targetOffset would bring the target in from off the screen qreal distance = targetOffset - _offset; if (distance <= -50) rounds--; -- cgit v0.12 From 12180c397a2007970978033928b4b5b12efad7c6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 15 Feb 2010 14:55:59 +0100 Subject: Prepare translations of the declarative module. Add to translations profile. move stuff out of QObject-context, correct spelling and contractions, correct usage of tr(). --- .../graphicsitems/qmlgraphicsanchors.cpp | 26 +++++++++++----------- src/declarative/qml/qmlcompiler.cpp | 12 +++++----- src/declarative/qml/qmlobjectscriptclass.cpp | 6 ++--- src/declarative/util/qmlanimation.cpp | 14 ++++++------ src/declarative/util/qmlbehavior.cpp | 2 +- src/declarative/util/qmlpropertychanges.cpp | 2 +- src/declarative/util/qmlstateoperations.cpp | 8 +++---- src/declarative/util/qmlxmllistmodel.cpp | 4 ++-- translations/translations.pri | 1 + 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 93055fc..945e7d3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -366,7 +366,7 @@ void QmlGraphicsAnchors::setFill(QmlGraphicsItem *f) return; } if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } d->remDepend(d->fill); @@ -400,7 +400,7 @@ void QmlGraphicsAnchors::setCenterIn(QmlGraphicsItem* c) return; } if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } @@ -991,7 +991,7 @@ bool QmlGraphicsAnchorsPrivate::checkHValid() const if (usedAnchors & QmlGraphicsAnchors::HasLeftAnchor && usedAnchors & QmlGraphicsAnchors::HasRightAnchor && usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't specify left, right, and hcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify left, right, and hcenter anchors."); return false; } @@ -1001,16 +1001,16 @@ bool QmlGraphicsAnchorsPrivate::checkHValid() const bool QmlGraphicsAnchorsPrivate::checkHAnchorValid(QmlGraphicsAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to a null item."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item."); return false; } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Vertical_Mask) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor a horizontal edge to a vertical edge."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a horizontal edge to a vertical edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor item to self."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self."); return false; } @@ -1022,13 +1022,13 @@ bool QmlGraphicsAnchorsPrivate::checkVValid() const if (usedAnchors & QmlGraphicsAnchors::HasTopAnchor && usedAnchors & QmlGraphicsAnchors::HasBottomAnchor && usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't specify top, bottom, and vcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify top, bottom, and vcenter anchors."); return false; } else if (usedAnchors & QmlGraphicsAnchors::HasBaselineAnchor && (usedAnchors & QmlGraphicsAnchors::HasTopAnchor || usedAnchors & QmlGraphicsAnchors::HasBottomAnchor || usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor)) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); return false; } @@ -1038,16 +1038,16 @@ bool QmlGraphicsAnchorsPrivate::checkVValid() const bool QmlGraphicsAnchorsPrivate::checkVAnchorValid(QmlGraphicsAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to a null item."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item."); return false; } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Horizontal_Mask) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor a vertical edge to a horizontal edge."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a vertical edge to a horizontal edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor item to self."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self."); return false; } diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 10150de..9990c06 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -730,7 +730,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) compileState.parserStatusCount++; // Check if this is a custom parser type. Custom parser types allow - // assignments to non-existant properties. These assignments are then + // assignments to non-existent properties. These assignments are then // compiled by the type. bool isCustomParser = output->types.at(obj->type).type && output->types.at(obj->type).type->customParser() != 0; @@ -1429,7 +1429,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, ctxt)); return true; } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existant attached object")); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object")); } if (!prop->value) @@ -1486,9 +1486,9 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, } else if (prop->index == -1) { if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant default property")); + COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent default property")); } else { - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name))); } } else if (prop->value) { @@ -1534,7 +1534,7 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, &type, 0, 0, 0); if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existant attached object")); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object")); if (!prop->value) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid attached object assignment")); @@ -1841,7 +1841,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, foreach (Property *prop, obj->properties) { int idx = type->metaObject()->indexOfProperty(prop->name.constData()); if (idx == -1) - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name))); QMetaProperty p = type->metaObject()->property(idx); prop->index = idx; prop->type = p.userType(); diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 1c41d46..c373a8e 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -313,7 +313,7 @@ void QmlObjectScriptClass::setProperty(QObject *obj, Q_ASSERT(lastData); if (!lastData->isValid()) { - QString error = QLatin1String("Cannot assign to non-existant property \"") + + QString error = QLatin1String("Cannot assign to non-existent property \"") + toString(name) + QLatin1Char('\"'); if (context()) context()->throwError(error); @@ -628,11 +628,11 @@ QmlObjectMethodScriptClass::Value QmlObjectMethodScriptClass::call(Object *o, QS for (int ii = 0; ii < argTypeNames.count(); ++ii) { argTypes[ii] = QMetaType::type(argTypeNames.at(ii)); if (argTypes[ii] == QVariant::Invalid) - return Value(ctxt, ctxt->throwError(QString(QLatin1String("Unknown method parameter type: %1")).arg(QLatin1String(argTypeNames.at(ii))))); + return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii))))); } if (argTypes.count() > ctxt->argumentCount()) - return Value(ctxt, ctxt->throwError("Insufficient arguments")); + return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments"))); QVarLengthArray args(argTypes.count() + 1); args[0].initAsType(method->data.propType, engine); diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index abffefe..6609c73 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -77,7 +77,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) if (hasParams) { QString easeName = curve.trimmed(); if (!easeName.endsWith(QLatin1Char(')'))) { - qmlInfo(obj) << obj->tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); return easingCurve; } @@ -86,7 +86,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); normalizedCurve = easeName.left(idx); if (!normalizedCurve.startsWith(QLatin1String("ease"))) { - qmlInfo(obj) << obj->tr("Easing function \"%1\" must start with \"ease\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve); return easingCurve; } @@ -101,7 +101,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) int value = me.keyToValue(normalizedCurve.toUtf8().constData()); if (value < 0) { - qmlInfo(obj) << obj->tr("Unknown easing curve \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve); return easingCurve; } easingCurve.setType((QEasingCurve::Type)value); @@ -111,7 +111,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) int sep = str.indexOf(QLatin1Char(':')); if (sep == -1) { - qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); continue; } @@ -120,7 +120,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk); if (propName.isEmpty() || !isOk) { - qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); continue; } @@ -131,7 +131,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) } else if (propName == QLatin1String("overshoot")) { easingCurve.setOvershoot(propValue); } else { - qmlInfo(obj) << obj->tr("Unknown easing parameter \"%1\"").arg(propName); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName); continue; } } @@ -226,7 +226,7 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const { QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { - qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); + qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); return QmlMetaProperty(); } else if (!prop.isWritable()) { qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index b9c77f5..e8feeaa 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -119,7 +119,7 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) { Q_D(QmlBehavior); if (d->animation) { - qmlInfo(this) << tr("Can't change the animation assigned to a Behavior."); + qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior."); return; } diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 68fc5cc..f1f39da 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -357,7 +357,7 @@ QmlPropertyChangesPrivate::property(const QByteArray &property) Q_Q(QmlPropertyChanges); QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property)); if (!prop.isValid()) { - qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(property)); + qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property)); return QmlMetaProperty(); } else if (!(prop.type() & QmlMetaProperty::SignalProperty) && !prop.isWritable()) { qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property)); diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 35c8f7d..cefe2bc 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -82,7 +82,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics bool ok; const QTransform &transform = target->itemTransform(targetParent, &ok); if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under complex transform"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under complex transform"); ok = false; } @@ -92,21 +92,21 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics if (transform.m11() == transform.m22()) scale = transform.m11(); else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); ok = false; } } else if (ok && transform.type() == QTransform::TxRotate) { if (transform.m11() == transform.m22()) scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); ok = false; } if (scale != 0) rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under scale of 0"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under scale of 0"); ok = false; } } diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index d31fadf..d586792 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -391,7 +391,7 @@ void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role) { QmlConcreteList::insert(i, role); if (model->roleNames.contains(role->name())) { - qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); + qmlInfo(role) << QCoreApplication::translate("QmlXmlRoleList", "\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); return; } model->roles.insert(i, model->highestRole); @@ -551,7 +551,7 @@ void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); if (!query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << tr("An XmlListModel query must start with '/' or \"//\""); + qmlInfo(this) << QCoreApplication::translate("QmlXmlRoleList", "An XmlListModel query must start with '/' or \"//\""); return; } diff --git a/translations/translations.pri b/translations/translations.pri index 808dc4f..a8fb7ee 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -25,6 +25,7 @@ ts-qt.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ 3rdparty/webkit \ activeqt \ corelib \ + declarative \ gui \ multimedia \ network \ -- cgit v0.12 From e885e8123fbe0d57a0d8a4c8115ea43dde31b05d Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 15 Feb 2010 17:16:53 +0100 Subject: Assistant: Rebuild search index at most once at start-up. Reviewed-by: kh1 --- .../tools/assistant/helpenginewrapper.cpp | 28 +++++++++++++++++++++- .../assistant/tools/assistant/helpenginewrapper.h | 6 +++++ tools/assistant/tools/assistant/mainwindow.cpp | 3 +-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 76211c5..a181c71 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -112,6 +112,7 @@ private: QFileSystemWatcher * const m_qchWatcher; typedef QPair > RecentSignal; QMap m_recentQchUpdates; + bool m_initialReindexingNeeded; }; const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered"); @@ -141,6 +142,18 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) : d(new HelpEngineWrapperPrivate(collectionFile)) { TRACE_OBJ + + /* + * Otherwise we will waste time if several new docs are found, + * because we will start to index them, only to be interupted + * by the next request. Also, there is a nasty SQLITE bug that will + * cause the application to hang for minutes in that case. + * This call is reverted by initalDocSetupDone(), which must be + * called after the new docs have been installed. + */ + disconnect(d->m_helpEngine, SIGNAL(setupFinished()), + searchEngine(), SLOT(indexDocumentation())); + connect(d, SIGNAL(documentationRemoved(QString)), this, SIGNAL(documentationRemoved(QString))); connect(d, SIGNAL(documentationUpdated(QString)), @@ -157,6 +170,15 @@ HelpEngineWrapper::~HelpEngineWrapper() delete d; } +void HelpEngineWrapper::initialDocSetupDone() +{ + TRACE_OBJ + connect(d->m_helpEngine, SIGNAL(setupFinished()), + searchEngine(), SLOT(indexDocumentation())); + if (d->m_initialReindexingNeeded) + setupData(); +} + QHelpSearchEngine *HelpEngineWrapper::searchEngine() const { TRACE_OBJ @@ -207,6 +229,7 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile) return false; d->m_qchWatcher->addPath(docFile); d->checkDocFilesWatched(); + d->m_initialReindexingNeeded = true; return true; } @@ -219,6 +242,7 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) return false; d->m_qchWatcher->removePath(file); d->checkDocFilesWatched(); + d->m_initialReindexingNeeded = true; return true; } @@ -698,7 +722,8 @@ void TimeoutForwarder::forward() HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile) : m_helpEngine(new QHelpEngine(collectionFile, this)), - m_qchWatcher(new QFileSystemWatcher(this)) + m_qchWatcher(new QFileSystemWatcher(this)), + m_initialReindexingNeeded(false) { TRACE_OBJ if (!m_helpEngine->customFilters().contains(Unfiltered)) @@ -797,6 +822,7 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName, } else { emit documentationUpdated(ns); } + m_initialReindexingNeeded = true; m_helpEngine->setupData(); } m_recentQchUpdates.erase(it); diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index a30fab8..8d95273 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -101,6 +101,12 @@ public: const QStringList filterAttributes(const QString &filterName) const; QString error() const; + /* + * To be called after assistant has finished looking for new documentation. + * This will mainly cause the search index to be updated, if necessary. + */ + void initialDocSetupDone(); + const QStringList qtDocInfo(const QString &component) const; void setQtDocInfo(const QString &component, const QStringList &doc); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 4115d39..8096218 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -354,8 +354,6 @@ void MainWindow::lookForNewQtDocumentation() void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) { TRACE_OBJ - if (newDocsInstalled) - HelpEngineWrapper::instance().setupData(); statusBar()->clearMessage(); checkInitState(); } @@ -383,6 +381,7 @@ void MainWindow::checkInitState() } emit initDone(); } + HelpEngineWrapper::instance().initialDocSetupDone(); } void MainWindow::insertLastPages() -- cgit v0.12 From d813575790f94fc4f98abcb45ad47248cdd8b2d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 08:35:10 +0100 Subject: Fix qml test breakage of 12180c397a2007970978033928b4b5b12efad7c6 Fix messages in test data. --- .../qmlanimations/tst_qmlanimations.cpp | 6 +++--- .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 2 +- tests/auto/declarative/qmldom/tst_qmldom.cpp | 2 +- .../qmlecmascript/tst_qmlecmascript.cpp | 12 +++++------ .../qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp | 24 +++++++++++----------- .../data/invalidAttachedProperty.1.errors.txt | 2 +- .../data/invalidAttachedProperty.10.errors.txt | 2 +- .../data/invalidAttachedProperty.2.errors.txt | 2 +- .../data/invalidAttachedProperty.6.errors.txt | 2 +- .../data/invalidAttachedProperty.7.errors.txt | 2 +- .../data/invalidAttachedProperty.8.errors.txt | 2 +- .../data/invalidAttachedProperty.9.errors.txt | 2 +- .../data/invalidGroupedProperty.4.errors.txt | 2 +- .../qmllanguage/data/missingSignal.errors.txt | 2 +- .../data/missingValueTypeProperty.errors.txt | 2 +- .../data/nonexistantProperty.1.errors.txt | 2 +- .../data/nonexistantProperty.2.errors.txt | 2 +- .../data/nonexistantProperty.3.errors.txt | 2 +- .../data/nonexistantProperty.4.errors.txt | 2 +- .../data/nonexistantProperty.6.errors.txt | 2 +- tests/auto/declarative/qmlstates/tst_qmlstates.cpp | 4 ++-- 21 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 17a1453..a00e911 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -308,7 +308,7 @@ void tst_animations::badProperties() QmlEngine engine; QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); - QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existant property \"border.colr\""; + QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); QTest::ignoreMessage(QtWarningMsg, message); // why twice? QmlGraphicsRectangle *rect = qobject_cast(c1.create()); @@ -546,8 +546,8 @@ void tst_animations::easingStringConversion() QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); QVERIFY(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); - animation->setEasing("easeOutQuad(nonexistantproperty: 12)"); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistentproperty\""); + animation->setEasing("easeOutQuad(nonexistentproperty: 12)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); delete animation; diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 61023a2..73ab35e 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -254,7 +254,7 @@ void tst_behaviors::reassignedAnimation() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Can't change the animation assigned to a Behavior.").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); QmlGraphicsRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast( diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp index ce35130..eb4d419 100644 --- a/tests/auto/declarative/qmldom/tst_qmldom.cpp +++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp @@ -394,7 +394,7 @@ void tst_qmldom::loadErrors() QCOMPARE(error.url(), QUrl()); QCOMPARE(error.line(), 3); QCOMPARE(error.column(), 3); - QCOMPARE(error.description(), QString("Cannot assign to non-existant property \"foo\"")); + QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\"")); } // Test loading a file with syntax errors diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index e5472bb..a6baf10 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -572,7 +572,7 @@ void tst_qmlecmascript::enums() QCOMPARE(object->property("i").toInt(), 19); QCOMPARE(object->property("j").toInt(), 19); } - // Non-existant enums + // Non-existent enums { QmlComponent component(&engine, TEST_FILE("enums.2.qml")); @@ -680,7 +680,7 @@ void tst_qmlecmascript::outerBindingOverridesInnerBinding() } /* -Access a non-existant attached object. +Access a non-existent attached object. Tests for a regression where this used to crash. */ @@ -928,7 +928,7 @@ void tst_qmlecmascript::scriptErrors() QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; QString warning6 = url + ":9: Unable to assign [undefined] to int"; QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\""; - QString warning8 = url + ":15: Error: Cannot assign to non-existant property \"fakeProperty\""; + QString warning8 = url + ":15: Error: Cannot assign to non-existent property \"fakeProperty\""; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); @@ -1207,15 +1207,15 @@ void tst_qmlecmascript::callQtInvokables() QScriptEngine *engine = &ep->scriptEngine; ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); - // Non-existant methods + // Non-existent methods o.reset(); - QCOMPARE(engine->evaluate("object.method_nonexistant()").isError(), true); + QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), -1); QCOMPARE(o.actuals().count(), 0); o.reset(); - QCOMPARE(engine->evaluate("object.method_nonexistant(10, 11)").isError(), true); + QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), -1); QCOMPARE(o.actuals().count(), 0); diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index 5850cf0..70e70d0 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -223,55 +223,55 @@ void tst_anchors::illegalSets_data() QTest::newRow("H - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }" - << "QML Rectangle (file::2:23) Can't specify left, right, and hcenter anchors."; + << "QML Rectangle (file::2:23) Cannot specify left, right, and hcenter anchors."; foreach (const QString &side, QStringList() << "left" << "right") { QTest::newRow("H - anchor to V") << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "QML Rectangle (file::2:13) Can't anchor a horizontal edge to a vertical edge."; + << "QML Rectangle (file::2:13) Cannot anchor a horizontal edge to a vertical edge."; QTest::newRow("H - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("H - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Cannot anchor item to self."; } QTest::newRow("V - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "QML Rectangle (file::2:23) Can't specify top, bottom, and vcenter anchors."; + << "QML Rectangle (file::2:23) Cannot specify top, bottom, and vcenter anchors."; QTest::newRow("V - too many anchors with baseline") << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "QML Text (file::2:47) Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; + << "QML Text (file::2:47) Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { QTest::newRow("V - anchor to H") << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "QML Rectangle (file::2:13) Can't anchor a vertical edge to a horizontal edge."; + << "QML Rectangle (file::2:13) Cannot anchor a vertical edge to a horizontal edge."; QTest::newRow("V - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("V - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Cannot anchor item to self."; } QTest::newRow("centerIn - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("fill - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; } void tst_anchors::reset() @@ -348,7 +348,7 @@ void tst_anchors::nullItem() const QMetaObject *meta = item->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Can't anchor to a null item."); + QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item."); QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); delete item; diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt index 68fe671..492bbb4 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt @@ -1 +1 @@ -5:17:Cannot assign to non-existant property "foo" +5:17:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt index 7f630f4..ff2409b 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt @@ -1 +1 @@ -5:15:Non-existant attached object +5:15:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt index 9f06e07..34de769 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt @@ -1 +1 @@ -5:27:Cannot assign to non-existant property "foo" +5:27:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt index 7f630f4..ff2409b 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt @@ -1 +1 @@ -5:15:Non-existant attached object +5:15:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt index 19934fa..69c6871 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt @@ -1 +1 @@ -4:5:Cannot assign to non-existant property "foo" +4:5:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt b/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt index e243ae5..f562246 100644 --- a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt @@ -1 +1 @@ -4:5:Cannot assign to non-existant property "onClicked" +4:5:Cannot assign to non-existent property "onClicked" diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt index dfaa218..caf7e55 100644 --- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt @@ -1 +1 @@ -4:18:Cannot assign to non-existant property "foo" +4:18:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt index cfc6fc8..6bfce9a 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt @@ -1 +1 @@ -2:15:Cannot assign to non-existant property "something" +2:15:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt index c02d7bd..89925b7 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant default property +3:5:Cannot assign to non-existent default property diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp index fc348a5..4e4f3fb 100644 --- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -731,7 +731,7 @@ void tst_states::propertyErrors() QCOMPARE(rect->color(),QColor("red")); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existant property \"colr\"").constData()); + QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData()); QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData()); rect->setState("blue"); } @@ -877,7 +877,7 @@ void tst_states::nonExistantProperty() QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existant property \"colr\"").constData()); + QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData()); rect->setState("blue"); QCOMPARE(rect->state(), QLatin1String("blue")); } -- cgit v0.12 From 96be992ccdc7a9aaf02672234be7bd341be105e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 10:12:11 +0100 Subject: Designer:Fix undo crash caused by special handling of key move. Remove special handling and storing of commands. Customize SetPropertyCommand such that it is able to perform a transformation of the new value., thus, the same (relative) distance can be used on all widgets and the normal command merging mechanism can be used to merge subsequent moves correctly. Task-number: QTBUG-8213 --- .../src/components/formeditor/formwindow.cpp | 172 ++++++++++++++------- .../src/components/formeditor/formwindow.h | 3 - .../src/lib/shared/qdesigner_formwindowcommand.cpp | 6 +- .../src/lib/shared/qdesigner_formwindowcommand_p.h | 4 +- .../src/lib/shared/qdesigner_propertycommand.cpp | 54 +++++-- .../src/lib/shared/qdesigner_propertycommand_p.h | 28 +++- 6 files changed, 177 insertions(+), 90 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 3a7cd83..8b8351d 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1428,26 +1428,123 @@ int FormWindow::calcValue(int val, bool forward, bool snap, int snapOffset) cons return (forward ? val + 1 : val - 1); } -QRect FormWindow::applyValue(const QRect &rect, int val, int key, bool size) const +// ArrowKeyOperation: Stores a keyboard move or resize (Shift pressed) +// operation. +struct ArrowKeyOperation { + ArrowKeyOperation() : resize(false), distance(0), arrowKey(Qt::Key_Left) {} + + QRect apply(const QRect &in) const; + + bool resize; // Resize: Shift-Key->drag bottom/right corner, else just move + int distance; + int arrowKey; +}; + +QRect ArrowKeyOperation::apply(const QRect &rect) const { QRect r = rect; - if (size) { - if (key == Qt::Key_Left || key == Qt::Key_Right) - r.setWidth(val); + if (resize) { + if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right) + r.setWidth(r.width() + distance); else - r.setHeight(val); + r.setHeight(r.height() + distance); } else { - if (key == Qt::Key_Left || key == Qt::Key_Right) - r.moveLeft(val); + if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right) + r.moveLeft(r.x() + distance); else - r.moveTop(val); + r.moveTop(r.y() + distance); } return r; } +QDebug operator<<(QDebug in, const ArrowKeyOperation &op) +{ + in.nospace() << "Resize=" << op.resize << " dist=" << op.distance << " Key=" << op.arrowKey << ' '; + return in; +} + +} // namespace qdesigner_internal + +Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) + +namespace qdesigner_internal { + +// ArrowKeyPropertyHelper: Applies a struct ArrowKeyOperation +// (stored as new value) to a list of widgets using to calculate the +// changed geometry of the widget in setValue(). Thus, the 'newValue' +// of the property command is the relative move distance, which is the same +// for all widgets (although resulting in different geometries for the widgets). +// The command merging can then work as it would when applying the same text +// to all QLabels. + +class ArrowKeyPropertyHelper : public PropertyHelper { +public: + ArrowKeyPropertyHelper(QObject* o, SpecialProperty sp, + QDesignerPropertySheetExtension *s, int i) : + PropertyHelper(o, sp, s, i) {} + + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); +}; + +PropertyHelper::Value ArrowKeyPropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) +{ + // Apply operation to obtain the new geometry value. + QWidget *w = qobject_cast(object()); + const ArrowKeyOperation operation = qvariant_cast(value); + const QRect newGeom = operation.apply(w->geometry()); + return PropertyHelper::setValue(fw, QVariant(newGeom), changed, subPropertyMask); +} + +// ArrowKeyPropertyCommand: Helper factory overwritten to create +// ArrowKeyPropertyHelper and a merge operation that merges values of +// the same direction. +class ArrowKeyPropertyCommand: public SetPropertyCommand { +public: + explicit ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw, + QUndoCommand *p = 0); + + void init(QWidgetList &l, const ArrowKeyOperation &op); + +protected: + virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp, + QDesignerPropertySheetExtension *s, int i) const + { return new ArrowKeyPropertyHelper(o, sp, s, i); } + virtual QVariant mergeValue(const QVariant &newValue); +}; + +ArrowKeyPropertyCommand::ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw, + QUndoCommand *p) : + SetPropertyCommand(fw, p) +{ + static const int mid = qRegisterMetaType(); + Q_UNUSED(mid) +} + +void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) +{ + QObjectList ol; + foreach(QWidget *w, l) + ol.push_back(w); + SetPropertyCommand::init(ol, QLatin1String("geometry"), qVariantFromValue(op)); + + setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move")); +} + +QVariant ArrowKeyPropertyCommand::mergeValue(const QVariant &newMergeValue) +{ + // Merge move operations of the same arrow key + if (!qVariantCanConvert(newMergeValue)) + return QVariant(); + ArrowKeyOperation mergedOperation = qvariant_cast(newValue()); + const ArrowKeyOperation newMergeOperation = qvariant_cast(newMergeValue); + if (mergedOperation.resize != newMergeOperation.resize || mergedOperation.arrowKey != newMergeOperation.arrowKey) + return QVariant(); + mergedOperation.distance += newMergeOperation.distance; + return qVariantFromValue(mergedOperation); +} + void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) { - bool startMacro = false; const QDesignerFormWindowCursorInterface *c = cursor(); if (!c->hasSelection()) return; @@ -1480,57 +1577,14 @@ void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) const int newValue = calcValue(oldValue, forward, snap, snapPoint); - const int offset = newValue - oldValue; + ArrowKeyOperation operation; + operation.resize = modifiers & Qt::ShiftModifier; + operation.distance = newValue - oldValue; + operation.arrowKey = key; - const int selCount = selection.count(); - // check if selection is the same as last time - if (selCount != m_moveSelection.count() || - m_lastUndoIndex != m_commandHistory->index()) { - m_moveSelection.clear(); - startMacro = true; - } else { - for (int index = 0; index < selCount; ++index) { - if (m_moveSelection[index]->object() != selection.at(index)) { - m_moveSelection.clear(); - startMacro = true; - break; - } - } - } - - if (startMacro) - beginCommand(tr("Key Move")); - - for (int index = 0; index < selCount; ++index) { - QWidget *w = selection.at(index); - const QRect oldGeom = w->geometry(); - const QRect geom = applyValue(oldGeom, getValue(oldGeom, key, size) + offset, key, size); - - SetPropertyCommand *cmd = 0; - - if (m_moveSelection.count() > index) - cmd = m_moveSelection[index]; - - if (!cmd) { - cmd = new SetPropertyCommand(this); - cmd->init(w, QLatin1String("geometry"), geom); - cmd->setText(tr("Key Move")); - m_commandHistory->push(cmd); - - if (m_moveSelection.count() > index) - m_moveSelection.replace(index, cmd); - else - m_moveSelection.append(cmd); - } else { - cmd->setNewValue(geom); - cmd->redo(); - } - } - - if (startMacro) { - endCommand(); - m_lastUndoIndex = m_commandHistory->index(); - } + ArrowKeyPropertyCommand *cmd = new ArrowKeyPropertyCommand(this); + cmd->init(selection, operation); + m_commandHistory->push(cmd); } bool FormWindow::handleKeyReleaseEvent(QWidget *, QWidget *, QKeyEvent *e) diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 3eee476..1b2916c 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -263,7 +263,6 @@ private: int getValue(const QRect &rect, int key, bool size) const; int calcValue(int val, bool forward, bool snap, int snapOffset) const; - QRect applyValue(const QRect &rect, int val, int key, bool size) const; void handleClickSelection(QWidget *managedWidget, unsigned mouseFlags); bool frameNeeded(QWidget *w) const; @@ -368,8 +367,6 @@ private: QString m_exportMacro; QStringList m_includeHints; - QList m_moveSelection; - int m_lastUndoIndex; QPoint m_contextMenuPosition; private: diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index 8c55d26..490373e 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -62,8 +62,10 @@ QT_BEGIN_NAMESPACE namespace qdesigner_internal { // ---- QDesignerFormWindowCommand ---- -QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow) - : QUndoCommand(description), +QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, + QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) + : QUndoCommand(description, parent), m_formWindow(formWindow) { } diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h index d8cd018..d73d70c 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h @@ -70,7 +70,9 @@ class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand { public: - QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow); + QDesignerFormWindowCommand(const QString &description, + QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent = 0); virtual void undo(); virtual void redo(); diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp index 822c14b..6cc054c 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -926,8 +926,9 @@ bool PropertyListCommand::PropertyDescription::equals(const PropertyDescription // ---- PropertyListCommand -PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow) : - QDesignerFormWindowCommand(QString(), formWindow) +PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) : + QDesignerFormWindowCommand(QString(), formWindow, parent) { } @@ -966,10 +967,17 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName) if (!match || m_propertyDescription.m_specialProperty == SP_ObjectName) return false; } - m_propertyHelperList.push_back(PropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index)); + + const PropertyHelperPtr ph(createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index)); + m_propertyHelperList.push_back(ph); return true; } +PropertyHelper *PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const +{ + return new PropertyHelper(object, sp, sheet, sheetIndex); +} // Init from a list and make sure referenceObject is added first to obtain the right property group bool PropertyListCommand::initList(const ObjectList &list, const QString &apropertyName, QObject *referenceObject) @@ -993,19 +1001,19 @@ bool PropertyListCommand::initList(const ObjectList &list, const QString &aprope QObject* PropertyListCommand::object(int index) const { Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList[index].object(); + return m_propertyHelperList.at(index)->object(); } QVariant PropertyListCommand::oldValue(int index) const { Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList[index].oldValue(); + return m_propertyHelperList.at(index)->oldValue(); } void PropertyListCommand::setOldValue(const QVariant &oldValue, int index) { Q_ASSERT(index < m_propertyHelperList.size()); - m_propertyHelperList[index].setOldValue(oldValue); + m_propertyHelperList.at(index)->setOldValue(oldValue); } // ----- SetValueFunction: Set a new value when applied to a PropertyHelper. class SetValueFunction { @@ -1065,9 +1073,10 @@ template bool updatedPropertyEditor = false; for (PropertyListIterator it = begin; it != end; ++it) { - if (QObject* object = it->object()) { // Might have been deleted in the meantime - const PropertyHelper::Value newValue = function(*it); - updateMask |= it->updateMask(); + PropertyHelper *ph = it->data(); + if (QObject* object = ph->object()) { // Might have been deleted in the meantime + const PropertyHelper::Value newValue = function( *ph ); + updateMask |= ph->updateMask(); // Update property editor if it is the current object if (!updatedPropertyEditor && propertyEditor && object == propertyEditor->object()) { propertyEditor->setPropertyValue(propertyName, newValue.first, newValue.second); @@ -1084,9 +1093,11 @@ template unsigned PropertyListCommand::setValue(QVariant value, bool changed, unsigned subPropertyMask) { if(debugPropertyCommands) - qDebug() << "PropertyListCommand::setValue(" << value << changed << subPropertyMask << ')'; + qDebug() << "PropertyListCommand::setValue(" << value + << changed << subPropertyMask << ')'; return changePropertyList(formWindow()->core(), - m_propertyDescription.m_propertyName, m_propertyHelperList.begin(), m_propertyHelperList.end(), + m_propertyDescription.m_propertyName, + m_propertyHelperList.begin(), m_propertyHelperList.end(), SetValueFunction(formWindow(), PropertyHelper::Value(value, changed), subPropertyMask)); } @@ -1146,15 +1157,16 @@ bool PropertyListCommand::canMergeLists(const PropertyHelperList& other) const if (m_propertyHelperList.size() != other.size()) return false; for (int i = 0; i < m_propertyHelperList.size(); i++) { - if (!m_propertyHelperList[i].canMerge(other[i])) + if (!m_propertyHelperList.at(i)->canMerge(*other.at(i))) return false; } return true; } // ---- SetPropertyCommand ---- -SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow) - : PropertyListCommand(formWindow), +SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) + : PropertyListCommand(formWindow, parent), m_subPropertyMask(SubPropertyAll) { } @@ -1210,7 +1222,7 @@ unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject * void SetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName())); + setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QApplication::translate("Command", "Changed '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName())); @@ -1231,6 +1243,11 @@ int SetPropertyCommand::id() const return 1976; } +QVariant SetPropertyCommand::mergeValue(const QVariant &newValue) +{ + return newValue; +} + bool SetPropertyCommand::mergeWith(const QUndoCommand *other) { if (id() != other->id() || !formWindow()->isDirty()) @@ -1248,7 +1265,10 @@ bool SetPropertyCommand::mergeWith(const QUndoCommand *other) !canMergeLists(cmd->propertyHelperList())) return false; - m_newValue = cmd->newValue(); + const QVariant newValue = mergeValue(cmd->newValue()); + if (!newValue.isValid()) + return false; + m_newValue = newValue; m_subPropertyMask |= cmd->m_subPropertyMask; if(debugPropertyCommands) qDebug() << "SetPropertyCommand::mergeWith() succeeded " << propertyName(); @@ -1289,7 +1309,7 @@ bool ResetPropertyCommand::init(const ObjectList &list, const QString &aproperty void ResetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName())); + setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QApplication::translate("Command", "Reset '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName())); diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h index f6b7262..75b23ca 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h @@ -58,6 +58,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -77,11 +78,12 @@ enum SpecialProperty { //Determine special property enum SpecialProperty getSpecialProperty(const QString& propertyName); - // A helper class for applying properties to objects. // Can be used for Set commands (setValue(), restoreOldValue()) or // Reset Commands restoreDefaultValue(), restoreOldValue()). -class PropertyHelper { +// +class QDESIGNER_SHARED_EXPORT PropertyHelper { + Q_DISABLE_COPY(PropertyHelper) public: // A pair of Value and changed flag typedef QPair Value; @@ -92,11 +94,13 @@ public: SpecialProperty specialProperty, QDesignerPropertySheetExtension *sheet, int index); + virtual ~PropertyHelper() {} QObject *object() const { return m_object; } SpecialProperty specialProperty() const { return m_specialProperty; } - // set a new value - Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); + // set a new value. Can be overwritten to perform a transformation (see + // handling of Arrow key move in FormWindow class). + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); // restore old value Value restoreOldValue(QDesignerFormWindowInterface *fw); @@ -147,7 +151,7 @@ class QDESIGNER_SHARED_EXPORT PropertyListCommand : public QDesignerFormWindowCo public: typedef QList ObjectList; - explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow); + explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0); QObject* object(int index = 0) const; @@ -159,8 +163,8 @@ public: virtual void undo(); protected: - typedef QList PropertyHelperList; - + typedef QSharedPointer PropertyHelperPtr; + typedef QList PropertyHelperList; // add an object bool add(QObject *object, const QString &propertyName); @@ -204,6 +208,10 @@ protected: }; const PropertyDescription &propertyDescription() const { return m_propertyDescription; } +protected: + virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const; + private: PropertyDescription m_propertyDescription; PropertyHelperList m_propertyHelperList; @@ -215,7 +223,7 @@ class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public PropertyListCommand public: typedef QList ObjectList; - explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow); + explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0); bool init(QObject *object, const QString &propertyName, const QVariant &newValue); bool init(const ObjectList &list, const QString &propertyName, const QVariant &newValue, @@ -232,6 +240,10 @@ public: bool mergeWith(const QUndoCommand *other); virtual void redo(); + +protected: + virtual QVariant mergeValue(const QVariant &newValue); + private: unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject); void setDescription(); -- cgit v0.12 From 73be91d3ec0f9c0701db7260f62426d43fdf5fb0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 16 Feb 2010 11:57:10 +0100 Subject: fix line endings get your git settings fixed, windows users! --- .../declarative/webview/content/Mapping/Map.qml | 40 ++++----- .../declarative/webview/content/Mapping/map.html | 94 +++++++++++----------- examples/declarative/webview/googleMaps.qml | 62 +++++++------- .../data/NoResizeGraphicsWidget.qml | 16 ++-- .../data/SizeGraphicsWidgetToLoader.qml | 16 ++-- .../data/SizeLoaderToGraphicsWidget.qml | 12 +-- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index aae6b5d..2e98940 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -1,20 +1,20 @@ -import Qt 4.6 - -Item { - id: page - property real latitude: -34.397 - property real longitude: 150.644 - property string address: "" - WebView { - id: map - anchors.fill: parent - url: "map.html" - javaScriptWindowObjects: QtObject { - WebView.windowObjectName: "qml" - property real lat: page.latitude - property real lng: page.longitude - property string address: page.address - onAddressChanged: {map.evaluateJavaScript("goToAddress()")} - } - } -} +import Qt 4.6 + +Item { + id: page + property real latitude: -34.397 + property real longitude: 150.644 + property string address: "" + WebView { + id: map + anchors.fill: parent + url: "map.html" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + property real lat: page.latitude + property real lng: page.longitude + property string address: page.address + onAddressChanged: {map.evaluateJavaScript("goToAddress()")} + } + } +} diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html index 8afa21c..72f426a 100755 --- a/examples/declarative/webview/content/Mapping/map.html +++ b/examples/declarative/webview/content/Mapping/map.html @@ -1,47 +1,47 @@ - - - - - - - -
- - + + + + + + + +
+ + diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml index b5b13bb..1886961 100644 --- a/examples/declarative/webview/googleMaps.qml +++ b/examples/declarative/webview/googleMaps.qml @@ -1,31 +1,31 @@ -// This example demonstrates how Web services such as Google Maps can be -// abstracted as QML types. Here we have a "Mapping" module with a "Map" -// type. The Map type has an address property. Setting that property moves -// the map. The underlying implementation uses WebView and the Google Maps -// API, but users from QML don't need to understand the implementation in -// order to create a Map. - -import Qt 4.6 -import "content/Mapping" - -Map { - id: map - width: 300 - height: 300 - address: "Paris" - Rectangle { - color: "white" - width: input.width + 20 - height: input.height + 4 - radius: 5 - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - x: 70 - TextInput { - id: input - text: map.address - anchors.centerIn: parent - Keys.onReturnPressed: map.address = input.text - } - } -} +// This example demonstrates how Web services such as Google Maps can be +// abstracted as QML types. Here we have a "Mapping" module with a "Map" +// type. The Map type has an address property. Setting that property moves +// the map. The underlying implementation uses WebView and the Google Maps +// API, but users from QML don't need to understand the implementation in +// order to create a Map. + +import Qt 4.6 +import "content/Mapping" + +Map { + id: map + width: 300 + height: 300 + address: "Paris" + Rectangle { + color: "white" + width: input.width + 20 + height: input.height + 4 + radius: 5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + x: 70 + TextInput { + id: input + text: map.address + anchors.centerIn: parent + Keys.onReturnPressed: map.address = input.text + } + } +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml index 0704e18..5eab965 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.NoResize - source: "GraphicsWidget250x250.qml" - width: 200 - height: 80 -} +import Qt 4.6 + +Loader { + resizeMode: Loader.NoResize + source: "GraphicsWidget250x250.qml" + width: 200 + height: 80 +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml index 97c72f4..568a136 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeItemToLoader - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeItemToLoader + width: 200 + height: 80 + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml index cb72f05..a710803 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml @@ -1,6 +1,6 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeLoaderToItem - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeLoaderToItem + source: "GraphicsWidget250x250.qml" +} -- cgit v0.12 From 329148df0bdbf7e66c2ba0f6608eb49658f5f2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 16 Feb 2010 12:51:16 +0100 Subject: doc: A QPlainTextEdit is never a QTextBrowser --- src/gui/widgets/qplaintextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 02ffe13..0d798b7 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -2394,7 +2394,7 @@ void QPlainTextEdit::setReadOnly(bool ro) then the focus policy is also automatically set to Qt::ClickFocus. The default value depends on whether the QPlainTextEdit is read-only - or editable, and whether it is a QTextBrowser or not. + or editable. */ void QPlainTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) -- cgit v0.12 From f36b0cb1ecdfd0cda6537bdd3acf47eb216db49f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 14:19:53 +0100 Subject: Designer: Implement isDirty()-handling using a QUndoStack. Remove Designer-specific handling of isDirty() due to its bug-proneness, use instead an extended QUndoStack.that allows for setting to 'dirty' without commands for some special cases. Task-number: QTBUG-8041 --- .../src/components/formeditor/formeditor.pri | 2 + .../src/components/formeditor/formwindow.cpp | 53 +++++----- .../src/components/formeditor/formwindow.h | 13 +-- .../components/formeditor/qdesignerundostack.cpp | 108 +++++++++++++++++++++ .../src/components/formeditor/qdesignerundostack.h | 89 +++++++++++++++++ 5 files changed, 225 insertions(+), 40 deletions(-) create mode 100644 tools/designer/src/components/formeditor/qdesignerundostack.cpp create mode 100644 tools/designer/src/components/formeditor/qdesignerundostack.h diff --git a/tools/designer/src/components/formeditor/formeditor.pri b/tools/designer/src/components/formeditor/formeditor.pri index bbe96d5..b1a9318 100644 --- a/tools/designer/src/components/formeditor/formeditor.pri +++ b/tools/designer/src/components/formeditor/formeditor.pri @@ -8,6 +8,7 @@ FORMS += $$PWD/deviceprofiledialog.ui \ $$PWD/templateoptionspage.ui HEADERS += $$PWD/qdesigner_resource.h \ + $$PWD/qdesignerundostack.h \ $$PWD/formwindow.h \ $$PWD/formwindow_widgetstack.h \ $$PWD/formwindow_dnditem.h \ @@ -41,6 +42,7 @@ HEADERS += $$PWD/qdesigner_resource.h \ $$PWD/templateoptionspage.h SOURCES += $$PWD/qdesigner_resource.cpp \ + $$PWD/qdesignerundostack.cpp \ $$PWD/formwindow.cpp \ $$PWD/formwindow_widgetstack.cpp \ $$PWD/formwindow_dnditem.cpp \ diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 8b8351d..ccb1984 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -399,8 +399,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start) void FormWindow::init() { if (FormWindowManager *manager = qobject_cast (core()->formWindowManager())) { - m_commandHistory = new QUndoStack(this); - manager->undoGroup()->addStack(m_commandHistory); + manager->undoGroup()->addStack(m_undoStack.qundoStack()); } m_blockSelectionChanged = false; @@ -429,9 +428,8 @@ void FormWindow::init() m_mainContainer = 0; m_currentWidget = 0; - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(updateDirty())); - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SIGNAL(changed())); - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(checkSelection())); + connect(&m_undoStack, SIGNAL(changed()), this, SIGNAL(changed())); + connect(&m_undoStack, SIGNAL(changed()), this, SLOT(checkSelection())); core()->metaDataBase()->add(this); @@ -1227,14 +1225,14 @@ void FormWindow::insertWidget(QWidget *w, const QRect &rect, QWidget *container, if (w->parentWidget() != container) { ReparentWidgetCommand *cmd = new ReparentWidgetCommand(this); cmd->init(w, container); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } - m_commandHistory->push(geom_cmd); + m_undoStack.push(geom_cmd); InsertWidgetCommand *cmd = new InsertWidgetCommand(this); cmd->init(w, already_in_form); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); endCommand(); @@ -1277,12 +1275,10 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry) Q_ASSERT(isDescendant(this, widget)); QRect r = geometry; - if (m_lastIndex > m_commandHistory->index()) - m_lastIndex = -1; SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, QLatin1String("geometry"), r); cmd->setText(tr("Resize")); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } void FormWindow::raiseChildSelections(QWidget *w) @@ -1584,7 +1580,7 @@ void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) ArrowKeyPropertyCommand *cmd = new ArrowKeyPropertyCommand(this); cmd->init(selection, operation); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } bool FormWindow::handleKeyReleaseEvent(QWidget *, QWidget *, QKeyEvent *e) @@ -1863,7 +1859,7 @@ void FormWindow::paste(PasteMode pasteMode) foreach (QWidget *w, clipboard.m_widgets) { InsertWidgetCommand *cmd = new InsertWidgetCommand(this); cmd->init(w); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); selectWidget(w); } } @@ -1873,7 +1869,7 @@ void FormWindow::paste(PasteMode pasteMode) ensureUniqueObjectName(a); AddActionCommand *cmd = new AddActionCommand(this); cmd->init(a); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } while (false); @@ -2009,14 +2005,12 @@ void FormWindow::breakLayout(QWidget *w) void FormWindow::beginCommand(const QString &description) { - if (m_lastIndex > m_commandHistory->index()) - m_lastIndex = -1; - m_commandHistory->beginMacro(description); + m_undoStack.beginMacro(description); } void FormWindow::endCommand() { - m_commandHistory->endMacro(); + m_undoStack.endMacro(); } void FormWindow::raiseWidgets() @@ -2031,7 +2025,7 @@ void FormWindow::raiseWidgets() foreach (QWidget *widget, widgets) { RaiseWidgetCommand *cmd = new RaiseWidgetCommand(this); cmd->init(widget); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } @@ -2048,7 +2042,7 @@ void FormWindow::lowerWidgets() foreach (QWidget *widget, widgets) { LowerWidgetCommand *cmd = new LowerWidgetCommand(this); cmd->init(widget); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } @@ -2429,20 +2423,12 @@ FormWindow *FormWindow::findFormWindow(QWidget *w) bool FormWindow::isDirty() const { - return m_dirty; + return m_undoStack.isDirty(); } void FormWindow::setDirty(bool dirty) { - m_dirty = dirty; - - if (!m_dirty) - m_lastIndex = m_commandHistory->index(); -} - -void FormWindow::updateDirty() -{ - m_dirty = m_commandHistory->index() != m_lastIndex; + m_undoStack.setDirty(dirty); } QWidget *FormWindow::containerAt(const QPoint &pos) @@ -2811,7 +2797,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g qVariantSetValue(v, e); SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, dockWidgetAreaName, v); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); @@ -2975,6 +2961,11 @@ QWidget *FormWindow::formContainer() const return m_widgetStack->formContainer(); } +QUndoStack *FormWindow::commandHistory() const +{ + return const_cast(m_undoStack).qundoStack(); +} + } // namespace QT_END_NAMESPACE diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 1b2916c..06f60b5 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -43,6 +43,7 @@ #define FORMWINDOW_H #include "formeditor_global.h" +#include "qdesignerundostack.h" #include // Qt @@ -64,7 +65,6 @@ class QLabel; class QTimer; class QAction; class QMenu; -class QUndoStack; class QRubberBand; namespace qdesigner_internal { @@ -76,6 +76,7 @@ class FormWindowWidgetStack; class FormWindowManager; class FormWindowDnDItem; class SetPropertyCommand; +class QDesignerUndoStack; class QT_FORMEDITOR_EXPORT FormWindow: public FormWindowBase { @@ -165,9 +166,7 @@ public: void manageWidget(QWidget *w); void unmanageWidget(QWidget *w); - inline QUndoStack *commandHistory() const - { return m_commandHistory; } - + virtual QUndoStack *commandHistory() const; void beginCommand(const QString &description); void endCommand(); @@ -238,7 +237,6 @@ protected: private slots: void selectionChangedTimerDone(); - void updateDirty(); void checkSelection(); void checkSelectionNow(); void slotSelectWidget(QAction *); @@ -337,7 +335,7 @@ private: QPoint m_startPos; - QUndoStack *m_commandHistory; + QDesignerUndoStack m_undoStack; QString m_fileName; @@ -351,9 +349,6 @@ private: QTimer *m_checkSelectionTimer; QTimer *m_geometryChangedTimer; - int m_dirty; - int m_lastIndex; - FormWindowWidgetStack *m_widgetStack; WidgetEditorTool *m_widgetEditor; diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.cpp b/tools/designer/src/components/formeditor/qdesignerundostack.cpp new file mode 100644 index 0000000..6996bcd --- /dev/null +++ b/tools/designer/src/components/formeditor/qdesignerundostack.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qdesignerundostack.h" + +#include +#include + +namespace qdesigner_internal { + +QDesignerUndoStack::QDesignerUndoStack(QObject *parent) : + QObject(parent), + m_undoStack(new QUndoStack), + m_fakeDirty(false) +{ + connect(m_undoStack, SIGNAL(indexChanged(int)), this, SIGNAL(changed())); +} + +QDesignerUndoStack::~QDesignerUndoStack() +{ // QUndoStack is managed by the QUndoGroup +} + +void QDesignerUndoStack::push(QUndoCommand * cmd) +{ + m_undoStack->push(cmd); +} + +void QDesignerUndoStack::beginMacro(const QString &text) +{ + m_undoStack->beginMacro(text); +} + +void QDesignerUndoStack::endMacro() +{ + m_undoStack->endMacro(); +} + +int QDesignerUndoStack::index() const +{ + return m_undoStack->index(); +} + +const QUndoStack *QDesignerUndoStack::qundoStack() const +{ + return m_undoStack; +} +QUndoStack *QDesignerUndoStack::qundoStack() +{ + return m_undoStack; +} + +bool QDesignerUndoStack::isDirty() const +{ + return m_fakeDirty || !m_undoStack->isClean(); +} + +void QDesignerUndoStack::setDirty(bool v) +{ + if (isDirty() == v) + return; + if (v) { + m_fakeDirty = true; + emit changed(); + } else { + m_fakeDirty = false; + m_undoStack->setClean(); + } +} + +} // namespace qdesigner_internal diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.h b/tools/designer/src/components/formeditor/qdesignerundostack.h new file mode 100644 index 0000000..b1b3389 --- /dev/null +++ b/tools/designer/src/components/formeditor/qdesignerundostack.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 Qt Designer 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 QDESIGNERUNDOSTACK_H +#define QDESIGNERUNDOSTACK_H + +#include + +QT_BEGIN_NAMESPACE +class QUndoStack; +class QUndoCommand; +QT_END_NAMESPACE + +namespace qdesigner_internal { + +/* QDesignerUndoStack: A QUndoStack extended by a way of setting it to + * "dirty" indepently of commands (by modifications without commands + * such as resizing). Accomplished via bool m_fakeDirty flag. The + * lifecycle of the QUndoStack is managed by the QUndoGroup. */ +class QDesignerUndoStack : public QObject +{ + Q_DISABLE_COPY(QDesignerUndoStack) + Q_OBJECT +public: + explicit QDesignerUndoStack(QObject *parent = 0); + virtual ~QDesignerUndoStack(); + + void push(QUndoCommand * cmd); + void beginMacro(const QString &text); + void endMacro(); + int index() const; + + const QUndoStack *qundoStack() const; + QUndoStack *qundoStack(); + + bool isDirty() const; + +signals: + void changed(); + +public slots: + void setDirty(bool); + +private: + QUndoStack *m_undoStack; + bool m_fakeDirty; +}; + +} // namespace qdesigner_internal + +#endif // QDESIGNERUNDOSTACK_H -- cgit v0.12 From 684e86adea5e89d6220560e82f1823f99920bb40 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 16 Feb 2010 15:11:58 +0100 Subject: Designer: Fix compile for namespaced qt. --- tools/designer/src/components/formeditor/formwindow.cpp | 8 ++------ tools/designer/src/components/formeditor/formwindow.h | 1 - tools/designer/src/components/formeditor/qdesignerundostack.cpp | 4 ++++ tools/designer/src/components/formeditor/qdesignerundostack.h | 3 ++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index ccb1984..631ca7c 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1459,12 +1459,6 @@ QDebug operator<<(QDebug in, const ArrowKeyOperation &op) return in; } -} // namespace qdesigner_internal - -Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) - -namespace qdesigner_internal { - // ArrowKeyPropertyHelper: Applies a struct ArrowKeyOperation // (stored as new value) to a list of widgets using to calculate the // changed geometry of the widget in setValue(). Thus, the 'newValue' @@ -2969,3 +2963,5 @@ QUndoStack *FormWindow::commandHistory() const } // namespace QT_END_NAMESPACE + +Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 06f60b5..dc0026f 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -76,7 +76,6 @@ class FormWindowWidgetStack; class FormWindowManager; class FormWindowDnDItem; class SetPropertyCommand; -class QDesignerUndoStack; class QT_FORMEDITOR_EXPORT FormWindow: public FormWindowBase { diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.cpp b/tools/designer/src/components/formeditor/qdesignerundostack.cpp index 6996bcd..007031d 100644 --- a/tools/designer/src/components/formeditor/qdesignerundostack.cpp +++ b/tools/designer/src/components/formeditor/qdesignerundostack.cpp @@ -44,6 +44,8 @@ #include #include +QT_BEGIN_NAMESPACE + namespace qdesigner_internal { QDesignerUndoStack::QDesignerUndoStack(QObject *parent) : @@ -106,3 +108,5 @@ void QDesignerUndoStack::setDirty(bool v) } } // namespace qdesigner_internal + +QT_END_NAMESPACE diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.h b/tools/designer/src/components/formeditor/qdesignerundostack.h index b1b3389..5451ad8 100644 --- a/tools/designer/src/components/formeditor/qdesignerundostack.h +++ b/tools/designer/src/components/formeditor/qdesignerundostack.h @@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE class QUndoStack; class QUndoCommand; -QT_END_NAMESPACE namespace qdesigner_internal { @@ -86,4 +85,6 @@ private: } // namespace qdesigner_internal +QT_END_NAMESPACE + #endif // QDESIGNERUNDOSTACK_H -- cgit v0.12 From 505dc33a4060b6fb2a80f3a3ab2a6702ec0b5f3b Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 17 Feb 2010 13:02:37 +0100 Subject: Make the licenseheader check pass trivial files. A file that contains so little doesn't have to have the copyright header. A good example usecase is a header file with nothing but an include line to another header. Reviewed-by: Thiago Macieira --- tests/auto/headers/tst_headers.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 5f79923..bf7ec3f 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -192,19 +192,20 @@ void tst_Headers::licenseCheck() QByteArray data = f.readAll(); data.replace("\r\n", "\n"); // Windows data.replace('\r', '\n'); // Mac OS9 - QStringList content = QString::fromLocal8Bit(data).split("\n"); + QStringList content = QString::fromLocal8Bit(data).split("\n", QString::SkipEmptyParts); + + if (content.count() <= 2) // likely a #include line and empty line only. Not a copyright issue. + return; if (content.first().contains("generated")) { content.takeFirst(); - if (content.first().isEmpty()) - content.takeFirst(); } if (sourceFile.endsWith("/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp") || sourceFile.endsWith("/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp")) { // These files are meant to start with empty lines. - while (content.first().isEmpty() || content.first().startsWith("//")) + while (content.first().startsWith("//")) content.takeFirst(); } -- cgit v0.12