2
* wbscene.h - an SVG whiteboard scene class
3
* Copyright (C) 2006 Joonas Govenius
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
/*! \brief The scene class for whiteboard items.
26
* Inherits QGraphicsScene.
28
* Processes remote whiteboard edits.
30
* This class also provides methods for queueing new edits and
31
* emits a signal with the corresponding whiteboard element.
36
class WbScene : public QGraphicsScene
41
/*! \brief Constructor
42
* Constructs a new scene with parent \a parent.
44
WbScene(const QString &session, const QString &ownJid, QObject * parent = 0);
45
/*! \brief Returns the session this widget is visualizing.*/
47
/*! \brief Returns the JID used by the user in the session.*/
48
const QString & ownJid() const;
49
/*! \brief Processes an incoming whiteboard element.*/
50
bool processWb(const QDomElement &wb);
51
/*! \brief Returns a pointer to the item with ID \a id*/
52
WbItem* findWbItem(const QString &id) const;
53
/*! \brief Returns a pointer to the item with graphicsitem() \a item*/
54
WbItem* findWbItem(QGraphicsItem* item) const;
55
/*! \brief Returns the SVG element representing the item with ID \a id*/
56
QDomElement element(const QString &id) const;
57
/*! \brief Returns the a list of all the elements on the whiteboard*/
58
QList<WbItem*> elements() const;
60
/*! \brief Adds the given item to scene.
61
* Connects the necessary signals so all items added to the board must be passed to this method.
63
void addWbItem(WbItem *);
64
/*! \brief Removes the element with ID \a id.*/
65
bool removeElement(const QString &id, bool emitChanges = false);
67
/*! \brief Return a new unique ID.*/
69
/*! \brief Return a new index value that will be the highest in the whiteboard.*/
72
/*! \brief Appends the given item on the pendigTransformations_ list.*/
73
void queueTransformationChange(WbItem* item);
74
/*! \brief Regenerate and signal the SVG transformation matrices for items on pendigTransformations_ list.*/
75
void regenerateTransformations();
77
/*! \brief If set true, all configure edits are accepted regardless of version.
78
* Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
83
/*! \brief Emitted when a new whiteboard element is ready to be sent.*/
84
void newWb(const QDomElement &wb);
87
/*! \brief Popsup a color dialog and sets color of the selected items.*/
88
void setStrokeColor();
89
/*! \brief Popsup a color dialog and sets fill color of the selected items.*/
91
/*! \brief Overload: Sets the width of selected items based on the QAction->data().*/
92
void setStrokeWidth(QAction*);
93
/*! \brief Brings the selected items \a n levels forward.
94
* If n < 0, the items are brought to the front.
96
void bringForward(int n = 1);
97
/*! \brief Same as bringForward(-1).*/
99
/*! \brief Sends the selected items \a n levels backwards.
100
* If n < 0, the items are sent to the back.
102
void sendBackwards(int n = 1);
103
/*! \brief Same as bringsendBackwardsForward(-1).*/
105
/*! \brief Groups the selected items.*/
107
/*! \brief Ungroups the selected item groups.*/
110
/*! \brief Composes queued edits and emits a new whiteboard element.*/
112
/*! \brief Queue a new element edit.*/
113
void queueNew(const QString &id, const qreal &index, const QDomElement &svg);
114
/*! \brief Queue an attribute edit.*/
115
void queueAttributeEdit(const QString &target, const QString &attribute, const QString &value, QString oldValue, int from = -1, int to = -1);
116
/*! \brief Queue a parent edit.*/
117
void queueParentEdit(const QString &target, const QString &value, QString oldValue);
118
/*! \brief Queue a content edit.*/
119
void queueContentEdit(const QString &target, const QDomNodeList &value, QDomNodeList oldValue);
120
/*! \brief Queue a move edit.*/
121
void queueMove(const QString &target, qreal di);
122
/*! \brief Queue a remove edit.*/
123
void queueRemove(const QString &target);
126
/*! \brief Adds or replaces specified element with the given SVG element.*/
127
bool setElement(QDomElement &element, const QString &parent, const QString &id, const qreal &index);
129
/*! \brief Processes an incoming new element edit.*/
130
bool processNew(const QDomElement &New);
131
/*! \brief Processes an incoming configure edit.*/
132
bool processConfigure(const QDomElement &configure);
133
/*! \brief Processes an incoming move edit.*/
134
bool processMove(const QDomElement &move);
135
/*! \brief Processes an incoming remove edit.*/
136
bool processRemove(const QDomElement &remove);
138
/*! \brief Removes specified edits from the queue.
139
* Removes queued edits that have the specified \a target and \a attribute.
140
* Sets the \a oldValue to the value at the time of last sent or received edit.
142
void removeFromQueue(const QString &target, const QString &attribute, QString &oldValue);
143
/*! \brief Removes specified edits from the queue.
144
* Removes queued edits that have the specified \a target and set a new parent.
145
* Sets the \a oldParent to the value at the time of last sent or received edit.
147
void removeFromQueue(const QString &target, QString &oldParent);
148
/*! \brief Removes specified edits from the queue.
149
* Removes queued edits that have the specified \a target and set content.
150
* Sets the \a oldContent to the value at the time of last sent or received edit.
152
void removeFromQueue(const QString &target, QDomNodeList &oldContent);
154
/*! \brief The whiteboard session being visualized.*/
156
/*! \brief The JID used in creation of IDs.*/
158
/*! \brief The highest index found in the whiteboard (with decimals cropped).*/
160
/*! \brief The highest primary part of and ID found in the whiteboard.*/
163
/*! \brief The list containing the queued edits.*/
166
/*! \brief A hash of element IDs and pointers to them.*/
167
QHash<QString, WbItem*> elements_;
169
/*! \brief A list of items whose transformation matrix has been changed and are waiting for the corresponding edit to be sent.*/
170
QList< QPointer<WbItem> > pendingTranformations_;