fixed some not need things for Chatting which does destroy the Chat format when Chatting, removed lastname and not needed lines which makes chatting bad

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2008-03-21 14:56:41 +00:00
parent 7044822e1f
commit 08bdd8f567
2 changed files with 22 additions and 118 deletions

View File

@ -118,37 +118,15 @@ void ChatDialog::insertChat()
return;
}
QTextEdit *msgWidget = ui.msgText;
QTextEdit *msgWidget = ui.msgText;
std::list<ChatInfo>::iterator it;
static std::string lastChatName("");
static int lastChatTime = 0;
//QString color = ci.messageColor.name();
//QString nickColor;
//QString font = ci.messageFont.family();
//QString fontSize = QString::number(ci.messageFont.pointSize());
/* determine how many spaces to add */
//int n = msgWidget->width();
/* now spaces = (width - txt width) / (pixel / space)
*/
//std::cerr << "Width is : " << n << std::endl;
/*n -= 256; 220 pixels for name */
/*if (n > 0)
{
n = 2 + n / 10;
}
else
{
n = 1;
}
n = 1 + n / 2;*/ /* shrink it! */
/* add in lines at the bottom */
int ts = time(NULL);
for(it = newchat.begin(); it != newchat.end(); it++)
{
/* are they private? */
@ -163,46 +141,20 @@ void ChatDialog::insertChat()
QString currenttxt = msgWidget->toHtml();
QString extraTxt;
if ((it->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
#if defined(Q_OS_WIN)
/* nothing */
#else
extraTxt += "<br>\n";
#endif
/*for(int i = 0; i < n; i++)
{
extraTxt += " ";
}*/
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
QString name = QString::fromStdString(it->name);
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
QString name = QString::fromStdString(it->name);
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span> <br>";
extraTxt += line;
extraTxt += line;
}
extraTxt += QString::fromStdWString(it->msg);
/* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */
#if defined(Q_OS_WIN)
extraTxt += "\n";
#else
extraTxt += "\n";
#endif
lastChatName = it -> name;
lastChatTime = ts;
/* add it everytime */
extraTxt += QString::fromStdWString(it->msg);
/* add it everytime */
currenttxt += extraTxt;
msgWidget->setHtml(currenttxt);
msgWidget->setHtml(currenttxt);
QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum());
@ -216,10 +168,10 @@ void ChatDialog::sendMsg()
{
QLineEdit *lineWidget = ui.lineEdit;
//QFont font = QFont("Comic Sans MS", 10);
//font.setBold(ui.textboldChatButton->isChecked());
//font.setUnderline(ui.textunderlineChatButton->isChecked());
//font.setItalic(ui.textitalicChatButton->isChecked());
QFont font = QFont("Comic Sans MS", 10);
font.setBold(ui.textboldChatButton->isChecked());
font.setUnderline(ui.textunderlineChatButton->isChecked());
font.setItalic(ui.textitalicChatButton->isChecked());
ChatInfo ci;
ci.msg = lineWidget->text().toStdWString();

View File

@ -174,34 +174,13 @@ void PopupChatDialog::updateChat()
void PopupChatDialog::addChatMsg(ChatInfo *ci)
{
QTextBrowser *msgWidget = ui.textBrowser;
QTextBrowser *msgWidget = ui.textBrowser;
QString currenttxt = msgWidget->toHtml();
/* determine how many spaces to add */
int n = msgWidget->width();
/* now spaces = (width - txt width) / (pixel / space)
*/
//std::cerr << "Width is : " << n << std::endl;
n -= 256; /* 220 pixels for name */
if (n > 0)
{
n = 2 + n / 10;
}
else
{
n = 1;
}
//std::cerr << "Space count : " << n << std::endl;
std::string spaces(" ");
/* add in lines at the bottom */
QString extraTxt;
int ts = time(NULL);
QString extraTxt;
bool offline = true;
@ -224,46 +203,19 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
extraTxt += line;
}
if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
#if defined(Q_OS_WIN)
// Nothing.
#else
extraTxt += "<br>\n";
#endif
for(int i = 0; i < n; i++)
{
extraTxt += " ";
}
QString timestamp = "(" + QDateTime::currentDateTime().toString("hh:mm:ss") + ") ";
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
//QString pre = tr("Peer:" );
QString name = QString::fromStdString(ci->name);
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
" " + name + "</strong></span> \n<br>";
" " + name + "</strong></span> \n<br>";
extraTxt += line;
}
extraTxt += QString::fromStdWString(ci -> msg);
/* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */
#if defined(Q_OS_WIN)
extraTxt += "\n";
#else
extraTxt += "\n";
#endif
lastChatTime = ts;
lastChatName = ci->name;
currenttxt += extraTxt;
msgWidget->setHtml(currenttxt);