mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-24 15:25:31 -04:00
Clean up Entry Model/View code
This commit is contained in:
parent
d8d758f0e1
commit
4b57fcb563
7 changed files with 37 additions and 72 deletions
|
@ -50,11 +50,7 @@ EntryView::EntryView(QWidget* parent)
|
|||
setDefaultDropAction(Qt::MoveAction);
|
||||
|
||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
|
||||
connect(selectionModel(),
|
||||
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
||||
|
||||
connect(m_model, SIGNAL(switchedToListMode()), SLOT(switchToListMode()));
|
||||
connect(m_model, SIGNAL(switchedToSearchMode()), SLOT(switchToSearchMode()));
|
||||
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
||||
connect(m_model, SIGNAL(usernamesHiddenChanged()), SIGNAL(viewStateChanged()));
|
||||
connect(m_model, SIGNAL(passwordsHiddenChanged()), SIGNAL(viewStateChanged()));
|
||||
|
||||
|
@ -158,16 +154,25 @@ void EntryView::focusOutEvent(QFocusEvent* event)
|
|||
QTreeView::focusOutEvent(event);
|
||||
}
|
||||
|
||||
void EntryView::setGroup(Group* group)
|
||||
void EntryView::displayGroup(Group* group)
|
||||
{
|
||||
m_model->setGroup(group);
|
||||
header()->hideSection(EntryModel::ParentGroup);
|
||||
setFirstEntryActive();
|
||||
m_inSearchMode = false;
|
||||
}
|
||||
|
||||
void EntryView::setEntryList(const QList<Entry*>& entries)
|
||||
void EntryView::displaySearch(const QList<Entry*>& entries)
|
||||
{
|
||||
m_model->setEntryList(entries);
|
||||
m_model->setEntries(entries);
|
||||
header()->showSection(EntryModel::ParentGroup);
|
||||
|
||||
// Reset sort column to 'Group', overrides DatabaseWidgetStateSync
|
||||
m_sortModel->sort(EntryModel::ParentGroup, Qt::AscendingOrder);
|
||||
sortByColumn(EntryModel::ParentGroup, Qt::AscendingOrder);
|
||||
|
||||
setFirstEntryActive();
|
||||
m_inSearchMode = true;
|
||||
}
|
||||
|
||||
void EntryView::setFirstEntryActive()
|
||||
|
@ -227,39 +232,6 @@ Entry* EntryView::entryFromIndex(const QModelIndex& index)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to list mode, i.e. list entries of group
|
||||
*/
|
||||
void EntryView::switchToListMode()
|
||||
{
|
||||
if (!m_inSearchMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
header()->hideSection(EntryModel::ParentGroup);
|
||||
m_inSearchMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to search mode, i.e. list search results
|
||||
*/
|
||||
void EntryView::switchToSearchMode()
|
||||
{
|
||||
if (m_inSearchMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
header()->showSection(EntryModel::ParentGroup);
|
||||
|
||||
// Always set sorting to column 'Group', as it does not feel right to
|
||||
// have the last known sort configuration of search view restored by
|
||||
// 'DatabaseWidgetStateSync', which is what happens without this
|
||||
m_sortModel->sort(EntryModel::ParentGroup, Qt::AscendingOrder);
|
||||
sortByColumn(EntryModel::ParentGroup, Qt::AscendingOrder);
|
||||
|
||||
m_inSearchMode = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current state of 'Hide Usernames' setting (NOTE: just pass-through for
|
||||
* m_model)
|
||||
|
@ -272,7 +244,7 @@ bool EntryView::isUsernamesHidden() const
|
|||
/**
|
||||
* Set state of 'Hide Usernames' setting (NOTE: just pass-through for m_model)
|
||||
*/
|
||||
void EntryView::setUsernamesHidden(const bool hide)
|
||||
void EntryView::setUsernamesHidden(bool hide)
|
||||
{
|
||||
bool block = m_hideUsernamesAction->signalsBlocked();
|
||||
m_hideUsernamesAction->blockSignals(true);
|
||||
|
@ -294,7 +266,7 @@ bool EntryView::isPasswordsHidden() const
|
|||
/**
|
||||
* Set state of 'Hide Passwords' setting (NOTE: just pass-through for m_model)
|
||||
*/
|
||||
void EntryView::setPasswordsHidden(const bool hide)
|
||||
void EntryView::setPasswordsHidden(bool hide)
|
||||
{
|
||||
bool block = m_hidePasswordsAction->signalsBlocked();
|
||||
m_hidePasswordsAction->blockSignals(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue