summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
commit793d3c2da83098e32063c4ae6df187058103bde8 (patch)
tree7b96581a67bd66ff30b0ede18b0fbfd71d9345cf /src
parent2d0f49df3a3c44601bf2e41ea722c2384b71aab0 (diff)
parentc2d47f6717fdccd44838f3c128693a3c09f6cf68 (diff)
downloadQt-793d3c2da83098e32063c4ae6df187058103bde8.zip
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.gz
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp77
-rw-r--r--src/corelib/codecs/qtextcodec.h3
-rw-r--r--src/corelib/global/qlibraryinfo.cpp107
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/io/qfile.cpp3
-rw-r--r--src/corelib/io/qtextstream.cpp9
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp14
-rw-r--r--src/corelib/kernel/qfunctions_wince.cpp5
-rw-r--r--src/corelib/kernel/qfunctions_wince.h5
-rw-r--r--src/corelib/tools/qlistdata.cpp8
-rw-r--r--src/dbus/qdbusintegrator.cpp2
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm19
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp25
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h1
-rw-r--r--src/gui/itemviews/qdirmodel.cpp11
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp9
-rw-r--r--src/gui/kernel/qaction.cpp2
-rw-r--r--src/gui/kernel/qapplication_mac.mm36
-rw-r--r--src/gui/kernel/qclipboard.cpp24
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm2
-rw-r--r--src/gui/kernel/qlayout.cpp2
-rw-r--r--src/gui/kernel/qshortcutmap.cpp6
-rw-r--r--src/gui/kernel/qwidget.cpp9
-rw-r--r--src/gui/kernel/qwidget_mac.mm86
-rw-r--r--src/gui/kernel/qwidget_p.h3
-rw-r--r--src/gui/painting/qcolormap_win.cpp6
-rw-r--r--src/gui/painting/qdrawutil.cpp54
-rw-r--r--src/gui/painting/qdrawutil.h10
-rw-r--r--src/gui/painting/qpainter.cpp31
-rw-r--r--src/gui/painting/qtransform.cpp4
-rw-r--r--src/gui/styles/qmacstyle_mac.mm5
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp185
-rw-r--r--src/gui/text/qtextformat.h6
-rw-r--r--src/gui/text/qtextlayout.cpp39
-rw-r--r--src/gui/widgets/qmenu_mac.mm34
-rw-r--r--src/gui/widgets/qmenubar.cpp107
-rw-r--r--src/gui/widgets/qmenubar.h4
-rw-r--r--src/gui/widgets/qmenubar_p.h5
-rw-r--r--src/network/access/qnetworkcookie.cpp9
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp21
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp180
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h20
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp17
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbsurface.h1
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp9
45 files changed, 656 insertions, 560 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 6e8ffa1..51ca43e 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1508,9 +1508,14 @@ QString QTextDecoder::toUnicode(const QByteArray &ba)
/*!
\since 4.4
- Tries to detect the encoding of the provided snippet of HTML in the given byte array, \a ba,
- and returns a QTextCodec instance that is capable of decoding the html to unicode.
- If the codec cannot be detected from the content provided, \a defaultCodec is returned.
+ Tries to detect the encoding of the provided snippet of HTML in
+ the given byte array, \a ba, by checking the BOM (Byte Order Mark)
+ and the content-type meta header and returns a QTextCodec instance
+ that is capable of decoding the html to unicode. If the codec
+ cannot be detected from the content provided, \a defaultCodec is
+ returned.
+
+ \sa codecForUtfText
*/
QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec)
{
@@ -1518,15 +1523,8 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
int pos;
QTextCodec *c = 0;
- if (ba.size() > 1 && (((uchar)ba[0] == 0xfe && (uchar)ba[1] == 0xff)
- || ((uchar)ba[0] == 0xff && (uchar)ba[1] == 0xfe))) {
- c = QTextCodec::codecForMib(1015); // utf16
- } else if (ba.size() > 2
- && (uchar)ba[0] == 0xef
- && (uchar)ba[1] == 0xbb
- && (uchar)ba[2] == 0xbf) {
- c = QTextCodec::codecForMib(106); // utf-8
- } else {
+ c = QTextCodec::codecForUtfText(ba, c);
+ if (!c) {
QByteArray header = ba.left(512).toLower();
if ((pos = header.indexOf("http-equiv=")) != -1) {
pos = header.indexOf("charset=", pos) + int(strlen("charset="));
@@ -1554,6 +1552,61 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba)
return codecForHtml(ba, QTextCodec::codecForMib(/*Latin 1*/ 4));
}
+/*!
+ \since 4.6
+
+ Tries to detect the encoding of the provided snippet \a ba by
+ using the BOM (Byte Order Mark) and returns a QTextCodec instance
+ that is capable of decoding the text to unicode. If the codec
+ cannot be detected from the content provided, \a defaultCodec is
+ returned.
+
+ \sa codecForHtml
+*/
+QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec)
+{
+ const uint arraySize = ba.size();
+
+ if (arraySize > 3) {
+ if ((uchar)ba[0] == 0x00
+ && (uchar)ba[1] == 0x00
+ && (uchar)ba[2] == 0xFE
+ && (uchar)ba[3] == 0xFF)
+ return QTextCodec::codecForMib(1018); // utf-32 be
+ else if ((uchar)ba[0] == 0xFF
+ && (uchar)ba[1] == 0xFE
+ && (uchar)ba[2] == 0x00
+ && (uchar)ba[3] == 0x00)
+ return QTextCodec::codecForMib(1019); // utf-32 le
+ }
+
+ if (arraySize < 2)
+ return defaultCodec;
+ if ((uchar)ba[0] == 0xfe && (uchar)ba[1] == 0xff)
+ return QTextCodec::codecForMib(1013); // utf16 be
+ else if ((uchar)ba[0] == 0xff && (uchar)ba[1] == 0xfe)
+ return QTextCodec::codecForMib(1014); // utf16 le
+
+ if (arraySize < 3)
+ return defaultCodec;
+ if ((uchar)ba[0] == 0xef
+ && (uchar)ba[1] == 0xbb
+ && (uchar)ba[2] == 0xbf)
+ return QTextCodec::codecForMib(106); // utf-8
+
+ return defaultCodec;
+}
+
+/*!
+ \overload
+
+ If the codec cannot be detected, this overload returns a Latin-1 QTextCodec.
+*/
+QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba)
+{
+ return codecForUtfText(ba, QTextCodec::codecForMib(/*Latin 1*/ 4));
+}
+
/*! \internal
\since 4.3
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index e32650f..83097a5 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -82,6 +82,9 @@ public:
static QTextCodec *codecForHtml(const QByteArray &ba);
static QTextCodec *codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec);
+ static QTextCodec *codecForUtfText(const QByteArray &ba);
+ static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec);
+
QTextDecoder* makeDecoder() const;
QTextEncoder* makeEncoder() const;
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index ada08c7..29e356e 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -485,100 +485,27 @@ QT_END_NAMESPACE
#if defined(Q_CC_GNU) && defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) && !defined(QT_BOOTSTRAPPED)
-# include <sys/syscall.h>
-# include <unistd.h>
-
-static const char boilerplate[] =
- "This is the QtCore library version " QT_VERSION_STR "\n"
- "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"
- "Contact: Qt Software Information (qt-info@nokia.com)\n"
- "\n"
- "Build key: " QT_BUILD_KEY;
-
-extern "C" {
-void qt_core_init_boilerplate() __attribute__((noreturn));
-}
+# include <stdio.h>
+# include <stdlib.h>
-# if defined(QT_ARCH_I386)
-#define sysinit() (void)0
-#define syswrite(msg, len) \
- ({ int res; \
- asm volatile ("movl %%ebx, %%edi\n" \
- "movl $1, %%ebx\n" \
- "int $0x80\n" \
- "movl %%edi, %%ebx\n" \
- : "=a" (res) : "0" (SYS_write), "c" (msg), "d" (len) : "edi"); res; })
-#define sysexit(c) \
- asm ("xor %%ebx, %%ebx\n" \
- "int $0x80\n" \
- : : "a" (SYS_exit)); _exit(c)
-
-# elif defined(QT_ARCH_X86_64)
-#define sysinit() (void)0
-#define syswrite(msg, len) \
- ({ int res; \
- asm volatile ("syscall\n" \
- : "=a" (res) : "0" (SYS_write), "D" (1), "S" (msg), "d" (len) : "rcx"); res; })
-#define sysexit(c) \
- asm ("syscall\n" \
- : : "a" (SYS_exit), "D" (0)); _exit(c)
-
-# elif defined(QT_ARCH_IA64)
-#define sysinit() \
- asm volatile ("{.mlx\n" \
- " nop.m 0\n" \
- " movl r2 = @pcrel(boilerplate);;" \
- "}\n" \
- "{.mii\n" \
- " mov r10 = @ltoffx(boilerplate)\n" \
- " mov r1 = ip\n" \
- " adds r2 = -16, r2\n;;\n" \
- "}\n" \
- " add r1 = r2, r1;;\n" \
- " sub r1 = r1, r10;;\n" \
- : : : "r2", "r10")
-#define syswrite(msg, len) \
- ({ const char *_msg = msg; \
- asm ("mov out0=%1\n" \
- "mov out1=%2\n" \
- "mov out2=%3\n" \
- ";;\n" \
- "mov r15=%0\n" \
- "break 0x100000;;\n" \
- : : "I" (SYS_write), "I" (1), "r" (_msg), "r" (len)); })
-#define sysexit(c) \
- asm ("mov out0=%1\n" \
- ";;\n" \
- "mov r15=%0\n" \
- "break 0x100000;;\n" \
- : : "I" (SYS_exit), "O" (0)); write(1, 0, 0); _exit(c)
-# else
-#define sysinit() (void)0
-#define syswrite(msg, len) (msg); (len)
-#define sysexit(c) __builtin_exit(c)
-# endif
-
-#define sysputs(msg) syswrite(msg, -1 + sizeof(msg))
-#define sysendl() syswrite("\n", 1)
-#define print_qt_configure(_which) \
- ({const char *which = _which; \
- which += 12; \
- int len = 0; \
- while (which[len]) ++len; \
- syswrite(which, len); })
+extern const char qt_core_interpreter[] __attribute__((section(".interp")))
+ = "/lib/ld-linux.so.2";
+extern "C"
void qt_core_init_boilerplate()
{
- sysinit();
- sysputs(boilerplate);
- sysputs("\nInstallation prefix: ");
- print_qt_configure(qt_configure_prefix_path_str);
- sysputs("\nLibrary path: ");
- print_qt_configure(qt_configure_libraries_path_str);
- sysputs("\nInclude path: ");
- print_qt_configure(qt_configure_headers_path_str);
- sysendl();
- sysexit(0);
+ printf("This is the QtCore library version " QT_VERSION_STR "\n"
+ "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "Contact: Qt Software Information (qt-info@nokia.com)\n"
+ "\n"
+ "Build key: " QT_BUILD_KEY "\n"
+ "Installation prefix: %s\n"
+ "Library path: %s\n"
+ "Include path: %s\n",
+ qt_configure_prefix_path_str + 12,
+ qt_configure_libraries_path_str + 12,
+ qt_configure_headers_path_str + 12);
+ exit(0);
}
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index ed44fa2..1635f8a 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -506,6 +506,7 @@ public:
AA_NativeWindows = 3,
AA_DontCreateNativeWidgetSiblings = 4,
AA_MacPluginApplication = 5,
+ AA_DontUseNativeMenuBar = 6,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index d7da800..04750b0 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -708,6 +708,7 @@ QFile::rename(const QString &newName)
d->setError(QFile::RenameError, tr("Destination file exists"));
return false;
}
+ unsetError();
close();
if(error() == QFile::NoError) {
if (fileEngine()->rename(newName)) {
@@ -849,6 +850,7 @@ QFile::copy(const QString &newName)
d->setError(QFile::CopyError, tr("Destination file exists"));
return false;
}
+ unsetError();
close();
if(error() == QFile::NoError) {
if(fileEngine()->copy(newName)) {
@@ -908,6 +910,7 @@ QFile::copy(const QString &newName)
out.setAutoRemove(false);
#endif
}
+ close();
}
if(!error) {
QFile::setPermissions(newName, permissions());
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 73408dc..3c015da 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -559,13 +559,8 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
if (!codec || autoDetectUnicode) {
autoDetectUnicode = false;
- if (bytesRead >= 4 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe && uchar(buf[2]) == 0 && uchar(buf[3]) == 0)
- || (uchar(buf[0]) == 0 && uchar(buf[1]) == 0 && uchar(buf[2]) == 0xfe && uchar(buf[3]) == 0xff))) {
- codec = QTextCodec::codecForName("UTF-32");
- } else if (bytesRead >= 2 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe)
- || (uchar(buf[0]) == 0xfe && uchar(buf[1]) == 0xff))) {
- codec = QTextCodec::codecForName("UTF-16");
- } else if (!codec) {
+ codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), 0);
+ if (!codec) {
codec = QTextCodec::codecForLocale();
writeConverterState.flags |= QTextCodec::IgnoreHeader;
}
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index e4bd664..c21cf87 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -556,6 +556,20 @@ void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on)
QCoreApplicationPrivate::attribs |= 1 << attribute;
else
QCoreApplicationPrivate::attribs &= ~(1 << attribute);
+#ifdef Q_OS_MAC
+ // Turn on the no native menubar here, since we used to
+ // do this implicitly. We DO NOT flip it off if someone sets
+ // it to false.
+ // Ideally, we'd have magic that would be something along the lines of
+ // "follow MacPluginApplication" unless explicitly set.
+ // Considering this attribute isn't only at the beginning
+ // it's unlikely it will ever be a problem, but I want
+ // to have the behavior documented here.
+ if (attribute == Qt::AA_MacPluginApplication && on
+ && !testAttribute(Qt::AA_DontUseNativeMenuBar)) {
+ setAttribute(Qt::AA_DontUseNativeMenuBar, true);
+ }
+#endif
}
/*!
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp
index 1c929c7..e0f7687 100644
--- a/src/corelib/kernel/qfunctions_wince.cpp
+++ b/src/corelib/kernel/qfunctions_wince.cpp
@@ -285,11 +285,6 @@ int qt_wince_SetErrorMode(int newValue)
return result;
}
-HRESULT qt_wince_CoInitialize(void* reserved)
-{
- return CoInitializeEx(reserved, 0);
-}
-
bool qt_wince__chmod(const char *file, int mode)
{
return _wchmod( reinterpret_cast<const wchar_t *> (QString::fromLatin1(file).utf16()), mode);
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index 123bd23..5f08bb3 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -199,7 +199,9 @@ int qt_wince__fstat( int handle, struct stat *buffer);
#define SEM_FAILCRITICALERRORS 0x0001
#define SEM_NOOPENFILEERRORBOX 0x0002
int qt_wince_SetErrorMode(int);
-HRESULT qt_wince_CoInitialize(void* reserved);
+#ifndef CoInitialize
+#define CoInitialize(x) CoInitializeEx(x, COINIT_MULTITHREADED)
+#endif
bool qt_wince__chmod(const char *file, int mode);
bool qt_wince__wchmod(const WCHAR *file, int mode);
@@ -376,7 +378,6 @@ typedef DWORD OLE_COLOR;
#define _rename(a,b) qt_wince__rename(a,b)
#define _remove(a) qt_wince__remove(a)
#define SetErrorMode(a) qt_wince_SetErrorMode(a)
-#define CoInitialize(a) qt_wince_CoInitialize(a)
#define _chmod(a,b) qt_wince__chmod(a,b)
#define _wchmod(a,b) qt_wince__wchmod(a,b)
#define CreateFileA(a,b,c,d,e,f,g) qt_wince_CreateFileA(a,b,c,d,e,f,g)
diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp
index d7c39a7..d40b6b6 100644
--- a/src/corelib/tools/qlistdata.cpp
+++ b/src/corelib/tools/qlistdata.cpp
@@ -764,6 +764,10 @@ void **QListData::erase(void **xi)
This function requires the value type to have an implementation of
\c operator==().
+ Note that QList uses 0-based indexes, just like C++ arrays. Negative
+ indexes are not supported with the exception of the value mentioned
+ above.
+
\sa lastIndexOf(), contains()
*/
@@ -780,6 +784,10 @@ void **QListData::erase(void **xi)
This function requires the value type to have an implementation of
\c operator==().
+ Note that QList uses 0-based indexes, just like C++ arrays. Negative
+ indexes are not supported with the exception of the value mentioned
+ above.
+
\sa indexOf()
*/
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 8c701f5..2c27381 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1102,7 +1102,7 @@ void QDBusConnectionPrivate::socketWrite(int fd)
}
for (int i = 0; i < pendingWatches.size(); ++i)
- if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_READABLE))
+ if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_WRITABLE))
qDebug("OUT OF MEM");
}
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 90af9fc..39a231b 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -911,8 +911,9 @@ void QFileDialogPrivate::createNavServicesDialog()
navOptions.windowTitle = QCFString::toCFStringRef(q->windowTitle());
- static const int w = 450, h = 350;
- navOptions.location.h = navOptions.location.v = -1;
+ navOptions.location.h = -1;
+ navOptions.location.v = -1;
+
QWidget *parent = q->parentWidget();
if (parent && parent->isVisible()) {
WindowClass wclass;
@@ -920,20 +921,6 @@ void QFileDialogPrivate::createNavServicesDialog()
parent = parent->window();
QString s = parent->windowTitle();
navOptions.clientName = QCFString::toCFStringRef(s);
- navOptions.location.h = (parent->x() + (parent->width() / 2)) - (w / 2);
- navOptions.location.v = (parent->y() + (parent->height() / 2)) - (h / 2);
-
- QRect r = QApplication::desktop()->screenGeometry(
- QApplication::desktop()->screenNumber(parent));
- const int border = 10;
- if (navOptions.location.h + w > r.right())
- navOptions.location.h -= (navOptions.location.h + w) - r.right() + border;
- if (navOptions.location.v + h > r.bottom())
- navOptions.location.v -= (navOptions.location.v + h) - r.bottom() + border;
- if (navOptions.location.h < r.left())
- navOptions.location.h = r.left() + border;
- if (navOptions.location.v < r.top())
- navOptions.location.v = r.top() + border;
}
filterInfo.currentSelection = 0;
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index cc14d3e..4e4392f 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -88,6 +88,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
autoScroll(true),
autoScrollMargin(16),
autoScrollCount(0),
+ shouldScrollToCurrentOnShow(false),
alternatingColors(false),
textElideMode(Qt::ElideRight),
verticalScrollMode(QAbstractItemView::ScrollPerItem),
@@ -1380,8 +1381,9 @@ bool QAbstractItemView::event(QEvent *event)
d->executePostedLayout(); //make sure we set the layout properly
break;
case QEvent::Show:
- if (d->delayedPendingLayout) {
- d->executePostedLayout(); //make sure we set the layout properly
+ d->executePostedLayout(); //make sure we set the layout properly
+ if (d->shouldScrollToCurrentOnShow) {
+ d->shouldScrollToCurrentOnShow = false;
const QModelIndex current = currentIndex();
if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll))
scrollTo(current);
@@ -3160,13 +3162,18 @@ void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelI
update(previous);
}
}
- if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) {
- if (d->autoScroll)
- scrollTo(current);
- update(current);
- edit(current, CurrentChanged, 0);
- if (current.row() == (d->model->rowCount(d->root) - 1))
- d->_q_fetchMore();
+
+ if (current.isValid() && !d->autoScrollTimer.isActive()) {
+ if (isVisible()) {
+ if (d->autoScroll)
+ scrollTo(current);
+ update(current);
+ edit(current, CurrentChanged, 0);
+ if (current.row() == (d->model->rowCount(d->root) - 1))
+ d->_q_fetchMore();
+ } else {
+ d->shouldScrollToCurrentOnShow = d->autoScroll;
+ }
}
}
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 37fe4a2..16bd1ab 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -359,6 +359,7 @@ public:
QBasicTimer autoScrollTimer;
int autoScrollMargin;
int autoScrollCount;
+ bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event
bool alternatingColors;
diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp
index 7da7c7a..65e3032 100644
--- a/src/gui/itemviews/qdirmodel.cpp
+++ b/src/gui/itemviews/qdirmodel.cpp
@@ -44,6 +44,7 @@
#ifndef QT_NO_DIRMODEL
#include <qstack.h>
#include <qfile.h>
+#include <qfilesystemmodel.h>
#include <qurl.h>
#include <qmime.h>
#include <qpair.h>
@@ -1335,14 +1336,14 @@ QString QDirModelPrivate::size(const QModelIndex &index) const
const quint64 tb = 1024 * gb;
quint64 bytes = n->info.size();
if (bytes >= tb)
- return QLocale().toString(bytes / tb) + QString::fromLatin1(" TB");
+ return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
if (bytes >= gb)
- return QLocale().toString(bytes / gb) + QString::fromLatin1(" GB");
+ return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
if (bytes >= mb)
- return QLocale().toString(bytes / mb) + QString::fromLatin1(" MB");
+ return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
if (bytes >= kb)
- return QLocale().toString(bytes / kb) + QString::fromLatin1(" KB");
- return QLocale().toString(bytes) + QString::fromLatin1(" bytes");
+ return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
+ return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
}
QString QDirModelPrivate::type(const QModelIndex &index) const
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index fee19c9..56925b8 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -153,6 +153,7 @@ public:
const QModelIndex &proxy_index) const
{
Q_ASSERT(proxy_index.isValid());
+ Q_ASSERT(proxy_index.model() == q_func());
const void *p = proxy_index.internalPointer();
Q_ASSERT(p);
QMap<QModelIndex, Mapping *>::const_iterator it =
@@ -320,6 +321,10 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro
{
if (!proxy_index.isValid())
return QModelIndex(); // for now; we may want to be able to set a root index later
+ if (proxy_index.model() != q_func()) {
+ qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource";
+ return QModelIndex();
+ }
IndexMap::const_iterator it = index_to_iterator(proxy_index);
Mapping *m = it.value();
if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size()))
@@ -333,6 +338,10 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou
{
if (!source_index.isValid())
return QModelIndex(); // for now; we may want to be able to set a root index later
+ if (source_index.model() != model) {
+ qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource";
+ return QModelIndex();
+ }
QModelIndex source_parent = source_index.parent();
IndexMap::const_iterator it = create_mapping(source_parent);
Mapping *m = it.value();
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index c6addc1..b2afbd0 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -1370,7 +1370,7 @@ QAction::MenuRole QAction::menuRole() const
void QAction::setIconVisibleInMenu(bool visible)
{
Q_D(QAction);
- if (visible != (bool)d->iconVisibleInMenu) {
+ if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
int oldValue = d->iconVisibleInMenu;
d->iconVisibleInMenu = visible;
// Only send data changed if we really need to.
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index ae99e83..d5fa9ea 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -194,8 +194,8 @@ static bool appNoGrab = false; // mouse/keyboard grabbing
#ifndef QT_MAC_USE_COCOA
static EventHandlerRef app_proc_handler = 0;
static EventHandlerUPP app_proc_handlerUPP = 0;
-static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL;
#endif
+static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL;
static EventHandlerRef tablet_proximity_handler = 0;
static EventHandlerUPP tablet_proximity_UPP = 0;
bool QApplicationPrivate::native_modal_dialog_active;
@@ -951,7 +951,6 @@ void qt_mac_event_release(QWidget *w)
}
}
-#ifndef QT_MAC_USE_COCOA
struct QMacAppleEventTypeSpec {
AEEventClass mac_class;
AEEventID mac_id;
@@ -959,6 +958,7 @@ struct QMacAppleEventTypeSpec {
{ kCoreEventClass, kAEQuitApplication },
{ kCoreEventClass, kAEOpenDocuments }
};
+#ifndef QT_MAC_USE_COCOA
/* watched events */
static EventTypeSpec app_events[] = {
{ kEventClassQt, kEventQtRequestWindowChange },
@@ -1156,13 +1156,13 @@ void qt_init(QApplicationPrivate *priv, int)
qt_init_app_proc_handler();
}
+#endif
if (!app_proc_ae_handlerUPP) {
app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor);
for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
app_proc_ae_handlerUPP, SRefCon(qApp), true);
}
-#endif
if (QApplicationPrivate::app_style) {
QEvent ev(QEvent::Style);
@@ -1196,10 +1196,6 @@ void qt_init(QApplicationPrivate *priv, int)
[qtMenuLoader release];
}
#endif
- if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
- extern void qt_mac_set_native_menubar(bool);
- qt_mac_set_native_menubar(false);
- }
// Register for Carbon tablet proximity events on the event monitor target.
// This means that we should receive proximity events even when we aren't the active application.
if (!tablet_proximity_handler) {
@@ -1210,6 +1206,17 @@ void qt_init(QApplicationPrivate *priv, int)
}
+void qt_release_apple_event_handler()
+{
+ if(app_proc_ae_handlerUPP) {
+ for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
+ AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
+ app_proc_ae_handlerUPP, true);
+ DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP);
+ app_proc_ae_handlerUPP = 0;
+ }
+}
+
/*****************************************************************************
qt_cleanup() - cleans up when the application is finished
*****************************************************************************/
@@ -1223,15 +1230,8 @@ void qt_cleanup()
DisposeEventHandlerUPP(app_proc_handlerUPP);
app_proc_handlerUPP = 0;
}
- if(app_proc_ae_handlerUPP) {
- for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
- AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
- app_proc_ae_handlerUPP, true);
- DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP);
- app_proc_ae_handlerUPP = NULL;
- }
#endif
-
+ qt_release_apple_event_handler();
qt_release_tablet_proximity_handler();
if (tablet_proximity_UPP)
DisposeEventHandlerUPP(tablet_proximity_UPP);
@@ -2358,6 +2358,12 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
#endif
}
+// In Carbon this is your one stop for apple events.
+// In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists
+// for the time between instantiating the NSApplication, but before the
+// NSApplication has installed it's OWN Apple Event handler. When Cocoa has
+// that set up, we remove this. So, if you are debugging problems, you likely
+// want to check out QCocoaApplicationDelegate instead.
OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, AppleEvent *, long handlerRefcon)
{
QApplication *app = (QApplication *)handlerRefcon;
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 917b5d5..6daf433 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -50,6 +50,7 @@
#include "qvariant.h"
#include "qbuffer.h"
#include "qimage.h"
+#include "qtextcodec.h"
QT_BEGIN_NAMESPACE
@@ -276,11 +277,12 @@ QClipboard::~QClipboard()
*/
QString QClipboard::text(QString &subtype, Mode mode) const
{
- const QMimeData *data = mimeData(mode);
+ const QMimeData *const data = mimeData(mode);
if (!data)
return QString();
+
+ const QStringList formats = data->formats();
if (subtype.isEmpty()) {
- QStringList formats = data->formats();
if (formats.contains(QLatin1String("text/plain")))
subtype = QLatin1String("plain");
else {
@@ -289,13 +291,21 @@ QString QClipboard::text(QString &subtype, Mode mode) const
subtype = formats.at(i).mid(5);
break;
}
+ if (subtype.isEmpty())
+ return QString();
}
- }
- if (subtype.isEmpty())
+ } else if (!formats.contains(QLatin1String("text/") + subtype)) {
return QString();
- if (subtype == QLatin1String("plain"))
- return data->text();
- return QString::fromUtf8(data->data(QLatin1String("text/") + subtype));
+ }
+
+ const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
+
+ QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
+ if (subtype == QLatin1String("html"))
+ codec = QTextCodec::codecForHtml(rawData, codec);
+ else
+ codec = QTextCodec::codecForUtfText(rawData, codec);
+ return codec->toUnicode(rawData);
}
/*!
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index 6571068..dad15d9 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -204,6 +204,8 @@ static void cleanupCocoaApplicationDelegate()
{
Q_UNUSED(aNotification);
inLaunch = false;
+ extern void qt_release_apple_event_handler(); //qapplication_mac.mm
+ qt_release_apple_event_handler();
}
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp
index aa46249..1d5a70d 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/gui/kernel/qlayout.cpp
@@ -1239,7 +1239,7 @@ bool QLayout::activate()
Must be implemented in subclasses to remove the layout item at \a
index from the layout, and return the item. If there is no such
item, the function must do nothing and return 0. Items are numbered
- consecutively from 0. If an item is deleted, other items will be
+ consecutively from 0. If an item is removed, other items will be
renumbered.
The following code fragment shows a safe way to remove all items
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index ed9654b..b6703e2 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -61,8 +61,6 @@
QT_BEGIN_NAMESPACE
-extern bool qt_mac_no_native_menubar; // qmenu_mac.cpp
-
// To enable verbose output uncomment below
//#define DEBUG_QSHORTCUTMAP
@@ -660,7 +658,7 @@ bool QShortcutMap::correctWidgetContext(Qt::ShortcutContext context, QWidget *w,
{
bool visible = w->isVisible();
#ifdef Q_WS_MAC
- if (!qt_mac_no_native_menubar && qobject_cast<QMenuBar *>(w))
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
@@ -723,7 +721,7 @@ bool QShortcutMap::correctGraphicsWidgetContext(Qt::ShortcutContext context, QGr
{
bool visible = w->isVisible();
#ifdef Q_WS_MAC
- if (!qt_mac_no_native_menubar && qobject_cast<QMenuBar *>(w))
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index dfc8365..dd95053 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -4829,8 +4829,13 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
const QRegion oldSystemClip = enginePriv->systemClip;
const QRegion oldSystemViewport = enginePriv->systemViewport;
- // This ensures that transformed system clips are inside the current system clip.
- enginePriv->setSystemViewport(oldSystemClip);
+ // This ensures that all painting triggered by render() is clipped to the current engine clip.
+ if (painter->hasClipping()) {
+ const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
+ enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
+ } else {
+ enginePriv->setSystemViewport(oldSystemClip);
+ }
render(target, targetOffset, toBePainted, renderFlags);
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index b238279..9da0b6b 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2156,6 +2156,7 @@ void QWidgetPrivate::finishCreateWindow_sys_Carbon(OSWindowRef windowRef)
setWindowModified_sys(q->isWindowModified());
updateFrameStrut();
qt_mac_update_sizer(q);
+ applyMaxAndMinSizeOnWindow();
}
#else // QT_MAC_USE_COCOA
void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef)
@@ -2241,6 +2242,7 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
syncCocoaMask();
macUpdateIsOpaque();
qt_mac_update_sizer(q);
+ applyMaxAndMinSizeOnWindow();
}
#endif // QT_MAC_USE_COCOA
@@ -3995,7 +3997,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
}
}
-void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h)
+void QWidgetPrivate::adjustWithinMaxAndMinSize(int &w, int &h)
{
if (QWExtra *extra = extraData()) {
w = qMin(w, extra->maxw);
@@ -4022,6 +4024,26 @@ void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h)
}
}
+void QWidgetPrivate::applyMaxAndMinSizeOnWindow()
+{
+ Q_Q(QWidget);
+ const float max_f(20000);
+#ifndef QT_MAC_USE_COCOA
+#define SF(x) ((x > max_f) ? max_f : x)
+ HISize max = CGSizeMake(SF(extra->maxw), SF(extra->maxh));
+ HISize min = CGSizeMake(SF(extra->minw), SF(extra->minh));
+#undef SF
+ SetWindowResizeLimits(qt_mac_window_for(q), &min, &max);
+#else
+#define SF(x) ((x > max_f) ? max_f : x)
+ NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh));
+ NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh));
+#undef SF
+ [qt_mac_window_for(q) setMinSize:min];
+ [qt_mac_window_for(q) setMaxSize:max];
+#endif
+}
+
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
{
Q_Q(QWidget);
@@ -4033,17 +4055,18 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QMacCocoaAutoReleasePool pool;
bool realWindow = isRealWindow();
- if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)
+ if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){
+ adjustWithinMaxAndMinSize(w, h);
#ifndef QT_MAC_USE_COCOA
- && !(w == 0 && h == 0)
-#endif
- ){
- applyMaxAndMinSizeConstraints(w, h);
- topData()->isSetGeometry = 1;
- topData()->isMove = isMove;
-#ifndef QT_MAC_USE_COCOA
- Rect r; SetRect(&r, x, y, x + w, y + h);
- SetWindowBounds(qt_mac_window_for(q), kWindowContentRgn, &r);
+ if (w != 0 && h != 0) {
+ topData()->isSetGeometry = 1;
+ topData()->isMove = isMove;
+ Rect r; SetRect(&r, x, y, x + w, y + h);
+ SetWindowBounds(qt_mac_window_for(q), kWindowContentRgn, &r);
+ topData()->isSetGeometry = 0;
+ } else {
+ setGeometry_sys_helper(x, y, w, h, isMove);
+ }
#else
NSWindow *window = qt_mac_window_for(q);
const QRect &fStrut = frameStrut();
@@ -4071,7 +4094,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
[window setFrameOrigin:cocoaFrameRect.origin];
}
#endif
- topData()->isSetGeometry = 0;
} else {
setGeometry_sys_helper(x, y, w, h, isMove);
}
@@ -4096,40 +4118,19 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
data.crect = QRect(x, y, w, h);
if (realWindow) {
- if (QWExtra *extra = extraData()) {
- applyMaxAndMinSizeConstraints(w, h);
- qt_mac_update_sizer(q);
+ adjustWithinMaxAndMinSize(w, h);
+ qt_mac_update_sizer(q);
- if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
#ifndef QT_MAC_USE_COCOA
- OSWindowRef window = qt_mac_window_for(q);
- if(extra->maxw && extra->maxh && extra->maxw == extra->minw
- && extra->maxh == extra->minh) {
- ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute);
- } else {
- ChangeWindowAttributes(window, kWindowFullZoomAttribute, kWindowNoAttributes);
- }
-#endif
+ if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
+ OSWindowRef window = qt_mac_window_for(q);
+ if (extra->maxw && extra->maxh && extra->maxw == extra->minw
+ && extra->maxh == extra->minh) {
+ ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute);
+ } else {
+ ChangeWindowAttributes(window, kWindowFullZoomAttribute, kWindowNoAttributes);
}
-
- // Update max and min constraints:
- const float max_f(20000);
-#ifndef QT_MAC_USE_COCOA
-#define SF(x) ((x > max_f) ? max_f : x)
- HISize max = CGSizeMake(SF(extra->maxw), SF(extra->maxh));
- HISize min = CGSizeMake(SF(extra->minw), SF(extra->minh));
-#undef SF
- SetWindowResizeLimits(qt_mac_window_for(q), &min, &max);
-#else
-#define SF(x) ((x > max_f) ? max_f : x)
- NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh));
- NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh));
-#undef SF
- [qt_mac_window_for(q) setMinSize:min];
- [qt_mac_window_for(q) setMaxSize:max];
-#endif
}
-#ifndef QT_MAC_USE_COCOA
HIRect bounds = CGRectMake(0, 0, w, h);
HIViewSetFrame(qt_mac_nativeview_for(q), &bounds);
#else
@@ -4175,6 +4176,7 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
void QWidgetPrivate::setConstraints_sys()
{
updateMaximizeButton_sys();
+ applyMaxAndMinSizeOnWindow();
}
void QWidgetPrivate::updateMaximizeButton_sys()
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index df17566..2dd3061 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -252,7 +252,8 @@ public:
void macUpdateIsOpaque();
void setEnabled_helper_sys(bool enable);
bool isRealWindow() const;
- void applyMaxAndMinSizeConstraints(int &w, int &h);
+ void adjustWithinMaxAndMinSize(int &w, int &h);
+ void applyMaxAndMinSizeOnWindow();
#endif
void raise_sys();
diff --git a/src/gui/painting/qcolormap_win.cpp b/src/gui/painting/qcolormap_win.cpp
index 0606f64..9ca2521 100644
--- a/src/gui/painting/qcolormap_win.cpp
+++ b/src/gui/painting/qcolormap_win.cpp
@@ -138,7 +138,11 @@ void QColormap::cleanup()
}
QColormap QColormap::instance(int)
-{ return QColormap(); }
+{
+ Q_ASSERT_X(screenMap, "QColormap",
+ "A QApplication object needs to be constructed before QColormap is used.");
+ return QColormap();
+}
QColormap::QColormap()
: d(screenMap)
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
index 4898b7e..230d30b 100644
--- a/src/gui/painting/qdrawutil.cpp
+++ b/src/gui/painting/qdrawutil.cpp
@@ -1039,31 +1039,34 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs,
#endif
/*!
- \struct QMargins
- \since 4.6
+ \struct QMargins
+ \since 4.6
- Holds the borders used to split a pixmap on into nine segments in order to draw it,
- similar to CSS3 border-images \l http://www.w3.org/TR/css3-background/.
+ Holds the borders used to split a pixmap into nine segments in order to
+ draw it, similar to \l{http://www.w3.org/TR/css3-background/}
+ {CSS3 border-images}.
- \sa qDrawBorderPixmap, Qt::TileRule, QTileRules
- */
+ \sa qDrawBorderPixmap, Qt::TileRule, QTileRules
+*/
/*!
- \struct QTileRules
- \since 4.6
+ \struct QTileRules
+ \since 4.6
- Holds the rules used to draw a pixmap or image split into nine segments, similar to CSS3 border-images.
+ Holds the rules used to draw a pixmap or image split into nine segments,
+ similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}.
- \sa qDrawBorderPixmap, Qt::TileRule, QMargins
- */
+ \sa qDrawBorderPixmap, Qt::TileRule, QMargins
+*/
/*!
- \fn qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
- \since 4.6
+ \fn qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
+ \since 4.6
- Draws the given \a pixmap into the given \a target rectangle, using the given \a painter.
- The pixmap will be splitt into nine segments and drawn according to the given \a margins structure.
- */
+ Draws the given \a pixmap into the given \a target rectangle, using the
+ given \a painter. The pixmap will be split into nine segments and drawn
+ according to the \a margins structure.
+*/
static inline void qVerticalRepeat(QPainter *painter, const QRect &target, const QPixmap &pixmap, const QRect &source,
void (*drawPixmap)(QPainter*, const QRect&, const QPixmap&, const QRect&))
@@ -1146,17 +1149,20 @@ static inline void qDrawHorizontallyRoundedPixmap(QPainter *painter, const QRect
}
/*!
- \since 4.6
+ \since 4.6
- Draws the indicated \a sourceRect rectangle from the given \a pixmap into the given \a targetRect rectangle,
- using the given \a painter.
- The pixmap will be splitt into nine segments according to the given \a targetMargins and
- \a sourceMargins structures and drawn according to the given \a rules.
+ Draws the indicated \a sourceRect rectangle from the given \a pixmap into
+ the given \a targetRect rectangle, using the given \a painter. The pixmap
+ will be split into nine segments according to the given \a targetMargins
+ and \a sourceMargins structures. Finally, the pixmap will be drawn
+ according to the given \a rules.
- This function is used to draw a scaled pixmap, similar to CSS3 border-images.
+ This function is used to draw a scaled pixmap, similar to
+ \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}
+
+ \sa Qt::TileRule, QTileRules, QMargins
+*/
- \sa Qt::TileRule, QTileRules, QMargins
- */
void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap,
const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules)
{
diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h
index 08fa1ab..38d9ec0 100644
--- a/src/gui/painting/qdrawutil.h
+++ b/src/gui/painting/qdrawutil.h
@@ -44,6 +44,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h> // char*->QString conversion
+#include <QtGui/qpixmap.h>
QT_BEGIN_HEADER
@@ -60,7 +61,6 @@ class QPoint;
class QColor;
class QBrush;
class QRect;
-class QPixmap;
//
// Standard shade drawing
@@ -153,10 +153,10 @@ struct Q_GUI_EXPORT QMargins
struct Q_GUI_EXPORT QTileRules
{
- inline QTileRules(Qt::TileRule horizontalRule = Qt::Stretch,
- Qt::TileRule verticalRule = Qt::Stretch)
- : horizontal(horizontalRule),
- vertical(verticalRule) {}
+ inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule = Qt::Stretch)
+ : horizontal(horizontalRule), vertical(verticalRule) {}
+ inline QTileRules(Qt::TileRule rule = Qt::Stretch)
+ : horizontal(rule), vertical(rule) {}
Qt::TileRule horizontal;
Qt::TileRule vertical;
};
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index d9c7937..b158392 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2398,7 +2398,6 @@ QRegion QPainter::clipRegion() const
// ### Falcon: Use QPainterPath
for (int i=0; i<d->state->clipInfo.size(); ++i) {
const QPainterClipInfo &info = d->state->clipInfo.at(i);
- QRegion other;
switch (info.clipType) {
case QPainterClipInfo::RegionClip: {
@@ -2451,15 +2450,20 @@ QRegion QPainter::clipRegion() const
lastWasNothing = false;
continue;
}
- if (info.operation == Qt::IntersectClip)
- region &= QRegion(info.rect) * matrix;
- else if (info.operation == Qt::UniteClip)
+ if (info.operation == Qt::IntersectClip) {
+ // Use rect intersection if possible.
+ if (matrix.type() <= QTransform::TxScale)
+ region &= matrix.mapRect(info.rect);
+ else
+ region &= matrix.map(QRegion(info.rect));
+ } else if (info.operation == Qt::UniteClip) {
region |= QRegion(info.rect) * matrix;
- else if (info.operation == Qt::NoClip) {
+ } else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
- } else
+ } else {
region = QRegion(info.rect) * matrix;
+ }
break;
}
@@ -2470,15 +2474,20 @@ QRegion QPainter::clipRegion() const
lastWasNothing = false;
continue;
}
- if (info.operation == Qt::IntersectClip)
- region &= QRegion(info.rectf.toRect()) * matrix;
- else if (info.operation == Qt::UniteClip)
+ if (info.operation == Qt::IntersectClip) {
+ // Use rect intersection if possible.
+ if (matrix.type() <= QTransform::TxScale)
+ region &= matrix.mapRect(info.rectf.toRect());
+ else
+ region &= matrix.map(QRegion(info.rectf.toRect()));
+ } else if (info.operation == Qt::UniteClip) {
region |= QRegion(info.rectf.toRect()) * matrix;
- else if (info.operation == Qt::NoClip) {
+ } else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
- } else
+ } else {
region = QRegion(info.rectf.toRect()) * matrix;
+ }
break;
}
}
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index d06107f..4a33b92 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1387,12 +1387,16 @@ QRegion QTransform::map(const QRegion &r) const
TransformationType t = inline_type();
if (t == TxNone)
return r;
+
if (t == TxTranslate) {
QRegion copy(r);
copy.translate(qRound(affine._dx), qRound(affine._dy));
return copy;
}
+ if (t == TxScale && r.numRects() == 1)
+ return QRegion(mapRect(r.boundingRect()));
+
QPainterPath p = map(qt_regionToPath(r));
return p.toFillPolygon(QTransform()).toPolygon();
}
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index e32c5e2..2558625 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -2161,8 +2161,11 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint
/*! \reimp */
void QMacStyle::polish(QPalette &pal)
{
- if (qt_mac_backgroundPattern == 0)
+ if (!qt_mac_backgroundPattern) {
+ if (!qApp)
+ return;
qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern());
+ }
QColor pc(Qt::black);
pc = qcolorForTheme(kThemeBrushDialogBackgroundActive);
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index f480008..ebddfd5 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -81,6 +81,7 @@
#include <private/qwidget_p.h>
#include <QAbstractSpinBox>
#include <QLabel>
+#include "qdrawutil.h"
#include <limits.h>
@@ -312,15 +313,10 @@ struct QStyleSheetBorderImageData : public QSharedData
for (int i = 0; i < 4; i++)
cuts[i] = -1;
}
- QPixmap topEdge, bottomEdge, leftEdge, rightEdge, middle;
- QRect topEdgeRect, bottomEdgeRect, leftEdgeRect, rightEdgeRect, middleRect;
- QRect topLeftCorner, topRightCorner, bottomRightCorner, bottomLeftCorner;
int cuts[4];
QPixmap pixmap;
QImage image;
QCss::TileMode horizStretch, vertStretch;
-
- void cutBorderImage();
};
struct QStyleSheetBackgroundData : public QSharedData
@@ -1122,176 +1118,27 @@ void QRenderRule::fixupBorder(int nativeWidth)
for (int i = 0; i < 4; i++) // assume, cut = border
bi->cuts[i] = int(border()->borders[i]);
}
- bi->cutBorderImage();
-}
-
-void QStyleSheetBorderImageData::cutBorderImage()
-{
- const int w = pixmap.width();
- const int h = pixmap.height();
- const int &l = cuts[LeftEdge], &r = cuts[RightEdge],
- &t = cuts[TopEdge], &b = cuts[BottomEdge];
-
- topEdgeRect = QRect(l, 0, w - r - l, t);
- bottomEdgeRect = QRect(l, h - b, w - l - r, b);
- if (horizStretch != TileMode_Stretch) {
- if (topEdgeRect.isValid())
- topEdge = pixmap.copy(topEdgeRect).scaledToHeight(t);
- if (bottomEdgeRect.isValid())
- bottomEdge = pixmap.copy(bottomEdgeRect).scaledToHeight(b);
- }
-
- leftEdgeRect = QRect(0, t, l, h - b - t);
- rightEdgeRect = QRect(w - r, t, r, h - t- b);
- if (vertStretch != TileMode_Stretch) {
- if (leftEdgeRect.isValid())
- leftEdge = pixmap.copy(leftEdgeRect).scaledToWidth(l);
- if (rightEdgeRect.isValid())
- rightEdge = pixmap.copy(rightEdgeRect).scaledToWidth(r);
- }
-
- middleRect = QRect(l, t, w - r -l, h - t - b);
- if (middleRect.isValid()
- && !(horizStretch == TileMode_Stretch && vertStretch == TileMode_Stretch)) {
- middle = pixmap.copy(middleRect);
- }
-}
-
-static void qDrawCenterTiledPixmap(QPainter *p, const QRectF& r, const QPixmap& pix)
-{
- p->drawTiledPixmap(r, pix, QPoint(pix.width() - int(r.width())%pix.width(),
- pix.height() - int(r.height())%pix.height()));
}
-// Note: Round is not supported
void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
{
- setClip(p, rect);
- const QRectF br(rect);
- const int *borders = border()->borders;
- const int &l = borders[LeftEdge], &r = borders[RightEdge],
- &t = borders[TopEdge], &b = borders[BottomEdge];
- QRectF pr = br.adjusted(l, t, -r, -b);
+ static const Qt::TileRule tileMode2TileRule[] = {
+ Qt::Stretch, Qt::Round, Qt::Stretch, Qt::Repeat, Qt::Stretch };
+
+ const QStyleSheetBorderImageData *borderImageData = border()->borderImage();
+ const int *targetBorders = border()->borders;
+ const int *sourceBorders = borderImageData->cuts;
+ QMargins sourceMargins(sourceBorders[TopEdge], sourceBorders[LeftEdge],
+ sourceBorders[BottomEdge], sourceBorders[RightEdge]);
+ QMargins targetMargins(targetBorders[TopEdge], targetBorders[LeftEdge],
+ targetBorders[BottomEdge], targetBorders[RightEdge]);
bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform;
p->setRenderHint(QPainter::SmoothPixmapTransform);
-
- const QStyleSheetBorderImageData *bi = border()->borderImage();
- const QPixmap& pix = bi->pixmap;
- const int *c = bi->cuts;
- QRectF tlc(0, 0, c[LeftEdge], c[TopEdge]);
- if (tlc.isValid())
- p->drawPixmap(QRectF(br.topLeft(), QSizeF(l, t)), pix, tlc);
- QRectF trc(pix.width() - c[RightEdge], 0, c[RightEdge], c[TopEdge]);
- if (trc.isValid())
- p->drawPixmap(QRectF(br.left() + br.width() - r, br.y(), r, t), pix, trc);
- QRectF blc(0, pix.height() - c[BottomEdge], c[LeftEdge], c[BottomEdge]);
- if (blc.isValid())
- p->drawPixmap(QRectF(br.x(), br.y() + br.height() - b, l, b), pix, blc);
- QRectF brc(pix.width() - c[RightEdge], pix.height() - c[BottomEdge],
- c[RightEdge], c[BottomEdge]);
- if (brc.isValid())
- p->drawPixmap(QRectF(br.x() + br.width() - r, br.y() + br.height() - b, r, b),
- pix, brc);
-
- QRectF topEdgeRect(br.x() + l, br.y(), pr.width(), t);
- QRectF bottomEdgeRect(br.x() + l, br.y() + br.height() - b, pr.width(), b);
-
- switch (bi->horizStretch) {
- case TileMode_Stretch:
- if (bi->topEdgeRect.isValid())
- p->drawPixmap(topEdgeRect, pix, bi->topEdgeRect);
- if (bi->bottomEdgeRect.isValid())
- p->drawPixmap(bottomEdgeRect, pix, bi->bottomEdgeRect);
- if (bi->middleRect.isValid()) {
- if (bi->vertStretch == TileMode_Stretch)
- p->drawPixmap(pr, pix, bi->middleRect);
- else if (bi->vertStretch == TileMode_Repeat) {
- QPixmap scaled = bi->middle.scaled(int(pr.width()), bi->middle.height());
- qDrawCenterTiledPixmap(p, pr, scaled);
- }
- }
- break;
- case TileMode_Repeat:
- if (!bi->topEdge.isNull() && !topEdgeRect.isEmpty()) {
- QPixmap scaled = bi->topEdge.scaled(bi->topEdge.width(), t);
- qDrawCenterTiledPixmap(p, topEdgeRect, scaled);
- }
- if (!bi->bottomEdge.isNull() && !bottomEdgeRect.isEmpty()) {
- QPixmap scaled = bi->bottomEdge.scaled(bi->bottomEdge.width(), b);
- qDrawCenterTiledPixmap(p, bottomEdgeRect, scaled);
- }
- if (bi->middleRect.isValid()) {
- if (bi->vertStretch == TileMode_Repeat) {
- qDrawCenterTiledPixmap(p, pr, bi->middle);
- } else if (bi->vertStretch == TileMode_Stretch) {
- QPixmap scaled = bi->middle.scaled(bi->middle.width(), int(pr.height()));
- qDrawCenterTiledPixmap(p, pr, scaled);
- }
- }
- break;
- case TileMode_Round:
- if (!bi->topEdge.isNull()) {
- int rwh = (int)pr.width()/ceil(pr.width()/bi->topEdge.width());
- QPixmap scaled = bi->topEdge.scaled(rwh, bi->topEdge.height());
- int blank = int(pr.width()) % rwh;
- p->drawTiledPixmap(QRectF(br.x() + l + blank/2, br.y(), pr.width() - blank, t),
- scaled);
- }
- if (!bi->bottomEdge.isNull()) {
- int rwh = (int) pr.width()/ceil(pr.width()/bi->bottomEdge.width());
- QPixmap scaled = bi->bottomEdge.scaled(rwh, bi->bottomEdge.height());
- int blank = int(pr.width()) % rwh;
- p->drawTiledPixmap(QRectF(br.x() + l+ blank/2, br.y()+br.height()-b,
- pr.width() - blank, b), scaled);
- }
- break;
- default:
- break;
- }
-
- QRectF leftEdgeRect(br.x(), br.y() + t, l, pr.height());
- QRectF rightEdgeRect(br.x() + br.width()- r, br.y() + t, r, pr.height());
-
- switch (bi->vertStretch) {
- case TileMode_Stretch:
- if (bi->leftEdgeRect.isValid())
- p->drawPixmap(leftEdgeRect, pix, bi->leftEdgeRect);
- if (bi->rightEdgeRect.isValid())
- p->drawPixmap(rightEdgeRect, pix, bi->rightEdgeRect);
- break;
- case TileMode_Repeat:
- if (!bi->leftEdge.isNull() && !leftEdgeRect.isEmpty()) {
- QPixmap scaled = bi->leftEdge.scaled(l, bi->leftEdge.height());
- qDrawCenterTiledPixmap(p, leftEdgeRect, scaled);
- }
- if (!bi->rightEdge.isNull() && !rightEdgeRect.isEmpty()) {
- QPixmap scaled = bi->rightEdge.scaled(r, bi->rightEdge.height());
- qDrawCenterTiledPixmap(p, rightEdgeRect, scaled);
- }
- break;
- case TileMode_Round:
- if (!bi->leftEdge.isNull()) {
- int rwh = (int) pr.height()/ceil(pr.height()/bi->leftEdge.height());
- QPixmap scaled = bi->leftEdge.scaled(bi->leftEdge.width(), rwh);
- int blank = int(pr.height()) % rwh;
- p->drawTiledPixmap(QRectF(br.x(), br.y() + t + blank/2, l, pr.height() - blank),
- scaled);
- }
- if (!bi->rightEdge.isNull()) {
- int rwh = (int) pr.height()/ceil(pr.height()/bi->rightEdge.height());
- QPixmap scaled = bi->rightEdge.scaled(bi->rightEdge.width(), rwh);
- int blank = int(pr.height()) % rwh;
- p->drawTiledPixmap(QRectF(br.x() + br.width() - r, br.y()+t+blank/2, r,
- pr.height() - blank), scaled);
- }
- break;
- default:
- break;
- }
-
+ qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap,
+ QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins,
+ QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform);
- unsetClip(p);
}
QRect QRenderRule::originRect(const QRect &rect, Origin origin) const
@@ -1525,7 +1372,7 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
/* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget
* to be transparent when we have a transparent background or border image */
if ((hasBackground() && background()->isTransparent())
- || (hasBorder() && border()->hasBorderImage() && border()->borderImage()->middleRect.isValid()))
+ || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull()))
p->setBrush(cg, w->backgroundRole(), Qt::NoBrush);
}
@@ -5827,7 +5674,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
bool QStyleSheetStyle::event(QEvent *e)
{
- return baseStyle()->event(e) || ParentStyle::event(e);
+ return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e);
}
void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 0571d75..8eaeeb1 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -232,6 +232,12 @@ public:
ImageWidth = 0x5010,
ImageHeight = 0x5011,
+ // internal
+ /*
+ SuppressText = 0x5012,
+ SuppressBackground = 0x513
+ */
+
// selection properties
FullWidthSelection = 0x06000,
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 434d1ca..3222237 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
#define ObjectSelectionBrush (QTextFormat::ForegroundBrush + 1)
+#define SuppressText 0x5012
+#define SuppressBackground 0x513
static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line)
{
@@ -1143,6 +1145,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
QPainterPath excludedRegion;
+ QPainterPath needsTextButNoBackground;
for (int i = 0; i < selections.size(); ++i) {
FormatRange selection = selections.at(i);
const QBrush bg = selection.format.background();
@@ -1211,14 +1214,35 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush());
selection.format.clearProperty(QTextFormat::OutlinePen);
+ bool noText = (selection.format.foreground().style() == Qt::NoBrush);
+
+ selection.format.setProperty(SuppressText, noText);
+
for (int line = firstLine; line < lastLine; ++line) {
QTextLine l(line, d);
l.draw(p, position, &selection);
}
p->restore();
- if (selection.format.foreground().style() != Qt::NoBrush) // i.e. we have drawn text
- excludedRegion += region;
+ if (noText)
+ needsTextButNoBackground += region;
+ else
+ needsTextButNoBackground -= region;
+ excludedRegion += region;
+ }
+
+ if (!needsTextButNoBackground.isEmpty()){
+ p->save();
+ p->setClipPath(needsTextButNoBackground, Qt::IntersectClip);
+ FormatRange selection;
+ selection.start = 0;
+ selection.length = INT_MAX;
+ selection.format.setProperty(SuppressBackground, true);
+ for (int line = firstLine; line < lastLine; ++line) {
+ QTextLine l(line, d);
+ l.draw(p, position, &selection);
+ }
+ p->restore();
}
if (!excludedRegion.isEmpty()) {
@@ -1912,14 +1936,17 @@ static void drawMenuText(QPainter *p, QFixed x, QFixed y, const QScriptItem &si,
static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const QTextCharFormat &chf, const QRectF &r)
{
QBrush c = chf.foreground();
- if (c.style() == Qt::NoBrush)
+ if (c.style() == Qt::NoBrush) {
p->setPen(defaultPen);
+ }
QBrush bg = chf.background();
- if (bg.style() != Qt::NoBrush)
+ if (bg.style() != Qt::NoBrush && !chf.property(SuppressBackground).toBool())
p->fillRect(r, bg);
- if (c.style() != Qt::NoBrush)
+ if (c.style() != Qt::NoBrush) {
p->setPen(QPen(c, 0));
+ }
+
}
/*!
@@ -1933,7 +1960,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
const QScriptLine &line = eng->lines[i];
QPen pen = p->pen();
- bool noText = (selection && selection->format.foreground().style() == Qt::NoBrush);
+ bool noText = (selection && selection->format.property(SuppressText).toBool());
if (!line.length) {
if (selection
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index ad848c9..d2aad99 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -71,7 +71,6 @@ QT_BEGIN_NAMESPACE
/*****************************************************************************
QMenu globals
*****************************************************************************/
-bool qt_mac_no_native_menubar = false;
bool qt_mac_no_menubar_merge = false;
bool qt_mac_quit_menu_item_enabled = true;
int qt_mac_menus_open_count = 0;
@@ -166,7 +165,7 @@ bool qt_mac_activate_action(MenuRef menu, uint command, QAction::ActionEvent act
QMenuMergeList *list = 0;
GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyMergeList,
sizeof(list), 0, &list);
- if (!list && qt_mac_current_menubar.qmenubar) {
+ if (!list && qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
MenuRef apple_menu = qt_mac_current_menubar.qmenubar->d_func()->mac_menubar->apple_menu;
GetMenuItemProperty(apple_menu, 0, kMenuCreatorQt, kMenuPropertyMergeList, sizeof(list), 0, &list);
if (list)
@@ -728,6 +727,18 @@ QMacMenuAction::~QMacMenuAction()
{
#ifdef QT_MAC_USE_COCOA
[menu release];
+ if (action) {
+ QAction::MenuRole role = action->menuRole();
+ // Check if the item is owned by Qt, and should be hidden to keep it from causing
+ // problems. Do it for everything but the quit menu item since that should always
+ // be visible.
+ if (role > QAction::ApplicationSpecificRole && role < QAction::QuitRole) {
+ [menuItem setHidden:YES];
+ } else if (role == QAction::TextHeuristicRole
+ && menuItem != [getMenuLoader() quitMenuItem]) {
+ [menuItem setHidden:YES];
+ }
+ }
[menuItem setTag:nil];
[menuItem release];
#endif
@@ -931,7 +942,8 @@ static QKeySequence qt_mac_menu_merge_accel(QMacMenuAction *action)
void Q_GUI_EXPORT qt_mac_set_menubar_icons(bool b)
{ QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, !b); }
-void Q_GUI_EXPORT qt_mac_set_native_menubar(bool b) { qt_mac_no_native_menubar = !b; }
+void Q_GUI_EXPORT qt_mac_set_native_menubar(bool b)
+{ QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, !b); }
void Q_GUI_EXPORT qt_mac_set_menubar_merge(bool b) { qt_mac_no_menubar_merge = !b; }
/*****************************************************************************
@@ -1728,9 +1740,14 @@ QMenuBarPrivate::macCreateMenuBar(QWidget *parent)
{
Q_Q(QMenuBar);
static int checkEnv = -1;
+ // We call the isNativeMenuBar function here
+ // becasue that will make sure that local overrides
+ // are dealt with correctly.
+ bool qt_mac_no_native_menubar = !q->isNativeMenuBar();
if (qt_mac_no_native_menubar == false && checkEnv < 0) {
checkEnv = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
- qt_mac_no_native_menubar = checkEnv;
+ QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, checkEnv);
+ qt_mac_no_native_menubar = !q->isNativeMenuBar();
}
if (!qt_mac_no_native_menubar) {
extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
@@ -1765,7 +1782,7 @@ void QMenuBarPrivate::macDestroyMenuBar()
OSMenuRef QMenuBarPrivate::macMenu()
{
Q_Q(QMenuBar);
- if (!mac_menubar) {
+ if (!q->isNativeMenuBar() || !mac_menubar) {
return 0;
} else if (!mac_menubar->menu) {
mac_menubar->menu = qt_mac_create_menu(q);
@@ -1886,9 +1903,6 @@ static void cancelAllMenuTracking()
*/
bool QMenuBar::macUpdateMenuBar()
{
- if (qt_mac_no_native_menubar) //nothing to be done..
- return true;
-
cancelAllMenuTracking();
QMenuBar *mb = 0;
//find a menu bar
@@ -1922,7 +1936,7 @@ bool QMenuBar::macUpdateMenuBar()
mb = fallback;
//now set it
bool ret = false;
- if (mb) {
+ if (mb && mb->isNativeMenuBar()) {
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
#endif
@@ -1943,7 +1957,7 @@ bool QMenuBar::macUpdateMenuBar()
qt_mac_current_menubar.qmenubar = mb;
qt_mac_current_menubar.modal = QApplicationPrivate::modalState();
ret = true;
- } else if (qt_mac_current_menubar.qmenubar) {
+ } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
const bool modal = QApplicationPrivate::modalState();
if (modal != qt_mac_current_menubar.modal) {
ret = true;
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index f235cd5..d4de5bd 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -194,7 +194,7 @@ void QMenuBarPrivate::updateGeometries()
}
#ifdef Q_WS_MAC
- if(mac_menubar) {//nothing to see here folks, move along..
+ if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
itemsDirty = false;
return;
}
@@ -1025,14 +1025,8 @@ void QMenuBar::paintEvent(QPaintEvent *e)
*/
void QMenuBar::setVisible(bool visible)
{
-#ifdef Q_WS_MAC
- Q_D(QMenuBar);
- if(d->mac_menubar)
- return;
-#endif
-#ifdef Q_WS_WINCE
- Q_D(QMenuBar);
- if(d->wce_menubar)
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+ if (isNativeMenuBar())
return;
#endif
QWidget::setVisible(visible);
@@ -1272,24 +1266,19 @@ void QMenuBar::actionEvent(QActionEvent *e)
{
Q_D(QMenuBar);
d->itemsDirty = true;
+#if defined (Q_WS_MAC) || defined(Q_OS_WINCE)
+ if (isNativeMenuBar()) {
#ifdef Q_WS_MAC
- if(d->mac_menubar) {
- if(e->type() == QEvent::ActionAdded)
- d->mac_menubar->addAction(e->action(), d->mac_menubar->findAction(e->before()));
- else if(e->type() == QEvent::ActionRemoved)
- d->mac_menubar->removeAction(e->action());
- else if(e->type() == QEvent::ActionChanged)
- d->mac_menubar->syncAction(e->action());
- }
+ QMenuBarPrivate::QMacMenuBarPrivate *nativeMenuBar = d->mac_menubar;
+#else
+ QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar;
#endif
-#ifdef Q_WS_WINCE
- if(d->wce_menubar) {
if(e->type() == QEvent::ActionAdded)
- d->wce_menubar->addAction(e->action(), d->wce_menubar->findAction(e->before()));
+ nativeMenuBar->addAction(e->action(), nativeMenuBar->findAction(e->before()));
else if(e->type() == QEvent::ActionRemoved)
- d->wce_menubar->removeAction(e->action());
+ nativeMenuBar->removeAction(e->action());
else if(e->type() == QEvent::ActionChanged)
- d->wce_menubar->syncAction(e->action());
+ nativeMenuBar->syncAction(e->action());
}
#endif
if(e->type() == QEvent::ActionAdded) {
@@ -1612,10 +1601,8 @@ QRect QMenuBar::actionGeometry(QAction *act) const
QSize QMenuBar::minimumSizeHint() const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_WS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
@@ -1672,14 +1659,13 @@ QSize QMenuBar::minimumSizeHint() const
QSize QMenuBar::sizeHint() const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_WS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
+
ensurePolished();
QSize ret(0, 0);
const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
@@ -1735,13 +1721,12 @@ QSize QMenuBar::sizeHint() const
int QMenuBar::heightForWidth(int) const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_WS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
+
int height = 0;
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
@@ -1856,6 +1841,60 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
}
/*!
+ \property QMenuBar::nativeMenuBar
+ \brief Whether or not a menubar will be used as a native menubar on platforms that support it
+ \since 4.6
+
+ This property specifies whether or not the menubar should be used as a native menubar on platforms
+ that support it. The currently supported platforms are Mac OS X and Windows CE. On these platforms
+ if this property is true, the menubar is used in the native menubar and is not in the window of
+ its parent, if false the menubar remains in the window. On other platforms the value of this
+ attribute has no effect.
+
+ The default is to follow whether the Qt::AA_DontUseNativeMenuBar attribute
+ is set for the application. Explicitly settings this property overrides
+ the presence (or abscence) of the attribute.
+*/
+
+void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
+{
+ Q_D(QMenuBar);
+ if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) {
+ d->nativeMenuBar = nativeMenuBar;
+#ifdef Q_WS_MAC
+ if (!d->nativeMenuBar) {
+ extern void qt_mac_clear_menubar();
+ qt_mac_clear_menubar();
+ d->macDestroyMenuBar();
+ const QList<QAction *> &menubarActions = actions();
+ for (int i = 0; i < menubarActions.size(); ++i) {
+ const QAction *action = menubarActions.at(i);
+ if (QMenu *menu = action->menu()) {
+ delete menu->d_func()->mac_menu;
+ menu->d_func()->mac_menu = 0;
+ }
+ }
+ } else {
+ d->macCreateMenuBar(parentWidget());
+ }
+ macUpdateMenuBar();
+ updateGeometry();
+ setVisible(false);
+ setVisible(true);
+#endif
+ }
+}
+
+bool QMenuBar::isNativeMenuBar() const
+{
+ Q_D(const QMenuBar);
+ if (d->nativeMenuBar == -1) {
+ return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
+ }
+ return d->nativeMenuBar;
+}
+
+/*!
\since 4.4
Sets the default action to \a act.
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
index 8e6dfb5..58a03ff 100644
--- a/src/gui/widgets/qmenubar.h
+++ b/src/gui/widgets/qmenubar.h
@@ -64,6 +64,7 @@ class Q_GUI_EXPORT QMenuBar : public QWidget
Q_OBJECT
Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
+ Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
public:
explicit QMenuBar(QWidget *parent = 0);
@@ -118,6 +119,9 @@ public:
static void wceRefresh();
#endif
+ bool isNativeMenuBar() const;
+ void setNativeMenuBar(bool nativeMenuBar);
+
public Q_SLOTS:
virtual void setVisible(bool visible);
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
index c0bcb00..5dab310 100644
--- a/src/gui/widgets/qmenubar_p.h
+++ b/src/gui/widgets/qmenubar_p.h
@@ -70,7 +70,8 @@ class QMenuBarPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QMenuBar)
public:
QMenuBarPrivate() : itemsDirty(0), itemsWidth(0), itemsStart(-1), currentAction(0), mouseDown(0),
- closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0)
+ closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
+ nativeMenuBar(-1)
#ifdef Q_WS_MAC
, mac_menubar(0)
#endif
@@ -119,6 +120,8 @@ public:
uint keyboardState : 1, altPressed : 1;
QPointer<QWidget> keyboardFocusWidget;
+
+ int nativeMenuBar : 3; // Only has values -1, 0, and 1
//firing of events
void activateAction(QAction *, QAction::ActionEvent);
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 01a743b..aaa5075 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -976,14 +976,14 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
cookie.setExpirationDate(dt);
} else if (field.first == "domain") {
QByteArray rawDomain = field.second;
- QString maybeLeadingDot;
if (rawDomain.startsWith('.')) {
- maybeLeadingDot = QLatin1Char('.');
rawDomain = rawDomain.mid(1);
}
-
QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain)));
- cookie.setDomain(maybeLeadingDot + normalizedDomain);
+ // always add the dot, there are some servers that forget the
+ // leading dot. This is actually forbidden according to RFC 2109,
+ // but all browsers accept it anyway so we do that as well
+ cookie.setDomain(QLatin1Char('.') + normalizedDomain);
} else if (field.first == "max-age") {
bool ok = false;
int secs = field.second.toInt(&ok);
@@ -1184,7 +1184,6 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieLis
cookie.expirationDate() < now;
// validate the cookie & set the defaults if unset
- // (RFC 2965: "The request-URI MUST path-match the Path attribute of the cookie.")
if (cookie.path().isEmpty())
cookie.setPath(defaultPath);
else if (!isParentPath(pathAndFileName, cookie.path()))
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 9e6f821..14d2146 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -189,11 +189,10 @@ CachedImage::CachedImage(const QImage &image)
: s(0)
{
IDirectFBSurface *tmpSurface = 0;
- DFBSurfaceDescription description;
- description = QDirectFBScreen::getSurfaceDescription(image);
+ DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image);
QDirectFBScreen* screen = QDirectFBScreen::instance();
- tmpSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
+ tmpSurface = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface);
if (!tmpSurface) {
qWarning("CachedImage CreateSurface failed!");
return;
@@ -205,7 +204,7 @@ CachedImage::CachedImage(const QImage &image)
description.flags = DFBSurfaceDescriptionFlags(description.flags & ~DSDESC_PREALLOCATED);
- s = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
+ s = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface);
if (!s)
qWarning("QDirectFBPaintEngine failed caching image");
@@ -237,10 +236,8 @@ IDirectFBSurface* SurfaceCache::getSurface(const uint *buf, int size)
clear();
- DFBSurfaceDescription description;
- description = QDirectFBScreen::getSurfaceDescription(buf, size);
-
- surface = QDirectFBScreen::instance()->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
+ const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size);
+ surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface);
if (!surface)
qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface");
@@ -736,10 +733,8 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest,
}
if (!imgSurface) {
- DFBSurfaceDescription description;
-
- description = QDirectFBScreen::getSurfaceDescription(image);
- imgSurface = QDirectFBScreen::instance()->createDFBSurface(&description,
+ DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image);
+ imgSurface = QDirectFBScreen::instance()->createDFBSurface(description,
QDirectFBScreen::DontTrackSurface);
if (!imgSurface) {
qWarning("QDirectFBPaintEnginePrivate::drawImage");
@@ -906,7 +901,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
{
Q_D(QDirectFBPaintEngine);
d->setClipDirty();
- if (!d->clip()->hasRectClip && d->clip()->enabled) {
+ if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) {
const QPoint bottom = d->transform.map(QPoint(0, rect.bottom()));
if (bottom.y() >= d->lastLockedHeight)
d->lock();
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index a53b1c0..c1b75c5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -84,7 +84,7 @@ public:
QImage::Format alphaPixmapFormat;
};
-QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen)
+QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen)
: QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
#ifndef QT_NO_DIRECTFB_LAYER
, dfbLayer(0)
@@ -113,7 +113,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
delete keyboard;
#endif
- foreach (IDirectFBSurface* surf, allocatedSurfaces)
+ foreach (IDirectFBSurface *surf, allocatedSurfaces)
surf->Release(surf);
allocatedSurfaces.clear();
@@ -137,7 +137,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
// creates a preallocated surface with the same format as the image if
// possible.
-IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options)
+IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options)
{
if (img.isNull()) // assert?
return 0;
@@ -155,8 +155,7 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCr
return surface;
}
- DFBSurfaceDescription desc = QDirectFBScreen::getSurfaceDescription(img);
- IDirectFBSurface *surface = createDFBSurface(&desc, options);
+ IDirectFBSurface *surface = createDFBSurface(QDirectFBScreen::getSurfaceDescription(img), options);
#ifdef QT_NO_DIRECTFB_PREALLOCATED
if (surface) {
int bpl;
@@ -211,53 +210,55 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size,
return 0;
desc.width = size.width();
desc.height = size.height();
- return createDFBSurface(&desc, options);
+ return createDFBSurface(desc, options);
}
-IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription *desc, SurfaceCreationOptions options)
+IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options)
{
- DFBResult result;
- IDirectFBSurface* newSurface = 0;
+ DFBResult result = DFB_OK;
+ IDirectFBSurface *newSurface = 0;
if (!d_ptr->dfb) {
qWarning("QDirectFBScreen::createDFBSurface() - not connected");
return 0;
}
- if (d_ptr->directFBFlags & VideoOnly && !(desc->flags & DSDESC_PREALLOCATED)) {
+ if (d_ptr->directFBFlags & VideoOnly && !(desc.flags & DSDESC_PREALLOCATED)) {
// Add the video only capability. This means the surface will be created in video ram
- DFBSurfaceDescription voDesc = *desc;
- if (!(voDesc.flags & DSDESC_CAPS)) {
- voDesc.caps = DSCAPS_VIDEOONLY;
- voDesc.flags = DFBSurfaceDescriptionFlags(voDesc.flags | DSDESC_CAPS);
+ if (!(desc.flags & DSDESC_CAPS)) {
+ desc.caps = DSCAPS_VIDEOONLY;
+ desc.flags = DFBSurfaceDescriptionFlags(desc.flags | DSDESC_CAPS);
} else {
- voDesc.caps = DFBSurfaceCapabilities(voDesc.caps | DSCAPS_VIDEOONLY);
+ desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_VIDEOONLY);
}
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &voDesc, &newSurface);
+ result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
if (result != DFB_OK
#ifdef QT_NO_DEBUG
- && (desc->flags & DSDESC_CAPS) && (desc->caps & DSCAPS_PRIMARY)
+ && (desc.flags & DSDESC_CAPS) && (desc.caps & DSCAPS_PRIMARY)
#endif
) {
qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n"
" Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc->flags, desc->caps, desc->width, desc->height,
- desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat),
- desc->preallocated[0].data, desc->preallocated[0].pitch,
+ desc.flags, desc.caps, desc.width, desc.height,
+ desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
+ desc.preallocated[0].data, desc.preallocated[0].pitch,
DirectFBErrorString(result));
}
+ desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY);
}
+ if (d_ptr->directFBFlags & SystemOnly)
+ desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_SYSTEMONLY);
if (!newSurface)
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, desc, &newSurface);
+ result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
if (result != DFB_OK) {
qWarning("QDirectFBScreen::createDFBSurface() Failed!\n"
" Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc->flags, desc->caps, desc->width, desc->height,
- desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat),
- desc->preallocated[0].data, desc->preallocated[0].pitch,
+ desc.flags, desc.caps, desc.width, desc.height,
+ desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
+ desc.preallocated[0].data, desc.preallocated[0].pitch,
DirectFBErrorString(result));
return 0;
}
@@ -349,18 +350,18 @@ QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const
{
return d_ptr->directFBFlags;
}
-IDirectFB* QDirectFBScreen::dfb()
+IDirectFB *QDirectFBScreen::dfb()
{
return d_ptr->dfb;
}
-IDirectFBSurface* QDirectFBScreen::dfbSurface()
+IDirectFBSurface *QDirectFBScreen::dfbSurface()
{
return d_ptr->dfbSurface;
}
#ifndef QT_NO_DIRECTFB_LAYER
-IDirectFBDisplayLayer* QDirectFBScreen::dfbDisplayLayer()
+IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer()
{
return d_ptr->dfbLayer;
}
@@ -730,7 +731,7 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args)
}
}
-QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const
+QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const
{
if (type == QPixmapData::BitmapType)
return QWSGraphicsSystem::createPixmapData(type);
@@ -738,6 +739,84 @@ QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ
return new QDirectFBPixmapData(type);
}
+#ifdef QT_NO_DEBUG
+struct FlagDescription;
+static const FlagDescription *accelerationDescriptions = 0;
+static const FlagDescription *blitDescriptions = 0;
+static const FlagDescription *drawDescriptions = 0;
+#else
+struct FlagDescription {
+ const char *name;
+ uint flag;
+};
+
+static const FlagDescription accelerationDescriptions[] = {
+ { "DFXL_NONE ", DFXL_NONE },
+ { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE },
+ { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE },
+ { "DFXL_DRAWLINE", DFXL_DRAWLINE },
+ { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE },
+ { "DFXL_BLIT", DFXL_BLIT },
+ { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT },
+ { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES },
+ { "DFXL_DRAWSTRING", DFXL_DRAWSTRING },
+ { 0, 0 }
+};
+
+static const FlagDescription blitDescriptions[] = {
+ { "DSBLIT_NOFX", DSBLIT_NOFX },
+ { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL },
+ { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA },
+ { "DSBLIT_COLORIZE", DSBLIT_COLORIZE },
+ { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY },
+ { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY },
+ { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY },
+ { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY },
+ { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY },
+ { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE },
+ { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR },
+ { "DSBLIT_XOR", DSBLIT_XOR },
+ { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION },
+ { 0, 0 }
+};
+
+static const FlagDescription drawDescriptions[] = {
+ { "DSDRAW_NOFX", DSDRAW_NOFX },
+ { "DSDRAW_BLEND", DSDRAW_BLEND },
+ { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY },
+ { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY },
+ { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY },
+ { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY },
+ { "DSDRAW_XOR", DSDRAW_XOR },
+ { 0, 0 }
+};
+#endif
+
+
+
+static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags)
+{
+#ifdef QT_NO_DEBUG
+ Q_UNUSED(mask);
+ Q_UNUSED(flags);
+ return QByteArray("");
+#else
+ if (!mask)
+ return flags[0].name;
+
+ QStringList list;
+ for (int i=1; flags[i].name; ++i) {
+ if (mask & flags[i].flag) {
+ list.append(QString::fromLatin1(flags[i].name));
+ }
+ }
+ Q_ASSERT(!list.isEmpty());
+ return (QLatin1Char(' ') + list.join(QLatin1String("|"))).toLatin1();
+#endif
+}
+
+
+
static void printDirectFBInfo(IDirectFB *fb)
{
DFBResult result;
@@ -750,10 +829,13 @@ static void printDirectFBInfo(IDirectFB *fb)
}
qDebug("Device: %s (%s), Driver: %s v%i.%i (%s)\n"
- " acceleration: 0x%x, blit: 0x%x, draw: 0x%0x video: %i\n",
+ " acceleration: 0x%x%s,\nblit: 0x%x%s,\ndraw: 0x%0x%s\nvideo: %iKB\n",
dev.name, dev.vendor, dev.driver.name, dev.driver.major,
dev.driver.minor, dev.driver.vendor, dev.acceleration_mask,
- dev.blitting_flags, dev.drawing_flags, dev.video_memory);
+ ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(),
+ dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(),
+ dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(),
+ (dev.video_memory >> 10));
}
static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value)
@@ -806,6 +888,18 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive))
d_ptr->directFBFlags |= VideoOnly;
+ if (displayArgs.contains(QLatin1String("systemonly"), Qt::CaseInsensitive)) {
+ if (d_ptr->directFBFlags & VideoOnly) {
+ qWarning("QDirectFBScreen: error. videoonly and systemonly are mutually exclusive");
+ } else {
+ d_ptr->directFBFlags |= SystemOnly;
+ }
+ }
+
+ if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) {
+ d_ptr->directFBFlags |= BoundingRectFlip;
+ }
+
if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive))
d_ptr->directFBFlags |= IgnoreSystemClip;
@@ -820,9 +914,23 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH);
if (::setIntOption(displayArgs, QLatin1String("height"), &description.height))
description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_HEIGHT);
+
uint caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE;
- if (displayArgs.contains(QLatin1String("static_alloc")))
- caps |= DSCAPS_STATIC_ALLOC;
+ struct {
+ const char *name;
+ const DFBSurfaceCapabilities cap;
+ } const capabilities[] = {
+ { "static_alloc", DSCAPS_STATIC_ALLOC },
+ { "triplebuffer", DSCAPS_TRIPLE },
+ { "interlaced", DSCAPS_INTERLACED },
+ { "separated", DSCAPS_SEPARATED },
+// { "depthbuffer", DSCAPS_DEPTH }, // only makes sense with TextureTriangles which are not supported
+ { 0, DSCAPS_NONE }
+ };
+ for (int i=0; capabilities[i].name; ++i) {
+ if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive))
+ caps |= capabilities[i].cap;
+ }
if (displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) {
caps |= DSCAPS_PREMULTIPLIED;
@@ -830,7 +938,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
description.caps = DFBSurfaceCapabilities(caps);
// We don't track the primary surface as it's released in disconnect
- d_ptr->dfbSurface = createDFBSurface(&description, DontTrackSurface);
+ d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface);
if (!d_ptr->dfbSurface) {
DirectFBError("QDirectFBScreen: error creating primary surface",
result);
@@ -921,7 +1029,7 @@ void QDirectFBScreen::disconnect()
d_ptr->dfbSurface->Release(d_ptr->dfbSurface);
d_ptr->dfbSurface = 0;
- foreach (IDirectFBSurface* surf, d_ptr->allocatedSurfaces)
+ foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces)
surf->Release(surf);
d_ptr->allocatedSurfaces.clear();
@@ -990,7 +1098,7 @@ void QDirectFBScreen::blank(bool on)
(on ? DSPM_ON : DSPM_SUSPEND));
}
-QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const
+QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const
{
#ifdef QT_NO_DIRECTFB_WM
if (QApplication::type() == QApplication::GuiServer) {
@@ -1003,7 +1111,7 @@ QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const
#endif
}
-QWSWindowSurface* QDirectFBScreen::createSurface(const QString &key) const
+QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const
{
if (key == QLatin1String("directfb")) {
return new QDirectFBSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this));
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index 8e75277..42d0ebe 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -62,7 +62,9 @@ public:
enum DirectFBFlag {
NoFlags = 0x00,
VideoOnly = 0x01,
- IgnoreSystemClip = 0x02
+ SystemOnly = 0x02,
+ IgnoreSystemClip = 0x04,
+ BoundingRectFlip = 0x08
};
Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
@@ -82,19 +84,19 @@ public:
void setMode(int width, int height, int depth);
void blank(bool on);
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
+ QWSWindowSurface *createSurface(QWidget *widget) const;
+ QWSWindowSurface *createSurface(const QString &key) const;
- static inline QDirectFBScreen* instance() {
+ static inline QDirectFBScreen *instance() {
QScreen *inst = QScreen::instance();
Q_ASSERT(!inst || inst->classId() == QScreen::DirectFBClass);
return static_cast<QDirectFBScreen*>(inst);
}
- IDirectFB* dfb();
- IDirectFBSurface* dfbSurface();
+ IDirectFB *dfb();
+ IDirectFBSurface *dfbSurface();
#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer* dfbDisplayLayer();
+ IDirectFBDisplayLayer *dfbDisplayLayer();
#endif
// Track surface creation/release so we can release all on exit
@@ -103,7 +105,7 @@ public:
TrackSurface = 1
};
Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption);
- IDirectFBSurface *createDFBSurface(const DFBSurfaceDescription *desc,
+ IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc,
SurfaceCreationOptions options);
IDirectFBSurface *createDFBSurface(const QImage &image,
SurfaceCreationOptions options);
@@ -116,7 +118,7 @@ public:
IDirectFBSurface *copyToDFBSurface(const QImage &image,
QImage::Format format,
SurfaceCreationOptions options);
- void releaseDFBSurface(IDirectFBSurface* surface);
+ void releaseDFBSurface(IDirectFBSurface *surface);
static int depth(DFBSurfacePixelFormat format);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
index 257efeb..beb9b5f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
@@ -50,13 +50,14 @@
//#define QT_DIRECTFB_DEBUG_SURFACES 1
-QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen* scr)
+QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
: QDirectFBPaintDevice(scr)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
, engine(0)
, flipFlags(flip)
+ , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
setSurfaceFlags(Opaque | Buffered);
#ifdef QT_DIRECTFB_TIMING
@@ -72,6 +73,7 @@ QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *sc
#endif
, engine(0)
, flipFlags(flip)
+ , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
onscreen = widget->testAttribute(Qt::WA_PaintOnScreen);
if (onscreen)
@@ -184,7 +186,7 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask)
description.height = rect.height();
QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description,
screen->pixelFormat());
- dfbSurface = screen->createDFBSurface(&description, false);
+ dfbSurface = screen->createDFBSurface(description, false);
forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32);
} else {
Q_ASSERT(dfbSurface);
@@ -369,20 +371,15 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion &region,
if (!(flipFlags & DSFLIP_BLIT)) {
dfbSurface->Flip(dfbSurface, 0, flipFlags);
} else {
- if (region.numRects() > 1) {
+ if (!boundingRectFlip && region.numRects() > 1) {
const QVector<QRect> rects = region.rects();
- DFBSurfaceFlipFlags tmpFlags = flipFlags;
- if (flipFlags & DSFLIP_WAIT)
- tmpFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT);
+ const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT);
for (int i=0; i<rects.size(); ++i) {
const QRect &r = rects.at(i);
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
r.x() + r.width() + offset.x(),
r.y() + r.height() + offset.y() };
- dfbSurface->Flip(dfbSurface, &dfbReg,
- i + 1 < rects.size()
- ? tmpFlags
- : flipFlags);
+ dfbSurface->Flip(dfbSurface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags);
}
} else {
const QRect r = region.boundingRect();
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
index ab4145d..54c14a5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
@@ -100,6 +100,7 @@ private:
QList<QImage*> bufferImages;
DFBSurfaceFlipFlags flipFlags;
+ bool boundingRectFlip;
#ifdef QT_DIRECTFB_TIMING
int frames;
QTime timer;
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 4e90777..9932463 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -70,13 +70,12 @@ QT_BEGIN_NAMESPACE
#endif
// newer platform SDKs use SQLLEN instead of SQLINTEGER
-//#if defined(SQLLEN) || defined(Q_OS_WIN64)
-#if ODBCVER >= 0x0270
-# define QSQLLEN SQLLEN
-# define QSQLULEN SQLULEN
-#else
+#if defined(WIN32) && (_MSC_VER < 1300)
# define QSQLLEN SQLINTEGER
# define QSQLULEN SQLUINTEGER
+#else
+# define QSQLLEN SQLLEN
+# define QSQLULEN SQLULEN
#endif