[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Tue Apr 13 20:43:49 CEST 2004


CVS commit by arwalker: 

Added ability to later limit the number of log messages retained.


  M +21 -2     kstdebug.cpp   1.8
  M +6 -3      kstdebug.h   1.8


--- kdeextragear-2/kst/kst/kstdebug.cpp  #1.7:1.8
@@ -23,4 +23,5 @@
 #include <klocale.h>
 #include <qdatetime.h>
+#include <qvaluelist.h>
 
 KStaticDeleter<KstDebug> sd;
@@ -35,4 +36,6 @@ KstDebug *KstDebug::self() {
 
 KstDebug::KstDebug() {
+  _bApplyLimit = false;
+  _iLimit      = 10000;
 }
 
@@ -55,4 +57,16 @@ void KstDebug::log(const QString& msg, L
   
   _messages.append( message );
+  if( _bApplyLimit ) {
+    if( (int)_messages.size( ) > _iLimit ) {
+      QValueListIterator<LogMessage> first;
+      QValueListIterator<LogMessage> last;
+      
+      first = _messages.begin( );
+      last  = first;
+      last += _messages.size( ) - _iLimit; 
+      
+      _messages.erase( first, last );
+    }
+  }
   
   emit logAdded( );
@@ -107,4 +121,9 @@ void KstDebug::getText(QString& body) {
 }
 
+void KstDebug::setLimit( bool bApplyLimit, int iLimit ) {
+  _bApplyLimit = bApplyLimit;
+  _iLimit      = iLimit;
+}
+
 void KstDebug::sendEmail() {
   QString                       body;

--- kdeextragear-2/kst/kst/kstdebug.h  #1.7:1.8
@@ -42,11 +42,12 @@ class KstDebug : public QObject {
     void clear();
     void log(const QString& msg, LogLevel level = Notice);
+    void setLimit( bool bApplyLimit, int iLimit );   
+    void getText(QString& body);
+    void sendEmail();
+    
     QValueList<LogMessage>* messages( ) { return &_messages; }
     QStringList dataSourcePlugins() const;
     QString getLabel(LogLevel level) const;
 
-    void getText(QString& body);
-    void sendEmail();
-
   signals: 
     void logAdded();
@@ -58,4 +59,6 @@ class KstDebug : public QObject {
     static KstDebug *_self;
     QValueList<LogMessage> _messages;
+    bool  _bApplyLimit;
+    int         _iLimit;
 };
 





More information about the Kst mailing list