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
12 changes: 5 additions & 7 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def sources(self, build):
"dlgprefcrossfader.cpp",
"dlgtagfetcher.cpp",
"dlgtrackinfo.cpp",
"dlgprepare.cpp",
"dlganalysis.cpp",
"dlgautodj.cpp",
"dlghidden.cpp",
"dlgmissing.cpp",
Expand Down Expand Up @@ -574,23 +574,21 @@ def sources(self, build):
"widget/wlibrarysidebar.cpp",
"widget/wlibrary.cpp",
"widget/wlibrarytableview.cpp",
"widget/wpreparelibrarytableview.cpp",
"widget/wpreparecratestableview.cpp",
"widget/wanalysislibrarytableview.cpp",
"widget/wlibrarytextbrowser.cpp",
"library/preparecratedelegate.cpp",
"library/trackcollection.cpp",
"library/basesqltablemodel.cpp",
"library/basetrackcache.cpp",
"library/librarytablemodel.cpp",
"library/searchqueryparser.cpp",
"library/preparelibrarytablemodel.cpp",
"library/analysislibrarytablemodel.cpp",
"library/missingtablemodel.cpp",
"library/hiddentablemodel.cpp",
"library/proxytrackmodel.cpp",

"library/playlisttablemodel.cpp",
"library/libraryfeature.cpp",
"library/preparefeature.cpp",
"library/analysisfeature.cpp",
"library/autodjfeature.cpp",
"library/mixxxlibraryfeature.cpp",
"library/baseplaylistfeature.cpp",
Expand Down Expand Up @@ -780,7 +778,7 @@ def sources(self, build):
build.env.Uic4('dlgaboutdlg.ui')
build.env.Uic4('dlgtagfetcher.ui')
build.env.Uic4('dlgtrackinfo.ui')
build.env.Uic4('dlgprepare.ui')
build.env.Uic4('dlganalysis.ui')
build.env.Uic4('dlgautodj.ui')
build.env.Uic4('dlgprefsounditem.ui')
build.env.Uic4('dlgrecording.ui')
Expand Down
2 changes: 1 addition & 1 deletion src/analyserqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ AnalyserQueue* AnalyserQueue::createDefaultAnalyserQueue(
}

// static
AnalyserQueue* AnalyserQueue::createPrepareViewAnalyserQueue(
AnalyserQueue* AnalyserQueue::createAnalysisFeatureAnalyserQueue(
ConfigObject<ConfigValue>* _config, TrackCollection* pTrackCollection) {
AnalyserQueue* ret = new AnalyserQueue(pTrackCollection);

Expand Down
2 changes: 1 addition & 1 deletion src/analyserqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnalyserQueue : public QThread {

static AnalyserQueue* createDefaultAnalyserQueue(
ConfigObject<ConfigValue>* _config, TrackCollection* pTrackCollection);
static AnalyserQueue* createPrepareViewAnalyserQueue(
static AnalyserQueue* createAnalysisFeatureAnalyserQueue(
ConfigObject<ConfigValue>* _config, TrackCollection* pTrackCollection);

public slots:
Expand Down
166 changes: 166 additions & 0 deletions src/dlganalysis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
#include <QSqlTableModel>

#include "widget/wwidget.h"
#include "widget/wskincolor.h"
#include "transposeproxymodel.h"
#include "widget/wanalysislibrarytableview.h"
#include "library/trackcollection.h"
#include "dlganalysis.h"


DlgAnalysis::DlgAnalysis(QWidget* parent,
ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection)
: QWidget(parent),
m_pConfig(pConfig),
m_pTrackCollection(pTrackCollection),
m_bAnalysisActive(false),
m_tracksInQueue(0),
m_currentTrack(0) {
setupUi(this);
m_songsButtonGroup.addButton(radioButtonRecentlyAdded);
m_songsButtonGroup.addButton(radioButtonAllSongs);

m_pAnalysisLibraryTableView = new WAnalysisLibraryTableView(this, pConfig, pTrackCollection);
connect(m_pAnalysisLibraryTableView, SIGNAL(loadTrack(TrackPointer)),
this, SIGNAL(loadTrack(TrackPointer)));
connect(m_pAnalysisLibraryTableView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)),
this, SIGNAL(loadTrackToPlayer(TrackPointer, QString)));

QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
box->removeWidget(m_pTrackTablePlaceholder);
m_pTrackTablePlaceholder->hide();
box->insertWidget(1, m_pAnalysisLibraryTableView);

m_pAnalysisLibraryTableModel = new AnalysisLibraryTableModel(this,
pTrackCollection);
m_pAnalysisLibraryTableView->loadTrackModel(m_pAnalysisLibraryTableModel);

connect(radioButtonRecentlyAdded, SIGNAL(clicked()),
this, SLOT(showRecentSongs()));
connect(radioButtonAllSongs, SIGNAL(clicked()),
this, SLOT(showAllSongs()));

radioButtonRecentlyAdded->click();

labelProgress->setText("");
pushButtonAnalyze->setEnabled(false);
connect(pushButtonAnalyze, SIGNAL(clicked()),
this, SLOT(analyze()));

connect(pushButtonSelectAll, SIGNAL(clicked()),
this, SLOT(selectAll()));

connect(m_pAnalysisLibraryTableView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection&)),
this,
SLOT(tableSelectionChanged(const QItemSelection &, const QItemSelection&)));
}

