From fccac04d600b0270e85dab4e4daa37c8fdf84ed1 Mon Sep 17 00:00:00 2001 From: Noldor Date: Sun, 10 Apr 2011 13:37:09 +0000 Subject: More work on #934 (html export) git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5772 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/logview/LogViewWindow.cpp | 80 ++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/src/modules/logview/LogViewWindow.cpp b/src/modules/logview/LogViewWindow.cpp index 0ea26591f..716d34860 100644 --- a/src/modules/logview/LogViewWindow.cpp +++ b/src/modules/logview/LogViewWindow.cpp @@ -27,6 +27,7 @@ #include "LogViewWindow.h" #include "LogViewWidget.h" +#include "KviHtmlGenerator.h" #include "KviIconManager.h" #include "KviLocale.h" #include "KviModule.h" @@ -671,9 +672,11 @@ void LogViewWindow::createLog(LogFile * pLog, int iId) QString szDate = pLog->date().toString("yyyy.MM.dd"); // The fresh new log - QString szLog = QDir::homePath(); - KviQString::ensureLastCharIs(szLog,QChar(KVI_PATH_SEPARATOR_CHAR)); - szLog += QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate); + 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); // Open file for reading QFile file(pLog->fileName()); @@ -724,7 +727,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId) szBuffer += "\n"; } - goto write_log; + break; } case LogFile::HTML: { @@ -765,26 +768,73 @@ void LogViewWindow::createLog(LogFile * pLog, int iId) while(!input.atEnd()) { szTmp = input.readLine(); - - // FIXME: remove this - szLine = KviControlCodes::stripControlBytes(szTmp); - - //szBuffer += "
";
-
- szBuffer += szLine;
+ // 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;
+ // remove msgtype tag
+ szTmp = szTmp.remove(0,szNum.length()+1);
+ szTmp = KviHtmlGenerator::convertToHtml(szTmp);
+ // 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";
}
-
+ // regexp to search all embedded icons
+ QRegExp expression("= 0)
+ {
+ int length = expression.matchedLength();
+ QString szCap = expression.cap(1);
+ // if the icon isn't in the images list then add
+ if(szImagesList.indexOf(szCap)==-1)
+ szImagesList.append(szCap);
+ iIndex = szBuffer.indexOf(expression, iIndex + length);
+ }
+ // get current theme path
+ QString szCurrentThemePath;
+ g_pApp->getLocalKvircDirectory(szCurrentThemePath,KviApplication::Themes,KVI_OPTION_STRING(KviOption_stringIconThemeSubdir));
+ szCurrentThemePath += KVI_PATH_SEPARATOR_CHAR;
+ // current coresmall path
+ szCurrentThemePath += "coresmall";
+ szCurrentThemePath += KVI_PATH_SEPARATOR_CHAR;
+ // check if coresmall exists in current theme
+ if(!KviFileUtils::directoryExists(szCurrentThemePath))
+ {
+ // get global coresmall path
+ g_pApp->getGlobalKvircDirectory(szCurrentThemePath,KviApplication::Pics,"coresmall");
+ KviQString::ensureLastCharIs(szCurrentThemePath,QChar(KVI_PATH_SEPARATOR_CHAR));
+ }
+ // copy all icons to the log destination folder
+ for(int i=0;i