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);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_find_items (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 ()) {

            QString str (v8_to_qstring (Args[0]));
            Qt::MatchFlags flag = Qt::MatchExactly;
            if (Args.Length () > 1) {

               flag = (Qt::MatchFlags)v8_to_uint32 (Args[1]);
            }
            QList<QTreeWidgetItem *> items = tree->findItems (str, flag);
            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);
}
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);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_root (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) { result = self->create_v8_qtreewidgetitem (tree->invisibleRootItem ()); }
   }

   return scope.Close (result);
}
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);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_at (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 = tree->topLevelItem (v8_to_uint32 (Args[0]));
         if (item) { result = self->create_v8_qtreewidgetitem (item); }
      }
   }

   return scope.Close (result);
}
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);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_above (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 ()) {

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

   return scope.Close (result);
}