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 */ /** Constructor */
PeersDialog::PeersDialog(QWidget *parent) 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 */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -149,7 +151,15 @@ PeersDialog::PeersDialog(QWidget *parent)
mCurrentFont = QFont("Comic Sans MS", 12); mCurrentFont = QFont("Comic Sans MS", 12);
ui.lineEdit->setFont(mCurrentFont); 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(); QMenu * grpchatmenu = new QMenu();
grpchatmenu->addAction(ui.actionClearChat); grpchatmenu->addAction(ui.actionClearChat);
@ -692,8 +702,11 @@ void PeersDialog::insertChat()
QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss"); QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
QString name = QString::fromStdString(it->name); QString name = QString::fromStdString(it->name);
QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" + 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 += line;
extraTxt += QString::fromStdWString(it->msg); extraTxt += QString::fromStdWString(it->msg);
@ -711,6 +724,7 @@ void PeersDialog::insertChat()
msgWidget->setHtml(currenttxt); msgWidget->setHtml(currenttxt);
QScrollBar *qsb = msgWidget->verticalScrollBar(); QScrollBar *qsb = msgWidget->verticalScrollBar();
@ -749,6 +763,8 @@ void PeersDialog::sendMsg()
ci.msg = lineWidget->toHtml().toStdWString(); ci.msg = lineWidget->toHtml().toStdWString();
ci.chatflags = RS_CHAT_PUBLIC; ci.chatflags = RS_CHAT_PUBLIC;
//historyKeeper.addMessage("THIS", "ALL", lineWidget->toHtml() );
std::string msg(ci.msg.begin(), ci.msg.end()); std::string msg(ci.msg.begin(), ci.msg.end());
#ifdef PEERS_DEBUG #ifdef PEERS_DEBUG
std::cerr << "PeersDialog::sendMsg(): " << msg << std::endl; std::cerr << "PeersDialog::sendMsg(): " << msg << std::endl;
@ -996,10 +1012,10 @@ void PeersDialog::displayInfoChatMenu(const QPoint& pos)
void PeersDialog::loadEmoticonsgroupchat() void PeersDialog::loadEmoticonsgroupchat()
{ {
QString sm_codes; QString sm_codes;
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs"); QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs");
#else #else
QFile sm_file(QString(":/smileys/emotes.acs")); QFile sm_file(QString(":/smileys/emotes.acs"));
#endif #endif
if(!sm_file.open(QIODevice::ReadOnly)) if(!sm_file.open(QIODevice::ReadOnly))
{ {

View File

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