+
+ foreach(int idx, indexList) {
+ QTextLine line = layout()->lineForTextPosition(idx);
+ qreal x = line.cursorToX(idx);
+ qreal width = line.cursorToX(idx + searchWord.count()) - x;
+ qreal height = fontMetrics()->lineSpacing();
+ qreal y = height * line.lineNumber();
+ resultList << QRectF(x, y, width, height);
+ }
+ return resultList;
+}
+
+
+void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
+ if(event->buttons() == Qt::LeftButton) {
+ 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();
+ }
+}
+
+void ChatItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+ if(event->buttons() == Qt::LeftButton) {
+ if(contains(event->pos())) {
+ qint16 end = posToCursor(event->pos());
+ if(end != _selectionEnd) {
+ _selectionEnd = end;
+ if(_selectionStart != _selectionEnd) _selectionMode = PartialSelection;
+ else _selectionMode = NoSelection;
+ update();
+ }
+ } else {
+ setFullSelection();
+ chatScene()->startGlobalSelection(this, event->pos());
+ }