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
16 changes: 10 additions & 6 deletions src/library/features/analysis/analysisfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,23 @@ QString AnalysisFeature::getSettingsName() const {
return "AnalysisFeature";
}

QWidget* AnalysisFeature::createPaneWidget(KeyboardEventFilter*, int paneId) {
WTrackTableView* pTable = createTableWidget(paneId);
parented_ptr<QWidget> AnalysisFeature::createPaneWidget(KeyboardEventFilter*,
int paneId, QWidget* parent) {
auto pTable = createTableWidget(paneId, parent);
pTable->loadTrackModel(&m_analysisLibraryTableModel);
connect(pTable->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this,
SLOT(tableSelectionChanged(const QItemSelection&, const QItemSelection&)));

return pTable;
return std::move(pTable);
}

QWidget* AnalysisFeature::createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) {
m_pAnalysisView = new DlgAnalysis(nullptr, this, m_pTrackCollection);
parented_ptr<QWidget> AnalysisFeature::createInnerSidebarWidget(
KeyboardEventFilter* pKeyboard, QWidget* parent) {
auto pAnalysisView = make_parented<DlgAnalysis>(parent, this, m_pTrackCollection);

m_pAnalysisView = pAnalysisView.toWeakRef();
m_pAnalysisView->setTableModel(&m_analysisLibraryTableModel);

connect(this, SIGNAL(analysisActive(bool)),
Expand All @@ -87,9 +90,10 @@ QWidget* AnalysisFeature::createInnerSidebarWidget(KeyboardEventFilter* pKeyboar
// Let the DlgAnalysis know whether or not analysis is active.
bool bAnalysisActive = m_pAnalyzerQueue != nullptr;
emit(analysisActive(bAnalysisActive));

m_pAnalysisView->onShow();

return m_pAnalysisView;
return std::move(pAnalysisView);
}

TreeItemModel* AnalysisFeature::getChildModel() {
Expand Down
6 changes: 4 additions & 2 deletions src/library/features/analysis/analysisfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class AnalysisFeature : public LibraryFeature {
bool dropAccept(QList<QUrl> urls, QObject* pSource);
bool dragMoveAccept(QUrl url);

QWidget* createPaneWidget(KeyboardEventFilter*, int paneId) override;
QWidget* createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) override;
parented_ptr<QWidget> createPaneWidget(KeyboardEventFilter*, int paneId,
QWidget* parent) override;
parented_ptr<QWidget> createInnerSidebarWidget(KeyboardEventFilter* pKeyboard,
QWidget* parent) override;

TreeItemModel* getChildModel();
void refreshLibraryModels();
Expand Down
27 changes: 14 additions & 13 deletions src/library/features/autodj/autodjfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,46 +104,47 @@ QString AutoDJFeature::getSettingsName() const {
return "AutoDJFeature";
}

QWidget* AutoDJFeature::createPaneWidget(KeyboardEventFilter*, int paneId) {
WTrackTableView* pTrackTableView = createTableWidget(paneId);
parented_ptr<QWidget> AutoDJFeature::createPaneWidget(KeyboardEventFilter*,
int paneId, QWidget* parent) {
auto pTrackTableView = createTableWidget(paneId, parent);
pTrackTableView->loadTrackModel(m_pAutoDJProcessor->getTableModel());

connect(pTrackTableView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this,
SLOT(selectionChanged(const QItemSelection&, const QItemSelection&)));

return pTrackTableView;
return std::move(pTrackTableView);
}

QWidget* AutoDJFeature::createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) {
QTabWidget* pContainer = new QTabWidget(nullptr);
parented_ptr<QWidget> AutoDJFeature::createInnerSidebarWidget(
KeyboardEventFilter* pKeyboard, QWidget* parent) {
auto pContainer = make_parented<QTabWidget>(parent);

// now the icon loader is set up and get an icon
m_pCratesTreeItem->setIcon(WPixmapStore::getLibraryIcon(
":/images/library/ic_library_crates.png"));

// Add controls
m_pAutoDJView = new DlgAutoDJ(pContainer, m_pAutoDJProcessor);
auto pAutoDJView = make_parented<DlgAutoDJ>(pContainer.get(), m_pAutoDJProcessor);
m_pAutoDJView = pAutoDJView.toWeakRef();
m_pAutoDJView->installEventFilter(pKeyboard);
QScrollArea* pScroll = new QScrollArea(pContainer);
auto pScroll = make_parented<QScrollArea>(pContainer.get());
pScroll->setWidget(m_pAutoDJView);
pScroll->setWidgetResizable(true);
pContainer->addTab(pScroll, tr("Controls"));
pContainer->addTab(pScroll.get(), tr("Controls"));

// Add drop target
WLibrarySidebar* pSidebar = createLibrarySidebarWidget(pKeyboard);
pSidebar->setParent(pContainer);

pContainer->addTab(pSidebar, tr("Track source"));
auto pSidebar = createLibrarySidebarWidget(pContainer.get());
pContainer->addTab(pSidebar.get(), tr("Track source"));

// Be informed when the user wants to add another random track.
connect(m_pAutoDJProcessor,SIGNAL(randomTrackRequested(int)),
this,SLOT(slotRandomQueue(int)));
connect(m_pAutoDJView, SIGNAL(addRandomButton(bool)),
this, SLOT(slotAddRandomTrack()));

return pContainer;
return std::move(pContainer);
}

TreeItemModel* AutoDJFeature::getChildModel() {
Expand Down
6 changes: 4 additions & 2 deletions src/library/features/autodj/autodjfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ class AutoDJFeature : public LibraryFeature {
bool dropAccept(QList<QUrl> urls, QObject* pSource);
bool dragMoveAccept(QUrl url);

QWidget* createPaneWidget(KeyboardEventFilter*, int paneId) override;
QWidget* createInnerSidebarWidget(KeyboardEventFilter* pKeyboard) override;
parented_ptr<QWidget> createPaneWidget(KeyboardEventFilter*, int paneId,
QWidget* parent) override;
parented_ptr<QWidget> createInnerSidebarWidget(KeyboardEventFilter* pKeyboard,
QWidget* parent) override;

TreeItemModel* getChildModel();

Expand Down
40 changes: 18 additions & 22 deletions src/library/features/baseplaylist/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ BasePlaylistFeature::BasePlaylistFeature(UserSettingsPointer pConfig,
m_playlistDao(pTrackCollection->getPlaylistDAO()),
m_trackDao(pTrackCollection->getTrackDAO()),
m_pPlaylistTableModel(nullptr) {
m_childModel = new TreeItemModel;

m_pCreatePlaylistAction = new QAction(tr("Create New Playlist"),this);
connect(m_pCreatePlaylistAction, SIGNAL(triggered()),
Expand Down Expand Up @@ -679,28 +678,23 @@ void BasePlaylistFeature::slotAnalyzePlaylist() {
}
}

TreeItemModel* BasePlaylistFeature::getChildModel() {
return m_childModel;
}

QWidget* BasePlaylistFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId) {
WLibraryStack* pStack = new WLibraryStack(nullptr);
m_panes[paneId] = pStack;
parented_ptr<QWidget> BasePlaylistFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId, QWidget* parent) {
auto pStack = make_parented<WLibraryStack>(parent);
m_panes[paneId] = pStack.toWeakRef();

WLibraryTextBrowser* edit = new WLibraryTextBrowser(pStack);
auto edit = make_parented<WLibraryTextBrowser>(pStack.get());
edit->setHtml(getRootViewHtml());
edit->setOpenLinks(false);
edit->installEventFilter(pKeyboard);
connect(edit, SIGNAL(anchorClicked(const QUrl)),
connect(edit.get(), SIGNAL(anchorClicked(const QUrl)),
this, SLOT(htmlLinkClicked(const QUrl)));
m_browseIndexByPaneId[paneId] = pStack->addWidget(edit);
m_browseIndexByPaneId[paneId] = pStack->addWidget(edit.get());

QWidget* pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId);
pTable->setParent(pStack);
m_tableIndexByPaneId[paneId] = pStack->addWidget(pTable);
auto pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId, pStack.get());
m_tableIndexByPaneId[paneId] = pStack->addWidget(pTable.get());

return pStack;
return std::move(pStack);
}

void BasePlaylistFeature::htmlLinkClicked(const QUrl& link) {
Expand Down Expand Up @@ -738,8 +732,9 @@ QModelIndex BasePlaylistFeature::constructChildModel(int selectedId) {
}

// Append all the newly created TreeItems in a dynamic way to the childmodel
m_childModel->insertTreeItemRows(dataList, 0);
return m_childModel->index(selectedRow, 0);
TreeItemModel *pChildModel = getChildModel();
pChildModel->insertTreeItemRows(dataList, 0);
return pChildModel->index(selectedRow, 0);
}

void BasePlaylistFeature::updateChildModel(int selectedId) {
Expand All @@ -750,7 +745,7 @@ void BasePlaylistFeature::updateChildModel(int selectedId) {
return;
}

TreeItem* item = m_childModel->getItem(index);
TreeItem* item = getChildModel()->getItem(index);
VERIFY_OR_DEBUG_ASSERT(item) {
return;
}
Expand All @@ -770,7 +765,7 @@ QModelIndex BasePlaylistFeature::indexFromPlaylistId(int playlistId) const {
return QModelIndex();
}

return m_childModel->index(row, 0);
return getConstChildModel()->index(row, 0);
}

void BasePlaylistFeature::slotTrackSelected(TrackPointer pTrack) {
Expand All @@ -783,12 +778,13 @@ void BasePlaylistFeature::slotTrackSelected(TrackPointer pTrack) {

// Set all playlists the track is in bold (or if there is no track selected,
// clear all the bolding).
TreeItemModel* pChildModel = getChildModel();
for (const PlaylistItem& p : m_playlistList) {
QModelIndex index = indexFromPlaylistId(p.id);

bool shouldBold = m_playlistsSelectedTrackIsIn.contains(p.id);
m_childModel->setData(index, shouldBold, AbstractRole::RoleBold);
pChildModel->setData(index, shouldBold, AbstractRole::RoleBold);
}

m_childModel->triggerRepaint();
pChildModel->triggerRepaint();
}
16 changes: 4 additions & 12 deletions src/library/features/baseplaylist/baseplaylistfeature.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
#ifndef BASEPLAYLISTFEATURE_H
#define BASEPLAYLISTFEATURE_H

#include <QAction>
#include <QUrl>
#include <QObject>
#include <QAction>
#include <QList>
#include <QPair>
#include <QPersistentModelIndex>
#include <QSet>
#include <QString>

#include "library/dao/playlistdao.h"
#include "library/dao/trackdao.h"
#include "library/libraryfeature.h"
#include "track/track.h"

class KeyboardEventFilter;
class PlaylistTableModel;
class TrackCollection;
class TreeItem;
Expand All @@ -31,10 +24,8 @@ class BasePlaylistFeature : public LibraryFeature {
QObject* parent,
TrackCollection* pTrackCollection);
virtual ~BasePlaylistFeature();

TreeItemModel* getChildModel();

QWidget* createPaneWidget(KeyboardEventFilter*pKeyboard, int paneId) override;
parented_ptr<QWidget> createPaneWidget(KeyboardEventFilter*pKeyboard,
int paneId, QWidget* parent) override;

signals:
void showPage(const QUrl& page);
Expand Down Expand Up @@ -84,6 +75,8 @@ class BasePlaylistFeature : public LibraryFeature {
}
};

virtual const TreeItemModel* getConstChildModel() const = 0;

virtual QModelIndex constructChildModel(int selected_id);
virtual void updateChildModel(int selectedId);
virtual void buildPlaylistList() = 0;
Expand Down Expand Up @@ -121,7 +114,6 @@ class BasePlaylistFeature : public LibraryFeature {
QAction *m_pAnalyzePlaylistAction;
QList<PlaylistItem> m_playlistList;
QPersistentModelIndex m_lastRightClickedIndex;
TreeItemModel* m_childModel;
TrackPointer m_pSelectedTrack;

QHash<int, QPersistentModelIndex> m_lastChildClicked;
Expand Down
19 changes: 9 additions & 10 deletions src/library/features/browse/browsefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,20 @@ TreeItemModel* BrowseFeature::getChildModel() {
return &m_childModel;
}

QWidget* BrowseFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId) {
WLibraryStack* pStack = new WLibraryStack(nullptr);
m_panes[paneId] = pStack;
parented_ptr<QWidget> BrowseFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId, QWidget* parent) {
auto pStack = make_parented<WLibraryStack>(parent);
m_panes[paneId] = pStack.toWeakRef();

WLibraryTextBrowser* pEdit = new WLibraryTextBrowser(nullptr);
auto pEdit = make_parented<WLibraryTextBrowser>(pStack.get());
pEdit->setHtml(getRootViewHtml());
pEdit->installEventFilter(pKeyboard);
m_idBrowse[paneId] = pStack->addWidget(pEdit);
m_idBrowse[paneId] = pStack->addWidget(pEdit.get());

QWidget* pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId);
pTable->setParent(pStack);
m_idTable[paneId] = pStack->addWidget(pTable);
auto pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId, pStack.get());
m_idTable[paneId] = pStack->addWidget(pTable.get());

return pStack;
return std::move(pStack);
}

void BrowseFeature::activate() {
Expand Down
3 changes: 2 additions & 1 deletion src/library/features/browse/browsefeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class BrowseFeature : public LibraryFeature {
QString getIconPath() override;
QString getSettingsName() const override;

QWidget* createPaneWidget(KeyboardEventFilter*pKeyboard, int paneId) override;
parented_ptr<QWidget> createPaneWidget(KeyboardEventFilter*pKeyboard,
int paneId, QWidget* parent) override;

TreeItemModel* getChildModel();

Expand Down
21 changes: 11 additions & 10 deletions src/library/features/crates/cratefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,24 +250,25 @@ bool CrateFeature::dragMoveAcceptChild(const QModelIndex& index, QUrl url) {
Parser::isPlaylistFilenameSupported(url.toLocalFile());
}

QWidget* CrateFeature::createPaneWidget(KeyboardEventFilter *pKeyboard,
int paneId) {
WLibraryStack* pContainer = new WLibraryStack(nullptr);
m_panes[paneId] = pContainer;
parented_ptr<QWidget> CrateFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId, QWidget* parent) {
auto pContainer = make_parented<WLibraryStack>(parent);
m_panes[paneId] = pContainer.toWeakRef();

WLibraryTextBrowser* pEdit = new WLibraryTextBrowser(pContainer);
auto pEdit = make_parented<WLibraryTextBrowser>(pContainer.get());
pEdit->setHtml(formatRootViewHtml());
pEdit->setOpenLinks(false);
pEdit->installEventFilter(pKeyboard);
connect(pEdit, SIGNAL(anchorClicked(const QUrl)),
connect(pEdit.get(), SIGNAL(anchorClicked(const QUrl)),
this, SLOT(htmlLinkClicked(const QUrl)));

m_idBrowse[paneId] = pContainer->addWidget(pEdit);
m_idBrowse[paneId] = pContainer->addWidget(pEdit.get());

QWidget* pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId);
m_idTable[paneId] = pContainer->addWidget(pTable);
auto pTable = LibraryFeature::createPaneWidget(pKeyboard, paneId,
pContainer.get());
m_idTable[paneId] = pContainer->addWidget(pTable.get());

return pContainer;
return std::move(pContainer);
}

TreeItemModel* CrateFeature::getChildModel() {
Expand Down
3 changes: 2 additions & 1 deletion src/library/features/crates/cratefeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CrateFeature : public LibraryFeature {
QObject* pSource) override;
bool dragMoveAcceptChild(const QModelIndex& index, QUrl url) override;

QWidget* createPaneWidget(KeyboardEventFilter* pKeyboard, int paneId) override;
parented_ptr<QWidget> createPaneWidget(KeyboardEventFilter* pKeyboard,
int paneId, QWidget* parent) override;

TreeItemModel* getChildModel() override;

Expand Down
Loading