void AllowedLookupsResolver::requestValueResolution( const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int> &roles )
{
	Q_ASSERT( topLeft.row() == bottomRight.row() );

	// We need to attempt to resolve the ownership information only if the property value was changed.
	bool filterChanged = roles.size() == 0;
	foreach( int role, roles )
	{
		if( role == PropertyValueListModel::FilterRole )
			filterChanged = true;
	}
	if( ! filterChanged )
		return;  // Other than changes to the property value do not affect ownership information.

	// Fetch the current value and abort resolution if the property isn't lookup.
	MFiles::PropertyValue currentValue( m_model->data( topLeft, PropertyValueListModel::PropertyValueRole ).toJsonValue() );
	if( currentValue.typedValue().dataType() != MFiles::Constants::MultiSelectLookup &&
		currentValue.typedValue().dataType() != MFiles::Constants::SingleSelectLookup  )
		return;

	// Fetch the allowed values using the new filter.
	AsyncFetch* fetchAllowed = this->fetchAllowedItems( topLeft, currentValue.value() );

	// Resolve the validity.
	QObject::connect( fetchAllowed, &AsyncFetch::finished, [=]() mutable {
		fetchAllowed->deleteLater();

		QJsonArray values = fetchAllowed->values();
		this->resolveValidity( values, topLeft, currentValue.value() );
	} );
}
Exemplo n.º 2
0
bool 
Reader::decodeDouble( Token &token )
{
   double value = 0;
   const int bufferSize = 32;
   int count;
   int length = int(token.end_ - token.start_);
   if ( length <= bufferSize )
   {
      Char buffer[bufferSize];
      memcpy( buffer, token.start_, length );
      buffer[length] = 0;
      count = sscanf( buffer, "%lf", &value );
   }
   else
   {
      std::string buffer( token.start_, token.end_ );
      count = sscanf( buffer.c_str(), "%lf", &value );
   }

   if ( count != 1 )
      return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
   currentValue() = value;
   return true;
}
Exemplo n.º 3
0
  bool 
  Reader::readObject ()
  {
    Token tokenName;
    std::string name;
    currentValue () = Value (objectValue);
    while (readToken (tokenName))
      {
	if (tokenName.type_ == tokenObjectEnd && name.empty ())  // empty object
	  return true;
	if (tokenName.type_ != tokenString)
	  break;
      
	name = "";
	if (!decodeString (tokenName, name))
	  return recoverFromError (tokenObjectEnd);

	Token colon;
	if (!readToken (colon) ||  colon.type_ != tokenMemberSeparator)
	  {
	    return addErrorAndRecover ("Missing ':' after object member name", 
				       colon, 
				       tokenObjectEnd);
	  }
	Value &value = currentValue ()[ name ];
	nodes_.push (&value);
	bool ok = readValue ();
	nodes_.pop ();
	if (!ok) // error already set
	  return recoverFromError (tokenObjectEnd);

	Token comma;
	if (!readToken (comma)
	     ||   (comma.type_ != tokenObjectEnd && 
		   comma.type_ != tokenArraySeparator))
	  {
	    return addErrorAndRecover ("Missing ',' or '}' in object declaration", 
				       comma, 
				       tokenObjectEnd);
	  }
	if (comma.type_ == tokenObjectEnd)
	  return true;
      }
    return addErrorAndRecover ("Missing '}' or object member name", 
			       tokenName, 
			       tokenObjectEnd);
  }
Exemplo n.º 4
0
void VariablesEditor::lvValues_selectionModel_selectionChanged()
{
    const QModelIndex variableIndex = currentVariable();
    const QModelIndex valueIndex = currentValue();
    const int count = mModel->rowCount( variableIndex );
    ui->tbValuesEdit->setEnabled( valueIndex.isValid() );
    ui->tbValuesClear->setEnabled( variableIndex.isValid() && count > 0 );
}
Exemplo n.º 5
0
void Worker::slotNextValue()
{
    emit currentValue(--m_nValue);
  
    if (!m_nValue)
    { 
      //emit finished(); 
    }
}
bool 
Reader::decodeString( Token &token )
{
   std::string decoded;
   if ( !decodeString( token, decoded ) )
      return false;
   currentValue() = decoded;
   return true;
}
Exemplo n.º 7
0
char
CaseValue::lireValeur(void) const {
	// Lire la premièrelettre de l'entrée
	wxString currentValue(GetLineText(0));
	std::string s(currentValue.ToStdString());
	// Si la taille est nulle, retourner un point
	if( s.size()==0 ) return '.';
	// Sinon retourner la valeur en tant que caractère
	return s.at(0);
}
Exemplo n.º 8
0
void SVGAnimatedAngle::synchronizeAttribute()
{
    AtomicString value;
    if (m_orientType->currentValue()->enumValue() == SVGMarkerOrientAuto)
        value = "auto";
    else
        value = AtomicString(currentValue()->valueAsString());

    contextElement()->setSynchronizedLazyAttribute(attributeName(), value);
}
Exemplo n.º 9
0
void SVGAnimatedAngle::synchronizeAttribute()
{
    DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto", AtomicString::ConstructFromLiteral));
    AtomicString value;
    if (m_orientType->currentValue()->enumValue() == SVGMarkerOrientAuto)
        value = autoValue;
    else
        value = AtomicString(currentValue()->valueAsString());

    contextElement()->setSynchronizedLazyAttribute(attributeName(), value);
}
Exemplo n.º 10
0
static JSValue getNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
{
    JSValue currentValue(rootValue);
    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; i++) {
        JSValue parentValue(currentValue);
        if (!get(exec, parentValue, keyPathElements[i], currentValue))
            return jsUndefined();
    }
    return currentValue;
}
Exemplo n.º 11
0
bool 
Reader::readArray( Token &/*tokenStart*/ )
{
   currentValue() = Value( arrayValue );
   skipSpaces();
   if ( *current_ == ']' ) // empty array
   {
      Token endArray;
      readToken( endArray );
      return true;
   }
   int index = 0;
   for (;;)
   {
      Value &value = currentValue()[ index++ ];
      nodes_.push( &value );
      bool ok = readValue();
      nodes_.pop();
      if ( !ok ) // error already set
         return recoverFromError( tokenArrayEnd );

      Token token;
      // Accept Comment after last item in the array.
      ok = readToken( token );
      while ( token.type_ == tokenComment  &&  ok )
      {
         ok = readToken( token );
      }
      bool badTokenType = ( token.type_ != tokenArraySeparator  &&
                            token.type_ != tokenArrayEnd );
      if ( !ok  ||  badTokenType )
      {
         return addErrorAndRecover( "Missing ',' or ']' in array declaration", 
                                    token, 
                                    tokenArrayEnd );
      }
      if ( token.type_ == tokenArrayEnd )
         break;
   }
   return true;
}
Exemplo n.º 12
0
long unsigned int findOptimalAmount(short int factor2,short int factor3)
{ unsigned int n = currentValue(factor2,factor3);
  if(n < 12)
  { costArray[factor2][factor3] = n;
    return (long unsigned int)n;
  }
  else
  { if(costArray[factor2][factor3] == 0)
      costArray[factor2][factor3] = (findOptimalAmount(factor2+1,factor3) + findOptimalAmount(factor2,factor3+1) + findOptimalAmount(factor2+2,factor3));
    return costArray[factor2][factor3];
  }
}
Exemplo n.º 13
0
bool QNumberStyleAnimation::isUpdateNeeded() const
{
    if (QStyleAnimation::isUpdateNeeded()) {
        qreal current = currentValue();
        if (!qFuzzyCompare(_prev, current))
        {
            _prev = current;
            return true;
        }
    }
    return false;
}
Exemplo n.º 14
0
static v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index, v8::Isolate* isolate)
{
    v8::Handle<v8::Value> currentValue(rootValue);
    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; ++i) {
        v8::Handle<v8::Value> parentValue(currentValue);
        if (!get(parentValue, keyPathElements[i], currentValue, isolate))
            return v8Undefined();
    }

    return currentValue;
}
Exemplo n.º 15
0
  bool
  Reader::readValue ()
  {
    Token token;
    do
      readToken (token);
    while (token.type_ == tokenComment);
    bool successful = true;

    switch (token.type_)
      {
      case tokenObjectBegin:
	successful = readObject ();
	break;
      case tokenArrayBegin:
	successful = readArray ();
	break;
      case tokenNumber:
	successful = decodeNumber (token);
	break;
      case tokenString:
	successful = decodeString (token);
	break;
      case tokenTrue:
	currentValue () = true;
	break;
      case tokenFalse:
	currentValue () = false;
	break;
      case tokenNull:
	currentValue () = Value ();
	break;
      default:
	return addError ("Syntax error: value, object or array expected.", token);
      }

    return successful;
  }
Exemplo n.º 16
0
void MyThread::slotNextValue()
{
  QString str;
  m_nValue--;
  if (!m_nValue)
  {   
   emit finished(); 
  }
   
  str = "TEST message: this is a test message without any parameters.";
  emit currentValue(str);
  emit currentNumValue(m_nValue);
  emit pushTheButton();
}
Exemplo n.º 17
0
bool 
Reader::decodeNumber( Token &token )
{
   bool isDouble = false;
   for ( Location inspect = token.start_; inspect != token.end_; ++inspect )
   {
      isDouble = isDouble  
                 ||  in( *inspect, '.', 'e', 'E', '+' )  
                 ||  ( *inspect == '-'  &&  inspect != token.start_ );
   }
   if ( isDouble )
      return decodeDouble( token );
   Location current = token.start_;
   bool isNegative = *current == '-';
   if ( isNegative )
      ++current;
   Value::UInt threshold = (isNegative ? Value::UInt(-Value::minInt) 
                                       : Value::maxUInt) / 10;
   Value::UInt value = 0;
   while ( current < token.end_ )
   {
      Char c = *current++;
      if ( c < '0'  ||  c > '9' )
         return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
      if ( value >= threshold )
         return decodeDouble( token );
      value = value * 10 + Value::UInt(c - '0');
   }
   if ( isNegative )
      currentValue() = -Value::Int( value );
   else if ( value <= Value::UInt(Value::maxInt) )
      currentValue() = Value::Int( value );
   else
      currentValue() = value;
   return true;
}
bool OnOffLightService::processRequest(uint16_t requestType, XBeeAddress from, uint8_t* payload, uint8_t payload_length) {
	switch (requestType) {
	case 0x0001: { //is on?
#ifdef DEBUG_ASRVS
		Serial.println("Request for current status");
#endif
		uint8_t value = currentValue() ? 0x01 : 0x00;
		uint8_t data[] = { 0, 0, 0, 0, value };
		fillResponseHeader(data, requestType);
		_sender->send(from, data, 5);
		return true;
	}
	default: return false;
	}
}
Exemplo n.º 19
0
bool ScriptNode::makeDatum(std::string n, PyTypeObject* type,
                           std::string value, bool output)
{
    for (auto a : script.active)
        if (a->name == n)
            return false;

    // If there's an existing datum and it's of the wrong type, delete it.
    auto d = getDatum(n);
    if (d != NULL && (d->type != type))
    {
        datums.remove_if([&](const std::unique_ptr<Datum>& d_)
                         { return d_.get() == d; });
        d = NULL;
    }

    if (d == NULL)
    {
        d = new Datum(n, value, type, this);
        assert(d->isValid());
    }
    else
    {
        // Move the existing datum to the end of the list
        // (so that ordering matches ordering in the script)
        for (auto itr = datums.begin(); itr != datums.end(); ++itr)
            if (itr->get() == d)
            {
                datums.splice(datums.end(), datums, itr);
                break;
            }

        // If the datum is an output, update its expression
        if (output)
            d->setText(value);
        // Otherwise, erase the output sigil by setting the text
        else if (d->isOutput())
            d->setText(value);
    }

    script.active.insert(d);

    // Inject this variable into the script's namespace
    script.inject(n.c_str(), d->currentValue());
    saveLookup(n, &script);

    return true;
}
Exemplo n.º 20
0
static bool canInjectNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
{
    if (!rootValue.isObject())
        return false;

    JSValue currentValue(rootValue);

    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; ++i) {
        JSValue parentValue(currentValue);
        const String& keyPathElement = keyPathElements[i];
        if (!get(exec, parentValue, keyPathElement, currentValue))
            return canSet(parentValue, keyPathElement);
    }
    return true;
}
Exemplo n.º 21
0
static bool canInjectNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index, v8::Isolate* isolate)
{
    if (!rootValue->IsObject())
        return false;

    v8::Handle<v8::Value> currentValue(rootValue);

    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; ++i) {
        v8::Handle<v8::Value> parentValue(currentValue);
        const String& keyPathElement = keyPathElements[i];
        if (!get(parentValue, keyPathElement, currentValue, isolate))
            return canSet(parentValue, keyPathElement);
    }
    return true;
}
Exemplo n.º 22
0
bool Beats::detected()
{
	bool beatDetected = false;
	
	if (	currentValue() > midPoint()
		&&	lastValue() < midPoint()
		&&	currentDerivative() > derivativeMidPoint()
		&&	currentDerivative() > derivativeLimit
		&&	beatCanTrigger())
	{
		beatDetected = true;
		iterationCounter = 1;
	}
	
	return beatDetected;
}
Exemplo n.º 23
0
static JSValue ensureNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
{
    JSValue currentValue(rootValue);

    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; i++) {
        JSValue parentValue(currentValue);
        const String& keyPathElement = keyPathElements[i];
        if (!get(exec, parentValue, keyPathElement, currentValue)) {
            JSObject* object = constructEmptyObject(exec);
            if (!set(exec, parentValue, keyPathElement, JSValue(object)))
                return jsUndefined();
            currentValue = JSValue(object);
        }
    }

    return currentValue;
}
Exemplo n.º 24
0
static v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index, v8::Isolate* isolate)
{
    v8::Handle<v8::Value> currentValue(rootValue);

    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; ++i) {
        v8::Handle<v8::Value> parentValue(currentValue);
        const String& keyPathElement = keyPathElements[i];
        if (!get(parentValue, keyPathElement, currentValue, isolate)) {
            v8::Handle<v8::Object> object = v8::Object::New();
            if (!set(parentValue, keyPathElement, object, isolate))
                return v8Undefined();
            currentValue = object;
        }
    }

    return currentValue;
}
Exemplo n.º 25
0
void AlDatabase::read()
{
  for (;;) {
    const char *key = currentKey();
    if (strcmp(key, "begin")==0) {
      const char *value = currentValue();
      if (strcmp(value, "MemoryMap")==0) {
        gMemoryMap.readBlock(*this);
      } else {
        printErrValue();
      }
    } else {
      printErrKey();
    }
    if (!readNext())
      return;
  }
}
Exemplo n.º 26
0
void VariablesEditor::on_tbValuesEdit_triggered( QAction* action )
{
    const QModelIndex variableIndex = currentVariable();
    const QModelIndex valueIndex = currentValue();

    if ( !variableIndex.isValid() || !valueIndex.isValid() ) {
        return;
    }

    const QString title = tr( "Edit a value..." );
    bool ok = true;
    QString value = valueIndex.data( Qt::DisplayRole ).toString();

    if ( action == aValuesEditValue ) {
        value = QInputDialog::getText( QApplication::activeWindow(), title, tr( "Edit the value :" ), QLineEdit::Normal, value, &ok );

        if ( !ok ) {
            value.clear();
        }
    }
    else {
        value = mProject->filePath( value );

        if ( action == aValuesEditFile ) {
            value = QFileDialog::getOpenFileName( QApplication::activeWindow(), tr( "Choose a file" ), value );
        }
        else if ( action == aValuesEditPath ) {
            value = QFileDialog::getExistingDirectory( QApplication::activeWindow(), tr( "Choose a path" ), value );
        }

        if ( !value.isEmpty() ) {
            value = mProject->relativeFilePath( value );
        }
    }

    if ( value.isEmpty() || !ok ) {
        return;
    }

    if ( !mModel->setData( valueIndex, value, Qt::DisplayRole ) ) {
        QMessageBox::information( QApplication::activeWindow(), tr( "Information..." ), tr( "This value already exists." ) );
    }
}
int ProgressStatus::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = app(); break;
        case 1: *reinterpret_cast< int*>(_v) = currentValue(); break;
        case 2: *reinterpret_cast< int*>(_v) = endValue(); break;
        case 3: *reinterpret_cast< QString*>(_v) = error(); break;
        case 4: *reinterpret_cast< QString*>(_v) = item(); break;
        case 5: *reinterpret_cast< QString*>(_v) = operation(); break;
        case 6: *reinterpret_cast< QString*>(_v) = units(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 28
0
char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType type, 
                                         DataArrayList **dataArrayList ) {
    if ( ddl_nullptr == dataArrayList ) {
        return in;
    }

    *dataArrayList = ddl_nullptr;
    if( ddl_nullptr == in || in == end ) {
        return in;
    }

    in = lookForNextToken( in, end );
    if( *in == Grammar::OpenBracketToken[ 0 ] ) {
        ++in;
        Value *currentValue( ddl_nullptr );
        Reference *refs( ddl_nullptr );
        DataArrayList *prev( ddl_nullptr ), *currentDataList( ddl_nullptr );
        do {
            size_t numRefs( 0 ), numValues( 0 );
            currentValue = ddl_nullptr;

            in = parseDataList( in, end, type, &currentValue, numValues, &refs, numRefs );
            if( ddl_nullptr != currentValue || 0 != numRefs ) {
                if( ddl_nullptr == prev ) {
                    *dataArrayList = createDataArrayList( currentValue, numValues, refs, numRefs );
                    prev = *dataArrayList;
                } else {
                    currentDataList = createDataArrayList( currentValue, numValues, refs, numRefs );
                    if( ddl_nullptr != prev ) {
                        prev->m_next = currentDataList;
                        prev = currentDataList;
                    }
                }
            }
        } while( Grammar::CommaSeparator[ 0 ] == *in && in != end );
        in = lookForNextToken( in, end );
        ++in;
    }

    return in;
}
Exemplo n.º 29
0
bool 
Reader::decodeDouble( Token &token )
{
   double value = 0;
   const int bufferSize = 32;
   int count;
   int length = int(token.end_ - token.start_);

   // Sanity check to avoid buffer overflow exploits.
   if (length < 0) {
      return addError( "Unable to parse token length", token );
   }

   // Avoid using a string constant for the format control string given to
   // sscanf, as this can cause hard to debug crashes on OS X. See here for more
   // info:
   //
   //     http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
   char format[] = "%lf";

   if ( length <= bufferSize )
   {
      Char buffer[bufferSize+1];
      memcpy( buffer, token.start_, length );
      buffer[length] = 0;
      count = sscanf( buffer, format, &value );
   }
   else
   {
      std::string buffer( token.start_, token.end_ );
      count = sscanf( buffer.c_str(), format, &value );
   }

   if ( count != 1 )
      return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
   currentValue() = value;
   return true;
}
Exemplo n.º 30
0
Buddy SelectBuddyComboBox::currentBuddy()
{
	return currentValue();
}