2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Katri Kaikkonen - katri.kaikkonen@ixonos.com
7 Pekka Nissinen - pekka.nissinen@ixonos.com
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.
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.
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,
24 #include <QScrollArea>
25 #include <QVBoxLayout>
27 #include "imagebutton.h"
28 #include "panelcommon.h"
31 #include "userinfopanel.h"
33 UserInfoPanel::UserInfoPanel(QWidget *parent)
36 qDebug() << __PRETTY_FUNCTION__;
38 QVBoxLayout *userInfoPanelLayout = new QVBoxLayout;
39 userInfoPanelLayout->setMargin(0);
40 userInfoPanelLayout->setSpacing(0);
41 userInfoPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
42 PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
43 setLayout(userInfoPanelLayout);
45 m_userInfo = new UserInfo(this);
47 QWidget *userInfoView = new QWidget(this);
48 QVBoxLayout *userInfoViewLayout = new QVBoxLayout(userInfoView);
49 userInfoViewLayout->setMargin(0);
50 userInfoViewLayout->setSpacing(0);
51 userInfoViewLayout->setStretch(0, 0);
52 userInfoViewLayout->setSizeConstraint(QLayout::SetFixedSize);
53 userInfoViewLayout->addWidget(m_userInfo);
55 QScrollArea *userInfoScroll = new QScrollArea();
56 userInfoScroll->setWidgetResizable(true);
57 userInfoScroll->setWidget(userInfoView);
58 userInfoScroll->setAlignment(Qt::AlignVCenter);
59 userInfoScroll->viewport()->setAutoFillBackground(false);
60 userInfoScroll->widget()->setAutoFillBackground(false);
62 userInfoPanelLayout->addWidget(userInfoScroll);
64 connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)),
65 this, SIGNAL(findUser(GeoCoordinate)));
67 connect(m_userInfo,SIGNAL(requestReverseGeo()),
68 this, SIGNAL(requestReverseGeo()));
70 connect(m_userInfo, SIGNAL(statusUpdate(QString, bool)),
71 this, SIGNAL(statusUpdate(QString, bool)));
73 connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
74 this, SIGNAL(notificateUpdateFailing(QString, bool)));
76 connect(this, SIGNAL(reverseGeoReady(QString)),
77 m_userInfo, SIGNAL(reverseGeoReady(QString)));
79 connect(this, SIGNAL(clearUpdateLocationDialogData()),
80 m_userInfo, SLOT(clearUpdateLocationDialogData()));
82 connect(this, SIGNAL(collapse()),
83 m_userInfo, SLOT(collapse()));
85 connect(m_userInfo, SIGNAL(itemSelectionChanged(bool)),
86 this, SLOT(onUserInfoItemSelected(bool)));
88 connect(m_userInfo, SIGNAL(addTags(QStringList)),
89 this, SIGNAL(addTags(QStringList)));
91 connect(m_userInfo, SIGNAL(removeTags(QStringList)),
92 this, SIGNAL(removeTags(QStringList)));
94 ImageButton *updateFriendsButton = new ImageButton(":/res/images/refresh.png",
95 ":/res/images/refresh_s.png",
97 ImageButton *updateStatusMessageButton = new ImageButton(":/res/images/send_position.png",
98 ":/res/images/send_position_s.png",
101 ImageButton *tagButton = new ImageButton(":/res/images/tag_btn.png",
102 ":/res/images/tag_btn_s.png",
103 ":/res/images/tag_btn_d.png", this);
105 m_genericButtonsLayout->addWidget(updateFriendsButton);
106 m_genericButtonsLayout->addWidget(updateStatusMessageButton);
108 m_itemButtonsLayout->addWidget(tagButton);
110 connect(updateFriendsButton, SIGNAL(clicked()),
111 this, SIGNAL(refreshUserData()));
113 connect(updateStatusMessageButton, SIGNAL(clicked()),
114 m_userInfo, SLOT(messageUpdate()));
116 connect(tagButton, SIGNAL(clicked()),
117 this, SLOT(showTagsDialog()));
121 void UserInfoPanel::populatePopularTags(QHash<QString, QString> &popularTags)
123 qDebug() << __PRETTY_FUNCTION__;
125 m_userInfo->setPopularTags(popularTags);
128 void UserInfoPanel::setImage(const QString &id, const QPixmap &image)
130 qDebug() << __PRETTY_FUNCTION__;
132 m_userInfo->setProfileImage(image);
135 void UserInfoPanel::showUserInfo(bool logged)
137 qDebug() << __PRETTY_FUNCTION__;
139 m_userInfo->setVisible(logged);
142 void UserInfoPanel::showTagsDialog()
144 qDebug() << __PRETTY_FUNCTION__;
146 m_userInfo->showTagsDialog();
148 emit requestPopularTags();
151 void UserInfoPanel::userDataReceived(User *user)
153 qDebug() << __PRETTY_FUNCTION__;
156 m_userInfo->setUserName(user->name());
157 m_userInfo->setProfileImage(user->profileImage());
158 m_userInfo->setMessageText(user->note());
159 m_userInfo->setAddress(user->address());
160 m_userInfo->setTime(user->timestamp());
161 m_userInfo->setCoordinates(user->coordinates());
162 m_userInfo->setTags(user->tags());