Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/library/abstractmodelroles.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum AbstractRole {
RoleDivider,
RoleQuery,
RoleBreadCrumb,
RoleSorting,
RoleSettings,
RoleGroupingLetter
};
Expand Down
2 changes: 1 addition & 1 deletion src/library/features/autodj/autodjfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BaseExternalLibraryFeature : public LibraryFeature {
// Must be implemented by external Libraries not copied to Mixxx DB
virtual void appendTrackIdsFromRightClickIndex(QList<TrackId>* trackIds, QString* pPlaylist);

QModelIndex m_lastRightClickedIndex;
QPersistentModelIndex m_lastRightClickedIndex;

private slots:
void slotAddToAutoDJ();
Expand Down
2 changes: 1 addition & 1 deletion src/library/features/baseplaylist/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/library/features/baseplaylist/baseplaylistfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <QAction>
#include <QUrl>
#include <QObject>
#include <QModelIndex>
#include <QAction>
#include <QList>
#include <QPair>
#include <QPersistentModelIndex>
#include <QSet>
#include <QString>

Expand Down Expand Up @@ -120,11 +120,11 @@ class BasePlaylistFeature : public LibraryFeature {
QAction *m_pDuplicatePlaylistAction;
QAction *m_pAnalyzePlaylistAction;
QList<PlaylistItem> m_playlistList;
QModelIndex m_lastRightClickedIndex;
QPersistentModelIndex m_lastRightClickedIndex;
TreeItemModel* m_childModel;
TrackPointer m_pSelectedTrack;

QHash<int, QModelIndex> m_lastChildClicked;
QHash<int, QPersistentModelIndex> m_lastChildClicked;

protected slots:
void slotTrackSelected(TrackPointer pTrack);
Expand Down
2 changes: 1 addition & 1 deletion src/library/features/browse/browsefeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class BrowseFeature : public LibraryFeature {
TreeItem* m_pLastRightClickedItem;
TreeItem* m_pQuickLinkItem;
QStringList m_quickLinkList;
QModelIndex m_lastClickedChild;
QPersistentModelIndex m_lastClickedChild;

QHash<int, QPointer<WLibraryStack> > m_panes;
QHash<int, int> m_idBrowse;
Expand Down
6 changes: 3 additions & 3 deletions src/library/features/crates/cratefeature.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef CRATEFEATURE_H
#define CRATEFEATURE_H

#include <QModelIndex>
#include <QList>
#include <QPair>
#include <QAction>
#include <QVariant>
#include <QUrl>
#include <QIcon>
#include <QPersistentModelIndex>
#include <QPoint>
#include <QSet>
#include <QStackedWidget>
Expand Down Expand Up @@ -112,14 +112,14 @@ class CrateFeature : public LibraryFeature {
QList<QPair<int, QString> > m_crateList;
QHash<int, QPointer<CrateTableModel> > m_crateTableModel;
CrateTableModel* m_pCrateTableModel;
QModelIndex m_lastRightClickedIndex;
QPersistentModelIndex m_lastRightClickedIndex;
TreeItemModel m_childModel;
TrackPointer m_pSelectedTrack;
QSet<int> m_cratesSelectedTrackIsIn;
QHash<int, QPointer<QStackedWidget> > m_panes;
QHash<int,int> m_idBrowse;
QHash<int,int> m_idTable;
QHash<int, QModelIndex> m_lastClickedIndex;
QHash<int, QPersistentModelIndex> m_lastClickedIndex;
};

#endif /* CRATEFEATURE_H */
81 changes: 45 additions & 36 deletions src/library/features/libraryfolder/libraryfoldermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TrackId>)),
Expand All @@ -34,56 +35,59 @@ 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<TreeItem*>(index.internalPointer());
DEBUG_ASSERT_AND_HANDLE(pTree != nullptr) {
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<TreeItem>(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());

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
23 changes: 10 additions & 13 deletions src/library/features/libraryfolder/libraryfoldermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

#include <QSqlQuery>

#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,
Expand All @@ -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
58 changes: 0 additions & 58 deletions src/library/features/libraryfolder/libraryfoldersfeature.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions src/library/features/libraryfolder/libraryfoldersfeature.h

This file was deleted.

Loading