Skip to content

Commit

Permalink
Browsemodel: store current directory, create unique model keys for st…
Browse files Browse the repository at this point in the history
…ate save/restore
  • Loading branch information
ronso0 committed Aug 9, 2021
1 parent e8bc921 commit 7297b1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/library/browse/browsetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ BrowseTableModel::BrowseTableModel(QObject* parent,
QStandardItemModel(parent),
m_pTrackCollectionManager(pTrackCollectionManager),
m_pRecordingManager(pRecordingManager),
m_pCurrentDirectory(QString()),
m_previewDeckGroup(PlayerManager::groupForPreviewDeck(0)) {
QStringList headerLabels;
/// The order of the columns appended here must exactly match the ordering
Expand Down Expand Up @@ -188,9 +189,18 @@ void BrowseTableModel::addSearchColumn(int index) {
}

void BrowseTableModel::setPath(mixxx::FileAccess path) {
if (path.info().hasLocation()) {
m_pCurrentDirectory = path.info().locationPath();
} else {
clearCurrentDir();
}
m_pBrowseThread->executePopulation(std::move(path), this);
}

void BrowseTableModel::clearCurrentDir() {
m_pCurrentDirectory = QString();
}

TrackPointer BrowseTableModel::getTrack(const QModelIndex& index) const {
return getTrackByRef(TrackRef::fromFilePath(getTrackLocation(index)));
}
Expand Down
14 changes: 7 additions & 7 deletions src/library/browse/browsetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class BrowseTableModel final : public QStandardItemModel, public virtual TrackMo
BrowseTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, RecordingManager* pRec);
virtual ~BrowseTableModel();

// initiate table population, store path in m_pCurrentDirectory
void setPath(mixxx::FileAccess path);
// clear m_pCurrentDirectory
void clearCurrentDir();

TrackPointer getTrack(const QModelIndex& index) const override;
TrackPointer getTrackByRef(const TrackRef& trackRef) const override;
Expand All @@ -78,16 +81,12 @@ class BrowseTableModel final : public QStandardItemModel, public virtual TrackMo
TrackModel::SortColumnId sortColumnIdFromColumnIndex(int index) const override;
int columnIndexFromSortColumnId(TrackModel::SortColumnId sortColumn) const override;
QString modelKey(bool noSearch = false) const override {
// TODO re-introduce m_current_directory / m_currentPath
// see https://github.com/mixxxdj/mixxx/commit/dcc6f9e71aac3ee56627bb93c4e37e93cf675bfd#diff-12546d29721e9b62bfba012a790de93c1e5c045a9ac4cc47f48d9c7d93b99d70L166
// or make m_pBrowseThread->m_path public
//m_current_directory.dir().path() +
if (noSearch) {
return QStringLiteral("browse/");
// + m_current_directory.dir().path();
return QStringLiteral("browse/") +
m_pCurrentDirectory;
} else {
return QStringLiteral("browse/") +
//m_current_directory.dir().path() +
m_pCurrentDirectory +
QStringLiteral("#") +
currentSearch();
}
Expand All @@ -109,6 +108,7 @@ class BrowseTableModel final : public QStandardItemModel, public virtual TrackMo
QList<int> m_searchColumns;
RecordingManager* m_pRecordingManager;
BrowseThreadPointer m_pBrowseThread;
QString m_pCurrentDirectory;
QString m_previewDeckGroup;
int m_columnIndexBySortColumnId[static_cast<int>(TrackModel::SortColumnId::IdMax)];
QMap<int, TrackModel::SortColumnId> m_sortColumnIdByColumnIndex;
Expand Down

0 comments on commit 7297b1d

Please sign in to comment.