SEXP qt_qsetTextItemInteraction(SEXP x, SEXP mode) { QList<QGraphicsItem*> ilist = unwrapQObject(x, QGraphicsScene)->items(); QGraphicsTextItem *textitem; QString smode = sexp2qstring(mode); if (smode == "none") { for (int i = 0; i < ilist.size(); ++i) { textitem = qgraphicsitem_cast<QGraphicsTextItem *>(ilist[i]); if (textitem) textitem->setTextInteractionFlags(Qt::NoTextInteraction); } } else if (smode == "editor") { for (int i = 0; i < ilist.size(); ++i) { textitem = qgraphicsitem_cast<QGraphicsTextItem *>(ilist[i]); if (textitem) textitem->setTextInteractionFlags(Qt::TextEditorInteraction); } } else if (smode == "browser") { for (int i = 0; i < ilist.size(); ++i) { textitem = qgraphicsitem_cast<QGraphicsTextItem *>(ilist[i]); if (textitem) textitem->setTextInteractionFlags(Qt::TextBrowserInteraction); } } return R_NilValue; }
static void init(QGraphicsView *view) { QGraphicsScene *scene = new QGraphicsScene; QGraphicsTextItem *textItem = new QGraphicsTextItem("Edit me"); textItem->setTextInteractionFlags(Qt::TextEditorInteraction); scene->addItem(textItem); view->setScene(scene); }
HelpItem::HelpItem(QGraphicsItem * parent) : AbstractDisposeable(true, parent) , m_frame(FrameFactory::createFrame(0x1001 /*HARDCODED*/)) { QString introduction = tr( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" "<html><!--head><meta name=\"qrichtext\" content=\"1\" /></head-->\n" "<body style=\"font-family:'Sans Serif';\">\n" " <span style='font-size: 26px; font-weight: normal; color: #FF0000;'>\n" " <img src=':/data/action-remove.png'>\n" " Welcome\n" " <img src=':/data/action-remove.png'>\n" " </span>\n" " <br />\n" " <div style='font-size: 16px; font-weight: normal;'>\n" " <b>Playing</b> with <b>Fotowall</b> is easy\n" " </div>\n" " <ul>\n" " <li><img src=':/data/action-add.png'><b> add contents</b> using the <i><span style='background-color: rgb(255, 226, 0);'>ADD NEW</span></i> buttons or <i><span style='background-color: rgb(255, 226, 0);'>drop them</span></i></li>\n" " <li><img src=':/data/action-move.png'><b> move contents around </b> and <b><img src=':/data/action-rotate.png'> rotate them</b> <span style='background-color: rgb(255, 226, 0);'>by <i>dragging the corners</i></span></li>\n" " <li><img src=':/data/action-configure.png'><i> <span style='background-color: rgb(255, 226, 0);'>right click on the objects</span></i> or <i><span style='background-color: rgb(255, 226, 0);'>use the top bar</span></i> to <b>modify properties</b></li>\n" " <li><span style='background-color: rgb(255, 226, 0);'><i>double click any content</i></span> to <b>open the editor</b> or set it as <b>background</b></li>\n" " <li>...and we'll let you discover the rest!</li>\n" " </ul>\n" " <div><font color='#2B2B2B'><b>\n" " Please make sure to share your best work with your friends ;-)\n" " </b></font></div>\n" " <br/>\n" " <div><font color='#616161' style='font-size: 11px; font-weight: normal;'>\n" " Fotowall is LGPL, by Enrico Ros <*****@*****.**>, 2009\n" " </font></div>\n" "</body>\n" "</html>" ); #if defined(USE_QTWEBKIT) // show fancy help in internal browser #error WebKit was completely disabled, to only have 1 version of the HTML to translate... //BrowserItem * bi = new BrowserItem(this); //bi->setGeometry(...); //bi->write(introduction); //bi->setReadOnly(true); #else // create an item to display it QGraphicsTextItem * ti = new QGraphicsTextItem(this); ti->setHtml(introduction); ti->setPos(boundingRect().adjusted(12, 12, -12, -12).topLeft()); ti->setTextInteractionFlags(Qt::NoTextInteraction); #endif }
void DataVisualizer::draw(SceneType scene, qreal& lastXPos, Element::Ptr e, int propertyIndex) { if (e.isNull()) return; // see if item should be drawn Element::Property p(Element::getProperty(propertyIndex)); Element::PropertyType type(Element::propertyType(p)); Element::PropertyVariant var(e->propertyConst(p)); if (p == Element::NUCLEONS_PROPERTY && !e->isIsotope()) return; if (!Element::isValidVariant(var)) return; // build the text item QGraphicsItem * item(0); QGraphicsTextItem * text = new QGraphicsTextItem(); text->setHtml( getLinkText(*e) + "<br>" + mMainWindow->toString(var)); text->setTextInteractionFlags(Qt::TextBrowserInteraction); text->setToolTip(tr("formattedFormulaToolTip")); connect(text, SIGNAL(linkActivated(const QString&)), this, SLOT(emitElementLinkActivated(const QString&))); item = text; // build the encapsulating box item QGraphicsRectItem * rect = new QGraphicsRectItem( item->boundingRect() ); rect->setBrush(QBrush(QColor(196, 255, 196))); // combine both and add them to the scene item->setParentItem(rect); scene->addItem(rect); QPointF pos(boost::apply_visitor(DrawingPositionFromPropertyVariant(), var)); if (type == Element::COMPLEX_TYPE || type == Element::STRING_TYPE) { // no stacking for 2D drawing // item positions are stretched in X direction if (lastXPos > pos.x()) { pos.setX(lastXPos); } rect->setPos(pos); // update drawing position for the next item lastXPos = pos.x() + rect->boundingRect().width() + itemMargin; } else { setItemPos(rect, pos); } }