You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dialogchat.cpp 1009B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "dialogchat.h"
  2. #include "ui_dialogchat.h"
  3. DialogChat::DialogChat(QWidget *parent) : QWidget(parent), ui(new Ui::DialogChat)
  4. {
  5. ui->setupUi(this);
  6. }
  7. DialogChat::~DialogChat()
  8. {
  9. delete ui;
  10. }
  11. NetSoul::User DialogChat::getUser()
  12. {
  13. return m_user;
  14. }
  15. bool DialogChat::match(NetSoul::User usr)
  16. {
  17. return usr.login == m_user.login && usr.location == m_user.location;
  18. }
  19. void DialogChat::closeEvent(QCloseEvent* e)
  20. {
  21. e->ignore();
  22. hide();
  23. }
  24. void DialogChat::setUser(NetSoul::User user)
  25. {
  26. m_user = user;
  27. setWindowTitle(user.login + "@" + user.location);
  28. }
  29. void DialogChat::newMessage(NetSoul::Message msg)
  30. {
  31. append(msg.from, msg.message);
  32. }
  33. void DialogChat::setMe(NetSoul::User usr)
  34. {
  35. m_me = usr;
  36. }
  37. void DialogChat::on_lineChat_returnPressed()
  38. {
  39. emit sendMessageRequested(m_user, ui->lineChat->text());
  40. append(m_me, ui->lineChat->text());
  41. ui->lineChat->clear();
  42. }
  43. void DialogChat::append(NetSoul::User usr, QString msg)
  44. {
  45. ui->textChat->append(usr.login + "@" + usr.location + ": " + msg);
  46. }