summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/contactlist/kopetemetacontactlvi.h
blob: c2c646fd873b8ae434b54c2835ca13bac599f8c4 (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
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
    kopetemetacontactlvi.h - Kopete Meta Contact TDEListViewItem

    Copyright (c) 2004      by Richard Smith          <kde@metafoo.co.uk>
    Copyright (c) 2002-2003 by Olivier Goffart        <ogoffart @ kde.org>
    Copyright (c) 2002-2003 by Martijn Klingens       <klingens@kde.org>
    Copyright (c) 2002      by Duncan Mac-Vicar P     <duncan@kde.org>

    Kopete    (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.org>

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

#ifndef __kopetemetacontactlvi_h__
#define __kopetemetacontactlvi_h__

#include "kopetelistviewitem.h"

#include <tqobject.h>
#include <tqpixmap.h>
#include <tqptrdict.h>

#include <tdelistview.h>

class TQVariant;

class TDEAction;
class TDEListAction;

namespace Kopete
{
class Account;
class MetaContact;
class Contact;
class Group;
class MessageEvent;
}

class AddContactPage;
class KopeteGroupViewItem;


/**
 * @author Martijn Klingens <klingens@kde.org>
 */
class KopeteMetaContactLVI : public Kopete::UI::ListView::Item
{
	TQ_OBJECT
  

public:
	KopeteMetaContactLVI( Kopete::MetaContact *contact, KopeteGroupViewItem *parent );
	KopeteMetaContactLVI( Kopete::MetaContact *contact, TQListViewItem *parent );
	KopeteMetaContactLVI( Kopete::MetaContact *contact, TQListView *parent );
	~KopeteMetaContactLVI();

	/**
	 * metacontact this visual item represents
	 */
	Kopete::MetaContact *metaContact() const
	{ return m_metaContact; };

	/**
	 * true if the item is at top level and not under a group
	 */
	bool isTopLevel() const;

	/**
	 * parent when top-level
	 */
	TQListView *parentView() const { return m_parentView; };

	/**
	 * parent when not top-level
	 */
	KopeteGroupViewItem *parentGroup() const { return m_parentGroup; };

	/**
	 * call this when the item has been moved to a different group
	 */
	void movedToDifferentGroup();
	void rename( const TQString& name );
	void startRename( int );

	Kopete::Group *group();

	/**
	 * Returns the Kopete::Contact of the small little icon at the point p
	 * @param p must be in the list view item's coordinate system.
	 * Returns a null pointer if p is not on a small icon.
	 * (This is used for e.g. the context-menu of a contact when
	 * right-clicking an icon, or the tooltips)
	 */
	Kopete::Contact *contactForPoint( const TQPoint &p ) const;

	/**
	 * Returns the TQRect small little icon used for the Kopete::Contact.
	 * The behavior is undefined if @param c doesn't point to a valid
	 * Kopete::Contact for this list view item.
	 * The returned TQRect is using the list view item's coordinate
	 * system and should probably be transformed into the list view's
	 * coordinates before being of any practical use.
	 * Note that the returned Rect is always vertically stretched to fill
	 * the full list view item's height, only the width is relative to
	 * the actual icon width.
	 */
	TQRect contactRect( const Kopete::Contact *c ) const;

	bool isGrouped() const;

	/**
	 * reimplemented from TDEListViewItem to take into account our alternate text storage
	 */
	virtual TQString text( int column ) const;
	virtual void setText( int column, const TQString &text );

public slots:
	/**
	 * Call the meta contact's execute as I don't want to expose m_contact
	 * directly.
	 */
	void execute() const;

	void catchEvent( Kopete::MessageEvent * );

	void updateVisibility();

private slots:
	void slotUpdateMetaContact();
	void slotContactStatusChanged( Kopete::Contact * );
	void slotContactPropertyChanged( Kopete::Contact *, const TQString &, const TQVariant &, const TQVariant & );
	void slotContactAdded( Kopete::Contact * );
	void slotContactRemoved( Kopete::Contact * );

	void slotDisplayNameChanged();
	void slotPhotoChanged();

	void slotAddToNewGroup();
	void slotIdleStateChanged( Kopete::Contact * =0L);

	void slotConfigChanged();

	void slotEventDone( Kopete::MessageEvent* );
	void slotBlink();

	void updateContactIcons();

protected:
	void okRename(int col);
	void cancelRename(int col);

private:
	void initLVI();
	void setDisplayMode( int mode, int iconMode );
	void setMetaContactToolTipSourceForComponent( Kopete::UI::ListView::Component *comp );
	TQString key( int column, bool ascending ) const;
	void updateContactIcon( Kopete::Contact * );
	Kopete::UI::ListView::ContactComponent *contactComponent( const Kopete::Contact *c ) const;

	Kopete::MetaContact *m_metaContact;
	KopeteGroupViewItem *m_parentGroup;
	TQListView *m_parentView;
	bool m_isTopLevel;

	int m_pixelWide;

	Kopete::OnlineStatus m_oldStatus;
	TQPixmap m_oldStatusIcon;
	TQPixmap m_originalBlinkIcon;

	TQTimer *mBlinkTimer;

	TQPtrDict<Kopete::Account> m_addContactActions;

	bool mIsBlinkIcon;
	int m_blinkLeft;

	class Private;
	Private *d;
};

#endif