[105ed6]: src / interfaces / idocumentscene.h  Maximize  Restore  History

Download this file

124 lines (100 with data), 3.7 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
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Copyright (C) 2010 Julian B채ume <julian@svg4all.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef IDOCUMENTSCENE_H
#define IDOCUMENTSCENE_H
#include "ktlinterfacesexport.h"
#include "interfaces/iroutinginformation.h"
#include <QtGui/QGraphicsScene>
#include <QVariantMap>
class QGraphicsSceneMouseEvent;
namespace KTechLab {
class IConRouter;
/**
* \short A QGraphicsScene with icons connectable through (complex) routed connections
*
* This class is used as a base-class for Documents that need routed connections
* between items located on a \class QGraphicsScene. All routing is handled by this
* class using a plugin implementing the \class KTechLab::IConRouter interface.
* The routing plugin can get information from the scene to find better routes within
* this scene.
*
* This class also implements some standard behaviour for key events.
* \author Julian B채ume <julian@svg4all.de>
*/
class KTLINTERFACES_EXPORT IDocumentScene : public QGraphicsScene
{
Q_OBJECT
public:
IDocumentScene(QObject* parent = 0);
virtual ~IDocumentScene();
/**
* Returns true, if the user is just routing a connections within this
* scene.
*
* \returns true, if the user is routing, false otherwise
*/
bool isRouting() const;
/**
* Start the routing process at point \param pos
*/
void startRouting(const QPointF &pos);
/**
* Abort the routing process.
*/
void abortRouting();
/**
* Finish the routing process and therefore place the route.
*/
void finishRouting();
/**
* Get the routing information stored by the routing plugin.
*
* Each scene can store routing information provided by the
* plugin for later usage.
*/
QSharedPointer<IRoutingInformation> routingInfo() const;
/**
* Set the routing information to be stored.
*
* Each scene can store routing information provided by the
* plugin for later usage.
*/
void setRoutingInfo( QSharedPointer<IRoutingInformation> info );
public slots:
virtual void updateData( const QString &name, const QVariantMap &value );
protected:
/**
* This method tracks mouse movement during the routing process.
* Make sure to call this method, in case you override it.
*/
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
/**
* handle default key events like delete
*/
virtual void keyPressEvent(QKeyEvent* event);
/**
* Fetch a plugin implementing \class KTechLab::IConRouter and return it.
* \returns a plugin capable of mapping a route
*/
virtual IConRouter *fetchRouter();
virtual void drawForeground(QPainter* painter, const QRectF& rect);
private:
QGraphicsPathItem* m_routePath;
QSharedPointer<IRoutingInformation> m_routingInfo;
QPointF m_startPos;
};
}
#endif // IDOCUMENTSCENE_H

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks