Initial commit
[tietoopcom] / include / TocUi / tocuserinfowidget.h
1 /** \file TocUserInfoWidget.h
2  * \brief Declaration of TocUserInfoWidget class
3  * 
4  * Tieto Open Communicator - Client for the Telepathy communications framework.
5  * Copyright (c) 2010, Tieto Corporation
6  *
7  * All rights reserved.
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  *      Redistributions of source code must retain the above copyright notice,
12  *      this list of conditions and the following disclaimer.
13  *      Redistributions in binary form must reproduce the above copyright notice,
14  *      this list of conditions and the following disclaimer in the documentation
15  *      and/or other materials provided with the distribution.
16  *      Neither the name of the Tieto Corporation nor the names of its contributors 
17  *      may be used to endorse or promote products derived from this software without
18  *      specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  * 
30  */
31
32 #ifndef TOCUSERINFOWIDGET_H
33 #define TOCUSERINFOWIDGET_H
34
35 #include "defs.h"
36
37 #include <QWidget>
38
39
40 class Ui_TocUserInfoWidgetClass;
41 class IconProvider;
42 class TocContactListWidget;
43 class QListWidgetItem;
44
45 QT_BEGIN_NAMESPACE
46
47 /** \brief TocUserInfoWidget class
48  * 
49  */
50 class TocUserInfoWidget : public QWidget
51 {
52         Q_OBJECT
53
54 public:
55
56         /**
57          * Public Constructor
58          */
59         TocUserInfoWidget( QListWidgetItem * contactItem, TocContactListWidget * parent, Qt::WindowFlags flags = 0 );
60
61         /**
62          * Destructor
63          */
64         ~TocUserInfoWidget();
65
66 signals:
67         
68         /** \brief Emited when user commits the changes
69          * 
70          * This signal is emited when user finished editing or creating contacts data. 
71          * 
72          * @param contactItem Newly created item or edited item representing the contact 
73          */
74         void contactChanged(QListWidgetItem* contactItem);
75
76         /** \brief Emited when user confirms or discards the changes
77          * 
78          * This signal is emited when user clicked OK or Cancel button. 
79          */
80         void finished();
81
82 protected:
83
84         /** \brief Reimplemented from QWidget
85          * 
86          */
87         virtual void showEvent(QShowEvent* event);
88         
89 private slots:
90
91         /** \brief Used when user finishes editing contacts data
92          * 
93          * When user adds new contact this slot should create a new QListWidgetItem AND
94          * TocContact with the data provided, and emit it with contactChanged( QListWidgetItem* ) signal.
95          * If user edits contact's data it should save the data in an item AND it's
96          * TocContact provided and emit them with contactChanged( QListWidgetItem* ) signal.
97          */
98         void okClicked();
99         
100         /** \brief Used to react on changes to the Gender ComboBox
101          * 
102          * When user changes the combo box selection, this slot should change
103          * an icon (if no custom icon is set by the user).
104          * 
105          * @param index Current changed index
106          */
107         void onCurrentIndexChanged( int index );
108
109 private: // Members
110
111         Ui_TocUserInfoWidgetClass*      ui;                                     /// Ui definition header
112         QListWidgetItem*                        _pContactItem;                  /// Item given to the constructor
113         QString                                         _customPicturePath;             /// Contact's PictureUrl
114         QString                                         _newCustomPicturePath;  /// Contact's PictureUrl
115         int                                             _currentIndex;                  /// Previous index
116         IconProvider*                           _pIconProvider;                 /// Class that provides contact icons
117         TocContactListWidget*           _pContactList;                  /// Contact list for which the widget is displayed
118 };
119
120 QT_END_NAMESPACE
121
122 #endif // TOCUSERINFOWIDGET_H