From 84083e790607b60fbfc6eabc5fad5ba43a2f135d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 26 May 2019 04:45:31 +0000 Subject: [PATCH] various cleanups Signed-off-by: Ivailo Monev --- CMakeLists.txt | 4 ---- src/gui/kernel/qlayout.cpp | 18 +++++++----------- src/gui/kernel/qlayoutengine.cpp | 23 +++++++++++------------ src/gui/kernel/qlayoutitem.cpp | 3 +-- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3a1bd3a6..2ba07206c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -586,10 +586,6 @@ if(NOT X11_Xext_FOUND) message(WARNING "The X11 Xext extension was not found") katie_definition(-DQT_NO_XSYNC -DQT_NO_XSHAPE -DQTT_NO_XSHM) endif() -if(NOT X11_Xinput_FOUND) - message(WARNING "X11 Xinput extension was not found thus disabling tabled support too") - katie_definition(-DQT_NO_TABLET) -endif() if(NOT X11_SM_FOUND) message(WARNING "X11 SM was not found thus disabling session manager support") katie_definition(-DQT_NO_SESSIONMANAGER) diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index a8fb71e31..f99df540b 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -568,8 +568,7 @@ static bool removeWidgetRecursively(QLayoutItem *li, QWidget *w) if (!lay) return false; int i = 0; - QLayoutItem *child; - while ((child = lay->itemAt(i))) { + while (QLayoutItem *child = lay->itemAt(i)) { if (child->widget() == w) { delete lay->takeAt(i); lay->invalidate(); @@ -780,9 +779,9 @@ QLayout::~QLayout() This function may be called during the QObject destructor, when the parent no longer is a QWidget. */ - if (d->topLevel && parent() && parent()->isWidgetType() && - ((QWidget*)parent())->layout() == this) - ((QWidget*)parent())->d_func()->layout = 0; + QWidget *mw = static_cast(parent()); + if (d->topLevel && mw && mw->isWidgetType() && mw->layout() == this) + mw->d_func()->layout = Q_NULLPTR; } @@ -989,9 +988,8 @@ void QLayout::activateRecursiveHelper(QLayoutItem *item) item->invalidate(); QLayout *layout = item->layout(); if (layout) { - QLayoutItem *child; int i=0; - while ((child = layout->itemAt(i++))) + while (QLayoutItem *child = layout->itemAt(i++)) activateRecursiveHelper(child); layout->d_func()->activated = true; } @@ -1298,8 +1296,7 @@ QRect QLayout::alignmentRect(const QRect &r) const void QLayout::removeWidget(QWidget *widget) { int i = 0; - QLayoutItem *child; - while ((child = itemAt(i))) { + while (QLayoutItem *child = itemAt(i)) { if (child->widget() == widget) { delete takeAt(i); invalidate(); @@ -1321,8 +1318,7 @@ void QLayout::removeWidget(QWidget *widget) void QLayout::removeItem(QLayoutItem *item) { int i = 0; - QLayoutItem *child; - while ((child = itemAt(i))) { + while (QLayoutItem *child = itemAt(i)) { if (child == item) { takeAt(i); invalidate(); diff --git a/src/gui/kernel/qlayoutengine.cpp b/src/gui/kernel/qlayoutengine.cpp index ae0370a14..06f8ae5cc 100644 --- a/src/gui/kernel/qlayoutengine.cpp +++ b/src/gui/kernel/qlayoutengine.cpp @@ -88,9 +88,8 @@ void qGeomCalc(QVector &chain, int start, int count, bool allEmptyNonstretch = true; int pendingSpacing = -1; int spacerCount = 0; - int i; - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { QLayoutStruct *data = &chain[i]; data->done = false; @@ -131,7 +130,7 @@ void qGeomCalc(QVector &chain, int start, int count, QList list; - for (i = start; i < start + count; i++) + for (int i = start; i < start + count; i++) list << chain.at(i).minimumSize; qSort(list); @@ -162,7 +161,7 @@ void qGeomCalc(QVector &chain, int start, int count, int maxval = current - deficitPerItem; int rest = 0; - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { int maxv = maxval; rest += remainder; if (rest >= items) { @@ -185,7 +184,7 @@ void qGeomCalc(QVector &chain, int start, int count, int overdraft = cHint - space_left; // first give to the fixed ones: - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { QLayoutStruct *data = &chain[i]; if (!data->done && data->minimumSize >= data->smartSizeHint()) { @@ -202,7 +201,7 @@ void qGeomCalc(QVector &chain, int start, int count, Fixed64 fp_over = toFixed(overdraft); Fixed64 fp_w = 0; - for (i = start; i < start+count; i++) { + for (int i = start; i < start+count; i++) { QLayoutStruct *data = &chain[i]; if (data->done) continue; @@ -228,7 +227,7 @@ void qGeomCalc(QVector &chain, int start, int count, int n = count; int space_left = space - sumSpacing; // first give to the fixed ones, and handle non-expansiveness - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { QLayoutStruct *data = &chain[i]; if (!data->done && (data->maximumSize <= data->smartSizeHint() @@ -260,7 +259,7 @@ void qGeomCalc(QVector &chain, int start, int count, surplus = deficit = 0; Fixed64 fp_space = toFixed(space_left); Fixed64 fp_w = 0; - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { QLayoutStruct *data = &chain[i]; if (data->done) continue; @@ -283,7 +282,7 @@ void qGeomCalc(QVector &chain, int start, int count, } if (deficit > 0 && surplus <= deficit) { // give to the ones that have too little - for (i = start; i < start+count; i++) { + for (int i = start; i < start+count; i++) { QLayoutStruct *data = &chain[i]; if (!data->done && data->size < data->smartSizeHint()) { data->size = data->smartSizeHint(); @@ -298,7 +297,7 @@ void qGeomCalc(QVector &chain, int start, int count, } if (surplus > 0 && surplus >= deficit) { // take from the ones that have too much - for (i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { QLayoutStruct *data = &chain[i]; if (!data->done && data->size > data->maximumSize) { data->size = data->maximumSize; @@ -324,7 +323,7 @@ void qGeomCalc(QVector &chain, int start, int count, */ int extra = extraspace / (spacerCount + 2); int p = pos + extra; - for (i = start; i < start+count; i++) { + for (int i = start; i < start+count; i++) { QLayoutStruct *data = &chain[i]; data->pos = p; p += data->size; @@ -335,7 +334,7 @@ void qGeomCalc(QVector &chain, int start, int count, #ifdef QLAYOUT_EXTRA_DEBUG qDebug() << "qGeomCalc" << "start" << start << "count" << count << "pos" << pos << "space" << space << "spacer" << spacer; - for (i = start; i < start + count; ++i) { + for (int i = start; i < start + count; ++i) { qDebug() << i << ':' << chain[i].minimumSize << chain[i].smartSizeHint() << chain[i].maximumSize << "stretch" << chain[i].stretch << "empty" << chain[i].empty << "expansive" << chain[i].expansive diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/gui/kernel/qlayoutitem.cpp index 9babdf388..954907627 100644 --- a/src/gui/kernel/qlayoutitem.cpp +++ b/src/gui/kernel/qlayoutitem.cpp @@ -304,7 +304,7 @@ void QLayoutItem::invalidate() */ QLayout * QLayoutItem::layout() { - return 0; + return Q_NULLPTR; } /*! @@ -558,7 +558,6 @@ Qt::Orientations QWidgetItem::expandingDirections() const Qt::Orientations e = wid->sizePolicy().expandingDirections(); /* - ### Qt 4.0: If the layout is expanding, we make the widget expanding, even if its own size policy isn't expanding. This behavior should be reconsidered. -- 2.11.0