mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-09 11:18:39 -05:00
Fix history view showing wrong item.
This commit is contained in:
parent
21e257e64d
commit
01706483fb
@ -91,18 +91,18 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
|||||||
|
|
||||||
m_historyModel = new EntryHistoryModel(this);
|
m_historyModel = new EntryHistoryModel(this);
|
||||||
|
|
||||||
QSortFilterProxyModel* sortModel = new QSortFilterProxyModel(this);
|
m_sortModel = new QSortFilterProxyModel(this);
|
||||||
sortModel->setSourceModel(m_historyModel);
|
m_sortModel->setSourceModel(m_historyModel);
|
||||||
sortModel->setDynamicSortFilter(true);
|
m_sortModel->setDynamicSortFilter(true);
|
||||||
sortModel->setSortLocaleAware(true);
|
m_sortModel->setSortLocaleAware(true);
|
||||||
sortModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
m_sortModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
sortModel->setSortRole(Qt::UserRole);
|
m_sortModel->setSortRole(Qt::UserRole);
|
||||||
|
|
||||||
m_historyUi->historyView->setModel(sortModel);
|
m_historyUi->historyView->setModel(m_sortModel);
|
||||||
m_historyUi->historyView->setRootIsDecorated(false);
|
m_historyUi->historyView->setRootIsDecorated(false);
|
||||||
|
|
||||||
connect(m_historyUi->historyView, SIGNAL(activated(const QModelIndex&)),
|
connect(m_historyUi->historyView, SIGNAL(activated(const QModelIndex&)),
|
||||||
SLOT(emitHistoryEntryActivated(const QModelIndex&)));
|
SLOT(histEntryActivated(const QModelIndex&)));
|
||||||
connect(m_historyUi->historyView->selectionModel(),
|
connect(m_historyUi->historyView->selectionModel(),
|
||||||
SIGNAL(currentChanged(QModelIndex ,QModelIndex)),
|
SIGNAL(currentChanged(QModelIndex ,QModelIndex)),
|
||||||
SLOT(updateHistoryButtons(QModelIndex, QModelIndex)));
|
SLOT(updateHistoryButtons(QModelIndex, QModelIndex)));
|
||||||
@ -122,7 +122,6 @@ EditEntryWidget::~EditEntryWidget()
|
|||||||
const QColor EditEntryWidget::CorrectSoFarColor = QColor(255, 205, 15);
|
const QColor EditEntryWidget::CorrectSoFarColor = QColor(255, 205, 15);
|
||||||
const QColor EditEntryWidget::ErrorColor = QColor(255, 125, 125);
|
const QColor EditEntryWidget::ErrorColor = QColor(255, 125, 125);
|
||||||
|
|
||||||
|
|
||||||
void EditEntryWidget::emitHistoryEntryActivated(const QModelIndex& index)
|
void EditEntryWidget::emitHistoryEntryActivated(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_history);
|
Q_ASSERT(!m_history);
|
||||||
@ -131,6 +130,16 @@ void EditEntryWidget::emitHistoryEntryActivated(const QModelIndex& index)
|
|||||||
Q_EMIT historyEntryActivated(entry);
|
Q_EMIT historyEntryActivated(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditEntryWidget::histEntryActivated(const QModelIndex& index)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!m_history);
|
||||||
|
|
||||||
|
QModelIndex indexMapped = m_sortModel->mapToSource(index);
|
||||||
|
if (indexMapped.isValid()) {
|
||||||
|
emitHistoryEntryActivated(indexMapped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditEntryWidget::updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous)
|
void EditEntryWidget::updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
@ -533,7 +542,7 @@ void EditEntryWidget::removeCurrentAttachment()
|
|||||||
|
|
||||||
void EditEntryWidget::showHistoryEntry()
|
void EditEntryWidget::showHistoryEntry()
|
||||||
{
|
{
|
||||||
QModelIndex index = m_historyUi->historyView->currentIndex();
|
QModelIndex index = m_sortModel->mapToSource(m_historyUi->historyView->currentIndex());
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
emitHistoryEntryActivated(index);
|
emitHistoryEntryActivated(index);
|
||||||
}
|
}
|
||||||
@ -541,7 +550,7 @@ void EditEntryWidget::showHistoryEntry()
|
|||||||
|
|
||||||
void EditEntryWidget::restoreHistoryEntry()
|
void EditEntryWidget::restoreHistoryEntry()
|
||||||
{
|
{
|
||||||
QModelIndex index = m_historyUi->historyView->currentIndex();
|
QModelIndex index = m_sortModel->mapToSource(m_historyUi->historyView->currentIndex());
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
setForms(m_historyModel->entryFromIndex(index), true);
|
setForms(m_historyModel->entryFromIndex(index), true);
|
||||||
}
|
}
|
||||||
@ -549,7 +558,7 @@ void EditEntryWidget::restoreHistoryEntry()
|
|||||||
|
|
||||||
void EditEntryWidget::deleteHistoryEntry()
|
void EditEntryWidget::deleteHistoryEntry()
|
||||||
{
|
{
|
||||||
QModelIndex index = m_historyUi->historyView->currentIndex();
|
QModelIndex index = m_sortModel->mapToSource(m_historyUi->historyView->currentIndex());
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
m_historyModel->deleteIndex(index);
|
m_historyModel->deleteIndex(index);
|
||||||
if (m_historyModel->rowCount() > 0) {
|
if (m_historyModel->rowCount() > 0) {
|
||||||
|
@ -31,6 +31,7 @@ class EntryAttachmentsModel;
|
|||||||
class EntryAttributes;
|
class EntryAttributes;
|
||||||
class EntryAttributesModel;
|
class EntryAttributesModel;
|
||||||
class EntryHistoryModel;
|
class EntryHistoryModel;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
class QStackedLayout;
|
class QStackedLayout;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -76,6 +77,7 @@ private Q_SLOTS:
|
|||||||
void deleteHistoryEntry();
|
void deleteHistoryEntry();
|
||||||
void deleteAllHistoryEntries();
|
void deleteAllHistoryEntries();
|
||||||
void emitHistoryEntryActivated(const QModelIndex& index);
|
void emitHistoryEntryActivated(const QModelIndex& index);
|
||||||
|
void histEntryActivated(const QModelIndex& index);
|
||||||
void updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous);
|
void updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -99,6 +101,7 @@ private:
|
|||||||
EntryAttachmentsModel* m_attachmentsModel;
|
EntryAttachmentsModel* m_attachmentsModel;
|
||||||
EntryAttributesModel* m_attributesModel;
|
EntryAttributesModel* m_attributesModel;
|
||||||
EntryHistoryModel* m_historyModel;
|
EntryHistoryModel* m_historyModel;
|
||||||
|
QSortFilterProxyModel* m_sortModel;
|
||||||
EntryAttachments* m_entryAttachments;
|
EntryAttachments* m_entryAttachments;
|
||||||
EntryAttributes* m_entryAttributes;
|
EntryAttributes* m_entryAttributes;
|
||||||
QPersistentModelIndex m_currentAttribute;
|
QPersistentModelIndex m_currentAttribute;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user