diff --git a/build/depends.py b/build/depends.py index 1c353740ea93..97dd3b177bf3 100644 --- a/build/depends.py +++ b/build/depends.py @@ -907,7 +907,6 @@ def sources(self, build): "library/features/history/historytreemodel.cpp", "library/features/libraryfolder/libraryfoldermodel.cpp", - "library/features/libraryfolder/libraryfoldersfeature.cpp", "library/features/maintenance/dlghidden.cpp", "library/features/maintenance/dlgmissing.cpp", diff --git a/src/library/abstractmodelroles.h b/src/library/abstractmodelroles.h index 669607943b29..f9e4a4d13978 100644 --- a/src/library/abstractmodelroles.h +++ b/src/library/abstractmodelroles.h @@ -9,6 +9,7 @@ enum AbstractRole { RoleDivider, RoleQuery, RoleBreadCrumb, + RoleSorting, RoleSettings, RoleGroupingLetter }; diff --git a/src/library/features/autodj/autodjfeature.h b/src/library/features/autodj/autodjfeature.h index c3212325d9f2..fc155de636b2 100644 --- a/src/library/features/autodj/autodjfeature.h +++ b/src/library/features/autodj/autodjfeature.h @@ -82,7 +82,7 @@ class AutoDJFeature : public LibraryFeature { // The model-index of the last tree-item that was right-clicked on. // Only stored for tree-items contained by the "Crates" tree-item. - QModelIndex m_lastRightClickedIndex; + QPersistentModelIndex m_lastRightClickedIndex; // A context-menu item that allows crates to be removed from the // auto-DJ list. diff --git a/src/library/features/baseexternalfeature/baseexternallibraryfeature.h b/src/library/features/baseexternalfeature/baseexternallibraryfeature.h index 43ce15bbbbb8..12ff29dc5876 100644 --- a/src/library/features/baseexternalfeature/baseexternallibraryfeature.h +++ b/src/library/features/baseexternalfeature/baseexternallibraryfeature.h @@ -31,7 +31,7 @@ class BaseExternalLibraryFeature : public LibraryFeature { // Must be implemented by external Libraries not copied to Mixxx DB virtual void appendTrackIdsFromRightClickIndex(QList* trackIds, QString* pPlaylist); - QModelIndex m_lastRightClickedIndex; + QPersistentModelIndex m_lastRightClickedIndex; private slots: void slotAddToAutoDJ(); diff --git a/src/library/features/baseplaylist/baseplaylistfeature.cpp b/src/library/features/baseplaylist/baseplaylistfeature.cpp index fc1117352812..365a363b5eb8 100644 --- a/src/library/features/baseplaylist/baseplaylistfeature.cpp +++ b/src/library/features/baseplaylist/baseplaylistfeature.cpp @@ -743,7 +743,7 @@ QModelIndex BasePlaylistFeature::constructChildModel(int selectedId) { } // Create the TreeItem whose parent is the invisible root item - TreeItem* item = new TreeItem(this, QString::number(p.id), p.id); + TreeItem* item = new TreeItem(this, p.name, p.id); item->setBold(m_playlistsSelectedTrackIsIn.contains(p.id)); decorateChild(item, p.id); diff --git a/src/library/features/baseplaylist/baseplaylistfeature.h b/src/library/features/baseplaylist/baseplaylistfeature.h index 67fa84dea70b..544de2d415bd 100644 --- a/src/library/features/baseplaylist/baseplaylistfeature.h +++ b/src/library/features/baseplaylist/baseplaylistfeature.h @@ -4,10 +4,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -120,11 +120,11 @@ class BasePlaylistFeature : public LibraryFeature { QAction *m_pDuplicatePlaylistAction; QAction *m_pAnalyzePlaylistAction; QList m_playlistList; - QModelIndex m_lastRightClickedIndex; + QPersistentModelIndex m_lastRightClickedIndex; TreeItemModel* m_childModel; TrackPointer m_pSelectedTrack; - QHash m_lastChildClicked; + QHash m_lastChildClicked; protected slots: void slotTrackSelected(TrackPointer pTrack); diff --git a/src/library/features/browse/browsefeature.h b/src/library/features/browse/browsefeature.h index d839b43174ba..a11874b43420 100644 --- a/src/library/features/browse/browsefeature.h +++ b/src/library/features/browse/browsefeature.h @@ -79,7 +79,7 @@ class BrowseFeature : public LibraryFeature { TreeItem* m_pLastRightClickedItem; TreeItem* m_pQuickLinkItem; QStringList m_quickLinkList; - QModelIndex m_lastClickedChild; + QPersistentModelIndex m_lastClickedChild; QHash > m_panes; QHash m_idBrowse; diff --git a/src/library/features/crates/cratefeature.h b/src/library/features/crates/cratefeature.h index 85fce0a7dab6..3cc82efe1670 100644 --- a/src/library/features/crates/cratefeature.h +++ b/src/library/features/crates/cratefeature.h @@ -1,13 +1,13 @@ #ifndef CRATEFEATURE_H #define CRATEFEATURE_H -#include #include #include #include #include #include #include +#include #include #include #include @@ -112,14 +112,14 @@ class CrateFeature : public LibraryFeature { QList > m_crateList; QHash > m_crateTableModel; CrateTableModel* m_pCrateTableModel; - QModelIndex m_lastRightClickedIndex; + QPersistentModelIndex m_lastRightClickedIndex; TreeItemModel m_childModel; TrackPointer m_pSelectedTrack; QSet m_cratesSelectedTrackIsIn; QHash > m_panes; QHash m_idBrowse; QHash m_idTable; - QHash m_lastClickedIndex; + QHash m_lastClickedIndex; }; #endif /* CRATEFEATURE_H */ diff --git a/src/library/features/libraryfolder/libraryfoldermodel.cpp b/src/library/features/libraryfolder/libraryfoldermodel.cpp index 3131909d844c..16311c14ddfe 100644 --- a/src/library/features/libraryfolder/libraryfoldermodel.cpp +++ b/src/library/features/libraryfolder/libraryfoldermodel.cpp @@ -10,16 +10,17 @@ LibraryFolderModel::LibraryFolderModel(LibraryFeature* pFeature, TrackCollection* pTrackCollection, UserSettingsPointer pConfig, QObject* parent) - : TreeItemModel(parent), - m_pFeature(pFeature), - m_pTrackCollection(pTrackCollection), - m_pConfig(pConfig), - m_pShowAllItem(nullptr) { - - QString recursive = m_pConfig->getValueString(ConfigKey("[Library]", - "FolderRecursive")); + : MixxxLibraryTreeModel(pFeature, pTrackCollection, pConfig, parent), + m_showFolders(false) { + + QString recursive = m_pConfig->getValueString( + ConfigKey("[Library]", LIBRARYFOLDERMODEL_RECURSIVE)); m_folderRecursive = recursive.toInt() == 1; + QString showFolders = m_pConfig->getValueString( + ConfigKey("[Library]", LIBRARYFOLDERMODEL_FOLDER)); + m_showFolders = showFolders.toInt() == 1; + TrackDAO& trackDAO(pTrackCollection->getTrackDAO()); connect(&trackDAO, SIGNAL(forceModelUpdate()), this, SLOT(reloadTree())); connect(&trackDAO, SIGNAL(tracksAdded(QSet)), @@ -34,19 +35,32 @@ LibraryFolderModel::LibraryFolderModel(LibraryFeature* pFeature, bool LibraryFolderModel::setData( const QModelIndex& index, const QVariant& value, int role) { - if (role == AbstractRole::RoleSettings) { + if (role == AbstractRole::RoleSorting) { + QStringList sort = value.toStringList(); + m_showFolders = sort.first() == LIBRARYFOLDERMODEL_FOLDER; + m_pConfig->set(ConfigKey("[Library]", LIBRARYFOLDERMODEL_FOLDER), + ConfigValue((int)m_showFolders)); + + } else if (role == AbstractRole::RoleSettings) { m_folderRecursive = value.toBool(); m_pConfig->set(ConfigKey("[Library]", "FolderRecursive"), ConfigValue((int)m_folderRecursive)); return true; - } else { - return TreeItemModel::setData(index, value, role); } + + return MixxxLibraryTreeModel::setData(index, value, role); } QVariant LibraryFolderModel::data(const QModelIndex& index, int role) const { if (role == AbstractRole::RoleSettings) { return m_folderRecursive; + } else if (role == AbstractRole::RoleSorting) { + if (m_showFolders) + return LIBRARYFOLDERMODEL_FOLDER; + + return MixxxLibraryTreeModel::data(index, role); + } else if (role == AbstractRole::RoleBreadCrumb) { + return MixxxLibraryTreeModel::data(index, role); } TreeItem* pTree = static_cast(index.internalPointer()); @@ -54,36 +68,26 @@ QVariant LibraryFolderModel::data(const QModelIndex& index, int role) const { return TreeItemModel::data(index, role); } - if (role == AbstractRole::RoleBreadCrumb) { - if (pTree == m_pShowAllItem) { - return m_pFeature->title(); - } else { - return TreeItemModel::data(index, role); - } - } - - if (role == AbstractRole::RoleQuery) { - // User has clicked the show all item - if (pTree == m_pShowAllItem) { - return ""; + if (role == AbstractRole::RoleQuery) { + // User has clicked the show all item or we are showing the library + // instead of the folders + if (!m_folderRecursive || pTree == m_pShowAll || pTree == m_pGrouping) { + return MixxxLibraryTreeModel::data(index, role); } const QString param("%1:=\"%2\""); return param.arg("folder", pTree->getData().toString()); } - return TreeItemModel::data(index, role); + return MixxxLibraryTreeModel::data(index, role); } -void LibraryFolderModel::reloadTree() { - //qDebug() << "LibraryFolderModel::reloadTree()"; - beginResetModel(); - // Remove current root - setRootItem(std::make_unique(m_pFeature)); - - // Add "show all" item - m_pShowAllItem = m_pRootItem->appendChild(tr("Show all"), ""); - +void LibraryFolderModel::createTracksTree() { + if (!m_showFolders) { + MixxxLibraryTreeModel::createTracksTree(); + return; + } + // Get the Library directories QStringList dirs(m_pTrackCollection->getDirectoryDAO().getDirs()); @@ -111,7 +115,13 @@ void LibraryFolderModel::reloadTree() { // For each source folder create the tree createTreeForLibraryDir(dir, query); } - endResetModel(); +} + +QString LibraryFolderModel::getGroupingOptions() { + if (m_showFolders) + return tr("Folders"); + + return MixxxLibraryTreeModel::getGroupingOptions(); } void LibraryFolderModel::createTreeForLibraryDir(const QString& dir, QSqlQuery& query) { @@ -124,8 +134,7 @@ void LibraryFolderModel::createTreeForLibraryDir(const QString& dir, QSqlQuery& QString location = query.value(1).toString(); //qDebug() << location; - - // Remove the + // Remove the first / character QString dispValue = location.mid(dir.size()); if (dispValue.startsWith("/")) { dispValue = dispValue.mid(1); diff --git a/src/library/features/libraryfolder/libraryfoldermodel.h b/src/library/features/libraryfolder/libraryfoldermodel.h index 982e5ee916c8..efa32a05b08e 100644 --- a/src/library/features/libraryfolder/libraryfoldermodel.h +++ b/src/library/features/libraryfolder/libraryfoldermodel.h @@ -3,13 +3,15 @@ #include -#include "library/treeitemmodel.h" -#include "preferences/usersettings.h" +#include "library/features/mixxxlibrary/mixxxlibrarytreemodel.h" class LibraryFeature; class TrackCollection; -class LibraryFolderModel : public TreeItemModel +const QString LIBRARYFOLDERMODEL_FOLDER = "$FOLDER$"; +const QString LIBRARYFOLDERMODEL_RECURSIVE = "FolderRecursive"; + +class LibraryFolderModel : public MixxxLibraryTreeModel { public: LibraryFolderModel(LibraryFeature* pFeature, @@ -19,21 +21,16 @@ class LibraryFolderModel : public TreeItemModel virtual bool setData(const QModelIndex& index, const QVariant& value, int role); virtual QVariant data(const QModelIndex &index, int role) const; - - public slots: - void reloadTree(); - private: + protected: + void createTracksTree() override; + QString getGroupingOptions() override; + private: void createTreeForLibraryDir(const QString& dir, QSqlQuery& query); - LibraryFeature* m_pFeature; - TrackCollection* m_pTrackCollection; - UserSettingsPointer m_pConfig; - - TreeItem* m_pShowAllItem; - bool m_folderRecursive; + bool m_showFolders; }; #endif // LIBRARYFOLDERMODEL_H diff --git a/src/library/features/libraryfolder/libraryfoldersfeature.cpp b/src/library/features/libraryfolder/libraryfoldersfeature.cpp deleted file mode 100644 index 1d53c43c60be..000000000000 --- a/src/library/features/libraryfolder/libraryfoldersfeature.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include - -#include "library/features/libraryfolder/libraryfoldersfeature.h" - -#include "library/features/libraryfolder/libraryfoldermodel.h" -#include "widget/wlibrarysidebar.h" - -LibraryFoldersFeature::LibraryFoldersFeature(UserSettingsPointer pConfig, - Library* pLibrary, - QObject* parent, - TrackCollection* pTrackCollection) - : MixxxLibraryFeature(pConfig, pLibrary, parent, pTrackCollection) { - - setChildModel(new LibraryFolderModel(this, m_pTrackCollection, m_pConfig)); -} - -QVariant LibraryFoldersFeature::title() { - return "Folders"; -} - -QString LibraryFoldersFeature::getIconPath() { - return ":/images/library/ic_library_folder.png"; -} - -QString LibraryFoldersFeature::getSettingsName() const { - return "LibraryFoldersFeature"; -} - -QWidget* LibraryFoldersFeature::createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) { - m_pSidebar = createLibrarySidebarWidget(pKeyboard); - return m_pSidebar; -} - -void LibraryFoldersFeature::onRightClickChild(const QPoint&pos, - const QModelIndex&) { - - bool recursive = m_pChildModel->data(QModelIndex(), - AbstractRole::RoleSettings).toBool(); - - QMenu menu; - QAction* showRecursive = menu.addAction(tr("Show recursive view in folders")); - showRecursive->setCheckable(true); - showRecursive->setChecked(recursive); - - QAction* selected = menu.exec(pos); - - if (selected == showRecursive) { - m_pChildModel->setData(QModelIndex(), selected->isChecked(), - AbstractRole::RoleSettings); - } else { - // Menu rejected - return; - } - - m_pChildModel->reloadTree(); -} diff --git a/src/library/features/libraryfolder/libraryfoldersfeature.h b/src/library/features/libraryfolder/libraryfoldersfeature.h deleted file mode 100644 index 398a6ee42e70..000000000000 --- a/src/library/features/libraryfolder/libraryfoldersfeature.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LIBRARYFOLDERSFEATURE_H -#define LIBRARYFOLDERSFEATURE_H - -#include "library/features/mixxxlibrary/mixxxlibraryfeature.h" - -class LibraryFoldersModel; - -class LibraryFoldersFeature : public MixxxLibraryFeature -{ - public: - LibraryFoldersFeature(UserSettingsPointer pConfig, - Library* pLibrary, - QObject* parent, - TrackCollection* pTrackCollection); - - QVariant title() override; - QString getIconPath() override; - QString getSettingsName() const override; - QWidget* createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) override; - - public slots: - void onRightClickChild(const QPoint& pos, const QModelIndex&) override; -}; - -#endif // LIBRARYFOLDERSFEATURE_H diff --git a/src/library/features/mixxxlibrary/mixxxlibraryfeature.cpp b/src/library/features/mixxxlibrary/mixxxlibraryfeature.cpp index 1d144ae23cdb..e4b3f02de9a7 100644 --- a/src/library/features/mixxxlibrary/mixxxlibraryfeature.cpp +++ b/src/library/features/mixxxlibrary/mixxxlibraryfeature.cpp @@ -7,6 +7,7 @@ #include #include "library/features/mixxxlibrary/mixxxlibraryfeature.h" +#include "library/features/libraryfolder/libraryfoldermodel.h" #include "library/basetrackcache.h" #include "library/librarytablemodel.h" @@ -26,7 +27,8 @@ const QStringList MixxxLibraryFeature::kGroupingText = tr("Artist > Album"), tr("Album"), tr("Genre > Artist > Album"), - tr("Genre > Album") + tr("Genre > Album"), + tr("Folder") }); const QList MixxxLibraryFeature::kGroupingOptions = @@ -35,7 +37,8 @@ const QList MixxxLibraryFeature::kGroupingOptions = QStringList::fromStdList({ LIBRARYTABLE_ALBUM }), QStringList::fromStdList({ LIBRARYTABLE_GENRE, LIBRARYTABLE_ARTIST, LIBRARYTABLE_ALBUM }), - QStringList::fromStdList({ LIBRARYTABLE_GENRE, LIBRARYTABLE_ALBUM }) + QStringList::fromStdList({ LIBRARYTABLE_GENRE, LIBRARYTABLE_ALBUM }), + QStringList::fromStdList({ LIBRARYFOLDERMODEL_FOLDER }) }); MixxxLibraryFeature::MixxxLibraryFeature(UserSettingsPointer pConfig, @@ -43,7 +46,8 @@ MixxxLibraryFeature::MixxxLibraryFeature(UserSettingsPointer pConfig, QObject* parent, TrackCollection* pTrackCollection) : LibraryFeature(pConfig, pLibrary, pTrackCollection, parent), - m_trackDao(pTrackCollection->getTrackDAO()) { + m_trackDao(pTrackCollection->getTrackDAO()), + m_foldersShown(false) { m_pBaseTrackCache = pTrackCollection->getTrackSource(); connect(&m_trackDao, SIGNAL(trackDirty(TrackId)), @@ -59,7 +63,7 @@ MixxxLibraryFeature::MixxxLibraryFeature(UserSettingsPointer pConfig, connect(&m_trackDao, SIGNAL(dbTrackAdded(TrackPointer)), m_pBaseTrackCache.data(), SLOT(slotDbTrackAdded(TrackPointer))); - setChildModel(new MixxxLibraryTreeModel(this, m_pTrackCollection, m_pConfig)); + setChildModel(new LibraryFolderModel(this, m_pTrackCollection, m_pConfig)); m_pLibraryTableModel = new LibraryTableModel(this, pTrackCollection, "mixxx.db.model.library"); } @@ -118,7 +122,7 @@ void MixxxLibraryFeature::setChildModel(TreeItemModel* pChild) { m_pChildModel, SLOT(reloadTree())); } -void MixxxLibraryFeature::activate() { +void MixxxLibraryFeature::activate() { if (m_lastClickedIndex.isValid()) { activateChild(m_lastClickedIndex); return; @@ -133,6 +137,7 @@ void MixxxLibraryFeature::activate() { void MixxxLibraryFeature::activateChild(const QModelIndex& index) { m_lastClickedIndex = index; + if (!index.isValid()) return; QString query = index.data(AbstractRole::RoleQuery).toString(); @@ -151,7 +156,7 @@ void MixxxLibraryFeature::activateChild(const QModelIndex& index) { } void MixxxLibraryFeature::invalidateChild() { - m_lastClickedIndex = QModelIndex(); + m_lastClickedIndex = QPersistentModelIndex(); } void MixxxLibraryFeature::onRightClickChild(const QPoint& pos, @@ -159,9 +164,11 @@ void MixxxLibraryFeature::onRightClickChild(const QPoint& pos, // Create the sort menu QMenu menu; - QVariant varSort = m_pChildModel->data(QModelIndex(), - AbstractRole::RoleSettings); - QStringList currentSort = varSort.toStringList(); + QStringList currentSort = m_pChildModel->data( + QModelIndex(), AbstractRole::RoleSorting).toStringList(); + bool recursive = m_pChildModel->data( + QModelIndex(), AbstractRole::RoleSettings).toBool(); + QActionGroup* orderGroup = new QActionGroup(&menu); for (int i = 0; i < kGroupingOptions.size(); ++i) { @@ -172,15 +179,20 @@ void MixxxLibraryFeature::onRightClickChild(const QPoint& pos, action->setChecked(currentSort == kGroupingOptions.at(i)); } + menu.addSeparator(); + QAction* folderRecursive = menu.addAction(tr("Get recursive folder search query")); + folderRecursive->setCheckable(true); + folderRecursive->setChecked(recursive); + QAction* selected = menu.exec(pos); if (selected == nullptr) { return; + } else if (selected == folderRecursive) { + setTreeSettings(folderRecursive->isChecked(), + AbstractRole::RoleSettings); + } else { + setTreeSettings(selected->data()); } - if (!m_pGroupingCombo.isNull()) { - int index = kGroupingOptions.indexOf(selected->data().toStringList()); - m_pGroupingCombo->setCurrentIndex(index); - } - setTreeSettings(selected->data()); } bool MixxxLibraryFeature::dropAccept(QList urls, QObject* pSource) { @@ -202,10 +214,11 @@ bool MixxxLibraryFeature::dragMoveAccept(QUrl url) { Parser::isPlaylistFilenameSupported(url.toLocalFile()); } -void MixxxLibraryFeature::setTreeSettings(const QVariant& settings) { +void MixxxLibraryFeature::setTreeSettings(const QVariant& settings, + AbstractRole role) { if (m_pChildModel.isNull()) { return; } - m_pChildModel->setData(QModelIndex(), settings, AbstractRole::RoleSettings); + m_pChildModel->setData(QModelIndex(), settings, role); m_pChildModel->reloadTree(); } diff --git a/src/library/features/mixxxlibrary/mixxxlibraryfeature.h b/src/library/features/mixxxlibrary/mixxxlibraryfeature.h index eb3d5cd4e952..e83df973af77 100644 --- a/src/library/features/mixxxlibrary/mixxxlibraryfeature.h +++ b/src/library/features/mixxxlibrary/mixxxlibraryfeature.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -74,16 +74,18 @@ class MixxxLibraryFeature : public LibraryFeature { static const QString kLibraryTitle; static const QList kGroupingOptions; static const QStringList kGroupingText; + static const QString kLibraryFolder; private slots: - void setTreeSettings(const QVariant &settings); + void setTreeSettings(const QVariant &settings, + AbstractRole role = AbstractRole::RoleSorting); private: - QPointer m_pGroupingCombo; QSharedPointer m_pBaseTrackCache; LibraryTableModel* m_pLibraryTableModel; TrackDAO& m_trackDao; - QModelIndex m_lastClickedIndex; + QPersistentModelIndex m_lastClickedIndex; + bool m_foldersShown; }; diff --git a/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.cpp b/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.cpp index 29d8afabf322..349c767509b6 100644 --- a/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.cpp +++ b/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.cpp @@ -58,7 +58,7 @@ MixxxLibraryTreeModel::MixxxLibraryTreeModel(LibraryFeature* pFeature, QVariant MixxxLibraryTreeModel::data(const QModelIndex& index, int role) const { - if (role == AbstractRole::RoleSettings) { + if (role == AbstractRole::RoleSorting) { return m_sortOrder; } @@ -69,14 +69,14 @@ QVariant MixxxLibraryTreeModel::data(const QModelIndex& index, int role) const { } if (role == AbstractRole::RoleGroupingLetter) { - if (pTree == m_pLibraryItem || pTree == m_pSettings) { + if (pTree == m_pShowAll || pTree == m_pGrouping) { return QChar(); } return TreeItemModel::data(index, role); } if (role == AbstractRole::RoleBreadCrumb) { - if (pTree == m_pLibraryItem) { + if (pTree == m_pShowAll) { return m_pFeature->title(); } else { return TreeItemModel::data(index, role); @@ -121,7 +121,7 @@ QVariant MixxxLibraryTreeModel::data(const QModelIndex& index, int role) const { bool MixxxLibraryTreeModel::setData(const QModelIndex& index, const QVariant& value, int role) { - if (role == AbstractRole::RoleSettings) { + if (role == AbstractRole::RoleSorting) { m_sortOrder = value.toStringList(); m_pConfig->set(ConfigKey("[Library]", LIBRARYTREEMODEL_SORT), ConfigValue(m_sortOrder.join(","))); @@ -137,10 +137,10 @@ void MixxxLibraryTreeModel::reloadTree() { // Create root item TreeItem* pRootItem = setRootItem(std::make_unique(m_pFeature)); - m_pLibraryItem = pRootItem->appendChild(tr("Show all"), ""); + m_pShowAll = pRootItem->appendChild(tr("Show all"), ""); - QString groupTitle = tr("Grouping Options (%1)").arg(m_sortOrder.join(" > ")); - m_pSettings = pRootItem->appendChild(groupTitle, ""); + QString groupTitle = tr("Grouping Options (%1)").arg(getGroupingOptions()); + m_pGrouping = pRootItem->appendChild(groupTitle, ""); // Deletes the old root item if the previous root item was not null createTracksTree(); @@ -166,9 +166,9 @@ QVariant MixxxLibraryTreeModel::getQuery(TreeItem* pTree) const { return ""; } - if (pTree == m_pLibraryItem) { + if (pTree == m_pShowAll) { return ""; - } else if (pTree == m_pSettings) { + } else if (pTree == m_pGrouping) { return "$groupingSettings$"; } @@ -320,6 +320,10 @@ void MixxxLibraryTreeModel::createTracksTree() { } } +QString MixxxLibraryTreeModel::getGroupingOptions() { + return m_sortOrder.join(" > "); +} + void MixxxLibraryTreeModel::addCoverArt(const MixxxLibraryTreeModel::CoverIndex& index, const QSqlQuery& query, TreeItem* pTree) { CoverInfo c; diff --git a/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.h b/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.h index 9fce412ade0a..5b33d9e4e073 100644 --- a/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.h +++ b/src/library/features/mixxxlibrary/mixxxlibrarytreemodel.h @@ -29,8 +29,18 @@ class MixxxLibraryTreeModel : public TreeItemModel { public slots: void reloadTree() override; - private: + protected: + virtual void createTracksTree(); + virtual QString getGroupingOptions(); + TreeItem* m_pGrouping; + TreeItem* m_pShowAll; + + LibraryFeature* m_pFeature; + TrackCollection* m_pTrackCollection; + UserSettingsPointer m_pConfig; + + private: struct CoverIndex { int iCoverHash; int iCoverLoc; @@ -45,20 +55,11 @@ class MixxxLibraryTreeModel : public TreeItemModel { private: QVariant getQuery(TreeItem* pTree) const; - void createTracksTree(); void addCoverArt(const CoverIndex& index, const QSqlQuery& query, TreeItem* pTree); - LibraryFeature* m_pFeature; - TrackCollection* m_pTrackCollection; - UserSettingsPointer m_pConfig; QStringList m_sortOrder; QStringList m_coverQuery; - - TreeItem* m_pSettings; - TreeItem* m_pLibraryItem; - - bool m_folderRecursive; }; #endif // LIBRARYTREEMODEL_H diff --git a/src/library/library.cpp b/src/library/library.cpp index 0c7fee93be35..cdd1e47fa184 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -16,7 +16,6 @@ #include "library/features/crates/cratefeature.h" #include "library/features/history/historyfeature.h" #include "library/features/itunes/itunesfeature.h" -#include "library/features/libraryfolder/libraryfoldersfeature.h" #include "library/features/maintenance/maintenancefeature.h" #include "library/features/mixxxlibrary/mixxxlibraryfeature.h" #include "library/features/playlist/playlistfeature.h" @@ -701,9 +700,6 @@ void Library::createFeatures(UserSettingsPointer pConfig, addFeature(new AutoDJFeature( pConfig, this, this, pPlayerManager, m_pTrackCollection)); - addFeature(new LibraryFoldersFeature( - pConfig, this, this, m_pTrackCollection)); - m_pPlaylistFeature = new PlaylistFeature( pConfig, this, this, m_pTrackCollection); addFeature(m_pPlaylistFeature); diff --git a/src/library/treeitem.h b/src/library/treeitem.h index 9566f7abd402..db2028d2322c 100644 --- a/src/library/treeitem.h +++ b/src/library/treeitem.h @@ -142,11 +142,11 @@ class TreeItem final { void appendChild(TreeItem* pChild); void insertChild(TreeItem* pChild, int row); + LibraryFeature* m_pFeature; + TreeItem* m_pParent; QList m_children; // owned child items - LibraryFeature* m_pFeature; - QString m_label; QString m_labelNumbered; QVariant m_data;