예제 #1
0
void ChatView::mouseMoveEvent(QMouseEvent *event)
{
	QString anchorHref = getFragmentUnderMouse(event->pos()).charFormat().anchorHref();
	if (!anchorHref.isEmpty()) {
		const int delimiterIndex = anchorHref.indexOf("://");
		if (delimiterIndex != -1) {
			const QString scheme = anchorHref.left(delimiterIndex);
			hoveredContent = anchorHref.mid(delimiterIndex + 3);
			if (scheme == "card") {
				hoveredItemType = HoveredCard;
				emit cardNameHovered(hoveredContent);
			} else if (scheme == "user")
				hoveredItemType = HoveredUser;
			else
				hoveredItemType = HoveredUrl;
			viewport()->setCursor(Qt::PointingHandCursor);
		} else {
			hoveredItemType = HoveredNothing;
			viewport()->setCursor(Qt::IBeamCursor);
		}
	} else {
		hoveredItemType = HoveredNothing;
		viewport()->setCursor(Qt::IBeamCursor);
	}
	
	QTextBrowser::mouseMoveEvent(event);
}
예제 #2
0
void ChatView::mouseMoveEvent(QMouseEvent *event)
{
    QTextFragment frag = getFragmentUnderMouse(event->pos());
    QString cardName = getCardNameUnderMouse(frag);
    if (!cardName.isEmpty()) {
        viewport()->setCursor(Qt::PointingHandCursor);
        emit cardNameHovered(cardName);
    } else if (frag.charFormat().isAnchor())
        viewport()->setCursor(Qt::PointingHandCursor);
    else
        viewport()->setCursor(Qt::IBeamCursor);

    QTextBrowser::mouseMoveEvent(event);
}