Re-factored the source to use the new coordinate 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
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include "userinfopanel.h"
23
24 #include "userinfo.h"
25 #include "panelcommon.h"
26
27 UserInfoPanel::UserInfoPanel(QWidget *parent)
28     : SidePanel(parent)
29 {
30     qDebug() << __PRETTY_FUNCTION__;
31
32     setType(SidePanel::UserPanel);
33
34     m_userInfo = new UserInfo(this);
35
36     QWidget *userInfoView = new QWidget(this);
37     QVBoxLayout *userViewLayout = new QVBoxLayout(userInfoView);
38     userViewLayout->setMargin(0);
39     userViewLayout->setSpacing(0);
40     userViewLayout->setStretch(0, 0);
41     userViewLayout->setSizeConstraint(QLayout::SetFixedSize);
42     userViewLayout->addWidget(m_userInfo);
43
44     QScrollArea *userInfoScroll = new QScrollArea(this);
45     userInfoScroll->setWidgetResizable(true);
46     userInfoScroll->setWidget(userInfoView);
47     userInfoScroll->setAlignment(Qt::AlignVCenter);
48     userInfoScroll->viewport()->setAutoFillBackground(false);
49     userInfoScroll->widget()->setAutoFillBackground(false);
50
51     m_panelVBox->addWidget(userInfoScroll);
52     m_panelVBox->setContentsMargins(USERPANEL_MARGIN_LEFT, 0, USERPANEL_MARGIN_RIGHT, 0);
53
54     connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)),
55             this, SIGNAL(findUser(GeoCoordinate)));
56
57     connect(m_userInfo,SIGNAL(requestReverseGeo()),
58             this, SIGNAL(requestReverseGeo()));
59
60     connect(this, SIGNAL(reverseGeoReady(QString)),
61             m_userInfo, SIGNAL(reverseGeoReady(QString)));
62
63     connect(m_userInfo, SIGNAL(statusUpdate(QString,bool)),
64             this, SIGNAL(statusUpdate(QString,bool)));
65
66     connect(m_userInfo, SIGNAL(refreshUserData()),
67             this, SIGNAL(refreshUserData()));
68
69     connect(this, SIGNAL(clearUpdateLocationDialogData()),
70             m_userInfo, SLOT(clearUpdateLocationDialogData()));
71
72     connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
73              this, SIGNAL(notificateUpdateFailing(QString, bool)));
74 }
75
76 void UserInfoPanel::userDataReceived(User *user)
77 {
78     qDebug() << __PRETTY_FUNCTION__;
79
80     if(user) {
81         m_userInfo->setUserName(user->name());
82         m_userInfo->setProfileImage(user->profileImage());
83         m_userInfo->setMessageText(user->note());
84         m_userInfo->setAddress(user->address());
85         m_userInfo->setTime(user->timestamp());
86         m_userInfo->setCoordinates(user->coordinates());
87     }
88 }