From 2b021749ce4dc3ec8e160a5800e323f7a45047db Mon Sep 17 00:00:00 2001 From: Chris MacLeod Date: Sat, 5 Aug 2023 04:39:01 -0400 Subject: Batch export logs (#2485) * Implement most basic functional batch export For the future: * The loop still needs to be made asynchronous so the process doesn't hang. * Ideally, there should be some sort of progress window. * There is redundant code that should be reduced. * Make batch export asynchronous Reminder: The comment about overwrite protection no longer applies Todo: Progress dialog * Avoid possible dangling pointer, improve type safety and const correctness in the process In reality, the log exporting code has no reason to be in the GUI class to begin with. `exportLog` makes sense as a Qt slot, but `createLog` should be a member function of the `LogFile` class and operate on `this` rather than a `LogFile` argument. A future commit should amend this, but for now I will avoid changing anything unnecessary until a working progress dialog is in place and I have tested the finished feature thoroughly. * Add progress dialog * Make LogViewWindow::createLog a member function of LogFile * Reduce memory usage by sharing `LogFile`s with the GUI thread * Correct progress dialog modality * Collect log files directly instead of reiterating through view items later Also adds a little documentation * Fix batch export for paths with reserved characters * avoid sigsegv * fix tags removal before nickname in html export * Fix directory selection and output path for icons in html export --------- Co-authored-by: ctrlaltca --- src/modules/logview/LogViewWindow.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/modules/logview/LogViewWindow.h') diff --git a/src/modules/logview/LogViewWindow.h b/src/modules/logview/LogViewWindow.h index b90866b39..fb479a726 100644 --- a/src/modules/logview/LogViewWindow.h +++ b/src/modules/logview/LogViewWindow.h @@ -36,6 +36,8 @@ #include "KviPointerList.h" #include +#include +#include class KviLogViewWidget; class LogListViewItem; @@ -52,7 +54,7 @@ class LogViewListView : public QTreeWidget Q_OBJECT public: LogViewListView(QWidget *); - ~LogViewListView(){}; + ~LogViewListView() {}; protected: void mousePressEvent(QMouseEvent * pEvent) override; @@ -68,7 +70,8 @@ public: ~LogViewWindow(); protected: - KviPointerList m_logList; + std::vector> m_logList; + std::vector>::const_iterator m_currentLog; LogViewListView * m_pListView; @@ -104,18 +107,8 @@ protected: QTimer * m_pTimer; QMenu * m_pExportLogPopup; -public: - /** - * \brief Exports the log and creates the file in the selected format - * \param pLog The log file associated with the item selected in the popup - * \param iId The id of the item in the popup - * \param pszFile The buffer to store the exported log name - * \return void - */ - void createLog(LogFile * pLog, int iId, QString * pszFile = nullptr); - protected: - void exportLog(int iId); + void exportLog(LogFile::ExportType exportType); void recurseDirectory(const QString & szDir); void setupItemList(); -- cgit v1.3.1-10-gc9f91