~ubuntu-branches/ubuntu/natty/kadu/natty

« back to all changes in this revision

Viewing changes to externalmodules/nextinfo/extendedinformationwindow.cpp

  • Committer: Package Import Robot
  • Author(s): Kiszel Kristóf
  • Date: 2010-07-21 15:24:54 UTC
  • mfrom: (0.6.1) (0.5.1) (1.4.1) (22.1.2 maverick)
  • Revision ID: package-import@ubuntu.com-20100721152454-vttqle18lovfudni
Tags: 0.6.5.4.ds1-3ubuntu2
Remove libqt4-webkit-dev from build-depends and add
libqtwebkit-dev for qtwebkit transition

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                                                                         *
 
3
 *   This program is free software; you can redistribute it and/or modify  *
 
4
 *   it under the terms of the GNU General Public License as published by  *
 
5
 *   the Free Software Foundation; either version 3 of the License, or     *
 
6
 *   (at your option) any later version.                                   *
 
7
 *                                                                         *
 
8
 ***************************************************************************/
 
9
 
 
10
 
 
11
 
 
12
 
 
13
#include <QApplication>
 
14
#include <QComboBox>
 
15
#include <QFileDialog>
 
16
#include <QLabel>
 
17
#include <QLayout>
 
18
#include <QLineEdit>
 
19
#include <QList>
 
20
#include <QMessageBox>
 
21
#include <QPair>
 
22
#include <QPicture>
 
23
#include <QPushButton>
 
24
#include <QRegExp>
 
25
#include <QScrollArea>
 
26
#include <QTabWidget>
 
27
#include <QTextEdit>
 
28
#include <QToolTip>
 
29
#include <QVariant>
 
30
#include <QWhatsThis>
 
31
 
 
32
#include "icons_manager.h"
 
33
 
 
34
#include "extendedinformationwindow.h"
 
35
 
 
36
#include "defines_stringencoder.h"
 
37
NEXTINFO_ENCODESTRING
 
38
NEXTINFO_DECODESTRING
 
39
 
 
40
 
 
41
 
 
42
 
 
43
ExtendedInformationWindow::ExtendedInformationWindow( QWidget* parent, const char* name, Qt::WindowFlags f ) : QWidget( parent, name, f )
 
44
{
 
45
        // user is not set yet
 
46
        userset = false;
 
47
        // window layout
 
48
        ExtendedInformationWindowLayout = new QVBoxLayout( this, 5, 4, "ExtendedInformationWindowLayout" );
 
49
        // tabs
 
50
        tabs = new QTabWidget( this, "tabs" );
 
51
        // tab: extinfo
 
52
        extinfotab = new QWidget( tabs, "extinfotab" );
 
53
        layout_extinfotab = new QVBoxLayout( extinfotab, 5, 3, "layout_extinfotab" );
 
54
        extinfotab_separator1 = new QWidget( extinfotab, "extinfotab_separator1" );
 
55
                extinfotab_separator1->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
56
                extinfotab_separator1->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
57
                layout_extinfotab->addWidget( extinfotab_separator1 );
 
58
        label_info = new QLabel( extinfotab, "label_info" );
 
59
                label_info->setMargin( 0 );
 
60
                label_info->setMinimumWidth( NEXTINFO_LABELINFOMINIMUMWIDTH );
 
61
                layout_extinfotab->addWidget( label_info );
 
62
        extinfotab_separator2 = new QWidget( extinfotab, "extinfotab_separator2" );
 
63
                extinfotab_separator2->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
64
                extinfotab_separator2->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
65
                layout_extinfotab->addWidget( extinfotab_separator2 );
 
66
        layout_firstname = new QHBoxLayout( 0, 0, 6, "layout_firstname" );
 
67
                label_firstname = new QLabel( extinfotab, "label_firstname" );
 
68
                label_firstname->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::AlignVCenter | Qt::AlignVCenter );
 
69
                layout_firstname->addWidget( label_firstname );
 
70
                field_firstname = new QLineEdit( extinfotab, "field_firstname" );
 
71
                layout_firstname->addWidget( field_firstname );
 
72
                layout_extinfotab->addLayout( layout_firstname );
 
73
        layout_lastname = new QHBoxLayout( 0, 0, 6, "layout_lastname" );
 
74
                label_lastname = new QLabel( extinfotab, "label_lastname" );
 
75
                label_lastname->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
76
                layout_lastname->addWidget( label_lastname );
 
77
                field_lastname = new QLineEdit( extinfotab, "field_lastname" );
 
78
                layout_lastname->addWidget( field_lastname );
 
79
                layout_extinfotab->addLayout( layout_lastname );
 
80
        layout_nickname = new QHBoxLayout( 0, 0, 6, "layout_nickname" );
 
