From: Manuel Nickschas Date: Mon, 17 Nov 2008 01:09:11 +0000 (+0100) Subject: Properly determine if mouse cursor is over selection in all cases X-Git-Tag: 0.4.0~425 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e7494078ad676d9fd14fab0396f51608a3ad46dc Properly determine if mouse cursor is over selection in all cases --- diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 9d1e04a2..af6ddc3a 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -555,7 +555,7 @@ bool ChatScene::isPosOverSelection(const QPointF &pos) const { if(hasGlobalSelection()) { int row = chatItem->row(); if(row >= qMin(_selectionStart, _selectionEnd) && row <= qMax(_selectionStart, _selectionEnd)) - return true; + return columnByScenePos(pos) >= _selectionMinCol; } else { return chatItem->isPosOverSelection(chatItem->mapFromScene(pos)); } @@ -766,7 +766,7 @@ void ChatScene::requestBacklog() { return; } -ChatLineModel::ColumnType ChatScene::columnByScenePos(qreal x) { +ChatLineModel::ColumnType ChatScene::columnByScenePos(qreal x) const { if(x < _firstColHandle->x()) return ChatLineModel::TimestampColumn; if(x < _secondColHandle->x()) @@ -775,7 +775,7 @@ ChatLineModel::ColumnType ChatScene::columnByScenePos(qreal x) { return ChatLineModel::ContentsColumn; } -int ChatScene::rowByScenePos(qreal y) { +int ChatScene::rowByScenePos(qreal y) const { // This is somewhat hacky... we look at the contents item that is at the given y position, since // it has the full height. From this item, we can then determine the row index and hence the ChatLine. // ChatItems cover their ChatLine, so we won't get to the latter directly. diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index 1c641093..12fc8c0f 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -74,10 +74,10 @@ public: inline QAbstractItemModel *model() const { return _model; } inline QString idString() const { return _idString; } - int rowByScenePos(qreal y); - inline int rowByScenePos(const QPointF &pos) { return rowByScenePos(pos.y()); } - ChatLineModel::ColumnType columnByScenePos(qreal x); - inline ChatLineModel::ColumnType columnByScenePos(const QPointF &pos) { return columnByScenePos(pos.x()); } + int rowByScenePos(qreal y) const; + inline int rowByScenePos(const QPointF &pos) const { return rowByScenePos(pos.y()); } + ChatLineModel::ColumnType columnByScenePos(qreal x) const ; + inline ChatLineModel::ColumnType columnByScenePos(const QPointF &pos) const { return columnByScenePos(pos.x()); } ChatView *chatView() const; ChatItem *chatItemAt(const QPointF &pos) const;