qcolumnviewgrip.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qcolumnviewgrip.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
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 https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#ifndef QT_NO_QCOLUMNVIEW-
41-
42#include "qcolumnviewgrip_p.h"-
43#include <qstyleoption.h>-
44#include <qpainter.h>-
45#include <qbrush.h>-
46#include <qevent.h>-
47#include <qdebug.h>-
48-
49QT_BEGIN_NAMESPACE-
50-
51/*-
52 \internal-
53 class QColumnViewGrip-
54-
55 QColumnViewGrip is created to go inside QAbstractScrollArea's corner.-
56 When the mouse it moved it will resize the scroll area and emit's a signal.-
57 */-
58-
59/*-
60 \internal-
61 \fn void QColumnViewGrip::gripMoved()-
62 Signal that is emitted when the grip moves the parent widget.-
63 */-
64-
65/*!-
66 Creates a new QColumnViewGrip with the given \a parent to view a model.-
67 Use setModel() to set the model.-
68*/-
69QColumnViewGrip::QColumnViewGrip(QWidget *parent)-
70: QWidget(*new QColumnViewGripPrivate, parent, 0)-
71{-
72#ifndef QT_NO_CURSOR-
73 setCursor(Qt::SplitHCursor);-
74#endif-
75}
never executed: end of block
0
76-
77/*!-
78 \internal-
79*/-
80QColumnViewGrip::QColumnViewGrip(QColumnViewGripPrivate & dd, QWidget *parent, Qt::WindowFlags f)-
81: QWidget(dd, parent, f)-
82{-
83}
never executed: end of block
0
84-
85/*!-
86 Destroys the view.-
87*/-
88QColumnViewGrip::~QColumnViewGrip()-
89{-
90}-
91-
92/*!-
93 Attempt to resize the parent object by \a offset-
94 returns the amount of offset that it was actually able to resized-
95*/-
96int QColumnViewGrip::moveGrip(int offset)-
97{-
98 QWidget *parentWidget = (QWidget*)parent();-
99-
100 // first resize the parent-
101 int oldWidth = parentWidget->width();-
102 int newWidth = oldWidth;-
103 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
104 newWidth -= offset;
never executed: newWidth -= offset;
0
105 else-
106 newWidth += offset;
never executed: newWidth += offset;
0
107 newWidth = qMax(parentWidget->minimumWidth(), newWidth);-
108 parentWidget->resize(newWidth, parentWidget->height());-
109-
110 // Then have the view move the widget-
111 int realOffset = parentWidget->width() - oldWidth;-
112 int oldX = parentWidget->x();-
113 if (realOffset != 0)
realOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
114 emit gripMoved(realOffset);
never executed: gripMoved(realOffset);
0
115 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
116 realOffset = -1 * (oldX - parentWidget->x());
never executed: realOffset = -1 * (oldX - parentWidget->x());
0
117 return realOffset;
never executed: return realOffset;
0
118}-
119-
120/*!-
121 \reimp-
122*/-
123void QColumnViewGrip::paintEvent(QPaintEvent *event)-
124{-
125 QPainter painter(this);-
126 QStyleOption opt;-
127 opt.initFrom(this);-
128 style()->drawControl(QStyle::CE_ColumnViewGrip, &opt, &painter, this);-
129 event->accept();-
130}
never executed: end of block
0
131-
132/*!-
133 \reimp-
134 Resize the parent window to the sizeHint-
135*/-
136void QColumnViewGrip::mouseDoubleClickEvent(QMouseEvent *event)-
137{-
138 Q_UNUSED(event);-
139 QWidget *parentWidget = (QWidget*)parent();-
140 int offset = parentWidget->sizeHint().width() - parentWidget->width();-
141 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
142 offset *= -1;
never executed: offset *= -1;
0
143 moveGrip(offset);-
144 event->accept();-
145}
never executed: end of block
0
146-
147/*!-
148 \reimp-
149 Begin watching for mouse movements-
150*/-
151void QColumnViewGrip::mousePressEvent(QMouseEvent *event)-
152{-
153 Q_D(QColumnViewGrip);-
154 d->originalXLocation = event->globalX();-
155 event->accept();-
156}
never executed: end of block
0
157-
158/*!-
159 \reimp-
160 Calculate the movement of the grip and moveGrip() and emit gripMoved-
161*/-
162void QColumnViewGrip::mouseMoveEvent(QMouseEvent *event)-
163{-
164 Q_D(QColumnViewGrip);-
165 int offset = event->globalX() - d->originalXLocation;-
166 d->originalXLocation = moveGrip(offset) + d->originalXLocation;-
167 event->accept();-
168}
never executed: end of block
0
169-
170/*!-
171 \reimp-
172 Stop watching for mouse movements-
173*/-
174void QColumnViewGrip::mouseReleaseEvent(QMouseEvent *event)-
175{-
176 Q_D(QColumnViewGrip);-
177 d->originalXLocation = -1;-
178 event->accept();-
179}
never executed: end of block
0
180-
181/*-
182 * private object implementation-
183 */-
184QColumnViewGripPrivate::QColumnViewGripPrivate()-
185: QWidgetPrivate(),-
186originalXLocation(-1)-
187{-
188}
never executed: end of block
0
189-
190QT_END_NAMESPACE-
191-
192#include "moc_qcolumnviewgrip_p.cpp"-
193-
194#endif // QT_NO_QCOLUMNVIEW-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9