예제 #1
0
KReportDesignerItemLine::KReportDesignerItemLine(KReportDesigner * d, QGraphicsScene * scene, const QPointF &pos)
        : KReportDesignerItemBase(d, this)
{
    init(scene, d);
    setLineScene(QLineF(pos, QPointF(20,20)+pos));
    
}
KoReportDesignerItemLine::KoReportDesignerItemLine(KoReportDesigner * d, QGraphicsScene * scene, const QPointF &pos)
        : KoReportDesignerItemBase(d)
{
    init(scene, d);
    setLineScene(QLineF(pos, QPointF(20,20)+pos));

    m_name->setValue(m_reportDesigner->suggestEntityName("line"));
}
void KoReportDesignerItemLine::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
    int x;
    int y;

    QPointF p = dynamic_cast<ReportScene*>(scene())->gridPoint(event->scenePos());

    kDebug() << p;
    
    x = p.x();
    y = p.y();

    if (x < 0) x = 0;
    if (y < 0) y = 0;
    if (x > scene()->width()) x = scene()->width();
    if (y > scene()->height()) y = scene()->height();

    switch (m_grabAction) {
    case 1:
	m_start.setScenePos(QPointF(x,y));
        break;
    case 2:
	m_end.setScenePos(QPointF(x,y));
        break;
    default:
        QPointF d = mapToItem(this, dynamic_cast<ReportScene*>(scene())->gridPoint(event->scenePos())) - mapToItem(this, dynamic_cast<ReportScene*>(scene())->gridPoint(event->lastScenePos()));

        if (((line().p1() + d).x() >= 0) &&
                ((line().p2() + d).x() >= 0) &&
                ((line().p1() + d).y() >= 0) &&
                ((line().p2() + d).y() >= 0)  &&
                ((line().p1() + d).x() <= scene()->width()) &&
                ((line().p2() + d).x() <= scene()->width()) &&
                ((line().p1() + d).y() <= scene()->height()) &&
                ((line().p2() + d).y() <= scene()->height()))
            setLineScene(QLineF(line().p1() + d, line().p2() + d));
        break;
    }
}
예제 #4
0
KReportDesignerItemLine::KReportDesignerItemLine(KReportDesigner * d, QGraphicsScene * scene, const QPointF &startPos, const QPointF &endPos)
        : KReportDesignerItemBase(d, this)
{
    init(scene, d);
    setLineScene(QLineF(startPos, endPos));
}