diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 10c58cd..c944745 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2689,6 +2689,9 @@ void MainWindow::addPaintItem(uid paintId, const QIcon& icon, const QString& nam // Set size. item->setSizeHint(QSize(item->sizeHint().width(), MainWindow::PAINT_LIST_ITEM_HEIGHT)); + + // Set tooltip. + item->setToolTip(QString("ID: %1").arg(paint->getId())); // Switch to paint tab. contentTab->setCurrentWidget(paintSplitter); @@ -2721,7 +2724,7 @@ void MainWindow::addMappingItem(uid mappingId) Mapping::ptr mapping = mappingManager->getMappingById(mappingId); Q_CHECK_PTR(mapping); - QString label; + QString defaultName; QIcon icon; QString shapeType = mapping->getShape()->getType(); @@ -2743,7 +2746,7 @@ void MainWindow::addMappingItem(uid mappingId) // Triangle if (shapeType == "triangle") { - label = QString("Triangle %1").arg(mappingId); + defaultName = QString("Triangle %1").arg(mappingId); icon = QIcon(":/shape-triangle"); if (paintType == "color") @@ -2754,7 +2757,7 @@ void MainWindow::addMappingItem(uid mappingId) // Mesh else if (shapeType == "mesh") { - label = QString("Mesh %1").arg(mappingId); + defaultName = QString("Mesh %1").arg(mappingId); icon = QIcon(":/shape-mesh"); if (paintType == "color") mapper = MappingGui::ptr(new MeshColorMappingGui(mapping)); @@ -2763,7 +2766,7 @@ void MainWindow::addMappingItem(uid mappingId) } else if (shapeType == "ellipse") { - label = QString("Ellipse %1").arg(mappingId); + defaultName = QString("Ellipse %1").arg(mappingId); icon = QIcon(":/shape-ellipse"); if (paintType == "color") mapper = MappingGui::ptr(new EllipseColorMappingGui(mapping)); @@ -2772,13 +2775,13 @@ void MainWindow::addMappingItem(uid mappingId) } else { - label = QString("Polygon %1").arg(mappingId); + defaultName = QString("Polygon %1").arg(mappingId); icon = QIcon(":/shape-polygon"); } // Label is only going to be applied if no name is present. - if (!mapping->getName().isEmpty()) - label = mapping->getName(); + if (mapping->getName().isEmpty()) + mapping->setName(defaultName); // Add to list of mappers. mappers[mappingId] = mapper; @@ -2808,7 +2811,7 @@ void MainWindow::addMappingItem(uid mappingId) contentTab->setCurrentWidget(mappingSplitter); // Add item to layerList widget. - mappingListModel->addItem(mapping, icon, label); + mappingListModel->addItem(mapping, icon, mapping->getName()); mappingListModel->updateModel(); setCurrentMapping(mappingId); diff --git a/src/gui/MappingGui.cpp b/src/gui/MappingGui.cpp index 536ee73..4aef3e8 100644 --- a/src/gui/MappingGui.cpp +++ b/src/gui/MappingGui.cpp @@ -35,12 +35,13 @@ MappingGui::MappingGui(Mapping::ptr mapping) _variantManager = new VariantManager; _variantFactory = new VariantFactory; - _topItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), - QObject::tr("Mapping")); - _propertyBrowser->setFactoryForManager(_variantManager, _variantFactory); - - _propertyBrowser->addProperty(_topItem); + + // Mapping UID. + _idItem = _variantManager->addProperty(QVariant::Int, QObject::tr("ID")); + _idItem->setEnabled(false); + _idItem->setValue(_mapping->getId()); + _propertyBrowser->addProperty(_idItem); // Mapping basic properties. _opacityItem = _variantManager->addProperty(QVariant::Double, QObject::tr("Opacity (%)")); @@ -48,14 +49,14 @@ MappingGui::MappingGui(Mapping::ptr mapping) _opacityItem->setAttribute("maximum", 100.0); _opacityItem->setAttribute("decimals", 1); _opacityItem->setValue(_mapping->getOpacity()*100.0); - _topItem->addSubProperty(_opacityItem); + _propertyBrowser->addProperty(_opacityItem); // Output shape. _outputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Output shape")); _buildShapeProperty(_outputItem, mapping->getShape().data()); - _topItem->addSubProperty(_outputItem); + _propertyBrowser->addProperty(_outputItem); // Collapse output shape. _propertyBrowser->setExpanded(_propertyBrowser->items(_outputItem).at(0), false); @@ -161,7 +162,7 @@ MeshColorMappingGui::MeshColorMappingGui(Mapping::ptr mapping) _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Dimensions")); _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows())); _meshItem->setAttribute("minimum", QSize(2,2)); - _topItem->insertSubProperty(_meshItem, _opacityItem); // insert at the beginning + _propertyBrowser->insertProperty(_meshItem, _opacityItem); // insert at the beginning } void MeshColorMappingGui::setValue(QtProperty* property, const QVariant& value) @@ -257,7 +258,7 @@ TextureMappingGui::TextureMappingGui(QSharedPointer mapping) _inputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Input shape")); _buildShapeProperty(_inputItem, inputShape.data()); - _topItem->insertSubProperty(_inputItem, _opacityItem); // insert + _propertyBrowser->insertProperty(_inputItem, _opacityItem); // insert // Collapse input shape. _propertyBrowser->setExpanded(_propertyBrowser->items(_inputItem).at(0), false); @@ -393,7 +394,7 @@ MeshTextureMappingGui::MeshTextureMappingGui(QSharedPointer mapp _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Dimensions")); _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows())); _meshItem->setAttribute("minimum", QSize(2,2)); - _topItem->insertSubProperty(_meshItem, _opacityItem); // insert at the beginning + _propertyBrowser->insertProperty(_meshItem, _opacityItem); // insert at the beginning } void MeshTextureMappingGui::setValue(QtProperty* property, const QVariant& value) diff --git a/src/gui/MappingGui.h b/src/gui/MappingGui.h index 6bc93cb..aeffb34 100644 --- a/src/gui/MappingGui.h +++ b/src/gui/MappingGui.h @@ -98,7 +98,7 @@ protected: QtVariantEditorFactory* _variantFactory; QtVariantPropertyManager* _variantManager; - QtProperty* _topItem; + QtVariantProperty* _idItem; QtVariantProperty* _opacityItem; QtProperty* _outputItem; diff --git a/src/gui/MappingListModel.cpp b/src/gui/MappingListModel.cpp index f5763a6..c9bda41 100644 --- a/src/gui/MappingListModel.cpp +++ b/src/gui/MappingListModel.cpp @@ -47,9 +47,9 @@ QVariant MappingListModel::data(const QModelIndex &index, int role) const case Qt::SizeHintRole: if (index.column() == MM::HideColumn) return QSize(24, 40); - if (index.column() == MM::IconAndNameColum) - return QSize(135, 40); - if (index.column() == MM::GroupButtonColum) +// if (index.column() == MM::IconAndNameColum) +// return QSize(135, 40); + else if (index.column() == MM::GroupButtonColum) return QSize(128, 40); break; case Qt::CheckStateRole + 1: @@ -70,6 +70,9 @@ QVariant MappingListModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: return mappingList.at(index.row()).icon; break; + case Qt::ToolTipRole: + return QString("ID: %1").arg(mappingList.at(index.row()).id); + break; default: return QVariant(); break; diff --git a/src/gui/PaintGui.cpp b/src/gui/PaintGui.cpp index 7dc3c64..7cec736 100644 --- a/src/gui/PaintGui.cpp +++ b/src/gui/PaintGui.cpp @@ -29,15 +29,16 @@ PaintGui::PaintGui(Paint::ptr paint) _variantManager = new VariantManager; _variantFactory = new VariantFactory; - _topItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), - QObject::tr("Paint")); - _propertyBrowser->setFactoryForManager(_variantManager, _variantFactory); connect(_variantManager, SIGNAL(valueChanged(QtProperty*, const QVariant&)), this, SLOT(setValue(QtProperty*, const QVariant&))); - _propertyBrowser->addProperty(_topItem); + // Mapping UID. + _idItem = _variantManager->addProperty(QVariant::Int, QObject::tr("ID")); + _idItem->setEnabled(false); + _idItem->setValue(_paint->getId()); + _propertyBrowser->addProperty(_idItem); // Paint basic properties. _opacityItem = _variantManager->addProperty(QVariant::Double, QObject::tr("Opacity (%)")); @@ -45,7 +46,7 @@ PaintGui::PaintGui(Paint::ptr paint) _opacityItem->setAttribute("maximum", 100.0); _opacityItem->setAttribute("decimals", 1); _opacityItem->setValue(_paint->getOpacity()*100.0); - _topItem->addSubProperty(_opacityItem); + _propertyBrowser->addProperty(_opacityItem); } PaintGui::~PaintGui() @@ -88,7 +89,7 @@ ColorGui::ColorGui(Paint::ptr paint) _colorItem->setValue(color->getColor()); - _topItem->addSubProperty(_colorItem); + _propertyBrowser->addProperty(_colorItem); } void ColorGui::setValue(QtProperty* property, const QVariant& value) { @@ -130,8 +131,8 @@ _imageFileItem->setValue(image->getUri()); _imageRateItem->setAttribute("decimals", 1); _imageRateItem->setValue(rate); - _topItem->addSubProperty(_imageFileItem); - _topItem->addSubProperty(_imageRateItem); + _propertyBrowser->addProperty(_imageFileItem); + _propertyBrowser->addProperty(_imageRateItem); } void ImageGui::setValue(QtProperty* property, const QVariant& value) { @@ -190,10 +191,10 @@ VideoGui::VideoGui(Paint::ptr paint) // tr("Reverse")); // _mediaReverseItem->setValue(false); - _topItem->addSubProperty(_mediaFileItem); - _topItem->addSubProperty(_mediaRateItem); - _topItem->addSubProperty(_mediaVolumeItem); -// _topItem->addSubProperty(_mediaReverseItem); + _propertyBrowser->addProperty(_mediaFileItem); + _propertyBrowser->addProperty(_mediaRateItem); + _propertyBrowser->addProperty(_mediaVolumeItem); +// _propertyBrowser->addProperty(_mediaReverseItem); } void VideoGui::setValue(QtProperty* property, const QVariant& value) diff --git a/src/gui/PaintGui.h b/src/gui/PaintGui.h index 2aafceb..afbd8df 100644 --- a/src/gui/PaintGui.h +++ b/src/gui/PaintGui.h @@ -78,7 +78,8 @@ protected: QtAbstractPropertyBrowser* _propertyBrowser; QtVariantEditorFactory* _variantFactory; QtVariantPropertyManager* _variantManager; - QtProperty* _topItem; + + QtVariantProperty* _idItem; QtVariantProperty* _opacityItem; };