Commit bbca0841 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use role constants and Columns enum values from namespace

parent f7d80849
......@@ -16,6 +16,7 @@
#include "certifycertificatecommand.h"
#include "kleopatra_debug.h"
#include <Libkleo/KeyList>
#include <Libkleo/KeyListSortFilterProxyModel>
#include <Libkleo/KeyCache>
#include <Libkleo/Predicates>
......@@ -88,7 +89,7 @@ protected:
if (!index.isValid() || role != Qt::ToolTipRole) {
return AbstractKeyListSortFilterProxyModel::data(index, role);
}
const QString fpr = index.data(FingerprintRole).toString();
const QString fpr = index.data(KeyList::FingerprintRole).toString();
// find information:
const std::vector<Import>::const_iterator it
= qBinaryFind(m_importsByFingerprint.begin(), m_importsByFingerprint.end(),
......@@ -118,7 +119,7 @@ protected:
//
// 1. Check that this is an imported key:
//
const QString fpr = index.data(FingerprintRole).toString();
const QString fpr = index.data(KeyList::FingerprintRole).toString();
return std::binary_search(m_importsByFingerprint.begin(), m_importsByFingerprint.end(),
fpr.toLatin1().constData(),
......
......@@ -20,6 +20,7 @@
#include <Libkleo/KeyCache>
#include <Libkleo/KeyFilter>
#include <Libkleo/KeyList>
#include <Libkleo/KeyListModel>
#include <Libkleo/KeyListSortFilterProxyModel>
#include <Libkleo/Formatting>
......@@ -60,8 +61,7 @@ public:
switch (role) {
case Qt::DecorationRole: {
const auto key = KeyListSortFilterProxyModel::data(index,
Kleo::KeyListModelInterface::KeyRole).value<GpgME::Key>();
const auto key = KeyListSortFilterProxyModel::data(index, KeyList::KeyRole).value<GpgME::Key>();
Q_ASSERT(!key.isNull());
if (key.isNull()) {
return QVariant();
......@@ -92,12 +92,12 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
mCompleterFilterModel->setSourceModel(model);
auto *completer = new QCompleter(this);
completer->setModel(mCompleterFilterModel);
completer->setCompletionColumn(KeyListModelInterface::Summary);
completer->setCompletionColumn(KeyList::Summary);
completer->setFilterMode(Qt::MatchContains);
completer->setCaseSensitivity(Qt::CaseInsensitive);
setCompleter(completer);
mFilterModel->setSourceModel(model);
mFilterModel->setFilterKeyColumn(KeyListModelInterface::Summary);
mFilterModel->setFilterKeyColumn(KeyList::Summary);
if (filter) {
mFilterModel->setKeyFilter(mFilter);
}
......@@ -172,7 +172,8 @@ void CertificateLineEdit::updateKey()
mLineAction->setToolTip(i18n("Open selection dialog."));
}
} else if (mFilterModel->rowCount() == 1) {
newKey = mFilterModel->data(mFilterModel->index(0, 0), KeyListModelInterface::KeyRole).value<Key>();
const auto index = mFilterModel->index(0, 0);
newKey = mFilterModel->data(index, KeyList::KeyRole).value<Key>();
mLineAction->setToolTip(Formatting::validity(newKey.userID(0)) +
QStringLiteral("<br/>Click here for details."));
/* FIXME: This needs to be solved by a multiple UID supporting model */
......
......@@ -11,6 +11,7 @@
#include "keytreeview.h"
#include <Libkleo/KeyList>
#include <Libkleo/KeyListModel>
#include <Libkleo/KeyListSortFilterProxyModel>
#include <Libkleo/KeyRearrangeColumnsProxyModel>
......@@ -273,22 +274,22 @@ void KeyTreeView::init()
KeyRearrangeColumnsProxyModel *rearangingModel = new KeyRearrangeColumnsProxyModel(this);
rearangingModel->setSourceModel(m_proxy);
rearangingModel->setSourceColumns(QVector<int>() << KeyListModelInterface::PrettyName
<< KeyListModelInterface::PrettyEMail
<< KeyListModelInterface::Validity
<< KeyListModelInterface::ValidFrom
<< KeyListModelInterface::ValidUntil
<< KeyListModelInterface::TechnicalDetails
<< KeyListModelInterface::KeyID
<< KeyListModelInterface::Fingerprint
<< KeyListModelInterface::OwnerTrust
<< KeyListModelInterface::Origin
<< KeyListModelInterface::LastUpdate
<< KeyListModelInterface::Issuer
<< KeyListModelInterface::SerialNumber
rearangingModel->setSourceColumns(QVector<int>() << KeyList::PrettyName
<< KeyList::PrettyEMail
<< KeyList::Validity
<< KeyList::ValidFrom
<< KeyList::ValidUntil
<< KeyList::TechnicalDetails
<< KeyList::KeyID
<< KeyList::Fingerprint
<< KeyList::OwnerTrust
<< KeyList::Origin
<< KeyList::LastUpdate
<< KeyList::Issuer
<< KeyList::SerialNumber
#ifdef GPGME_HAS_REMARKS
// If a column is added before this TAGS_COLUMN define has to be updated accordingly
<< KeyListModelInterface::Remarks
<< KeyList::Remarks
#endif
);
m_view->setModel(rearangingModel);
......@@ -300,7 +301,7 @@ void KeyTreeView::init()
if (!index.isValid()) {
return;
}
const auto &key = index.data(Kleo::KeyListModelInterface::KeyRole).value<GpgME::Key>();
const auto &key = index.data(KeyList::KeyRole).value<GpgME::Key>();
const auto fpr = QString::fromLatin1(key.primaryFingerprint());
if (m_expandedKeys.contains(fpr)) {
......@@ -314,7 +315,7 @@ void KeyTreeView::init()
if (!index.isValid()) {
return;
}
const auto &key = index.data(Kleo::KeyListModelInterface::KeyRole).value<GpgME::Key>();
const auto &key = index.data(KeyList::KeyRole).value<GpgME::Key>();
m_expandedKeys.removeAll(QString::fromLatin1(key.primaryFingerprint()));
m_group.writeEntry("Expanded", m_expandedKeys);
});
......@@ -688,8 +689,8 @@ bool KeyTreeView::connectSearchBar(const QObject *bar)
void KeyTreeView::resizeColumns()
{
m_view->setColumnWidth(KeyListModelInterface::PrettyName, 260);
m_view->setColumnWidth(KeyListModelInterface::PrettyEMail, 260);
m_view->setColumnWidth(KeyList::PrettyName, 260);
m_view->setColumnWidth(KeyList::PrettyEMail, 260);
for (int i = 2; i < m_view->model()->columnCount(); ++i) {
m_view->resizeColumnToContents(i);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment