Cleaned up url display code

This commit is contained in:
Jonathan White 2017-10-25 23:29:01 -04:00 committed by thez3ro
parent b9fd609bb2
commit f3d85ae219
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
4 changed files with 11 additions and 7 deletions

View File

@ -247,6 +247,13 @@ QString Entry::webUrl() const
return resolveUrl(url);
}
QString Entry::displayUrl() const
{
QString url = maskPasswordPlaceholders(m_attributes->value(EntryAttributes::URLKey));
url = resolveMultiplePlaceholders(url);
return resolveUrl(url);
}
QString Entry::username() const
{
return m_attributes->value(EntryAttributes::UserNameKey);

View File

@ -79,6 +79,7 @@ public:
QString title() const;
QString url() const;
QString webUrl() const;
QString displayUrl() const;
QString username() const;
QString password() const;
QString notes() const;

View File

@ -114,10 +114,7 @@ void DetailsWidget::getSelectedEntry(Entry* selectedEntry)
// URL is well formed and can be opened in a browser
// create a new display url that masks password placeholders
// the actual link will use the password
QString displayUrl = m_currentEntry->url();
displayUrl = m_currentEntry->maskPasswordPlaceholders(displayUrl);
displayUrl = m_currentEntry->resolveMultiplePlaceholders(displayUrl);
url = QString("<a href=\"%1\">%2</a>").arg(url).arg(shortUrl(displayUrl));
url = QString("<a href=\"%1\">%2</a>").arg(url).arg(shortUrl(m_currentEntry->displayUrl()));
m_ui->urlLabel->setOpenExternalLinks(true);
} else {
// Fallback to the raw url string
@ -325,4 +322,4 @@ void DetailsWidget::updateTabIndex(int index) {
} else {
m_selectedTabEntry = index;
}
}
}

View File

@ -151,8 +151,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
}
return result;
case Url:
result = entry->maskPasswordPlaceholders(entry->url());
result = entry->resolveMultiplePlaceholders(result);
result = entry->displayUrl();
if (attr->isReference(EntryAttributes::URLKey)) {
result.prepend(tr("Ref: ","Reference abbreviation"));
}