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
|
/*
Copyright (c) 2005 Olivier Goffart <ogoffart@ kde.org>
Kopete (c) 2005 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 KOPETE_UICONTACTADDEDNOTIFYDIALOG_H
#define KOPETE_UICONTACTADDEDNOTIFYDIALOG_H
#include <kdialogbase.h>
#include "kopete_export.h"
namespace KABC {
class Addressee;
}
namespace Kopete {
class Group;
class Account;
class MetaContact;
namespace UI {
/**
* @brief Dialog which is shown when a contact added you in the contactlist.
*
* This dialog asks the user to give authorization for the addition to the
* person who added the user and also asks the user if the contact who you've
* received the notification for should be added to the user's contact list
*
* example of usage
* @code
Kopete::UI::ContactAddedNotifyDialog *dialog =
new ContactAddedNotifyDialog(contactId, TQString(),account);
TQObject::connect(dialog,TQT_SIGNAL(applyClicked(const TQString&)),this,TQT_SLOT(contactAddedDialogApplied()));
TQObject::connect(dialog,TQT_SIGNAL(infoClicked(const TQString&)),this,TQT_SLOT(contactAddedDialogInfo()));
dialog->show();
* @endcode
*
* and in your contactAddedDialogApplied slot
* @code
const Kopete::UI::ContactAddedNotifyDialog *dialog =
dynamic_cast<const Kopete::UI::ContactAddedNotifyDialog *>(sender());
if(!dialog)
return;
if(dialog->authorized())
socket->authorize(contactId);
if(dialog->added())
dialog->addContact();
* @endcode
*
* Note that you can also use exec() but this is not recommended
*
* @author Olivier Goffart
* @since 0.11
*/
class KOPETE_EXPORT ContactAddedNotifyDialog : public KDialogBase
{
Q_OBJECT
TQ_OBJECT
public:
/**
* All widget in the dialog that may be hidden.
*/
enum HideWidget
{
InfoButton = 0x01, /**< the button which ask for more info about the contact */
AuthorizeCheckBox = 0x02, /**< the checkbox which ask for authorize the contact */
AddCheckBox = 0x04, /**< the checkbox which ask if the contact should be added */
AddGroupBox = 0x08 /**< all the widget about metacontact properties */
};
/**
* @brief Constructor
*
* The dialog is by default not modal, and will delete itself when closed
*
* @param contactId the contactId of the contact which just added the user
* @param contactNick the nickname of the contact if available.
* @param account is used to display the account icon and informaiton about the account
* @param hide a bitmask of HideWidget used to hide some widget. By default, everything is shown.
*
*/
ContactAddedNotifyDialog(const TQString& contactId, const TQString& contactNick=TQString(),
Kopete::Account *account=0L, uint hide=0x00);
/**
* @brief Destructor
*/
~ContactAddedNotifyDialog();
/**
* @brief return if the user has checked the "authorize" checkbox
* @return true if the authorize checkbox is checked, false otherwise
*/
bool authorized() const;
/**
* @brief return if the user has checked the "add" checkbox
* @return true if the add checkbox is checked, false otherwise
*/
bool added() const;
/**
* @brief return the display name the user has entered
*/
TQString displayName() const;
/**
* @brief return the group the user has selected
*
* If the user has entered a group which doesn't exist yet, it will be created now
*/
Group* group() const;
public slots:
/**
* @brief create a metacontact.
*
* This function only works if the add checkbox is checked, otherwise,
* it will return 0L.
*
* it uses the Account::addContact function to add the contact
*
* @return the new metacontact created, or 0L if the operation failed.
*/
MetaContact *addContact() const;
signals:
/**
* @brief the dialog has been applied
* @param contactId is the id of the contact passed in the constructor.
*/
void applyClicked(const TQString &contactId);
/**
* @brief the button "info" has been pressed
* If you haven't hidden the more info button, you should connect this
* signal to a slot which show a dialog with more info about the
* contact.
*
* hint: you can use sender() as parent of the new dialog
* @param contactId is the id of the contact passed in the constructor.
*/
void infoClicked(const TQString &contactId);
private slots:
void slotAddresseeSelected( const KABC::Addressee &);
void slotInfoClicked();
void slotFinished();
private:
struct Private;
Private *d;
};
} // namespace UI
} // namespace Kopete
#endif
|