本文整理汇总了C++中QWebHitTestResult::linkTargetFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebHitTestResult::linkTargetFrame方法的具体用法?C++ QWebHitTestResult::linkTargetFrame怎么用?C++ QWebHitTestResult::linkTargetFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebHitTestResult
的用法示例。
在下文中一共展示了QWebHitTestResult::linkTargetFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotLinkHovered
void KWebKitPart::slotLinkHovered(const QString& _link, const QString& /*title*/, const QString& /*content*/)
{
QString message;
if (_link.isEmpty()) {
message = QL1S("");
emit m_browserExtension->mouseOverInfo(KFileItem());
} else {
QUrl linkUrl (_link);
const QString scheme = linkUrl.scheme();
// Protect the user against URL spoofing!
linkUrl.setUserName(QString());
const QString link (linkUrl.toString());
if (QString::compare(scheme, QL1S("mailto"), Qt::CaseInsensitive) == 0) {
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", "Email: ");
// Workaround: for QUrl's parsing deficiencies of "mailto:[email protected]".
if (!linkUrl.hasQuery())
linkUrl = QUrl(scheme + '?' + linkUrl.path());
QMap<QString, QStringList> fields;
QList<QPair<QString, QString> > queryItems = linkUrl.queryItems();
const int count = queryItems.count();
for(int i = 0; i < count; ++i) {
const QPair<QString, QString> queryItem (queryItems.at(i));
//kDebug() << "query: " << queryItem.first << queryItem.second;
if (queryItem.first.contains(QL1C('@')) && queryItem.second.isEmpty())
fields["to"] << queryItem.first;
if (QString::compare(queryItem.first, QL1S("to"), Qt::CaseInsensitive) == 0)
fields["to"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("cc"), Qt::CaseInsensitive) == 0)
fields["cc"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("bcc"), Qt::CaseInsensitive) == 0)
fields["bcc"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("subject"), Qt::CaseInsensitive) == 0)
fields["subject"] << queryItem.second;
}
if (fields.contains(QL1S("to")))
message += fields.value(QL1S("to")).join(QL1S(", "));
if (fields.contains(QL1S("cc")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - CC: ") + fields.value(QL1S("cc")).join(QL1S(", "));
if (fields.contains(QL1S("bcc")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - BCC: ") + fields.value(QL1S("bcc")).join(QL1S(", "));
if (fields.contains(QL1S("subject")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - Subject: ") + fields.value(QL1S("subject")).join(QL1S(" "));
} else if (scheme == QL1S("javascript")) {
message = KStringHandler::rsqueeze(link, 150);
if (link.startsWith(QL1S("javascript:window.open")))
message += i18n(" (In new window)");
} else {
message = link;
QWebFrame* frame = page() ? page()->currentFrame() : 0;
if (frame) {
QWebHitTestResult result = frame->hitTestContent(page()->view()->mapFromGlobal(QCursor::pos()));
QWebFrame* target = result.linkTargetFrame();
if (frame->parentFrame() && target == frame->parentFrame()) {
message += i18n(" (In parent frame)");
} else if (!target || target != frame) {
message += i18n(" (In new window)");
}
}
KFileItem item (linkUrl, QString(), KFileItem::Unknown);
emit m_browserExtension->mouseOverInfo(item);
}
}
emit setStatusBarText(message);
}