81
                label_nickname = new QLabel( extinfotab, "label_nickname" );
 
82
                label_nickname->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
83
                layout_nickname->addWidget( label_nickname );
 
84
                field_nickname = new QLineEdit( extinfotab, "field_nickname" );
 
85
                layout_nickname->addWidget( field_nickname );
 
86
                layout_extinfotab->addLayout( layout_nickname );
 
87
        layout_address = new QHBoxLayout( 0, 0, 6, "layout_address" );
 
88
                label_address = new QLabel( extinfotab, "label_address" );
 
89
                label_address->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
90
                layout_address->addWidget( label_address );
 
91
                field_address = new QLineEdit( extinfotab, "field_address" );
 
92
                layout_address->addWidget( field_address );
 
93
                layout_extinfotab->addLayout( layout_address );
 
94
        layout_city = new QHBoxLayout( 0, 0, 6, "layout_city" );
 
95
                label_city = new QLabel( extinfotab, "label_city" );
 
96
                label_city->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
97
                layout_city->addWidget( label_city );
 
98
                field_city = new QLineEdit( extinfotab, "field_city" );
 
99
                layout_city->addWidget( field_city );
 
100
                layout_extinfotab->addLayout( layout_city );
 
101
        extinfotab_separator3 = new QWidget( extinfotab, "extinfotab_separator3" );
 
102
                extinfotab_separator3->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
103
                extinfotab_separator3->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
104
                layout_extinfotab->addWidget( extinfotab_separator3 );
 
105
        layout_sex = new QHBoxLayout( 0, 0, 6, "layout_sex" );
 
106
                label_sex = new QLabel( extinfotab, "label_sex" );
 
107
                label_sex->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
108
                layout_sex->addWidget( label_sex );
 
109
                field_sex = new QComboBox( false, extinfotab, "field_sex" );
 
110
                field_sex->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
 
111
                layout_sex->addWidget( field_sex );
 
112
                layout_extinfotab->addLayout( layout_sex );
 
113
        extinfotab_separator4 = new QWidget( extinfotab, "extinfotab_separator4" );
 
114
                extinfotab_separator4->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
115
                extinfotab_separator4->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
116
                layout_extinfotab->addWidget( extinfotab_separator4 );
 
117
        layout_mobile = new QHBoxLayout( 0, 0, 6, "layout_mobile" );
 
118
                label_mobile = new QLabel( extinfotab, "label_mobile" );
 
119
                label_mobile->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
120
                layout_mobile->addWidget( label_mobile );
 
121
                field_mobile = new QLineEdit( extinfotab, "field_mobile" );
 
122
                layout_mobile->addWidget( field_mobile );
 
123
                layout_extinfotab->addLayout( layout_mobile );
 
124
        layout_phone2 = new QHBoxLayout( 0, 0, 6, "layout_phone2" );
 
125
                label_phone2 = new QLabel( extinfotab, "label_phone2" );
 
126
                label_phone2->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
127
                layout_phone2->addWidget( label_phone2 );
 
128
                field_phone2 = new QLineEdit( extinfotab, "field_phone2" );
 
129
                layout_phone2->addWidget( field_phone2 );
 
130
                layout_extinfotab->addLayout( layout_phone2 );
 
131
        extinfotab_separator5 = new QWidget( extinfotab, "extinfotab_separator5" );
 
132
                extinfotab_separator5->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
133
                extinfotab_separator5->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
134
                layout_extinfotab->addWidget( extinfotab_separator5 );
 
135
        layout_email = new QHBoxLayout( 0, 0, 6, "layout_email" );
 
136
                label_email = new QLabel( extinfotab, "label_email" );
 
137
                label_email->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
138
                layout_email->addWidget( label_email );
 
139
                field_email = new QLineEdit( extinfotab, "field_email" );
 
140
                layout_email->addWidget( field_email );
 
141
                layout_extinfotab->addLayout( layout_email );
 
142
        layout_email2 = new QHBoxLayout( 0, 0, 6, "layout_email2" );
 
143
                label_email2 = new QLabel( extinfotab, "label_email2" );
 
144
                label_email2->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
145
                layout_email2->addWidget( label_email2 );
 
146
                field_email2 = new QLineEdit( extinfotab, "field_email2" );
 
147
                layout_email2->addWidget( field_email2 );
 
148
                layout_extinfotab->addLayout( layout_email2 );
 
149
        layout_www = new QHBoxLayout( 0, 0, 6, "layout_www" );
 
150
                label_www = new QLabel( extinfotab, "label_www" );
 
151
                label_www->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
152
                layout_www->addWidget( label_www );
 
153
                field_www = new QLineEdit( extinfotab, "field_www" );
 
154
                layout_www->addWidget( field_www );
 
