~ubuntu-branches/ubuntu/vivid/psi/vivid

« back to all changes in this revision

Viewing changes to src/whiteboarding/wbitem.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * wbitem.h - the item classes for the SVG WB
 
3
 * Copyright (C) 2006  Joonas Govenius
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef WBITEM_H
 
22
#define WBITEM_H
 
23
 
 
24
#include <QGraphicsSvgItem>
 
25
#include <QGraphicsScene>
 
26
#include <QGraphicsSceneMouseEvent>
 
27
#include <QMenu>
 
28
#include "iconaction.h"
 
29
#include "../sxe/sxesession.h"
 
30
 
 
31
class WbScene;
 
32
class WbWidget;
 
33
 
 
34
/*! \brief The context menu for WbItems
 
35
 *  This menu pops up when as the context menu for WbItems and displays
 
36
 *  \sa WbItem
 
37
 */
 
38
class WbItemMenu : public QMenu {
 
39
        Q_OBJECT
 
40
public:
 
41
        /*! \brief Constructor
 
42
         *  Constructs a new empty menu.
 
43
         */
 
44
        WbItemMenu(QWidget* parent);
 
45
        /*! \brief Destructor
 
46
         *  Deletes all the actiongroups and their actions.
 
47
         */
 
48
        ~WbItemMenu();
 
49
        /*! \brief Add actiongroup to the menu.*/
 
50
        void addActionGroup(QActionGroup*);
 
51
 
 
52
private slots:
 
53
        /*! \brief Destruct self.*/
 
54
        void destructSelf();
 
55
 
 
56
private:
 
57
        /*! \brief The actiongroups that the menu shows.*/
 
58
        QList<QActionGroup*> groups_;
 
59
};
 
60
 
 
61
class WbItem : public QGraphicsSvgItem {
 
62
        Q_OBJECT
 
63
public:
 
64
        /*! \brief Constructor
 
65
         *  Constructs a new whiteboard item that visualized \a node.
 
66
         */
 
67
        WbItem(SxeSession* session, QSvgRenderer* renderer, QDomElement node, WbScene* scene, WbWidget* widget);
 
68
        /*! \brief Destructor
 
69
         *  Makes sure that the item gets deleted from the underlying <svg/> document
 
70
         */
 
71
    ~WbItem();
 
72
 
 
73
    /*! \brief Returns the xml:id of the node.*/
 
74
    QString id();
 
75
    /*! \brief Returns the underlying node.*/
 
76
    QDomNode node();
 
77
 
 
78
    /*! \brief Regenerates the SVG transformation matrix.*/
 
79
    void regenerateTransform();
 
80
 
 
81
    /*! \brief Adds the item to the scene.
 
82
        Generates an 'id' attribute for the node if none exists. */
 
83
    void addToScene();
 
84
    /*! \brief Removes the item from the scene. */
 
85
    void removeFromScene();
 
86
 
 
87
    /*! \brief Resets the position of the item according to the SVG and clears any QGraphicsItem transformations.*/
 
88
    void resetPos();
 
89
 
 
90
    /*! \brief Returns a QTransform based on \a string provided in the SVG 'transform' attribute format.*/
 
91
    static QMatrix parseSvgTransform(QString string);
 
92
    /*! \brief Returns a QString in the SVG 'transform' attribute format based on \a matrix.*/
 
93
    static QString toSvgTransform(const QMatrix &matrix);
 
94
 
 
95
protected:
 
96
     /*! \brief Constructs and popsup the default context menu.*/
 
97
     virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
 
98
     /*! \brief Implements the default item interaction behaviour.
 
99
     *  The action depends on the mode of widget_;
 
100
      */
 
101
     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
 
102
     /*! \brief Implements the default item interaction behaviour.
 
103
      *  The action depends on the mode of widget_;
 
104
      */
 
105
     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
 
106
 
 
107
private:
 
108
     /*! \brief Construct a context menu with the default items.*/
 
109
     WbItemMenu* constructContextMenu();
 
110
     /*! \brief Return the center of the item in item coordinates.*/
 
111
     QPointF center();
 
112
 
 
113
    // The session that the item belongs to
 
114
    SxeSession* session_;
 
115
    // The WbScene that the item belongs to
 
116
    WbScene* scene_;
 
117
    // The WbWidget that shows the item
 
118
    WbWidget* widget_;
 
119
    // The node SVG node that's being visualized
 
120
    QDomElement node_;
 
121
 
 
122
};
 
123
 
 
124
#endif