summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/ui/kopeteview.h
blob: 86f3233f482495c6c2a771aef713af330d27b2b3 (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
    kopeteview.h - View Manager

    Copyright (c) 2003      by Jason Keirstead       <[email protected]>
    Copyright (c) 2004      by Matt Rogers           <[email protected]>
    Kopete    (c) 2002-2003 by the Kopete developers <[email protected]>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/


#ifndef KOPETEVIEW_H
#define KOPETEVIEW_H

#include "kopetemessage.h"
#include <tqvaluelist.h>
#include "kopete_export.h"

namespace Kopete
{
	class ViewPlugin;
}

/**
 * @author Jason Keirstead
 *
 * Abstract parent class for all types of views used for messaging.These view objects
 * are provided by a @ref Kopete::ViewPlugin
 *
 * @see Kopete::ViewPlugin
 */
class KOPETE_EXPORT KopeteView
{
	public:
		/**
		 * constructor
		 */
		KopeteView( Kopete::ChatSession *manager, Kopete::ViewPlugin *parent );
		virtual ~KopeteView();

		/**
		 * @brief Returns the message currently in the edit area
		 * @return The Kopete::Message object containing the message
		 */
		virtual Kopete::Message currentMessage() = 0;
		/**
		 * Set the message that the view is currently editing.
		 * @param newMessage The Kopete::Message object containing the message to be edited.
		 */
		virtual void setCurrentMessage( const Kopete::Message &newMessage ) = 0;

		/**
		 * @brief Get the message manager
		 * @return The Kopete::ChatSession that the view is in communication with.
		 */
		Kopete::ChatSession *msgManager() const;

		/**
		 * @brief add a message to the view
		 *
		 * The message gets added at the end of the view and is automatically
		 * displayed. Classes that inherit from KopeteView should make this a slot.
		 */
		virtual void appendMessage( Kopete::Message & ) = 0;

		/**
		 * @brief append multiple messages to the view
		 *
		 * This function does the same thing as the above function but
		 * can be reimplemented if it is faster to apend several messages
		 * in the same time.
		 *
		 * The default implementation just call @ref appendMessage() X times
		 */
		virtual void appendMessages( TQValueList<Kopete::Message> );

		/**
		 * @brief Raises the view above other windows
		 * @param activate change the focus to the window
		 */
		virtual void raise(bool activate = false) = 0;

		/**
		 * @brief Clear the buffer
		 */
		 virtual void clear();

		/**
		 * @brief Make the view visible
		 *
		 * Makes the view visible if it is currently hidden.
		 */
		virtual void makeVisible() = 0;

		/**
		 * @brief Close this view
		 */
		virtual bool closeView( bool force = false ) = 0;

		/**
		 * @brief Get the current visibility of the view
		 * @return Whether the view is visible or not.
		 */
		virtual bool isVisible() = 0;

		/**
		 * @brief Get the view widget
		 *
		 * Can be reimplemented to return this if derived object is a widget
		 */
		virtual TQWidget *mainWidget() = 0;

		/**
		 * @brief Inform the view the message was sent successfully
		 *
		 * This should be reimplemented as a TQ_SLOT in any derived objects
		 */
		virtual void messageSentSuccessfully() = 0;

		/**
		 * @brief Register a handler for the context menu
		 *
		 * Plugins should call this slot at view creation to register
		 * themselves as handlers for the context menu of this view. Plugins
		 * can attach to the viewCreated signal of KopeteMessageManagerFactory
		 * to know when views are created.
		 *
		 * A view does not need to implement this method unless they have context
		 * menus that can be extended
		 *
		 * @param target A target TQObject for the contextMenuEvent signal of the view
		 * @param slot A slot that matches the signature ( TQString&, TDEPopupMenu *)
		 */
		virtual void registerContextMenuHandler( TQObject *target, const char*slot ){ Q_UNUSED(target); Q_UNUSED(slot); };

		/**
		* @brief Register a handler for the tooltip
		*
		* Plugins should call this slot at view creation to register
		* themselves as handlers for the tooltip of this view. Plugins
		* can attach to the viewCreated signal of KopeteMessageManagerFactory
		* to know when views are created.
		*
		* A view does not need to impliment this method unless it has the ability
		* to show tooltips
		*
		* @param target A target TQObject for the contextMenuEvent signal of the view
		* @param slot A slot that matches the signature ( TQString&, TDEPopupMenu *)
		*/
		virtual void registerTooltipHandler( TQObject *target, const char*slot ){ Q_UNUSED(target); Q_UNUSED(slot); };

		/**
		 * @brief Returns the Kopete::ViewPlugin responsible for this view
		 *
		 * KopeteView objects are created by plugins. This returns a pointer to the plugin
		 * that created this view. You can use this to infer other information on this view
		 * and it's capabilities.
		 */
		Kopete::ViewPlugin *plugin();

	protected:
		/**
		 * a pointer to the Kopete::ChatSession given in the constructor
		 */
		Kopete::ChatSession *m_manager;
		Kopete::ViewPlugin *m_plugin;
};

#endif