19
19
********************************************************************
22
$Author: cohen@irascible.com $:
23
$Date: 2012-08-09 08:53:47 +0200 (Thu, 09 Aug 2012) $
22
$Author: irascibl@gmail.com $:
23
$Date: 2012-09-29 17:40:27 +0200 (Sat, 29 Sep 2012) $
25
25
********************************************************************/
82
82
////////////////////////////////////////////////////////////
84
SvgIconWidget::SvgIconWidget(ModelPart * modelPart, ViewIdentifierClass::ViewIdentifier viewIdentifier, ItemBase * itemBase, bool plural)
84
SvgIconWidget::SvgIconWidget(ModelPart * modelPart, ViewLayer::ViewIdentifier viewIdentifier, ItemBase * itemBase, bool plural)
85
85
: QGraphicsWidget()
87
87
m_moduleId = modelPart->moduleID();
105
105
this->setMaximumSize(PluralImage->size());
106
106
setAcceptHoverEvents(true);
107
107
setFlags(QGraphicsItem::ItemIsSelectable);
110
LayerAttributes layerAttributes;
111
FSvgRenderer * renderer = m_itemBase->setUpImage(modelPart, viewIdentifier, ViewLayer::Icon, ViewLayer::ThroughHoleThroughTop_OneLayer, layerAttributes, error);
112
if (renderer == NULL) {
113
DebugDialog::debug(QString("missing renderer for icon %1").arg(modelPart->moduleID()));
115
if (renderer && m_itemBase) {
116
m_itemBase->setFilename(renderer->filename());
119
QPixmap pixmap(plural ? *PluralImage : *SingularImage);
120
QPixmap * icon = (renderer == NULL) ? NULL : FSvgRenderer::getPixmap(renderer, QSize(ICON_SIZE, ICON_SIZE));
123
painter.begin(&pixmap);
125
painter.drawPixmap(PLURAL_OFFSET, PLURAL_OFFSET, *icon);
128
painter.drawPixmap(SINGULAR_OFFSET, SINGULAR_OFFSET, *icon);
134
m_pixmapItem = new SvgIconPixmapItem(pixmap, this);
135
m_pixmapItem->setPlural(plural);
137
m_pixmapItem->setFlags(0);
138
m_pixmapItem->setPos(0, 0);
141
m_itemBase->setTooltip();
142
setToolTip(m_itemBase->toolTip());
146
itemBase->setSharedRendererEx(renderer);
108
setupImage(plural, viewIdentifier);
227
188
QGraphicsWidget::paint(painter, option, widget);
191
void SvgIconWidget::setItemBase(ItemBase * itemBase, bool plural)
193
m_itemBase = itemBase;
194
setupImage(plural, itemBase->viewIdentifier());
197
void SvgIconWidget::setupImage(bool plural, ViewLayer::ViewIdentifier viewIdentifier)
200
LayerAttributes layerAttributes;
201
ModelPart * modelPart = m_itemBase->modelPart();
202
FSvgRenderer * renderer = m_itemBase->setUpImage(modelPart, viewIdentifier, ViewLayer::Icon, ViewLayer::ThroughHoleThroughTop_OneLayer, layerAttributes, error);
203
if (renderer == NULL) {
204
DebugDialog::debug(QString("missing renderer for icon %1").arg(modelPart->moduleID()));
206
if (renderer && m_itemBase) {
207
m_itemBase->setFilename(renderer->filename());
210
QPixmap pixmap(plural ? *PluralImage : *SingularImage);
211
QPixmap * icon = (renderer == NULL) ? NULL : FSvgRenderer::getPixmap(renderer, QSize(ICON_SIZE, ICON_SIZE));
214
painter.begin(&pixmap);
216
painter.drawPixmap(PLURAL_OFFSET, PLURAL_OFFSET, *icon);
219
painter.drawPixmap(SINGULAR_OFFSET, SINGULAR_OFFSET, *icon);
225
m_pixmapItem = new SvgIconPixmapItem(pixmap, this);
226
m_pixmapItem->setPlural(plural);
228
m_pixmapItem->setFlags(0);
229
m_pixmapItem->setPos(0, 0);
232
m_itemBase->setTooltip();
233
setToolTip(m_itemBase->toolTip());
237
m_itemBase->setSharedRendererEx(renderer);