Git commit a4b5fec99693067524c980f93487a5c8279f515a by Peter Grasch. Committed on 23/12/2012 at 20:20. Pushed by grasch into branch 'master'. Removed stale log manager D +0 -266 simonlib/simonlogging/logmanager.cpp D +0 -75 simonlib/simonlogging/logmanager.h D +0 -251 simonlib/simonlogging/logmanagerdlg.ui http://commits.kde.org/simon/a4b5fec99693067524c980f93487a5c8279f515a diff --git a/simonlib/simonlogging/logmanager.cpp b/simonlib/simonlogging/l= ogmanager.cpp deleted file mode 100644 index 5839e86..0000000 --- a/simonlib/simonlogging/logmanager.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2008 Peter Grasch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * 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 "logmanager.h" -#include -#include -#include -#include -#include "logger.h" - -/** - * \brief Constructor - * - * \author Peter Grasch - */ -LogManager::LogManager() -: entries(new LogEntryList()), -killMe(false), -finishedLoading(false) -{ - connect(this, SIGNAL(finished()), this, SLOT(resetKillFlag())); - connect(this, SIGNAL(terminated()), this, SLOT(resetKillFlag())); -} - - -/** - * \brief Returns true if there would no point in (re-)reading the logfile - * \author Peter Grasch - * - * If this is false either the logfile changed or we never actually comple= tely read it - * - * @return have we finished reading the logfile? - */ -bool LogManager::hasFinishedReading() -{ - QFile logF("log/simon.log"); - return (this->finishedLoading && (logF.size() =3D=3D logFilesize)); -} - - -/** - * \brief reads the logfile, and saves the content into a vector of LogEnt= ry - * get the information of the loggfile by reading line by line. chops ever= y line into - * the tags; - * researches every line if a extra information is given - * [ERR] for Error - * [INF] for Info - * [UPD] for Update - * saves the read information into a Vector of LogEntry - * - * \author Phillip Goriup, Peter Grasch - */ -void LogManager::run () -{ - finishedLoading =3D false; - if(!this->entries) { - this->entries =3D new LogEntryList; - } - else { - delete(this->entries); - this->entries =3D new LogEntryList; - } - QFile *LogF =3D new QFile("log/simon.log"); - if (!LogF->open(QIODevice::ReadOnly)) { - emit logReadFinished(1); - } - logFilesize =3D LogF->size(); - QString str; - int type; - - int i =3D 0; - - QCoreApplication::processEvents(); - while (!LogF->atEnd () && !killMe) { - type =3D 0; - - str =3D LogF->readLine(); - if(str.contains("[ERR]", Qt::CaseInsensitive)) - type =3D type|ERR; - if(str.contains("[INF]", Qt::CaseInsensitive)) - type =3D type|INF; - if(str.contains("[UPD]", Qt::CaseInsensitive)) - type =3D type|UPD; - if(str.contains("[SET]", Qt::CaseInsensitive)) - type =3D type|SET; - - //MMMMMMMMMMMMUUUUUUUUUUUUUUUUUUHHHHHHHAAAAAAHHHHHHAAAAAAAA - QTime funzi_der_erste =3D QTime::fromString(str.mid(12 ,8),"hh:mm:ss"); - QDate funzus_der_grosse =3D QDate::fromString(str.mid(1,10),"yyyy/MM/d= d"); - //____________________________________________________________________= ___ - - this->entries->append(LogEntry(funzus_der_grosse , - funzi_der_erste, - str.remove(QRegExp("\\[.*\\]")).trimmed().toUtf8(), type)); - - i++; - } - delete(LogF); - if (!killMe) { - finishedLoading =3D true; - emit this->logReadFinished(0); - } - else { - emit this->logReadFinished(2); - } -} - - -/** - * \brief Retrieves the entries of the given day and emits them using foun= dEntries() - * - * The method will try to determine if the thread is currently running (an= d thus building the list) - * by calling isBusy() and will queue the process by connecting itself to = the finished() signal of - * the process - * - * \param day The day we want to view - * - * \author Phillip Goriup, Peter Grasch - */ -void LogManager::getDay(QDate day) -{ - - if (this->isBusy()) { - dayToGet =3D day; - disconnect(this, SIGNAL(finished())); - connect(this, SIGNAL(finished()), this, SLOT(getDay())); - return; - } - - if (day.isNull()) { - if (dayToGet.isNull()) return; - else day =3D dayToGet; - } - - LogEntryList *entriesperday =3D new LogEntryList; - - if (!this->entries || this->entries->count() =3D=3D 0) { - emit foundEntries(entriesperday,true); - return; //if we haven't read the= logfile - //there is no point in filtering it afterwards - } - - int i =3D 0; - int size =3D entries->count(); - while((ientries->at(i++).getDate() < day)) - ; - - i--; - - size =3D entries->count(); - while((ientries->at(i).getDate() =3D=3D day)) { - entriesperday->append(this->entries->at(i)); - i++; - - } - - emit foundEntries(entriesperday,true); - - dayToGet =3D QDate(); -} - - -/** - * \brief Frees the memory (if the entries are not clean (i.e. hasFinished= Reading() returns false) - * - * \author Phillip Goriup, Peter Grasch - */ -void LogManager::stop() -{ - disconnect(this, SIGNAL(finished()), 0,0); - - killMe=3Dtrue; - - if (isRunning()) - wait(5000); - if (isRunning()) - terminate(); //make ABSOLUTELY sure - if (isRunning()) //that the thread WILL s= top - wait(500); - - if(!hasFinishedReading()) - this->entries->clear(); - - killMe=3Dfalse; -} - - -/** - * \brief Will attempt to create a list of QDates ("Dates") and emit it us= ing daysAvailable(Dates) - * - * The method will try to determine if the thread is currently running (an= d thus building the list) - * by calling isBusy() and will queue the process by connecting itself to = the finished() signal of - * the process - * - * \author Peter Grasch - */ -void LogManager::getDateList() -{ - if (this->isBusy()) { - disconnect(this, SIGNAL(finished())); - connect(this, SIGNAL(finished()), this, SLOT(getDateList())); - return; - } - - if (!entries) { - emit daysAvailable(Dates()); - return; - } - Dates daysAvail; - QDate currentDate; - for (int i=3D0; i < this->entries->count(); i++) { - if (entries->at(i).getDate()!=3DcurrentDate) { - currentDate =3D entries->at(i).getDate(); - daysAvail << currentDate; - } - } - emit daysAvailable(daysAvail); -} - - -/** - * \brief Builds a list of all entries and emits them using foundEntries() - * - * The method will try to determine if the thread is currently running (an= d thus building the list) - * by calling isBusy() and will queue the process by connecting itself to = the finished() signal of - * the process - * - * \author Phillip Goriup - */ -void LogManager::getAll() -{ - if (this->isBusy()) { - disconnect(this, SIGNAL(finished())); - connect(this, SIGNAL(finished()), this, SLOT(getAll())); - return; - } - emit foundEntries(this->entries,false); -} - - -/** - * \brief Destructor - * - * \author Phillip Goriup - */ -LogManager::~LogManager() -{ - this->entries->clear(); - delete entries; -} diff --git a/simonlib/simonlogging/logmanager.h b/simonlib/simonlogging/log= manager.h deleted file mode 100644 index 4b1736b..0000000 --- a/simonlib/simonlogging/logmanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2008 Peter Grasch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * 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. - */ - -#ifndef SIMON_LOGMANAGER_H_3CC0A73916E54CBFBCDF602ABFF87075 -#define SIMON_LOGMANAGER_H_3CC0A73916E54CBFBCDF602ABFF87075 - -#include "logentry.h" -#include -#include - -class QDate; - -typedef QVector Dates; - -/** - * \class LogManager - * \brief Manages the logfile - * \author Phillip Goriup - * \date 6.8.2007 - * \version 0.1 - */ -class LogManager : public QThread -{ - Q_OBJECT - - private: - LogEntryList *entries; - bool killMe; - qint64 logFilesize; - bool finishedLoading; - QDate dayToGet; - - private slots: - void resetKillFlag() { killMe =3D false; } - - public: - LogManager(); - - ~LogManager(); - - bool isBusy() { return isRunning(); } - - bool hasFinishedReading(); - void run (); - - public slots: - void getDateList(); - void stop(); - void getDay(QDate day=3DQDate()); - void getAll(); - - signals: - void done(); - void logReadFinished(int value); - void foundEntries(LogEntryList* entries,bool copy); - void daysAvailable(Dates days); - -}; -#endif diff --git a/simonlib/simonlogging/logmanagerdlg.ui b/simonlib/simonlogging= /logmanagerdlg.ui deleted file mode 100644 index 904ca15..0000000 --- a/simonlib/simonlogging/logmanagerdlg.ui +++ /dev/null @@ -1,251 +0,0 @@ - - LogManagerDlg - - - - 0 - 0 - 564 - 394 - - - - Log Manager - - - - - - - Date - - - - - Message - - - - - - - - - 16777215 - 16777215 - - - - Search - - - false - - - - - - - - - - - 16777215 - 15 - - - - Search: - - - leSearchLogs - - - - - - - - - - - 0 - 0 - - - - - 16 - 16777215 - - - - &x - - - - - - - Search - - - - - - - - - - 16777215 - 15 - - - - Error - - - - - - - U= pdate - - - - - - - - 16777215 - 15 - - - - Information - - - - - - - Settings - - - - - - - 24 - - - - - - - - - - true - - - - - - - Cancel - - - - - - - - - Only of day - - - false - - - true - - - false - - - - - - Calendar - - - cwLogDay - - - - - - - true - - - - 0 - 0 - - - - - 200 - 0 - - - - Qt::Monday - - - true - - - - - - - - - - - - - - SimonGroupBox - QGroupBox -
simongroupbox.h
- 1 -
- - SimonCalendarWidget - QCalendarWidget -
simoncalendarwidget.h
-
-
- - - pbClearSearch - clicked() - leSearchLogs - clear() - - - 149 - 48 - - - 90 - 47 - - - - -