mirror of
https://gitlab.com/comunic/comunicmessages
synced 2025-09-22 23:38:50 +00:00
Can get the list of conversations
This commit is contained in:
33
widgets/conversationslistwidget.cpp
Normal file
33
widgets/conversationslistwidget.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "conversationslistwidget.h"
|
||||
#include "../helpers/conversationslisthelper.h"
|
||||
|
||||
ConversationsListWidget::ConversationsListWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
//Create conversations helper
|
||||
mConversationsList = new ConversationsListHelper(this);
|
||||
connect(mConversationsList, &ConversationsListHelper::onGotList, this, &ConversationsListWidget::onGotConversationsList);
|
||||
}
|
||||
|
||||
ConversationsListWidget::~ConversationsListWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ConversationsListWidget::refresh()
|
||||
{
|
||||
mConversationsList->getList();
|
||||
}
|
||||
|
||||
void ConversationsListWidget::onGotConversationsList(bool success, const QList<Conversation> &list)
|
||||
{
|
||||
qWarning("Got conversations list (or failure).");
|
||||
|
||||
if(!success)
|
||||
qWarning("Failure.");
|
||||
else {
|
||||
for(Conversation conv : list){
|
||||
qWarning("Conv %d : %s", conv.iD(), conv.name().toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
37
widgets/conversationslistwidget.h
Normal file
37
widgets/conversationslistwidget.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef CONVERSATIONSLISTWIDGET_H
|
||||
#define CONVERSATIONSLISTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "../data/conversation.h"
|
||||
|
||||
class ConversationsListHelper;
|
||||
|
||||
class ConversationsListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConversationsListWidget(QWidget *parent = nullptr);
|
||||
~ConversationsListWidget();
|
||||
|
||||
/**
|
||||
* Refresh the list of conversations of the user
|
||||
*/
|
||||
void refresh();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* This slot is triggered once we have got a new list of conversations
|
||||
*
|
||||
* @param success TRUE for a success / FALSE else
|
||||
* @param list The list of conversation (empty list in case of failure)
|
||||
*/
|
||||
void onGotConversationsList(bool success, const QList<Conversation> &list);
|
||||
|
||||
private:
|
||||
ConversationsListHelper *mConversationsList;
|
||||
};
|
||||
|
||||
#endif // CONVERSATIONSLISTWIDGET_H
|
@@ -4,6 +4,7 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include "aboutthisappdialog.h"
|
||||
#include "loginwidget.h"
|
||||
#include "conversationslistwidget.h"
|
||||
|
||||
#include "../helpers/accounthelper.h"
|
||||
|
||||
@@ -12,6 +13,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//Display the list of conversations
|
||||
mConversationsListWidget = new ConversationsListWidget;
|
||||
mConversationsListWidget->refresh();
|
||||
ui->conversationsListArea->setWidget(mConversationsListWidget);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@@ -13,6 +13,8 @@ namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class ConversationsListWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -30,6 +32,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ConversationsListWidget *mConversationsListWidget;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@@ -13,7 +13,27 @@
|
||||
<property name="windowTitle">
|
||||
<string>ComunicMessages</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="conversationsListArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>780</width>
|
||||
<height>536</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
Reference in New Issue
Block a user