[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [simon] simonlib/simonlogging: Removed stale log manager
From:       Peter Grasch <grasch () simon-listens ! org>
Date:       2012-12-23 19:20:39
Message-ID: 20121223192039.E61E3A60C4 () git ! kde ! org
[Download RAW message or body]

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/logmanager.cpp
deleted file mode 100644
index 5839e86..0000000
--- a/simonlib/simonlogging/logmanager.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- *   Copyright (C) 2008 Peter Grasch <peter.grasch@bedahr.org>
- *
- *   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 <QRegExp>
-#include <QFile>
-#include <QCoreApplication>
-#include <QDate>
-#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 completely read it
- *
- * @return have we finished reading the logfile?
- */
-bool LogManager::hasFinishedReading()
-{
-  QFile logF("log/simon.log");
-  return (this->finishedLoading && (logF.size() == logFilesize));
-}
-
-
-/**
- * \brief reads the logfile, and saves the content into a vector of LogEntry
- * get the information of the loggfile by reading line by line. chops every 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 = false;
-  if(!this->entries) {
-    this->entries = new LogEntryList;
-  }
-  else {
-    delete(this->entries);
-    this->entries = new LogEntryList;
-  }
-  QFile *LogF = new QFile("log/simon.log");
-  if (!LogF->open(QIODevice::ReadOnly)) {
-    emit logReadFinished(1);
-  }
-  logFilesize = LogF->size();
-  QString str;
-  int type;
-
-  int i = 0;
-
-  QCoreApplication::processEvents();
-  while (!LogF->atEnd () && !killMe) {
-    type = 0;
-
-    str = LogF->readLine();
-    if(str.contains("[ERR]", Qt::CaseInsensitive))
-      type = type|ERR;
-    if(str.contains("[INF]", Qt::CaseInsensitive))
-      type = type|INF;
-    if(str.contains("[UPD]", Qt::CaseInsensitive))
-      type = type|UPD;
-    if(str.contains("[SET]", Qt::CaseInsensitive))
-      type = type|SET;
-
-    //MMMMMMMMMMMMUUUUUUUUUUUUUUUUUUHHHHHHHAAAAAAHHHHHHAAAAAAAA
-    QTime funzi_der_erste = QTime::fromString(str.mid(12 ,8),"hh:mm:ss");
-    QDate funzus_der_grosse = QDate::fromString(str.mid(1,10),"yyyy/MM/dd");
-    //_______________________________________________________________________
-
-    this->entries->append(LogEntry(funzus_der_grosse ,
-      funzi_der_erste,
-      str.remove(QRegExp("\\[.*\\]")).trimmed().toUtf8(), type));
-
-    i++;
-  }
-  delete(LogF);
-  if (!killMe) {
-    finishedLoading = true;
-    emit this->logReadFinished(0);
-  }
-  else {
-    emit this->logReadFinished(2);
-  }
-}
-
-
-/**
- * \brief Retrieves the entries of the given day and emits them using foundEntries()
- *
- * The method will try to determine if the thread is currently running (and 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 = day;
-    disconnect(this, SIGNAL(finished()));
-    connect(this, SIGNAL(finished()), this, SLOT(getDay()));
-    return;
-  }
-
-  if (day.isNull()) {
-    if (dayToGet.isNull()) return;
-    else day = dayToGet;
-  }
-
-  LogEntryList *entriesperday = new LogEntryList;
-
-  if (!this->entries || this->entries->count() == 0) {
-    emit foundEntries(entriesperday,true);
-    return;                                       //if we haven't read the logfile
-    //there is no point in filtering it afterwards
-  }
-
-  int i = 0;
-  int size = entries->count();
-  while((i<size) && (this->entries->at(i++).getDate() < day))
-    ;
-
-  i--;
-
-  size = entries->count();
-  while((i<size) && (this->entries->at(i).getDate() == day)) {
-    entriesperday->append(this->entries->at(i));
-    i++;
-
-  }
-
-  emit foundEntries(entriesperday,true);
-
-  dayToGet = QDate();
-}
-
-
-/**
- * \brief Frees the memory (if the entries are not clean (i.e. hasFinishedReading() returns false)
- *
- * \author Phillip Goriup, Peter Grasch
- */
-void LogManager::stop()
-{
-  disconnect(this, SIGNAL(finished()), 0,0);
-
-  killMe=true;
-
-  if (isRunning())
-    wait(5000);
-  if (isRunning())
-    terminate();                                  //make ABSOLUTELY sure
-  if (isRunning())                                //that the thread WILL stop
-    wait(500);
-
-  if(!hasFinishedReading())
-    this->entries->clear();
-
-  killMe=false;
-}
-
-
-/**
- * \brief Will attempt to create a list of QDates ("Dates") and emit it using daysAvailable(Dates)
- *
- * The method will try to determine if the thread is currently running (and 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=0; i < this->entries->count(); i++) {
-    if (entries->at(i).getDate()!=currentDate) {
-      currentDate = 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 (and 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/logmanager.h
deleted file mode 100644
index 4b1736b..0000000
--- a/simonlib/simonlogging/logmanager.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *   Copyright (C) 2008 Peter Grasch <peter.grasch@bedahr.org>
- *
- *   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 <QThread>
-#include <QVector>
-
-class QDate;
-
-typedef QVector<QDate> 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 = false; }
-
-  public:
-    LogManager();
-
-    ~LogManager();
-
-    bool isBusy() { return isRunning(); }
-
-    bool hasFinishedReading();
-    void run ();
-
-  public slots:
-    void getDateList();
-    void stop();
-    void getDay(QDate day=QDate());
-    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 @@
-<ui version="4.0" >
- <class>LogManagerDlg</class>
- <widget class="QWidget" name="LogManagerDlg" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>564</width>
-    <height>394</height>
-   </rect>
-  </property>
-  <property name="windowTitle" >
-   <string>Log Manager</string>
-  </property>
-  <layout class="QVBoxLayout" >
-   <item>
-    <widget class="QTreeWidget" name="twLogEntries" >
-     <column>
-      <property name="text" >
-       <string>Date</string>
-      </property>
-     </column>
-     <column>
-      <property name="text" >
-       <string>Message</string>
-      </property>
-     </column>
-    </widget>
-   </item>
-   <item>
-    <widget class="QGroupBox" name="gwSearchInLogs" >
-     <property name="maximumSize" >
-      <size>
-       <width>16777215</width>
-       <height>16777215</height>
-      </size>
-     </property>
-     <property name="title" >
-      <string comment="Search for a specific log message">Search</string>
-     </property>
-     <property name="flat" >
-      <bool>false</bool>
-     </property>
-     <layout class="QHBoxLayout" >
-      <item>
-       <layout class="QGridLayout" >
-        <item row="0" column="0" colspan="2" >
-         <layout class="QHBoxLayout" >
-          <item>
-           <widget class="QLabel" name="lbSearchLogsFor" >
-            <property name="maximumSize" >
-             <size>
-              <width>16777215</width>
-              <height>15</height>
-             </size>
-            </property>
-            <property name="text" >
-             <string comment="Search pattern">Search:</string>
-            </property>
-            <property name="buddy" >
-             <cstring>leSearchLogs</cstring>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="KLineEdit" name="leSearchLogs" />
-          </item>
-          <item>
-           <widget class="KPushButton" name="pbClearSearch" >
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="maximumSize" >
-             <size>
-              <width>16</width>
-              <height>16777215</height>
-             </size>
-            </property>
-            <property name="text" >
-             <string>&amp;x</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="KPushButton" name="pbLogSearch" >
-            <property name="text" >
-             <string comment="Start the log search">Search</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </item>
-        <item row="1" column="0" >
-         <widget class="QCheckBox" name="cbLogError" >
-          <property name="maximumSize" >
-           <size>
-            <width>16777215</width>
-            <height>15</height>
-           </size>
-          </property>
-          <property name="text" >
-           <string>Error</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="1" >
-         <widget class="QCheckBox" name="cbLogUpdate" >
-          <property name="text" >
-           <string comment="Display messages of the category 'Update'">Update</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="0" >
-         <widget class="QCheckBox" name="cbLogInfo" >
-          <property name="maximumSize" >
-           <size>
-            <width>16777215</width>
-            <height>15</height>
-           </size>
-          </property>
-          <property name="text" >
-           <string>Information</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="1" >
-         <widget class="QCheckBox" name="cbLogSettings" >
-          <property name="text" >
-           <string>Settings</string>
-          </property>
-         </widget>
-        </item>
-        <item row="3" column="0" colspan="2" >
-         <widget class="QProgressBar" name="pbLogLoad" >
-          <property name="value" >
-           <number>24</number>
-          </property>
-         </widget>
-        </item>
-        <item row="4" column="0" >
-         <widget class="QLabel" name="lbLogLoad" >
-          <property name="text" >
-           <string/>
-          </property>
-          <property name="wordWrap" >
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item row="4" column="1" >
-         <widget class="KPushButton" name="pbAbort" >
-          <property name="text" >
-           <string>Cancel</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <widget class="SimonGroupBox" name="gbOnlyDay" >
-        <property name="title" >
-         <string>Only of day</string>
-        </property>
-        <property name="flat" >
-         <bool>false</bool>
-        </property>
-        <property name="checkable" >
-         <bool>true</bool>
-        </property>
-        <property name="checked" >
-         <bool>false</bool>
-        </property>
-        <layout class="QVBoxLayout" >
-         <item>
-          <widget class="QLabel" name="lbCalendar" >
-           <property name="text" >
-            <string>Calendar</string>
-           </property>
-           <property name="buddy" >
-            <cstring>cwLogDay</cstring>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="SimonCalendarWidget" name="cwLogDay" >
-           <property name="enabled" >
-            <bool>true</bool>
-           </property>
-           <property name="sizePolicy" >
-            <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
-           </property>
-           <property name="minimumSize" >
-            <size>
-             <width>200</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="firstDayOfWeek" >
-            <enum>Qt::Monday</enum>
-           </property>
-           <property name="gridVisible" >
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <customwidgets>
-  <customwidget>
-   <class>SimonGroupBox</class>
-   <extends>QGroupBox</extends>
-   <header>simongroupbox.h</header>
-   <container>1</container>
-  </customwidget>
-  <customwidget>
-   <class>SimonCalendarWidget</class>
-   <extends>QCalendarWidget</extends>
-   <header>simoncalendarwidget.h</header>
-  </customwidget>
- </customwidgets>
- <connections>
-  <connection>
-   <sender>pbClearSearch</sender>
-   <signal>clicked()</signal>
-   <receiver>leSearchLogs</receiver>
-   <slot>clear()</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>149</x>
-     <y>48</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>90</x>
-     <y>47</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic