connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
+ connect(m_ui, SIGNAL(requestPopularTags()),
+ m_situareService, SLOT(fetchPopularTags()));
+
// routing signal from friend list tab & search location tab
connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
this, SLOT(routeTo(const GeoCoordinate&)));
connect(m_situareService, SIGNAL(messagesReceived(QList<Message>&, QList<Message> &)),
m_ui, SIGNAL(messagesReceived(QList<Message>&, QList<Message>&)));
+
+ connect(m_situareService, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+ m_ui, SIGNAL(popularTagsReceived(QHash<QString,QString>&)));
}
void SituareEngine::startAutomaticUpdate()
if (lastComma != -1)
result.remove(result.lastIndexOf(","), 1);
- result.append("]");
-
+ result.append("]}");
+ qWarning() << result;
return result.toUtf8();
}
#include <QPixmap>
#include <QString>
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
/**
* @brief Container for a single message.
popularTags.insert(tag["id"].toString(), tag["name"].toString());
}
- emit interestingPeopleReceived(friends, others);
+ emit popularTagsReceived(popularTags);
}
}
void messagesReceived(QList<Message> &received, QList<Message> &sent);
/**
+ * @brief Signals when fetchPopularTags request is finished
+ *
+ * @param popularTags list of popular tags
+ */
+ void popularTagsReceived(QHash<QString, QString> &popularTags);
+
+ /**
* @brief Signals when address data is retrieved
*
* @param address Street address
qDebug() << __PRETTY_FUNCTION__;
setIcon(icon);
- setIconSize(size);
- setFixedSize(size);
+
+ if (size.isValid()) {
+ setIconSize(size);
+ setFixedSize(size);
+ }
}
connect(m_userInfoPanel, SIGNAL(removeTags(QStringList)),
this, SIGNAL(removeTags(QStringList)));
+
+ connect(this, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+ m_userInfoPanel, SLOT(populatePopularTags(QHash<QString,QString>&)));
+
+ connect(m_userInfoPanel, SIGNAL(requestPopularTags()),
+ this, SIGNAL(requestPopularTags()));
}
void MainWindow::buildWebView()
void messagesReceived(QList<Message> &received, QList<Message> &sent);
/**
+ * @brief Signals when fetchPopularTags request is finished
+ *
+ * @param popularTags list of popular tags
+ */
+ void popularTagsReceived(QHash<QString, QString> &popularTags);
+
+ /**
+ * @brief Signal for requesting popular tags
+ */
+ void requestPopularTags();
+
+ /**
* @brief Signal for refreshing user data.
*
*/
PersonListItem *personItem = dynamic_cast<PersonListItem*>(m_personListView->selectedItem());
- if (personItem && !personItem->isFriend())
+ if (personItem) {
+ if (personItem->isFriend())
+ m_friendListButton->setEnabled(true);
+ else
+ m_friendListButton->setDisabled(true);
+ } else {
m_friendListButton->setDisabled(true);
- else
- m_friendListButton->setEnabled(true);
+ }
onListItemSelectionChanged();
}
#include <QDebug>
#include "listcommon.h"
-#include "situareservice/message.h"
+#include "../situareservice/message.h"
#include "messagelistitem.h"
qDebug() << __PRETTY_FUNCTION__;
}
-GeoCoordinate MessageListItem::coordinates() const
+GeoCoordinate &MessageListItem::coordinates() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_coordinates;
}
-const QString &MessageListItem::id() const
+QString &MessageListItem::id() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_id;
}
-const QString &MessageListItem::receiverId() const
+QString &MessageListItem::newMessageReceiverId() const
{
qDebug() << __PRETTY_FUNCTION__;
- return m_receiverId;
+ return m_newMessageReceiverId;
+}
+
+void MessageListItem::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+ m_newMessageReceiverId = newMessageReceiverId;
}
void MessageListItem::setMessageData(const Message &message)
m_id = message.id();
if (message.type() == Message::MessageTypeReceived)
- m_receiverId = message.senderId();
+ setNewMessageReceiverId(message.senderId());
else
- m_receiverId = message.receiverId();
+ setNewMessageReceiverId(message.receiverId());
setTitle(message.senderName());
#ifndef MESSAGELISTITEM_H
#define MESSAGELISTITEM_H
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
#include "extendedlistitem.h"
class Message;
*
* @return item's coordinates
*/
- GeoCoordinate coordinates() const;
+ GeoCoordinate &coordinates() const;
/**
* @brief Returns message's ID.
*
* @return message's ID
*/
- const QString &id() const;
+ QString &id() const;
/**
- * @brief Returns message receiver's ID.
+ * @brief Returns new message message receiver's ID.
*
- * @return message receiver's ID
+ * @return new message message receiver's ID
*/
- const QString &receiverId() const;
+ QString &newMessageReceiverId() const;
+
+ /**
+ * @brief Sets new message message receiver's ID.
+ *
+ * @return newMessageReceiverId new message message receiver's ID
+ */
+ void setNewMessageReceiverId(const QString &newMessageReceiverId);
/**
* @brief Set message data for this item.
******************************************************************************/
private:
QString m_id; ///< message's ID
- QString m_receiverId; ///< message reveiver's ID
+ QString m_newMessageReceiverId; ///< new message reveiver's ID
GeoCoordinate m_coordinates; ///< message's coordinates
};
#include <QDebug>
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
#include "messagelistitem.h"
#include "messagelistview.h"
if (messageItem) {
m_messageListView->clearItemSelection();
- emit requestMessageDialog(QPair<QString, QString>(messageItem->receiverId(),
+ emit requestMessageDialog(QPair<QString, QString>(messageItem->newMessageReceiverId(),
messageItem->title()));
}
}
m_facebookId = facebookId;
}
-void PersonListItem::setIsFriend(bool isFriend)
+void PersonListItem::setIsFriend(const bool isFriend)
{
qDebug() << __PRETTY_FUNCTION__;
*
* @param isFriend true if friend, false otherwise
*/
- void setIsFriend(bool isFriend);
+ void setIsFriend(const bool isFriend);
/**
* @brief Set person data for this item.
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *lineEditLayout = new QHBoxLayout;
QGridLayout *listLayout = new QGridLayout;
+ QVBoxLayout *buttonLayout = new QVBoxLayout;
m_addTagEdit = new QLineEdit("");
QPushButton *addButton = new QPushButton(tr("Add"));
lineEditLayout->addWidget(addButton);
QPushButton *deleteButton = new QPushButton(tr("Delete"));
- QPushButton *cancelButton = new QPushButton(tr("Cancel"));
QPushButton *okButton = new QPushButton(tr("Update"));
+ buttonLayout->addWidget(deleteButton, 0, Qt::AlignBottom);
+ buttonLayout->addWidget(okButton, 0, Qt::AlignBottom);
QLabel *yourTagsLabel = new QLabel(tr("Your tags:"));
yourTagsLabel->setAlignment(Qt::AlignCenter);
popularTagsLabel->setAlignment(Qt::AlignCenter);
m_userTagsView = new QListWidget();
m_popularTagsView = new QListWidget();
+ m_popularTagsView->setSelectionMode(QAbstractItemView::NoSelection);
listLayout->addWidget(yourTagsLabel, 0, 0);
listLayout->addWidget(popularTagsLabel, 0, 1);
listLayout->addWidget(m_userTagsView, 1, 0);
- listLayout->addWidget(m_userTagsView, 1, 1);
+ listLayout->addWidget(m_popularTagsView, 1, 1);
+ listLayout->addLayout(buttonLayout, 0, 2, -1, 1);
mainLayout->addLayout(lineEditLayout);
mainLayout->addLayout(listLayout);
connect(okButton, SIGNAL(clicked()),
this, SLOT(accept()));
- connect(cancelButton, SIGNAL(clicked()),
- this, SLOT(reject()));
-
connect(addButton, SIGNAL(clicked()),
this, SLOT(addTagToList()));
void TagsDialog::populatePopularTags(const QHash<QString, QString> &popularTags)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
m_popularTagsView->clear();
foreach (QString tag, popularTags)
void TagsDialog::populateUserTags(const QHash<QString, QString> &userTags)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
m_userTagsView->clear();
foreach (QString tag, m_newTags) {
class QLineEdit;
class QPushButton;
class QListWidget;
+class QListWidgetItem;
/**
* @brief User tags dialog shows user tags.
UserInfo::UserInfo(QWidget *parent)
: QWidget(parent),
m_expanded(false),
+ m_tagsDialog(0),
m_updateLocation(0)
{
qDebug() << __PRETTY_FUNCTION__;
m_tagsDialog->populateUserTags(m_userTags);
}
+void UserInfo::setPopularTags(const QHash<QString, QString> &tags)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_tagsDialog)
+ m_tagsDialog->populatePopularTags(tags);
+}
+
void UserInfo::setTime(const QString &time)
{
qDebug() << __PRETTY_FUNCTION__;
void setTags(const QHash<QString, QString> &tags);
/**
+ * @brief Sets the popular tags
+ *
+ * @param tags list of tags
+ */
+ void setPopularTags(const QHash<QString, QString> &tags);
+
+ /**
* @brief Sets the time of updated message
*
* @param time Reference to time when message was sent.
}
+void UserInfoPanel::populatePopularTags(QHash<QString, QString> &popularTags)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_userInfo->setPopularTags(popularTags);
+}
+
void UserInfoPanel::setImage(const QString &id, const QPixmap &image)
{
qDebug() << __PRETTY_FUNCTION__;
qDebug() << __PRETTY_FUNCTION__;
m_userInfo->showTagsDialog();
+
+ emit requestPopularTags();
}
void UserInfoPanel::userDataReceived(User *user)
******************************************************************************/
public slots:
/**
+ * @brief Populates popular tags list
+ *
+ * @param popularTags list of popular tags
+ */
+ void populatePopularTags(QHash<QString, QString> &popularTags);
+
+ /**
* @brief show / hide user information
*
* @param show true if userinfo should be shown
*/
void userDataReceived(User *user);
+private slots:
+ /**
+ * @brief Sets user's image.
+ *
+ * @param id image ID
+ * @param image image pixmap
+ */
+ void setImage(const QString &id, const QPixmap &image);
+
+ void showTagsDialog();
+
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
void removeTags(const QStringList &tags);
/**
+ * @brief Signal for requesting popular tags
+ */
+ void requestPopularTags();
+
+ /**
* @brief Signal for requesting reverseGeo from SituareEngine
*/
void requestReverseGeo();
*/
void clearUpdateLocationDialogData();
-private slots:
- /**
- * @brief Sets user's image.
- *
- * @param id image ID
- * @param image image pixmap
- */
- void setImage(const QString &id, const QPixmap &image);
-
- void showTagsDialog();
-
-
/*******************************************************************************
* DATA MEMBERS
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Jussi Laitinen - jussi.laitinen@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef EXTENDEDLISTITEMSTUB_H
-#define EXTENDEDLISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "listitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "stubbase.h"
-
-class ExtendedListItemStub : public StubBase
-{
-public:
- virtual void ExtendedListItemConstructor(QListWidget *parent, int type);
- virtual void addSubItem(const QString &text, const QPixmap &icon = QPixmap());
- virtual void clearSubItems();
- virtual void setSelected(bool selected);
- virtual void setSubitemTextWidth(int width);
- virtual bool toggleSelection();
-};
-
-void ExtendedListItemStub::ExtendedListItemConstructor(QListWidget *parent, int type)
-{
- Q_UNUSED(parent)
- Q_UNUSED(type)
-}
-
-void ExtendedListItemStub::addSubItem(const QString &text, const QPixmap &icon)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(text));
- params.append(new Parameter<const QPixmap &>(icon));
- stubMethodEntered("addSubItem", params);
-}
-
-void ExtendedListItemStub::clearSubItems()
-{
- stubMethodEntered("clearSubItems");
-}
-
-void ExtendedListItemStub::setSelected(bool selected)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<bool>(selected));
- stubMethodEntered("setSelected", params);
-}
-
-void ExtendedListItemStub::setSubitemTextWidth(int width)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<int>(width));
- stubMethodEntered("setSubitemTextWidth", params);
-}
-
-bool ExtendedListItemStub::toggleSelection()
-{
- stubMethodEntered("toggleSelection");
-
- return stubReturnValue<bool>("toggleSelection");
-}
-
-//Create a stub instance
-ExtendedListItemStub defaultExtendedListItemStub;
-ExtendedListItemStub *extendedListItemStub = &defaultExtendedListItemStub;
-
-ExtendedListItem::ExtendedListItem(QListWidget *parent, int type)
- : ListItem(parent, type)
-{
- extendedListItemStub->ExtendedListItemConstructor(parent, type);
-}
-
-ExtendedListItem::~ExtendedListItem()
-{
-
-}
-
-void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon)
-{
- extendedListItemStub->addSubItem(text, icon);
-}
-
-void ExtendedListItem::clearSubItems()
-{
- extendedListItemStub->clearSubItems();
-}
-
-void ExtendedListItem::setSelected(bool selected)
-{
- extendedListItemStub->setSelected(selected);
-}
-
-void ExtendedListItem::setSubitemTextWidth(int width)
-{
- extendedListItemStub->setSubitemTextWidth(width);
-}
-
-bool ExtendedListItem::toggleSelection()
-{
- return extendedListItemStub->toggleSelection();
-}
-
-#endif // EXTENDEDLISTITEMSTUB_H
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef EXTENDEDLISTITEMSTUB_H
+#define EXTENDEDLISTITEMSTUB_H
+
+#include "../../src/ui/extendedlistitem.h"
+#include "listitemstub.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "stubbase.h"
+
+class ExtendedListItemStub : public StubBase
+{
+public:
+ virtual void ExtendedListItemConstructor(QListWidget *parent, int type);
+ virtual void addSubItem(const QString &text, const QPixmap &icon = QPixmap());
+ virtual void clearSubItems();
+ virtual void setSelected(bool selected);
+ virtual void setSubitemTextWidth(int width);
+ virtual bool toggleSelection();
+};
+
+void ExtendedListItemStub::ExtendedListItemConstructor(QListWidget *parent, int type)
+{
+ Q_UNUSED(parent)
+ Q_UNUSED(type)
+}
+
+void ExtendedListItemStub::addSubItem(const QString &text, const QPixmap &icon)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(text));
+ params.append(new Parameter<const QPixmap &>(icon));
+ stubMethodEntered("addSubItem", params);
+}
+
+void ExtendedListItemStub::clearSubItems()
+{
+ stubMethodEntered("clearSubItems");
+}
+
+void ExtendedListItemStub::setSelected(bool selected)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<bool>(selected));
+ stubMethodEntered("setSelected", params);
+}
+
+void ExtendedListItemStub::setSubitemTextWidth(int width)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<int>(width));
+ stubMethodEntered("setSubitemTextWidth", params);
+}
+
+bool ExtendedListItemStub::toggleSelection()
+{
+ stubMethodEntered("toggleSelection");
+
+ return stubReturnValue<bool>("toggleSelection");
+}
+
+//Create a stub instance
+ExtendedListItemStub defaultExtendedListItemStub;
+ExtendedListItemStub *extendedListItemStub = &defaultExtendedListItemStub;
+
+ExtendedListItem::ExtendedListItem(QListWidget *parent, int type)
+ : ListItem(parent, type)
+{
+ extendedListItemStub->ExtendedListItemConstructor(parent, type);
+}
+
+ExtendedListItem::~ExtendedListItem()
+{
+
+}
+
+void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon)
+{
+ extendedListItemStub->addSubItem(text, icon);
+}
+
+void ExtendedListItem::clearSubItems()
+{
+ extendedListItemStub->clearSubItems();
+}
+
+void ExtendedListItem::setSelected(bool selected)
+{
+ extendedListItemStub->setSelected(selected);
+}
+
+void ExtendedListItem::setSubitemTextWidth(int width)
+{
+ extendedListItemStub->setSubitemTextWidth(width);
+}
+
+bool ExtendedListItem::toggleSelection()
+{
+ return extendedListItemStub->toggleSelection();
+}
+
+#endif // EXTENDEDLISTITEMSTUB_H
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Jussi Laitinen - jussi.laitinen@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef LISTITEMSTUB_H
-#define LISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "stubbase.h"
-
-class ListItemStub : public StubBase
-{
-public:
- virtual void ListItemConstructor(QListWidget *parent = 0,
- int type = QListWidgetItem::Type);
- enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
- virtual void setImage(const QPixmap &image);
- virtual void setTitle(const QString &name);
- virtual void setSize(const QSize &size);
- virtual QString shortenText(const QString &text, int textWidth, ListItem::TextSize textSize);
- virtual QString title();
-};
-
-void ListItemStub::ListItemConstructor(QListWidget *parent, int type)
-{
- Q_UNUSED(parent)
- Q_UNUSED(type)
-}
-
-void ListItemStub::setImage(const QPixmap &image)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QPixmap &>(image));
- stubMethodEntered("setImage", params);
-}
-
-void ListItemStub::setTitle(const QString &name)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(name));
- stubMethodEntered("setTitle", params);
-}
-
-void ListItemStub::setSize(const QSize &size)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QSize &>(size));
- stubMethodEntered("setSize", params);
-}
-
-QString ListItemStub::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(text));
- params.append(new Parameter<int>(textWidth));
- params.append(new Parameter<ListItem::TextSize>(textSize));
- stubMethodEntered("shortenText", params);
-
- return stubReturnValue<QString>("shortenText");
-}
-
-QString ListItemStub::title()
-{
- return stubReturnValue<QString>("title");
-}
-
-//Create a stub instance
-ListItemStub defaultListItemStub;
-ListItemStub *listItemStub = &defaultListItemStub;
-
-ListItem::ListItem(QListWidget *parent, int type)
- : QListWidgetItem(parent, type)
-{
- listItemStub->ListItemConstructor(parent, type);
-}
-
-void ListItem::setImage(const QPixmap &image)
-{
- listItemStub->setImage(image);
-}
-
-void ListItem::setTitle(const QString &name)
-{
- listItemStub->setTitle(name);
-}
-
-void ListItem::setSize(const QSize &size)
-{
- listItemStub->setSize(size);
-}
-
-QString ListItem::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
-{
- return listItemStub->shortenText(text, textWidth, textSize);
-}
-
-QString ListItem::title()
-{
- return listItemStub->title();
-}
-
-#endif // LISTITEMSTUB_H
-
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef LISTITEMSTUB_H
+#define LISTITEMSTUB_H
+
+#include "../../src/ui/listitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "stubbase.h"
+
+class ListItemStub : public StubBase
+{
+public:
+ virtual void ListItemConstructor(QListWidget *parent = 0,
+ int type = QListWidgetItem::Type);
+ enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
+ virtual void setImage(const QPixmap &image);
+ virtual void setTitle(const QString &name);
+ virtual void setSize(const QSize &size);
+ virtual QString shortenText(const QString &text, int textWidth, ListItem::TextSize textSize);
+ virtual QString title();
+};
+
+void ListItemStub::ListItemConstructor(QListWidget *parent, int type)
+{
+ Q_UNUSED(parent)
+ Q_UNUSED(type)
+}
+
+void ListItemStub::setImage(const QPixmap &image)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QPixmap &>(image));
+ stubMethodEntered("setImage", params);
+}
+
+void ListItemStub::setTitle(const QString &name)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(name));
+ stubMethodEntered("setTitle", params);
+}
+
+void ListItemStub::setSize(const QSize &size)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QSize &>(size));
+ stubMethodEntered("setSize", params);
+}
+
+QString ListItemStub::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(text));
+ params.append(new Parameter<int>(textWidth));
+ params.append(new Parameter<ListItem::TextSize>(textSize));
+ stubMethodEntered("shortenText", params);
+
+ return stubReturnValue<QString>("shortenText");
+}
+
+QString ListItemStub::title()
+{
+ return stubReturnValue<QString>("title");
+}
+
+//Create a stub instance
+ListItemStub defaultListItemStub;
+ListItemStub *listItemStub = &defaultListItemStub;
+
+ListItem::ListItem(QListWidget *parent, int type)
+ : QListWidgetItem(parent, type)
+{
+ listItemStub->ListItemConstructor(parent, type);
+}
+
+void ListItem::setImage(const QPixmap &image)
+{
+ listItemStub->setImage(image);
+}
+
+void ListItem::setTitle(const QString &name)
+{
+ listItemStub->setTitle(name);
+}
+
+void ListItem::setSize(const QSize &size)
+{
+ listItemStub->setSize(size);
+}
+
+QString ListItem::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
+{
+ return listItemStub->shortenText(text, textWidth, textSize);
+}
+
+QString ListItem::title()
+{
+ return listItemStub->title();
+}
+
+#endif // LISTITEMSTUB_H
+
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Jussi Laitinen - jussi.laitinen@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef LISTVIEWSTUB_H
-#define LISTVIEWSTUB_H
-
-#include <QListWidget>
-
-#include "../../src/ui/personlistview.h"
-#include "listitem.h"
-#include "stubbase.h"
-
-class ListViewStub : public StubBase
-{
-public:
- virtual void ListViewConstructor(QWidget *parent = 0);
- virtual void addListItem(const QString &key, ListItem *item);
- virtual void addListItemToView(ListItem *item);
- virtual void clearUnused(const QStringList &itemIDs);
- virtual void clearFilter();
- virtual void clearItemSelection();
- virtual void clearList();
- virtual bool contains(const QString &userID);
- virtual void filter(const QList<QString> &itemIDs);
- virtual void filter(const QString &pattern);
- virtual ListItem *takeListItemFromView(const QString &itemID);
- virtual ListItem *listItem(const QString &itemID);
- virtual ListItem *listItemAt(int index);
- virtual void prependListItem(const QString &key, ListItem *item);
- virtual void removeLastItem();
- virtual ListItem *selectedItem();
- virtual void setSelectedItem(ListItem *item);
- virtual bool listItemClicked(ListItem *clickedItem);
- virtual void listItemClicked(QListWidgetItem *item);
-};
-
-void ListViewStub::ListViewConstructor(QWidget *parent)
-{
- Q_UNUSED(parent)
-}
-
-void ListViewStub::addListItem(const QString &key, ListItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(key));
- params.append(new Parameter<ListItem *>(item));
- stubMethodEntered("addListItem", params);
-}
-
-void ListViewStub::addListItemToView(ListItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<ListItem *>(item));
- stubMethodEntered("addListItemToView", params);
-}
-
-void ListViewStub::clearUnused(const QStringList &itemIDs)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QStringList &>(itemIDs));
- stubMethodEntered("clearUnused", params);
-}
-
-void ListViewStub::clearFilter()
-{
- stubMethodEntered("clearFilter");
-}
-
-void ListViewStub::clearItemSelection()
-{
- stubMethodEntered("clearItemSelection");
-}
-
-void ListViewStub::clearList()
-{
- stubMethodEntered("clearList");
-}
-
-bool ListViewStub::contains(const QString &userID)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(userID));
- stubMethodEntered("contains", params);
-
- return stubReturnValue<bool>("contains");
-}
-
-void ListViewStub::filter(const QList<QString> &itemIDs)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QList<QString> &>(itemIDs));
- stubMethodEntered("filter", params);
-}
-
-void ListViewStub::filter(const QString &pattern)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(pattern));
- stubMethodEntered("filter", params);
-}
-
-ListItem *ListViewStub::takeListItemFromView(const QString &itemID)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(itemID));
- stubMethodEntered("takeListItemFromView", params);
-
- return stubReturnValue<ListItem *>("takeListItemFromView");
-}
-
-ListItem *ListViewStub::listItem(const QString &itemID)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(itemID));
- stubMethodEntered("listItem", params);
-
- return stubReturnValue<ListItem *>("listItem");
-}
-
-ListItem *ListViewStub::listItemAt(int index)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<int>(index));
- stubMethodEntered("listItemAt", params);
-
- return stubReturnValue<ListItem *>("listItemAt");
-}
-
-void ListViewStub::prependListItem(const QString &key, ListItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QString &>(key));
- params.append(new Parameter<ListItem *>(item));
- stubMethodEntered("prependListItem", params);
-}
-
-void ListViewStub::removeLastItem()
-{
- stubMethodEntered("removeLastItem");
-}
-
-ListItem *ListViewStub::selectedItem()
-{
- return stubReturnValue<ListItem *>("selectedItem");
-}
-
-void ListViewStub::setSelectedItem(ListItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<ListItem *>(item));
- stubMethodEntered("setSelectedItem", params);
-}
-
-bool ListViewStub::listItemClicked(ListItem *clickedItem)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<ListItem *>(clickedItem));
- stubMethodEntered("listItemClicked", params);
-
- return stubReturnValue<bool>("listItemClicked");
-}
-
-void ListViewStub::listItemClicked(QListWidgetItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<QListWidgetItem *>(item));
- stubMethodEntered("listItemClicked", params);
-}
-
-ListViewStub defaultListViewStub;
-ListViewStub *listViewStub = &defaultListViewStub;
-
-ListView::ListView(QWidget *parent)
- : QListWidget(parent)
-{
- listViewStub->ListViewConstructor(parent);
-}
-
-ListView::~ListView()
-{
-
-}
-
-void ListView::addListItem(const QString &key, ListItem *item)
-{
- listViewStub->addListItem(key, item);
-}
-
-void ListView::addListItemToView(ListItem *item)
-{
- listViewStub->addListItemToView(item);
-}
-
-void ListView::clearUnused(const QStringList &itemIDs)
-{
- listViewStub->clearUnused(itemIDs);
-}
-
-void ListView::clearFilter()
-{
- listViewStub->clearFilter();
-}
-
-void ListView::clearItemSelection()
-{
- listViewStub->clearItemSelection();
-}
-
-void ListView::clearList()
-{
- listViewStub->clearList();
-}
-
-bool ListView::contains(const QString &userID)
-{
- return listViewStub->contains(userID);
-}
-
-void ListView::filter(const QList<QString> &itemIDs)
-{
- listViewStub->filter(itemIDs);
-}
-
-void ListView::filter(const QString &pattern)
-{
- listViewStub->filter(pattern);
-}
-
-ListItem *ListView::takeListItemFromView(const QString &itemID)
-{
- return listViewStub->takeListItemFromView(itemID);
-}
-
-ListItem *ListView::listItem(const QString &itemID)
-{
- return listViewStub->listItem(itemID);
-}
-
-ListItem *ListView::listItemAt(int index)
-{
- return listViewStub->listItemAt(index);
-}
-
-void ListView::prependListItem(const QString &key, ListItem *item)
-{
- listViewStub->prependListItem(key, item);
-}
-
-void ListView::removeLastItem()
-{
- listViewStub->removeLastItem();
-}
-
-ListItem *ListView::selectedItem()
-{
- return listViewStub->selectedItem();
-}
-
-void ListView::setSelectedItem(ListItem *item)
-{
- listViewStub->setSelectedItem(item);
-}
-
-bool ListView::listItemClicked(ListItem *clickedItem)
-{
- return listViewStub->listItemClicked(clickedItem);
-}
-
-void ListView::listItemClicked(QListWidgetItem *item)
-{
- listViewStub->listItemClicked(item);
-}
-
-#endif // LISTVIEWSTUB_H
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef LISTVIEWSTUB_H
+#define LISTVIEWSTUB_H
+
+#include <QListWidget>
+
+#include "../../src/ui/listview.h"
+#include "listitemstub.h"
+#include "stubbase.h"
+
+class ListViewStub : public StubBase
+{
+public:
+ virtual void ListViewConstructor(QWidget *parent = 0);
+ virtual void addListItem(const QString &key, ListItem *item);
+ virtual void addListItemToView(ListItem *item);
+ virtual void clearUnused(const QStringList &itemIDs);
+ virtual void clearFilter();
+ virtual void clearItemSelection();
+ virtual void clearList();
+ virtual bool contains(const QString &userID);
+ virtual void filter(const QList<QString> &itemIDs);
+ virtual void filter(const QString &pattern);
+ virtual ListItem *takeListItemFromView(const QString &itemID);
+ virtual ListItem *listItem(const QString &itemID);
+ virtual ListItem *listItemAt(int index);
+ virtual void prependListItem(const QString &key, ListItem *item);
+ virtual void removeLastItem();
+ virtual ListItem *selectedItem();
+ virtual void setSelectedItem(ListItem *item);
+ virtual bool listItemClicked(ListItem *clickedItem);
+ virtual void listItemClicked(QListWidgetItem *item);
+};
+
+void ListViewStub::ListViewConstructor(QWidget *parent)
+{
+ Q_UNUSED(parent)
+}
+
+void ListViewStub::addListItem(const QString &key, ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(key));
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("addListItem", params);
+}
+
+void ListViewStub::addListItemToView(ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("addListItemToView", params);
+}
+
+void ListViewStub::clearUnused(const QStringList &itemIDs)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QStringList &>(itemIDs));
+ stubMethodEntered("clearUnused", params);
+}
+
+void ListViewStub::clearFilter()
+{
+ stubMethodEntered("clearFilter");
+}
+
+void ListViewStub::clearItemSelection()
+{
+ stubMethodEntered("clearItemSelection");
+}
+
+void ListViewStub::clearList()
+{
+ stubMethodEntered("clearList");
+}
+
+bool ListViewStub::contains(const QString &userID)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(userID));
+ stubMethodEntered("contains", params);
+
+ return stubReturnValue<bool>("contains");
+}
+
+void ListViewStub::filter(const QList<QString> &itemIDs)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QList<QString> &>(itemIDs));
+ stubMethodEntered("filter", params);
+}
+
+void ListViewStub::filter(const QString &pattern)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(pattern));
+ stubMethodEntered("filter", params);
+}
+
+ListItem *ListViewStub::takeListItemFromView(const QString &itemID)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(itemID));
+ stubMethodEntered("takeListItemFromView", params);
+
+ return stubReturnValue<ListItem *>("takeListItemFromView");
+}
+
+ListItem *ListViewStub::listItem(const QString &itemID)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(itemID));
+ stubMethodEntered("listItem", params);
+
+ return stubReturnValue<ListItem *>("listItem");
+}
+
+ListItem *ListViewStub::listItemAt(int index)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<int>(index));
+ stubMethodEntered("listItemAt", params);
+
+ return stubReturnValue<ListItem *>("listItemAt");
+}
+
+void ListViewStub::prependListItem(const QString &key, ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(key));
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("prependListItem", params);
+}
+
+void ListViewStub::removeLastItem()
+{
+ stubMethodEntered("removeLastItem");
+}
+
+ListItem *ListViewStub::selectedItem()
+{
+ return stubReturnValue<ListItem *>("selectedItem");
+}
+
+void ListViewStub::setSelectedItem(ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("setSelectedItem", params);
+}
+
+bool ListViewStub::listItemClicked(ListItem *clickedItem)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<ListItem *>(clickedItem));
+ stubMethodEntered("listItemClicked", params);
+
+ return stubReturnValue<bool>("listItemClicked");
+}
+
+void ListViewStub::listItemClicked(QListWidgetItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<QListWidgetItem *>(item));
+ stubMethodEntered("listItemClicked", params);
+}
+
+ListViewStub defaultListViewStub;
+ListViewStub *listViewStub = &defaultListViewStub;
+
+ListView::ListView(QWidget *parent)
+ : QListWidget(parent)
+{
+ listViewStub->ListViewConstructor(parent);
+}
+
+ListView::~ListView()
+{
+
+}
+
+void ListView::addListItem(const QString &key, ListItem *item)
+{
+ listViewStub->addListItem(key, item);
+}
+
+void ListView::addListItemToView(ListItem *item)
+{
+ listViewStub->addListItemToView(item);
+}
+
+void ListView::clearUnused(const QStringList &itemIDs)
+{
+ listViewStub->clearUnused(itemIDs);
+}
+
+void ListView::clearFilter()
+{
+ listViewStub->clearFilter();
+}
+
+void ListView::clearItemSelection()
+{
+ listViewStub->clearItemSelection();
+}
+
+void ListView::clearList()
+{
+ listViewStub->clearList();
+}
+
+bool ListView::contains(const QString &userID)
+{
+ return listViewStub->contains(userID);
+}
+
+void ListView::filter(const QList<QString> &itemIDs)
+{
+ listViewStub->filter(itemIDs);
+}
+
+void ListView::filter(const QString &pattern)
+{
+ listViewStub->filter(pattern);
+}
+
+ListItem *ListView::takeListItemFromView(const QString &itemID)
+{
+ return listViewStub->takeListItemFromView(itemID);
+}
+
+ListItem *ListView::listItem(const QString &itemID)
+{
+ return listViewStub->listItem(itemID);
+}
+
+ListItem *ListView::listItemAt(int index)
+{
+ return listViewStub->listItemAt(index);
+}
+
+void ListView::prependListItem(const QString &key, ListItem *item)
+{
+ listViewStub->prependListItem(key, item);
+}
+
+void ListView::removeLastItem()
+{
+ listViewStub->removeLastItem();
+}
+
+ListItem *ListView::selectedItem()
+{
+ return listViewStub->selectedItem();
+}
+
+void ListView::setSelectedItem(ListItem *item)
+{
+ listViewStub->setSelectedItem(item);
+}
+
+bool ListView::listItemClicked(ListItem *clickedItem)
+{
+ return listViewStub->listItemClicked(clickedItem);
+}
+
+void ListView::listItemClicked(QListWidgetItem *item)
+{
+ listViewStub->listItemClicked(item);
+}
+
+#endif // LISTVIEWSTUB_H
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef MESSAGELISTITEMSTUB_H
+#define MESSAGELISTITEMSTUB_H
+
+#include "../../src/ui/messagelistitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "../../src/situareservice/message.h"
+#include "extendedlistitemstub.h"
+#include "stubbase.h"
+
+class MessageListItemStub : public StubBase
+{
+public:
+ virtual void MessageListItemConstructor();
+ virtual GeoCoordinate &coordinates() const;
+ virtual QString &id() const;
+ virtual QString &newMessageReceiverId() const;
+ virtual void setNewMessageReceiverId(const QString &newMessageReceiverId);
+ virtual void setMessageData(const Message &message);
+};
+
+void MessageListItemStub::MessageListItemConstructor()
+{
+
+}
+
+GeoCoordinate &MessageListItemStub::coordinates() const
+{
+ return stubReturnValue<GeoCoordinate>("coordinates");
+}
+
+QString &MessageListItemStub::id() const
+{
+ return stubReturnValue<QString>("id");
+}
+
+QString &MessageListItemStub::newMessageReceiverId() const
+{
+ return stubReturnValue<QString>("newMessageReceiverId");
+}
+
+void MessageListItemStub::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(newMessageReceiverId));
+ stubMethodEntered("setNewMessageReceiverId", params);
+}
+
+void MessageListItemStub::setMessageData(const Message &message)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const Message &>(message));
+ stubMethodEntered("setMessageData", params);
+}
+
+//Create a stub instance
+MessageListItemStub defaultMessageListItemStub;
+MessageListItemStub *messageListItemStub = &defaultMessageListItemStub;
+
+MessageListItem::MessageListItem()
+ : ExtendedListItem()
+{
+ messageListItemStub->MessageListItemConstructor();
+}
+
+MessageListItem::~MessageListItem()
+{
+
+}
+
+GeoCoordinate &MessageListItem::coordinates() const
+{
+ return messageListItemStub->coordinates();
+}
+
+QString &MessageListItem::id() const
+{
+ return messageListItemStub->id();
+}
+
+QString &MessageListItem::newMessageReceiverId() const
+{
+ return messageListItemStub->newMessageReceiverId();
+}
+
+void MessageListItem::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+ messageListItemStub->setNewMessageReceiverId(newMessageReceiverId);
+}
+
+void MessageListItem::setMessageData(const Message &message)
+{
+ messageListItemStub->setMessageData(message);
+}
+
+#endif // MESSAGELISTITEMSTUB_H
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Jussi Laitinen - jussi.laitinen@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef PERSONLISTITEMSTUB_H
-#define PERSONLISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "extendedlistitem.h"
-#include "stubbase.h"
-
-class PersonListItemStub : public StubBase
-{
-public:
- virtual void PersonListItemConstructor();
- virtual GeoCoordinate coordinates() const;
- virtual QString facebookId() const;
- virtual void setAvatarImage(const QPixmap &image);
- virtual void setCoordinates(const GeoCoordinate &coordinates);
- virtual void setPersonData(const User &user);
-};
-
-void PersonListItemStub::PersonListItemConstructor()
-{
-
-}
-
-GeoCoordinate PersonListItemStub::coordinates() const
-{
- return stubReturnValue<GeoCoordinate>("coordinates");
-}
-
-QString PersonListItemStub::facebookId() const
-{
- return stubReturnValue<QString>("facebookId");
-}
-
-void PersonListItemStub::setAvatarImage(const QPixmap &image)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const QPixmap &>(image));
- stubMethodEntered("setAvatarImage", params);
-}
-
-void PersonListItemStub::setCoordinates(const GeoCoordinate &coordinates)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const GeoCoordinate &>(coordinates));
- stubMethodEntered("setCoordinates", params);
-}
-
-void PersonListItemStub::setPersonData(const User &user)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<const User &>(user));
- stubMethodEntered("setUserData", params);
-}
-
-//Create a stub instance
-PersonListItemStub defaultPersonListItemStub;
-PersonListItemStub *personListItemStub = &defaultPersonListItemStub;
-
-PersonListItem::PersonListItem()
- : ExtendedListItem()
-{
- personListItemStub->PersonListItemConstructor();
-}
-
-PersonListItem::~PersonListItem()
-{
-
-}
-
-GeoCoordinate PersonListItem::coordinates() const
-{
- return personListItemStub->coordinates();
-}
-
-QString PersonListItem::facebookId() const
-{
- return personListItemStub->facebookId();
-}
-
-void PersonListItem::setAvatarImage(const QPixmap &image)
-{
- personListItemStub->setAvatarImage(image);
-}
-
-void PersonListItem::setCoordinates(const GeoCoordinate &coordinates)
-{
- personListItemStub->setCoordinates(coordinates);
-}
-
-void PersonListItem::setPersonData(const User &user)
-{
- personListItemStub->setPersonData(user);
-}
-
-#endif // PERSONLISTITEMSTUB_H
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef PERSONLISTITEMSTUB_H
+#define PERSONLISTITEMSTUB_H
+
+#include "../../src/ui/personlistitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "extendedlistitemstub.h"
+#include "stubbase.h"
+
+class PersonListItemStub : public StubBase
+{
+public:
+ virtual void PersonListItemConstructor();
+ virtual GeoCoordinate coordinates() const;
+ virtual QString facebookId() const;
+ virtual bool isFriend() const;
+ virtual void setAvatarImage(const QPixmap &image);
+ virtual void setCoordinates(const GeoCoordinate &coordinates);
+ virtual void setIsFriend(const bool isFriend);
+ virtual void setPersonData(const User &user, bool isFriend);
+};
+
+void PersonListItemStub::PersonListItemConstructor()
+{
+
+}
+
+GeoCoordinate PersonListItemStub::coordinates() const
+{
+ return stubReturnValue<GeoCoordinate>("coordinates");
+}
+
+QString PersonListItemStub::facebookId() const
+{
+ return stubReturnValue<QString>("facebookId");
+}
+
+bool PersonListItemStub::isFriend() const
+{
+ return stubReturnValue<bool>("isFriend");
+}
+
+void PersonListItemStub::setAvatarImage(const QPixmap &image)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QPixmap &>(image));
+ stubMethodEntered("setAvatarImage", params);
+}
+
+void PersonListItemStub::setCoordinates(const GeoCoordinate &coordinates)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const GeoCoordinate &>(coordinates));
+ stubMethodEntered("setCoordinates", params);
+}
+
+void PersonListItemStub::setIsFriend(const bool isFriend)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const bool>(isFriend));
+ stubMethodEntered("setIsFriend", params);
+}
+
+
+void PersonListItemStub::setPersonData(const User &user, bool isFriend)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const User &>(user));
+ params.append(new Parameter<bool>(isFriend));
+ stubMethodEntered("setUserData", params);
+}
+
+//Create a stub instance
+PersonListItemStub defaultPersonListItemStub;
+PersonListItemStub *personListItemStub = &defaultPersonListItemStub;
+
+PersonListItem::PersonListItem()
+ : ExtendedListItem()
+{
+ personListItemStub->PersonListItemConstructor();
+}
+
+PersonListItem::~PersonListItem()
+{
+
+}
+
+GeoCoordinate PersonListItem::coordinates() const
+{
+ return personListItemStub->coordinates();
+}
+
+QString PersonListItem::facebookId() const
+{
+ return personListItemStub->facebookId();
+}
+
+bool PersonListItem::isFriend() const
+{
+ return personListItemStub->isFriend();
+}
+
+void PersonListItem::setAvatarImage(const QPixmap &image)
+{
+ personListItemStub->setAvatarImage(image);
+}
+
+void PersonListItem::setCoordinates(const GeoCoordinate &coordinates)
+{
+ personListItemStub->setCoordinates(coordinates);
+}
+
+void PersonListItem::setIsFriend(const bool isFriend)
+{
+ personListItemStub->setIsFriend(isFriend);
+}
+
+void PersonListItem::setPersonData(const User &user, bool isFriend)
+{
+ personListItemStub->setPersonData(user, isFriend);
+}
+
+#endif // PERSONLISTITEMSTUB_H
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Jussi Laitinen - jussi.laitinen@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef PERSONLISTVIEWSTUB_H
-#define PERSONLISTVIEWSTUB_H
-
-#include "../../src/ui/personlistview.h"
-#include "listview.h"
-#include "stubbase.h"
-
-class PersonListViewStub : public StubBase
-{
-public:
- virtual void PersonListViewConstructor(QWidget *parent = 0);
- virtual bool listItemClicked(ListItem *item);
-};
-
-void PersonListViewStub::PersonListViewConstructor(QWidget *parent)
-{
- Q_UNUSED(parent)
-}
-
-bool PersonListViewStub::listItemClicked(ListItem *item)
-{
- QList<ParameterBase *> params;
- params.append(new Parameter<ListItem *>(item));
- stubMethodEntered("listItemClicked", params);
-
- return stubReturnValue<bool>("listItemClicked");
-}
-
-//Create a stub instance
-PersonListViewStub defaultPersonListViewStub;
-PersonListViewStub *personListViewStub = &defaultPersonListViewStub;
-
-PersonListView::PersonListView(QWidget *parent)
- : ListView(parent)
-{
- personListViewStub->PersonListViewConstructor(parent);
-}
-
-bool PersonListView::listItemClicked(ListItem *item)
-{
- return personListViewStub->listItemClicked(item);
-}
-
-#endif // PERSONLISTVIEWSTUB_H
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef PERSONLISTVIEWSTUB_H
+#define PERSONLISTVIEWSTUB_H
+
+#include "../../src/ui/personlistview.h"
+#include "listviewstub.h"
+#include "stubbase.h"
+
+class PersonListViewStub : public StubBase
+{
+public:
+ virtual void PersonListViewConstructor(QWidget *parent = 0);
+ virtual bool listItemClicked(ListItem *item);
+};
+
+void PersonListViewStub::PersonListViewConstructor(QWidget *parent)
+{
+ Q_UNUSED(parent)
+}
+
+bool PersonListViewStub::listItemClicked(ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("listItemClicked", params);
+
+ return stubReturnValue<bool>("listItemClicked");
+}
+
+//Create a stub instance
+PersonListViewStub defaultPersonListViewStub;
+PersonListViewStub *personListViewStub = &defaultPersonListViewStub;
+
+PersonListView::PersonListView(QWidget *parent)
+ : ListView(parent)
+{
+ personListViewStub->PersonListViewConstructor(parent);
+}
+
+bool PersonListView::listItemClicked(ListItem *item)
+{
+ return personListViewStub->listItemClicked(item);
+}
+
+#endif // PERSONLISTVIEWSTUB_H
parameter.h \
networkaccessmanagerstub.h \
imagefetcherstub.h \
- personlistitem.h \
- personlistview.h \
- listview.h \
- listitem.h \
- extendedlistitem.h
+ personlistitemstub.h \
+ personlistviewstub.h \
+ listviewstub.h \
+ listitemstub.h \
+ extendedlistitemstub.h \
+ messagelistitemstub.h
SOURCES += \
stubbase.cpp
HEADERS += \
../../stubs/stubbase.h \
- ../../stubs/listitem.h \
+ ../../stubs/listitemstub.h \
../../../src/ui/listview.h
SOURCES += \
#include <QtTest>
#include <QtGui>
+#include "../../stubs/listitemstub.h"
#include "../../../src/ui/listview.h"
class TestListView: public QObject
HEADERS += \
../../stubs/stubbase.h \
- ../../stubs/personlistview.h \
- ../../stubs/personlistitem.h \
- ../../stubs/listview.h \
- ../../stubs/listitem.h \
- ../../stubs/extendedlistitem.h \
+ ../../stubs/personlistviewstub.h \
+ ../../stubs/personlistitemstub.h \
+ ../../stubs/listviewstub.h \
+ ../../stubs/listitemstub.h \
+ ../../stubs/extendedlistitemstub.h \
../../../src/ui/extendedlistitemdelegate.h \
../../../src/ui/headerlistitemdelegate.h \
../../../src/ui/listitemdelegate.h \
../../../src/ui/extendedlistitemstore.h \
../../../src/common.h \
../../../src/map/osm.h \
- ../../../src/user/user.h
+ ../../../src/user/user.h \
+ ../../../src/ui/listview.h \
+ ../../../src/ui/personlistview.h \
SOURCES += \
../../stubs/stubbase.cpp \
#include <QtTest>
#include <QtGui>
+#include <QMetaType>
+
+#include "../../stubs/personlistviewstub.h"
+#include "../../stubs/personlistitemstub.h"
+#include "../../stubs/listviewstub.h"
+#include "../../stubs/listitemstub.h"
+#include "../../stubs/extendedlistitemstub.h"
+#include "../../../src/ui/imagebutton.h"
+#include "../../../src/user/user.h"
+#include "../../../src/ui/headerlistitemdelegate.h"
#include "../../../src/ui/meetpeoplepanel.h"
private slots:
void cleanup();
void init();
+ void populateInterestingPeopleListViewWithFriends();
+ void populateInterestingPeopleListViewWithFriendsAndOthers();
+ void listItemSelectionHandler();
+ void messageButtonPressed();
+ void setImage();
+ void showFriend();
+
+private:
+ QList<User> getFriends();
+ QList<User> getOthers();
private:
MeetPeoplePanel *m_meetPeoplePanel;
void TestMeetPeoplePanel::cleanup()
{
delete m_meetPeoplePanel;
+
+ listViewStub->stubReset();
}
void TestMeetPeoplePanel::init()
QVERIFY(m_meetPeoplePanel);
}
+QList<User> TestMeetPeoplePanel::getFriends()
+{
+ QList<User> friends;
+ User user1;
+ user1.setUserId("1");
+ User user2;
+ user2.setUserId(("2"));
+ friends.append(user1);
+ friends.append(user2);
+
+ return friends;
+}
+
+QList<User> TestMeetPeoplePanel::getOthers()
+{
+ QList<User> others;
+ User user1;
+ user1.setUserId("10");
+ User user2;
+ user2.setUserId(("20"));
+ others.append(user1);
+ others.append(user2);
+
+ return others;
+}
+
+void TestMeetPeoplePanel::populateInterestingPeopleListViewWithFriends()
+{
+ QList<User> friends = getFriends();
+ QList<User> others;
+
+ PersonListView *personListView = m_meetPeoplePanel->m_personListView;
+
+ m_meetPeoplePanel->populateInterestingPeopleListView(friends, others);
+
+ QCOMPARE(listViewStub->stubCallCount("addListItem"), 3);
+
+ QVERIFY(dynamic_cast<HeaderListItemDelegate *>(personListView->itemDelegateForRow(0)));
+ QList<MethodCall *> methodCalls = listViewStub->stubCallsTo("addListItem");
+ QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(0)->parameter<ListItem *>(1)));
+
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(1)->parameter<ListItem *>(1)));
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(2)->parameter<ListItem *>(1)));
+}
+
+void TestMeetPeoplePanel::populateInterestingPeopleListViewWithFriendsAndOthers()
+{
+ QList<User> friends = getFriends();
+ QList<User> others = getOthers();
+
+ PersonListView *personListView = m_meetPeoplePanel->m_personListView;
+
+ m_meetPeoplePanel->populateInterestingPeopleListView(friends, others);
+
+ QCOMPARE(listViewStub->stubCallCount("addListItem"), 6);
+
+ QVERIFY(dynamic_cast<HeaderListItemDelegate *>(personListView->itemDelegateForRow(0)));
+ QList<MethodCall *> methodCalls = listViewStub->stubCallsTo("addListItem");
+ QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(0)->parameter<ListItem *>(1)));
+ QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(3)->parameter<ListItem *>(1)));
+
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(1)->parameter<ListItem *>(1)));
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(2)->parameter<ListItem *>(1)));
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(4)->parameter<ListItem *>(1)));
+ QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(5)->parameter<ListItem *>(1)));
+}
+
+
+void TestMeetPeoplePanel::listItemSelectionHandler()
+{
+ PersonListItem friendItem;
+ friendItem.setPersonData(getFriends().at(0), true);
+ PersonListItem otherItem;
+ otherItem.setPersonData(getOthers().at(0), false);
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+ m_meetPeoplePanel->listItemSelectionHandler();
+ QVERIFY(!m_meetPeoplePanel->m_friendListButton->isEnabled());
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+ personListItemStub->stubSetReturnValue("isFriend", true);
+
+ m_meetPeoplePanel->listItemSelectionHandler();
+ QVERIFY(m_meetPeoplePanel->m_friendListButton->isEnabled());
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&otherItem);
+ personListItemStub->stubSetReturnValue("isFriend", false);
+
+ m_meetPeoplePanel->listItemSelectionHandler();
+ QVERIFY(!m_meetPeoplePanel->m_friendListButton->isEnabled());
+}
+
+void TestMeetPeoplePanel::messageButtonPressed()
+{
+ PersonListItem friendItem;
+ friendItem.setPersonData(getFriends().at(0), true);
+
+ qRegisterMetaType<QPair<QString, QString> >("QPair<QString,QString>");
+
+ QSignalSpy requestMessageDialogSpy(m_meetPeoplePanel,
+ SIGNAL(requestMessageDialog(QPair<QString,QString>)));
+ QVERIFY(requestMessageDialogSpy.isValid());
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+ m_meetPeoplePanel->messageButtonPressed();
+ QCOMPARE(requestMessageDialogSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+
+ m_meetPeoplePanel->messageButtonPressed();
+ QCOMPARE(listViewStub->stubCallCount("clearItemSelection"), 1);
+ QCOMPARE(requestMessageDialogSpy.count(), 1);
+}
+
+void TestMeetPeoplePanel::setImage()
+{
+ PersonListItem friendItem;
+ friendItem.setPersonData(getFriends().at(0), true);
+
+ listViewStub->stubSetReturnValue("listItem", (ListItem*)0);
+
+ m_meetPeoplePanel->setImage("1", QPixmap());
+ QCOMPARE(personListItemStub->stubCallCount("setAvatarImage"), 0);
+
+ listViewStub->stubSetReturnValue("listItem", (ListItem*)&friendItem);
+
+ m_meetPeoplePanel->setImage("1", QPixmap());
+ QCOMPARE(personListItemStub->stubCallCount("setAvatarImage"), 1);
+}
+
+void TestMeetPeoplePanel::showFriend()
+{
+ PersonListItem friendItem;
+ friendItem.setPersonData(getFriends().at(0), true);
+
+ qRegisterMetaType<QList<QString> >("QList<QString>");
+
+ QSignalSpy requestShowFriendSpy(m_meetPeoplePanel, SIGNAL(requestShowFriend(QList<QString>)));
+ QVERIFY(requestShowFriendSpy.isValid());
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+ m_meetPeoplePanel->showFriend();
+ QCOMPARE(requestShowFriendSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+
+ m_meetPeoplePanel->showFriend();
+ QCOMPARE(requestShowFriendSpy.count(), 1);
+ QCOMPARE(listViewStub->stubCallCount("clearItemSelection"), 1);
+}
+
QTEST_MAIN(TestMeetPeoplePanel)
#include "testmeetpeoplepanel.moc"
--- /dev/null
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+ ../../stubs/stubbase.h \
+ ./../stubs/listitemstub.h \
+ ../../stubs/extendedlistitemstub.h \
+ ../../../src/ui/messagelistitem.h \
+ ../../../src/ui/listcommon.h \
+ ../../../src/coordinates/geocoordinate.h \
+ ../../../src/coordinates/scenecoordinate.h \
+ ../../../src/situareservice/message.h
+
+SOURCES += \
+ ../../stubs/stubbase.cpp \
+ ../../../src/ui/messagelistitem.cpp \
+ ../../../src/coordinates/geocoordinate.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ ../../../src/situareservice/message.cpp \
+ testmessagelistitem.cpp
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QtTest>
+#include <QtGui>
+
+#include "../../stubs/extendedlistitemstub.h"
+#include "../../../src/situareservice/message.h"
+#include "../../../src/coordinates/geocoordinate.h"
+
+#include "../../../src/ui/messagelistitem.h"
+
+class TestMessageListItem: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void cleanup();
+ void init();
+ void setMessageData();
+
+private:
+ MessageListItem *m_messageListItem;
+};
+
+void TestMessageListItem::cleanup()
+{
+ delete m_messageListItem;
+
+ extendedListItemStub->stubReset();
+}
+
+void TestMessageListItem::init()
+{
+ m_messageListItem = new MessageListItem();
+ QVERIFY(m_messageListItem);
+}
+
+void TestMessageListItem::setMessageData()
+{
+ Message message1;
+ message1.setReceiverId("1");
+ message1.setSenderId("3");
+ Message message2(Message::MessageTypeSent);
+ message2.setReceiverId("1");
+ message2.setSenderId("3");
+ message2.setCoordinates(GeoCoordinate(65.5, 25.5));
+
+ m_messageListItem->setMessageData(message1);
+ QCOMPARE(m_messageListItem->newMessageReceiverId(), QString("3"));
+ QCOMPARE(extendedListItemStub->stubCallCount("setImage"), 0);
+ QCOMPARE(extendedListItemStub->stubCallCount("addSubItem"), 2);
+
+ extendedListItemStub->stubReset();
+
+ m_messageListItem->setMessageData(message2);
+ QCOMPARE(m_messageListItem->newMessageReceiverId(), QString("1"));
+ QCOMPARE(extendedListItemStub->stubCallCount("addSubItem"), 3);
+}
+
+QTEST_MAIN(TestMessageListItem)
+#include "testmessagelistitem.moc"
+
+
--- /dev/null
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+ ../../stubs/stubbase.h \
+ ../../stubs/listviewstub.h \
+ ../../stubs/messagelistitemstub.h \
+ ../../../src/ui/messagelistview.h \
+ ../../../src/ui/listview.h \
+ ../../../src/coordinates/geocoordinate.h \
+ ../../../src/coordinates/scenecoordinate.h
+
+SOURCES += \
+ ../../stubs/stubbase.cpp \
+ ../../../src/ui/messagelistview.cpp \
+ ../../../src/coordinates/geocoordinate.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ testmessagelistview.cpp
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QtTest>
+#include <QtGui>
+
+#include "../../stubs/listviewstub.h"
+#include "../../stubs/messagelistitemstub.h"
+
+#include "../../../src/ui/messagelistview.h"
+
+class TestMessageListView: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void cleanup();
+ void init();
+ void listItemClicked();
+
+private:
+ MessageListView *m_messageListView;
+};
+
+void TestMessageListView::cleanup()
+{
+ delete m_messageListView;
+
+ listViewStub->stubReset();
+}
+
+void TestMessageListView::init()
+{
+ m_messageListView = new MessageListView();
+ QVERIFY(m_messageListView);
+}
+
+void TestMessageListView::listItemClicked()
+{
+ MessageListItem item;
+
+ QSignalSpy messageItemClickedSpy(m_messageListView, SIGNAL(messageItemClicked(GeoCoordinate)));
+ QVERIFY(messageItemClickedSpy.isValid());
+
+ m_messageListView->listItemClicked(0);
+ QCOMPARE(messageItemClickedSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("listItemClicked", false);
+
+ m_messageListView->listItemClicked(&item);
+ QCOMPARE(listViewStub->stubCallCount("listItemClicked"), 2);
+ QCOMPARE(messageItemClickedSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("listItemClicked", true);
+
+ m_messageListView->listItemClicked(&item);
+ QCOMPARE(messageItemClickedSpy.count(), 0);
+
+ messageListItemStub->stubSetReturnValue("coordinates", GeoCoordinate(55.2, 22.5));
+
+ m_messageListView->listItemClicked(&item);
+ QCOMPARE(messageItemClickedSpy.count(), 1);
+}
+
+QTEST_MAIN(TestMessageListView)
+#include "testmessagelistview.moc"
+
--- /dev/null
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+ ../../stubs/stubbase.h \
+ ../../stubs/listviewstub.h \
+ ../../stubs/personlistitemstub.h \
+ ../../../src/ui/personlistview.h \
+ ../../../src/ui/listview.h \
+ ../../../src/coordinates/geocoordinate.h \
+ ../../../src/coordinates/scenecoordinate.h
+
+SOURCES += \
+ ../../stubs/stubbase.cpp \
+ ../../../src/ui/personlistview.cpp \
+ ../../../src/coordinates/geocoordinate.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ testpersonlistview.cpp
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QtTest>
+#include <QtGui>
+
+#include "../../stubs/listviewstub.h"
+#include "../../stubs/personlistitemstub.h"
+
+#include "../../../src/ui/personlistview.h"
+
+class TestPersonListView: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void cleanup();
+ void init();
+ void listItemClicked();
+
+private:
+ PersonListView *m_personListView;
+};
+
+void TestPersonListView::cleanup()
+{
+ delete m_personListView;
+
+ listViewStub->stubReset();
+}
+
+void TestPersonListView::init()
+{
+ m_personListView = new PersonListView();
+ QVERIFY(m_personListView);
+}
+
+void TestPersonListView::listItemClicked()
+{
+ PersonListItem item;
+
+ QSignalSpy personItemClickedSpy(m_personListView, SIGNAL(personItemClicked(GeoCoordinate)));
+ QVERIFY(personItemClickedSpy.isValid());
+
+ m_personListView->listItemClicked(0);
+ QCOMPARE(personItemClickedSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("listItemClicked", false);
+
+ m_personListView->listItemClicked(&item);
+ QCOMPARE(listViewStub->stubCallCount("listItemClicked"), 2);
+ QCOMPARE(personItemClickedSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("listItemClicked", true);
+
+ m_personListView->listItemClicked(&item);
+ QCOMPARE(personItemClickedSpy.count(), 0);
+
+ personListItemStub->stubSetReturnValue("coordinates", GeoCoordinate(55.2, 22.5));
+
+ m_personListView->listItemClicked(&item);
+ QCOMPARE(personItemClickedSpy.count(), 1);
+}
+
+QTEST_MAIN(TestPersonListView)
+#include "testpersonlistview.moc"
+
void initTestCase();
void cleanup();
void init();
- void addTagToList();
- void addAndDeleteTag();
+ void addTagToUserTagList();
+ void addAndDeleteTagFromUserTagList();
+ void populateUserTags();
private:
QHash<QString, QString> m_tags;
{
m_tagsDialog = new TagsDialog(m_tags);
QVERIFY(m_tagsDialog);
- QCOMPARE(m_tagsDialog->m_tagsView->count(), 3);
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
}
void TestTagsDialog::initTestCase()
m_tags.insert("3", "britney spears");
}
-void TestTagsDialog::addTagToList()
+void TestTagsDialog::addTagToUserTagList()
{
m_tagsDialog->m_addTagEdit->setText("new age");
m_tagsDialog->addTagToList();
- QCOMPARE(m_tagsDialog->m_tagsView->count(), 4);
- QCOMPARE(m_tagsDialog->m_tagsView->item(0)->text(), QString("new age"));
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 4);
+ QCOMPARE(m_tagsDialog->m_userTagsView->item(0)->text(), QString("new age"));
QVERIFY(m_tagsDialog->newTags().contains("new age"));
}
-void TestTagsDialog::addAndDeleteTag()
+void TestTagsDialog::addAndDeleteTagFromUserTagList()
{
- addTagToList();
+ addTagToUserTagList();
- m_tagsDialog->m_tagsView->setItemSelected(m_tagsDialog->m_tagsView->item(0), true);
+ m_tagsDialog->m_userTagsView->setItemSelected(m_tagsDialog->m_userTagsView->item(0), true);
m_tagsDialog->deleteTagFromList();
- QCOMPARE(m_tagsDialog->m_tagsView->count(), 3);
- QVERIFY(m_tags.contains("1"));
- QVERIFY(m_tags.contains("2"));
- QVERIFY(m_tags.contains("3"));
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
- QListWidgetItem *item = m_tagsDialog->m_tagsView->item(0);
- m_tagsDialog->m_tagsView->setItemSelected(item, true);
+ QListWidgetItem *item = m_tagsDialog->m_userTagsView->item(0);
+ m_tagsDialog->m_userTagsView->setItemSelected(item, true);
m_tagsDialog->deleteTagFromList();
- QCOMPARE(m_tagsDialog->m_tagsView->count(), 2);
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 2);
QVERIFY(m_tagsDialog->removedTags().contains(item->text()));
}
+void TestTagsDialog::populateUserTags()
+{
+ QHash<QString, QString> tags;
+ tags.insert("1", "pop");
+ tags.insert("2", "rock");
+ tags.insert("3", "britney spears");
+
+ m_tagsDialog->populateUserTags(tags);
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
+
+ tags.insert("5", "new age");
+
+ m_tagsDialog->populateUserTags(tags);
+ QCOMPARE(m_tagsDialog->m_userTagsView->count(), 4);
+}
+
QTEST_MAIN(TestTagsDialog)
#include "testtagsdialog.moc"