X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.h;h=66026c1bc323b43ee98c7237097f8f0de05cdd20;hp=e72308e43e0dba33ea322bbcafd32e46d8a50af5;hb=62192fb6cd9cc211b5b9fe844c9b4c2f98f923cc;hpb=dbefd590650e9053c7a1513a5f49aad3e582108a diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index e72308e4..66026c1b 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -18,105 +18,87 @@ * 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 "types.h" +#include "columnhandleitem.h" + class AbstractUiMsg; -class Buffer; -class BufferId; class ChatItem; class ChatLine; -class ColumnHandleItem; class QGraphicsSceneMouseEvent; class ChatScene : public QGraphicsScene { Q_OBJECT - public: - ChatScene(QAbstractItemModel *model, const QString &idString, QObject *parent); - virtual ~ChatScene(); - - inline QAbstractItemModel *model() const { return _model; } - inline QString idString() const { return _idString; } - - inline bool isFetchingBacklog() const; - inline bool isBacklogFetchingEnabled() const; - inline BufferId bufferForBacklogFetching() const; +public: + ChatScene(QAbstractItemModel *model, const QString &idString, qreal width, QObject *parent); + virtual ~ChatScene(); - public slots: - void setWidth(qreal); + inline QAbstractItemModel *model() const { return _model; } + inline QString idString() const { return _idString; } - // 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); + int sectionByScenePos(int x); + inline int sectionByScenePos(const QPoint &pos) { return sectionByScenePos(pos.x()); } + inline bool isSingleBufferScene() const { return _singleBufferScene; } + inline ChatLine *chatLine(int row) { return (row < _lines.count()) ? _lines[row] : 0; } - void setIsFetchingBacklog(bool); - inline void setBufferForBacklogFetching(BufferId buffer); + inline ColumnHandleItem *firstColumnHandle() const { return firstColHandle; } + inline ColumnHandleItem *secondColumnHandle() const { return secondColHandle; } - signals: - void heightChanged(qreal height); +public slots: + void setWidth(qreal, bool forceReposition = false); - protected: - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); + // 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 &); - protected slots: - void rowsInserted(const QModelIndex &, int, int); - void modelReset(); + void requestBacklog(); - private slots: - void rectChanged(const QRectF &); - void handlePositionChanged(qreal xpos); +signals: + void sceneHeightChanged(qreal dh); - private: - void updateSelection(const QPointF &pos); - QString selectionToString() const; - void requestBacklogIfNeeded(); +protected: + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); - QString _idString; - qreal _width, _height; - QAbstractItemModel *_model; - QList _lines; +protected slots: + void rowsInserted(const QModelIndex &, int, int); + void rowsAboutToBeRemoved(const QModelIndex &, int, int); - ColumnHandleItem *firstColHandle, *secondColHandle; - qreal firstColHandlePos, secondColHandlePos; +private slots: + void handlePositionChanged(qreal xpos); - ChatItem *_selectingItem, *_lastItem; - QSet _selectedItems; - int _selectionStartCol, _selectionMinCol; - int _selectionStart; - int _selectionEnd; - bool _isSelecting; +private: + void setHandleXLimits(); + void updateSelection(const QPointF &pos); + QString selectionToString() const; - bool _fetchingBacklog; - BufferId _backlogFetchingBuffer; - MsgId _lastBacklogOffset; - int _lastBacklogSize; -}; - -bool ChatScene::isFetchingBacklog() const { - return _fetchingBacklog; -} + QString _idString; + QAbstractItemModel *_model; + QList _lines; + bool _singleBufferScene; -bool ChatScene::isBacklogFetchingEnabled() const { - return _backlogFetchingBuffer.isValid(); -} + ColumnHandleItem *firstColHandle, *secondColHandle; + qreal firstColHandlePos, secondColHandlePos; -BufferId ChatScene::bufferForBacklogFetching() const { - return _backlogFetchingBuffer; -} + ChatItem *_selectingItem; + int _selectionStartCol, _selectionMinCol; + int _selectionStart; + int _selectionEnd; + int _firstSelectionRow, _lastSelectionRow; + bool _isSelecting; -void ChatScene::setBufferForBacklogFetching(BufferId buf) { - _backlogFetchingBuffer = buf; -} + int _lastBacklogSize; +}; #endif