dmz::V8Value
dmz::JsModuleUiV8QtBasic::create_v8_qevent (QEvent *value) {

   v8::Context::Scope cscope (_state.context);
   v8::HandleScope scope;

   V8Value result = v8::Undefined ();

   if (value) {

      V8Object obj;

      // NOTE: Adding a default will cause a DMZ crash for some events when the "type"
      // function is called. Until the specific reason is found, add and test events
      // on a case-by-case basis.
      switch (value->type ()) {

      case QEvent::MouseButtonDblClick:
      case QEvent::MouseButtonPress:
      case QEvent::MouseButtonRelease:
      case QEvent::Enter:
      case QEvent::Leave:
      case QEvent::MouseMove:
         if (!_mouseEventCtor.IsEmpty ()) { obj = _mouseEventCtor->NewInstance (); }
         break;
      case QEvent::GraphicsSceneMouseDoubleClick:
      case QEvent::GraphicsSceneMouseMove:
      case QEvent::GraphicsSceneMousePress:
      case QEvent::GraphicsSceneMouseRelease:
         if (!_gsceneMouseEventCtor.IsEmpty ()) {

            obj = _gsceneMouseEventCtor->NewInstance ();
         }
         break;
      case QEvent::Resize:
         if (!_resizeEventCtor.IsEmpty ()) { obj = _resizeEventCtor->NewInstance (); }
         break;
      }

      if (!obj.IsEmpty ()) {

         obj->SetInternalField (0, v8::External::Wrap ((void *)value));
         result = obj;
      }
   }

   return scope.Close (result);
}
Esempio n. 2
0
dmz::V8QtObject::V8QtObject (
      const V8Object &Self,
      QObject *object,
      JsModuleUiV8QtBasicState *state) :
      QObject (0),
      _object (object),
      _state (state),
      _current (0),
      _deleteObject (True) {

   setObjectName ("V8QtObject");
   if (!Self.IsEmpty ()) {

      Self->SetInternalField (0, v8::External::Wrap ((void *)this));
      self = V8ObjectPersist::New (Self);
   }
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::create_v8_qtreewidgetitem (QTreeWidgetItem *value) {

   v8::Context::Scope cscope (_state.context);
   v8::HandleScope scope;

   V8Value result = v8::Undefined ();

   if (value) {

      V8Object obj;
      if (!_treeWidgetItemCtor.IsEmpty ()) { obj = _treeWidgetItemCtor->NewInstance (); }

      if (!obj.IsEmpty ()) {

         obj->SetInternalField (0, v8::External::Wrap ((void *)value));
         result = obj;
      }
   }

   return scope.Close (result);
}