mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 15:59:50 -05:00
Make history view sortable.
This commit is contained in:
parent
2448976643
commit
9f1ab080ee
@ -26,6 +26,7 @@
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QStackedLayout>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
@ -89,7 +90,15 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
connect(m_mainUi->passwordRepeatEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors()));
|
||||
|
||||
m_historyModel = new EntryHistoryModel(this);
|
||||
m_historyUi->historyView->setModel(m_historyModel);
|
||||
|
||||
QSortFilterProxyModel* sortModel = new QSortFilterProxyModel(this);
|
||||
sortModel->setSourceModel(m_historyModel);
|
||||
sortModel->setDynamicSortFilter(true);
|
||||
sortModel->setSortLocaleAware(true);
|
||||
sortModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sortModel->setSortRole(Qt::UserRole);
|
||||
|
||||
m_historyUi->historyView->setModel(sortModel);
|
||||
m_historyUi->historyView->setRootIsDecorated(false);
|
||||
|
||||
connect(m_historyUi->historyView, SIGNAL(activated(const QModelIndex&)),
|
||||
@ -230,6 +239,7 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore)
|
||||
|
||||
if (!m_history && !restore) {
|
||||
m_historyModel->setEntries(entry->historyItems());
|
||||
m_historyUi->historyView->sortByColumn(0, Qt::DescendingOrder);
|
||||
}
|
||||
if (m_historyModel->rowCount() > 0) {
|
||||
m_historyUi->deleteAllButton->setEnabled(true);
|
||||
|
@ -12,7 +12,11 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="historyView"/>
|
||||
<widget class="QTreeView" name="historyView">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
|
@ -56,10 +56,15 @@ QVariant EntryHistoryModel::data(const QModelIndex& index, int role) const
|
||||
TimeInfo timeInfo = entry->timeInfo();
|
||||
QDateTime lastModificationLocalTime = timeInfo.lastModificationTime().toLocalTime();
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (role == Qt::DisplayRole || role == Qt::UserRole) {
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return lastModificationLocalTime.toString(Qt::SystemLocaleShortDate);
|
||||
if (role == Qt::DisplayRole) {
|
||||
return lastModificationLocalTime.toString(Qt::SystemLocaleShortDate);
|
||||
}
|
||||
else {
|
||||
return lastModificationLocalTime;
|
||||
}
|
||||
case 1:
|
||||
return entry->title();
|
||||
case 2:
|
||||
|
Loading…
Reference in New Issue
Block a user