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


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

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


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

示例1: 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

示例2: stat

void TrashProtocol::stat(const KUrl& url)
{
    INIT_IMPL;
    const QString path = url.path();
    if (path.isEmpty() || path == QLatin1String("/")) {
        // The root is "virtual" - it's not a single physical directory
        KIO::UDSEntry entry;
        createTopLevelDirEntry( entry );
        statEntry( entry );
        finished();
    } else {
        int trashId;
        QString fileId, relativePath;

        bool ok = TrashImpl::parseURL( url, trashId, fileId, relativePath );

        if ( !ok ) {
            // ######## do we still need this?
            kDebug() << url << " looks fishy, returning does-not-exist";
            // A URL like trash:/file simply means that CopyJob is trying to see if
            // the destination exists already (it made up the URL by itself).
            error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
            //error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1" ).arg( url.prettyUrl() ) );
            return;
        }

        kDebug() << "parsed" << url << "got" << trashId << fileId << relativePath;

        const QString filePath = impl.physicalPath( trashId, fileId, relativePath );
        if ( filePath.isEmpty() ) {
            error( impl.lastErrorCode(), impl.lastErrorMessage() );
            return;
        }

        // For a toplevel file, use the fileId as display name (to hide the trashId)
        // For a file in a subdir, use the fileName as is.
        QString fileDisplayName = relativePath.isEmpty() ? fileId : url.fileName();

        KUrl fileURL;
        if ( url.path().length() > 1 ) {
            fileURL = url;
        }

        KIO::UDSEntry entry;
        TrashedFileInfo info;
        ok = impl.infoForFile( trashId, fileId, info );
        if ( ok )
            ok = createUDSEntry( filePath, fileDisplayName, fileURL.fileName(), entry, info );

        if ( !ok ) {
            error( KIO::ERR_COULD_NOT_STAT, url.prettyUrl() );
            return;
        }

        statEntry( entry );
        finished();
    }
}
开发者ID:KDE,项目名称:kde-runtime,代码行数:58,代码来源:kio_trash.cpp

示例3: 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;
}
开发者ID:unwork-inc,项目名称:soundkonverter,代码行数:11,代码来源:outputdirectory.cpp

示例4: values

QVariantHash ChooseSamba::values() const
{
    QVariantHash ret = m_args;

    QString address = ui->addressLE->text().trimmed();
    KUrl url;
    if (address.startsWith(QLatin1String("//"))) {
        url = QLatin1String("smb:") % address;
    } else if (address.startsWith(QLatin1String("/"))) {
        url = QLatin1String("smb:/") % address;
    } else if (address.startsWith(QLatin1String("://"))) {
        url = QLatin1String("smb") % address;
    } else if (address.startsWith(QLatin1String("smb://"))) {
        url = address;
    } else if (!KUrl(address).protocol().isEmpty() &&
               KUrl(address).protocol() != QLatin1String("smb")) {
        url = address;
        url.setProtocol(QLatin1String("smb"));
    } else {
        url = QLatin1String("smb://") % address;
    }

    kDebug() << 1 << url;
    if (!ui->usernameLE->text().isEmpty()) {
        url.setUser(ui->usernameLE->text());
    }

    if (!ui->passwordLE->text().isEmpty()) {
        url.setPass(ui->passwordLE->text());
    }

    kDebug() << 2 << url;
    kDebug() << 3 << url.url() << url.path().section(QLatin1Char('/'), -1, -1);// same as url.fileName()
    kDebug() << 4 << url.fileName();
    kDebug() << 5 << url.host() << url.url().section(QLatin1Char('/'), 3, 3).toLower();

    ret[KCUPS_DEVICE_URI] = url.url();
    ret[KCUPS_DEVICE_INFO] = url.fileName();

    // if there is 4 '/' means the url is like
    // smb://group/host/printer, so the location is at a different place
    if (url.url().count(QLatin1Char('/') == 4)) {
        ret[KCUPS_DEVICE_LOCATION] = url.url().section(QLatin1Char('/'), 3, 3).toLower();
    } else {
        ret[KCUPS_DEVICE_LOCATION] = url.host();
    }

    return ret;
}
开发者ID:freexploit,项目名称:print-manager,代码行数:49,代码来源:ChooseSamba.cpp

示例5: fileSaveAs

void MainWindow::fileSaveAs()
{
    WebTab *w = currentTab();
    KUrl srcUrl = w->url();
    
    // First, try with suggested file name...
    QString name = w->page()->suggestedFileName();

    // Second, with KUrl fileName...
    if (name.isEmpty())
    {
        name = srcUrl.fileName();
    }
    
    // Last chance...
    if(name.isEmpty())
    {
        name = srcUrl.host() + QString(".html");
    }
    
    const QString destUrl = KFileDialog::getSaveFileName(name, QString(), this);
    if (destUrl.isEmpty()) 
        return;
    
    KIO::Job *job = KIO::file_copy(srcUrl, KUrl(destUrl), -1, KIO::Overwrite);
    job->addMetaData("MaxCacheSize", "0");  // Don't store in http cache.
    job->addMetaData("cache", "cache");     // Use entry from cache if available.
    job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
开发者ID:Fxrh,项目名称:rekonq,代码行数:29,代码来源:mainwindow.cpp

示例6: foreach

static KUrl::List thread_getProjectFiles(const KUrl dir, bool recursive, const QStringList include,
                                         const QStringList exlude, volatile bool &abort)
{
    ///@todo This is not thread-safe!
    KDevelop::IProject *project = KDevelop::ICore::self()->projectController()->findProjectForUrl( dir );
    KUrl::List res;
    if(!project)
        return res;

    const QSet<IndexedString> fileSet = project->fileSet();
    foreach( const IndexedString &item, fileSet )
    {
        if(abort)
            break;
        KUrl url = item.toUrl();
        if( !url.equals(dir) )
        {
            if( recursive && !dir.isParentOf(url) )
                continue;
            if( !recursive && !url.upUrl().equals(dir, KUrl::CompareWithoutTrailingSlash))
                continue;
        }
        if( QDir::match(include, url.fileName()) && !QDir::match(exlude, url.toLocalFile()) )
            res << url;
    }

    return res;
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:28,代码来源:grepfindthread.cpp

示例7: 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";
    }
开发者ID:saurabhsood91,项目名称:Amarok,代码行数:60,代码来源:M3UPlaylist.cpp

示例8: promptUser

static KUrl promptUser (QWidget *parent, const KUrl& url, const QString& suggestedName)
{
    KUrl destUrl;
    int result = KIO::R_OVERWRITE;
    const QString fileName ((suggestedName.isEmpty() ? url.fileName() : suggestedName));

    do {
        // convert filename to URL using fromPath to avoid trouble with ':' in filenames (#184202)
        destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);

        if (destUrl.isLocalFile()) {
            QFileInfo finfo (destUrl.toLocalFile());
            if (finfo.exists()) {
                QDateTime now = QDateTime::currentDateTime();
                KIO::RenameDialog dlg (parent, i18n("Overwrite File?"), url, destUrl,
                                       KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP),
                                       -1, finfo.size(),
                                       now.toTime_t(), finfo.created().toTime_t(),
                                       now.toTime_t(), finfo.lastModified().toTime_t());
                result = dlg.exec();
            }
        }
    } while (result == KIO::R_CANCEL && destUrl.isValid());

    return destUrl;
}
开发者ID:vasi,项目名称:kdelibs,代码行数:26,代码来源:kwebpage.cpp

示例9: slotFileRenamed

bool ScanGallery::slotFileRenamed(FileTreeViewItem *item, const QString &newName)
{
    if (item->isRoot()) return (false);			// cannot rename root here

    KUrl urlFrom = item->url();
    kDebug() << "url" << urlFrom << "->" << newName;
    QString oldName = urlFrom.fileName();

    KUrl urlTo(urlFrom);
    urlTo.setFileName(newName);

    /* clear selection, because the renamed image comes in through
     * kdirlister again
     */
    // slotUnloadItem(item);				// unnecessary, bug 68532
							// because of "note new URL" below
    kDebug() << "Renaming " << urlFrom << "->" << urlTo;

    //setSelected(item,false);

    bool success = ImgSaver::renameImage(urlFrom, urlTo, true, this);
    if (success)					// rename the file
    {
        item->setUrl(urlTo);				// note new URL
        emit fileRenamed(item->fileItem(), newName);
    }
    else
    {
        kDebug() << "renaming failed";
        item->setText(0, oldName);			// restore original name
    }

//    setSelected(item,true);				// restore the selection
    return (success);
}
开发者ID:KDE,项目名称:kooka,代码行数:35,代码来源:scangallery.cpp

示例10: slotLoadSettings

void ResizeTool::slotLoadSettings()
{
    KUrl loadBlowupFile = KFileDialog::getOpenUrl(KGlobalSettings::documentPath(),
                          QString( "*" ), kapp->activeWindow(),
                          QString( i18n("Photograph Resizing Settings File to Load")) );

    if ( loadBlowupFile.isEmpty() )
    {
        return;
    }

    QFile file(loadBlowupFile.toLocalFile());

    if ( file.open(QIODevice::ReadOnly) )
    {
        if (!d->settingsWidget->loadSettings(file, QString("# Photograph Resizing Configuration File")))
        {
            KMessageBox::error(kapp->activeWindow(),
                               i18n("\"%1\" is not a Photograph Resizing settings text file.",
                                    loadBlowupFile.fileName()));
            file.close();
            return;
        }
    }
    else
    {
        KMessageBox::error(kapp->activeWindow(),
                           i18n("Cannot load settings from the Photograph Resizing text file."));
    }

    file.close();
}
开发者ID:UIKit0,项目名称:digikam,代码行数:32,代码来源:resizetool.cpp

示例11: KFileItemPrivate

 KFileItemPrivate(const KIO::UDSEntry& entry,
                  mode_t mode, mode_t permissions,
                  const KUrl& itemOrDirUrl,
                  bool urlIsDirectory,
                  bool delayedMimeTypes)
     : m_entry( entry ),
       m_url(itemOrDirUrl),
       m_strName(),
       m_strText(),
       m_iconName(),
       m_strLowerCaseName(),
       m_pMimeType( 0 ),
       m_fileMode( mode ),
       m_permissions( permissions ),
       m_bMarked( false ),
       m_bLink( false ),
       m_bIsLocalUrl(itemOrDirUrl.isLocalFile()),
       m_bMimeTypeKnown( false ),
       m_delayedMimeTypes( delayedMimeTypes ),
       m_useIconNameCache(false),
       m_hidden( Auto )
 {
     if (entry.count() != 0) {
         readUDSEntry( urlIsDirectory );
     } else {
         Q_ASSERT(!urlIsDirectory);
         m_strName = itemOrDirUrl.fileName();
         m_strText = KIO::decodeFileName( m_strName );
     }
     init();
 }
开发者ID:vasi,项目名称:kdelibs,代码行数:31,代码来源:kfileitem.cpp

示例12: slotRename

void KonqSessionDlg::slotRename(KUrl dirpathTo)
{
    if ( !d->m_pListView->currentIndex().isValid() )
        return;
    
    KUrl dirpathFrom = d->m_pModel->itemForIndex(
        d->m_pListView->currentIndex()).url();
    
    dirpathTo = (dirpathTo == KUrl()) ? dirpathFrom : dirpathTo;
    
    KIO::RenameDialog dlg(this, i18nc("@title:window", "Rename Session"), dirpathFrom,
        dirpathTo, KIO::RenameDialog_Mode(0));
        
    if(dlg.exec() == KIO::R_RENAME)
    {
        dirpathTo = dlg.newDestUrl();
        QDir dir(dirpathTo.path());
        if(dir.exists())
            slotRename(dirpathTo);
        else {
            QDir dir(KStandardDirs::locateLocal("appdata", "sessions/"));
            dir.rename(dirpathFrom.fileName(), dlg.newDestUrl().fileName());
        }
    } 
}
开发者ID:blue-shell,项目名称:folderview,代码行数:25,代码来源:konqsessiondlg.cpp

示例13: doStart

void FileTransferJob::doStart()
{
    description(this, i18n("Receiving file over KDE-Connect"),
        QPair<QString, QString>(i18nc("File transfer origin", "From"),
        QString(mDeviceName))
    );
    KUrl destCheck = mDestination;
    if (QFile::exists(destCheck.path())) {
        QFileInfo destInfo(destCheck.path());
        KIO::RenameDialog *dialog = new KIO::RenameDialog(0,
            i18n("Incoming file exists"),
            KUrl(mDeviceName + ":/" + destCheck.fileName()),
            destCheck,
            KIO::M_OVERWRITE,
            mSize,
            destInfo.size(),
            -1,
            destInfo.created().toTime_t(),
            -1,
            destInfo.lastModified().toTime_t()
        );
        connect(this, SIGNAL(finished(KJob*)), dialog, SLOT(deleteLater()));
        connect(dialog, SIGNAL(finished(int)), SLOT(renameDone(int)));
        dialog->show();
        return;
    }
开发者ID:build3r,项目名称:kdeconnect-kde,代码行数:26,代码来源:filetransferjob.cpp

示例14: stat

void ApplicationsProtocol::stat(const KUrl& url)
{
    KIO::UDSEntry entry;

    QString servicePath( url.path( KUrl::AddTrailingSlash ) );
    servicePath.remove(0, 1); // remove starting '/'

    KServiceGroup::Ptr grp = KServiceGroup::group(servicePath);

    if (grp && grp->isValid()) {
        createDirEntry(entry, ((m_runMode==ApplicationsMode) ? i18n("Applications") : i18n("Programs")),
                       url.url(), "inode/directory",grp->icon() );
    } else {
        KService::Ptr service = KService::serviceByDesktopName( url.fileName() );
        if (service && service->isValid()) {
            createFileEntry(entry, service, url );
        } else {
            error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown application folder"));
            return;
        }
    }

    statEntry(entry);
    finished();
}
开发者ID:KDE,项目名称:kde-runtime,代码行数:25,代码来源:kio_applications.cpp

示例15: saveButton

ImageViewer::ImageViewer (const KUrl &url, const QString &capText, QWidget *parent) :
    KDialog( parent ),
    m_ImageUrl(url),
    fileIsImage(false),
    downloadJob(0)
{
    init(url.fileName(), capText);
    // Add save button
    setButtons( KDialog::User2 | KDialog::User1 | KDialog::Close );

    KGuiItem saveButton( i18n("Save"), "document-save", i18n("Save the image to disk") );
    setButtonGuiItem( KDialog::User1, saveButton );

    // FIXME: Add more options, and do this more nicely
    KGuiItem invertButton( i18n("Invert colors"), "", i18n("Reverse colors of the image. This is useful to enhance contrast at times. This affects only the display and not the saving.") );
    setButtonGuiItem( KDialog::User2, invertButton );

    connect( this, SIGNAL( user1Clicked() ), this, SLOT ( saveFileToDisc() ) );
    connect( this, SIGNAL( user2Clicked() ), this, SLOT ( invertColors() ) );
    // check URL
    if (!m_ImageUrl.isValid())
        kDebug() << "URL is malformed: " << m_ImageUrl;
    
    // FIXME: check the logic with temporary files. Races are possible
    {
        KTemporaryFile tempfile;
        tempfile.open();
        file.setFileName( tempfile.fileName() );
    }// we just need the name and delete the tempfile from disc; if we don't do it, a dialog will be show

    loadImageFromURL();
}
开发者ID:mohanaprasad1994,项目名称:kstars-hackfest,代码行数:32,代码来源:imageviewer.cpp


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