From e528271e366acaa788b420bdfab8e1dd03b43e12 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 27 Jul 2008 00:13:24 +0200 Subject: [PATCH] chatmonitor++ --- src/client/messagefilter.cpp | 4 ++++ src/client/messagefilter.h | 3 +++ src/qtui/CMakeLists.txt | 2 ++ src/qtui/chatmonitorfilter.cpp | 37 ++++++++++++++++++++++++++++++ src/qtui/chatmonitorfilter.h | 41 ++++++++++++++++++++++++++++++++++ src/qtui/chatview.cpp | 17 +++++++++----- src/qtui/chatview.h | 4 ++++ src/qtui/columnhandleitem.cpp | 2 +- src/qtui/mainwin.cpp | 19 +++++----------- 9 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 src/qtui/chatmonitorfilter.cpp create mode 100644 src/qtui/chatmonitorfilter.h diff --git a/src/client/messagefilter.cpp b/src/client/messagefilter.cpp index bf86a3bf..e375b2e7 100644 --- a/src/client/messagefilter.cpp +++ b/src/client/messagefilter.cpp @@ -20,6 +20,10 @@ #include "messagefilter.h" +MessageFilter::MessageFilter(QAbstractItemModel *source, QObject *parent) : QSortFilterProxyModel(parent) { + setSourceModel(source); +} + MessageFilter::MessageFilter(MessageModel *source, const QList &buffers, QObject *parent) : QSortFilterProxyModel(parent), _bufferList(buffers) diff --git a/src/client/messagefilter.h b/src/client/messagefilter.h index d07a6e25..73388428 100644 --- a/src/client/messagefilter.h +++ b/src/client/messagefilter.h @@ -29,6 +29,9 @@ class MessageFilter : public QSortFilterProxyModel { Q_OBJECT + protected: + MessageFilter(QAbstractItemModel *source, QObject *parent = 0); + public: MessageFilter(MessageModel *, const QList &buffers = QList(), QObject *parent = 0); diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 2951cf69..2ae71a35 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -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 index 00000000..7c33bc75 --- /dev/null +++ b/src/qtui/chatmonitorfilter.cpp @@ -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(), 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 index 00000000..0443daca --- /dev/null +++ b/src/qtui/chatmonitorfilter.h @@ -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 + +#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 diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 5bc02c57..ffd9e72a 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -30,20 +30,27 @@ #include "quasselui.h" ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), AbstractChatView() { - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlignment(Qt::AlignBottom); - setInteractive(true); - QList 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() { } diff --git a/src/qtui/chatview.h b/src/qtui/chatview.h index 88a7e23a..be26a119 100644 --- a/src/qtui/chatview.h +++ b/src/qtui/chatview.h @@ -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; }; diff --git a/src/qtui/columnhandleitem.cpp b/src/qtui/columnhandleitem.cpp index 36311688..2b0231c8 100644 --- a/src/qtui/columnhandleitem.cpp +++ b/src/qtui/columnhandleitem.cpp @@ -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)); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 1515dd47..d82ac15e 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -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() { -- 2.20.1