added history support in group chat; almost stable;

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1069 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
beardog_uk 2009-03-12 14:14:55 +00:00
parent 05659d6b7c
commit 8a08033728
2 changed files with 28 additions and 8 deletions

View File

@ -81,7 +81,9 @@
/** Constructor */
PeersDialog::PeersDialog(QWidget *parent)
: MainPage(parent), chatDialog(NULL)
: MainPage(parent),
chatDialog(NULL),
historyKeeper(Rshare::dataDirectory() + "/his1.xml")
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -149,7 +151,15 @@ PeersDialog::PeersDialog(QWidget *parent)
mCurrentFont = QFont("Comic Sans MS", 12);
ui.lineEdit->setFont(mCurrentFont);
setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue"));
setChatInfo(tr("Welcome to RetroShare's group chat."),
QString::fromUtf8("blue"));
QStringList him;
historyKeeper.getMessages(him, "", "THIS", 8);
foreach(QString mess, him)
ui.msgText->append(mess);
//setChatInfo(mess, "green");
QMenu * grpchatmenu = new QMenu();
grpchatmenu->addAction(ui.actionClearChat);
@ -692,8 +702,11 @@ void PeersDialog::insertChat()
QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
QString name = QString::fromStdString(it->name);
QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" +
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "fff</strong></span>";
//std::cerr << "PeersDialog::insertChat(): 1.11\n";
historyKeeper.addMessage(name, "THIS", QString::fromStdWString(it->msg));
//std::cerr << "PeersDialog::insertChat(): 1.12\n";
extraTxt += line;
extraTxt += QString::fromStdWString(it->msg);
@ -711,6 +724,7 @@ void PeersDialog::insertChat()
msgWidget->setHtml(currenttxt);
QScrollBar *qsb = msgWidget->verticalScrollBar();
@ -749,6 +763,8 @@ void PeersDialog::sendMsg()
ci.msg = lineWidget->toHtml().toStdWString();
ci.chatflags = RS_CHAT_PUBLIC;
//historyKeeper.addMessage("THIS", "ALL", lineWidget->toHtml() );
std::string msg(ci.msg.begin(), ci.msg.end());
#ifdef PEERS_DEBUG
std::cerr << "PeersDialog::sendMsg(): " << msg << std::endl;
@ -996,10 +1012,10 @@ void PeersDialog::displayInfoChatMenu(const QPoint& pos)
void PeersDialog::loadEmoticonsgroupchat()
{
QString sm_codes;
#if defined(Q_OS_WIN32)
QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs");
#else
QFile sm_file(QString(":/smileys/emotes.acs"));
#if defined(Q_OS_WIN32)
QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs");
#else
QFile sm_file(QString(":/smileys/emotes.acs"));
#endif
if(!sm_file.open(QIODevice::ReadOnly))
{

View File

@ -29,6 +29,8 @@
#include "mainpage.h"
#include "ui_PeersDialog.h"
#include "im_history/IMHistoryKeeper.h"
class QFont;
class QAction;
class QTextEdit;
@ -122,6 +124,8 @@ private:
QAction* removefriendAct;
QTreeWidget *peertreeWidget;
IMHistoryKeeper historyKeeper;
QColor _currentColor;
bool _underline;