MeetPeoplePanel.
<file>res/images/zoom_in.png</file>
<file>res/images/zoom_out.png</file>
<file>res/images/meet_people.png</file>
- <file>res/images/chat_button.png</file>
- <file>res/images/chat_button_s.png</file>
+ <file>res/images/tag.png</file>
+ <file>res/images/tag_btn_d.png</file>
+ <file>res/images/tag_btn_s.png</file>
+ <file>res/images/tag_btn.png</file>
</qresource>
</RCC>
connect(m_situareService, SIGNAL(updateWasSuccessful()),
m_ui, SIGNAL(clearUpdateLocationDialogData()));
+
+ connect(m_situareService, SIGNAL(interestingPeopleReceived(QList<User*>&)),
+ m_ui, SIGNAL(interestingPeopleReceived(QList<User*>&)));
}
void SituareEngine::startAutomaticUpdate()
qDebug() << __PRETTY_FUNCTION__;
}
-bool Database::addTag(int userId, const QString &tag)
+bool Database::addTag(qulonglong userId, const QString &tag)
{
qDebug() << __PRETTY_FUNCTION__;
bool ret = false;
- int tagId = -1;
+ qulonglong tagId = 0;
if (m_database.isOpen()) {
QSqlQuery tagQuery;
//Tag already exists
if (ret && tagQuery.next()) {
- tagId = tagQuery.value(0).toInt();
+ tagId = tagQuery.value(0).toULongLong();
}
else {
QSqlQuery tagInsertQuery;
.arg(tag));
if (ret) {
- tagId = tagInsertQuery.lastInsertId().toInt();
+ tagId = tagInsertQuery.lastInsertId().toULongLong();
}
}
- if (ret && (tagId != -1)) {
+ if (ret && (tagId != 0)) {
QSqlQuery userTagQuery;
ret = userTagQuery.exec(QString("INSERT INTO usertag VALUES('%1', '%2')")
return created;
}
-QStringList Database::getInterestingPeople(int userId)
+QStringList Database::getInterestingPeople(qulonglong userId)
{
qDebug() << __PRETTY_FUNCTION__;
return interestingPeopleId;
}
-QStringList Database::getTags(int userId)
+QStringList Database::getTags(qulonglong userId)
{
qDebug() << __PRETTY_FUNCTION__;
return m_database.open();
}
-
-void Database::test()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- bool ret = false;
-
- QSqlQuery tagQuery(QString("SELECT * from tag"));
- qWarning() << tagQuery.lastError().text();
- qWarning() << "id" << "name";
- while (tagQuery.next()) {
- qWarning() << tagQuery.value(0).toString() << tagQuery.value(1).toString();
- }
-
- QSqlQuery userTagQuery(QString("SELECT * from usertag"));
- qWarning() << userTagQuery.lastError().text();
- qWarning() << "id" << "userid" << "tagid";
- while (userTagQuery.next()) {
- qWarning() << userTagQuery.value(0).toString() <<
- userTagQuery.value(1).toString() << userTagQuery.value(2).toString();
- }
-}
Database(QObject *parent = 0);
~Database();
- bool addTag(int userId, const QString &tag);
- QStringList getTags(int userId);
- QStringList getInterestingPeople(int userId);
+ bool addTag(qulonglong userId, const QString &tag);
+ QStringList getTags(qulonglong userId);
+ QStringList getInterestingPeople(qulonglong userId);
bool openDatabase();
bool createTagTable();
bool createUserTagTable();
- void test();
private:
QSqlDatabase m_database;
qDebug() << __PRETTY_FUNCTION__;
QList<User *> interestingPeople;
- QStringList userIds = m_database->getInterestingPeople(m_user->userId());
+ QStringList userIds = m_database->getInterestingPeople(m_user->userId().toULongLong());
foreach (User *user, m_friendsList) {
if (userIds.contains(user->userId()))
}
tmpFriendsList.clear();
- //get user tags and set tags to the user
+ //REMOVE WHEN NOT NEEDED! get user tags and set tags to the user
m_user->setTags(getTags(m_user->userId()));
emit userDataChanged(m_user, m_friendsList);
addProfileImages(imageUrlList);
imageUrlList.clear();
+
+ //REMOVE WHEN NOT NEEDED! get interesting people
+ fetchPeopleWithSimilarInterest();
} else {
QVariant address = result.value("address");
if(!address.toString().isEmpty()) {
* @brief Updates tags to the Situare server
*
* CURRENTLY TAGS ARE UPDATED TO THE LOCAL DATABASE, NOT SITUARE SERVER
+ * @param userId user ID
* @param tags list of user's tags
*/
- void updateTags(const QStringList &tags);
+ void updateTags(const QString &userId, const QStringList &tags);
public slots:
{
m_meetPeoplePanel = new MeetPeoplePanel(this);
- connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
- m_meetPeoplePanel, SLOT(populateNearbyFriendListView(QList<User*>&)));
-
connect(this, SIGNAL(friendImageReady(User*)),
m_meetPeoplePanel, SLOT(friendImageReady(User*)));
+
+ connect(this, SIGNAL(interestingPeopleReceived(QList<User*>&)),
+ m_meetPeoplePanel, SLOT(populateInterestingPeopleListView(QList<User*>&)));
}
void MainWindow::buildOsmLicense()
void gpsTriggered(bool enabled);
/**
+ * @brief Signal when fetchPeopleWithSimilarInterest request is finished
+ *
+ * @param interestingPeople list of interesting people
+ */
+ void interestingPeopleReceived(QList<User *> &interestingPeople);
+
+ /**
* @brief Signal for friend location ready.
*
* @param friendsList
PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
listViewLayout->addWidget(m_nearbyFriendListView);
meetPeopleLayout->addLayout(listViewLayout);
-
- ImageButton *searchPeopleButton = new ImageButton(0, ":/res/images/search.png",
- ":/res/images/search_s.png");
- m_contextButtonList.append(searchPeopleButton);
-
- m_chatButton = new ImageButton(0, ":/res/images/chat_button", ":/res/images/chat_button_s.png");
- m_contextButtonList.append(m_chatButton);
-
- connect(m_nearbyFriendListView, SIGNAL(listItemSelectionChanged()),
- this, SLOT(setChatButtonDisabled()));
}
void MeetPeoplePanel::friendImageReady(User *user)
item->setAvatarImage(user->profileImage());
}
-void MeetPeoplePanel::populateNearbyFriendListView(QList<User *> &nearbyFriendList)
+void MeetPeoplePanel::populateInterestingPeopleListView(QList<User *> &interestingPeople)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__ ;
- foreach (User *nearbyFriend, nearbyFriendList) {
+ foreach (User *interestingPerson, interestingPeople) {
FriendListItem *item = new FriendListItem();
- item->setUserData(nearbyFriend);
- m_nearbyFriendListView->addListItem(nearbyFriend->userId(), item);
+ item->setUserData(interestingPerson);
+ m_nearbyFriendListView->addListItem(interestingPerson->userId(), item);
}
m_nearbyFriendListView->scrollToTop();
{
qDebug() << __PRETTY_FUNCTION__;
- m_chatButton->setDisabled(m_nearbyFriendListView->selectedItems().isEmpty());
+ //
}
void friendImageReady(User *user);
/**
- * @brief Populates nearby friends list view.
+ * @brief Populates interesting people list view.
*
- * @param nearbyFriendList list of nearby friends
+ * @param interestingPeople list of interesting people
*/
- void populateNearbyFriendListView(QList<User *> &nearbyFriendList);
+ void populateInterestingPeopleListView(QList<User *> &interestingPeople);
/**
* @brief Sets chat button disabled.
clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
clockLabel->setContentsMargins(0, 0, MARGIN, 0);
clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
+ QLabel *tagsLabel = new QLabel();
+ tagsLabel->setPixmap(QPixmap(":/res/images/tag.png"));
+ tagsLabel->setContentsMargins(0, 0, MARGIN, 0);
+ tagsLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
m_findButton = new ImageButton();
m_locationLabel->setWordWrap(true);
m_updatedLabel = new QLabel();
m_updatedLabel->setWordWrap(true);
+ m_tagsTextLabel = new QLabel();
+ m_tagsTextLabel->setWordWrap(true);
infoLayout->addRow(envelopeLabel, m_statusTextLabel);
infoLayout->addRow(compassLabel, m_locationLabel);
infoLayout->addRow(clockLabel, m_updatedLabel);
+ infoLayout->addRow(tagsLabel, m_tagsTextLabel);
verticalLayout->addWidget(m_findButton, 0, Qt::AlignHCenter);
verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
m_findButton->setButtonIcon(image);
}
+void UserInfo::setTags(const QStringList &tags)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QString tagsText;
+
+ foreach (QString tag, tags)
+ tagsText.append("[" + tag + "] ");
+
+ m_tagsTextLabel->setText(tagsText);
+}
+
void UserInfo::setTime(const QString &time)
{
qDebug() << __PRETTY_FUNCTION__;
void setProfileImage(const QPixmap &image);
/**
+ * @brief Sets the user tags
+ *
+ * @param tags list of tags
+ */
+ void setTags(const QStringList &tags);
+
+ /**
* @brief Sets the time of updated message
*
* @param time Reference to time when message was sent.
QLabel *m_locationLabel; ///< Location label
QLabel *m_nameLabel; ///< Name label
QLabel *m_statusTextLabel; ///< Status text label
+ QLabel *m_tagsTextLabel; ///< Tags text label
QLabel *m_updatedLabel; ///< Updated label
QPixmap m_backgroundBottomImage; ///< Bottom background image
":/res/images/send_position_s.png",
"", this);
+ ImageButton *tagButton = new ImageButton(":/res/images/tag_btn.png",
+ ":/res/images/tag_btn_s.png",
+ "/res/images/tag_btn_d", this);
+
+
m_contextButtonLayout->addWidget(updateFriendsButton);
m_contextButtonLayout->addWidget(updateStatusMessageButton);
+ m_contextButtonLayout->addWidget(tagButton);
connect(updateFriendsButton, SIGNAL(clicked()),
this, SIGNAL(refreshUserData()));
connect(updateStatusMessageButton, SIGNAL(clicked()),
m_userInfo, SLOT(messageUpdate()));
+
+ connect(tagButton, SIGNAL(clicked()),
+ this, SLOT(showTagDialog()));
+}
+
+void UserInfoPanel::showTagDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+
}
void UserInfoPanel::userDataReceived(User *user)
m_userInfo->setAddress(user->address());
m_userInfo->setTime(user->timestamp());
m_userInfo->setCoordinates(user->coordinates());
+ m_userInfo->setTags(user->tags());
}
}
*/
void clearUpdateLocationDialogData();
+private slots:
+ void showTagDialog();
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
User::User(const QString &address, const GeoCoordinate &coordinates, const QString &name,
const QString ¬e, const QUrl &imageUrl, const QString ×tamp, const bool &type,
const QString &userId, const QString &units, const double &value,
- const QStringList &tags = QStringList())
+ const QStringList &tags)
: m_address(address)
, m_coordinates(coordinates)
, m_name(name)
User(const QString &address, const GeoCoordinate &coordinates, const QString &name,
const QString ¬e, const QUrl &imageUrl, const QString ×tamp,
const bool &type, const QString &userId, const QString &units = 0,
- const double &value = 0);
+ const double &value = 0, const QStringList &tags = QStringList());
/**
* @brief Default constructor, initializes member data as NULL/0