Rename methods in EntryModel and EntryView from "search" to "entry list mode".

This commit is contained in:
Felix Geyer 2012-07-21 18:35:24 +02:00
parent 33b4cd8636
commit 39b9260719
6 changed files with 27 additions and 27 deletions

View File

@ -464,7 +464,7 @@ void DatabaseWidget::switchToEntryEdit(Entry* entry, bool create)
{ {
Group* group = m_groupView->currentGroup(); Group* group = m_groupView->currentGroup();
if (!group) { if (!group) {
Q_ASSERT(m_entryView->inSearch()); Q_ASSERT(m_entryView->inEntryListMode());
group = m_lastGroup; group = m_lastGroup;
} }
Q_ASSERT(group); Q_ASSERT(group);
@ -560,7 +560,7 @@ void DatabaseWidget::switchToImportKeepass1(const QString& fileName)
void DatabaseWidget::toggleSearch() void DatabaseWidget::toggleSearch()
{ {
if (m_entryView->inSearch()) { if (m_entryView->inEntryListMode()) {
closeSearch(); closeSearch();
} }
else { else {
@ -637,7 +637,7 @@ void DatabaseWidget::search()
QList<Entry*> searchResult = searchGroup->search(m_searchUi->searchEdit->text(), sensitivity); QList<Entry*> searchResult = searchGroup->search(m_searchUi->searchEdit->text(), sensitivity);
m_entryView->search(searchResult); m_entryView->setEntryList(searchResult);
} }
void DatabaseWidget::startSearchTimer() void DatabaseWidget::startSearchTimer()
@ -686,7 +686,7 @@ void DatabaseWidget::updateGroupActions(Group* group)
void DatabaseWidget::updateEntryActions() void DatabaseWidget::updateEntryActions()
{ {
bool singleEntrySelected = m_entryView->isSingleEntrySelected(); bool singleEntrySelected = m_entryView->isSingleEntrySelected();
bool inSearch = m_entryView->inSearch(); bool inSearch = m_entryView->inEntryListMode();
m_actionEntryNew->setEnabled(!inSearch); m_actionEntryNew->setEnabled(!inSearch);
m_actionEntryClone->setEnabled(singleEntrySelected && !inSearch); m_actionEntryClone->setEnabled(singleEntrySelected && !inSearch);

View File

@ -179,7 +179,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete)); m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete));
m_ui->actionSearch->setEnabled(true); m_ui->actionSearch->setEnabled(true);
// TODO: get checked state from db widget // 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->actionChangeMasterKey->setEnabled(true);
m_ui->actionChangeDatabaseSettings->setEnabled(true); m_ui->actionChangeDatabaseSettings->setEnabled(true);
m_ui->actionDatabaseSave->setEnabled(true); m_ui->actionDatabaseSave->setEnabled(true);

View File

@ -62,10 +62,10 @@ void EntryModel::setGroup(Group* group)
makeConnections(group); makeConnections(group);
endResetModel(); endResetModel();
Q_EMIT switchedToView(); Q_EMIT switchedToGroupMode();
} }
void EntryModel::setEntries(const QList<Entry*>& entries) void EntryModel::setEntryList(const QList<Entry*>& entries)
{ {
beginResetModel(); beginResetModel();
@ -85,7 +85,7 @@ void EntryModel::setEntries(const QList<Entry*>& entries)
} }
endResetModel(); endResetModel();
Q_EMIT switchedToSearch(); Q_EMIT switchedToEntryListMode();
} }
int EntryModel::rowCount(const QModelIndex& parent) const int EntryModel::rowCount(const QModelIndex& parent) const

View File

