Inter- and intra-item selections now behave properly, except deactivating a global...
[quassel.git] / src / qtui / chatscene.h
index a0bcefc..62a65f2 100644 (file)
 #ifndef _CHATSCENE_H_
 #define _CHATSCENE_H_
 
+#include <QAbstractItemModel>
 #include <QGraphicsScene>
-
-#include "messagemodel.h"
+#include <QSet>
 
 class AbstractUiMsg;
 class Buffer;
 class ChatItem;
 class ChatLine;
+class ColumnHandleItem;
+
 class QGraphicsSceneMouseEvent;
 
 class ChatScene : public QGraphicsScene {
   Q_OBJECT
 
   public:
-    ChatScene(MessageModel *model, QObject *parent);
+    ChatScene(QAbstractItemModel *model, const QString &idString, QObject *parent);
     virtual ~ChatScene();
 
     Buffer *buffer() const;
-    inline MessageModel *model() const { return _model; }
+    inline QAbstractItemModel *model() const { return _model; }
 
   public slots:
-    void setWidth(int);
+    void setWidth(qreal);
+
+    // 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);
 
   signals:
-    void heightChanged(int height);
+    void heightChanged(qreal height);
+
+  protected:
+    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
+    virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
+    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
 
   protected slots:
     void rowsInserted(const QModelIndex &, int, int);
-    void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );
+
+  private slots:
+    void rectChanged(const QRectF &);
+    void handlePositionChanged(qreal xpos);
 
   private:
-    int _width, _height;
-    int _timestampWidth, _senderWidth;
-    MessageModel *_model;
+    void updateSelection(const QPointF &pos);
+
+    QString _idString;
+    qreal _width, _height;
+    QAbstractItemModel *_model;
     QList<ChatLine *> _lines;
 
+    ColumnHandleItem *firstColHandle, *secondColHandle;
+    qreal firstColHandlePos, secondColHandlePos;
+
+    ChatItem *_selectingItem, *_lastItem;
+    QSet<ChatLine *> _selectedItems;
+    int _selectionStartCol, _selectionMinCol;
+    int _selectionStart;
+    int _selectionEnd;
+    bool _isSelecting;
 };
 
 #endif