summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-10 13:31:43 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-10 15:02:55 (GMT)
commit4a8a851315ba10824ac107084ccff9de649418ea (patch)
treeaa5c2696f6a3a5a8dd0e74b57c04003769f10455 /src
parent747444c6776d948dad479e7b6f3564d0515d4e52 (diff)
downloadQt-4a8a851315ba10824ac107084ccff9de649418ea.zip
Qt-4a8a851315ba10824ac107084ccff9de649418ea.tar.gz
Qt-4a8a851315ba10824ac107084ccff9de649418ea.tar.bz2
removed superflous indirection (ie. using q->..) instead of using the
private class member.
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp63
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp12
-rw-r--r--src/gui/itemviews/qcolumnview.cpp38
-rw-r--r--src/gui/itemviews/qheaderview.cpp7
-rw-r--r--src/gui/itemviews/qlistview.cpp10
-rw-r--r--src/gui/itemviews/qtreeview.cpp45
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/text/qtextcontrol.cpp2
-rw-r--r--src/gui/widgets/qabstractbutton.cpp20
-rw-r--r--src/gui/widgets/qmdiarea.cpp32
-rw-r--r--src/gui/widgets/qmdisubwindow.cpp24
-rw-r--r--src/gui/widgets/qmdisubwindow_p.h2
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<QGraphicsItem *> 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(&currentAnimation, SIGNAL(frameChanged(int)),
- q->horizontalScrollBar(), SLOT(setValue(int)));
- q->connect(&currentAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn()));
+ QObject::connect(&currentAnimation, SIGNAL(frameChanged(int)),
+ hbar, SLOT(setValue(int)));
+ QObject::connect(&currentAnimation, 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<QAbstractItemView*>(q->parent())) {
+ if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(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<QAbstractScrollArea *>(q->parent());
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
if (scrollArea && scrollArea->viewport() == q) {
QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr;
QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(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<QWidget*>(q->parent());
+ QWidget *parentWidget = qobject_cast<QWidget*>(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 @@ QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const
return group->d_func()->buttonList;
#endif
- Q_Q(const QAbstractButton);
- QList<QAbstractButton*>candidates;
- if (q->parentWidget()) {
- candidates = qFindChildren<QAbstractButton *>(q->parentWidget());
- if (autoExclusive) {
- for (int i = candidates.count() - 1; i >= 0; --i) {
- QAbstractButton *candidate = candidates.at(i);
- if (!candidate->autoExclusive()
+ QList<QAbstractButton*>candidates = qFindChildren<QAbstractButton *>(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<QMdiSubWindow>(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;
}