本文整理汇总了C++中KUrl::ref方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::ref方法的具体用法?C++ KUrl::ref怎么用?C++ KUrl::ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectItem
void Navigator::selectItem( const KUrl &url )
{
kDebug() << "Navigator::selectItem(): " << url.url();
if ( url.url() == "khelpcenter:home" ) {
clearSelection();
return;
}
// help:/foo&anchor=bar gets redirected to help:/foo#bar
// Make sure that we match both the original URL as well as
// its counterpart.
KUrl alternativeURL = url;
if (url.hasRef())
{
alternativeURL.setQuery("anchor="+url.ref());
alternativeURL.setRef(QString());
}
// If the navigator already has the given URL selected, do nothing.
NavigatorItem *item;
item = static_cast<NavigatorItem *>( mContentsTree->currentItem() );
if ( item && mSelected ) {
KUrl currentURL ( item->entry()->url() );
if ( (currentURL == url) || (currentURL == alternativeURL) ) {
kDebug() << "URL already shown.";
return;
}
}
// First, populate the NavigatorAppItems if we don't want the home page
if ( url != homeURL() ) {
QTreeWidgetItemIterator it1( mContentsTree );
while( (*it1) )
{
NavigatorAppItem *appItem = dynamic_cast<NavigatorAppItem *>( (*it1) );
if ( appItem ) appItem->populate( true );
++it1;
}
}
QTreeWidgetItemIterator it( mContentsTree );
while ( (*it) ) {
NavigatorItem *item = static_cast<NavigatorItem *>( (*it) );
KUrl itemUrl( item->entry()->url() );
if ( (itemUrl == url) || (itemUrl == alternativeURL) ) {
mContentsTree->setCurrentItem( item );
// If the current item was not selected and remained unchanged it
// needs to be explicitly selected
mContentsTree->setCurrentItem(item);
item->setExpanded( true );
break;
}
++it;
}
if ( !(*it) ) {
clearSelection();
} else {
mSelected = true;
}
}
示例2: filterUri
//.........这里部分代码省略.........
const QString info_proto = QL1S("info:");
if( cmd[0] == '#' ||
cmd.indexOf( man_proto ) == 0 ||
cmd.indexOf( info_proto ) == 0 )
{
if( cmd.left(2) == QL1S("##") )
cmd = QL1S("info:/") + cmd.mid(2);
else if ( cmd[0] == '#' )
cmd = QL1S("man:/") + cmd.mid(1);
else if ((cmd==info_proto) || (cmd==man_proto))
cmd+='/';
setFilteredUri( data, KUrl( cmd ));
setUriType( data, KUriFilterData::Help );
return true;
}
// Detect UNC style (aka windows SMB) URLs
if ( cmd.startsWith( QLatin1String( "\\\\") ) )
{
// make sure path is unix style
cmd.replace('\\', '/');
cmd.prepend( QLatin1String( "smb:" ) );
setFilteredUri( data, KUrl( cmd ));
setUriType( data, KUriFilterData::NetProtocol );
return true;
}
bool expanded = false;
// Expanding shortcut to HOME URL...
QString path;
QString ref;
QString query;
QString nameFilter;
if (KUrl::isRelativeUrl(cmd) && QDir::isRelativePath(cmd)) {
path = cmd;
//kDebug(7023) << "path=cmd=" << path;
} else {
if (url.isLocalFile())
{
//kDebug(7023) << "hasRef=" << url.hasRef();
// Split path from ref/query
// but not for "/tmp/a#b", if "a#b" is an existing file,
// or for "/tmp/a?b" (#58990)
if( ( url.hasRef() || !url.query().isEmpty() )
&& !url.path().endsWith(QL1S("/")) ) // /tmp/?foo is a namefilter, not a query
{
path = url.path();
ref = url.ref();
//kDebug(7023) << "isLocalFile set path to " << stringDetails( path );
//kDebug(7023) << "isLocalFile set ref to " << stringDetails( ref );
query = url.query();
if (path.isEmpty() && url.hasHost())
path = '/';
}
else
{
path = cmd;
//kDebug(7023) << "(2) path=cmd=" << path;
}
}
}