ganeswidgets/src/hgwidgetitem.cpp
changeset 5 4fa04caf0f43
parent 3 c863538fcbb6
child 17 a10844a9914d
--- a/ganeswidgets/src/hgwidgetitem.cpp	Thu May 27 13:59:05 2010 +0300
+++ b/ganeswidgets/src/hgwidgetitem.cpp	Fri Jun 11 14:43:11 2010 +0300
@@ -114,6 +114,12 @@
 {
     mValidData = false;
     if( mModelIndex.isValid() ){
+
+        if (!mHgImage)
+        {
+            mHgImage = mRenderer->createNativeImage();
+        }    
+    
         QVariant image = mModelIndex.data(Qt::DecorationRole);
         QVariant texts = mModelIndex.data(Qt::DisplayRole);
 
@@ -121,8 +127,9 @@
         if (vis.canConvert<bool>())
         {
             setVisibility(vis.toBool());
+        } else {
+            setVisibility(true);
         }
-        
                     
         // Convert data to correct format if possible.
         if (image.type() == QVariant::Pixmap)
@@ -146,11 +153,8 @@
                     if (size.width() != 0 && size.height() != 0 ){
                         QPixmap pixmap = qicon.pixmap(size);
                         if (!pixmap.isNull()){
-                            QImage tempImage = pixmap.toImage();
-                            if (!tempImage.isNull()) {
-                                setImage(tempImage);
-                                mValidData = true;        
-                            }
+                            setPixmap(pixmap);
+                            mValidData = true;        
                         }
                     break;
                     }
@@ -166,7 +170,7 @@
                 QPixmap pixmap = tempIcon.pixmap(tempIcon.actualSize(QSize(250, 250)));
                 if (!pixmap.isNull()){
                     INFO("Valid image found for" << mModelIndex);
-                    setImage(pixmap.toImage());
+                    setPixmap(pixmap);
                     mValidData = true;
                 }
             }
@@ -176,7 +180,7 @@
                     if (size.width() != 0 && size.height() != 0 ){
                         QPixmap pixmap = tempIcon.pixmap(size);
                         if (!pixmap.isNull()){
-                            setImage(pixmap.toImage());
+                            setPixmap(pixmap);
                             mValidData = true;
                         }
                     break;
@@ -186,10 +190,12 @@
         }
         if( texts.canConvert<QStringList>() ){
             QStringList list(texts.toStringList() );
-            if( list.count() >= 2 ){
+            if (list.count() >= 1) {
+                mValidData = true;
                 setTitle(list.at(0));
+            }
+            if (list.count() >= 2){
                 setDescription(list.at(1));
-                mValidData = true;
             }
         }