[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kjsembed
Subject:    [kjsembed] [Bug 81980] QTimeEdit always returns -1 time
From:       Richard Moore <rich () kde ! org>
Date:       2004-05-28 23:15:40
Message-ID: 20040528231540.9465.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=81980      
rich kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From rich kde org  2004-05-29 01:15 -------
CVS commit by rich: 

- Fixed the problem of the time property of a QTimeEdit returning -1. This
  in fact turned out to be a general problem that affects all QTime
  properties and was happening because you can't create a Date object in js
  with just a time in it.

CCMAIL: 81980-done bugs kde org


  A            tests/test_qtimeedit.js   1.1
  M +52 -41    jsbinding.cpp   1.57


--- kdebindings/kjsembed/jsbinding.cpp  #1.56:1.57
 @ -75,7 +75,14  @ KJS::Value convertToValue( KJS::ExecStat
         return KJS::Object( exec->interpreter()->builtinArray().construct( exec, \
items ) );  }
-    else if ( type == QVariant::Date || type == QVariant::Time || type == \
QVariant::DateTime ) +    else if ( type == QVariant::Date || type == \
QVariant::DateTime || type == QVariant::Time )  {
-        QDateTime dt( val.toDateTime() );
+        QDateTime dt = QDateTime::currentDateTime();
+        if ( type == QVariant::Date )
+            dt.setDate( val.toDate() );
+        else if ( type == QVariant::Time )
+            dt.setTime( val.toTime() );
+        else
+            dt = val.toDateTime();
+
         items.append( KJS::Number( dt.date().year() ));
         items.append( KJS::Number( dt.date().month() - 1 ));
 @ -507,9 +514,8  @ QStringList convertArrayToStringList( KJ
         QStringList returnList;
         KJS::Object obj = value.toObject(exec);
-        if( obj.className().qstring() == "Array" )
-        {
+
+    if( obj.className().qstring() == "Array" ) {
                 int length = obj.get(exec, \
                KJS::Identifier("length")).toInteger(exec);
-                for( int index = 0; index < length; ++index)
-                {
+        for( int index = 0; index < length; ++index ) {
                         returnList << obj.get(exec, KJS::Identifier( \
KJS::UString::from(index) ) ).toString(exec).qstring();  }
 @ -522,7 +529,7  @ QDateTime convertDateToDateTime(KJS::Exe
         KJS::List args;
         QDateTime returnDateTime;
-        KJS::Object obj = value.toObject(exec);
-        if( obj.className().qstring() == "Date" )
-        {
+    KJS::Object obj = value.toObject( exec );
+
+    if ( obj.className().qstring() == "Date" ) {
                 int seconds = obj.get(exec, KJS::Identifier("getSeconds")).toObject( \
                exec ).call(exec, obj, args).toInteger(exec);
                 int minutes = obj.get(exec, KJS::Identifier("getMinutes")).toObject( \
exec ).call(exec, obj, args).toInteger(exec);  @ -532,7 +539,11  @ QDateTime \
                convertDateToDateTime(KJS::Exe
                 int year = obj.get(exec, KJS::Identifier("getFullYear")).toObject( \
exec ).call(exec, obj, args).toInteger(exec);  
-                returnDateTime.setDate(QDate(year,month+1,day));
-                returnDateTime.setTime(QTime(hours,minutes,seconds));
+        returnDateTime.setDate( QDate( year, month+1, day ) );
+        returnDateTime.setTime( QTime( hours, minutes, seconds ) );
+    }
+    else {
+        kdWarning() << "convertDateToDateTime() received a " << \
obj.className().qstring() << " instead of a Date" << endl;  }
+
         return returnDateTime;
 }
 @ -573,9 +584,8  @ QStrList convertArrayToStrList( KJS::Exe
         QStrList returnList;
         KJS::Object obj = value.toObject(exec);
-        if( obj.className().qstring() == "Array" )
-        {
+
+    if( obj.className().qstring() == "Array" ) {
                 int length = obj.get(exec, \
                KJS::Identifier("length")).toInteger(exec);
-                for( int index = 0; index < length; ++index)
-                {
+        for( int index = 0; index < length; ++index) {
                         returnList.append( obj.get(exec, KJS::Identifier( \
KJS::UString::from(index) ) ).toString(exec).qstring().latin1() );  }
_______________________________________________
kjsembed mailing list
kjsembed@kde.org
https://mail.kde.org/mailman/listinfo/kjsembed


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic