Display the list of conversations.

This commit is contained in:
Pierre HUBERT
2018-12-07 11:31:42 +01:00
parent 3d9748ad62
commit 1df359735d
24 changed files with 484 additions and 11 deletions

View File

@ -1,4 +1,5 @@
#include "conversation.h"
#include "userslist.h"
Conversation::Conversation()
{

View File

@ -15,3 +15,13 @@ QList<int> ConversationsList::getAllMembersId() const
}
return members;
}
UsersList ConversationsList::getMembersInformation() const
{
return mMembersInformation;
}
void ConversationsList::setMembersInformation(const UsersList &membersInformation)
{
mMembersInformation = membersInformation;
}

View File

@ -10,6 +10,8 @@
#include <QList>
#include "conversation.h"
#include "user.h"
#include "userslist.h"
class ConversationsList : public QList<Conversation>
{
@ -23,6 +25,14 @@ public:
* @return The IDs of the conversations
*/
QList<int> getAllMembersId() const;
UsersList getMembersInformation() const;
void setMembersInformation(const UsersList &membersInformation);
private:
//Private fields
UsersList mMembersInformation;
};
#endif // CONVERSATIONSLIST_H

View File

@ -35,6 +35,11 @@ void User::setLastName(const QString &lastName)
mLastName = lastName;
}
QString User::displayName() const
{
return firstName() + " " + lastName();
}
QString User::accountImage() const
{
return mAccountImage;

View File

@ -23,6 +23,11 @@ public:
QString lastName() const;
void setLastName(const QString &lastName);
/**
* Get and return display name of the user
*/
QString displayName() const;
QString accountImage() const;
void setAccountImage(const QString &accountImage);

16
data/userslist.cpp Normal file
View File

@ -0,0 +1,16 @@
#include "userslist.h"
UsersList::UsersList() : QList()
{
}
User UsersList::get(int userID) const
{
for(User user : *this)
if(user.iD() == userID)
return user;
//User not found
return User();
}

31
data/userslist.h Normal file
View File

@ -0,0 +1,31 @@
/**
* A list of users
*
* Provides methods to fetch users
*
* @author Pierre HUBERT
*/
#ifndef USERSLISTS_H
#define USERSLISTS_H
#include <QList>
#include "user.h"
class UsersList : public QList<User>
{
public:
UsersList();
/**
* Find and return information about a user specified
* by its ID
*
* @param userID The ID of the target user
* @return Information about the user
*/
User get(int userID) const;
};
#endif // USERSLISTS_H