Skip to content

Commit

Permalink
Merge pull request #4264 from uklotzde/previewbuttondelegate
Browse files Browse the repository at this point in the history
lp1929141: Fix handling of preview button cell events
  • Loading branch information
daschuer authored Sep 7, 2021
2 parents cf0a029 + 23590a4 commit 3568473
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/library/previewbuttondelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,31 @@ QSize PreviewButtonDelegate::sizeHint(const QStyleOptionViewItem& option,
}

void PreviewButtonDelegate::cellEntered(const QModelIndex& index) {
DEBUG_ASSERT(index.isValid());
VERIFY_OR_DEBUG_ASSERT(index.isValid()) {
return;
}
VERIFY_OR_DEBUG_ASSERT(parentTableView()) {
return;
}
// this slot is called if the mouse pointer enters ANY cell on
// the QTableView but the code should only be executed on a button
if (index.column() == m_column) {
DEBUG_ASSERT(index != m_currentEditedCellIndex);
if (m_currentEditedCellIndex.isValid()) {
// Close the editor in the other cell
parentTableView()->closePersistentEditor(m_currentEditedCellIndex);
}
parentTableView()->openPersistentEditor(index);
m_currentEditedCellIndex = index;
} else if (m_currentEditedCellIndex.isValid()) {
// Close editor if the mouse leaves the button
// Ignore signal if the edited cell index didn't change.
// Receiving this signal for the same cell again could happen
// if no other cell has been entered between those events.
// https://bugs.launchpad.net/mixxx/+bug/1929141
if (index == m_currentEditedCellIndex) {
return;
}
// Close the editor when leaving the currently edited cell
if (m_currentEditedCellIndex.isValid()) {
parentTableView()->closePersistentEditor(m_currentEditedCellIndex);
m_currentEditedCellIndex = QModelIndex();
}
// Only open a new editor for preview column cells, but not any
// other cells
if (index.column() != m_column) {
return;
}
parentTableView()->openPersistentEditor(index);
m_currentEditedCellIndex = index;
}

void PreviewButtonDelegate::buttonClicked() {
Expand Down

0 comments on commit 3568473

Please sign in to comment.