155
                layout_extinfotab->addLayout( layout_www );
 
156
        extinfotab_separator6 = new QWidget( extinfotab, "extinfotab_separator6" );
 
157
                extinfotab_separator6->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
158
                extinfotab_separator6->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
159
                layout_extinfotab->addWidget( extinfotab_separator6 );
 
160
        layout_gg = new QHBoxLayout( 0, 0, 6, "layout_gg" );
 
161
                label_gg = new QLabel( extinfotab, "label_gg" );
 
162
                label_gg->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
163
                layout_gg->addWidget( label_gg );
 
164
                field_gg = new QLineEdit( extinfotab, "field_gg" );
 
165
                layout_gg->addWidget( field_gg );
 
166
                layout_extinfotab->addLayout( layout_gg );
 
167
        layout_gg2 = new QHBoxLayout( 0, 0, 6, "layout_gg2" );
 
168
                label_gg2 = new QLabel( extinfotab, "label_gg2" );
 
169
                label_gg2->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
170
                layout_gg2->addWidget( label_gg2 );
 
171
                field_gg2 = new QLineEdit( extinfotab, "field_gg2" );
 
172
                layout_gg2->addWidget( field_gg2 );
 
173
                layout_extinfotab->addLayout( layout_gg2 );
 
174
        layout_irc = new QHBoxLayout( 0, 0, 6, "layout_irc" );
 
175
                label_irc = new QLabel( extinfotab, "label_irc" );
 
176
                label_irc->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
177
                layout_irc->addWidget( label_irc );
 
178
                field_irc = new QLineEdit( extinfotab, "field_irc" );
 
179
                layout_irc->addWidget( field_irc );
 
180
                layout_extinfotab->addLayout( layout_irc );
 
181
        layout_tlen = new QHBoxLayout( 0, 0, 6, "layout_tlen" );
 
182
                label_tlen = new QLabel( extinfotab, "label_tlen" );
 
183
                label_tlen->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
184
                layout_tlen->addWidget( label_tlen );
 
185
                field_tlen = new QLineEdit( extinfotab, "field_tlen" );
 
186
                layout_tlen->addWidget( field_tlen );
 
187
                layout_extinfotab->addLayout( layout_tlen );
 
188
        layout_wp = new QHBoxLayout( 0, 0, 6, "layout_wp" );
 
189
                label_wp = new QLabel( extinfotab, "label_wp" );
 
190
                label_wp->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
191
                layout_wp->addWidget( label_wp );
 
192
                field_wp = new QLineEdit( extinfotab, "field_wp" );
 
193
                layout_wp->addWidget( field_wp );
 
194
                layout_extinfotab->addLayout( layout_wp );
 
195
        layout_icq = new QHBoxLayout( 0, 0, 6, "layout_icq" );
 
196
                label_icq = new QLabel( extinfotab, "label_icq" );
 
197
                label_icq->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
198
                layout_icq->addWidget( label_icq );
 
199
                field_icq = new QLineEdit( extinfotab, "field_icq" );
 
200
                layout_icq->addWidget( field_icq );
 
201
                layout_extinfotab->addLayout( layout_icq );
 
202
        extinfotab_separator7 = new QWidget( extinfotab, "extinfotab_separator7" );
 
203
                extinfotab_separator7->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
204
                extinfotab_separator7->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
205
                layout_extinfotab->addWidget( extinfotab_separator7 );
 
206
        layout_birthday = new QHBoxLayout( 0, 0, 6, "layout_birthday" );
 
207
                label_birthday = new QLabel( extinfotab, "label_birthday" );
 
208
                label_birthday->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
209
                layout_birthday->addWidget( label_birthday );
 
210
                field_birthday = new QLineEdit( extinfotab, "field_birthday" );
 
211
                layout_birthday->addWidget( field_birthday );
 
212
                layout_extinfotab->addLayout( layout_birthday );
 
213
        layout_nameday = new QHBoxLayout( 0, 0, 6, "layout_nameday" );
 
214
                label_nameday = new QLabel( extinfotab, "label_nameday" );
 
215
                label_nameday->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
216
                layout_nameday->addWidget( label_nameday );
 
217
                field_nameday = new QLineEdit( extinfotab, "field_nameday" );
 
218
                layout_nameday->addWidget( field_nameday );
 
219
                layout_extinfotab->addLayout( layout_nameday );
 
220
        extinfotab_separator8 = new QWidget( extinfotab, "extinfotab_separator8" );
 
221
                extinfotab_separator8->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
222
                extinfotab_separator8->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
223
                layout_extinfotab->addWidget( extinfotab_separator8 );
 
224
        extinfotab_spacer = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
225
                layout_extinfotab->addItem( extinfotab_spacer );
 
