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


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

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


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

示例1: generateKey

static QString generateKey(const KUrl& url)
{
  QString key;

  if (url.isValid()) {
    key = url.protocol();
    key += QLatin1Char(':');

    if (url.hasHost()) {
      key += url.host();
      key += QLatin1Char(':');
    }

    if (url.hasPath()) {
        key += url.path();
    }
  }

  return key;
}
开发者ID:theunbelievablerepo,项目名称:dolphin2.1,代码行数:20,代码来源:dirfilterplugin.cpp

示例2: checkCorrectRepository

bool BupSlave::checkCorrectRepository(const KUrl &pUrl, QStringList &pPathInRepository) {
	// make this slave accept most URLs.. even incorrect ones. (no slash (wrong),
	// one slash (correct), two slashes (wrong), three slashes (correct))
	QString lPath;
	if(pUrl.hasHost()) {
		lPath = QLatin1String("/") + pUrl.host() + pUrl.path(KUrl::AddTrailingSlash);
	} else {
		lPath = pUrl.path(KUrl::AddTrailingSlash);
		if(!lPath.startsWith(QLatin1Char('/'))) {
			lPath.prepend(QLatin1Char('/'));
		}
	}

	if(mRepository && mRepository->isValid()) {
		if(lPath.startsWith(mRepository->objectName())) {
			lPath.remove(0, mRepository->objectName().length());
			pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
			return true;
		}
		else {
			delete mRepository;
			mRepository = NULL;
		}
	}

	pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
	QString lRepoPath = QString::fromLatin1("/");
	while(!pPathInRepository.isEmpty()) {
		// make sure the repo path will end with a slash
		lRepoPath += pPathInRepository.takeFirst();
		lRepoPath += QLatin1String("/");
		if((QFile::exists(lRepoPath + QLatin1String("objects")) &&
		    QFile::exists(lRepoPath + QLatin1String("refs"))) ||
		      (QFile::exists(lRepoPath + QLatin1String(".git/objects")) &&
		       QFile::exists(lRepoPath + QLatin1String(".git/refs")))) {
			mRepository = new Repository(NULL, lRepoPath);
			return mRepository->isValid();
		}
	}
	return false;
}
开发者ID:josejamilena,项目名称:Kup,代码行数:41,代码来源:bupslave.cpp

示例3: filterUri


//.........这里部分代码省略.........
    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;
      }
    }
  }

  if( path[0] == '~' )
  {
    int slashPos = path.indexOf('/');
    if( slashPos == -1 )
      slashPos = path.length();
    if( slashPos == 1 )   // ~/
    {
      path.replace ( 0, 1, QDir::homePath() );
    }
    else // ~username/
    {
      const QString userName (path.mid( 1, slashPos-1 ));
      KUser user (userName);
      if( user.isValid() && !user.homeDir().isEmpty())
      {
        path.replace (0, slashPos, user.homeDir());
      }
      else
      {
        if (user.isValid()) {
          setErrorMsg(data, i18n("<qt><b>%1</b> does not have a home folder.</qt>", userName));
        } else {
开发者ID:KDE,项目名称:kde-runtime,代码行数:67,代码来源:kshorturifilter.cpp


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