diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index def7e843..fd4e8da8 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -464,7 +464,7 @@ void DatabaseWidget::switchToEntryEdit(Entry* entry, bool create) { Group* group = m_groupView->currentGroup(); if (!group) { - Q_ASSERT(m_entryView->inSearch()); + Q_ASSERT(m_entryView->inEntryListMode()); group = m_lastGroup; } Q_ASSERT(group); @@ -560,7 +560,7 @@ void DatabaseWidget::switchToImportKeepass1(const QString& fileName) void DatabaseWidget::toggleSearch() { - if (m_entryView->inSearch()) { + if (m_entryView->inEntryListMode()) { closeSearch(); } else { @@ -637,7 +637,7 @@ void DatabaseWidget::search() QList searchResult = searchGroup->search(m_searchUi->searchEdit->text(), sensitivity); - m_entryView->search(searchResult); + m_entryView->setEntryList(searchResult); } void DatabaseWidget::startSearchTimer() @@ -686,7 +686,7 @@ void DatabaseWidget::updateGroupActions(Group* group) void DatabaseWidget::updateEntryActions() { bool singleEntrySelected = m_entryView->isSingleEntrySelected(); - bool inSearch = m_entryView->inSearch(); + bool inSearch = m_entryView->inEntryListMode(); m_actionEntryNew->setEnabled(!inSearch); m_actionEntryClone->setEnabled(singleEntrySelected && !inSearch); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 86239cc9..f8aa38d8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -179,7 +179,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete)); m_ui->actionSearch->setEnabled(true); // TODO: get checked state from db widget - m_ui->actionSearch->setChecked(dbWidget->entryView()->inSearch()); + m_ui->actionSearch->setChecked(dbWidget->entryView()->inEntryListMode()); m_ui->actionChangeMasterKey->setEnabled(true); m_ui->actionChangeDatabaseSettings->setEnabled(true); m_ui->actionDatabaseSave->setEnabled(true); diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index a4452d68..6e0bb7fd 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -62,10 +62,10 @@ void EntryModel::setGroup(Group* group) makeConnections(group); endResetModel(); - Q_EMIT switchedToView(); + Q_EMIT switchedToGroupMode(); } -void EntryModel::setEntries(const QList& entries) +void EntryModel::setEntryList(const QList& entries) { beginResetModel(); @@ -85,7 +85,7 @@ void EntryModel::setEntries(const QList& entries) } endResetModel(); - Q_EMIT switchedToSearch(); + Q_EMIT switchedToEntryListMode(); } int EntryModel::rowCount(const QModelIndex& parent) const diff --git a/src/gui/entry/EntryModel.h b/src/gui/entry/EntryModel.h index a5edcddb..8fd9c961 100644 --- a/src/gui/entry/EntryModel.h +++ b/src/gui/entry/EntryModel.h @@ -43,11 +43,11 @@ public: QStringList mimeTypes() const Q_DECL_OVERRIDE; QMimeData* mimeData(const QModelIndexList& indexes) const Q_DECL_OVERRIDE; - void setEntries(const QList& entries); + void setEntryList(const QList& entries); Q_SIGNALS: - void switchedToSearch(); - void switchedToView(); + void switchedToEntryListMode(); + void switchedToGroupMode(); public Q_SLOTS: void setGroup(Group* group); diff --git a/src/gui/entry/EntryView.cpp b/src/gui/entry/EntryView.cpp index e2fb97bf..5d21ed7e 100644 --- a/src/gui/entry/EntryView.cpp +++ b/src/gui/entry/EntryView.cpp @@ -25,7 +25,7 @@ EntryView::EntryView(QWidget* parent) : QTreeView(parent) , m_model(new EntryModel(this)) , m_sortModel(new QSortFilterProxyModel(this)) - , m_inSearch(false) + , m_inEntryListMode(false) { m_sortModel->setSourceModel(m_model); m_sortModel->setDynamicSortFilter(true); @@ -43,8 +43,8 @@ EntryView::EntryView(QWidget* parent) connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex))); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged())); - connect(m_model, SIGNAL(switchedToSearch()), SLOT(switchToSearch())); - connect(m_model, SIGNAL(switchedToView()), SLOT(switchToView())); + connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode())); + connect(m_model, SIGNAL(switchedToGroupMode()), SLOT(switchToGroupMode())); sortByColumn(0, Qt::AscendingOrder); } @@ -55,15 +55,15 @@ void EntryView::setGroup(Group* group) Q_EMIT entrySelectionChanged(); } -void EntryView::search(const QList& entries) +void EntryView::setEntryList(const QList& entries) { - m_model->setEntries(entries); + m_model->setEntryList(entries); Q_EMIT entrySelectionChanged(); } -bool EntryView::inSearch() +bool EntryView::inEntryListMode() { - return m_inSearch; + return m_inEntryListMode; } void EntryView::emitEntryActivated(const QModelIndex& index) @@ -108,17 +108,17 @@ Entry* EntryView::entryFromIndex(const QModelIndex& index) } } -void EntryView::switchToSearch() +void EntryView::switchToEntryListMode() { sortByColumn(1, Qt::AscendingOrder); // TODO: should probably be improved sortByColumn(0, Qt::AscendingOrder); showColumn(0); - m_inSearch = true; + m_inEntryListMode = true; } -void EntryView::switchToView() +void EntryView::switchToGroupMode() { sortByColumn(1, Qt::AscendingOrder); hideColumn(0); - m_inSearch = false; + m_inEntryListMode = false; } diff --git a/src/gui/entry/EntryView.h b/src/gui/entry/EntryView.h index c9328729..5096b1fa 100644 --- a/src/gui/entry/EntryView.h +++ b/src/gui/entry/EntryView.h @@ -38,8 +38,8 @@ public: bool isSingleEntrySelected(); void setCurrentEntry(Entry* entry); Entry* entryFromIndex(const QModelIndex& index); - void search(const QList& entries); - bool inSearch(); + void setEntryList(const QList& entries); + bool inEntryListMode(); public Q_SLOTS: void setGroup(Group* group); @@ -50,13 +50,13 @@ Q_SIGNALS: private Q_SLOTS: void emitEntryActivated(const QModelIndex& index); - void switchToSearch(); - void switchToView(); + void switchToEntryListMode(); + void switchToGroupMode(); private: EntryModel* const m_model; QSortFilterProxyModel* const m_sortModel; - bool m_inSearch; + bool m_inEntryListMode; }; #endif // KEEPASSX_ENTRYVIEW_H