226
        tabs->insertTab( extinfotab, QString("") );
 
227
        // tab: notes
 
228
        notestab = new QWidget( tabs, "notestab" );
 
229
        layout_notestab = new QVBoxLayout( notestab, 5, 3, "layout_notestab" );
 
230
        notestab_separator1 = new QWidget( notestab, "notestab_separator1" );
 
231
                notestab_separator1->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
232
                notestab_separator1->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
233
                layout_notestab->addWidget( notestab_separator1 );
 
234
        label_interests = new QLabel( notestab, "label_interests" );
 
235
                layout_notestab->addWidget( label_interests );
 
236
                field_interests = new QTextEdit( notestab, "interests" );
 
237
                field_interests->setMaximumSize( QSize( 32767, NEXTINFO_FIELDINTERESTSHEIGHT ) );
 
238
                field_interests->setTabChangesFocus( true );
 
239
                layout_notestab->addWidget( field_interests );
 
240
        notestab_separator2 = new QWidget( notestab, "notestab_separator2" );
 
241
                notestab_separator2->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
242
                notestab_separator2->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
243
                layout_notestab->addWidget( notestab_separator2 );
 
244
        label_notes = new QLabel( notestab, "label_notes" );
 
245
                layout_notestab->addWidget( label_notes );
 
246
                field_notes = new QTextEdit( notestab, "notes" );
 
247
                field_notes->setTabChangesFocus( true );
 
248
                layout_notestab->addWidget( field_notes );
 
249
        notestab_separator3 = new QWidget( notestab, "notestab_separator3" );
 
250
                notestab_separator3->setMinimumHeight( NEXTINFO_FIELDSEPARATORSHEIGHT );
 
251
                notestab_separator3->resize( 1, NEXTINFO_FIELDSEPARATORSHEIGHT );
 
252
                layout_notestab->addWidget( notestab_separator3 );
 
253
        tabs->insertTab( notestab, QString("") );
 
254
        // tab: photo
 
255
        phototab = new QWidget( tabs, "phototab" );
 
256
        layout_phototab = new QVBoxLayout( phototab, 5, 6, "layout_phototab" );
 
257
                photoscrollarea = new QScrollArea( phototab );
 
258
                photoscrollarea->setFrameStyle( QFrame::NoFrame );
 
259
                photoscrollarea->setLineWidth( 0 );
 
260
                photoscrollarea->setAlignment( Qt::AlignCenter );
 
261
                photoscrollarea->setAttribute( Qt::WA_NoSystemBackground, true );
 
262
                QWidget *photoscrollareaviewport = new QWidget( photoscrollarea );
 
263
                photoscrollareaviewport->setAttribute( Qt::WA_NoSystemBackground, true );
 
264
                photoscrollarea->setViewport( photoscrollareaviewport );
 
265
                photo = new QLabel( phototab, "photo" );
 
266
                photo->setAlignment( Qt::AlignCenter );
 
267
                photo->setAttribute( Qt::WA_NoSystemBackground, true );
 
268
                photoscrollarea->setWidget( photo );
 
269
                photo->setAutoFillBackground( false );  // must be after photoscrollarea->setWidget( photo );
 
270
                layout_phototab->addWidget( photoscrollarea );
 
271
        layout_photobuttons = new QHBoxLayout( 0, 0, 6, "layout_photobuttons" );
 
272
                photobuttons_spacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
 
273
                layout_photobuttons->addItem( photobuttons_spacer );
 
274
                photobuttons_select = new QPushButton( QIconSet( icons_manager->loadIcon( "ChooseSelectPathDialogButton" ) ), "photobuttons_select", phototab, "photobuttons_select" );
 
275
                connect( photobuttons_select, SIGNAL(clicked()), this, SLOT(photoSelect()) );
 
276
                layout_photobuttons->addWidget( photobuttons_select );
 
277
                photobuttons_clear = new QPushButton( QIconSet( icons_manager->loadIcon( "RemoveSelectPathDialogButton" ) ), "photobuttons_clear", phototab, "photobuttons_clear" );
 
278
                connect( photobuttons_clear, SIGNAL(clicked()), this, SLOT(photoClear()) );
 
279
                layout_photobuttons->addWidget( photobuttons_clear );
 
280
                layout_phototab->addLayout( layout_photobuttons );
 
281
        tabs->insertTab( phototab, QString("") );
 
282
        // insert tabs widget into the window's layout
 
283
        ExtendedInformationWindowLayout->addWidget( tabs );
 
284
        // bottom buttons
 
285
        bottombuttons = new QHBoxLayout( 0, 0, 6, "bottombuttons" );
 
286
        bottombuttons_spacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
 
287
                bottombuttons->addItem( bottombuttons_spacer );
 
