Replaced QtMobility BatteryInfo
[harmattan/cameraplus] / src / quillitem.cpp
index 1a16e70..6732b17 100644 (file)
@@ -35,10 +35,6 @@ QuillItem::~QuillItem() {
   delete m_file; m_file = 0;
 }
 
-void QuillItem::componentComplete() {
-  QDeclarativeItem::componentComplete();
-}
-
 void QuillItem::initialize(const QUrl& url, const QString& mimeType) {
   if (m_error) {
     m_error = false;
@@ -75,6 +71,7 @@ bool QuillItem::error() const {
 
 void QuillItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
   Q_UNUSED(widget);
+  Q_UNUSED(option);
 
   QRectF rect = boundingRect();
   painter->fillRect(rect, Qt::black);
@@ -83,27 +80,23 @@ void QuillItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
     return;
   }
 
-  if (m_image.isNull()) {
-    return;
-  }
+  QImage image = m_file->image(0);
 
-  QPoint pos((rect.width() - m_image.width()) / 2, (rect.height() - m_image.height()) / 2);
-  if (!m_image.isNull()) {
-    painter->drawImage(pos, m_image);
+  if (image.isNull()) {
+    return;
   }
-}
 
-void QuillItem::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
-  // TODO: rotation animation looks weird
-  QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+  QSizeF imageSize = QSizeF(image.size());
+  QSizeF widgetSize = rect.size();
+  imageSize.scale(widgetSize, Qt::KeepAspectRatio);
 
-  m_image = QImage();
+  QPointF pos = QPointF(widgetSize.width() - imageSize.width(),
+                       widgetSize.height() - imageSize.height()) / 2;
 
-  updateImage();
+  painter->drawImage(QRectF(pos, imageSize), image, QRect(0, 0, image.width(), image.height()));
 }
 
 void QuillItem::fileLoaded() {
-  updateImage();
   update();
 }
 
@@ -134,18 +127,3 @@ bool QuillItem::fileError() {
 
   return false;
 }
-
-void QuillItem::updateImage() {
-  if (!m_file) {
-    return;
-  }
-
-  QImage image = m_file->image(0);
-
-  if (image.isNull()) {
-    return;
-  }
-
-  m_image = image.scaled(boundingRect().size().toSize(),
-                        Qt::KeepAspectRatio, Qt::SmoothTransformation);
-}