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


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

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


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

示例1: setUpRemoteTestDir

QUrl setUpRemoteTestDir(const QString& testFile)
{
    QWidget* authWindow = 0;
    if (qgetenv("GV_REMOTE_TESTS_BASE_URL").isEmpty()) {
        qWarning() << "Environment variable GV_REMOTE_TESTS_BASE_URL not set: remote tests disabled";
        return QUrl();
    }

    QUrl baseUrl(QString::fromLocal8Bit(qgetenv("GV_REMOTE_TESTS_BASE_URL")));
    baseUrl = baseUrl.adjusted(QUrl::StripTrailingSlash);
    baseUrl.setPath(baseUrl.path() + "/gwenview-remote-tests");

    KIO::StatJob *statJob = KIO::stat(baseUrl, KIO::StatJob::DestinationSide, 0);
    KJobWidgets::setWindow(statJob, authWindow);

    if (statJob->exec()) {
        KIO::DeleteJob *deleteJob = KIO::del(baseUrl);
        KJobWidgets::setWindow(deleteJob, authWindow);
        deleteJob->exec();
    }

    KIO::MkdirJob *mkdirJob = KIO::mkdir(baseUrl);
    KJobWidgets::setWindow(mkdirJob, authWindow);
    if (!mkdirJob->exec()) {
        qCritical() << "Could not create dir" << baseUrl << ":" << mkdirJob->errorString();
        return QUrl();
    }

    if (!testFile.isEmpty()) {
        QUrl dstUrl = baseUrl;
        dstUrl = dstUrl.adjusted(QUrl::StripTrailingSlash);
        dstUrl.setPath(dstUrl.path() + '/' + testFile);
        KIO::FileCopyJob *copyJob = KIO::file_copy(urlForTestFile(testFile), dstUrl);
        KJobWidgets::setWindow(copyJob, authWindow);
        if (!copyJob->exec()) {
            qCritical() << "Could not copy" << testFile << "to" << dstUrl << ":" << copyJob->errorString();
            return QUrl();
        }
    }

    return baseUrl;
}
开发者ID:shlomif,项目名称:gwenview,代码行数:42,代码来源:testutils.cpp

示例2: showPreview