288
        button_save = new QPushButton( QIconSet( icons_manager->loadIcon( "SavePersonalInfoButton" ) ), "button_save", this, "button_save" );
 
289
                connect( button_save, SIGNAL(clicked()), this, SLOT(saveUser()) );
 
290
                bottombuttons->addWidget( button_save );
 
291
        button_close = new QPushButton( QIconSet( icons_manager->loadIcon( "OkWindowButton" ) ), "button_close", this, "button_close" );
 
292
                connect( button_close, SIGNAL(clicked()), this, SLOT(close()) );
 
293
                bottombuttons->addWidget( button_close );
 
294
        // insert bottom buttons into the window's layout
 
295
        ExtendedInformationWindowLayout->addLayout( bottombuttons );
 
296
        // change captions
 
297
        languageChange();
 
298
        // resize window to the minimum size
 
299
        resize( minimumSizeHint() );
 
300
}
 
301
 
 
302
 
 
303
ExtendedInformationWindow::~ExtendedInformationWindow()
 
304
{
 
305
}
 
306
 
 
307
 
 
308
void ExtendedInformationWindow::languageChange()
 
309
{
 
310
        // tab: extinfo
 
311
        tabs->changeTab( extinfotab, qApp->translate( "@nextinfo", "Extended information" ) );
 
312
        // tab: extinfo: labels: set texts
 
313
        label_firstname->setText( qApp->translate( "@nextinfo", "First name"            ) + ":" );
 
314
        label_lastname->setText(  qApp->translate( "@nextinfo", "Last name"             ) + ":" );
 
315
        label_nickname->setText(  qApp->translate( "@nextinfo", "Nickname"              ) + ":" );
 
316
        label_address->setText(   qApp->translate( "@nextinfo", "Address"               ) + ":" );
 
317
        label_city->setText(      qApp->translate( "@nextinfo", "City"                  ) + ":" );
 
318
        label_sex->setText(       qApp->translate( "@nextinfo", "Sex"                   ) + ":" );
 
319
        label_mobile->setText(    qApp->translate( "@nextinfo", "Mobile phone"          ) + ":" );
 
320
        label_phone2->setText(    qApp->translate( "@nextinfo", "Alternative phone"     ) + ":" );
 
321
        label_email->setText(     qApp->translate( "@nextinfo", "e-mail"                ) + ":" );
 
322
        label_email2->setText(    qApp->translate( "@nextinfo", "Alternative e-mail"    ) + ":" );
 
323
        label_www->setText(       qApp->translate( "@nextinfo", "WWW"                   ) + ":" );
 
324
        label_gg->setText(        qApp->translate( "@nextinfo", "GG"                    ) + ":" );
 
325
        label_gg2->setText(       qApp->translate( "@nextinfo", "Alternative GG"        ) + ":" );
 
326
        label_irc->setText(       qApp->translate( "@nextinfo", "IRC"                   ) + ":" );
 
327
        label_tlen->setText(      qApp->translate( "@nextinfo", "Tlen"                  ) + ":" );
 
328
        label_wp->setText(        qApp->translate( "@nextinfo", "WP"                    ) + ":" );
 
329
        label_icq->setText(       qApp->translate( "@nextinfo", "ICQ"                   ) + ":" );
 
330
        label_birthday->setText(  qApp->translate( "@nextinfo", "Birthday (DD.MM.YYYY)" ) + ":" );
 
331
        label_nameday->setText(   qApp->translate( "@nextinfo", "Name-day (DD.MM)"      ) + ":" );
 
332
        // set sex combobox items
 
333
        field_sex->insertItem( ""                                      , 0 );
 
334
        field_sex->insertItem( qApp->translate( "@nextinfo", "female" ), 1 );
 
335
        field_sex->insertItem( qApp->translate( "@nextinfo", "male"   ), 2 );
 
336
        // tab: extinfo: labels: set new sizes
 
337
        label_firstname->adjustSize();
 
338
        label_lastname->adjustSize();
 
339
        label_nickname->adjustSize();
 
340
        label_address->adjustSize();
 
341
        label_city->adjustSize();
 
342
        label_sex->adjustSize();
 
343
        label_mobile->adjustSize();
 
344
        label_phone2->adjustSize();
 
345
        label_email->adjustSize();
 
346
        label_email2->adjustSize();
 
347
        label_www->adjustSize();
 
348
        label_gg->adjustSize();
 
349
        label_gg2->adjustSize();
 
350
        label_irc->adjustSize();
 
351
        label_tlen->adjustSize();
 
352
        label_wp->adjustSize();
 
353
        label_icq->adjustSize();
 
354
        label_birthday->adjustSize();
 
355
        label_nameday->adjustSize();
 
356
        // tab: extinfo: labels: get maximum width
 
357
        int labels_width = 1;  // px
 
358
        if( label_firstname->width() > labels_width ) { labels_width = label_firstname->width(); }
 
359
        if( label_lastname->width()  > labels_width ) { labels_width = label_lastname->width();  }
 
360
        if( label_nickname->width()  > labels_width ) { labels_width = label_nickname->width();  }
 
361
        if( label_address->width()   > labels_width ) { labels_width = label_address->width();   }
 
362
        if( label_city->width()      > labels_width ) { labels_width = label_city->width();      }
 
363
        if( label_sex->width()       > labels_width ) { labels_width = label_sex->width();       }
 
364
        if( label_mobile->width()    > labels_width ) { labels_width = label_mobile->width();    }
 
365
        if( label_phone2->width()    > labels_width ) { labels_width = label_phone2->width();    }
 
366
        if( label_email->width()     > labels_width ) { labels_width = label_email->width();     }
 
367
        if( label_email2->width()    > labels_width ) { labels_width = label_email2->width();    }
 
368
        if( label_www->width()       > labels_width ) { labels_width = label_www->width();       }
 
369
        if( label_gg->width()        > labels_width ) { labels_width = label_gg->width();        }
 
370
        if( label_gg2->width()       > labels_width ) { labels_width = label_gg2->width();       }
 
371
        if( label_irc->width()       > labels_width ) { labels_width = label_irc->width();       }
 
372
        if( label_tlen->width()      > labels_width ) { labels_width = label_tlen->width();      }
 
373
        if( label_wp->width()        > labels_width ) { labels_width = label_wp->width();        }
 
374
        if( label_icq->width()       > labels_width ) { labels_width = label_icq->width();       }
 
375
        if( label_birthday->width()  > labels_width ) { labels_width = label_birthday->width();  }
 
376
        if( label_nameday->width()   > labels_width ) { labels_width = label_nameday->width();   }
 
377
        // tab: extinfo: labels: set width of each label to the maximum width
 
378
        label_firstname->setMinimumWidth( labels_width );
 
379
        label_lastname->setMinimumWidth(  labels_width );
 
380
        label_nickname->setMinimumWidth(  labels_width );
 
381
        label_address->setMinimumWidth(   labels_width );
 
382
        label_city->setMinimumWidth(      labels_width );
 
383
        label_sex->setMinimumWidth(       labels_width );
 
384
        label_mobile->setMinimumWidth(    labels_width );
 
385
        label_phone2->setMinimumWidth(    labels_width );
 
386
        label_email->setMinimumWidth(     labels_width );
 
387
        label_email2->setMinimumWidth(    labels_width );
 
388
        label_www->setMinimumWidth(       labels_width );
 
389
        label_gg->setMinimumWidth(        labels_width );
 
390
        label_gg2->setMinimumWidth(       labels_width );
 
391
        label_irc->setMinimumWidth(       labels_width );
 
392
        label_tlen->setMinimumWidth(      labels_width );
 
393
        label_wp->setMinimumWidth(        labels_width );
 
394
        label_icq->setMinimumWidth(       labels_width );
 
395
        label_birthday->setMinimumWidth(  labels_width );
 
396
        label_nameday->setMinimumWidth(   labels_width );
 
397
        // tab: extinfo: labels: update labels' geometry
 
398
        label_firstname->updateGeometry();
 
399
        label_lastname->updateGeometry();
 
400
        label_nickname->updateGeometry();
 
401
        label_address->updateGeometry();
 
402
        label_city->updateGeometry();
 
403
        label_sex->updateGeometry();
 
404
        label_mobile->updateGeometry();
 
405
        label_phone2->updateGeometry();
 
406
        label_email->updateGeometry();
 
407
        label_email2->updateGeometry();
 
408
        label_www->updateGeometry();
 
409
        label_gg->updateGeometry();
 
410
        label_gg2->updateGeometry();
 
411
        label_irc->updateGeometry();
 
412
        label_tlen->updateGeometry();
 
413
        label_wp->updateGeometry();
 
414
        label_icq->updateGeometry();
 
415
        label_birthday->updateGeometry();
 
416
        label_nameday->updateGeometry();
 
417
        // tab: notes
 
418
        tabs->changeTab( notestab, qApp->translate( "@nextinfo", "Notes" ) );
 
419
        label_interests->setText( qApp->translate( "@nextinfo", "Interests" ) + ":" );
 
420
        label_notes->setText(     qApp->translate( "@nextinfo", "Notes"     ) + ":" );
 
421
        // tab: photo
 
422
        tabs->changeTab( phototab, qApp->translate( "@nextinfo", "Photo" ) );
 
423
        photobuttons_select->setText( qApp->translate( "@nextinfo", "Select ..." ) );
 
424
        photobuttons_clear->setText(  qApp->translate( "@nextinfo", "Clear"      ) );
 
425
        // bottom buttons
 
426
        button_save->setText(  qApp->translate( "@nextinfo", "Save"  ) );
 
427
        button_close->setText( qApp->translate( "@nextinfo", "Close" ) );
 
428
        // reload user information
 
429
        if( userset )
 
430
                setUser( user );
 
431
}
 
