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