1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2000-2013 Licq developers <licq-dev@googlegroups.com>
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef USERDLG_INFO_H
21 #define USERDLG_INFO_H
22 
23 #include <config.h>
24 
25 #include <QObject>
26 
27 #include <licq/icq/user.h>
28 
29 #include "userdlg.h"
30 
31 class QCheckBox;
32 class QComboBox;
33 class QGroupBox;
34 class QLabel;
35 class QPushButton;
36 class QTreeWidget;
37 class QTreeWidgetItem;
38 class QVBoxLayout;
39 
40 
41 namespace LicqQtGui
42 {
43 class InfoField;
44 class MLEdit;
45 class MLView;
46 class SkinnableLabel;
47 class SpecialSpinBox;
48 class TimeZoneEdit;
49 class UserDlg;
50 
51 namespace UserPages
52 {
53 
54 class Info : public QObject
55 {
56   Q_OBJECT
57 
58 public:
59   /**
60    * Constructor
61    *
62    * @param isOwner True if the user is a protocol owner
63    * @param protocolId Protocol to create info pages for
64    * @param parent User dialog that is parent
65    */
66   Info(bool isOwner, unsigned long protocolId, UserDlg* parent);
67 
68   /**
69    * Destructor
70    */
~Info()71   virtual ~Info() {}
72 
73   /**
74    * Load user data for pages
75    *
76    * @param user User to get data from
77    */
78   void load(const Licq::User* user);
79 
80   /**
81    * Save user data for pages
82    *
83    * @param user User to write data to
84    */
85   void apply(Licq::User* user);
86 
87   /**
88    * Save user data for pages
89    * Call this function without user locked
90    *
91    * @param userId User id
92    */
93   void apply2(const Licq::UserId& userId);
94 
95   /**
96    * User was updated
97    *
98    * @param user User locked for read access
99    * @param subSignal Sub signal telling what the change was
100    */
101   void userUpdated(const Licq::User* user, unsigned long subSignal);
102 
103   /**
104    * Retrieve info from server
105    *
106    * @param page to get info for
107    * @return Icq event tag for retrieve request
108    */
109   unsigned long retrieve(UserDlg::UserPage page);
110 
111   /**
112    * Send info to server
113    * Only called if dialog is for owner
114    *
115    * @param page to send info for
116    * @return Icq event tag for send request
117    */
118   unsigned long send(UserDlg::UserPage page);
119 
120 private slots:
121   /**
122    * User alias field has been changed
123    */
124   void aliasChanged();
125 
126   /**
127    * Open dialog to edit interest, organization or background
128    *
129    * @param selected Item to edit
130    */
131   void editCategory(QTreeWidgetItem* selected);
132 
133   /**
134    * Set interest, organization or background after editing dialog has finished
135    *
136    * @param cat Category to update
137    * @param category New category map
138    */
139   void setCategory(Licq::UserCat cat, const Licq::UserCategoryMap& category);
140 
141   /**
142    * Add/update phone book entry after editing dialog has finished
143    *
144    * @param pbe Data for entry
145    * @param nEntry Position in list to update
146    */
147   void phoneBookUpdated(struct Licq::PhoneBookEntry& pbe, int nEntry);
148 
149   /**
150    * Open dialog to edit phone entry
151    *
152    * @param selected Phone entry to edit
153    */
154   void editPhoneEntry(QTreeWidgetItem* selected);
155 
156   /**
157    * Set active phone
158    *
159    * @param index Position in list to make active
160    */
161   void changeActivePhone(int index);
162 
163   /**
164    * Remove entry from phone book
165    */
166   void clearPhone();
167 
168   /**
169    * Add entry to phone book
170    */
171   void addPhone();
172 
173   /**
174    * Browse for a file to use as owner picture
175    */
176   void browsePicture();
177 
178   /**
179    * Clear owner picture
180    */
181   void clearPicture();
182 
183 private:
184   /**
185    * Setup the general page.
186    *
187    * @param parent Parent dialog
188    * @return a widget with the general info
189    */
190   QWidget* createPageGeneral(QWidget* parent);
191 
192   /**
193    * Load user data for general page
194    *
195    * @param user User to get data from
196    */
197   void loadPageGeneral(const Licq::User* user);
198 
199   /**
200    * Save user data for general page
201    *
202    * @param user User to write data to
203    */
204   void savePageGeneral(Licq::User* user);
205 
206   /**
207    * Setup the more page
208    *
209    * @param parent Parent dialog
210    * @return A widget with the more info
211    */
212   QWidget* createPageMore(QWidget* parent);
213 
214   /**
215    * Load user data for more page
216    *
217    * @param user User to get data from
218    */
219   void loadPageMore(const Licq::User* user);
220 
221   /**
222    * Save user data for more page
223    *
224    * @param user User to write data to
225    */
226   void savePageMore(Licq::User* user);
227 
228   /**
229    * Setup the more2 page
230    *
231    * @param parent Parent dialog
232    * @return A widget with the more2 info
233    */
234   QWidget* createPageMore2(QWidget* parent);
235 
236   /**
237    * Load user data for more2 page
238    *
239    * @param user User to get data from
240    */
241   void loadPageMore2(const Licq::IcqUser* user);
242 
243   /**
244    * Save user data for more2 page
245    *
246    * @param user User to write data to
247    */
248   void savePageMore2(Licq::IcqUser* user);
249 
250   /**
251    * Split interest, organization or background string for presentation
252    *
253    * @param parent Parent widget item to add items to
254    * @param descr Description string to split
255    * @return 0 on success or -1 on failure
256    */
257   int splitCategory(QTreeWidgetItem* parent, const char* descr);
258 
259   /**
260    * Present interest, organization or background data
261    *
262    * @param cat Category to update
263    * @param category New category map
264    */
265   void updateMore2Info(Licq::UserCat cat, const Licq::UserCategoryMap& category);
266 
267   /**
268    * Setup the work page.
269    *
270    * @param parent Parent dialog
271    * @return a widget with the work info
272    */
273   QWidget* createPageWork(QWidget* parent);
274 
275   /**
276    * Load user data for work page
277    *
278    * @param user User to get data from
279    */
280   void loadPageWork(const Licq::User* user);
281 
282   /**
283    * Save user data for work page
284    *
285    * @param user User to write data to
286    */
287   void savePageWork(Licq::User* user);
288 
289   /**
290    * Setup the about page.
291    *
292    * @param parent Parent dialog
293    * @return a widget with the about info
294    */
295   QWidget* createPageAbout(QWidget* parent);
296 
297   /**
298    * Load user data for about page
299    *
300    * @param user User to get data from
301    */
302   void loadPageAbout(const Licq::User* user);
303 
304   /**
305    * Save user data for about page
306    *
307    * @param user User to write data to
308    */
309   void savePageAbout(Licq::User* user);
310 
311   /**
312    * Setup the phone book page.
313    *
314    * @param parent Parent dialog
315    * @return a widget with the phone book
316    */
317   QWidget* createPagePhoneBook(QWidget* parent);
318 
319   /**
320    * Load user data for phone book
321    *
322    * @param user User to get data from
323    */
324   void loadPagePhoneBook(const Licq::IcqUser* user);
325 
326   /**
327    * Save user data for phone book
328    *
329    * @param user User to write data to
330    */
331   void savePagePhoneBook(Licq::IcqUser* user);
332 
333   /**
334    * Update data in phone book widget
335    */
336   void updatePhoneBook();
337 
338   /**
339    * Setup the picture page.
340    *
341    * @param parent Parent dialog
342    * @return a widget with the picture
343    */
344   QWidget* createPagePicture(QWidget* parent);
345 
346   /**
347    * Load user data for picture page
348    *
349    * @param user User to get data from
350    */
351   void loadPagePicture(const Licq::User* user);
352 
353   /**
354    * Save user data for picture page
355    *
356    * @param user User to write data to
357    */
358   void savePagePicture(Licq::User* user);
359 
360   /**
361    * Setup the counters page.
362    *
363    * @param parent Parent dialog
364    * @return a widget with the last counters
365    */
366   QWidget* createPageCounters(QWidget* parent);
367 
368   /**
369    * Load user data for counters page
370    *
371    * @param user User to get data from
372    */
373   void loadPageCounters(const Licq::User* user);
374 
375   Licq::UserId myUserId;
376   QString myId;
377   unsigned long myPpid;
378   bool m_bOwner;
379 
380   // General info
381   QVBoxLayout* myPageGeneralLayout;
382   QGroupBox* myGeneralBox;
383   InfoField* nfoFirstName;
384   InfoField* nfoLastName;
385   InfoField* nfoEmailPrimary;
386   InfoField* nfoEmailSecondary;
387   InfoField* nfoEmailOld;
388   InfoField* nfoAlias;
389   InfoField* nfoIp;
390   InfoField* nfoUin;
391   SkinnableLabel* myProtocolLabel;
392   InfoField* nfoOwner;
393   InfoField* nfoCity;
394   InfoField* nfoState;
395   InfoField* nfoZipCode;
396   InfoField* nfoAddress;
397   InfoField* nfoCountry;
398   InfoField* nfoFax;
399   InfoField* nfoCellular;
400   InfoField* nfoPhone;
401   InfoField* nfoStatus;
402   QCheckBox* chkKeepAliasOnUpdate;
403   QComboBox* cmbCountry;
404   QLabel* lblAuth;
405   QLabel* lblICQHomepage;
406   TimeZoneEdit* tznZone;
407   bool myAliasHasChanged;
408 
409   // More info
410   QVBoxLayout* myPageMoreLayout;
411   QGroupBox* myMoreBox;
412   InfoField* nfoAge;
413   InfoField* nfoBirthday;
414   InfoField* nfoLanguage[3];
415   InfoField* nfoHomepage;
416   InfoField* nfoGender;
417   QTreeWidget* lvHomepageCategory;
418   MLEdit* mleHomepageDesc;
419   QComboBox* cmbLanguage[3];
420   QComboBox* cmbGender;
421   SpecialSpinBox* spnBirthDay;
422   SpecialSpinBox* spnBirthMonth;
423   SpecialSpinBox* spnBirthYear;
424 
425   // More2 info
426   QVBoxLayout* myPageMore2Layout;
427   QGroupBox* myMore2Box;
428   QTreeWidget* lsvMore2;
429   QTreeWidgetItem* lviMore2Top[3];
430   Licq::UserCategoryMap myInterests;
431   Licq::UserCategoryMap myBackgrounds;
432   Licq::UserCategoryMap myOrganizations;
433 
434   // Work info
435   QVBoxLayout* myPageWorkLayout;
436   QGroupBox* myWorkBox;
437   InfoField* nfoCompanyName;
438   InfoField* nfoCompanyCity;
439   InfoField* nfoCompanyState;
440   InfoField* nfoCompanyAddress;
441   InfoField* nfoCompanyZip;
442   InfoField* nfoCompanyCountry;
443   InfoField* nfoCompanyPhone;
444   InfoField* nfoCompanyFax;
445   InfoField* nfoCompanyHomepage;
446   InfoField* nfoCompanyPosition;
447   InfoField* nfoCompanyDepartment;
448   InfoField* nfoCompanyOccupation;
449   QComboBox* cmbCompanyCountry;
450   QComboBox* cmbCompanyOccupation;
451 
452   // About
453   QVBoxLayout* myPageAboutLayout;
454   QGroupBox* myAboutBox;
455   QLabel* lblAbout;
456   MLView* mlvAbout;
457 
458   // PhoneBook
459   QVBoxLayout* myPagePhoneBookLayout;
460   QGroupBox* myPhoneBookBox;
461   QTreeWidget* lsvPhoneBook;
462   QComboBox* cmbActive;
463   InfoField* nfoActive;
464   QPushButton* myPhoneAddButton;
465   QPushButton* myPhoneClearButton;
466   Licq::IcqPhoneBookVector myIcqPhoneBook;
467 
468   // Picture
469   QVBoxLayout* myPagePictureLayout;
470   QGroupBox* myPictureBox;
471   QPushButton* myPictureBrowseButton;
472   QPushButton* myPictureClearButton;
473   QLabel* lblPicture;
474   QString m_sFilename;
475 
476   // Last Counters
477   QVBoxLayout* myPageCountersLayout;
478   QGroupBox* myCountersBox;
479   InfoField* nfoLastOnline;
480   InfoField* nfoLastSent;
481   InfoField* nfoLastRecv;
482   InfoField* nfoLastCheckedAR;
483   InfoField* nfoOnlineSince;
484   InfoField* nfoRegDate;
485 };
486 
487 } // namespace UserPages
488 } // namespace LicqQtGui
489 
490 #endif
491