2 /***************************************************************************
3 * Copyright (C) 2007 by Jorge Cuadrado *
4 * kuadrosxx@gmail.com *
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. *
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. *
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 ***************************************************************************/
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>
35 #include <QKeySequence>
37 #include <QGraphicsLineItem>
38 #include <QGraphicsView>
39 #include <QGraphicsRectItem>
40 #include <QGraphicsSceneMouseEvent>
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);
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);
96 * Retorna el id de la herramienta.
98 QString
Hand::id() const
105 * Función sobrecargada para habilitar la carateristica de la herramieta.
107 void Hand::press(const QGraphicsSceneMouseEvent
*input
)
110 PaintArea
*paintArea
= this->paintArea();
111 paintArea
->setDragMode(QGraphicsView::ScrollHandDrag
);
112 d
->paintarea
= paintArea
;
117 * Función sobrecargada para habilitar la carateristica de la herramieta.
119 void Hand::move(const QGraphicsSceneMouseEvent
*input
)
126 * Función sobrecargada para habilitar la carateristica de la herramieta.
128 void Hand::release(const QGraphicsSceneMouseEvent
*input
)
135 * Retorna la acción que representa la herramienta.
137 DGui::Action
*Hand::action() const
144 * Retorna que la herramienta es de tipo View.
146 int Hand::type() const
148 return AbstractTool::View
;
153 * Función sobrecargada para desactivar la caracteristica de la herramienta.
155 void Hand::aboutToChangeTool()
158 d
->paintarea
->setDragMode(QGraphicsView::NoDrag
);