void Preview::showPreview( const QUrl &u, int size )
{
    if ( u.isLocalFile() ) {
	QString path = u.path();
	QFileInfo fi( path );
	if ( fi.isFile() && (int)fi.size() > size * 1000 ) {
	    normalText->setText( tr( "The File\n%1\nis too large, so I don't show it!" ).arg( path ) );
	    raiseWidget( normalText );
	    return;
	}
	
	QPixmap pix( path );
	if ( pix.isNull() ) {
	    if ( fi.isFile() ) {
		QFile f( path );
		if ( f.open( IO_ReadOnly ) ) {
		    QTextStream ts( &f );
		    QString text = ts.read();
		    f.close();
		    if ( fi.extension().lower().contains( "htm" ) ) {
			QString url = html->mimeSourceFactory()->makeAbsolute( path, html->context() );
			html->setText( text, url ); 	
			raiseWidget( html );
			return;
		    } else {
			normalText->setText( text ); 	
			raiseWidget( normalText );
			return;
		    }
		}
	    }
	    normalText->setText( QString::null );
	    raiseWidget( normalText );
	} else {
	    pixmap->setPixmap( pix );
	    raiseWidget( pixmap );
	}
    } else {
	normalText->setText( "I only show local files!" );
	raiseWidget( normalText );
    }
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:42,代码来源:qdir.cpp

示例3: setUrl

void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex)
{
    setData(index, url, UrlRole);
    if (url.path().isEmpty()) {
        setData(index, fileSystemModel->myComputer());
        setData(index, fileSystemModel->myComputer(Qt::DecorationRole), Qt::DecorationRole);
    } else {
        QString newName;
        if (showFullPath) {
            //On windows the popup display the "C:\", convert to nativeSeparators
            newName = QDir::toNativeSeparators(dirIndex.data(QFileSystemModel::FilePathRole).toString());
        } else {
            newName = dirIndex.data().toString();
        }

        QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole));
        if (!dirIndex.isValid()) {
            newIcon = fileSystemModel->iconProvider()->icon(QFileIconProvider::Folder);
            newName = QFileInfo(url.toLocalFile()).fileName();
            if (!invalidUrls.contains(url))
                invalidUrls.append(url);
            //The bookmark is invalid then we set to false the EnabledRole
            setData(index, false, EnabledRole);
        } else {
            //The bookmark is valid then we set to true the EnabledRole
            setData(index, true, EnabledRole);
        }

        // Make sure that we have at least 32x32 images
        const QSize size = newIcon.actualSize(QSize(32,32));
        if (size.width() < 32) {
            QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32));
            newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation));
        }

        if (index.data().toString() != newName)
            setData(index, newName);
        QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
        if (oldIcon.cacheKey() != newIcon.cacheKey())
            setData(index, newIcon, Qt::DecorationRole);
    }
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例4: QString

	QList<QUrl> Core::GetPackageURLs (int packageId) const
	{
		QList<QUrl> result;

		const auto& repo2cmpt = Storage_->GetPackageLocations (packageId);

		PackageShortInfo info;
		try
		{
			info = Storage_->GetPackage (packageId);
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "error getting package"
					<< packageId;
			return result;
		}

		auto pathAddition = QString ("dists/%1/all/");
		const auto& normalized = NormalizePackageName (info.Name_);
		const auto& version = info.Versions_.at (0);
		pathAddition += QString ("%1/%1-%2.tar.%3")
				.arg (normalized)
				.arg (version)
				.arg (info.VersionArchivers_.value (version, "gz"));

		Q_FOREACH (int repoId, repo2cmpt.keys ())
		{
			RepoInfo ri = Storage_->GetRepo (repoId);
			QUrl url = ri.GetUrl ();
			QString path = url.path ();
			if (!path.endsWith ('/'))
				path += '/';

			Q_FOREACH (const QString& component, repo2cmpt [repoId])
			{
				QUrl tmp = url;
				tmp.setPath (path + pathAddition.arg (component));
				result << tmp;
			}
		}
开发者ID:panter-dsd,项目名称:leechcraft,代码行数:42,代码来源:core.cpp

示例5: LRNAMReply

QNetworkReply *LRNAM::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{	
	QUrl url = request.url();

	QString path = url.path();
	if (op == QNetworkAccessManager::GetOperation && url.isLocalFile())
	{
			path = url.toLocalFile();
			return new LRNAMReply(path);
	}
	else if (path.startsWith("/core/resources/"))
	{
		path = _baseResourceDirectory + path.mid(5);
		return new LRNAMReply(path);
	}
	else
	{
		return QNetworkAccessManager::createRequest(op, request, outgoingData);
	}
}
开发者ID:FransMeerhoff,项目名称:jasp-desktop,代码行数:20,代码来源:lrnam.cpp

示例6: dragEnterEvent

void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
	const QMimeData *data = event->mimeData();

	if (data->hasUrls())
	{
		QList<QUrl> urls = data->urls();
		QUrl first = urls.first();
		QFileInfo file(first.path());

		if (file.exists() && (file.completeSuffix() == "csv" || file.completeSuffix() == "jasp"))
			event->accept();
		else
			event->ignore();
	}
	else
	{
		event->ignore();
	}
}
开发者ID:lvanderlinden,项目名称:jasp-desktop,代码行数:20,代码来源:mainwindow.cpp

示例7: SimpleTargetRunner

LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runControl)
    : SimpleTargetRunner(runControl)
{
    setId("LocalQmlPreviewSupport");
    const QUrl serverUrl = Utils::urlFromLocalSocket();

    QmlPreviewRunner *preview = qobject_cast<QmlPreviewRunner *>(
                runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE));
    preview->setServerUrl(serverUrl);

    addStopDependency(preview);
    addStartDependency(preview);

    ProjectExplorer::Runnable run = runnable();

    Utils::QtcProcess::addArg(&run.commandLineArguments,
                              QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices,
                                                               serverUrl.path()));
    setRunnable(run);
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:20,代码来源:qmlpreviewruncontrol.cpp

示例8: array

IndexedString::IndexedString( const QUrl& url ) {
  QByteArray array(url.path().toUtf8());

  const char* str = array.constData();

  int size = array.size();

  if(!size)
    m_index = 0;
  else if(size == 1)
    m_index = 0xffff0000 | str[0];
  else {
    m_index = getIndex(QString::fromUtf8(str));
    /*QMutexLocker lock(globalIndexedStringRepository->mutex());
    m_index = globalIndexedStringRepository->index(IndexedStringRepositoryItemRequest(str, hashString(str, size), size));
    
    if(shouldDoDUChainReferenceCounting(this))
      increase(globalIndexedStringRepository->dynamicItemFromIndexSimple(m_index)->refCount);*/
  }
}
开发者ID:BaderSZ,项目名称:qtbindings,代码行数:20,代码来源:indexedstring.cpp

示例9: startRequest

