-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctimecodeitemgroup.cpp
More file actions
59 lines (43 loc) · 1.98 KB
/
ctimecodeitemgroup.cpp
File metadata and controls
59 lines (43 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/************************************************************************\
Copyright 2009, Jochen Issing
This is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this software; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
\************************************************************************/
#include <QRectF>
#include <QPointF>
#include <QGraphicsScene>
#include <iostream>
#include "ctimecodeitemgroup.h"
using namespace std;
CTimecodeItemGroup::CTimecodeItemGroup()
{
}
QVariant CTimecodeItemGroup::itemChange( GraphicsItemChange change, const QVariant & value )
{
// apply change in items position to main window using signal and slots
if( change == ItemPositionChange && scene() )
{
// value is the new position.
QPointF newPos = value.toPointF();
QRectF rect = scene()->sceneRect();
//std::cout << "new pos x=" << newPos.x() << " y=" << newPos.y() << std::endl;
// Keep the item inside the scene rect.
newPos.setX( qMin(rect.right(), qMax(newPos.x(), rect.left())) );
newPos.setY( qMin(rect.bottom(), qMax(newPos.y(), rect.top())) );
//std::cout << " cor x=" << newPos.x() << " y=" << newPos.y() << std::endl;
emit positionChanged( newPos.x(), newPos.y() );
return newPos;
}
// return base classes result
return QGraphicsItemGroup::itemChange( change, value );
}