DlgAnalysis::~DlgAnalysis() {
}

void DlgAnalysis::onShow() {
// Refresh table
// There might be new tracks dropped to other views
m_pAnalysisLibraryTableModel->select();
}

void DlgAnalysis::onSearch(const QString& text) {
m_pAnalysisLibraryTableModel->search(text);
}

void DlgAnalysis::loadSelectedTrack() {
m_pAnalysisLibraryTableView->loadSelectedTrack();
}

void DlgAnalysis::loadSelectedTrackToGroup(QString group, bool play) {
m_pAnalysisLibraryTableView->loadSelectedTrackToGroup(group, play);
}

void DlgAnalysis::moveSelection(int delta) {
m_pAnalysisLibraryTableView->moveSelection(delta);
}

void DlgAnalysis::tableSelectionChanged(const QItemSelection& selected,
const QItemSelection& deselected) {
Q_UNUSED(selected);
Q_UNUSED(deselected);
bool tracksSelected = m_pAnalysisLibraryTableView->selectionModel()->hasSelection();
pushButtonAnalyze->setEnabled(tracksSelected || m_bAnalysisActive);
}

void DlgAnalysis::selectAll() {
m_pAnalysisLibraryTableView->selectAll();
}

void DlgAnalysis::analyze() {
//qDebug() << this << "analyze()";
if (m_bAnalysisActive) {
emit(stopAnalysis());
} else {
QList<int> trackIds;

QModelIndexList selectedIndexes = m_pAnalysisLibraryTableView->selectionModel()->selectedRows();
foreach(QModelIndex selectedIndex, selectedIndexes) {
bool ok;
int trackId = selectedIndex.sibling(
selectedIndex.row(),
m_pAnalysisLibraryTableModel->fieldIndex(LIBRARYTABLE_ID)).data().toInt(&ok);
if (ok) {
trackIds.append(trackId);
}
}
m_currentTrack = 1;
emit(analyzeTracks(trackIds));
}
}

void DlgAnalysis::analysisActive(bool bActive) {
qDebug() << this << "analysisActive" << bActive;
m_bAnalysisActive = bActive;
if (bActive) {
pushButtonAnalyze->setEnabled(true);
pushButtonAnalyze->setText(tr("Stop Analysis"));
} else {
pushButtonAnalyze->setText(tr("Analyze"));
labelProgress->setText("");
}
}

// slot
void DlgAnalysis::trackAnalysisFinished(int size) {
qDebug() << "Analysis finished" << size << "tracks left";
if (size > 0) {
m_currentTrack = m_tracksInQueue - size + 1;
}
}

