本文整理汇总了C++中KUrl::hasPath方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::hasPath方法的具体用法?C++ KUrl::hasPath怎么用?C++ KUrl::hasPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::hasPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateSuggestions
void CppHelperPluginConfigPage::updateSuggestions()
{
// Obtain a list of currecntly opened documents
auto documents = m_plugin->application()->documentManager()->documents();
// Collect paths
auto dirs = QStringList{};
const auto should_check_vcs = m_favorite_sets->vcsOnly->isChecked();
for (auto* current_doc : documents)
{
// Get current document's URI
const auto current_doc_uri = current_doc->url();
// Check if valid
if (current_doc_uri.isValid() && !current_doc_uri.isEmpty())
{
// Traverse over all parent dirs
for (
KUrl url = current_doc_uri.directory()
; url.hasPath() && url.path() != QDir::rootPath()
; url = url.upUrl()
)
{
auto dir = QDir::cleanPath(url.path()); // Obtain path as string
// Check uniqueness and other constraints
const bool should_add = dirs.indexOf(dir) == -1
&& !contains(dir, m_system_list->pathsList)
&& !contains(dir, m_session_list->pathsList)
&& (
(should_check_vcs && hasVCSDir(dir))
|| (!should_check_vcs && !isOneOfWellKnownPaths(dir) && !isFirstLevelPath(dir))
)
;
if (should_add) // Add current path only if not added yet
dirs << dir;
}
}
}
qSort(dirs);
kDebug(DEBUG_AREA) << "Suggestions list:" << dirs;
// Update combobox w/ collected list
m_favorite_sets->suggestionsList->clear();
m_favorite_sets->suggestionsList->addItems(dirs);
// Enable/disable controls according documents list emptyness
const auto is_enabled = !dirs.isEmpty();
m_favorite_sets->addSuggestedDirButton->setEnabled(is_enabled);
m_favorite_sets->suggestionsList->setEnabled(is_enabled);
}
示例2: 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;
}