Exemple #1
0
bool TitlePicker::eventFilter(QObject *object, QEvent *e) {
  if (object != (QObject *)title)
    return FALSE;

  if (object->inherits("QwtTextLabel") &&
      e->type() == QEvent::MouseButtonDblClick) {
    emit doubleClicked();
    d_selected = true;
    return TRUE;
  }

  if (object->inherits("QwtTextLabel") &&
      e->type() == QEvent::MouseButtonPress) {
    const QMouseEvent *me = (const QMouseEvent *)e;

    emit clicked();

    if (me->button() == Qt::RightButton)
      emit showTitleMenu();
    else if (me->button() == Qt::LeftButton)
      setSelected();

    return !(me->modifiers() & Qt::ShiftModifier);
  }

  if (object->inherits("QwtTextLabel") && e->type() == QEvent::KeyPress) {
    switch (((const QKeyEvent *)e)->key()) {
    case Qt::Key_Delete:
      emit removeTitle();
      return TRUE;
    }
  }

  return QObject::eventFilter(object, e);
}
bool TitlePicker::eventFilter(QObject *object, QEvent *e)
{
	if (object != (QObject *)title)
		return FALSE;
	
    if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonDblClick)
		{
		emit doubleClicked();
        return TRUE;
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseButtonPress )
		{
		emit clicked();

		const QMouseEvent *me = (const QMouseEvent *)e;	
		if (me->button()==QEvent::LeftButton)
			{
			if(me->state()==Qt::ShiftButton)
				ShiftButton=TRUE;
			return TRUE;
			}
		else if (me->button()==QEvent::RightButton)
			{
			emit showTitleMenu();
			return TRUE;
			}
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseMove)
		{	
		const QMouseEvent *me = (const QMouseEvent *)e;			
		if(ShiftButton)
			{
			graphToResize=TRUE;
			emit resizeGraph(me->pos());	
			}				
		else
			{
			movedGraph=TRUE;
			emit moveGraph(me->pos());
			}		
        return TRUE;
		}
	
	if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonRelease)
		{
		const QMouseEvent *me = (const QMouseEvent *)e;
		if (me->button()== QEvent::LeftButton)
			{
			emit clicked();
			if (movedGraph)
				{
				emit releasedGraph();
				movedGraph=FALSE;
				}
			if (graphToResize)
				{
				emit resizedGraph();
				graphToResize=FALSE;
				ShiftButton=FALSE;
				}
        	return TRUE;
			}
		}

	if ( object->inherits("QLabel") && 
        e->type() == QEvent::KeyPress)
		{
		switch (((const QKeyEvent *)e)->key()) 
			{
			case Qt::Key_Delete: 
			emit removeTitle();	
            return TRUE;
			}
		}

    return QObject::eventFilter(object, e);
}
bool TitlePicker::eventFilter(QObject *object, QEvent *e)
{
	if (object != (QObject *)title)
		return FALSE;
	
    if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonDblClick)
		{
		emit doubleClicked();
        return TRUE;
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseButtonPress )
		{
		emit clicked();

		const QMouseEvent *me = (const QMouseEvent *)e;	
		if (me->button()==QEvent::RightButton)
			emit showTitleMenu();

		QwtPlot *plot = (QwtPlot *)title->parent();
		if (plot->margin() < 2 && plot->lineWidth() < 2)
			{
			QRect r = title->rect();
			r.addCoords(2, 2, -2, -2);
			if (!r.contains(me->pos()))
				emit highlightGraph();
			}

		return TRUE;
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseMove)
		{	
		const QMouseEvent *me = (const QMouseEvent *)e;			
		movedGraph=TRUE;
		emit moveGraph(me->pos());

        return TRUE;
		}
	
	if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonRelease)
		{
		const QMouseEvent *me = (const QMouseEvent *)e;
		if (me->button()== QEvent::LeftButton)
			{
			emit clicked();
			if (movedGraph)
				{
				emit releasedGraph();
				movedGraph=FALSE;
				}
        	return TRUE;
			}
		}

	if ( object->inherits("QLabel") && 
        e->type() == QEvent::KeyPress)
		{
		switch (((const QKeyEvent *)e)->key()) 
			{
			case Qt::Key_Delete: 
			emit removeTitle();	
            return TRUE;
			}
		}

    return QObject::eventFilter(object, e);
}