nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent, nsXULTemplateQueryProcessorRDF* aProcessor, nsIAtom* aSourceVariable, nsIRDFResource* aProperty, nsIRDFNode* aTarget) : nsRDFTestNode(aParent), mProcessor(aProcessor), mSourceVariable(aSourceVariable), mSource(nullptr), mProperty(aProperty), mTargetVariable(0), mTarget(aTarget) { #ifdef PR_LOGGING if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) { nsAutoString svar(NS_LITERAL_STRING("(none)")); if (mSourceVariable) mSourceVariable->ToString(svar); const char* prop = "(null)"; if (aProperty) aProperty->GetValueConst(&prop); nsAutoString target; nsXULContentUtils::GetTextForNode(aTarget, target); PR_LOG(gXULTemplateLog, PR_LOG_DEBUG, ("nsRDFPropertyTestNode[%p]: parent=%p source=%s property=%s target=%s", this, aParent, NS_ConvertUTF16toUTF8(svar).get(), prop, NS_ConvertUTF16toUTF8(target).get())); } #endif }
void ChangeProperties::on_buttonSet_clicked() { QTreeWidgetItem *item = listProperties->currentItem(); if (!item) return; QString prop = item->text(0); QVariant value = activex->property(prop.toLatin1()); QVariant::Type type = value.type(); if (!value.isValid()) { const QMetaObject *mo = activex->metaObject(); const QMetaProperty property = mo->property(mo->indexOfProperty(prop.toLatin1())); type = QVariant::nameToType(property.typeName()); } switch (type) { case QVariant::Color: { QColor col; col.setNamedColor(editValue->text()); if (col.isValid()) { value = qVariantFromValue(col); } else { QMessageBox::warning(this, tr("Can't parse input"), QString(tr("Failed to create a color from %1\n" "The string has to be a valid color name (e.g. 'red')\n" "or a RGB triple of format '#rrggbb'." ).arg(editValue->text()))); } } break; case QVariant::Font: { QFont fnt; if (fnt.fromString(editValue->text())) { value = qVariantFromValue(fnt); } else { QMessageBox::warning(this, tr("Can't parse input"), (tr("Failed to create a font from %1\n" "The string has to have a format family,<point size> or\n" "family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode." ).arg(editValue->text()))); } } break; case QVariant::Pixmap: { QString fileName = editValue->text(); if (fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this); QPixmap pm(fileName); if (pm.isNull()) return; value = qVariantFromValue(pm); } break; case QVariant::Bool: { QString txt = editValue->text().toLower(); value = QVariant(txt != QLatin1String("0") && txt != QLatin1String("false")); } break; case QVariant::List: { QStringList txtList = editValue->text().split(QRegExp(QLatin1String("[,;]"))); QList<QVariant> varList; for (int i = 0; i < txtList.count(); ++i) { QVariant svar(txtList.at(i)); QString str = svar.toString(); str = str.trimmed(); bool ok; int n = str.toInt(&ok); if (ok) { varList << n; continue; } double d = str.toDouble(&ok); if (ok) { varList << d; continue; } varList << str; } value = varList; } break; default: value = editValue->text(); break; } Q_ASSERT(activex->setProperty(prop.toLatin1(), value)); updateProperties(); listProperties->setCurrentItem(listProperties->findItems(prop, Qt::MatchExactly).at(0)); }
/* * set a variable * * int f; default flag * int n; numeric arg (can overide prompted value) */ int setvar(int f, int n) { int status; /* status return */ #if DEBUGM char *sp; /* temp string pointer */ char *ep; /* ptr to end of outline */ #endif struct variable_description vd; /* variable num/type */ char var[NVSIZE + 1]; /* name of variable to fetch */ char value[NSTRING]; /* value to set variable to */ /* first get the variable to set.. */ if (clexec == FALSE) { status = mlreply("Variable to set: ", &var[0], NVSIZE); if (status != TRUE) return status; } else { /* macro line argument */ /* grab token and skip it */ execstr = token(execstr, var, NVSIZE + 1); } /* check the legality and find the var */ findvar(var, &vd, NVSIZE + 1); /* if its not legal....bitch */ if (vd.v_type == -1) { mlwrite("%%No such variable as '%s'", var); return FALSE; } /* get the value for that variable */ if (f == TRUE) strcpy(value, itoa(n)); else { status = mlreply("Value: ", &value[0], NSTRING); if (status != TRUE) return status; } /* and set the appropriate value */ status = svar(&vd, value); #if DEBUGM /* if $debug == TRUE, every assignment will echo a statment to that effect here. */ if (macbug) { strcpy(outline, "((("); /* assignment status */ strcat(outline, ltos(status)); strcat(outline, ":"); /* variable name */ strcat(outline, var); strcat(outline, ":"); /* and lastly the value we tried to assign */ strcat(outline, value); strcat(outline, ")))"); /* expand '%' to "%%" so mlwrite wont bitch */ sp = outline; while (*sp) if (*sp++ == '%') { /* advance to the end */ ep = --sp; while (*ep++); /* null terminate the string one out */ *(ep + 1) = 0; /* copy backwards */ while (ep-- > sp) *(ep + 1) = *ep; /* and advance sp past the new % */ sp += 2; } /* write out the debug line */ mlforce(outline); update(TRUE); /* and get the keystroke to hold the output */ if (get1key() == abortc) { mlforce("(Macro aborted)"); status = FALSE; } } #endif /* and return it */ return status; }