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

Crate archives #10997

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Crate archives #10997

wants to merge 17 commits into from

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Oct 24, 2022

This is a small feature that creates an Archive subfolder of the crate menu, much like the history playlist now has per-year folders. Users can move a crate to the archive folder if they don't want it to appear in the crate submenu. This requires a small change to the db (the addition of a bool to determine if the crate is in the archive) and a small amount of qt for the new submenu.

image

This is a draft because it needs more testing and UX improvement

if (selectedIsArchived) {
QModelIndex archiveIndex = m_pSidebarModel->index(rowCount - 1, 0);
m_pSidebarWidget->setExpanded(archiveIndex, true);
return m_pSidebarModel->index(selectedRow, 0, archiveIndex);
Copy link
Member Author

Choose a reason for hiding this comment

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

In my use, I find it not very convenient to keep the archived crate selected. Instead I think it might be nicer to select the crate below where it used to be in the hierarchy. This is because archiving a crate is kind of like "please make this go away" so having the selection follow the archive process doesn't quite make sense.

Copy link
Member

Choose a reason for hiding this comment

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

But why expand the Archive item?

@github-actions
Copy link

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Jan 23, 2023
ywwg added 2 commits May 20, 2023 14:43
…crate into the archive folder

Also, make sure to highlight archived crates when selecting tracks.
@ywwg ywwg marked this pull request as ready for review May 20, 2023 19:35
@ywwg ywwg removed the stale Stale issues that haven't been updated for a long time. label May 20, 2023
@ywwg ywwg requested a review from ronso0 May 21, 2023 18:49
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.

Thank you. This looks like a nice feature.

@@ -569,18 +577,20 @@ bool CrateStorage::onInsertingCrate(
FwdSqlQuery query(m_database,
QStringLiteral(
"INSERT INTO %1 (%2,%3,%4) "
"VALUES (:name,:locked,:autoDjSource)")
"VALUES (:name,:locked,:archived,:autoDjSource)")
Copy link
Member

Choose a reason for hiding this comment

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

I got a violated Debug Assertion:

warning [Main] QString::arg: 1 argument(s) missing in INSERT INTO %1 (%2,%3,%4) VALUES (:name,:locked,:archived,:autoDjSource)
critical [Main] FwdSqlQuery - Failed to prepare statement "INSERT INTO crates (name,locked,archived) VALUES (:name,:locked,:archived,:autoDjSource)" : QSqlError("1", "Unable to execute statement", "4 values for 3 columns")
critical [Main] DEBUG ASSERT: "query.isPrepared()" in function bool CrateStorage::onInsertingCrate(const Crate&, CrateId*) at ../../src/library/trackset/crate/cratestorage.cpp:587

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@ronso0
Copy link
Member

ronso0 commented May 22, 2023

The debug assert in CrateFeature::activateChild needs to just return for crateId = -1 (Archived item)
27e625a

It would be a nice addon if the table view is cleared when clicking the Archived item, currently it sticks to the previous view (which might be any item of any sidebar feature). Just fyi, for the YEAR items in History I created a temporary, locked playlist. Dunno if that's too much of a hack, or if CrateTableModel could use a clearView method, or if we just call BaseTrackSetFeature::activate() to show the root view when Archived is selected.

@ywwg
Copy link
Member Author

ywwg commented May 23, 2023

yeah I can clear the view. I'll try the different options you suggest

treeitems can either be crates or have children, not both.
@ronso0
Copy link
Member

ronso0 commented May 25, 2023

Actually I wanted something like archiving for playlists (don't use crates that much anymore).
I think, now that you did the work for crates I can easily adopt if for playlists.
However, that would require another schema upgrade. I'm not much into that, do we want to keep schema upgrades to a minimum or is this irrelevant?
In case a minimum of upgrades is preferred, could you add the archived column to the playlist table as well in this PR?

@ronso0
Copy link
Member

ronso0 commented May 25, 2023

Btw CrateStorageTest.persistentLifecycle is failing on all OS except macOS arm64, and it passes locally here 🤷‍♂️

@ronso0
Copy link
Member

ronso0 commented May 27, 2023

#11208 was merged, so now the sidebar selection should remain unchanged if the right-clicked item wasn't also selected. This is mostly done in slotCrateTableChanged.

With this branch however, if I

  • have Tracks selected
  • expand Crates > right-click any crate > click Archive
  • = crate above the now archived crate is selected

I think the reselection part can be simplified if we use a dedicated crate archive method in TrackCollection, as well as a new archiveChanged signal. Connect that to an equivalent of slotCrateTableChanged to takes care of reselect if required.
Coding that proposal was faster than writing it down as review, so here you go ywwg#12

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.

Thank you. I have left some comments.

<description>
Support for crates being Archived.
</description>
<sql>
Copy link
Member

Choose a reason for hiding this comment

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

This uses an integer column for a bool value.

Does it make sense to make the use of this column extensible? Something like "type" or even "parent". We did the same "mistake" with the hidden column for playlists.

if (archiving) {
const auto index = indexFromCrateId(crate.getId());
// Constrain reselection between first and last valid crate positions.
reselectRow = std::min(std::max(index.row(), 0), m_pSidebarModel->rowCount() - 3);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this required? Why -3? Can you make it a constant?

}
crate.setArchived(archiving);
if (!m_pTrackCollection->updateCrate(crate)) {
qDebug() << "Failed to toggle archive status of crate" << crate;
Copy link
Member

Choose a reason for hiding this comment

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

What is the scenario for this?
Can you give more details to also desringush this message from the one below?

CrateId(pTreeItem->getData()));
pTreeItem->setBold(crateContainsSelectedTrack);
if (pTreeItem->hasChildren()) {
for (auto subItem : pTreeItem->children()) {
Copy link
Member

Choose a reason for hiding this comment

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

pSubItem?

@@ -607,12 +617,13 @@ bool CrateStorage::onUpdatingCrate(
FwdSqlQuery query(m_database,
QString(
"UPDATE %1 "
"SET %2=:name,%3=:locked,%4=:autoDjSource "
"WHERE %5=:id")
"SET %2=:name,%3=:locked,%4=:archived,%5=:autoDjSource "
Copy link
Member

Choose a reason for hiding this comment

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

This can become a QStringLiteral

@@ -14,6 +14,8 @@ const mixxx::Logger kLogger("CrateStorage");

const QString CRATETABLE_LOCKED = "locked";
Copy link
Member

Choose a reason for hiding this comment

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

This can become a QStringLiteral

@ywwg ywwg added this to the 2.5-beta milestone Feb 18, 2024
@ywwg
Copy link
Member Author

ywwg commented Feb 18, 2024

I'll be picking this back up and addressing comments

@daschuer
Copy link
Member

daschuer commented May 8, 2024

This has unfortunately build errors. I will remove it from the 2.5-beta for now.

@daschuer daschuer removed this from the 2.5-beta milestone May 8, 2024
@ywwg
Copy link
Member Author

ywwg commented May 8, 2024

no problem. Hopefully I will find time for this in the future

@ywwg
Copy link
Member Author

ywwg commented May 9, 2024

this seems to be a desired feature so I'm going to try to pick it back up and also add the same thing for playlists. One thing I am tempted by is instead of using a bool, use a string, and call it "Archive". Then in the future this could become a more generic feature of named folders (one layer deep, no subfolders allowed!) or perhaps a csv tag system, where one crate could have multiple tags. It's really just a matter of UX decisions.

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