Exemplo n.º 1
0
void SciDoc::onCursorMoved(int line, int col) {
	if ( int_->hlTimer_->isActive() )
		int_->hlTimer_->stop();
	if ( QSciSettings::get(QSciSettings::HighlightCurWord) )
		int_->hlTimer_->start(500);
	emit cursorPosChanged(line, col);
}
Exemplo n.º 2
0
void QgsLayoutView::mouseMoveEvent( QMouseEvent *event )
{
  mMouseCurrentXY = event->pos();

  QPointF cursorPos = mapToScene( mMouseCurrentXY );
  if ( mTool )
  {
    std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event, false ) );
    if ( mTool->flags() & QgsLayoutViewTool::FlagSnaps )
    {
      me->snapPoint( mHorizontalSnapLine.get(), mVerticalSnapLine.get() );
    }
    if ( mTool->flags() & QgsLayoutViewTool::FlagSnaps )
    {
      //draw snapping point indicator
      if ( me->isSnapped() )
      {
        cursorPos = me->snappedPoint();
        mSnapMarker->setPos( me->snappedPoint() );
        mSnapMarker->setVisible( true );
      }
      else
        mSnapMarker->setVisible( false );
    }
    mTool->layoutMoveEvent( me.get() );
    event->setAccepted( me->isAccepted() );
  }

  //update cursor position in status bar
  emit cursorPosChanged( cursorPos );

  if ( !mTool || !event->isAccepted() )
    QGraphicsView::mouseMoveEvent( event );
}
Exemplo n.º 3
0
void QgsLayoutView::mouseMoveEvent( QMouseEvent *event )
{
  mMouseCurrentXY = event->pos();

  //update cursor position in status bar
  emit cursorPosChanged( mapToScene( mMouseCurrentXY ) );

  if ( mTool )
  {
    std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
    mTool->layoutMoveEvent( me.get() );
    event->setAccepted( me->isAccepted() );
  }

  if ( !mTool || !event->isAccepted() )
    QGraphicsView::mouseMoveEvent( event );
}
Exemplo n.º 4
0
void QgsComposerRuler::mouseMoveEvent( QMouseEvent* event )
{
    //qWarning( "QgsComposerRuler::mouseMoveEvent" );
    updateMarker( event->posF() );
    setSnapLinePosition( event->posF() );

    //update cursor position in status bar
    QPointF displayPos = mTransform.inverted().map( event->posF() );
    if ( mDirection == Horizontal )
    {
        //mouse is over a horizontal ruler, so don't show a y coordinate
        displayPos.setY( 0 );
    }
    else
    {
        //mouse is over a vertical ruler, so don't show an x coordinate
        displayPos.setX( 0 );
    }
    emit cursorPosChanged( displayPos );
}
Exemplo n.º 5
0
/**
 * Handles changes in the cursor position.
 * Emits a signal with the new line and column numbers.
 */
void EditorPage::slotCursorPosChange()
{
	uint nLine, nCol;
	
	// Find the new line and column number, and emit the signal
	if (!getCursorPos(nLine, nCol))
		return;
		
	emit cursorPosChanged(nLine, nCol);
	
	// Select the relevant symbol in the tag list
	if (Config().getAutoTagHl() && (m_nLine != nLine)) {
		m_pCtagsList->gotoLine(nLine);
		m_nLine = nLine;
	}
	
	// Abort code completion on cursor changes during the completion
	// process
	m_pCompletion->abort();
}
Exemplo n.º 6
0
/**
 * Handles changes in the cursor position.
 * Emits a signal with the new line and column numbers.
 */
void EditorPage::slotCursorPosChange(KTextEditor::View *pView)
{
	KTextEditor::Cursor position(pView->cursorPositionVirtual());

	// Find the new line and column number, and emit the signal
	uint nLine = position.line() + 1;
	uint nCol = position.column() + 1;

	emit cursorPosChanged(nLine, nCol);

	// Select the relevant symbol in the tag list
	if (Config().getAutoTagHl() && (m_nLine != nLine)) {
		m_pCtagsList->gotoLine(nLine);
		m_nLine = nLine;
	}

	// Abort code completion on cursor changes during the completion
	// process
	m_pCompletion->abort();
}
Exemplo n.º 7
0
/**
 * Handles changes in the cursor position.
 * Emits a signal with the new line and column numbers.
 */
