core defaults to safer umask
[quassel.git] / src / qtui / chatview.cpp
index 866ad4e..f8fe6b8 100644 (file)
 #include "messagefilter.h"
 #include "qtui.h"
 #include "qtuistyle.h"
+#include "clientignorelistmanager.h"
 
 ChatView::ChatView(BufferId bufferId, QWidget *parent)
   : QGraphicsView(parent),
     AbstractChatView(),
     _bufferContainer(0),
-    _currentScaleFactor(1)
+    _currentScaleFactor(1),
+    _invalidateFilter(false)
 {
   QList<BufferId> filterList;
   filterList.append(bufferId);
@@ -47,14 +49,15 @@ ChatView::ChatView(MessageFilter *filter, QWidget *parent)
   : QGraphicsView(parent),
     AbstractChatView(),
     _bufferContainer(0),
-    _currentScaleFactor(1)
+    _currentScaleFactor(1),
+    _invalidateFilter(false)
 {
   init(filter);
 }
 
 void ChatView::init(MessageFilter *filter) {
   setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  setAlignment(Qt::AlignBottom|Qt::AlignLeft);
+  setAlignment(Qt::AlignBottom);
   setInteractive(true);
   //setOptimizationFlags(QGraphicsView::DontClipPainter | QGraphicsView::DontAdjustForAntialiasing);
   // setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
@@ -66,10 +69,6 @@ void ChatView::init(MessageFilter *filter) {
   _scrollTimer.setSingleShot(true);
   connect(&_scrollTimer, SIGNAL(timeout()), SLOT(scrollTimerTimeout()));
 
-  _resizeTimer.setInterval(100);
-  _resizeTimer.setSingleShot(true);
-  connect(&_resizeTimer, SIGNAL(timeout()), SLOT(resizeTimerTimeout()));
-
   _scene = new ChatScene(filter, filter->idString(), viewport()->width() - 4, this); // see below: resizeEvent()
   connect(_scene, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(sceneRectChanged(const QRectF &)));
   connect(_scene, SIGNAL(lastLineChanged(QGraphicsItem *, qreal)), this, SLOT(lastLineChanged(QGraphicsItem *, qreal)));
@@ -77,7 +76,10 @@ void ChatView::init(MessageFilter *filter) {
   setScene(_scene);
 
   connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int)));
-  connect(QtUi::style(), SIGNAL(changed()), this, SLOT(styleChanged()));
+
+  // only connect if client is synched with a core
+  if(Client::isSynced())
+    connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), this, SLOT(invalidateFilter()));
 }
 
 bool ChatView::event(QEvent *event) {
@@ -104,15 +106,16 @@ bool ChatView::event(QEvent *event) {
     }
   }
 
+  if(event->type() == QEvent::Show) {
+    if(_invalidateFilter)
+      invalidateFilter();
+  }
+
   return QGraphicsView::event(event);
 }
 
 void ChatView::resizeEvent(QResizeEvent *event) {
   QGraphicsView::resizeEvent(event);
-  _resizeTimer.start();
-}
-
-void ChatView::resizeTimerTimeout() {
 
   // we can reduce viewport updates if we scroll to the bottom allready at the beginning
   verticalScrollBar()->setValue(verticalScrollBar()->maximum());
@@ -180,12 +183,6 @@ void ChatView::verticalScrollbarChanged(int newPos) {
     vbar->setValue(vbar->maximum());
 }
 
-void ChatView::styleChanged() {
-  invalidateScene();
-  if(scene())
-    scene()->update();
-}
-
 MsgId ChatView::lastMsgId() const {
   if(!scene())
     return MsgId();
@@ -223,3 +220,16 @@ void ChatView::zoomOriginal() {
     _currentScaleFactor = 1;
     scene()->setWidth(viewport()->width() - 2);
 }
+
+void ChatView::invalidateFilter() {
+  // if this is the currently selected chatview
+  // invalidate immediately
+  if(isVisible()) {
+    _scene->filter()->invalidateFilter();
+    _invalidateFilter = false;
+  }
+  // otherwise invalidate whenever the view is shown
+  else {
+    _invalidateFilter = true;
+  }
+}