bool Renderer::ConditionSingle::eval( const NifModel * nif, const QList<QModelIndex> & iBlocks ) const { QModelIndex iLeft = getIndex( nif, iBlocks, left ); if ( ! iLeft.isValid() ) return invert; if ( comp == NONE ) return ! invert; NifValue val = nif->getValue( iLeft ); if ( val.isString() ) return compare( val.toString(), right ) ^ invert; else if ( val.isCount() ) return compare( val.toCount(), right.toUInt(NULL, 0) ) ^ invert; else if ( val.isFloat() ) return compare( val.toFloat(), (float) right.toDouble() ) ^ invert; else if ( val.isFileVersion() ) return compare( val.toFileVersion(), right.toUInt(NULL, 0) ) ^ invert; return false; }
void ValueEdit::setValue( const NifValue & v ) { typ = v.type(); if ( edit ) { // segfaults with Qt 4.5: //delete edit; edit = 0; resize( this->baseSize() ); } switch ( typ ) { case NifValue::tByte: { QSpinBox * be = new QSpinBox( this ); be->setFrame(false); be->setRange( 0, 0xff ); be->setValue( v.toCount() ); edit = be; } break; case NifValue::tWord: case NifValue::tFlags: { QSpinBox * we = new QSpinBox( this ); we->setFrame(false); we->setRange( 0, 0xffff ); we->setValue( v.toCount() ); edit = we; } break; case NifValue::tShort: { QSpinBox * we = new QSpinBox( this ); we->setFrame(false); we->setRange( SHRT_MIN, SHRT_MAX ); we->setValue( (short)v.toCount() ); edit = we; } break; case NifValue::tInt: { QSpinBox * ie = new QSpinBox( this ); ie->setFrame(false); ie->setRange( INT_MIN, INT_MAX ); ie->setValue( (int)v.toCount() ); edit = ie; } break; case NifValue::tStringIndex: { QSpinBox * ie = new QSpinBox( this ); ie->setFrame(false); ie->setRange( -1, INT_MAX ); ie->setValue( (int)v.toCount() ); edit = ie; } break; case NifValue::tUInt: { QSpinBox * ie = new UIntSpinBox( this ); ie->setFrame(false); ie->setValue( v.toCount() ); edit = ie; } break; case NifValue::tLink: case NifValue::tUpLink: { QLineEdit * le = new QLineEdit( this ); int tmp = v.toLink(); if ( tmp > 0 ) { le->setText( QString::number(tmp) ); } edit = le; } break; case NifValue::tFloat: { FloatEdit * fe = new FloatEdit( this ); /* fe->setFrame(false); fe->setRange( -1e10, +1e10 ); fe->setDecimals( 4 ); */ fe->setValue( v.toFloat() ); edit = fe; } break; case NifValue::tText: case NifValue::tSizedString: { TextEdit * te = new TextEdit( v.toString(), this ); te->resize( size() ); connect( te, SIGNAL( sigResized(QResizeEvent *) ), this, SLOT( childResized(QResizeEvent *) ) ); edit = te; } break; case NifValue::tLineString: case NifValue::tShortString: case NifValue::tChar8String: { QLineEdit * le = new QLineEdit( this ); le->setText( v.toString() ); edit = le; } break; //case NifValue::tText: //{ // TextEdit * te = new TextEdit( v.toString(), this ); // te->setMinimumSize( width(), height() ); // te->setBaseSize( width(), height() * 5); // edit = te; //} break; case NifValue::tColor4: { ColorEdit * ce = new ColorEdit( this ); ce->setColor4( v.get<Color4>() ); edit = ce; } break; case NifValue::tColor3: { ColorEdit * ce = new ColorEdit( this ); ce->setColor3( v.get<Color3>() ); edit = ce; } break; case NifValue::tVector4: { VectorEdit * ve = new VectorEdit( this ); ve->setVector4( v.get<Vector4>() ); edit = ve; } break; case NifValue::tVector3: { VectorEdit * ve = new VectorEdit( this ); ve->setVector3( v.get<Vector3>() ); edit = ve; } break; case NifValue::tVector2: { VectorEdit * ve = new VectorEdit( this ); ve->setVector2( v.get<Vector2>() ); edit = ve; } break; case NifValue::tMatrix: { RotationEdit * re = new RotationEdit( this ); re->setMatrix( v.get<Matrix>() ); edit = re; } break; case NifValue::tQuat: case NifValue::tQuatXYZW: { RotationEdit * re = new RotationEdit( this ); re->setQuat( v.get<Quat>() ); edit = re; } break; case NifValue::tTriangle: { TriangleEdit * te = new TriangleEdit( this ); te->setTriangle( v.get<Triangle>() ); edit = te; } break; case NifValue::tString: { if (/*???*/false) { QSpinBox * ie = new UIntSpinBox( this ); ie->setFrame(false); ie->setValue( v.toCount() ); edit = ie; } else { QLineEdit * le = new QLineEdit( this ); le->setText( v.toString() ); edit = le; } } break; case NifValue::tFilePath: { if (/*???*/false) { QSpinBox * ie = new UIntSpinBox( this ); ie->setFrame(false); ie->setValue( v.toCount() ); edit = ie; } else { QLineEdit * le = new QLineEdit( this ); le->setText( v.toString() ); edit = le; } } break; default: edit = 0; break; } resizeEditor(); setFocusProxy( edit ); }