void EditorPage::slotCursorPosChange(KTextEditor::View *view, 
        const KTextEditor::Cursor &newPosition)
{
	int nLine, nCol;

    if (view == NULL)
        return;

	// Find the new line and column number, and emit the signal
    newPosition.position(nLine, nCol);
    nLine++;
    nCol++;

	emit cursorPosChanged(nLine, nCol);
	
	// Select the relevant symbol in the tag list
	if (Config().getAutoTagHl() && (m_nLine != nLine)) {
		m_pCtagsListWidget->gotoLine(nLine);
		m_nLine = nLine;
	}
    m_pView->setFocus();
}
Exemplo n.º 8
0
void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
{
  if ( !composition() )
  {
    return;
  }

  mMouseCurrentXY = e->pos();
  //update cursor position in composer status bar
  emit cursorPosChanged( mapToScene( e->pos() ) );

  updateRulers();
  if ( mHorizontalRuler )
  {
    mHorizontalRuler->updateMarker( e->posF() );
  }
  if ( mVerticalRuler )
  {
    mVerticalRuler->updateMarker( e->posF() );
  }

  if ( mPanning )
  {
    //panning, so scroll view
    horizontalScrollBar()->setValue( horizontalScrollBar()->value() - ( e->x() - mMouseLastXY.x() ) );
    verticalScrollBar()->setValue( verticalScrollBar()->value() - ( e->y() - mMouseLastXY.y() ) );
    mMouseLastXY = e->pos();
    return;
  }
  else if ( e->buttons() == Qt::NoButton )
  {
    if ( mCurrentTool == Select )
    {
      QGraphicsView::mouseMoveEvent( e );
    }
  }
  else
  {
    QPointF scenePoint = mapToScene( e->pos() );

    if ( mMarqueeSelect || mMarqueeZoom )
    {
      updateRubberBand( scenePoint );
      return;
    }

    switch ( mCurrentTool )
    {
      case Select:
        QGraphicsView::mouseMoveEvent( e );
        break;

      case AddArrow:
      {
        if ( mRubberBandLineItem )
        {
          mRubberBandLineItem->setLine( mRubberBandStartPos.x(), mRubberBandStartPos.y(),  scenePoint.x(),  scenePoint.y() );
        }
        break;
      }

      case AddMap:
      case AddRectangle:
      case AddTriangle:
      case AddEllipse:
      case AddHtml:
        //adjust rubber band item
      {
        updateRubberBand( scenePoint );
        break;
      }

      case MoveItemContent:
      {
        //update map preview if composer map
        QgsComposerMap* composerMap = dynamic_cast<QgsComposerMap *>( mMoveContentItem );
        if ( composerMap )
        {
          composerMap->setOffset( scenePoint.x() - mMoveContentStartPos.x(), scenePoint.y() - mMoveContentStartPos.y() );
          composerMap->update();
        }
        break;
      }
      default:
        break;
    }
  }
}
Exemplo n.º 9
0
void QgsLayoutRuler::mouseMoveEvent( QMouseEvent *event )
{
  mMarkerPos = event->pos();
  update();

  QPointF displayPos;
  if ( mCreatingGuide || mDraggingGuide )
  {
    // event -> layout coordinates
    displayPos = convertLocalPointToLayout( event->pos() );

    if ( mCreatingGuide )
    {
      QgsLayout *layout = mView->currentLayout();
      int pageNo = layout->pageCollection()->pageNumberForPoint( displayPos );
      QgsLayoutItemPage *page = layout->pageCollection()->page( pageNo );
      if ( !page )
        return;

      QPen linePen = mGuideItem->pen();
      // if guide preview is outside a page draw it a lot fainter, to indicate it's invalid
      if ( !layout->pageCollection()->pageAtPoint( displayPos ) )
      {
        linePen.setColor( QColor( 255, 0, 0, 150 ) );
      }
      else
      {
        linePen.setColor( QColor( 255, 0, 0, 225 ) );
      }
      mGuideItem->setPen( linePen );
      switch ( mOrientation )
      {
        case Qt::Horizontal:
        {
          //mouse is creating a horizontal ruler, so don't show x coordinate
          mGuideItem->setLine( page->scenePos().x(), displayPos.y(), page->scenePos().x() + page->rect().width(), displayPos.y() );
          displayPos.setX( 0 );
          break;
        }
        case Qt::Vertical:
        {
          //mouse is creating a vertical ruler, so don't show a y coordinate
          mGuideItem->setLine( displayPos.x(), page->scenePos().y(), displayPos.x(), page->scenePos().y() + page->rect().height() );
          displayPos.setY( 0 );
          break;
        }
      }
    }
    else
    {
      // dragging guide
      switch ( mOrientation )
      {
        case Qt::Horizontal:
        {
          mView->currentLayout()->guides().setGuideLayoutPosition( mDraggingGuide, displayPos.x() );
          displayPos.setY( 0 );
          break;
        }
        case Qt::Vertical:
        {
          mView->currentLayout()->guides().setGuideLayoutPosition( mDraggingGuide, displayPos.y() );
          displayPos.setX( 0 );
          break;
        }
      }
    }
  }
  else
  {
    // is cursor over a guide marker?
    mHoverGuide = guideAtPoint( event->pos() );
    if ( mHoverGuide )
    {
      setCursor( mOrientation == Qt::Vertical ? Qt::SplitVCursor : Qt::SplitHCursor );
    }
    else
    {
      setCursor( Qt::ArrowCursor );
    }

    //update cursor position in status bar
    displayPos = mTransform.inverted().map( event->pos() );
    switch ( mOrientation )
    {
      case Qt::Horizontal:
      {
        //mouse is over a horizontal ruler, so don't show a y coordinate
        displayPos.setY( 0 );
        break;
      }
      case Qt::Vertical:
      {
        //mouse is over a vertical ruler, so don't show an x coordinate
        displayPos.setX( 0 );
        break;
      }
    }
  }
  emit cursorPosChanged( displayPos );
}