12345678910111213141516171819202122232425262728293031323334353637 |
- /**
- * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * For the applicable distribution terms see the license.txt -file, included in
- * the distribution.
- */
- #include <QDebug>
- #include "itemstatusimageprovider.h"
- #include "declarativepurchaselistmodel.h"
- #include "purchasableitembase.h"
- ItemstatusImageProvider::ItemstatusImageProvider(DeclarativePurchaseListModel& model):
- QDeclarativeImageProvider(QDeclarativeImageProvider::Image),
- m_model(&model)
- {
- }
- QImage ItemstatusImageProvider::requestImage(const QString & url, QSize * size, const QSize & requestedSize)
- {
- bool ok = false;
- //NOTE: see workaround for http://bugreports.qt.nokia.com/browse/QTBUG-14900 in 'main.qml'
- int ignorelength = url.indexOf("ignoringpart");
- QString id((ignorelength > 0) ? url.left(ignorelength) : url);
- int index = id.toInt(&ok);
- Q_ASSERT(ok); //design time sanity check
- qDebug() << "requested index " << index;
- QImage image = m_model->record(index)->stateIcon(); //NOTE: return value is created in the stack and uses copy constructor
- if (size)
- *size = QSize(image.width(), image.height());
- return image;
- }
|