From 484d54532a773cf90ebf8c9c2c4f4d839b1b3744 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Apr 2009 09:12:34 +0200 Subject: Fix stylesheet test when button color != window color --- tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index aa63753..24ccecf 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -605,8 +605,9 @@ void tst_QStyleSheetStyle::palettePropagation() QVERIFY(COLOR(gb) == Qt::red); QVERIFY(COLOR(pb) == APPCOLOR(pb)); // palette shouldn't propagate gb.setStyleSheet("QGroupBox * { color: red }"); + QVERIFY(COLOR(pb) == Qt::red); - QVERIFY(COLOR(gb) == APPCOLOR(pb)); + QVERIFY(COLOR(gb) == APPCOLOR(gb)); QWidget window; window.setStyleSheet("* { color: white; }"); -- cgit v0.12 From e372dc629927b60943568e9bbadb79fbaafab3a8 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 28 Apr 2009 09:16:01 +0200 Subject: Fix crash in uic regarding setting QIcon The regression was intruduced in change 04c01e15. Task: 252333 RevBy: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 3d702dd..47566ad 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1650,19 +1650,19 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) if (i->hasElementNormalOff()) m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::Off);\n"; if (i->hasElementNormalOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; if (i->hasElementDisabledOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; if (i->hasElementDisabledOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; if (i->hasElementActiveOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; if (i->hasElementActiveOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n"; if (i->hasElementSelectedOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; if (i->hasElementSelectedOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; } else { // pre-4.4 legacy m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; } -- cgit v0.12 From 0f0dbd09f7bf2ef9d69d1e559ace961d9b236d3b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 28 Apr 2009 10:16:04 +0200 Subject: When minimizing/restoring an item view it could jump to its currently selected item Task-number: 250446 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 2 +- tests/auto/qlistview/tst_qlistview.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 55b3a03..975decc 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1380,7 +1380,7 @@ 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 const QModelIndex current = currentIndex(); if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll)) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2e7f412..c372475 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -105,6 +105,7 @@ private slots: void task203585_selectAll(); void task228566_infiniteRelayout(); void task248430_crashWith0SizedItem(); + void task250446_scrollChanged(); }; // Testing get/set functions @@ -1528,5 +1529,32 @@ void tst_QListView::task248430_crashWith0SizedItem() QTest::qWait(100); } +void tst_QListView::task250446_scrollChanged() +{ + QStandardItemModel model(200, 1); + QListView view; + view.setModel(&model); + QModelIndex index = model.index(0, 0); + QVERIFY(index.isValid()); + view.setCurrentIndex(index); + view.show(); + QTest::qWait(100); + const int scrollValue = view.verticalScrollBar()->maximum(); + view.verticalScrollBar()->setValue(scrollValue); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); + + view.showMinimized(); + QTest::qWait(100); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); + + view.showNormal(); + QTest::qWait(100); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 0901f3f8055240d97def42d59e6a76e0b299e985 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 28 Apr 2009 10:54:11 +0200 Subject: Fix a crash with a proxy model applied on the QFileDialog. The problem was located in _q_enterDirectory, this method take a QModelIndex that can be a model index from the treeview/listview (so it comes from the proxy that is applied) and from the side bar where there is always no proxy applied. Previously we were trying to convert from a proxy index to a source index the value that come from the sidebar which is already a source model index. Now, we just check if the model index is coming from the proxy and in that case we convert it otherwise this model index come from the source. Task-number: 252068 Reviewed-by: jasplin Reviewed-by: ogoffart --- src/gui/dialogs/qfiledialog.cpp | 2 +- tests/auto/qfiledialog/tst_qfiledialog.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 073c25b..abb13c0 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2793,7 +2793,7 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) { Q_Q(QFileDialog); // My Computer or a directory - QModelIndex sourceIndex = mapToSource(index); + QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index; QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); if (path.isEmpty() || model->isDir(sourceIndex)) { q->setDirectory(path); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 13b13d6..689f73d 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -1602,6 +1602,19 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() QTest::keyClick(list, Qt::Key_Return); QTest::qWait(200); + dialog->close(); + fd.close(); + + QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0); + QSortFilterProxyModel *pm = new QSortFilterProxyModel; + fd2.setProxyModel(pm); + fd2.show(); + QSidebar *sidebar = qFindChild(&fd2, "sidebar"); + sidebar->setFocus(); + sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath())); + QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); + QTest::qWait(250); + //We shouldn't crash } void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() -- cgit v0.12 From 20217d3521a9e59a0730a0eb63d09ffb1c236bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 28 Apr 2009 10:55:31 +0200 Subject: Fixed rendering of bitmap fonts on X11 with Xrender and fontconfig. It seems the Xrender PictStandardA1 mask format doesn't work with XLFD bitmap fonts wrapped in a fontconfig structure. Task-number: 252328 Reviewed-by: Samuel --- src/gui/painting/qpaintengine_x11.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 39ce59f..4b2fbca 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2352,7 +2352,9 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti) GlyphSet glyphSet = set->id; const QColor &pen = d->cpen.color(); ::Picture src = X11->getSolidFill(d->scrn, pen); - XRenderPictFormat *maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format); + XRenderPictFormat *maskFormat = 0; + if (ft->xglyph_format != PictStandardA1) + maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format); enum { t_min = SHRT_MIN, t_max = SHRT_MAX }; -- cgit v0.12 From c1691ab1f69919c51f8c66732bbc38bae39329df Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 28 Apr 2009 11:41:06 +0200 Subject: Fixed showing messageboxes on small screens. On small screens use the whole screen width when adjusting the size of the messagebox. Task-number: 251925 Reviewed-by: Brad --- src/gui/dialogs/qmessagebox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 456b480..5e59501 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -280,6 +280,9 @@ void QMessageBoxPrivate::updateSize() int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); #else int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this + // on small screens allows the messagebox be the same size as the screen + if (screenSize.width() <= 1024) + hardLimit = screenSize.width(); #endif #ifdef Q_WS_MAC int softLimit = qMin(screenSize.width()/2, 420); -- cgit v0.12 From d851374c7894ac62367d885e7c24650d8635d2e8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 23 Apr 2009 17:06:45 +0200 Subject: performance improvement of isUncRoot in qfsfileengine_win.cpp We always called QStringList::split in this function, which was just expensive. Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 522be20..63506c2 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -346,8 +346,15 @@ bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringL static bool isUncRoot(const QString &server) { QString localPath = QDir::toNativeSeparators(server); - QStringList parts = localPath.split(QLatin1Char('\\'), QString::SkipEmptyParts); - return localPath.startsWith(QLatin1String("\\\\")) && parts.count() <= 1; + if (!localPath.startsWith(QLatin1String("\\\\"))) + return false; + + int idx = localPath.indexOf(QLatin1Char('\\'), 2); + if (idx == -1 || idx + 1 == localPath.length()) + return true; + + localPath = localPath.right(localPath.length() - idx - 1).trimmed(); + return localPath.isEmpty(); } static bool isUncPath(const QString &path) -- cgit v0.12 From 8ec06f944915a56ef7ad3f1a9416b16271055fb9 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 28 Apr 2009 11:33:56 +0200 Subject: Cocoa: qwidget auto test fails (windowMoveResize) The test fails because, in cocoa, when resizing a window to zero (either w or h), cocoa will also move the window up in the corner (!). So the fix is to issue an extra move back to it's true location after the resize. The faulty cocoa move is issued inside the resize callback, so we choose to not update the window location anymore from a pure resize callback. Task-number: 251895 Reviewed-by: Trenton Schulz --- src/gui/kernel/qcocoawindowdelegate_mac.mm | 17 ++++++++--------- src/gui/kernel/qwidget_mac.mm | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 03b2fce..fa325f4 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -194,7 +194,6 @@ static void cleanupCocoaWindowDelegate() { NSWindow *window = [notification object]; QWidget *qwidget = m_windowHash->value(window); - // Just here to handle the is zoomed method. QWidgetData *widgetData = qt_qwidget_data(qwidget); if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) { widgetData->window_state = widgetData->window_state | Qt::WindowMaximized; @@ -202,7 +201,6 @@ static void cleanupCocoaWindowDelegate() & ~Qt::WindowMaximized)); qt_sendSpontaneousEvent(qwidget, &e); } - [self checkForMove:[window frame] forWidget:qwidget]; NSRect rect = [[window contentView] frame]; const QSize newSize(rect.size.width, rect.size.height); const QSize &oldSize = widgetData->crect.size(); @@ -212,12 +210,18 @@ static void cleanupCocoaWindowDelegate() } } -- (void)checkForMove:(const NSRect &)newRect forWidget:(QWidget *)qwidget +- (void)windowDidMove:(NSNotification *)notification { - // newRect's origin is bottom left. + // The code underneath needs to translate the window location + // from bottom left (which is the origin used by Cocoa) to + // upper left (which is the origin used by Qt): + NSWindow *window = [notification object]; + NSRect newRect = [window frame]; + QWidget *qwidget = m_windowHash->value(window); QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x, newRect.origin.y + newRect.size.height)).toPoint(); const QRect &oldRect = qwidget->frameGeometry(); + if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) { QWidgetData *widgetData = qt_qwidget_data(qwidget); QRect oldCRect = widgetData->crect; @@ -233,11 +237,6 @@ static void cleanupCocoaWindowDelegate() } } -- (void)windowDidMove:(NSNotification *)notification -{ - [self windowDidResize:notification]; -} - -(BOOL)windowShouldClose:(id)windowThatWantsToClose { QWidget *qwidget = m_windowHash->value(windowThatWantsToClose); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index a00f969..5abaaf8 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4039,7 +4039,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QMacCocoaAutoReleasePool pool; bool realWindow = isRealWindow(); - if (realWindow && !(w == 0 && h == 0) && !q->testAttribute(Qt::WA_DontShowOnScreen)) { + if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen) +#ifndef QT_MAC_USE_COCOA + && !(w == 0 && h == 0) +#endif + ){ applyMaxAndMinSizeConstraints(w, h); topData()->isSetGeometry = 1; topData()->isMove = isMove; @@ -4054,7 +4058,24 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) fStrut.top() + fStrut.bottom() + h)); NSRect cocoaFrameRect = NSMakeRect(frameRect.x(), flipYCoordinate(frameRect.bottom() + 1), frameRect.width(), frameRect.height()); - [window setFrame:cocoaFrameRect display:NO]; + + QPoint currTopLeft = data.crect.topLeft(); + if (currTopLeft.x() == x && currTopLeft.y() == y + && cocoaFrameRect.size.width != 0 + && cocoaFrameRect.size.height != 0) { + [window setFrame:cocoaFrameRect display:NO]; + } else { + // The window is moved and resized (or resized to zero). + // Since Cocoa usually only sends us a resize callback after + // setting a window frame, we issue an explicit move as + // well. To stop Cocoa from optimize away the move (since the move + // would have the same origin as the setFrame call) we shift the + // window back and forth inbetween. + cocoaFrameRect.origin.y += 1; + [window setFrame:cocoaFrameRect display:NO]; + cocoaFrameRect.origin.y -= 1; + [window setFrameOrigin:cocoaFrameRect.origin]; + } #endif topData()->isSetGeometry = 0; } else { -- cgit v0.12 From 5d6a56fd14cb21d9955c49305993f7b7527a27c6 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 27 Apr 2009 17:11:43 +0200 Subject: Don't send extra events when using the scroll wheel in Cocoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Argh! Copy and paste is evil, not only was the test was wrong, We sent the event twice and the second time we sent the wrong value. Task-number: 250668 Reviewed-by: Morten Sørvig --- src/gui/kernel/qcocoaview_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index fae4821..ff36ca1 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -807,10 +807,10 @@ extern "C" { QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical); qt_sendSpontaneousEvent(qwidget, &qwe); wheelOK = qwe.isAccepted(); - if (wheelOK && QApplicationPrivate::focus_widget + if (!wheelOK && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != qwidget) { QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal, - deltaZ, buttons, keyMods, Qt::Vertical); + deltaY, buttons, keyMods, Qt::Vertical); qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2); wheelOK = qwe2.isAccepted(); } -- cgit v0.12 From 49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Apr 2009 14:07:24 +0200 Subject: Fix regression in QSelectionModel::rowIntersectsSelection and QSelectionModel::columnsIntersectsSelection The documentation says "if one is selected" inside the row/column, so we need to look over if we find one which is selected Task-number: 252069 Reviewed-by: Marius Bugge Monsen --- src/gui/itemviews/qitemselectionmodel.cpp | 20 +++++----- .../tst_qitemselectionmodel.cpp | 46 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 1a3ae2d..8baefdf 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -1313,11 +1313,11 @@ bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &par int left = sel.at(i).left(); int right = sel.at(i).right(); if (top <= row && bottom >= row) { - Qt::ItemFlags leftFlags = d->model->index(row, left, parent).flags(); - Qt::ItemFlags rightFlags = d->model->index(row, right, parent).flags(); - if ((leftFlags & Qt::ItemIsSelectable) && (leftFlags & Qt::ItemIsEnabled) - && (rightFlags & Qt::ItemIsSelectable) && (rightFlags & Qt::ItemIsEnabled)) - return true; + for (int j = left; j <= right; j++) { + const Qt::ItemFlags flags = d->model->index(row, j, parent).flags(); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return true; + } } } @@ -1342,11 +1342,11 @@ bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelInde int top = sel.at(i).top(); int bottom = sel.at(i).bottom(); if (left <= column && right >= column) { - Qt::ItemFlags topFlags = d->model->index(top, column, parent).flags(); - Qt::ItemFlags bottomFlags = d->model->index(bottom, column, parent).flags(); - if ((topFlags & Qt::ItemIsSelectable) && (topFlags & Qt::ItemIsEnabled) - && (bottomFlags & Qt::ItemIsSelectable) && (bottomFlags & Qt::ItemIsEnabled)) - return true; + for (int j = top; j <= bottom; j++) { + const Qt::ItemFlags flags = d->model->index(j, column, parent).flags(); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return true; + } } } diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 15b36b8..9bd1ce3 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -89,6 +89,7 @@ private slots: void merge_data(); void merge(); void task119433_isRowSelected(); + void task252069_rowIntersectsSelection(); private: QAbstractItemModel *model; @@ -2140,6 +2141,51 @@ void tst_QItemSelectionModel::task119433_isRowSelected() QVERIFY(sel.isRowSelected(0, QModelIndex())); } +void tst_QItemSelectionModel::task252069_rowIntersectsSelection() +{ + QStandardItemModel m; + for (int i=0; i<8; ++i) { + for (int j=0; j<8; ++j) { + QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + if ((i % 2 == 0 && j == 0) || + (j % 2 == 0 && i == 0) || + j == 5 || i == 5 ) { + item->setEnabled(false); + //item->setSelectable(false); + } + m.setItem(i, j, item); + } + } + + QItemSelectionModel selected(&m); + //nothing is selected + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(2, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(0, 5), QItemSelectionModel::Select | QItemSelectionModel::Columns); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); +} QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From 2f2811f24268d9f34e2725e1aca4212a6ffdd81f Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 28 Apr 2009 17:49:24 +0200 Subject: Changed include file name to lowercase to be able to crosscompile win32-g++ version from a Linux machine. Reviewed-by: trustme --- qmake/project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index eef32db..00bb2f0 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -57,7 +57,7 @@ #include #include #elif defined(Q_OS_WIN32) -#include +#include #endif #include #include -- cgit v0.12 From cde40ce4a211816bf4222fa5487139c416f7b165 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 28 Apr 2009 19:11:51 +0200 Subject: Fix documentation about native dialogs It basically says that on KDE and GNOME the native dialogs are called. It fix a mistake about a regular instantiation on QFileDialog object on Windows. --- src/gui/dialogs/qfiledialog.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index abb13c0..2f524cb 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -96,9 +96,8 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook order to select one or many files or a directory. The easiest way to create a QFileDialog is to use the static - functions. On Windows, these static functions will call the native - Windows file dialog, and on Mac OS X these static function will call - the native Mac OS X file dialog. + functions. On Windows, Mac OS X, KDE and GNOME, these static functions will + call the native file dialog when possible. \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 0 @@ -216,7 +215,7 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook are resolved. \value DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. By default confirmation is requested. - \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X and Windows, + \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X, the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro. \value ReadOnly Indicates that the model is readonly. -- cgit v0.12 From b4caab9d25d1a2a6f95bf4bd15094475586ccf6a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 10:22:57 -0700 Subject: Cleaned up constness errors All these drawing functions really shouldn't be const even if some of them can be. They should never be called from const functions and when/if they change pen/brush stuff they cease being able to be const. Also make sure fillRegion() uses the right brush. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index ba5d71a..83c2039 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -270,14 +270,14 @@ public: inline bool dfbCanHandleClip() const; inline bool isSimpleBrush(const QBrush &brush) const; - void drawLines(const QLine *lines, int count) const; - void drawLines(const QLineF *lines, int count) const; + void drawLines(const QLine *lines, int count); + void drawLines(const QLineF *lines, int count); - void fillRegion(const QRegion &r) const; - void fillRects(const QRect *rects, int count) const; - void drawRects(const QRect *rects, int count) const; - void fillRects(const QRectF *rects, int count) const; - void drawRects(const QRectF *rects, int count) const; + void fillRegion(const QRegion &r); + void fillRects(const QRect *rects, int count); + void drawRects(const QRect *rects, int count); + void fillRects(const QRectF *rects, int count); + void drawRects(const QRectF *rects, int count); void drawPixmap(const QRectF &dest, @@ -545,7 +545,7 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags)); } -void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const +void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) { for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]); @@ -553,7 +553,7 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const } } -void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const +void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) { for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]).toLine(); @@ -561,14 +561,16 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const } } -void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) const +void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) { + Q_ASSERT(isSimpleBrush(q->state()->brush)); + setDFBColor(q->state()->brush.color()); const QVector rects = region.rects(); const int n = rects.size(); fillRects(rects.constData(), n); } -void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const +void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); @@ -577,7 +579,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const } } -void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const +void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); @@ -586,7 +588,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const } } -void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const +void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); @@ -595,7 +597,7 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const } } -void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) const +void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); -- cgit v0.12 From de14db188ada5e00980a152dadb13d38438a7fa2 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 10:46:34 -0700 Subject: Make the disable/warn on fallbacks more flexible Allow programmers to select which operations they want to warn on/disable and which not to. To warn for DRAW_PIXMAP only you can do this: DEFINES += QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=DRAW_PIXMAP To include fillRect you can do: DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=DRAW_PIXMAP|FILL_RECT\" Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 37 ++++----- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 97 ++++++++++++++-------- 2 files changed, 82 insertions(+), 52 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 1ee9030..67f5d61 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -14,30 +14,29 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers #DEFINES += QT_NO_DIRECTFB_KEYBOARD #DEFINES += QT_DIRECTFB_TIMING #DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION -#DEFINES += QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#DEFINES += QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS +#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" +#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target -HEADERS = \ - qdirectfbscreen.h \ - qdirectfbsurface.h \ - qdirectfbpaintengine.h \ - qdirectfbpaintdevice.h \ - qdirectfbpixmap.h \ - qdirectfbkeyboard.h \ - qdirectfbmouse.h +HEADERS = qdirectfbscreen.h \ + qdirectfbsurface.h \ + qdirectfbpaintengine.h \ + qdirectfbpaintdevice.h \ + qdirectfbpixmap.h \ + qdirectfbkeyboard.h \ + qdirectfbmouse.h -SOURCES = \ - qdirectfbscreen.cpp \ - qdirectfbscreenplugin.cpp \ - qdirectfbsurface.cpp \ - qdirectfbpaintengine.cpp \ - qdirectfbpaintdevice.cpp \ - qdirectfbpixmap.cpp \ - qdirectfbkeyboard.cpp \ - qdirectfbmouse.cpp +SOURCES = qdirectfbscreen.cpp \ + qdirectfbscreenplugin.cpp \ + qdirectfbsurface.cpp \ + qdirectfbpaintengine.cpp \ + qdirectfbpaintdevice.cpp \ + qdirectfbpixmap.cpp \ + qdirectfbkeyboard.cpp \ + qdirectfbmouse.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 83c2039..c4dae2e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -54,6 +54,27 @@ #include #include +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define VOID_ARG() static_cast(false) +enum PaintOperation { + DRAW_RECTS = 0x0001, + DRAW_LINES = 0x0002, + DRAW_IMAGE = 0x0004, + DRAW_PIXMAP = 0x0008, + DRAW_TILED_PIXMAP = 0x0010, + STROKE_PATH = 0x0020, + DRAW_PATH = 0x0040, + DRAW_POINTS = 0x0080, + DRAW_ELLIPSE = 0x0100, + DRAW_POLYGON = 0x0200, + DRAW_TEXT = 0x0400, + FILL_PATH = 0x0800, + FILL_RECT = 0x1000, + DRAW_COLORSPANS = 0x2000, + ALL = 0xffff +}; +#endif + #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } @@ -98,24 +119,31 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * #endif #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Disabled raster engine operation", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ - #one, one, #two, two, #three, three); \ - return; +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Disabled raster engine operation", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; #elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) return; +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; #elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Falling back to raster engine for", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ - #one, one, #two, two, #three, three); +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Falling back to raster engine for", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); #else -#define RASTERFALLBACK(one, two, three) +#define RASTERFALLBACK(op, one, two, three) #endif static inline uint ALPHA_MUL(uint x, uint a) @@ -892,7 +920,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || d->forceRasterPrimitives || !d->isSimpleBrush(brush)) { - RASTERFALLBACK(rectCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; @@ -918,6 +946,7 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || d->forceRasterPrimitives || !d->isSimpleBrush(brush)) { + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; @@ -940,7 +969,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -958,7 +987,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -984,7 +1013,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) #endif { - RASTERFALLBACK(r, image.size(), sr); + RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); d->lock(); QRasterPaintEngine::drawImage(r, image, sr, flags); return; @@ -1008,11 +1037,11 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { - // not using RASTERFALLBACK since this is the way we do bitmaps? + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) { - RASTERFALLBACK(r, pixmap.size(), sr); + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPaintEngine::drawImage(r, *img, sr); @@ -1034,10 +1063,11 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, Q_D(QDirectFBPaintEngine); d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) { - RASTERFALLBACK(r, pixmap.size(), sp); + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); @@ -1053,6 +1083,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { + RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::stroke(path, pen); @@ -1060,7 +1091,7 @@ void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) void QDirectFBPaintEngine::drawPath(const QPainterPath &path) { - RASTERFALLBACK(path.boundingRect(), static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPath(path); @@ -1068,7 +1099,7 @@ void QDirectFBPaintEngine::drawPath(const QPainterPath &path) void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) { - RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1076,7 +1107,7 @@ void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) { - RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1084,7 +1115,7 @@ void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) { - RASTERFALLBACK(rect, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawEllipse(rect); @@ -1093,7 +1124,7 @@ void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) { - RASTERFALLBACK(pointCount, mode, static_cast(false)); + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1102,7 +1133,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) { - RASTERFALLBACK(pointCount, mode, static_cast(false)); + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1111,7 +1142,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, void QDirectFBPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) { - RASTERFALLBACK(p, textItem.text(), static_cast(false)); + RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawTextItem(p, textItem); @@ -1119,7 +1150,7 @@ void QDirectFBPaintEngine::drawTextItem(const QPointF &p, void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) { - RASTERFALLBACK(path, brush, static_cast(false)); + RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::fill(path, brush); @@ -1153,7 +1184,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) break; } } - RASTERFALLBACK(rect, brush, static_cast(false)); + RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, brush); } @@ -1163,7 +1194,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { - RASTERFALLBACK(rect, color, static_cast(false)); + RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { @@ -1180,7 +1211,7 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, { Q_D(QDirectFBPaintEngine); if (d->forceRasterPrimitives) { - RASTERFALLBACK(count, color, static_cast(false)); + RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG()); d->lock(); QRasterPaintEngine::drawColorSpans(spans, count, color); } else { -- cgit v0.12 From 2e9071afbf86ca3143552a3eed75418328b5ce6c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Apr 2009 20:36:29 -0700 Subject: Added an option for ignoring the system clip This is currently the only way I can make QGraphicsView not have to fall back to the raster engine for all operations. It seems the QRegion passed to the paintEvent of QGraphicsView also is set as the systemClip which in the end makes the QRasterPaintEngine's clipRegion equal the systemClip. By exporting QWS_DISPLAY=directfb:ignoresystemclip you can now draw without having a complex clip and therefore take advantage of hw acceleration with DirectFB. Reviewed-By: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 23 ++++++++++++---------- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 9 +++++++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c4dae2e..101c4b7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -337,6 +337,7 @@ private: bool dirtyClip; bool dfbHandledClip; + bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; QDirectFBPaintEngine *q; @@ -350,6 +351,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); + ignoreSystemClip = QDirectFBScreen::instance()->ignoreSystemClip(); surfaceCache = new SurfaceCache; static int cacheLimit = qgetenv("QT_DIRECTFB_IMAGECACHE").toInt(); if (cacheLimit > 0) @@ -774,23 +776,24 @@ void QDirectFBPaintEnginePrivate::updateClip() if (!dirtyClip) return; - if (!clip() || !clip()->enabled) { + const QClipData *clipData = clip(); + if (!clipData || !clipData->enabled) { surface->SetClip(surface, NULL); dfbHandledClip = true; - } - else if (clip()->hasRectClip) { + } else if (clipData->hasRectClip) { const DFBRegion r = { - clip()->clipRect.x(), - clip()->clipRect.y(), - clip()->clipRect.x() + clip()->clipRect.width(), - clip()->clipRect.y() + clip()->clipRect.height() + clipData->clipRect.x(), + clipData->clipRect.y(), + clipData->clipRect.x() + clipData->clipRect.width(), + clipData->clipRect.y() + clipData->clipRect.height() }; surface->SetClip(surface, &r); - dfbHandledClip = true; - } - else + } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) { + dfbHandledClip = true; + } else { dfbHandledClip = false; + } dirtyClip = false; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 3e54e7f..177df1d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -81,6 +81,7 @@ public: QDirectFBKeyboardHandler *keyboard; #endif bool videoonly; + bool ignoreSystemClip; QImage::Format alphaPixmapFormat; }; @@ -97,6 +98,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) , keyboard(0) #endif , videoonly(false) + , ignoreSystemClip(false) , alphaPixmapFormat(QImage::Format_Invalid) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -826,6 +828,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("videoonly"))) d_ptr->videoonly = true; + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) + d_ptr->ignoreSystemClip = true; + #ifndef QT_NO_DIRECTFB_WM if (displayArgs.contains(QLatin1String("fullscreen"))) #endif @@ -1256,3 +1261,7 @@ uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFla return reinterpret_cast(mem); } +bool QDirectFBScreen::ignoreSystemClip() const +{ + return d_ptr->ignoreSystemClip; +} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8dd38dc..08c9ac1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -109,6 +109,7 @@ public: void releaseDFBSurface(IDirectFBSurface* surface); bool preferVideoOnly() const; + bool ignoreSystemClip() const; static int depth(DFBSurfacePixelFormat format); -- cgit v0.12 From 69051b4e49f16ea0d25db99ba42c557095a61a99 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 11:17:25 -0700 Subject: Fold boolean options into flags Instead of having multiple bool QDirectFBScreen::.* getters I added DirectFBFlags QDirectFBScreen::directFBFlags() function. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 23 ++++++++-------------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 14 ++++++++++--- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 101c4b7..9e6f821 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -351,7 +351,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); - ignoreSystemClip = QDirectFBScreen::instance()->ignoreSystemClip(); + ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; surfaceCache = new SurfaceCache; static int cacheLimit = qgetenv("QT_DIRECTFB_IMAGECACHE").toInt(); if (cacheLimit > 0) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 177df1d..4b8af41 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -80,8 +80,7 @@ public: #ifndef QT_NO_DIRECTFB_KEYBOARD QDirectFBKeyboardHandler *keyboard; #endif - bool videoonly; - bool ignoreSystemClip; + QDirectFBScreen::DirectFBFlags directFBFlags; QImage::Format alphaPixmapFormat; }; @@ -97,8 +96,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) #ifndef QT_NO_DIRECTFB_KEYBOARD , keyboard(0) #endif - , videoonly(false) - , ignoreSystemClip(false) + , directFBFlags(QDirectFBScreen::NoFlags) , alphaPixmapFormat(QImage::Format_Invalid) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -227,7 +225,7 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription return 0; } - if (d_ptr->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)) { @@ -347,11 +345,10 @@ void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface) //qDebug("Released surface at %p. New count = %d", surface, d_ptr->allocatedSurfaces.count()); } -bool QDirectFBScreen::preferVideoOnly() const +QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const { - return d_ptr->videoonly; + return d_ptr->directFBFlags; } - IDirectFB* QDirectFBScreen::dfb() { return d_ptr->dfb; @@ -825,11 +822,11 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) printDirectFBInfo(d_ptr->dfb); - if (displayArgs.contains(QLatin1String("videoonly"))) - d_ptr->videoonly = true; + if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive)) + d_ptr->directFBFlags |= VideoOnly; if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) - d_ptr->ignoreSystemClip = true; + d_ptr->directFBFlags |= IgnoreSystemClip; #ifndef QT_NO_DIRECTFB_WM if (displayArgs.contains(QLatin1String("fullscreen"))) @@ -1261,7 +1258,3 @@ uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFla return reinterpret_cast(mem); } -bool QDirectFBScreen::ignoreSystemClip() const -{ - return d_ptr->ignoreSystemClip; -} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 08c9ac1..8e75277 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -59,6 +59,16 @@ public: QDirectFBScreen(int display_id); ~QDirectFBScreen(); + enum DirectFBFlag { + NoFlags = 0x00, + VideoOnly = 0x01, + IgnoreSystemClip = 0x02 + }; + + Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); + + DirectFBFlags directFBFlags() const; + bool connect(const QString &displaySpec); void disconnect(); bool initDevice(); @@ -108,9 +118,6 @@ public: SurfaceCreationOptions options); void releaseDFBSurface(IDirectFBSurface* surface); - bool preferVideoOnly() const; - bool ignoreSystemClip() const; - static int depth(DFBSurfacePixelFormat format); static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format); @@ -139,6 +146,7 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); +Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags); inline bool QDirectFBScreen::isPremultiplied(QImage::Format format) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 8ed308c..257efeb 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -110,7 +110,7 @@ void QDirectFBSurface::createWindow() |DWDESC_PIXELFORMAT); description.surface_caps = DSCAPS_NONE; - if (screen->preferVideoOnly()) + if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY); const QImage::Format format = screen->pixelFormat(); description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); -- cgit v0.12 From d7be4d1cd394c04f85647b6de823a33aa7b2d900 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 15:44:01 -0700 Subject: Fixed cursors with QT_NO_DIRECTFB_PREALLOCATED Refactor cursor management code to do. No need to change the cooperative level four times for each show/hide. Simplify code a little. Also we used to disable the cursor when we wanted to hide it which meant that we no longer received mouse events. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 150 ++++++++++----------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4b8af41..0374e58 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -538,16 +538,12 @@ class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor { public: QDirectFBScreenCursor(); - ~QDirectFBScreenCursor(); - - void set(const QImage &image, int hotx, int hoty); - void move(int x, int y); - void show(); - void hide(); - + virtual void set(const QImage &image, int hotx, int hoty); + virtual void move(int x, int y); + virtual void show(); + virtual void hide(); private: IDirectFBDisplayLayer *layer; - bool implicitHide; }; QDirectFBScreenCursor::QDirectFBScreenCursor() @@ -557,116 +553,120 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() qFatal("QDirectFBScreenCursor: DirectFB not initialized"); layer = QDirectFBScreen::instance()->dfbDisplayLayer(); - - if (layer) - layer->SetCooperativeLevel(layer, DLSCL_SHARED); // XXX: hw: remove? - else - qFatal("QDirectFBScreenCursor: Unable to get primary display layer!"); - - enable = true; - hwaccel = true; - implicitHide = false; - supportsAlpha = true; - - set(QImage(), 0, 0); -} - -QDirectFBScreenCursor::~QDirectFBScreenCursor() -{ -} - -void QDirectFBScreenCursor::show() -{ + Q_ASSERT(layer); DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " "Unable to set cooperative level", result); } result = layer->EnableCursor(layer, 1); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " "Unable to enable cursor", result); } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::show: " - "Unable to reset cooperative level", result); + "Unable to set cooperative level", result); } - implicitHide = false; + + layer->SetCooperativeLevel(layer, DLSCL_SHARED); + + enable = false; + hwaccel = true; + supportsAlpha = true; +} + +void QDirectFBScreenCursor::move(int x, int y) +{ + layer->WarpCursor(layer, x, y); } void QDirectFBScreenCursor::hide() { - DFBResult result; - result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to set cooperative level", result); - } - result = layer->EnableCursor(layer, 0); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to disable cursor", result); - } - result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to reset cooperative level", result); + if (enable) { + QScreenCursor::hide(); + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } + result = layer->SetCursorOpacity(layer, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cursor opacity", result); + } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } } - implicitHide = true; } -void QDirectFBScreenCursor::move(int x, int y) +void QDirectFBScreenCursor::show() { - layer->WarpCursor(layer, x, y); + if (!enable) { + QScreenCursor::show(); + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + result = layer->SetCursorOpacity(layer, 255); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cursor shape", result); + } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + } } void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty) { - if (image.isNull() && isVisible()) { - hide(); - implicitHide = true; - } else if (!image.isNull() && implicitHide) { - show(); - } - cursor = image.convertToFormat(QDirectFBScreen::instance()->alphaPixmapFormat()); + QDirectFBScreen *screen = QDirectFBScreen::instance(); + if (!screen) + return; - if (!image.isNull()) { - Q_ASSERT(cursor.numColors() == 0); + if (image.isNull()) { + cursor = QImage(); + hide(); + } else { + cursor = image.convertToFormat(screen->alphaPixmapFormat()); size = cursor.size(); hotspot = QPoint(hotx, hoty); - - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(cursor); - - IDirectFBSurface *surface; - surface = QDirectFBScreen::instance()->createDFBSurface(&description, - QDirectFBScreen::TrackSurface); + IDirectFBSurface *surface = screen->createDFBSurface(cursor, QDirectFBScreen::DontTrackSurface); if (!surface) { qWarning("QDirectFBScreenCursor::set: Unable to create surface"); return; } DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: " + DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); } result = layer->SetCursorShape(layer, surface, hotx, hoty); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: Unable to set cursor shape", - result); + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cursor shape", result); } - + surface->Release(surface); result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: " - "Unable to reset cooperative level", result); + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); } - - if (surface) - QDirectFBScreen::instance()->releaseDFBSurface(surface); + show(); } + } #endif // QT_NO_DIRECTFB_LAYER -- cgit v0.12 From a2397ff9d22c9e66453601226ddb6fc506ea05c0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 19:15:11 -0700 Subject: Cleaned up mouse/cursor code The enabling/disabling of the Cursor belongs in the QDirectFBMouseHandler class and not in the QDirectFBScreenCursor. Even if we use the Qt software cursor we need the events to come in from the mouse handler. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 41 +++++++++++++++------- src/plugins/gfxdrivers/directfb/qdirectfbmouse.h | 1 - .../gfxdrivers/directfb/qdirectfbscreen.cpp | 19 ---------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index f4d9b46..b999dd2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -56,9 +56,7 @@ public: QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h); ~QDirectFBMouseHandlerPrivate(); - void suspend(); - void resume(); - + void setEnabled(bool on); private: QDirectFBMouseHandler *handler; IDirectFBEventBuffer *eventBuffer; @@ -130,7 +128,7 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); - resume(); + setEnabled(true); } QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate() @@ -139,15 +137,32 @@ QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate() eventBuffer->Release(eventBuffer); } -void QDirectFBMouseHandlerPrivate::suspend() +void QDirectFBMouseHandlerPrivate::setEnabled(bool on) { - mouseNotifier->setEnabled(false); -} + if (mouseNotifier->isEnabled() != on) { +#ifndef QT_NO_DIRECTFB_LAYER + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " + "Unable to set cooperative level", result); + } + result = layer->EnableCursor(layer, on ? 1 : 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " + "Unable to enable cursor", result); + } -void QDirectFBMouseHandlerPrivate::resume() -{ - eventBuffer->Reset(eventBuffer); - mouseNotifier->setEnabled(true); + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + + layer->SetCooperativeLevel(layer, DLSCL_SHARED); +#endif + mouseNotifier->setEnabled(on); + } } void QDirectFBMouseHandlerPrivate::readMouseData() @@ -260,12 +275,12 @@ QDirectFBMouseHandler::~QDirectFBMouseHandler() void QDirectFBMouseHandler::suspend() { - d->suspend(); + d->setEnabled(false); } void QDirectFBMouseHandler::resume() { - d->resume(); + d->setEnabled(true); } #include "qdirectfbmouse.moc" diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index e81a4ba..d2eccfc 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -61,7 +61,6 @@ public: void suspend(); void resume(); - protected: QDirectFBMouseHandlerPrivate *d; }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 0374e58..b01e1be 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -554,25 +554,6 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() layer = QDirectFBScreen::instance()->dfbDisplayLayer(); Q_ASSERT(layer); - DFBResult result; - result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " - "Unable to set cooperative level", result); - } - result = layer->EnableCursor(layer, 1); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " - "Unable to enable cursor", result); - } - - result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " - "Unable to set cooperative level", result); - } - - layer->SetCooperativeLevel(layer, DLSCL_SHARED); enable = false; hwaccel = true; -- cgit v0.12 From 063d9a01fee83a2753063ff5117d8d84cf219aa3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 19:17:19 -0700 Subject: Remove superfluous call to base class Make code more readable by not chaining to QScreenCursor for hide/show. Since hwaccel is true we don't need the exposeRegion call anyway. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index b01e1be..a53b1c0 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -568,7 +568,7 @@ void QDirectFBScreenCursor::move(int x, int y) void QDirectFBScreenCursor::hide() { if (enable) { - QScreenCursor::hide(); + enable = false; DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { @@ -591,7 +591,7 @@ void QDirectFBScreenCursor::hide() void QDirectFBScreenCursor::show() { if (!enable) { - QScreenCursor::show(); + enable = true; DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { -- cgit v0.12 From 341fc0e32f715e9227c3329d8eb24f15fd550723 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 29 Apr 2009 13:07:46 +1000 Subject: Fix compile failure on Visual C++ 6. No need to be excessively clever here. Reviewed-by: Trust Me --- tools/assistant/tools/assistant/centralwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index f953ab7..4390a10 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -394,8 +394,10 @@ void CentralWidget::setLastShownPages() QString::SkipEmptyParts); const int pageCount = lastShownPageList.count(); - if (pageCount == 0 && usesDefaultCollection) - return setSource(QUrl(QLatin1String("help"))); + if (pageCount == 0 && usesDefaultCollection) { + setSource(QUrl(QLatin1String("help"))); + return; + } #if !defined(QT_NO_WEBKIT) const QLatin1String zoom("LastPagesZoomWebView"); -- cgit v0.12 From e378783811b2ace2379becefd1e479ce840f2850 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 29 Apr 2009 13:42:38 +1000 Subject: Fixes performance degradation from precision fix in 4.5.1 Alleviates the performance hit of querying the database except when necessary, try and use XSQLVAR as much as possible, except for floating point fields. Task-number: 252426 --- src/sql/drivers/ibase/qsql_ibase.cpp | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 0705722..9eeb41d 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1270,27 +1270,27 @@ QSqlRecord QIBaseResult::record() const v = d->sqlda->sqlvar[i]; QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(), qIBaseTypeName2(v.sqltype, v.sqlscale < 0)); - QSqlQuery q(new QIBaseResult(d->db)); - q.setForwardOnly(true); - q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG " - "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " - "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " - "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' " - "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' ")); - if(q.first()) { - if(v.sqlscale < 0) { - f.setLength(q.value(0).toInt()); - f.setPrecision(qAbs(q.value(1).toInt())); - } else { - f.setLength(q.value(2).toInt()); - f.setPrecision(0); + f.setLength(v.sqllen); + f.setPrecision(qAbs(v.sqlscale)); + f.setRequiredStatus((v.sqltype & 1) == 0 ? QSqlField::Required : QSqlField::Optional); + if(v.sqlscale < 0) { + QSqlQuery q(new QIBaseResult(d->db)); + q.setForwardOnly(true); + q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG " + "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " + "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " + "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' " + "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' ")); + if(q.first()) { + if(v.sqlscale < 0) { + f.setLength(q.value(0).toInt()); + f.setPrecision(qAbs(q.value(1).toInt())); + } else { + f.setLength(q.value(2).toInt()); + f.setPrecision(0); + } + f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional); } - f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional); - } - else { - f.setLength(0); - f.setPrecision(0); - f.setRequiredStatus(QSqlField::Unknown); } f.setSqlType(v.sqltype); rec.append(f); -- cgit v0.12 From 822114e976d7c6644f060ac366c08c92da1a4779 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 29 Apr 2009 14:26:29 +1000 Subject: Try and clean up ODBC 64/32 bit type disparity It seems that after approx version 2.7.0, microsoft changed the ODBC types of certain functions, to cater for 64bit architectures. This tries to be a little bit smarter about which types are used in which places. --- src/sql/drivers/odbc/qsql_odbc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 2a83fe6..4e90777 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -70,18 +70,16 @@ QT_BEGIN_NAMESPACE #endif // newer platform SDKs use SQLLEN instead of SQLINTEGER -#if defined(SQLLEN) || defined(Q_OS_WIN64) +//#if defined(SQLLEN) || defined(Q_OS_WIN64) +#if ODBCVER >= 0x0270 # define QSQLLEN SQLLEN -#else -# define QSQLLEN SQLINTEGER -#endif - -#if defined(SQLULEN) || defined(Q_OS_WIN64) # define QSQLULEN SQLULEN #else +# define QSQLLEN SQLINTEGER # define QSQLULEN SQLUINTEGER #endif + static const int COLNAMESIZE = 256; //Map Qt parameter types to ODBC types static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; -- cgit v0.12