1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
|
//=============================================================================
//
// File : LogViewWindow.cpp
// Creation date : Tue Apr 23 2002 18:08:22 by Juanjo Alvarez
//
// This file is part of the KVIrc IRC client distribution
// 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
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the HOPE that it will be USEFUL,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================
#include "LogViewWindow.h"
#include "LogViewWidget.h"
#include "KviHtmlGenerator.h"
#include "KviIconManager.h"
#include "KviLocale.h"
#include "KviModule.h"
#include "KviOptions.h"
#include "KviMainWindow.h"
#include "KviIrcView.h"
#include "KviQString.h"
#include "KviApplication.h"
#include "KviFileUtils.h"
#include "KviFileDialog.h"
#include "KviControlCodes.h"
#include "ExportOperation.h"
#include <QList>
#include <QFileInfo>
#include <QDir>
#include <QCursor>
#include <QHeaderView>
#include <QPushButton>
#include <QDateEdit>
#include <QLineEdit>
#include <QLabel>
#include <QMouseEvent>
#include <QMessageBox>
#include <QProgressBar>
#include <QProgressDialog>
#include <QTextStream>
#include <QTabWidget>
#include <QCheckBox>
#include <QMenu>
#include <QtConcurrent>
#include <climits> //for INT_MAX
extern LogViewWindow * g_pLogViewWindow;
LogViewListView::LogViewListView(QWidget * pParent)
: QTreeWidget(pParent)
{
header()->setSortIndicatorShown(true);
setColumnCount(1);
setHeaderLabel(__tr2qs_ctx("Log File", "log"));
setSelectionMode(QAbstractItemView::SingleSelection);
setSortingEnabled(true);
setRootIsDecorated(true);
setAnimated(true);
}
void LogViewListView::mousePressEvent(QMouseEvent * pEvent)
{
if(pEvent->button() == Qt::RightButton)
{
QTreeWidgetItem * pItem = itemAt(pEvent->pos());
if(pItem)
emit rightButtonPressed(pItem, QCursor::pos());
}
QTreeWidget::mousePressEvent(pEvent);
}
LogViewWindow::LogViewWindow()
: KviWindow(KviWindow::LogView, "log")
{
g_pLogViewWindow = this;
//m_pLogViewWidget = new KviLogViewWidget(this);
m_pSplitter = new KviTalSplitter(Qt::Horizontal, this);
m_pSplitter->setObjectName("main_splitter");
m_pSplitter->setChildrenCollapsible(false);
m_pLeftLayout = new KviTalVBox(m_pSplitter);
m_pTabWidget = new QTabWidget(m_pLeftLayout);
m_pBottomLayout = new KviTalHBox(m_pLeftLayout);
m_pProgressBar = new QProgressBar(m_pBottomLayout);
m_pCancelButton = new QPushButton(m_pBottomLayout);
m_pCancelButton->setText(__tr2qs_ctx("Cancel", "log"));
connect(m_pCancelButton, SIGNAL(clicked()), this, SLOT(abortFilter()));
m_pBottomLayout->setVisible(false);
m_pIndexTab = new KviTalVBox(m_pTabWidget);
m_pTabWidget->addTab(m_pIndexTab, __tr2qs_ctx("Index", "log"));
m_pListView = new LogViewListView(m_pIndexTab);
connect(m_pListView, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(itemSelected(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(m_pListView, SIGNAL(rightButtonPressed(QTreeWidgetItem *, QPoint)), this, SLOT(rightButtonClicked(QTreeWidgetItem *, QPoint)));
m_pSearchTab = new QWidget(m_pTabWidget);
m_pTabWidget->addTab(m_pSearchTab, __tr2qs_ctx("Filter", "log"));
QGridLayout * pLayout = new QGridLayout(m_pSearchTab);
m_pShowChannelsCheck = new QCheckBox(__tr2qs_ctx("Show channel logs", "log"), m_pSearchTab);
m_pShowChannelsCheck->setChecked(true);
pLayout->addWidget(m_pShowChannelsCheck, 0, 0, 1, 2);
m_pShowQueryesCheck = new QCheckBox(__tr2qs_ctx("Show query logs", "log"), m_pSearchTab);
m_pShowQueryesCheck->setChecked(true);
pLayout->addWidget(m_pShowQueryesCheck, 1, 0, 1, 2);
m_pShowConsolesCheck = new QCheckBox(__tr2qs_ctx("Show console logs", "log"), m_pSearchTab);
m_pShowConsolesCheck->setChecked(true);
pLayout->addWidget(m_pShowConsolesCheck, 2, 0, 1, 2);
m_pShowDccChatCheck = new QCheckBox(__tr2qs_ctx("Show DCC chat logs", "log"), m_pSearchTab);
m_pShowDccChatCheck->setChecked(true);
pLayout->addWidget(m_pShowDccChatCheck, 3, 0, 1, 2);
m_pShowOtherCheck = new QCheckBox(__tr2qs_ctx("Show other logs", "log"), m_pSearchTab);
m_pShowOtherCheck->setChecked(true);
pLayout->addWidget(m_pShowOtherCheck, 4, 0, 1, 2);
QLabel * pLabel;
pLabel = new QLabel(__tr2qs_ctx("Contents Filter", "log"), m_pSearchTab);
pLayout->addWidget(pLabel, 5, 0, 1, 2);
pLabel = new QLabel(__tr2qs_ctx("Log name mask:", "log"), m_pSearchTab);
m_pFileNameMask = new QLineEdit(m_pSearchTab);
pLayout->addWidget(pLabel, 6, 0);
pLayout->addWidget(m_pFileNameMask, 6, 1);
connect(m_pFileNameMask, SIGNAL(returnPressed()), this, SLOT(applyFilter()));
pLabel = new QLabel(__tr2qs_ctx("Log contents mask:", "log"), m_pSearchTab);
m_pContentsMask = new QLineEdit(m_pSearchTab);
pLayout->addWidget(pLabel, 7, 0);
pLayout->addWidget(m_pContentsMask, 7, 1);
connect(m_pContentsMask, SIGNAL(returnPressed()), this, SLOT(applyFilter()));
m_pEnableFromFilter = new QCheckBox(__tr2qs_ctx("Only older than:", "log"), m_pSearchTab);
m_pFromDateEdit = new QDateEdit(m_pSearchTab);
m_pFromDateEdit->setDate(QDate::currentDate());
m_pFromDateEdit->setEnabled(false);
pLayout->addWidget(m_pEnableFromFilter, 8, 0);
pLayout->addWidget(m_pFromDateEdit, 8, 1);
connect(m_pEnableFromFilter, SIGNAL(toggled(bool)), m_pFromDateEdit, SLOT(setEnabled(bool)));
m_pEnableToFilter = new QCheckBox(__tr2qs_ctx("Only newer than:", "log"), m_pSearchTab);
m_pToDateEdit = new QDateEdit(m_pSearchTab);
m_pToDateEdit->setDate(QDate::currentDate());
m_pToDateEdit->setEnabled(false);
pLayout->addWidget(m_pEnableToFilter, 9, 0);
pLayout->addWidget(m_pToDateEdit, 9, 1);
connect(m_pEnableToFilter, SIGNAL(toggled(bool)), m_pToDateEdit, SLOT(setEnabled(bool)));
m_pFilterButton = new QPushButton(__tr2qs_ctx("Apply Filter", "log"), m_pSearchTab);
pLayout->addWidget(m_pFilterButton, 10, 1);
connect(m_pFilterButton, SIGNAL(clicked()), this, SLOT(applyFilter()));
QWidget * pWidget = new QWidget(m_pSearchTab);
pWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
pLayout->addWidget(pWidget, 11, 1);
m_pIrcView = new KviIrcView(m_pSplitter, this);
m_pIrcView->setMaxBufferSize(INT_MAX);
m_pIrcView->setFocusPolicy(Qt::ClickFocus);
QList<int> li;
li.append(110);
li.append(width() - 110);
m_pSplitter->setSizes(li);
// Using setData to track the option ordinal that used to be passed as id
m_pExportLogPopup = new QMenu("exportlog", this);
QAction * pAction = m_pExportLogPopup->addAction(__tr2qs_ctx("Plain Text File", "log"));
pAction->setData(LogFile::PlainText);
pAction = m_pExportLogPopup->addAction(__tr2qs_ctx("HTML Archive", "log"));
pAction->setData(LogFile::HTML);
//m_pExportLogPopup->addAction(__tr2qs_ctx("XML file","log"));
//m_pExportLogPopup->addAction(__tr2qs_ctx("database file","log"));
// 18.11.14: Originally this hooked activated, but Qt4 kept sending bullshit IDs here
// https://github.com/kvirc/KVIrc/issues/934#issuecomment-124933890
connect(m_pExportLogPopup, SIGNAL(triggered(QAction *)), this, SLOT(exportLog(QAction *)));
m_pTimer = new QTimer(this);
m_pTimer->setSingleShot(true);
m_pTimer->setInterval(0);
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(filterNext()));
//avoid to execute the long time-consuming procedure of log indexing here:
//we could still be inside the context of the "Browse log files" QAction
QTimer::singleShot(0, this, SLOT(cacheFileList()));
}
LogViewWindow::~LogViewWindow()
{
g_pLogViewWindow = nullptr;
}
void LogViewWindow::keyPressEvent(QKeyEvent * pEvent)
{
if((pEvent->modifiers() & Qt::ControlModifier) || (pEvent->modifiers() & Qt::AltModifier) || (pEvent->modifiers() & Qt::MetaModifier))
{
if(pEvent->key() == Qt::Key_F)
{
m_pIrcView->toggleToolWidget();
return;
}
}
KviWindow::keyPressEvent(pEvent);
}
QPixmap * LogViewWindow::myIconPtr()
{
return g_pIconManager->getSmallIcon(KviIconManager::Log);
}
void LogViewWindow::resizeEvent(QResizeEvent *)
{
m_pSplitter->setGeometry(0, 0, width(), height());
}
void LogViewWindow::fillCaptionBuffers()
{
m_szPlainTextCaption = __tr2qs_ctx("Log Viewer", "log");
}
void LogViewWindow::die()
{
close();
}
QSize LogViewWindow::sizeHint() const
{
QSize ret(m_pSplitter->sizeHint().width(), m_pIrcView->sizeHint().height());
return ret;
}
void LogViewWindow::recurseDirectory(const QString & szDir)
{
QDir dir(szDir);
QFileInfoList list = dir.entryInfoList();
for(int i = 0; i < list.count(); i++)
{
QFileInfo info = list[i];
if(info.isDir())
{
// recursive
if((info.fileName() != "..") && (info.fileName() != "."))
recurseDirectory(info.filePath());
}
else if((info.suffix() == "gz") || (info.suffix() == "log"))
{
m_logList.emplace_back(new LogFile(info.filePath()));
}
}
}
void LogViewWindow::setupItemList()
{
if(m_logList.empty())
return;
m_pFilterButton->setEnabled(false);
m_pListView->clear();
m_bAborted = false;
m_pBottomLayout->setVisible(true);
m_pProgressBar->setRange(0, m_logList.size());
m_pProgressBar->setValue(0);
m_pLastCategory = nullptr;
m_pLastGroupItem = nullptr;
m_currentLog = m_logList.begin();
m_pTimer->start(); //singleshot
}
void LogViewWindow::applyFilter()
{
setupItemList();
}
void LogViewWindow::abortFilter()
{
m_bAborted = true;
}
void LogViewWindow::filterNext()
{
QString szCurGroup;
std::shared_ptr<LogFile> pFile = *m_currentLog;
if(m_currentLog == m_logList.end())
goto filter_last;
if(pFile->type() == LogFile::Channel && !m_pShowChannelsCheck->isChecked())
goto filter_next;
if(pFile->type() == LogFile::Console && !m_pShowConsolesCheck->isChecked())
goto filter_next;
if(pFile->type() == LogFile::DccChat && !m_pShowDccChatCheck->isChecked())
goto filter_next;
if(pFile->type() == LogFile::Other && !m_pShowOtherCheck->isChecked())
goto filter_next;
if(pFile->type() == LogFile::Query && !m_pShowQueryesCheck->isChecked())
goto filter_next;
if(m_pEnableFromFilter->isChecked())
if(pFile->date() > m_pFromDateEdit->date())
goto filter_next;
if(m_pEnableToFilter->isChecked())
if(pFile->date() < m_pToDateEdit->date())
goto filter_next;
if(!m_pFileNameMask->text().isEmpty())
if(!KviQString::matchString(m_pFileNameMask->text(), pFile->name()))
goto filter_next;
if(!m_pContentsMask->text().isEmpty())
{
QString szBuffer;
pFile->getText(szBuffer);
if(!KviQString::matchString(m_pContentsMask->text(), szBuffer))
goto filter_next;
}
if(m_pLastCategory)
{
if(m_pLastCategory->m_eType != pFile->type())
{
m_pLastCategory = nullptr;
for(int i = 0; i < m_pListView->topLevelItemCount(); ++i)
{
LogListViewItemType * pTmp = (LogListViewItemType *)m_pListView->topLevelItem(i);
if(pTmp->m_eType == pFile->type())
{
m_pLastCategory = pTmp;
break;
}
}
if(!m_pLastCategory)
m_pLastCategory = new LogListViewItemType(m_pListView, pFile->type());
}
}
else
{
m_pLastCategory = new LogListViewItemType(m_pListView, pFile->type());
}
szCurGroup = __tr2qs_ctx("%1 on %2", "log").arg(pFile->name(), pFile->network());
if(m_szLastGroup != szCurGroup)
{
m_szLastGroup = szCurGroup;
m_pLastGroupItem = nullptr;
for(int i = 0; i < m_pLastCategory->childCount(); ++i)
{
LogListViewItemFolder * pTmp = (LogListViewItemFolder *)m_pLastCategory->child(i);
if(pTmp->text(0) == m_szLastGroup)
{
m_pLastGroupItem = pTmp;
break;
}
}
if(!m_pLastGroupItem)
m_pLastGroupItem = new LogListViewItemFolder(m_pLastCategory, m_szLastGroup);
}
new LogListViewLog(m_pLastGroupItem, pFile->type(), pFile);
filter_next:
++m_currentLog;
filter_last:
if((m_currentLog != m_logList.end()) && !m_bAborted)
{
m_pProgressBar->setValue(m_pProgressBar->value() + 1);
m_pTimer->start(); //singleshot
}
else
{
m_pBottomLayout->setVisible(false);
m_pListView->sortItems(0, Qt::AscendingOrder);
m_pProgressBar->setValue(0);
m_pFilterButton->setEnabled(true);
// Reset m_szLastGroup for next search
m_szLastGroup = "";
}
}
void LogViewWindow::cacheFileList()
{
QString szLogPath;
g_pApp->getLocalKvircDirectory(szLogPath, KviApplication::Log);
recurseDirectory(szLogPath);
setupItemList();
}
void LogViewWindow::itemSelected(QTreeWidgetItem * it, QTreeWidgetItem *)
{
//A parent node
m_pIrcView->clearBuffer();
if(!it || !it->parent() || !(((LogListViewItem *)it)->m_pFileData))
return;
QString szText;
((LogListViewItem *)it)->m_pFileData->getText(szText);
QStringList lines = szText.split('\n');
bool bOk;
int iMsgType;
for(auto & line : lines)
{
QString szNum = line.section(' ', 0, 0);
iMsgType = szNum.toInt(&bOk);
if(iMsgType < 0 || iMsgType > (KVI_NUM_MSGTYPE_OPTIONS - 1))
iMsgType = 0;
if(bOk)
outputNoFmt(iMsgType, line.section(' ', 1), KviIrcView::NoRepaint | KviIrcView::NoTimestamp);
else
outputNoFmt(0, line, KviIrcView::NoRepaint | KviIrcView::NoTimestamp);
}
m_pIrcView->repaint();
}
void LogViewWindow::rightButtonClicked(QTreeWidgetItem * pItem, const QPoint &)
{
if(!pItem)
return;
m_pListView->setCurrentItem(pItem);
QMenu * pPopup = new QMenu(this);
if(((LogListViewItem *)pItem)->childCount())
{
pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Save)), __tr2qs_ctx("Export All Log Files to", "log"))->setMenu(m_pExportLogPopup);
pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)), __tr2qs_ctx("Remove All Log Files Within This Folder", "log"), this, SLOT(deleteCurrent()));
}
else
{
pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Save)), __tr2qs_ctx("Export Log File to", "log"))->setMenu(m_pExportLogPopup);
pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)), __tr2qs_ctx("Remove Log File", "log"), this, SLOT(deleteCurrent()));
}
pPopup->exec(QCursor::pos());
}
void LogViewWindow::deleteCurrent()
{
LogListViewItem * pItem = dynamic_cast<LogListViewItem *>(m_pListView->currentItem());
if(!pItem)
return;
if(!pItem->childCount())
{
if(!pItem->fileName().isNull())
{
if(QMessageBox::question(
this,
__tr2qs_ctx("Confirm Current User Log Deletion", "log"),
__tr2qs_ctx("Do you really wish to delete this log?", "log"),
__tr2qs("Yes"), __tr2qs("No"), nullptr, 1)
!= 0)
return;
KviFileUtils::removeFile(pItem->fileName());
if(!pItem->parent()->childCount())
delete pItem->parent();
delete pItem;
m_pIrcView->clearBuffer();
}
return;
}
if(QMessageBox::question(
this,
__tr2qs_ctx("Confirm Current User Logs Deletion", "log"),
__tr2qs_ctx("Do you really wish to delete all these logs?", "log"),
__tr2qs("Yes"), __tr2qs("No"), nullptr, 1)
!= 0)
return;
KviPointerList<LogListViewItem> itemsList;
itemsList.setAutoDelete(false);
for(int i = 0; i < pItem->childCount(); i++)
{
if(!pItem->child(i)->childCount())
{
itemsList.append((LogListViewItem *)pItem->child(i));
continue;
}
LogListViewItem * pChild = (LogListViewItem *)pItem->child(i);
for(int j = 0; j < pChild->childCount(); j++)
{
if(!(LogListViewItem *)pChild->child(j))
{
qDebug("Null pointer in logviewitem");
continue;
}
itemsList.append((LogListViewItem *)pChild->child(j));
}
}
for(unsigned int u = 0; u < itemsList.count(); u++)
{
LogListViewItem * pCurItem = itemsList.at(u);
if(!pCurItem->fileName().isNull())
KviFileUtils::removeFile(pCurItem->fileName());
}
delete pItem;
}
void LogViewWindow::exportLog(QAction * pAction)
{
/* This slot is required as Qt4 has started to screw up the menu ordinal
* sent with the old activated signal - the ordinal is now stored as
* QAction user data */
if(pAction)
exportLog(static_cast<LogFile::ExportType>(pAction->data().toInt()));
else
qDebug("LogViewWindow::exportLog called with invalid pAction");
}
void LogViewWindow::exportLog(LogFile::ExportType exportType)
{
LogListViewItem * pItem = (LogListViewItem *)(m_pListView->currentItem());
if(!pItem)
return;
if(!pItem->childCount())
{
std::shared_ptr<LogFile> pLog { pItem->log() };
QString szDate = pLog->date().toString("yyyy.MM.dd");
QString 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);
// Getting output file path from the user, with overwrite confirmation
if(!KviFileDialog::askForSaveFileName(
szLog,
__tr2qs_ctx("Export Log - KVIrc", "log"),
szLog,
QString(),
false,
true,
true,
this))
return;
// Export the log
pLog->createLog(exportType, szLog);
return;
}
// We selected a node in the log list, scan the children
std::vector<std::shared_ptr<LogFile>> logList;
for(int i = 0; i < pItem->childCount(); i++)
{
if(!pItem->child(i)->childCount())
{
// The child is a log file, append it to the list
LogListViewItem * pViewItem = static_cast<LogListViewItem *>(pItem->child(i));
std::shared_ptr<LogFile> pLog { pViewItem->log() };
logList.push_back(pLog);
continue;
}
// The child is a node, scan it
LogListViewItem * pChild = (LogListViewItem *)pItem->child(i);
for(int j = 0; j < pChild->childCount(); j++)
{
if(!(LogListViewItem *)pChild->child(j))
{
qDebug("Null pointer in logviewitem");
continue;
}
// Add the child to the list
LogListViewItem * pViewItem = static_cast<LogListViewItem *>(pItem->child(j));
std::shared_ptr<LogFile> pLog { pViewItem->log() };
logList.push_back(pLog);
}
}
// Select output directory
QString szDir = KVI_OPTION_STRING(KviOption_stringLogsExportPath).trimmed();
if(!KviFileDialog::askForDirectoryName(
szDir,
__tr2qs_ctx("Export Log - KVIrc", "log"),
szDir,
QString(),
false,
true,
this))
return;
KVI_OPTION_STRING(KviOption_stringLogsExportPath) = szDir;
// Begin asynchronously writing the logs to persistent storage
ExportOperation * worker = new ExportOperation(logList, exportType, szDir);
worker->start();
}
|