void TDownlad::startRequest(QUrl url)
{
    qDebug() << "url host: " << url.host();
    this->http = new QHttp(url.host(), QHttp::ConnectionModeHttp, 80);
    qDebug("http init");
    connect(http, SIGNAL(requestFinished(int, bool)),
                 this, SLOT(httpFinished(int, bool)));
    connect(http, SIGNAL(dataReadProgress(int, int)),
                 this, SLOT(downloadProgress(int, int)));
    QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
    qDebug() << path;
    if (path.isEmpty())
        path = "/";
    qDebug() << "state: " << http->state();
    reply = this->http->get(path, file);
    http->ignoreSslErrors();
    http->close();
    qDebug() << "get id" << reply;
    qDebug("http request send");
}
开发者ID:mefest,项目名称:apdvmupdater,代码行数:20,代码来源:tdownlad.cpp

示例10: QFileInfo

QUrlInfo::QUrlInfo(const QUrl &url, int permissions, const QString &owner,
                    const QString &group, qint64 size, const QDateTime &lastModified,
                    const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,
                    bool isWritable, bool isReadable, bool isExecutable)
{
    d = new QUrlInfoPrivate;
    d->name = QFileInfo(url.path()).fileName();
    d->permissions = permissions;
    d->owner = owner;
    d->group = group;
    d->size = size;
    d->lastModified = lastModified;
    d->lastRead = lastRead;
    d->isDir = isDir;
    d->isFile = isFile;
    d->isSymLink = isSymLink;
    d->isWritable = isWritable;
    d->isReadable = isReadable;
    d->isExecutable = isExecutable;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:20,代码来源:qurlinfo.cpp

示例11: saveFileName

QString DownloadManager::saveFileName(const QUrl &url)
{
	QString path = url.path();
	QString basename = QFileInfo(path).fileName();

	if (basename.isEmpty())
		basename = "download";

	if (QFile::exists(basename)) {
		// already exists, don't overwrite
		int i = 0;
		basename += '.';
		while (QFile::exists(basename + QString::number(i)))
			++i;

		basename += QString::number(i);
	}

	return basename;
}
开发者ID:rbbrnc,项目名称:QTWidgets,代码行数:20,代码来源:downloadmanager.cpp

示例12: load

void BrowserView::load(const QUrl & url)
{
    if(isLoading)
        stop();

    view->load(url);
    view->setUrl(url);
    if (url.scheme().size() < 2) {
        QString path     = url.path();
        QFileInfo fi(path);
        QString name = fi.baseName();

        setWindowTitle(name);
    }
    else {
        setWindowTitle(url.host());
    }

    setWindowIcon(QWebSettings::iconForUrl(url));
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:20,代码来源:BrowserView.cpp

示例13: saveFileName

QString DownloadManager::saveFileName(const QUrl &url)
{
#if QT_VERSION < 0x050000
    QString dataPath = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/chessdata";
#else
    QString dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/chessdata";
#endif

    QString dir = AppSettings->value("/General/DefaultDataPath", dataPath).toString();
    QDir().mkpath(dir);

    QString path = url.path();

    QString basename = QFileInfo(path).fileName();

    if (basename.isEmpty())
        basename = "download.pgn";

    return dir + "/" + basename;
}
开发者ID:niklasf,项目名称:chessx,代码行数:20,代码来源:downloadmanager.cpp

示例14: thumbnailPath

QString ThumbnailModel::thumbnailPath(const QUrl &url) const
{
#if defined(Q_OS_UNIX) && !(defined(Q_OS_SYMBIAN) || defined(Q_OS_MAC))
#if defined(Q_WS_MAEMO_5)
    QString thumbnailPath = QDir::homePath()
            + QLatin1String("/.thumbnails/cropped/")
            + QCryptographicHash::hash(url.toString().toUtf8(), QCryptographicHash::Md5).toHex()
            + QLatin1String(".jpeg");
#else
    QString thumbnailPath = QDir::homePath()
            + QLatin1String("/.thumbnails/normal/")
            + QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex()
            + QLatin1String(".png");
#endif
    if (QFile::exists(thumbnailPath))
        return thumbnailPath;
#endif

    return url.path();
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:20,代码来源:thumbnailmodel.cpp

示例15: QProgressDialog

HttpWindow::HttpWindow(QWidget *parent, QUrl _url, QString _savePath) :
		QDialog(parent) {

	this->setFont(THE_REPO->fontVariableWidthSmall);
	this->fullUrlString = _url.scheme() + "://" + _url.authority()
	+ _url.path();
	this->downloadSuccess = false;
	this->uploadFlag = false;
	this->savePath = _savePath;
	progressDialog = new QProgressDialog(this);

	connect(&qnam,
			SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
			this,
			SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));

	connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));

	this->downloadFile();
}
开发者ID:,项目名称:,代码行数:20,代码来源:


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