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


C++ KUrl::pathOrUrl方法代码示例

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


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

示例1: removeUrl

bool KDevelop::removeUrl(const KDevelop::IProject* project, const KUrl& url, const bool isFolder)
{
    QWidget* window(ICore::self()->uiController()->activeMainWindow()->window());

    if ( !KIO::NetAccess::exists(url, KIO::NetAccess::DestinationSide, window) ) {
        kWarning() << "tried to remove non-existing url:" << url << project << isFolder;
        return true;
    }

    IPlugin* vcsplugin=project->versionControlPlugin();
    if(vcsplugin) {
        IBasicVersionControl* vcs=vcsplugin->extension<IBasicVersionControl>();

        // We have a vcs and the file/folder is controller, need to make the rename through vcs
        if(vcs->isVersionControlled(url)) {
            VcsJob* job=vcs->remove(KUrl::List() << url);
            if(job) {
                return job->exec();
            }
        }
    }

    //if we didn't find a VCS, we remove using KIO
    if ( !KIO::NetAccess::del( url, window ) ) {
        KMessageBox::error( window,
            isFolder ? i18n( "Cannot remove folder <i>%1</i>.", url.pathOrUrl() )
                        : i18n( "Cannot remove file <i>%1</i>.", url.pathOrUrl() ) );
        return false;
    }
    return true;
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:31,代码来源:helper.cpp

示例2: verify

GpgME::VerificationResult SignaturePrivate::verify(const KUrl &dest, const QByteArray &sig)
{
    GpgME::VerificationResult result;
    if (!QFile::exists(dest.pathOrUrl()) || sig.isEmpty()) {
        return result;
    }

    GpgME::initializeLibrary();
    GpgME::Error error = GpgME::checkEngine(GpgME::OpenPGP);
    if (error) {
        kDebug(5001) << "OpenPGP not supported!";
        return result;
    }

    QScopedPointer<GpgME::Context> context(GpgME::Context::createForProtocol(GpgME::OpenPGP));
    if (!context.data()) {
        kDebug(5001) << "Could not create context.";
        return result;
    }

    boost::shared_ptr<QFile> qFile(new QFile(dest.pathOrUrl()));
    qFile->open(QIODevice::ReadOnly);
    QGpgME::QIODeviceDataProvider *file = new QGpgME::QIODeviceDataProvider(qFile);
    GpgME::Data dFile(file);

    QGpgME::QByteArrayDataProvider signatureBA(sig);
    GpgME::Data signature(&signatureBA);

    return context->verifyDetachedSignature(signature, dFile);
}
开发者ID:KDE,项目名称:kget,代码行数:30,代码来源:signature.cpp

示例3: slotTreeItemSelected

/**
 * Emits the fileRequested() signal when a file name is selected in the file 
 * tree. An item is selected by either double-clicking it or by hittin 
 * "ENTER" when it is highlighted.
 * This slot is connected to the doubleClicked() and returnPressed() signals
 * of the KFileTreeView object.
 * @param	pItem	The selected tree item
 */
void FileView::slotTreeItemSelected(const KUrl& url)
{
	QFileInfo fileInfo = QFileInfo(url.pathOrUrl());

	if (! fileInfo.isDir())
		emit fileRequested(url.pathOrUrl(), 0);
}
开发者ID:AlexanderStein,项目名称:kscope4,代码行数:15,代码来源:fileview.cpp

示例4: doBrokenPieces

void VerificationThread::doBrokenPieces()
{
    m_mutex.lock();
    const QString type = m_types.takeFirst();
    const QStringList checksums = m_checksums;
    m_checksums.clear();
    const KUrl url = m_files.takeFirst();
    const KIO::filesize_t length = m_length;
    m_mutex.unlock();

    QList<KIO::fileoffset_t> broken;

    if (QFile::exists(url.pathOrUrl()))
    {
        QFile file(url.pathOrUrl());
        if (!file.open(QIODevice::ReadOnly))
        {
            emit brokenPieces(broken, length);
            return;
        }

        const KIO::filesize_t fileSize = file.size();
        if (!length || !fileSize)
        {
            emit brokenPieces(broken, length);
            return;
        }

        const QStringList fileChecksums = Verifier::partialChecksums(url, type, length, &m_abort).checksums();
        if (m_abort)
        {
            emit brokenPieces(broken, length);
            return;
        }

        if (fileChecksums.size() != checksums.size())
        {
            kDebug(5001) << "Number of checksums differs!";
            emit brokenPieces(broken, length);
            return;
        }

        for (int i = 0; i < checksums.size(); ++i)
        {
            if (fileChecksums.at(i) != checksums.at(i))
            {
                const int brokenStart = length * i;
                kDebug(5001) << url << "broken segment" << i << "start" << brokenStart << "length" << length;
                broken.append(brokenStart);
            }
        }
    }

    emit brokenPieces(broken, length);
}
开发者ID:KDE,项目名称:kget,代码行数:55,代码来源:verificationthread.cpp

示例5: createWorkingCopy

DvcsJob::JobStatus GitRunner::createWorkingCopy(const KUrl &repoOrigin,
                                                const KUrl &repoDestination)
{
    // TODO: now supports only cloning a local repo(not very useful, I know =P),
    // so extend the method to be used over the Internet.
    m_lastRepoRoot->setDirectory(repoDestination.pathOrUrl());
    DvcsJob *job = new DvcsJob();
    initJob(*job);

    *job << "clone";
    *job << repoOrigin.pathOrUrl();
    startJob(*job);
    return m_jobStatus;
}
开发者ID:netrunner-debian-kde-extras,项目名称:plasmate,代码行数:14,代码来源:gitrunner.cpp

示例6: addInput

bool AddToArchive::addInput(const KUrl& url)
{
    m_inputs << url.pathOrUrl(
        QFileInfo(url.pathOrUrl()).isDir() ?
        KUrl::AddTrailingSlash :
        KUrl::RemoveTrailingSlash
    );

    if (m_firstPath.isEmpty()) {
        QString firstEntry = url.pathOrUrl(KUrl::RemoveTrailingSlash);
        m_firstPath = QFileInfo(firstEntry).dir().absolutePath();
    }

    return true;
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:15,代码来源:addtoarchive.cpp

示例7: createWorkingCopy

void GitRunner::createWorkingCopy(const KUrl &repoOrigin,
                                                const KUrl &repoDestination)
{
    // TODO: now supports only cloning a local repo(not very useful, I know =P),
    // so extend the method to be used over the Internet.
    m_lastRepoRoot->setDirectory(repoDestination.pathOrUrl());

    QStringList command;
    command << "clone " + repoOrigin.pathOrUrl();
    KJob *job = initJob(command);

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

    job->start();
}
开发者ID:deiv,项目名称:plasmate-pkg,代码行数:15,代码来源:gitrunner.cpp

示例8: kDebug

KoTarStore::KoTarStore(QWidget* window, const KUrl& _url, const QString & _filename, Mode _mode, const QByteArray & appIdentification)
{
    kDebug(30002) << "KoTarStore Constructor url=" << _url.pathOrUrl()
    << " filename = " << _filename
    << " mode = " << int(_mode) << endl;
    Q_D(KoStore);

    d->url = _url;
    d->window = window;

    if (_mode == KoStore::Read) {
        d->fileMode = KoStorePrivate::RemoteRead;
        d->localFileName = _filename;

    } else {
        d->fileMode = KoStorePrivate::RemoteWrite;
        d->localFileName = "/tmp/kozip"; // ### FIXME with KTempFile
    }

    m_pTar = new KTar(d->localFileName, "application/x-gzip");

    d->good = init(_mode);   // open the targz file and init some vars

    if (d->good && _mode == Write)
        m_pTar->setOrigFileName(completeMagic(appIdentification));
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:26,代码来源:KoTarStore.cpp

示例9: setDoc

bool DocumentChild::setDoc( const Document *doc )
{
    Q_ASSERT ( m_doc == 0 );
    if ( isOpen() ) {
        KMessageBox::error( 0, i18n( "Document is already open:<br>%1", doc->url().pathOrUrl() ) );
        return false;
    }
    m_doc = doc;
    KUrl url;
    if ( doc->sendAs() == Document::SendAs_Copy ) {
        url = parentPackage()->extractFile( doc );
        if ( url.url().isEmpty() ) {
            KMessageBox::error( 0, i18n( "Could not extract document from storage:<br>%1", doc->url().pathOrUrl() ) );
            return false;
        }
        m_copy = true;
    } else {
        url = doc->url();
    }
    if ( ! url.isValid() ) {
        KMessageBox::error( 0, i18n( "Invalid URL:<br>%1", url.pathOrUrl() ) );
        return false;
    }
    setFileInfo( url );
    return true;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:26,代码来源:part.cpp

示例10:

KUrl KUrlNavigator::Private::buttonUrl(int index) const
{
    if (index < 0) {
        index = 0;
    }

    // Keep scheme, hostname etc. as this is needed for e. g. browsing
    // FTP directories
    const KUrl currentUrl = q->locationUrl();
    KUrl newUrl = currentUrl;
    newUrl.setPath(QString());

    QString pathOrUrl = currentUrl.pathOrUrl();
    if (!pathOrUrl.isEmpty()) {
        if (index == 0) {
            // prevent the last "/" from being stripped
            // or we end up with an empty path
            pathOrUrl = QLatin1String("/");
        } else {
            pathOrUrl = pathOrUrl.section('/', 0, index);
        }
    }

    newUrl.setPath(KUrl(pathOrUrl).path());
    return newUrl;
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:26,代码来源:kurlnavigator.cpp

示例11: checksum

QString Verifier::checksum(const KUrl &dest, const QString &type)
{
    QStringList supported = supportedVerficationTypes();
    if (!supported.contains(type))
    {
        return QString();
    }

    QFile file(dest.pathOrUrl());
    if (!file.open(QIODevice::ReadOnly))
    {
        return QString();
    }

    if (type == VerifierPrivate::MD5) {
        QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5);
        file.close();
        return hash.toHex();
    } else if (type == VerifierPrivate::SHA1) {
        QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Sha1);
        file.close();
        return hash.toHex();
    }

    return QString();
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:26,代码来源:verifier.cpp

示例12: saveAs

void GvCore::saveAs(const KUrl& url)
{
    QByteArray format;
    KUrl saveAsUrl;
    if (!d->showSaveAsDialog(url, &saveAsUrl, &format)) {
        return;
    }

    // Check for overwrite
    if (KIO::NetAccess::exists(saveAsUrl, KIO::NetAccess::DestinationSide, d->mMainWindow)) {
        int answer = KMessageBox::warningContinueCancel(
                         d->mMainWindow,
                         i18nc("@info",
                               "A file named <filename>%1</filename> already exists.\n"
                               "Are you sure you want to overwrite it?",
                               saveAsUrl.fileName()),
                         QString(),
                         KStandardGuiItem::overwrite());
        if (answer == KMessageBox::Cancel) {
            return;
        }
    }

    // Start save
    Document::Ptr doc = DocumentFactory::instance()->load(url);
    KJob* job = doc->save(saveAsUrl, format.data());
    if (!job) {
        const QString name = saveAsUrl.fileName().isEmpty() ? saveAsUrl.pathOrUrl() : saveAsUrl.fileName();
        const QString msg = i18nc("@info", "<b>Saving <filename>%1</filename> failed:</b><br>%2",
                                  name, doc->errorString());
        KMessageBox::sorry(QApplication::activeWindow(), msg);
    } else {
        connect(job, SIGNAL(result(KJob*)), SLOT(slotSaveResult(KJob*)));
    }
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:35,代码来源:gvcore.cpp

示例13: urlToTitle

QString MetaDataManager::urlToTitle(const KUrl &url)
{
    QString title = QFileInfo(url.pathOrUrl()).completeBaseName();
    title = title.replace(QString("%20"), QChar(' '));
    title = title.replace(QChar('_'), QChar(' '));

    return title;
}
开发者ID:Emdek,项目名称:plasmoid-mini-player,代码行数:8,代码来源:MetaDataManager.cpp

示例14: openUrl

bool ServiceItemHandler::openUrl(const KUrl& url)
{
    int result = KToolInvocation::startServiceByDesktopPath(url.pathOrUrl(), QStringList(), 0, 0, 0, "", true);

    if (result == 0) {
        KService::Ptr service = KService::serviceByDesktopPath(url.pathOrUrl());

        if (service) {
            RecentApplications::self()->add(service);
        } else {
            qWarning() << "Failed to find service for" << url;
            return false;
        }
    }

    return result == 0;
}
开发者ID:aarontc,项目名称:kde-workspace,代码行数:17,代码来源:itemhandlers.cpp

示例15: data

QVariant PlaylistModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || (index.row() >= m_tracks.count()))
    {
        return QVariant();
    }

    const KUrl url(m_tracks.at(index.row()));

    if (role == Qt::DecorationRole && index.column() == FileTypeColumn && url.isValid())
    {
        return ((index.row() == m_currentTrack)?KIcon((m_manager->state() != StoppedState && isCurrent())?"media-playback-start":"arrow-right"):MetaDataManager::icon(url));
    }
    else if (role == Qt::DisplayRole || role == Qt::EditRole)
    {
        if (index.column() == FileTypeColumn || index.column() == FileNameColumn)
        {
            if (index.column() == FileNameColumn && role == Qt::DisplayRole)
            {
                return QFileInfo(url.pathOrUrl()).fileName();
            }

            return url.pathOrUrl();
        }
        else if (index.column() == DurationColumn)
        {
            return MetaDataManager::timeToString(MetaDataManager::duration(url));
        }
        else
        {
            return MetaDataManager::metaData(url, translateColumn(index.column()));
        }
    }
    else if (role == Qt::ToolTipRole)
    {
        return ((MetaDataManager::duration(url) > 0)?QString("<nobr>%1 - %2 (%3)</nobr>").arg(MetaDataManager::metaData(url, ArtistKey)).arg(MetaDataManager::metaData(url, TitleKey)).arg(MetaDataManager::timeToString(MetaDataManager::duration(url))):QString("<nobr>%1 - %2</nobr>").arg(MetaDataManager::metaData(url, ArtistKey)).arg(MetaDataManager::metaData(url, TitleKey)));
    }
    else if (role == Qt::UserRole)
    {
        return url.pathOrUrl();
    }

    return QVariant();
}
开发者ID:Emdek,项目名称:plasmoid-mini-player,代码行数:44,代码来源:PlaylistModel.cpp


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