@ -43,11 +43,11 @@ public:
QStringList mimeTypes() const Q_DECL_OVERRIDE; QStringList mimeTypes() const Q_DECL_OVERRIDE;
QMimeData* mimeData(const QModelIndexList& indexes) const Q_DECL_OVERRIDE; QMimeData* mimeData(const QModelIndexList& indexes) const Q_DECL_OVERRIDE;
void setEntries(const QList<Entry*>& entries); void setEntryList(const QList<Entry*>& entries);
Q_SIGNALS: Q_SIGNALS:
void switchedToSearch(); void switchedToEntryListMode();
void switchedToView(); void switchedToGroupMode();
public Q_SLOTS: public Q_SLOTS:
void setGroup(Group* group); void setGroup(Group* group);

View File

@ -25,7 +25,7 @@ EntryView::EntryView(QWidget* parent)
: QTreeView(parent) : QTreeView(parent)
, m_model(new EntryModel(this)) , m_model(new EntryModel(this))
, m_sortModel(new QSortFilterProxyModel(this)) , m_sortModel(new QSortFilterProxyModel(this))
, m_inSearch(false) , m_inEntryListMode(false)
{ {
m_sortModel->setSourceModel(m_model); m_sortModel->setSourceModel(m_model);
m_sortModel->setDynamicSortFilter(true); m_sortModel->setDynamicSortFilter(true);
@ -43,8 +43,8 @@ EntryView::EntryView(QWidget* parent)
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex))); connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged())); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
connect(m_model, SIGNAL(switchedToSearch()), SLOT(switchToSearch())); connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
connect(m_model, SIGNAL(switchedToView()), SLOT(switchToView())); connect(m_model, SIGNAL(switchedToGroupMode()), SLOT(switchToGroupMode()));
sortByColumn(0, Qt::AscendingOrder); sortByColumn(0, Qt::AscendingOrder);
} }
@ -55,15 +55,15 @@ void EntryView::setGroup(Group* group)
Q_EMIT entrySelectionChanged(); Q_EMIT entrySelectionChanged();
} }
void EntryView::search(const QList<Entry*>& entries) void EntryView::setEntryList(const QList<Entry*>& entries)
{ {
m_model->setEntries(entries); m_model->setEntryList(entries);
Q_EMIT entrySelectionChanged(); Q_EMIT entrySelectionChanged();
} }
bool EntryView::inSearch() bool EntryView::inEntryListMode()
{ {
return m_inSearch; return m_inEntryListMode;
} }
void EntryView::emitEntryActivated(const QModelIndex& index) 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(1, Qt::AscendingOrder); // TODO: should probably be improved
sortByColumn(0, Qt::AscendingOrder); sortByColumn(0, Qt::AscendingOrder);
showColumn(0); showColumn(0);
m_inSearch = true; m_inEntryListMode = true;
} }
void EntryView::switchToView() void EntryView::switchToGroupMode()
{ {
sortByColumn(1, Qt::AscendingOrder); sortByColumn(1, Qt::AscendingOrder);
hideColumn(0); hideColumn(0);
m_inSearch = false; m_inEntryListMode = false;
} }

View File

@ -38,8 +38,8 @@ public:
bool isSingleEntrySelected(); bool isSingleEntrySelected();
void setCurrentEntry(Entry* entry); void setCurrentEntry(Entry* entry);
Entry* entryFromIndex(const QModelIndex& index); Entry* entryFromIndex(const QModelIndex& index);
void search(const QList<Entry*>& entries); void setEntryList(const QList<Entry*>& entries);
bool inSearch(); bool inEntryListMode();
public Q_SLOTS: public Q_SLOTS:
void setGroup(Group* group); void setGroup(Group* group);
@ -50,13 +50,13 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void emitEntryActivated(const QModelIndex& index); void emitEntryActivated(const QModelIndex& index);
void switchToSearch(); void switchToEntryListMode();
void switchToView(); void switchToGroupMode();
private: private:
EntryModel* const m_model; EntryModel* const m_model;
QSortFilterProxyModel* const m_sortModel; QSortFilterProxyModel* const m_sortModel;
bool m_inSearch; bool m_inEntryListMode;
}; };
#endif // KEEPASSX_ENTRYVIEW_H #endif // KEEPASSX_ENTRYVIEW_H