chatmonitor++
authorManuel Nickschas <sputnick@quassel-irc.org>
Sat, 26 Jul 2008 22:13:24 +0000 (00:13 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 2 Aug 2008 13:17:11 +0000 (15:17 +0200)
src/client/messagefilter.cpp
src/client/messagefilter.h
src/qtui/CMakeLists.txt
src/qtui/chatmonitorfilter.cpp [new file with mode: 0644]
src/qtui/chatmonitorfilter.h [new file with mode: 0644]
src/qtui/chatview.cpp
src/qtui/chatview.h
src/qtui/columnhandleitem.cpp
src/qtui/mainwin.cpp

index bf86a3b..e375b2e 100644 (file)
 
 #include "messagefilter.h"
 
+MessageFilter::MessageFilter(QAbstractItemModel *source, QObject *parent) : QSortFilterProxyModel(parent) {
+  setSourceModel(source);
+}
+
 MessageFilter::MessageFilter(MessageModel *source, const QList<BufferId> &buffers, QObject *parent)
   : QSortFilterProxyModel(parent),
     _bufferList(buffers)
index d07a6e2..7338842 100644 (file)
@@ -29,6 +29,9 @@
 class MessageFilter : public QSortFilterProxyModel {
   Q_OBJECT
 
+  protected:
+    MessageFilter(QAbstractItemModel *source, QObject *parent = 0);
+
   public:
     MessageFilter(MessageModel *, const QList<BufferId> &buffers = QList<BufferId>(), QObject *parent = 0);
 
index 2951cf6..2ae71a3 100644 (file)
@@ -13,6 +13,7 @@ set(SOURCES
     chatline.cpp
     chatlinemodel.cpp
     chatlinemodelitem.cpp
+    chatmonitorfilter.cpp
     chatscene.cpp
     chatview.cpp
     columnhandleitem.cpp
@@ -39,6 +40,7 @@ set(MOC_HDRS
     bufferwidget.h
     channellistdlg.h
     chatlinemodel.h
+    chatmonitorfilter.h
     chatscene.h
     chatview.h
     columnhandleitem.h
diff --git a/src/qtui/chatmonitorfilter.cpp b/src/qtui/chatmonitorfilter.cpp
new file mode 100644 (file)
index 0000000..7c33bc7
--- /dev/null
@@ -0,0 +1,37 @@
+/***************************************************************************
+*   Copyright (C) 2005-08 by the Quassel Project                          *
+*   devel@quassel-irc.org                                                 *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) version 3.                                           *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+
+#include "chatmonitorfilter.h"
+
+ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
+: MessageFilter(model, QList<BufferId>(), parent)
+{
+  _initTime = QDateTime::currentDateTime();
+
+}
+
+bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
+  QDateTime msgTime = sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::TimestampRole).toDateTime();
+  return msgTime > _initTime;
+}
+
+QString ChatMonitorFilter::idString() const {
+  return "ChatMonitor";
+}
diff --git a/src/qtui/chatmonitorfilter.h b/src/qtui/chatmonitorfilter.h
new file mode 100644 (file)
index 0000000..0443dac
--- /dev/null
@@ -0,0 +1,41 @@
+/***************************************************************************
+*   Copyright (C) 2005-08 by the Quassel Project                          *
+*   devel@quassel-irc.org                                                 *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) version 3.                                           *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+
+#ifndef CHATMONITORFILTER_H_
+#define CHATMONITORFILTER_H_
+
+#include <QDateTime>
+
+#include "messagefilter.h"
+
+class ChatMonitorFilter : public MessageFilter {
+  Q_OBJECT
+
+  public:
+    ChatMonitorFilter(MessageModel *model, QObject *parent = 0);
+
+    virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+    virtual QString idString() const;
+
+  private:
+    QDateTime _initTime;
+};
+
+#endif
index 5bc02c5..ffd9e72 100644 (file)
 #include "quasselui.h"
 
 ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), AbstractChatView() {
-  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  setAlignment(Qt::AlignBottom);
-  setInteractive(true);
-
   QList<BufferId> filterList;
   filterList.append(buf->bufferInfo().bufferId());
   MessageFilter *filter = new MessageFilter(Client::messageModel(), filterList, this);
+  init(filter);
+
+}
+
+ChatView::ChatView(MessageFilter *filter, QWidget *parent) : QGraphicsView(parent), AbstractChatView() {
+  init(filter);
+}
+
+void ChatView::init(MessageFilter *filter) {
+  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  setAlignment(Qt::AlignBottom);
+  setInteractive(true);
 
   _scene = new ChatScene(filter, filter->idString(), this);
   connect(_scene, SIGNAL(heightChanged(qreal)), this, SLOT(sceneHeightChanged(qreal)));
   setScene(_scene);
 }
 
-
 ChatView::~ChatView() {
 
 }
index 88a7e23..be26a11 100644 (file)
@@ -29,11 +29,13 @@ class AbstractUiMsg;
 class Buffer;
 class ChatLine;
 class ChatScene;
+class MessageFilter;
 
 class ChatView : public QGraphicsView, public AbstractChatView {
   Q_OBJECT
 
   public:
+    ChatView(MessageFilter *, QWidget *parent = 0);
     ChatView(Buffer *, QWidget *parent = 0);
     ~ChatView();
 
@@ -60,6 +62,8 @@ class ChatView : public QGraphicsView, public AbstractChatView {
     virtual void sceneHeightChanged(qreal height);
 
   private:
+    void init(MessageFilter *filter);
+
     ChatScene *_scene;
 };
 
index 3631168..2b0231c 100644 (file)
@@ -118,7 +118,7 @@ void ColumnHandleItem::hoverChanged(qreal value) {
 void ColumnHandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
   Q_UNUSED(option);
   Q_UNUSED(widget);
-  
+
   QLinearGradient gradient(0, 0, width(), 0);
   gradient.setColorAt(0.25, Qt::transparent);
   gradient.setColorAt(0.5, QColor(0, 0, 0, _hover * 200));
index 1515dd4..d82ac15 100644 (file)
@@ -25,6 +25,8 @@
 #include "bufferviewfilter.h"
 #include "bufferviewmanager.h"
 #include "channellistdlg.h"
+#include "chatmonitorfilter.h"
+#include "chatview.h"
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "coreinfodlg.h"
@@ -285,26 +287,17 @@ void MainWin::setupNickWidget() {
 }
 
 void MainWin::setupChatMonitor() {
-/*
   VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
   dock->setObjectName("ChatMonitorDock");
 
-  ChatWidget *chatWidget = new ChatWidget(0, this);
-  chatWidget->show();
-  dock->setWidget(chatWidget);
+  ChatMonitorFilter *filter = new ChatMonitorFilter(Client::messageModel(), this); qDebug() << filter;
+  ChatView *chatView = new ChatView(filter, this);
+  chatView->show();
+  dock->setWidget(chatView);
   dock->show();
 
-  Buffer *buf = Client::monitorBuffer();
-  if(!buf)
-    return;
-
-  chatWidget->setContents(buf->contents());
-  connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *)));
-  connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *)));
-
   addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
   ui.menuViews->addAction(dock->toggleViewAction());
-*/
 }
 
 void MainWin::setupInputWidget() {