432
 
 
433
 
 
434
void ExtendedInformationWindow::setUser( UserListElement usertoset )
 
435
{
 
436
        // set the user
 
437
        user = usertoset;
 
438
        userset = true;
 
439
        // update window caption
 
440
        this->setCaption( qApp->translate( "@nextinfo", "Kadu - extended information for %%" ).replace( "%%", user.altNick() ) );
 
441
        // update info label
 
442
        label_info->setText( qApp->translate( "@nextinfo", "Extended information for %%" ).replace( "%%", QString("<b>")+user.altNick()+QString("</b>") ) );
 
443
        // load simple information
 
444
        field_firstname->setText( user.firstName() );
 
445
        field_lastname->setText(  user.lastName()  );
 
446
        field_nickname->setText(  user.nickName()  );
 
447
        field_mobile->setText(    user.mobile()    );
 
448
        field_email->setText(     user.email()     );
 
449
        // load "Gadu" protocol's UIN
 
450
        field_gg->setText(        user.ID( "Gadu" ) );
 
451
        // load extended information
 
452
        field_address->setText(                 user.data( "nextinfo_address"   ).toString()   );
 
453
        field_city->setText(                    user.data( "nextinfo_city"      ).toString()   );
 
454
        field_sex->setCurrentItem(              user.data( "nextinfo_sex"       ).toInt()      );
 
455
        field_phone2->setText(                  user.data( "nextinfo_phone2"    ).toString()   );
 
456
        field_email2->setText(                  user.data( "nextinfo_email2"    ).toString()   );
 
457
        field_www->setText(                     user.data( "nextinfo_www"       ).toString()   );
 
458
        field_gg2->setText(                     user.data( "nextinfo_gg2"       ).toString()   );
 
459
        field_irc->setText(                     user.data( "nextinfo_irc"       ).toString()   );
 
460
        field_tlen->setText(                    user.data( "nextinfo_tlen"      ).toString()   );
 
461
        field_wp->setText(                      user.data( "nextinfo_wp"        ).toString()   );
 
462
        field_icq->setText(                     user.data( "nextinfo_icq"       ).toString()   );
 
463
        field_birthday->setText(                user.data( "nextinfo_birthday"  ).toString()   );
 
464
        field_nameday->setText(                 user.data( "nextinfo_nameday"   ).toString()   );
 
465
        field_interests->setText( decodeString( user.data( "nextinfo_interests" ).toString() ) );
 
466
        field_notes->setText(     decodeString( user.data( "nextinfo_notes"     ).toString() ) );
 
467
        // load photo
 
468
        photopath = user.data( "nextinfo_photo" ).toString().stripWhiteSpace();
 
469
        if( photopath.isNull() )
 
470
                photopath = "";
 
471
        QPixmap photopixmap;
 
472
        if( ( ! photopath.isEmpty() ) && photopixmap.load( photopath ) )
 
473
        {
 
474
                photo->clear();
 
475
                photo->setPixmap( photopixmap );
 
476
        }
 
477
        else
 
478
        {
 
479
                photopath = "";
 
480
                photo->setText( qApp->translate( "@nextinfo", "No photo" ) );
 
481
        }
 
482
        photo->adjustSize();
 
483
}
 
