Example #1
0
KReportDesignerItemLine::KReportDesignerItemLine(const QDomNode & entity, KReportDesigner * d, QGraphicsScene * scene)
        : KReportItemLine(entity), KReportDesignerItemBase(d, this)
{
    init(scene, d);
    QPointF s = scenePosition(m_start->value().toPointF());
    QPointF e = scenePosition(m_end->value().toPointF());
    
    setLine ( s.x(), s.y(), e.x(), e.y() );
}
Example #2
0
void KReportDesignerItemLine::move(const QPointF& m)
{
    QPointF original = scenePosition(position());
    original += m;
    
    setPosition(positionFromScene(original));
}
Example #3
0
QVariant KWidget::itemChange( GraphicsItemChange change, const QVariant & value )
{
    if(change == QGraphicsItem::ItemParentHasChanged
        || change == QGraphicsItem::ItemParentChange)
    {
        clearThemeCheckFlag();
    }
    else if(change == QGraphicsItem::ItemScenePositionHasChanged)
    {
        emit scenePosition(value.toPointF());
    }
    else if(change == QGraphicsItem::ItemVisibleHasChanged)
    {
        bool bvis = isVisible();
        visibleEvent(bvis);
        if(bvis)
        {
            showEvent();
        }
        else
        {
            hideEvent();
        }
    }
    return QGraphicsWidget::itemChange(change, value);
}
Example #4
0
void KFollowWindow::listenEvent( KWidget *w, ListenFlags flags )
{
	Q_D(KFollowWindow);
	if(w == NULL)
		return;

	if(flags.testFlag(targetVisible))
	{
		QObject::connect(w, SIGNAL(visibleChanged()), this, SLOT(on_visibleChanged()), Qt::QueuedConnection);
	}
	else
	{
		QObject::disconnect(w, SIGNAL(visibleChanged()), this, SLOT(on_visibleChanged()));
	}

	if(flags.testFlag(targetWindowEvent))
	{
		QWidget *viewport = w->viewport();
		viewport->installEventFilter(this);
	}
	else
	{
		QWidget *viewport = w->viewport();
		viewport->removeEventFilter(this);
	}

	if(flags.testFlag(targetEvent))
	{
		w->installEventFilter(this);
	}
	else
	{
		w->removeEventFilter(this);
	}

	if(flags.testFlag(targetScenePosition))
	{
		w->setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
		QObject::connect(w, SIGNAL(scenePosition(QPointF)), this, SLOT(on_scenePosition(QPointF)), Qt::QueuedConnection);
	}
	else
	{
		w->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
		QObject::disconnect(w, SIGNAL(scenePosition(QPointF)), this, SLOT(on_scenePosition(QPointF)));
	}
}
Example #5
0
void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p)
{
    Q_UNUSED(s);

    if (p.name() == "startposition" || p.name() == "endposition") {
        QPointF s = scenePosition(m_start->value().toPointF());
        QPointF e = scenePosition(m_end->value().toPointF());
        
        setLine ( s.x(), s.y(), e.x(), e.y() );
    }
    else if (p.name() == "name") {
        //For some reason p.oldValue returns an empty string
        if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
            p.setValue(oldName());
        } else {
            setOldName(p.value().toString());
        }
    }
    if (designer())
        designer()->setModified(true);

    update();
}
Example #6
0
int KReportItemCheckBox::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset,
                                        const QVariant &data, KReportScriptHandler *script)
{
    OROCheckBox *chk = new OROCheckBox();

    chk->setPosition(scenePosition(position()) + offset);
    chk->setSize(sceneSize(size()));

    chk->setLineStyle(lineStyle());
    chk->setForegroundColor(m_foregroundColor->value().value<QColor>());
    if (m_checkStyle->value().toString() == QLatin1String("Cross")) {
        chk->setCheckType(OROCheckBox::Cross);
    } else if (m_checkStyle->value().toString() == QLatin1String("Dot")) {
        chk->setCheckType(OROCheckBox::Dot);
    } else {
        chk->setCheckType(OROCheckBox::Tick);
    }
                
    QString str;
    bool v = false;
    QString cs = itemDataSource();

    //kreportpluginDebug() << "ControlSource:" << cs;
    if (!cs.isEmpty()) {
#ifdef KREPORT_SCRIPTING
        if (cs.left(1) == QLatin1String("=") && script) {
            str = script->evaluate(cs.mid(1)).toString();
        } else
#else
        Q_UNUSED(script);
#endif
        {
            str = data.toString();
        }

        str = str.toLower();

        //kreportpluginDebug() << "Check Value:" << str;
        if (str == QLatin1String("t") || str == QLatin1String("y") || str == QLatin1String("true") || str == QLatin1String("1"))
            v = true;

    } else {
        v = value();
    }

    chk->setValue(v);

    if (page) {
        page->insertPrimitive(chk);
    }

    if (section) {
        OROCheckBox *chk2 = dynamic_cast<OROCheckBox*>(chk->clone());
        chk2->setPosition(scenePosition(position()));
        section->addPrimitive(chk2);
    }

    if (!page) {
        delete chk;
    }

    return 0; //Item doesn't stretch the section height
}
Example #7
0
int KReportItemField::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset,
                                        const QVariant &data, KReportScriptHandler *script)
{
    OROTextBox * tb = new OROTextBox();
    tb->setPosition(scenePosition(position()) + offset);
    tb->setSize(sceneSize(size()));
    tb->setFont(font());
    tb->setFlags(textFlags());
    tb->setTextStyle(textStyle());
    tb->setLineStyle(lineStyle());
    tb->setCanGrow(m_canGrow->value().toBool());
    tb->setWordWrap(m_wordWrap->value().toBool());

    QString str;

    QString ids = itemDataSource();
    if (!ids.isEmpty()) {
#ifdef KREPORT_SCRIPTING
        if (ids.left(1) == QLatin1String("=") && script) { //Everything after = is treated as code
            if (!ids.contains(QLatin1String("PageTotal()"))) {
                QVariant v = script->evaluate(ids.mid(1));
                str = v.toString();
            } else {
                str = ids.mid(1);
                tb->setRequiresPostProcessing(true);
            }
        } else
#else
        Q_UNUSED(script);
#endif
        if (ids.left(1) == QLatin1String("$")) { //Everything past $ is treated as a string
            str = ids.mid(1);
        } else {
            str = data.toString();
        }
    } else {
            str = m_itemValue->value().toString();
    }

    tb->setText(str);

    //Work out the size of the text
    if (tb->canGrow()) {
        QRect r;
        if (tb->wordWrap()) {
            //Grow vertically
            QFontMetrics metrics(font());
            QRect temp(tb->position().x(), tb->position().y(), tb->size().width(), 5000); // a large vertical height
            r = metrics.boundingRect(temp, tb->flags(), str);
        } else {
            //Grow Horizontally
            QFontMetrics metrics(font());
            QRect temp(tb->position().x(), tb->position().y(), 5000, tb->size().height()); // a large vertical height
            r = metrics.boundingRect(temp, tb->flags(), str);
        }
        tb->setSize(r.size() + QSize(4,4));
    }

    if (page) {
        page->insertPrimitive(tb);
    }

    if (section) {
        OROPrimitive *clone = tb->clone();
        clone->setPosition(scenePosition(position()));
        section->addPrimitive(clone);
    }
    int height = scenePosition(position()).y() + tb->size().height();
    //If there is no page to add the item to, delete it now because it wont be deleted later
    if (!page) {
        delete tb;
    }
    return height;
}