QTfrontend/ui/widget/flowlayout.cpp
author dag10 <gottlieb.drew@gmail.com>
Mon, 14 Jan 2013 22:09:07 -0500
changeset 8390 0b2403003640
parent 8386 2aaa2995a32e
child 8434 4821897a0f10
permissions -rw-r--r--
Added "what we use" section to "about" page. From GCI.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8377
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     1
 /****************************************************************************
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     2
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     3
 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     4
 ** All rights reserved.
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     5
 ** Contact: Nokia Corporation (qt-info@nokia.com)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     6
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     7
 ** This file is part of the examples of the Qt Toolkit.
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     8
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
     9
 ** $QT_BEGIN_LICENSE:BSD$
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    10
 ** You may use this file under the terms of the BSD license as follows:
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    11
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    12
 ** "Redistribution and use in source and binary forms, with or without
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    13
 ** modification, are permitted provided that the following conditions are
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    14
 ** met:
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    15
 **   * Redistributions of source code must retain the above copyright
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    16
 **     notice, this list of conditions and the following disclaimer.
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    17
 **   * Redistributions in binary form must reproduce the above copyright
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    18
 **     notice, this list of conditions and the following disclaimer in
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    19
 **     the documentation and/or other materials provided with the
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    20
 **     distribution.
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    21
 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    22
 **     the names of its contributors may be used to endorse or promote
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    23
 **     products derived from this software without specific prior written
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    24
 **     permission.
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    25
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    26
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    27
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    28
 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    29
 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    30
 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    31
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    32
 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    33
 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    34
 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    35
 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    36
 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    37
 ** $QT_END_LICENSE$
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    38
 **
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    39
 ****************************************************************************/
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    40
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    41
 #include <QtGui>
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    42
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    43
 #include "flowlayout.h"
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    44
 
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    45
 FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    46
     : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    47
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    48
     setContentsMargins(margin, margin, margin, margin);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    49
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    50
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    51
 FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    52
     : m_hSpace(hSpacing), m_vSpace(vSpacing)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    53
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    54
     setContentsMargins(margin, margin, margin, margin);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    55
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    56
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    57
 FlowLayout::~FlowLayout()
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    58
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    59
     QLayoutItem *item;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    60
     while ((item = takeAt(0)))
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    61
         delete item;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    62
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    63
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    64
 void FlowLayout::addItem(QLayoutItem *item)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    65
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    66
     itemList.append(item);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    67
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    68
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    69
 int FlowLayout::horizontalSpacing() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    70
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    71
     if (m_hSpace >= 0) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    72
         return m_hSpace;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    73
     } else {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    74
         return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    75
     }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    76
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    77
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    78
 int FlowLayout::verticalSpacing() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    79
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    80
     if (m_vSpace >= 0) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    81
         return m_vSpace;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    82
     } else {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    83
         return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    84
     }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    85
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    86
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    87
 int FlowLayout::count() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    88
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    89
     return itemList.size();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    90
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    91
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    92
 QLayoutItem *FlowLayout::itemAt(int index) const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    93
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    94
     return itemList.value(index);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    95
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    96
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    97
 QLayoutItem *FlowLayout::takeAt(int index)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    98
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
    99
     if (index >= 0 && index < itemList.size())
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   100
         return itemList.takeAt(index);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   101
     else
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   102
         return 0;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   103
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   104
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   105
 Qt::Orientations FlowLayout::expandingDirections() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   106
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   107
     return 0;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   108
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   109
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   110
 bool FlowLayout::hasHeightForWidth() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   111
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   112
     return true;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   113
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   114
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   115
 int FlowLayout::heightForWidth(int width) const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   116
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   117
     int height = doLayout(QRect(0, 0, width, 0), true);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   118
     return height;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   119
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   120
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   121
 void FlowLayout::setGeometry(const QRect &rect)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   122
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   123
     QLayout::setGeometry(rect);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   124
     doLayout(rect, false);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   125
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   126
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   127
 QSize FlowLayout::sizeHint() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   128
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   129
     return minimumSize();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   130
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   131
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   132
 QSize FlowLayout::minimumSize() const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   133
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   134
     QSize size;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   135
     QLayoutItem *item;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   136
     foreach (item, itemList)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   137
         size = size.expandedTo(item->minimumSize());
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   138
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   139
     size += QSize(2*margin(), 2*margin());
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   140
     return size;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   141
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   142
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   143
 int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   144
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   145
     int left, top, right, bottom;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   146
     getContentsMargins(&left, &top, &right, &bottom);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   147
     QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   148
     int x = effectiveRect.x();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   149
     int y = effectiveRect.y();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   150
     int lineHeight = 0;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   151
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   152
     QLayoutItem *item;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   153
     foreach (item, itemList) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   154
         QWidget *wid = item->widget();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   155
         int spaceX = horizontalSpacing();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   156
         if (spaceX == -1)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   157
             spaceX = wid->style()->layoutSpacing(
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   158
                 QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   159
         int spaceY = verticalSpacing();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   160
         if (spaceY == -1)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   161
             spaceY = wid->style()->layoutSpacing(
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   162
                 QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   163
         int nextX = x + item->sizeHint().width() + spaceX;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   164
         if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   165
             x = effectiveRect.x();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   166
             y = y + lineHeight + spaceY;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   167
             nextX = x + item->sizeHint().width() + spaceX;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   168
             lineHeight = 0;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   169
         }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   170
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   171
         if (!testOnly)
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   172
             item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   173
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   174
         x = nextX;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   175
         lineHeight = qMax(lineHeight, item->sizeHint().height());
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   176
     }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   177
     return y + lineHeight - rect.y() + bottom;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   178
 }
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   179
 int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   180
 {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   181
     QObject *parent = this->parent();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   182
     if (!parent) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   183
         return -1;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   184
     } else if (parent->isWidgetType()) {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   185
         QWidget *pw = static_cast<QWidget *>(parent);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   186
         return pw->style()->pixelMetric(pm, 0, pw);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   187
     } else {
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   188
         return static_cast<QLayout *>(parent)->spacing();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents:
diff changeset
   189
     }
8386
2aaa2995a32e - Fix another ton of bugs and misbehavior
unc0rr
parents: 8377
diff changeset
   190
 }