~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/wbwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * wbwidget.h - a widget for processing and showing whiteboard
 
3
 *              messages.
 
4
 * Copyright (C) 2006  Joonas Govenius
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (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 library; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 *
 
20
 */
 
21
 
 
22
#ifndef WBWIDGET_H
 
23
#define WBWIDGET_H
 
24
#include "wbscene.h"
 
25
#include <QWidget>
 
26
#include <QGraphicsView>
 
27
#include <QTimer>
 
28
#include <QTime>
 
29
#include <QFileDialog>
 
30
 
 
31
/*! \brief The whiteboard widget.
 
32
 *  Visualizes the whiteboard scene and provides different modes for editing and adding new elements.
 
33
 *  Local edits to existing elements are handled by the elements themselves
 
34
 *  as mouse events are passed on to them but new items are temporarily
 
35
 *  added to the scene while being drawn and only when finished, added to
 
36
 *  the WbScene.
 
37
 *
 
38
 *  \sa WbScene
 
39
 *  \sa WbDlg
 
40
 */
 
41
class WbWidget : public QGraphicsView
 
42
{
 
43
        Q_OBJECT
 
44
public:
 
45
        /*! \brief Mode
 
46
         *  Indicates the mode the widget is in.
 
47
         */
 
48
        enum Mode { Select, Translate, Rotate, Scale, Scroll, Erase, DrawPath, DrawLine, DrawRectangle, DrawEllipse, DrawCircle, DrawPolyline, DrawText, DrawImage };
 
49
 
 
50
        /*! \brief Constructor
 
51
         *  Constructs a new widget with \a session and \a size with parent \a parent.
 
52
         *  \a ownJid is the Jid that should be used in item IDs created by this widget.
 
53
         */
 
54
        WbWidget(const QString &session, const QString &ownJid, const QSize &size, QWidget *parent=0);
 
55
        /*! \brief Processes an incoming whiteboard element.*/
 
56
        bool processWb(const QDomElement &wb);
 
57
        /*! \brief Returns the session this widget is visualizing.*/
 
58
        QString session();
 
59
        /*! \brief Returns the JID used by the user in the session.*/
 
60
        const QString & ownJid() const;
 
61
        /*! \brief Returns the mode this widget is in.*/
 
62
        Mode mode();
 
63
        /*! \brief Sets the mode which determines how to react to user interaction.*/
 
64
        void setMode(Mode mode);
 
65
        /*! \brief Sets the size of the whiteboard.*/
 
66
        void setSize(const QSize &s);
 
67
        /*! \brief Sets the stroke color of new items.*/
 
68
        void setStrokeColor(const QColor &color);
 
69
        /*! \brief Sets the stroke color of new items.*/
 
70
        void setFillColor(const QColor &color);
 
71
        /*! \brief Sets the stroke width of new items.*/
 
72
        void setStrokeWidth(int width);
 
73
        /*! \brief Sets whether configure edits are accepted regardless of version.
 
74
         *  Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
 
75
         */
 
76
        void setImporting(bool);
 
77
 
 
78
        /*! \brief Returns the size set by setSize().*/
 
79
        virtual QSize sizeHint() const;
 
80
 
 
81
        /*! \brief A pointer to the WbScene.*/
 
82
        WbScene* scene;
 
83
 
 
84
signals:
 
85
        /*! \brief Emitted when a new whiteboard element is ready to be sent.*/
 
86
        void newWb(const QDomElement &wb);
 
87
 
 
88
public slots:
 
89
        /*! \brief Clears the whiteboard.
 
90
         *  If \a sendEdits is true, the remove edits are sent.
 
91
         */
 
92
        void clear(const bool &sendEdits = true);
 
93
 
 
94
protected:
 
95
        /*! \brief Makes sure that area outside the whiteboard is not shown by zooming if necessary.*/
 
96
        virtual void resizeEvent(QResizeEvent * event);
 
97
        /*! \brief Passes events to items as specified by the mode.*/
 
98
        virtual void mousePressEvent(QMouseEvent * event);
 
99
        /*! \brief Passes events to items as specified by the mode.*/
 
100
        virtual void mouseMoveEvent(QMouseEvent * event);
 
101
        /*! \brief Passes events to items as specified by the mode.*/
 
102
        virtual void mouseReleaseEvent(QMouseEvent * event);
 
103
 
 
104
private:
 
105
        /*! \brief The user interaction mode the widget is in.*/
 
106
        Mode mode_;
 
107
        /*! \brief The stroke color used for new items.*/
 
108
        QColor strokeColor_;
 
109
        /*! \brief The fill color used for new items.*/
 
110
        QColor fillColor_;
 
111
        /*! \brief The stroke width used for new items.*/
 
112
        int strokeWidth_;
 
113
 
 
114
        /*! \brief Pointer to a new item that is being drawn.*/
 
115
        WbItem* newWbItem_;
 
116
        /*! \brief Boolean used to force adding a vertex to a path being drawn.*/
 
117
        bool addVertex_;
 
118
        /*! \brief Pointer to a control point to be used for the next vertex.*/
 
119
        QPointF* controlPoint_;
 
120
        /*! \brief Timer used for forcing the addition of a new vertex.*/
 
121
        QTimer* adding_;
 
122
 
 
123
private slots:
 
124
        /*! \brief Slot used for forcing the addition of a new vertex.*/
 
125
        void addVertex();
 
126
};
 
127
 
 
128
#endif