当前位置: 首页>>代码示例>>C++>>正文


C++ QUrl::isEmpty方法代码示例

本文整理汇总了C++中QUrl::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::isEmpty方法的具体用法?C++ QUrl::isEmpty怎么用?C++ QUrl::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUrl的用法示例。


在下文中一共展示了QUrl::isEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
	// QTBUG-32789 - GUI widgets use the wrong font on OS X Mavericks
	QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
#endif

	SingleApplication theApp( argc, argv );

	if(!theApp.shouldContinue())return 0;

	QStringList args = theApp.arguments();

	QUrl proxy;
	int index = args.indexOf("-proxy");
	if ( index != -1 )
		proxy = QUrl( args.value(index + 1) );
	else
		proxy = QUrl( qgetenv( "http_proxy" ) );
	if ( !proxy.isEmpty() )
		setApplicationProxy( proxy );

	QByteArray encoding;
	index = args.indexOf( "-encoding" );
	if ( index != -1 )
		encoding = args.value( index + 1 ).toLocal8Bit();
	else if ( !qgetenv( "COMMUNI_ENCODING" ).isEmpty())
		encoding = qgetenv( "COMMUNI_ENCODING" );
	if ( !encoding.isEmpty() )
		SingleApplication::setEncoding( encoding );


// To enable this, run qmake with "DEFINES+=_SNAPSHOT_BUILD"
#ifdef _SNAPSHOT_BUILD
	QDate oExpire = QDate::fromString( Version::BUILD_DATE, Qt::ISODate ).addDays( 60 );

	if( QDate::currentDate() > oExpire )
	{
		QMessageBox::information( NULL,
								  QObject::tr( "Cool Software, but..." ),
								  QObject::tr( "This build is expired. If you wish to continue using this "
											   "Cool Software you must download either latest stable releas"
											   "e or latest snapshot build from http://quazaa.sf.net/.\n\n"
											   "The program will now terminate." ) );
		return 0;
	}

	if( !args.contains("--no-alpha-warning") )
	{
		int ret = QMessageBox::warning( NULL,
										QObject::tr("Snapshot/Debug Build Warning"),
										QObject::tr("WARNING: This is a SNAPSHOT BUILD of Quazaa. \n"
													"It is NOT meant for GENERAL USE, and is only for testi"
													"ng specific features in a controlled environment.\n"
													"It will frequently stop running, or will display debug"
													"information to assist testing.\n"
													"This build will expire on %1.\n\n"
													"Do you wish to continue?"
													).arg( oExpire.toString( Qt::SystemLocaleLongDate ) ),
									   QMessageBox::Yes | QMessageBox::No );
		if( ret == QMessageBox::No )
			return 0;
	}
#endif

	qsrand( time( 0 ) );

#ifdef Q_OS_LINUX

	rlimit sLimit;
	memset( &sLimit, 0, sizeof( rlimit ) );
	getrlimit( RLIMIT_NOFILE, &sLimit );

	sLimit.rlim_cur = sLimit.rlim_max;

	if( setrlimit( RLIMIT_NOFILE, &sLimit ) == 0 )
	{
		qDebug() << "Successfully raised resource limits";
	}
	else
	{
		qDebug() << "Cannot set resource limits";
	}

#endif // Q_OS_LINUX

	theApp.setApplicationName(    CQuazaaGlobals::APPLICATION_NAME() );
	theApp.setApplicationVersion( CQuazaaGlobals::APPLICATION_VERSION_STRING() );
	theApp.setOrganizationDomain( CQuazaaGlobals::APPLICATION_ORGANIZATION_DOMAIN() );
	theApp.setOrganizationName(   CQuazaaGlobals::APPLICATION_ORGANIZATION_NAME() );
	theApp.setApplicationSlogan( QObject::tr("World class file sharing.") );

	QIcon icon;
	icon.addFile( ":/Resource/Quazaa16.png" );
	icon.addFile( ":/Resource/Quazaa24.png" );
	icon.addFile( ":/Resource/Quazaa32.png" );
	icon.addFile( ":/Resource/Quazaa48.png" );
	icon.addFile( ":/Resource/Quazaa64.png" );
	icon.addFile( ":/Resource/Quazaa128.png" );
	qApp->setWindowIcon( icon );
//.........这里部分代码省略.........
开发者ID:quazaa-development-team,项目名称:quazaa,代码行数:101,代码来源:main.cpp