484
 
 
485
 
 
486
void ExtendedInformationWindow::saveUser()
 
487
{
 
488
        // check birthday format
 
489
        if( field_birthday->text().find( QRegExp( NEXTINFO_REGEXPBIRTHDAY ) ) == -1 )  // if bad format
 
490
                field_birthday->setText( "" );
 
491
        // check name-day format
 
492
        if( field_nameday->text().find( QRegExp( NEXTINFO_REGEXPNAMEDAY ) ) == -1 )  // if bad format
 
493
                field_nameday->setText( "" );
 
494
        // save simple information
 
495
        user.setData( "FirstName" , QVariant( field_firstname->text() ), true, false );
 
496
        user.setData( "LastName"  , QVariant( field_lastname->text()  ), true, false );
 
497
        user.setData( "NickName"  , QVariant( field_nickname->text()  ), true, false );
 
498
        user.setData( "Mobile"    , QVariant( field_mobile->text()    ), true, false );
 
499
        user.setData( "Email"     , QVariant( field_email->text()     ), true, false );
 
500
        // save "Gadu" protocol's UIN
 
501
        field_gg->setText( field_gg->text().stripWhiteSpace() );
 
502
        QString id = QString::number( 0 );
 
503
        if( ! field_gg->text().isEmpty() )
 
504
                id = field_gg->text();
 
505
        if( user.usesProtocol( "Gadu" ) )  // there was an UIN so far?
 
506
        {
 
507
                if( user.ID( "Gadu" ) != id )  // uin was changed
 
508
                {
 
509
                        user.deleteProtocol( "Gadu" );
 
510
                        if( id.toUInt() != 0 )  // but it might be deleted
 
511
                                user.addProtocol( "Gadu" , id );
 
512
                }
 
513
        }
 
514
        else  // there was no UIN so far
 
515
                if( id.toUInt() != 0 )  // if it was filled, then we add new protocol
 
516
                        user.addProtocol( "Gadu", id );
 
517
        // save extended information
 
518
        user.setData( "nextinfo_address"  , QVariant(               field_address->text()     ), true, false );
 
519
        user.setData( "nextinfo_city"     , QVariant(               field_city->text()        ), true, false );
 
520
        user.setData( "nextinfo_sex"      , QVariant(               field_sex->currentItem()  ), true, false );
 
521
        user.setData( "nextinfo_phone2"   , QVariant(               field_phone2->text()      ), true, false );
 
522
        user.setData( "nextinfo_email2"   , QVariant(               field_email2->text()      ), true, false );
 
523
        user.setData( "nextinfo_www"      , QVariant(               field_www->text()         ), true, false );
 
524
        user.setData( "nextinfo_gg2"      , QVariant(               field_gg2->text()         ), true, false );
 
525
        user.setData( "nextinfo_irc"      , QVariant(               field_irc->text()         ), true, false );
 
526
        user.setData( "nextinfo_tlen"     , QVariant(               field_tlen->text()        ), true, false );
 
527
        user.setData( "nextinfo_wp"       , QVariant(               field_wp->text()          ), true, false );
 
528
        user.setData( "nextinfo_icq"      , QVariant(               field_icq->text()         ), true, false );
 
529
        user.setData( "nextinfo_birthday" , QVariant(               field_birthday->text()    ), true, false );
 
530
        user.setData( "nextinfo_nameday"  , QVariant(               field_nameday->text()     ), true, false );
 
531
        user.setData( "nextinfo_interests", QVariant( encodeString( field_interests->text() ) ), true, false );
 
532
        user.setData( "nextinfo_notes"    , QVariant( encodeString( field_notes->text()     ) ), true, false );
 
533
        // save photo
 
534
        user.setData( "nextinfo_photo"    , QVariant(               photopath                 ), true, true  );  // last change (!)
 
535
}
 
