OSDN Git Service

various cleanups
authorIvailo Monev <xakepa10@laimg.moc>
Sun, 26 May 2019 04:45:31 +0000 (04:45 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sun, 26 May 2019 05:06:49 +0000 (05:06 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
CMakeLists.txt
src/gui/kernel/qlayout.cpp
src/gui/kernel/qlayoutengine.cpp
src/gui/kernel/qlayoutitem.cpp

index e3a1bd3..2ba0720 100644 (file)
@@ -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)
index a8fb71e..f99df54 100644 (file)
@@ -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<QWidget*>(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();
index ae0370a..06f8ae5 100644 (file)
@@ -88,9 +88,8 @@ void qGeomCalc(QVector<QLayoutStruct> &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<QLayoutStruct> &chain, int start, int count,
 
         QList<int> 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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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<QLayoutStruct> &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
index 9babdf3..9549076 100644 (file)
@@ -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.