本文整理汇总了C++中KUrl::setFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::setFileName方法的具体用法?C++ KUrl::setFileName怎么用?C++ KUrl::setFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::setFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findUrlForAccount
static KUrl findUrlForAccount( const KMail::ImapAccountBase * a ) {
assert( a );
const SieveConfig sieve = a->sieveConfig();
if ( !sieve.managesieveSupported() )
return KUrl();
if ( sieve.reuseConfig() ) {
// assemble Sieve url from the settings of the account:
KUrl u;
u.setProtocol( "sieve" );
u.setHost( a->host() );
u.setUser( a->login() );
u.setPass( a->passwd() );
u.setPort( sieve.port() );
u.addQueryItem( "x-mech", a->auth() == "*" ? "PLAIN" : a->auth() ); //translate IMAP LOGIN to PLAIN
if ( !a->useSSL() && !a->useTLS() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
} else {
KUrl u = sieve.alternateURL();
if ( u.protocol().toLower() == "sieve" && !a->useSSL() && !a->useTLS() && u.queryItem("x-allow-unencrypted").isEmpty() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
}
}
示例2: 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 *)));
}
示例3: file
bool
M3UPlaylist::save( const KUrl &location, bool relative )
{
KUrl savePath = location;
//if the location is a directory append the name of this playlist.
if( savePath.fileName().isNull() )
savePath.setFileName( name() );
QFile file( savePath.path() );
if( !file.open( QIODevice::WriteOnly ) )
{
error() << "Unable to write to playlist " << savePath.path();
return false;
}
QTextStream stream( &file );
stream << "#EXTM3U\n";
KUrl::List urls;
QStringList titles;
QList<int> lengths;
foreach( Meta::TrackPtr track, m_tracks )
{
Q_ASSERT(track);
const KUrl &url = track->playableUrl();
int length = track->length() / 1000;
const QString &title = track->name();
const QString &artist = track->artist()->name();
if( !title.isEmpty() && !artist.isEmpty() && length )
{
stream << "#EXTINF:";
stream << QString::number( length );
stream << ',';
stream << artist << " - " << title;
stream << '\n';
}
if( url.protocol() == "file" )
{
if( relative )
{
const QFileInfo fi( file );
QString relativePath = KUrl::relativePath( fi.path(), url.path() );
relativePath.remove( 0, 2 ); //remove "./"
stream << relativePath;
}
else
{
stream << url.path();
}
}
else
{
stream << url.url();
}
stream << "\n";
}
示例4: generateXhtmlForProject
/**
* Exports the current model to XHTML in a directory named as the model
* with the .xmi suffix removed. The XHTML file will have the same name
* with the .html suffix. Figures will be named as the corresponding
* diagrams in the GUI
* @todo change file naming to avoid paths with spaces or non-ASCII chars
* @todo better handling of error conditions
* @return true if saving is successful and false otherwise.
*/
bool XhtmlGenerator::generateXhtmlForProject()
{
KUrl url = m_umlDoc->url();
QString fileName = url.fileName();
fileName.remove(QRegExp(".xmi$"));
url.setFileName(fileName);
uDebug() << "Exporting to directory: " << url;
return generateXhtmlForProjectInto(url);
}
示例5: updateUrl
void KexiProjectTitleSelectionPage::updateUrl()
{
KUrl url = contents->file_requester->url();
QString fn = KexiDB::string2FileName(contents->le_title->text());
if (!fn.isEmpty() && !fn.endsWith(".kexi"))
fn += ".kexi";
url.setFileName(fn);
contents->file_requester->setUrl(url);
}
示例6: generateDocbookForProject
/**
* Exports the current model to docbook in a directory named as the model
* with the .xmi suffix removed. The docbook file will have the same name
* with the .docbook suffix. Figures will be named as the corresponding
* diagrams in the GUI
* @todo change file naming to avoid paths with spaces or non-ASCII chars
* @todo better handling of error conditions
* @return true if saving is successful and false otherwise.
*/
bool DocbookGenerator::generateDocbookForProject()
{
KUrl url = umlDoc->url();
QString fileName = url.fileName();
fileName.remove(QRegExp(".xmi$"));
url.setFileName(fileName);
uDebug() << "Exporting to directory: " << url;
generateDocbookForProjectInto(url);
return true;
}
示例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: changeExtension
KUrl OutputDirectory::changeExtension( const KUrl& url, const QString& extension )
{
KUrl newUrl = url;
QString fileName = newUrl.fileName();
fileName = newUrl.fileName().left( newUrl.fileName().lastIndexOf(".")+1 ) + extension;
newUrl.setFileName( fileName );
return newUrl;
}
示例9: itemDirectory
/* The absolute URL of the item (if it is a directory), or its parent (if
it is a file).
*/
KUrl ScanGallery::itemDirectory(const FileTreeViewItem *item) const
{
if (item==NULL)
{
kDebug() << "no item";
return (KUrl());
}
KUrl u = item->url();
if (!item->isDir()) u.setFileName(""); // not a directory, remove file name
else u.adjustPath(KUrl::AddTrailingSlash); // is a directory, ensure ends with "/"
return (u);
}
示例10: uniqueFileName
KUrl OutputDirectory::uniqueFileName( const KUrl& url, const QStringList& usedOutputNames )
{
KUrl uniqueUrl = url;
while( QFile::exists(uniqueUrl.toLocalFile()) || usedOutputNames.contains(uniqueUrl.toLocalFile()) )
{
QString fileName = uniqueUrl.fileName();
fileName = fileName.left( fileName.lastIndexOf(".")+1 ) + i18nc("will be appended to the filename if a file with the same name already exists","new") + fileName.mid( fileName.lastIndexOf(".") );
uniqueUrl.setFileName( fileName );
}
return uniqueUrl;
}
示例11: saveRecentDir
void KexiStartupFileHandler::saveRecentDir()
{
if (!d->recentDirClass.isEmpty()) {
kDebug() << d->recentDirClass;
KUrl dirUrl;
if (d->requester)
dirUrl = d->requester->url();
else if (d->dialog)
dirUrl = d->dialog->selectedUrl();
kDebug() << dirUrl;
if (dirUrl.isValid() && dirUrl.isLocalFile()) {
dirUrl.setFileName(QString());
kDebug() << "Added" << dirUrl.url() << "to recent dirs class" << d->recentDirClass;
KRecentDirs::add(d->recentDirClass, dirUrl.url());
}
}
}
示例12: if
KUrl Kopete::Transfer::displayURL( const Kopete::Contact *contact, const QString &file )
{
KUrl url;
url.setProtocol( QString::fromLatin1("kopete") );
QString host;
if( !contact )
host = QString::fromLatin1("unknown origin");
else if( contact->metaContact() )
host = contact->metaContact()->displayName();
else
host = contact->contactId();
url.setHost(host);
// url.setPath( contact->protocol()->displayName() );
url.setFileName( file );
return url;
}
示例13: slotCreateFolder
/* ----------------------------------------------------------------------- */
void ScanGallery::slotCreateFolder( )
{
bool ok;
QString folder = KInputDialog::getText( i18n( "New Folder" ),
i18n( "Name for the new folder:" ), QString::null,
&ok, this );
if( ok )
{
/* KIO create folder goes here */
FileTreeViewItem *it = highlightedFileTreeViewItem();
if( it )
{
KUrl url = it->url();
/* If a directory is selected, the filename needs not to be deleted */
if( ! it->isDir())
url.setFileName( "" );
/* add the folder name from user input */
url.addPath( folder );
kDebug() << "Creating folder" << url;
/* Since the new directory arrives in the packager in the newItems-slot, we set a
* variable urlToSelectOnArrive here. The newItems-slot will honor it and select
* the treeviewitem with that url.
*/
slotSetNextUrlToSelect( url );
if( ! KIO::NetAccess::mkdir( url, 0, -1 ))
{
kDebug() << "Error: creation of" << url << "failed!";
}
else
{
/* created successfully */
/* open the branch if necessary and select the new folder */
}
}
}
}
示例14: 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 );
}
示例15: internalName
QString Theme::internalName() const {
KUrl url = d->mUrl;
url.setFileName("");
return url.fileName();
}