forked from kutegram/client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhistorywindow.cpp
51 lines (42 loc) · 1.54 KB
/
historywindow.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
#include "historywindow.h"
#include "ui_historywindow.h"
#include "historyitemdelegate.h"
#include "library/telegramclient.h"
#include <QScrollBar>
HistoryWindow::HistoryWindow(TelegramClient *client, TLInputPeer input, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::HistoryWindow),
flickcharm(),
client(client),
model(0),
backAction(this)
{
ui->setupUi(this);
#if QT_VERSION >= 0x040702
ui->messageEdit->setPlaceholderText(QApplication::translate("HistoryWindow", "Type a message...", 0, QApplication::UnicodeUTF8));
#endif
connect(&backAction, SIGNAL(triggered()), this, SLOT(backAction_triggered()));
backAction.setText(QApplication::translate("HistoryWindow", "Back", 0, QApplication::UnicodeUTF8));
backAction.setIcon(QIcon(":/icons/back.svg"));
backAction.setSoftKeyRole(QAction::NegativeSoftKey);
addAction(&backAction);
flickcharm.activateOn(ui->historyView);
ui->historyView->setModel(model = new HistoryItemModel(client, input, ui->historyView));
ui->historyView->setItemDelegate(new HistoryItemDelegate(ui->historyView));
if (model->canFetchMoreUpwards(QModelIndex())) model->fetchMoreUpwards(QModelIndex());
if (model->canFetchMore(QModelIndex())) model->fetchMore(QModelIndex());
}
HistoryWindow::~HistoryWindow()
{
delete ui;
}
void HistoryWindow::sendButton_clicked()
{
if (ui->messageEdit->text().isEmpty()) return;
client->sendMessage(model->peer, ui->messageEdit->text());
ui->messageEdit->clear();
}
void HistoryWindow::backAction_triggered()
{
close();
}