コード例 #1
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_add (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) {

            QTreeWidgetItem *child = 0;
            if (Args[0]->IsArray ()) {

               QStringList list;
               V8Array array = v8_to_array (Args[0]);
               const int Length = array->Length ();
               for (int ix = 0; ix < Length; ++ix) {

                  V8Value value = array->Get (v8::Integer::New (ix));
                  list << v8_to_qstring (value);
               }
               child = new QTreeWidgetItem (item, list);
            }
            else {

               QTreeWidgetItem *prev = self->_to_qtreewidgetitem (Args[0]);
               if (prev) {

                  child = new QTreeWidgetItem (item, prev);
               }
               else {

                  child = new QTreeWidgetItem (item);
               }
            }

            if ((Args.Length () > 2) && child) {

               QVariant variant = self->_qvariant_wrap_v8 (Args[1]);
               int col = v8_to_uint32 (Args[2]);
               child->setData (col, Qt::UserRole, variant);
            }

            if (child) {

               result = self->create_v8_qtreewidgetitem (child);
            }
         }
      }
   }

   return scope.Close (result);
}
コード例 #2
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_take_children (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         QList<QTreeWidgetItem *> items = item->takeChildren ();
         const int Length = items.count ();
         V8Array array = v8::Array::New (Length);
         for (int ix = 0; ix < Length; ++ix) {

            V8Value value = self->create_v8_qtreewidgetitem (items.at (ix));
            array->Set (v8::Integer::New (ix), value);
         }
         result = array;
      }
   }

   return scope.Close (result);
}
コード例 #3
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_text (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) {

            int col = v8_to_uint32 (Args[0]);
            if (Args.Length () > 1) {

               item->setText (col, v8_to_qstring (Args[1]));
            }
            result = v8::String::New (qPrintable (item->text (col)));
         }
      }
   }

   return scope.Close (result);
}
コード例 #4
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_data (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) {

            int col = v8_to_uint32 (Args[0]);

            if (Args.Length () > 1) {

               QVariant variant = self->_qvariant_wrap_v8 (Args[1]);
               item->setData (col, Qt::UserRole, variant);
            }
            result = self->_qvariant_unwrap_v8 (item->data (col, Qt::UserRole));
         }
      }
   }

   return scope.Close (result);
}
コード例 #5
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_widget (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidget *tree = self->v8_to_qobject<QTreeWidget> (Args.This ());
      if (tree) {

         if (Args.Length () > 1) {

            QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args[0]);
            int col = v8_to_uint32 (Args[1]);
            if (item) {
               if (Args.Length () > 2) {

                  tree->setItemWidget (item, col, self->_to_qwidget (Args[2]));
               }

               result = self->create_v8_qwidget (tree->itemWidget (item, col));
            }
         }
      }
   }

   return scope.Close (result);
}
コード例 #6
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_index_of (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) {

            QTreeWidgetItem *it = self->_to_qtreewidgetitem (Args[0]);
            if (it) { result = v8::Number::New (item->indexOfChild (it)); }
         }
      }
   }

   return scope.Close (result);
}
コード例 #7
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_is_expanded (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) { result = v8::Boolean::New (item->isExpanded ()); }
   }

   return scope.Close (result);
}
コード例 #8
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_parent (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         result = self->create_v8_qtreewidgetitem (item->parent ());
      }
   }

   return scope.Close (result);
}
コード例 #9
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_below (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidget *tree = self->v8_to_qobject<QTreeWidget> (Args.This ());
      if (tree) {

         QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args[0]);
         result = self->create_v8_qtreewidgetitem (tree->itemBelow (item));
      }
   }

   return scope.Close (result);
}
コード例 #10
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_disable (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) { item->setDisabled (v8_to_boolean (Args[0])); }
         result = v8::Boolean::New (item->isDisabled ());
      }
   }

   return scope.Close (result);
}
コード例 #11
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_take_child (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length ()) {

            result = self->create_v8_qtreewidgetitem (
            item->takeChild (v8_to_uint32 (Args[0])));
         }
      }
   }

   return scope.Close (result);
}
コード例 #12
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_sort_children (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length () > 1) {

            item->sortChildren (
               v8_to_uint32 (Args[0]),
               (Qt::SortOrder)v8_to_uint32 (Args[1]));
         }
      }
   }

   return scope.Close (result);
}
コード例 #13
0
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_background (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length () > 1) {

            int column = v8_to_uint32 (Args[0]);
            QBrush *brush = self->_to_gbrush (Args[1]);
            if (brush) { item->setBackground (column, *brush); }
         }
      }
   }

   return scope.Close (result);
}