m_itemButtonsLayout->addWidget(messageButton);
}
+void MeetPeoplePanel::addHeaderItem(const QString &key, const QString &title)
+{
+ m_personListView->setItemDelegateForRow(m_personListView->count(), m_headerListItemDelegate);
+ ExtendedListItem *friendsHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
+ friendsHeaderItem->setTitle(title);
+ m_personListView->addListItem(key, friendsHeaderItem);
+}
+
void MeetPeoplePanel::anyPanelClosed()
{
qDebug() << __PRETTY_FUNCTION__;
initItemDelegates();
if (friends.count() > 0) {
- m_personListView->setItemDelegateForRow(0, m_headerListItemDelegate);
- ExtendedListItem *friendsHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
- friendsHeaderItem->setTitle(tr("Friends:"));
- m_personListView->addListItem(QString("friendsHeader"), friendsHeaderItem);
+ addHeaderItem("friendsHeader", tr("Friends:"));
foreach (User user, friends) {
PersonListItem *item = new PersonListItem();
}
if (others.count() > 0) {
+ addHeaderItem("friendsHeader", tr("Friends:"));
+
m_personListView->setItemDelegateForRow(m_personListView->count(),
m_headerListItemDelegate);
ExtendedListItem *othersHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
*/
void hideEvent(QHideEvent *event);
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
private slots:
/**
* @brief Called when any of the panel tabs is closed
private:
/**
+ * @brief Adds header item to the list.
+ *
+ * @param key item key
+ * @param title item title
+ */
+ void addHeaderItem(const QString &key, const QString &title);
+
+ /**
* @brief Inits item delegates for message list view.
*/
void initItemDelegates();
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
signals:
/**
* @brief Signal for person finding
qDebug() << __PRETTY_FUNCTION__;
}
-GeoCoordinate &MessageListItem::coordinates() const
+GeoCoordinate MessageListItem::coordinates() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_coordinates;
}
-QString &MessageListItem::id() const
+QString MessageListItem::id() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_id;
}
-QString &MessageListItem::newMessageReceiverId() const
+QString MessageListItem::newMessageReceiverId() const
{
qDebug() << __PRETTY_FUNCTION__;
*
* @return item's coordinates
*/
- GeoCoordinate &coordinates() const;
+ GeoCoordinate coordinates() const;
/**
* @brief Returns message's ID.
*
* @return message's ID
*/
- QString &id() const;
+ QString id() const;
/**
* @brief Returns new message message receiver's ID.
*
* @return new message message receiver's ID
*/
- QString &newMessageReceiverId() const;
+ QString newMessageReceiverId() const;
/**
* @brief Sets new message message receiver's ID.
******************************************************************************/
private:
QString m_id; ///< message's ID
- QString m_newMessageReceiverId; ///< new message reveiver's ID
+ QString m_newMessageReceiverId; ///< new message reveiver's ID
GeoCoordinate m_coordinates; ///< message's coordinates
};
#include "messagelistitem.h"
#include "messagelistview.h"
#include "panelcommon.h"
-#include "situareservice/message.h"
+#include "../situareservice/message.h"
#include "messagepanel.h"
m_genericButtonsLayout->addWidget(refreshMessagesButton);
}
+void MessagePanel::addHeaderItem(const QString &key, const QString &title)
+{
+ m_messageListView->setItemDelegateForRow(m_messageListView->count(), m_headerListItemDelegate);
+ ExtendedListItem *receivedHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
+ receivedHeaderItem->setTitle(title);
+ m_messageListView->addListItem(key, receivedHeaderItem);
+}
+
void MessagePanel::anyPanelClosed()
{
qDebug() << __PRETTY_FUNCTION__;
initItemDelegates();
if (received.count() > 0) {
- m_messageListView->setItemDelegateForRow(0, m_headerListItemDelegate);
- ExtendedListItem *receivedHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
- receivedHeaderItem->setTitle(tr("Received:"));
- m_messageListView->addListItem(QString("receivedHeader"), receivedHeaderItem);
+ addHeaderItem("receivedHeader", tr("Received from:"));
foreach (Message message, received) {
MessageListItem *item = new MessageListItem();
}
if (sent.count() > 0) {
- m_messageListView->setItemDelegateForRow(m_messageListView->count(),
- m_headerListItemDelegate);
- ExtendedListItem *sentHeaderItem = new ExtendedListItem(0, QListWidgetItem::UserType);
- sentHeaderItem->setTitle(tr("Sent:"));
- m_messageListView->addListItem(QString("sentHeader"), sentHeaderItem);
+ addHeaderItem("sentHeader", tr("Sent to:"));
foreach (Message message, sent) {
MessageListItem *item = new MessageListItem();
public:
/**
+ * @brief Unit test class
+ */
+ friend class TestMessagePanel;
+
+ /**
* @brief Default constructor
*
* @param parent
private:
/**
+ * @brief Adds header item to the list.
+ *
+ * @param key item key
+ * @param title item title
+ */
+ void addHeaderItem(const QString &key, const QString &title);
+
+ /**
* @brief Inits item delegates for message list view.
*/
void initItemDelegates();
--- /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/messagelistview.h"
+#include "listviewstub.h"
+#include "stubbase.h"
+
+class MessageListViewStub : public StubBase
+{
+public:
+ virtual void MessageListViewConstructor(QWidget *parent = 0);
+ virtual bool listItemClicked(ListItem *item);
+};
+
+void MessageListViewStub::MessageListViewConstructor(QWidget *parent)
+{
+ Q_UNUSED(parent)
+}
+
+bool MessageListViewStub::listItemClicked(ListItem *item)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<ListItem *>(item));
+ stubMethodEntered("listItemClicked", params);
+
+ return stubReturnValue<bool>("listItemClicked");
+}
+
+//Create a stub instance
+MessageListViewStub defaultMessageListViewStub;
+MessageListViewStub *messageListViewStub = &defaultMessageListViewStub;
+
+MessageListView::MessageListView(QWidget *parent)
+ : ListView(parent)
+{
+ messageListViewStub->MessageListViewConstructor(parent);
+}
+
+bool MessageListView::listItemClicked(ListItem *item)
+{
+ return messageListViewStub->listItemClicked(item);
+}
+
+#endif // PERSONLISTVIEWSTUB_H
listviewstub.h \
listitemstub.h \
extendedlistitemstub.h \
- messagelistitemstub.h
+ messagelistitemstub.h \
+ messagelistviewstub.h
SOURCES += \
stubbase.cpp
--- /dev/null
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+ ../../stubs/stubbase.h \
+ ../../stubs/messagelistitemstub.h \
+ ../../stubs/messagelistviewstub.h \
+ ../../../src/ui/messagelistview.h \
+ ../../../src/ui/listview.h \
+ ../../../src/ui/imagebutton.h \
+ ../../../src/ui/messagepanel.h \
+ ../../../src/ui/panelcommon.h \
+ ../../../src/ui/panelbase.h \
+ ../../../src/ui/extendedlistitemdelegate.h \
+ ../../../src/ui/extendedlistitemstore.h \
+ ../../../src/ui/headerlistitemdelegate.h \
+ ../../../src/ui/listitemdelegate.h \
+ ../../../src/coordinates/geocoordinate.h \
+ ../../../src/coordinates/scenecoordinate.h \
+ ../../../src/situareservice/message.h \
+
+SOURCES += \
+ ../../stubs/stubbase.cpp \
+ ../../../src/ui/messagepanel.cpp \
+ ../../../src/coordinates/geocoordinate.cpp \
+ ../../../src/ui/panelbase.cpp \
+ ../../../src/ui/imagebutton.cpp \
+ ../../../src/ui/extendedlistitemdelegate.cpp \
+ ../../../src/ui/headerlistitemdelegate.cpp \
+ ../../../src/ui/extendedlistitemstore.cpp \
+ ../../../src/situareservice/message.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ ../../../src/ui/listitemdelegate.cpp \
+ testmessagepanel.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 <QMetaType>
+
+#include "../../stubs/messagelistviewstub.h"
+#include "../../stubs/messagelistitemstub.h"
+
+#include "../../../src/ui/messagepanel.h"
+
+class TestMessagePanel: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void cleanup();
+ void init();
+ void messageButtonPressed();
+
+private:
+ QList<Message> getMessages();
+
+private:
+ MessagePanel *m_messagePanel;
+};
+
+void TestMessagePanel::cleanup()
+{
+ delete m_messagePanel;
+
+ listViewStub->stubReset();
+}
+
+void TestMessagePanel::init()
+{
+ m_messagePanel = new MessagePanel();
+ QVERIFY(m_messagePanel);
+}
+
+QList<Message> TestMessagePanel::getMessages()
+{
+ QList<Message> messages;
+ Message message1;
+ message1.setSenderId("1");
+ message1.setReceiverId("2");
+ Message message2(Message::MessageTypeSent);
+ message2.setSenderId("3");
+ message2.setReceiverId("4");
+ messages.append(message1);
+ messages.append(message2);
+
+ return messages;
+}
+
+void TestMessagePanel::messageButtonPressed()
+{
+ MessageListItem messageItem;
+ messageItem.setMessageData(getMessages().at(0));
+ messageListItemStub->stubSetReturnValue("newMessageReceiverId", QString("1"));
+
+ typedef QPair<QString, QString> ReceiverPair;
+ Q_DECLARE_METATYPE(ReceiverPair);
+ qRegisterMetaType< QPair<QString, QString> >("QPair<QString,QString>");
+
+ QSignalSpy requestMessageDialogSpy(m_messagePanel,
+ SIGNAL(requestMessageDialog(QPair<QString,QString>)));
+ QVERIFY(requestMessageDialogSpy.isValid());
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+ m_messagePanel->messageButtonPressed();
+ QCOMPARE(requestMessageDialogSpy.count(), 0);
+
+ listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&messageItem);
+
+ m_messagePanel->messageButtonPressed();
+ QCOMPARE(listViewStub->stubCallCount("clearItemSelection"), 1);
+ QCOMPARE(requestMessageDialogSpy.count(), 1);
+ QList<QVariant> arguments = requestMessageDialogSpy.takeFirst();
+ //QPair<QString, QString> receiver = arguments.at(0).value<QPair<QString, QString> >();
+}
+
+QTEST_MAIN(TestMessagePanel)
+#include "testmessagepanel.moc"
+
+