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


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

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


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

示例1: sync

	void Konsole::sync()
	{
		if(!KileConfig::syncConsoleDirWithTabs()) {
			return;
		}

		KTextEditor::Document *doc = m_ki->activeTextDocument();
		KTextEditor::View *view = Q_NULLPTR;

		if(doc) {
			view = doc->views().first();
		}

		if(view) {
			QString finame;
			QUrl url = view->document()->url();

			if(url.path().isEmpty()) {
				return;
			}

			QFileInfo fic(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path());
			if(fic.isReadable()) {
				setDirectory(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path());
			}
		}
	}
开发者ID:KDE,项目名称:kile,代码行数:27,代码来源:konsolewidget.cpp

示例2: vfs_addFiles

// copy a file to the vfs (physical)
void ftp_vfs::vfs_addFiles(const QList<QUrl> &fileUrls, KIO::CopyJob::CopyMode mode, QObject* toNotify, QString dir, PreserveMode /*pmode*/)
{
    QUrl destUrl = vfs_origin;

    if (!dir.isEmpty()) {
        destUrl.setPath(QDir::cleanPath(destUrl.path() + '/' + dir));

        if (destUrl.scheme() == "tar" || destUrl.scheme() == "zip" || destUrl.scheme() == "krarc") {
            if (QDir(destUrl.adjusted(QUrl::StripTrailingSlash).path()).exists())
                destUrl.setScheme("file");    // if we get out from the archive change the protocol
        }
    }

    KIO::Job* job = 0;
    switch (mode) {
    case KIO::CopyJob::Copy:
        job = KIO::copy(fileUrls, destUrl);
        break;
    case KIO::CopyJob::Move:
        job = KIO::move(fileUrls, destUrl);
        break;
    case KIO::CopyJob::Link:
        job = KIO::link(fileUrls, destUrl);
        break;
    }

    connect(job, SIGNAL(result(KJob*)), this, SLOT(vfs_refresh(KJob*)));
    if (mode == KIO::CopyJob::Move)    // notify the other panel
        connect(job, SIGNAL(result(KJob*)), toNotify, SLOT(vfs_refresh(KJob*)));
}
开发者ID:unknownnf,项目名称:krusader,代码行数:31,代码来源:ftp_vfs.cpp

示例3: isValidDirectory

bool MercurialPlugin::isValidDirectory(const QUrl &directory)
{
    // Mercurial uses the same test, so we don't lose any functionality
    static const QString hgDir(".hg");

    if (m_lastRepoRoot.isParentOf(directory))
        return true;

    const QString initialPath(directory.adjusted(QUrl::StripTrailingSlash).toLocalFile());
    const QFileInfo finfo(initialPath);
    QDir dir;
    if (finfo.isFile()) {
        dir = finfo.absoluteDir();
    } else {
        dir = QDir(initialPath);
        dir.makeAbsolute();
    }

    while (!dir.cd(hgDir) && dir.cdUp())
    {} // cdUp, until there is a sub-directory called .hg

    if (hgDir != dir.dirName())
        return false;

    dir.cdUp(); // Leave .hg
    // TODO: Check whether this is the right port, original code was: m_lastRepoRoot.setDirectory(dir.absolutePath());
    m_lastRepoRoot.setPath(dir.absolutePath());
    return true;
}
开发者ID:KDE,项目名称:kdev-mercurial,代码行数:29,代码来源:mercurialplugin.cpp

示例4: copyAppData

bool Manager::copyAppData(const QUrl &src, const QString& subdir, const QString& fileName)
{
	//let saveLocation find and create the appropriate place to
	//store the templates (usually $HOME/.kde/share/apps/kile/templates)
	QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + '/' + subdir;

	QUrl targetURL = QUrl::fromUserInput(dir);
	targetURL = targetURL.adjusted(QUrl::StripTrailingSlash);
	targetURL.setPath(targetURL.path() + '/' + fileName);

	//if a directory is found
	if (!dir.isNull()) {
		// create dir if not existing, needed for copyjob
		QDir testDir(dir);
		if (!testDir.exists()){
			testDir.mkpath(dir);
		}
		// copy file
		KIO::FileCopyJob* copyJob = KIO::file_copy(src, targetURL);
		KJobWidgets::setWindow(copyJob, m_kileInfo->mainWindow());
		return copyJob->exec();
	}
	else {
		KMessageBox::error(Q_NULLPTR, i18n("Could not find a folder to save %1 to.\nCheck whether you have a .kde folder with write permissions in your home folder.", fileName));
		return false;
	}
}
开发者ID:KDE,项目名称:kile,代码行数:27,代码来源:templates.cpp

示例5: album

