Changeset 561 for trunk/examples/layouts/flowlayout/flowlayout.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/examples/layouts/flowlayout/flowlayout.cpp
r2 r561 2 2 ** 3 3 ** 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]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 43 43 44 44 #include "flowlayout.h" 45 45 //! [1] 46 46 FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) 47 47 : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) 48 48 { 49 set Margin(margin);49 setmargin); 50 50 } 51 51 … … 53 53 : m_hSpace(hSpacing), m_vSpace(vSpacing) 54 54 { 55 setMargin(margin); 56 } 57 55 setContentsMargins(margin, margin, margin, margin); 56 } 57 //! [1] 58 59 //! [2] 58 60 FlowLayout::~FlowLayout() 59 61 { … … 62 64 delete item; 63 65 } 64 66 //! [2] 67 68 //! [3] 65 69 void FlowLayout::addItem(QLayoutItem *item) 66 70 { 67 71 itemList.append(item); 68 72 } 69 73 //! [3] 74 75 //! [4] 70 76 int FlowLayout::horizontalSpacing() const 71 77 { … … 85 91 } 86 92 } 87 93 //! [4] 94 95 //! [5] 88 96 int FlowLayout::count() const 89 97 { … … 103 111 return 0; 104 112 } 105 113 //! [5] 114 115 //! [6] 106 116 Qt::Orientations FlowLayout::expandingDirections() const 107 117 { 108 118 return 0; 109 119 } 110 120 //! [6] 121 122 //! [7] 111 123 bool FlowLayout::hasHeightForWidth() const 112 124 { … … 119 131 return height; 120 132 } 121 133 //! [7] 134 135 //! [8] 122 136 void FlowLayout::setGeometry(const QRect &rect) 123 137 { … … 141 155 return size; 142 156 } 143 157 //! [8] 158 159 //! [9] 144 160 int FlowLayout::doLayout(const QRect &rect, bool testOnly) const 145 161 { … … 150 166 int y = effectiveRect.y(); 151 167 int lineHeight = 0; 152 168 //! [9] 169 170 //! [10] 153 171 QLayoutItem *item; 154 172 foreach (item, itemList) { … … 162 180 spaceY = wid->style()->layoutSpacing( 163 181 QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); 182 183 164 184 int nextX = x + item->sizeHint().width() + spaceX; 165 185 if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { … … 178 198 return y + lineHeight - rect.y() + bottom; 179 199 } 180 200 //! [11] 201 //! [12] 181 202 int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const 182 203 { … … 191 212 } 192 213 } 193 214 //! [12]
Note:
See TracChangeset
for help on using the changeset viewer.