~ubuntu-branches/ubuntu/karmic/psi/karmic

« back to all changes in this revision

Viewing changes to src/wbdlg.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
 * wbdlg.h - dialog for whiteboarding
 
3
 * Copyright (C) 2006  Joonas Govenius
 
4
 *
 
5
 * Originally developed from:
 
6
 * wbdlg.h - dialog for handling chats
 
7
 * Copyright (C) 2001, 2002  Justin Karneges
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License
 
11
 * as published by the Free Software Foundation; either version 2
 
12
 * of the License, or (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
22
 *
 
23
 */
 
24
 
 
25
#ifndef WBDLG_H
 
26
#define WBDLG_H
 
27
 
 
28
#include <QToolBar>
 
29
#include <QLabel>
 
30
#include <QLineEdit>
 
31
#include <QContextMenuEvent>
 
32
#include <QShowEvent>
 
33
#include <QKeyEvent>
 
34
#include <QResizeEvent>
 
35
#include <QCloseEvent>
 
36
#include <QInputDialog>
 
37
// #include <QMessageBoxEx>
 
38
 
 
39
#include "advwidget.h"
 
40
#include "im.h"
 
41
#include "common.h"
 
42
#include "wbwidget.h"
 
43
#include "iconlabel.h"
 
44
#include "psiaccount.h"
 
45
#include "psioptions.h"
 
46
 
 
47
class AccountLabel;
 
48
 
 
49
using namespace XMPP;
 
50
 
 
51
/*! \brief The dialog for a whiteboard session.
 
52
 *  Inherits Advanced Widget.
 
53
 *
 
54
 *  Takes in whiteboard elements for the session from the WbManager and passes
 
55
 *  them on to the WbWidget.
 
56
 *
 
57
 *  Contains the WbWidget and provides controls for setting the mode, stroke
 
58
 *  width and color of new items. TODO: Also provides controls for setting general
 
59
 *  properties of the session and a control for ending the session.
 
60
 * 
 
61
 *  \sa WbManager
 
62
 *  \sa WbWidget
 
63
 */
 
64
class WbDlg : public AdvancedWidget<QWidget>
 
65
{
 
66
        Q_OBJECT
 
67
 
 
68
        struct incomingElement {
 
69
                QDomElement wb;
 
70
                Jid sender;
 
71
        };
 
72
 
 
73
public:
 
74
        /*! \brief Constructor.
 
75
        *  Creates a new dialog for the specified jid and session.
 
76
        */
 
77
        WbDlg(const Jid &target, const QString &session, const Jid &ownJid, bool groupChat, PsiAccount *pa);
 
78
        /*! \brief Destructor.
 
79
        *  Emits sessionEnded()
 
80
        */
 
81
        ~WbDlg();
 
82
 
 
83
        /*! \brief Passes the incoming element to the WbWidget and remembers the last edit.*/
 
84
        void incomingWbElement(const QDomElement &, const Jid &sender);
 
85
        /*! \brief Returns true if the target is a groupchat.*/
 
86
        const bool groupChat() const;
 
87
        /*! \brief Returns the target contact's JID.*/
 
88
        const Jid target() const;
 
89
        /*! \brief Returns the session identifier.*/
 
90
        const QString session() const;
 
91
        /*! \brief Returns the JID used by the user in the session.*/
 
92
        const Jid ownJid() const;
 
93
        /*! \brief Returns whether further edits to the session are allowed.*/
 
94
        bool allowEdits() const;
 
95
        /*! \brief Sets whether further edits to the session are allowed.*/
 
96
        void setAllowEdits(bool);
 
97
        /*! \brief Asks whether dialog should be deleted if peer left the session.*/
 
98
        void peerLeftSession();
 
99
        /*! \brief Sets whether new wb elements should be queued.*/
 
100
        void setQueueing(bool);
 
101
        /*! \brief Erases the wb elements from the incoming queue up to and including the wb identified by the parameters.
 
102
         *  The parameters correspond to the attributes of the last-edit element.
 
103
         */
 
104
        void eraseQueueUntil(QString sender, QString hash);
 
105
        /*! \brief Return the snapshot that was created when queueing was set true.*/
 
106
        QList<WbItem*> snapshot() const;
 
107
        /*! \brief Sets whether configure edits are accepted regardless of version.
 
108
         *  Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
 
109
         *  Clears the whiteboard without emitting emitting wb elements when set true.
 
110
         */
 
111
        void setImporting(bool);
 
112
        /*! \brief Return a hash with information identifying the last processed wb element.*/
 
113
        QHash<QString, QString> lastWb() const;
 
114
        /*! \brief Sets the information identifying the last processed wb.*/
 
115
        void setLastWb(const QString &sender, const QString &hash);
 
116
 
 
117
public slots:
 
118
        /*! \brief Ends the session.
 
119
         *  Asks for confirmation if invoked by user's action.
 
120
         */
 
121
        void endSession();
 
122
        /*! \brief Removes indicators of new edits.*/
 
123
        void activated();
 
124
 
 
125
signals:
 
126
        /*! \brief Passes the new whiteboard elements from the widget.*/
 
127
        void newWbElement(const QDomElement &, const Jid &, bool groupChat);
 
128
        /*! \brief Signals that the session ended and the dialog is to be deleted.*/
 
129
        void sessionEnded(const QString &);
 
130
 
 
131
protected:
 
132
        // reimplemented
 
133
        /*! \brief Catches keyboard shortcuts.*/
 
134
        void keyPressEvent(QKeyEvent *);
 
135
        /*! \brief Sets the destruction times as specified by options.*/
 
136
        void closeEvent(QCloseEvent *);
 
137
        /*! \brief Saves the size of the dialog as default if so specified in options.*/
 
138
        void resizeEvent(QResizeEvent *);
 
139
        /*! \brief Removes the destruction timer.*/
 
140
        void showEvent(QShowEvent *);
 
141
        /*! \brief Invokes activated() if activated.*/
 
142
        void changeEvent(QEvent *e);
 
143
 
 
144
private slots:
 
145
        /*! \brief Popsup a dialog asking for a new viewBox for the whiteboard.*/
 
146
        void setGeometry();
 
147
        /*! \brief Popsup a color dialog and sets the selected color as the default stroke color for new items.*/
 
148
        void setStrokeColor();
 
149
        /*! \brief Popsup a color dialog and sets the selected color as the default fill color for new items.*/
 
150
        void setFillColor();
 
151
        /*! \brief Sets the stroke width for new elements based on the invoker.*/
 
152
        void setStrokeWidth(QAction *);
 
153
        /*! \brief Sets the WbWidget's mode based on the invoker.*/
 
154
        void setMode(QAction *);
 
155
        /*! \brief Emits the newWbElement() signal with the given element (usually from WbWidget).*/
 
156
        void doSend(const QDomElement &);
 
157
        /*! \brief Sets keep open false.*/
 
158
        void setKeepOpenFalse();
 
159
        /*! \brief Constructs the context menu.*/
 
160
        void buildMenu();
 
161
 
 
162
private:
 
163
        /*! \brief Pops up the context menu.*/
 
164
        void contextMenuEvent(QContextMenuEvent *);
 
165
        /*! \brief Set a timer for self destruction in the give n number of minutes.*/
 
166
        void setSelfDestruct(int);
 
167
        /*! \brief Update the caption to indicate the number of unseen whiteboard messages.*/
 
168
        void updateCaption();
 
169
 
 
170
        /*! \brief The target JID.*/
 
171
        Jid target_;
 
172
 
 
173
        /*! \brief The main widget.*/
 
174
        WbWidget *wbWidget_;
 
175
 
 
176
        /*! \brief The label showing own identity.*/
 
177
        AccountLabel *lb_ident_;
 
178
        /*! \brief The line edit showing target JID.*/
 
179
        QLineEdit *le_jid_;
 
180
        /*! \brief The context menu.*/
 
181
        QMenu *pm_settings_;
 
182
 
 
183
        /*! \brief The main toolbar.*/
 
184
        QToolBar *toolbar_;
 
185
        /*! \brief The action group for colors.*/
 
186
        QActionGroup *group_colors_;
 
187
        /*! \brief The action group for widths.*/
 
188
        QActionGroup *group_widths_;
 
189
        /*! \brief The action group for modes.*/
 
190
        QActionGroup *group_modes_;
 
191
        /*! \brief The menu for colors.*/
 
192
        QMenu *menu_colors_;
 
193
        /*! \brief The menu for widths.*/
 
194
        QMenu *menu_widths_;
 
195
        /*! \brief The menu for modes.*/
 
196
        QMenu *menu_modes_;
 
197
        QAction *act_color_, *act_fill_;
 
198
        IconAction *act_end_, *act_clear_, *act_geometry_, *act_widths_, *act_modes_;
 
199
        /*! \brief List of queued incoming wb elements.*/
 
200
        QList<incomingElement> queuedIncomingElements_;
 
201
        /*! \brief List of queued outgoing wb elements.*/
 
202
        QList<QDomElement> queuedOutgoingElements_;
 
203
        /*! \brief An SVG document representing the the whiteboard when queued was set true.*/
 
204
        QList<WbItem*> snapshot_;
 
205
        /*! \brief True if the target is a groupchat.*/
 
206
        bool groupChat_;
 
207
        /*! \brief The number of whiteboard messages since last activation.*/
 
208
        uint pending_;
 
209
        /*! \brief Boolean set true if a new edit was just received.*/
 
210
        bool keepOpen_;
 
211
        /*! \brief Boolean about whether further edits to the session are allowed.*/
 
212
        bool allowEdits_;
 
213
        /*! \brief If true, new wb elements are queued rather than processed.*/
 
214
        bool queueing_;
 
215
        /*! \brief A string that identifies the last edit that was processed.*/
 
216
        QHash<QString, QString> lastWb_;
 
217
 
 
218
        /*! \brief Pointer to the timer that will invoke destruction.*/
 
219
        QTimer *selfDestruct_;
 
220
};
 
221
 
 
222
#endif