QString CoreDbUrl::album() const
{
    // obey trailing slash in the path - albums have a trailing slash
    // get result without trailing slash
    QUrl url = adjusted(QUrl::RemoveFilename);

    return ( url.adjusted(QUrl::StripTrailingSlash).path() );
}
开发者ID:swatilodha,项目名称:digikam,代码行数:8,代码来源:coredburl.cpp

示例6: save

void MainWindow::save(QUrl url) {
    //if saving process was aborted
    if(!url.isValid())
        return;

    QString path = url.toLocalFile();

    //if no file suffix was chosen, automatically use the PNG format
    QFileInfo file(path);
    if(!file.baseName().isEmpty() && file.suffix().isEmpty())
        path += ".png";

    QString suffix = file.suffix();
    //Qt can only read tga, saving is not supported
    if(suffix.toLower() == "tga")
        suffix = "png";

    //append a suffix to the map names (result: path/original_normal.png)
    QString name_normal = file.absolutePath() + "/" + file.baseName() + "_normal." + suffix;
    QString name_specular = file.absolutePath() + "/" + file.baseName() + "_spec." + suffix;
    QString name_displace = file.absolutePath() + "/" + file.baseName() + "_displace." + suffix;

    bool successfullySaved = true;
    
    if(ui->checkBox_queue_generateNormal->isChecked()) {
        if(normalmap.isNull())
            ui->statusBar->showMessage("calculating normalmap...");
            calcNormal();
        
        successfullySaved &= normalmap.save(name_normal);
    }    
    
    if(ui->checkBox_queue_generateSpec->isChecked()) {
        if(specmap.isNull())
            ui->statusBar->showMessage("calculating specularmap...");
            calcSpec();
        
        successfullySaved &= specmap.save(name_specular);
    }

    if(ui->checkBox_queue_generateDisplace->isChecked()) {
        if(displacementmap.isNull())
            ui->statusBar->showMessage("calculating displacementmap...");
            calcDisplace();
        
        successfullySaved &= displacementmap.save(name_displace);
    }
    
    if(successfullySaved)
        ui->statusBar->showMessage("Maps successfully saved", 4000);
    else
        QMessageBox::information(this, "Maps not saved", "One or more of the maps was NOT saved!");
    
    //store export path
    setExportPath(url.adjusted(QUrl::RemoveFilename));
    //enable "Open Export Folder" gui button
    ui->pushButton_openExportFolder->setEnabled(true);
}
开发者ID:magnomatos822,项目名称:NormalmapGenerator,代码行数:58,代码来源:mainwindow.cpp

示例7: importImageModel

CamItemInfo& ImportIconView::camItemInfoRef(const QString& folder, const QString& file)
{
    QUrl url = QUrl::fromLocalFile(folder);
    url = url.adjusted(QUrl::StripTrailingSlash);
    url.setPath(url.path() + QLatin1Char('/') + (file));
    QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(url.toLocalFile());
    QModelIndex mappedIndex         = importFilterModel()->mapToSource(indexForCamItemInfo);
    return importImageModel()->camItemInfoRef(mappedIndex);
}
开发者ID:Match-Yang,项目名称:digikam,代码行数:9,代码来源:importiconview.cpp

示例8: extractFiles

bool CliInterface::extractFiles(const QVector<Archive::Entry*> &files, const QString &destinationDirectory, const ExtractionOptions &options)
{
    qCDebug(ARK) << Q_FUNC_INFO << "to" << destinationDirectory;

    m_operationMode = Extract;
    m_extractionOptions = options;
    m_extractedFiles = files;
    m_extractDestDir = destinationDirectory;



    if (!m_cliProps->property("passwordSwitch").toString().isEmpty() && options.encryptedArchiveHint() && password().isEmpty()) {
        qCDebug(ARK) << "Password hint enabled, querying user";
        if (!passwordQuery()) {
            return false;
        }
    }

    QUrl destDir = QUrl(destinationDirectory);
    QDir::setCurrent(destDir.adjusted(QUrl::RemoveScheme).url());

    const bool useTmpExtractDir = options.isDragAndDropEnabled() || options.alwaysUseTempDir();

    if (useTmpExtractDir) {
        // Create an hidden temp folder in the current directory.
        m_extractTempDir.reset(new QTemporaryDir(QStringLiteral(".%1-").arg(QCoreApplication::applicationName())));

        qCDebug(ARK) << "Using temporary extraction dir:" << m_extractTempDir->path();
        if (!m_extractTempDir->isValid()) {
            qCDebug(ARK) << "Creation of temporary directory failed.";
            emit finished(false);
            return false;
        }
        m_oldWorkingDir = QDir::currentPath();
        destDir = QUrl(m_extractTempDir->path());
        QDir::setCurrent(destDir.adjusted(QUrl::RemoveScheme).url());
    }

    return runProcess(m_cliProps->property("extractProgram").toString(),
                    m_cliProps->extractArgs(filename(),
                                            extractFilesList(files),
                                            options.preservePaths(),
                                            password()));
}
开发者ID:KDE,项目名称:ark,代码行数:44,代码来源:cliinterface.cpp

