QScriptValue qDBusReplyToScriptValue(QScriptEngine *eng, const QDBusReply<T> &reply) { return QScriptValue(eng, reply.value()); }
static QScriptValue qtscript_QSourceLocation_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 8; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QSourceLocation* _q_self = qscriptvalue_cast<QSourceLocation*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QSourceLocation.%0(): this object is not a QSourceLocation") .arg(qtscript_QSourceLocation_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 0) { qint64 _q_result = _q_self->column(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 1: if (context->argumentCount() == 0) { bool _q_result = _q_self->isNull(); return QScriptValue(context->engine(), _q_result); } break; case 2: if (context->argumentCount() == 0) { qint64 _q_result = _q_self->line(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 3: if (context->argumentCount() == 1) { QSourceLocation _q_arg0 = qscriptvalue_cast<QSourceLocation>(context->argument(0)); bool _q_result = _q_self->operator==(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 1) { qint64 _q_arg0 = qscriptvalue_cast<qint64>(context->argument(0)); _q_self->setColumn(_q_arg0); return context->engine()->undefinedValue(); } break; case 5: if (context->argumentCount() == 1) { qint64 _q_arg0 = qscriptvalue_cast<qint64>(context->argument(0)); _q_self->setLine(_q_arg0); return context->engine()->undefinedValue(); } break; case 6: if (context->argumentCount() == 1) { QUrl _q_arg0 = qscriptvalue_cast<QUrl>(context->argument(0)); _q_self->setUri(_q_arg0); return context->engine()->undefinedValue(); } break; case 7: if (context->argumentCount() == 0) { QUrl _q_result = _q_self->uri(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 8: { QString result; QDebug d(&result); d << *_q_self; return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QSourceLocation_throw_ambiguity_error_helper(context, qtscript_QSourceLocation_function_names[_id+1], qtscript_QSourceLocation_function_signatures[_id+1]); }
QScriptValue REcmaSnap::toScriptValueEnumStatus(QScriptEngine* engine, const RSnap::Status& value) { return QScriptValue(engine, (int)value); }
static QScriptValue qtscript_QWebElement_StyleResolveStrategy_toString(QScriptContext *context, QScriptEngine *engine) { QWebElement::StyleResolveStrategy value = qscriptvalue_cast<QWebElement::StyleResolveStrategy>(context->thisObject()); return QScriptValue(engine, qtscript_QWebElement_StyleResolveStrategy_toStringHelper(value)); }
QScriptValue REcmaSharedPointerDimRadialEntity::setProperty (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerDimRadialEntity::setProperty", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerDimRadialEntity::setProperty"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RDimRadialEntity* self = getSelf("setProperty", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 2 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RPropertyTypeId */ && ( context->argument(1).isVariant() || context->argument(1).isQObject() || context->argument(1).isNumber() || context->argument(1).isString() || context->argument(1).isBool() || context->argument(1).isArray() || context->argument(1).isNull() || context->argument(1).isUndefined() ) /* type: QVariant */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RDimRadialEntity: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // argument isCopyable or pointer QVariant a1 = qscriptvalue_cast< QVariant >( context->argument( 1 ) ); // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->setProperty(a0 , a1); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RDimRadialEntity.setProperty().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerDimRadialEntity::setProperty", context, engine); return result; }
QScriptValue REcmaSharedPointerLinetype::operator_less (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerLinetype::operator<", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerLinetype::operator<"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RLinetype* self = getSelf("operator<", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 1 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RLinetype */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RLinetype* ap0 = qscriptvalue_cast< RLinetype* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RLinetype: Argument 0 is not of type RLinetype.", context); } RLinetype a0 = *ap0; // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->operator<(a0); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RLinetype.operator_less().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerLinetype::operator<", context, engine); return result; }
static QScriptValue qtscript_QDomImplementation_InvalidDataPolicy_toString(QScriptContext *context, QScriptEngine *engine) { QDomImplementation::InvalidDataPolicy value = qscriptvalue_cast<QDomImplementation::InvalidDataPolicy>(context->thisObject()); return QScriptValue(engine, qtscript_QDomImplementation_InvalidDataPolicy_toStringHelper(value)); }
static QScriptValue qtscript_QAbstractXmlNodeModel_SimpleAxis_toString(QScriptContext *context, QScriptEngine *engine) { QAbstractXmlNodeModel::SimpleAxis value = qscriptvalue_cast<QAbstractXmlNodeModel::SimpleAxis>(context->thisObject()); return QScriptValue(engine, qtscript_QAbstractXmlNodeModel_SimpleAxis_toStringHelper(value)); }
static QScriptValue qtscript_QAbstractXmlNodeModel_NodeCopySetting_toString(QScriptContext *context, QScriptEngine *engine) { QAbstractXmlNodeModel::NodeCopySetting value = qscriptvalue_cast<QAbstractXmlNodeModel::NodeCopySetting>(context->thisObject()); return QScriptValue(engine, qtscript_QAbstractXmlNodeModel_NodeCopySetting_toStringHelper(value)); }
bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged, EntityTree::FilterType filterType, EntityItemID& itemID, EntityItemPointer& existingEntity) { // get the ids of all the zones (plus the global entity edit filter) that the position // lies within auto zoneIDs = getZonesByPosition(position); for (auto id : zoneIDs) { if (!itemID.isInvalidID() && id == itemID) { continue; } // get the filter pair, etc... _lock.lockForRead(); FilterData filterData = _filterDataMap.value(id); _lock.unlock(); if (filterData.valid()) { if (filterData.rejectAll) { return false; } // check to see if this filter wants to filter this message type if ((!filterData.wantsToFilterEdit && filterType == EntityTree::FilterType::Edit) || (!filterData.wantsToFilterPhysics && filterType == EntityTree::FilterType::Physics) || (!filterData.wantsToFilterDelete && filterType == EntityTree::FilterType::Delete) || (!filterData.wantsToFilterAdd && filterType == EntityTree::FilterType::Add)) { wasChanged = false; return true; // accept the message } auto oldProperties = propertiesIn.getDesiredProperties(); auto specifiedProperties = propertiesIn.getChangedProperties(); propertiesIn.setDesiredProperties(specifiedProperties); QScriptValue inputValues = propertiesIn.copyToScriptValue(filterData.engine, false, true, true); propertiesIn.setDesiredProperties(oldProperties); auto in = QJsonValue::fromVariant(inputValues.toVariant()); // grab json copy now, because the inputValues might be side effected by the filter. QScriptValueList args; args << inputValues; args << filterType; // get the current properties for then entity and include them for the filter call if (existingEntity && filterData.wantsOriginalProperties) { auto currentProperties = existingEntity->getProperties(filterData.includedOriginalProperties); QScriptValue currentValues = currentProperties.copyToScriptValue(filterData.engine, false, true, true); args << currentValues; } // get the zone properties if (filterData.wantsZoneProperties) { auto zoneEntity = _tree->findEntityByEntityItemID(id); if (zoneEntity) { auto zoneProperties = zoneEntity->getProperties(filterData.includedZoneProperties); QScriptValue zoneValues = zoneProperties.copyToScriptValue(filterData.engine, false, true, true); if (filterData.wantsZoneBoundingBox) { bool success = true; AABox aaBox = zoneEntity->getAABox(success); if (success) { QScriptValue boundingBox = filterData.engine->newObject(); QScriptValue bottomRightNear = vec3ToScriptValue(filterData.engine, aaBox.getCorner()); QScriptValue topFarLeft = vec3ToScriptValue(filterData.engine, aaBox.calcTopFarLeft()); QScriptValue center = vec3ToScriptValue(filterData.engine, aaBox.calcCenter()); QScriptValue boundingBoxDimensions = vec3ToScriptValue(filterData.engine, aaBox.getDimensions()); boundingBox.setProperty("brn", bottomRightNear); boundingBox.setProperty("tfl", topFarLeft); boundingBox.setProperty("center", center); boundingBox.setProperty("dimensions", boundingBoxDimensions); zoneValues.setProperty("boundingBox", boundingBox); } } // If this is an add or delete, or original properties weren't requested // there won't be original properties in the args, but zone properties need // to be the fourth parameter, so we need to pad the args accordingly int EXPECTED_ARGS = 3; if (args.length() < EXPECTED_ARGS) { args << QScriptValue(); } assert(args.length() == EXPECTED_ARGS); // we MUST have 3 args by now! args << zoneValues; } } QScriptValue result = filterData.filterFn.call(_nullObjectForFilter, args); if (filterData.uncaughtExceptions()) { return false; } if (result.isObject()) { // make propertiesIn reflect the changes, for next filter... propertiesIn.copyFromScriptValue(result, false); // and update propertiesOut too. TODO: this could be more efficient... propertiesOut.copyFromScriptValue(result, false); // Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON. auto out = QJsonValue::fromVariant(result.toVariant()); wasChanged |= (in != out); } else if (result.isBool()) { // if the filter returned false, then it's authoritative if (!result.toBool()) { return false; } // otherwise, assume it wants to pass all properties propertiesOut = propertiesIn; wasChanged = false; } else { return false; } } } // if we made it here, return true; }
static QScriptValue qtscript_QAbstractXmlNodeModel_SimpleAxis_valueOf(QScriptContext *context, QScriptEngine *engine) { QAbstractXmlNodeModel::SimpleAxis value = qscriptvalue_cast<QAbstractXmlNodeModel::SimpleAxis>(context->thisObject()); return QScriptValue(engine, static_cast<int>(value)); }
static QScriptValue qtscript_QStyleOptionProgressBar_StyleOptionVersion_valueOf(QScriptContext *context, QScriptEngine *engine) { QStyleOptionProgressBar::StyleOptionVersion value = qscriptvalue_cast<QStyleOptionProgressBar::StyleOptionVersion>(context->thisObject()); return QScriptValue(engine, static_cast<int>(value)); }
static QScriptValue qtscript_QStyleOptionProgressBar_StyleOptionType_toString(QScriptContext *context, QScriptEngine *engine) { QStyleOptionProgressBar::StyleOptionType value = qscriptvalue_cast<QStyleOptionProgressBar::StyleOptionType>(context->thisObject()); return QScriptValue(engine, qtscript_QStyleOptionProgressBar_StyleOptionType_toStringHelper(value)); }
void ScriptUndoCommand::doRedo() { QScriptValueList args; args << _redoData; _redoFunction.call(QScriptValue(), args); }
static QScriptValue qtscript_QUndoCommand_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 9; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QUndoCommand* _q_self = qscriptvalue_cast<QUndoCommand*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QUndoCommand.%0(): this object is not a QUndoCommand") .arg(qtscript_QUndoCommand_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 0) { QString _q_result = _q_self->actionText(); return QScriptValue(context->engine(), _q_result); } break; case 1: if (context->argumentCount() == 1) { int _q_arg0 = context->argument(0).toInt32(); const QUndoCommand* _q_result = const_cast<const QUndoCommand*>(_q_self->child(_q_arg0)); return qScriptValueFromValue(context->engine(), _q_result); } break; case 2: if (context->argumentCount() == 0) { int _q_result = _q_self->childCount(); return QScriptValue(context->engine(), _q_result); } break; case 3: if (context->argumentCount() == 0) { int _q_result = _q_self->id(); return QScriptValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 1) { const QUndoCommand* _q_arg0 = qscriptvalue_cast<const QUndoCommand*>(context->argument(0)); bool _q_result = _q_self->mergeWith(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 5: if (context->argumentCount() == 0) { _q_self->redo(); return context->engine()->undefinedValue(); } break; case 6: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->setText(_q_arg0); return context->engine()->undefinedValue(); } break; case 7: if (context->argumentCount() == 0) { QString _q_result = _q_self->text(); return QScriptValue(context->engine(), _q_result); } break; case 8: if (context->argumentCount() == 0) { _q_self->undo(); return context->engine()->undefinedValue(); } break; case 9: { QString result = QString::fromLatin1("QUndoCommand"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QUndoCommand_throw_ambiguity_error_helper(context, qtscript_QUndoCommand_function_names[_id+1], qtscript_QUndoCommand_function_signatures[_id+1]); }
static QScriptValue qtscript_QAbstractXmlNodeModel_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 12; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QAbstractXmlNodeModel* _q_self = qscriptvalue_cast<QAbstractXmlNodeModel*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QAbstractXmlNodeModel.%0(): this object is not a QAbstractXmlNodeModel") .arg(qtscript_QAbstractXmlNodeModel_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QUrl _q_result = _q_self->baseUri(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 1: if (context->argumentCount() == 2) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QXmlNodeModelIndex _q_arg1 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(1)); QXmlNodeModelIndex::DocumentOrder _q_result = _q_self->compareOrder(_q_arg0, _q_arg1); return qScriptValueFromValue(context->engine(), _q_result); } break; case 2: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QUrl _q_result = _q_self->documentUri(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 3: if (context->argumentCount() == 1) { QXmlName _q_arg0 = qscriptvalue_cast<QXmlName>(context->argument(0)); QXmlNodeModelIndex _q_result = _q_self->elementById(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QXmlNodeModelIndex::NodeKind _q_result = _q_self->kind(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 5: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QXmlName _q_result = _q_self->name(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 6: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QVector<QXmlName > _q_result = _q_self->namespaceBindings(_q_arg0); return qScriptValueFromSequence(context->engine(), _q_result); } break; case 7: if (context->argumentCount() == 1) { QXmlName _q_arg0 = qscriptvalue_cast<QXmlName>(context->argument(0)); QVector<QXmlNodeModelIndex > _q_result = _q_self->nodesByIdref(_q_arg0); return qScriptValueFromSequence(context->engine(), _q_result); } break; case 8: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QXmlNodeModelIndex _q_result = _q_self->root(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 9: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QSourceLocation _q_result = _q_self->sourceLocation(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 10: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QString _q_result = _q_self->stringValue(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 11: if (context->argumentCount() == 1) { QXmlNodeModelIndex _q_arg0 = qscriptvalue_cast<QXmlNodeModelIndex>(context->argument(0)); QVariant _q_result = _q_self->typedValue(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 12: { QString result = QString::fromLatin1("QAbstractXmlNodeModel"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QAbstractXmlNodeModel_throw_ambiguity_error_helper(context, qtscript_QAbstractXmlNodeModel_function_names[_id+1], qtscript_QAbstractXmlNodeModel_function_signatures[_id+1]); }
QScriptValue REcmaSharedPointerLinetype::getTitle (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerLinetype::getTitle", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerLinetype::getTitle"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); if( context->argumentCount() == 1 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RLinetype */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RLinetype* ap0 = qscriptvalue_cast< RLinetype* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RLinetype: Argument 0 is not of type RLinetype.", context); } RLinetype a0 = *ap0; // end of arguments // call C++ function: // return type 'QString' QString cppResult = RLinetype:: getTitle(a0); // return type: QString // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RLinetype.getTitle().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerLinetype::getTitle", context, engine); return result; }
QScriptValue REcmaCircleData::moveReferencePoint (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaCircleData::moveReferencePoint", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaCircleData::moveReferencePoint"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RCircleData* self = getSelf("moveReferencePoint", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 2 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RVector */ && ( context->argument(1).isVariant() || context->argument(1).isQObject() || context->argument(1).isNull() ) /* type: RVector */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RVector* ap0 = qscriptvalue_cast< RVector* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RCircleData: Argument 0 is not of type RVector.", context); } RVector a0 = *ap0; // argument isCopyable and has default constructor and isSimpleClass RVector* ap1 = qscriptvalue_cast< RVector* >( context->argument( 1 ) ); if (ap1 == NULL) { return REcmaHelper::throwError("RCircleData: Argument 1 is not of type RVector.", context); } RVector a1 = *ap1; // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->moveReferencePoint(a0 , a1); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RCircleData.moveReferencePoint().", context); } //REcmaHelper::functionEnd("REcmaCircleData::moveReferencePoint", context, engine); return result; }
static QScriptValue qtscript_QDomImplementation_InvalidDataPolicy_valueOf(QScriptContext *context, QScriptEngine *engine) { QDomImplementation::InvalidDataPolicy value = qscriptvalue_cast<QDomImplementation::InvalidDataPolicy>(context->thisObject()); return QScriptValue(engine, static_cast<int>(value)); }
QImage Plotter::makeHistro() { QImage img= QImage(width,height,QImage::Format_RGB32); img.fill(0xffffff); QPainter painter(&img); painter.setFont(QFont(painter.font().family(),_fs)); float step_x=float(width/(_text_x.length()+1)); float max = float(scriptEngine->evaluate("Math.max.apply( Math, results );").toNumber()); float step_y=float(height)/max; float ident_right=step_x/2; float ident_left=ident_right; float ident_top=step_y+_fs*2; float ident_bottom=step_y+_fs*2; int dataCount = scriptEngine->evaluate("results.length").toInt32(); step_x=(width-ident_left-ident_right)/float(dataCount); step_y=(height-ident_bottom-ident_top)/max; QVector<QRectF> rects; QStringList text_up; QList<QPointF> text_up_pos; QList<QPointF> text_down_pos; QFontMetrics metrics=QFontMetrics(painter.font()); QString num; for(int i=0; i<dataCount; i++) { QScriptValue index = QScriptValue(i); scriptEngine->globalObject().setProperty("index",index); float curResult = (float)scriptEngine->evaluate("results[index]").toNumber(); rects.append(QRectF(ident_left+i*step_x,height-(ident_bottom+curResult*step_y),step_x,curResult*step_y)); num.setNum(curResult); text_up_pos.append(QPointF(ident_left+i*step_x+step_x/2-metrics.width(num)/2,height-(ident_bottom+curResult*step_y-_fs-_fs/2))); text_down_pos.append(QPointF(ident_left+i*step_x+step_x/2-metrics.width(_text_x[i])/2,height-ident_bottom+1.5*_fs)); num.setNum(curResult); text_up.append(num); } QLine max_line; QString max_text=QString::fromUtf8("Максимум: "); QPointF max_text_pos; if(_maximum!=0) { if(_maximum<max) _maximum=max; max_line=QLine(ident_left,height-_maximum*step_y-ident_bottom,width-ident_right,height-_maximum*step_y-ident_bottom); num.setNum(_maximum); max_text.append(num); max_text_pos=QPointF(width/2-metrics.width(max_text)/2,height-_maximum*step_y-_fs/2-ident_bottom); } QPen pen=QPen(Qt::black,2); QBrush brush1=QBrush(Qt::lightGray); QBrush brush2=QBrush(Qt::lightGray); if(_difcol==true) brush2=QBrush(Qt::gray); painter.setPen(pen); painter.setBrush(brush1); QStringList sl = _text_x.split(";",QString::SkipEmptyParts,Qt::CaseSensitive); for(int i=0; i<rects.size(); i++) { if(_difcol==true) { if(i%2==0)//если чётное painter.setBrush(brush1); else if(i%2!=0) painter.setBrush(brush2); painter.drawRect(rects[i]); } if(i<sl.size()) painter.drawText(text_down_pos[i],QString(sl[i])); painter.drawText(text_up_pos[i],QString(text_up[i])); } if(_difcol==false) painter.drawRects(rects); if(_maximum!=0) { painter.drawLine(max_line); painter.drawText(max_text_pos,max_text); } return img; }
static QScriptValue qtscript_QDomImplementation_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 5; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QDomImplementation* _q_self = qscriptvalue_cast<QDomImplementation*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QDomImplementation.%0(): this object is not a QDomImplementation") .arg(qtscript_QDomImplementation_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 3) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QDomDocumentType _q_arg2 = qscriptvalue_cast<QDomDocumentType>(context->argument(2)); QDomDocument _q_result = _q_self->createDocument(_q_arg0, _q_arg1, _q_arg2); return qScriptValueFromValue(context->engine(), _q_result); } break; case 1: if (context->argumentCount() == 3) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QString _q_arg2 = context->argument(2).toString(); QDomDocumentType _q_result = _q_self->createDocumentType(_q_arg0, _q_arg1, _q_arg2); return qScriptValueFromValue(context->engine(), _q_result); } break; case 2: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); bool _q_result = _q_self->hasFeature(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } break; case 3: if (context->argumentCount() == 0) { bool _q_result = _q_self->isNull(); return QScriptValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 1) { QDomImplementation _q_arg0 = qscriptvalue_cast<QDomImplementation>(context->argument(0)); bool _q_result = _q_self->operator==(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 5: { QString result = QString::fromLatin1("QDomImplementation"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QDomImplementation_throw_ambiguity_error_helper(context, qtscript_QDomImplementation_function_names[_id+3], qtscript_QDomImplementation_function_signatures[_id+3]); }
QImage Plotter::makePlot() { QImage img=QImage(width,height,QImage::Format_RGB32); img.fill(0xffffff); QPainter painter(&img); painter.setFont(QFont(painter.font().family(),_fs)); //Отступы QFontMetrics metrics(painter.font()); std::vector<int> lens; foreach(QString str,_text_y) lens.push_back(str.size()); float ident_left; std::vector<int>::const_iterator it, it2; for(int i=0;i<lens.size(); i++) { it2 = std::max_element(lens.begin(), lens.end()); if(lens.at(i)==*it2) { ident_left=metrics.width(_text_y[i])+metrics.width(_text_y[i])/5; break; } } float ident_right=metrics.width(_text_x[_text_x.size()-1])+metrics.width(_text_x[_text_x.size()-1])/5; //Шаги и отступы снизу и сверху float step_x=(width-ident_right-ident_left)/_text_x.size(); float step_y=height/(_text_y.size()+1); float ident_bottom=step_y+_fs; float ident_top=step_y+_fs; step_y=(height-ident_top-ident_bottom)/(_text_y.size()); //Оси QLineF axis_x(ident_left,height-ident_bottom,width-ident_right,height-ident_bottom); QLineF axis_y(ident_left,height-ident_bottom,ident_left,ident_top); //Черточки и подписи QVector<QLineF> x_hyphen; float hx_size=step_x/10; float hy_size=step_y/10; QList<QRectF> text_x_pos; QStringList sl_x = _text_x.split(";",QString::SkipEmptyParts); for(int i=0; i<sl_x.size();i++) { if(i<sl_x.size()-1) x_hyphen.append(QLineF(ident_left+(i+1)*step_x,height-ident_bottom-hx_size,ident_left+(i+1)*step_x,height-ident_bottom)); QFontMetrics metrics(painter.font()); if(i==sl_x.size()-1) { text_x_pos.append(QRectF(ident_left+(i+1)*step_x,height-ident_bottom+_fs+hy_size*2,step_x,ident_bottom-_fs-hy_size*2)); //text_x_pos.append(QRectF(x,y,w,h)) } else { //text_x_pos.append(QPointF(ident_left+(i+1)*step_x-metrics.width(text_x[i])/2,height-ident_bottom+font+hy_size*2)) text_x_pos.append(QRectF(ident_left+(i+1)*step_x-metrics.width(sl_x[i])/2,height-ident_bottom+_fs+hy_size*2,step_x,ident_bottom-_fs-hy_size*2)); } } QVector<QLineF> y_hyphen; QList<QPointF> text_y_pos; QStringList sl_y = _text_y.split(";",QString::SkipEmptyParts); for(int i=0; i<sl_y.size();i++) { if(i<sl_y.size()-1) y_hyphen.append(QLineF(ident_left,height-ident_bottom-(i+1)*step_y,ident_left+hy_size,height-ident_bottom-(i+1)*step_y)); QFontMetrics metrics(painter.font()); if(i==sl_y.size()-1) text_y_pos.append(QPointF(ident_left-metrics.width(sl_y[i])/2,ident_top/2+_fs/2)); else text_y_pos.append(QPointF(ident_left-metrics.width(sl_y[i])-hy_size,height-ident_bottom-(i+1)*step_y+_fs/2)); } //Точки графика QVector<QPoint> graph_points; QVector<QLineF> dot_line_x; QVector<QLineF> dot_line_y; int dataCount = scriptEngine->evaluate("results.length").toInteger(); for(int i=0;i<dataCount; i++) { QScriptValue index = QScriptValue(i); scriptEngine->globalObject().setProperty("index",index); float curResult = (float)scriptEngine->evaluate("results[index]").toNumber(); graph_points.append(QPoint(ident_left+step_x*(i+1),height-(ident_bottom+curResult*step_y))); dot_line_x.append(QLineF(QPointF(ident_left,graph_points[graph_points.size()-1].y()),graph_points[graph_points.size()-1])); dot_line_y.append(QLineF(QPointF(graph_points[graph_points.size()-1].x(),height-ident_bottom),graph_points[graph_points.size()-1])); } //Перья для рисования QPen axis_pen(Qt::black); axis_pen.setWidth(4); QPen dot_pen(Qt::black); dot_pen.setWidth(1); dot_pen.setStyle(Qt::DotLine); QPen main_pen(Qt::black); main_pen.setWidth(2); QPen point_pen(Qt::red); point_pen.setWidth(4); //Рисуем //Оси painter.setRenderHint(QPainter::Antialiasing); painter.setPen(axis_pen); painter.drawLine(axis_x); painter.drawLine(axis_y); //Черточки и подписи painter.setPen(main_pen); painter.drawLines(x_hyphen); painter.drawLines(y_hyphen); for(int i=0; i<text_x_pos.size(); i++) { if(i==text_x_pos.size()-1) { QFont nf(painter.font()); nf.setWeight(QFont::Bold); painter.setFont(nf); painter.drawText(text_x_pos[i],QString(sl_x[i])); nf.setWeight(QFont::Normal); painter.setFont(nf); } else painter.drawText(text_x_pos[i],Qt::TextWordWrap,QString(sl_x[i])); } for(int i=0;i<text_y_pos.size();i++) { if(i==text_y_pos.size()-1) { QFont nf(painter.font()); nf.setWeight(QFont::Bold); painter.setFont(nf); painter.drawText(text_y_pos[i],QString(sl_y[i])); nf.setWeight(QFont::Normal); painter.setFont(nf); } else painter.drawText(text_y_pos[i],QString(sl_y[i])); } //График QPolygon p(graph_points); painter.drawPolyline(p); //Пунктирные линии painter.setRenderHint(QPainter::Antialiasing,false); painter.setPen(dot_pen); painter.drawLines(dot_line_x); painter.drawLines(dot_line_y); //Точки графика painter.setRenderHint(QPainter::Antialiasing); painter.setPen(point_pen); painter.drawPoints(p); return img; }
static QScriptValue qtscript_QWebElement_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 54; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QWebElement* _q_self = qscriptvalue_cast<QWebElement*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QWebElement.%0(): this object is not a QWebElement") .arg(qtscript_QWebElement_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->addClass(_q_arg0); return context->engine()->undefinedValue(); } break; case 1: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->appendInside(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->appendInside(_q_arg0); return context->engine()->undefinedValue(); } } break; case 2: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->appendOutside(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->appendOutside(_q_arg0); return context->engine()->undefinedValue(); } } break; case 3: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); QString _q_result = _q_self->attribute(_q_arg0); return QScriptValue(context->engine(), _q_result); } if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QString _q_result = _q_self->attribute(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QString _q_result = _q_self->attributeNS(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } if (context->argumentCount() == 3) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QString _q_arg2 = context->argument(2).toString(); QString _q_result = _q_self->attributeNS(_q_arg0, _q_arg1, _q_arg2); return QScriptValue(context->engine(), _q_result); } break; case 5: if (context->argumentCount() == 0) { QStringList _q_result = _q_self->attributeNames(); return qScriptValueFromSequence(context->engine(), _q_result); } if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); QStringList _q_result = _q_self->attributeNames(_q_arg0); return qScriptValueFromSequence(context->engine(), _q_result); } break; case 6: if (context->argumentCount() == 0) { QStringList _q_result = _q_self->classes(); return qScriptValueFromSequence(context->engine(), _q_result); } break; case 7: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->clone(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 8: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->document(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 9: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->encloseContentsWith(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->encloseContentsWith(_q_arg0); return context->engine()->undefinedValue(); } } break; case 10: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->encloseWith(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->encloseWith(_q_arg0); return context->engine()->undefinedValue(); } } break; case 11: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); QVariant _q_result = _q_self->evaluateJavaScript(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 12: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); QWebElement _q_result = _q_self->findFirst(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 13: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->firstChild(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 14: if (context->argumentCount() == 0) { QRect _q_result = _q_self->geometry(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 15: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); bool _q_result = _q_self->hasAttribute(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 16: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); bool _q_result = _q_self->hasAttributeNS(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } break; case 17: if (context->argumentCount() == 0) { bool _q_result = _q_self->hasAttributes(); return QScriptValue(context->engine(), _q_result); } break; case 18: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); bool _q_result = _q_self->hasClass(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 19: if (context->argumentCount() == 0) { bool _q_result = _q_self->hasFocus(); return QScriptValue(context->engine(), _q_result); } break; case 20: if (context->argumentCount() == 0) { bool _q_result = _q_self->isNull(); return QScriptValue(context->engine(), _q_result); } break; case 21: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->lastChild(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 22: if (context->argumentCount() == 0) { QString _q_result = _q_self->localName(); return QScriptValue(context->engine(), _q_result); } break; case 23: if (context->argumentCount() == 0) { QString _q_result = _q_self->namespaceUri(); return QScriptValue(context->engine(), _q_result); } break; case 24: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->nextSibling(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 25: if (context->argumentCount() == 1) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); QWebElement& _q_result = _q_self->operator=(_q_arg0); return qScriptValueFromValue(context->engine(), _q_result); } break; case 26: if (context->argumentCount() == 1) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); bool _q_result = _q_self->operator==(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 27: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->parent(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 28: if (context->argumentCount() == 0) { QString _q_result = _q_self->prefix(); return QScriptValue(context->engine(), _q_result); } break; case 29: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->prependInside(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->prependInside(_q_arg0); return context->engine()->undefinedValue(); } } break; case 30: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->prependOutside(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->prependOutside(_q_arg0); return context->engine()->undefinedValue(); } } break; case 31: if (context->argumentCount() == 0) { QWebElement _q_result = _q_self->previousSibling(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 32: if (context->argumentCount() == 0) { _q_self->removeAllChildren(); return context->engine()->undefinedValue(); } break; case 33: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->removeAttribute(_q_arg0); return context->engine()->undefinedValue(); } break; case 34: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); _q_self->removeAttributeNS(_q_arg0, _q_arg1); return context->engine()->undefinedValue(); } break; case 35: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->removeClass(_q_arg0); return context->engine()->undefinedValue(); } break; case 36: if (context->argumentCount() == 0) { _q_self->removeFromDocument(); return context->engine()->undefinedValue(); } break; case 37: if (context->argumentCount() == 1) { QPainter* _q_arg0 = qscriptvalue_cast<QPainter*>(context->argument(0)); _q_self->render(_q_arg0); return context->engine()->undefinedValue(); } if (context->argumentCount() == 2) { QPainter* _q_arg0 = qscriptvalue_cast<QPainter*>(context->argument(0)); QRect _q_arg1 = qscriptvalue_cast<QRect>(context->argument(1)); _q_self->render(_q_arg0, _q_arg1); return context->engine()->undefinedValue(); } break; case 38: if (context->argumentCount() == 1) { if (context->argument(0).isString()) { QString _q_arg0 = context->argument(0).toString(); _q_self->replace(_q_arg0); return context->engine()->undefinedValue(); } else if ((qMetaTypeId<QWebElement>() == context->argument(0).toVariant().userType())) { QWebElement _q_arg0 = qscriptvalue_cast<QWebElement>(context->argument(0)); _q_self->replace(_q_arg0); return context->engine()->undefinedValue(); } } break; case 39: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); _q_self->setAttribute(_q_arg0, _q_arg1); return context->engine()->undefinedValue(); } break; case 40: if (context->argumentCount() == 3) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); QString _q_arg2 = context->argument(2).toString(); _q_self->setAttributeNS(_q_arg0, _q_arg1, _q_arg2); return context->engine()->undefinedValue(); } break; case 41: if (context->argumentCount() == 0) { _q_self->setFocus(); return context->engine()->undefinedValue(); } break; case 42: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->setInnerXml(_q_arg0); return context->engine()->undefinedValue(); } break; case 43: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->setOuterXml(_q_arg0); return context->engine()->undefinedValue(); } break; case 44: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->setPlainText(_q_arg0); return context->engine()->undefinedValue(); } break; case 45: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QString _q_arg1 = context->argument(1).toString(); _q_self->setStyleProperty(_q_arg0, _q_arg1); return context->engine()->undefinedValue(); } break; case 46: if (context->argumentCount() == 2) { QString _q_arg0 = context->argument(0).toString(); QWebElement::StyleResolveStrategy _q_arg1 = qscriptvalue_cast<QWebElement::StyleResolveStrategy>(context->argument(1)); QString _q_result = _q_self->styleProperty(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } break; case 47: if (context->argumentCount() == 0) { QString _q_result = _q_self->tagName(); return QScriptValue(context->engine(), _q_result); } break; case 48: if (context->argumentCount() == 0) { QWebElement& _q_result = _q_self->takeFromDocument(); return qScriptValueFromValue(context->engine(), _q_result); } break; case 49: if (context->argumentCount() == 0) { QString _q_result = _q_self->toInnerXml(); return QScriptValue(context->engine(), _q_result); } break; case 50: if (context->argumentCount() == 0) { QString _q_result = _q_self->toOuterXml(); return QScriptValue(context->engine(), _q_result); } break; case 51: if (context->argumentCount() == 0) { QString _q_result = _q_self->toPlainText(); return QScriptValue(context->engine(), _q_result); } break; case 52: if (context->argumentCount() == 1) { QString _q_arg0 = context->argument(0).toString(); _q_self->toggleClass(_q_arg0); return context->engine()->undefinedValue(); } break; /* andrew: case 53: if (context->argumentCount() == 0) { QWebFrame* _q_result = _q_self->webFrame(); return qScriptValueFromValue(context->engine(), _q_result); } break; */ case 54: { QString result = QString::fromLatin1("QWebElement"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QWebElement_throw_ambiguity_error_helper(context, qtscript_QWebElement_function_names[_id+1], qtscript_QWebElement_function_signatures[_id+1]); }
static QScriptValue qtscript_QReadWriteLock_RecursionMode_valueOf(QScriptContext *context, QScriptEngine *engine) { QReadWriteLock::RecursionMode value = qscriptvalue_cast<QReadWriteLock::RecursionMode>(context->thisObject()); return QScriptValue(engine, static_cast<int>(value)); }
static QScriptValue qtscript_QWaitCondition_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 3; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QWaitCondition* _q_self = qscriptvalue_cast<QWaitCondition*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QWaitCondition.%0(): this object is not a QWaitCondition") .arg(qtscript_QWaitCondition_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 1) { if (qscriptvalue_cast<QMutex*>(context->argument(0))) { QMutex* _q_arg0 = qscriptvalue_cast<QMutex*>(context->argument(0)); bool _q_result = _q_self->wait(_q_arg0); return QScriptValue(context->engine(), _q_result); } else if (qscriptvalue_cast<QReadWriteLock*>(context->argument(0))) { QReadWriteLock* _q_arg0 = qscriptvalue_cast<QReadWriteLock*>(context->argument(0)); bool _q_result = _q_self->wait(_q_arg0); return QScriptValue(context->engine(), _q_result); } } if (context->argumentCount() == 2) { if (qscriptvalue_cast<QMutex*>(context->argument(0)) && (qMetaTypeId<ulong>() == context->argument(1).toVariant().userType())) { QMutex* _q_arg0 = qscriptvalue_cast<QMutex*>(context->argument(0)); ulong _q_arg1 = qscriptvalue_cast<ulong>(context->argument(1)); bool _q_result = _q_self->wait(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } else if (qscriptvalue_cast<QReadWriteLock*>(context->argument(0)) && (qMetaTypeId<ulong>() == context->argument(1).toVariant().userType())) { QReadWriteLock* _q_arg0 = qscriptvalue_cast<QReadWriteLock*>(context->argument(0)); ulong _q_arg1 = qscriptvalue_cast<ulong>(context->argument(1)); bool _q_result = _q_self->wait(_q_arg0, _q_arg1); return QScriptValue(context->engine(), _q_result); } } break; case 1: if (context->argumentCount() == 0) { _q_self->wakeAll(); return context->engine()->undefinedValue(); } break; case 2: if (context->argumentCount() == 0) { _q_self->wakeOne(); return context->engine()->undefinedValue(); } break; case 3: { QString result = QString::fromLatin1("QWaitCondition"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QWaitCondition_throw_ambiguity_error_helper(context, qtscript_QWaitCondition_function_names[_id+1], qtscript_QWaitCondition_function_signatures[_id+1]); }
static QScriptValue qtscript_QReadWriteLock_RecursionMode_toString(QScriptContext *context, QScriptEngine *engine) { QReadWriteLock::RecursionMode value = qscriptvalue_cast<QReadWriteLock::RecursionMode>(context->thisObject()); return QScriptValue(engine, qtscript_QReadWriteLock_RecursionMode_toStringHelper(value)); }
// includes for base ecma wrapper classes void REcmaSnap::init(QScriptEngine& engine, QScriptValue* proto ) { bool protoCreated = false; if(proto == NULL){ proto = new QScriptValue(engine.newVariant(qVariantFromValue( (RSnap*) 0))); protoCreated = true; } QScriptValue fun; // toString: REcmaHelper::registerFunction(&engine, proto, toString, "toString"); // destroy: REcmaHelper::registerFunction(&engine, proto, destroy, "destroy"); // get class name REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName"); // conversion to all base classes (multiple inheritance): REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses"); // properties: // methods: REcmaHelper::registerFunction(&engine, proto, snap, "snap"); REcmaHelper::registerFunction(&engine, proto, showUiOptions, "showUiOptions"); REcmaHelper::registerFunction(&engine, proto, hideUiOptions, "hideUiOptions"); REcmaHelper::registerFunction(&engine, proto, getEntityIds, "getEntityIds"); REcmaHelper::registerFunction(&engine, proto, getStatus, "getStatus"); REcmaHelper::registerFunction(&engine, proto, getLastSnap, "getLastSnap"); REcmaHelper::registerFunction(&engine, proto, reset, "reset"); engine.setDefaultPrototype( qMetaTypeId<RSnap*>(), *proto); QScriptValue ctor = engine.newFunction(create, *proto, 2); // static methods: // static properties: // enum values: ctor.setProperty("Unknown", QScriptValue(RSnap::Unknown), QScriptValue::ReadOnly); ctor.setProperty("Free", QScriptValue(RSnap::Free), QScriptValue::ReadOnly); ctor.setProperty("Grid", QScriptValue(RSnap::Grid), QScriptValue::ReadOnly); ctor.setProperty("Endpoint", QScriptValue(RSnap::Endpoint), QScriptValue::ReadOnly); ctor.setProperty("OnEntity", QScriptValue(RSnap::OnEntity), QScriptValue::ReadOnly); ctor.setProperty("Center", QScriptValue(RSnap::Center), QScriptValue::ReadOnly); ctor.setProperty("Middle", QScriptValue(RSnap::Middle), QScriptValue::ReadOnly); ctor.setProperty("Distance", QScriptValue(RSnap::Distance), QScriptValue::ReadOnly); ctor.setProperty("Intersection", QScriptValue(RSnap::Intersection), QScriptValue::ReadOnly); ctor.setProperty("IntersectionManual", QScriptValue(RSnap::IntersectionManual), QScriptValue::ReadOnly); ctor.setProperty("Reference", QScriptValue(RSnap::Reference), QScriptValue::ReadOnly); ctor.setProperty("Perpendicular", QScriptValue(RSnap::Perpendicular), QScriptValue::ReadOnly); ctor.setProperty("Coordinate", QScriptValue(RSnap::Coordinate), QScriptValue::ReadOnly); ctor.setProperty("CoordinatePolar", QScriptValue(RSnap::CoordinatePolar), QScriptValue::ReadOnly); // enum conversions: qScriptRegisterMetaType<RSnap::Status>( &engine, toScriptValueEnumStatus, fromScriptValueEnumStatus, ctor.property(QString::fromLatin1("prototype")) ); // init class: engine.globalObject().setProperty("RSnap", ctor, QScriptValue::SkipInEnumeration); if( protoCreated ){ delete proto; } }
static QScriptValue qtscript_QReadWriteLock_prototype_call(QScriptContext *context, QScriptEngine *) { #if QT_VERSION > 0x040400 Q_ASSERT(context->callee().isFunction()); uint _id = context->callee().data().toUInt32(); #else uint _id; if (context->callee().isFunction()) _id = context->callee().data().toUInt32(); else _id = 0xBABE0000 + 5; #endif Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); _id &= 0x0000FFFF; QReadWriteLock* _q_self = qscriptvalue_cast<QReadWriteLock*>(context->thisObject()); if (!_q_self) { return context->throwError(QScriptContext::TypeError, QString::fromLatin1("QReadWriteLock.%0(): this object is not a QReadWriteLock") .arg(qtscript_QReadWriteLock_function_names[_id+1])); } switch (_id) { case 0: if (context->argumentCount() == 0) { _q_self->lockForRead(); return context->engine()->undefinedValue(); } break; case 1: if (context->argumentCount() == 0) { _q_self->lockForWrite(); return context->engine()->undefinedValue(); } break; case 2: if (context->argumentCount() == 0) { bool _q_result = _q_self->tryLockForRead(); return QScriptValue(context->engine(), _q_result); } if (context->argumentCount() == 1) { int _q_arg0 = context->argument(0).toInt32(); bool _q_result = _q_self->tryLockForRead(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 3: if (context->argumentCount() == 0) { bool _q_result = _q_self->tryLockForWrite(); return QScriptValue(context->engine(), _q_result); } if (context->argumentCount() == 1) { int _q_arg0 = context->argument(0).toInt32(); bool _q_result = _q_self->tryLockForWrite(_q_arg0); return QScriptValue(context->engine(), _q_result); } break; case 4: if (context->argumentCount() == 0) { _q_self->unlock(); return context->engine()->undefinedValue(); } break; case 5: { QString result = QString::fromLatin1("QReadWriteLock"); return QScriptValue(context->engine(), result); } default: Q_ASSERT(false); } return qtscript_QReadWriteLock_throw_ambiguity_error_helper(context, qtscript_QReadWriteLock_function_names[_id+1], qtscript_QReadWriteLock_function_signatures[_id+1]); }
/* Currently documented in doc/src/declarative/globalobject.qdoc */ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEngine *engine) { #ifndef QT_NO_SETTINGS qmlsqldatabase_initDatabasesPath(engine); QSqlDatabase database; QString dbname = context->argument(0).toString(); QString dbversion = context->argument(1).toString(); QString dbdescription = context->argument(2).toString(); int dbestimatedsize = context->argument(3).toNumber(); QScriptValue dbcreationCallback = context->argument(4); QCryptographicHash md5(QCryptographicHash::Md5); md5.addData(dbname.toUtf8()); QString dbid(QLatin1String(md5.result().toHex())); QString basename = qmlsqldatabase_databaseFile(dbid, engine); bool created = false; QString version = dbversion; { QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat); if (QSqlDatabase::connectionNames().contains(dbid)) { database = QSqlDatabase::database(dbid); version = ini.value(QLatin1String("Version")).toString(); if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty()) THROW_SQL(VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch")); } else { created = !QFile::exists(basename+QLatin1String(".sqlite")); database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); if (created) { ini.setValue(QLatin1String("Name"), dbname); if (dbcreationCallback.isFunction()) version = QString(); ini.setValue(QLatin1String("Version"), version); ini.setValue(QLatin1String("Description"), dbdescription); ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize); ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE")); } else { if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) { // Incompatible THROW_SQL(VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch")); } version = ini.value(QLatin1String("Version")).toString(); } database.setDatabaseName(basename+QLatin1String(".sqlite")); } if (!database.isOpen()) database.open(); } QScriptValue instance = engine->newObject(); instance.setProperty(QLatin1String("transaction"), engine->newFunction(qmlsqldatabase_transaction,1)); instance.setProperty(QLatin1String("readTransaction"), engine->newFunction(qmlsqldatabase_read_transaction,1)); instance.setProperty(QLatin1String("version"), version, QScriptValue::ReadOnly); instance.setProperty(QLatin1String("changeVersion"), engine->newFunction(qmlsqldatabase_change_version,3)); QScriptValue result = engine->newVariant(instance,QVariant::fromValue(database)); if (created && dbcreationCallback.isFunction()) { dbcreationCallback.call(QScriptValue(), QScriptValueList() << result); } return result; #else return engine->undefinedValue(); #endif // QT_NO_SETTINGS }
QScriptValue QSqlErrorTypetoScriptValue(QScriptEngine *engine, const enum QSqlError::ErrorType &p) { return QScriptValue(engine, (int)p); }