本文整理汇总了C++中QUrl::isParentOf方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::isParentOf方法的具体用法?C++ QUrl::isParentOf怎么用?C++ QUrl::isParentOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::isParentOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isParentOf
bool QUrlProto::isParentOf(const QUrl &childUrl) const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->isParentOf(childUrl);
return false;
}
示例2: isParentOf
int Url::isParentOf ( lua_State * L )// ( const QUrl & childUrl ) const : bool
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
QUrl* childUrl = ValueInstaller2<QUrl>::check( L, 2 );
Util::push( L, lhs->isParentOf( *childUrl ) );
return 1;
}
示例3: displayUrl
static QString displayUrl(const QUrl &url, const QUrl &base)
{
if (base.isParentOf(url)) {
return url.toDisplayString(QUrl::PreferLocalFile).mid(base.toDisplayString(QUrl::PreferLocalFile).length());
} else {
return ICore::self()->projectController()->prettyFileName(url, IProjectController::FormatPlain);
}
}
示例4: isBlacklisted
bool NetworkAccessManager::isBlacklisted(QUrl url) {
QListIterator<QUrl> iter(m_urlBlacklist);
while (iter.hasNext()) {
QUrl blacklisted = iter.next();
if (blacklisted == url) {
return true;
} else if (blacklisted.path().isEmpty() && blacklisted.isParentOf(url)) {
return true;
}
}
return false;
};
示例5: findRootIndex
QModelIndex FolderViewContextManagerItem::findRootIndex(const QUrl& wantedUrl)
{
QModelIndex matchIndex;
int matchUrlLength = 0;
for (int row = 0; row < mModel->rowCount(); ++row) {
QModelIndex index = mModel->index(row, 0);
QUrl url = mModel->urlForIndex(index);
int urlLength = url.url().length();
if (url.isParentOf(wantedUrl) && urlLength > matchUrlLength) {
matchIndex = index;
matchUrlLength = urlLength;
}
}
if (!matchIndex.isValid()) {
qWarning() << "Found no root index for" << wantedUrl;
}
return matchIndex;
}
示例6: closestItem
int PlacesItemModel::closestItem(const QUrl& url) const
{
int foundIndex = -1;
int maxLength = 0;
for (int i = 0; i < count(); ++i) {
const QUrl itemUrl = placesItem(i)->url();
if (url == itemUrl) {
// We can't find a closer one, so stop here.
foundIndex = i;
break;
} else if (itemUrl.isParentOf(url)) {
const int length = itemUrl.path().length();
if (length > maxLength) {
foundIndex = i;
maxLength = length;
}
}
}
return foundIndex;
}
示例7: findClosestIndex
QModelIndex FolderViewContextManagerItem::findClosestIndex(const QModelIndex& parent, const QUrl& wantedUrl)
{
Q_ASSERT(mModel);
QModelIndex index = parent;
if (!index.isValid()) {
index = findRootIndex(wantedUrl);
if (!index.isValid()) {
return QModelIndex();
}
}
QUrl url = mModel->urlForIndex(index);
if (!url.isParentOf(wantedUrl)) {
qWarning() << url << "is not a parent of" << wantedUrl << "!";
return QModelIndex();
}
QString relativePath = QDir(url.path()).relativeFilePath(wantedUrl.path());
QModelIndex lastFoundIndex = index;
Q_FOREACH(const QString & pathPart, relativePath.split(QDir::separator(), QString::SkipEmptyParts)) {
bool found = false;
for (int row = 0; row < mModel->rowCount(lastFoundIndex); ++row) {
QModelIndex index = mModel->index(row, 0, lastFoundIndex);
if (index.data().toString() == pathPart) {
// FIXME: Check encoding
found = true;
lastFoundIndex = index;
break;
}
}
if (!found) {
break;
}
}
return lastFoundIndex;
}
示例8: setListContent
//! [set list content]
void FtpReply::setListContent()
{
QUrl u = url();
if (!u.path().endsWith("/"))
u.setPath(u.path() + "/");
QString base_url = url().toString();
QString base_path = u.path();
open(ReadOnly | Unbuffered);
QString content(
"<html>\n"
"<head>\n"
" <title>" + Qt::escape(base_url) + "</title>\n"
" <style type=\"text/css\">\n"
" th { background-color: #aaaaaa; color: black }\n"
" table { border: solid 1px #aaaaaa }\n"
" tr.odd { background-color: #dddddd; color: black\n }\n"
" tr.even { background-color: white; color: black\n }\n"
" </style>\n"
"</head>\n\n"
"<body>\n"
"<h1>" + tr("Listing for %1").arg(base_path) + "</h1>\n\n"
"<table align=\"center\" cellspacing=\"0\" width=\"90%\">\n"
"<tr><th>Name</th><th>Size</th></tr>\n");
QUrl parent = u.resolved(QUrl(".."));
if (parent.isParentOf(u))
content += QString("<tr><td><strong><a href=\"" + parent.toString() + "\">"
+ tr("Parent directory") + "</a></strong></td><td></td></tr>\n");
int i = 0;
foreach (const QUrlInfo &item, items) {
QUrl child = u.resolved(QUrl(item.name()));
if (i == 0)
content += QString("<tr class=\"odd\">");
else
content += QString("<tr class=\"even\">");
content += QString("<td><a href=\"" + child.toString() + "\">"
+ Qt::escape(item.name()) + "</a></td>");
qint64 size = item.size();
int unit = 0;
while (size) {
qint64 new_size = size/1024;
if (new_size && unit < units.size()) {
size = new_size;
unit += 1;
} else
break;
}
if (item.isFile())
content += QString("<td>" + QString::number(size) + " "
+ units[unit] + "</td></tr>\n");
else
content += QString("<td></td></tr>\n");
i = 1 - i;
}