示例9:

KIO::TransferJob * Resource::getTransferJob(const QString &uri, const QString &token) const
{
    QUrl url = baseUrl;
    url = url.adjusted(QUrl::StripTrailingSlash);
    url.setPath(url.path() + '/' + uri);
    KIO::TransferJob *job = KIO::get(url, KIO::Reload, KIO::HideProgressInfo);
    if (!token.isEmpty())
        job->addMetaData("customHTTPHeader", "Authorization: token " + token);
    return job;
}
开发者ID:salamanderrake,项目名称:KDevelop,代码行数:10,代码来源:ghresource.cpp

示例10: normalizeUrl

QUrl normalizeUrl(QUrl url)
{
	url = url.adjusted(QUrl::RemoveFragment | QUrl::NormalizePathSegments | QUrl::StripTrailingSlash);

	if (url.path() == QLatin1String("/"))
	{
		url.setPath(QString());
	}

	return url;
}
开发者ID:testmana2,项目名称:otter-browser,代码行数:11,代码来源:Utils.cpp

示例11: stat

// This function should only be called when:
// - KFileItem is called with a QUrl object directly!
// - refresh is called.
// This is done to re-populate the UDSEntry object.
void KFileItemPrivate::stat()
{
    if(m_url.isLocalFile()) {
        QT_STATBUF buf;
        const QString path = m_url.adjusted(QUrl::StripTrailingSlash).toLocalFile();
        const QByteArray pathBA = QFile::encodeName(path);
        if (QT_LSTAT(pathBA.constData(), &buf) == 0) {
            m_entry = KIO::UDSEntry(buf, m_url.fileName());
        }
    }
}
开发者ID:emmanuel099,项目名称:kio,代码行数:15,代码来源:kfileitem.cpp

示例12: authenticate

void Resource::authenticate(const QString &name, const QString &password)
{
    QUrl url = baseUrl;
    url = url.adjusted(QUrl::StripTrailingSlash);
    url.setPath(url.path() + '/' + "/authorizations");
    QByteArray data = "{ \"scopes\": [\"repo\"], \"note\": \"KDevelop Github Provider\" }";
    KIO::StoredTransferJob *job = KIO::storedHttpPost(data, url, KIO::HideProgressInfo);
    job->addMetaData("customHTTPHeader", "Authorization: Basic " + QString (name + ':' + password).toUtf8().toBase64());
    connect(job, &KIO::StoredTransferJob::result, this, &Resource::slotAuthenticate);
    job->start();
}
开发者ID:salamanderrake,项目名称:KDevelop,代码行数:11,代码来源:ghresource.cpp

示例13: checkCorrectRepository

bool BupSlave::checkCorrectRepository(const QUrl &pUrl, QStringList &pPathInRepository) {
	// make this slave accept most URLs.. even incorrect ones. (no slash (wrong),
	// one slash (correct), two slashes (wrong), three slashes (correct))
	QString lPath;
	if(!pUrl.host().isEmpty()) {
		lPath = QStringLiteral("/") + pUrl.host() + pUrl.adjusted(QUrl::StripTrailingSlash).path() + '/';
	} else {
		lPath = pUrl.adjusted(QUrl::StripTrailingSlash).path() + '/';
		if(!lPath.startsWith(QLatin1Char('/'))) {
			lPath.prepend(QLatin1Char('/'));
		}
	}

	if(mRepository && mRepository->isValid()) {
		if(lPath.startsWith(mRepository->objectName())) {
			lPath.remove(0, mRepository->objectName().length());
			pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
			return true;
		}
		else {
			delete mRepository;
			mRepository = NULL;
		}
	}

	pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
	QString lRepoPath = QStringLiteral("/");
	while(!pPathInRepository.isEmpty()) {
		// make sure the repo path will end with a slash
		lRepoPath += pPathInRepository.takeFirst();
		lRepoPath += QStringLiteral("/");
		if((QFile::exists(lRepoPath + QStringLiteral("objects")) &&
		    QFile::exists(lRepoPath + QStringLiteral("refs"))) ||
		      (QFile::exists(lRepoPath + QStringLiteral(".git/objects")) &&
		       QFile::exists(lRepoPath + QStringLiteral(".git/refs")))) {
			mRepository = new Repository(NULL, lRepoPath);
			return mRepository->isValid();
		}
	}
	return false;
}
开发者ID:somniumAeternam,项目名称:Kup,代码行数:41,代码来源:bupslave.cpp

示例14: init