示例2: apply


//.........这里部分代码省略.........
        settings->setCSSRegionsEnabled(value);

        value = attributes.value(QWebSettings::HyperlinkAuditingEnabled,
                                 global->attributes.value(QWebSettings::HyperlinkAuditingEnabled));

        settings->setHyperlinkAuditingEnabled(value);
 
        value = attributes.value(QWebSettings::JavascriptCanOpenWindows,
                                      global->attributes.value(QWebSettings::JavascriptCanOpenWindows));
        settings->setJavaScriptCanOpenWindowsAutomatically(value);

        value = attributes.value(QWebSettings::JavascriptCanCloseWindows,
                                      global->attributes.value(QWebSettings::JavascriptCanCloseWindows));
        settings->setAllowScriptsToCloseWindows(value);

        value = attributes.value(QWebSettings::JavaEnabled,
                                      global->attributes.value(QWebSettings::JavaEnabled));
        settings->setJavaEnabled(value);

        value = attributes.value(QWebSettings::PluginsEnabled,
                                      global->attributes.value(QWebSettings::PluginsEnabled));
        settings->setPluginsEnabled(value);

        value = attributes.value(QWebSettings::PrivateBrowsingEnabled,
                                      global->attributes.value(QWebSettings::PrivateBrowsingEnabled));
        settings->setPrivateBrowsingEnabled(value);

        value = attributes.value(QWebSettings::SpatialNavigationEnabled,
                                      global->attributes.value(QWebSettings::SpatialNavigationEnabled));
        settings->setSpatialNavigationEnabled(value);

        value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
                                      global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
        settings->setDOMPasteAllowed(value);
        settings->setJavaScriptCanAccessClipboard(value);

        value = attributes.value(QWebSettings::DeveloperExtrasEnabled,
                                      global->attributes.value(QWebSettings::DeveloperExtrasEnabled));
        settings->setDeveloperExtrasEnabled(value);

        value = attributes.value(QWebSettings::FrameFlatteningEnabled,
                                      global->attributes.value(QWebSettings::FrameFlatteningEnabled));
        settings->setFrameFlatteningEnabled(value);

        QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
        settings->setUserStyleSheetLocation(WebCore::KURL(location));

        QString encoding = !defaultTextEncoding.isEmpty() ? defaultTextEncoding: global->defaultTextEncoding;
        settings->setDefaultTextEncodingName(encoding);

        QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath;
        settings->setLocalStorageDatabasePath(storagePath);

        value = attributes.value(QWebSettings::PrintElementBackgrounds,
                                      global->attributes.value(QWebSettings::PrintElementBackgrounds));
        settings->setShouldPrintBackgrounds(value);

#if ENABLE(SQL_DATABASE)
        value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled,
                                      global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled));
        WebCore::AbstractDatabase::setIsAvailable(value);
#endif

        value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled,
                                      global->attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled));
        settings->setOfflineWebApplicationCacheEnabled(value);

        value = attributes.value(QWebSettings::LocalStorageEnabled,
                                      global->attributes.value(QWebSettings::LocalStorageEnabled));
        settings->setLocalStorageEnabled(value);

        value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls,
                                      global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls));
        settings->setAllowUniversalAccessFromFileURLs(value);

        value = attributes.value(QWebSettings::LocalContentCanAccessFileUrls,
                                      global->attributes.value(QWebSettings::LocalContentCanAccessFileUrls));
        settings->setAllowFileAccessFromFileURLs(value);

        value = attributes.value(QWebSettings::XSSAuditingEnabled,
                                      global->attributes.value(QWebSettings::XSSAuditingEnabled));
        settings->setXSSAuditorEnabled(value);

#if USE(TILED_BACKING_STORE)
        value = attributes.value(QWebSettings::TiledBackingStoreEnabled,
                                      global->attributes.value(QWebSettings::TiledBackingStoreEnabled));
        settings->setTiledBackingStoreEnabled(value);
#endif

        value = attributes.value(QWebSettings::SiteSpecificQuirksEnabled,
                                      global->attributes.value(QWebSettings::SiteSpecificQuirksEnabled));
        settings->setNeedsSiteSpecificQuirks(value);

        settings->setUsesPageCache(WebCore::pageCache()->capacity());
    } else {
        QList<QWebSettingsPrivate*> settings = *::allSettings();
        for (int i = 0; i < settings.count(); ++i)
            settings[i]->apply();
    }
}
开发者ID:Spencerx,项目名称:webkit,代码行数:101,代码来源:qwebsettings.cpp