// slot
void DlgAnalysis::trackAnalysisProgress(int progress) {
if (m_bAnalysisActive) {
QString text = tr("Analyzing %1/%2 %3%").arg(
QString::number(m_currentTrack),
QString::number(m_tracksInQueue),
QString::number(progress));
labelProgress->setText(text);
}
}

void DlgAnalysis::trackAnalysisStarted(int size) {
m_tracksInQueue = size;
}

void DlgAnalysis::showRecentSongs() {
m_pAnalysisLibraryTableModel->showRecentSongs();
}

void DlgAnalysis::showAllSongs() {
m_pAnalysisLibraryTableModel->showAllSongs();
}

void DlgAnalysis::installEventFilter(QObject* pFilter) {
QWidget::installEventFilter(pFilter);
m_pAnalysisLibraryTableView->installEventFilter(pFilter);
}
27 changes: 13 additions & 14 deletions src/dlgprepare.h → src/dlganalysis.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
#ifndef DLGTRIAGE_H
#define DLGTRIAGE_H
#ifndef DLGANALYSIS_H
#define DLGANALYSIS_H

#include <QItemSelection>
#include "ui_dlgprepare.h"
#include "ui_dlganalysis.h"
#include "configobject.h"
#include "library/libraryview.h"
#include "library/trackcollection.h"
#include "library/preparelibrarytablemodel.h"
#include "library/analysislibrarytablemodel.h"

class PrepareLibraryTableModel;
class WPrepareCratesTableView;
class WPrepareLibraryTableView;
class AnalysisLibraryTableModel;
class WAnalysisLibraryTableView;

class DlgPrepare : public QWidget, public Ui::DlgPrepare, public virtual LibraryView {
class DlgAnalysis : public QWidget, public Ui::DlgAnalysis, public virtual LibraryView {
Q_OBJECT
public:
DlgPrepare(QWidget *parent,
DlgAnalysis(QWidget *parent,
ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection);
virtual ~DlgPrepare();
virtual ~DlgAnalysis();

virtual void onSearch(const QString& text);
virtual void onShow();
virtual void loadSelectedTrack();
virtual void loadSelectedTrackToGroup(QString group, bool play);
virtual void moveSelection(int delta);
inline const QString currentSearch() { return m_pPrepareLibraryTableModel->currentSearch(); };
inline const QString currentSearch() { return m_pAnalysisLibraryTableModel->currentSearch(); };

public slots:
void tableSelectionChanged(const QItemSelection& selected,
Expand All @@ -34,6 +33,7 @@ class DlgPrepare : public QWidget, public Ui::DlgPrepare, public virtual Library
void analyze();
void trackAnalysisFinished(int size);
void trackAnalysisProgress(int progress);
void trackAnalysisStarted(int size);
void showRecentSongs();
void showAllSongs();
void installEventFilter(QObject* pFilter);
Expand All @@ -51,9 +51,8 @@ class DlgPrepare : public QWidget, public Ui::DlgPrepare, public virtual Library
TrackCollection* m_pTrackCollection;
bool m_bAnalysisActive;
QButtonGroup m_songsButtonGroup;
WPrepareLibraryTableView* m_pPrepareLibraryTableView;
PrepareLibraryTableModel* m_pPrepareLibraryTableModel;
WPrepareCratesTableView* m_pPrepareCratesTableView;
WAnalysisLibraryTableView* m_pAnalysisLibraryTableView;
AnalysisLibraryTableModel* m_pAnalysisLibraryTableModel;
int m_tracksInQueue;
int m_currentTrack;
};
Expand Down
4 changes: 2 additions & 2 deletions src/dlgprepare.ui → src/dlganalysis.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgPrepare</class>
<widget class="QWidget" name="DlgPrepare">
<class>DlgAnalysis</class>
<widget class="QWidget" name="DlgAnalysis">
<property name="geometry">
<rect>
<x>0</x>
Expand Down
Loading