mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-28 07:17:08 -05:00
Allow selecting multiple rows in entry view.
This commit is contained in:
parent
5c0a83eae5
commit
28bfd39bca
@ -121,14 +121,14 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
|||||||
m_ui->actionEntryNew->setEnabled(true);
|
m_ui->actionEntryNew->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (dbWidget->entryView()->inSearch() ||
|
if (dbWidget->entryView()->inSearch() ||
|
||||||
!dbWidget->entryView()->currentIndex().isValid()) {
|
!dbWidget->entryView()->isSingleEntrySelected()) {
|
||||||
m_ui->actionEntryClone->setEnabled(false);
|
m_ui->actionEntryClone->setEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->actionEntryClone->setEnabled(true);
|
m_ui->actionEntryClone->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbWidget->entryView()->currentIndex().isValid()) {
|
if (dbWidget->entryView()->isSingleEntrySelected()) {
|
||||||
m_ui->actionEntryEdit->setEnabled(true);
|
m_ui->actionEntryEdit->setEnabled(true);
|
||||||
m_ui->actionEntryDelete->setEnabled(true);
|
m_ui->actionEntryDelete->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ EntryView::EntryView(QWidget* parent)
|
|||||||
setAlternatingRowColors(true);
|
setAlternatingRowColors(true);
|
||||||
setDragEnabled(true);
|
setDragEnabled(true);
|
||||||
setSortingEnabled(true);
|
setSortingEnabled(true);
|
||||||
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
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()));
|
||||||
@ -78,8 +79,13 @@ void EntryView::setModel(QAbstractItemModel* model)
|
|||||||
|
|
||||||
Entry* EntryView::currentEntry()
|
Entry* EntryView::currentEntry()
|
||||||
{
|
{
|
||||||
// TODO: use selection instead of current?
|
QModelIndexList list = selectionModel()->selectedRows();
|
||||||
return m_model->entryFromIndex(m_sortModel->mapToSource(currentIndex()));
|
if (list.size() == 1) {
|
||||||
|
return m_model->entryFromIndex(m_sortModel->mapToSource(list.first()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntryView::isSingleEntrySelected()
|
bool EntryView::isSingleEntrySelected()
|
||||||
|
@ -42,15 +42,15 @@ public:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setGroup(Group* group);
|
void setGroup(Group* group);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void entryActivated(Entry* entry);
|
||||||
|
void entrySelectionChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void emitEntryActivated(const QModelIndex& index);
|
void emitEntryActivated(const QModelIndex& index);
|
||||||
void switchToSearch();
|
void switchToSearch();
|
||||||
void switchToView();
|
void switchToView();
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void entryActivated(Entry* entry);
|
|
||||||
void entrySelectionChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntryModel* const m_model;
|
EntryModel* const m_model;
|
||||||
QSortFilterProxyModel* const m_sortModel;
|
QSortFilterProxyModel* const m_sortModel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user