示例3: migrateData

void GraphMigrationJob::migrateData()
{
    mergeAgents();

    int graphCount = instanceBaseGraphCount();
    int discardableGraphCount = discardableInstanceBaseGraphCount();
    int totalCount = graphCount + discardableGraphCount;
    int count = 0;

    kDebug() << "Total Count:" << totalCount;

    m_nepomukGraph = nepomukGraph(m_model);
    if( m_nepomukGraph.isEmpty() ) {
        setErrorText("No nepomuk graph. Something is very wrong. Please report a bug");
        emitResult();
    }

    QString appQ = QString::fromLatin1("select distinct ?r where { ?r a %1 ; %2 ?i . }")
                   .arg( Soprano::Node::resourceToN3(NAO::Agent()),
                         Soprano::Node::resourceToN3(NAO::identifier()) );

    Soprano::QueryResultIterator it = m_model->executeQuery( appQ, Soprano::Query::QueryLanguageSparqlNoInference );
    if( it.next() ) {
        QUrl app = it[0].uri();
        if( !app.isEmpty() ) {
            m_apps << app;
            kDebug() << "Inserting" << app;
        }
    }

    if( m_apps.isEmpty() ) {
        setErrorText( "No application agents found. Data cannot be migrated" );
        emitResult();
    }

    // Fetch a graph for each application
    QHash<QUrl, QUrl> graphCache;
    QHash<QUrl, QUrl> discardableGraphCache;

    foreach(const QUrl& app, m_apps) {
        // Normal Graph
        QString query = QString::fromLatin1("select ?g where { ?g a nrl:Graph ; nao:maintainedBy %1 ."
                                            " FILTER NOT EXISTS { ?g a nrl:DiscardableInstanceBase . } }")
                        .arg( Soprano::Node::resourceToN3(app) );

        it = m_model->executeQuery( query, Soprano::Query::QueryLanguageSparqlNoInference );
        while (it.next()) {
            const QUrl graph = it[0].uri();
            if( fetchAppCount(m_model, graph) == 1 ) {
                graphCache.insert( app, graph );
                count++;
                emitPercent( count, totalCount );
            }
        }

        // Discardable Graphs
        query = QString::fromLatin1("select ?g where { ?g a nrl:DiscardableInstanceBase ; nao:maintainedBy %1 .}")
                .arg( Soprano::Node::resourceToN3(app) );

        it = m_model->executeQuery( query, Soprano::Query::QueryLanguageSparqlNoInference );
        while (it.next()) {
            const QUrl graph = it[0].uri();
            if( fetchAppCount(m_model, graph) == 1 ) {
                discardableGraphCache.insert( app, graph );
                count++;
                emitPercent( count, totalCount );
            }
        }
    }
开发者ID:KDE,项目名称:nepomuk-core,代码行数:69,代码来源:graphmigrationjob.cpp

示例4: folders

QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
{
    QList<BookmarksModel::Bookmark> list;

    QString bookmarks = QString::fromUtf8(m_file.readAll());
    m_file.close();

    // Converting tags to lower case -,-
    // For some reason Qt::CaseInsensitive is not everytime insensitive :-D

    bookmarks.replace(QLatin1String("<DL"), QLatin1String("<dl"));
    bookmarks.replace(QLatin1String("</DL"), QLatin1String("</dl"));
    bookmarks.replace(QLatin1String("<DT"), QLatin1String("<dt"));
    bookmarks.replace(QLatin1String("</DT"), QLatin1String("</dt"));
    bookmarks.replace(QLatin1String("<P"), QLatin1String("<p"));
    bookmarks.replace(QLatin1String("</P"), QLatin1String("</p"));
    bookmarks.replace(QLatin1String("<A"), QLatin1String("<a"));
    bookmarks.replace(QLatin1String("</A"), QLatin1String("</a"));
    bookmarks.replace(QLatin1String("HREF="), QLatin1String("href="));
    bookmarks.replace(QLatin1String("<H3"), QLatin1String("<h3"));
    bookmarks.replace(QLatin1String("</H3"), QLatin1String("</h3"));

    bookmarks = bookmarks.left(bookmarks.lastIndexOf(QLatin1String("</dl><p>")));
    int start = bookmarks.indexOf(QLatin1String("<dl><p>"));

    QStringList folders("Html Import");

    while (start > 0) {
        QString string = bookmarks.mid(start);

        int posOfFolder = string.indexOf(QLatin1String("<dt><h3"));
        int posOfEndFolder = string.indexOf(QLatin1String("</dl><p>"));
        int posOfLink = string.indexOf(QLatin1String("<dt><a"));

        int nearest = qzMin(posOfLink, qzMin(posOfFolder, posOfEndFolder));
        if (nearest == -1) {
            break;
        }

        if (nearest == posOfFolder) {
            // Next is folder
            QRegExp rx("<dt><h3(.*)>(.*)</h3>");
            rx.setMinimal(true);
            rx.indexIn(string);

//            QString arguments = rx.cap(1);
            QString folderName = rx.cap(2).trimmed();

            folders.append(folderName);

            start += posOfFolder + rx.cap(0).size();
        }
        else if (nearest == posOfEndFolder) {
            // Next is end of folder
            if (!folders.isEmpty()) {
                folders.removeLast();
            }

            start += posOfEndFolder + 8;
        }
        else {
            // Next is link
            QRegExp rx("<dt><a(.*)>(.*)</a>");
            rx.setMinimal(true);
            rx.indexIn(string);

            QString arguments = rx.cap(1);
            QString linkName = rx.cap(2).trimmed();

            QRegExp rx2("href=\"(.*)\"");
            rx2.setMinimal(true);
            rx2.indexIn(arguments);

            QUrl url = QUrl::fromEncoded(rx2.cap(1).trimmed().toUtf8());

            start += posOfLink + rx.cap(0).size();

            if (linkName.isEmpty() || url.isEmpty() || url.scheme() == QLatin1String("place")
                    || url.scheme() == QLatin1String("about")) {
                continue;
            }

            BookmarksModel::Bookmark b;
            b.folder = folders.last();
            b.title = linkName;
            b.url = url;

            list.append(b);
        }
    }

    return list;
}
开发者ID:Haommin,项目名称:qupzilla,代码行数:93,代码来源:htmlimporter.cpp

示例5: stateChanged

bool S60VideoCaptureSession::setOutputLocation(const QUrl &sink)
{
    m_requestedSink = sink;

    if (m_error)
        return false;

    switch (m_captureState) {
    case ENotInitialized:
    case EInitializing:
    case EOpening:
    case EPreparing:
        m_openWhenReady = true;
        return true;
    case EInitialized:
    case EOpenComplete:
    case EPrepared:
        // Continue
        break;
    case ERecording:
    case EPaused:
        setError(KErrNotReady, tr("Cannot set file name while recording."));
        return false;
    default:
        setError(KErrGeneral, tr("Unexpected camera error."));
        return false;
    }

    // Empty URL - Use default file name and path
    if (sink.isEmpty()) {
        if (m_captureState == EInitialized) {
            // File is already opened with generated default name

            m_captureState = EOpenComplete;
            emit stateChanged(m_captureState);

            // Prepare right away if needed
            if (m_startAfterPrepareComplete || m_prepareAfterOpenComplete) {
                m_prepareAfterOpenComplete = false; // Reset

                // Commit settings and prepare with them
                applyAllSettings();
            }
            return true;
        } else {
            // Video not yet initialized
            if (m_videoSettings->m_requestedContainer == QLatin1String("video/mp4"))
                m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
                                                               QLatin1String(".mp4"));
            else if (m_videoSettings->m_requestedContainer == QLatin1String("video/3gp"))
                m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
                                                               QLatin1String(".3gp"));
            else
                m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
                                                               QLatin1String(".3gp2"));
        }

    } else { // Non-empty URL

        QString postfix;
        if (m_videoSettings->m_requestedContainer == QLatin1String("video/mp4"))
            postfix = QLatin1String(".mp4");
        else if (m_videoSettings->m_requestedContainer == QLatin1String("video/3gp"))
            postfix = QLatin1String(".3gp");
        else
            postfix = QLatin1String(".3gp2");

        if (sink.scheme().contains(QLatin1String("file"), Qt::CaseInsensitive)) {
            m_sink = S60FileNameGenerator::generateFileNameFromUrl(S60FileNameGenerator::VideoFileName,
                                                                   sink,
                                                                   postfix);
        } else {
            setError(KErrNotSupported, tr("Network URL is not supported as video sink."));
        }
    }

    // State is either Initialized, OpenComplete or Prepared, Close previously opened file
    if (m_videoRecorder)
        m_videoRecorder->Close();
    else
        setError(KErrNotReady, tr("Unexpected camera error."));

    // Open file

    QString fileName(m_sink);
    TPtrC16 fileSink(reinterpret_cast<const TUint16*>(fileName.utf16()));

    int cameraHandle = m_cameraEngine->Camera() ? m_cameraEngine->Camera()->Handle() : 0;

    TUid controllerUid;
    TUid formatUid;
    m_videoSettings->selectController(controllerUid, formatUid);

    if (m_videoRecorder) {
        // File open completes in MvruoOpenComplete
        TRAPD(err, m_videoRecorder->OpenFileL(fileSink, cameraHandle, controllerUid, formatUid));
        setError(err, tr("Failed to initialize video recorder."));
        m_videoSettings->m_container = m_videoSettings->m_requestedContainer;
        m_captureState = EOpening;
        emit stateChanged(m_captureState);
//.........这里部分代码省略.........
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:101,代码来源:s60videocapturesession.cpp

示例6: saver

KrPopupMenu::KrPopupMenu(KrPanel *thePanel, QWidget *parent) : QMenu(parent), panel(thePanel), empty(false),
        multipleSelections(false), actions(0), _item(0)
{
#ifdef __LIBKONQ__
    konqMenu = 0;
    konqMenuActions = 0;
#endif

    KrViewItemList items;
    panel->view->getSelectedKrViewItems(&items);

    for (KrViewItemList::Iterator it = items.begin(); it != items.end(); ++it) {
        vfile *file = panel->func->files()->vfs_search(((*it)->name()));
        QUrl url = file->vfile_getUrl();
        _items.append(KFileItem(url, file->vfile_getMime(), file->vfile_getMode()));
    }

    if (items.empty()) {
        addCreateNewMenu();
        addSeparator();
        addEmptyMenuEntries();
        return;
    } else if (items.size() > 1) multipleSelections = true;

    QList<QString> protocols;
    for (int i = 0; i < items.size(); ++i) {
        protocols.append(panel->func->getVFile(items[ i ]) ->vfile_getUrl().scheme());
    }
    bool inTrash = protocols.contains("trash");
    bool trashOnly = (protocols.count() == 1) && (protocols[ 0 ] == "trash");

    KrViewItem *item = items.first();
    vfile *vf = panel->func->getVFile(item);
    _item = &_items.first();

    // ------------ the OPEN/BROWSE option - open preferred service
    QAction * openAct = addAction(i18n("Open/Run"));
    openAct->setData(QVariant(OPEN_ID));
    if (!multipleSelections) {   // meaningful only if one file is selected
        openAct->setIcon(item->icon());
        openAct->setText(vf->vfile_isExecutable() && !vf->vfile_isDir() ? i18n("Run") : i18n("Open"));
        // open in a new tab (if folder)
        if (vf->vfile_isDir()) {
            QAction * openTab = addAction(i18n("Open in New Tab"));
            openTab->setData(QVariant(OPEN_TAB_ID));
            openTab->setIcon(krLoader->loadIcon("tab-new", KIconLoader::Panel));
            openTab->setText(i18n("Open in New Tab"));
        }
        QUrl arcPath = panel->func->browsableArchivePath(vf->vfile_getName());
        if (!arcPath.isEmpty()) {
            bool theArchiveMustBeBrowsedAsADirectory = KConfigGroup(krConfig, "Archives").readEntry("ArchivesAsDirectories", _ArchivesAsDirectories) &&
                                                       KRarcHandler::arcSupported(vf->vfile_getMime());
            if (!theArchiveMustBeBrowsedAsADirectory) {
                // Add an option to browse the archive
                QAction *browseAct = addAction(i18n("Browse"));
                browseAct->setData(QVariant(BROWSE_ID));
                browseAct->setIcon(krLoader->loadIcon("", KIconLoader::Panel));
                browseAct->setText(i18n("Browse Archive"));
            }
        }
        addSeparator();
    }

    // ------------- Preview - normal vfs only ?
    if (panel->func->files()->vfs_getType() == vfs::VFS_NORMAL) {
        // create the preview popup
        QStringList names;
        panel->gui->getSelectedNames(&names);
        preview.setUrls(panel->func->files() ->vfs_getFiles(names));
        QAction *pAct = addMenu(&preview);
        pAct->setData(QVariant(PREVIEW_ID));
        pAct->setText(i18n("Preview"));
    }

    // -------------- Open with: try to find-out which apps can open the file
    // this too, is meaningful only if one file is selected or if all the files
    // have the same mimetype !
    QString mime = panel->func->getVFile(item)->vfile_getMime();
    // check if all the list have the same mimetype
    for (int i = 1; i < items.size(); ++i) {
        if (panel->func->getVFile(items[ i ]) ->vfile_getMime() != mime) {
            mime.clear();
            break;
        }
    }
    if (!mime.isEmpty()) {
        offers = KMimeTypeTrader::self()->query(mime);
        for (int i = 0; i < offers.count(); ++i) {
            QExplicitlySharedDataPointer<KService> service = offers[i];
            if (service->isValid() && service->isApplication()) {
                openWith.addAction(krLoader->loadIcon(service->icon(), KIconLoader::Small), service->name())->setData(QVariant(SERVICE_LIST_ID + i));
            }
        }
        openWith.addSeparator();
        if (vf->vfile_isDir())
            openWith.addAction(krLoader->loadIcon("utilities-terminal", KIconLoader::Small), i18n("Terminal"))->setData(QVariant(OPEN_TERM_ID));
        openWith.addAction(i18n("Other..."))->setData(QVariant(CHOOSE_ID));
        QAction *owAct = addMenu(&openWith);
        owAct->setData(QVariant(OPEN_WITH_ID));
        owAct->setText(i18n("Open With"));
//.........这里部分代码省略.........
开发者ID:unknownnf,项目名称:krusader,代码行数:101,代码来源:krpopupmenu.cpp

示例7: metaDataChanged

void DownloadItem::metaDataChanged()
{
    // https://tools.ietf.org/html/rfc6266
    if (m_reply->hasRawHeader(QByteArray("Content-Disposition"))) {
        QByteArray header = m_reply->rawHeader(QByteArray("Content-Disposition"));
        int index = header.indexOf("filename=");
        if (index >= 0) {
            header = header.mid(index+9);
            if (header.startsWith("\"") || header.startsWith("'"))
                header = header.mid(1);
            if ((index = header.lastIndexOf("\"")) > 0)
                header = header.left(index);
            else if ((index = header.lastIndexOf("'")) > 0)
                header = header.left(index);
            m_fileName = QUrl::fromPercentEncoding(header);
        }
        // Sometimes "filename=" and "filename*=UTF-8''" is set.
        // So, search for this too.
        index = header.indexOf("filename*=UTF-8''");
        if (index >= 0) {
            header = header.mid(index+17);
            if (header.startsWith("\"") || header.startsWith("'"))
                header = header.mid(1);
            if ((index = header.lastIndexOf("\"")) > 0)
                header = header.left(index);
            else if ((index = header.lastIndexOf("'")) > 0)
                header = header.left(index);
            m_fileName = QUrl::fromPercentEncoding(header);
        }
    }

    QUrl url = m_reply->url();

    // If this is a redirected url use this instead
    QUrl redirectUrl = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (!redirectUrl.isEmpty()) {
        QString s = redirectUrl.toString();
        std::cout << "Redirected to " << s.toStdString() << std::endl;

        QVariant header = m_reply->header(QNetworkRequest::LocationHeader);
        QString loc = header.toString();
        Q_UNUSED(loc);

        if (url != redirectUrl) {
            url = redirectUrl;

            if (m_reply) {
                disconnect(m_reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));
                disconnect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
                           this, SLOT(error(QNetworkReply::NetworkError)));
                disconnect(m_reply, SIGNAL(downloadProgress(qint64, qint64)),
                           this, SLOT(downloadProgress(qint64, qint64)));
                disconnect(m_reply, SIGNAL(metaDataChanged()),
                           this, SLOT(metaDataChanged()));
                disconnect(m_reply, SIGNAL(finished()),
                           this, SLOT(finished()));
                m_reply->close();
                m_reply->deleteLater();
            }

            m_reply = DownloadManager::getInstance()->networkAccessManager()->get(QNetworkRequest(url));
            init();
        }
    }
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:65,代码来源:DownloadItem.cpp

示例8: apply

void QWebSettingsPrivate::apply()
{
    if (settings) {
        settings->setTextAreasAreResizable(true);

        QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;

        QString family = fontFamilies.value(QWebSettings::StandardFont,
                                            global->fontFamilies.value(QWebSettings::StandardFont));
        settings->setStandardFontFamily(family);

        family = fontFamilies.value(QWebSettings::FixedFont,
                                    global->fontFamilies.value(QWebSettings::FixedFont));
        settings->setFixedFontFamily(family);

        family = fontFamilies.value(QWebSettings::SerifFont,
                                    global->fontFamilies.value(QWebSettings::SerifFont));
        settings->setSerifFontFamily(family);

        family = fontFamilies.value(QWebSettings::SansSerifFont,
                                    global->fontFamilies.value(QWebSettings::SansSerifFont));
        settings->setSansSerifFontFamily(family);

        family = fontFamilies.value(QWebSettings::CursiveFont,
                                    global->fontFamilies.value(QWebSettings::CursiveFont));
        settings->setCursiveFontFamily(family);

        family = fontFamilies.value(QWebSettings::FantasyFont,
                                    global->fontFamilies.value(QWebSettings::FantasyFont));
        settings->setFantasyFontFamily(family);

        int size = fontSizes.value(QWebSettings::MinimumFontSize,
                                   global->fontSizes.value(QWebSettings::MinimumFontSize));
        settings->setMinimumFontSize(size);

        size = fontSizes.value(QWebSettings::MinimumLogicalFontSize,
                                   global->fontSizes.value(QWebSettings::MinimumLogicalFontSize));
        settings->setMinimumLogicalFontSize(size);

        size = fontSizes.value(QWebSettings::DefaultFontSize,
                                   global->fontSizes.value(QWebSettings::DefaultFontSize));
        settings->setDefaultFontSize(size);

        size = fontSizes.value(QWebSettings::DefaultFixedFontSize,
                                   global->fontSizes.value(QWebSettings::DefaultFixedFontSize));
        settings->setDefaultFixedFontSize(size);

        bool value = attributes.value(QWebSettings::AutoLoadImages,
                                      global->attributes.value(QWebSettings::AutoLoadImages));
        settings->setLoadsImagesAutomatically(value);

        value = attributes.value(QWebSettings::JavascriptEnabled,
                                      global->attributes.value(QWebSettings::JavascriptEnabled));
        settings->setJavaScriptEnabled(value);

        value = attributes.value(QWebSettings::JavascriptCanOpenWindows,
                                      global->attributes.value(QWebSettings::JavascriptCanOpenWindows));
        settings->setJavaScriptCanOpenWindowsAutomatically(value);

        value = attributes.value(QWebSettings::JavaEnabled,
                                      global->attributes.value(QWebSettings::JavaEnabled));
        settings->setJavaEnabled(value);

        value = attributes.value(QWebSettings::PluginsEnabled,
                                      global->attributes.value(QWebSettings::PluginsEnabled));
        settings->setPluginsEnabled(value);

        value = attributes.value(QWebSettings::PrivateBrowsingEnabled,
                                      global->attributes.value(QWebSettings::PrivateBrowsingEnabled));
        settings->setPrivateBrowsingEnabled(value);

        value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
                                      global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
        settings->setDOMPasteAllowed(value);

        value = attributes.value(QWebSettings::DeveloperExtrasEnabled,
                                      global->attributes.value(QWebSettings::DeveloperExtrasEnabled));
        settings->setDeveloperExtrasEnabled(value);

        QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
        settings->setUserStyleSheetLocation(WebCore::KURL(location));

        QString localStoragePath = !localStorageDatabasePath.isEmpty() ? localStorageDatabasePath : global->localStorageDatabasePath;
        settings->setLocalStorageDatabasePath(localStoragePath);

        value = attributes.value(QWebSettings::ZoomTextOnly,
                                 global->attributes.value(QWebSettings::ZoomTextOnly));
        settings->setZoomsTextOnly(value);

        value = attributes.value(QWebSettings::PrintElementBackgrounds,
                                      global->attributes.value(QWebSettings::PrintElementBackgrounds));
        settings->setShouldPrintBackgrounds(value);

        value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled,
                                      global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled));
        settings->setDatabasesEnabled(value);

        value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled,
                                      global->attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled));
        settings->setOfflineWebApplicationCacheEnabled(value);
//.........这里部分代码省略.........
开发者ID:marshall,项目名称:webkit_titanium,代码行数:101,代码来源:qwebsettings.cpp


注:本文中的QUrl::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。