aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar OmegaPhil2014-12-02 21:11:41 +0000
committerGravatar OmegaPhil2014-12-02 21:11:41 +0000
commit2a758a2ad752509c91ddb0ec32b83cee5292726e (patch)
tree72b2f495f4e8b1082e73dfba7dd8551346f0a0fe /src
parentWork around Qt4 bug to actually export a logfile to the temprary (diff)
downloadKVIrc-2a758a2ad752509c91ddb0ec32b83cee5292726e.tar.gz
KVIrc-2a758a2ad752509c91ddb0ec32b83cee5292726e.tar.bz2
KVIrc-2a758a2ad752509c91ddb0ec32b83cee5292726e.zip
Allow user to export logs to a custom directory, save directory path for future use
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@6400 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kernel/KviOptions.cpp4
-rw-r--r--src/kvirc/kernel/KviOptions.h4
-rw-r--r--src/modules/logview/LogViewWindow.cpp44
-rw-r--r--src/modules/logview/LogViewWindow.h1
4 files changed, 36 insertions, 17 deletions
diff --git a/src/kvirc/kernel/KviOptions.cpp b/src/kvirc/kernel/KviOptions.cpp
index 07e6c9ed6..308016486 100644
--- a/src/kvirc/kernel/KviOptions.cpp
+++ b/src/kvirc/kernel/KviOptions.cpp
@@ -5,6 +5,7 @@
//
// This file is part of the KVIrc irc client distribution
// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2014 OmegaPhil (OmegaPhil at startmail dot com)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -411,7 +412,8 @@ KviStringOption g_stringOptionsTable[KVI_NUM_STRING_OPTIONS]=
STRING_OPTION("PreferredTorrentClient","auto",KviOption_sectFlagFrame),
STRING_OPTION("DefaultSrvEncoding","",KviOption_sectFlagFrame),
STRING_OPTION("LogsPath","",KviOption_sectFlagUser | KviOption_encodePath),
- STRING_OPTION("LogsDynamicPath","",KviOption_sectFlagUser | KviOption_encodePath)
+ STRING_OPTION("LogsDynamicPath","",KviOption_sectFlagUser | KviOption_encodePath),
+ STRING_OPTION("LogsExportPath","",KviOption_sectFlagUser | KviOption_encodePath)
};
#define STRINGLIST_OPTION(_txt,_flags) \
diff --git a/src/kvirc/kernel/KviOptions.h b/src/kvirc/kernel/KviOptions.h
index a44183f0c..fff70415a 100644
--- a/src/kvirc/kernel/KviOptions.h
+++ b/src/kvirc/kernel/KviOptions.h
@@ -8,6 +8,7 @@
//
// This file is part of the KVIrc irc client distribution
// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2014 OmegaPhil (OmegaPhil at startmail dot com)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -420,8 +421,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList)
#define KviOption_stringDefaultSrvEncoding 57 /* server encoding */
#define KviOption_stringLogsPath 58 /* logfolder */
#define KviOption_stringLogsDynamicPath 59 /* logfolder */
+#define KviOption_stringLogsExportPath 60 /* logview module log export */
-#define KVI_NUM_STRING_OPTIONS 60
+#define KVI_NUM_STRING_OPTIONS 61
diff --git a/src/modules/logview/LogViewWindow.cpp b/src/modules/logview/LogViewWindow.cpp
index 7eec8b577..762d2ee62 100644
--- a/src/modules/logview/LogViewWindow.cpp
+++ b/src/modules/logview/LogViewWindow.cpp
@@ -7,6 +7,7 @@
// Copyright (C) 2002 Juanjo Alvarez
// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
// Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
+// Copyright (C) 2014 OmegaPhil (OmegaPhil at startmail dot com)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -37,6 +38,7 @@
#include "KviQString.h"
#include "KviApplication.h"
#include "KviFileUtils.h"
+#include "KviFileDialog.h"
#include "KviControlCodes.h"
#include <QList>
@@ -581,14 +583,25 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
QString szLog, szLogDir, szBuffer, szLine, szTmp;
QString szDate = pLog->date().toString("yyyy.MM.dd");
- // The fresh new log
- g_pApp->getLocalKvircDirectory(szLogDir,KviApplication::Tmp);
- KviFileUtils::adjustFilePath(szLogDir);
- szLogDir += KVI_PATH_SEPARATOR_CHAR;
- szLog += szLogDir;
+ /* Fetching previous export path and concatenating with generated filename
+ * adjustFilePath is for file paths not directory paths */
+ szLog = KVI_OPTION_STRING(KviOption_stringLogsExportPath).trimmed();
+ if (!szLog.isEmpty())
+ szLog += KVI_PATH_SEPARATOR_CHAR;
szLog += QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate);
+ KviFileUtils::adjustFilePath(szLog);
- // Open file for reading
+ // Getting output file path from the user, with overwrite confirmation
+ if(!KviFileDialog::askForSaveFileName(szLog, __tr2qs_ctx("Export Log - KVIrc","log"), szLog, NULL, false, true))
+ return;
+
+ /* Save export directory - this directory path is also used in the HTML export
+ * and info is used when working with pszFile */
+ QFileInfo info(szLog);
+ szLogDir = info.absoluteDir().absolutePath();
+ KVI_OPTION_STRING(KviOption_stringLogsExportPath) = szLogDir;
+
+ // Open log file for reading
QFile file(pLog->fileName());
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
@@ -601,7 +614,10 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
{
case LogFile::PlainText:
{
- szLog += ".txt";
+ /* Only append extension if it isn't there already (e.g. a specific
+ * file is to be overwritten) */
+ if(!szLog.endsWith(".txt"))
+ szLog += ".txt";
// Scan the file
while(!input.atEnd())
@@ -641,7 +657,11 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
}
case LogFile::HTML:
{
- szLog += ".html";
+ /* Only append extension if it isn't there already (e.g. a specific
+ * file is to be overwritten) */
+ if(!szLog.endsWith(".html"))
+ szLog += ".html";
+
szTmp = QString("KVIrc %1 %2").arg(KVI_VERSION).arg(KVI_RELEASE_NAME);
QString szNick = "";
bool bFirstLine = true;
@@ -789,12 +809,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
}
}
- if(QFile::exists(szLog))
- {
- if(QMessageBox::question(this,__tr2qs_ctx("Export Log - KVIrc","log"),__tr2qs_ctx("File '%1' already exists. Do you want to overwrite it?","log").arg(szLog),QMessageBox::Yes,QMessageBox::No) == QMessageBox::No)
- return;
- }
-
+ // File overwriting already dealt with when file path was obtained
QFile log(szLog);
if(!log.open(QIODevice::WriteOnly | QIODevice::Text))
return;
@@ -802,7 +817,6 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
if(pszFile)
{
*pszFile = "";
- QFileInfo info(log);
*pszFile = info.filePath();
}
diff --git a/src/modules/logview/LogViewWindow.h b/src/modules/logview/LogViewWindow.h
index ed2d82ade..7f37bcd1b 100644
--- a/src/modules/logview/LogViewWindow.h
+++ b/src/modules/logview/LogViewWindow.h
@@ -9,6 +9,7 @@
// Copyright (C) 2002 Juanjo Alvarez
// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
// Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
+// Copyright (C) 2014 OmegaPhil (OmegaPhil at startmail dot com)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License