void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if(event->buttons() & Qt::LeftButton) {
- chatScene()->setSelectingItem(this); // removes earlier selection if exists
- _selectionStart = _selectionEnd = posToCursor(event->pos());
- _selectionMode = PartialSelection;
+ if(_selectionMode == NoSelection) {
+ chatScene()->setSelectingItem(this); // removes earlier selection if exists
+ _selectionStart = _selectionEnd = posToCursor(event->pos());
+ _selectionMode = PartialSelection;
+ } else {
+ chatScene()->setSelectingItem(0);
+ _selectionMode = NoSelection;
+ update();
+ }
event->accept();
} else {
event->ignore();
_width = 0;
_selectingItem = 0;
_isSelecting = false;
+ _selectionStart = -1;
connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &)));
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowsInserted(const QModelIndex &, int, int)));
}
void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
- qDebug() << "pressed";
- QGraphicsScene::mousePressEvent(event);
+ if(event->buttons() & Qt::LeftButton && _selectionStart >= 0) {
+ for(int l = qMin(_selectionStart, _selectionEnd); l <= qMax(_selectionStart, _selectionEnd); l++) {
+ _lines[l]->setSelected(false);
+ }
+ _selectionStart = -1;
+ event->accept();
+ } else {
+ QGraphicsScene::mousePressEvent(event);
+ }
}
void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {