From 4a8a851315ba10824ac107084ccff9de649418ea Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 10 Jun 2009 15:31:43 +0200 Subject: removed superflous indirection (ie. using q->..) instead of using the private class member. --- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicsview.cpp | 63 +++++++++++++++------------------ src/gui/itemviews/qabstractitemview.cpp | 12 +++---- src/gui/itemviews/qcolumnview.cpp | 38 ++++++++++---------- src/gui/itemviews/qheaderview.cpp | 7 ++-- src/gui/itemviews/qlistview.cpp | 10 +++--- src/gui/itemviews/qtreeview.cpp | 45 +++++++++++------------ src/gui/kernel/qwidget.cpp | 4 +-- src/gui/text/qtextcontrol.cpp | 2 +- src/gui/widgets/qabstractbutton.cpp | 20 +++++------ src/gui/widgets/qmdiarea.cpp | 32 ++++++++--------- src/gui/widgets/qmdisubwindow.cpp | 24 ++++++------- src/gui/widgets/qmdisubwindow_p.h | 2 +- 13 files changed, 123 insertions(+), 138 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index c502655..5626867 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -365,7 +365,7 @@ public: QGraphicsScene *scene; QGraphicsItem *parent; QList children; - class TransformData; + struct TransformData; TransformData *transformData; QTransform sceneTransform; int index; diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 4891e81..4a8099c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -387,7 +387,7 @@ void QGraphicsViewPrivate::recalculateContentSize() int left = q_round_bound(viewRect.left()); int right = q_round_bound(viewRect.right() - width); if (left >= right) { - q->horizontalScrollBar()->setRange(0, 0); + hbar->setRange(0, 0); switch (alignment & Qt::AlignHorizontal_Mask) { case Qt::AlignLeft: @@ -402,9 +402,9 @@ void QGraphicsViewPrivate::recalculateContentSize() break; } } else { - q->horizontalScrollBar()->setRange(left, right); - q->horizontalScrollBar()->setPageStep(width); - q->horizontalScrollBar()->setSingleStep(width / 20); + hbar->setRange(left, right); + hbar->setPageStep(width); + hbar->setSingleStep(width / 20); leftIndent = 0; } @@ -413,7 +413,7 @@ void QGraphicsViewPrivate::recalculateContentSize() int top = q_round_bound(viewRect.top()); int bottom = q_round_bound(viewRect.bottom() - height); if (top >= bottom) { - q->verticalScrollBar()->setRange(0, 0); + vbar->setRange(0, 0); switch (alignment & Qt::AlignVertical_Mask) { case Qt::AlignTop: @@ -428,9 +428,9 @@ void QGraphicsViewPrivate::recalculateContentSize() break; } } else { - q->verticalScrollBar()->setRange(top, bottom); - q->verticalScrollBar()->setPageStep(height); - q->verticalScrollBar()->setSingleStep(height / 20); + vbar->setRange(top, bottom); + vbar->setPageStep(height); + vbar->setSingleStep(height / 20); topIndent = 0; } @@ -442,7 +442,7 @@ void QGraphicsViewPrivate::recalculateContentSize() // scroll instead. if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) { dirtyScroll = true; - q->viewport()->update(); + viewport->update(); } else if (q->isRightToLeft() && !leftIndent) { // In reverse mode, the horizontal scroll always changes after the content // size has changed, as the scroll is calculated by summing the min and @@ -468,7 +468,7 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) if (q->underMouse()) { // Last scene pos: lastMouseMoveScenePoint // Current mouse pos: - QPointF transformationDiff = q->mapToScene(q->viewport()->rect().center()) + QPointF transformationDiff = q->mapToScene(viewport->rect().center()) - q->mapToScene(q->mapFromGlobal(QCursor::pos())); q->centerOn(lastMouseMoveScenePoint + transformationDiff);; } else { @@ -490,7 +490,7 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) void QGraphicsViewPrivate::updateLastCenterPoint() { Q_Q(QGraphicsView); - lastCenterPoint = q->mapToScene(q->viewport()->rect().center()); + lastCenterPoint = q->mapToScene(viewport->rect().center()); } /*! @@ -528,15 +528,15 @@ void QGraphicsViewPrivate::updateScroll() scrollX = qint64(-leftIndent); if (q->isRightToLeft()) { if (!leftIndent) { - scrollX += q->horizontalScrollBar()->minimum(); - scrollX += q->horizontalScrollBar()->maximum(); - scrollX -= q->horizontalScrollBar()->value(); + scrollX += hbar->minimum(); + scrollX += hbar->maximum(); + scrollX -= hbar->value(); } } else { - scrollX += q->horizontalScrollBar()->value(); + scrollX += hbar->value(); } - scrollY = qint64(q->verticalScrollBar()->value() - topIndent); + scrollY = qint64(vbar->value() - topIndent); dirtyScroll = false; } @@ -576,7 +576,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) return; QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); - mouseEvent.setWidget(q->viewport()); + mouseEvent.setWidget(viewport); mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint); mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint); mouseEvent.setScenePos(q->mapToScene(event->pos())); @@ -623,7 +623,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) if (hasStoredOriginalCursor) { // Restore the original viewport cursor. hasStoredOriginalCursor = false; - q->viewport()->setCursor(originalCursor); + viewport->setCursor(originalCursor); } #endif } @@ -655,8 +655,6 @@ QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRec #ifndef QT_NO_CURSOR void QGraphicsViewPrivate::_q_setViewportCursor(const QCursor &cursor) { - Q_Q(QGraphicsView); - QWidget *viewport = q->viewport(); if (!hasStoredOriginalCursor) { hasStoredOriginalCursor = true; originalCursor = viewport->cursor(); @@ -682,9 +680,9 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor() // Restore the original viewport cursor. hasStoredOriginalCursor = false; if (dragMode == QGraphicsView::ScrollHandDrag) - q->viewport()->setCursor(Qt::OpenHandCursor); + viewport->setCursor(Qt::OpenHandCursor); else - q->viewport()->setCursor(originalCursor); + viewport->setCursor(originalCursor); } #endif @@ -723,7 +721,7 @@ void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEven dest->setProposedAction(source->proposedAction()); dest->setDropAction(source->dropAction()); dest->setMimeData(source->mimeData()); - dest->setWidget(q->viewport()); + dest->setWidget(viewport); dest->setSource(source->source()); #else Q_UNUSED(dest) @@ -827,8 +825,7 @@ void QGraphicsViewPrivate::processPendingUpdates() void QGraphicsViewPrivate::updateAll() { - Q_Q(QGraphicsView); - q->viewport()->update(); + viewport->update(); fullUpdatePending = true; dirtyBoundingRect = QRect(); dirtyRegion = QRegion(); @@ -839,19 +836,17 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r) if (r.isEmpty() || fullUpdatePending) return; - Q_Q(QGraphicsView); - // Rect intersects viewport - update everything? switch (viewportUpdateMode) { case QGraphicsView::FullViewportUpdate: fullUpdatePending = true; - q->viewport()->update(); + viewport->update(); break; case QGraphicsView::BoundingRectViewportUpdate: dirtyBoundingRect |= r.boundingRect(); - if (dirtyBoundingRect.contains(q->viewport()->rect())) { + if (dirtyBoundingRect.contains(viewport->rect())) { fullUpdatePending = true; - q->viewport()->update(); + viewport->update(); } break; case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE @@ -875,19 +870,17 @@ void QGraphicsViewPrivate::updateRect(const QRect &r) if (r.isEmpty() || fullUpdatePending) return; - Q_Q(QGraphicsView); - // Rect intersects viewport - update everything? switch (viewportUpdateMode) { case QGraphicsView::FullViewportUpdate: fullUpdatePending = true; - q->viewport()->update(); + viewport->update(); break; case QGraphicsView::BoundingRectViewportUpdate: dirtyBoundingRect |= r; - if (dirtyBoundingRect.contains(q->viewport()->rect())) { + if (dirtyBoundingRect.contains(viewport->rect())) { fullUpdatePending = true; - q->viewport()->update(); + viewport->update(); } break; case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index d353c2d..7890e1f 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -108,16 +108,16 @@ void QAbstractItemViewPrivate::init() Q_Q(QAbstractItemView); q->setItemDelegate(new QStyledItemDelegate(q)); - q->verticalScrollBar()->setRange(0, 0); - q->horizontalScrollBar()->setRange(0, 0); + vbar->setRange(0, 0); + hbar->setRange(0, 0); - QObject::connect(q->verticalScrollBar(), SIGNAL(actionTriggered(int)), + QObject::connect(vbar, SIGNAL(actionTriggered(int)), q, SLOT(verticalScrollbarAction(int))); - QObject::connect(q->horizontalScrollBar(), SIGNAL(actionTriggered(int)), + QObject::connect(hbar, SIGNAL(actionTriggered(int)), q, SLOT(horizontalScrollbarAction(int))); - QObject::connect(q->verticalScrollBar(), SIGNAL(valueChanged(int)), + QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(verticalScrollbarValueChanged(int))); - QObject::connect(q->horizontalScrollBar(), SIGNAL(valueChanged(int)), + QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(horizontalScrollbarValueChanged(int))); viewport->setBackgroundRole(QPalette::Base); diff --git a/src/gui/itemviews/qcolumnview.cpp b/src/gui/itemviews/qcolumnview.cpp index 4fb08bb..1f88f7c 100644 --- a/src/gui/itemviews/qcolumnview.cpp +++ b/src/gui/itemviews/qcolumnview.cpp @@ -108,9 +108,9 @@ void QColumnViewPrivate::initialize() { Q_Q(QColumnView); q->setTextElideMode(Qt::ElideMiddle); - q->connect(¤tAnimation, SIGNAL(frameChanged(int)), - q->horizontalScrollBar(), SLOT(setValue(int))); - q->connect(¤tAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn())); + QObject::connect(¤tAnimation, SIGNAL(frameChanged(int)), + hbar, SLOT(setValue(int))); + QObject::connect(¤tAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn())); delete itemDelegate; q->setItemDelegate(new QColumnViewDelegate(q)); } @@ -421,23 +421,23 @@ void QColumnViewPrivate::updateScrollbars() horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); } - QSize viewportSize = q->viewport()->size(); - if (horizontalLength < viewportSize.width() && q->horizontalScrollBar()->value() == 0) { - q->horizontalScrollBar()->setRange(0, 0); + QSize viewportSize = viewport->size(); + if (horizontalLength < viewportSize.width() && hbar->value() == 0) { + hbar->setRange(0, 0); } else { int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width()); int hiddenLength = horizontalLength - visibleLength; - if (hiddenLength != q->horizontalScrollBar()->maximum()) - q->horizontalScrollBar()->setRange(0, hiddenLength); + if (hiddenLength != hbar->maximum()) + hbar->setRange(0, hiddenLength); } if (!columns.isEmpty()) { int pageStepSize = columns.at(0)->width(); - if (pageStepSize != q->horizontalScrollBar()->pageStep()) - q->horizontalScrollBar()->setPageStep(pageStepSize); + if (pageStepSize != hbar->pageStep()) + hbar->setPageStep(pageStepSize); } - bool visible = (q->horizontalScrollBar()->maximum() > 0); - if (visible != q->horizontalScrollBar()->isVisible()) - q->horizontalScrollBar()->setVisible(visible); + bool visible = (hbar->maximum() > 0); + if (visible != hbar->isVisible()) + hbar->setVisible(visible); } /*! @@ -696,7 +696,7 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo q, SIGNAL(pressed(const QModelIndex &))); view->setFocusPolicy(Qt::NoFocus); - view->setParent(q->viewport()); + view->setParent(viewport); Q_ASSERT(view); // Setup corner grip @@ -707,13 +707,13 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo } if (columnSizes.count() > columns.count()) { - view->setGeometry(0, 0, columnSizes.at(columns.count()), q->viewport()->height()); + view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); } else { int initialWidth = view->sizeHint().width(); if (q->isRightToLeft()) - view->setGeometry(q->viewport()->width() - initialWidth, 0, initialWidth, q->viewport()->height()); + view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); else - view->setGeometry(0, 0, initialWidth, q->viewport()->height()); + view->setGeometry(0, 0, initialWidth, viewport->height()); columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); columnSizes[columns.count()] = initialWidth; } @@ -1056,11 +1056,11 @@ void QColumnViewPrivate::doLayout() if (!model || columns.isEmpty()) return; - int viewportHeight = q->viewport()->height(); + int viewportHeight = viewport->height(); int x = columns.at(0)->x(); if (q->isRightToLeft()) { - x = q->viewport()->width() + q->horizontalOffset(); + x = viewport->width() + q->horizontalOffset(); for (int i = 0; i < columns.size(); ++i) { QAbstractItemView *view = columns.at(i); x -= view->width(); diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 7ad825a..d0321d8 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -3474,11 +3474,10 @@ void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) int QHeaderViewPrivate::viewSectionSizeHint(int logical) const { - Q_Q(const QHeaderView); - if (QAbstractItemView *parent = qobject_cast(q->parent())) { + if (QAbstractItemView *view = qobject_cast(parent)) { return (orientation == Qt::Horizontal - ? parent->sizeHintForColumn(logical) - : parent->sizeHintForRow(logical)); + ? view->sizeHintForColumn(logical) + : view->sizeHintForRow(logical)); } return 0; } diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 03ba641..fe7916c 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -610,7 +610,7 @@ int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QR const bool rightOf = q->isRightToLeft() ? rect.right() > area.right() : (rect.right() > area.right()) && (rect.left() > area.left()); - int horizontalValue = q->horizontalScrollBar()->value(); + int horizontalValue = hbar->value(); // ScrollPerItem if (q->horizontalScrollMode() == QAbstractItemView::ScrollPerItem && viewMode == QListView::ListMode) { @@ -652,10 +652,10 @@ int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRec const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top()); const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom()); - int verticalValue = q->verticalScrollBar()->value(); + int verticalValue = vbar->value(); // ScrollPerItem - if (q->verticalScrollMode() == QAbstractItemView::ScrollPerItem && viewMode == QListView::ListMode) { + if (verticalScrollMode == QAbstractItemView::ScrollPerItem && viewMode == QListView::ListMode) { const QListViewItem item = indexToListViewItem(index); const QRect rect = q->visualRect(index); verticalValue = staticListView->verticalPerItemValue(itemIndex(item), @@ -1972,10 +1972,10 @@ void QListViewPrivate::prepareItemsLayout() // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy // is Qt::ScrollBarAsNeeded int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded - ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->verticalScrollBar()) + frameAroundContents + ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents : 0; int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded - ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q->horizontalScrollBar()) + frameAroundContents + ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents : 0; layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 9910118..53fa170 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1319,7 +1319,7 @@ bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos) expand(i, true); if (!isAnimating()) { q->updateGeometries(); - q->viewport()->update(); + viewport->update(); } return true; } @@ -3201,19 +3201,18 @@ int QTreeViewPrivate::itemHeight(int item) const */ int QTreeViewPrivate::coordinateForItem(int item) const { - Q_Q(const QTreeView); if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) { if (uniformRowHeights) - return (item * defaultItemHeight) - q->verticalScrollBar()->value(); + return (item * defaultItemHeight) - vbar->value(); // ### optimize (spans or caching) int y = 0; for (int i = 0; i < viewItems.count(); ++i) { if (i == item) - return y - q->verticalScrollBar()->value(); + return y - vbar->value(); y += itemHeight(i); } } else { // ScrollPerItem - int topViewItemIndex = q->verticalScrollBar()->value(); + int topViewItemIndex = vbar->value(); if (uniformRowHeights) return defaultItemHeight * (item - topViewItemIndex); if (item >= topViewItemIndex) { @@ -3253,7 +3252,6 @@ int QTreeViewPrivate::coordinateForItem(int item) const */ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const { - Q_Q(const QTreeView); const int itemCount = viewItems.count(); if (itemCount == 0) return -1; @@ -3261,19 +3259,19 @@ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const return -1; if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) { if (uniformRowHeights) { - const int viewItemIndex = (coordinate + q->verticalScrollBar()->value()) / defaultItemHeight; + const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight; return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); } // ### optimize int viewItemCoordinate = 0; - const int contentsCoordinate = coordinate + q->verticalScrollBar()->value(); + const int contentsCoordinate = coordinate + vbar->value(); for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) { viewItemCoordinate += itemHeight(viewItemIndex); if (viewItemCoordinate >= contentsCoordinate) return (viewItemIndex >= itemCount ? -1 : viewItemIndex); } } else { // ScrollPerItem - int topViewItemIndex = q->verticalScrollBar()->value(); + int topViewItemIndex = vbar->value(); if (uniformRowHeights) { if (coordinate < 0) coordinate -= defaultItemHeight - 1; @@ -3365,8 +3363,7 @@ QModelIndex QTreeViewPrivate::modelIndex(int i, int column) const int QTreeViewPrivate::firstVisibleItem(int *offset) const { - Q_Q(const QTreeView); - const int value = q->verticalScrollBar()->value(); + const int value = vbar->value(); if (verticalScrollMode == QAbstractItemView::ScrollPerItem) { if (offset) *offset = 0; @@ -3443,9 +3440,9 @@ void QTreeViewPrivate::updateScrollBars() if (verticalScrollMode == QAbstractItemView::ScrollPerItem) { if (!viewItems.isEmpty()) itemsInViewport = qMax(1, itemsInViewport); - q->verticalScrollBar()->setRange(0, viewItems.count() - itemsInViewport); - q->verticalScrollBar()->setPageStep(itemsInViewport); - q->verticalScrollBar()->setSingleStep(1); + vbar->setRange(0, viewItems.count() - itemsInViewport); + vbar->setPageStep(itemsInViewport); + vbar->setSingleStep(1); } else { // scroll per pixel int contentsHeight = 0; if (uniformRowHeights) { @@ -3454,9 +3451,9 @@ void QTreeViewPrivate::updateScrollBars() for (int i = 0; i < viewItems.count(); ++i) contentsHeight += itemHeight(i); } - q->verticalScrollBar()->setRange(0, contentsHeight - viewportSize.height()); - q->verticalScrollBar()->setPageStep(viewportSize.height()); - q->verticalScrollBar()->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); + vbar->setRange(0, contentsHeight - viewportSize.height()); + vbar->setPageStep(viewportSize.height()); + vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); } const int columnCount = header->count(); @@ -3472,17 +3469,17 @@ void QTreeViewPrivate::updateScrollBars() if (columnCount > 0) columnsInViewport = qMax(1, columnsInViewport); if (horizontalScrollMode == QAbstractItemView::ScrollPerItem) { - q->horizontalScrollBar()->setRange(0, columnCount - columnsInViewport); - q->horizontalScrollBar()->setPageStep(columnsInViewport); - q->horizontalScrollBar()->setSingleStep(1); + hbar->setRange(0, columnCount - columnsInViewport); + hbar->setPageStep(columnsInViewport); + hbar->setSingleStep(1); } else { // scroll per pixel const int horizontalLength = header->length(); const QSize maxSize = q->maximumViewportSize(); - if (maxSize.width() >= horizontalLength && q->verticalScrollBar()->maximum() <= 0) + if (maxSize.width() >= horizontalLength && vbar->maximum() <= 0) viewportSize = maxSize; - q->horizontalScrollBar()->setPageStep(viewportSize.width()); - q->horizontalScrollBar()->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); - q->horizontalScrollBar()->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); + hbar->setPageStep(viewportSize.width()); + hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); + hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); } } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 6026821..61d8f20 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1067,7 +1067,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) q->data = &data; #ifndef QT_NO_THREAD - if (!q->parent()) { + if (!parent) { Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", "Widgets must be created in the GUI thread."); } @@ -4993,7 +4993,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QPoint scrollAreaOffset; #ifndef QT_NO_SCROLLAREA - QAbstractScrollArea *scrollArea = qobject_cast(q->parent()); + QAbstractScrollArea *scrollArea = qobject_cast(parent); if (scrollArea && scrollArea->viewport() == q) { QObjectData *scrollPrivate = static_cast(scrollArea)->d_ptr; QAbstractScrollAreaPrivate *priv = static_cast(scrollPrivate); diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 0958b52..780891b 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -394,7 +394,7 @@ void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QText Q_Q(QTextControl); setContent(format, text, document); - QWidget *parentWidget = qobject_cast(q->parent()); + QWidget *parentWidget = qobject_cast(parent); if (parentWidget) { QTextOption opt = doc->defaultTextOption(); opt.setTextDirection(parentWidget->layoutDirection()); diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index 1900016..f28288e 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -319,20 +319,16 @@ QListQAbstractButtonPrivate::queryButtonList() const return group->d_func()->buttonList; #endif - Q_Q(const QAbstractButton); - QListcandidates; - if (q->parentWidget()) { - candidates = qFindChildren(q->parentWidget()); - if (autoExclusive) { - for (int i = candidates.count() - 1; i >= 0; --i) { - QAbstractButton *candidate = candidates.at(i); - if (!candidate->autoExclusive() + QListcandidates = qFindChildren(parent); + if (autoExclusive) { + for (int i = candidates.count() - 1; i >= 0; --i) { + QAbstractButton *candidate = candidates.at(i); + if (!candidate->autoExclusive() #ifndef QT_NO_BUTTONGROUP - || candidate->group() + || candidate->group() #endif - ) - candidates.removeAt(i); - } + ) + candidates.removeAt(i); } } return candidates; diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp index 6acd977..0235c04 100644 --- a/src/gui/widgets/qmdiarea.cpp +++ b/src/gui/widgets/qmdiarea.cpp @@ -800,12 +800,12 @@ void QMdiAreaPrivate::appendChild(QMdiSubWindow *child) Q_Q(QMdiArea); Q_ASSERT(child && childWindows.indexOf(child) == -1); - if (child->parent() != q->viewport()) - child->setParent(q->viewport(), child->windowFlags()); + if (child->parent() != viewport) + child->setParent(viewport, child->windowFlags()); childWindows.append(QPointer(child)); if (!child->testAttribute(Qt::WA_Resized) && q->isVisible()) { - QSize newSize(child->sizeHint().boundedTo(q->viewport()->size())); + QSize newSize(child->sizeHint().boundedTo(viewport->size())); child->resize(newSize.expandedTo(qSmartMinSize(child))); } @@ -931,7 +931,7 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger) widgets.move(indexToActive, 0); } - QRect domain = q->viewport()->rect(); + QRect domain = viewport->rect(); if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); @@ -1236,7 +1236,7 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in { Q_Q(QMdiArea); if (!minSubWindowSize.isValid() || subWindowCount <= 0) - return q->viewport()->rect(); + return viewport->rect(); // Calculate minimum size. const int columns = qMax(qCeil(qSqrt(qreal(subWindowCount))), 1); @@ -1255,10 +1255,10 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in // We don't want sub-subwindows to be placed at the edge, thus add 2 pixels. int minAreaWidth = minWidth + left + right + 2; int minAreaHeight = minHeight + top + bottom + 2; - if (q->horizontalScrollBar()->isVisible()) - minAreaHeight += q->horizontalScrollBar()->height(); - if (q->verticalScrollBar()->isVisible()) - minAreaWidth += q->verticalScrollBar()->width(); + if (hbar->isVisible()) + minAreaHeight += hbar->height(); + if (vbar->isVisible()) + minAreaWidth += vbar->width(); if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) { const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q); minAreaWidth += 2 * frame; @@ -1268,23 +1268,23 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in topLevel->resize(topLevel->size() + diff); } - QRect domain = q->viewport()->rect(); + QRect domain = viewport->rect(); // Adjust domain width and provide horizontal scroll bar. if (domain.width() < minWidth) { domain.setWidth(minWidth); - if (q->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) + if (hbarpolicy == Qt::ScrollBarAlwaysOff) q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - else if (q->horizontalScrollBar()->value() != 0) - q->horizontalScrollBar()->setValue(0); + else + hbar->setValue(0); } // Adjust domain height and provide vertical scroll bar. if (domain.height() < minHeight) { domain.setHeight(minHeight); - if (q->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) + if (vbarpolicy == Qt::ScrollBarAlwaysOff) q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - else if (q->verticalScrollBar()->value() != 0) - q->verticalScrollBar()->setValue(0); + else + vbar->setValue(0); } return domain; } diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp index 56df8ea..b366c28 100644 --- a/src/gui/widgets/qmdisubwindow.cpp +++ b/src/gui/widgets/qmdisubwindow.cpp @@ -1115,7 +1115,7 @@ void QMdiSubWindowPrivate::updateDirtyRegions() void QMdiSubWindowPrivate::updateGeometryConstraints() { Q_Q(QMdiSubWindow); - if (!q->parent()) + if (!parent) return; internalMinimumSize = (!q->isMinimized() && !q->minimumSize().isNull()) @@ -1145,7 +1145,7 @@ void QMdiSubWindowPrivate::updateMask() if (!q->mask().isEmpty()) q->clearMask(); - if (!q->parent()) + if (!parent) return; if ((q->isMaximized() && !drawTitleBarWhenMaximized()) @@ -1168,7 +1168,7 @@ void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos) { Q_Q(QMdiSubWindow); Q_ASSERT(currentOperation != None); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); uint cflags = operationMap.find(currentOperation).value().changeFlags; int posX = pos.x(); @@ -1235,7 +1235,7 @@ void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos) void QMdiSubWindowPrivate::setMinimizeMode() { Q_Q(QMdiSubWindow); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); ensureWindowState(Qt::WindowMinimized); isShadeRequestFromMinimizeMode = true; @@ -1263,7 +1263,7 @@ void QMdiSubWindowPrivate::setMinimizeMode() void QMdiSubWindowPrivate::setNormalMode() { Q_Q(QMdiSubWindow); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); isShadeMode = false; isMaximizeMode = false; @@ -1334,7 +1334,7 @@ void QMdiSubWindowPrivate::setNormalMode() void QMdiSubWindowPrivate::setMaximizeMode() { Q_Q(QMdiSubWindow); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); ensureWindowState(Qt::WindowMaximized); isShadeMode = false; @@ -1423,7 +1423,7 @@ void QMdiSubWindowPrivate::setMaximizeMode() void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus) { Q_Q(QMdiSubWindow); - if (!q->parent() || !activationEnabled) + if (!parent || !activationEnabled) return; if (activate && !isActive && q->isEnabled()) { @@ -1711,7 +1711,7 @@ void QMdiSubWindowPrivate::ensureWindowState(Qt::WindowState state) int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const { Q_Q(const QMdiSubWindow); - if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint + if (!parent || q->windowFlags() & Qt::FramelessWindowHint || (q->isMaximized() && !drawTitleBarWhenMaximized())) { return 0; } @@ -1734,7 +1734,7 @@ void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const { Q_Q(const QMdiSubWindow); Qt::WindowFlags flags = q->windowFlags(); - if (!q->parent() || flags & Qt::FramelessWindowHint) { + if (!parent || flags & Qt::FramelessWindowHint) { *margin = 0; *minWidth = 0; return; @@ -1893,7 +1893,7 @@ void QMdiSubWindowPrivate::enterRubberBandMode() if (q->isMaximized()) return; Q_ASSERT(oldGeometry.isValid()); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); if (!rubberBand) { rubberBand = new QRubberBand(QRubberBand::Rectangle, q->parentWidget()); // For accessibility to identify this special widget. @@ -2079,7 +2079,7 @@ void QMdiSubWindowPrivate::restoreFocus() void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) { Q_Q(QMdiSubWindow); - if (!q->parent()) { + if (!parent) { q->setWindowFlags(windowFlags); return; } @@ -2164,7 +2164,7 @@ void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QStri QSize QMdiSubWindowPrivate::iconSize() const { Q_Q(const QMdiSubWindow); - if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint) + if (!parent || q->windowFlags() & Qt::FramelessWindowHint) return QSize(-1, -1); return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); } diff --git a/src/gui/widgets/qmdisubwindow_p.h b/src/gui/widgets/qmdisubwindow_p.h index 2e672d6..394f11c 100644 --- a/src/gui/widgets/qmdisubwindow_p.h +++ b/src/gui/widgets/qmdisubwindow_p.h @@ -287,7 +287,7 @@ public: inline int titleBarHeight() const { Q_Q(const QMdiSubWindow); - if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint + if (!parent || q->windowFlags() & Qt::FramelessWindowHint || (q->isMaximized() && !drawTitleBarWhenMaximized())) { return 0; } -- cgit v0.12 From 060727ed4f8b1ffea58229817640a03be5b095ed Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 10 Jun 2009 16:58:06 +0200 Subject: Adding support in QVariant for conversions between QUrl and QString Reviewed-by: ogoffart --- src/corelib/kernel/qvariant.cpp | 16 ++++++++++++++-- tests/auto/qvariant/tst_qvariant.cpp | 14 +++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e6f1c48..a3434a4 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -591,6 +591,15 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, ok = &dummy; switch (uint(t)) { + case QVariant::Url: + switch (d->type) { + case QVariant::String: + *static_cast(result) = QUrl(*v_cast(d)); + break; + default: + return false; + } + break; case QVariant::String: { QString *str = static_cast(result); switch (d->type) { @@ -640,6 +649,8 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, if (v_cast(d)->count() == 1) *str = v_cast(d)->at(0); break; + case QVariant::Url: + *str = v_cast(d)->toString(); default: return false; } @@ -2484,7 +2495,8 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime - | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char, + | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char + | 1 << QVariant::Url, /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, @@ -2499,7 +2511,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, -/*QUrl*/ 0, +/*QUrl*/ 1 << QVariant::String, /*QLocale*/ 0, diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 0ede920..2d26914 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2449,14 +2449,22 @@ void tst_QVariant::saveLoadCustomTypes() void tst_QVariant::url() { - QUrl url("http://www.trolltech.com"); + QString str("http://www.trolltech.com"); + QUrl url(str); - QVariant v(url); + QVariant v(url); //built with a QUrl QVariant v2 = v; - QVERIFY(v2.toUrl() == url); + QVariant v3(str); //built with a QString + QCOMPARE(v2.toUrl(), url); + QVERIFY(qVariantCanConvert(v3)); + QCOMPARE(v2.toUrl(), v3.toUrl()); + + QVERIFY(qVariantCanConvert(v2)); + QCOMPARE(v2.toString(), str); + QCOMPARE(v3.toString(), str); } void tst_QVariant::globalColor() -- cgit v0.12 From de74fcaeba4551afaa06f3d295e8e834fd5d3eb7 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 10 Jun 2009 17:05:11 +0200 Subject: Some adjustments to the documentation Headers are slightly lighter now. Not all tables are affected by the changes any more. --- doc/src/index.qdoc | 20 ++++++------- tools/qdoc3/test/classic.css | 71 ++++++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 23e8623..b18a50d 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -86,15 +86,15 @@ \endif \raw HTML - +
- - - @@ -128,13 +128,13 @@ - - - @@ -194,13 +194,13 @@ - - - diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 9c59c81..5087f9e 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -17,7 +17,7 @@ h3.fn,span.fn background-color: #eee; border-width: 1px; border-style: solid; - border-color: #ddd #ddd #ddd #ddd ; + border-color: #ddd; font-weight: bold; padding: 6px 0px 6px 10px; margin: 42px 0px 0px 0px; @@ -25,7 +25,7 @@ h3.fn,span.fn hr { border: 0; - color: #9E9E9E; + color: #a0a0a0; background-color: #ccc; height: 1px; width: 100%; @@ -33,7 +33,7 @@ hr { margin: 34px 0px 34px 0px; } -table { +table.valuelist { border-width: 1px 1px 1px 1px; border-style: solid; border-color: #dddddd; @@ -43,13 +43,32 @@ table { width: 97% } -table th { +table.indextable { + border-width: 1px 1px 1px 1px; + border-collapse: collapse; + background-color: #f0f0f0; + border-color:#555; + margin-left: 1.5%; + width: 97% +} + + +table.valuelist th { border-width: 1px 1px 1px 2px; padding: 4px; border-style: solid; + border-color: #666; + color:white; + background-color:#666; +} + +th.titleheader { + border-width: 1px 0px 1px 0px; + padding: 4px; + border-style: solid; border-color: #444; color:white; - background-color:#444; + background-color:#555555; } p { @@ -101,42 +120,30 @@ body color: black } +table.generic, table.annotated +{ + border-width: 1px; + border-color:#bbb; + border-style:solid; + border-collapse:collapse; +} + table td.memItemLeft { - width: 200px; + width: 160px; padding: 2px 0px 0px 8px; margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; font-size: 100%; white-space: nowrap } table td.memItemRight { padding: 2px 8px 0px 8px; margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; font-size: 100%; } -- cgit v0.12 From 11730b27413218c9e9bf1fc35f5e46a35baad874 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 10 Jun 2009 16:09:46 +0200 Subject: tst_qpixmap compile fix QPixmap(QImage) works with Qt3 support only... Reviewed-by: thartman --- tests/auto/qpixmap/tst_qpixmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8a6b63b..058c3c6 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -376,7 +376,7 @@ void tst_QPixmap::scroll() QFETCH(QRegion, exposed); QFETCH(bool, newPix); - QPixmap pixmap(input); + QPixmap pixmap = QPixmap::fromImage(input); QRegion exp; qint64 oldKey = pixmap.cacheKey(); pixmap.scroll(dx, dy, rect, &exp); -- cgit v0.12 From 859c0d5f2fe8234e9f1b8f638a3e3c592e7f3224 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Wed, 10 Jun 2009 17:18:20 +0200 Subject: Optimize QDirPrivate::sortFileList by using a QFileInfoList directly instead of "constructing" a new one with empty file infos Reviewed-by:alexis Request-url: http://qt.gitorious.org/qt/qt/merge_requests/636 Task-number:253382 Merge-request: 636 Reviewed-by: Alexis Menard --- src/corelib/io/qdir.cpp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 7d330e6..1795245 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -45,6 +45,7 @@ #ifndef QT_NO_DEBUG_STREAM #include "qdebug.h" #endif +#include "qdiriterator.h" #include "qfsfileengine.h" #include "qdatetime.h" #include "qstring.h" @@ -92,7 +93,7 @@ protected: QString initFileEngine(const QString &file); void updateFileLists() const; - void sortFileList(QDir::SortFlags, QStringList &, QStringList *, QFileInfoList *) const; + void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *) const; private: #ifdef QT3_SUPPORT @@ -268,7 +269,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt return r < 0; } -inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QStringList &l, +inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, QStringList *names, QFileInfoList *infos) const { if(names) @@ -278,16 +279,12 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QStringList &l, if(!l.isEmpty()) { QDirSortItem *si= new QDirSortItem[l.count()]; int i; - for (i = 0; i < l.size(); ++i) { - QString path = data->path; - if (!path.isEmpty() && !path.endsWith(QLatin1Char('/'))) - path += QLatin1Char('/'); - si[i].item = QFileInfo(path + l.at(i)); - } + for (i = 0; i < l.size(); ++i) + si[i].item = l.at(i); if ((sort & QDir::SortByMask) != QDir::Unsorted) - qStableSort(si, si+i, QDirSortItemComparator(sort)); + qStableSort(si, si + i, QDirSortItemComparator(sort)); // put them back in the list(s) - for (int j = 0; jappend(si[j].item); if(names) @@ -300,7 +297,12 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QStringList &l, inline void QDirPrivate::updateFileLists() const { if(data->listsDirty) { - QStringList l = data->fileEngine->entryList(data->filters, data->nameFilters); + QFileInfoList l; + QDirIterator it(data->path, data->nameFilters, data->filters); + while (it.hasNext()) { + it.next(); + l.append(it.fileInfo()); + } sortFileList(data->sort, l, &data->files, &data->fileInfos); data->listsDirty = 0; } @@ -1346,7 +1348,12 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, d->updateFileLists(); return d->data->files; } - QStringList l = d->data->fileEngine->entryList(filters, nameFilters); + QFileInfoList l; + QDirIterator it(d->data->path, nameFilters, filters); + while (it.hasNext()) { + it.next(); + l.append(it.fileInfo()); + } if ((sort & QDir::SortByMask) == QDir::Unsorted) return l; @@ -1389,8 +1396,16 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter d->updateFileLists(); return d->data->fileInfos; } + QFileInfoList l; + QDirIterator it(d->data->path, nameFilters, filters); + while (it.hasNext()) { + it.next(); + l.append(it.fileInfo()); + } + if ((sort & QDir::SortByMask) == QDir::Unsorted) + return l; + QFileInfoList ret; - QStringList l = d->data->fileEngine->entryList(filters, nameFilters); d->sortFileList(sort, l, 0, &ret); return ret; } -- cgit v0.12 From 28323eab144cdc3db9d947b9b94fb2ebfa477234 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Wed, 10 Jun 2009 17:18:21 +0200 Subject: Improve QDirPrivate::sortFileList by leaving right avway is we don't need to sort. Reviewed-by:alexis Request-url: http://qt.gitorious.org/qt/qt/merge_requests/636 Merge-request: 636 Reviewed-by: Alexis Menard --- src/corelib/io/qdir.cpp | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 1795245..302d9b5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -276,21 +276,31 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, names->clear(); if(infos) infos->clear(); - if(!l.isEmpty()) { - QDirSortItem *si= new QDirSortItem[l.count()]; - int i; - for (i = 0; i < l.size(); ++i) - si[i].item = l.at(i); - if ((sort & QDir::SortByMask) != QDir::Unsorted) - qStableSort(si, si + i, QDirSortItemComparator(sort)); - // put them back in the list(s) - for (int j = 0; j < i; j++) { + int n = l.size(); + if(n > 0) { + if (n == 1 || (sort & QDir::SortByMask) == QDir::Unsorted) { if(infos) - infos->append(si[j].item); - if(names) - names->append(si[j].item.fileName()); + *infos = l; + if(names) { + for (int i = 0; i < n; ++i) + names->append(l.at(i).fileName()); + } + } else { + QDirSortItem *si = new QDirSortItem[n]; + for (int i = 0; i < n; ++i) + si[i].item = l.at(i); + qStableSort(si, si + n, QDirSortItemComparator(sort)); + // put them back in the list(s) + if(infos) { + for (int i = 0; i < n; ++i) + infos->append(si[i].item); + } + if(names) { + for (int i = 0; i < n; ++i) + names->append(si[i].item.fileName()); + } + delete [] si; } - delete [] si; } } @@ -1354,9 +1364,6 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, it.next(); l.append(it.fileInfo()); } - if ((sort & QDir::SortByMask) == QDir::Unsorted) - return l; - QStringList ret; d->sortFileList(sort, l, &ret, 0); return ret; @@ -1402,9 +1409,6 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter it.next(); l.append(it.fileInfo()); } - if ((sort & QDir::SortByMask) == QDir::Unsorted) - return l; - QFileInfoList ret; d->sortFileList(sort, l, 0, &ret); return ret; -- cgit v0.12 From a863beab4c18f4bda777b61e55e7b66074a467f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 10 Jun 2009 16:41:14 +0200 Subject: We don't have to combine the world matrix anymore. See also: 32f32ee3e752a6cc03505ddaa48d2849eaedc2a6 Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsview.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 4a8099c..de7b9f4 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3238,7 +3238,6 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Set up the painter QPainter painter(viewport()); - QTransform original = painter.worldTransform(); #ifndef QT_NO_RUBBERBAND if (d->rubberBanding && !d->rubberBandRect.isEmpty()) painter.save(); @@ -3249,7 +3248,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Set up viewport transform const QTransform viewTransform = viewportTransform(); - painter.setTransform(viewTransform, true); + painter.setWorldTransform(viewTransform); // Draw background if ((d->cacheMode & CacheBackground) @@ -3281,10 +3280,9 @@ void QGraphicsView::paintEvent(QPaintEvent *event) } // Blit the background from the background pixmap - QTransform oldMatrix = painter.worldTransform(); - painter.setWorldTransform(original); + painter.setWorldTransform(QTransform()); painter.drawPixmap(QPoint(), d->backgroundPixmap); - painter.setWorldTransform(oldMatrix); + painter.setWorldTransform(viewTransform); } else { if (!(d->optimizationFlags & DontSavePainterState)) painter.save(); -- cgit v0.12 From 2e41f3fd234a31a57c111b16e0339dea52d77d4d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 10 Jun 2009 17:26:57 +0200 Subject: Reduce left-margins in qdoc The current implementation is a bit hackish and does not work for all cases. It is better to remove it for now until we have a proper way of supporting it. --- tools/qdoc3/test/classic.css | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 5087f9e..7f22861 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -39,8 +39,6 @@ table.valuelist { border-color: #dddddd; border-collapse: collapse; background-color: #f0f0f0; - margin-left: 1.5%; - width: 97% } table.indextable { @@ -48,8 +46,6 @@ table.indextable { border-collapse: collapse; background-color: #f0f0f0; border-color:#555; - margin-left: 1.5%; - width: 97% } @@ -72,9 +68,9 @@ th.titleheader { } p { - margin-left: 1.5%; + + margin-left: 4px; margin-top: 8px; - width: 97% margin-bottom: 8px; } @@ -138,6 +134,7 @@ table td.memItemLeft { font-size: 100%; white-space: nowrap } + table td.memItemRight { padding: 2px 8px 0px 8px; margin: 4px; -- cgit v0.12 From 0989cbe2b164560eef14334a540fcbcb2e2ec8cb Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 11 Jun 2009 08:29:11 +0200 Subject: Remove var->QMAKE_COMP_var docs, and mark feature unsupported. Reviewed By: andy --- doc/src/qmake-manual.qdoc | 4 ---- qmake/generators/makefile.cpp | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index 172bc60..9714a44 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -3303,10 +3303,6 @@ \o output_function \o Specifies a custom qmake function that is used to specify the filename to be created. \row - \o variables - \o Indicates that the variables specified here are replaced with $(QMAKE_COMP_VARNAME) when refered to - in the pro file as $(VARNAME). - \row \o variable_out \o The variable that the files created from the output should be added to. \endtable diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 2d4658e..a385748 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1910,6 +1910,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) deps += replaceExtraCompilerVariables(pre_deps.at(i), (*input), out); } QString cmd = replaceExtraCompilerVariables(tmp_cmd, (*input), out); + // NOTE: The var -> QMAKE_COMP_var replace feature is unsupported, do not use! for(QStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3) cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")"); if(!tmp_dep_cmd.isEmpty() && doDepends()) { -- cgit v0.12 From 65373d007797b559a573b7b08f40c6801da11686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 11 Jun 2009 10:13:24 +0200 Subject: Compile on the Mac. Broke after this commit: 32f32ee3e752a6cc03505ddaa48d2849eaedc2a6 --- src/gui/painting/qpaintengine_mac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index 5889388..3d0a1b7 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -131,8 +131,8 @@ QMacCGContext::QMacCGContext(QPainter *p) QPainterState *state = static_cast(pe->state); Q_ASSERT(state); - if (!state->redirection_offset.isNull()) - CGContextTranslateCTM(context, -state->redirection_offset.x(), -state->redirection_offset.y()); + if (!state->redirectionMatrix.isIdentity()) + CGContextTranslateCTM(context, state->redirectionMatrix.dx(), state->redirectionMatrix.dy()); } } CGContextRetain(context); -- cgit v0.12 From 615f8a53355ea501e489eecddab1d5c4295cab80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 11 Jun 2009 11:42:05 +0200 Subject: Partially revert "Add (back) properties to QGraphicsItem to change the transformations component" This partially reverts commit 56f23d4c, which changed the logic in updateCachedClipPathFromSetPosHelper. We cannot compute the item's transform relative to the parent by using transformToParent() because the new position is not yet set on the item, that's why the new position is passed into the function. However, I'll look into how we can get rid of the entire function, but keep it as is for now. Reviewed-by: Olivier --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f50d210..eae2bf3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4281,7 +4281,9 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n // Find closest clip ancestor and transform. Q_Q(QGraphicsItem); // COMBINE - QTransform thisToParentTransform = transformToParent(); + QTransform thisToParentTransform = transformData + ? transformData->computedFullTransform() * QTransform::fromTranslate(newPos.x(), newPos.y()) + : QTransform::fromTranslate(newPos.x(), newPos.y()); QGraphicsItem *clipParent = parent; while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { thisToParentTransform *= clipParent->d_ptr->transformToParent(); -- cgit v0.12 From 05cb12eb18605aa32ff7a6761ff82d86aa339995 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 3 Jun 2009 14:14:09 +0200 Subject: add a QGraphicsObject class and change QGraphicsWidget and QGraphicsTextItem to inherit from it This changes the inheritance hierarchy of QGraphicsWidget from multiply inheriting from QObject, QGraphicsItem and QGraphicsLayoutItem to inherit from QGraphicsObject and QGraphicsLayoutItem. QGraphicsObject then simply inherits from QObject and QGraphicsItem. This change is binary compatible as it will leave the vtable layout unchanged and as the parent class doesn't appear in the C++ name mangling on any of our platforms. It's also source compatible as it isn't noticable by existing code. The restriction we have on QGraphicsObject is that we can not add any new virtual methods to it, or add data members to the class. We can however implement a QGraphicsObjectprivate inheriting from QGraphicsItemPrivate if there is a need to add data members to the class. This change will allow us to now have one single base for all QGraphicsItems that inherit from QObject: QGraphicsTextItem, QGraphicsWidget and in the future QFxItem. Having that single base class will significantly simplify our work in the qml engine. Reviewed-by: Andreas --- src/gui/graphicsview/graphicsview.pri | 77 ++++++++++++++------------------ src/gui/graphicsview/qgraphicsitem.cpp | 16 ++++++- src/gui/graphicsview/qgraphicsitem.h | 12 ++++- src/gui/graphicsview/qgraphicswidget.cpp | 4 +- src/gui/graphicsview/qgraphicswidget.h | 3 +- 5 files changed, 63 insertions(+), 49 deletions(-) diff --git a/src/gui/graphicsview/graphicsview.pri b/src/gui/graphicsview/graphicsview.pri index 02d9bb1..4cee6d6 100644 --- a/src/gui/graphicsview/graphicsview.pri +++ b/src/gui/graphicsview/graphicsview.pri @@ -1,46 +1,37 @@ # Qt graphicsview module - -HEADERS += \ - graphicsview/qgraphicsitem.h \ - graphicsview/qgraphicsitem_p.h \ - graphicsview/qgraphicsitemanimation.h \ - graphicsview/qgraphicsscene.h \ - graphicsview/qgraphicsscene_p.h \ - graphicsview/qgraphicsscene_bsp_p.h \ - graphicsview/qgraphicssceneevent.h \ - graphicsview/qgraphicsview_p.h \ - graphicsview/qgraphicsview.h - -SOURCES += \ - graphicsview/qgraphicsitem.cpp \ - graphicsview/qgraphicsitemanimation.cpp \ - graphicsview/qgraphicsscene.cpp \ - graphicsview/qgraphicsscene_bsp.cpp \ - graphicsview/qgraphicssceneevent.cpp \ - graphicsview/qgraphicsview.cpp +HEADERS += graphicsview/qgraphicsitem.h \ + graphicsview/qgraphicsitem_p.h \ + graphicsview/qgraphicsitemanimation.h \ + graphicsview/qgraphicsscene.h \ + graphicsview/qgraphicsscene_p.h \ + graphicsview/qgraphicsscene_bsp_p.h \ + graphicsview/qgraphicssceneevent.h \ + graphicsview/qgraphicsview_p.h \ + graphicsview/qgraphicsview.h +SOURCES += graphicsview/qgraphicsitem.cpp \ + graphicsview/qgraphicsitemanimation.cpp \ + graphicsview/qgraphicsscene.cpp \ + graphicsview/qgraphicsscene_bsp.cpp \ + graphicsview/qgraphicssceneevent.cpp \ + graphicsview/qgraphicsview.cpp # Widgets on the canvas - -HEADERS += \ - graphicsview/qgraphicslayout.h \ - graphicsview/qgraphicslayout_p.h \ - graphicsview/qgraphicslayoutitem.h \ - graphicsview/qgraphicslayoutitem_p.h \ - graphicsview/qgraphicslinearlayout.h \ - graphicsview/qgraphicswidget.h \ - graphicsview/qgraphicswidget_p.h \ - graphicsview/qgridlayoutengine_p.h \ - graphicsview/qgraphicsproxywidget.h \ - graphicsview/qgraphicsgridlayout.h - -SOURCES += \ - graphicsview/qgraphicslayout.cpp \ - graphicsview/qgraphicslayout_p.cpp \ - graphicsview/qgraphicslayoutitem.cpp \ - graphicsview/qgraphicslinearlayout.cpp \ - graphicsview/qgraphicswidget.cpp \ - graphicsview/qgraphicswidget_p.cpp \ - graphicsview/qgridlayoutengine.cpp \ - graphicsview/qgraphicsproxywidget.cpp \ - graphicsview/qgraphicsgridlayout.cpp - +HEADERS += graphicsview/qgraphicslayout.h \ + graphicsview/qgraphicslayout_p.h \ + graphicsview/qgraphicslayoutitem.h \ + graphicsview/qgraphicslayoutitem_p.h \ + graphicsview/qgraphicslinearlayout.h \ + graphicsview/qgraphicswidget.h \ + graphicsview/qgraphicswidget_p.h \ + graphicsview/qgridlayoutengine_p.h \ + graphicsview/qgraphicsproxywidget.h \ + graphicsview/qgraphicsgridlayout.h +SOURCES += graphicsview/qgraphicslayout.cpp \ + graphicsview/qgraphicslayout_p.cpp \ + graphicsview/qgraphicslayoutitem.cpp \ + graphicsview/qgraphicslinearlayout.cpp \ + graphicsview/qgraphicswidget.cpp \ + graphicsview/qgraphicswidget_p.cpp \ + graphicsview/qgridlayoutengine.cpp \ + graphicsview/qgraphicsproxywidget.cpp \ + graphicsview/qgraphicsgridlayout.cpp diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index eae2bf3..b83f9db 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -8147,6 +8147,18 @@ public: QGraphicsTextItem *qq; }; + +QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) + : QGraphicsItem(parent) +{ +} + +QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene) + : QGraphicsItem(dd, parent, scene) +{ +} + + /*! Constructs a QGraphicsTextItem, using \a text as the default plain text. \a parent is passed to QGraphicsItem's constructor. @@ -8159,7 +8171,7 @@ QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent , QGraphicsScene *scene #endif ) - : QGraphicsItem(parent, scene), dd(new QGraphicsTextItemPrivate) + : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate) { dd->qq = this; if (!text.isEmpty()) @@ -8181,7 +8193,7 @@ QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent , QGraphicsScene *scene #endif ) - : QGraphicsItem(parent, scene), dd(new QGraphicsTextItemPrivate) + : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate) { dd->qq = this; setAcceptDrops(true); diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index cff4f1f..a9b5d71 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -832,10 +832,20 @@ private: inline void QGraphicsPixmapItem::setOffset(qreal ax, qreal ay) { setOffset(QPointF(ax, ay)); } +class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsItem) +public: + QGraphicsObject(QGraphicsItem *parent = 0); +protected: + QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); +}; + class QGraphicsTextItemPrivate; class QTextDocument; class QTextCursor; -class Q_GUI_EXPORT QGraphicsTextItem : public QObject, public QGraphicsItem +class Q_GUI_EXPORT QGraphicsTextItem : public QGraphicsObject { Q_OBJECT QDOC_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 7314167..84434db 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -257,7 +257,7 @@ QT_BEGIN_NAMESPACE window, a tool, a popup, etc). */ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsItem(*new QGraphicsWidgetPrivate, 0, 0), QGraphicsLayoutItem(0, false) + : QGraphicsObject(*new QGraphicsWidgetPrivate, 0, 0), QGraphicsLayoutItem(0, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); @@ -269,7 +269,7 @@ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) Constructs a new QGraphicsWidget, using \a dd as parent. */ QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene, Qt::WindowFlags wFlags) - : QGraphicsItem(dd, 0, scene), QGraphicsLayoutItem(0, false) + : QGraphicsObject(dd, 0, scene), QGraphicsLayoutItem(0, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index a5c9068..6f324cf 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -66,9 +66,10 @@ class QStyleOption; class QGraphicsWidgetPrivate; -class Q_GUI_EXPORT QGraphicsWidget : public QObject, public QGraphicsItem, public QGraphicsLayoutItem +class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem { Q_OBJECT + Q_INTERFACES(QGraphicsLayoutItem) Q_PROPERTY(QPalette palette READ palette WRITE setPalette) Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) -- cgit v0.12 From 27f602b3c6075f7f664a7d3fd71f03f795f490fb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 4 Jun 2009 11:14:31 +0200 Subject: move some properties from QGraphicsWidget to QGraphicsObject These are properties of QGraphicsItem. QGraphicsObject should expose these. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsitem.h | 4 ++++ src/gui/graphicsview/qgraphicswidget.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index a9b5d71..69aab20 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -836,6 +836,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem { Q_OBJECT Q_INTERFACES(QGraphicsItem) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) + Q_PROPERTY(QPointF pos READ pos WRITE setPos) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible) public: QGraphicsObject(QGraphicsItem *parent = 0); protected: diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index 6f324cf..e19513d 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -75,12 +75,8 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) Q_PROPERTY(QSizeF size READ size WRITE resize) Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible) Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry) Q_PROPERTY(QPointF transformOrigin READ transformOrigin WRITE setTransformOrigin) Q_PROPERTY(qreal xRotation READ xRotation WRITE setXRotation) -- cgit v0.12 From e9876fdfaece0dcb09188cb4ddd5801ebb588647 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 4 Jun 2009 12:14:55 +0200 Subject: Add some meat to QGraphicsObject Added a toGraphicsObject() method to QGraphicsItem to allow upcasting. Expose some of QGraphicsItems setter/getter pairs as real properties in QGraphicsObject, including NOTIFY signals. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 145 ++++++++++++++++++++++++++++--- src/gui/graphicsview/qgraphicsitem.h | 43 ++++++--- src/gui/graphicsview/qgraphicsitem_p.h | 4 +- src/gui/graphicsview/qgraphicswidget.cpp | 81 ----------------- 4 files changed, 166 insertions(+), 107 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b83f9db..6d87c36 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1260,6 +1260,28 @@ QGraphicsWidget *QGraphicsItem::window() const } /*! + \since 4.6 + + Return the graphics item cast to a QGraphicsObject, if the class is actually a + graphics object, 0 otherwise. +*/ +QGraphicsObject *QGraphicsItem::toGraphicsObject() +{ + return d_ptr->isObject ? static_cast(this) : 0; +} + +/*! + \since 4.6 + + Return the graphics item cast to a QGraphicsObject, if the class is actually a + graphics object, 0 otherwise. +*/ +const QGraphicsObject *QGraphicsItem::toGraphicsObject() const +{ + return d_ptr->isObject ? static_cast(this) : 0; +} + +/*! Sets this item's parent item to \a parent. If this item already has a parent, it is first removed from the previous parent. If \a parent is 0, this item will become a top-level item. @@ -1799,6 +1821,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo void QGraphicsItem::setVisible(bool visible) { d_ptr->setVisibleHelper(visible, /* explicit = */ true); + + if (d_ptr->isObject) + emit static_cast(this)->visibleChanged(); } /*! @@ -1920,6 +1945,9 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo void QGraphicsItem::setEnabled(bool enabled) { d_ptr->setEnabledHelper(enabled, /* explicitly = */ true); + + if (d_ptr->isObject) + emit static_cast(this)->enabledChanged(); } /*! @@ -2082,6 +2110,8 @@ void QGraphicsItem::setOpacity(qreal opacity) /*maybeDirtyClipPath=*/false, /*force=*/false, /*ignoreOpacity=*/true); + if (d_ptr->isObject) + emit static_cast(this)->opacityChanged(); } /*! @@ -2524,6 +2554,8 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) this->pos = pos; dirtySceneTransform = 1; inSetPosHelper = 0; + if (isObject) + emit static_cast(q)->positionChanged(); } /*! @@ -6324,6 +6356,108 @@ static void qt_graphicsItem_highlightSelected( } /*! + \class QGraphicsObject + \brief The QGraphicsObject class provides a base class for all graphics items that + require signals, slots and properties. + \since 4.6 + \ingroup graphicsview-api + + The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms. + It maps many of QGraphicsItem's basic setters and getters to properties and adds notification + signals for many of them. +*/ + +/*! + Constructs a QGraphicsObject with \a parent. +*/ +QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) + : QGraphicsItem(parent) +{ + QGraphicsItem::d_ptr->isObject = true; +} + +/*! + \internal +*/ +QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene) + : QGraphicsItem(dd, parent, scene) +{ + QGraphicsItem::d_ptr->isObject = true; +} + +/*! + \property QGraphicsObject::opacity + \brief the opacity of the item + + \sa QGraphicsItem::setOpacity, QGraphicsItem::opacity +*/ + +/*! + \fn QGraphicsObject::opacityChanged() + + This signal gets emitted whenever the opacity of the item changes + + \sa opacity +*/ + +/*! + \property QGraphicsObject::pos + \brief the position of the item + + Describes the items position. + + \sa QGraphicsItem::setPos, QGraphicsItem::pos, positionChanged +*/ + +/*! + \fn QGraphicsObject::positionChanged() + + This signal gets emitted whenever the position of the item changes + + \sa pos +*/ + +/*! + \property QGraphicsObject::enabled + \brief whether the item is enabled or not + + This property is declared in QGraphicsItem. + + By default, this property is true. + + \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled(), enabledChanged() +*/ + +/*! + \fn QGraphicsObject::enabledChanged() + + This signal gets emitted whenever the item get's enabled or disabled. + + \sa enabled +*/ + +/*! + \property QGraphicsObject::visible + \brief whether the item is visible or not + + This property is declared in QGraphicsItem. + + By default, this property is true. + + \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible(), visibleChanged() +*/ + +/*! + \fn QGraphicsObject::visibleChanged() + + This signal gets emitted whenever the visibility of the item changes + + \sa visible +*/ + + + +/*! \class QAbstractGraphicsShapeItem \brief The QAbstractGraphicsShapeItem class provides a common base for all path items. @@ -8148,17 +8282,6 @@ public: }; -QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) - : QGraphicsItem(parent) -{ -} - -QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsItem(dd, parent, scene) -{ -} - - /*! Constructs a QGraphicsTextItem, using \a text as the default plain text. \a parent is passed to QGraphicsItem's constructor. diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 69aab20..a5ccef2 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -63,6 +63,7 @@ class QBrush; class QCursor; class QFocusEvent; class QGraphicsItemGroup; +class QGraphicsObject; class QGraphicsSceneContextMenuEvent; class QGraphicsSceneDragDropEvent; class QGraphicsSceneEvent; @@ -159,6 +160,9 @@ public: bool isWidget() const; bool isWindow() const; + QGraphicsObject *toGraphicsObject(); + const QGraphicsObject *toGraphicsObject() const; + QGraphicsItemGroup *group() const; void setGroup(QGraphicsItemGroup *group); @@ -484,6 +488,31 @@ inline QRectF QGraphicsItem::mapRectFromParent(qreal ax, qreal ay, qreal w, qrea inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal h) const { return mapRectFromScene(QRectF(ax, ay, w, h)); } + +class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsItem) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY positionChanged) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) +public: + QGraphicsObject(QGraphicsItem *parent = 0); + +Q_SIGNALS: + void opacityChanged(); + void visibleChanged(); + void enabledChanged(); + void positionChanged(); + +protected: + QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); +private: + friend class QGraphicsItem; +}; + + class QAbstractGraphicsShapeItemPrivate; class Q_GUI_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem { @@ -832,20 +861,6 @@ private: inline void QGraphicsPixmapItem::setOffset(qreal ax, qreal ay) { setOffset(QPointF(ax, ay)); } -class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible) -public: - QGraphicsObject(QGraphicsItem *parent = 0); -protected: - QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); -}; - class QGraphicsTextItemPrivate; class QTextDocument; class QTextCursor; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 5626867..0e6658c 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -149,6 +149,7 @@ public: dirtySceneTransform(1), geometryChanged(0), inDestructor(0), + isObject(0), globalStackingOrder(-1), q_ptr(0) { @@ -405,7 +406,8 @@ public: quint32 dirtySceneTransform : 1; quint32 geometryChanged : 1; quint32 inDestructor : 1; - quint32 unused : 15; // feel free to use + quint32 isObject : 1; + quint32 unused : 14; // feel free to use // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 84434db..419277d 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -170,87 +170,6 @@ QT_BEGIN_NAMESPACE */ /*! - \property QGraphicsWidget::enabled - \brief whether the item is enabled or not - - This property is declared in QGraphicsItem. - - By default, this property is true. - - \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled() -*/ - -/*! - \property QGraphicsWidget::visible - \brief whether the item is visible or not - - This property is declared in QGraphicsItem. - - By default, this property is true. - - \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible(), show(), - hide() -*/ - -/*! - \property QGraphicsWidget::opacity - \brief the opacity of the widget -*/ - -/*! - \property QGraphicsWidget::pos - \brief the position of the widget -*/ - -/*! - \property QGraphicsWidget::xRotation - \since 4.6 - \brief the rotation angle in degrees around the X axis -*/ - -/*! - \property QGraphicsWidget::yRotation - \since 4.6 - \brief the rotation angle in degrees around the Y axis -*/ - -/*! - \property QGraphicsWidget::zRotation - \since 4.6 - \brief the rotation angle in degrees around the Z axis -*/ - -/*! - \property QGraphicsWidget::xScale - \since 4.6 - \brief the scale factor on the X axis. -*/ - -/*! - \property QGraphicsWidget::yScale - \since 4.6 - \brief the scale factor on the Y axis. -*/ - -/*! - \property QGraphicsWidget::horizontalShear - \since 4.6 - \brief the horizontal shear. -*/ - -/*! - \property QGraphicsWidget::verticalShear - \since 4.6 - \brief the vertical shear. -*/ - -/*! - \property QGraphicsWidget::transformOrigin - \since 4.6 - \brief the transformation origin for the transformation properties. -*/ - -/*! Constructs a QGraphicsWidget instance. The optional \a parent argument is passed to QGraphicsItem's constructor. The optional \a wFlags argument specifies the widget's window flags (e.g., whether the widget should be a -- cgit v0.12 From b3ff3392128c9c701b687887ef2c21b000209908 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 4 Jun 2009 14:38:05 +0200 Subject: added properties for x,y and z. Removed the notify for the pos property, add auto tests for QGraphicsObject FX items are better off with property notifications on each component rather than on the position. Added some basic testing for QGraphicsObject and fixed the failures exposed. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 47 +++- src/gui/graphicsview/qgraphicsitem.h | 13 +- src/gui/graphicsview/qgraphicswidget.h | 1 - tests/auto/auto.pro | 10 +- tests/auto/qgraphicsobject/qgraphicsobject.pro | 2 + tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp | 255 +++++++++++++++++++++ 6 files changed, 315 insertions(+), 13 deletions(-) create mode 100644 tests/auto/qgraphicsobject/qgraphicsobject.pro create mode 100644 tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 6d87c36..3622c82 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1789,6 +1789,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo // Deliver post-change notification. q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant); + + if (isObject) + emit static_cast(q_ptr)->visibleChanged(); } /*! @@ -1821,9 +1824,6 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo void QGraphicsItem::setVisible(bool visible) { d_ptr->setVisibleHelper(visible, /* explicit = */ true); - - if (d_ptr->isObject) - emit static_cast(this)->visibleChanged(); } /*! @@ -1912,6 +1912,9 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo // Deliver post-change notification. q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant); + + if (isObject) + emit static_cast(q_ptr)->enabledChanged(); } /*! @@ -1945,9 +1948,6 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo void QGraphicsItem::setEnabled(bool enabled) { d_ptr->setEnabledHelper(enabled, /* explicitly = */ true); - - if (d_ptr->isObject) - emit static_cast(this)->enabledChanged(); } /*! @@ -2110,6 +2110,7 @@ void QGraphicsItem::setOpacity(qreal opacity) /*maybeDirtyClipPath=*/false, /*force=*/false, /*ignoreOpacity=*/true); + if (d_ptr->isObject) emit static_cast(this)->opacityChanged(); } @@ -2520,6 +2521,17 @@ QPointF QGraphicsItem::pos() const \sa y() */ +/* + Set's the x coordinate of the item's position. Equivalent to + calling setPos(x, y()). + + \sa x(), setPos() +*/ +void QGraphicsItem::setX(qreal x) +{ + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); +} + /*! \fn QGraphicsItem::y() const @@ -2528,6 +2540,17 @@ QPointF QGraphicsItem::pos() const \sa x() */ +/* + Set's the y coordinate of the item's position. Equivalent to + calling setPos(x(), y). + + \sa x(), setPos() +*/ +void QGraphicsItem::setY(qreal y) +{ + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); +} + /*! Returns the item's position in scene coordinates. This is equivalent to calling \c mapToScene(0, 0). @@ -2551,11 +2574,16 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) updateCachedClipPathFromSetPosHelper(pos); if (scene) q->prepareGeometryChange(); + QPointF oldPos = this->pos; this->pos = pos; dirtySceneTransform = 1; inSetPosHelper = 0; - if (isObject) - emit static_cast(q)->positionChanged(); + if (isObject) { + if (pos.x() != oldPos.x()) + emit static_cast(q_ptr)->xChanged(); + if (pos.y() != oldPos.y()) + emit static_cast(q_ptr)->yChanged(); + } } /*! @@ -3535,6 +3563,9 @@ void QGraphicsItem::setZValue(qreal z) } itemChange(ItemZValueHasChanged, newZVariant); + + if (d_ptr->isObject) + emit static_cast(this)->zChanged(); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index a5ccef2..a69eced 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -227,7 +227,9 @@ public: // Positioning in scene coordinates QPointF pos() const; inline qreal x() const { return pos().x(); } + void setX(qreal x); inline qreal y() const { return pos().y(); } + void setY(qreal y); QPointF scenePos() const; void setPos(const QPointF &pos); inline void setPos(qreal x, qreal y); @@ -492,11 +494,13 @@ inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem { Q_OBJECT - Q_INTERFACES(QGraphicsItem) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) - Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY positionChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) + Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged) public: QGraphicsObject(QGraphicsItem *parent = 0); @@ -504,12 +508,15 @@ Q_SIGNALS: void opacityChanged(); void visibleChanged(); void enabledChanged(); - void positionChanged(); + void xChanged(); + void yChanged(); + void zChanged(); protected: QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); private: friend class QGraphicsItem; + friend class QGraphicsItemPrivate; }; diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index e19513d..337490c 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -69,7 +69,6 @@ class QGraphicsWidgetPrivate; class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem { Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) Q_PROPERTY(QPalette palette READ palette WRITE setPalette) Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a65c172..d5803bc 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -141,9 +141,17 @@ SUBDIRS += _networkselftest \ qglobal \ qgraphicsitem \ qgraphicsitemanimation \ + qgraphicslayout \ + qgraphicslayoutitem \ + qgraphicslinearlayout \ + qgraphicsobject \ + qgraphicspixmapitem \ + qgraphicspolygonitem \ + qgraphicsproxywidget \ qgraphicsscene \ qgraphicsview \ - qgridlayout \ + qgraphicswidget \ + qgridlayout \ qgroupbox \ qguivariant \ qhash \ diff --git a/tests/auto/qgraphicsobject/qgraphicsobject.pro b/tests/auto/qgraphicsobject/qgraphicsobject.pro new file mode 100644 index 0000000..965b319 --- /dev/null +++ b/tests/auto/qgraphicsobject/qgraphicsobject.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qgraphicsobject.cpp diff --git a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp new file mode 100644 index 0000000..eb12c48 --- /dev/null +++ b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_QGraphicsObject : public QObject { + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void pos(); + void x(); + void y(); + void z(); + void opacity(); + void enabled(); + void visible(); +}; + + +// This will be called before the first test function is executed. +// It is only called once. +void tst_QGraphicsObject::initTestCase() +{ +} + +// This will be called after the last test function is executed. +// It is only called once. +void tst_QGraphicsObject::cleanupTestCase() +{ +} + +// This will be called before each test function is executed. +void tst_QGraphicsObject::init() +{ +} + +// This will be called after every test function. +void tst_QGraphicsObject::cleanup() +{ +} + + +class MyGraphicsObject : public QGraphicsObject +{ +public: + MyGraphicsObject() : QGraphicsObject() {} + virtual QRectF boundingRect() const { return QRectF(); } + virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {} +}; + +void tst_QGraphicsObject::pos() +{ + MyGraphicsObject object; + QSignalSpy xSpy(&object, SIGNAL(xChanged())); + QSignalSpy ySpy(&object, SIGNAL(yChanged())); + QVERIFY(object.pos() == QPointF(0, 0)); + object.setPos(10, 10); + QCOMPARE(xSpy.count(), 1); + QCOMPARE(ySpy.count(), 1); + + QVERIFY(object.pos() == QPointF(10,10)); + + object.setPos(10, 10); + QCOMPARE(xSpy.count(), 1); + QCOMPARE(ySpy.count(), 1); + + object.setProperty("pos", QPointF(0, 0)); + QCOMPARE(xSpy.count(), 2); + QCOMPARE(ySpy.count(), 2); + QVERIFY(object.property("pos") == QPointF(0,0)); + + object.setProperty("pos", QPointF(10, 0)); + QCOMPARE(xSpy.count(), 3); + QCOMPARE(ySpy.count(), 2); + QVERIFY(object.property("pos") == QPointF(10,0)); + + object.setProperty("pos", QPointF(10, 10)); + QCOMPARE(xSpy.count(), 3); + QCOMPARE(ySpy.count(), 3); + QVERIFY(object.property("pos") == QPointF(10, 10)); +} + +void tst_QGraphicsObject::x() +{ + MyGraphicsObject object; + QSignalSpy xSpy(&object, SIGNAL(xChanged())); + QSignalSpy ySpy(&object, SIGNAL(yChanged())); + QVERIFY(object.pos() == QPointF(0, 0)); + object.setX(10); + QCOMPARE(xSpy.count(), 1); + QCOMPARE(ySpy.count(), 0); + + QVERIFY(object.pos() == QPointF(10, 0)); + QVERIFY(object.x() == 10); + + object.setX(10); + QCOMPARE(xSpy.count(), 1); + QCOMPARE(ySpy.count(), 0); + + object.setProperty("x", 0); + QCOMPARE(xSpy.count(), 2); + QCOMPARE(ySpy.count(), 0); + QVERIFY(object.property("x") == 0); +} + +void tst_QGraphicsObject::y() +{ + MyGraphicsObject object; + QSignalSpy xSpy(&object, SIGNAL(xChanged())); + QSignalSpy ySpy(&object, SIGNAL(yChanged())); + QVERIFY(object.pos() == QPointF(0, 0)); + object.setY(10); + QCOMPARE(xSpy.count(), 0); + QCOMPARE(ySpy.count(), 1); + + QVERIFY(object.pos() == QPointF(0, 10)); + QVERIFY(object.y() == 10); + + object.setY(10); + QCOMPARE(xSpy.count(), 0); + QCOMPARE(ySpy.count(), 1); + + object.setProperty("y", 0); + QCOMPARE(xSpy.count(), 0); + QCOMPARE(ySpy.count(), 2); + QVERIFY(object.property("y") == 0); +} + +void tst_QGraphicsObject::z() +{ + MyGraphicsObject object; + QSignalSpy zSpy(&object, SIGNAL(zChanged())); + QVERIFY(object.zValue() == 0); + object.setZValue(10); + QCOMPARE(zSpy.count(), 1); + + QVERIFY(object.zValue() == 10); + + object.setZValue(10); + QCOMPARE(zSpy.count(), 1); + + object.setProperty("z", 0); + QCOMPARE(zSpy.count(), 2); + QVERIFY(object.property("z") == 0); +} + +void tst_QGraphicsObject::opacity() +{ + MyGraphicsObject object; + QSignalSpy spy(&object, SIGNAL(opacityChanged())); + QVERIFY(object.opacity() == 1.); + object.setOpacity(0); + QCOMPARE(spy.count(), 1); + + QVERIFY(object.opacity() == 0.); + + object.setOpacity(0); + QCOMPARE(spy.count(), 1); + + object.setProperty("opacity", .5); + QCOMPARE(spy.count(), 2); + QVERIFY(object.property("opacity") == .5); +} + +void tst_QGraphicsObject::enabled() +{ + MyGraphicsObject object; + QSignalSpy spy(&object, SIGNAL(enabledChanged())); + QVERIFY(object.isEnabled() == true); + object.setEnabled(false); + QCOMPARE(spy.count(), 1); + + QVERIFY(object.isEnabled() == false); + + object.setEnabled(false); + QCOMPARE(spy.count(), 1); + + object.setProperty("enabled", true); + QCOMPARE(spy.count(), 2); + QVERIFY(object.property("enabled") == true); +} + +void tst_QGraphicsObject::visible() +{ + MyGraphicsObject object; + QSignalSpy spy(&object, SIGNAL(visibleChanged())); + QVERIFY(object.isVisible() == true); + object.setVisible(false); + QCOMPARE(spy.count(), 1); + + QVERIFY(object.isVisible() == false); + + object.setVisible(false); + QCOMPARE(spy.count(), 1); + + object.setProperty("visible", true); + QCOMPARE(spy.count(), 2); + QVERIFY(object.property("visible") == true); +} + + +QTEST_MAIN(tst_QGraphicsObject) +#include "tst_qgraphicsobject.moc" + -- cgit v0.12 From 15366ae05397cdf322e0a34e729eb5db2bae9c2a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 8 Jun 2009 10:18:59 +0200 Subject: add parent and id properties to QGraphicsObject In addition added documentation for the other properties. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 73 +++++++++++++++++++++++++++++++++- src/gui/graphicsview/qgraphicsitem.h | 6 ++- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3622c82..0390a83 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -959,6 +959,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) // Deliver post-change notification q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant); + + if (isObject) + emit static_cast(q)->parentChanged(); } /*! @@ -1213,6 +1216,20 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const /*! \since 4.4 + Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item + is not a QGraphicsObject. + + \sa parentItem(), childItems() +*/ +QGraphicsObject *QGraphicsItem::parentObject() const +{ + QGraphicsItem *p = d_ptr->parent; + return (p && p->d_ptr->isObject) ? static_cast(p) : 0; +} + +/*! + \since 4.4 + Returns a pointer to the item's parent widget. The item's parent widget is the closest parent item that is a widget. @@ -6417,6 +6434,14 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent } /*! + \property QGraphicsObject::parent + \brief the parent of the item + + \sa QGraphicsItem::setParentItem, QGraphicsItem::parentObject +*/ + + +/*! \property QGraphicsObject::opacity \brief the opacity of the item @@ -6441,13 +6466,57 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent */ /*! - \fn QGraphicsObject::positionChanged() + \property QGraphicsObject::x + \brief the x position of the item + + Describes the items x position. + + \sa QGraphicsItem::setX, setPos, xChanged +*/ + +/*! + \fn QGraphicsObject::xChanged() + + This signal gets emitted whenever the x position of the item changes + + \sa pos +*/ + +/*! + \property QGraphicsObject:y + \brief the y position of the item + + Describes the items y position. + + \sa QGraphicsItem::setY, setPos, yChanged +*/ + +/*! + \fn QGraphicsObject::yChanged() + + This signal gets emitted whenever the y position of the item changes + + \sa pos +*/ + +/*! + \property QGraphicsObject::z + \brief the z value of the item - This signal gets emitted whenever the position of the item changes + Describes the items z value. + + \sa QGraphicsItem::setZValue, zValue, zChanged +*/ + +/*! + \fn QGraphicsObject::zChanged() + + This signal gets emitted whenever the z value of the item changes \sa pos */ + /*! \property QGraphicsObject::enabled \brief whether the item is enabled or not diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index a69eced..6ea17c2 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -151,6 +151,7 @@ public: QGraphicsItem *parentItem() const; QGraphicsItem *topLevelItem() const; + QGraphicsObject *parentObject() const; QGraphicsWidget *parentWidget() const; QGraphicsWidget *topLevelWidget() const; QGraphicsWidget *window() const; @@ -494,10 +495,12 @@ inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem { Q_OBJECT + Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) + Q_PROPERTY(QString id READ objectName WRITE setObjectName) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged) @@ -505,6 +508,7 @@ public: QGraphicsObject(QGraphicsItem *parent = 0); Q_SIGNALS: + void parentChanged(); void opacityChanged(); void visibleChanged(); void enabledChanged(); -- cgit v0.12 From a6eac57ee46c150aabd5cff331d6859e7999680f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 10 Jun 2009 18:41:41 +0200 Subject: Autotest compile. This one is for qstandarditemmodel autotest --- src/gui/itemviews/qabstractitemview_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 139d0b7..8594ad7 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -99,7 +99,7 @@ public: QVariant data(const QModelIndex &, int) const { return QVariant(); } }; -class QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate +class Q_AUTOTEST_EXPORT QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate { Q_DECLARE_PUBLIC(QAbstractItemView) -- cgit v0.12 From e0be99974d5d66f548543df9b5b919c8e81ade62 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 10 Jun 2009 18:42:35 +0200 Subject: Invalid QPersistentIndexes after QStandardItem::takeRow We need the parent of each potential QPersistentModelIndex in order to cleanup when removing the rows. They need not to change in order QSortFilterProxyModel maping to be still valid. takeRow must not change the internal data before calling beginRemoveRow. Same thing for takeColumn Task-number: 255652 Reviewed-by: Thierry Reviewed-by: Leo --- src/gui/itemviews/qstandarditemmodel.cpp | 36 ++++---- .../tst_qsortfilterproxymodel.cpp | 99 +++++++++++++++++----- .../qstandarditemmodel/tst_qstandarditemmodel.cpp | 49 ++++++++++- 3 files changed, 148 insertions(+), 36 deletions(-) diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index 9d0f796..30daed2 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -1742,18 +1742,21 @@ QList QStandardItem::takeRow(int row) Q_D(QStandardItem); if ((row < 0) || (row >= rowCount())) return QList(); + if (d->model) + d->model->d_func()->rowsAboutToBeRemoved(this, row, row); QList items; int index = d->childIndex(row, 0); - for (int column = 0; column < d->columnCount(); ++column) { - QStandardItem *ch = d->children.at(index); - if (ch) { + int col_count = d->columnCount(); + for (int column = 0; column < col_count; ++column) { + QStandardItem *ch = d->children.at(index + column); + if (ch) ch->d_func()->setParentAndModel(0, 0); - d->children.replace(index, 0); - } items.append(ch); - ++index; } - removeRow(row); + d->children.remove(index, col_count); + d->rows--; + if (d->model) + d->model->d_func()->rowsRemoved(this, row, 1); return items; } @@ -1769,18 +1772,21 @@ QList QStandardItem::takeColumn(int column) Q_D(QStandardItem); if ((column < 0) || (column >= columnCount())) return QList(); + if (d->model) + d->model->d_func()->columnsAboutToBeRemoved(this, column, column); QList items; - int index = d->childIndex(0, column); - for (int row = 0; row < d->rowCount(); ++row) { + + for (int row = d->rowCount() - 1; row >= 0; --row) { + int index = d->childIndex(row, column); QStandardItem *ch = d->children.at(index); - if (ch) { + if (ch) ch->d_func()->setParentAndModel(0, 0); - d->children.replace(index, 0); - } - items.append(ch); - index += d->columnCount(); + d->children.remove(index); + items.prepend(ch); } - removeColumn(column); + d->columns--; + if (d->model) + d->model->d_func()->columnsRemoved(this, column, 1); return items; } diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index d7c231f..274b177 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -134,6 +134,7 @@ private slots: void task250023_fetchMore(); void task251296_hiddenChildren(); void task252507_mapFromToSource(); + void task255652_removeRowsRecursive(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -390,7 +391,7 @@ void tst_QSortFilterProxyModel::sort() QModelIndex index = m_proxy->index(row, 0, QModelIndex()); QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row)); } - + } void tst_QSortFilterProxyModel::sortHierarchy_data() @@ -411,7 +412,7 @@ void tst_QSortFilterProxyModel::sortHierarchy_data() << static_cast(Qt::AscendingOrder) << (QStringList() << "a" << "<" << "b" << "<" << "c" << ">" << ">") << (QStringList() << "a" << "<" << "b" << "<" << "c" << ">" << ">"); - + #if 1 QTest::newRow("hierarchical ascending") << static_cast(Qt::AscendingOrder) @@ -571,7 +572,7 @@ void tst_QSortFilterProxyModel::insertRows() QModelIndex index = m_proxy->index(row, 0, QModelIndex()); QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row)); } - + // insert the row m_proxy->insertRows(position, insert.count(), QModelIndex()); QCOMPARE(m_model->rowCount(QModelIndex()), expected.count()); @@ -615,7 +616,7 @@ void tst_QSortFilterProxyModel::prependRow() QStandardItem sub2("sub2"); sub2.appendRow(new QStandardItem("sub3")); item.insertRow(0, &sub2); - + QModelIndex index_sub2 = proxy.mapFromSource(model.indexFromItem(&sub2)); QCOMPARE(sub2.rowCount(), proxy.rowCount(index_sub2)); @@ -626,7 +627,7 @@ void tst_QSortFilterProxyModel::prependRow() /* void tst_QSortFilterProxyModel::insertColumns_data() { - + } void tst_QSortFilterProxyModel::insertColumns() @@ -923,7 +924,7 @@ void tst_QSortFilterProxyModel::removeRows() // prepare model foreach (QString s, initial) model.appendRow(new QStandardItem(s)); - + // remove the rows QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success); QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count()); @@ -1164,10 +1165,10 @@ void tst_QSortFilterProxyModel::removeColumns() proxy.setSourceModel(&model); if (!filter.isEmpty()) proxy.setFilterRegExp(QRegExp(filter)); - + // prepare model model.setHorizontalHeaderLabels(initial); - + // remove the columns QCOMPARE(proxy.removeColumns(position, count, QModelIndex()), success); QCOMPARE(model.columnCount(QModelIndex()), expectedSource.count()); @@ -1266,7 +1267,7 @@ void tst_QSortFilterProxyModel::filter_data() << "golf" << "quebec" << "foxtrot" - << "india" + << "india" << "romeo" << "november" << "oskar" @@ -1274,9 +1275,9 @@ void tst_QSortFilterProxyModel::filter_data() << "kilo" << "whiskey" << "mike" - << "papa" + << "papa" << "sierra" - << "xray" + << "xray" << "viktor") << (QStringList() << "delta" @@ -1334,7 +1335,7 @@ void tst_QSortFilterProxyModel::filterHierarchy_data() << "foo" << "boo" << "baz" << "moo" << "laa" << "haa") << (QStringList() << "foo" << "boo" << "moo"); - + QTest::newRow("simple hierarchy") << "b.*z" << (QStringList() << "baz" << "<" << "boz" << "<" << "moo" << ">" << ">") << (QStringList() << "baz" << "<" << "boz" << ">"); @@ -1671,7 +1672,7 @@ void tst_QSortFilterProxyModel::removeSourceRows() QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int))); QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int))); QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int))); - + model.removeRows(start, count, QModelIndex()); QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count()); @@ -1827,7 +1828,7 @@ void tst_QSortFilterProxyModel::changeFilter() QFETCH(IntPairList, finalRemoveIntervals); QFETCH(IntPairList, insertIntervals); QFETCH(QStringList, finalProxyItems); - + QStandardItemModel model; QSortFilterProxyModel proxy; @@ -1880,7 +1881,7 @@ void tst_QSortFilterProxyModel::changeFilter() #ifdef Q_OS_IRIX QEXPECT_FAIL("filter (2)", "Not reliable on IRIX", Abort); -#endif +#endif QCOMPARE(finalInsertSpy.count(), insertIntervals.count()); for (int i = 0; i < finalInsertSpy.count(); ++i) { QList args = finalInsertSpy.at(i); @@ -2068,7 +2069,7 @@ void tst_QSortFilterProxyModel::sortFilterRole() model.setData(index, sourceItems.at(i).first, Qt::DisplayRole); model.setData(index, sourceItems.at(i).second, Qt::UserRole); } - + proxy.setFilterRegExp("2"); QCOMPARE(proxy.rowCount(), 0); // Qt::DisplayRole is default role @@ -2358,7 +2359,7 @@ void tst_QSortFilterProxyModel::sourceInsertRows() model.insertColumns(0, 1, parent); model.insertRows(0, 1, parent); } - + model.insertRows(0, 1, QModelIndex()); model.insertRows(0, 1, QModelIndex()); @@ -2462,7 +2463,7 @@ void tst_QSortFilterProxyModel::task236755_hiddenColumns() QVERIFY(view.isColumnHidden(0)); } -void tst_QSortFilterProxyModel::task247867_insertRowsSort() +void tst_QSortFilterProxyModel::task247867_insertRowsSort() { QStandardItemModel model(2,2); QSortFilterProxyModel proxyModel; @@ -2567,7 +2568,7 @@ void tst_QSortFilterProxyModel::task248868_dynamicSorting() QStringList initial2 = initial; initial2.replaceInStrings("bateau", "girafe"); model1.setStringList(initial2); //this will cause a reset - + QStringList expected2 = initial2; expected2.sort(); @@ -2648,7 +2649,7 @@ class QtTestModel: public QAbstractItemModel { if (!idx.isValid()) return QVariant(); - + if (role == Qt::DisplayRole) { if (idx.row() < 0 || idx.column() < 0 || idx.column() >= cols || idx.row() >= rows) { wrongIndex = true; @@ -2756,5 +2757,63 @@ void tst_QSortFilterProxyModel::task252507_mapFromToSource() QCOMPARE(proxy.mapFromSource(proxy.index(6, 2)), QModelIndex()); } +static QStandardItem *addEntry(QStandardItem* pParent, const QString &description) +{ + QStandardItem* pItem = new QStandardItem(description); + pParent->appendRow(pItem); + return pItem; +} + + +void tst_QSortFilterProxyModel::task255652_removeRowsRecursive() +{ + QStandardItemModel pModel; + QStandardItem *pItem1 = new QStandardItem("root"); + pModel.appendRow(pItem1); + QList items; + + QStandardItem *pItem11 = addEntry(pItem1,"Sub-heading"); + items << pItem11; + QStandardItem *pItem111 = addEntry(pItem11,"A"); + items << pItem111; + items << addEntry(pItem111,"A1"); + items << addEntry(pItem111,"A2"); + QStandardItem *pItem112 = addEntry(pItem11,"B"); + items << pItem112; + items << addEntry(pItem112,"B1"); + items << addEntry(pItem112,"B2"); + QStandardItem *pItem1123 = addEntry(pItem112,"B3"); + items << pItem1123; + items << addEntry(pItem1123,"B3-"); + + QSortFilterProxyModel proxy; + proxy.setSourceModel(&pModel); + + QList sourceIndexes; + QList proxyIndexes; + foreach (QStandardItem *item, items) { + QModelIndex idx = item->index(); + sourceIndexes << idx; + proxyIndexes << proxy.mapFromSource(idx); + } + + foreach (const QPersistentModelIndex &pidx, sourceIndexes) + QVERIFY(pidx.isValid()); + foreach (const QPersistentModelIndex &pidx, proxyIndexes) + QVERIFY(pidx.isValid()); + + QList itemRow = pItem1->takeRow(0); + + QCOMPARE(itemRow.count(), 1); + QCOMPARE(itemRow.first(), pItem11); + + foreach (const QPersistentModelIndex &pidx, sourceIndexes) + QVERIFY(!pidx.isValid()); + foreach (const QPersistentModelIndex &pidx, proxyIndexes) + QVERIFY(!pidx.isValid()); + + delete pItem11; +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp index 84bda92..8067554 100644 --- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -135,6 +135,7 @@ private slots: void rootItemFlags(); void treeDragAndDrop(); + void removeRowsAndColumns(); private: QAbstractItemModel *m_model; @@ -1403,7 +1404,7 @@ bool tst_QStandardItemModel::compareItems(QStandardItem *item1, QStandardItem *i return true; if (!item1 || !item2) return false; - if (item1->text() != item2->text()){ + if (item1->text() != item2->text()){ qDebug() << item1->text() << item2->text(); return false; } @@ -1606,6 +1607,52 @@ void tst_QStandardItemModel::treeDragAndDrop() } } +void tst_QStandardItemModel::removeRowsAndColumns() +{ +#define VERIFY_MODEL \ + for (int c = 0; c < col_list.count(); c++) \ + for (int r = 0; r < row_list.count(); r++) \ + QCOMPARE(model.item(r,c)->text() , row_list[r] + "x" + col_list[c]); + + QVector row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector(); + QVector col_list = row_list; + QStandardItemModel model; + for (int c = 0; c < col_list.count(); c++) + for (int r = 0; r < row_list.count(); r++) + model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c])); + VERIFY_MODEL + + row_list.remove(3); + model.removeRow(3); + VERIFY_MODEL + + col_list.remove(5); + model.removeColumn(5); + VERIFY_MODEL + + row_list.remove(2, 5); + model.removeRows(2, 5); + VERIFY_MODEL + + col_list.remove(1, 6); + model.removeColumns(1, 6); + VERIFY_MODEL + + QList row_taken = model.takeRow(6); + QCOMPARE(row_taken.count(), col_list.count()); + for (int c = 0; c < col_list.count(); c++) + QCOMPARE(row_taken[c]->text() , row_list[6] + "x" + col_list[c]); + row_list.remove(6); + VERIFY_MODEL + + QList col_taken = model.takeColumn(10); + QCOMPARE(col_taken.count(), row_list.count()); + for (int r = 0; r < row_list.count(); r++) + QCOMPARE(col_taken[r]->text() , row_list[r] + "x" + col_list[10]); + col_list.remove(10); + VERIFY_MODEL +} + QTEST_MAIN(tst_QStandardItemModel) #include "tst_qstandarditemmodel.moc" -- cgit v0.12 From 0295d0aa5111f31eec8dd8109b4df6389f4efbce Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 11 Jun 2009 11:02:11 +0200 Subject: Clean up qwidget_p.h since the last change Reviewed-by: bnilsen Reviewed-by: Denis --- src/gui/kernel/qwidget_p.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index ff194f7..2bc4da6 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -131,10 +131,6 @@ struct QTLWExtra { uint embedded : 1; // *************************** Platform specific values (bit fields first) ********** -#ifndef QT_NO_XSYNC - int newCounterValueHi : 32; - uint newCounterValueLo : 32; -#endif #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 uint spont_unmapped: 1; // window was spontaneously unmapped uint dnd : 1; // DND properties installed @@ -143,6 +139,12 @@ struct QTLWExtra { WId parentWinId; // parent window Id (valid after reparenting) WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom QPoint fullScreenOffset; +#ifndef QT_NO_XSYNC + WId syncUpdateCounter; + ulong syncRequestTimestamp; + qint32 newCounterValueHi; + quint32 newCounterValueLo; +#endif #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN HICON winIconBig; // internal big Windows icon HICON winIconSmall; // internal small Windows icon @@ -160,10 +162,6 @@ struct QTLWExtra { QWSManager *qwsManager; #endif #endif -#ifndef QT_NO_XSYNC - WId syncUpdateCounter; - ulong syncRequestTimestamp; -#endif }; struct QWExtra { -- cgit v0.12 From 713e52d9531277b8c13856246701729de16d4502 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 11 Jun 2009 11:11:46 +0200 Subject: Only include QMetaType if required in moc generated files Including it might cause build errors. (and thus break source compatibility) The problem was seen on KDE where some cpp files included x11 headers and then later included the .moc file, then qmetatype.h complains that Bool is defined Reviewed-by: Brad --- src/tools/moc/moc.cpp | 8 ++++++-- src/tools/moc/moc.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 4629ac5..a1738a5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -767,7 +767,8 @@ void Moc::generate(FILE *out) if (classList.size() && classList.first().classname == "Qt") fprintf(out, "#include \n"); - fprintf(out, "#include \n"); + if (mustIncludeQMetaTypeH) + fprintf(out, "#include \n"); fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n" "#error \"The header file '%s' doesn't include .\"\n", (const char *)fn); @@ -900,6 +901,9 @@ void Moc::parseProperty(ClassDef *def) type = "qlonglong"; else if (type == "ULongLong") type = "qulonglong"; + else if (type == "qreal") + mustIncludeQMetaTypeH = true; + propDef.type = type; next(); @@ -961,7 +965,7 @@ void Moc::parseProperty(ClassDef *def) msg += " has no READ accessor function. The property will be invalid."; warning(msg.constData()); } - if(!propDef.notify.isEmpty()) + if(!propDef.notify.isEmpty()) def->notifyableProperties++; def->propertyList += propDef; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 689104c..4a1dee9 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -177,13 +177,14 @@ class Moc : public Parser { public: Moc() - : noInclude(false), generatedCode(false) + : noInclude(false), generatedCode(false), mustIncludeQMetaTypeH(false) {} QByteArray filename; bool noInclude; bool generatedCode; + bool mustIncludeQMetaTypeH; QByteArray includePath; QList includeFiles; QList classList; -- cgit v0.12 From f20f242c7d45ad675c6d955628d318ffecdfe517 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 11 Jun 2009 12:07:50 +0200 Subject: Make sure custom arrow images works if we only specify it. Include change for spinbox, combobox, and menu. Task-number: 255849 Tested-by: Pierre Reviewed-by: jbache --- src/gui/styles/qstylesheetstyle.cpp | 18 ++- .../uiloader/baseline/css_task255849_downarrow.ui | 144 +++++++++++++++++++++ tests/auto/uiloader/baseline/images/arrow-down.png | Bin 0 -> 1006 bytes tests/auto/uiloader/baseline/images/arrow-up.png | Bin 0 -> 927 bytes 4 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 tests/auto/uiloader/baseline/css_task255849_downarrow.ui create mode 100644 tests/auto/uiloader/baseline/images/arrow-down.png create mode 100644 tests/auto/uiloader/baseline/images/arrow-up.png diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 9a8f97e..fe0e53c 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -2850,7 +2850,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawBackgroundImage(p, cmbOpt.rect); rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button); bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow) - && hasStyleRule(w, PseudoElement_ComboBoxDropDown); + && (hasStyleRule(w, PseudoElement_ComboBoxDropDown) || hasStyleRule(w, PseudoElement_ComboBoxArrow)); if (customDropDown) cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow; if (rule.baseStyleCanDraw()) { @@ -2896,11 +2896,11 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) { rule.drawBackgroundImage(p, spinOpt.rect); customUp = (opt->subControls & QStyle::SC_SpinBoxUp) - && hasStyleRule(w, PseudoElement_SpinBoxUpButton); + && (hasStyleRule(w, PseudoElement_SpinBoxUpButton) || hasStyleRule(w, PseudoElement_UpArrow)); if (customUp) spinOpt.subControls &= ~QStyle::SC_SpinBoxUp; customDown = (opt->subControls & QStyle::SC_SpinBoxDown) - && hasStyleRule(w, PseudoElement_SpinBoxDownButton); + && (hasStyleRule(w, PseudoElement_SpinBoxDownButton) || hasStyleRule(w, PseudoElement_DownArrow)); if (customDown) spinOpt.subControls &= ~QStyle::SC_SpinBoxDown; if (rule.baseStyleCanDraw()) { @@ -3573,7 +3573,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction); drawPrimitive(arrow, &mi, p, w); } - } else if (hasStyleRule(w, PseudoElement_MenuCheckMark)) { + } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) { QWindowsStyle::drawControl(ce, &mi, p, w); } else { if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) { @@ -4339,6 +4339,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op pseudoElement = PseudoElement_ScrollAreaCorner; break; + case PE_IndicatorSpinDown: + case PE_IndicatorSpinMinus: + pseudoElement = PseudoElement_SpinBoxDownArrow; + break; + + case PE_IndicatorSpinUp: + case PE_IndicatorSpinPlus: + pseudoElement = PseudoElement_SpinBoxUpArrow; + break; + default: break; } diff --git a/tests/auto/uiloader/baseline/css_task255849_downarrow.ui b/tests/auto/uiloader/baseline/css_task255849_downarrow.ui new file mode 100644 index 0000000..d3e99b1 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_task255849_downarrow.ui @@ -0,0 +1,144 @@ + + + Form + + + + 0 + 0 + 275 + 175 + + + + Form + + + /* Some widget were not displaying the arrow if only the arrow was set */ +*::down-arrow { image: url("images/arrow-down.png") } +*::up-arrow { image: url("images/arrow-up.png") } + + + + + + + + + + + + true + + + true + + + true + + + + 1 + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + + + + + + + foo + + + Qt::DownArrow + + + + + + + + + + Qt::NoContextMenu + + + PushButton + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/tests/auto/uiloader/baseline/images/arrow-down.png b/tests/auto/uiloader/baseline/images/arrow-down.png new file mode 100644 index 0000000..7c9274f Binary files /dev/null and b/tests/auto/uiloader/baseline/images/arrow-down.png differ diff --git a/tests/auto/uiloader/baseline/images/arrow-up.png b/tests/auto/uiloader/baseline/images/arrow-up.png new file mode 100644 index 0000000..758a0d1 Binary files /dev/null and b/tests/auto/uiloader/baseline/images/arrow-up.png differ -- cgit v0.12 From 0ba0f0ceba0aa9469d965bd97d1cb5f738504ebb Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 11 Jun 2009 12:18:17 +0200 Subject: QHttpNetworkConnection: Some renamings Reviewed-by: Prasanth --- src/network/access/qhttpnetworkconnection.cpp | 20 ++++++++++---------- src/network/access/qhttpnetworkconnection_p.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 43fbb16..741a9a5 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -468,7 +468,7 @@ bool QHttpNetworkConnectionPrivate::sendRequest(QAbstractSocket *socket) return true; } -bool QHttpNetworkConnectionPrivate::emitSignals(QHttpNetworkReply *reply) +bool QHttpNetworkConnectionPrivate::shouldEmitSignals(QHttpNetworkReply *reply) { // for 401 & 407 don't emit the data signals. Content along with these // responses are send only if the authentication fails. @@ -484,7 +484,7 @@ bool QHttpNetworkConnectionPrivate::expectContent(QHttpNetworkReply *reply) || reply->d_func()->statusCode == 204 || reply->d_func()->statusCode == 304) return false; if (reply->d_func()->request.operation() == QHttpNetworkRequest::Head) - return !emitSignals(reply); + return !shouldEmitSignals(reply); if (reply->d_func()->contentLength() == 0) return false; return true; @@ -528,7 +528,7 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); appendData(*reply, inflated, false); - if (emitSignals(reply)) { + if (shouldEmitSignals(reply)) { emit reply->readyRead(); // make sure that the reply is valid if (channels[i].reply != reply) @@ -613,7 +613,7 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState; break; // ignore } - if (emitSignals(reply)) + if (shouldEmitSignals(reply)) emit reply->headerChanged(); if (!expectContent(reply)) { reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; @@ -631,7 +631,7 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN appendData(*reply, fragment.data(), reply->d_func()->autoDecompress); if (!reply->d_func()->autoDecompress) { reply->d_func()->totalProgress += fragment.size(); - if (emitSignals(reply)) { + if (shouldEmitSignals(reply)) { emit reply->readyRead(); // make sure that the reply is valid if (channels[i].reply != reply) @@ -673,7 +673,7 @@ void QHttpNetworkConnectionPrivate::allDone(QAbstractSocket *socket, QHttpNetwor expand(socket, reply, true); // ### if expand returns false, its an error #endif // while handling 401 & 407, we might reset the status code, so save this. - bool emitFinished = emitSignals(reply); + bool emitFinished = shouldEmitSignals(reply); handleStatus(socket, reply); // ### at this point there should be no more data on the socket // close if server requested @@ -828,7 +828,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket if (priv->phase != QAuthenticatorPrivate::Done) { // send any pending requests copyCredentials(i, auth, isProxy); - QMetaObject::invokeMethod(q, "_q_restartPendingRequest", Qt::QueuedConnection); + QMetaObject::invokeMethod(q, "_q_restartAuthPendingRequests", Qt::QueuedConnection); } } // changing values in QAuthenticator will reset the 'phase' @@ -907,7 +907,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor return reply; } -void QHttpNetworkConnectionPrivate::unqueueRequest(QAbstractSocket *socket) +void QHttpNetworkConnectionPrivate::unqueueAndSendRequest(QAbstractSocket *socket) { Q_ASSERT(socket); @@ -1112,10 +1112,10 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() if (!socket) { return; // this will be called after finishing current request. } - unqueueRequest(socket); + unqueueAndSendRequest(socket); } -void QHttpNetworkConnectionPrivate::_q_restartPendingRequest() +void QHttpNetworkConnectionPrivate::_q_restartAuthPendingRequests() { // send the request using the idle socket for (int i = 0 ; i < channelCount; ++i) { diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 9b127dd..4603a55 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -140,7 +140,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_readyRead()) Q_PRIVATE_SLOT(d_func(), void _q_disconnected()) Q_PRIVATE_SLOT(d_func(), void _q_startNextRequest()) - Q_PRIVATE_SLOT(d_func(), void _q_restartPendingRequest()) + Q_PRIVATE_SLOT(d_func(), void _q_restartAuthPendingRequests()) Q_PRIVATE_SLOT(d_func(), void _q_connected()) Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) #ifndef QT_NO_NETWORKPROXY @@ -189,7 +189,7 @@ public: bool isSocketReading(QAbstractSocket *socket) const; QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request); - void unqueueRequest(QAbstractSocket *socket); + void unqueueAndSendRequest(QAbstractSocket *socket); void prepareRequest(HttpMessagePair &request); bool sendRequest(QAbstractSocket *socket); void receiveReply(QAbstractSocket *socket, QHttpNetworkReply *reply); @@ -202,7 +202,7 @@ public: void _q_readyRead(); // pending data to read void _q_disconnected(); // disconnected from host void _q_startNextRequest(); // send the next request from the queue - void _q_restartPendingRequest(); // send the currently blocked request + void _q_restartAuthPendingRequests(); // send the currently blocked request void _q_connected(); // start sending request void _q_error(QAbstractSocket::SocketError); // error from socket #ifndef QT_NO_NETWORKPROXY @@ -261,7 +261,7 @@ public: bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend); void allDone(QAbstractSocket *socket, QHttpNetworkReply *reply); void handleStatus(QAbstractSocket *socket, QHttpNetworkReply *reply); - inline bool emitSignals(QHttpNetworkReply *reply); + inline bool shouldEmitSignals(QHttpNetworkReply *reply); inline bool expectContent(QHttpNetworkReply *reply); #ifndef QT_NO_OPENSSL @@ -283,9 +283,6 @@ public: QT_END_NAMESPACE -//Q_DECLARE_METATYPE(QHttpNetworkRequest) -//Q_DECLARE_METATYPE(QHttpNetworkReply) - #endif // QT_NO_HTTP #endif -- cgit v0.12 From 61569e83107e30deb671f37f29ca71989410d8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 11 Jun 2009 13:44:00 +0200 Subject: Make configure pass the -sdk option on to the configure tests. This makes sure that we only detect and use libraries that are actually in the SDK. Task-number: 109757 Reviewed-by: Richard Moe Gustavsen --- config.tests/unix/compile.test | 5 ++++ configure | 60 +++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index ff51c91..a854bd1 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -28,6 +28,11 @@ while [ "$#" -gt 0 ]; do MAC_ARCH_LFLAGS="$MAC_ARCH_LFLAGS -arch $2" shift ;; + -sdk) + LFLAGS="$LFLAGS -Wl,-syslibroot,$2" + CXXFLAGS="$CXXFLAGS -isysroot $2" + shift + ;; -F*|-m*|-x*) LFLAGS="$LFLAGS $PARAM" CXXFLAGS="$CXXFLAGS $PARAM" diff --git a/configure b/configure index 58ab08c..0a8b61a 100755 --- a/configure +++ b/configure @@ -668,7 +668,7 @@ CFG_INOTIFY=auto CFG_RPATH=yes CFG_FRAMEWORK=auto CFG_MAC_ARCHS= -MAC_ARCHS_COMMANDLINE= +MAC_CONFIG_TEST_COMMANDLINE= # used to make the configure tests run with the correct arch's and SDK settings CFG_MAC_DWARF2=auto CFG_MAC_XARCH=auto CFG_MAC_CARBON=yes @@ -2718,14 +2718,20 @@ if [ "$PLATFORM_MAC" = "yes" ]; then # These are synonymous values # CFG_MAC_ARCHS requires x86 while GCC requires i386 CFG_MAC_ARCHS="$CFG_MAC_ARCHS x86" - MAC_ARCHS_COMMANDLINE="$MAC_ARCHS_COMMANDLINE -arch i386" + MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -arch i386" else CFG_MAC_ARCHS="$CFG_MAC_ARCHS $i" - MAC_ARCHS_COMMANDLINE="$MAC_ARCHS_COMMANDLINE -arch $i" + MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -arch $i" fi done fi +# pass on $CFG_SDK to the configure tests. +if [ '!' -z "$CFG_SDK" ]; then + MAC_CONFIG_TEST_COMMANDLINE="-sdk $CFG_SDK" + echo "tests command line: $MAC_CONFIG_TEST_COMMANDLINE" +fi + # find the default framework value if [ "$PLATFORM_MAC" = "yes" ] && [ "$PLATFORM" != "macx-xlc" ]; then if [ "$CFG_FRAMEWORK" = "auto" ]; then @@ -4263,7 +4269,7 @@ if [ "$CFG_ZLIB" = "no" ]; then ZLIB_FORCED=yes fi if [ "$CFG_ZLIB" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_ZLIB=system else CFG_ZLIB=yes @@ -4280,7 +4286,7 @@ if [ "$CFG_JPEG" = "auto" ]; then fi # detect jpeg if [ "$CFG_LIBJPEG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_LIBJPEG=system else CFG_LIBJPEG=qt @@ -4307,7 +4313,7 @@ fi # detect tiff if [ "$CFG_LIBTIFF" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_LIBTIFF=system else CFG_LIBTIFF=qt @@ -4324,7 +4330,7 @@ if [ "$CFG_MNG" = "auto" ]; then fi # detect mng if [ "$CFG_LIBMNG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_LIBMNG=system else CFG_LIBMNG=qt @@ -4333,7 +4339,7 @@ fi # detect png if [ "$CFG_LIBPNG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_LIBPNG=system else CFG_LIBPNG=qt @@ -4372,13 +4378,13 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do QT_CFLAGS_MYSQL="" fi else - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then QMakeVar add CONFIG use_libmysqlclient_r if [ "$CFG_SQL_mysql" = "auto" ]; then CFG_SQL_mysql=plugin fi QT_LFLAGS_MYSQL="$QT_LFLAGS_MYSQL_R" - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_mysql" = "auto" ]; then CFG_SQL_mysql=plugin fi @@ -4407,7 +4413,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do fi [ -z "$QT_CFLAGS_PSQL" ] || QT_CFLAGS_PSQL="-I$QT_CFLAGS_PSQL" [ -z "$QT_LFLAGS_PSQL" ] || QT_LFLAGS_PSQL="-L$QT_LFLAGS_PSQL" - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_psql" = "auto" ]; then CFG_SQL_psql=plugin fi @@ -4428,12 +4434,12 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; odbc) if [ "$CFG_SQL_odbc" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_odbc" = "auto" ]; then CFG_SQL_odbc=plugin fi else - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iodbc "iODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iodbc "iODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then QT_LFLAGS_ODBC="-liodbc" if [ "$CFG_SQL_odbc" = "auto" ]; then CFG_SQL_odbc=plugin @@ -4454,7 +4460,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; oci) if [ "$CFG_SQL_oci" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_oci" = "auto" ]; then CFG_SQL_oci=plugin fi @@ -4473,7 +4479,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; tds) if [ "$CFG_SQL_tds" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_tds" = "auto" ]; then CFG_SQL_tds=plugin fi @@ -4492,7 +4498,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; db2) if [ "$CFG_SQL_db2" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_db2" = "auto" ]; then CFG_SQL_db2=plugin fi @@ -4511,7 +4517,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; ibase) if [ "$CFG_SQL_ibase" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_ibase" = "auto" ]; then CFG_SQL_ibase=plugin fi @@ -4530,7 +4536,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; sqlite2) if [ "$CFG_SQL_sqlite2" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_sqlite2" = "auto" ]; then CFG_SQL_sqlite2=plugin fi @@ -4555,7 +4561,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null` QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null` fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_sqlite" = "auto" ]; then CFG_SQL_sqlite=plugin fi @@ -4592,7 +4598,7 @@ done # auto-detect NIS support if [ "$CFG_NIS" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_NIS=yes else if [ "$CFG_NIS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4609,7 +4615,7 @@ fi # auto-detect CUPS support if [ "$CFG_CUPS" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_CUPS=yes else if [ "$CFG_CUPS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4628,9 +4634,9 @@ fi if [ "$CFG_ICONV" != "no" ]; then if [ "$PLATFORM_QWS" = "yes" ]; then CFG_ICONV=no - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_ICONV=yes - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_ICONV=gnu else if [ "$CFG_ICONV" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4651,7 +4657,7 @@ if [ "$CFG_DBUS" != "no" ]; then QT_CFLAGS_DBUS=`$PKG_CONFIG --cflags dbus-1 2>/dev/null` QT_LIBS_DBUS=`$PKG_CONFIG --libs dbus-1 2>/dev/null` fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS $MAC_CONFIG_TEST_COMMANDLINE; then [ "$CFG_DBUS" = "auto" ] && CFG_DBUS=yes QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS" QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS" @@ -5228,7 +5234,7 @@ fi # QWS [ "x$CFG_EMBEDDED" != "xno" ] && CFG_LIBFREETYPE="$CFG_QWS_FREETYPE" [ "x$PLATFORM_MAC" = "xyes" ] && CFG_LIBFREETYPE=no if [ "$CFG_LIBFREETYPE" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_LIBFREETYPE=system else CFG_LIBFREETYPE=yes @@ -5345,7 +5351,7 @@ fi # find if the platform supports IPv6 if [ "$CFG_IPV6" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_IPV6=yes else if [ "$CFG_IPV6" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -5476,7 +5482,7 @@ fi # detect OpenSSL if [ "$CFG_OPENSSL" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_OPENSSL" = "auto" ]; then CFG_OPENSSL=yes fi -- cgit v0.12 From d91a4e137556854f2d9c9a3fea5f480acd0e62c2 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 11 Jun 2009 12:24:43 +0200 Subject: QHttpNetworkConnection: Removed an unnecessary/dead check --- src/network/access/qhttpnetworkconnection.cpp | 25 +++++++++++-------------- src/network/access/qhttpnetworkreply.cpp | 2 +- src/network/access/qhttpnetworkreply_p.h | 1 - 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 741a9a5..abaa7fb 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -918,13 +918,12 @@ void QHttpNetworkConnectionPrivate::unqueueAndSendRequest(QAbstractSocket *socke HttpMessagePair &messagePair = highPriorityQueue[j]; if (!messagePair.second->d_func()->requestIsPrepared) prepareRequest(messagePair); - if (!messagePair.second->d_func()->requestIsBuffering) { - channels[i].request = messagePair.first; - channels[i].reply = messagePair.second; - sendRequest(socket); - highPriorityQueue.removeAt(j); - return; - } + + channels[i].request = messagePair.first; + channels[i].reply = messagePair.second; + sendRequest(socket); + highPriorityQueue.removeAt(j); + return; } } @@ -933,13 +932,11 @@ void QHttpNetworkConnectionPrivate::unqueueAndSendRequest(QAbstractSocket *socke HttpMessagePair &messagePair = lowPriorityQueue[j]; if (!messagePair.second->d_func()->requestIsPrepared) prepareRequest(messagePair); - if (!messagePair.second->d_func()->requestIsBuffering) { - channels[i].request = messagePair.first; - channels[i].reply = messagePair.second; - sendRequest(socket); - lowPriorityQueue.removeAt(j); - return; - } + channels[i].request = messagePair.first; + channels[i].reply = messagePair.second; + sendRequest(socket); + lowPriorityQueue.removeAt(j); + return; } } } diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 310994c..88b1a44 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -187,7 +187,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl) : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100), majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0), currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false), - autoDecompress(false), requestIsBuffering(false), requestIsPrepared(false) + autoDecompress(false), requestIsPrepared(false) { } diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index cc5cce8..eff1da3 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -206,7 +206,6 @@ public: QByteArray responseData; // uncompressed body QByteArray compressedData; // compressed body (temporary) - bool requestIsBuffering; bool requestIsPrepared; }; -- cgit v0.12 From 5f31403e74c4eaf89a213ce3514fe380d221298b Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 11 Jun 2009 13:58:42 +0200 Subject: doc: Fixed several qdoc warnings. --- src/corelib/tools/qcontiguouscache.cpp | 7 ------- src/corelib/tools/qstringbuilder.cpp | 10 +++++----- src/gui/painting/qdrawutil.cpp | 4 ++-- tools/qdoc3/test/qt-cpp-ignore.qdocconf | 3 ++- tools/qdoc3/test/qt-inc.qdocconf | 3 ++- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp index 996ac18..fc75cc0 100644 --- a/src/corelib/tools/qcontiguouscache.cpp +++ b/src/corelib/tools/qcontiguouscache.cpp @@ -429,11 +429,4 @@ MyRecord record(int row) const \sa normalizeIndexes(), append(), prepend() */ -/*! \fn void QContiguousCache::dump() const - - \internal - - Sends information about the cache's internal structure to qDebug() -*/ - QT_END_NAMESPACE diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 740deb4..366a07b 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -64,17 +64,17 @@ \sa QStringBuilder, QLatin1String, QString, QStringRef */ -/*! \fn QLatin1Literal::QLatin1Literal(const char(&string)[N]) - - Constructs a new literal from the given \a string. -*/ - /*! \fn int QLatin1Literal::size() const Returns the number of characters in the literal \e{excluding} the trailing NULL char. */ +/*! \fn QLatin1Literal::QLatin1Literal(const char(&string)[N]) + + Constructs a new literal from the given \a string. +*/ + /*! \fn char *QLatin1Literal::data() const Returns a pointer to the first character of the string literal. diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 230d30b..4020593 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1039,7 +1039,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, #endif /*! - \struct QMargins + \class QMargins \since 4.6 Holds the borders used to split a pixmap into nine segments in order to @@ -1050,7 +1050,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, */ /*! - \struct QTileRules + \class QTileRules \since 4.6 Holds the rules used to draw a pixmap or image split into nine segments, diff --git a/tools/qdoc3/test/qt-cpp-ignore.qdocconf b/tools/qdoc3/test/qt-cpp-ignore.qdocconf index 107c692..cfb3afd 100644 --- a/tools/qdoc3/test/qt-cpp-ignore.qdocconf +++ b/tools/qdoc3/test/qt-cpp-ignore.qdocconf @@ -65,7 +65,8 @@ Cpp.ignoretokens = QAXFACTORY_EXPORT \ QT_BEGIN_INCLUDE_NAMESPACE \ QT_END_NAMESPACE \ QT_END_INCLUDE_NAMESPACE \ - PHONON_EXPORT + PHONON_EXPORT \ + Q_GADGET Cpp.ignoredirectives = Q_DECLARE_HANDLE \ Q_DECLARE_INTERFACE \ Q_DECLARE_METATYPE \ diff --git a/tools/qdoc3/test/qt-inc.qdocconf b/tools/qdoc3/test/qt-inc.qdocconf index d6cb0e6..01b07b3 100644 --- a/tools/qdoc3/test/qt-inc.qdocconf +++ b/tools/qdoc3/test/qt-inc.qdocconf @@ -99,7 +99,8 @@ Cpp.ignoretokens = QAXFACTORY_EXPORT \ Q_TESTLIB_EXPORT \ Q_TYPENAME \ Q_XML_EXPORT \ - QDBUS_EXPORT + QDBUS_EXPORT \ + Q_GADGET Cpp.ignoredirectives = Q_DECLARE_HANDLE \ Q_DECLARE_INTERFACE \ Q_DECLARE_METATYPE \ -- cgit v0.12 From dc802d17d998b62546de0a9725535202d7cbf9e4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 11 Jun 2009 13:12:30 +0200 Subject: Makes the ODF writer use one text:tab tag for each tab, per ODF spec. We used tab-ref to place multiple tabs compressed into one tag just like text:s does, but thats not what the spec says. We now don't sum up tabs anymore but just simply write out one "" tag per tab. Task: 249110 --- src/gui/text/qtextodfwriter.cpp | 51 +++++++++++------------- tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 2 +- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 75e89d2..bc8ac5b 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -295,28 +295,13 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("c%1") .arg(frag.fragment().charFormatIndex())); bool escapeNextSpace = true; - int precedingSpaces = 0, precedingTabs = 0; + int precedingSpaces = 0; int exportedIndex = 0; for (int i=0; i <= fragmentText.count(); ++i) { - bool isTab = false, isSpace = false; - if (i < fragmentText.count()) { + bool isSpace = false; QChar character = fragmentText[i]; - isTab = character.unicode() == '\t'; isSpace = character.unicode() == ' '; - if (character.unicode() == 0x2028) { // soft-return - writer.writeCharacters(fragmentText.mid(exportedIndex, i)); - writer.writeEmptyElement(textNS, QString::fromLatin1("line-break")); - exportedIndex = i+1; - continue; - } - if (isSpace) { - ++precedingSpaces; - escapeNextSpace = true; - } - else if (isTab) { - precedingTabs++; - } - } + // find more than one space. -> if (!isSpace && escapeNextSpace && precedingSpaces > 1) { const bool startParag = exportedIndex == 0 && i == precedingSpaces; @@ -329,17 +314,27 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc precedingSpaces = 0; exportedIndex = i; } - // find tabs. -> or - if (!isTab && precedingTabs) { - writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingTabs - exportedIndex)); - writer.writeEmptyElement(textNS, QString::fromLatin1("tab")); - if (precedingTabs > 1) - writer.writeAttribute(textNS, QString::fromLatin1("tab-ref"), QString::number(precedingTabs)); - precedingTabs = 0; - exportedIndex = i; + + if (i < fragmentText.count()) { + if (character.unicode() == 0x2028) { // soft-return + //if (exportedIndex < i) + writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex)); + writer.writeEmptyElement(textNS, QString::fromLatin1("line-break")); + exportedIndex = i+1; + continue; + } else if (character.unicode() == '\t') { // Tab + //if (exportedIndex < i) + writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex)); + writer.writeEmptyElement(textNS, QString::fromLatin1("tab")); + exportedIndex = i+1; + precedingSpaces = 0; + } else if (isSpace) { + ++precedingSpaces; + escapeNextSpace = true; + } else if (!isSpace) { + precedingSpaces = 0; + } } - if (!isSpace && !isTab) - precedingSpaces = 0; } writer.writeCharacters(fragmentText.mid(exportedIndex)); diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index f92e30f..f8c7cdf 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -133,7 +133,7 @@ void tst_QTextOdfWriter::testWriteParagraph_data() QTest::newRow("tab") << "word\ttab x" << "wordtab x"; QTest::newRow("tab2") << "word\t\ttab\tx" << - "wordtabx"; + "wordtabx"; QTest::newRow("misc") << "foobar word\ttab x" << "foobar wordtab x"; QTest::newRow("misc2") << "\t \tFoo" << -- cgit v0.12 From 26f55ab3ebbb7d1aa7a218cc3373224acc482c56 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 11 Jun 2009 15:21:44 +0200 Subject: doc: Fixed several qdoc warnings. --- src/gui/graphicsview/qgraphicsitem.cpp | 9 ++++++--- src/gui/painting/qpainterpath.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 0390a83..43cbca1 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3064,7 +3064,7 @@ QPointF QGraphicsItem::transformOrigin() const /*! \since 4.6 - Sets the origin for transformation in item coordinate + Sets the \a origin for transformation in item coordinate \sa transformOrigin(), {Transformations} */ @@ -3079,11 +3079,14 @@ void QGraphicsItem::setTransformOrigin(const QPointF &origin) } /*! - \fn inline void setTransformOrigin(qreal x, qreal y) + \fn void QGraphicsItem::setTransformOrigin(qreal x, qreal y) \since 4.6 \overload + Sets the origin for the transformation to the point + composed of \a x and \a y. + \sa setTransformOrigin(), {Transformations} */ @@ -6483,7 +6486,7 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent */ /*! - \property QGraphicsObject:y + \property QGraphicsObject::y \brief the y position of the item Describes the items y position. diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index e1bb317..2f3a0cb 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -2049,7 +2049,7 @@ QPainterPath QPainterPath::translated(qreal dx, qreal dy) const } /*! - \fn void QPainterPath::translated(const QPointF &offset) + \fn QPainterPath QPainterPath::translated(const QPointF &offset) const; \overload \since 4.6 -- cgit v0.12 From f0a4a37a5182660580fd361110d3fd51463221d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 11 Jun 2009 14:25:40 +0200 Subject: Fixed clipping bugs due to not accounting for the redirection offset. Also, updateInvMatrix() can be greatly simplified as updateMatrix() is always called whenever anything related to the state matrix changes, so we can assume that it's up-to-date. Reviewed-by: bnilsen --- src/gui/painting/qpainter.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 0ece498..528c575 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -414,7 +414,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio bool old_txinv = txinv; QTransform old_invMatrix = invMatrix; txinv = true; - invMatrix = state->redirectionMatrix; + invMatrix = state->redirectionMatrix.inverted(); QPainterPath clipPath = q->clipPath(); QRectF r = clipPath.boundingRect().intersected(absPathRect); absPathRect = r.toAlignedRect(); @@ -653,18 +653,7 @@ void QPainterPrivate::updateInvMatrix() { Q_ASSERT(txinv == false); txinv = true; // creating inverted matrix - QTransform m; - - if (state->VxF) - m = viewTransform(); - - if (state->WxF) { - if (state->VxF) - m = state->worldMatrix * m; - else - m = state->worldMatrix; - } - invMatrix = m.inverted(); // invert matrix + invMatrix = state->matrix.inverted(); } void QPainterPrivate::updateEmulationSpecifier(QPainterState *s) @@ -2569,7 +2558,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); d->state->clipEnabled = true; d->extended->clip(vp, op); - d->state->clipInfo << QPainterClipInfo(rect, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); d->state->clipOperation = op; return; } @@ -2612,7 +2601,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) if (d->extended) { d->state->clipEnabled = true; d->extended->clip(rect, op); - d->state->clipInfo << QPainterClipInfo(rect, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); d->state->clipOperation = op; return; } @@ -2624,7 +2613,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) d->state->clipInfo.clear(); - d->state->clipInfo << QPainterClipInfo(rect, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); d->state->clipEnabled = true; d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; d->updateState(d->state); @@ -2665,7 +2654,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) if (d->extended) { d->state->clipEnabled = true; d->extended->clip(r, op); - d->state->clipInfo << QPainterClipInfo(r, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); d->state->clipOperation = op; return; } @@ -2677,7 +2666,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) d->state->clipInfo.clear(); - d->state->clipInfo << QPainterClipInfo(r, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); d->state->clipEnabled = true; d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; d->updateState(d->state); @@ -3062,7 +3051,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) if (d->extended) { d->state->clipEnabled = true; d->extended->clip(path, op); - d->state->clipInfo << QPainterClipInfo(path, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); d->state->clipOperation = op; return; } @@ -3076,7 +3065,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) d->state->clipInfo.clear(); - d->state->clipInfo << QPainterClipInfo(path, op, combinedTransform()); + d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); d->state->clipEnabled = true; d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled; d->updateState(d->state); -- cgit v0.12 From 0f60b6e05a707630e02655c60ae60884262a4b8e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 11 Jun 2009 10:51:54 +0200 Subject: remove q->layout() and q->parentWidget() code where unnecessary --- src/corelib/io/qfile.cpp | 6 +- src/corelib/statemachine/qabstractstate.cpp | 3 +- src/corelib/statemachine/qabstracttransition.cpp | 6 +- src/gui/dialogs/qmessagebox.cpp | 14 ++--- src/gui/itemviews/qtreewidget.cpp | 10 ++-- src/gui/kernel/qapplication_win.cpp | 10 ++-- src/gui/kernel/qwidget.cpp | 8 +-- src/gui/widgets/qdockwidget.cpp | 75 ++++++++++++------------ src/gui/widgets/qmdiarea.cpp | 2 +- src/gui/widgets/qmdisubwindow.cpp | 12 ++-- src/gui/widgets/qmdisubwindow_p.h | 2 +- src/gui/widgets/qpushbutton.cpp | 2 +- src/gui/widgets/qspinbox.cpp | 13 ++-- src/gui/widgets/qsplitter.cpp | 2 +- src/gui/widgets/qtoolbar.cpp | 8 +-- src/gui/widgets/qtoolbutton.cpp | 4 +- 16 files changed, 84 insertions(+), 93 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 4deaddb..bfb1aae 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -154,17 +154,15 @@ QFilePrivate::setError(QFile::FileError err) void QFilePrivate::setError(QFile::FileError err, const QString &errStr) { - Q_Q(QFile); error = err; - q->setErrorString(errStr); + errorString = errStr; } void QFilePrivate::setError(QFile::FileError err, int errNum) { - Q_Q(QFile); error = err; - q->setErrorString(qt_error_string(errNum)); + errorString = qt_error_string(errNum); } //************* QFile diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp index b9a50a2..973057b 100644 --- a/src/corelib/statemachine/qabstractstate.cpp +++ b/src/corelib/statemachine/qabstractstate.cpp @@ -89,8 +89,7 @@ QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q) QStateMachine *QAbstractStatePrivate::machine() const { - Q_Q(const QAbstractState); - QObject *par = q->parent(); + QObject *par = parent; while (par != 0) { if (QStateMachine *mach = qobject_cast(par)) return mach; diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index f582b8c..c1b553c 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -113,8 +113,7 @@ QAbstractTransitionPrivate *QAbstractTransitionPrivate::get(QAbstractTransition QStateMachine *QAbstractTransitionPrivate::machine() const { - Q_Q(const QAbstractTransition); - QObject *par = q->parent(); + QObject *par = parent; while (par != 0) { if (QStateMachine *mach = qobject_cast(par)) return mach; @@ -137,8 +136,7 @@ void QAbstractTransitionPrivate::callOnTransition(QEvent *e) QState *QAbstractTransitionPrivate::sourceState() const { - Q_Q(const QAbstractTransition); - return qobject_cast(q->parent()); + return qobject_cast(parent); } /*! diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 648cda8..c526c7d 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -258,10 +258,8 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) int QMessageBoxPrivate::layoutMinimumWidth() { - Q_Q(QMessageBox); - - q->layout()->activate(); - return q->layout()->totalMinimumSize().width(); + layout->activate(); + return layout->totalMinimumSize().width(); } void QMessageBoxPrivate::updateSize() @@ -339,10 +337,10 @@ void QMessageBoxPrivate::updateSize() if (windowTitleWidth > width) width = windowTitleWidth; - q->layout()->activate(); - int height = (q->layout()->hasHeightForWidth()) - ? q->layout()->totalHeightForWidth(width) - : q->layout()->totalMinimumSize().height(); + layout->activate(); + int height = (layout->hasHeightForWidth()) + ? layout->totalHeightForWidth(width) + : layout->totalMinimumSize().height(); q->setFixedSize(width, height); QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); } diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 5604f8d..24713c4 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -2280,10 +2280,9 @@ void QTreeWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, void QTreeWidgetPrivate::_q_sort() { - Q_Q(QTreeWidget); if (sortingEnabled) { - int column = q->header()->sortIndicatorSection(); - Qt::SortOrder order = q->header()->sortIndicatorOrder(); + int column = header->sortIndicatorSection(); + Qt::SortOrder order = header->sortIndicatorOrder(); model()->sort(column, order); } } @@ -2311,12 +2310,11 @@ void QTreeWidgetPrivate::_q_selectionChanged(const QItemSelection &selected, con void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { - Q_Q(QTreeWidget); if (sortingEnabled && topLeft.isValid() && bottomRight.isValid() && !model()->sortPendingTimer.isActive()) { - int column = q->header()->sortIndicatorSection(); + int column = header->sortIndicatorSection(); if (column >= topLeft.column() && column <= bottomRight.column()) { - Qt::SortOrder order = q->header()->sortIndicatorOrder(); + Qt::SortOrder order = header->sortIndicatorOrder(); model()->ensureSorted(column, order, topLeft.row(), bottomRight.row(), topLeft.parent()); } diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index b21eb36..8d77c4c 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2748,9 +2748,9 @@ void QApplicationPrivate::openPopup(QWidget *popup) if (popup->focusWidget()) { popup->focusWidget()->setFocus(Qt::PopupFocusReason); } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup - if (QWidget *fw = q_func()->focusWidget()) { + if (QWidget *fw = QApplication::focusWidget()) { QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); - q_func()->sendEvent(fw, &e); + QApplication::sendEvent(fw, &e); } } } @@ -2777,13 +2777,13 @@ void QApplicationPrivate::closePopup(QWidget *popup) if (!qt_nograb()) // grabbing not disabled releaseAutoCapture(); QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() - : q_func()->focusWidget(); + : QApplication::focusWidget(); if (fw) { - if (fw != q_func()->focusWidget()) { + if (fw != QApplication::focusWidget()) { fw->setFocus(Qt::PopupFocusReason); } else { QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); - q_func()->sendEvent(fw, &e); + QApplication::sendEvent(fw, &e); } } } else { diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 61d8f20..230b8f6 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7268,10 +7268,10 @@ QSize QWidgetPrivate::adjustedSize() const if (q->isWindow()) { Qt::Orientations exp; - if (QLayout *l = q->layout()) { - if (l->hasHeightForWidth()) - s.setHeight(l->totalHeightForWidth(s.width())); - exp = l->expandingDirections(); + if (layout) { + if (layout->hasHeightForWidth()) + s.setHeight(layout->totalHeightForWidth(s.width())); + exp = layout->expandingDirections(); } else { if (q->sizePolicy().hasHeightForWidth()) diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 6a0c879..30f9a87 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -69,6 +69,9 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); / extern QHash *qt_app_fonts_hash(); // qapplication.cpp +static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) +{ return (priv->features & feature) == feature; } + static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) { return (dockwidget->features() & feature) == feature; } @@ -647,25 +650,25 @@ void QDockWidgetPrivate::_q_toggleView(bool b) void QDockWidgetPrivate::updateButtons() { Q_Q(QDockWidget); - QDockWidgetLayout *layout = qobject_cast(q->layout()); + QDockWidgetLayout *dwLayout = qobject_cast(layout); QStyleOptionDockWidget opt; q->initStyleOption(&opt); - bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; - bool nativeDeco = layout->nativeWindowDeco(); + bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; + bool nativeDeco = dwLayout->nativeWindowDeco(); bool hideButtons = nativeDeco || customTitleBar; - bool canClose = hasFeature(q, QDockWidget::DockWidgetClosable); - bool canFloat = hasFeature(q, QDockWidget::DockWidgetFloatable); + bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable); + bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable); QAbstractButton *button - = qobject_cast(layout->widgetForRole(QDockWidgetLayout::FloatButton)); + = qobject_cast(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); button->setVisible(canFloat && !hideButtons); button - = qobject_cast (layout->widgetForRole(QDockWidgetLayout::CloseButton)); + = qobject_cast (dwLayout->widgetForRole(QDockWidgetLayout::CloseButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); button->setVisible(canClose && !hideButtons); @@ -688,7 +691,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) if (state != 0) return; - QMainWindow *win = qobject_cast(q->parentWidget()); + QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast(win->layout()); Q_ASSERT(layout != 0); @@ -741,15 +744,15 @@ void QDockWidgetPrivate::endDrag(bool abort) q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *layout = + QMainWindowLayout *mwLayout = qobject_cast(q->parentWidget()->layout()); - Q_ASSERT(layout != 0); + Q_ASSERT(mwLayout != 0); - if (abort || !layout->plug(state->widgetItem)) { - if (hasFeature(q, QDockWidget::DockWidgetFloatable)) { + if (abort || !mwLayout->plug(state->widgetItem)) { + if (hasFeature(this, QDockWidget::DockWidgetFloatable)) { if (state->ownWidgetItem) delete state->widgetItem; - layout->restore(); + mwLayout->restore(); #ifdef Q_WS_X11 // get rid of the X11BypassWindowManager window flag and activate the resizer Qt::WindowFlags flags = q->windowFlags(); @@ -759,14 +762,14 @@ void QDockWidgetPrivate::endDrag(bool abort) q->show(); #else QDockWidgetLayout *myLayout - = qobject_cast(q->layout()); + = qobject_cast(layout); resizer->setActive(QWidgetResizeHandler::Resize, myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0); #endif undockedGeometry = q->geometry(); q->activateWindow(); } else { - layout->revert(state->widgetItem); + mwLayout->revert(state->widgetItem); } } } @@ -778,7 +781,7 @@ bool QDockWidgetPrivate::isAnimating() const { Q_Q(const QDockWidget); - QMainWindow *mainWin = qobject_cast(q->parentWidget()); + QMainWindow *mainWin = qobject_cast(parent); if (mainWin == 0) return false; @@ -795,18 +798,18 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) #if !defined(QT_NO_MAINWINDOW) Q_Q(QDockWidget); - QDockWidgetLayout *layout - = qobject_cast(q->layout()); + QDockWidgetLayout *dwLayout + = qobject_cast(layout); - if (!layout->nativeWindowDeco()) { - QRect titleArea = layout->titleArea(); + if (!dwLayout->nativeWindowDeco()) { + QRect titleArea = dwLayout->titleArea(); if (event->button() != Qt::LeftButton || !titleArea.contains(event->pos()) || // check if the tool window is movable... do nothing if it // is not (but allow moving if the window is floating) - (!hasFeature(q, QDockWidget::DockWidgetMovable) && !q->isFloating()) || - qobject_cast(q->parentWidget()) == 0 || + (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) || + qobject_cast(parent) == 0 || isAnimating() || state != 0) { return false; } @@ -814,7 +817,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) initDrag(event->pos(), false); if (state) - state->ctrlDrag = hasFeature(q, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier; + state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier; return true; } @@ -825,15 +828,13 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) { - Q_Q(QDockWidget); + QDockWidgetLayout *dwLayout = qobject_cast(layout); - QDockWidgetLayout *layout = qobject_cast(q->layout()); - - if (!layout->nativeWindowDeco()) { - QRect titleArea = layout->titleArea(); + if (!dwLayout->nativeWindowDeco()) { + QRect titleArea = dwLayout->titleArea(); if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) && - hasFeature(q, QDockWidget::DockWidgetFloatable)) { + hasFeature(this, QDockWidget::DockWidgetFloatable)) { _q_toggleTopLevel(); return true; } @@ -851,7 +852,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) return ret; QDockWidgetLayout *dwlayout - = qobject_cast(q->layout()); + = qobject_cast(layout); QMainWindowLayout *mwlayout = qobject_cast(q->parentWidget()->layout()); if (!dwlayout->nativeWindowDeco()) { @@ -924,7 +925,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) break; if (state != 0) break; - if (qobject_cast(q->parentWidget()) == 0) + if (qobject_cast(parent) == 0) break; if (isAnimating()) break; @@ -997,9 +998,9 @@ void QDockWidgetPrivate::unplug(const QRect &rect) Q_Q(QDockWidget); QRect r = rect; r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); - QDockWidgetLayout *layout = qobject_cast(q->layout()); - if (layout->nativeWindowDeco(true)) - r.adjust(0, layout->titleHeight(), 0, 0); + QDockWidgetLayout *dwLayout = qobject_cast(layout); + if (dwLayout->nativeWindowDeco(true)) + r.adjust(0, dwLayout->titleHeight(), 0, 0); setWindowState(true, true, r); } @@ -1020,12 +1021,12 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; - QDockWidgetLayout *layout = qobject_cast(q->layout()); - const bool nativeDeco = layout->nativeWindowDeco(floating); + QDockWidgetLayout *dwLayout = qobject_cast(layout); + const bool nativeDeco = dwLayout->nativeWindowDeco(floating); if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; - if (hasFeature(q, QDockWidget::DockWidgetClosable)) + if (hasFeature(this, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowCloseButtonHint; } else { flags |= Qt::FramelessWindowHint; diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp index 0235c04..efaa2d3 100644 --- a/src/gui/widgets/qmdiarea.cpp +++ b/src/gui/widgets/qmdiarea.cpp @@ -1212,7 +1212,7 @@ void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const QMdiSubWindow *stackUnderChild = 0; if (!windowStaysOnTop(mdiChild)) { - foreach (QObject *object, q_func()->viewport()->children()) { + foreach (QObject *object, viewport->children()) { QMdiSubWindow *child = qobject_cast(object); if (!child || !childWindows.contains(child)) continue; diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp index b366c28..e5cc6b6 100644 --- a/src/gui/widgets/qmdisubwindow.cpp +++ b/src/gui/widgets/qmdisubwindow.cpp @@ -1006,7 +1006,7 @@ void QMdiSubWindowPrivate::removeBaseWidget() Q_Q(QMdiSubWindow); baseWidget->removeEventFilter(q); - if (QLayout *layout = q->layout()) + if (layout) layout->removeWidget(baseWidget); if (baseWidget->windowTitle() == q->windowTitle()) { ignoreWindowTitleChange = true; @@ -1102,7 +1102,7 @@ void QMdiSubWindowPrivate::updateCursor() void QMdiSubWindowPrivate::updateDirtyRegions() { // No update necessary - if (!q_func()->parent()) + if (!parent) return; foreach (Operation operation, operationMap.keys()) @@ -2180,17 +2180,17 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) if (!newSizeGrip || sizeGrip || q->windowFlags() & Qt::FramelessWindowHint) return; - if (q->layout() && q->layout()->indexOf(newSizeGrip) != -1) + if (layout && layout->indexOf(newSizeGrip) != -1) return; newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); - bool putSizeGripInLayout = q->layout() ? true : false; + bool putSizeGripInLayout = layout ? true : false; #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) if (qobject_cast(q->style())) putSizeGripInLayout = false; #endif if (putSizeGripInLayout) { - q->layout()->addWidget(newSizeGrip); - q->layout()->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); + layout->addWidget(newSizeGrip); + layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); } else { newSizeGrip->setParent(q); newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0, diff --git a/src/gui/widgets/qmdisubwindow_p.h b/src/gui/widgets/qmdisubwindow_p.h index 394f11c..d706546 100644 --- a/src/gui/widgets/qmdisubwindow_p.h +++ b/src/gui/widgets/qmdisubwindow_p.h @@ -308,7 +308,7 @@ public: inline void setNewGeometry(QRect *geometry) { Q_Q(QMdiSubWindow); - Q_ASSERT(q->parent()); + Q_ASSERT(parent); geometry->setSize(geometry->size().expandedTo(internalMinimumSize)); #ifndef QT_NO_RUBBERBAND if (isInRubberBandMode) diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index ca58f87..5001001 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -576,7 +576,7 @@ void QPushButtonPrivate::_q_popupPressed() menu->setNoReplayFor(q); bool horizontal = true; #if !defined(QT_NO_TOOLBAR) - QToolBar *tb = qobject_cast(q->parentWidget()); + QToolBar *tb = qobject_cast(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index f12946c..a9b9a84 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -983,7 +983,7 @@ QVariant QSpinBoxPrivate::valueFromText(const QString &text) const bool QSpinBoxPrivate::isIntermediateValue(const QString &str) const { - const int num = q_func()->locale().toInt(str, 0, 10); + const int num = locale.toInt(str, 0, 10); const int min = minimum.toInt(); const int max = maximum.toInt(); @@ -1053,13 +1053,13 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } else { bool ok = false; bool removedThousand = false; - num = q_func()->locale().toInt(copy, &ok, 10); + num = locale.toInt(copy, &ok, 10); if (!ok && copy.contains(thousand) && (max >= 1000 || min <= -1000)) { const int s = copy.size(); copy.remove(thousand); pos = qMax(0, pos - (s - copy.size())); removedThousand = true; - num = q_func()->locale().toInt(copy, &ok, 10); + num = locale.toInt(copy, &ok, 10); } QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; if (!ok) { @@ -1346,9 +1346,8 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, { bool ok = false; - QLocale loc(q_func()->locale()); - num = loc.toDouble(copy, &ok); - QSBDEBUG() << __FILE__ << __LINE__ << loc << copy << num << ok; + num = locale.toDouble(copy, &ok); + QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok; bool notAcceptable = false; if (!ok) { @@ -1373,7 +1372,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, pos = qMax(0, pos - (s - copy.size())); - num = loc.toDouble(copy, &ok); + num = locale.toDouble(copy, &ok); QSBDEBUG() << thousand << num << copy << ok; if (!ok) { diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp index 400d78a..24a8b6c 100644 --- a/src/gui/widgets/qsplitter.cpp +++ b/src/gui/widgets/qsplitter.cpp @@ -397,7 +397,7 @@ void QSplitterPrivate::recalc(bool update) } if (empty) { - if (qobject_cast(q->parentWidget())) { + if (qobject_cast(parent)) { // nested splitters; be nice maxl = maxt = 0; } else { diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index d765794..20f2c23 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -198,7 +198,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos) if (state != 0) return; - QMainWindow *win = qobject_cast(q->parentWidget()); + QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast(win->layout()); Q_ASSERT(layout != 0); @@ -224,7 +224,7 @@ void QToolBarPrivate::startDrag(bool moving) if ((moving && state->moving) || state->dragging) return; - QMainWindow *win = qobject_cast(q->parentWidget()); + QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast(win->layout()); Q_ASSERT(layout != 0); @@ -283,7 +283,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) // drag between toolbar contents to move the window. Make this work by // implementing the standard mouse-dragging code and then call // window->move() in mouseMoveEvent below. - if (QMainWindow *mainWindow = qobject_cast(q->parentWidget())) { + if (QMainWindow *mainWindow = qobject_cast(parent)) { if (mainWindow->toolBarArea(q) == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac() && q->childAt(event->pos()) == 0) { @@ -337,7 +337,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) return false; } - QMainWindow *win = qobject_cast(q->parentWidget()); + QMainWindow *win = qobject_cast(parent); if (win == 0) return true; diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/gui/widgets/qtoolbutton.cpp index 20b84ef..7d41d1e 100644 --- a/src/gui/widgets/qtoolbutton.cpp +++ b/src/gui/widgets/qtoolbutton.cpp @@ -278,7 +278,7 @@ void QToolButtonPrivate::init() #endif defaultAction = 0; #ifndef QT_NO_TOOLBAR - if (qobject_cast(q->parentWidget())) + if (qobject_cast(parent)) autoRaise = true; else #endif @@ -890,7 +890,7 @@ void QToolButtonPrivate::popupTimerDone() q->setAutoRepeat(false); bool horizontal = true; #if !defined(QT_NO_TOOLBAR) - QToolBar *tb = qobject_cast(q->parentWidget()); + QToolBar *tb = qobject_cast(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif -- cgit v0.12 From 3f7a7c20c8493f62e090e703acfd581a4e3c4d2e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 11 Jun 2009 11:56:54 +0200 Subject: refactor of private getters for the mode i item widget classes --- src/gui/itemviews/qlistwidget.cpp | 92 +++++++++++++-------------- src/gui/itemviews/qlistwidget_p.h | 2 +- src/gui/itemviews/qtablewidget.cpp | 118 +++++++++++++++++------------------ src/gui/itemviews/qtablewidget_p.h | 2 +- src/gui/itemviews/qtreeview.cpp | 2 +- src/gui/itemviews/qtreewidget.cpp | 87 +++++++++++++------------- src/gui/itemviews/qtreewidget_p.h | 7 +-- src/gui/text/qtextdocumentlayout.cpp | 10 ++- 8 files changed, 158 insertions(+), 162 deletions(-) diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 504908f..51861b3 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -1020,51 +1020,51 @@ void QListWidgetPrivate::setup() QObject::connect(q, SIGNAL(activated(QModelIndex)), q, SLOT(_q_emitItemActivated(QModelIndex))); QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex))); - QObject::connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), q, SLOT(_q_emitItemChanged(QModelIndex))); QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), q, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex))); QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), q, SIGNAL(itemSelectionChanged())); - QObject::connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), q, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); - QObject::connect(model(), SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); + QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); } void QListWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemPressed(model()->at(index.row())); + emit q->itemPressed(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemClicked(model()->at(index.row())); + emit q->itemClicked(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemDoubleClicked(model()->at(index.row())); + emit q->itemDoubleClicked(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemActivated(model()->at(index.row())); + emit q->itemActivated(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemEntered(model()->at(index.row())); + emit q->itemEntered(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) { Q_Q(QListWidget); - emit q->itemChanged(model()->at(index.row())); + emit q->itemChanged(listModel()->at(index.row())); } void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, @@ -1072,8 +1072,8 @@ void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, { Q_Q(QListWidget); QPersistentModelIndex persistentCurrent = current; - QListWidgetItem *currentItem = model()->at(persistentCurrent.row()); - emit q->currentItemChanged(currentItem, model()->at(previous.row())); + QListWidgetItem *currentItem = listModel()->at(persistentCurrent.row()); + emit q->currentItemChanged(currentItem, listModel()->at(previous.row())); //persistentCurrent is invalid if something changed the model in response //to the currentItemChanged signal emission and the item was removed @@ -1088,14 +1088,14 @@ void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, void QListWidgetPrivate::_q_sort() { if (sortingEnabled) - model()->sort(0, sortOrder); + model->sort(0, sortOrder); } void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()) - model()->ensureSorted(topLeft.column(), sortOrder, + listModel()->ensureSorted(topLeft.column(), sortOrder, topLeft.row(), bottomRight.row()); } @@ -1308,9 +1308,9 @@ QListWidget::~QListWidget() QListWidgetItem *QListWidget::item(int row) const { Q_D(const QListWidget); - if (row < 0 || row >= d->model()->rowCount()) + if (row < 0 || row >= d->model->rowCount()) return 0; - return d->model()->at(row); + return d->listModel()->at(row); } /*! @@ -1322,7 +1322,7 @@ QListWidgetItem *QListWidget::item(int row) const int QListWidget::row(const QListWidgetItem *item) const { Q_D(const QListWidget); - return d->model()->index(const_cast(item)).row(); + return d->listModel()->index(const_cast(item)).row(); } @@ -1336,7 +1336,7 @@ void QListWidget::insertItem(int row, QListWidgetItem *item) { Q_D(QListWidget); if (item && !item->view) - d->model()->insert(row, item); + d->listModel()->insert(row, item); } /*! @@ -1349,7 +1349,7 @@ void QListWidget::insertItem(int row, QListWidgetItem *item) void QListWidget::insertItem(int row, const QString &label) { Q_D(QListWidget); - d->model()->insert(row, new QListWidgetItem(label)); + d->listModel()->insert(row, new QListWidgetItem(label)); } /*! @@ -1362,7 +1362,7 @@ void QListWidget::insertItem(int row, const QString &label) void QListWidget::insertItems(int row, const QStringList &labels) { Q_D(QListWidget); - d->model()->insert(row, labels); + d->listModel()->insert(row, labels); } /*! @@ -1378,9 +1378,9 @@ void QListWidget::insertItems(int row, const QStringList &labels) QListWidgetItem *QListWidget::takeItem(int row) { Q_D(QListWidget); - if (row < 0 || row >= d->model()->rowCount()) + if (row < 0 || row >= d->model->rowCount()) return 0; - return d->model()->take(row); + return d->listModel()->take(row); } /*! @@ -1391,7 +1391,7 @@ QListWidgetItem *QListWidget::takeItem(int row) int QListWidget::count() const { Q_D(const QListWidget); - return d->model()->rowCount(); + return d->model->rowCount(); } /*! @@ -1400,7 +1400,7 @@ int QListWidget::count() const QListWidgetItem *QListWidget::currentItem() const { Q_D(const QListWidget); - return d->model()->at(currentIndex().row()); + return d->listModel()->at(currentIndex().row()); } @@ -1438,7 +1438,7 @@ int QListWidget::currentRow() const void QListWidget::setCurrentRow(int row) { Q_D(QListWidget); - QModelIndex index = d->model()->index(row); + QModelIndex index = d->listModel()->index(row); if (d->selectionMode == SingleSelection) selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); else if (d->selectionMode == NoSelection) @@ -1455,7 +1455,7 @@ void QListWidget::setCurrentRow(int row) void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command) { Q_D(QListWidget); - d->selectionModel->setCurrentIndex(d->model()->index(row), command); + d->selectionModel->setCurrentIndex(d->listModel()->index(row), command); } /*! @@ -1464,7 +1464,7 @@ void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags com QListWidgetItem *QListWidget::itemAt(const QPoint &p) const { Q_D(const QListWidget); - return d->model()->at(indexAt(p).row()); + return d->listModel()->at(indexAt(p).row()); } @@ -1482,7 +1482,7 @@ QListWidgetItem *QListWidget::itemAt(const QPoint &p) const QRect QListWidget::visualItemRect(const QListWidgetItem *item) const { Q_D(const QListWidget); - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->listModel()->index(const_cast(item)); return visualRect(index); } @@ -1493,7 +1493,7 @@ void QListWidget::sortItems(Qt::SortOrder order) { Q_D(QListWidget); d->sortOrder = order; - d->model()->sort(0, order); + d->listModel()->sort(0, order); } /*! @@ -1532,7 +1532,7 @@ Qt::SortOrder QListWidget::sortOrder() const void QListWidget::editItem(QListWidgetItem *item) { Q_D(QListWidget); - edit(d->model()->index(item)); + edit(d->listModel()->index(item)); } /*! @@ -1543,7 +1543,7 @@ void QListWidget::editItem(QListWidgetItem *item) void QListWidget::openPersistentEditor(QListWidgetItem *item) { Q_D(QListWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->listModel()->index(item); QAbstractItemView::openPersistentEditor(index); } @@ -1555,7 +1555,7 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item) void QListWidget::closePersistentEditor(QListWidgetItem *item) { Q_D(QListWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->listModel()->index(item); QAbstractItemView::closePersistentEditor(index); } @@ -1567,7 +1567,7 @@ void QListWidget::closePersistentEditor(QListWidgetItem *item) QWidget *QListWidget::itemWidget(QListWidgetItem *item) const { Q_D(const QListWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->listModel()->index(item); return QAbstractItemView::indexWidget(index); } @@ -1585,7 +1585,7 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) { Q_D(QListWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->listModel()->index(item); QAbstractItemView::setIndexWidget(index, widget); } @@ -1599,7 +1599,7 @@ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) bool QListWidget::isItemSelected(const QListWidgetItem *item) const { Q_D(const QListWidget); - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->listModel()->index(const_cast(item)); return selectionModel()->isSelected(index); } @@ -1614,7 +1614,7 @@ bool QListWidget::isItemSelected(const QListWidgetItem *item) const void QListWidget::setItemSelected(const QListWidgetItem *item, bool select) { Q_D(QListWidget); - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->listModel()->index(const_cast(item)); if (d->selectionMode == SingleSelection) { selectionModel()->select(index, select @@ -1638,7 +1638,7 @@ QList QListWidget::selectedItems() const QModelIndexList indexes = selectionModel()->selectedIndexes(); QList items; for (int i = 0; i < indexes.count(); ++i) - items.append(d->model()->at(indexes.at(i).row())); + items.append(d->listModel()->at(indexes.at(i).row())); return items; } @@ -1649,11 +1649,11 @@ QList QListWidget::selectedItems() const QList QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const { Q_D(const QListWidget); - QModelIndexList indexes = d->model()->match(model()->index(0, 0, QModelIndex()), + QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()), Qt::DisplayRole, text, -1, flags); QList items; for (int i = 0; i < indexes.size(); ++i) - items.append(d->model()->at(indexes.at(i).row())); + items.append(d->listModel()->at(indexes.at(i).row())); return items; } @@ -1690,7 +1690,7 @@ void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint) { Q_D(QListWidget); - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->listModel()->index(const_cast(item)); QListView::scrollTo(index, hint); } @@ -1703,7 +1703,7 @@ void QListWidget::clear() { Q_D(QListWidget); selectionModel()->clear(); - d->model()->clear(); + d->listModel()->clear(); } /*! @@ -1714,7 +1714,7 @@ void QListWidget::clear() */ QStringList QListWidget::mimeTypes() const { - return d_func()->model()->QAbstractListModel::mimeTypes(); + return d_func()->listModel()->QAbstractListModel::mimeTypes(); } /*! @@ -1727,7 +1727,7 @@ QStringList QListWidget::mimeTypes() const */ QMimeData *QListWidget::mimeData(const QList) const { - return d_func()->model()->internalMimeData(); + return d_func()->listModel()->internalMimeData(); } #ifndef QT_NO_DRAGANDDROP @@ -1750,7 +1750,7 @@ bool QListWidget::dropMimeData(int index, const QMimeData *data, Qt::DropAction row = -1; column = -1; } - return d_func()->model()->QAbstractListModel::dropMimeData(data, action , row, column, idx); + return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx); } /*! \reimp */ @@ -1809,7 +1809,7 @@ void QListWidget::dropEvent(QDropEvent *event) { Qt::DropActions QListWidget::supportedDropActions() const { Q_D(const QListWidget); - return d->model()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; + return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; } #endif // QT_NO_DRAGANDDROP @@ -1833,7 +1833,7 @@ QList QListWidget::items(const QMimeData *data) const QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const { Q_D(const QListWidget); - return d->model()->index(item); + return d->listModel()->index(item); } /*! @@ -1844,7 +1844,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const { Q_D(const QListWidget); if (d->isIndexValid(index)) - return d->model()->at(index.row()); + return d->listModel()->at(index.row()); return 0; } diff --git a/src/gui/itemviews/qlistwidget_p.h b/src/gui/itemviews/qlistwidget_p.h index 8556047..6887d9d 100644 --- a/src/gui/itemviews/qlistwidget_p.h +++ b/src/gui/itemviews/qlistwidget_p.h @@ -143,7 +143,7 @@ class QListWidgetPrivate : public QListViewPrivate Q_DECLARE_PUBLIC(QListWidget) public: QListWidgetPrivate() : QListViewPrivate(), sortOrder(Qt::AscendingOrder), sortingEnabled(false) {} - inline QListModel *model() const { return qobject_cast(q_func()->model()); } + inline QListModel *listModel() const { return qobject_cast(model); } void setup(); void _q_emitItemPressed(const QModelIndex &index); void _q_emitItemClicked(const QModelIndex &index); diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index 072e435..6645376 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -1570,7 +1570,7 @@ void QTableWidgetPrivate::setup() QObject::connect(q, SIGNAL(activated(QModelIndex)), q, SLOT(_q_emitItemActivated(QModelIndex))); QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex))); // model signals - QObject::connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), q, SLOT(_q_emitItemChanged(QModelIndex))); // selection signals QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), @@ -1578,15 +1578,15 @@ void QTableWidgetPrivate::setup() QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), q, SIGNAL(itemSelectionChanged())); // sorting - QObject::connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), q, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); - QObject::connect(model(), SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); + QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); } void QTableWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemPressed(item); emit q->cellPressed(index.row(), index.column()); } @@ -1594,7 +1594,7 @@ void QTableWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) void QTableWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemClicked(item); emit q->cellClicked(index.row(), index.column()); } @@ -1602,7 +1602,7 @@ void QTableWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) void QTableWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemDoubleClicked(item); emit q->cellDoubleClicked(index.row(), index.column()); } @@ -1610,7 +1610,7 @@ void QTableWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) void QTableWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemActivated(item); emit q->cellActivated(index.row(), index.column()); } @@ -1618,7 +1618,7 @@ void QTableWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) void QTableWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemEntered(item); emit q->cellEntered(index.row(), index.column()); } @@ -1626,7 +1626,7 @@ void QTableWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) void QTableWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) { Q_Q(QTableWidget); - if (QTableWidgetItem *item = model()->item(index)) + if (QTableWidgetItem *item = tableModel()->item(index)) emit q->itemChanged(item); emit q->cellChanged(index.row(), index.column()); } @@ -1635,8 +1635,8 @@ void QTableWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, const QModelIndex &previous) { Q_Q(QTableWidget); - QTableWidgetItem *currentItem = model()->item(current); - QTableWidgetItem *previousItem = model()->item(previous); + QTableWidgetItem *currentItem = tableModel()->item(current); + QTableWidgetItem *previousItem = tableModel()->item(previous); if (currentItem || previousItem) emit q->currentItemChanged(currentItem, previousItem); emit q->currentCellChanged(current.row(), current.column(), previous.row(), previous.column()); @@ -1647,7 +1647,7 @@ void QTableWidgetPrivate::_q_sort() if (sortingEnabled) { int column = horizontalHeader->sortIndicatorSection(); Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); - model()->sort(column, order); + model->sort(column, order); } } @@ -1658,7 +1658,7 @@ void QTableWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, int column = horizontalHeader->sortIndicatorSection(); if (column >= topLeft.column() && column <= bottomRight.column()) { Qt::SortOrder order = horizontalHeader->sortIndicatorOrder(); - model()->ensureSorted(column, order, topLeft.row(), bottomRight.row()); + tableModel()->ensureSorted(column, order, topLeft.row(), bottomRight.row()); } } } @@ -1862,7 +1862,7 @@ QTableWidget::~QTableWidget() void QTableWidget::setRowCount(int rows) { Q_D(QTableWidget); - d->model()->setRowCount(rows); + d->tableModel()->setRowCount(rows); } /*! @@ -1872,7 +1872,7 @@ void QTableWidget::setRowCount(int rows) int QTableWidget::rowCount() const { Q_D(const QTableWidget); - return d->model()->rowCount(); + return d->model->rowCount(); } /*! @@ -1885,7 +1885,7 @@ int QTableWidget::rowCount() const void QTableWidget::setColumnCount(int columns) { Q_D(QTableWidget); - d->model()->setColumnCount(columns); + d->tableModel()->setColumnCount(columns); } /*! @@ -1895,7 +1895,7 @@ void QTableWidget::setColumnCount(int columns) int QTableWidget::columnCount() const { Q_D(const QTableWidget); - return d->model()->columnCount(); + return d->model->columnCount(); } /*! @@ -1904,7 +1904,7 @@ int QTableWidget::columnCount() const int QTableWidget::row(const QTableWidgetItem *item) const { Q_D(const QTableWidget); - return d->model()->index(item).row(); + return d->tableModel()->index(item).row(); } /*! @@ -1913,7 +1913,7 @@ int QTableWidget::row(const QTableWidgetItem *item) const int QTableWidget::column(const QTableWidgetItem *item) const { Q_D(const QTableWidget); - return d->model()->index(item).column(); + return d->tableModel()->index(item).column(); } @@ -1926,7 +1926,7 @@ int QTableWidget::column(const QTableWidgetItem *item) const QTableWidgetItem *QTableWidget::item(int row, int column) const { Q_D(const QTableWidget); - return d->model()->item(row, column); + return d->tableModel()->item(row, column); } /*! @@ -1955,7 +1955,7 @@ void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) qWarning("QTableWidget: cannot insert an item that is already owned by another QTableWidget"); } else { item->view = this; - d->model()->setItem(row, column, item); + d->tableModel()->setItem(row, column, item); } } else { delete takeItem(row, column); @@ -1968,7 +1968,7 @@ void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) QTableWidgetItem *QTableWidget::takeItem(int row, int column) { Q_D(QTableWidget); - QTableWidgetItem *item = d->model()->takeItem(row, column); + QTableWidgetItem *item = d->tableModel()->takeItem(row, column); if (item) item->view = 0; return item; @@ -1980,7 +1980,7 @@ QTableWidgetItem *QTableWidget::takeItem(int row, int column) QTableWidgetItem *QTableWidget::verticalHeaderItem(int row) const { Q_D(const QTableWidget); - return d->model()->verticalHeaderItem(row); + return d->tableModel()->verticalHeaderItem(row); } /*! @@ -1991,7 +1991,7 @@ void QTableWidget::setVerticalHeaderItem(int row, QTableWidgetItem *item) Q_D(QTableWidget); if (item) { item->view = this; - d->model()->setVerticalHeaderItem(row, item); + d->tableModel()->setVerticalHeaderItem(row, item); } else { delete takeVerticalHeaderItem(row); } @@ -2004,7 +2004,7 @@ void QTableWidget::setVerticalHeaderItem(int row, QTableWidgetItem *item) QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row) { Q_D(QTableWidget); - QTableWidgetItem *itm = d->model()->takeVerticalHeaderItem(row); + QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row); if (itm) itm->view = 0; return itm; @@ -2017,7 +2017,7 @@ QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row) QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const { Q_D(const QTableWidget); - return d->model()->horizontalHeaderItem(column); + return d->tableModel()->horizontalHeaderItem(column); } /*! @@ -2028,7 +2028,7 @@ void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem *item) Q_D(QTableWidget); if (item) { item->view = this; - d->model()->setHorizontalHeaderItem(column, item); + d->tableModel()->setHorizontalHeaderItem(column, item); } else { delete takeHorizontalHeaderItem(column); } @@ -2041,7 +2041,7 @@ void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem *item) QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column) { Q_D(QTableWidget); - QTableWidgetItem *itm = d->model()->takeHorizontalHeaderItem(column); + QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column); if (itm) itm->view = 0; return itm; @@ -2053,7 +2053,7 @@ QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column) void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) { Q_D(QTableWidget); - QTableModel *model = d->model(); + QTableModel *model = d->tableModel(); QTableWidgetItem *item = 0; for (int i = 0; i < model->rowCount() && i < labels.count(); ++i) { item = model->verticalHeaderItem(i); @@ -2071,7 +2071,7 @@ void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels) { Q_D(QTableWidget); - QTableModel *model = d->model(); + QTableModel *model = d->tableModel(); QTableWidgetItem *item = 0; for (int i = 0; i < model->columnCount() && i < labels.count(); ++i) { item = model->horizontalHeaderItem(i); @@ -2111,7 +2111,7 @@ int QTableWidget::currentColumn() const QTableWidgetItem *QTableWidget::currentItem() const { Q_D(const QTableWidget); - return d->model()->item(currentIndex()); + return d->tableModel()->item(currentIndex()); } /*! @@ -2125,7 +2125,7 @@ QTableWidgetItem *QTableWidget::currentItem() const void QTableWidget::setCurrentItem(QTableWidgetItem *item) { Q_D(QTableWidget); - setCurrentIndex(d->model()->index(item)); + setCurrentIndex(d->tableModel()->index(item)); } /*! @@ -2138,7 +2138,7 @@ void QTableWidget::setCurrentItem(QTableWidgetItem *item) void QTableWidget::setCurrentItem(QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command) { Q_D(QTableWidget); - d->selectionModel->setCurrentIndex(d->model()->index(item), command); + d->selectionModel->setCurrentIndex(d->tableModel()->index(item), command); } /*! @@ -2177,7 +2177,7 @@ void QTableWidget::setCurrentCell(int row, int column, QItemSelectionModel::Sele void QTableWidget::sortItems(int column, Qt::SortOrder order) { Q_D(QTableWidget); - d->model()->sort(column, order); + d->model->sort(column, order); horizontalHeader()->setSortIndicator(column, order); } @@ -2206,7 +2206,7 @@ void QTableWidget::editItem(QTableWidgetItem *item) Q_D(QTableWidget); if (!item) return; - edit(d->model()->index(item)); + edit(d->tableModel()->index(item)); } /*! @@ -2219,7 +2219,7 @@ void QTableWidget::openPersistentEditor(QTableWidgetItem *item) Q_D(QTableWidget); if (!item) return; - QModelIndex index = d->model()->index(item); + QModelIndex index = d->tableModel()->index(item); QAbstractItemView::openPersistentEditor(index); } @@ -2233,7 +2233,7 @@ void QTableWidget::closePersistentEditor(QTableWidgetItem *item) Q_D(QTableWidget); if (!item) return; - QModelIndex index = d->model()->index(item); + QModelIndex index = d->tableModel()->index(item); QAbstractItemView::closePersistentEditor(index); } @@ -2283,7 +2283,7 @@ void QTableWidget::setCellWidget(int row, int column, QWidget *widget) bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const { Q_D(const QTableWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->tableModel()->index(item); return selectionModel()->isSelected(index); } @@ -2297,7 +2297,7 @@ bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const void QTableWidget::setItemSelected(const QTableWidgetItem *item, bool select) { Q_D(QTableWidget); - QModelIndex index = d->model()->index(item); + QModelIndex index = d->tableModel()->index(item); selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); } @@ -2354,7 +2354,7 @@ QList QTableWidget::selectedItems() QModelIndex index = indexes.at(i); if (isIndexHidden(index)) continue; - QTableWidgetItem *item = d->model()->item(index); + QTableWidgetItem *item = d->tableModel()->item(index); if (item) items.append(item); } @@ -2370,11 +2370,11 @@ QList QTableWidget::findItems(const QString &text, Qt::MatchF Q_D(const QTableWidget); QModelIndexList indexes; for (int column = 0; column < columnCount(); ++column) - indexes += d->model()->match(model()->index(0, column, QModelIndex()), + indexes += d->model->match(model()->index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags); QList items; for (int i = 0; i < indexes.size(); ++i) - items.append(d->model()->item(indexes.at(i))); + items.append(d->tableModel()->item(indexes.at(i))); return items; } @@ -2408,7 +2408,7 @@ int QTableWidget::visualColumn(int logicalColumn) const QTableWidgetItem *QTableWidget::itemAt(const QPoint &p) const { Q_D(const QTableWidget); - return d->model()->item(indexAt(p)); + return d->tableModel()->item(indexAt(p)); } /*! @@ -2419,7 +2419,7 @@ QRect QTableWidget::visualItemRect(const QTableWidgetItem *item) const Q_D(const QTableWidget); if (!item) return QRect(); - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->tableModel()->index(const_cast(item)); Q_ASSERT(index.isValid()); return visualRect(index); } @@ -2435,7 +2435,7 @@ void QTableWidget::scrollToItem(const QTableWidgetItem *item, QAbstractItemView: Q_D(QTableWidget); if (!item) return; - QModelIndex index = d->model()->index(const_cast(item)); + QModelIndex index = d->tableModel()->index(const_cast(item)); Q_ASSERT(index.isValid()); QTableView::scrollTo(index, hint); } @@ -2448,7 +2448,7 @@ void QTableWidget::scrollToItem(const QTableWidgetItem *item, QAbstractItemView: const QTableWidgetItem *QTableWidget::itemPrototype() const { Q_D(const QTableWidget); - return d->model()->itemPrototype(); + return d->tableModel()->itemPrototype(); } /*! @@ -2467,7 +2467,7 @@ const QTableWidgetItem *QTableWidget::itemPrototype() const void QTableWidget::setItemPrototype(const QTableWidgetItem *item) { Q_D(QTableWidget); - d->model()->setItemPrototype(item); + d->tableModel()->setItemPrototype(item); } /*! @@ -2476,7 +2476,7 @@ void QTableWidget::setItemPrototype(const QTableWidgetItem *item) void QTableWidget::insertRow(int row) { Q_D(QTableWidget); - d->model()->insertRows(row); + d->tableModel()->insertRows(row); } /*! @@ -2485,7 +2485,7 @@ void QTableWidget::insertRow(int row) void QTableWidget::insertColumn(int column) { Q_D(QTableWidget); - d->model()->insertColumns(column); + d->tableModel()->insertColumns(column); } /*! @@ -2494,7 +2494,7 @@ void QTableWidget::insertColumn(int column) void QTableWidget::removeRow(int row) { Q_D(QTableWidget); - d->model()->removeRows(row); + d->tableModel()->removeRows(row); } /*! @@ -2503,7 +2503,7 @@ void QTableWidget::removeRow(int row) void QTableWidget::removeColumn(int column) { Q_D(QTableWidget); - d->model()->removeColumns(column); + d->tableModel()->removeColumns(column); } /*! @@ -2516,7 +2516,7 @@ void QTableWidget::clear() { Q_D(QTableWidget); selectionModel()->clear(); - d->model()->clear(); + d->tableModel()->clear(); } /*! @@ -2530,7 +2530,7 @@ void QTableWidget::clearContents() { Q_D(QTableWidget); selectionModel()->clear(); - d->model()->clearContents(); + d->tableModel()->clearContents(); } /*! @@ -2541,7 +2541,7 @@ void QTableWidget::clearContents() */ QStringList QTableWidget::mimeTypes() const { - return d_func()->model()->QAbstractTableModel::mimeTypes(); + return d_func()->tableModel()->QAbstractTableModel::mimeTypes(); } /*! @@ -2554,7 +2554,7 @@ QStringList QTableWidget::mimeTypes() const */ QMimeData *QTableWidget::mimeData(const QList) const { - return d_func()->model()->internalMimeData(); + return d_func()->tableModel()->internalMimeData(); } /*! @@ -2576,7 +2576,7 @@ bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt:: column = -1; } #endif - return d_func()->model()->QAbstractTableModel::dropMimeData(data, action , row, column, idx); + return d_func()->tableModel()->QAbstractTableModel::dropMimeData(data, action , row, column, idx); } /*! @@ -2586,7 +2586,7 @@ bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt:: */ Qt::DropActions QTableWidget::supportedDropActions() const { - return d_func()->model()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; + return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; } /*! @@ -2610,7 +2610,7 @@ QList QTableWidget::items(const QMimeData *data) const QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const { Q_D(const QTableWidget); - return d->model()->index(item); + return d->tableModel()->index(item); } /*! @@ -2620,7 +2620,7 @@ QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const QTableWidgetItem *QTableWidget::itemFromIndex(const QModelIndex &index) const { Q_D(const QTableWidget); - return d->model()->item(index); + return d->tableModel()->item(index); } /*! diff --git a/src/gui/itemviews/qtablewidget_p.h b/src/gui/itemviews/qtablewidget_p.h index d8bfcc5..2acaf9b 100644 --- a/src/gui/itemviews/qtablewidget_p.h +++ b/src/gui/itemviews/qtablewidget_p.h @@ -189,7 +189,7 @@ class QTableWidgetPrivate : public QTableViewPrivate Q_DECLARE_PUBLIC(QTableWidget) public: QTableWidgetPrivate() : QTableViewPrivate() {} - inline QTableModel *model() const { return qobject_cast(q_func()->model()); } + inline QTableModel *tableModel() const { return qobject_cast(model); } void setup(); // view signals diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 53fa170..ecbd683 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3485,7 +3485,7 @@ void QTreeViewPrivate::updateScrollBars() int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const { - const_cast(q_func())->executeDelayedItemsLayout(); + executePostedLayout(); int x = pos.x(); int column = header->logicalIndexAt(x); if (column != 0) diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 24713c4..2a6ac30 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -2283,7 +2283,7 @@ void QTreeWidgetPrivate::_q_sort() if (sortingEnabled) { int column = header->sortIndicatorSection(); Qt::SortOrder order = header->sortIndicatorOrder(); - model()->sort(column, order); + treeModel()->sort(column, order); } } @@ -2292,7 +2292,7 @@ void QTreeWidgetPrivate::_q_selectionChanged(const QItemSelection &selected, con Q_Q(QTreeWidget); QModelIndexList indices = selected.indexes(); int i; - QTreeModel *m = model(); + QTreeModel *m = treeModel(); for (i = 0; i < indices.count(); ++i) { QTreeWidgetItem *item = m->item(indices.at(i)); item->d->selected = true; @@ -2311,11 +2311,11 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { if (sortingEnabled && topLeft.isValid() && bottomRight.isValid() - && !model()->sortPendingTimer.isActive()) { + && !treeModel()->sortPendingTimer.isActive()) { int column = header->sortIndicatorSection(); if (column >= topLeft.column() && column <= bottomRight.column()) { Qt::SortOrder order = header->sortIndicatorOrder(); - model()->ensureSorted(column, order, topLeft.row(), + treeModel()->ensureSorted(column, order, topLeft.row(), bottomRight.row(), topLeft.parent()); } } @@ -2543,7 +2543,7 @@ QTreeWidget::~QTreeWidget() int QTreeWidget::columnCount() const { Q_D(const QTreeWidget); - return d->model()->columnCount(); + return d->model->columnCount(); } /* @@ -2555,7 +2555,7 @@ void QTreeWidget::setColumnCount(int columns) Q_D(QTreeWidget); if (columns < 0) return; - d->model()->setColumnCount(columns); + d->treeModel()->setColumnCount(columns); } /*! @@ -2572,7 +2572,7 @@ void QTreeWidget::setColumnCount(int columns) QTreeWidgetItem *QTreeWidget::invisibleRootItem() const { Q_D(const QTreeWidget); - return d->model()->rootItem; + return d->treeModel()->rootItem; } /*! @@ -2585,7 +2585,7 @@ QTreeWidgetItem *QTreeWidget::invisibleRootItem() const QTreeWidgetItem *QTreeWidget::topLevelItem(int index) const { Q_D(const QTreeWidget); - return d->model()->rootItem->child(index); + return d->treeModel()->rootItem->child(index); } /*! @@ -2600,7 +2600,7 @@ QTreeWidgetItem *QTreeWidget::topLevelItem(int index) const int QTreeWidget::topLevelItemCount() const { Q_D(const QTreeWidget); - return d->model()->rootItem->childCount(); + return d->treeModel()->rootItem->childCount(); } /*! @@ -2614,7 +2614,7 @@ int QTreeWidget::topLevelItemCount() const void QTreeWidget::insertTopLevelItem(int index, QTreeWidgetItem *item) { Q_D(QTreeWidget); - d->model()->rootItem->insertChild(index, item); + d->treeModel()->rootItem->insertChild(index, item); } /*! @@ -2639,7 +2639,7 @@ void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item) QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index) { Q_D(QTreeWidget); - return d->model()->rootItem->takeChild(index); + return d->treeModel()->rootItem->takeChild(index); } /*! @@ -2648,8 +2648,8 @@ QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index) int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) { Q_D(QTreeWidget); - d->model()->executePendingSort(); - return d->model()->rootItem->children.indexOf(item); + d->treeModel()->executePendingSort(); + return d->treeModel()->rootItem->children.indexOf(item); } /*! @@ -2661,8 +2661,8 @@ int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - d->model()->executePendingSort(); - return d->model()->rootItem->children.indexOf(item); + d->treeModel()->executePendingSort(); + return d->treeModel()->rootItem->children.indexOf(item); } /*! @@ -2677,7 +2677,7 @@ int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) const void QTreeWidget::insertTopLevelItems(int index, const QList &items) { Q_D(QTreeWidget); - d->model()->rootItem->insertChildren(index, items); + d->treeModel()->rootItem->insertChildren(index, items); } /*! @@ -2699,7 +2699,7 @@ void QTreeWidget::addTopLevelItems(const QList &items) QTreeWidgetItem *QTreeWidget::headerItem() const { Q_D(const QTreeWidget); - return d->model()->headerItem; + return d->treeModel()->headerItem; } /*! @@ -2720,16 +2720,16 @@ void QTreeWidget::setHeaderItem(QTreeWidgetItem *item) int oldCount = columnCount(); if (oldCount < item->columnCount()) - d->model()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount()); + d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount()); else - d->model()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount); - delete d->model()->headerItem; - d->model()->headerItem = item; + d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount); + delete d->treeModel()->headerItem; + d->treeModel()->headerItem = item; if (oldCount < item->columnCount()) - d->model()->endInsertColumns(); + d->treeModel()->endInsertColumns(); else - d->model()->endRemoveColumns(); - d->model()->headerDataChanged(Qt::Horizontal, 0, oldCount); + d->treeModel()->endRemoveColumns(); + d->treeModel()->headerDataChanged(Qt::Horizontal, 0, oldCount); } @@ -2746,8 +2746,7 @@ void QTreeWidget::setHeaderLabels(const QStringList &labels) Q_D(QTreeWidget); if (columnCount() < labels.count()) setColumnCount(labels.count()); - QTreeModel *model = d->model(); - QTreeWidgetItem *item = model->headerItem; + QTreeWidgetItem *item = d->treeModel()->headerItem; for (int i = 0; i < labels.count(); ++i) item->setText(i, labels.at(i)); } @@ -2875,7 +2874,7 @@ void QTreeWidget::sortItems(int column, Qt::SortOrder order) { Q_D(QTreeWidget); header()->setSortIndicator(column, order); - d->model()->sort(column, order); + d->model->sort(column, order); } /*! @@ -3042,7 +3041,7 @@ QList QTreeWidget::selectedItems() const QList QTreeWidget::findItems(const QString &text, Qt::MatchFlags flags, int column) const { Q_D(const QTreeWidget); - QModelIndexList indexes = d->model()->match(model()->index(0, column, QModelIndex()), + QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags); QList items; for (int i = 0; i < indexes.size(); ++i) @@ -3060,11 +3059,11 @@ QList QTreeWidget::findItems(const QString &text, Qt::MatchFla bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - if (item == d->model()->headerItem) + if (item == d->treeModel()->headerItem) return header()->isHidden(); if (d->hiddenIndexes.isEmpty()) return false; - QTreeModel::SkipSorting skipSorting(d->model()); + QTreeModel::SkipSorting skipSorting(d->treeModel()); return d->isRowHidden(d->index(item)); } @@ -3080,7 +3079,7 @@ bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide) { Q_D(QTreeWidget); - if (item == d->model()->headerItem) { + if (item == d->treeModel()->headerItem) { header()->setHidden(hide); } else { const QModelIndex index = d->index(item); @@ -3100,7 +3099,7 @@ void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide) bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - QTreeModel::SkipSorting skipSorting(d->model()); + QTreeModel::SkipSorting skipSorting(d->treeModel()); return isExpanded(d->index(item)); } @@ -3117,7 +3116,7 @@ bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand) { Q_D(QTreeWidget); - QTreeModel::SkipSorting skipSorting(d->model()); + QTreeModel::SkipSorting skipSorting(d->treeModel()); setExpanded(d->index(item), expand); } @@ -3132,7 +3131,7 @@ void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand) bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - if (item == d->model()->headerItem) + if (item == d->treeModel()->headerItem) return false; // We can't set the header items to spanning const QModelIndex index = d->index(item); return isFirstColumnSpanned(index.row(), index.parent()); @@ -3149,7 +3148,7 @@ bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span) { Q_D(QTreeWidget); - if (item == d->model()->headerItem) + if (item == d->treeModel()->headerItem) return; // We can't set header items to spanning const QModelIndex index = d->index(item); setFirstColumnSpanned(index.row(), index.parent(), span); @@ -3163,7 +3162,7 @@ void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool sp QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - if (item == d->model()->headerItem) + if (item == d->treeModel()->headerItem) return 0; const QModelIndex index = d->index(item); const QModelIndex above = indexAbove(index); @@ -3178,7 +3177,7 @@ QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); - if (item == d->model()->headerItem) + if (item == d->treeModel()->headerItem) return 0; const QModelIndex index = d->index(item); const QModelIndex below = indexBelow(index); @@ -3218,7 +3217,7 @@ void QTreeWidget::scrollToItem(const QTreeWidgetItem *item, QAbstractItemView::S void QTreeWidget::expandItem(const QTreeWidgetItem *item) { Q_D(QTreeWidget); - QTreeModel::SkipSorting skipSorting(d->model()); + QTreeModel::SkipSorting skipSorting(d->treeModel()); expand(d->index(item)); } @@ -3231,7 +3230,7 @@ void QTreeWidget::expandItem(const QTreeWidgetItem *item) void QTreeWidget::collapseItem(const QTreeWidgetItem *item) { Q_D(QTreeWidget); - QTreeModel::SkipSorting skipSorting(d->model()); + QTreeModel::SkipSorting skipSorting(d->treeModel()); collapse(d->index(item)); } @@ -3248,7 +3247,7 @@ void QTreeWidget::clear() { Q_D(QTreeWidget); selectionModel()->clear(); - d->model()->clear(); + d->treeModel()->clear(); } /*! @@ -3273,7 +3272,7 @@ QStringList QTreeWidget::mimeTypes() const QMimeData *QTreeWidget::mimeData(const QList items) const { Q_D(const QTreeWidget); - if (d->model()->cachedIndexes.isEmpty()) { + if (d->treeModel()->cachedIndexes.isEmpty()) { QList indexes; for (int i = 0; i < items.count(); ++i) { QTreeWidgetItem *item = items.at(i); @@ -3281,9 +3280,9 @@ QMimeData *QTreeWidget::mimeData(const QList items) const indexes << indexFromItem(item, c); } } - return model()->QAbstractItemModel::mimeData(indexes); + return d->model->QAbstractItemModel::mimeData(indexes); } - return d->model()->internalMimeData(); + return d->treeModel()->internalMimeData(); } /*! @@ -3427,7 +3426,7 @@ bool QTreeWidget::event(QEvent *e) { Q_D(QTreeWidget); if (e->type() == QEvent::Polish) - d->model()->executePendingSort(); + d->treeModel()->executePendingSort(); return QTreeView::event(e); } diff --git a/src/gui/itemviews/qtreewidget_p.h b/src/gui/itemviews/qtreewidget_p.h index a089cf5..fb0ee11 100644 --- a/src/gui/itemviews/qtreewidget_p.h +++ b/src/gui/itemviews/qtreewidget_p.h @@ -219,12 +219,11 @@ class QTreeWidgetPrivate : public QTreeViewPrivate Q_DECLARE_PUBLIC(QTreeWidget) public: QTreeWidgetPrivate() : QTreeViewPrivate(), explicitSortColumn(-1) {} - inline QTreeModel *model() const - { return qobject_cast(q_func()->model()); } + inline QTreeModel *treeModel() const { return qobject_cast(model); } inline QModelIndex index(const QTreeWidgetItem *item, int column = 0) const - { return model()->index(item, column); } + { return treeModel()->index(item, column); } inline QTreeWidgetItem *item(const QModelIndex &index) const - { return model()->item(index); } + { return treeModel()->item(index); } void _q_emitItemPressed(const QModelIndex &index); void _q_emitItemClicked(const QModelIndex &index); void _q_emitItemDoubleClicked(const QModelIndex &index); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index fa032e6..cf40ad8 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -3205,18 +3205,16 @@ bool QTextDocumentLayout::contentHasAlignment() const qreal QTextDocumentLayoutPrivate::scaleToDevice(qreal value) const { - QPaintDevice *dev = q_func()->paintDevice(); - if (!dev) + if (!paintDevice) return value; - return value * dev->logicalDpiY() / qreal(qt_defaultDpi()); + return value * paintDevice->logicalDpiY() / qreal(qt_defaultDpi()); } QFixed QTextDocumentLayoutPrivate::scaleToDevice(QFixed value) const { - QPaintDevice *dev = q_func()->paintDevice(); - if (!dev) + if (!paintDevice) return value; - return value * QFixed(dev->logicalDpiY()) / QFixed(qt_defaultDpi()); + return value * QFixed(paintDevice->logicalDpiY()) / QFixed(qt_defaultDpi()); } QT_END_NAMESPACE -- cgit v0.12 From 35e2a2978a2318ca025393a8f67d30746c8b78fc Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 11 Jun 2009 13:39:09 +0200 Subject: Removed qApp and replaced with QApplication:: for static member calls --- src/gui/accessible/qaccessible_win.cpp | 4 +- src/gui/accessible/qaccessibleobject.cpp | 14 ++--- src/gui/dialogs/qcolordialog.cpp | 2 +- src/gui/dialogs/qerrormessage.cpp | 2 +- src/gui/dialogs/qfiledialog_win.cpp | 6 +-- src/gui/dialogs/qfilesystemmodel.cpp | 2 +- src/gui/dialogs/qmessagebox.cpp | 10 ++-- src/gui/dialogs/qpagesetupdialog_win.cpp | 2 +- src/gui/dialogs/qprintdialog_win.cpp | 2 +- src/gui/dialogs/qprogressdialog.cpp | 2 +- src/gui/dialogs/qwizard.cpp | 2 +- src/gui/dialogs/qwizard_win.cpp | 4 +- src/gui/graphicsview/qgraphicsgridlayout.cpp | 2 +- src/gui/graphicsview/qgraphicslinearlayout.cpp | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 16 +++--- src/gui/image/qicon.cpp | 2 +- src/gui/inputmethod/qinputcontext.cpp | 4 +- src/gui/inputmethod/qwininputcontext_win.cpp | 4 +- src/gui/itemviews/qabstractitemview.cpp | 2 +- src/gui/itemviews/qcolumnview.cpp | 2 +- src/gui/kernel/qapplication.cpp | 36 ++++++------- src/gui/kernel/qapplication_win.cpp | 74 +++++++++++++------------- src/gui/kernel/qcursor.cpp | 2 +- src/gui/kernel/qdnd.cpp | 2 +- src/gui/kernel/qdnd_win.cpp | 2 +- src/gui/kernel/qshortcutmap.cpp | 6 +-- src/gui/kernel/qwidget.cpp | 24 ++++----- src/gui/kernel/qwidget_win.cpp | 6 +-- src/gui/painting/qbackingstore.cpp | 4 +- src/gui/styles/qcleanlooksstyle.cpp | 4 +- src/gui/styles/qcommonstyle.cpp | 6 +-- src/gui/styles/qstylesheetstyle.cpp | 8 +-- src/gui/styles/qwindowsvistastyle.cpp | 4 +- src/gui/styles/qwindowsxpstyle.cpp | 6 +-- src/gui/text/qfontdatabase.cpp | 36 ++++++------- src/gui/text/qtextcontrol.cpp | 2 +- src/gui/util/qsystemtrayicon_win.cpp | 2 +- src/gui/widgets/qabstractbutton.cpp | 2 +- src/gui/widgets/qeffects.cpp | 8 +-- src/gui/widgets/qmenu.cpp | 12 ++--- src/gui/widgets/qmenubar.cpp | 4 +- src/gui/widgets/qpushbutton.cpp | 4 +- src/gui/widgets/qtabwidget.cpp | 2 +- src/gui/widgets/qtextbrowser.cpp | 8 +-- src/gui/widgets/qtoolbar.cpp | 4 +- src/gui/widgets/qtoolbutton.cpp | 2 +- src/gui/widgets/qwidgetresizehandler.cpp | 2 +- 47 files changed, 178 insertions(+), 180 deletions(-) diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index f287874..6195451 100644 --- a/src/gui/accessible/qaccessible_win.cpp +++ b/src/gui/accessible/qaccessible_win.cpp @@ -270,9 +270,9 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason) if (!w) { if (reason != QAccessible::ContextHelpStart && reason != QAccessible::ContextHelpEnd) - w = qApp->focusWidget(); + w = QApplication::focusWidget(); if (!w) { - w = qApp->activeWindow(); + w = QApplication::activeWindow(); if (!w) return; diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 7df097b..0c710f0 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -212,7 +212,7 @@ QAccessibleApplication::QAccessibleApplication() static QWidgetList topLevelWidgets() { QWidgetList list; - const QWidgetList tlw(qApp->topLevelWidgets()); + const QWidgetList tlw(QApplication::topLevelWidgets()); for (int i = 0; i < tlw.count(); ++i) { QWidget *w = tlw.at(i); if (!(w->windowType() == Qt::Popup) && !(w->windowType() == Qt::Desktop)) @@ -308,7 +308,7 @@ int QAccessibleApplication::navigate(RelationFlag relation, int entry, } break; case FocusChild: - targetObject = qApp->activeWindow(); + targetObject = QApplication::activeWindow(); break; default: break; @@ -322,11 +322,11 @@ QString QAccessibleApplication::text(Text t, int) const { switch (t) { case Name: - if (qApp->activeWindow()) - return qApp->activeWindow()->windowTitle(); + if (QApplication::activeWindow()) + return QApplication::activeWindow()->windowTitle(); break; case Description: - return qApp->applicationFilePath(); + return QApplication::applicationFilePath(); default: break; } @@ -342,7 +342,7 @@ QAccessible::Role QAccessibleApplication::role(int) const /*! \reimp */ QAccessible::State QAccessibleApplication::state(int) const { - return qApp->activeWindow() ? Focused : Normal; + return QApplication::activeWindow() ? Focused : Normal; } /*! \reimp */ @@ -356,7 +356,7 @@ bool QAccessibleApplication::doAction(int action, int child, const QVariantList { if (action == 0 || action == 1) { QWidget *w = 0; - w = qApp->activeWindow(); + w = QApplication::activeWindow(); if (!w) w = topLevelWidgets().at(0); if (!w) diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index dc7e3cc..8299381 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1375,7 +1375,7 @@ void QColorDialogPrivate::init(const QColor &initial) #else // small displays (e.g. PDAs) cannot fit the full color dialog, // so just use the color picker. - smallDisplay = (qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350); + smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350); const int lumSpace = topLay->spacing() / 2; #endif diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/gui/dialogs/qerrormessage.cpp index ca39d31..d24d348 100644 --- a/src/gui/dialogs/qerrormessage.cpp +++ b/src/gui/dialogs/qerrormessage.cpp @@ -300,7 +300,7 @@ QErrorMessage * QErrorMessage::qtHandler() if (!qtMessageHandler) { qtMessageHandler = new QErrorMessage(0); qAddPostRoutine(deleteStaticcQErrorMessage); // clean up - qtMessageHandler->setWindowTitle(qApp->applicationName()); + qtMessageHandler->setWindowTitle(QApplication::applicationName()); qInstallMsgHandler(jump); } return qtMessageHandler; diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 75a1820..4e818be 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -206,7 +206,7 @@ static OPENFILENAMEA *qt_win_make_OFNA(QWidget *parent, if (parent) parent = parent->window(); else - parent = qApp->activeWindow(); + parent = QApplication::activeWindow(); aTitle = title.toLocal8Bit(); aInitDir = QDir::toNativeSeparators(initialDirectory).toLocal8Bit(); @@ -279,7 +279,7 @@ static OPENFILENAME* qt_win_make_OFN(QWidget *parent, if (parent) parent = parent->window(); else - parent = qApp->activeWindow(); + parent = QApplication::activeWindow(); tInitDir = QDir::toNativeSeparators(initialDirectory); tFilters = filters; @@ -692,7 +692,7 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) if (parent) parent = parent->window(); else - parent = qApp->activeWindow(); + parent = QApplication::activeWindow(); if (parent) parent->createWinId(); diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 2c47116..603789e 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1407,7 +1407,7 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider) { Q_D(QFileSystemModel); d->fileInfoGatherer.setIconProvider(provider); - qApp->processEvents(); + QApplication::processEvents(); d->root.updateIcon(provider, QString()); } diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index c526c7d..1fefb67 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -332,7 +332,7 @@ void QMessageBoxPrivate::updateSize() label->setSizePolicy(policy); } - QFontMetrics fm(qApp->font("QWorkspaceTitleBar")); + QFontMetrics fm(QApplication::font("QWorkspaceTitleBar")); int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit); if (windowTitleWidth > width) width = windowTitleWidth; @@ -361,7 +361,7 @@ void QMessageBoxPrivate::hideSpecial() QPushButton *pb = list.at(i); QString text = pb->text(); text.remove(QChar::fromLatin1('&')); - if (text == qApp->translate("QMessageBox", "OK" )) + if (text == QApplication::translate("QMessageBox", "OK" )) pb->setFixedSize(0,0); } } @@ -1208,8 +1208,8 @@ bool QMessageBox::event(QEvent *e) case QEvent::HelpRequest: { QString bName = (e->type() == QEvent::OkRequest) - ? qApp->translate("QMessageBox", "OK") - : qApp->translate("QMessageBox", "Help"); + ? QApplication::translate("QMessageBox", "OK") + : QApplication::translate("QMessageBox", "Help"); QList list = qFindChildren(this); for (int i=0; iclipboard()->setText(textToCopy); + QApplication::clipboard()->setText(textToCopy); return; } #endif //QT_NO_SHORTCUT QT_NO_CLIPBOARD Q_OS_WIN diff --git a/src/gui/dialogs/qpagesetupdialog_win.cpp b/src/gui/dialogs/qpagesetupdialog_win.cpp index 4bb571c..2c74ed2 100644 --- a/src/gui/dialogs/qpagesetupdialog_win.cpp +++ b/src/gui/dialogs/qpagesetupdialog_win.cpp @@ -98,7 +98,7 @@ int QPageSetupDialog::exec() psd.hDevNames = tempDevNames; QWidget *parent = parentWidget(); - parent = parent ? parent->window() : qApp->activeWindow(); + parent = parent ? parent->window() : QApplication::activeWindow(); Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); psd.hwndOwner = parent ? parent->winId() : 0; diff --git a/src/gui/dialogs/qprintdialog_win.cpp b/src/gui/dialogs/qprintdialog_win.cpp index 936d1ed..2561227 100644 --- a/src/gui/dialogs/qprintdialog_win.cpp +++ b/src/gui/dialogs/qprintdialog_win.cpp @@ -225,7 +225,7 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally() if (parent) parent = parent->window(); else - parent = qApp->activeWindow(); + parent = QApplication::activeWindow(); QWidget modal_widget; modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); diff --git a/src/gui/dialogs/qprogressdialog.cpp b/src/gui/dialogs/qprogressdialog.cpp index 66a1285..b68a0a72 100644 --- a/src/gui/dialogs/qprogressdialog.cpp +++ b/src/gui/dialogs/qprogressdialog.cpp @@ -643,7 +643,7 @@ void QProgressDialog::setValue(int progress) if (d->shown_once) { if (isModal()) - qApp->processEvents(); + QApplication::processEvents(); } else { if (progress == 0) { d->starttime.start(); diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index b2ed983..7fc8a63 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -377,7 +377,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, /* There is no widthForHeight() function, so we simulate it with a loop. */ - int candidateSubTitleWidth = qMin(512, 2 * qApp->desktop()->width() / 3); + int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); int delta = candidateSubTitleWidth >> 1; while (delta > 0) { if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta) diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index 8aad4af..e0aaa19 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -279,7 +279,7 @@ QVistaHelper::VistaState QVistaHelper::vistaState() QColor QVistaHelper::basicWindowFrameColor() { DWORD rgb; - HANDLE hTheme = pOpenThemeData(qApp->desktop()->winId(), L"WINDOW"); + HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW"); pGetThemeColor( hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE, wizard->isActiveWindow() ? WIZ_TMT_FILLCOLORHINT : WIZ_TMT_BORDERCOLORHINT, @@ -611,7 +611,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q { bool value = false; if (vistaState() == VistaAero) { - HANDLE hTheme = pOpenThemeData(qApp->desktop()->winId(), L"WINDOW"); + HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW"); if (!hTheme) return false; // Set up a memory DC and bitmap that we'll draw into HDC dcMem; diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 1e21b54..36281f8 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -100,7 +100,7 @@ QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const if (!wid) wid = new QWidget; QGraphicsItem *item = parentItem(); - QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : qApp->style(); + QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : QApplication::style(); return QLayoutStyleInfo(style, wid); } diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 6a2d456..2f32950 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -178,7 +178,7 @@ QLayoutStyleInfo QGraphicsLinearLayoutPrivate::styleInfo() const if (!wid) wid = new QWidget; QGraphicsItem *item = parentItem(); - QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : qApp->style(); + QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : QApplication::style(); return QLayoutStyleInfo(style, wid); } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index e6c3503..1c48675 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2161,7 +2161,7 @@ void QGraphicsScenePrivate::setFont_helper(const QFont &font) */ void QGraphicsScenePrivate::resolveFont() { - QFont naturalFont = qApp->font(); + QFont naturalFont = QApplication::font(); naturalFont.resolve(0); QFont resolvedFont = font.resolve(naturalFont); updateFont(resolvedFont); @@ -2217,7 +2217,7 @@ void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette) */ void QGraphicsScenePrivate::resolvePalette() { - QPalette naturalPalette = qApp->palette(); + QPalette naturalPalette = QApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); updatePalette(resolvedPalette); @@ -3975,10 +3975,10 @@ bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event) switch (event->type()) { case QEvent::ApplicationPaletteChange: - qApp->postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); + QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); break; case QEvent::ApplicationFontChange: - qApp->postEvent(this, new QEvent(QEvent::ApplicationFontChange)); + QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); break; default: break; @@ -4918,7 +4918,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte bool allowPartialCacheExposure = !viewRect.contains(deviceRect); #else // Only if deviceRect is 20% taller or wider than the desktop. - QRect desktopRect = qApp->desktop()->availableGeometry(widget); + QRect desktopRect = QApplication::desktop()->availableGeometry(widget); bool allowPartialCacheExposure = (desktopRect.width() * 1.2 < deviceRect.width() || desktopRect.height() * 1.2 < deviceRect.height()); #endif @@ -5606,7 +5606,7 @@ QStyle *QGraphicsScene::style() const { Q_D(const QGraphicsScene); // ### This function, and the use of styles in general, is non-reentrant. - return d->style ? d->style : qApp->style(); + return d->style ? d->style : QApplication::style(); } /*! @@ -5683,7 +5683,7 @@ QFont QGraphicsScene::font() const void QGraphicsScene::setFont(const QFont &font) { Q_D(QGraphicsScene); - QFont naturalFont = qApp->font(); + QFont naturalFont = QApplication::font(); naturalFont.resolve(0); QFont resolvedFont = font.resolve(naturalFont); d->setFont_helper(resolvedFont); @@ -5720,7 +5720,7 @@ QPalette QGraphicsScene::palette() const void QGraphicsScene::setPalette(const QPalette &palette) { Q_D(QGraphicsScene); - QPalette naturalPalette = qApp->palette(); + QPalette naturalPalette = QApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); d->setPalette_helper(resolvedPalette); diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index f24aeff..7e262b1 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -304,7 +304,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St QString key = QLatin1String("$qt_icon_") + QString::number(pm.cacheKey()) + QString::number(pe->mode) - + QString::number(qApp->palette().cacheKey()) + + QString::number(QApplication::palette().cacheKey()) + QLatin1Char('_') + QString::number(actualSize.width()) + QLatin1Char('_') diff --git a/src/gui/inputmethod/qinputcontext.cpp b/src/gui/inputmethod/qinputcontext.cpp index f78b86a..8db326b 100644 --- a/src/gui/inputmethod/qinputcontext.cpp +++ b/src/gui/inputmethod/qinputcontext.cpp @@ -262,7 +262,7 @@ void QInputContext::sendEvent(const QInputMethodEvent &event) return; QInputMethodEvent e(event); - qApp->sendEvent(focus, &e); + QApplication::sendEvent(focus, &e); } @@ -408,7 +408,7 @@ QList QInputContext::actions() QTextFormat QInputContext::standardFormat(StandardFormat s) const { QWidget *focus = focusWidget(); - const QPalette &pal = focus ? focus->palette() : qApp->palette(); + const QPalette &pal = focus ? focus->palette() : QApplication::palette(); QTextCharFormat fmt; QColor bg; diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp index dd966d5..b94c604 100644 --- a/src/gui/inputmethod/qwininputcontext_win.cpp +++ b/src/gui/inputmethod/qwininputcontext_win.cpp @@ -539,7 +539,7 @@ bool QWinInputContext::endComposition() } if (!fw) - fw = qApp->focusWidget(); + fw = QApplication::focusWidget(); if (fw) { QInputMethodEvent e; @@ -637,7 +637,7 @@ bool QWinInputContext::composition(LPARAM lParam) // bogus event return true; - QWidget *fw = qApp->focusWidget(); + QWidget *fw = QApplication::focusWidget(); if (fw) { Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created)); HIMC imc = getContext(fw->effectiveWinId()); diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 7890e1f..9effc70 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -3784,7 +3784,7 @@ void QAbstractItemViewPrivate::clearOrRemove() void QAbstractItemViewPrivate::checkPersistentEditorFocus() { Q_Q(QAbstractItemView); - if (QWidget *widget = qApp->focusWidget()) { + if (QWidget *widget = QApplication::focusWidget()) { if (persistent.contains(widget)) { //a persistent editor has gained the focus QModelIndex index = indexForEditor(widget); diff --git a/src/gui/itemviews/qcolumnview.cpp b/src/gui/itemviews/qcolumnview.cpp index 1f88f7c..16ae8e9 100644 --- a/src/gui/itemviews/qcolumnview.cpp +++ b/src/gui/itemviews/qcolumnview.cpp @@ -1116,7 +1116,7 @@ void QColumnViewDelegate::paint(QPainter *painter, // Draw > if (index.model()->hasChildren(index)) { const QWidget *view = opt.widget; - QStyle *style = view ? view->style() : qApp->style(); + QStyle *style = view ? view->style() : QApplication::style(); style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view); } } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4923d23..cbb1f45 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -491,8 +491,6 @@ QWidgetList * qt_modal_stack=0; // stack of modal widgets */ void QApplicationPrivate::process_cmdline() { - Q_Q(QApplication); - Q_UNUSED(q);// only static members being used. // process platform-indep command line if (!qt_is_gui_used || !argc) return; @@ -537,7 +535,7 @@ void QApplicationPrivate::process_cmdline() #endif } else if (qstrcmp(arg, "-reverse") == 0) { force_reverse = true; - q->setLayoutDirection(Qt::RightToLeft); + QApplication::setLayoutDirection(Qt::RightToLeft); } else if (qstrcmp(arg, "-widgetcount") == 0) { widgetCount = true; } else if (arg == "-graphicssystem" && i < argc-1) { @@ -2577,14 +2575,14 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { QEvent leaveEvent(QEvent::Leave); for (int i = 0; i < leaveList.size(); ++i) { w = leaveList.at(i); - if (!qApp->activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { + if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { #if defined(Q_WS_WIN) || defined(Q_WS_X11) if (leaveAfterRelease == w) leaveAfterRelease = 0; #endif QApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && - (!qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) { + (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { Q_ASSERT(instance()); QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos)); qApp->d_func()->notify_helper(w, &he); @@ -2595,10 +2593,10 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { QEvent enterEvent(QEvent::Enter); for (int i = 0; i < enterList.size(); ++i) { w = enterList.at(i); - if (!qApp->activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { + if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { QApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && - (!qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) { + (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1)); qApp->d_func()->notify_helper(w, &he); } @@ -2672,7 +2670,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) widget = widget->window(); if (!modalState()) return false; - if (qApp->activePopupWidget() == widget) + if (QApplication::activePopupWidget() == widget) return false; for (int i = 0; i < qt_modal_stack->size(); ++i) { @@ -2761,7 +2759,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) void QApplicationPrivate::enterModal(QWidget *widget) { QSet blocked; - QList windows = qApp->topLevelWidgets(); + QList windows = QApplication::topLevelWidgets(); for (int i = 0; i < windows.count(); ++i) { QWidget *window = windows.at(i); if (window->windowType() != Qt::Tool && isBlockedByModal(window)) @@ -2770,7 +2768,7 @@ void QApplicationPrivate::enterModal(QWidget *widget) enterModal_sys(widget); - windows = qApp->topLevelWidgets(); + windows = QApplication::topLevelWidgets(); QEvent e(QEvent::WindowBlocked); for (int i = 0; i < windows.count(); ++i) { QWidget *window = windows.at(i); @@ -2784,7 +2782,7 @@ void QApplicationPrivate::enterModal(QWidget *widget) void QApplicationPrivate::leaveModal(QWidget *widget) { QSet blocked; - QList windows = qApp->topLevelWidgets(); + QList windows = QApplication::topLevelWidgets(); for (int i = 0; i < windows.count(); ++i) { QWidget *window = windows.at(i); if (window->windowType() != Qt::Tool && isBlockedByModal(window)) @@ -2793,7 +2791,7 @@ void QApplicationPrivate::leaveModal(QWidget *widget) leaveModal_sys(widget); - windows = qApp->topLevelWidgets(); + windows = QApplication::topLevelWidgets(); QEvent e(QEvent::WindowUnblocked); for (int i = 0; i < windows.count(); ++i) { QWidget *window = windows.at(i); @@ -2816,7 +2814,7 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) *rettop = top; // the active popup widget always gets the input event - if (qApp->activePopupWidget()) + if (QApplication::activePopupWidget()) return true; #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) @@ -2882,7 +2880,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, QPointer receiverGuard = receiver; QPointer nativeGuard = nativeWidget; QPointer alienGuard = alienWidget; - QPointer activePopupWidget = qApp->activePopupWidget(); + QPointer activePopupWidget = QApplication::activePopupWidget(); const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen); @@ -3779,7 +3777,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos); while (w) { if (w->testAttribute(Qt::WA_Hover) && - (!qApp->activePopupWidget() || qApp->activePopupWidget() == w->window())) { + (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff); d->notify_helper(w, &he); } @@ -4038,7 +4036,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) #if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR)) // toggle HasMouse widget state on enter and leave if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) && - (!qApp->activePopupWidget() || qApp->activePopupWidget() == widget->window())) + (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window())) widget->setAttribute(Qt::WA_UnderMouse, true); else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave) widget->setAttribute(Qt::WA_UnderMouse, false); @@ -4568,9 +4566,9 @@ void QSessionManager::requestPhase2() \oldcode app.setWinStyleHighlightColor(color); \newcode - QPalette palette(qApp->palette()); + QPalette palette(QApplication::palette()); palette.setColor(QPalette::Highlight, color); - qApp->setPalette(palette); + QApplication::setPalette(palette); \endcode */ @@ -4589,7 +4587,7 @@ void QSessionManager::requestPhase2() /*! \fn const QColor &QApplication::winStyleHighlightColor() - Use qApp->palette().color(QPalette::Active, QPalette::Highlight) instead. + Use QApplication::palette().color(QPalette::Active, QPalette::Highlight) instead. */ /*! diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 8d77c4c..f449141 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1526,13 +1526,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam int index = QApplication::staticMetaObject.indexOfSignal("aboutToQuit()"); qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0); // since the process will be killed immediately quit() has no real effect - qApp->quit(); + QApplication::quit(); } RETURN(0); } case WM_DISPLAYCHANGE: - if (qApp->type() == QApplication::Tty) + if (QApplication::type() == QApplication::Tty) break; if (qt_desktopWidget) { qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77)); @@ -1558,7 +1558,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam } #endif // ignore spurious XP message when user logs in again after locking - if (qApp->type() == QApplication::Tty) + if (QApplication::type() == QApplication::Tty) break; if (QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA) { widget = (QETWidget*)QWidget::find(hwnd); @@ -1581,7 +1581,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam if (wParam == SPI_SETFONTSMOOTHINGTYPE) { qt_win_read_cleartype_settings(); - foreach (QWidget *w, qApp->topLevelWidgets()) { + foreach (QWidget *w, QApplication::topLevelWidgets()) { if (!w->isVisible()) continue; ((QETWidget *) w)->forceUpdate(); @@ -1590,7 +1590,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam break; case WM_SYSCOLORCHANGE: - if (qApp->type() == QApplication::Tty) + if (QApplication::type() == QApplication::Tty) break; if (QApplication::desktopSettingsAware()) { widget = (QETWidget*)QWidget::find(hwnd); @@ -1642,7 +1642,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam RETURN(res); if (qt_is_translatable_mouse_event(message)) { - if (qApp->activePopupWidget() != 0) { // in popup mode + if (QApplication::activePopupWidget() != 0) { // in popup mode POINT curPos = msg.pt; QWidget* w = QApplication::widgetAt(curPos.x, curPos.y); if (w) @@ -1652,9 +1652,9 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam if (!qt_tabletChokeMouse) { result = widget->translateMouseEvent(msg); // mouse event #if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU) - if (message == WM_LBUTTONDOWN && widget != qApp->activePopupWidget()) { + if (message == WM_LBUTTONDOWN && widget != QApplication::activePopupWidget()) { QWidget* alienWidget = widget; - if ((alienWidget != qApp->activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) { + if ((alienWidget != QApplication::activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) { QPoint pos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); QPoint globalPos(msg.pt.x, msg.pt.y); // In case we are using Alien, then the widget to @@ -1673,8 +1673,8 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION; resolveAygLibs(); if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) { - if (qApp->activePopupWidget()) - qApp->activePopupWidget()->close(); + if (QApplication::activePopupWidget()) + QApplication::activePopupWidget()->close(); QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos); result = qt_sendSpontaneousEvent(alienWidget, &e); } @@ -1752,7 +1752,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam widget = (QETWidget*)QApplication::activePopupWidget()->focusWidget() ? (QETWidget*)QApplication::activePopupWidget()->focusWidget() : (QETWidget*)QApplication::activePopupWidget(); - else if (qApp->focusWidget()) + else if (QApplication::focusWidget()) widget = (QETWidget*)QApplication::focusWidget(); else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget. widget = (QETWidget*)widget->window(); @@ -1875,8 +1875,8 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam QWidget *g = QWidget::keyboardGrabber(); if (g) widget = (QETWidget*)g; - else if (qApp->focusWidget()) - widget = (QETWidget*)qApp->focusWidget(); + else if (QApplication::focusWidget()) + widget = (QETWidget*)QApplication::focusWidget(); else widget = (QETWidget*)widget->window(); if (widget->isEnabled()) { @@ -1991,7 +1991,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam } case WM_SETTINGCHANGE: - if ( qApp->type() == QApplication::Tty ) + if ( QApplication::type() == QApplication::Tty ) break; if (!msg.wParam) { @@ -2004,7 +2004,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam } } else if (msg.wParam == SPI_SETICONTITLELOGFONT) { - if (qApp->desktopSettingsAware()) { + if (QApplication::desktopSettingsAware()) { widget = (QETWidget*)QWidget::find(hwnd); if (widget && !widget->parentWidget()) { qt_set_windows_font_resources(); @@ -2047,7 +2047,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam break; case WM_ACTIVATE: - if ( qApp->type() == QApplication::Tty ) + if ( QApplication::type() == QApplication::Tty ) break; if (ptrWTOverlap && ptrWTEnable) { @@ -2276,12 +2276,12 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam QWidget *fw = QWidget::keyboardGrabber(); if (!fw) { - if (qApp->activePopupWidget()) - fw = (qApp->activePopupWidget()->focusWidget() - ? qApp->activePopupWidget()->focusWidget() - : qApp->activePopupWidget()); - else if (qApp->focusWidget()) - fw = qApp->focusWidget(); + if (QApplication::activePopupWidget()) + fw = (QApplication::activePopupWidget()->focusWidget() + ? QApplication::activePopupWidget()->focusWidget() + : QApplication::activePopupWidget()); + else if (QApplication::focusWidget()) + fw = QApplication::focusWidget(); else if (widget) fw = widget->window(); } @@ -2298,7 +2298,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_COMPOSITION: { - QWidget *fw = qApp->focusWidget(); + QWidget *fw = QApplication::focusWidget(); QWinInputContext *im = fw ? qobject_cast(fw->inputContext()) : 0; if (fw && im) { if(message == WM_IME_STARTCOMPOSITION) @@ -2331,7 +2331,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case WM_GETOBJECT: { // Ignoring all requests while starting up - if (qApp->startingUp() || qApp->closingDown() || (DWORD)lParam != OBJID_CLIENT) { + if (QApplication::startingUp() || QApplication::closingDown() || (DWORD)lParam != OBJID_CLIENT) { result = false; break; } @@ -2431,7 +2431,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case WM_KILLFOCUS: if (!QWidget::find((HWND)wParam)) { // we don't get focus, so unset it now if (!widget->hasFocus()) // work around Windows bug after minimizing/restoring - widget = (QETWidget*)qApp->focusWidget(); + widget = (QETWidget*)QApplication::focusWidget(); HWND focus = ::GetFocus(); //if there is a current widget and the new widget belongs to the same toplevel window //or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP) @@ -2450,16 +2450,16 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam } break; case WM_THEMECHANGED: - if ((widget->windowType() == Qt::Desktop) || !qApp || qApp->closingDown() - || qApp->type() == QApplication::Tty) + if ((widget->windowType() == Qt::Desktop) || !qApp || QApplication::closingDown() + || QApplication::type() == QApplication::Tty) break; if (widget->testAttribute(Qt::WA_WState_Polished)) - qApp->style()->unpolish(widget); + QApplication::style()->unpolish(widget); if (widget->testAttribute(Qt::WA_WState_Polished)) - qApp->style()->polish(widget); - widget->repolishStyle(*qApp->style()); + QApplication::style()->polish(widget); + widget->repolishStyle(*QApplication::style()); if (widget->isVisible()) widget->update(); break; @@ -3047,7 +3047,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg) HWND id = effectiveWinId(); QWidget *mouseGrabber = QWidget::mouseGrabber(); - QWidget *activePopupWidget = qApp->activePopupWidget(); + QWidget *activePopupWidget = QApplication::activePopupWidget(); if (mouseGrabber) { if (!activePopupWidget || (activePopupWidget == this && !rect().contains(widgetPos))) id = mouseGrabber->effectiveWinId(); @@ -3140,7 +3140,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg) return false; replayPopupMouseEvent = false; - QWidget* activePopupWidget = qApp->activePopupWidget(); + QWidget* activePopupWidget = QApplication::activePopupWidget(); QWidget *target = activePopupWidget; const QPoint globalPos(gpos.x, gpos.y); @@ -3198,7 +3198,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg) } if (type == QEvent::MouseButtonPress - && qApp->activePopupWidget() != activePopupWidget + && QApplication::activePopupWidget() != activePopupWidget && replayPopupMouseEvent) { // the popup dissappeared. Replay the event QWidget* w = QApplication::widgetAt(gpos.x, gpos.y); @@ -3215,7 +3215,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg) winPostMessage(hwndTarget, msg.message, msg.wParam, lParam); } } else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton - && qApp->activePopupWidget() == activePopupWidget) { + && QApplication::activePopupWidget() == activePopupWidget) { // popup still alive and received right-button-release #if !defined(QT_NO_CONTEXTMENU) QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos, @@ -3325,7 +3325,7 @@ bool QETWidget::translateWheelEvent(const MSG &msg) // send the event to the widget or its ancestors { - QWidget* popup = qApp->activePopupWidget(); + QWidget* popup = QApplication::activePopupWidget(); if (popup && w->window() != popup) popup->close(); #ifndef QT_NO_WHEELEVENT @@ -3341,8 +3341,8 @@ bool QETWidget::translateWheelEvent(const MSG &msg) } // send the event to the widget that has the focus or its ancestors, if different - if (w != qApp->focusWidget() && (w = qApp->focusWidget())) { - QWidget* popup = qApp->activePopupWidget(); + if (w != QApplication::focusWidget() && (w = QApplication::focusWidget())) { + QWidget* popup = QApplication::activePopupWidget(); if (popup && w->window() != popup) popup->close(); #ifndef QT_NO_WHEELEVENT diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 598f4ba..4ffa8fd 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -403,7 +403,7 @@ void QCursorData::initialize() QCursor::QCursor() { if (!QCursorData::initialized) { - if (qApp->startingUp()) { + if (QApplication::startingUp()) { d = 0; return; } diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index a5092a0..e83a2ae 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -368,7 +368,7 @@ QDragManager::~QDragManager() QDragManager *QDragManager::self() { - if (!instance && qApp && !qApp->closingDown()) + if (!instance && !QApplication::closingDown()) instance = new QDragManager; return instance; } diff --git a/src/gui/kernel/qdnd_win.cpp b/src/gui/kernel/qdnd_win.cpp index 8bf5c84..b8c65e8 100644 --- a/src/gui/kernel/qdnd_win.cpp +++ b/src/gui/kernel/qdnd_win.cpp @@ -549,7 +549,7 @@ QOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) return ResultFromScode(DRAGDROP_S_DROP); } #endif - qApp->processEvents(); + QApplication::processEvents(); return NOERROR; } } diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 3c2fcdd..735fe0f 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -628,13 +628,13 @@ QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1, bool QShortcutMap::correctContext(const QShortcutEntry &item) const { Q_ASSERT_X(item.owner, "QShortcutMap", "Shortcut has no owner. Illegal map state!"); - QWidget *active_window = qApp->activeWindow(); + QWidget *active_window = QApplication::activeWindow(); // popups do not become the active window, // so we fake it here to get the correct context // for the shortcut system. - if (qApp->activePopupWidget()) - active_window = qApp->activePopupWidget(); + if (QApplication::activePopupWidget()) + active_window = QApplication::activePopupWidget(); if (!active_window) return false; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 230b8f6..7b0bf1e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1052,7 +1052,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) { Q_Q(QWidget); - if (qApp->type() == QApplication::Tty) + if (QApplication::type() == QApplication::Tty) qFatal("QWidget: Cannot create a QWidget when no GUI is being used"); Q_ASSERT(uncreatedWidgets); @@ -1345,7 +1345,7 @@ QWidget::~QWidget() #ifdef QT3_SUPPORT if (QApplicationPrivate::main_widget == this) { // reset main widget QApplicationPrivate::main_widget = 0; - qApp->quit(); + QApplication::quit(); } #endif @@ -2034,8 +2034,8 @@ void QWidgetPrivate::deactivateWidgetCleanup() { Q_Q(QWidget); // If this was the active application window, reset it - if (qApp->activeWindow() == q) - qApp->setActiveWindow(0); + if (QApplication::activeWindow() == q) + QApplication::setActiveWindow(0); // If the is the active mouse press widget, reset it if (q == qt_button_down) qt_button_down = 0; @@ -2236,7 +2236,7 @@ QStyle *QWidget::style() const if (d->extra && d->extra->style) return d->extra->style; - return qApp->style(); + return QApplication::style(); } /*! @@ -5372,7 +5372,7 @@ QIcon QWidget::windowIcon() const return *d->extra->topextra->icon; w = w->parentWidget(); } - return qApp->windowIcon(); + return QApplication::windowIcon(); } void QWidgetPrivate::setWindowIcon_helper() @@ -5894,7 +5894,7 @@ QWidget *QWidget::previousInFocusChain() const bool QWidget::isActiveWindow() const { QWidget *tlw = window(); - if(tlw == qApp->activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup))) + if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup))) return true; #ifndef QT_NO_GRAPHICSVIEW @@ -5915,7 +5915,7 @@ bool QWidget::isActiveWindow() const !tlw->isModal() && (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) return true; - QWidget *w = qApp->activeWindow(); + QWidget *w = QApplication::activeWindow(); while(w && tlw->windowType() == Qt::Tool && !w->isModal() && w->parentWidget()) { w = w->parentWidget()->window(); @@ -7085,7 +7085,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode) #ifdef QT3_SUPPORT if (isMain) - qApp->quit(); + QApplication::quit(); #endif // Attempt to close the application only if this widget has the // WA_QuitOnClose flag set set and has a non-visible parent @@ -7784,7 +7784,7 @@ bool QWidget::event(QEvent *event) QList childList = d->children; for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); - if (o != qApp->activeModalWidget()) { + if (o != QApplication::activeModalWidget()) { if (qobject_cast(o) && static_cast(o)->isWindow()) { // do not forward the event to child windows, // QApplication does this for us @@ -8007,9 +8007,9 @@ void QWidget::mousePressEvent(QMouseEvent *event) if ((windowType() == Qt::Popup)) { event->accept(); QWidget* w; - while ((w = qApp->activePopupWidget()) && w != this){ + while ((w = QApplication::activePopupWidget()) && w != this){ w->close(); - if (qApp->activePopupWidget() == w) // widget does not want to dissappear + if (QApplication::activePopupWidget() == w) // widget does not want to dissappear w->hide(); // hide at least } if (!rect().contains(event->pos())){ diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index ea79329..6ad2548 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1036,7 +1036,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) if (isVisible()) style |= WS_VISIBLE; SetWindowLongA(internalWinId(), GWL_STYLE, style); - QRect r = qApp->desktop()->screenGeometry(this); + QRect r = QApplication::desktop()->screenGeometry(this); UINT swpf = SWP_FRAMECHANGED; if (newstate & Qt::WindowActive) swpf |= SWP_NOACTIVATE; @@ -1977,8 +1977,8 @@ public: // in QOnScreenRasterPaintEngine() : QRasterPaintEngine(new QImage(qt_primary_surface_bits, - qApp->desktop()->width(), - qApp->desktop()->height(), + QApplication::desktop()->width(), + QApplication::desktop()->height(), qt_primary_surface_stride, qt_primary_surface_format)) { diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 0a3a8dd..25dab4c 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -758,7 +758,7 @@ void QWidgetBackingStore::paintWindowDecoration() engine->setSystemClip(decorationRegion.translated(tlwOffset)); QPainter painter(windowSurface->paintDevice()); - painter.setFont(qApp->font()); + painter.setFont(QApplication::font()); painter.translate(tlwOffset); const int numDirty = managerPrivate->dirtyRegions.size(); @@ -1347,7 +1347,7 @@ void QWidgetBackingStore::flush(QWidget *widget, QWindowSurface *surface) static inline bool discardInvalidateBufferRequest(QWidget *widget, QTLWExtra *tlwExtra) { Q_ASSERT(widget); - if (qApp && qApp->closingDown()) + if (QApplication::closingDown()) return true; if (!tlwExtra || tlwExtra->inTopLevelResize || !tlwExtra->backingStore) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 805cd05..aff0af3 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -4419,7 +4419,7 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, { #ifdef Q_WS_X11 Q_D(const QCleanlooksStyle); - if (!qApp->desktopSettingsAware()) + if (!QApplication::desktopSettingsAware()) return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); QIcon icon; QPixmap pixmap; @@ -4588,7 +4588,7 @@ QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QS #ifdef Q_WS_X11 Q_D(const QCleanlooksStyle); QPixmap pixmap; - if (!qApp->desktopSettingsAware()) + if (!QApplication::desktopSettingsAware()) return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); d->lookupIconTheme(); #ifndef QT_NO_IMAGEFORMAT_XPM diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 1285598..74eacf6 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -3130,7 +3130,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, if (dw->isFloating()) icon = dw->windowIcon(); if (!icon.isNull() - && icon.cacheKey() != qApp->windowIcon().cacheKey()) { + && icon.cacheKey() != QApplication::windowIcon().cacheKey()) { QSize sz = icon.actualSize(QSize(r.height(), r.height())); if (verticalTitleBar) sz.transpose(); @@ -5309,7 +5309,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti #ifdef Q_WS_X11 Q_D(const QCommonStyle); QPixmap pixmap; - if (qApp->desktopSettingsAware()) { + if (QApplication::desktopSettingsAware()) { d->lookupIconTheme(); switch (sp) { case SP_DirHomeIcon: @@ -5730,7 +5730,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons QIcon icon; #ifdef Q_WS_X11 Q_D(const QCommonStyle); - if (qApp->desktopSettingsAware()) { + if (QApplication::desktopSettingsAware()) { d->lookupIconTheme(); QPixmap pixmap; switch (standardIcon) { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index fe0e53c..1bbe70e 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -867,7 +867,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) QRenderRule::QRenderRule(const QVector &declarations, const QWidget *widget) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { - QPalette palette = qApp->palette(); // ###: ideally widget's palette + QPalette palette = QApplication::palette(); // ###: ideally widget's palette ValueExtractor v(declarations, palette); features = v.extractStyleFeatures(); @@ -2584,7 +2584,7 @@ static void updateWidgets(const QList& widgets) continue; widget->style()->polish(widget); QEvent event(QEvent::StyleChange); - qApp->sendEvent(widget, &event); + QApplication::sendEvent(widget, &event); widget->update(); widget->updateGeometry(); } @@ -2630,9 +2630,9 @@ QStyle *QStyleSheetStyle::baseStyle() const { if (base) return base; - if (QStyleSheetStyle *me = qobject_cast(qApp->style())) + if (QStyleSheetStyle *me = qobject_cast(QApplication::style())) return me->base; - return qApp->style(); + return QApplication::style(); } void QStyleSheetStyle::widgetDestroyed(QObject *o) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 013ca1e..9ea9a03 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -1436,7 +1436,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey()) + if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -2435,7 +2435,7 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) else if (QTreeView *tree = qobject_cast (widget)) { tree->viewport()->setAttribute(Qt::WA_Hover, false); } else if (qobject_cast(widget)) { - QFont font = qApp->font("QCommandLinkButton"); + QFont font = QApplication::font("QCommandLinkButton"); QFont widgetFont = widget->font(); widgetFont.setFamily(font.family()); //Only family set by polish widget->setFont(widgetFont); diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 3dac9f5..b5dfdbd 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -261,7 +261,7 @@ void QWindowsXPStylePrivate::cleanup(bool force) use_xp = false; cleanupHandleMap(); if (limboWidget) { - if (qApp->closingDown()) + if (QApplication::closingDown()) delete limboWidget; else limboWidget->deleteLater(); @@ -2275,7 +2275,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey()) + if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -2322,7 +2322,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op // Figure out maximal button space on title bar QIcon ico = widget->windowIcon(); - bool hasIcon = (ico.cacheKey() != qApp->windowIcon().cacheKey()); + bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey()); if (hasIcon) { QPixmap pxIco = ico.pixmap(titleHeight); if (!verticalTitleBar && QApplication::layoutDirection() == Qt::RightToLeft) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 9c3c4a4..e9f067a 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -87,34 +87,34 @@ static int getFontWeight(const QString &weightString) // Test in decreasing order of commonness if (s == QLatin1String("medium") || s == QLatin1String("normal") - || s.compare(qApp->translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0) return QFont::Normal; if (s == QLatin1String("bold") - || s.compare(qApp->translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0) return QFont::Bold; if (s == QLatin1String("demibold") || s == QLatin1String("demi bold") - || s.compare(qApp->translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0) return QFont::DemiBold; if (s == QLatin1String("black") - || s.compare(qApp->translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0) return QFont::Black; if (s == QLatin1String("light")) return QFont::Light; if (s.contains(QLatin1String("bold")) - || s.contains(qApp->translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) { + || s.contains(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) { if (s.contains(QLatin1String("demi")) - || s.compare(qApp->translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0) return (int) QFont::DemiBold; return (int) QFont::Bold; } if (s.contains(QLatin1String("light")) - || s.compare(qApp->translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0) return (int) QFont::Light; if (s.contains(QLatin1String("black")) - || s.compare(qApp->translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0) + || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0) return (int) QFont::Black; return (int) QFont::Normal; @@ -251,10 +251,10 @@ QtFontStyle::Key::Key(const QString &styleString) weight = getFontWeight(styleString); if (styleString.contains(QLatin1String("Italic")) - || styleString.contains(qApp->translate("QFontDatabase", "Italic"))) + || styleString.contains(QApplication::translate("QFontDatabase", "Italic"))) style = QFont::StyleItalic; else if (styleString.contains(QLatin1String("Oblique")) - || styleString.contains(qApp->translate("QFontDatabase", "Oblique"))) + || styleString.contains(QApplication::translate("QFontDatabase", "Oblique"))) style = QFont::StyleOblique; } @@ -1249,21 +1249,21 @@ static QString styleStringHelper(int weight, QFont::Style style) { QString result; if (weight >= QFont::Black) - result = qApp->translate("QFontDatabase", "Black"); + result = QApplication::translate("QFontDatabase", "Black"); else if (weight >= QFont::Bold) - result = qApp->translate("QFontDatabase", "Bold"); + result = QApplication::translate("QFontDatabase", "Bold"); else if (weight >= QFont::DemiBold) - result = qApp->translate("QFontDatabase", "Demi Bold"); + result = QApplication::translate("QFontDatabase", "Demi Bold"); else if (weight < QFont::Normal) - result = qApp->translate("QFontDatabase", "Light"); + result = QApplication::translate("QFontDatabase", "Light"); if (style == QFont::StyleItalic) - result += QLatin1Char(' ') + qApp->translate("QFontDatabase", "Italic"); + result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Italic"); else if (style == QFont::StyleOblique) - result += QLatin1Char(' ') + qApp->translate("QFontDatabase", "Oblique"); + result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Oblique"); if (result.isEmpty()) - result = qApp->translate("QFontDatabase", "Normal"); + result = QApplication::translate("QFontDatabase", "Normal"); return result.simplified(); } @@ -2067,7 +2067,7 @@ QString QFontDatabase::writingSystemName(WritingSystem writingSystem) Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter"); break; } - return qApp ? qApp->translate("QFontDatabase", name) : QString::fromLatin1(name); + return QApplication::translate("QFontDatabase", name); } diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 780891b..8573fc9 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1712,7 +1712,7 @@ void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton butto selectedWordOnDoubleClick = cursor; trippleClickPoint = pos; - trippleClickTimer.start(qApp->doubleClickInterval(), q); + trippleClickTimer.start(QApplication::doubleClickInterval(), q); if (doEmit) { selectionChanged(); #ifndef QT_NO_CLIPBOARD diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index c46c929..f79f135 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -518,7 +518,7 @@ void QSystemTrayIconPrivate::install_sys() QRect QSystemTrayIconSys::findTrayGeometry() { //Use lower right corner as fallback - QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight(); + QPoint brCorner = QApplication::desktop()->screenGeometry().bottomRight(); QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10); #if defined(Q_OS_WINCE) HWND trayHandle = FindWindowW(L"Shell_TrayWnd", NULL); diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index f28288e..6337b5c 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -379,7 +379,7 @@ void QAbstractButtonPrivate::moveFocus(int key) #else bool exclusive = autoExclusive; #endif - QWidget *f = qApp->focusWidget(); + QWidget *f = QApplication::focusWidget(); QAbstractButton *fb = qobject_cast(f); if (!fb || !buttonList.contains(fb)) return; diff --git a/src/gui/widgets/qeffects.cpp b/src/gui/widgets/qeffects.cpp index 140953d..19cdf89 100644 --- a/src/gui/widgets/qeffects.cpp +++ b/src/gui/widgets/qeffects.cpp @@ -588,8 +588,8 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) if (!w) return; - qApp->sendPostedEvents(w, QEvent::Move); - qApp->sendPostedEvents(w, QEvent::Resize); + QApplication::sendPostedEvents(w, QEvent::Move); + QApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; // those can be popups - they would steal the focus, but are disabled @@ -610,8 +610,8 @@ void qFadeEffect(QWidget* w, int time) if (!w) return; - qApp->sendPostedEvents(w, QEvent::Move); - qApp->sendPostedEvents(w, QEvent::Resize); + QApplication::sendPostedEvents(w, QEvent::Move); + QApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 711f1f4..7baea94 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1048,7 +1048,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e if (q->testAttribute(Qt::WA_DontShowOnScreen)) { hideUpToMenuBar(); } else { - for(QWidget *widget = qApp->activePopupWidget(); widget; ) { + for(QWidget *widget = QApplication::activePopupWidget(); widget; ) { if (QMenu *qmenu = qobject_cast(widget)) { if(qmenu == q) hideUpToMenuBar(); @@ -1843,7 +1843,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (adjustToDesktop) { //handle popup falling "off screen" - if (qApp->layoutDirection() == Qt::RightToLeft) { + if (QApplication::layoutDirection() == Qt::RightToLeft) { if(snapToMouse) //position flowing left from the mouse pos.setX(mouse.x()-size.width()); @@ -1881,9 +1881,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } setGeometry(QRect(pos, size)); #ifndef QT_NO_EFFECTS - int hGuess = qApp->layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll; + int hGuess = QApplication::layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll; int vGuess = QEffects::DownScroll; - if (qApp->layoutDirection() == Qt::RightToLeft) { + if (QApplication::layoutDirection() == Qt::RightToLeft) { if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) || (qobject_cast(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x())) hGuess = QEffects::RightScroll; @@ -2575,7 +2575,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) { d->hideMenu(this); #ifndef QT_NO_MENUBAR - if (QMenuBar *mb = qobject_cast(qApp->focusWidget())) { + if (QMenuBar *mb = qobject_cast(QApplication::focusWidget())) { mb->d_func()->setKeyboardMode(false); } #endif @@ -2719,7 +2719,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) #ifdef Q_OS_WIN32 if (key_consumed && (e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift || e->key() == Qt::Key_Meta)) - qApp->beep(); + QApplication::beep(); #endif // Q_OS_WIN32 } if (key_consumed) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index fc7e901..51e38e6 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -284,7 +284,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b) } keyboardState = b; if(b) { - QWidget *fw = qApp->focusWidget(); + QWidget *fw = QApplication::focusWidget(); if (fw != q) keyboardFocusWidget = fw; if(!currentAction && !actionList.isEmpty()) @@ -294,7 +294,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b) if(!popupState) setCurrentAction(0); if(keyboardFocusWidget) { - if (qApp->focusWidget() == q) + if (QApplication::focusWidget() == q) keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); keyboardFocusWidget = 0; } diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index 5001001..b526f02 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -589,7 +589,7 @@ void QPushButtonPrivate::_q_popupPressed() int x = globalPos.x(); int y = globalPos.y(); if (horizontal) { - if (globalPos.y() + rect.height() + menuSize.height() <= qApp->desktop()->height()) { + if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->height()) { y += rect.height(); } else { y -= menuSize.height(); @@ -597,7 +597,7 @@ void QPushButtonPrivate::_q_popupPressed() if (q->layoutDirection() == Qt::RightToLeft) x += rect.width() - menuSize.width(); } else { - if (globalPos.x() + rect.width() + menu->sizeHint().width() <= qApp->desktop()->width()) + if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->width()) x += rect.width(); else x -= menuSize.width(); diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 43b2f54..c97154c 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -1057,7 +1057,7 @@ void QTabWidget::keyPressEvent(QKeyEvent *e) break; } } - if (!qApp->focusWidget()) + if (!QApplication::focusWidget()) d->tabs->setFocus(); } else { e->ignore(); diff --git a/src/gui/widgets/qtextbrowser.cpp b/src/gui/widgets/qtextbrowser.cpp index a1f4d34..d849184 100644 --- a/src/gui/widgets/qtextbrowser.cpp +++ b/src/gui/widgets/qtextbrowser.cpp @@ -263,7 +263,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url) Q_Q(QTextBrowser); #ifndef QT_NO_CURSOR if (q->isVisible()) - qApp->setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor(Qt::WaitCursor); #endif textOrSourceChanged = true; @@ -295,9 +295,9 @@ void QTextBrowserPrivate::setSource(const QUrl &url) if (q->isVisible()) { QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1); - if (firstTag.left(3) == QLatin1String("restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); #endif #ifndef QT_NO_WHATSTHIS QWhatsThis::showText(QCursor::pos(), txt, q); @@ -342,7 +342,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url) #ifndef QT_NO_CURSOR if (q->isVisible()) - qApp->restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); #endif emit q->sourceChanged(url); } diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 20f2c23..7787a66 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -1181,7 +1181,7 @@ bool QToolBar::event(QEvent *event) if (!d->layout->expanded) break; - QWidget *w = qApp->activePopupWidget(); + QWidget *w = QApplication::activePopupWidget(); if (waitForPopup(this, w)) { d->waitForPopupTimer->start(); break; @@ -1201,7 +1201,7 @@ void QToolBarPrivate::_q_waitForPopup() { Q_Q(QToolBar); - QWidget *w = qApp->activePopupWidget(); + QWidget *w = QApplication::activePopupWidget(); if (!waitForPopup(q, w)) { waitForPopupTimer->stop(); if (!q->underMouse()) diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/gui/widgets/qtoolbutton.cpp index 7d41d1e..0eb6364 100644 --- a/src/gui/widgets/qtoolbutton.cpp +++ b/src/gui/widgets/qtoolbutton.cpp @@ -895,7 +895,7 @@ void QToolButtonPrivate::popupTimerDone() horizontal = false; #endif QPoint p; - QRect screen = qApp->desktop()->availableGeometry(q); + QRect screen = QApplication::desktop()->availableGeometry(q); QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint(); QRect rect = q->rect(); if (horizontal) { diff --git a/src/gui/widgets/qwidgetresizehandler.cpp b/src/gui/widgets/qwidgetresizehandler.cpp index 9171244..0e5b28a 100644 --- a/src/gui/widgets/qwidgetresizehandler.cpp +++ b/src/gui/widgets/qwidgetresizehandler.cpp @@ -258,7 +258,7 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e) #ifdef Q_WS_X11 // Workaround for window managers which refuse to move a tool window partially offscreen. - QRect desktop = qApp->desktop()->availableGeometry(widget); + QRect desktop = QApplication::desktop()->availableGeometry(widget); pp.rx() = qMax(pp.x(), desktop.left()); pp.ry() = qMax(pp.y(), desktop.top()); p.rx() = qMin(p.x(), desktop.right()); -- cgit v0.12 From a208e75bcdeb4fe39e82d0f86cc2cd72980f40a4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 11 Jun 2009 13:47:31 +0200 Subject: small change in a string, using startsWith --- src/gui/styles/qstylefactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qstylefactory.cpp b/src/gui/styles/qstylefactory.cpp index 70717db..376aa0f 100644 --- a/src/gui/styles/qstylefactory.cpp +++ b/src/gui/styles/qstylefactory.cpp @@ -170,7 +170,7 @@ QStyle *QStyleFactory::create(const QString& key) else #endif #ifndef QT_NO_STYLE_MAC - if (style.left(9) == QLatin1String("macintosh")) { + if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # ifdef Q_WS_MAC if (style == QLatin1String("macintosh")) -- cgit v0.12 From e3d6bd3fc41b09c2eb7c56789d7dc5e26722a3b9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 11 Jun 2009 16:05:28 +0200 Subject: Fixed ToolBar layout so that when a toolbar is resized to its sizeHint we get a "sticky" effect --- src/gui/widgets/qtoolbararealayout.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 240d059..b1b743e 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -440,9 +440,10 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) //we check if the previous is near its size hint //in which case we try to stick to it - if (qAbs(pick(o, previous.sizeHint()) - (previous.size + extra)) < QApplication::startDragDistance()) { - //we stick to the default space - extra = 0; + const int diff = pick(o, previous.sizeHint()) - (previous.size + extra); + if (qAbs(diff) < QApplication::startDragDistance()) { + //we stick to the default place and size + extra += diff; } //update for the current item -- cgit v0.12 From aa2adb8d0072eccb549692d56168b8fde33f7b4f Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 11 Jun 2009 16:27:29 +0200 Subject: Sort QDir with qSort instead of qStableSort The commit 3e7fc907e5cc1937fb98bf4581cee960fe3d4e7a have changed the behavior of sorting of QDir. This revert to the old behavior with qSort instead of qStableSort. Reviewed-by: Alexis --- src/corelib/io/qdir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 302d9b5..b6900bc 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -289,7 +289,7 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, QDirSortItem *si = new QDirSortItem[n]; for (int i = 0; i < n; ++i) si[i].item = l.at(i); - qStableSort(si, si + n, QDirSortItemComparator(sort)); + qSort(si, si+n, QDirSortItemComparator(sort)); // put them back in the list(s) if(infos) { for (int i = 0; i < n; ++i) @@ -1316,7 +1316,6 @@ QStringList QDir::entryList(Filters filters, SortFlags sort) const \sa entryList(), setNameFilters(), setSorting(), setFilter(), isReadable(), exists() */ - QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const { Q_D(const QDir); -- cgit v0.12 From fa5f3a4464f8265692c2ff50bd03b9b24b6ad912 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 11 Jun 2009 17:27:23 +0200 Subject: Use the original order if two files are equivalent for the sort of QDir Set back the sort order of QDir::entryList() and entryInfoList(). This complement the change of aa2adb8d0072eccb549692d56168b8fde33f7b4f Reviewed-by: Olivier --- src/corelib/io/qdir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index b6900bc..8aadf34 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -263,7 +263,8 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt ? f1->filename_cache.localeAwareCompare(f2->filename_cache) : f1->filename_cache.compare(f2->filename_cache); } - + if (r == 0) // Enforce an order - the order the items appear in the array + r = (&n1) - (&n2); if (qt_cmp_si_sort_flags & QDir::Reversed) return r > 0; return r < 0; -- cgit v0.12 From 17f573ed026f0790cc305a407e69bb1e9a424e41 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 11 Jun 2009 17:59:28 +0200 Subject: Doc: Added information about QDBUS_DEBUG to the D-Bus documentation. Task-number: 253715 Reviewed-by: Trust Me --- doc/src/introtodbus.qdoc | 19 ++++++++++++++++++- doc/src/snippets/code/doc_src_introtodbus.qdoc | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/src/introtodbus.qdoc b/doc/src/introtodbus.qdoc index 71c65d5..1edc6eb 100644 --- a/doc/src/introtodbus.qdoc +++ b/doc/src/introtodbus.qdoc @@ -198,7 +198,24 @@ \row \o Interface \o Plugin identifier \o Dot-separated \endtable - \section2 Further Reading + \section1 Debugging + + When developing applications that use D-Bus, it is sometimes useful to be able + to see information about the messages that are sent and received across the + bus by each application. + + This feature can be enabled on a per-application basis by setting the + \c QDBUS_DEBUG environment variable before running each application. + For example, we can enable debugging only for the car in the + \l{Remote Controlled Car Example} by running the controller and the + car in the following way: + + \snippet doc/src/snippets/code/doc_src_introtodbus.qdoc QDBUS_DEBUG + + Information about the messages will be written to the console the application + was launched from. + + \section1 Further Reading The following documents contain information about Qt's D-Bus integration features, and provide details about the mechanisms used to send and receive diff --git a/doc/src/snippets/code/doc_src_introtodbus.qdoc b/doc/src/snippets/code/doc_src_introtodbus.qdoc index bedfe7f..97b14e9 100644 --- a/doc/src/snippets/code/doc_src_introtodbus.qdoc +++ b/doc/src/snippets/code/doc_src_introtodbus.qdoc @@ -1,3 +1,8 @@ //! [0] org.freedesktop.DBus //! [0] + +//! [QDBUS_DEBUG] +examples/dbus/remotecontrolledcar/controller/controller & +QDBUS_DEBUG=1 examples/dbus/remotecontrolledcar/car/car & +//! [QDBUS_DEBUG] -- cgit v0.12 From a1786a441e9101500ae2c28a5226372ba0c7b4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 11 Jun 2009 16:24:40 +0200 Subject: QGraphicsView: Replace update() with updateAll(). We have some nice cut-offs when there's a full update pending, but we don't know about it if we call update() directly on the viewport. Instead call QGraphicsViewPrivate::updateAll() which has the same effect, except that it also sets a flag telling us a full update is pending. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsview.cpp | 34 +++++++++++++--------------------- src/gui/graphicsview/qgraphicsview_p.h | 8 +++++++- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index de7b9f4..4a32ee5 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -442,7 +442,7 @@ void QGraphicsViewPrivate::recalculateContentSize() // scroll instead. if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) { dirtyScroll = true; - viewport->update(); + updateAll(); } else if (q->isRightToLeft() && !leftIndent) { // In reverse mode, the horizontal scroll always changes after the content // size has changed, as the scroll is calculated by summing the min and @@ -823,14 +823,6 @@ void QGraphicsViewPrivate::processPendingUpdates() dirtyRegion = QRegion(); } -void QGraphicsViewPrivate::updateAll() -{ - viewport->update(); - fullUpdatePending = true; - dirtyBoundingRect = QRect(); - dirtyRegion = QRegion(); -} - void QGraphicsViewPrivate::updateRegion(const QRegion &r) { if (r.isEmpty() || fullUpdatePending) @@ -1084,7 +1076,7 @@ void QGraphicsView::setRenderHints(QPainter::RenderHints hints) if (hints == d->renderHints) return; d->renderHints = hints; - viewport()->update(); + d->updateAll(); } /*! @@ -1102,7 +1094,7 @@ void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled) else d->renderHints &= ~hint; if (oldHints != d->renderHints) - viewport()->update(); + d->updateAll(); } /*! @@ -1389,7 +1381,7 @@ void QGraphicsView::resetCachedContent() if (d->cacheMode & CacheBackground) { // Background caching is enabled. d->mustResizeBackgroundPixmap = true; - viewport()->update(); + d->updateAll(); } else if (d->mustResizeBackgroundPixmap) { // Background caching is disabled. // Cleanup, free some resources. @@ -1478,7 +1470,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) return; // Always update the viewport when the scene changes. - viewport()->update(); + d->updateAll(); // Remove the previously assigned scene. if (d->scene) { @@ -2434,7 +2426,7 @@ void QGraphicsView::setBackgroundBrush(const QBrush &brush) { Q_D(QGraphicsView); d->backgroundBrush = brush; - viewport()->update(); + d->updateAll(); if (d->cacheMode & CacheBackground) { // Invalidate the background pixmap @@ -2464,7 +2456,7 @@ void QGraphicsView::setForegroundBrush(const QBrush &brush) { Q_D(QGraphicsView); d->foregroundBrush = brush; - viewport()->update(); + d->updateAll(); } /*! @@ -3062,7 +3054,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event) if (d->viewportUpdateMode != FullViewportUpdate) viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect)); else - viewport()->update(); + d->updateAll(); } // Stop rubber banding if the user has let go of all buttons (even @@ -3084,7 +3076,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event) if (d->viewportUpdateMode != FullViewportUpdate) viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect)); else - viewport()->update(); + d->updateAll(); } // Set the new selection area QPainterPath selectionArea; @@ -3127,7 +3119,7 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) if (d->viewportUpdateMode != FullViewportUpdate) viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect)); else - viewport()->update(); + d->updateAll(); } d->rubberBanding = false; d->rubberBandRect = QRect(); @@ -3395,10 +3387,10 @@ void QGraphicsView::scrollContentsBy(int dx, int dy) #endif viewport()->scroll(dx, dy); } else { - viewport()->update(); + d->updateAll(); } } else { - viewport()->update(); + d->updateAll(); } } @@ -3611,7 +3603,7 @@ void QGraphicsView::setTransform(const QTransform &matrix, bool combine ) d->transforming = false; // Any matrix operation requires a full update. - viewport()->update(); + d->updateAll(); } /*! diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 814e476..00f3035 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -163,7 +163,13 @@ public: QRegion dirtyRegion; QRect dirtyBoundingRect; void processPendingUpdates(); - void updateAll(); + inline void updateAll() + { + viewport->update(); + fullUpdatePending = true; + dirtyBoundingRect = QRect(); + dirtyRegion = QRegion(); + } void updateRect(const QRect &rect); void updateRegion(const QRegion ®ion); bool updateSceneSlotReimplementedChecked; -- cgit v0.12 From 5918d108579d53e9c41ee674379a8c60124e9838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 11 Jun 2009 17:29:46 +0200 Subject: Painting artifacts in QGraphicsView. Problem appears in the chip demo when clicking an item while scrolling the view using the mouse wheel. The problem was that we didn't translate the the item's old painted view rect. There was also a problem when enabling the DontAdjustForAntialiasing flag, causing an item to not redraw its edges. We have to adjust the rectangle by (-1, -1, 1, 1) since QRect() and QRectF() behaves differently. Auto-test (made by Andreas) included. Reviewed-by: Andreas --- src/gui/graphicsview/qgraphicsscene.cpp | 8 +++- src/gui/graphicsview/qgraphicsview.cpp | 21 +++++---- src/gui/graphicsview/qgraphicsview_p.h | 1 + tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 63 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 10 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 1c48675..55d8a1d 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5269,7 +5269,9 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b for (int i = 0; i < views.size(); ++i) { QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func(); - viewPrivate->updateRect(item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport)); + QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport); + rect.translate(viewPrivate->dirtyScrollOffset); + viewPrivate->updateRect(rect); } return; } @@ -5350,7 +5352,9 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) { wasDirtyParentViewBoundingRects = true; - viewPrivate->updateRect(item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport)); + QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport); + rect.translate(viewPrivate->dirtyScrollOffset); + viewPrivate->updateRect(rect); } if (!item->d_ptr->dirty) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 4a32ee5..a72aa5a 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -812,7 +812,7 @@ void QGraphicsViewPrivate::processPendingUpdates() if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) { if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) - viewport->update(dirtyBoundingRect); + viewport->update(dirtyBoundingRect.adjusted(-1, -1, 1, 1)); else viewport->update(dirtyBoundingRect.adjusted(-2, -2, 2, 2)); } else { @@ -843,14 +843,16 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r) break; case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE case QGraphicsView::MinimalViewportUpdate: - if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) { - dirtyRegion += r; - } else { - const QVector &rects = r.rects(); - for (int i = 0; i < rects.size(); ++i) + { + const QVector &rects = r.rects(); + for (int i = 0; i < rects.size(); ++i) { + if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) + dirtyRegion += rects.at(i).adjusted(-1, -1, 1, 1); + else dirtyRegion += rects.at(i).adjusted(-2, -2, 2, 2); } break; + } case QGraphicsView::NoViewportUpdate: // Unreachable break; @@ -878,7 +880,7 @@ void QGraphicsViewPrivate::updateRect(const QRect &r) case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE case QGraphicsView::MinimalViewportUpdate: if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) - dirtyRegion += r; + dirtyRegion += r.adjusted(-1, -1, 1, 1); else dirtyRegion += r.adjusted(-2, -2, 2, 2); break; @@ -2678,6 +2680,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) case QEvent::Paint: // Reset full update d->fullUpdatePending = false; + d->dirtyScrollOffset = QPoint(); if (d->scene) { // Check if this view reimplements the updateScene slot; if it // does, we can't do direct update delivery and have to fall back @@ -3375,7 +3378,6 @@ void QGraphicsView::scrollContentsBy(int dx, int dy) if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) { if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) { - d->dirtyRegion.translate(dx, dy); if (d->accelerateScrolling) { #ifndef QT_NO_RUBBERBAND // Update new and old rubberband regions @@ -3385,6 +3387,9 @@ void QGraphicsView::scrollContentsBy(int dx, int dy) viewport()->update(rubberBandRegion); } #endif + d->dirtyScrollOffset.rx() += dx; + d->dirtyScrollOffset.ry() += dy; + d->dirtyRegion.translate(dx, dy); viewport()->scroll(dx, dy); } else { d->updateAll(); diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 00f3035..a6f0d04 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -94,6 +94,7 @@ public: QPoint mousePressScreenPoint; QPointF lastMouseMoveScenePoint; QPoint lastMouseMoveScreenPoint; + QPoint dirtyScrollOffset; Qt::MouseButton mousePressButton; QTransform matrix; bool identityMatrix; diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 5167682..06b4a78 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -188,6 +188,8 @@ private slots: void embeddedViews(); void scrollAfterResize_data(); void scrollAfterResize(); + void moveItemWhileScrolling_data(); + void moveItemWhileScrolling(); void centerOnDirtyItem(); void mouseTracking(); void mouseTracking2(); @@ -3045,6 +3047,67 @@ void tst_QGraphicsView::scrollAfterResize() QCOMPARE(view.viewportTransform(), x3); } +void tst_QGraphicsView::moveItemWhileScrolling_data() +{ + QTest::addColumn("adjustForAntialiasing"); + + QTest::newRow("no adjust") << false; + QTest::newRow("adjust") << true; +} + +void tst_QGraphicsView::moveItemWhileScrolling() +{ + QFETCH(bool, adjustForAntialiasing); + + class MoveItemScrollView : public QGraphicsView + { + public: + MoveItemScrollView() + { + setScene(new QGraphicsScene(0, 0, 1000, 1000)); + rect = scene()->addRect(0, 0, 10, 10); + rect->setPos(50, 50); + } + QRegion lastPaintedRegion; + QGraphicsItem *rect; + protected: + void paintEvent(QPaintEvent *event) + { + lastPaintedRegion = event->region(); + QGraphicsView::paintEvent(event); + } + }; + + MoveItemScrollView view; + view.setFrameStyle(0); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setResizeAnchor(QGraphicsView::NoAnchor); + view.setTransformationAnchor(QGraphicsView::NoAnchor); + if (!adjustForAntialiasing) + view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing); + view.show(); + view.resize(200, 200); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + + view.lastPaintedRegion = QRegion(); + view.horizontalScrollBar()->setValue(view.horizontalScrollBar()->value() + 10); + view.rect->moveBy(0, 10); + QTest::qWait(100); + + QRegion expectedRegion; + expectedRegion += QRect(0, 0, 200, 200); + expectedRegion -= QRect(0, 0, 190, 200); + int a = adjustForAntialiasing ? 2 : 1; + expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a); + expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a); + + QCOMPARE(view.lastPaintedRegion, expectedRegion); +} + void tst_QGraphicsView::centerOnDirtyItem() { QGraphicsView view; -- cgit v0.12 From 021ce0ba93168dcaf1744fc2da8faf4e2f4ba683 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 11 Jun 2009 18:22:54 +0200 Subject: Compile the qsettins autotest As suggested in merge request 641 --- src/corelib/io/qsettings_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index 93d07e0..565aeb6 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -146,7 +146,7 @@ inline QString QSettingsGroup::toString() const return result; } -class QConfFile +class Q_AUTOTEST_EXPORT QConfFile { public: ParsedSettingsMap mergedKeyMap() const; -- cgit v0.12 From 3c4239a9ced4945e9b016a755180fac2f6b3a5ab Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 11 Jun 2009 18:46:57 +0200 Subject: Doc: Make it easier to find supported platform information from the installation page. Reviewed-by: Trust Me --- doc/src/installation.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/src/installation.qdoc b/doc/src/installation.qdoc index bc310c9..49ab45a 100644 --- a/doc/src/installation.qdoc +++ b/doc/src/installation.qdoc @@ -508,6 +508,9 @@ in the \l{Qt for Windows CE Requirements} document. This page describes the specific requirements of libraries and components on which Qt depends. For information about installing Qt, see the \l{Installation} page. + For information about the platforms that Qt supports, see the \l{Supported Platforms} + page. + \section1 OpenSSL (version 0.9.7 or later) Support for \l{SSL}{Secure Sockets Layer (SSL)} communication is provided by the -- cgit v0.12 From a2baabcfcb60a7a0e5d3926ad6938983e50dfefc Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 10 Jun 2009 22:13:57 +0200 Subject: Use the old codec if there is one available when reading data in qtextstream. Reviewed-by: trustme --- src/corelib/io/qtextstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 7c925f1..75c682a 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -561,7 +561,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) if (!codec || autoDetectUnicode) { autoDetectUnicode = false; - codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), 0); + codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), codec); if (!codec) { codec = QTextCodec::codecForLocale(); writeConverterState.flags |= QTextCodec::IgnoreHeader; -- cgit v0.12 From 52392292c8fa096e3b0bb692dedce66924ab3305 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 10 Jun 2009 22:15:00 +0200 Subject: Skip the byte order mark when converting the utf16 and utf32 data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reading one character at a time (as QTextStream::pos does) the byte order mark could be ignored. This happens only with UTF-16 BE/LE and UTF-32 BE/LE codecs. This fixes the qtextstream autotest. Author: Olivier Goffart Author: João Abecasis --- src/corelib/codecs/qutfcodec.cpp | 4 ++-- tests/auto/qtextstream/tst_qtextstream.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index d9defe1..6611315 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -387,7 +387,7 @@ QString QUtf16Codec::convertToUnicode(const char *chars, int len, ConverterState result.truncate(qch - result.unicode()); if (state) { - if (endian != Detect) + if (headerdone) state->flags |= IgnoreHeader; state->state_data[Endian] = endian; if (half) { @@ -569,7 +569,7 @@ QString QUtf32Codec::convertToUnicode(const char *chars, int len, ConverterState result.truncate(qch - result.unicode()); if (state) { - if (endian != Detect) + if (headerdone) state->flags |= IgnoreHeader; state->state_data[Endian] = endian; state->remainingChars = num; diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 358b4b6..cf495d5 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -552,8 +552,8 @@ void tst_QTextStream::generateLineData(bool for_QString) QTest::newRow("threelines/crlf/crlf/crlf") << QByteArray("ole\r\ndole\r\ndoffen\r\n") << (QStringList() << "ole" << "dole" << "doffen"); QTest::newRow("threelines/crlf/crlf/nothing") << QByteArray("ole\r\ndole\r\ndoffen") << (QStringList() << "ole" << "dole" << "doffen"); - // utf-16 if (!for_QString) { + // utf-16 // one line QTest::newRow("utf16-BE/nothing") << QByteArray("\xfe\xff" @@ -593,6 +593,18 @@ void tst_QTextStream::generateLineData(bool for_QString) "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26) << (QStringList() << "\345ge" << "\345ge" << "\345ge"); + + // utf-32 + QTest::newRow("utf32-BE/twolines") + << QByteArray("\x00\x00\xfe\xff" + "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a" + "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a", 36) + << (QStringList() << "\345ge" << "\345ge"); + QTest::newRow("utf32-LE/twolines") + << QByteArray("\xff\xfe\x00\x00" + "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00" + "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00", 36) + << (QStringList() << "\345ge" << "\345ge"); } // partials -- cgit v0.12 From f6aa5d8cfbec4f4ffacf20a94a1653c1a8ee2134 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 11 Jun 2009 14:59:23 +0200 Subject: UTF-8 text codec should be able to convert data when fed one by one byte. When the input data is fed to utf-8 by one byte it couldn't parse the BOM correctly. So we wait until the BOM is composed into a code point and check it afterwards. Reviewed-by: Olivier Goffart --- src/corelib/codecs/qutfcodec.cpp | 11 +++++- tests/auto/qtextcodec/tst_qtextcodec.cpp | 60 ++++++++++++++++++++++++++++++ tests/auto/qtextstream/tst_qtextstream.cpp | 7 ++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index 6611315..27c0572 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -184,7 +184,10 @@ void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, C uc = (uc << 6) | (ch & 0x3f); need--; if (!need) { - if (uc > 0xffff && uc < 0x110000) { + // utf-8 bom composes into 0xfeff code point + if (!headerdone && uc == 0xfeff) { + // dont do anything, just skip the BOM + } else if (uc > 0xffff && uc < 0x110000) { // surrogate pair uc -= 0x10000; unsigned short high = uc/0x400 + 0xd800; @@ -206,6 +209,7 @@ void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, C } else { *qch++ = uc; } + headerdone = true; } } else { // error @@ -213,15 +217,18 @@ void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, C *qch++ = replacement; ++invalid; need = 0; + headerdone = true; } } else { if (ch < 128) { *qch++ = QLatin1Char(ch); + headerdone = true; } else if ((ch & 0xe0) == 0xc0) { uc = ch & 0x1f; need = 1; error = i; min_uc = 0x80; + headerdone = true; } else if ((ch & 0xf0) == 0xe0) { uc = ch & 0x0f; need = 2; @@ -232,10 +239,12 @@ void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, C need = 3; error = i; min_uc = 0x10000; + headerdone = true; } else { // error *qch++ = replacement; ++invalid; + headerdone = true; } } } diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 97c409b..88dbaf7 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -74,6 +74,9 @@ private slots: void utf8Codec_data(); void utf8Codec(); + void utf8bom_data(); + void utf8bom(); + void utfHeaders_data(); void utfHeaders(); @@ -1513,6 +1516,63 @@ void tst_QTextCodec::utf8Codec() QCOMPARE(str, res); } +void tst_QTextCodec::utf8bom_data() +{ + QTest::addColumn("data"); + QTest::addColumn("result"); + + QTest::newRow("nobom") + << QByteArray("\302\240", 2) + << QString("\240"); + + { + static const ushort data[] = { 0x201d }; + QTest::newRow("nobom 2") + << QByteArray("\342\200\235", 3) + << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + } + + { + static const ushort data[] = { 0xf000 }; + QTest::newRow("bom1") + << QByteArray("\357\200\200", 3) + << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + } + + { + static const ushort data[] = { 0xfec0 }; + QTest::newRow("bom2") + << QByteArray("\357\273\200", 3) + << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + } + + { + QTest::newRow("normal-bom") + << QByteArray("\357\273\277a", 4) + << QString("a"); + } + + { + static const ushort data[] = { 0x61, 0xfeff, 0x62 }; + QTest::newRow("middle-bom") + << QByteArray("a\357\273\277b", 5) + << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + } +} + +void tst_QTextCodec::utf8bom() +{ + QFETCH(QByteArray, data); + QFETCH(QString, result); + + QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8 + Q_ASSERT(codec); + + QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result); + + QTextCodec::ConverterState state; + QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result); +} void tst_QTextCodec::utfHeaders_data() { diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index cf495d5..9573957 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -553,6 +553,13 @@ void tst_QTextStream::generateLineData(bool for_QString) QTest::newRow("threelines/crlf/crlf/nothing") << QByteArray("ole\r\ndole\r\ndoffen") << (QStringList() << "ole" << "dole" << "doffen"); if (!for_QString) { + // utf-8 + QTest::newRow("utf8/twolines") + << QByteArray("\xef\xbb\xbf" + "\x66\x67\x65\x0a" + "\x66\x67\x65\x0a", 11) + << (QStringList() << "fge" << "fge"); + // utf-16 // one line QTest::newRow("utf16-BE/nothing") -- cgit v0.12 From 66f34c40dbc52b76434db4ccac6c43101bd57e1e Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 11 Jun 2009 21:00:49 +0200 Subject: Fixed qtextcodec autotest so it can be run from a build directory. Reviewed-by: trustme --- tests/auto/qtextcodec/test/test.pro | 6 +++--- tests/auto/qtextcodec/tst_qtextcodec.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro index e52bb7a..9c07e76 100644 --- a/tests/auto/qtextcodec/test/test.pro +++ b/tests/auto/qtextcodec/test/test.pro @@ -6,7 +6,7 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - - - diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 88dbaf7..1802c3e 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -95,8 +95,8 @@ void tst_QTextCodec::toUnicode_data() QTest::addColumn("fileName"); QTest::addColumn("codecName"); - QTest::newRow( "korean-eucKR" ) << "korean.txt" << "eucKR"; - QTest::newRow( "UTF-8" ) << "utf8.txt" << "UTF-8"; + QTest::newRow( "korean-eucKR" ) << SRCDIR "korean.txt" << "eucKR"; + QTest::newRow( "UTF-8" ) << SRCDIR "utf8.txt" << "UTF-8"; } void tst_QTextCodec::toUnicode() @@ -237,7 +237,7 @@ void tst_QTextCodec::fromUnicode() void tst_QTextCodec::toUnicode_codecForHtml() { - QFile file(QString("QT4-crashtest.txt")); + QFile file(QString(SRCDIR "QT4-crashtest.txt")); QVERIFY(file.open(QFile::ReadOnly)); QByteArray data = file.readAll(); -- cgit v0.12 From d0baa9b8dc9ed191903447032f1cf6afe9a2463e Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 12 Jun 2009 11:21:14 +1000 Subject: Set qreal to float for Symbian. Make sure we match the logic in qglobal.h. --- src/corelib/kernel/qmetatype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 22214a4..687a070 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -89,7 +89,7 @@ public: // This logic must match the one in qglobal.h #if defined(QT_COORD_TYPE) QReal = 0, -#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) +#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) QReal = Float, #else QReal = Double, -- cgit v0.12
+ Getting Started + General + Developer Resources
+ API Reference + Core Features + Key Technologies
+ Add-ons & Services + Tools + Licenses & Credits