void KFileItemPrivate::init()
{
    m_access.clear();
    //  metaInfo = KFileMetaInfo();

    // stat() local files if needed
    // TODO: delay this until requested
    if (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.count() == 0) {
        if (m_url.isLocalFile()) {
            /* directories may not have a slash at the end if
             * we want to stat() them; it requires that we
             * change into it .. which may not be allowed
             * stat("/is/unaccessible")  -> rwx------
             * stat("/is/unaccessible/") -> EPERM            H.Z.
             * This is the reason for the StripTrailingSlash
             */
            QT_STATBUF buf;
            const QString path = m_url.adjusted(QUrl::StripTrailingSlash).toLocalFile();
            const QByteArray pathBA = QFile::encodeName(path);
            if (QT_LSTAT(pathBA.constData(), &buf) == 0) {
                m_entry.insert(KIO::UDSEntry::UDS_DEVICE_ID,           buf.st_dev);
                m_entry.insert(KIO::UDSEntry::UDS_INODE,               buf.st_ino);

                mode_t mode = buf.st_mode;
                if ((buf.st_mode & QT_STAT_MASK) == QT_STAT_LNK) {
                    m_bLink = true;
                    if (QT_STAT(pathBA, &buf) == 0) {
                        mode = buf.st_mode;
                    } else {// link pointing to nowhere (see FileProtocol::createUDSEntry() in ioslaves/file/file.cpp)
                        mode = (QT_STAT_MASK - 1) | S_IRWXU | S_IRWXG | S_IRWXO;
                    }
                }
                m_entry.insert(KIO::UDSEntry::UDS_SIZE,      buf.st_size);
                m_entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, buf.st_mode & QT_STAT_MASK); // extract file type
                m_entry.insert(KIO::UDSEntry::UDS_ACCESS,    buf.st_mode & 07777); // extract permissions
                m_entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME,   buf.st_mtime); // TODO: we could use msecs too...
                m_entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME,         buf.st_atime);
#ifndef Q_OS_WIN
                m_entry.insert(KIO::UDSEntry::UDS_USER,                KUser(buf.st_uid).loginName());
                m_entry.insert(KIO::UDSEntry::UDS_GROUP,               KUserGroup(buf.st_gid).name());
#endif

                // TODO: these can be removed, we can use UDS_FILE_TYPE and UDS_ACCESS everywhere
                if (m_fileMode == KFileItem::Unknown) {
                    m_fileMode = mode & QT_STAT_MASK; // extract file type
                }
                if (m_permissions == KFileItem::Unknown) {
                    m_permissions = mode & 07777; // extract permissions
                }
            }
        }
    }
}
开发者ID:KDE,项目名称:kio,代码行数:53,代码来源:kfileitem.cpp

示例15: populateVfsList

bool ftp_vfs::populateVfsList(const QUrl &origin, bool showHidden)
{
    QString errorMsg;
    if (!origin.isValid())
        errorMsg = i18n("Malformed URL:\n%1", origin.url());
    if (!KProtocolManager::supportsListing(origin)) {
        if (origin.scheme() == "ftp" && KProtocolManager::supportsReading(origin))
            errorMsg = i18n("Krusader does not support FTP access via HTTP.\nIf it is not the case, please check and change the proxy settings in the System Settings.");
        else
            errorMsg = i18n("Protocol not supported by Krusader:\n%1", origin.url());
    }

    if (!errorMsg.isEmpty()) {
        printf("error\n");
        if (!quietMode)
            emit error(errorMsg);
        return false;
    }

    busy = true;

    vfs_origin = origin.adjusted(QUrl::StripTrailingSlash);

    //QTimer::singleShot( 0,this,SLOT(startLister()) );
    listError = false;
    // Open the directory marked by origin
    KIO::Job *job = KIO::listDir(vfs_origin, KIO::HideProgressInfo, showHidden);
    connect(job, SIGNAL(entries(KIO::Job*, const KIO::UDSEntryList&)),
            this, SLOT(slotAddFiles(KIO::Job*, const KIO::UDSEntryList&)));
    connect(job, SIGNAL(redirection(KIO::Job*, const QUrl&)),
            this, SLOT(slotRedirection(KIO::Job*, const QUrl&)));
    connect(job, SIGNAL(permanentRedirection(KIO::Job*, const QUrl&, const QUrl&)),
            this, SLOT(slotPermanentRedirection(KIO::Job*, const QUrl&, const QUrl&)));

    connect(job, SIGNAL(result(KJob*)),
            this, SLOT(slotListResult(KJob*)));

    if(!parentWindow.isNull()) {
        KIO::JobUiDelegate *ui = static_cast<KIO::JobUiDelegate*>(job->uiDelegate());
        ui->setWindow(parentWindow);
    }

    if (!quietMode) {
        emit startJob(job);
    }

    while (busy && vfs_processEvents());

    if (listError) return false;

    return true;
}
开发者ID:unknownnf,项目名称:krusader,代码行数:52,代码来源:ftp_vfs.cpp


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