Minor cosmetic and other kind of changes to UserInfoPanel & FriendListPanel classes
[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 "userinfopanel.h"
25
26 #include "userinfo.h"
27 #include "panelcommon.h"
28
29 UserInfoPanel::UserInfoPanel(QWidget *parent)
30     : QWidget(parent)
31 {
32     qDebug() << __PRETTY_FUNCTION__;
33
34     QVBoxLayout *userInfoPanelLayout = new QVBoxLayout;
35     userInfoPanelLayout->setMargin(0);
36     userInfoPanelLayout->setSpacing(0);
37     userInfoPanelLayout->setContentsMargins(USERPANEL_MARGIN_LEFT, 0, USERPANEL_MARGIN_RIGHT, 0);
38     setLayout(userInfoPanelLayout);
39
40     m_userInfo = new UserInfo(this);
41
42     QWidget *userInfoView = new QWidget(this);
43     QVBoxLayout *userInfoViewLayout = new QVBoxLayout(userInfoView);
44     userInfoViewLayout->setMargin(0);
45     userInfoViewLayout->setSpacing(0);
46     userInfoViewLayout->setStretch(0, 0);
47     userInfoViewLayout->setSizeConstraint(QLayout::SetFixedSize);
48     userInfoViewLayout->addWidget(m_userInfo);
49
50     QScrollArea *userInfoScroll = new QScrollArea();
51     userInfoScroll->setWidgetResizable(true);
52     userInfoScroll->setWidget(userInfoView);
53     userInfoScroll->setAlignment(Qt::AlignVCenter);
54     userInfoScroll->viewport()->setAutoFillBackground(false);
55     userInfoScroll->widget()->setAutoFillBackground(false);
56
57     userInfoPanelLayout->addWidget(userInfoScroll);
58
59     connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)),
60             this, SIGNAL(findUser(GeoCoordinate)));
61
62     connect(m_userInfo,SIGNAL(requestReverseGeo()),
63             this, SIGNAL(requestReverseGeo()));
64
65     connect(this, SIGNAL(reverseGeoReady(QString)),
66             m_userInfo, SIGNAL(reverseGeoReady(QString)));
67
68     connect(m_userInfo, SIGNAL(statusUpdate(QString,bool)),
69             this, SIGNAL(statusUpdate(QString,bool)));
70
71     connect(m_userInfo, SIGNAL(refreshUserData()),
72             this, SIGNAL(refreshUserData()));
73
74     connect(this, SIGNAL(clearUpdateLocationDialogData()),
75             m_userInfo, SLOT(clearUpdateLocationDialogData()));
76
77     connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
78              this, SIGNAL(notificateUpdateFailing(QString, bool)));
79 }
80
81 void UserInfoPanel::userDataReceived(User *user)
82 {
83     qDebug() << __PRETTY_FUNCTION__;
84
85     if(user) {
86         m_userInfo->setUserName(user->name());
87         m_userInfo->setProfileImage(user->profileImage());
88         m_userInfo->setMessageText(user->note());
89         m_userInfo->setAddress(user->address());
90         m_userInfo->setTime(user->timestamp());
91         m_userInfo->setCoordinates(user->coordinates());
92     }
93 }