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

BaseTrackTableModel: Fix column header mapping #13682

Closed
wants to merge 10 commits into from

Conversation

uklotzde
Copy link
Contributor

Without these fixes BaseTrackTableModel doesn't work as expected when used as a base class, i.e. internal column values are undefined and visible columns are missing.

However BaseSqlTableModel doesn't seem to suffer from these deficiencies and inconsistencies in its base class.

@uklotzde uklotzde changed the title BaseTrackTableModel: Fix various reusability issues BaseTrackTableModel: Fix base class issues Sep 23, 2024
@Swiftb0y
Copy link
Member

I'm not sure how to proceed here. Who is qualified enough to review this?

@uklotzde uklotzde changed the title BaseTrackTableModel: Fix base class issues BaseTrackTableModel: Fix column header mapping Sep 30, 2024
@uklotzde
Copy link
Contributor Author

uklotzde commented Sep 30, 2024

I recommend to squash this PR into a single commit when merging, using the title as the commit message.

src/library/basetracktablemodel.cpp Outdated Show resolved Hide resolved
src/library/basetracktablemodel.cpp Outdated Show resolved Hide resolved
src/library/basetracktablemodel.cpp Show resolved Hide resolved
@uklotzde
Copy link
Contributor Author

uklotzde commented Oct 3, 2024

I appreciate that this base class is still maintained: 8983ca8

Any chances to get these fixes merged?

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you. Waiting for @daschuer

@uklotzde
Copy link
Contributor Author

If you are not interested in these fixes I will close the PR, stash the commits, and maintain a local patch. Only affects my use case.

@Swiftb0y
Copy link
Member

friendly ping @daschuer

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

We are still interested in this PR, sorry for the delay.

Can you please squash this PR as suggested after applying the final fix?

Thank you.

}
DEBUG_ASSERT(headerIndex < m_columnHeaders.size());
m_columnHeaders[headerIndex].column = column;
DEBUG_ASSERT(mapColumn(headerIndex) == column);
}
Copy link
Member

Choose a reason for hiding this comment

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

It turns out that the whole loop Is redundant, because the header properties are reinitialized below. There is only a dummy entry missing rot the ID header. Something like:

    setHeaderProperties(
            ColumnCache::COLUMN_LIBRARYTABLE_ID,
            QString(), // hidden
            0);

You may assert below initHeaderProperties() that all m_columnHeaders have been initialized.

It would be better to not initalizer the header properties at runtime, because all columns are known at compile time. But it is OK for me to not extend the scope of this PR as suggested in the other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how an alternative initialization ordering looks like: e0d4374. IMHO more complicated and cluttered.

I suppose this code either vanishes or needs to be rewritten when migrating to QML. I wouldn't put too much effort in it.

Squashing can be done on merge. The PR title already contains the final commit message.

Copy link
Member

Choose a reason for hiding this comment

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

I was probably not clear enough: Please remove this complicated and cluttered loop. It is not necessary.

Instead just this is requied:

 setHeaderProperties(
            ColumnCache::COLUMN_LIBRARYTABLE_ID,
            QString(), // hidden
            0);

uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
}
DEBUG_ASSERT(headerIndex < m_columnHeaders.size());
m_columnHeaders[headerIndex].column = column;
DEBUG_ASSERT(mapColumn(headerIndex) == column);
}
Copy link
Member

Choose a reason for hiding this comment

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

I was probably not clear enough: Please remove this complicated and cluttered loop. It is not necessary.

Instead just this is requied:

 setHeaderProperties(
            ColumnCache::COLUMN_LIBRARYTABLE_ID,
            QString(), // hidden
            0);

@uklotzde
Copy link
Contributor Author

@daschuer Sorry, but what you are proposing doesn't work. There are more hidden columns which remain uninitialized. Initializing them one by one is brittle and will break as soon as more (hidden) columns are added in the future. Initializing all columns in a loop is the only safe and sustainable option.

I will maintain a patch for myself and leave the rest to you.

@uklotzde uklotzde closed this Oct 14, 2024
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 14, 2024
@uklotzde
Copy link
Contributor Author

The proposed changes could be found as a single commit in this (permanent) branch: https:/uklotzde/mixxx/tree/aoide.

I decided to keep the branch accessible for everyone. It will be available as long as rebasing and maintaining is manageable.

Thanks for the review. It has considerably helped improving and simplifying the code.

@uklotzde uklotzde deleted the basetracktablemodel branch October 14, 2024 14:21
uklotzde added a commit to uklotzde/mixxx that referenced this pull request Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants