-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
101 lines (88 loc) · 2.44 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QIcon>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->listWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
//ui->emoList->hide();
md = new ModemDriver();
this->setupSignals();
firstShow = false;
}
MainWindow::~MainWindow()
{
delete ui;
delete md;
}
void MainWindow::setupSignals()
{
connect(ui->tEdit_message, &QTextEdit::textChanged, this, &MainWindow::addTask);
connect(ui->textButton, &QPushButton::clicked, this, &MainWindow::addDiscussion);
connect(ui->tBtn_emoji,&QPushButton::clicked,this,&MainWindow::showEmoji);
connect(ui->psbGetContact,&QPushButton::clicked,this,&MainWindow::getContacts);
connect(md,&ModemDriver::contactsReceived,this,&MainWindow::onGetContacts);
connect(ui->psbAddMsg,&QPushButton::clicked,this,&MainWindow::displayMessage);
}
void MainWindow::addTask()
{
qDebug() << "on appele";
}
void MainWindow::addDiscussion()
{
QString text = this->ui->lneNumber->text();
Discussion ds = Discussion(this->ui->listWidget, NULL, text);
discussList.append(ds);
}
void MainWindow::showEmoji()
{
/*ui->emoList->show();
int i=0;
foreach( const QString &imageName, QDir(":emojis/Graphics/Emojis/png_512x512").entryList() )
{
qDebug()<< imageName;
QListWidgetItem *item = new QListWidgetItem(QIcon(":emojis/Graphics/Emojis/png_512x512/"+imageName),"");
ui->emoList->insertItem(ui->emoList->currentRow(),item);
if(++i>50)
break;
}*/
}
void MainWindow::onGetContacts(QList<Contact> &contacts)
{
foreach(Contact ct,contacts)
{
Discussion ds = Discussion(this->ui->listWidget, NULL, ct.getName());
//ct.saveToLocal();
}
}
void MainWindow::getContacts()
{
md->getContacts();
}
void MainWindow::loadAll()
{
}
void MainWindow::showEvent(QShowEvent *ev)
{
if(!firstShow)
{
QList<Contact> ctList = Contact::getFromDatabase();
onGetContacts(ctList);
firstShow = true;
}
QMainWindow::showEvent(ev);
}
void MainWindow::displayMessage()
{
qDebug()<< "Called";
Message msg("wandaful",0);
MessageWidget* msgWid = new MessageWidget(msg);
ui->discussLayout->addWidget(msgWid);
//msgWid->show();
/*msgWid->setGeometry(50,50,0,0);
ui->frame_2->hide();
ui->frame_2->show();*/
//delete msgWid;
}