diff options
Diffstat (limited to 'src/gui')
26 files changed, 241 insertions, 138 deletions
diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index 1fd1bfd..f404535 100644 --- a/src/gui/accessible/qaccessible_win.cpp +++ b/src/gui/accessible/qaccessible_win.cpp @@ -353,8 +353,8 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason) static PtrNotifyWinEvent ptrNotifyWinEvent = 0; static bool resolvedNWE = false; if (!resolvedNWE) { - resolvedNWE = true; ptrNotifyWinEvent = (PtrNotifyWinEvent)QSystemLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent"); + resolvedNWE = true; } if (!ptrNotifyWinEvent) return; @@ -691,14 +691,7 @@ private: static inline BSTR QStringToBSTR(const QString &str) { - BSTR bstrVal; - - int wlen = str.length()+1; - bstrVal = SysAllocStringByteLen(0, wlen*2); - memcpy(bstrVal, str.unicode(), sizeof(QChar)*(wlen)); - bstrVal[wlen] = 0; - - return bstrVal; + return SysAllocStringLen((OLECHAR*)str.unicode(), str.length()); } /* diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 6691ff1..2d4769a 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -55,10 +55,6 @@ #include <private/qsystemlibrary_p.h> #include "qfiledialog_win_p.h" -#ifndef QT_NO_THREAD -# include <private/qmutexpool_p.h> -#endif - #ifdef Q_WS_WINCE #include <commdlg.h> bool qt_priv_ptr_valid = false; @@ -83,35 +79,23 @@ QT_BEGIN_NAMESPACE static void qt_win_resolve_libs() { static bool triedResolve = false; - if (!triedResolve) { -#ifndef QT_NO_THREAD - // protect initialization - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - // check triedResolve again, since another thread may have already - // done the initialization - if (triedResolve) { - // another thread did initialize the security function pointers, - // so we shouldn't do it again. - return; - } -#endif - - triedResolve = true; #if !defined(Q_WS_WINCE) - QSystemLibrary lib(L"shell32"); + QSystemLibrary lib(QLatin1String("shell32")); ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW"); ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDListW"); ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc"); #else // CE stores them in a different lib and does not use unicode version - HINSTANCE handle = LoadLibrary(L"Ceshell"); - ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder"); - ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList"); - ptrSHGetMalloc = (PtrSHGetMalloc)GetProcAddress(handle, L"SHGetMalloc"); + QSystemLibrary lib(QLatin1String("Ceshell")); + ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolder"); + ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDList"); + ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc"); if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList && ptrSHGetMalloc) qt_priv_ptr_valid = true; #endif + + triedResolve = true; } } diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index 9ea114c..00ebbfd 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -705,7 +705,6 @@ bool QVistaHelper::resolveSymbols() { static bool tried = false; if (!tried) { - tried = true; QSystemLibrary dwmLib(L"dwmapi"); pDwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); @@ -727,6 +726,7 @@ bool QVistaHelper::resolveSymbols() pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx"); pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute"); } + tried = true; } return ( diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index cb7349c..73e8eed 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2237,7 +2237,8 @@ bool QGraphicsItem::isVisible() const returned. \a parent can be 0, in which case this function will return whether the item is visible to the scene or not. - An item may not be visible to its ancestors even if isVisible() is true. If + An item may not be visible to its ancestors even if isVisible() is true. It + may also be visible to its ancestors even if isVisible() is false. If any ancestor is hidden, the item itself will be implicitly hidden, in which case this function will return false. @@ -2245,15 +2246,16 @@ bool QGraphicsItem::isVisible() const */ bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const { - if (!d_ptr->visible) + const QGraphicsItem *p = this; + if (d_ptr->explicitlyHidden) return false; - if (parent == this) - return true; - if (parentItem() && parentItem()->isVisibleTo(parent)) - return true; - if (!parent && !parentItem()) - return true; - return false; + do { + if (p == parent) + return true; + if (p->d_ptr->explicitlyHidden) + return false; + } while ((p = p->d_ptr->parent)); + return parent == 0; } /*! diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 47b6eef..aa1571b 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -752,7 +752,8 @@ static PtrglReadPixels ptrglReadPixels = 0; static bool resolveOpenGLSymbols() { - if (ptrCGLChoosePixelFormat == 0) { + static bool triedResolve = false; + if (!triedResolve) { QLibrary library(QLatin1String("/System/Library/Frameworks/OpenGL.framework/OpenGL")); ptrCGLChoosePixelFormat = (PtrCGLChoosePixelFormat)(library.resolve("CGLChoosePixelFormat")); ptrCGLClearDrawable = (PtrCGLClearDrawable)(library.resolve("CGLClearDrawable")); @@ -765,6 +766,7 @@ static bool resolveOpenGLSymbols() ptrglPixelStorei = (PtrglPixelStorei)(library.resolve("glPixelStorei")); ptrglReadBuffer = (PtrglReadBuffer)(library.resolve("glReadBuffer")); ptrglReadPixels = (PtrglReadPixels)(library.resolve("glReadPixels")); + triedResolve = true; } return ptrCGLChoosePixelFormat && ptrCGLClearDrawable && ptrCGLCreateContext && ptrCGLDestroyContext && ptrCGLDestroyPixelFormat && ptrCGLSetCurrentContext diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index ad51b4b..90d47f9 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -205,6 +205,7 @@ private: QBasicTimer m_tempPreeditStringTimeout; bool m_hasTempPreeditString; QString m_cachedPreeditString; + int m_cachedCursorAndAnchorPosition; int m_splitViewResizeBy; Qt::WindowStates m_splitViewPreviousWindowStates; diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 8f13c53..ed7411f 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -380,6 +380,7 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_formatRetriever(0), m_pointerHandler(0), m_hasTempPreeditString(false), + m_cachedCursorAndAnchorPosition(-1), m_splitViewResizeBy(0), m_splitViewPreviousWindowStates(Qt::WindowNoState), m_splitViewPreviousFocusItem(0), @@ -448,9 +449,18 @@ void QCoeFepInputContext::reset() } // Store a copy of preedit text, if prediction is active and input context is reseted. // This is to ensure that we can replace preedit string after losing focus to FEP manager's - // internal sub-windows. - if (m_cachedPreeditString.isEmpty() && !(currentHints & Qt::ImhNoPredictiveText)) + // internal sub-windows. Additionally, store the cursor position if there is no selected text. + // This allows input context to replace preedit strings if they are not at the end of current + // text. + if (m_cachedPreeditString.isEmpty() && !(currentHints & Qt::ImhNoPredictiveText)) { m_cachedPreeditString = m_preeditString; + if (focusWidget() && !m_cachedPreeditString.isEmpty()) { + int cursor = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = focusWidget()->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + if (cursor == anchor) + m_cachedCursorAndAnchorPosition = cursor; + } + } commitCurrentString(true); // QGraphicsScene calls reset() when changing focus item. Unfortunately, the new focus item is @@ -491,6 +501,7 @@ void QCoeFepInputContext::setFocusWidget(QWidget *w) void QCoeFepInputContext::widgetDestroyed(QWidget *w) { m_cachedPreeditString.clear(); + m_cachedCursorAndAnchorPosition = -1; // Make sure that the input capabilities of whatever new widget got focused are queried. CCoeControl *ctrl = w->effectiveWinId(); @@ -1350,6 +1361,7 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText, return; m_cachedPreeditString.clear(); + m_cachedCursorAndAnchorPosition = -1; commitTemporaryPreeditString(); @@ -1408,8 +1420,16 @@ void QCoeFepInputContext::UpdateFepInlineTextL(const TDesC& aNewInlineText, QString newPreeditString = qt_TDesC2QString(aNewInlineText); QInputMethodEvent event(newPreeditString, attributes); if (!m_cachedPreeditString.isEmpty()) { - event.setCommitString(QLatin1String(""), -m_cachedPreeditString.length(), m_cachedPreeditString.length()); + int cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + // Predicted word is either replaced from the end of the word (normal case), + // or from stored location, if the predicted word is either in the beginning of, + // or in the middle of already committed word. + int diff = cursorPos - m_cachedCursorAndAnchorPosition; + int replaceLocation = (diff != m_cachedPreeditString.length()) ? diff : m_cachedPreeditString.length(); + + event.setCommitString(QLatin1String(""), -replaceLocation, m_cachedPreeditString.length()); m_cachedPreeditString.clear(); + m_cachedCursorAndAnchorPosition = -1; } else if (newPreeditString.isEmpty() && m_preeditString.isEmpty()) { // In Symbian world this means "erase last character". event.setCommitString(QLatin1String(""), -1, 1); @@ -1507,6 +1527,10 @@ void QCoeFepInputContext::SetCursorSelectionForFepL(const TCursorSelection& aCur int pos = aCursorSelection.iAnchorPos; int length = aCursorSelection.iCursorPos - pos; + if (m_cachedCursorAndAnchorPosition != -1) { + pos = m_cachedCursorAndAnchorPosition; + length = 0; + } QList<QInputMethodEvent::Attribute> attributes; attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos, length, QVariant()); @@ -1524,6 +1548,13 @@ void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSele int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size(); int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size(); + + // If the position is stored, use that value, so that word replacement from proposed word + // lists are added to the correct position. + if (m_cachedCursorAndAnchorPosition != -1) { + cursor = m_cachedCursorAndAnchorPosition; + anchor = m_cachedCursorAndAnchorPosition; + } QString text = w->inputMethodQuery(Qt::ImSurroundingText).value<QString>(); int combinedSize = text.size() + m_preeditString.size(); if (combinedSize < anchor || combinedSize < cursor) { diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index ded4d63..1676c46 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -4238,6 +4238,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, for (int j = 0; j < paintPairs.count(); ++j) { option.rect = paintPairs.at(j).first.translated(-r->topLeft()); const QModelIndex ¤t = paintPairs.at(j).second; + adjustViewOptionsForIndex(&option, current); delegateForIndex(current)->paint(&painter, option, current); } return pixmap; diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 04babde..b742529 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -193,6 +193,8 @@ public: #endif virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; + // reimplemented in subclasses + virtual void adjustViewOptionsForIndex(QStyleOptionViewItemV4*, const QModelIndex&) const {} inline void releaseEditor(QWidget *editor) const { if (editor) { diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index a0955d2..01a9eec 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1475,7 +1475,7 @@ void QListView::doItemsLayout() void QListView::updateGeometries() { Q_D(QListView); - if (d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) { + if (geometry().isEmpty() || d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) { horizontalScrollBar()->setRange(0, 0); verticalScrollBar()->setRange(0, 0); } else { @@ -1490,15 +1490,15 @@ void QListView::updateGeometries() // if the scroll bars are turned off, we resize the contents to the viewport if (d->movement == Static && !d->isWrapping()) { - const QSize maxSize = maximumViewportSize(); + d->layoutChildren(); // we need the viewport size to be updated if (d->flow == TopToBottom) { if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { - d->setContentsSize(maxSize.width(), contentsSize().height()); + d->setContentsSize(viewport()->width(), contentsSize().height()); horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway } } else { // LeftToRight if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { - d->setContentsSize(contentsSize().width(), maxSize.height()); + d->setContentsSize(contentsSize().width(), viewport()->height()); verticalScrollBar()->setRange(0, 0); // we see all the contents anyway } } diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 6f532eb..356f187 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -3205,7 +3205,7 @@ void QTableView::selectionChanged(const QItemSelection &selected, QModelIndex desel = deselected.indexes().value(0); if (desel.isValid()) { #ifdef Q_WS_X11 - int entry = d->accessibleTable2Index(sel); + int entry = d->accessibleTable2Index(desel); QAccessible::updateAccessibility(this, entry, QAccessible::SelectionRemove); #else int entry = visualIndex(sel); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 9228ac8..868cd92 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1378,6 +1378,23 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList return ret; } +void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const +{ + const int row = current.row(); + option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None) + | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None) + | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); + + option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows) + || option->showDecorationSelected; + + QVector<int> logicalIndices; + QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex + calcLogicalIndices(&logicalIndices, &viewItemPosList); + int logicalIndex = header->logicalIndex(current.column()); + option->viewItemPosition = viewItemPosList.at(logicalIndex); +} + /*! \since 4.2 @@ -1463,6 +1480,59 @@ static inline bool ancestorOf(QObject *widget, QObject *other) return false; } +void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const +{ + const int left = (spanning ? header->visualIndex(0) : leftAndRight.first); + const int right = (spanning ? header->visualIndex(0) : leftAndRight.second); + const int columnCount = header->count(); + /* 'left' and 'right' are the left-most and right-most visible visual indices. + Compute the first visible logical indices before and after the left and right. + We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */ + int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; + for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) { + int logicalIndex = header->logicalIndex(visualIndex); + if (!header->isSectionHidden(logicalIndex)) { + logicalIndexBeforeLeft = logicalIndex; + break; + } + } + + for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) { + int logicalIndex = header->logicalIndex(visualIndex); + if (!header->isSectionHidden(logicalIndex)) { + if (visualIndex > right) { + logicalIndexAfterRight = logicalIndex; + break; + } + logicalIndices->append(logicalIndex); + } + } + + itemPositions->resize(logicalIndices->count()); + for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) { + const int headerSection = logicalIndices->at(currentLogicalSection); + // determine the viewItemPosition depending on the position of column 0 + int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count() + ? logicalIndexAfterRight + : logicalIndices->at(currentLogicalSection + 1); + int prevLogicalSection = currentLogicalSection - 1 < 0 + ? logicalIndexBeforeLeft + : logicalIndices->at(currentLogicalSection - 1); + QStyleOptionViewItemV4::ViewItemPosition pos; + if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1) + || (headerSection == 0 && nextLogicalSection == -1) || spanning) + pos = QStyleOptionViewItemV4::OnlyOne; + else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1)) + pos = QStyleOptionViewItemV4::Beginning; + else if (nextLogicalSection == 0 || nextLogicalSection == -1) + pos = QStyleOptionViewItemV4::End; + else + pos = QStyleOptionViewItemV4::Middle; + (*itemPositions)[currentLogicalSection] = pos; + } +} + + /*! Draws the row in the tree view that contains the model item \a index, using the \a painter given. The \a option control how the item is @@ -1531,33 +1601,13 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, int width, height = option.rect.height(); int position; QModelIndex modelIndex; - int columnCount = header->count(); const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows && index.parent() == hover.parent() && index.row() == hover.row(); - /* 'left' and 'right' are the left-most and right-most visible visual indices. - Compute the first visible logical indices before and after the left and right. - We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */ - int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; - for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) { - int logicalIndex = header->logicalIndex(visualIndex); - if (!header->isSectionHidden(logicalIndex)) { - logicalIndexBeforeLeft = logicalIndex; - break; - } - } - QVector<int> logicalIndices; // vector of currently visibly logical indices - for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) { - int logicalIndex = header->logicalIndex(visualIndex); - if (!header->isSectionHidden(logicalIndex)) { - if (visualIndex > right) { - logicalIndexAfterRight = logicalIndex; - break; - } - logicalIndices.append(logicalIndex); - } - } + QVector<int> logicalIndices; + QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex + d->calcLogicalIndices(&logicalIndices, &viewItemPosList); for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) { int headerSection = logicalIndices.at(currentLogicalSection); @@ -1579,22 +1629,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, continue; opt.state = state; - // determine the viewItemPosition depending on the position of column 0 - int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices.count() - ? logicalIndexAfterRight - : logicalIndices.at(currentLogicalSection + 1); - int prevLogicalSection = currentLogicalSection - 1 < 0 - ? logicalIndexBeforeLeft - : logicalIndices.at(currentLogicalSection - 1); - if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1) - || (headerSection == 0 && nextLogicalSection == -1) || spanning) - opt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1)) - opt.viewItemPosition = QStyleOptionViewItemV4::Beginning; - else if (nextLogicalSection == 0 || nextLogicalSection == -1) - opt.viewItemPosition = QStyleOptionViewItemV4::End; - else - opt.viewItemPosition = QStyleOptionViewItemV4::Middle; + opt.viewItemPosition = viewItemPosList.at(currentLogicalSection); // fake activeness when row editor has focus if (indexWidgetHasFocus) diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index a9dc452..ef8f11c 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -97,6 +97,7 @@ public: void initialize(); QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; + void adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const; #ifndef QT_NO_ANIMATION struct AnimatedOperation : public QVariantAnimation @@ -167,6 +168,10 @@ public: void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const; + // logicalIndices: vector of currently visibly logical indices + // itemPositions: vector of view item positions (beginning/middle/end/onlyone) + void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const; + QHeaderView *header; int indent; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 35a9559..3605472 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -3426,7 +3426,35 @@ QString QApplication::sessionKey() const } #endif +/*! + \since 4.7.4 + \fn void QApplication::aboutToReleaseGpuResources() + + This signal is emitted when application is about to release all + GPU resources associated to contexts owned by application. + + The signal is particularly useful if your application has allocated + GPU resources directly apart from Qt and needs to do some last-second + cleanup. + + \warning This signal is only emitted on Symbian. + + \sa aboutToUseGpuResources() +*/ +/*! + \since 4.7.4 + \fn void QApplication::aboutToUseGpuResources() + + This signal is emitted when application is about to use GPU resources. + + The signal is particularly useful if your application needs to know + when GPU resources are be available. + + \warning This signal is only emitted on Symbian. + + \sa aboutToFreeGpuResources() +*/ /*! \since 4.2 diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 1548849..3334056 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -305,6 +305,10 @@ Q_SIGNALS: void commitDataRequest(QSessionManager &sessionManager); void saveStateRequest(QSessionManager &sessionManager); #endif +#ifdef Q_OS_SYMBIAN + void aboutToReleaseGpuResources(); + void aboutToUseGpuResources(); +#endif public: QString styleSheet() const; diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 0756d6c..c4cb19c 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -564,6 +564,9 @@ public: void symbianHandleLiteModeStartup(); void _q_aboutToQuit(); + + void emitAboutToReleaseGpuResources(); + void emitAboutToUseGpuResources(); #endif #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) void sendSyntheticEnterLeave(QWidget *widget); diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 9acf429..46b16cb 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -239,6 +239,9 @@ void QS60Data::controlVisibilityChanged(CCoeControl *control, bool visible) if (QTLWExtra *topData = qt_widget_private(window)->maybeTopData()) { QWidgetBackingStoreTracker &backingStore = topData->backingStore; if (visible) { + QApplicationPrivate *d = QApplicationPrivate::instance(); + d->emitAboutToUseGpuResources(); + if (backingStore.data()) { backingStore.registerWidget(widget); } else { @@ -248,6 +251,9 @@ void QS60Data::controlVisibilityChanged(CCoeControl *control, bool visible) widget->repaint(); } } else { + QApplicationPrivate *d = QApplicationPrivate::instance(); + d->emitAboutToReleaseGpuResources(); + // In certain special scenarios we may get an ENotVisible event // without a previous EPartiallyVisible. The backingstore must // still be destroyed, hence the registerWidget() call below. @@ -2875,6 +2881,24 @@ void QApplicationPrivate::_q_aboutToQuit() #endif } +void QApplicationPrivate::emitAboutToReleaseGpuResources() +{ +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES + Q_Q(QApplication); + QPointer<QApplication> guard(q); + emit q->aboutToReleaseGpuResources(); +#endif +} + +void QApplicationPrivate::emitAboutToUseGpuResources() +{ +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES + Q_Q(QApplication); + QPointer<QApplication> guard(q); + emit q->aboutToUseGpuResources(); +#endif +} + QS60ThreadLocalData::QS60ThreadLocalData() { CCoeEnv *env = CCoeEnv::Static(); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index c472738..19e7ba5 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -218,9 +218,9 @@ static bool aygResolved = false; static void resolveAygLibs() { if (!aygResolved) { - aygResolved = true; QSystemLibrary ayglib(QLatin1String("aygshell")); ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture"); + aygResolved = true; } } #endif // QT_NO_GESTURES @@ -854,19 +854,15 @@ void qt_init(QApplicationPrivate *priv, int) qt_win_initialize_directdraw(); #ifndef Q_OS_WINCE - ptrUpdateLayeredWindowIndirect = - (PtrUpdateLayeredWindowIndirect) QSystemLibrary::resolve(QLatin1String("user32"), - "UpdateLayeredWindowIndirect"); - ptrUpdateLayeredWindow = - (PtrUpdateLayeredWindow) QSystemLibrary::resolve(QLatin1String("user32"), - "UpdateLayeredWindow"); + QSystemLibrary user32(QLatin1String("user32")); + ptrUpdateLayeredWindowIndirect = (PtrUpdateLayeredWindowIndirect)user32.resolve("UpdateLayeredWindowIndirect"); + ptrUpdateLayeredWindow = (PtrUpdateLayeredWindow)user32.resolve("UpdateLayeredWindow"); if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect) ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect; // Notify Vista and Windows 7 that we support highter DPI settings - ptrSetProcessDPIAware = (PtrSetProcessDPIAware) - QSystemLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware"); + ptrSetProcessDPIAware = (PtrSetProcessDPIAware)user32.resolve("SetProcessDPIAware"); if (ptrSetProcessDPIAware) ptrSetProcessDPIAware(); #endif @@ -886,29 +882,16 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments; #elif !defined(Q_WS_WINCE) #if !defined(QT_NO_NATIVE_GESTURES) - priv->GetGestureInfo = - (PtrGetGestureInfo)QSystemLibrary::resolve(QLatin1String("user32"), - "GetGestureInfo"); - priv->GetGestureExtraArgs = - (PtrGetGestureExtraArgs)QSystemLibrary::resolve(QLatin1String("user32"), - "GetGestureExtraArgs"); - priv->CloseGestureInfoHandle = - (PtrCloseGestureInfoHandle)QSystemLibrary::resolve(QLatin1String("user32"), - "CloseGestureInfoHandle"); - priv->SetGestureConfig = - (PtrSetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"), - "SetGestureConfig"); - priv->GetGestureConfig = - (PtrGetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"), - "GetGestureConfig"); + priv->GetGestureInfo = (PtrGetGestureInfo)user32.resolve("GetGestureInfo"); + priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs)user32.resolve("GetGestureExtraArgs"); + priv->CloseGestureInfoHandle = (PtrCloseGestureInfoHandle)user32.resolve("CloseGestureInfoHandle"); + priv->SetGestureConfig = (PtrSetGestureConfig)user32.resolve("SetGestureConfig"); + priv->GetGestureConfig = (PtrGetGestureConfig)user32.resolve("GetGestureConfig"); #endif // QT_NO_NATIVE_GESTURES QSystemLibrary libTheme(QLatin1String("uxtheme")); - priv->BeginPanningFeedback = - (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback"); - priv->UpdatePanningFeedback = - (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback"); - priv->EndPanningFeedback = - (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback"); + priv->BeginPanningFeedback = (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback"); + priv->UpdatePanningFeedback = (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback"); + priv->EndPanningFeedback = (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback"); #endif #endif // QT_NO_GESTURES } @@ -2388,15 +2371,14 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa break; } +#if !defined(Q_OS_WINCE) typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN); static PtrLresultFromObject ptrLresultFromObject = 0; static bool oleaccChecked = false; - if (!oleaccChecked) { + QSystemLibrary oleacclib(QLatin1String("oleacc")); + ptrLresultFromObject = (PtrLresultFromObject)oleacclib.resolve("LresultFromObject"); oleaccChecked = true; -#if !defined(Q_OS_WINCE) - ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject"); -#endif } if (ptrLresultFromObject) { QAccessibleInterface *acc = QAccessible::queryAccessibleInterface(widget); @@ -2413,6 +2395,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa if (res > 0) RETURN(res); } +#endif } result = false; break; @@ -3198,8 +3181,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg) if (curWin != 0) { if (!trackMouseEventLookup) { - trackMouseEventLookup = true; ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent"); + trackMouseEventLookup = true; } if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) { // We always have to set the tracking, since diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index 78dc469..ae2ca04 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -125,17 +125,16 @@ static AygInitDialog ptrAygInitDialog = 0; static AygFullScreen ptrAygFullScreen = 0; static AygSHSipInfo ptrAygSHSipInfo = 0; static AygSHDoneButton ptrAygSHDoneButton = 0; -static bool aygResolved = false; - static void resolveAygLibs() { + static bool aygResolved = false; if (!aygResolved) { - aygResolved = true; QLibrary ayglib(QLatin1String("aygshell")); ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog"); ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen"); ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo"); ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton"); + aygResolved = true; } } diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index 8b47d8e..e92bd49 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -520,13 +520,15 @@ static PtrGraphicsExportDoExport ptrGraphicsExportDoExport = 0; static bool resolveMimeQuickTimeSymbols() { - if (ptrGraphicsImportSetDataHandle == 0) { + static bool triedResolve = false; + if (!triedResolve) { QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime")); ptrGraphicsImportSetDataHandle = reinterpret_cast<PtrGraphicsImportSetDataHandle>(library.resolve("GraphicsImportSetDataHandle")); ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage")); ptrGraphicsExportSetInputCGImage = reinterpret_cast<PtrGraphicsExportSetInputCGImage>(library.resolve("GraphicsExportSetInputCGImage")); ptrGraphicsExportSetOutputHandle = reinterpret_cast<PtrGraphicsExportSetOutputHandle>(library.resolve("GraphicsExportSetOutputHandle")); ptrGraphicsExportDoExport = reinterpret_cast<PtrGraphicsExportDoExport>(library.resolve("GraphicsExportDoExport")); + triedResolve = true; } return ptrGraphicsImportSetDataHandle != 0 diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 342c4c6..2244c11 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -221,7 +221,8 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) d->bars << bar; if (d->bars.size() == 1) { Q_ASSERT(d->animationFps> 0); - d->animateTimer = startTimer(1000 / d->animationFps); + if (d->animateTimer == 0) + d->animateTimer = startTimer(1000 / d->animationFps); } } } diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 997d429..5525468 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -2586,7 +2586,6 @@ bool QWindowsVistaStylePrivate::resolveSymbols() { static bool tried = false; if (!tried) { - tried = true; QSystemLibrary themeLib(QLatin1String("uxtheme")); pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme"); pIsThemePartDefined = (PtrIsThemePartDefined )themeLib.resolve("IsThemePartDefined"); @@ -2611,6 +2610,7 @@ bool QWindowsVistaStylePrivate::resolveSymbols() pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString"); pGetThemeTransitionDuration = (PtrGetThemeTransitionDuration)themeLib.resolve("GetThemeTransitionDuration"); pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin"); + tried = true; } return pGetThemeTransitionDuration != 0; } diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 343f262..9934545 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -343,7 +343,6 @@ bool QWindowsXPStylePrivate::resolveSymbols() { static bool tried = false; if (!tried) { - tried = true; QSystemLibrary themeLib(QLatin1String("uxtheme")); pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed"); if (pIsAppThemed) { @@ -372,6 +371,7 @@ bool QWindowsXPStylePrivate::resolveSymbols() pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty"); pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent"); } + tried = true; } return pIsAppThemed != 0; diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index fc11387..bb5e041 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -138,8 +138,11 @@ static void resolveGetCharWidthI() { if (resolvedGetCharWidthI) return; + + QSystemLibrary gdi32(QLatin1String("gdi32")); + ptrGetCharWidthI = (PtrGetCharWidthI)gdi32.resolve("GetCharWidthI"); + resolvedGetCharWidthI = true; - ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI"); } #endif // !defined(Q_WS_WINCE) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index aeeef85..5babbc2 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -408,7 +408,6 @@ void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QText setContent(format, text, document); doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable); - q->setCursorWidth(-1); } void QTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document) @@ -2236,7 +2235,10 @@ int QTextControl::cursorWidth() const { #ifndef QT_NO_PROPERTIES Q_D(const QTextControl); - return d->doc->documentLayout()->property("cursorWidth").toInt(); + int width = d->doc->documentLayout()->property("cursorWidth").toInt(); + if (width == -1) + width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth); + return width; #else return 1; #endif @@ -2248,8 +2250,6 @@ void QTextControl::setCursorWidth(int width) #ifdef QT_NO_PROPERTIES Q_UNUSED(width); #else - if (width == -1) - width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth); d->doc->documentLayout()->setProperty("cursorWidth", width); #endif d->repaintCursor(); diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index b0c6c1b..d45daf8 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -111,10 +111,10 @@ static AygEnableSoftKey ptrEnableSoftKey = 0; static void resolveAygLibs() { if (!aygResolved) { - aygResolved = true; QLibrary aygLib(QLatin1String("aygshell")); ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar"); ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey"); + aygResolved = true; } } |