void PropertyBrowser::loadItem(int id) { updateExpandState(); //Clean up old state resetState(); if (id < 0) return; //Get object by it's id IScaObject *object = m_model->getObjectById(id); if (object == NULL) { qDebug() << "[PropertyManager]: can't get object from model!"; return; } ObjectVisual *visObj = m_scene->getObjectById(id); if (visObj == NULL) { qDebug() << "[PropertyManager]: can't cast object from scene!"; return; // no return if sometime we wish to see object with no graphics } m_currentId = id; processObject(object); processVisualObject(visObj); }
void MainWindow::itemClicked(QtCanvasItem *item) { updateExpandState(); QMap<QtProperty *, QString>::ConstIterator itProp = propertyToId.constBegin(); while (itProp != propertyToId.constEnd()) { delete itProp.key(); itProp++; } propertyToId.clear(); idToProperty.clear(); currentItem = item; if (!currentItem) { deleteAction->setEnabled(false); return; } deleteAction->setEnabled(true); QtProperty *property; property = doubleManager->addProperty(tr("Position X")); doubleManager->setRange(property, 0, canvas->width()); doubleManager->setValue(property, item->x()); addProperty(property, QLatin1String("xpos")); property = doubleManager->addProperty(tr("Position Y")); doubleManager->setRange(property, 0, canvas->height()); doubleManager->setValue(property, item->y()); addProperty(property, QLatin1String("ypos")); property = doubleManager->addProperty(tr("Position Z")); doubleManager->setRange(property, 0, 256); doubleManager->setValue(property, item->z()); addProperty(property, QLatin1String("zpos")); if (item->rtti() == QtCanvasItem::Rtti_Rectangle) { QtCanvasRectangle *i = (QtCanvasRectangle *)item; property = colorManager->addProperty(tr("Brush Color")); colorManager->setValue(property, i->brush().color()); addProperty(property, QLatin1String("brush")); property = colorManager->addProperty(tr("Pen Color")); colorManager->setValue(property, i->pen().color()); addProperty(property, QLatin1String("pen")); property = sizeManager->addProperty(tr("Size")); sizeManager->setValue(property, i->size()); addProperty(property, QLatin1String("size")); } else if (item->rtti() == QtCanvasItem::Rtti_Line) { QtCanvasLine *i = (QtCanvasLine *)item; property = colorManager->addProperty(tr("Pen Color")); colorManager->setValue(property, i->pen().color()); addProperty(property, QLatin1String("pen")); property = pointManager->addProperty(tr("Vector")); pointManager->setValue(property, i->endPoint()); addProperty(property, QLatin1String("endpoint")); } else if (item->rtti() == QtCanvasItem::Rtti_Ellipse) { QtCanvasEllipse *i = (QtCanvasEllipse *)item; property = colorManager->addProperty(tr("Brush Color")); colorManager->setValue(property, i->brush().color()); addProperty(property, QLatin1String("brush")); property = sizeManager->addProperty(tr("Size")); sizeManager->setValue(property, QSize(i->width(), i->height())); sizeManager->setRange(property, QSize(0, 0), QSize(1000, 1000)); addProperty(property, QLatin1String("size")); } else if (item->rtti() == QtCanvasItem::Rtti_Text) { QtCanvasText *i = (QtCanvasText *)item; property = colorManager->addProperty(tr("Color")); colorManager->setValue(property, i->color()); addProperty(property, QLatin1String("color")); property = stringManager->addProperty(tr("Text")); stringManager->setValue(property, i->text()); addProperty(property, QLatin1String("text")); property = fontManager->addProperty(tr("Font")); fontManager->setValue(property, i->font()); addProperty(property, QLatin1String("font")); } }