X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=60f3f1bb6cca414821fc867c7cfb916eabd1ecfe;hp=7d2944c696c83c167ebdbce61b8a581538f21183;hb=e8e50ceb0f0df46a6f281f6d4fd587f00fe532d3;hpb=7e76b93191c8f19c24709f36992c99f8ee9d508d diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 7d2944c6..60f3f1bb 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -48,7 +48,7 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w _chatView(parent), _idString(idString), _model(model), - _singleBufferScene(false), + _singleBufferId(BufferId()), _sceneRect(0, 0, width, 0), _firstLineRow(-1), _viewportHeight(0), @@ -61,8 +61,8 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w _leftButtonPressed(false) { MessageFilter *filter = qobject_cast(model); - if(filter) { - _singleBufferScene = filter->isSingleBufferFilter(); + if(filter && filter->isSingleBufferFilter()) { + _singleBufferId = filter->singleBufferId(); } ChatViewSettings defaultSettings; @@ -110,10 +110,6 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w _clickTimer.setSingleShot(true); connect(&_clickTimer, SIGNAL(timeout()), SLOT(clickTimeout())); - _clickTimer.setInterval(QApplication::doubleClickInterval()); - _clickTimer.setSingleShot(true); - connect(&_clickTimer, SIGNAL(timeout()), SLOT(clickTimeout())); - setItemIndexMethod(QGraphicsScene::NoIndex); } @@ -579,7 +575,8 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu menu; // zoom actions and similar - chatView()->addActionsToMenu(&menu); + chatView()->addActionsToMenu(&menu, pos); + menu.addSeparator(); if(isPosOverSelection(pos)) menu.addAction(SmallIcon("edit-copy"), tr("Copy Selection"), @@ -590,6 +587,9 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ChatItem *item = chatItemAt(pos); if(item) item->addActionsToMenu(&menu, item->mapFromScene(pos)); + else + // no item -> default scene actions + Client::mainUi()->actionProvider()->addActions(&menu, filter(), BufferId()); menu.exec(event->screenPos()); @@ -598,7 +598,8 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if(event->buttons() == Qt::LeftButton) { if(!_clickHandled && (event->scenePos() - _clickPos).toPoint().manhattanLength() >= QApplication::startDragDistance()) { - if(_clickTimer.isActive()) _clickTimer.stop(); + if(_clickTimer.isActive()) + _clickTimer.stop(); if(_clickMode == SingleClick && isPosOverSelection(_clickPos)) initiateDrag(event->widget()); else { @@ -611,7 +612,7 @@ void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { updateSelection(event->scenePos()); emit mouseMoveWhileSelecting(event->scenePos()); event->accept(); - } else if(_clickHandled) + } else if(_clickHandled && _clickMode < DoubleClick) QGraphicsScene::mouseMoveEvent(event); } else QGraphicsScene::mouseMoveEvent(event); @@ -626,15 +627,19 @@ void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) { clearSelection(); } if(_clickMode != NoClick && _clickTimer.isActive()) { - _clickMode = (ClickMode)(_clickMode == TripleClick ? DoubleClick : _clickMode + 1); - handleClick(Qt::LeftButton, event->scenePos()); + switch(_clickMode) { + case NoClick: _clickMode = SingleClick; break; + case SingleClick: _clickMode = DoubleClick; break; + case DoubleClick: _clickMode = TripleClick; break; + case TripleClick: _clickMode = DoubleClick; break; + case DragStartClick: break; + } + handleClick(Qt::LeftButton, _clickPos); } else { _clickMode = SingleClick; _clickPos = event->scenePos(); } _clickTimer.start(); - } else if(event->buttons() == Qt::RightButton) { - handleClick(Qt::RightButton, event->scenePos()); } if(event->type() == QEvent::GraphicsSceneMouseDoubleClick) QGraphicsScene::mouseDoubleClickEvent(event); @@ -648,7 +653,7 @@ void ChatScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { } void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if(!event->buttons() & Qt::LeftButton) { + if(event->button() == Qt::LeftButton && _leftButtonPressed) { _leftButtonPressed = false; if(_clickMode != NoClick) { if(_clickMode == SingleClick)