コード例 #1
0
ファイル: eveVariant.cpp プロジェクト: eveCSS/eveEngine
eveVariant eveVariant::operator- (const eveVariant& other){
	eveVariant result;

	if (varianttype == eveDOUBLE){
		result.setType(eveDOUBLE);
		result.setValue(toDouble() - other.toDouble());
	}
	else if (varianttype == eveINT){
		result.setType(eveINT);
		result.setValue(toInt() - other.toInt());
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveDateTimeT)){
		result.setType(eveDateTimeT);
		int relativeMSecs = other.toTime().msecsTo(QTime());
		result.setValue(toDateTime().addMSecs((qint64)relativeMSecs));
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveDOUBLE)){
		result.setType(eveDateTimeT);
		result.setValue(toDateTime().addMSecs((qint64)(-1000.0 * other.toDouble())));
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveINT)){
		result.setType(eveDateTimeT);
		result.setValue(toDateTime().addSecs(-1 * other.toInt()));
	}
	return result;
}
コード例 #2
0
ファイル: eveVariant.cpp プロジェクト: eveCSS/eveEngine
eveVariant eveVariant::operator+ (const eveVariant& other){
	eveVariant result;

	if (varianttype == eveDOUBLE){
		result.setType(eveDOUBLE);
		result.setValue(toDouble() + other.toDouble());
	}
	else if (varianttype == eveINT){
		result.setType(eveINT);
		result.setValue(toInt() + other.toInt());
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveDateTimeT)){
		// we assume other is a relative time without date
		result.setType(eveDateTimeT);
		int relativeMSecs = -1 * other.toTime().msecsTo(QTime());
		result.setValue(toDateTime().addMSecs((qint64)relativeMSecs));
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveDOUBLE)){
		result.setType(eveDateTimeT);
		result.setValue(toDateTime().addMSecs((qint64)(1000.0 * other.toDouble())));
	}
	else if ((varianttype == eveDateTimeT) && (other.getType() == eveINT)){
		result.setType(eveDateTimeT);
		result.setValue(toDateTime().addSecs(other.toInt()));
	}
	return result;
}
コード例 #3
0
/*!
   \brief Calculate a scale division for a date/time interval

   \param x1 First interval limit
   \param x2 Second interval limit
   \param maxMajorSteps Maximum for the number of major steps
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.
   \return Calculated scale division
*/
QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
{
    if ( maxMajorSteps < 1 )
        maxMajorSteps = 1;

    const double min = qMin( x1, x2 );
    const double max = qMax( x1, x2 );

    const QDateTime from = toDateTime( min );
    const QDateTime to = toDateTime( max );

    if ( from == to )
        return QwtScaleDiv();

    stepSize = qAbs( stepSize );
    if ( stepSize > 0.0 )
    {
        // as interval types above hours are not equidistant
        // ( even days might have 23/25 hours because of daylight saving )
        // the stepSize is used as a hint only

        maxMajorSteps = qCeil( ( max - min ) / stepSize );
    }

    const QwtDate::IntervalType intvType = 
        intervalType( from, to, maxMajorSteps );

    QwtScaleDiv scaleDiv;

    if ( intvType == QwtDate::Millisecond )
    {
        // for milliseconds and below we can use the decimal system
        scaleDiv = QwtLinearScaleEngine::divideScale( min, max,
            maxMajorSteps, maxMinorSteps, stepSize );
    }
    else
    {
        const QDateTime minDate = QwtDate::floor( from, intvType );
        const QDateTime maxDate = QwtDate::ceil( to, intvType );

        scaleDiv = buildScaleDiv( minDate, maxDate, 
            maxMajorSteps, maxMinorSteps, intvType );

        // scaleDiv has been calculated from an extended interval
        // adjusted to the step size. We have to shrink it again.

        scaleDiv = scaleDiv.bounded( min, max );
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}
コード例 #4
0
/*!
  Align and divide an interval

  The algorithm aligns and divides the interval into steps. 

  Datetime interval divisions are usually not equidistant and the
  calculated stepSize can only be used as an approximation
  for the steps calculated by divideScale(). 

  \param maxNumSteps Max. number of steps
  \param x1 First limit of the interval (In/Out)
  \param x2 Second limit of the interval (In/Out)
  \param stepSize Step size (Out)

  \sa QwtScaleEngine::setAttribute()
*/
void QwtDateScaleEngine::autoScale( int maxNumSteps,
    double &x1, double &x2, double &stepSize ) const
{
    stepSize = 0.0;

    QwtInterval interval( x1, x2 );
    interval = interval.normalized();

    interval.setMinValue( interval.minValue() - lowerMargin() );
    interval.setMaxValue( interval.maxValue() + upperMargin() );

    if ( testAttribute( QwtScaleEngine::Symmetric ) )
        interval = interval.symmetrize( reference() );

    if ( testAttribute( QwtScaleEngine::IncludeReference ) )
        interval = interval.extend( reference() );

    if ( interval.width() == 0.0 )
        interval = buildInterval( interval.minValue() );

    const QDateTime from = toDateTime( interval.minValue() );
    const QDateTime to = toDateTime( interval.maxValue() );

    if ( from.isValid() && to.isValid() )
    {
        if ( maxNumSteps < 1 )
            maxNumSteps = 1;

        const QwtDate::IntervalType intvType = 
            intervalType( from, to, maxNumSteps );

        const double width = qwtIntervalWidth( from, to, intvType );

        const double stepWidth = qwtDivideScale( width, maxNumSteps, intvType );
        if ( stepWidth != 0.0 && !testAttribute( QwtScaleEngine::Floating ) )
        {
            const QDateTime d1 = alignDate( from, stepWidth, intvType, false );
            const QDateTime d2 = alignDate( to, stepWidth, intvType, true );

            interval.setMinValue( QwtDate::toDouble( d1 ) );
            interval.setMaxValue( QwtDate::toDouble( d2 ) );
        }

        stepSize = stepWidth * qwtMsecsForType( intvType );
    }

    x1 = interval.minValue();
    x2 = interval.maxValue();

    if ( testAttribute( QwtScaleEngine::Inverted ) )
    {
        qSwap( x1, x2 );
        stepSize = -stepSize;
    }
}
コード例 #5
0
 FileInfo RunManager_Util::dirFile(QFileInfo fi) 
 {
   fi.refresh();
   return FileInfo(toString(fi.fileName()),
       (fi.exists()&&fi.lastModified().isValid())?toDateTime(fi.lastModified()):openstudio::DateTime(),
       toString(fi.fileName()), /* The default key is the filename */
       toPath(fi.absoluteFilePath()),
       fi.exists());
 }
コード例 #6
0
ファイル: FileReference.cpp プロジェクト: whztt07/OpenStudio
bool FileReference::update(const openstudio::path& searchDirectory,bool lastOnly) {
    makePathAbsolute(searchDirectory);
    openstudio::path p = path();
    if (boost::filesystem::exists(p)) {
        QFileInfo fileInfo(toQString(p));
        OS_ASSERT(fileInfo.exists());

        if (!lastOnly) {
            m_timestampCreate = toDateTime(fileInfo.created());
        }

        m_timestampLast = toDateTime(fileInfo.lastModified());
        m_checksumLast = checksum(p);
        m_versionUUID = createUUID();
        return true;
    }
    return false;
}
コード例 #7
0
ファイル: eveVariant.cpp プロジェクト: eveCSS/eveEngine
bool eveVariant::operator< (const eveVariant& other){

	if (varianttype == eveDOUBLE){
		if (toDouble() < other.toDouble()) return true;
	}
	else if (varianttype == eveINT){
		if (toInt() < other.toInt()) return true;
	}
	else if (varianttype == eveDateTimeT){
		if (toDateTime() < other.toDateTime()) return true;
	}
	return false;
}
コード例 #8
0
QVariant QScriptValueImpl::toVariant() const
{
    switch (m_type) {
    case QScript::InvalidType:
        return QVariant();

    case QScript::UndefinedType:
    case QScript::NullType:
    case QScript::PointerType:
    case QScript::ReferenceType:
        break;

    case QScript::BooleanType:
        return QVariant(m_bool_value);

    case QScript::IntegerType:
        return QVariant(m_int_value);

    case QScript::NumberType:
        return QVariant(m_number_value);

    case QScript::StringType:
        return QVariant(m_string_value->s);

    case QScript::LazyStringType:
        return QVariant(*m_lazy_string_value);

    case QScript::ObjectType:
        if (isDate())
            return QVariant(toDateTime());

#ifndef QT_NO_REGEXP
        if (isRegExp())
            return QVariant(toRegExp());
#endif
        if (isVariant())
            return variantValue();

#ifndef QT_NO_QOBJECT
        if (isQObject())        
            return qVariantFromValue(toQObject());
#endif

        QScriptValueImpl v = engine()->toPrimitive(*this);
        if (!v.isObject())
            return v.toVariant();
        break;
    } // switch
    return QVariant();
}
コード例 #9
0
ファイル: xmlparser.cpp プロジェクト: colgur/qtwitter
bool XmlParserDirectMsg::characters( const QString &ch )
{
    if ( important ) {
        if (parsingSender)
            parseUserInfo(ch);
        else {
            if ( currentTag == TAG_STATUS_ID && entry.id == Q_UINT64_C(0) ) {
                entry.id = ch.toULongLong();
            } else if ( currentTag == TAG_USER_TEXT && entry.text.isNull() ) {
                entry.originalText = ch;
                entry.text = textToHtml( ch );
            } else if ( currentTag == TAG_USER_TIMESTAMP && entry.timestamp.isNull() ) {
                entry.timestamp = toDateTime( ch );
                entry.localTime = entry.timestamp.addSecs( timeShift );
            }
        }
    }
    return true;
}
コード例 #10
0
ファイル: xmlparser.cpp プロジェクト: colgur/qtwitter
bool XmlParser::characters( const QString &ch )
{
    if ( important ) {
        if ( parsingUser ) {
            parseUserInfo(ch);
        } else {
            if ( currentTag == TAG_STATUS_ID && entry.id == Q_UINT64_C(0) ) {
                entry.id = ch.toULongLong();
            } else if ( currentTag == TAG_USER_TEXT && entry.text.isNull() ) {
                entry.originalText = ch;
                entry.originalText.replace( "&lt;", "<" );
                entry.originalText.replace( "&gt;", ">" );
                entry.text = textToHtml( entry.originalText );
            } else if ( currentTag == TAG_USER_TIMESTAMP && entry.timestamp.isNull() ) {
                entry.timestamp = toDateTime( ch ); //utc
                /* It's better to leave UTC timestamp alone; Additional member localTime is added to store local time when
         user's system supports timezones. */
                entry.localTime = entry.timestamp.addSecs( timeShift ); //now - utc
            } else if ( currentTag == TAG_INREPLYTO_STATUS_ID && entry.inReplyToStatusId == 0) {
                if( !ch.trimmed().isEmpty() ) {
                    /* In reply to status id exists and is not empty; Hack for dealing with tags that are opened and closed
           at the same time, e.g. <in_reply_to_screen_name/>  */
                    entry.hasInReplyToStatusId = true;
                    entry.inReplyToStatusId = ch.toULongLong();
                }
            } else if ( currentTag == TAG_INREPLYTO_SCREEN_NAME && entry.hasInReplyToStatusId ) {
                /* When hasInReplyToStatusId is true, inReplyToScreenName should be present, but it won't hurt to check it again
         just in case */
                if( !ch.trimmed().isEmpty() ) {
                    entry.inReplyToScreenName = ch;
                }
            } else if ( currentTag == TAG_FAVORITED && !favoritedSet ) {
                if ( ch.compare("false") == 0 )
                    entry.favorited = false;
                else
                    entry.favorited = true;
                favoritedSet = true;
            }
        }
    }

    return true;
}
コード例 #11
0
ファイル: FileSystemServiceImpl.cpp プロジェクト: xcodez/jsfs
PFileInfo CFileSystemServiceImpl::fileInfoFromWin32FindData(const wstring& dir, const WIN32_FIND_DATA& fd) {
	
	if (fd.cFileName[0] == '.') {
		if (fd.cFileName[1] == 0) return PFileInfo();
		if (fd.cFileName[1] == '.' && fd.cFileName[2] == 0) return PFileInfo();
	}

	FileInfo* fi = new FileInfo();
	fi->setName(dir + wstring(fd.cFileName));

	fi->setDirectory((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
	fi->setReadonly((fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0);
	//fi->setHidden((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0);

	LARGE_INTEGER sizeL;
	sizeL.LowPart = fd.nFileSizeLow;
	sizeL.HighPart = fd.nFileSizeHigh;
	fi->setSize(fd.nFileSizeHigh == 0 ? (int32_t)fd.nFileSizeLow : (-1)); // use fi.sizeL if fi.size < 0
	fi->setSizeL(sizeL.QuadPart);

	fi->setLastModified(toDateTime(fd.ftLastWriteTime));

	return PFileInfo(fi);
}
コード例 #12
0
// here we use DataTime instead of QT's built-in time conversion
// since the latter does not properly handle fractions of seconds
// in the ISO8601 specification.
QString Soprano::LiteralValue::toString() const
{
    if ( d ) {
        if ( !d->stringCacheValid ) {
            if( isInt() )
                d->stringCache = QString::number( toInt() );
            else if( isInt64() )
                d->stringCache = QString::number( toInt64() );
            else if( isUnsignedInt() )
                d->stringCache = QString::number( toUnsignedInt() );
            else if( isUnsignedInt64() )
                d->stringCache = QString::number( toUnsignedInt64() );
            else if( isBool() )
                d->stringCache = ( toBool() ? QString("true") : QString("false" ) );
            else if( isDouble() ) // FIXME: decide on a proper double encoding or check if there is one in xml schema
                d->stringCache = QString::number( toDouble(), 'e', 10 );
            else if( isDate() )
                d->stringCache = DateTime::toString( toDate() );
            else if( isTime() )
                d->stringCache = DateTime::toString( toTime() );
            else if( isDateTime() )
                d->stringCache = DateTime::toString( toDateTime() );
            else if ( isByteArray() )
                d->stringCache = QString::fromAscii( toByteArray().toBase64() );
            else
                d->stringCache = d->value.toString();

            d->stringCacheValid = true;
        }

        return d->stringCache;
    }
    else {
        return QString();
    }
}