~ubuntu-branches/ubuntu/trusty/fritzing/trusty-proposed

« back to all changes in this revision

Viewing changes to src/partsbinpalette/svgiconwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Enrique Hernández Bello
  • Date: 2012-11-11 21:38:56 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121111213856-0825ywdrtdcshl91
Tags: 0.7.10b-1
* New upstream version. Closes: #661495, #692998
* Removed useless patches.
* Removed SetupAPI.lib from sourceless files.
* Skip dfsg tarball creation if there are no sourceless files.
* Added libqt4-sql-sqlite to dependencies. Thanks to Tom Hummel <tom@bluespice.org>.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
********************************************************************
20
20
 
21
 
$Revision: 6268 $:
22
 
$Author: cohen@irascible.com $:
23
 
$Date: 2012-08-09 08:53:47 +0200 (Thu, 09 Aug 2012) $
 
21
$Revision: 6494 $:
 
22
$Author: irascibl@gmail.com $:
 
23
$Date: 2012-09-29 17:40:27 +0200 (Sat, 29 Sep 2012) $
24
24
 
25
25
********************************************************************/
26
26
 
81
81
 
82
82
////////////////////////////////////////////////////////////
83
83
 
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() 
86
86
{
87
87
        m_moduleId = modelPart->moduleID();
105
105
                this->setMaximumSize(PluralImage->size());
106
106
                setAcceptHoverEvents(true);
107
107
                setFlags(QGraphicsItem::ItemIsSelectable);
108
 
 
109
 
                QString error;
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()));
114
 
        }
115
 
                if (renderer && m_itemBase) {
116
 
                        m_itemBase->setFilename(renderer->filename());
117
 
                }
118
 
 
119
 
                QPixmap pixmap(plural ? *PluralImage : *SingularImage);
120
 
                QPixmap * icon = (renderer == NULL) ? NULL : FSvgRenderer::getPixmap(renderer, QSize(ICON_SIZE, ICON_SIZE));
121
 
                if (icon) {
122
 
                        QPainter painter;
123
 
                        painter.begin(&pixmap);
124
 
                        if (plural) {
125
 
                                painter.drawPixmap(PLURAL_OFFSET, PLURAL_OFFSET, *icon);
126
 
                        }
127
 
                        else {
128
 
                                painter.drawPixmap(SINGULAR_OFFSET, SINGULAR_OFFSET, *icon);
129
 
                        }
130
 
                        painter.end();
131
 
                        delete icon;
132
 
                }
133
 
 
134
 
                m_pixmapItem = new SvgIconPixmapItem(pixmap, this);
135
 
                m_pixmapItem->setPlural(plural);
136
 
 
137
 
                m_pixmapItem->setFlags(0);
138
 
                m_pixmapItem->setPos(0, 0);
139
 
 
140
 
                if (m_itemBase) {
141
 
                        m_itemBase->setTooltip();
142
 
                        setToolTip(m_itemBase->toolTip());
143
 
                }
144
 
 
145
 
        if (renderer) {
146
 
            itemBase->setSharedRendererEx(renderer);
147
 
        }
 
108
                setupImage(plural, viewIdentifier);
148
109
        }
149
110
}
150
111
 
227
188
        QGraphicsWidget::paint(painter, option, widget);
228
189
}
229
190
 
 
191
void SvgIconWidget::setItemBase(ItemBase * itemBase, bool plural)
 
192
{
 
193
        m_itemBase = itemBase;
 
194
        setupImage(plural, itemBase->viewIdentifier());
 
195
}
 
196
 
 
197
void SvgIconWidget::setupImage(bool plural, ViewLayer::ViewIdentifier viewIdentifier)
 
198
{
 
199
        QString error;
 
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()));
 
205
    }
 
206
        if (renderer && m_itemBase) {
 
207
                m_itemBase->setFilename(renderer->filename());
 
208
        }
 
209
 
 
210
        QPixmap pixmap(plural ? *PluralImage : *SingularImage);
 
211
        QPixmap * icon = (renderer == NULL) ? NULL : FSvgRenderer::getPixmap(renderer, QSize(ICON_SIZE, ICON_SIZE));
 
212
        if (icon) {
 
213
                QPainter painter;
 
214
                painter.begin(&pixmap);
 
215
                if (plural) {
 
216
                        painter.drawPixmap(PLURAL_OFFSET, PLURAL_OFFSET, *icon);
 
217
                }
 
218
                else {
 
219
                        painter.drawPixmap(SINGULAR_OFFSET, SINGULAR_OFFSET, *icon);
 
220
                }
 
221
                painter.end();
 
222
                delete icon;
 
223
        }
 
224
 
 
225
        m_pixmapItem = new SvgIconPixmapItem(pixmap, this);
 
226
        m_pixmapItem->setPlural(plural);
 
227
 
 
228
        m_pixmapItem->setFlags(0);
 
229
        m_pixmapItem->setPos(0, 0);
 
230
 
 
231
        if (m_itemBase) {
 
232
                m_itemBase->setTooltip();
 
233
                setToolTip(m_itemBase->toolTip());
 
234
        }
 
235
 
 
236
    if (renderer) {
 
237
        m_itemBase->setSharedRendererEx(renderer);
 
238
    }
 
239
}