diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-16 17:19:46 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-16 17:19:46 (GMT) |
commit | da2a86555ba79fa67cf98c5985ff64cfdb6b57c7 (patch) | |
tree | 2fe40042e128329c8ad91f18bb1ec70b37da46dc | |
parent | 9d174f13e48730ac06aa429e0f011a02b333025e (diff) | |
parent | 42dda19d82ceea48f19d356cfaf2b26acb763df8 (diff) | |
download | Qt-da2a86555ba79fa67cf98c5985ff64cfdb6b57c7.zip Qt-da2a86555ba79fa67cf98c5985ff64cfdb6b57c7.tar.gz Qt-da2a86555ba79fa67cf98c5985ff64cfdb6b57c7.tar.bz2 |
Merge remote branch 'qt/master' into s60-master
Conflicts:
qmake/generators/symbian/symmake.cpp
tests/auto/qlineedit/tst_qlineedit.cpp
tests/benchmarks/benchmarks.pro
43 files changed, 1129 insertions, 2831 deletions
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 6913dc9..aab766d 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -75,21 +75,23 @@ 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 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 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_DEL_TREE = rm -rf QMAKE_CHK_DIR_EXISTS = if not exist } 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.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 <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <io.h> -#include <direct.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <windows.h> - -#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-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 <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <io.h> -#include <direct.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <windows.h> - -#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/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" 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/makefile.cpp b/qmake/generators/makefile.cpp index b0a8011..ec712a0 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -65,12 +65,6 @@ #include <sys/types.h> #include <sys/stat.h> -#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), @@ -2164,9 +2152,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"; @@ -2681,8 +2667,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/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 4151193..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,15 +457,8 @@ 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 || proj->first("TEMPLATE").indexOf(QRegExp("^ce.*")) != -1) + if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1) mkfile = new VcprojGenerator; else mkfile = new NmakeMakefileGenerator; diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 26dd3fd..a3a504f 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<QString, QStringList>::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" <<endl; -#endif + t << "\t-@ " << dirExists << " \"" << fixedValue << "\" " + << mkdir << " \"" << fixedValue << "\"" << endl; } } } @@ -324,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 ":" 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/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 <qdir.h> -#include <qset.h> - -#include <stdlib.h> - -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<DspMakefileGenerator*>(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<QString> > 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<QString>::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<QString>::fromSet(files["SWAPPED_BUILD_STEPS"]); - project->values("GENERATED_SOURCES") = QList<QString>::fromSet(files["GENERATED_SOURCES"]); - project->values("GENERATED_FILES") = QList<QString>::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<QString, WorkspaceDepend*> workspace_depends; - QList<WorkspaceDepend*> 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 <lib>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<QString, QStringList> &vars = tmp_proj.variables(); - for(QMap<QString, QStringList>::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<WorkspaceDepend*>::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<QString, FolderGroup *> subFolders; - QMap<QString, QString> 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<QString, FolderGroup *>::const_iterator folderIt = folder->subFolders.begin(); - while (folderIt != folder->subFolders.end()) { - writeSubFileGroup(t, folderIt.value()); - ++folderIt; - } - QMap<QString, QString>::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<QString, BuildStep> swappedBuildSteps; - - // Holds all configurations for glue (merged) project - QList<DspMakefileGenerator*> mergedProjects; -}; - -inline DspMakefileGenerator::~DspMakefileGenerator() -{ } - -inline bool DspMakefileGenerator::findLibraries() -{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } - -QT_END_NAMESPACE - -#endif // MSVC_DSP_H 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/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 4ce8ba4..8871152 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"; @@ -612,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; } @@ -1456,9 +1450,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()); @@ -1617,12 +1608,7 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QMap<QString, QString if((Option::target_mode == Option::TARG_MACX_MODE || Option::target_mode == Option::TARG_UNIX_MODE) && x == "unix") return !isForSymbian(); - else if(Option::target_mode == Option::TARG_MACX_MODE && x == "macx") - return !isForSymbian(); - else if(Option::target_mode == Option::TARG_MAC9_MODE && x == "mac9") - return !isForSymbian(); - else if((Option::target_mode == Option::TARG_MAC9_MODE || Option::target_mode == Option::TARG_MACX_MODE) && - x == "mac") + else if(Option::target_mode == Option::TARG_MACX_MODE && (x == "macx" || x == "mac")) return !isForSymbian(); else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32") return !isForSymbian(); @@ -3080,8 +3066,6 @@ QStringList &QMakeProject::values(const QString &_var, QMap<QString, QStringList QString orig_template = place["TEMPLATE"].first(), real_template; if(!Option::user_template_prefix.isEmpty() && !orig_template.startsWith(Option::user_template_prefix)) real_template = Option::user_template_prefix + orig_template; - if(real_template.endsWith(".t")) - real_template = real_template.left(real_template.length()-2); if(!real_template.isEmpty()) { var = ".BUILTIN." + var; place[var] = QStringList(real_template); 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 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 \ 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; 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--; diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index 26d488d..a9bc352 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -70,7 +70,7 @@ void AboutLabel::setText(const QString &text, const QByteArray &resources) TRACE_OBJ QDataStream in(resources); in >> m_resourceMap; - + QTextBrowser::setText(text); } @@ -96,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) @@ -153,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 @@ -165,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) @@ -173,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 edaf076..0733128 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -29,6 +29,8 @@ HEADERS += aboutdialog.h \ filternamedialog.h \ helpenginewrapper.h \ helpviewer.h \ + helpviewer_qtb.h \ + helpviewer_qwv.h \ indexwindow.h \ installdialog.h \ mainwindow.h \ @@ -55,6 +57,8 @@ SOURCES += aboutdialog.cpp \ filternamedialog.cpp \ helpenginewrapper.cpp \ helpviewer.cpp \ + helpviewer_qtb.cpp \ + helpviewer_qwv.cpp \ indexwindow.cpp \ installdialog.cpp \ main.cpp \ 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 <QtGui/QKeyEvent> #include <QtGui/QMenu> @@ -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 03af06c..dd91326 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -43,7 +43,8 @@ #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" #include "../shared/collectionconfiguration.h" @@ -57,6 +58,7 @@ #include <QtGui/QPrinter> #include <QtGui/QTabBar> #include <QtGui/QTabWidget> +#include <QtGui/QTextBrowser> #include <QtGui/QToolButton> #include <QtGui/QPageSetupDialog> #include <QtGui/QPrintDialog> @@ -70,6 +72,7 @@ namespace { HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, const QPoint &point) { + TRACE_OBJ QTabBar *tabBar = qFindChild<QTabBar*>(widget); for (int i = 0; i < tabBar->count(); ++i) { if (tabBar->tabRect(i).contains(point)) @@ -80,10 +83,8 @@ namespace { CentralWidget *staticCentralWidget = 0; } - // -- CentralWidget - CentralWidget::CentralWidget(MainWindow *parent) : QWidget(parent) , lastTabPage(0) @@ -174,7 +175,7 @@ CentralWidget::~CentralWidget() HelpViewer *viewer = qobject_cast<HelpViewer*>(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<HelpViewer*>(tabWidget->widget(index)); +} + +HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ return qobject_cast<HelpViewer*>(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<int, QString> 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<QWebView*> (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<QWebView*> (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<QAction*> globalActions() const; void setGlobalActions(const QList<QAction*> &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<QAction*> globalActionList; diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 976ed7a..e0347c8 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -144,7 +144,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast<QHelpContentModel*>(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) { @@ -170,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 8e4d3ed..8597f6b 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -38,603 +38,31 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "helpviewer.h" -#include "centralwidget.h" -#include "helpenginewrapper.h" - -#include <QtCore/QDir> -#include <QtCore/QEvent> -#include <QtCore/QVariant> -#include <QtCore/QByteArray> -#include <QtCore/QStringBuilder> -#include <QtCore/QTemporaryFile> -#include <QtCore/QTimer> - -#include <QtGui/QMenu> -#include <QtGui/QKeyEvent> -#include <QtGui/QClipboard> -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> -#include <QtGui/QDesktopServices> +#include "tracer.h" -#include <QNetworkAccessManager> -#include <QNetworkReply> -#include <QNetworkRequest> +#include <QtCore/QCoreApplication> +#include <QtCore/QUrl> QT_BEGIN_NAMESPACE -namespace { - const QString PageNotFoundMessage = - QCoreApplication::translate("HelpViewer", - "<title>Error 404...</title><div align=\"center\"><br><br>" - "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>"); -} - -#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<HelpPage*>(centralWidget->newEmptyTab()->page()); - if (newPage) - newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; - closeNewTabIfNeeded = false; - return newPage; -} +QString AbstractHelpViewer::PageNotFoundMessage = + QCoreApplication::translate("HelpViewer", "<title>Error 404...</title><div " + "align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'" + "</h3></div>"); -void HelpPage::triggerAction(WebAction action, bool checked) +AbstractHelpViewer::AbstractHelpViewer() { - 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) +AbstractHelpViewer::~AbstractHelpViewer() { - 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()) +bool AbstractHelpViewer::isLocalUrl(const QUrl &url) { 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) -{ - 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<QAction *>(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<HelpPage*>(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()); -} - -#else // !defined(QT_NO_WEBKIT) - -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::wheelEvent(QWheelEvent *e) -{ - TRACE_OBJ - if (e->modifiers() == Qt::CTRL) { - e->accept(); - (e->delta() > 0) ? zoomIn() : zoomOut(); - } else { - e->ignore(); - QTextBrowser::wheelEvent(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(); + const QString &scheme = url.scheme(); return scheme.isEmpty() || scheme == QLatin1String("file") || scheme == QLatin1String("qrc") @@ -643,5 +71,12 @@ bool HelpViewer::isLocalUrl(const QUrl &url) || scheme == QLatin1String("about"); } +bool AbstractHelpViewer::canOpenPage(const QString &url) +{ + TRACE_OBJ + return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) + || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) + || url == QLatin1String("blank"); +} QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 4dd8064..fe860fd 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -38,144 +38,37 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - #ifndef HELPVIEWER_H #define HELPVIEWER_H -#include <QtCore/QUrl> -#include <QtCore/QVariant> -#include <QtGui/QTextBrowser> -#include <QtGui/QAction> +#include <QtCore/QString> -#if !defined(QT_NO_WEBKIT) -#include <QWebView> -#endif +#include <QtGui/QFont> QT_BEGIN_NAMESPACE -class CentralWidget; -class HelpEngineWrapper; - -class QPoint; -class QString; -class QKeyEvent; -class QMouseEvent; -class QContextMenuEvent; +class QUrl; -#if !defined(QT_NO_WEBKIT) - -class HelpViewer : public QWebView +class AbstractHelpViewer { - 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); + AbstractHelpViewer(); + ~AbstractHelpViewer(); - inline void copy() - { return triggerPageAction(QWebPage::Copy); } + virtual QFont viewerFont() const = 0; + virtual void setViewerFont(const QFont &font) = 0; - 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(); } + virtual void scaleUp() = 0; + virtual void scaleDown() = 0; + + virtual void resetScale() = 0; + virtual qreal scale() const = 0; - static bool canOpenPage(const QString &url); + static QString PageNotFoundMessage; 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 -{ - 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); static bool canOpenPage(const QString &url); - 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; }; -#endif - QT_END_NAMESPACE -#endif +#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..3aafe67 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** 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 <QtCore/QDir> +#include <QtCore/QStringBuilder> + +#include <QtGui/QContextMenuEvent> +#include <QtGui/QMenu> +#include <QtGui/QClipboard> +#include <QtGui/QApplication> +#include <QtGui/QMessageBox> +#include <QtGui/QDesktopServices> + +QT_BEGIN_NAMESPACE + +HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) + : QTextBrowser(parent) + , zoomCount(zoom) + , controlPressed(false) + , lastAnchor(QString()) + , parentWidget(parent) + , helpEngine(HelpEngineWrapper::instance()) + , forceFont(false) +{ + TRACE_OBJ + 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) +{ + 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); + } +} + +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::ControlModifier) { + e->accept(); + e->delta() > 0 ? scaleUp() : scaleDown(); + } else { + 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 new file mode 100644 index 0000000..e927b34 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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 <QtCore/QUrl> +#include <QtCore/QVariant> + +#include <QtGui/QTextBrowser> + +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, qreal zoom = 0.0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); + + void scaleUp(); + void scaleDown(); + void resetScale(); + qreal scale() const { return zoomCount; } + + void setSource(const QUrl &url); + + inline bool hasSelection() const + { return textCursor().hasSelection(); } + + bool launchedWithExternalApp(const QUrl &url); + +public Q_SLOTS: + void home(); + +protected: + void wheelEvent(QWheelEvent *e); + bool eventFilter(QObject *obj, QEvent *event); + +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; + + bool forceFont; +}; + +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 new file mode 100644 index 0000000..4857e00 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -0,0 +1,413 @@ +/**************************************************************************** +** +** 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_qwv.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#include "tracer.h" + +#include <QtCore/QFileInfo> +#include <QtCore/QString> +#include <QtCore/QStringBuilder> +#include <QtCore/QTemporaryFile> +#include <QtCore/QTimer> + +#include <QtGui/QDesktopServices> +#include <QtGui/QWheelEvent> + +#include <QtNetwork/QNetworkAccessManager> +#include <QtNetwork/QNetworkReply> +#include <QtNetwork/QNetworkRequest> + +QT_BEGIN_NAMESPACE + +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) + : AbstractHelpViewer::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<HelpPage*>(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 (AbstractHelpViewer::isLocalUrl(url)) { + const QString& path = url.path(); + if (!AbstractHelpViewer::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::HelpViewer(CentralWidget *parent, qreal zoom) + : 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))); + + setFont(viewerFont()); + setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); +} + +HelpViewer::~HelpViewer() +{ + TRACE_OBJ +} + +QFont HelpViewer::viewerFont() const +{ + TRACE_OBJ + if (helpEngine.usesBrowserFont()) + return helpEngine.browserFont(); + + QWebSettings *webSettings = QWebSettings::globalSettings(); + return QFont(webSettings->fontFamily(QWebSettings::StandardFont), + webSettings->fontSize(QWebSettings::DefaultFontSize)); +} + +void HelpViewer::setViewerFont(const QFont &font) +{ + TRACE_OBJ + QWebSettings *webSettings = settings(); + webSettings->setFontFamily(QWebSettings::StandardFont, font.family()); + webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); +} + +void HelpViewer::scaleUp() +{ + TRACE_OBJ + 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() +{ + TRACE_OBJ + setSource(helpEngine.homePage()); +} + +void HelpViewer::wheelEvent(QWheelEvent *e) +{ + TRACE_OBJ + if (e->modifiers()& Qt::ControlModifier) { + e->accept(); + e->delta() > 0 ? scaleUp() : scaleDown(); + } else { + 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<QAction *>(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<HelpPage*>(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()); +} + +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 new file mode 100644 index 0000000..3f2e537 --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** 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 HELPVIEWERQWV_H +#define HELPVIEWERQWV_H + +#include "helpviewer.h" + +#include <QtGui/QAction> +#include <QtWebKit/QWebView> + +QT_BEGIN_NAMESPACE + +class CentralWidget; +class HelpEngineWrapper; +class QMouseEvent; + +class HelpViewer : public QWebView, public AbstractHelpViewer +{ + Q_OBJECT + +public: + HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); + + 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(); } + + inline bool hasSelection() const + { return !selectedText().isEmpty(); } // ### this is suboptimal + + 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; } + +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; +}; + +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 82242e5..63ddbe4 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -219,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..4115d39 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" @@ -760,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(); } @@ -970,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 <QtCore/QtAlgorithms> #include <QtCore/QFileSystemWatcher> -#include <QtGui/QHeaderView> +#include <QtGui/QDesktopWidget> #include <QtGui/QFileDialog> -#include <QtGui/QMessageBox> -#include <QtGui/QMenu> #include <QtGui/QFontDatabase> -#include <QtGui/QApplication> -#include <QtGui/QDesktopWidget> +#include <QtGui/QHeaderView> +#include <QtGui/QMenu> +#include <QtGui/QMessageBox> #include <QtHelp/QHelpEngineCore> @@ -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(); } |