diff options
Diffstat (limited to 'src/modules/logview')
| -rw-r--r-- | src/modules/logview/LogFile.cpp | 43 | ||||
| -rw-r--r-- | src/modules/logview/LogFile.h | 38 | ||||
| -rw-r--r-- | src/modules/logview/LogViewWidget.cpp | 42 | ||||
| -rw-r--r-- | src/modules/logview/LogViewWidget.h | 9 | ||||
| -rw-r--r-- | src/modules/logview/LogViewWindow.cpp | 286 | ||||
| -rw-r--r-- | src/modules/logview/LogViewWindow.h | 56 | ||||
| -rw-r--r-- | src/modules/logview/libkvilogview.cpp | 36 |
7 files changed, 269 insertions, 241 deletions
diff --git a/src/modules/logview/LogFile.cpp b/src/modules/logview/LogFile.cpp index 21961b124..43d98f01c 100644 --- a/src/modules/logview/LogFile.cpp +++ b/src/modules/logview/LogFile.cpp @@ -32,7 +32,7 @@ #include <QFileInfo> #ifdef COMPILE_ZLIB_SUPPORT - #include <zlib.h> +#include <zlib.h> #endif LogFile::LogFile(const QString & szName) @@ -48,37 +48,42 @@ LogFile::LogFile(const QString & szName) //removes trailing dot and extension szTmpName.chop(3); } - QString szTypeToken = szTmpName.section('_',0,0); + QString szTypeToken = szTmpName.section('_', 0, 0); // Ignore non-logs files, this includes '.' and '..' - if(KviQString::equalCI(szTypeToken,"channel") || KviQString::equalCI(szTypeToken,"deadchannel")) + if(KviQString::equalCI(szTypeToken, "channel") || KviQString::equalCI(szTypeToken, "deadchannel")) { m_szType = "channel"; m_eType = Channel; - } else if(KviQString::equalCI(szTypeToken,"console")) + } + else if(KviQString::equalCI(szTypeToken, "console")) { m_szType = "console"; m_eType = Console; - } else if(KviQString::equalCI(szTypeToken,"query")) + } + else if(KviQString::equalCI(szTypeToken, "query")) { m_szType = "query"; m_eType = Query; - } else if(KviQString::equalCI(szTypeToken,"dccchat")) + } + else if(KviQString::equalCI(szTypeToken, "dccchat")) { m_szType = "dccchat"; m_eType = DccChat; - } else { + } + else + { m_szType = ""; m_eType = Other; } - KviCString szUndecoded = szTmpName.section('.',0,0); + KviCString szUndecoded = szTmpName.section('.', 0, 0); szUndecoded.cutToFirst('_'); m_szName = szUndecoded.hexDecode(szUndecoded.ptr()).ptr(); - szUndecoded = szTmpName.section('.',1).section('_',0,-2); + szUndecoded = szTmpName.section('.', 1).section('_', 0, -2); m_szNetwork = szUndecoded.hexDecode(szUndecoded.ptr()).ptr(); - QString szDate = szTmpName.section('_',-1).section('.',0,-2); + QString szDate = szTmpName.section('_', -1).section('.', 0, -2); switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) { @@ -145,26 +150,30 @@ void LogFile::getText(QString & szText) #ifdef COMPILE_ZLIB_SUPPORT if(m_bCompressed) { - gzFile file = gzopen(szLogName.toLocal8Bit().data(),"rb"); + gzFile file = gzopen(szLogName.toLocal8Bit().data(), "rb"); if(file) { char cBuff[1025]; int iLen; QByteArray data; //QCString data; - iLen = gzread(file,cBuff,1024); + iLen = gzread(file, cBuff, 1024); while(iLen > 0) { cBuff[iLen] = 0; data.append(cBuff); - iLen = gzread(file,cBuff,1024); + iLen = gzread(file, cBuff, 1024); } gzclose(file); szText = QString::fromUtf8(data); - } else { - qDebug("Can't open compressed file %s",szLogName.toLocal8Bit().data()); } - } else { + else + { + qDebug("Can't open compressed file %s", szLogName.toLocal8Bit().data()); + } + } + else + { #endif logFile.setFileName(szLogName); @@ -173,7 +182,7 @@ void LogFile::getText(QString & szText) QByteArray bytes; bytes = logFile.readAll(); - szText = QString::fromUtf8(bytes.data(),bytes.size()); + szText = QString::fromUtf8(bytes.data(), bytes.size()); logFile.close(); #ifdef COMPILE_ZLIB_SUPPORT } diff --git a/src/modules/logview/LogFile.h b/src/modules/logview/LogFile.h index a5091ca84..53281af8a 100644 --- a/src/modules/logview/LogFile.h +++ b/src/modules/logview/LogFile.h @@ -43,9 +43,9 @@ class QString; */ typedef struct _LogFileData { - QString szName; /**< the name of the log */ - QString szType; /**< the type of the log */ - QString szFile; /**< the name of the exported log */ + QString szName; /**< the name of the log */ + QString szType; /**< the type of the log */ + QString szFile; /**< the name of the exported log */ } LogFileData; /** @@ -65,23 +65,25 @@ public: * \enum Type * \brief Holds the type of the log file */ - enum Type { - Channel = 0, /**< the log file of a channel */ - Console = 1, /**< the log file of a console */ - Query = 2, /**< the log file of a query */ - DccChat = 3, /**< the log file of a dcc chat */ - Other = 4 /**< any other log file */ + enum Type + { + Channel = 0, /**< the log file of a channel */ + Console = 1, /**< the log file of a console */ + Query = 2, /**< the log file of a query */ + DccChat = 3, /**< the log file of a dcc chat */ + Other = 4 /**< any other log file */ }; /** * \enum ExportType * \brief Holds the type of the exported log file */ - enum ExportType { - PlainText, /**< export log in plain text file */ - HTML /**< export log in a HTML archive */ - //XML /**< export log in a XML file */ - //DB /**< export log in a database file */ + enum ExportType + { + PlainText, /**< export log in plain text file */ + HTML /**< export log in a HTML archive */ + //XML /**< export log in a XML file */ + //DB /**< export log in a database file */ }; /** @@ -90,14 +92,16 @@ public: * \return LogFile */ LogFile(const QString & szName); + private: - Type m_eType; + Type m_eType; QString m_szType; QString m_szFilename; - bool m_bCompressed; + bool m_bCompressed; QString m_szName; QString m_szNetwork; - QDate m_date; + QDate m_date; + public: /** * \brief Returns the type of the log diff --git a/src/modules/logview/LogViewWidget.cpp b/src/modules/logview/LogViewWidget.cpp index c7e870ef7..5de6f3078 100644 --- a/src/modules/logview/LogViewWidget.cpp +++ b/src/modules/logview/LogViewWidget.cpp @@ -35,29 +35,29 @@ #include <QTextCodec> #ifdef COMPILE_ZLIB_SUPPORT - #include <zlib.h> +#include <zlib.h> #endif LogListViewItem::LogListViewItem(QTreeWidgetItem * pPar, LogFile::Type eType, LogFile * pLog) -: QTreeWidgetItem(pPar), m_eType(eType), m_pFileData(pLog) + : QTreeWidgetItem(pPar), m_eType(eType), m_pFileData(pLog) { - setText(0,m_pFileData ? m_pFileData->name() : QString()); + setText(0, m_pFileData ? m_pFileData->name() : QString()); } LogListViewItem::LogListViewItem(QTreeWidget * pPar, LogFile::Type eType, LogFile * pLog) -: QTreeWidgetItem(pPar), m_eType(eType), m_pFileData(pLog) + : QTreeWidgetItem(pPar), m_eType(eType), m_pFileData(pLog) { - setText(0,m_pFileData ? m_pFileData->name() : QString()); + setText(0, m_pFileData ? m_pFileData->name() : QString()); } LogListViewItemFolder::LogListViewItemFolder(QTreeWidgetItem * pPar, const QString & szLabel) -: LogListViewItem(pPar,LogFile::Other,0) + : LogListViewItem(pPar, LogFile::Other, 0) { - setText(0,szLabel); + setText(0, szLabel); } LogListViewItemType::LogListViewItemType(QTreeWidget * pPar, LogFile::Type eType) -: LogListViewItem(pPar,eType,0) + : LogListViewItem(pPar, eType, 0) { QIcon icon; QString szText; @@ -66,31 +66,31 @@ LogListViewItemType::LogListViewItemType(QTreeWidget * pPar, LogFile::Type eType { case LogFile::Channel: icon = QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Channel)); - szText = __tr2qs_ctx("Channel","log"); - break; + szText = __tr2qs_ctx("Channel", "log"); + break; case LogFile::Query: icon = QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Query)); - szText = __tr2qs_ctx("Query","log"); - break; + szText = __tr2qs_ctx("Query", "log"); + break; case LogFile::DccChat: icon = QIcon(*g_pIconManager->getSmallIcon(KviIconManager::DccMsg)); - szText = __tr2qs_ctx("DCC Chat","log"); - break; + szText = __tr2qs_ctx("DCC Chat", "log"); + break; case LogFile::Console: icon = QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Console)); - szText = __tr2qs_ctx("Console","log"); - break; + szText = __tr2qs_ctx("Console", "log"); + break; default: icon = QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Log)); - szText = __tr2qs_ctx("Other","log"); + szText = __tr2qs_ctx("Other", "log"); } - setIcon(0,icon); - setText(0,szText); + setIcon(0, icon); + setText(0, szText); } LogListViewLog::LogListViewLog(QTreeWidgetItem * pPar, LogFile::Type eType, LogFile * pLog) -: LogListViewItem(pPar,eType,pLog) + : LogListViewItem(pPar, eType, pLog) { - setText(0,m_pFileData->date().toString("yyyy-MM-dd")); + setText(0, m_pFileData->date().toString("yyyy-MM-dd")); } diff --git a/src/modules/logview/LogViewWidget.h b/src/modules/logview/LogViewWidget.h index d48604247..9092dae84 100644 --- a/src/modules/logview/LogViewWidget.h +++ b/src/modules/logview/LogViewWidget.h @@ -37,11 +37,13 @@ public: LogListViewItem(QTreeWidgetItem * pPar, LogFile::Type eType, LogFile * pLog); LogListViewItem(QTreeWidget * pPar, LogFile::Type eType, LogFile * pLog); ~LogListViewItem(){}; + public: - LogFile::Type m_eType; - LogFile * m_pFileData; + LogFile::Type m_eType; + LogFile * m_pFileData; + public: - LogFile * log(){ return m_pFileData; }; + LogFile * log() { return m_pFileData; }; virtual QString fileName() const { return QString(); }; }; @@ -50,6 +52,7 @@ class LogListViewItemFolder : public LogListViewItem public: LogListViewItemFolder(QTreeWidgetItem * pPar, const QString & szLabel); ~LogListViewItemFolder(){}; + public: }; diff --git a/src/modules/logview/LogViewWindow.cpp b/src/modules/logview/LogViewWindow.cpp index dc0c188f5..0c5f0b9d6 100644 --- a/src/modules/logview/LogViewWindow.cpp +++ b/src/modules/logview/LogViewWindow.cpp @@ -63,11 +63,11 @@ extern LogViewWindow * g_pLogViewWindow; LogViewListView::LogViewListView(QWidget * pParent) -: QTreeWidget(pParent) + : QTreeWidget(pParent) { header()->setSortIndicatorShown(true); setColumnCount(1); - setHeaderLabel(__tr2qs_ctx("Log File","log")); + setHeaderLabel(__tr2qs_ctx("Log File", "log")); setSelectionMode(QAbstractItemView::SingleSelection); setSortingEnabled(true); setRootIsDecorated(true); @@ -80,19 +80,18 @@ void LogViewListView::mousePressEvent(QMouseEvent * pEvent) { QTreeWidgetItem * pItem = itemAt(pEvent->pos()); if(pItem) - emit rightButtonPressed(pItem,QCursor::pos()); + emit rightButtonPressed(pItem, QCursor::pos()); } QTreeWidget::mousePressEvent(pEvent); } - LogViewWindow::LogViewWindow() -: KviWindow(KviWindow::LogView,"log") + : KviWindow(KviWindow::LogView, "log") { g_pLogViewWindow = this; //m_pLogViewWidget = new KviLogViewWidget(this); - m_pSplitter = new KviTalSplitter(Qt::Horizontal,this); + m_pSplitter = new KviTalSplitter(Qt::Horizontal, this); m_pSplitter->setObjectName("main_splitter"); m_pSplitter->setChildrenCollapsible(false); @@ -102,112 +101,112 @@ LogViewWindow::LogViewWindow() 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_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_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))); + 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")); + 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 = new QCheckBox(__tr2qs_ctx("Show channel logs", "log"), m_pSearchTab); m_pShowChannelsCheck->setChecked(true); - pLayout->addWidget(m_pShowChannelsCheck,0,0,1,2); + pLayout->addWidget(m_pShowChannelsCheck, 0, 0, 1, 2); - m_pShowQueryesCheck = new QCheckBox(__tr2qs_ctx("Show query logs","log"),m_pSearchTab); + m_pShowQueryesCheck = new QCheckBox(__tr2qs_ctx("Show query logs", "log"), m_pSearchTab); m_pShowQueryesCheck->setChecked(true); - pLayout->addWidget(m_pShowQueryesCheck,1,0,1,2); + pLayout->addWidget(m_pShowQueryesCheck, 1, 0, 1, 2); - m_pShowConsolesCheck = new QCheckBox(__tr2qs_ctx("Show console logs","log"),m_pSearchTab); + m_pShowConsolesCheck = new QCheckBox(__tr2qs_ctx("Show console logs", "log"), m_pSearchTab); m_pShowConsolesCheck->setChecked(true); - pLayout->addWidget(m_pShowConsolesCheck,2,0,1,2); + pLayout->addWidget(m_pShowConsolesCheck, 2, 0, 1, 2); - m_pShowDccChatCheck = new QCheckBox(__tr2qs_ctx("Show DCC chat logs","log"),m_pSearchTab); + 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); + pLayout->addWidget(m_pShowDccChatCheck, 3, 0, 1, 2); - m_pShowOtherCheck = new QCheckBox(__tr2qs_ctx("Show other logs","log"),m_pSearchTab); + m_pShowOtherCheck = new QCheckBox(__tr2qs_ctx("Show other logs", "log"), m_pSearchTab); m_pShowOtherCheck->setChecked(true); - pLayout->addWidget(m_pShowOtherCheck,4,0,1,2); + 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("Contents Filter", "log"), m_pSearchTab); + pLayout->addWidget(pLabel, 5, 0, 1, 2); - pLabel = new QLabel(__tr2qs_ctx("Log name mask:","log"),m_pSearchTab); + 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())); + 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); + 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())); + 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_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))); + 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_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))); + 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())); + 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); + pWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + pLayout->addWidget(pWidget, 11, 1); - m_pIrcView = new KviIrcView(m_pSplitter,this); + 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); + 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")); + 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 = 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*))); + 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())); + 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())); + QTimer::singleShot(0, this, SLOT(cacheFileList())); } LogViewWindow::~LogViewWindow() @@ -235,12 +234,12 @@ QPixmap * LogViewWindow::myIconPtr() void LogViewWindow::resizeEvent(QResizeEvent *) { - m_pSplitter->setGeometry(0,0,width(),height()); + m_pSplitter->setGeometry(0, 0, width(), height()); } void LogViewWindow::fillCaptionBuffers() { - m_szPlainTextCaption = __tr2qs_ctx("Log Viewer","log"); + m_szPlainTextCaption = __tr2qs_ctx("Log Viewer", "log"); } void LogViewWindow::die() @@ -250,7 +249,7 @@ void LogViewWindow::die() QSize LogViewWindow::sizeHint() const { - QSize ret(m_pSplitter->sizeHint().width(),m_pIrcView->sizeHint().height()); + QSize ret(m_pSplitter->sizeHint().width(), m_pIrcView->sizeHint().height()); return ret; } @@ -258,7 +257,7 @@ void LogViewWindow::recurseDirectory(const QString & szDir) { QDir dir(szDir); QFileInfoList list = dir.entryInfoList(); - for(int i=0; i < list.count(); i++) + for(int i = 0; i < list.count(); i++) { QFileInfo info = list[i]; if(info.isDir()) @@ -266,7 +265,8 @@ void LogViewWindow::recurseDirectory(const QString & szDir) // recursive if((info.fileName() != "..") && (info.fileName() != ".")) recurseDirectory(info.filePath()); - } else if((info.suffix() == "gz") || (info.suffix() == "log")) + } + else if((info.suffix() == "gz") || (info.suffix() == "log")) { m_logList.append(new LogFile(info.filePath())); } @@ -283,7 +283,7 @@ void LogViewWindow::setupItemList() m_bAborted = false; m_pBottomLayout->setVisible(true); - m_pProgressBar->setRange(0,m_logList.count()); + m_pProgressBar->setRange(0, m_logList.count()); m_pProgressBar->setValue(0); m_pLastCategory = 0; @@ -329,14 +329,14 @@ void LogViewWindow::filterNext() goto filter_next; if(!m_pFileNameMask->text().isEmpty()) - if(!KviQString::matchString(m_pFileNameMask->text(),pFile->name())) + 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)) + if(!KviQString::matchString(m_pContentsMask->text(), szBuffer)) goto filter_next; } @@ -345,7 +345,7 @@ void LogViewWindow::filterNext() if(m_pLastCategory->m_eType != pFile->type()) { m_pLastCategory = 0; - for(int i=0; i < m_pListView->topLevelItemCount(); ++i) + for(int i = 0; i < m_pListView->topLevelItemCount(); ++i) { LogListViewItemType * pTmp = (LogListViewItemType *)m_pListView->topLevelItem(i); if(pTmp->m_eType == pFile->type()) @@ -355,19 +355,21 @@ void LogViewWindow::filterNext() } } if(!m_pLastCategory) - m_pLastCategory = new LogListViewItemType(m_pListView,pFile->type()); + m_pLastCategory = new LogListViewItemType(m_pListView, pFile->type()); } - } else { - 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()); + szCurGroup = __tr2qs_ctx("%1 on %2", "log").arg(pFile->name(), pFile->network()); if(m_szLastGroup != szCurGroup) { m_szLastGroup = szCurGroup; m_pLastGroupItem = 0; - for(int i=0; i < m_pLastCategory->childCount(); ++i) + for(int i = 0; i < m_pLastCategory->childCount(); ++i) { LogListViewItemFolder * pTmp = (LogListViewItemFolder *)m_pLastCategory->child(i); if(pTmp->text(0) == m_szLastGroup) @@ -378,10 +380,10 @@ void LogViewWindow::filterNext() } if(!m_pLastGroupItem) - m_pLastGroupItem = new LogListViewItemFolder(m_pLastCategory,m_szLastGroup); + m_pLastGroupItem = new LogListViewItemFolder(m_pLastCategory, m_szLastGroup); } - new LogListViewLog(m_pLastGroupItem,pFile->type(),pFile); + new LogListViewLog(m_pLastGroupItem, pFile->type(), pFile); filter_next: pFile = m_logList.next(); @@ -391,9 +393,11 @@ filter_last: { m_pProgressBar->setValue(m_pProgressBar->value() + 1); m_pTimer->start(); //singleshot - } else { + } + else + { m_pBottomLayout->setVisible(false); - m_pListView->sortItems(0,Qt::AscendingOrder); + m_pListView->sortItems(0, Qt::AscendingOrder); m_pProgressBar->setValue(0); m_pFilterButton->setEnabled(true); } @@ -402,7 +406,7 @@ filter_last: void LogViewWindow::cacheFileList() { QString szLogPath; - g_pApp->getLocalKvircDirectory(szLogPath,KviApplication::Log); + g_pApp->getLocalKvircDirectory(szLogPath, KviApplication::Log); recurseDirectory(szLogPath); setupItemList(); @@ -423,14 +427,14 @@ void LogViewWindow::itemSelected(QTreeWidgetItem * it, QTreeWidgetItem *) int iMsgType; for(QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) { - QString szNum = (*it).section(' ',0,0); + QString szNum = (*it).section(' ', 0, 0); iMsgType = szNum.toInt(&bOk); - if(iMsgType < 0 || iMsgType > (KVI_NUM_MSGTYPE_OPTIONS-1)) - iMsgType=0; + if(iMsgType < 0 || iMsgType > (KVI_NUM_MSGTYPE_OPTIONS - 1)) + iMsgType = 0; if(bOk) - outputNoFmt(iMsgType,(*it).section(' ',1),KviIrcView::NoRepaint | KviIrcView::NoTimestamp); + outputNoFmt(iMsgType, (*it).section(' ', 1), KviIrcView::NoRepaint | KviIrcView::NoTimestamp); else - outputNoFmt(0,*it,KviIrcView::NoRepaint | KviIrcView::NoTimestamp); + outputNoFmt(0, *it, KviIrcView::NoRepaint | KviIrcView::NoTimestamp); } m_pIrcView->repaint(); } @@ -441,14 +445,16 @@ void LogViewWindow::rightButtonClicked(QTreeWidgetItem * pItem, const QPoint &) return; m_pListView->setCurrentItem(pItem); - QMenu * pPopup = new QMenu(this); + QMenu * pPopup = new QMenu(this); if(((LogListViewItem *)pItem)->childCount()) { //pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::UserList)),__tr2qs_ctx("Export all log files to","log"),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->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()); @@ -465,10 +471,11 @@ void LogViewWindow::deleteCurrent() 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"),0,1) != 0) + this, + __tr2qs_ctx("Confirm Current User Log Deletion", "log"), + __tr2qs_ctx("Do you really wish to delete this log?", "log"), + __tr2qs("Yes"), __tr2qs("No"), 0, 1) + != 0) return; KviFileUtils::removeFile(pItem->fileName()); @@ -482,14 +489,15 @@ void LogViewWindow::deleteCurrent() } 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"),0,1) != 0) + 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"), 0, 1) + != 0) return; KviPointerList<LogListViewItem> itemsList; itemsList.setAutoDelete(false); - for(int i=0; i < pItem->childCount(); i++) + for(int i = 0; i < pItem->childCount(); i++) { if(!pItem->child(i)->childCount()) { @@ -497,7 +505,7 @@ void LogViewWindow::deleteCurrent() continue; } LogListViewItem * pChild = (LogListViewItem *)pItem->child(i); - for(int j=0; j < pChild->childCount(); j++) + for(int j = 0; j < pChild->childCount(); j++) { if(!(LogListViewItem *)pChild->child(j)) { @@ -507,7 +515,7 @@ void LogViewWindow::deleteCurrent() itemsList.append((LogListViewItem *)pChild->child(j)); } } - for(unsigned int u=0; u < itemsList.count(); u++) + for(unsigned int u = 0; u < itemsList.count(); u++) { LogListViewItem * pCurItem = itemsList.at(u); if(!pCurItem->fileName().isNull()) @@ -516,12 +524,12 @@ void LogViewWindow::deleteCurrent() delete pItem; } -void LogViewWindow::exportLog(QAction* pAction) +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) + if(pAction) exportLog(pAction->data().toInt()); else qDebug("LogViewWindow::exportLog called with invalid pAction"); @@ -554,7 +562,7 @@ void LogViewWindow::exportLog(int iId) // The child is a node, scan it LogListViewItem * pChild = (LogListViewItem *)pItem->child(i); - for(int j=0; j < pChild->childCount(); j++) + for(int j = 0; j < pChild->childCount(); j++) { if(!(LogListViewItem *)pChild->child(j)) { @@ -587,21 +595,21 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) /* 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()) + if(!szLog.isEmpty()) szLog += KVI_PATH_SEPARATOR_CHAR; - szLog += QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate); + 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)) + szLog, + __tr2qs_ctx("Export Log - KVIrc", "log"), + szLog, + QString(), + false, + true, + true, + this)) return; /* Save export directory - this directory path is also used in the HTML export @@ -632,27 +640,27 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) // Remove icons' code rx.setPattern("^\\d{1,3}\\s"); - szLine.replace(rx,""); + szLine.replace(rx, ""); // Remove link from a user speaking, deal with (and keep) various ranks // e.g.: <!ncHelLViS69> --> <HelLViS69> rx.setPattern("\\s<([+%@&~!]?)!nc"); - szLine.replace(rx," <\\1"); + szLine.replace(rx, " <\\1"); // Remove link from a nick in a mask // e.g.: !nFoo [~bar@!hfoo.bar] --> Foo [~bar@!hfoo.bar] rx.setPattern("\\s!n"); - szLine.replace(rx," "); + szLine.replace(rx, " "); // Remove link from a host in a mask // e.g.: Foo [~bar@!hfoo.bar] --> Foo [~bar@foo.bar] rx.setPattern("@!h"); - szLine.replace(rx,"@"); + szLine.replace(rx, "@"); // Remove link from a channel // e.g.: !c#KVIrc --> #KVIrc rx.setPattern("!c#"); - szLine.replace(rx,"#"); + szLine.replace(rx, "#"); szOutputBuffer += szLine; szOutputBuffer += "\n"; @@ -675,20 +683,20 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) switch(pLog->type()) { case LogFile::Channel: - szTitle = __tr2qs_ctx("Channel %1 on %2","log").arg(pLog->name(),pLog->network()); - break; + szTitle = __tr2qs_ctx("Channel %1 on %2", "log").arg(pLog->name(), pLog->network()); + break; case LogFile::Console: - szTitle = __tr2qs_ctx("Console on %1","log").arg(pLog->network()); - break; + szTitle = __tr2qs_ctx("Console on %1", "log").arg(pLog->network()); + break; case LogFile::Query: - szTitle = __tr2qs_ctx("Query with: %1 on %2","log").arg(pLog->name(),pLog->network()); - break; + szTitle = __tr2qs_ctx("Query with: %1 on %2", "log").arg(pLog->name(), pLog->network()); + break; case LogFile::DccChat: - szTitle = __tr2qs_ctx("DCC Chat with: %1","log").arg(pLog->name()); - break; + szTitle = __tr2qs_ctx("DCC Chat with: %1", "log").arg(pLog->name()); + break; case LogFile::Other: - szTitle = __tr2qs_ctx("Something on: %1","log").arg(pLog->network()); - break; + szTitle = __tr2qs_ctx("Something on: %1", "log").arg(pLog->network()); + break; } // Prepare HTML document @@ -707,23 +715,23 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) szTmp = (*it); // Find who has talked - QString szTmpNick = szTmp.section(" ",2,2); + QString szTmpNick = szTmp.section(" ", 2, 2); if((szTmpNick.left(1) != "<") && (szTmpNick.right(1) != ">")) szTmpNick = ""; // locate msgtype - QString szNum = szTmp.section(' ',0,0); + QString szNum = szTmp.section(' ', 0, 0); bool bOk; int iMsgType = szNum.toInt(&bOk); // only human text for now... - if(iMsgType != 24 && iMsgType != 25 && iMsgType != 26) + if(iMsgType != 24 && iMsgType != 25 && iMsgType != 26) continue; // remove msgtype tag - szTmp = szTmp.remove(0,szNum.length()+1); + szTmp = szTmp.remove(0, szNum.length() + 1); - szTmp = KviHtmlGenerator::convertToHtml(szTmp,true); + szTmp = KviHtmlGenerator::convertToHtml(szTmp, true); // insert msgtype icon at start of the current text line KviMessageTypeSettings msg(KVI_OPTION_MSGTYPE(iMsgType)); @@ -746,7 +754,9 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) szTmp.prepend("<p>"); szNick = szTmpNick; - } else { + } + else + { // Break the line szTmp.prepend("<br />\n"); } @@ -764,7 +774,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) QStringList szImagesList; // search for icons - while (iIndex >= 0) + while(iIndex >= 0) { int iLength = rx.matchedLength(); QString szCap = rx.cap(1); @@ -777,7 +787,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) // get current theme path QString szCurrentThemePath; - g_pApp->getLocalKvircDirectory(szCurrentThemePath,KviApplication::Themes,KVI_OPTION_STRING(KviOption_stringIconThemeSubdir)); + g_pApp->getLocalKvircDirectory(szCurrentThemePath, KviApplication::Themes, KVI_OPTION_STRING(KviOption_stringIconThemeSubdir)); szCurrentThemePath += KVI_PATH_SEPARATOR_CHAR; // current coresmall path @@ -788,24 +798,24 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) if(!KviFileUtils::directoryExists(szCurrentThemePath)) { // get global coresmall path - g_pApp->getGlobalKvircDirectory(szCurrentThemePath,KviApplication::Pics,"coresmall"); - KviQString::ensureLastCharIs(szCurrentThemePath,QChar(KVI_PATH_SEPARATOR_CHAR)); + 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 < szImagesList.count(); i++) + for(int i = 0; i < szImagesList.count(); i++) { QString szSourceFile = szCurrentThemePath + szImagesList.at(i); QString szDestFile = szLogDir + szImagesList.at(i); - KviFileUtils::copyFile(szSourceFile,szDestFile); + KviFileUtils::copyFile(szSourceFile, szDestFile); } // remove internal tags rx.setPattern("<qt>|</qt>|smallicons:"); - szOutputBuffer.replace(rx,""); - szOutputBuffer.replace(">!nc",">"); - szOutputBuffer.replace("@!nc","@"); - szOutputBuffer.replace("%!nc","%"); + szOutputBuffer.replace(rx, ""); + szOutputBuffer.replace(">!nc", ">"); + szOutputBuffer.replace("@!nc", "@"); + szOutputBuffer.replace("%!nc", "%"); // Close the document szOutputBuffer += "</body>\n</html>\n"; diff --git a/src/modules/logview/LogViewWindow.h b/src/modules/logview/LogViewWindow.h index 72accda18..971166b95 100644 --- a/src/modules/logview/LogViewWindow.h +++ b/src/modules/logview/LogViewWindow.h @@ -53,6 +53,7 @@ class LogViewListView : public QTreeWidget public: LogViewListView(QWidget *); ~LogViewListView(){}; + protected: void mousePressEvent(QMouseEvent * pEvent); signals: @@ -65,43 +66,45 @@ class LogViewWindow : public KviWindow public: LogViewWindow(); ~LogViewWindow(); + protected: KviPointerList<LogFile> m_logList; - LogViewListView * m_pListView; + LogViewListView * m_pListView; // Type filter - QCheckBox * m_pShowChannelsCheck; - QCheckBox * m_pShowQueryesCheck; - QCheckBox * m_pShowConsolesCheck; - QCheckBox * m_pShowOtherCheck; - QCheckBox * m_pShowDccChatCheck; + QCheckBox * m_pShowChannelsCheck; + QCheckBox * m_pShowQueryesCheck; + QCheckBox * m_pShowConsolesCheck; + QCheckBox * m_pShowOtherCheck; + QCheckBox * m_pShowDccChatCheck; // Content filter - QLineEdit * m_pFileNameMask; - QLineEdit * m_pContentsMask; + QLineEdit * m_pFileNameMask; + QLineEdit * m_pContentsMask; // Date/time mask - QCheckBox * m_pEnableFromFilter; - QCheckBox * m_pEnableToFilter; - QDateEdit * m_pFromDateEdit; - QDateEdit * m_pToDateEdit; + QCheckBox * m_pEnableFromFilter; + QCheckBox * m_pEnableToFilter; + QDateEdit * m_pFromDateEdit; + QDateEdit * m_pToDateEdit; - QStringList * m_pFileNames; - QTabWidget * m_pTabWidget; - KviTalVBox * m_pIndexTab; - KviTalVBox * m_pLeftLayout; - QWidget * m_pSearchTab; - QPushButton * m_pFilterButton; - QPushButton * m_pCancelButton; - KviTalHBox * m_pBottomLayout; - QProgressBar * m_pProgressBar; - LogListViewItem * m_pLastCategory; + QStringList * m_pFileNames; + QTabWidget * m_pTabWidget; + KviTalVBox * m_pIndexTab; + KviTalVBox * m_pLeftLayout; + QWidget * m_pSearchTab; + QPushButton * m_pFilterButton; + QPushButton * m_pCancelButton; + KviTalHBox * m_pBottomLayout; + QProgressBar * m_pProgressBar; + LogListViewItem * m_pLastCategory; LogListViewItemFolder * m_pLastGroupItem; - QString m_szLastGroup; - bool m_bAborted; - QTimer * m_pTimer; - QMenu * m_pExportLogPopup; + QString m_szLastGroup; + bool m_bAborted; + QTimer * m_pTimer; + QMenu * m_pExportLogPopup; + public: /** * \brief Exports the log and creates the file in the selected format @@ -111,6 +114,7 @@ public: * \return void */ void createLog(LogFile * pLog, int iId, QString * pszFile = 0); + protected: void exportLog(int iId); void recurseDirectory(const QString & szDir); diff --git a/src/modules/logview/libkvilogview.cpp b/src/modules/logview/libkvilogview.cpp index f4742b98d..165973955 100644 --- a/src/modules/logview/libkvilogview.cpp +++ b/src/modules/logview/libkvilogview.cpp @@ -33,7 +33,7 @@ #include "KviLocale.h" #include "KviApplication.h" -static QRect g_rectLogViewGeometry; +static QRect g_rectLogViewGeometry; LogViewWindow * g_pLogViewWindow = 0; #define LOGVIEW_MODULE_EXTENSION_NAME "Log viewer extension" @@ -58,17 +58,16 @@ LogViewWindow * g_pLogViewWindow = 0; stored on disk. */ - static bool logview_kvs_cmd_open(KviKvsModuleCommandCall * c) { QString dummy; - bool bCreateMinimized = c->hasSwitch('m',dummy); - bool bNoRaise = c->hasSwitch('n',dummy); + bool bCreateMinimized = c->hasSwitch('m', dummy); + bool bNoRaise = c->hasSwitch('n', dummy); if(!g_pLogViewWindow) { g_pLogViewWindow = new LogViewWindow(); - g_pMainWindow->addWindow(g_pLogViewWindow,!bCreateMinimized); + g_pMainWindow->addWindow(g_pLogViewWindow, !bCreateMinimized); return true; } @@ -81,7 +80,7 @@ static bool logview_module_init(KviModule * m) { g_pLogViewWindow = 0; - KVSM_REGISTER_SIMPLE_COMMAND(m,"open",logview_kvs_cmd_open); + KVSM_REGISTER_SIMPLE_COMMAND(m, "open", logview_kvs_cmd_open); return true; } @@ -101,7 +100,7 @@ static bool logview_module_can_unload(KviModule *) static bool logview_module_ctrl(KviModule *, const char * pcOperation, void * pParam) { - if(!kvi_strEqualCI("logview::export",pcOperation)) + if(!kvi_strEqualCI("logview::export", pcOperation)) return false; LogFileData * pData = (LogFileData *)pParam; @@ -113,20 +112,19 @@ static bool logview_module_ctrl(KviModule *, const char * pcOperation, void * pP if(pData->szType == "html") iId = LogFile::HTML; - g_pLogViewWindow->createLog(pLog,iId,&(pData->szFile)); + g_pLogViewWindow->createLog(pLog, iId, &(pData->szFile)); return true; } KVIRC_MODULE( - "KVIrc Log Viewer Widget", - "4.0.0", - "Copyright (C) 2000 Juanjo Alvarez <juanjux@yahoo.es>\n" \ - " 2011 Elvio Basello (hellvis69 at gmail dot com)", - "A structured log file viewer", - logview_module_init, - logview_module_can_unload, - logview_module_ctrl, - logview_module_cleanup, - "logview" -) + "KVIrc Log Viewer Widget", + "4.0.0", + "Copyright (C) 2000 Juanjo Alvarez <juanjux@yahoo.es>\n" + " 2011 Elvio Basello (hellvis69 at gmail dot com)", + "A structured log file viewer", + logview_module_init, + logview_module_can_unload, + logview_module_ctrl, + logview_module_cleanup, + "logview") |
