本文整理汇总了C++中KUrl::addPath方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::addPath方法的具体用法?C++ KUrl::addPath怎么用?C++ KUrl::addPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::addPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listDir
void RemoteProtocol::listDir(const KUrl &url)
{
kDebug(1220) << "RemoteProtocol::listDir: " << url;
if ( url.path().length() <= 1 )
{
listRoot();
return;
}
int second_slash_idx = url.path().indexOf( '/', 1 );
const QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
KUrl target = m_impl.findBaseURL( root_dirname );
kDebug(1220) << "possible redirection target : " << target;
if( target.isValid() )
{
if ( second_slash_idx < 0 ) {
second_slash_idx = url.path().size();
}
target.addPath( url.path().remove(0, second_slash_idx) );
kDebug(1220) << "complete redirection target : " << target;
redirection(target);
finished();
return;
}
error(KIO::ERR_MALFORMED_URL, url.prettyUrl());
}
示例2: restore
void TrashProtocol::restore( const KUrl& trashURL )
{
int trashId;
QString fileId, relativePath;
bool ok = TrashImpl::parseURL( trashURL, trashId, fileId, relativePath );
if ( !ok ) {
error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", trashURL.prettyUrl() ) );
return;
}
TrashedFileInfo info;
ok = impl.infoForFile( trashId, fileId, info );
if ( !ok ) {
error( impl.lastErrorCode(), impl.lastErrorMessage() );
return;
}
KUrl dest;
dest.setPath( info.origPath );
if ( !relativePath.isEmpty() )
dest.addPath( relativePath );
// Check that the destination directory exists, to improve the error code in case it doesn't.
const QString destDir = dest.directory();
KDE_struct_stat buff;
if ( KDE_lstat( QFile::encodeName( destDir ), &buff ) == -1 ) {
error( KIO::ERR_SLAVE_DEFINED,
i18n( "The directory %1 does not exist anymore, so it is not possible to restore this item to its original location. "
"You can either recreate that directory and use the restore operation again, or drag the item anywhere else to restore it.", destDir ) );
return;
}
copyOrMove( trashURL, dest, false /*overwrite*/, Move );
}
示例3: slotDocbookGenerationFinished
void DocbookGenerator::slotDocbookGenerationFinished(const QString& tmpFileName)
{
uDebug() << "Generation Finished" << tmpFileName;
KUrl url = umlDoc->url();
QString fileName = url.fileName();
fileName.replace(QRegExp(".xmi$"),".docbook");
url.setPath(m_destDir.path());
url.addPath(fileName);
KIO::Job* job = KIO::file_copy(KUrl::fromPath(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo);
if ( KIO::NetAccess::synchronousRun( job, (QWidget*)UMLApp::app() ) ) {
umlDoc->writeToStatusBar(i18n("Docbook Generation Complete..."));
m_pStatus = true;
} else {
umlDoc->writeToStatusBar(i18n("Docbook Generation Failed..."));
m_pStatus = false;
}
while ( m_pThreadFinished == false ) {
// wait for thread to finish
qApp->processEvents();
}
emit finished(m_pStatus);
}
示例4: slotUrlsDropped
void ScanGallery::slotUrlsDropped(QDropEvent *ev, FileTreeViewItem *item)
{
KUrl::List urls = ev->mimeData()->urls();
if (urls.isEmpty()) return;
kDebug() << "onto" << (item==NULL ? "NULL" : item->url().prettyUrl())
<< "srcs" << urls.count() << "first" << urls.first();
if (item==NULL) return;
KUrl dest = item->url();
// Check whether the drop is on top of a directory (in which case we
// want to move/copy into it) or a file (move/copy into its containing
// directory).
if (!item->isDir()) dest.setFileName(QString::null);
dest.adjustPath(KUrl::AddTrailingSlash);
kDebug() << "resolved destination" << dest;
// Make the last URL to copy the one to select next
KUrl nextSel = dest;
nextSel.addPath(urls.back().fileName(KUrl::ObeyTrailingSlash));
m_nextUrlToShow = nextSel;
KIO::Job *job;
// TODO: top level window as 3rd parameter?
if (ev->dropAction()==Qt::MoveAction) job = KIO::move(urls, dest);
else job = KIO::copy(urls, dest);
connect(job, SIGNAL(result(KJob *)), SLOT(slotJobResult(KJob *)));
}
示例5: extractTemplate
void TemplatePage::extractTemplate()
{
QModelIndex index = ui->treeView->currentIndex();
QString archiveName= ui->treeView->model()->data(index, KDevelop::TemplatesModel::ArchiveFileRole).toString();
QFileInfo info(archiveName);
if (!info.exists())
{
ui->extractButton->setEnabled(false);
return;
}
QScopedPointer<KArchive> archive;
if (info.suffix() == QLatin1String("zip"))
{
archive.reset(new KZip(archiveName));
}
else
{
archive.reset(new KTar(archiveName));
}
archive->open(QIODevice::ReadOnly);
KUrl destination = KUrl::fromLocalFile(KFileDialog::getExistingDirectory());
destination.addPath(info.baseName());
archive->directory()->copyTo(destination.toLocalFile());
}
示例6: buildUrl
KUrl LaconicaSearch::buildUrl(const SearchInfo &searchInfo,
ChoqokId sinceStatusId, uint count, uint page)
{
kDebug();
QString formattedQuery;
switch ( searchInfo.option ) {
case ToUser:
formattedQuery = searchInfo.query + "/replies/rss";
break;
case FromUser:
formattedQuery = searchInfo.query + "/rss";
break;
case ReferenceGroup:
formattedQuery = "group/" + searchInfo.query + "/rss";
break;
case ReferenceHashtag:
formattedQuery = searchInfo.query;
break;
default:
formattedQuery = searchInfo.query + "/rss";
break;
};
KUrl url;
TwitterApiAccount *theAccount = qobject_cast<TwitterApiAccount*>(searchInfo.account);
Q_ASSERT(theAccount);
if( searchInfo.option == ReferenceHashtag ) {
url = theAccount->apiUrl();
url.addPath("/search.atom");
url.addQueryItem("q", formattedQuery);
if( !sinceStatusId.isEmpty() )
url.addQueryItem( "since_id", sinceStatusId );
int cntStr = Choqok::BehaviorSettings::countOfPosts();
if( count && count <= 100 )
cntStr = count;
url.addQueryItem( "rpp", QString::number(cntStr) );
if( page > 1 )
url.addQueryItem( "page", QString::number( page ) );
} else {
url = theAccount->apiUrl().url(KUrl::AddTrailingSlash).remove("api/", Qt::CaseInsensitive);
url.addPath( formattedQuery );
}
return url;
}
示例7: isValidDirectory
bool CvsProxy::isValidDirectory(KUrl dirPath) const
{
QFileInfo fsObject( dirPath.toLocalFile() );
if( !fsObject.isDir() )
dirPath.setFileName( QString() );
dirPath.addPath( "CVS" );
fsObject.setFile( dirPath.toLocalFile() );
return fsObject.exists();
}
示例8: processFile
QString DirSortPlugin::processFile( BatchRenamer* b, int index, const QString &, EPluginType )
{
QString errorMsg = QString::null;
if( index == 0 )
{
// Initialize plugin
m_dirCounter = m_widget->spinStart->value();
m_fileCounter = 0;
m_filesPerDir = m_widget->spinFiles->value();
m_digits = m_widget->spinDigits->value();
m_baseDirectory = m_widget->outputUrl->url();
if( !KIO::NetAccess::exists( m_baseDirectory, true, m_widget->spinStart ) )
{
m_valid = false;
return this->name() +
i18n(": The output directory %1 does not exist.",
m_baseDirectory.prettyUrl() );
}
else
{
m_valid = true;
m_currentDirectory = createNewSubdirectory();
}
}
if( !m_valid )
return errorMsg;
if( m_fileCounter == m_filesPerDir )
{
m_fileCounter = 0;
m_dirCounter++;
m_currentDirectory = createNewSubdirectory();
}
KUrl srcUrl = b->buildDestinationUrl( (*b->files())[index] );
KUrl dstUrl = m_currentDirectory;
dstUrl.addPath( srcUrl.fileName() );
KIO::JobFlags flags = KIO::DefaultFlags | KIO::HideProgressInfo;
KIO::Job* job = KIO::file_move( srcUrl, dstUrl, -1, flags );
m_fileCounter++;
if( m_valid && job && !KIO::NetAccess::synchronousRun( job, m_widget->spinStart ) )
{
errorMsg = i18n("Error renaming %2 (to %1)",
dstUrl.prettyUrl(),
srcUrl.prettyUrl());
}
return errorMsg;
}
示例9: exportImageToTmpDir
void KPrHtmlExport::exportImageToTmpDir()
{
// Export slides as image into the temporary export directory
KUrl fileUrl;
for(int i=0; i < m_parameters.slides.size(); ++i){
fileUrl = m_tmpDirPath;
fileUrl.addPath(QString("slide%1.png").arg(i));
KoPAPageBase *slide = m_parameters.slides.at(i);
m_parameters.kprView->exportPageThumbnail(slide,fileUrl, slide->size().toSize(), "PNG", -1);
}
}
示例10: isVersionControlled
bool CvsProxy::isVersionControlled(KUrl filePath) const
{
QFileInfo fsObject( filePath.toLocalFile() );
if( !fsObject.isDir() )
filePath.setFileName( QString() );
filePath.addPath( "CVS" );
QFileInfo cvsObject( filePath.toLocalFile() );
if( !cvsObject.exists() )
return false;
if( fsObject.isDir() )
return true;
filePath.addPath( "Entries" );
QFile cvsEntries( filePath.toLocalFile() );
cvsEntries.open( QIODevice::ReadOnly );
QString cvsEntriesData = cvsEntries.readAll();
cvsEntries.close();
return ( cvsEntriesData.indexOf( fsObject.fileName() ) != -1 );
}
示例11: buildTimelineQuery
// only used for the queries
bool Nepomuk2::TimelineProtocol::rewriteUrl( const KUrl& url, KUrl& newURL )
{
if ( parseTimelineUrl( url, &m_date, &m_filename ) == DayFolder ) {
newURL = buildTimelineQuery( m_date ).toSearchUrl();
newURL.addPath( m_filename );
kDebug() << url << newURL;
return true;
}
else {
return false;
}
}
示例12: slotHtmlGenerated
/**
* Triggered when the copying of the HTML result file is finished.
* Emits the signal finished().
* @param tmpFileName temporary file name
*/
void XhtmlGenerator::slotHtmlGenerated(const QString& tmpFileName)
{
uDebug() << "HTML Generated " << tmpFileName;
KUrl url = m_umlDoc->url();
QString fileName = url.fileName();
fileName.replace(QRegExp(".xmi$"),".html");
url.setPath(m_destDir.path());
url.addPath(fileName);
KIO::Job* htmlCopyJob = KIO::file_copy( KUrl::fromPath( tmpFileName ), url, -1, KIO::Overwrite | KIO::HideProgressInfo );
if ( KIO::NetAccess::synchronousRun( htmlCopyJob, (QWidget*)UMLApp::app() ) ) {
m_umlDoc->writeToStatusBar(i18n("XHTML Generation Complete..."));
} else {
m_pStatus = false;
return;
}
m_umlDoc->writeToStatusBar(i18n("Copying CSS..."));
QString cssFileName(KGlobal::dirs()->findResource("appdata","xmi.css"));
KUrl cssUrl = m_destDir;
cssUrl.addPath("xmi.css");
KIO::Job* cssJob = KIO::file_copy(cssFileName,cssUrl,-1, KIO::Overwrite | KIO::HideProgressInfo );
if ( KIO::NetAccess::synchronousRun( cssJob, (QWidget*)UMLApp::app() ) ) {
m_umlDoc->writeToStatusBar(i18n("Finished Copying CSS..."));
m_pStatus = true;
} else {
m_umlDoc->writeToStatusBar(i18n("Failed Copying CSS..."));
m_pStatus = false;
}
while ( m_pThreadFinished == false ) {
// wait for thread to finish
qApp->processEvents();
}
emit finished( m_pStatus );
}
示例13: getConfigFilePath
bool HgConfig::getConfigFilePath()
{
switch (m_configType) {
case RepoConfig:
{
KUrl repoBase = KUrl(HgWrapper::instance()->getBaseDir());
repoBase.addPath(QLatin1String(".hg/hgrc"));
m_configFilePath = repoBase.path();
break;
}
case GlobalConfig:
{
KUrl homeUrl = KUrl(QDir::homePath());
homeUrl.addPath(QLatin1String(".hgrc"));
m_configFilePath = homeUrl.path();
break;
}
case TempConfig:
break;
}
return true;
}
示例14: slotShowOriginalFile
void KonqPopupMenuPrivate::slotShowOriginalFile()
{
const KFileItem item = m_popupItemProperties.items().first();
const QString dest = item.linkDest();
KUrl destUrl = m_sViewURL;
if (dest.startsWith('/')) {
destUrl.setPath(dest);
} else {
destUrl.addPath(dest);
}
// Now destUrl points to the target file, let's go up to parent dir
destUrl.setPath(destUrl.directory());
KRun::runUrl(destUrl, "inode/directory", m_parentWidget);
}
示例15: createNewSubdirectory
KUrl DirSortPlugin::createNewSubdirectory() const
{
KUrl url = m_baseDirectory;
QString dir;
dir.sprintf("%0*i", m_digits, m_dirCounter );
url.addPath( dir );
if( !KIO::NetAccess::mkdir( url, m_widget->spinStart ) ) {
KMessageBox::error( m_widget->spinStart,
i18n("Cannot create directory %1", url.prettyUrl()) );
}
return url;
}