536
 
 
537
 
 
538
void ExtendedInformationWindow::photoSelect()
 
539
{
 
540
        // start path for QFileDialog
 
541
        QString startpath = photopath;
 
542
        int lastslashposition = startpath.findRev( "/" );
 
543
        if( lastslashposition != -1 )
 
544
        {
 
545
                startpath = startpath.left( lastslashposition + 1 );  // only the directory path
 
546
        }
 
547
        else
 
548
        {
 
549
                startpath = "/home/";
 
550
        }
 
551
        // QFileDialog
 
552
        QString newphotopath = QFileDialog::getOpenFileName( startpath, QString::null, this, 0, qApp->translate( "@nextinfo", "Select a photo" ) );
 
553
        if( newphotopath.isNull() )
 
554
                newphotopath = "";
 
555
        QPixmap photopixmap;
 
556
        if( ( ! newphotopath.isEmpty() ) && photopixmap.load( newphotopath ) )
 
557
        {
 
558
                photopath = newphotopath;
 
559
                photo->clear();
 
560
                photo->setPixmap( photopixmap );
 
561
                photo->adjustSize();
 
562
        }
 
563
        else
 
564
        {
 
565
                if( ! newphotopath.isEmpty() )  // a file was selected, but it is not an displayable image
 
566
                {
 
567
                        // display invalid image warning
 
568
                        QMessageBox *messagebox = new QMessageBox(
 
569
                                        qApp->translate( "@nextinfo", "Kadu - extended information" ),
 
570
                                        qApp->translate( "@nextinfo", "Selected file is not an image." ),
 
571
                                        QMessageBox::Warning,
 
572
                                        QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton,
 
573
                                        this
 
574
                                );
 
575
                        messagebox->show();
 
576
                }
 
577
        }
 
578
}
 
579
 
 
580
 
 
581
void ExtendedInformationWindow::photoClear()
 
582
{
 
583
        photopath = "";
 
584
        photo->clear();
 
585
        photo->setText( qApp->translate( "@nextinfo", "No photo" ) );
 
586
        photo->adjustSize();
 
587
}