コード例 #1
0
  void InputTextItem::gridsCreate(Device *dev, Grids::Event *evt) {
    //dev->getNoticeWindow()->write(tr("Creating input text"));
    /*dev->getScene()->addInputTextItem(evt->getArgsPtr(), evt->getPosition()); */

    Scene2D *scene = dev->getScene();
    Grids::Value *val = evt->getArgsPtr();
    Vec3D item_pos = evt->getPosition();

    InputTextItem *text_item = new InputTextItem(dev, val);
    /*text_item->setFont(myFont);*/
    text_item->setTextInteractionFlags(Qt::TextEditorInteraction);
    /* Set the stack order.  This should be adjusted. */
    text_item->setZValue(item_pos.Z);
    connect(text_item, SIGNAL(lostFocus(InputTextItem*)),
            scene, SLOT(editorLostFocus(InputTextItem*)));
    connect(text_item, SIGNAL(selectedChange(QGraphicsItem*)),
            scene, SIGNAL(itemSelected(QGraphicsItem*)));
    scene->addItem(text_item);
    text_item->setDefaultTextColor(text_item->getTextColor() );

    /*text_item->setPos(mouseEvent->scenePos());*/
    text_item->setPos(QPointF(item_pos.X, item_pos.Y));
    //text_item->setPlainText(tr("This is a test"));
    /*emit textInserted(textItem);*/

    scene->addInputTextItem(text_item);
  }
コード例 #2
0
void GenericLinkItem::gridsCreate(Device* dev, Grids::Event* evt) {
    Scene2D* scene = dev->getScene();
    Grids::Value *val = evt->getArgsPtr();

    GenericLinkItem *generic_link = new GenericLinkItem(dev, val);

    if( generic_link->getLinkType() == GenericLinkItem::BROKEN_LINK) {
        delete generic_link;
        return;
    }

    scene->addItem(generic_link);
    scene->addLinkItem(generic_link);
}