Fixed the last remaining magic numbers
[situare] / src / ui / userinfopanel.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6         Katri Kaikkonen - katri.kaikkonen@ixonos.com
7         Pekka Nissinen - pekka.nissinen@ixonos.com
8
9     Situare is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License
11     version 2 as published by the Free Software Foundation.
12
13     Situare is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with Situare; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
21     USA.
22 */
23
24 #include <QScrollArea>
25 #include <QVBoxLayout>
26
27 #include "panelcommon.h"
28 #include "userinfo.h"
29
30 #include "userinfopanel.h"
31
32 UserInfoPanel::UserInfoPanel(QWidget *parent)
33     : QWidget(parent)
34 {
35     qDebug() << __PRETTY_FUNCTION__;
36
37     QVBoxLayout *userInfoPanelLayout = new QVBoxLayout;
38     userInfoPanelLayout->setMargin(0);
39     userInfoPanelLayout->setSpacing(0);
40     userInfoPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
41                                             PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
42     setLayout(userInfoPanelLayout);
43
44     m_userInfo = new UserInfo(this);
45
46     QWidget *userInfoView = new QWidget(this);
47     QVBoxLayout *userInfoViewLayout = new QVBoxLayout(userInfoView);
48     userInfoViewLayout->setMargin(0);
49     userInfoViewLayout->setSpacing(0);
50     userInfoViewLayout->setStretch(0, 0);
51     userInfoViewLayout->setSizeConstraint(QLayout::SetFixedSize);
52     userInfoViewLayout->addWidget(m_userInfo);
53
54     QScrollArea *userInfoScroll = new QScrollArea();
55     userInfoScroll->setWidgetResizable(true);
56     userInfoScroll->setWidget(userInfoView);
57     userInfoScroll->setAlignment(Qt::AlignVCenter);
58     userInfoScroll->viewport()->setAutoFillBackground(false);
59     userInfoScroll->widget()->setAutoFillBackground(false);
60
61     userInfoPanelLayout->addWidget(userInfoScroll);
62
63     connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)),
64             this, SIGNAL(findUser(GeoCoordinate)));
65
66     connect(m_userInfo,SIGNAL(requestReverseGeo()),
67             this, SIGNAL(requestReverseGeo()));
68
69     connect(this, SIGNAL(reverseGeoReady(QString)),
70             m_userInfo, SIGNAL(reverseGeoReady(QString)));
71
72     connect(m_userInfo, SIGNAL(statusUpdate(QString,bool)),
73             this, SIGNAL(statusUpdate(QString,bool)));
74
75     connect(m_userInfo, SIGNAL(refreshUserData()),
76             this, SIGNAL(refreshUserData()));
77
78     connect(this, SIGNAL(clearUpdateLocationDialogData()),
79             m_userInfo, SLOT(clearUpdateLocationDialogData()));
80
81     connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
82              this, SIGNAL(notificateUpdateFailing(QString, bool)));
83 }
84
85 void UserInfoPanel::userDataReceived(User *user)
86 {
87     qDebug() << __PRETTY_FUNCTION__;
88
89     if(user) {
90         m_userInfo->setUserName(user->name());
91         m_userInfo->setProfileImage(user->profileImage());
92         m_userInfo->setMessageText(user->note());
93         m_userInfo->setAddress(user->address());
94         m_userInfo->setTime(user->timestamp());
95         m_userInfo->setCoordinates(user->coordinates());
96     }
97 }