From 8a0803372818735f8140ad2d0412ec96df9ce409 Mon Sep 17 00:00:00 2001 From: beardog_uk Date: Thu, 12 Mar 2009 14:14:55 +0000 Subject: [PATCH] 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 --- retroshare-gui/src/gui/PeersDialog.cpp | 32 +++++++++++++++++++------- retroshare-gui/src/gui/PeersDialog.h | 4 ++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index dc344b976..9cba652fa 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -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 = "" + timestamp + "" + - "" + " " + name + ""; - + "" + " " + name + "fff"; + + //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)) { diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index 30cea8d86..15e16041c 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -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;