if(_selectionMode == NoSelection) {
chatScene()->setSelectingItem(this); // removes earlier selection if exists
_selectionStart = _selectionEnd = posToCursor(event->pos());
- _selectionMode = PartialSelection;
+ //_selectionMode = PartialSelection;
} else {
chatScene()->setSelectingItem(0);
_selectionMode = NoSelection;
qint16 end = posToCursor(event->pos());
if(end != _selectionEnd) {
_selectionEnd = end;
+ if(_selectionStart != _selectionEnd) _selectionMode = PartialSelection;
+ else _selectionMode = NoSelection;
update();
}
} else {
_selectionEnd = posToCursor(event->pos());
QString selection
= data(MessageModel::DisplayRole).toString().mid(qMin(_selectionStart, _selectionEnd), qAbs(_selectionStart - _selectionEnd));
- QApplication::clipboard()->setText(selection, QClipboard::Clipboard); // TODO configure where selections should go
+ chatScene()->putToClipboard(selection);
event->accept();
} else {
event->ignore();
void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if(_isSelecting && !event->buttons() & Qt::LeftButton) {
-# ifdef Q_WS_X11
- QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection);
-# endif
-//# else
- QApplication::clipboard()->setText(selectionToString());
-//# endif
+ putToClipboard(selectionToString());
_isSelecting = false;
event->accept();
} else {
}
}
+void ChatScene::putToClipboard(const QString &selection) {
+ // TODO Configure clipboards
+# ifdef Q_WS_X11
+ QApplication::clipboard()->setText(selection, QClipboard::Selection);
+# endif
+//# else
+ QApplication::clipboard()->setText(selection);
+//# endif
+}
+
//!\brief Convert current selection to human-readable string.
QString ChatScene::selectionToString() const {
//TODO Make selection format configurable!
void setSelectingItem(ChatItem *item);
ChatItem *selectingItem() const { return _selectingItem; }
void startGlobalSelection(ChatItem *item, const QPointF &itemPos);
+ void putToClipboard(const QString &);
void setIsFetchingBacklog(bool);
inline void setBufferForBacklogFetching(BufferId buffer);