Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lp1929141: Fix handling of preview button cell events #4264

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now don't reset m_currentEditedCellIndex when leaving the cell is this intended?

Copy link
Contributor Author

@uklotzde uklotzde Sep 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not intended: 64d1c73

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd try: bf77aa5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a 3rd try...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now all cases should be covered: 23590a4

}
// 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