Last change
on this file was 160, checked in by dmik, 19 years ago |
Imported table and iconview modules and a bunch of dependent examples from the official release 3.3.1 from Trolltech.
|
-
Property svn:keywords
set to
Id
|
File size:
1.3 KB
|
Line | |
---|
1 | #include "canvasview.h"
|
---|
2 | #include "chartform.h"
|
---|
3 |
|
---|
4 | #include <qcursor.h>
|
---|
5 | #include <qpoint.h>
|
---|
6 | #include <qpopupmenu.h>
|
---|
7 | #include <qstatusbar.h>
|
---|
8 |
|
---|
9 |
|
---|
10 | void CanvasView::contentsContextMenuEvent( QContextMenuEvent * )
|
---|
11 | {
|
---|
12 | ((ChartForm*)parent())->optionsMenu->exec( QCursor::pos() );
|
---|
13 | }
|
---|
14 |
|
---|
15 |
|
---|
16 | void CanvasView::viewportResizeEvent( QResizeEvent *e )
|
---|
17 | {
|
---|
18 | canvas()->resize( e->size().width(), e->size().height() );
|
---|
19 | ((ChartForm*)parent())->drawElements();
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | void CanvasView::contentsMousePressEvent( QMouseEvent *e )
|
---|
24 | {
|
---|
25 | QCanvasItemList list = canvas()->collisions( e->pos() );
|
---|
26 | for ( QCanvasItemList::iterator it = list.begin(); it != list.end(); ++it )
|
---|
27 | if ( (*it)->rtti() == CanvasText::CANVAS_TEXT ) {
|
---|
28 | m_movingItem = *it;
|
---|
29 | m_pos = e->pos();
|
---|
30 | return;
|
---|
31 | }
|
---|
32 | m_movingItem = 0;
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | void CanvasView::contentsMouseMoveEvent( QMouseEvent *e )
|
---|
37 | {
|
---|
38 | if ( m_movingItem ) {
|
---|
39 | QPoint offset = e->pos() - m_pos;
|
---|
40 | m_movingItem->moveBy( offset.x(), offset.y() );
|
---|
41 | m_pos = e->pos();
|
---|
42 | ChartForm *form = (ChartForm*)parent();
|
---|
43 | form->setChanged( TRUE );
|
---|
44 | int chartType = form->chartType();
|
---|
45 | CanvasText *item = (CanvasText*)m_movingItem;
|
---|
46 | int i = item->index();
|
---|
47 |
|
---|
48 | (*m_elements)[i].setProX( chartType, item->x() / canvas()->width() );
|
---|
49 | (*m_elements)[i].setProY( chartType, item->y() / canvas()->height() );
|
---|
50 |
|
---|
51 | canvas()->update();
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.