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) 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#ifndef QT_NO_QCOLUMNVIEW-
35-
36#include "qcolumnviewgrip_p.h"-
37#include <qstyleoption.h>-
38#include <qpainter.h>-
39#include <qbrush.h>-
40#include <qevent.h>-
41#include <qdebug.h>-
42-
43QT_BEGIN_NAMESPACE-
44-
45/*-
46 \internal-
47 class QColumnViewGrip-
48-
49 QColumnViewGrip is created to go inside QAbstractScrollArea's corner.-
50 When the mouse it moved it will resize the scroll area and emit's a signal.-
51 */-
52-
53/*-
54 \internal-
55 \fn void QColumnViewGrip::gripMoved()-
56 Signal that is emitted when the grip moves the parent widget.-
57 */-
58-
59/*!-
60 Creates a new QColumnViewGrip with the given \a parent to view a model.-
61 Use setModel() to set the model.-
62*/-
63QColumnViewGrip::QColumnViewGrip(QWidget *parent)-
64: QWidget(*new QColumnViewGripPrivate, parent, 0)-
65{-
66#ifndef QT_NO_CURSOR-
67 setCursor(Qt::SplitHCursor);-
68#endif-
69}
never executed: end of block
0
70-
71/*!-
72 \internal-
73*/-
74QColumnViewGrip::QColumnViewGrip(QColumnViewGripPrivate & dd, QWidget *parent, Qt::WindowFlags f)-
75: QWidget(dd, parent, f)-
76{-
77}
never executed: end of block
0
78-
79/*!-
80 Destroys the view.-
81*/-
82QColumnViewGrip::~QColumnViewGrip()-
83{-
84}-
85-
86/*!-
87 Attempt to resize the parent object by \a offset-
88 returns the amount of offset that it was actually able to resized-
89*/-
90int QColumnViewGrip::moveGrip(int offset)-
91{-
92 QWidget *parentWidget = (QWidget*)parent();-
93-
94 // first resize the parent-
95 int oldWidth = parentWidget->width();-
96 int newWidth = oldWidth;-
97 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
98 newWidth -= offset;
never executed: newWidth -= offset;
0
99 else-
100 newWidth += offset;
never executed: newWidth += offset;
0
101 newWidth = qMax(parentWidget->minimumWidth(), newWidth);-
102 parentWidget->resize(newWidth, parentWidget->height());-
103-
104 // Then have the view move the widget-
105 int realOffset = parentWidget->width() - oldWidth;-
106 int oldX = parentWidget->x();-
107 if (realOffset != 0)
realOffset != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
108 emit gripMoved(realOffset);
never executed: gripMoved(realOffset);
0
109 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
110 realOffset = -1 * (oldX - parentWidget->x());
never executed: realOffset = -1 * (oldX - parentWidget->x());
0
111 return realOffset;
never executed: return realOffset;
0
112}-
113-
114/*!-
115 \reimp-
116*/-
117void QColumnViewGrip::paintEvent(QPaintEvent *event)-
118{-
119 QPainter painter(this);-
120 QStyleOption opt;-
121 opt.initFrom(this);-
122 style()->drawControl(QStyle::CE_ColumnViewGrip, &opt, &painter, this);-
123 event->accept();-
124}
never executed: end of block
0
125-
126/*!-
127 \reimp-
128 Resize the parent window to the sizeHint-
129*/-
130void QColumnViewGrip::mouseDoubleClickEvent(QMouseEvent *event)-
131{-
132 Q_UNUSED(event);-
133 QWidget *parentWidget = (QWidget*)parent();-
134 int offset = parentWidget->sizeHint().width() - parentWidget->width();-
135 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
136 offset *= -1;
never executed: offset *= -1;
0
137 moveGrip(offset);-
138 event->accept();-
139}
never executed: end of block
0
140-
141/*!-
142 \reimp-
143 Begin watching for mouse movements-
144*/-
145void QColumnViewGrip::mousePressEvent(QMouseEvent *event)-
146{-
147 Q_D(QColumnViewGrip);-
148 d->originalXLocation = event->globalX();-
149 event->accept();-
150}
never executed: end of block
0
151-
152/*!-
153 \reimp-
154 Calculate the movement of the grip and moveGrip() and emit gripMoved-
155*/-
156void QColumnViewGrip::mouseMoveEvent(QMouseEvent *event)-
157{-
158 Q_D(QColumnViewGrip);-
159 int offset = event->globalX() - d->originalXLocation;-
160 d->originalXLocation = moveGrip(offset) + d->originalXLocation;-
161 event->accept();-
162}
never executed: end of block
0
163-
164/*!-
165 \reimp-
166 Stop watching for mouse movements-
167*/-
168void QColumnViewGrip::mouseReleaseEvent(QMouseEvent *event)-
169{-
170 Q_D(QColumnViewGrip);-
171 d->originalXLocation = -1;-
172 event->accept();-
173}
never executed: end of block
0
174-
175/*-
176 * private object implementation-
177 */-
178QColumnViewGripPrivate::QColumnViewGripPrivate()-
179: QWidgetPrivate(),-
180originalXLocation(-1)-
181{-
182}
never executed: end of block
0
183-
184QT_END_NAMESPACE-
185-
186#include "moc_qcolumnviewgrip_p.cpp"-
187-
188#endif // QT_NO_QCOLUMNVIEW-
Source codeSwitch to Preprocessed file

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