本文整理汇总了C++中KFileItem::mostLocalUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem::mostLocalUrl方法的具体用法?C++ KFileItem::mostLocalUrl怎么用?C++ KFileItem::mostLocalUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItem
的用法示例。
在下文中一共展示了KFileItem::mostLocalUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDesktopFile
/**
* Returns true if this is a desktop file.
* Mimetype determination is optional.
*/
static bool checkDesktopFile(const KFileItem& item, bool _determineMimeType)
{
// only local files
bool isLocal;
const KUrl url = item.mostLocalUrl(isLocal);
if (!isLocal)
return false;
// only regular files
if (!item.isRegularFile())
return false;
// only if readable
if (!item.isReadable())
return false;
// return true if desktop file
KMimeType::Ptr mime = _determineMimeType ? item.determineMimeType() : item.mimeTypePtr();
return mime->is("application/x-desktop");
}
示例2: asyncDrop
void KonqOperations::asyncDrop( const KFileItem & destItem )
{
assert(m_info); // setDropInfo should have been called before asyncDrop
bool m_destIsLocal = false;
m_destUrl = destItem.mostLocalUrl(m_destIsLocal); // #168154
//kDebug(1203) << "destItem->mode=" << destItem->mode() << " url=" << m_destUrl;
// Check what the destination is
if ( destItem.isDir() )
{
doDropFileCopy();
return;
}
if ( !m_destIsLocal )
{
// We dropped onto a remote URL that is not a directory!
// (e.g. an HTTP link in the sidebar).
// Can't do that, but we can't prevent it before stating the dest....
kWarning(1203) << "Cannot drop onto " << m_destUrl ;
deleteLater();
return;
}
if ( destItem.isDesktopFile() )
{
// Local .desktop file. What type ?
KDesktopFile desktopFile( m_destUrl.path() );
KConfigGroup desktopGroup = desktopFile.desktopGroup();
if ( desktopFile.hasApplicationType() )
{
QString error;
const QStringList urlStrList = m_info->urls.toStringList();
if ( KToolInvocation::startServiceByDesktopPath( m_destUrl.path(), urlStrList, &error ) > 0 )
KMessageBox::error( parentWidget(), error );
}
else
{
// Device or Link -> adjust dest
if ( desktopFile.hasDeviceType() && desktopGroup.hasKey("MountPoint") ) {
QString point = desktopGroup.readEntry( "MountPoint" );
m_destUrl.setPath( point );
QString dev = desktopFile.readDevice();
KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByDevice( dev );
// Is the device already mounted ?
if ( mp ) {
doDropFileCopy();
}
else
{
const bool ro = desktopGroup.readEntry( "ReadOnly", false );
const QByteArray fstype = desktopGroup.readEntry( "FSType" ).toLatin1();
KAutoMount* am = new KAutoMount( ro, fstype, dev, point, m_destUrl.path(), false );
connect( am, SIGNAL(finished()), this, SLOT(doDropFileCopy()) );
}
return;
}
else if ( desktopFile.hasLinkType() && desktopGroup.hasKey("URL") ) {
m_destUrl = desktopGroup.readPathEntry("URL", QString());
doDropFileCopy();
return;
}
// else, well: mimetype, service, servicetype or .directory. Can't really drop anything on those.
}
}
else
{
// Should be a local executable
// (If this fails, there is a bug in KFileItem::acceptsDrops / KDirModel::flags)
kDebug(1203) << m_destUrl.path() << "should be an executable";
Q_ASSERT ( access( QFile::encodeName(m_destUrl.path()), X_OK ) == 0 );
// Launch executable for each of the files
QStringList args;
const KUrl::List lst = m_info->urls;
KUrl::List::ConstIterator it = lst.begin();
for ( ; it != lst.end() ; it++ )
args << (*it).path(); // assume local files
kDebug(1203) << "starting " << m_destUrl.path() << " with " << lst.count() << " arguments";
QProcess::startDetached( m_destUrl.path(), args );
}
deleteLater();
}