X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.h;h=fa441023c8be96bcb99296a13fe4c906c57024b5;hp=beeb699ecee4c65abe63ec2bbc5a29d7b47a8158;hb=fc81975a545211f3ccd3d25e266477adad2c9445;hpb=d6b056e936ec441258d291b7a8af7b83f9f53016 diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index beeb699e..fa441023 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,37 +18,97 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _CHATSCENE_H_ -#define _CHATSCENE_H_ +#ifndef CHATSCENE_H_ +#define CHATSCENE_H_ +#include #include +#include + +#include "columnhandleitem.h" +#include "messagefilter.h" class AbstractUiMsg; -class Buffer; +class ChatItem; class ChatLine; + class QGraphicsSceneMouseEvent; class ChatScene : public QGraphicsScene { Q_OBJECT - public: - ChatScene(Buffer *buffer, QObject *parent); - virtual ~ChatScene(); +public: + ChatScene(QAbstractItemModel *model, const QString &idString, qreal width, QObject *parent); + virtual ~ChatScene(); + + inline QAbstractItemModel *model() const { return _model; } + inline QString idString() const { return _idString; } + + int sectionByScenePos(int x); + inline int sectionByScenePos(const QPoint &pos) { return sectionByScenePos(pos.x()); } + inline bool isSingleBufferScene() const { return _singleBufferScene; } + inline bool containsBuffer(const BufferId &id) const; + inline ChatLine *chatLine(int row) { return (row < _lines.count()) ? _lines[row] : 0; } + + inline ColumnHandleItem *firstColumnHandle() const { return firstColHandle; } + inline ColumnHandleItem *secondColumnHandle() const { return secondColHandle; } + +public slots: + void setWidth(qreal, bool forceReposition = false); + + // these are used by the chatitems to notify the scene and manage selections + void setSelectingItem(ChatItem *item); + ChatItem *selectingItem() const { return _selectingItem; } + void startGlobalSelection(ChatItem *item, const QPointF &itemPos); + void putToClipboard(const QString &); - Buffer *buffer() const; + void requestBacklog(); - public slots: +signals: + void sceneHeightChanged(qreal dh); - protected slots: - void appendMsg(AbstractUiMsg *msg); - void prependMsg(AbstractUiMsg *msg); +protected: + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); - void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ); +protected slots: + void rowsInserted(const QModelIndex &, int, int); + void rowsAboutToBeRemoved(const QModelIndex &, int, int); - private: - Buffer *_buffer; - QList _lines; +private slots: + void handlePositionChanged(qreal xpos); +private: + void setHandleXLimits(); + void updateSelection(const QPointF &pos); + QString selectionToString() const; + + QString _idString; + QAbstractItemModel *_model; + QList _lines; + bool _singleBufferScene; + + // calls to QChatScene::sceneRect() are very expensive. As we manage the scenerect ourselves + // we store the size in a member variable. + QRectF _sceneRect; + void updateSceneRect(const QRectF &rect); + + ColumnHandleItem *firstColHandle, *secondColHandle; + qreal firstColHandlePos, secondColHandlePos; + + ChatItem *_selectingItem; + int _selectionStartCol, _selectionMinCol; + int _selectionStart; + int _selectionEnd; + int _firstSelectionRow, _lastSelectionRow; + bool _isSelecting; + + int _lastBacklogSize; }; +bool ChatScene::containsBuffer(const BufferId &id) const { + return qobject_cast(model()) ? qobject_cast(model())->containsBuffer(id) : false; +} + #endif