modify abstracttool iface
[yamf.git] / yamf / tools / view / hand.cpp
blob0e43a343f5392773d10659b74a13de17277d5801
2 /***************************************************************************
3 * Copyright (C) 2007 by Jorge Cuadrado *
4 * kuadrosxx@gmail.com *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
22 #include "hand.h"
24 #include <drawing/photogram.h>
25 #include <drawing/brushmanager.h>
26 #include <drawing/paintarea.h>
27 #include <model/frame.h>
29 #include <dgui/action.h>
30 #include <dgui/iconloader.h>
31 #include <dcore/debug.h>
33 #include <QPointF>
34 #include <QIcon>
35 #include <QKeySequence>
36 #include <QMatrix>
37 #include <QGraphicsLineItem>
38 #include <QGraphicsView>
39 #include <QGraphicsRectItem>
40 #include <QGraphicsSceneMouseEvent>
42 namespace YAMF {
44 namespace Drawing {
46 namespace Tool {
48 struct Hand::Private
50 DGui::Action *action;
51 PaintArea *paintarea;
54 /**
55 * @~spanish
56 * Construye la herramienta.
58 Hand::Hand(QObject *parent)
59 : Drawing::AbstractTool(parent), d(new Private)
61 d->action = new DGui::Action( DGui::IconLoader::self()->load(".svg"), tr("Hand"), this);
62 d->paintarea = 0;
65 /**
66 * Destructor
68 Hand::~Hand()
70 delete d;
73 /**
74 * @~spanish
75 * Inicializa la herramienta, evita que los items dentro de el fotograma se puedan mover o seleccionar.
77 void Hand::init(Photogram *photogram)
79 foreach(QGraphicsView * view, photogram->views())
81 view->setDragMode ( QGraphicsView::NoDrag );
83 if ( QGraphicsScene *photogram = qobject_cast<QGraphicsScene *>(view->scene()) )
85 foreach(QGraphicsItem *item, photogram->items() )
87 item->setFlag(QGraphicsItem::ItemIsSelectable, false);
88 item->setFlag(QGraphicsItem::ItemIsMovable, false);
94 /**
95 * @~spanish
96 * Retorna el id de la herramienta.
98 QString Hand::id() const
100 return tr("Hand");
104 * @~spanish
105 * Función sobrecargada para habilitar la carateristica de la herramieta.
107 void Hand::press(const QGraphicsSceneMouseEvent *input)
109 Q_UNUSED(input)
110 PaintArea *paintArea = this->paintArea();
111 paintArea->setDragMode(QGraphicsView::ScrollHandDrag);
112 d->paintarea = paintArea;
116 * @~spanish
117 * Función sobrecargada para habilitar la carateristica de la herramieta.
119 void Hand::move(const QGraphicsSceneMouseEvent *input)
121 Q_UNUSED(input)
125 * @~spanish
126 * Función sobrecargada para habilitar la carateristica de la herramieta.
128 void Hand::release(const QGraphicsSceneMouseEvent *input)
130 Q_UNUSED(input)
134 * @~spanish
135 * Retorna la acción que representa la herramienta.
137 DGui::Action *Hand::action() const
139 return d->action;
143 * @~spanish
144 * Retorna que la herramienta es de tipo View.
146 int Hand::type() const
148 return AbstractTool::View;
152 * @~spanish
153 * Función sobrecargada para desactivar la caracteristica de la herramienta.
155 void Hand::aboutToChangeTool()
157 if(d->paintarea)
158 d->paintarea->setDragMode(QGraphicsView::NoDrag);