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); 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 QString Entry::username() const
{ {
return m_attributes->value(EntryAttributes::UserNameKey); return m_attributes->value(EntryAttributes::UserNameKey);

View file

@ -79,6 +79,7 @@ public:
QString title() const; QString title() const;
QString url() const; QString url() const;
QString webUrl() const; QString webUrl() const;
QString displayUrl() const;
QString username() const; QString username() const;
QString password() const; QString password() const;
QString notes() 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 // URL is well formed and can be opened in a browser
// create a new display url that masks password placeholders // create a new display url that masks password placeholders
// the actual link will use the password // the actual link will use the password
QString displayUrl = m_currentEntry->url(); url = QString("<a href=\"%1\">%2</a>").arg(url).arg(shortUrl(m_currentEntry->displayUrl()));
displayUrl = m_currentEntry->maskPasswordPlaceholders(displayUrl);
displayUrl = m_currentEntry->resolveMultiplePlaceholders(displayUrl);
url = QString("<a href=\"%1\">%2</a>").arg(url).arg(shortUrl(displayUrl));
m_ui->urlLabel->setOpenExternalLinks(true); m_ui->urlLabel->setOpenExternalLinks(true);
} else { } else {
// Fallback to the raw url string // Fallback to the raw url string
@ -325,4 +322,4 @@ void DetailsWidget::updateTabIndex(int index) {
} else { } else {
m_selectedTabEntry = index; m_selectedTabEntry = index;
} }
} }

View file

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