Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qsplitter.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "qsplitter.h" | - | ||||||||||||||||||
35 | #ifndef QT_NO_SPLITTER | - | ||||||||||||||||||
36 | - | |||||||||||||||||||
37 | #include "qapplication.h" | - | ||||||||||||||||||
38 | #include "qcursor.h" | - | ||||||||||||||||||
39 | #include "qdrawutil.h" | - | ||||||||||||||||||
40 | #include "qevent.h" | - | ||||||||||||||||||
41 | #include "qlayout.h" | - | ||||||||||||||||||
42 | #include "qlist.h" | - | ||||||||||||||||||
43 | #include "qpainter.h" | - | ||||||||||||||||||
44 | #include "qrubberband.h" | - | ||||||||||||||||||
45 | #include "qstyle.h" | - | ||||||||||||||||||
46 | #include "qstyleoption.h" | - | ||||||||||||||||||
47 | #include "qtextstream.h" | - | ||||||||||||||||||
48 | #include "qvarlengtharray.h" | - | ||||||||||||||||||
49 | #include "qvector.h" | - | ||||||||||||||||||
50 | #include "private/qlayoutengine_p.h" | - | ||||||||||||||||||
51 | #include "private/qsplitter_p.h" | - | ||||||||||||||||||
52 | #include "qtimer.h" | - | ||||||||||||||||||
53 | #include "qdebug.h" | - | ||||||||||||||||||
54 | - | |||||||||||||||||||
55 | #include <ctype.h> | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | //#define QSPLITTER_DEBUG | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | QSplitterPrivate::~QSplitterPrivate() | - | ||||||||||||||||||
62 | { | - | ||||||||||||||||||
63 | } | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | /*! | - | ||||||||||||||||||
66 | \class QSplitterHandle | - | ||||||||||||||||||
67 | \brief The QSplitterHandle class provides handle functionality for the splitter. | - | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | \ingroup organizers | - | ||||||||||||||||||
70 | \inmodule QtWidgets | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | QSplitterHandle is typically what people think about when they think about | - | ||||||||||||||||||
73 | a splitter. It is the handle that is used to resize the widgets. | - | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | A typical developer using QSplitter will never have to worry about | - | ||||||||||||||||||
76 | QSplitterHandle. It is provided for developers who want splitter handles | - | ||||||||||||||||||
77 | that provide extra features, such as popup menus. | - | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | The typical way one would create splitter handles is to subclass QSplitter and then | - | ||||||||||||||||||
80 | reimplement QSplitter::createHandle() to instantiate the custom splitter | - | ||||||||||||||||||
81 | handle. For example, a minimum QSplitter subclass might look like this: | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | \snippet splitterhandle/splitter.h 0 | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | The \l{QSplitter::}{createHandle()} implementation simply constructs a | - | ||||||||||||||||||
86 | custom splitter handle, called \c Splitter in this example: | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | \snippet splitterhandle/splitter.cpp 1 | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | Information about a given handle can be obtained using functions like | - | ||||||||||||||||||
91 | orientation() and opaqueResize(), and is retrieved from its parent splitter. | - | ||||||||||||||||||
92 | Details like these can be used to give custom handles different appearances | - | ||||||||||||||||||
93 | depending on the splitter's orientation. | - | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | The complexity of a custom handle subclass depends on the tasks that it | - | ||||||||||||||||||
96 | needs to perform. A simple subclass might only provide a paintEvent() | - | ||||||||||||||||||
97 | implementation: | - | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | \snippet splitterhandle/splitter.cpp 0 | - | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | In this example, a predefined gradient is set up differently depending on | - | ||||||||||||||||||
102 | the orientation of the handle. QSplitterHandle provides a reasonable | - | ||||||||||||||||||
103 | size hint for the handle, so the subclass does not need to provide a | - | ||||||||||||||||||
104 | reimplementation of sizeHint() unless the handle has special size | - | ||||||||||||||||||
105 | requirements. | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | \sa QSplitter | - | ||||||||||||||||||
108 | */ | - | ||||||||||||||||||
109 | - | |||||||||||||||||||
110 | /*! | - | ||||||||||||||||||
111 | Creates a QSplitter handle with the given \a orientation and | - | ||||||||||||||||||
112 | \a parent. | - | ||||||||||||||||||
113 | */ | - | ||||||||||||||||||
114 | QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) | - | ||||||||||||||||||
115 | : QWidget(*new QSplitterHandlePrivate, parent, 0) | - | ||||||||||||||||||
116 | { | - | ||||||||||||||||||
117 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
118 | d->s = parent; | - | ||||||||||||||||||
119 | setOrientation(orientation); | - | ||||||||||||||||||
120 | } never executed: end of block | 0 | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | /*! | - | ||||||||||||||||||
123 | Destructor. | - | ||||||||||||||||||
124 | */ | - | ||||||||||||||||||
125 | QSplitterHandle::~QSplitterHandle() | - | ||||||||||||||||||
126 | { | - | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | /*! | - | ||||||||||||||||||
130 | Sets the orientation of the splitter handle to \a orientation. | - | ||||||||||||||||||
131 | This is usually propagated from the QSplitter. | - | ||||||||||||||||||
132 | - | |||||||||||||||||||
133 | \sa QSplitter::setOrientation() | - | ||||||||||||||||||
134 | */ | - | ||||||||||||||||||
135 | void QSplitterHandle::setOrientation(Qt::Orientation orientation) | - | ||||||||||||||||||
136 | { | - | ||||||||||||||||||
137 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
138 | d->orient = orientation; | - | ||||||||||||||||||
139 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
140 | setCursor(orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); | - | ||||||||||||||||||
141 | #endif | - | ||||||||||||||||||
142 | } never executed: end of block | 0 | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | /*! | - | ||||||||||||||||||
145 | Returns the handle's orientation. This is usually propagated from the QSplitter. | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | \sa QSplitter::orientation() | - | ||||||||||||||||||
148 | */ | - | ||||||||||||||||||
149 | Qt::Orientation QSplitterHandle::orientation() const | - | ||||||||||||||||||
150 | { | - | ||||||||||||||||||
151 | Q_D(const QSplitterHandle); | - | ||||||||||||||||||
152 | return d->orient; never executed: return d->orient; | 0 | ||||||||||||||||||
153 | } | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | - | |||||||||||||||||||
156 | /*! | - | ||||||||||||||||||
157 | Returns \c true if widgets are resized dynamically (opaquely), otherwise | - | ||||||||||||||||||
158 | returns \c false. This value is controlled by the QSplitter. | - | ||||||||||||||||||
159 | - | |||||||||||||||||||
160 | \sa QSplitter::opaqueResize() | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | */ | - | ||||||||||||||||||
163 | bool QSplitterHandle::opaqueResize() const | - | ||||||||||||||||||
164 | { | - | ||||||||||||||||||
165 | Q_D(const QSplitterHandle); | - | ||||||||||||||||||
166 | return d->s->opaqueResize(); never executed: return d->s->opaqueResize(); | 0 | ||||||||||||||||||
167 | } | - | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | - | |||||||||||||||||||
170 | /*! | - | ||||||||||||||||||
171 | Returns the splitter associated with this splitter handle. | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | \sa QSplitter::handle() | - | ||||||||||||||||||
174 | */ | - | ||||||||||||||||||
175 | QSplitter *QSplitterHandle::splitter() const | - | ||||||||||||||||||
176 | { | - | ||||||||||||||||||
177 | return d_func()->s; never executed: return d_func()->s; | 0 | ||||||||||||||||||
178 | } | - | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | /*! | - | ||||||||||||||||||
181 | Tells the splitter to move this handle to position \a pos, which is | - | ||||||||||||||||||
182 | the distance from the left or top edge of the widget. | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | Note that \a pos is also measured from the left (or top) for | - | ||||||||||||||||||
185 | right-to-left languages. This function will map \a pos to the | - | ||||||||||||||||||
186 | appropriate position before calling QSplitter::moveSplitter(). | - | ||||||||||||||||||
187 | - | |||||||||||||||||||
188 | \sa QSplitter::moveSplitter(), closestLegalPosition() | - | ||||||||||||||||||
189 | */ | - | ||||||||||||||||||
190 | void QSplitterHandle::moveSplitter(int pos) | - | ||||||||||||||||||
191 | { | - | ||||||||||||||||||
192 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
193 | if (d->s->isRightToLeft() && d->orient == Qt::Horizontal)
| 0 | ||||||||||||||||||
194 | pos = d->s->contentsRect().width() - pos; never executed: pos = d->s->contentsRect().width() - pos; | 0 | ||||||||||||||||||
195 | d->s->moveSplitter(pos, d->s->indexOf(this)); | - | ||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | /*! | - | ||||||||||||||||||
199 | Returns the closest legal position to \a pos of the splitter | - | ||||||||||||||||||
200 | handle. The positions are measured from the left or top edge of | - | ||||||||||||||||||
201 | the splitter, even for right-to-left languages. | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | \sa QSplitter::closestLegalPosition(), moveSplitter() | - | ||||||||||||||||||
204 | */ | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | int QSplitterHandle::closestLegalPosition(int pos) | - | ||||||||||||||||||
207 | { | - | ||||||||||||||||||
208 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
209 | QSplitter *s = d->s; | - | ||||||||||||||||||
210 | if (s->isRightToLeft() && d->orient == Qt::Horizontal) {
| 0 | ||||||||||||||||||
211 | int w = s->contentsRect().width(); | - | ||||||||||||||||||
212 | return w - s->closestLegalPosition(w - pos, s->indexOf(this)); never executed: return w - s->closestLegalPosition(w - pos, s->indexOf(this)); | 0 | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | return s->closestLegalPosition(pos, s->indexOf(this)); never executed: return s->closestLegalPosition(pos, s->indexOf(this)); | 0 | ||||||||||||||||||
215 | } | - | ||||||||||||||||||
216 | - | |||||||||||||||||||
217 | /*! | - | ||||||||||||||||||
218 | \reimp | - | ||||||||||||||||||
219 | */ | - | ||||||||||||||||||
220 | QSize QSplitterHandle::sizeHint() const | - | ||||||||||||||||||
221 | { | - | ||||||||||||||||||
222 | Q_D(const QSplitterHandle); | - | ||||||||||||||||||
223 | int hw = d->s->handleWidth(); | - | ||||||||||||||||||
224 | QStyleOption opt(0); | - | ||||||||||||||||||
225 | opt.init(d->s); | - | ||||||||||||||||||
226 | opt.state = QStyle::State_None; | - | ||||||||||||||||||
227 | return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) never executed: return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) .expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||
228 | .expandedTo(QApplication::globalStrut()); never executed: return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) .expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | /*! | - | ||||||||||||||||||
232 | \reimp | - | ||||||||||||||||||
233 | */ | - | ||||||||||||||||||
234 | void QSplitterHandle::resizeEvent(QResizeEvent *event) | - | ||||||||||||||||||
235 | { | - | ||||||||||||||||||
236 | Q_D(const QSplitterHandle); | - | ||||||||||||||||||
237 | - | |||||||||||||||||||
238 | // When splitters are only 1 or 0 pixel large we increase the | - | ||||||||||||||||||
239 | // actual grab area to five pixels | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | // Note that QSplitter uses contentsRect for layouting | - | ||||||||||||||||||
242 | // and ensures that handles are drawn on top of widgets | - | ||||||||||||||||||
243 | // We simply use the contents margins for draggin and only | - | ||||||||||||||||||
244 | // paint the mask area | - | ||||||||||||||||||
245 | bool useTinyMode = (d->s->handleWidth() <= 1); | - | ||||||||||||||||||
246 | setAttribute(Qt::WA_MouseNoMask, useTinyMode); | - | ||||||||||||||||||
247 | if (useTinyMode) {
| 0 | ||||||||||||||||||
248 | if (orientation() == Qt::Horizontal)
| 0 | ||||||||||||||||||
249 | setContentsMargins(2, 0, 2, 0); never executed: setContentsMargins(2, 0, 2, 0); | 0 | ||||||||||||||||||
250 | else | - | ||||||||||||||||||
251 | setContentsMargins(0, 2, 0, 2); never executed: setContentsMargins(0, 2, 0, 2); | 0 | ||||||||||||||||||
252 | setMask(QRegion(contentsRect())); | - | ||||||||||||||||||
253 | } never executed: end of block | 0 | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | QWidget::resizeEvent(event); | - | ||||||||||||||||||
256 | } never executed: end of block | 0 | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | /*! | - | ||||||||||||||||||
259 | \reimp | - | ||||||||||||||||||
260 | */ | - | ||||||||||||||||||
261 | bool QSplitterHandle::event(QEvent *event) | - | ||||||||||||||||||
262 | { | - | ||||||||||||||||||
263 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
264 | switch(event->type()) { | - | ||||||||||||||||||
265 | case QEvent::HoverEnter: never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||
266 | d->hover = true; | - | ||||||||||||||||||
267 | update(); | - | ||||||||||||||||||
268 | break; never executed: break; | 0 | ||||||||||||||||||
269 | case QEvent::HoverLeave: never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||
270 | d->hover = false; | - | ||||||||||||||||||
271 | update(); | - | ||||||||||||||||||
272 | break; never executed: break; | 0 | ||||||||||||||||||
273 | default: never executed: default: | 0 | ||||||||||||||||||
274 | break; never executed: break; | 0 | ||||||||||||||||||
275 | } | - | ||||||||||||||||||
276 | return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||
277 | } | - | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | /*! | - | ||||||||||||||||||
280 | \reimp | - | ||||||||||||||||||
281 | */ | - | ||||||||||||||||||
282 | void QSplitterHandle::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||
283 | { | - | ||||||||||||||||||
284 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
285 | if (!(e->buttons() & Qt::LeftButton))
| 0 | ||||||||||||||||||
286 | return; never executed: return; | 0 | ||||||||||||||||||
287 | int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) | - | ||||||||||||||||||
288 | - d->mouseOffset; | - | ||||||||||||||||||
289 | if (opaqueResize()) {
| 0 | ||||||||||||||||||
290 | moveSplitter(pos); | - | ||||||||||||||||||
291 | } else { never executed: end of block | 0 | ||||||||||||||||||
292 | d->s->setRubberBand(closestLegalPosition(pos)); | - | ||||||||||||||||||
293 | } never executed: end of block | 0 | ||||||||||||||||||
294 | } | - | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | /*! | - | ||||||||||||||||||
297 | \reimp | - | ||||||||||||||||||
298 | */ | - | ||||||||||||||||||
299 | void QSplitterHandle::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||
300 | { | - | ||||||||||||||||||
301 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
302 | if (e->button() == Qt::LeftButton) {
| 0 | ||||||||||||||||||
303 | d->mouseOffset = d->pick(e->pos()); | - | ||||||||||||||||||
304 | d->pressed = true; | - | ||||||||||||||||||
305 | update(); | - | ||||||||||||||||||
306 | } never executed: end of block | 0 | ||||||||||||||||||
307 | } never executed: end of block | 0 | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | /*! | - | ||||||||||||||||||
310 | \reimp | - | ||||||||||||||||||
311 | */ | - | ||||||||||||||||||
312 | void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||
313 | { | - | ||||||||||||||||||
314 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
315 | if (!opaqueResize() && e->button() == Qt::LeftButton) {
| 0 | ||||||||||||||||||
316 | int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPos())) | - | ||||||||||||||||||
317 | - d->mouseOffset; | - | ||||||||||||||||||
318 | d->s->setRubberBand(-1); | - | ||||||||||||||||||
319 | moveSplitter(pos); | - | ||||||||||||||||||
320 | } never executed: end of block | 0 | ||||||||||||||||||
321 | if (e->button() == Qt::LeftButton) {
| 0 | ||||||||||||||||||
322 | d->pressed = false; | - | ||||||||||||||||||
323 | update(); | - | ||||||||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | /*! | - | ||||||||||||||||||
328 | \reimp | - | ||||||||||||||||||
329 | */ | - | ||||||||||||||||||
330 | void QSplitterHandle::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
331 | { | - | ||||||||||||||||||
332 | Q_D(QSplitterHandle); | - | ||||||||||||||||||
333 | QPainter p(this); | - | ||||||||||||||||||
334 | QStyleOption opt(0); | - | ||||||||||||||||||
335 | opt.rect = contentsRect(); | - | ||||||||||||||||||
336 | opt.palette = palette(); | - | ||||||||||||||||||
337 | if (orientation() == Qt::Horizontal)
| 0 | ||||||||||||||||||
338 | opt.state = QStyle::State_Horizontal; never executed: opt.state = QStyle::State_Horizontal; | 0 | ||||||||||||||||||
339 | else | - | ||||||||||||||||||
340 | opt.state = QStyle::State_None; never executed: opt.state = QStyle::State_None; | 0 | ||||||||||||||||||
341 | if (d->hover)
| 0 | ||||||||||||||||||
342 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||
343 | if (d->pressed)
| 0 | ||||||||||||||||||
344 | opt.state |= QStyle::State_Sunken; never executed: opt.state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||
345 | if (isEnabled())
| 0 | ||||||||||||||||||
346 | opt.state |= QStyle::State_Enabled; never executed: opt.state |= QStyle::State_Enabled; | 0 | ||||||||||||||||||
347 | parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s); | - | ||||||||||||||||||
348 | } never executed: end of block | 0 | ||||||||||||||||||
349 | - | |||||||||||||||||||
350 | - | |||||||||||||||||||
351 | int QSplitterLayoutStruct::getWidgetSize(Qt::Orientation orient) | - | ||||||||||||||||||
352 | { | - | ||||||||||||||||||
353 | if (sizer == -1) {
| 0 | ||||||||||||||||||
354 | QSize s = widget->sizeHint(); | - | ||||||||||||||||||
355 | const int presizer = pick(s, orient); | - | ||||||||||||||||||
356 | const int realsize = pick(widget->size(), orient); | - | ||||||||||||||||||
357 | if (!s.isValid() || (widget->testAttribute(Qt::WA_Resized) && (realsize > presizer))) {
| 0 | ||||||||||||||||||
358 | sizer = pick(widget->size(), orient); | - | ||||||||||||||||||
359 | } else { never executed: end of block | 0 | ||||||||||||||||||
360 | sizer = presizer; | - | ||||||||||||||||||
361 | } never executed: end of block | 0 | ||||||||||||||||||
362 | QSizePolicy p = widget->sizePolicy(); | - | ||||||||||||||||||
363 | int sf = (orient == Qt::Horizontal) ? p.horizontalStretch() : p.verticalStretch();
| 0 | ||||||||||||||||||
364 | if (sf > 1)
| 0 | ||||||||||||||||||
365 | sizer *= sf; never executed: sizer *= sf; | 0 | ||||||||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||||||||
367 | return sizer; never executed: return sizer; | 0 | ||||||||||||||||||
368 | } | - | ||||||||||||||||||
369 | - | |||||||||||||||||||
370 | int QSplitterLayoutStruct::getHandleSize(Qt::Orientation orient) | - | ||||||||||||||||||
371 | { | - | ||||||||||||||||||
372 | return pick(handle->sizeHint(), orient); never executed: return pick(handle->sizeHint(), orient); | 0 | ||||||||||||||||||
373 | } | - | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | void QSplitterPrivate::init() | - | ||||||||||||||||||
376 | { | - | ||||||||||||||||||
377 | Q_Q(QSplitter); | - | ||||||||||||||||||
378 | QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Preferred); | - | ||||||||||||||||||
379 | if (orient == Qt::Vertical)
| 0 | ||||||||||||||||||
380 | sp.transpose(); never executed: sp.transpose(); | 0 | ||||||||||||||||||
381 | q->setSizePolicy(sp); | - | ||||||||||||||||||
382 | q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - | ||||||||||||||||||
383 | } never executed: end of block | 0 | ||||||||||||||||||
384 | - | |||||||||||||||||||
385 | void QSplitterPrivate::recalc(bool update) | - | ||||||||||||||||||
386 | { | - | ||||||||||||||||||
387 | Q_Q(QSplitter); | - | ||||||||||||||||||
388 | int n = list.count(); | - | ||||||||||||||||||
389 | /* | - | ||||||||||||||||||
390 | Splitter handles before the first visible widget or right | - | ||||||||||||||||||
391 | before a hidden widget must be hidden. | - | ||||||||||||||||||
392 | */ | - | ||||||||||||||||||
393 | bool first = true; | - | ||||||||||||||||||
394 | bool allInvisible = n != 0; | - | ||||||||||||||||||
395 | for (int i = 0; i < n ; ++i) {
| 0 | ||||||||||||||||||
396 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
397 | bool widgetHidden = s->widget->isHidden(); | - | ||||||||||||||||||
398 | if (allInvisible && !widgetHidden && !s->collapsed)
| 0 | ||||||||||||||||||
399 | allInvisible = false; never executed: allInvisible = false; | 0 | ||||||||||||||||||
400 | s->handle->setHidden(first || widgetHidden); | - | ||||||||||||||||||
401 | if (!widgetHidden)
| 0 | ||||||||||||||||||
402 | first = false; never executed: first = false; | 0 | ||||||||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | if (allInvisible)
| 0 | ||||||||||||||||||
406 | for (int i = 0; i < n ; ++i) {
| 0 | ||||||||||||||||||
407 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
408 | if (!s->widget->isHidden()) {
| 0 | ||||||||||||||||||
409 | s->collapsed = false; | - | ||||||||||||||||||
410 | break; never executed: break; | 0 | ||||||||||||||||||
411 | } | - | ||||||||||||||||||
412 | } never executed: end of block | 0 | ||||||||||||||||||
413 | - | |||||||||||||||||||
414 | int fi = 2 * q->frameWidth(); | - | ||||||||||||||||||
415 | int maxl = fi; | - | ||||||||||||||||||
416 | int minl = fi; | - | ||||||||||||||||||
417 | int maxt = QWIDGETSIZE_MAX; | - | ||||||||||||||||||
418 | int mint = fi; | - | ||||||||||||||||||
419 | /* | - | ||||||||||||||||||
420 | calculate min/max sizes for the whole splitter | - | ||||||||||||||||||
421 | */ | - | ||||||||||||||||||
422 | bool empty = true; | - | ||||||||||||||||||
423 | for (int j = 0; j < n; j++) {
| 0 | ||||||||||||||||||
424 | QSplitterLayoutStruct *s = list.at(j); | - | ||||||||||||||||||
425 | - | |||||||||||||||||||
426 | if (!s->widget->isHidden()) {
| 0 | ||||||||||||||||||
427 | empty = false; | - | ||||||||||||||||||
428 | if (!s->handle->isHidden()) {
| 0 | ||||||||||||||||||
429 | minl += s->getHandleSize(orient); | - | ||||||||||||||||||
430 | maxl += s->getHandleSize(orient); | - | ||||||||||||||||||
431 | } never executed: end of block | 0 | ||||||||||||||||||
432 | - | |||||||||||||||||||
433 | QSize minS = qSmartMinSize(s->widget); | - | ||||||||||||||||||
434 | minl += pick(minS); | - | ||||||||||||||||||
435 | maxl += pick(s->widget->maximumSize()); | - | ||||||||||||||||||
436 | mint = qMax(mint, trans(minS)); | - | ||||||||||||||||||
437 | int tm = trans(s->widget->maximumSize()); | - | ||||||||||||||||||
438 | if (tm > 0)
| 0 | ||||||||||||||||||
439 | maxt = qMin(maxt, tm); never executed: maxt = qMin(maxt, tm); | 0 | ||||||||||||||||||
440 | } never executed: end of block | 0 | ||||||||||||||||||
441 | } never executed: end of block | 0 | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | if (empty) {
| 0 | ||||||||||||||||||
444 | if (qobject_cast<QSplitter *>(parent)) {
| 0 | ||||||||||||||||||
445 | // nested splitters; be nice | - | ||||||||||||||||||
446 | maxl = maxt = 0; | - | ||||||||||||||||||
447 | } else { never executed: end of block | 0 | ||||||||||||||||||
448 | // QSplitter with no children yet | - | ||||||||||||||||||
449 | maxl = QWIDGETSIZE_MAX; | - | ||||||||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||||||||
451 | } else { | - | ||||||||||||||||||
452 | maxl = qMin<int>(maxl, QWIDGETSIZE_MAX); | - | ||||||||||||||||||
453 | } never executed: end of block | 0 | ||||||||||||||||||
454 | if (maxt < mint)
| 0 | ||||||||||||||||||
455 | maxt = mint; never executed: maxt = mint; | 0 | ||||||||||||||||||
456 | - | |||||||||||||||||||
457 | if (update) {
| 0 | ||||||||||||||||||
458 | if (orient == Qt::Horizontal) {
| 0 | ||||||||||||||||||
459 | q->setMaximumSize(maxl, maxt); | - | ||||||||||||||||||
460 | if (q->isWindow())
| 0 | ||||||||||||||||||
461 | q->setMinimumSize(minl,mint); never executed: q->setMinimumSize(minl,mint); | 0 | ||||||||||||||||||
462 | } else { never executed: end of block | 0 | ||||||||||||||||||
463 | q->setMaximumSize(maxt, maxl); | - | ||||||||||||||||||
464 | if (q->isWindow())
| 0 | ||||||||||||||||||
465 | q->setMinimumSize(mint,minl); never executed: q->setMinimumSize(mint,minl); | 0 | ||||||||||||||||||
466 | } never executed: end of block | 0 | ||||||||||||||||||
467 | doResize(); | - | ||||||||||||||||||
468 | q->updateGeometry(); | - | ||||||||||||||||||
469 | } else { never executed: end of block | 0 | ||||||||||||||||||
470 | firstShow = true; | - | ||||||||||||||||||
471 | } never executed: end of block | 0 | ||||||||||||||||||
472 | } | - | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | void QSplitterPrivate::doResize() | - | ||||||||||||||||||
475 | { | - | ||||||||||||||||||
476 | Q_Q(QSplitter); | - | ||||||||||||||||||
477 | QRect r = q->contentsRect(); | - | ||||||||||||||||||
478 | int n = list.count(); | - | ||||||||||||||||||
479 | QVector<QLayoutStruct> a(n*2); | - | ||||||||||||||||||
480 | int i; | - | ||||||||||||||||||
481 | - | |||||||||||||||||||
482 | bool noStretchFactorsSet = true; | - | ||||||||||||||||||
483 | for (i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||
484 | QSizePolicy p = list.at(i)->widget->sizePolicy(); | - | ||||||||||||||||||
485 | int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
| 0 | ||||||||||||||||||
486 | if (sf != 0) {
| 0 | ||||||||||||||||||
487 | noStretchFactorsSet = false; | - | ||||||||||||||||||
488 | break; never executed: break; | 0 | ||||||||||||||||||
489 | } | - | ||||||||||||||||||
490 | } never executed: end of block | 0 | ||||||||||||||||||
491 | - | |||||||||||||||||||
492 | int j=0; | - | ||||||||||||||||||
493 | for (i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||
494 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
495 | #ifdef QSPLITTER_DEBUG | - | ||||||||||||||||||
496 | qDebug("widget %d hidden: %d collapsed: %d handle hidden: %d", i, s->widget->isHidden(), | - | ||||||||||||||||||
497 | s->collapsed, s->handle->isHidden()); | - | ||||||||||||||||||
498 | #endif | - | ||||||||||||||||||
499 | - | |||||||||||||||||||
500 | a[j].init(); | - | ||||||||||||||||||
501 | if (s->handle->isHidden()) {
| 0 | ||||||||||||||||||
502 | a[j].maximumSize = 0; | - | ||||||||||||||||||
503 | } else { never executed: end of block | 0 | ||||||||||||||||||
504 | a[j].sizeHint = a[j].minimumSize = a[j].maximumSize = s->getHandleSize(orient); | - | ||||||||||||||||||
505 | a[j].empty = false; | - | ||||||||||||||||||
506 | } never executed: end of block | 0 | ||||||||||||||||||
507 | ++j; | - | ||||||||||||||||||
508 | - | |||||||||||||||||||
509 | a[j].init(); | - | ||||||||||||||||||
510 | if (s->widget->isHidden() || s->collapsed) {
| 0 | ||||||||||||||||||
511 | a[j].maximumSize = 0; | - | ||||||||||||||||||
512 | } else { never executed: end of block | 0 | ||||||||||||||||||
513 | a[j].minimumSize = pick(qSmartMinSize(s->widget)); | - | ||||||||||||||||||
514 | a[j].maximumSize = pick(s->widget->maximumSize()); | - | ||||||||||||||||||
515 | a[j].empty = false; | - | ||||||||||||||||||
516 | - | |||||||||||||||||||
517 | bool stretch = noStretchFactorsSet; | - | ||||||||||||||||||
518 | if (!stretch) {
| 0 | ||||||||||||||||||
519 | QSizePolicy p = s->widget->sizePolicy(); | - | ||||||||||||||||||
520 | int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
| 0 | ||||||||||||||||||
521 | stretch = (sf != 0); | - | ||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||
523 | if (stretch) {
| 0 | ||||||||||||||||||
524 | a[j].stretch = s->getWidgetSize(orient); | - | ||||||||||||||||||
525 | a[j].sizeHint = a[j].minimumSize; | - | ||||||||||||||||||
526 | a[j].expansive = true; | - | ||||||||||||||||||
527 | } else { never executed: end of block | 0 | ||||||||||||||||||
528 | a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize); | - | ||||||||||||||||||
529 | } never executed: end of block | 0 | ||||||||||||||||||
530 | } | - | ||||||||||||||||||
531 | ++j; | - | ||||||||||||||||||
532 | } never executed: end of block | 0 | ||||||||||||||||||
533 | - | |||||||||||||||||||
534 | qGeomCalc(a, 0, n*2, pick(r.topLeft()), pick(r.size()), 0); | - | ||||||||||||||||||
535 | - | |||||||||||||||||||
536 | #ifdef QSPLITTER_DEBUG | - | ||||||||||||||||||
537 | for (i = 0; i < n*2; ++i) { | - | ||||||||||||||||||
538 | qDebug("%*s%d: stretch %d, sh %d, minS %d, maxS %d, exp %d, emp %d -> %d, %d", | - | ||||||||||||||||||
539 | i, "", i, | - | ||||||||||||||||||
540 | a[i].stretch, | - | ||||||||||||||||||
541 | a[i].sizeHint, | - | ||||||||||||||||||
542 | a[i].minimumSize, | - | ||||||||||||||||||
543 | a[i].maximumSize, | - | ||||||||||||||||||
544 | a[i].expansive, | - | ||||||||||||||||||
545 | a[i].empty, | - | ||||||||||||||||||
546 | a[i].pos, | - | ||||||||||||||||||
547 | a[i].size); | - | ||||||||||||||||||
548 | } | - | ||||||||||||||||||
549 | #endif | - | ||||||||||||||||||
550 | - | |||||||||||||||||||
551 | for (i = 0; i < n; ++i) {
| 0 | ||||||||||||||||||
552 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
553 | setGeo(s, a[i*2+1].pos, a[i*2+1].size, false); | - | ||||||||||||||||||
554 | } never executed: end of block | 0 | ||||||||||||||||||
555 | } never executed: end of block | 0 | ||||||||||||||||||
556 | - | |||||||||||||||||||
557 | void QSplitterPrivate::storeSizes() | - | ||||||||||||||||||
558 | { | - | ||||||||||||||||||
559 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
560 | QSplitterLayoutStruct *sls = list.at(i); | - | ||||||||||||||||||
561 | sls->sizer = pick(sls->rect.size()); | - | ||||||||||||||||||
562 | } never executed: end of block | 0 | ||||||||||||||||||
563 | } never executed: end of block | 0 | ||||||||||||||||||
564 | - | |||||||||||||||||||
565 | void QSplitterPrivate::addContribution(int index, int *min, int *max, bool mayCollapse) const | - | ||||||||||||||||||
566 | { | - | ||||||||||||||||||
567 | QSplitterLayoutStruct *s = list.at(index); | - | ||||||||||||||||||
568 | if (!s->widget->isHidden()) {
| 0 | ||||||||||||||||||
569 | if (!s->handle->isHidden()) {
| 0 | ||||||||||||||||||
570 | *min += s->getHandleSize(orient); | - | ||||||||||||||||||
571 | *max += s->getHandleSize(orient); | - | ||||||||||||||||||
572 | } never executed: end of block | 0 | ||||||||||||||||||
573 | if (mayCollapse || !s->collapsed)
| 0 | ||||||||||||||||||
574 | *min += pick(qSmartMinSize(s->widget)); never executed: *min += pick(qSmartMinSize(s->widget)); | 0 | ||||||||||||||||||
575 | - | |||||||||||||||||||
576 | *max += pick(s->widget->maximumSize()); | - | ||||||||||||||||||
577 | } never executed: end of block | 0 | ||||||||||||||||||
578 | } never executed: end of block | 0 | ||||||||||||||||||
579 | - | |||||||||||||||||||
580 | int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int &collapsibleSize) const | - | ||||||||||||||||||
581 | { | - | ||||||||||||||||||
582 | if (delta < 0)
| 0 | ||||||||||||||||||
583 | index += delta; never executed: index += delta; | 0 | ||||||||||||||||||
584 | do { | - | ||||||||||||||||||
585 | QWidget *w = list.at(index)->widget; | - | ||||||||||||||||||
586 | if (!w->isHidden()) {
| 0 | ||||||||||||||||||
587 | if (collapsible(list.at(index)))
| 0 | ||||||||||||||||||
588 | collapsibleSize = pick(qSmartMinSize(w)); never executed: collapsibleSize = pick(qSmartMinSize(w)); | 0 | ||||||||||||||||||
589 | return index; never executed: return index; | 0 | ||||||||||||||||||
590 | } | - | ||||||||||||||||||
591 | index += delta; | - | ||||||||||||||||||
592 | } while (index >= 0 && index < list.count()); never executed: end of block
| 0 | ||||||||||||||||||
593 | - | |||||||||||||||||||
594 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
595 | } | - | ||||||||||||||||||
596 | - | |||||||||||||||||||
597 | /* | - | ||||||||||||||||||
598 | For the splitter handle with index \a index, \a min and \a max give the range without collapsing any widgets, | - | ||||||||||||||||||
599 | and \a farMin and farMax give the range with collapsing included. | - | ||||||||||||||||||
600 | */ | - | ||||||||||||||||||
601 | void QSplitterPrivate::getRange(int index, int *farMin, int *min, int *max, int *farMax) const | - | ||||||||||||||||||
602 | { | - | ||||||||||||||||||
603 | Q_Q(const QSplitter); | - | ||||||||||||||||||
604 | int n = list.count(); | - | ||||||||||||||||||
605 | if (index <= 0 || index >= n)
| 0 | ||||||||||||||||||
606 | return; never executed: return; | 0 | ||||||||||||||||||
607 | - | |||||||||||||||||||
608 | int collapsibleSizeBefore = 0; | - | ||||||||||||||||||
609 | int idJustBefore = findWidgetJustBeforeOrJustAfter(index, -1, collapsibleSizeBefore); | - | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | int collapsibleSizeAfter = 0; | - | ||||||||||||||||||
612 | int idJustAfter = findWidgetJustBeforeOrJustAfter(index, +1, collapsibleSizeAfter); | - | ||||||||||||||||||
613 | - | |||||||||||||||||||
614 | int minBefore = 0; | - | ||||||||||||||||||
615 | int minAfter = 0; | - | ||||||||||||||||||
616 | int maxBefore = 0; | - | ||||||||||||||||||
617 | int maxAfter = 0; | - | ||||||||||||||||||
618 | int i; | - | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | for (i = 0; i < index; ++i)
| 0 | ||||||||||||||||||
621 | addContribution(i, &minBefore, &maxBefore, i == idJustBefore); never executed: addContribution(i, &minBefore, &maxBefore, i == idJustBefore); | 0 | ||||||||||||||||||
622 | for (i = index; i < n; ++i)
| 0 | ||||||||||||||||||
623 | addContribution(i, &minAfter, &maxAfter, i == idJustAfter); never executed: addContribution(i, &minAfter, &maxAfter, i == idJustAfter); | 0 | ||||||||||||||||||
624 | - | |||||||||||||||||||
625 | QRect r = q->contentsRect(); | - | ||||||||||||||||||
626 | int farMinVal; | - | ||||||||||||||||||
627 | int minVal; | - | ||||||||||||||||||
628 | int maxVal; | - | ||||||||||||||||||
629 | int farMaxVal; | - | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | int smartMinBefore = qMax(minBefore, pick(r.size()) - maxAfter); | - | ||||||||||||||||||
632 | int smartMaxBefore = qMin(maxBefore, pick(r.size()) - minAfter); | - | ||||||||||||||||||
633 | - | |||||||||||||||||||
634 | minVal = pick(r.topLeft()) + smartMinBefore; | - | ||||||||||||||||||
635 | maxVal = pick(r.topLeft()) + smartMaxBefore; | - | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | farMinVal = minVal; | - | ||||||||||||||||||
638 | if (minBefore - collapsibleSizeBefore >= pick(r.size()) - maxAfter)
| 0 | ||||||||||||||||||
639 | farMinVal -= collapsibleSizeBefore; never executed: farMinVal -= collapsibleSizeBefore; | 0 | ||||||||||||||||||
640 | farMaxVal = maxVal; | - | ||||||||||||||||||
641 | if (pick(r.size()) - (minAfter - collapsibleSizeAfter) <= maxBefore)
| 0 | ||||||||||||||||||
642 | farMaxVal += collapsibleSizeAfter; never executed: farMaxVal += collapsibleSizeAfter; | 0 | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | if (farMin)
| 0 | ||||||||||||||||||
645 | *farMin = farMinVal; never executed: *farMin = farMinVal; | 0 | ||||||||||||||||||
646 | if (min)
| 0 | ||||||||||||||||||
647 | *min = minVal; never executed: *min = minVal; | 0 | ||||||||||||||||||
648 | if (max)
| 0 | ||||||||||||||||||
649 | *max = maxVal; never executed: *max = maxVal; | 0 | ||||||||||||||||||
650 | if (farMax)
| 0 | ||||||||||||||||||
651 | *farMax = farMaxVal; never executed: *farMax = farMaxVal; | 0 | ||||||||||||||||||
652 | } never executed: end of block | 0 | ||||||||||||||||||
653 | - | |||||||||||||||||||
654 | int QSplitterPrivate::adjustPos(int pos, int index, int *farMin, int *min, int *max, int *farMax) const | - | ||||||||||||||||||
655 | { | - | ||||||||||||||||||
656 | const int Threshold = 40; | - | ||||||||||||||||||
657 | - | |||||||||||||||||||
658 | getRange(index, farMin, min, max, farMax); | - | ||||||||||||||||||
659 | - | |||||||||||||||||||
660 | if (pos >= *min) {
| 0 | ||||||||||||||||||
661 | if (pos <= *max) {
| 0 | ||||||||||||||||||
662 | return pos; never executed: return pos; | 0 | ||||||||||||||||||
663 | } else { | - | ||||||||||||||||||
664 | int delta = pos - *max; | - | ||||||||||||||||||
665 | int width = *farMax - *max; | - | ||||||||||||||||||
666 | - | |||||||||||||||||||
667 | if (delta > width / 2 && delta >= qMin(Threshold, width)) {
| 0 | ||||||||||||||||||
668 | return *farMax; never executed: return *farMax; | 0 | ||||||||||||||||||
669 | } else { | - | ||||||||||||||||||
670 | return *max; never executed: return *max; | 0 | ||||||||||||||||||
671 | } | - | ||||||||||||||||||
672 | } | - | ||||||||||||||||||
673 | } else { | - | ||||||||||||||||||
674 | int delta = *min - pos; | - | ||||||||||||||||||
675 | int width = *min - *farMin; | - | ||||||||||||||||||
676 | - | |||||||||||||||||||
677 | if (delta > width / 2 && delta >= qMin(Threshold, width)) {
| 0 | ||||||||||||||||||
678 | return *farMin; never executed: return *farMin; | 0 | ||||||||||||||||||
679 | } else { | - | ||||||||||||||||||
680 | return *min; never executed: return *min; | 0 | ||||||||||||||||||
681 | } | - | ||||||||||||||||||
682 | } | - | ||||||||||||||||||
683 | } | - | ||||||||||||||||||
684 | - | |||||||||||||||||||
685 | bool QSplitterPrivate::collapsible(QSplitterLayoutStruct *s) const | - | ||||||||||||||||||
686 | { | - | ||||||||||||||||||
687 | if (s->collapsible != Default) {
| 0 | ||||||||||||||||||
688 | return (bool)s->collapsible; never executed: return (bool)s->collapsible; | 0 | ||||||||||||||||||
689 | } else { | - | ||||||||||||||||||
690 | return childrenCollapsible; never executed: return childrenCollapsible; | 0 | ||||||||||||||||||
691 | } | - | ||||||||||||||||||
692 | } | - | ||||||||||||||||||
693 | - | |||||||||||||||||||
694 | void QSplitterPrivate::updateHandles() | - | ||||||||||||||||||
695 | { | - | ||||||||||||||||||
696 | Q_Q(QSplitter); | - | ||||||||||||||||||
697 | recalc(q->isVisible()); | - | ||||||||||||||||||
698 | } never executed: end of block | 0 | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | void QSplitterPrivate::setSizes_helper(const QList<int> &sizes, bool clampNegativeSize) | - | ||||||||||||||||||
701 | { | - | ||||||||||||||||||
702 | int j = 0; | - | ||||||||||||||||||
703 | - | |||||||||||||||||||
704 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
705 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
706 | - | |||||||||||||||||||
707 | s->collapsed = false; | - | ||||||||||||||||||
708 | s->sizer = sizes.value(j++); | - | ||||||||||||||||||
709 | if (clampNegativeSize && s->sizer < 0)
| 0 | ||||||||||||||||||
710 | s->sizer = 0; never executed: s->sizer = 0; | 0 | ||||||||||||||||||
711 | int smartMinSize = pick(qSmartMinSize(s->widget)); | - | ||||||||||||||||||
712 | - | |||||||||||||||||||
713 | // Make sure that we reset the collapsed state. | - | ||||||||||||||||||
714 | if (s->sizer == 0) {
| 0 | ||||||||||||||||||
715 | if (collapsible(s) && smartMinSize > 0) {
| 0 | ||||||||||||||||||
716 | s->collapsed = true; | - | ||||||||||||||||||
717 | } else { never executed: end of block | 0 | ||||||||||||||||||
718 | s->sizer = smartMinSize; | - | ||||||||||||||||||
719 | } never executed: end of block | 0 | ||||||||||||||||||
720 | } else { | - | ||||||||||||||||||
721 | if (s->sizer < smartMinSize)
| 0 | ||||||||||||||||||
722 | s->sizer = smartMinSize; never executed: s->sizer = smartMinSize; | 0 | ||||||||||||||||||
723 | } never executed: end of block | 0 | ||||||||||||||||||
724 | } | - | ||||||||||||||||||
725 | doResize(); | - | ||||||||||||||||||
726 | } never executed: end of block | 0 | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool allowCollapse) | - | ||||||||||||||||||
729 | { | - | ||||||||||||||||||
730 | Q_Q(QSplitter); | - | ||||||||||||||||||
731 | QWidget *w = sls->widget; | - | ||||||||||||||||||
732 | QRect r; | - | ||||||||||||||||||
733 | QRect contents = q->contentsRect(); | - | ||||||||||||||||||
734 | if (orient == Qt::Horizontal) {
| 0 | ||||||||||||||||||
735 | r.setRect(p, contents.y(), s, contents.height()); | - | ||||||||||||||||||
736 | } else { never executed: end of block | 0 | ||||||||||||||||||
737 | r.setRect(contents.x(), p, contents.width(), s); | - | ||||||||||||||||||
738 | } never executed: end of block | 0 | ||||||||||||||||||
739 | sls->rect = r; | - | ||||||||||||||||||
740 | - | |||||||||||||||||||
741 | int minSize = pick(qSmartMinSize(w)); | - | ||||||||||||||||||
742 | - | |||||||||||||||||||
743 | if (orient == Qt::Horizontal && q->isRightToLeft())
| 0 | ||||||||||||||||||
744 | r.moveRight(contents.width() - r.left()); never executed: r.moveRight(contents.width() - r.left()); | 0 | ||||||||||||||||||
745 | - | |||||||||||||||||||
746 | if (allowCollapse)
| 0 | ||||||||||||||||||
747 | sls->collapsed = s <= 0 && minSize > 0 && !w->isHidden(); never executed: sls->collapsed = s <= 0 && minSize > 0 && !w->isHidden();
| 0 | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | // Hide the child widget, but without calling hide() so that | - | ||||||||||||||||||
750 | // the splitter handle is still shown. | - | ||||||||||||||||||
751 | if (sls->collapsed)
| 0 | ||||||||||||||||||
752 | r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1)); never executed: r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1)); | 0 | ||||||||||||||||||
753 | - | |||||||||||||||||||
754 | w->setGeometry(r); | - | ||||||||||||||||||
755 | - | |||||||||||||||||||
756 | if (!sls->handle->isHidden()) {
| 0 | ||||||||||||||||||
757 | QSplitterHandle *h = sls->handle; | - | ||||||||||||||||||
758 | QSize hs = h->sizeHint(); | - | ||||||||||||||||||
759 | int left, top, right, bottom; | - | ||||||||||||||||||
760 | h->getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||
761 | if (orient==Qt::Horizontal) {
| 0 | ||||||||||||||||||
762 | if (q->isRightToLeft())
| 0 | ||||||||||||||||||
763 | p = contents.width() - p + hs.width(); never executed: p = contents.width() - p + hs.width(); | 0 | ||||||||||||||||||
764 | h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height()); | - | ||||||||||||||||||
765 | } else { never executed: end of block | 0 | ||||||||||||||||||
766 | h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom); | - | ||||||||||||||||||
767 | } never executed: end of block | 0 | ||||||||||||||||||
768 | } | - | ||||||||||||||||||
769 | } never executed: end of block | 0 | ||||||||||||||||||
770 | - | |||||||||||||||||||
771 | void QSplitterPrivate::doMove(bool backwards, int hPos, int index, int delta, bool mayCollapse, | - | ||||||||||||||||||
772 | int *positions, int *widths) | - | ||||||||||||||||||
773 | { | - | ||||||||||||||||||
774 | if (index < 0 || index >= list.count())
| 0 | ||||||||||||||||||
775 | return; never executed: return; | 0 | ||||||||||||||||||
776 | - | |||||||||||||||||||
777 | #ifdef QSPLITTER_DEBUG | - | ||||||||||||||||||
778 | qDebug() << "QSplitterPrivate::doMove" << backwards << hPos << index << delta << mayCollapse; | - | ||||||||||||||||||
779 | #endif | - | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | QSplitterLayoutStruct *s = list.at(index); | - | ||||||||||||||||||
782 | QWidget *w = s->widget; | - | ||||||||||||||||||
783 | - | |||||||||||||||||||
784 | int nextId = backwards ? index - delta : index + delta;
| 0 | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | if (w->isHidden()) {
| 0 | ||||||||||||||||||
787 | doMove(backwards, hPos, nextId, delta, collapsible(nextId), positions, widths); | - | ||||||||||||||||||
788 | } else { never executed: end of block | 0 | ||||||||||||||||||
789 | int hs =s->handle->isHidden() ? 0 : s->getHandleSize(orient);
| 0 | ||||||||||||||||||
790 | - | |||||||||||||||||||
791 | int ws = backwards ? hPos - pick(s->rect.topLeft())
| 0 | ||||||||||||||||||
792 | : pick(s->rect.bottomRight()) - hPos -hs + 1; | - | ||||||||||||||||||
793 | if (ws > 0 || (!s->collapsed && !mayCollapse)) {
| 0 | ||||||||||||||||||
794 | ws = qMin(ws, pick(w->maximumSize())); | - | ||||||||||||||||||
795 | ws = qMax(ws, pick(qSmartMinSize(w))); | - | ||||||||||||||||||
796 | } else { never executed: end of block | 0 | ||||||||||||||||||
797 | ws = 0; | - | ||||||||||||||||||
798 | } never executed: end of block | 0 | ||||||||||||||||||
799 | positions[index] = backwards ? hPos - ws : hPos + hs;
| 0 | ||||||||||||||||||
800 | widths[index] = ws; | - | ||||||||||||||||||
801 | doMove(backwards, backwards ? hPos - ws - hs : hPos + hs + ws, nextId, delta, | - | ||||||||||||||||||
802 | collapsible(nextId), positions, widths); | - | ||||||||||||||||||
803 | } never executed: end of block | 0 | ||||||||||||||||||
804 | - | |||||||||||||||||||
805 | } | - | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | QSplitterLayoutStruct *QSplitterPrivate::findWidget(QWidget *w) const | - | ||||||||||||||||||
808 | { | - | ||||||||||||||||||
809 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
810 | if (list.at(i)->widget == w)
| 0 | ||||||||||||||||||
811 | return list.at(i); never executed: return list.at(i); | 0 | ||||||||||||||||||
812 | } never executed: end of block | 0 | ||||||||||||||||||
813 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
814 | } | - | ||||||||||||||||||
815 | - | |||||||||||||||||||
816 | - | |||||||||||||||||||
817 | /*! | - | ||||||||||||||||||
818 | \internal | - | ||||||||||||||||||
819 | */ | - | ||||||||||||||||||
820 | void QSplitterPrivate::insertWidget_helper(int index, QWidget *widget, bool show) | - | ||||||||||||||||||
821 | { | - | ||||||||||||||||||
822 | Q_Q(QSplitter); | - | ||||||||||||||||||
823 | QBoolBlocker b(blockChildAdd); | - | ||||||||||||||||||
824 | bool needShow = show && q->isVisible() &&
| 0 | ||||||||||||||||||
825 | !(widget->isHidden() && widget->testAttribute(Qt::WA_WState_ExplicitShowHide));
| 0 | ||||||||||||||||||
826 | if (widget->parentWidget() != q)
| 0 | ||||||||||||||||||
827 | widget->setParent(q); never executed: widget->setParent(q); | 0 | ||||||||||||||||||
828 | if (needShow)
| 0 | ||||||||||||||||||
829 | widget->show(); never executed: widget->show(); | 0 | ||||||||||||||||||
830 | insertWidget(index, widget); | - | ||||||||||||||||||
831 | recalc(q->isVisible()); | - | ||||||||||||||||||
832 | } never executed: end of block | 0 | ||||||||||||||||||
833 | - | |||||||||||||||||||
834 | /* | - | ||||||||||||||||||
835 | Inserts the widget \a w at position \a index in the splitter's list of widgets. | - | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | If \a w is already in the splitter, it will be moved to the new position. | - | ||||||||||||||||||
838 | */ | - | ||||||||||||||||||
839 | - | |||||||||||||||||||
840 | QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) | - | ||||||||||||||||||
841 | { | - | ||||||||||||||||||
842 | Q_Q(QSplitter); | - | ||||||||||||||||||
843 | QSplitterLayoutStruct *sls = 0; | - | ||||||||||||||||||
844 | int i; | - | ||||||||||||||||||
845 | int last = list.count(); | - | ||||||||||||||||||
846 | for (i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
847 | QSplitterLayoutStruct *s = list.at(i); | - | ||||||||||||||||||
848 | if (s->widget == w) {
| 0 | ||||||||||||||||||
849 | sls = s; | - | ||||||||||||||||||
850 | --last; | - | ||||||||||||||||||
851 | break; never executed: break; | 0 | ||||||||||||||||||
852 | } | - | ||||||||||||||||||
853 | } never executed: end of block | 0 | ||||||||||||||||||
854 | if (index < 0 || index > last)
| 0 | ||||||||||||||||||
855 | index = last; never executed: index = last; | 0 | ||||||||||||||||||
856 | - | |||||||||||||||||||
857 | if (sls) {
| 0 | ||||||||||||||||||
858 | list.move(i,index); | - | ||||||||||||||||||
859 | } else { never executed: end of block | 0 | ||||||||||||||||||
860 | QSplitterHandle *newHandle = 0; | - | ||||||||||||||||||
861 | sls = new QSplitterLayoutStruct; | - | ||||||||||||||||||
862 | QString tmp = QLatin1String("qt_splithandle_"); | - | ||||||||||||||||||
863 | tmp += w->objectName(); | - | ||||||||||||||||||
864 | newHandle = q->createHandle(); | - | ||||||||||||||||||
865 | newHandle->setObjectName(tmp); | - | ||||||||||||||||||
866 | sls->handle = newHandle; | - | ||||||||||||||||||
867 | sls->widget = w; | - | ||||||||||||||||||
868 | w->lower(); | - | ||||||||||||||||||
869 | list.insert(index,sls); | - | ||||||||||||||||||
870 | - | |||||||||||||||||||
871 | if (newHandle && q->isVisible())
| 0 | ||||||||||||||||||
872 | newHandle->show(); // will trigger sending of post events never executed: newHandle->show(); | 0 | ||||||||||||||||||
873 | - | |||||||||||||||||||
874 | } never executed: end of block | 0 | ||||||||||||||||||
875 | return sls; never executed: return sls; | 0 | ||||||||||||||||||
876 | } | - | ||||||||||||||||||
877 | - | |||||||||||||||||||
878 | /*! | - | ||||||||||||||||||
879 | \class QSplitter | - | ||||||||||||||||||
880 | \brief The QSplitter class implements a splitter widget. | - | ||||||||||||||||||
881 | - | |||||||||||||||||||
882 | \ingroup organizers | - | ||||||||||||||||||
883 | \inmodule QtWidgets | - | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | - | |||||||||||||||||||
886 | A splitter lets the user control the size of child widgets by dragging the | - | ||||||||||||||||||
887 | boundary between them. Any number of widgets may be controlled by a | - | ||||||||||||||||||
888 | single splitter. The typical use of a QSplitter is to create several | - | ||||||||||||||||||
889 | widgets and add them using insertWidget() or addWidget(). | - | ||||||||||||||||||
890 | - | |||||||||||||||||||
891 | The following example will show a QListView, QTreeView, and | - | ||||||||||||||||||
892 | QTextEdit side by side, with two splitter handles: | - | ||||||||||||||||||
893 | - | |||||||||||||||||||
894 | \snippet splitter/splitter.cpp 0 | - | ||||||||||||||||||
895 | - | |||||||||||||||||||
896 | If a widget is already inside a QSplitter when insertWidget() or | - | ||||||||||||||||||
897 | addWidget() is called, it will move to the new position. This can be used | - | ||||||||||||||||||
898 | to reorder widgets in the splitter later. You can use indexOf(), | - | ||||||||||||||||||
899 | widget(), and count() to get access to the widgets inside the splitter. | - | ||||||||||||||||||
900 | - | |||||||||||||||||||
901 | A default QSplitter lays out its children horizontally (side by side); you | - | ||||||||||||||||||
902 | can use setOrientation(Qt::Vertical) to lay its | - | ||||||||||||||||||
903 | children out vertically. | - | ||||||||||||||||||
904 | - | |||||||||||||||||||
905 | By default, all widgets can be as large or as small as the user | - | ||||||||||||||||||
906 | wishes, between the \l minimumSizeHint() (or \l minimumSize()) | - | ||||||||||||||||||
907 | and \l maximumSize() of the widgets. | - | ||||||||||||||||||
908 | - | |||||||||||||||||||
909 | QSplitter resizes its children dynamically by default. If you | - | ||||||||||||||||||
910 | would rather have QSplitter resize the children only at the end of | - | ||||||||||||||||||
911 | a resize operation, call setOpaqueResize(false). | - | ||||||||||||||||||
912 | - | |||||||||||||||||||
913 | The initial distribution of size between the widgets is determined by | - | ||||||||||||||||||
914 | multiplying the initial size with the stretch factor. | - | ||||||||||||||||||
915 | You can also use setSizes() to set the sizes | - | ||||||||||||||||||
916 | of all the widgets. The function sizes() returns the sizes set by the user. | - | ||||||||||||||||||
917 | Alternatively, you can save and restore the sizes of the widgets from a | - | ||||||||||||||||||
918 | QByteArray using saveState() and restoreState() respectively. | - | ||||||||||||||||||
919 | - | |||||||||||||||||||
920 | When you hide() a child, its space will be distributed among the | - | ||||||||||||||||||
921 | other children. It will be reinstated when you show() it again. | - | ||||||||||||||||||
922 | - | |||||||||||||||||||
923 | \note Adding a QLayout to a QSplitter is not supported (either through | - | ||||||||||||||||||
924 | setLayout() or making the QSplitter a parent of the QLayout); use addWidget() | - | ||||||||||||||||||
925 | instead (see example above). | - | ||||||||||||||||||
926 | - | |||||||||||||||||||
927 | \sa QSplitterHandle, QHBoxLayout, QVBoxLayout, QTabWidget | - | ||||||||||||||||||
928 | */ | - | ||||||||||||||||||
929 | - | |||||||||||||||||||
930 | - | |||||||||||||||||||
931 | /*! | - | ||||||||||||||||||
932 | Constructs a horizontal splitter with the \a parent | - | ||||||||||||||||||
933 | argument passed on to the QFrame constructor. | - | ||||||||||||||||||
934 | - | |||||||||||||||||||
935 | \sa setOrientation() | - | ||||||||||||||||||
936 | */ | - | ||||||||||||||||||
937 | QSplitter::QSplitter(QWidget *parent) | - | ||||||||||||||||||
938 | : QFrame(*new QSplitterPrivate, parent) | - | ||||||||||||||||||
939 | { | - | ||||||||||||||||||
940 | Q_D(QSplitter); | - | ||||||||||||||||||
941 | d->orient = Qt::Horizontal; | - | ||||||||||||||||||
942 | d->init(); | - | ||||||||||||||||||
943 | } never executed: end of block | 0 | ||||||||||||||||||
944 | - | |||||||||||||||||||
945 | - | |||||||||||||||||||
946 | /*! | - | ||||||||||||||||||
947 | Constructs a splitter with the given \a orientation and \a parent. | - | ||||||||||||||||||
948 | - | |||||||||||||||||||
949 | \sa setOrientation() | - | ||||||||||||||||||
950 | */ | - | ||||||||||||||||||
951 | QSplitter::QSplitter(Qt::Orientation orientation, QWidget *parent) | - | ||||||||||||||||||
952 | : QFrame(*new QSplitterPrivate, parent) | - | ||||||||||||||||||
953 | { | - | ||||||||||||||||||
954 | Q_D(QSplitter); | - | ||||||||||||||||||
955 | d->orient = orientation; | - | ||||||||||||||||||
956 | d->init(); | - | ||||||||||||||||||
957 | } never executed: end of block | 0 | ||||||||||||||||||
958 | - | |||||||||||||||||||
959 | - | |||||||||||||||||||
960 | /*! | - | ||||||||||||||||||
961 | Destroys the splitter. All children are deleted. | - | ||||||||||||||||||
962 | */ | - | ||||||||||||||||||
963 | - | |||||||||||||||||||
964 | QSplitter::~QSplitter() | - | ||||||||||||||||||
965 | { | - | ||||||||||||||||||
966 | Q_D(QSplitter); | - | ||||||||||||||||||
967 | delete d->rubberBand; | - | ||||||||||||||||||
968 | while (!d->list.isEmpty())
| 0 | ||||||||||||||||||
969 | delete d->list.takeFirst(); never executed: delete d->list.takeFirst(); | 0 | ||||||||||||||||||
970 | } never executed: end of block | 0 | ||||||||||||||||||
971 | - | |||||||||||||||||||
972 | /*! | - | ||||||||||||||||||
973 | Updates the splitter's state. You should not need to call this | - | ||||||||||||||||||
974 | function. | - | ||||||||||||||||||
975 | */ | - | ||||||||||||||||||
976 | void QSplitter::refresh() | - | ||||||||||||||||||
977 | { | - | ||||||||||||||||||
978 | Q_D(QSplitter); | - | ||||||||||||||||||
979 | d->recalc(true); | - | ||||||||||||||||||
980 | } never executed: end of block | 0 | ||||||||||||||||||
981 | - | |||||||||||||||||||
982 | /*! | - | ||||||||||||||||||
983 | \property QSplitter::orientation | - | ||||||||||||||||||
984 | \brief the orientation of the splitter | - | ||||||||||||||||||
985 | - | |||||||||||||||||||
986 | By default, the orientation is horizontal (i.e., the widgets are | - | ||||||||||||||||||
987 | laid out side by side). The possible orientations are | - | ||||||||||||||||||
988 | Qt::Horizontal and Qt::Vertical. | - | ||||||||||||||||||
989 | - | |||||||||||||||||||
990 | \sa QSplitterHandle::orientation() | - | ||||||||||||||||||
991 | */ | - | ||||||||||||||||||
992 | - | |||||||||||||||||||
993 | void QSplitter::setOrientation(Qt::Orientation orientation) | - | ||||||||||||||||||
994 | { | - | ||||||||||||||||||
995 | Q_D(QSplitter); | - | ||||||||||||||||||
996 | if (d->orient == orientation)
| 0 | ||||||||||||||||||
997 | return; never executed: return; | 0 | ||||||||||||||||||
998 | - | |||||||||||||||||||
999 | if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
| 0 | ||||||||||||||||||
1000 | QSizePolicy sp = sizePolicy(); | - | ||||||||||||||||||
1001 | sp.transpose(); | - | ||||||||||||||||||
1002 | setSizePolicy(sp); | - | ||||||||||||||||||
1003 | setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - | ||||||||||||||||||
1004 | } never executed: end of block | 0 | ||||||||||||||||||
1005 | - | |||||||||||||||||||
1006 | d->orient = orientation; | - | ||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | for (int i = 0; i < d->list.size(); ++i) {
| 0 | ||||||||||||||||||
1009 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1010 | s->handle->setOrientation(orientation); | - | ||||||||||||||||||
1011 | } never executed: end of block | 0 | ||||||||||||||||||
1012 | d->recalc(isVisible()); | - | ||||||||||||||||||
1013 | } never executed: end of block | 0 | ||||||||||||||||||
1014 | - | |||||||||||||||||||
1015 | Qt::Orientation QSplitter::orientation() const | - | ||||||||||||||||||
1016 | { | - | ||||||||||||||||||
1017 | Q_D(const QSplitter); | - | ||||||||||||||||||
1018 | return d->orient; never executed: return d->orient; | 0 | ||||||||||||||||||
1019 | } | - | ||||||||||||||||||
1020 | - | |||||||||||||||||||
1021 | /*! | - | ||||||||||||||||||
1022 | \property QSplitter::childrenCollapsible | - | ||||||||||||||||||
1023 | \brief whether child widgets can be resized down to size 0 by the user | - | ||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | By default, children are collapsible. It is possible to enable | - | ||||||||||||||||||
1026 | and disable the collapsing of individual children using | - | ||||||||||||||||||
1027 | setCollapsible(). | - | ||||||||||||||||||
1028 | - | |||||||||||||||||||
1029 | \sa setCollapsible() | - | ||||||||||||||||||
1030 | */ | - | ||||||||||||||||||
1031 | - | |||||||||||||||||||
1032 | void QSplitter::setChildrenCollapsible(bool collapse) | - | ||||||||||||||||||
1033 | { | - | ||||||||||||||||||
1034 | Q_D(QSplitter); | - | ||||||||||||||||||
1035 | d->childrenCollapsible = collapse; | - | ||||||||||||||||||
1036 | } never executed: end of block | 0 | ||||||||||||||||||
1037 | - | |||||||||||||||||||
1038 | bool QSplitter::childrenCollapsible() const | - | ||||||||||||||||||
1039 | { | - | ||||||||||||||||||
1040 | Q_D(const QSplitter); | - | ||||||||||||||||||
1041 | return d->childrenCollapsible; never executed: return d->childrenCollapsible; | 0 | ||||||||||||||||||
1042 | } | - | ||||||||||||||||||
1043 | - | |||||||||||||||||||
1044 | /*! | - | ||||||||||||||||||
1045 | Sets whether the child widget at \a index is collapsible to \a collapse. | - | ||||||||||||||||||
1046 | - | |||||||||||||||||||
1047 | By default, children are collapsible, meaning that the user can | - | ||||||||||||||||||
1048 | resize them down to size 0, even if they have a non-zero | - | ||||||||||||||||||
1049 | minimumSize() or minimumSizeHint(). This behavior can be changed | - | ||||||||||||||||||
1050 | on a per-widget basis by calling this function, or globally for | - | ||||||||||||||||||
1051 | all the widgets in the splitter by setting the \l | - | ||||||||||||||||||
1052 | childrenCollapsible property. | - | ||||||||||||||||||
1053 | - | |||||||||||||||||||
1054 | \sa childrenCollapsible | - | ||||||||||||||||||
1055 | */ | - | ||||||||||||||||||
1056 | - | |||||||||||||||||||
1057 | void QSplitter::setCollapsible(int index, bool collapse) | - | ||||||||||||||||||
1058 | { | - | ||||||||||||||||||
1059 | Q_D(QSplitter); | - | ||||||||||||||||||
1060 | - | |||||||||||||||||||
1061 | if (index < 0 || index >= d->list.size()) {
| 0 | ||||||||||||||||||
1062 | qWarning("QSplitter::setCollapsible: Index %d out of range", index); | - | ||||||||||||||||||
1063 | return; never executed: return; | 0 | ||||||||||||||||||
1064 | } | - | ||||||||||||||||||
1065 | d->list.at(index)->collapsible = collapse ? 1 : 0;
| 0 | ||||||||||||||||||
1066 | } never executed: end of block | 0 | ||||||||||||||||||
1067 | - | |||||||||||||||||||
1068 | /*! | - | ||||||||||||||||||
1069 | Returns \c true if the widget at \a index is collapsible, otherwise returns \c false. | - | ||||||||||||||||||
1070 | */ | - | ||||||||||||||||||
1071 | bool QSplitter::isCollapsible(int index) const | - | ||||||||||||||||||
1072 | { | - | ||||||||||||||||||
1073 | Q_D(const QSplitter); | - | ||||||||||||||||||
1074 | if (index < 0 || index >= d->list.size()) {
| 0 | ||||||||||||||||||
1075 | qWarning("QSplitter::isCollapsible: Index %d out of range", index); | - | ||||||||||||||||||
1076 | return false; never executed: return false; | 0 | ||||||||||||||||||
1077 | } | - | ||||||||||||||||||
1078 | return d->list.at(index)->collapsible; never executed: return d->list.at(index)->collapsible; | 0 | ||||||||||||||||||
1079 | } | - | ||||||||||||||||||
1080 | - | |||||||||||||||||||
1081 | /*! | - | ||||||||||||||||||
1082 | \reimp | - | ||||||||||||||||||
1083 | */ | - | ||||||||||||||||||
1084 | void QSplitter::resizeEvent(QResizeEvent *) | - | ||||||||||||||||||
1085 | { | - | ||||||||||||||||||
1086 | Q_D(QSplitter); | - | ||||||||||||||||||
1087 | d->doResize(); | - | ||||||||||||||||||
1088 | } never executed: end of block | 0 | ||||||||||||||||||
1089 | - | |||||||||||||||||||
1090 | /*! | - | ||||||||||||||||||
1091 | Adds the given \a widget to the splitter's layout after all the other | - | ||||||||||||||||||
1092 | items. | - | ||||||||||||||||||
1093 | - | |||||||||||||||||||
1094 | If \a widget is already in the splitter, it will be moved to the new position. | - | ||||||||||||||||||
1095 | - | |||||||||||||||||||
1096 | \note The splitter takes ownership of the widget. | - | ||||||||||||||||||
1097 | - | |||||||||||||||||||
1098 | \sa insertWidget(), widget(), indexOf() | - | ||||||||||||||||||
1099 | */ | - | ||||||||||||||||||
1100 | void QSplitter::addWidget(QWidget *widget) | - | ||||||||||||||||||
1101 | { | - | ||||||||||||||||||
1102 | Q_D(QSplitter); | - | ||||||||||||||||||
1103 | insertWidget(d->list.count(), widget); | - | ||||||||||||||||||
1104 | } never executed: end of block | 0 | ||||||||||||||||||
1105 | - | |||||||||||||||||||
1106 | /*! | - | ||||||||||||||||||
1107 | Inserts the \a widget specified into the splitter's layout at the | - | ||||||||||||||||||
1108 | given \a index. | - | ||||||||||||||||||
1109 | - | |||||||||||||||||||
1110 | If \a widget is already in the splitter, it will be moved to the new position. | - | ||||||||||||||||||
1111 | - | |||||||||||||||||||
1112 | If \a index is an invalid index, then the widget will be inserted at the end. | - | ||||||||||||||||||
1113 | - | |||||||||||||||||||
1114 | \note The splitter takes ownership of the widget. | - | ||||||||||||||||||
1115 | - | |||||||||||||||||||
1116 | \sa addWidget(), indexOf(), widget() | - | ||||||||||||||||||
1117 | */ | - | ||||||||||||||||||
1118 | void QSplitter::insertWidget(int index, QWidget *widget) | - | ||||||||||||||||||
1119 | { | - | ||||||||||||||||||
1120 | Q_D(QSplitter); | - | ||||||||||||||||||
1121 | d->insertWidget_helper(index, widget, true); | - | ||||||||||||||||||
1122 | } never executed: end of block | 0 | ||||||||||||||||||
1123 | - | |||||||||||||||||||
1124 | /*! | - | ||||||||||||||||||
1125 | \fn int QSplitter::indexOf(QWidget *widget) const | - | ||||||||||||||||||
1126 | - | |||||||||||||||||||
1127 | Returns the index in the splitter's layout of the specified \a widget. This | - | ||||||||||||||||||
1128 | also works for handles. | - | ||||||||||||||||||
1129 | - | |||||||||||||||||||
1130 | Handles are numbered from 0. There are as many handles as there | - | ||||||||||||||||||
1131 | are child widgets, but the handle at position 0 is always hidden. | - | ||||||||||||||||||
1132 | - | |||||||||||||||||||
1133 | - | |||||||||||||||||||
1134 | \sa count(), widget() | - | ||||||||||||||||||
1135 | */ | - | ||||||||||||||||||
1136 | int QSplitter::indexOf(QWidget *w) const | - | ||||||||||||||||||
1137 | { | - | ||||||||||||||||||
1138 | Q_D(const QSplitter); | - | ||||||||||||||||||
1139 | for (int i = 0; i < d->list.size(); ++i) {
| 0 | ||||||||||||||||||
1140 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1141 | if (s->widget == w || s->handle == w)
| 0 | ||||||||||||||||||
1142 | return i; never executed: return i; | 0 | ||||||||||||||||||
1143 | } never executed: end of block | 0 | ||||||||||||||||||
1144 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
1145 | } | - | ||||||||||||||||||
1146 | - | |||||||||||||||||||
1147 | /*! | - | ||||||||||||||||||
1148 | Returns a new splitter handle as a child widget of this splitter. | - | ||||||||||||||||||
1149 | This function can be reimplemented in subclasses to provide support | - | ||||||||||||||||||
1150 | for custom handles. | - | ||||||||||||||||||
1151 | - | |||||||||||||||||||
1152 | \sa handle(), indexOf() | - | ||||||||||||||||||
1153 | */ | - | ||||||||||||||||||
1154 | QSplitterHandle *QSplitter::createHandle() | - | ||||||||||||||||||
1155 | { | - | ||||||||||||||||||
1156 | Q_D(QSplitter); | - | ||||||||||||||||||
1157 | return new QSplitterHandle(d->orient, this); never executed: return new QSplitterHandle(d->orient, this); | 0 | ||||||||||||||||||
1158 | } | - | ||||||||||||||||||
1159 | - | |||||||||||||||||||
1160 | /*! | - | ||||||||||||||||||
1161 | Returns the handle to the left (or above) for the item in the | - | ||||||||||||||||||
1162 | splitter's layout at the given \a index. The handle at index 0 is | - | ||||||||||||||||||
1163 | always hidden. | - | ||||||||||||||||||
1164 | - | |||||||||||||||||||
1165 | For right-to-left languages such as Arabic and Hebrew, the layout | - | ||||||||||||||||||
1166 | of horizontal splitters is reversed. The handle will be to the | - | ||||||||||||||||||
1167 | right of the widget at \a index. | - | ||||||||||||||||||
1168 | - | |||||||||||||||||||
1169 | \sa count(), widget(), indexOf(), createHandle(), setHandleWidth() | - | ||||||||||||||||||
1170 | */ | - | ||||||||||||||||||
1171 | QSplitterHandle *QSplitter::handle(int index) const | - | ||||||||||||||||||
1172 | { | - | ||||||||||||||||||
1173 | Q_D(const QSplitter); | - | ||||||||||||||||||
1174 | if (index < 0 || index >= d->list.size())
| 0 | ||||||||||||||||||
1175 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1176 | return d->list.at(index)->handle; never executed: return d->list.at(index)->handle; | 0 | ||||||||||||||||||
1177 | } | - | ||||||||||||||||||
1178 | - | |||||||||||||||||||
1179 | /*! | - | ||||||||||||||||||
1180 | Returns the widget at the given \a index in the splitter's layout. | - | ||||||||||||||||||
1181 | - | |||||||||||||||||||
1182 | \sa count(), handle(), indexOf(), insertWidget() | - | ||||||||||||||||||
1183 | */ | - | ||||||||||||||||||
1184 | QWidget *QSplitter::widget(int index) const | - | ||||||||||||||||||
1185 | { | - | ||||||||||||||||||
1186 | Q_D(const QSplitter); | - | ||||||||||||||||||
1187 | if (index < 0 || index >= d->list.size())
| 0 | ||||||||||||||||||
1188 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1189 | return d->list.at(index)->widget; never executed: return d->list.at(index)->widget; | 0 | ||||||||||||||||||
1190 | } | - | ||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | /*! | - | ||||||||||||||||||
1193 | Returns the number of widgets contained in the splitter's layout. | - | ||||||||||||||||||
1194 | - | |||||||||||||||||||
1195 | \sa widget(), handle() | - | ||||||||||||||||||
1196 | */ | - | ||||||||||||||||||
1197 | int QSplitter::count() const | - | ||||||||||||||||||
1198 | { | - | ||||||||||||||||||
1199 | Q_D(const QSplitter); | - | ||||||||||||||||||
1200 | return d->list.count(); never executed: return d->list.count(); | 0 | ||||||||||||||||||
1201 | } | - | ||||||||||||||||||
1202 | - | |||||||||||||||||||
1203 | /*! | - | ||||||||||||||||||
1204 | \reimp | - | ||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | Tells the splitter that the child widget described by \a c has been | - | ||||||||||||||||||
1207 | inserted or removed. | - | ||||||||||||||||||
1208 | - | |||||||||||||||||||
1209 | This method is also used to handle the situation where a widget is created | - | ||||||||||||||||||
1210 | with the splitter as a parent but not explicitly added with insertWidget() | - | ||||||||||||||||||
1211 | or addWidget(). This is for compatibility and not the recommended way of | - | ||||||||||||||||||
1212 | putting widgets into a splitter in new code. Please use insertWidget() or | - | ||||||||||||||||||
1213 | addWidget() in new code. | - | ||||||||||||||||||
1214 | - | |||||||||||||||||||
1215 | \sa addWidget(), insertWidget() | - | ||||||||||||||||||
1216 | */ | - | ||||||||||||||||||
1217 | - | |||||||||||||||||||
1218 | void QSplitter::childEvent(QChildEvent *c) | - | ||||||||||||||||||
1219 | { | - | ||||||||||||||||||
1220 | Q_D(QSplitter); | - | ||||||||||||||||||
1221 | if (!c->child()->isWidgetType()) {
| 0 | ||||||||||||||||||
1222 | if (c->type() == QEvent::ChildAdded && qobject_cast<QLayout *>(c->child()))
| 0 | ||||||||||||||||||
1223 | qWarning("Adding a QLayout to a QSplitter is not supported."); never executed: QMessageLogger(__FILE__, 1223, __PRETTY_FUNCTION__).warning("Adding a QLayout to a QSplitter is not supported."); | 0 | ||||||||||||||||||
1224 | return; never executed: return; | 0 | ||||||||||||||||||
1225 | } | - | ||||||||||||||||||
1226 | QWidget *w = static_cast<QWidget*>(c->child()); | - | ||||||||||||||||||
1227 | if (w->isWindow())
| 0 | ||||||||||||||||||
1228 | return; never executed: return; | 0 | ||||||||||||||||||
1229 | if (c->added() && !d->blockChildAdd && !d->findWidget(w)) {
| 0 | ||||||||||||||||||
1230 | d->insertWidget_helper(d->list.count(), w, false); | - | ||||||||||||||||||
1231 | } else if (c->polished() && !d->blockChildAdd) { never executed: end of block
| 0 | ||||||||||||||||||
1232 | if (isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)))
| 0 | ||||||||||||||||||
1233 | w->show(); never executed: w->show(); | 0 | ||||||||||||||||||
1234 | } else if (c->type() == QEvent::ChildRemoved) { never executed: end of block
| 0 | ||||||||||||||||||
1235 | for (int i = 0; i < d->list.size(); ++i) {
| 0 | ||||||||||||||||||
1236 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1237 | if (s->widget == w) {
| 0 | ||||||||||||||||||
1238 | d->list.removeAt(i); | - | ||||||||||||||||||
1239 | delete s; | - | ||||||||||||||||||
1240 | d->recalc(isVisible()); | - | ||||||||||||||||||
1241 | return; never executed: return; | 0 | ||||||||||||||||||
1242 | } | - | ||||||||||||||||||
1243 | } never executed: end of block | 0 | ||||||||||||||||||
1244 | } never executed: end of block | 0 | ||||||||||||||||||
1245 | } never executed: end of block | 0 | ||||||||||||||||||
1246 | - | |||||||||||||||||||
1247 | - | |||||||||||||||||||
1248 | /*! | - | ||||||||||||||||||
1249 | Displays a rubber band at position \a pos. If \a pos is negative, the | - | ||||||||||||||||||
1250 | rubber band is removed. | - | ||||||||||||||||||
1251 | */ | - | ||||||||||||||||||
1252 | - | |||||||||||||||||||
1253 | void QSplitter::setRubberBand(int pos) | - | ||||||||||||||||||
1254 | { | - | ||||||||||||||||||
1255 | Q_D(QSplitter); | - | ||||||||||||||||||
1256 | if (pos < 0) {
| 0 | ||||||||||||||||||
1257 | if (d->rubberBand)
| 0 | ||||||||||||||||||
1258 | d->rubberBand->deleteLater(); never executed: d->rubberBand->deleteLater(); | 0 | ||||||||||||||||||
1259 | return; never executed: return; | 0 | ||||||||||||||||||
1260 | } | - | ||||||||||||||||||
1261 | QRect r = contentsRect(); | - | ||||||||||||||||||
1262 | const int rBord = 3; // customizable? | - | ||||||||||||||||||
1263 | int hw = handleWidth(); | - | ||||||||||||||||||
1264 | if (!d->rubberBand) {
| 0 | ||||||||||||||||||
1265 | QBoolBlocker b(d->blockChildAdd); | - | ||||||||||||||||||
1266 | d->rubberBand = new QRubberBand(QRubberBand::Line, this); | - | ||||||||||||||||||
1267 | // For accessibility to identify this special widget. | - | ||||||||||||||||||
1268 | d->rubberBand->setObjectName(QLatin1String("qt_rubberband")); | - | ||||||||||||||||||
1269 | } never executed: end of block | 0 | ||||||||||||||||||
1270 | - | |||||||||||||||||||
1271 | const QRect newGeom = d->orient == Qt::Horizontal ? QRect(QPoint(pos + hw / 2 - rBord, r.y()), QSize(2 * rBord, r.height()))
| 0 | ||||||||||||||||||
1272 | : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord)); | - | ||||||||||||||||||
1273 | d->rubberBand->setGeometry(newGeom); | - | ||||||||||||||||||
1274 | d->rubberBand->show(); | - | ||||||||||||||||||
1275 | } never executed: end of block | 0 | ||||||||||||||||||
1276 | - | |||||||||||||||||||
1277 | /*! | - | ||||||||||||||||||
1278 | \reimp | - | ||||||||||||||||||
1279 | */ | - | ||||||||||||||||||
1280 | - | |||||||||||||||||||
1281 | bool QSplitter::event(QEvent *e) | - | ||||||||||||||||||
1282 | { | - | ||||||||||||||||||
1283 | Q_D(QSplitter); | - | ||||||||||||||||||
1284 | switch (e->type()) { | - | ||||||||||||||||||
1285 | case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||
1286 | // Reset firstShow to false here since things can be done to the splitter in between | - | ||||||||||||||||||
1287 | if (!d->firstShow)
| 0 | ||||||||||||||||||
1288 | d->firstShow = true; never executed: d->firstShow = true; | 0 | ||||||||||||||||||
1289 | break; never executed: break; | 0 | ||||||||||||||||||
1290 | case QEvent::Show: never executed: case QEvent::Show: | 0 | ||||||||||||||||||
1291 | if (!d->firstShow)
| 0 | ||||||||||||||||||
1292 | break; never executed: break; | 0 | ||||||||||||||||||
1293 | d->firstShow = false; | - | ||||||||||||||||||
1294 | // fall through | - | ||||||||||||||||||
1295 | case QEvent::HideToParent: code before this statement never executed: case QEvent::HideToParent: never executed: case QEvent::HideToParent: | 0 | ||||||||||||||||||
1296 | case QEvent::ShowToParent: never executed: case QEvent::ShowToParent: | 0 | ||||||||||||||||||
1297 | case QEvent::LayoutRequest: never executed: case QEvent::LayoutRequest: | 0 | ||||||||||||||||||
1298 | d->recalc(isVisible()); | - | ||||||||||||||||||
1299 | break; never executed: break; | 0 | ||||||||||||||||||
1300 | default: never executed: default: | 0 | ||||||||||||||||||
1301 | ; | - | ||||||||||||||||||
1302 | } never executed: end of block | 0 | ||||||||||||||||||
1303 | return QWidget::event(e); never executed: return QWidget::event(e); | 0 | ||||||||||||||||||
1304 | } | - | ||||||||||||||||||
1305 | - | |||||||||||||||||||
1306 | /*! | - | ||||||||||||||||||
1307 | \fn QSplitter::splitterMoved(int pos, int index) | - | ||||||||||||||||||
1308 | - | |||||||||||||||||||
1309 | This signal is emitted when the splitter handle at a particular \a | - | ||||||||||||||||||
1310 | index has been moved to position \a pos. | - | ||||||||||||||||||
1311 | - | |||||||||||||||||||
1312 | For right-to-left languages such as Arabic and Hebrew, the layout | - | ||||||||||||||||||
1313 | of horizontal splitters is reversed. \a pos is then the | - | ||||||||||||||||||
1314 | distance from the right edge of the widget. | - | ||||||||||||||||||
1315 | - | |||||||||||||||||||
1316 | \sa moveSplitter() | - | ||||||||||||||||||
1317 | */ | - | ||||||||||||||||||
1318 | - | |||||||||||||||||||
1319 | /*! | - | ||||||||||||||||||
1320 | Moves the left or top edge of the splitter handle at \a index as | - | ||||||||||||||||||
1321 | close as possible to position \a pos, which is the distance from the | - | ||||||||||||||||||
1322 | left or top edge of the widget. | - | ||||||||||||||||||
1323 | - | |||||||||||||||||||
1324 | For right-to-left languages such as Arabic and Hebrew, the layout | - | ||||||||||||||||||
1325 | of horizontal splitters is reversed. \a pos is then the distance | - | ||||||||||||||||||
1326 | from the right edge of the widget. | - | ||||||||||||||||||
1327 | - | |||||||||||||||||||
1328 | \sa splitterMoved(), closestLegalPosition(), getRange() | - | ||||||||||||||||||
1329 | */ | - | ||||||||||||||||||
1330 | void QSplitter::moveSplitter(int pos, int index) | - | ||||||||||||||||||
1331 | { | - | ||||||||||||||||||
1332 | Q_D(QSplitter); | - | ||||||||||||||||||
1333 | QSplitterLayoutStruct *s = d->list.at(index); | - | ||||||||||||||||||
1334 | int farMin; | - | ||||||||||||||||||
1335 | int min; | - | ||||||||||||||||||
1336 | int max; | - | ||||||||||||||||||
1337 | int farMax; | - | ||||||||||||||||||
1338 | - | |||||||||||||||||||
1339 | #ifdef QSPLITTER_DEBUG | - | ||||||||||||||||||
1340 | int debugp = pos; | - | ||||||||||||||||||
1341 | #endif | - | ||||||||||||||||||
1342 | - | |||||||||||||||||||
1343 | pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax); | - | ||||||||||||||||||
1344 | int oldP = d->pick(s->rect.topLeft()); | - | ||||||||||||||||||
1345 | #ifdef QSPLITTER_DEBUG | - | ||||||||||||||||||
1346 | qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; | - | ||||||||||||||||||
1347 | #endif | - | ||||||||||||||||||
1348 | - | |||||||||||||||||||
1349 | QVarLengthArray<int, 32> poss(d->list.count()); | - | ||||||||||||||||||
1350 | QVarLengthArray<int, 32> ws(d->list.count()); | - | ||||||||||||||||||
1351 | bool upLeft; | - | ||||||||||||||||||
1352 | - | |||||||||||||||||||
1353 | d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); | - | ||||||||||||||||||
1354 | d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data()); | - | ||||||||||||||||||
1355 | upLeft = (pos < oldP); | - | ||||||||||||||||||
1356 | - | |||||||||||||||||||
1357 | int wid, delta, count = d->list.count(); | - | ||||||||||||||||||
1358 | if (upLeft) {
| 0 | ||||||||||||||||||
1359 | wid = 0; | - | ||||||||||||||||||
1360 | delta = 1; | - | ||||||||||||||||||
1361 | } else { never executed: end of block | 0 | ||||||||||||||||||
1362 | wid = count - 1; | - | ||||||||||||||||||
1363 | delta = -1; | - | ||||||||||||||||||
1364 | } never executed: end of block | 0 | ||||||||||||||||||
1365 | for (; wid >= 0 && wid < count; wid += delta) {
| 0 | ||||||||||||||||||
1366 | QSplitterLayoutStruct *sls = d->list.at( wid ); | - | ||||||||||||||||||
1367 | if (!sls->widget->isHidden())
| 0 | ||||||||||||||||||
1368 | d->setGeo(sls, poss[wid], ws[wid], true); never executed: d->setGeo(sls, poss[wid], ws[wid], true); | 0 | ||||||||||||||||||
1369 | } never executed: end of block | 0 | ||||||||||||||||||
1370 | d->storeSizes(); | - | ||||||||||||||||||
1371 | - | |||||||||||||||||||
1372 | emit splitterMoved(pos, index); | - | ||||||||||||||||||
1373 | } never executed: end of block | 0 | ||||||||||||||||||
1374 | - | |||||||||||||||||||
1375 | - | |||||||||||||||||||
1376 | /*! | - | ||||||||||||||||||
1377 | Returns the valid range of the splitter at \a index in | - | ||||||||||||||||||
1378 | *\a{min} and *\a{max} if \a min and \a max are not 0. | - | ||||||||||||||||||
1379 | */ | - | ||||||||||||||||||
1380 | - | |||||||||||||||||||
1381 | void QSplitter::getRange(int index, int *min, int *max) const | - | ||||||||||||||||||
1382 | { | - | ||||||||||||||||||
1383 | Q_D(const QSplitter); | - | ||||||||||||||||||
1384 | d->getRange(index, min, 0, 0, max); | - | ||||||||||||||||||
1385 | } never executed: end of block | 0 | ||||||||||||||||||
1386 | - | |||||||||||||||||||
1387 | - | |||||||||||||||||||
1388 | /*! | - | ||||||||||||||||||
1389 | Returns the closest legal position to \a pos of the widget at \a index. | - | ||||||||||||||||||
1390 | - | |||||||||||||||||||
1391 | For right-to-left languages such as Arabic and Hebrew, the layout | - | ||||||||||||||||||
1392 | of horizontal splitters is reversed. Positions are then measured | - | ||||||||||||||||||
1393 | from the right edge of the widget. | - | ||||||||||||||||||
1394 | - | |||||||||||||||||||
1395 | \sa getRange() | - | ||||||||||||||||||
1396 | */ | - | ||||||||||||||||||
1397 | - | |||||||||||||||||||
1398 | int QSplitter::closestLegalPosition(int pos, int index) | - | ||||||||||||||||||
1399 | { | - | ||||||||||||||||||
1400 | Q_D(QSplitter); | - | ||||||||||||||||||
1401 | int x, i, n, u; | - | ||||||||||||||||||
1402 | return d->adjustPos(pos, index, &u, &n, &i, &x); never executed: return d->adjustPos(pos, index, &u, &n, &i, &x); | 0 | ||||||||||||||||||
1403 | } | - | ||||||||||||||||||
1404 | - | |||||||||||||||||||
1405 | /*! | - | ||||||||||||||||||
1406 | \property QSplitter::opaqueResize | - | ||||||||||||||||||
1407 | \brief whether resizing is opaque | - | ||||||||||||||||||
1408 | - | |||||||||||||||||||
1409 | The default resize behavior is style dependent (determined by the | - | ||||||||||||||||||
1410 | SH_Splitter_OpaqueResize style hint). However, you can override it | - | ||||||||||||||||||
1411 | by calling setOpaqueResize() | - | ||||||||||||||||||
1412 | - | |||||||||||||||||||
1413 | \sa QStyle::StyleHint | - | ||||||||||||||||||
1414 | */ | - | ||||||||||||||||||
1415 | - | |||||||||||||||||||
1416 | bool QSplitter::opaqueResize() const | - | ||||||||||||||||||
1417 | { | - | ||||||||||||||||||
1418 | Q_D(const QSplitter); | - | ||||||||||||||||||
1419 | return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this); never executed: return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this);
| 0 | ||||||||||||||||||
1420 | } | - | ||||||||||||||||||
1421 | - | |||||||||||||||||||
1422 | - | |||||||||||||||||||
1423 | void QSplitter::setOpaqueResize(bool on) | - | ||||||||||||||||||
1424 | { | - | ||||||||||||||||||
1425 | Q_D(QSplitter); | - | ||||||||||||||||||
1426 | d->opaqueResizeSet = true; | - | ||||||||||||||||||
1427 | d->opaque = on; | - | ||||||||||||||||||
1428 | } never executed: end of block | 0 | ||||||||||||||||||
1429 | - | |||||||||||||||||||
1430 | - | |||||||||||||||||||
1431 | /*! | - | ||||||||||||||||||
1432 | \reimp | - | ||||||||||||||||||
1433 | */ | - | ||||||||||||||||||
1434 | QSize QSplitter::sizeHint() const | - | ||||||||||||||||||
1435 | { | - | ||||||||||||||||||
1436 | Q_D(const QSplitter); | - | ||||||||||||||||||
1437 | ensurePolished(); | - | ||||||||||||||||||
1438 | int l = 0; | - | ||||||||||||||||||
1439 | int t = 0; | - | ||||||||||||||||||
1440 | for (int i = 0; i < d->list.size(); ++i) {
| 0 | ||||||||||||||||||
1441 | QWidget *w = d->list.at(i)->widget; | - | ||||||||||||||||||
1442 | if (w->isHidden())
| 0 | ||||||||||||||||||
1443 | continue; never executed: continue; | 0 | ||||||||||||||||||
1444 | QSize s = w->sizeHint(); | - | ||||||||||||||||||
1445 | if (s.isValid()) {
| 0 | ||||||||||||||||||
1446 | l += d->pick(s); | - | ||||||||||||||||||
1447 | t = qMax(t, d->trans(s)); | - | ||||||||||||||||||
1448 | } never executed: end of block | 0 | ||||||||||||||||||
1449 | } never executed: end of block | 0 | ||||||||||||||||||
1450 | return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l); never executed: return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
| 0 | ||||||||||||||||||
1451 | } | - | ||||||||||||||||||
1452 | - | |||||||||||||||||||
1453 | - | |||||||||||||||||||
1454 | /*! | - | ||||||||||||||||||
1455 | \reimp | - | ||||||||||||||||||
1456 | */ | - | ||||||||||||||||||
1457 | - | |||||||||||||||||||
1458 | QSize QSplitter::minimumSizeHint() const | - | ||||||||||||||||||
1459 | { | - | ||||||||||||||||||
1460 | Q_D(const QSplitter); | - | ||||||||||||||||||
1461 | ensurePolished(); | - | ||||||||||||||||||
1462 | int l = 0; | - | ||||||||||||||||||
1463 | int t = 0; | - | ||||||||||||||||||
1464 | - | |||||||||||||||||||
1465 | for (int i = 0; i < d->list.size(); ++i) {
| 0 | ||||||||||||||||||
1466 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1467 | if (!s || !s->widget)
| 0 | ||||||||||||||||||
1468 | continue; never executed: continue; | 0 | ||||||||||||||||||
1469 | if (s->widget->isHidden())
| 0 | ||||||||||||||||||
1470 | continue; never executed: continue; | 0 | ||||||||||||||||||
1471 | QSize widgetSize = qSmartMinSize(s->widget); | - | ||||||||||||||||||
1472 | if (widgetSize.isValid()) {
| 0 | ||||||||||||||||||
1473 | l += d->pick(widgetSize); | - | ||||||||||||||||||
1474 | t = qMax(t, d->trans(widgetSize)); | - | ||||||||||||||||||
1475 | } never executed: end of block | 0 | ||||||||||||||||||
1476 | if (!s->handle || s->handle->isHidden())
| 0 | ||||||||||||||||||
1477 | continue; never executed: continue; | 0 | ||||||||||||||||||
1478 | QSize splitterSize = s->handle->sizeHint(); | - | ||||||||||||||||||
1479 | if (splitterSize.isValid()) {
| 0 | ||||||||||||||||||
1480 | l += d->pick(splitterSize); | - | ||||||||||||||||||
1481 | t = qMax(t, d->trans(splitterSize)); | - | ||||||||||||||||||
1482 | } never executed: end of block | 0 | ||||||||||||||||||
1483 | } never executed: end of block | 0 | ||||||||||||||||||
1484 | return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l); never executed: return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
| 0 | ||||||||||||||||||
1485 | } | - | ||||||||||||||||||
1486 | - | |||||||||||||||||||
1487 | - | |||||||||||||||||||
1488 | /*! | - | ||||||||||||||||||
1489 | Returns a list of the size parameters of all the widgets in this splitter. | - | ||||||||||||||||||
1490 | - | |||||||||||||||||||
1491 | If the splitter's orientation is horizontal, the list contains the | - | ||||||||||||||||||
1492 | widgets width in pixels, from left to right; if the orientation is | - | ||||||||||||||||||
1493 | vertical, the list contains the widgets' heights in pixels, | - | ||||||||||||||||||
1494 | from top to bottom. | - | ||||||||||||||||||
1495 | - | |||||||||||||||||||
1496 | Giving the values to another splitter's setSizes() function will | - | ||||||||||||||||||
1497 | produce a splitter with the same layout as this one. | - | ||||||||||||||||||
1498 | - | |||||||||||||||||||
1499 | Note that invisible widgets have a size of 0. | - | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | \sa setSizes() | - | ||||||||||||||||||
1502 | */ | - | ||||||||||||||||||
1503 | - | |||||||||||||||||||
1504 | QList<int> QSplitter::sizes() const | - | ||||||||||||||||||
1505 | { | - | ||||||||||||||||||
1506 | Q_D(const QSplitter); | - | ||||||||||||||||||
1507 | ensurePolished(); | - | ||||||||||||||||||
1508 | - | |||||||||||||||||||
1509 | const int numSizes = d->list.size(); | - | ||||||||||||||||||
1510 | QList<int> list; | - | ||||||||||||||||||
1511 | list.reserve(numSizes); | - | ||||||||||||||||||
1512 | - | |||||||||||||||||||
1513 | for (int i = 0; i < numSizes; ++i) {
| 0 | ||||||||||||||||||
1514 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1515 | list.append(d->pick(s->rect.size())); | - | ||||||||||||||||||
1516 | } never executed: end of block | 0 | ||||||||||||||||||
1517 | return list; never executed: return list; | 0 | ||||||||||||||||||
1518 | } | - | ||||||||||||||||||
1519 | - | |||||||||||||||||||
1520 | /*! | - | ||||||||||||||||||
1521 | Sets the child widgets' respective sizes to the values given in the \a list. | - | ||||||||||||||||||
1522 | - | |||||||||||||||||||
1523 | If the splitter is horizontal, the values set the width of each | - | ||||||||||||||||||
1524 | widget in pixels, from left to right. If the splitter is vertical, the | - | ||||||||||||||||||
1525 | height of each widget is set, from top to bottom. | - | ||||||||||||||||||
1526 | - | |||||||||||||||||||
1527 | Extra values in the \a list are ignored. If \a list contains too few | - | ||||||||||||||||||
1528 | values, the result is undefined, but the program will still be well-behaved. | - | ||||||||||||||||||
1529 | - | |||||||||||||||||||
1530 | The overall size of the splitter widget is not affected. | - | ||||||||||||||||||
1531 | Instead, any additional/missing space is distributed amongst the | - | ||||||||||||||||||
1532 | widgets according to the relative weight of the sizes. | - | ||||||||||||||||||
1533 | - | |||||||||||||||||||
1534 | If you specify a size of 0, the widget will be invisible. The size policies | - | ||||||||||||||||||
1535 | of the widgets are preserved. That is, a value smaller than the minimal size | - | ||||||||||||||||||
1536 | hint of the respective widget will be replaced by the value of the hint. | - | ||||||||||||||||||
1537 | - | |||||||||||||||||||
1538 | \sa sizes() | - | ||||||||||||||||||
1539 | */ | - | ||||||||||||||||||
1540 | - | |||||||||||||||||||
1541 | void QSplitter::setSizes(const QList<int> &list) | - | ||||||||||||||||||
1542 | { | - | ||||||||||||||||||
1543 | Q_D(QSplitter); | - | ||||||||||||||||||
1544 | d->setSizes_helper(list, true); | - | ||||||||||||||||||
1545 | } never executed: end of block | 0 | ||||||||||||||||||
1546 | - | |||||||||||||||||||
1547 | /*! | - | ||||||||||||||||||
1548 | \property QSplitter::handleWidth | - | ||||||||||||||||||
1549 | \brief the width of the splitter handles | - | ||||||||||||||||||
1550 | - | |||||||||||||||||||
1551 | By default, this property contains a value that depends on the user's platform | - | ||||||||||||||||||
1552 | and style preferences. | - | ||||||||||||||||||
1553 | - | |||||||||||||||||||
1554 | If you set handleWidth to 1 or 0, the actual grab area will grow to overlap a | - | ||||||||||||||||||
1555 | few pixels of its respective widgets. | - | ||||||||||||||||||
1556 | */ | - | ||||||||||||||||||
1557 | - | |||||||||||||||||||
1558 | int QSplitter::handleWidth() const | - | ||||||||||||||||||
1559 | { | - | ||||||||||||||||||
1560 | Q_D(const QSplitter); | - | ||||||||||||||||||
1561 | if (d->handleWidth >= 0) {
| 0 | ||||||||||||||||||
1562 | return d->handleWidth; never executed: return d->handleWidth; | 0 | ||||||||||||||||||
1563 | } else { | - | ||||||||||||||||||
1564 | return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); never executed: return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); | 0 | ||||||||||||||||||
1565 | } | - | ||||||||||||||||||
1566 | } | - | ||||||||||||||||||
1567 | - | |||||||||||||||||||
1568 | void QSplitter::setHandleWidth(int width) | - | ||||||||||||||||||
1569 | { | - | ||||||||||||||||||
1570 | Q_D(QSplitter); | - | ||||||||||||||||||
1571 | d->handleWidth = width; | - | ||||||||||||||||||
1572 | d->updateHandles(); | - | ||||||||||||||||||
1573 | } never executed: end of block | 0 | ||||||||||||||||||
1574 | - | |||||||||||||||||||
1575 | /*! | - | ||||||||||||||||||
1576 | \reimp | - | ||||||||||||||||||
1577 | */ | - | ||||||||||||||||||
1578 | void QSplitter::changeEvent(QEvent *ev) | - | ||||||||||||||||||
1579 | { | - | ||||||||||||||||||
1580 | Q_D(QSplitter); | - | ||||||||||||||||||
1581 | if(ev->type() == QEvent::StyleChange)
| 0 | ||||||||||||||||||
1582 | d->updateHandles(); never executed: d->updateHandles(); | 0 | ||||||||||||||||||
1583 | QFrame::changeEvent(ev); | - | ||||||||||||||||||
1584 | } never executed: end of block | 0 | ||||||||||||||||||
1585 | - | |||||||||||||||||||
1586 | static const qint32 SplitterMagic = 0xff; | - | ||||||||||||||||||
1587 | - | |||||||||||||||||||
1588 | /*! | - | ||||||||||||||||||
1589 | Saves the state of the splitter's layout. | - | ||||||||||||||||||
1590 | - | |||||||||||||||||||
1591 | Typically this is used in conjunction with QSettings to remember the size | - | ||||||||||||||||||
1592 | for a future session. A version number is stored as part of the data. | - | ||||||||||||||||||
1593 | Here is an example: | - | ||||||||||||||||||
1594 | - | |||||||||||||||||||
1595 | \snippet splitter/splitter.cpp 1 | - | ||||||||||||||||||
1596 | - | |||||||||||||||||||
1597 | \sa restoreState() | - | ||||||||||||||||||
1598 | */ | - | ||||||||||||||||||
1599 | QByteArray QSplitter::saveState() const | - | ||||||||||||||||||
1600 | { | - | ||||||||||||||||||
1601 | Q_D(const QSplitter); | - | ||||||||||||||||||
1602 | int version = 1; | - | ||||||||||||||||||
1603 | QByteArray data; | - | ||||||||||||||||||
1604 | QDataStream stream(&data, QIODevice::WriteOnly); | - | ||||||||||||||||||
1605 | - | |||||||||||||||||||
1606 | stream << qint32(SplitterMagic); | - | ||||||||||||||||||
1607 | stream << qint32(version); | - | ||||||||||||||||||
1608 | const int numSizes = d->list.size(); | - | ||||||||||||||||||
1609 | QList<int> list; | - | ||||||||||||||||||
1610 | list.reserve(numSizes); | - | ||||||||||||||||||
1611 | for (int i = 0; i < numSizes; ++i) {
| 0 | ||||||||||||||||||
1612 | QSplitterLayoutStruct *s = d->list.at(i); | - | ||||||||||||||||||
1613 | list.append(s->sizer); | - | ||||||||||||||||||
1614 | } never executed: end of block | 0 | ||||||||||||||||||
1615 | stream << list; | - | ||||||||||||||||||
1616 | stream << childrenCollapsible(); | - | ||||||||||||||||||
1617 | stream << qint32(d->handleWidth); | - | ||||||||||||||||||
1618 | stream << opaqueResize(); | - | ||||||||||||||||||
1619 | stream << qint32(orientation()); | - | ||||||||||||||||||
1620 | stream << d->opaqueResizeSet; | - | ||||||||||||||||||
1621 | return data; never executed: return data; | 0 | ||||||||||||||||||
1622 | } | - | ||||||||||||||||||
1623 | - | |||||||||||||||||||
1624 | /*! | - | ||||||||||||||||||
1625 | Restores the splitter's layout to the \a state specified. | - | ||||||||||||||||||
1626 | Returns \c true if the state is restored; otherwise returns \c false. | - | ||||||||||||||||||
1627 | - | |||||||||||||||||||
1628 | Typically this is used in conjunction with QSettings to restore the size | - | ||||||||||||||||||
1629 | from a past session. Here is an example: | - | ||||||||||||||||||
1630 | - | |||||||||||||||||||
1631 | Restore the splitter's state: | - | ||||||||||||||||||
1632 | - | |||||||||||||||||||
1633 | \snippet splitter/splitter.cpp 2 | - | ||||||||||||||||||
1634 | - | |||||||||||||||||||
1635 | A failure to restore the splitter's layout may result from either | - | ||||||||||||||||||
1636 | invalid or out-of-date data in the supplied byte array. | - | ||||||||||||||||||
1637 | - | |||||||||||||||||||
1638 | \sa saveState() | - | ||||||||||||||||||
1639 | */ | - | ||||||||||||||||||
1640 | bool QSplitter::restoreState(const QByteArray &state) | - | ||||||||||||||||||
1641 | { | - | ||||||||||||||||||
1642 | Q_D(QSplitter); | - | ||||||||||||||||||
1643 | int version = 1; | - | ||||||||||||||||||
1644 | QByteArray sd = state; | - | ||||||||||||||||||
1645 | QDataStream stream(&sd, QIODevice::ReadOnly); | - | ||||||||||||||||||
1646 | QList<int> list; | - | ||||||||||||||||||
1647 | bool b; | - | ||||||||||||||||||
1648 | qint32 i; | - | ||||||||||||||||||
1649 | qint32 marker; | - | ||||||||||||||||||
1650 | qint32 v; | - | ||||||||||||||||||
1651 | - | |||||||||||||||||||
1652 | stream >> marker; | - | ||||||||||||||||||
1653 | stream >> v; | - | ||||||||||||||||||
1654 | if (marker != SplitterMagic || v > version)
| 0 | ||||||||||||||||||
1655 | return false; never executed: return false; | 0 | ||||||||||||||||||
1656 | - | |||||||||||||||||||
1657 | stream >> list; | - | ||||||||||||||||||
1658 | d->setSizes_helper(list, false); | - | ||||||||||||||||||
1659 | - | |||||||||||||||||||
1660 | stream >> b; | - | ||||||||||||||||||
1661 | setChildrenCollapsible(b); | - | ||||||||||||||||||
1662 | - | |||||||||||||||||||
1663 | stream >> i; | - | ||||||||||||||||||
1664 | setHandleWidth(i); | - | ||||||||||||||||||
1665 | - | |||||||||||||||||||
1666 | stream >> b; | - | ||||||||||||||||||
1667 | setOpaqueResize(b); | - | ||||||||||||||||||
1668 | - | |||||||||||||||||||
1669 | stream >> i; | - | ||||||||||||||||||
1670 | setOrientation(Qt::Orientation(i)); | - | ||||||||||||||||||
1671 | d->doResize(); | - | ||||||||||||||||||
1672 | - | |||||||||||||||||||
1673 | if (v >= 1)
| 0 | ||||||||||||||||||
1674 | stream >> d->opaqueResizeSet; never executed: stream >> d->opaqueResizeSet; | 0 | ||||||||||||||||||
1675 | - | |||||||||||||||||||
1676 | return true; never executed: return true; | 0 | ||||||||||||||||||
1677 | } | - | ||||||||||||||||||
1678 | - | |||||||||||||||||||
1679 | /*! | - | ||||||||||||||||||
1680 | Updates the size policy of the widget at position \a index to | - | ||||||||||||||||||
1681 | have a stretch factor of \a stretch. | - | ||||||||||||||||||
1682 | - | |||||||||||||||||||
1683 | \a stretch is not the effective stretch factor; the effective | - | ||||||||||||||||||
1684 | stretch factor is calculated by taking the initial size of the | - | ||||||||||||||||||
1685 | widget and multiplying it with \a stretch. | - | ||||||||||||||||||
1686 | - | |||||||||||||||||||
1687 | This function is provided for convenience. It is equivalent to | - | ||||||||||||||||||
1688 | - | |||||||||||||||||||
1689 | \snippet code/src_gui_widgets_qsplitter.cpp 0 | - | ||||||||||||||||||
1690 | - | |||||||||||||||||||
1691 | \sa setSizes(), widget() | - | ||||||||||||||||||
1692 | */ | - | ||||||||||||||||||
1693 | void QSplitter::setStretchFactor(int index, int stretch) | - | ||||||||||||||||||
1694 | { | - | ||||||||||||||||||
1695 | Q_D(QSplitter); | - | ||||||||||||||||||
1696 | if (index <= -1 || index >= d->list.count())
| 0 | ||||||||||||||||||
1697 | return; never executed: return; | 0 | ||||||||||||||||||
1698 | - | |||||||||||||||||||
1699 | QWidget *widget = d->list.at(index)->widget; | - | ||||||||||||||||||
1700 | QSizePolicy sp = widget->sizePolicy(); | - | ||||||||||||||||||
1701 | sp.setHorizontalStretch(stretch); | - | ||||||||||||||||||
1702 | sp.setVerticalStretch(stretch); | - | ||||||||||||||||||
1703 | widget->setSizePolicy(sp); | - | ||||||||||||||||||
1704 | } never executed: end of block | 0 | ||||||||||||||||||
1705 | - | |||||||||||||||||||
1706 | - | |||||||||||||||||||
1707 | /*! | - | ||||||||||||||||||
1708 | \relates QSplitter | - | ||||||||||||||||||
1709 | \obsolete | - | ||||||||||||||||||
1710 | - | |||||||||||||||||||
1711 | Use \a ts << \a{splitter}.saveState() instead. | - | ||||||||||||||||||
1712 | */ | - | ||||||||||||||||||
1713 | - | |||||||||||||||||||
1714 | QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter) | - | ||||||||||||||||||
1715 | { | - | ||||||||||||||||||
1716 | ts << splitter.saveState() << endl; | - | ||||||||||||||||||
1717 | return ts; never executed: return ts; | 0 | ||||||||||||||||||
1718 | } | - | ||||||||||||||||||
1719 | - | |||||||||||||||||||
1720 | /*! | - | ||||||||||||||||||
1721 | \relates QSplitter | - | ||||||||||||||||||
1722 | \obsolete | - | ||||||||||||||||||
1723 | - | |||||||||||||||||||
1724 | Use \a ts >> \a{splitter}.restoreState() instead. | - | ||||||||||||||||||
1725 | */ | - | ||||||||||||||||||
1726 | - | |||||||||||||||||||
1727 | QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) | - | ||||||||||||||||||
1728 | { | - | ||||||||||||||||||
1729 | QString line = ts.readLine(); | - | ||||||||||||||||||
1730 | line = line.simplified(); | - | ||||||||||||||||||
1731 | line.replace(QLatin1Char(' '), QString()); | - | ||||||||||||||||||
1732 | line = line.toUpper(); | - | ||||||||||||||||||
1733 | - | |||||||||||||||||||
1734 | splitter.restoreState(line.toLatin1()); | - | ||||||||||||||||||
1735 | return ts; never executed: return ts; | 0 | ||||||||||||||||||
1736 | } | - | ||||||||||||||||||
1737 | - | |||||||||||||||||||
1738 | QT_END_NAMESPACE | - | ||||||||||||||||||
1739 | - | |||||||||||||||||||
1740 | #include "moc_qsplitter.cpp" | - | ||||||||||||||||||
1741 | - | |||||||||||||||||||
1742 | #endif // QT_NO_SPLITTER | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |