本文整理汇总了C++中KUrl::isLocalFile方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::isLocalFile方法的具体用法?C++ KUrl::isLocalFile怎么用?C++ KUrl::isLocalFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::isLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KVBox
AudioPreview::AudioPreview( QWidget *parent, const KUrl &url, const QString &mimeType)
: KVBox( parent )
{
m_isTempFile = false;
pic = 0;
m_player = 0L;
description = 0;
setSpacing( 0 );
if( url.isValid() && url.isLocalFile() ) {
m_localFile = url.toLocalFile();
pic = new QLabel(this);
pic->setPixmap(KIO::pixmapForUrl( url ));
pic->adjustSize();
initView( mimeType );
} else if( !url.isLocalFile() ) {
KUrlLabel *label = new KUrlLabel( this );
label->setText(i18n("This audio file is not stored\non the local host.\nClick on this label to load it.\n" ) );
label->setUrl( url.prettyUrl() );
connect(label, SIGNAL(leftClickedUrl(const QString&)), SLOT(downloadFile(const QString&)));
pic = label;
} else {
description = new QLabel(this );
description->setText(i18n("Unable to load audio file") );
}
}
示例2: handleInsertFromFileAction
void KexiBlobTableEdit::handleInsertFromFileAction(const KUrl& url)
{
if (isReadOnly())
return;
QString fileName(url.isLocalFile() ? url.toLocalFile() : url.prettyUrl());
//! @todo download the file if remote, then set fileName properly
QFile f(fileName);
if (!f.open(IO_ReadOnly)) {
//! @todo err msg
return;
}
QByteArray ba = f.readAll();
if (f.error() != QFile::NoError) {
//! @todo err msg
f.close();
return;
}
f.close();
// m_valueMimeType = KImageIO::mimeType( fileName );
setValueInternal(ba, true);
signalEditRequested();
//emit acceptRequested();
}
示例3: if
BreadcrumbSiblingList
FileBrowser::Private::siblingsForDir( const KUrl &path )
{
BreadcrumbSiblingList siblings;
if( path.protocol() == "places" )
{
for( int i = 0; i < placesModel->rowCount(); i++ )
{
QModelIndex idx = placesModel->index( i, 0 );
QString name = idx.data( Qt::DisplayRole ).toString();
QString url = idx.data( KFilePlacesModel::UrlRole ).toString();
if( url.isEmpty() )
// the place perhaps needs mounting, use places url instead
url = placesString + name;
siblings << BreadcrumbSibling( idx.data( Qt::DecorationRole ).value<QIcon>(),
name, url );
}
}
else if( path.isLocalFile() )
{
QDir dir( path.toLocalFile() );
dir.cdUp();
foreach( const QString &item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
{
siblings << BreadcrumbSibling( KIcon( "folder-amarok" ), item,
dir.absoluteFilePath( item ) );
}
}
示例4: f
void K3b::MovixDoc::addUrlsAt( const KUrl::List& urls, int pos )
{
QList<K3b::MovixFileItem*> items;
for( KUrl::List::ConstIterator it = urls.begin(); it != urls.end(); ++it ) {
KUrl url = K3b::convertToLocalUrl( *it );
QFileInfo f( url.toLocalFile() );
if( !f.isFile() || !url.isLocalFile() )
continue;
QString newName = f.fileName();
bool ok = true;
while( ok && nameAlreadyInDir( newName, root() ) ) {
newName = KInputDialog::getText( i18n("Enter New Filename"),
i18n("A file with that name already exists. Please enter a new name:"),
newName, &ok, view() );
}
if( ok ) {
MovixFileItem* newItem = new MovixFileItem( f.absoluteFilePath(), *this, newName );
root()->addDataItem( newItem );
items.append( newItem );
}
}
addMovixItems( items, pos );
}
示例5: checkIfFolder
void AsyncFileTester::checkIfFolder(const QModelIndex &index, QObject *object, const char *method)
{
if (!index.isValid()) {
callResultMethod(object, method, index, false);
return;
}
KFileItem item = static_cast<const ProxyModel*>(index.model())->itemForIndex(index);
KUrl url = item.targetUrl();
if (item.isDir()) {
callResultMethod(object, method, index, true);
return;
}
if (item.isDesktopFile()) {
// Check if the desktop file is a link to a local folder
KDesktopFile file(url.path());
if (file.readType() == "Link") {
url = file.readUrl();
if (url.isLocalFile()) {
KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, url);
callResultMethod(object, method, index, destItem.isDir());
return;
}
if (KProtocolInfo::protocolClass(url.protocol()) == QString(":local")) {
AsyncFileTester *tester = new AsyncFileTester(index, object, method);
tester->delayedFolderCheck(url);
return;
}
}
}
callResultMethod(object, method, index, false);
}
示例6: slotExecuteShellCommand
void KShellCmdPlugin::slotExecuteShellCommand()
{
KParts::ReadOnlyPart *part = qobject_cast<KParts::ReadOnlyPart *>(parent());
if (!part) {
KMessageBox::sorry(0L, i18n("KShellCmdPlugin::slotExecuteShellCommand: Program error, please report a bug."));
return;
}
KUrl url = KIO::NetAccess::mostLocalUrl(part->url(), NULL);
if (!url.isLocalFile()) {
KMessageBox::sorry(part->widget(), i18n("Executing shell commands works only on local directories."));
return;
}
QString path;
KParts::FileInfoExtension *ext = KParts::FileInfoExtension::childObject(part);
if (ext && ext->hasSelection() && (ext->supportedQueryModes() & KParts::FileInfoExtension::SelectedItems)) {
KFileItemList list = ext->queryFor(KParts::FileInfoExtension::SelectedItems);
QStringList fileNames;
Q_FOREACH (const KFileItem &item, list) {
fileNames << item.name();
}
path = KShell::joinArgs(fileNames);
}
示例7: setUDSEntry
void KFileItem::setUDSEntry( const KIO::UDSEntry& _entry, const KUrl& _url,
bool _delayedMimeTypes, bool _urlIsDirectory )
{
d->m_entry = _entry;
d->m_url = _url;
d->m_strName.clear();
d->m_strText.clear();
d->m_iconName.clear();
d->m_strLowerCaseName.clear();
d->m_pMimeType = 0;
d->m_fileMode = KFileItem::Unknown;
d->m_permissions = KFileItem::Unknown;
d->m_bMarked = false;
d->m_bLink = false;
d->m_bIsLocalUrl = _url.isLocalFile();
d->m_bMimeTypeKnown = false;
d->m_hidden = KFileItemPrivate::Auto;
d->m_guessedMimeType.clear();
d->m_metaInfo = KFileMetaInfo();
d->m_delayedMimeTypes = _delayedMimeTypes;
d->m_useIconNameCache = false;
d->readUDSEntry( _urlIsDirectory );
d->init();
}
示例8: RCommand
RKLoadAgent::RKLoadAgent (const KUrl &url, bool merge) {
RK_TRACE (APP);
RKWardMainWindow::getMain ()->slotSetStatusBarText (i18n ("Loading Workspace ..."));
QString filename;
if (!url.isLocalFile ()) {
KIO::NetAccess::download (url, tmpfile, RKWardMainWindow::getMain ());
filename = tmpfile;
} else {
filename = url.toLocalFile ();
}
RCommand *command;
if (!merge) {
RKWardMainWindow::getMain ()->slotCloseAllWindows ();
command = new RCommand ("remove (list=ls (all.names=TRUE))", RCommand::App | RCommand::ObjectListUpdate);
RKGlobals::rInterface ()->issueCommand (command);
}
command = new RCommand ("load (\"" + filename + "\")", RCommand::App | RCommand::ObjectListUpdate, QString::null, this, WORKSPACE_LOAD_COMMAND);
RKGlobals::rInterface ()->issueCommand (command);
RKWorkplace::mainWorkplace ()->setWorkspaceURL (url);
}
示例9: selectPixmapFileName
QString PixmapEdit::selectPixmapFileName()
{
/*#ifdef PURE_QT
QString url = QFileDialog::getOpenFileName();
if (!url.isEmpty()) {
m_edit->setPixmap(QPixmap(url));
emit valueChanged(this);
}
#endif*/
const QString caption(i18n("Insert Image From File (for \"%1\" property)", m_property->caption()));
/*KDE4:
#ifdef Q_WS_WIN
QString recentDir;
QString fileName = Q3FileDialog::getOpenFileName(
KFileDialog::getStartURL(":lastVisitedImagePath", recentDir).path(),
convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)),
this, 0, caption);
#else*/
const KUrl url(KFileDialog::getImageOpenUrl(
KUrl(":lastVisitedImagePath"), this, caption));
QString fileName = url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();
//! @todo download the file if remote, then set fileName properly
//#endif
return fileName;
}
示例10: exists
bool NetAccess::exists( const KUrl & url, StatSide side, QWidget* window )
{
if ( url.isLocalFile() )
return QFile::exists( url.toLocalFile() );
NetAccess kioNet;
return kioNet.statInternal( url, 0 /*no details*/, side, window );
}
示例11: download
bool NetAccess::download(const KUrl& u, QString & target, QWidget* window)
{
if (u.isLocalFile()) {
// file protocol. We do not need the network
target = u.toLocalFile();
bool accessible = KStandardDirs::checkAccess(target, R_OK);
if(!accessible)
{
if(!lastErrorMsg)
lastErrorMsg = new QString;
*lastErrorMsg = i18n("File '%1' is not readable", target);
lastErrorCode = ERR_COULD_NOT_READ;
}
return accessible;
}
if (target.isEmpty())
{
KTemporaryFile tmpFile;
tmpFile.setAutoRemove(false);
tmpFile.open();
target = tmpFile.fileName();
if (!tmpfiles)
tmpfiles = new QStringList;
tmpfiles->append(target);
}
NetAccess kioNet;
KUrl dest;
dest.setPath( target );
return kioNet.filecopyInternal( u, dest, -1, KIO::Overwrite, window, false /*copy*/);
}
示例12: load
bool KTCLI::load(const KUrl & url)
{
QDir dir(url.toLocalFile());
if (dir.exists() && dir.exists("torrent") && dir.exists("stats"))
{
// Load existing torrent
if (loadFromDir(dir.absolutePath()))
{
tc->start();
connect(&timer,SIGNAL(timeout()),this,SLOT(update()));
timer.start(250);
return true;
}
}
else if (url.isLocalFile())
{
QString path = url.toLocalFile();
if (loadFromFile(path))
{
tc->start();
connect(&timer,SIGNAL(timeout()),this,SLOT(update()));
timer.start(250);
return true;
}
}
else
{
Out(SYS_GEN|LOG_IMPORTANT) << "Non local files not supported" << endl;
}
return false;
}
示例13: 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();
}
示例14: loadSilently
void Core::loadSilently(const KUrl& url, const QString& group)
{
if (url.protocol() == "magnet")
{
MagnetLinkLoadOptions options;
options.silently = true;
options.group = group;
load(bt::MagnetLink(url.prettyUrl()), options);
}
else if (url.isLocalFile())
{
QString path = url.toLocalFile();
QString dir = locationHint(group);
if (dir != QString::null)
loadFromFile(path, dir, group, true);
}
else
{
// download to a random file in tmp
KIO::Job* j = KIO::storedGet(url);
connect(j, SIGNAL(result(KJob*)), this, SLOT(downloadFinishedSilently(KJob*)));
if (!group.isNull())
add_to_groups.insert(url, group);
}
}
示例15:
QString KUrlNavigator::Private::firstButtonText() const
{
QString text;
// The first URL navigator button should get the name of the
// place instead of the directory name
if ((m_placesSelector != 0) && !m_showFullPath) {
const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
text = m_placesSelector->selectedPlaceText();
}
if (text.isEmpty()) {
const KUrl currentUrl = q->locationUrl();
if (currentUrl.isLocalFile()) {
text = m_showFullPath ? QLatin1String("/") : i18n("Custom Path");
} else {
text = currentUrl.protocol() + QLatin1Char(':');
if (!currentUrl.host().isEmpty()) {
text += QLatin1Char(' ') + currentUrl.host();
}
}
}
return text;
}