javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp
changeset 61 bf7ee68962da
parent 48 e0d6e9bd3ca7
child 69 773449708c84
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp	Tue Jul 06 14:10:26 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp	Wed Aug 18 09:43:15 2010 +0300
@@ -86,6 +86,7 @@
 #include <qnetworkconfigmanager.h>
 #include <qnetworkconfiguration.h>
 #include <hbinputsettingproxy.h>
+#include <hbicon.h>
 #endif
 
 #include <org_eclipse_swt_internal_qt_OS.h>
@@ -5332,7 +5333,7 @@
         jboolean isCopy;
         jint* imagesHandles = NULL;
 
-        const QPixmap** detailImages = const_cast<const QPixmap**>(new QPixmap*[aDetailImageCount]);
+        QPixmap** detailImages = new QPixmap*[aDetailImageCount];
         if( !detailImages )
             {
             throw std::bad_alloc();
@@ -5342,6 +5343,7 @@
             imagesHandles = aJniEnv->GetIntArrayElements(aDetailImageHandles, &isCopy);
             if( !imagesHandles )
                 {
+                delete [] detailImages;
                 throw std::bad_alloc();
                 }
             for(int i = 0; i < aDetailImageCount; i++)
@@ -5351,9 +5353,10 @@
             aJniEnv->ReleaseIntArrayElements(aDetailImageHandles, imagesHandles, JNI_ABORT);
             }
 
-        const QPixmap** headingImages =  const_cast<const QPixmap**>(new QPixmap*[aHeadingImageCount]);
+        QPixmap** headingImages = new QPixmap*[aHeadingImageCount];
         if( !headingImages )
             {
+            delete [] detailImages; // allocated earlier
             throw std::bad_alloc();
             }
         if(aHeadingImageHandles)
@@ -5361,6 +5364,8 @@
             imagesHandles = aJniEnv->GetIntArrayElements(aHeadingImageHandles, &isCopy);
             if( !imagesHandles )
                 {
+                delete [] detailImages;
+                delete [] headingImages;
                 throw std::bad_alloc();
                 }
             for(int i = 0; i < aHeadingImageCount; i++)
@@ -5371,8 +5376,10 @@
             }
 
         ListModel* listDataModel = reinterpret_cast< ListModel* > ( aHandle );
-        listDataModel->appendItem( swtApp->jniUtils().JavaStringToQString( aJniEnv, aDetailText ), detailImages, aDetailImageCount,
-            swtApp->jniUtils().JavaStringToQString( aJniEnv, aHeadingText ), headingImages, aHeadingImageCount );
+        listDataModel->appendItem( swtApp->jniUtils().JavaStringToQString( aJniEnv, aDetailText ), 
+            const_cast<const QPixmap**>(detailImages), aDetailImageCount,
+            swtApp->jniUtils().JavaStringToQString( aJniEnv, aHeadingText ), 
+            const_cast<const QPixmap**>(headingImages), aHeadingImageCount );
         }
     SWT_CATCH
     }
@@ -6337,7 +6344,60 @@
     return reinterpret_cast< jint >(pixmap);
     }
 
-
+//
+// HbIcon
+//
+
+JNIEXPORT jint JNICALL OS_NATIVE ( HbIcon_1new )
+    (JNIEnv* aJniEnv , jclass, jstring aName)
+    {
+#ifdef __SYMBIAN32__
+    HbIcon* icon = NULL;
+    SWT_TRY
+        {
+        SWT_LOG_JNI_CALL();
+        icon = new HbIcon(swtApp->jniUtils().JavaStringToQString(aJniEnv, aName));
+        }
+    SWT_CATCH
+    return reinterpret_cast< jint >( static_cast< HbIcon* >( icon ) );
+#else
+    return 0;
+#endif
+    }
+
+JNIEXPORT jint JNICALL OS_NATIVE( HbIcon_1pixmap )
+    (JNIEnv* aJniEnv , jclass, jint aHandle)
+    {
+#ifdef __SYMBIAN32__
+    QPixmap* pixmap = NULL;
+    SWT_TRY
+        {
+        SWT_LOG_JNI_CALL();
+        HbIcon* icon = reinterpret_cast< HbIcon* >( aHandle );
+        pixmap = new QPixmap(icon->pixmap());
+        }
+    SWT_CATCH
+    return reinterpret_cast< jint >(pixmap);
+#else
+    return 0;
+#endif
+    }
+
+JNIEXPORT void JNICALL OS_NATIVE( HbIcon_1delete )
+    (JNIEnv* aJniEnv , jclass, jint aHandle)
+    {
+#ifdef __SYMBIAN32__
+    SWT_TRY
+        {
+        SWT_LOG_JNI_CALL();
+        SWT_LOG_DATA_1("handle=%x", aHandle);
+        HbIcon* icon = reinterpret_cast< HbIcon* >( aHandle );
+        delete icon;
+        icon = NULL;
+        }
+    SWT_CATCH
+#endif
+    }
 
 //
 // QSlider
@@ -11662,7 +11722,7 @@
         SWT_LOG_JNI_CALL();
         SWT_LOG_DATA_2( "handle=%x duration=%x", aHandle, aDuration );
         CSwtMobileDevice* mobileDevice =  reinterpret_cast<CSwtMobileDevice*>(aHandle);
-        vibraSupport = mobileDevice->Vibrate((TTimeIntervalMicroSeconds32)static_cast<TInt>(aDuration));
+        vibraSupport = mobileDevice->Vibrate(static_cast<TInt>(aDuration));
         }
     SWT_CATCH
 #endif