Ejemplo n.º 1
0
void QStaticFileReader::staticLoad(const QString &file, const QJSValue &params){
    bool monitor = false;
    if ( params.isObject() ){
        if ( params.hasOwnProperty("monitor") ){
            monitor = params.property("monitor").toBool();
        }
    }

    if ( m_reader )
        disconnect(m_reader, SIGNAL(dataChanged(QByteArray)), this, SLOT(readerDataChanged(QByteArray)));

    QStaticContainer* container = QStaticContainer::grabFromContext(this);
    m_reader = container->get<QFileReader>(file);

    if ( !m_reader ){
        m_reader = new QFileReader();
        m_reader->setSource(file);
        m_reader->componentComplete();
        container->set<QFileReader>(file, m_reader);
        connect(m_reader, SIGNAL(dataChanged(QByteArray)), this, SLOT(readerDataChanged(QByteArray)));
    }

    m_data = m_reader->data();
    emit dataChanged(m_data);

    m_reader->setMonitor(monitor);
}