Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4747#include <QtNetwork/QNetworkRequest>
    4848
    49 #include "qacceltreebuilder_p.h"
    5049#include "qatomicstring_p.h"
    5150#include "qautoptr_p.h"
     
    5857using namespace QPatternist;
    5958
    60 static inline uint qHash(const QUrl &uri)
    61 {
    62         return qHash(uri.toString());
    63 }
    64 
    6559AccelTreeResourceLoader::AccelTreeResourceLoader(const NamePool::Ptr &np,
    66                                                  const NetworkAccessDelegator::Ptr &manager) : m_namePool(np)
    67                                                                                              , m_networkAccessDelegator(manager)
     60                                                 const NetworkAccessDelegator::Ptr &manager,
     61                                                 AccelTreeBuilder<true>::Features features)
     62    : m_namePool(np)
     63    , m_networkAccessDelegator(manager)
     64    , m_features(features)
    6865{
    6966    Q_ASSERT(m_namePool);
     
    7572{
    7673    Q_ASSERT(uri.isValid());
    77     AccelTreeBuilder<true> builder(uri, uri, m_namePool, context.data());
     74    AccelTreeBuilder<true> builder(uri, uri, m_namePool, context.data(), m_features);
    7875
    7976    const AutoPtr<QNetworkReply> reply(load(uri, m_networkAccessDelegator, context));
     
    8986}
    9087
     88bool AccelTreeResourceLoader::retrieveDocument(QIODevice *source, const QUrl &documentUri, const ReportContext::Ptr &context)
     89{
     90    Q_ASSERT(source);
     91    Q_ASSERT(source->isReadable());
     92    Q_ASSERT(documentUri.isValid());
     93
     94    AccelTreeBuilder<true> builder(documentUri, documentUri, m_namePool, context.data(), m_features);
     95
     96    bool success = false;
     97    success = streamToReceiver(source, &builder, m_namePool, context, documentUri);
     98
     99    m_loadedDocuments.insert(documentUri, builder.builtDocument());
     100
     101    return success;
     102}
     103
    91104QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri,
    92105                                             const NetworkAccessDelegator::Ptr &networkDelegator,
    93                                              const ReportContext::Ptr &context)
     106                                             const ReportContext::Ptr &context, ErrorHandling errorHandling)
    94107{
    95108    return load(uri,
    96109                networkDelegator->managerFor(uri),
    97                 context);
     110                context, errorHandling);
    98111}
    99112
    100113QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri,
    101114                                             QNetworkAccessManager *const networkManager,
    102                                              const ReportContext::Ptr &context)
     115                                             const ReportContext::Ptr &context, ErrorHandling errorHandling)
     116
    103117{
    104118    Q_ASSERT(networkManager);
     
    112126    networkLoop.connect(reply, SIGNAL(finished()), SLOT(finished()));
    113127
    114     if(networkLoop.exec())
     128    if(networkLoop.exec(QEventLoop::ExcludeUserInputEvents))
    115129    {
    116130        const QString errorMessage(escape(reply->errorString()));
     
    121135        const QSourceLocation location(uri);
    122136
    123         if(context)
     137        if(context && (errorHandling == FailOnError))
    124138            context->error(errorMessage, ReportContext::FODC0002, location);
    125139
     
    131145
    132146bool AccelTreeResourceLoader::streamToReceiver(QIODevice *const dev,
    133                                                QAbstractXmlReceiver *const receiver,
     147                                               AccelTreeBuilder<true> *const receiver,
    134148                                               const NamePool::Ptr &np,
    135149                                               const ReportContext::Ptr &context,
     
    155169                /* Send the name. */
    156170                receiver->startElement(np->allocateQName(reader.namespaceUri().toString(), reader.name().toString(),
    157                                                          reader.prefix().toString()));
     171                                                         reader.prefix().toString()), reader.lineNumber(), reader.columnNumber());
    158172
    159173                /* Send namespace declarations. */
     
    259273        if(retrieveDocument(uri, context))
    260274            return m_loadedDocuments.value(uri)->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
     275        else
     276            return Item();
     277    }
     278}
     279
     280Item AccelTreeResourceLoader::openDocument(QIODevice *source, const QUrl &documentUri,
     281                                           const ReportContext::Ptr &context)
     282{
     283    const AccelTree::Ptr doc(m_loadedDocuments.value(documentUri));
     284
     285    if(doc)
     286        return doc->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
     287    else
     288    {
     289        if(retrieveDocument(source, documentUri, context))
     290            return m_loadedDocuments.value(documentUri)->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
    261291        else
    262292            return Item();
Note: See TracChangeset for help on using the changeset viewer.