Added chat history to a room that is displayed on join.

With this update a new chat history definition is added on a per
room bases which allows operators to specify the number of chat
messages to store and present to the user on join.  Please see
the sample ini for room definitions.
This commit is contained in:
woogerboy21 2015-09-12 13:46:22 -04:00
parent f97a7e8370
commit 87a64da1bc
23 changed files with 141 additions and 16 deletions

View file

@ -13,6 +13,7 @@
#include <QSystemTrayIcon>
#include <QCompleter>
#include <QWidget>
#include <QtCore/qdatetime.h>
#include "tab_supervisor.h"
#include "tab_room.h"
#include "tab_userlists.h"
@ -34,6 +35,7 @@
#include "pending_command.h"
#include "dlg_settings.h"
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, const ServerInfo_Room &info)
: Tab(_tabSupervisor), client(_client), roomId(info.room_id()), roomName(QString::fromStdString(info.name())), ownUser(_ownUser)
{
@ -265,8 +267,11 @@ void TabRoom::processLeaveRoomEvent(const Event_LeaveRoom &event)
void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
{
QString senderName = QString::fromStdString(event.name());
QString message = QString::fromStdString(event.message());
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(senderName))
return;
UserListTWI *twi = userList->getUsers().value(senderName);
UserLevelFlags userLevel;
if (twi) {
@ -274,7 +279,15 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
if (settingsCache->getIgnoreUnregisteredUsers() && !userLevel.testFlag(ServerInfo_User::IsRegistered))
return;
}
chatView->appendMessage(QString::fromStdString(event.message()), senderName, userLevel, true);
if (event.message_type() == Event_RoomSay::ChatHistory && !settingsCache->getRoomHistory())
return;
if (event.message_type() == Event_RoomSay::ChatHistory)
message = "[" + QString(QDateTime::fromMSecsSinceEpoch(event.time_of()).toLocalTime().toString("d MMM yyyy HH:mm:ss")) + "] " + message;
chatView->appendMessage(message, event.message_type(), senderName, userLevel, true);
emit userEvent(false);
}