From 295d030fb9df956d90efb17296da37f402ab3185 Mon Sep 17 00:00:00 2001
From: Elvio Basello
Date: Mon, 11 Apr 2011 20:24:38 +0000
Subject: more work on #934; improved hungarian notation;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5776 17fca916-40b9-46aa-a4ea-0a15b648b75c
---
src/modules/logview/LogViewWindow.cpp | 91 +++++++++++++++++++++++++----------
1 file changed, 66 insertions(+), 25 deletions(-)
(limited to 'src/modules/logview')
diff --git a/src/modules/logview/LogViewWindow.cpp b/src/modules/logview/LogViewWindow.cpp
index c392f7c74..6b428f2d3 100644
--- a/src/modules/logview/LogViewWindow.cpp
+++ b/src/modules/logview/LogViewWindow.cpp
@@ -672,11 +672,11 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
QString szDate = pLog->date().toString("yyyy.MM.dd");
// The fresh new log
- QString szLogPath = QDir::homePath();
- KviQString::ensureLastCharIs(szLogPath,QChar(KVI_PATH_SEPARATOR_CHAR));
- szLogPath += "temp";
- szLogPath += KVI_PATH_SEPARATOR_CHAR;
- QString szLog = szLogPath+QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate);
+ QString szLog = QDir::homePath();
+ KviQString::ensureLastCharIs(szLog,QChar(KVI_PATH_SEPARATOR_CHAR));
+ szLog += "temp";
+ szLog += KVI_PATH_SEPARATOR_CHAR;
+ szLog += QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate);
// Open file for reading
QFile file(pLog->fileName());
@@ -700,7 +700,6 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
szLine = KviControlCodes::stripControlBytes(szTmp);
// Remove icons' code
- QRegExp rx;
rx.setPattern("^\\d{1,3}\\s");
szLine.replace(rx,"");
@@ -720,7 +719,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
szLine.replace(rx,"@");
// Remove link from a channel
- // e.g.: !c#reloaded --> #reloaded
+ // e.g.: !c#KVIrc --> #KVIrc
rx.setPattern("!c#");
szLine.replace(rx,"#");
@@ -734,6 +733,8 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
{
szLog += ".html";
szTmp = QString("KVIrc %1 %2").arg(KVI_VERSION).arg(KVI_RELEASE_NAME);
+ QString szNick = "";
+ static bool bFirstLine = true;
QString szTitle;
switch(pLog->type())
@@ -769,12 +770,19 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
while(!input.atEnd())
{
szTmp = input.readLine();
+
+ // Find who has talked
+ QString szTmpNick = szTmp.section(" ",2,2);
+
// locate msgtype
QString szNum = szTmp.section(' ',0,0);
bool bOk;
int iMsgType = szNum.toInt(&bOk);
- // only human text at present...
- if(iMsgType!=24 && iMsgType!=26 && iMsgType!=25) continue;
+
+ // only human text for now...
+ if(iMsgType != 24 && iMsgType != 25 && iMsgType != 26)
+ continue;
+
// remove msgtype tag
szTmp = szTmp.remove(0,szNum.length()+1);
@@ -782,32 +790,63 @@ void LogViewWindow::createLog(LogFile * pLog, int iId)
// insert msgtype icon at start of the current text line
KviMessageTypeSettings msg(KVI_OPTION_MSGTYPE(iMsgType));
- QString szIcon=g_pIconManager->getSmallIconResourceName((KviIconManager::SmallIcon)msg.pixId());
- szTmp.prepend("");
- szBuffer += szTmp+"
";
- szBuffer += "\n";
+ QString szIcon = g_pIconManager->getSmallIconResourceName((KviIconManager::SmallIcon)msg.pixId());
+ szTmp.prepend("");
+
+ /*
+ * Check if the nick who has talked is the same of the above line.
+ * If so, we have to put the line as it is, otherwise we have to
+ * open a new paragraph
+ */
+ if(szTmpNick != szNick)
+ {
+ /*
+ * People is not the same, close the paragraph opened
+ * before and open a new one
+ */
+ if(!bFirstLine)
+ szBuffer += "
");
+
+ szNick = szTmpNick;
+ bFirstLine = false;
+ } else {
+ // Break the line
+ szTmp += "
\n";
+ }
+
+ szBuffer += szTmp;
}
+
+ // Close the last paragraph
+ szBuffer += "