speed improvement to checkForHighlight (non longer uses QSettings itself)
[quassel.git] / src / qtui / qtuimessageprocessor.h
index 161385b..57ed9bc 100644 (file)
 #ifndef QTUIMESSAGEPROCESSOR_H_
 #define QTUIMESSAGEPROCESSOR_H_
 
+#include <QTime>
+#include <QTimer>
+
 #include "abstractmessageprocessor.h"
 
 class QtUiMessageProcessor : public AbstractMessageProcessor {
   Q_OBJECT
 
-  public:
-    QtUiMessageProcessor(QObject *parent);
+public:
+  enum Mode {
+    TimerBased,
+    Concurrent
+  };
+
+  QtUiMessageProcessor(QObject *parent);
+
+  inline bool isProcessing() const { return _processing; }
+  inline Mode processMode() const { return _processMode; }
+
+  void reset();
+
+public slots:
+  void process(Message &msg);
+  void process(QList<Message> &msgs);
 
+private slots:
+  void processNextMessage();
+  void highlightListChanged(const QVariant &variant);
+  void highlightNickChanged(const QVariant &variant);
 
-  private:
-    void processMessage(Message &msg);
-    void processMessages(QList<Message> &msgs);
+private:
+  void checkForHighlight(Message &msg);
+  void startProcessing();
+  void updateProgress(bool start = false);
 
-    void checkForHighlight(Message &msg);
+  QList<QList<Message> > _processQueue;
+  QList<Message> _currentBatch;
+  QTimer _processTimer;
+  bool _processing;
+  Mode _processMode;
+  int _msgsProcessed, _msgCount;
+  QTime _progressTimer;
 
+  struct HighlightRule {
+    QString name;
+    bool isEnabled;
+    Qt::CaseSensitivity caseSensitive;
+    bool isRegExp;
+    inline HighlightRule(const QString &name, bool enabled, Qt::CaseSensitivity cs, bool regExp) : name(name), isEnabled(enabled), caseSensitive(cs), isRegExp(regExp) {}
+  };
+  
+  QList<HighlightRule> _highlightRules;
+  NotificationSettings::HighlightNickType _highlightNick;
 };
 
 #endif