Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/examples/layouts/flowlayout/flowlayout.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343
    4444#include "flowlayout.h"
    45 
     45//! [1]
    4646FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
    4747    : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
    4848{
    49     setMargin(margin);
     49    setmargin);
    5050}
    5151
     
    5353    : m_hSpace(hSpacing), m_vSpace(vSpacing)
    5454{
    55     setMargin(margin);
    56 }
    57 
     55    setContentsMargins(margin, margin, margin, margin);
     56}
     57//! [1]
     58
     59//! [2]
    5860FlowLayout::~FlowLayout()
    5961{
     
    6264        delete item;
    6365}
    64 
     66//! [2]
     67
     68//! [3]
    6569void FlowLayout::addItem(QLayoutItem *item)
    6670{
    6771    itemList.append(item);
    6872}
    69 
     73//! [3]
     74
     75//! [4]
    7076int FlowLayout::horizontalSpacing() const
    7177{
     
    8591    }
    8692}
    87 
     93//! [4]
     94
     95//! [5]
    8896int FlowLayout::count() const
    8997{
     
    103111        return 0;
    104112}
    105 
     113//! [5]
     114
     115//! [6]
    106116Qt::Orientations FlowLayout::expandingDirections() const
    107117{
    108118    return 0;
    109119}
    110 
     120//! [6]
     121
     122//! [7]
    111123bool FlowLayout::hasHeightForWidth() const
    112124{
     
    119131    return height;
    120132}
    121 
     133//! [7]
     134
     135//! [8]
    122136void FlowLayout::setGeometry(const QRect &rect)
    123137{
     
    141155    return size;
    142156}
    143 
     157//! [8]
     158
     159//! [9]
    144160int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
    145161{
     
    150166    int y = effectiveRect.y();
    151167    int lineHeight = 0;
    152 
     168//! [9]
     169
     170//! [10]
    153171    QLayoutItem *item;
    154172    foreach (item, itemList) {
     
    162180            spaceY = wid->style()->layoutSpacing(
    163181                QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
     182
     183
    164184        int nextX = x + item->sizeHint().width() + spaceX;
    165185        if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
     
    178198    return y + lineHeight - rect.y() + bottom;
    179199}
    180 
     200//! [11]
     201//! [12]
    181202int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
    182203{
     
    191212    }
    192213}
    193 
     214//! [12]
Note: See TracChangeset for help on using the changeset viewer.