Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/library/librarytablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@ TrackModel::Capabilities LibraryTableModel::getCapabilities() const {
Capability::Properties |
Capability::Sorting;
}

void LibraryTableModel::select() {
BaseSqlTableModel::select();
emit updateTrackCount();
}
5 changes: 5 additions & 0 deletions src/library/librarytablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ class LibraryTableModel : public BaseSqlTableModel {
// number of successful additions.
int addTracks(const QModelIndex& index, const QList<QString>& locations) final;
TrackModel::Capabilities getCapabilities() const final;

void select() override;

signals:
void updateTrackCount();
};
19 changes: 17 additions & 2 deletions src/library/mixxxlibraryfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
m_pLibraryTableModel(nullptr),
m_pSidebarModel(make_parented<TreeItemModel>(this)),
m_pMissingView(nullptr),
m_pHiddenView(nullptr) {
m_pHiddenView(nullptr),
m_trackCount{0} {
QString idColumn = LIBRARYTABLE_ID;
QStringList columns = {
LIBRARYTABLE_ID,
Expand Down Expand Up @@ -114,6 +115,11 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
pLibrary->trackCollectionManager(),
"mixxx.db.model.library");

connect(m_pLibraryTableModel,
&LibraryTableModel::updateTrackCount,
this,
&MixxxLibraryFeature::slotUpdateTrackCount);

std::unique_ptr<TreeItem> pRootItem = TreeItem::newRoot(this);
pRootItem->appendChild(kMissingTitle);
pRootItem->appendChild(kHiddenTitle);
Expand Down Expand Up @@ -149,7 +155,8 @@ void MixxxLibraryFeature::bindLibraryWidget(WLibrary* pLibraryWidget,
}

QVariant MixxxLibraryFeature::title() {
return tr("Tracks");
const QString title = tr("Tracks") + QStringLiteral(" (%1)").arg(m_trackCount);
return title;
}

TreeItemModel* MixxxLibraryFeature::sidebarModel() const {
Expand Down Expand Up @@ -183,6 +190,14 @@ void MixxxLibraryFeature::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) {
}
#endif

void MixxxLibraryFeature::slotUpdateTrackCount() {
m_trackCount = m_pLibraryTableModel->rowCount();

// Force updating the Tracks sidebar item.
// `select` must be false as we don't want to select again
emit featureIsLoading(this, false);
}

void MixxxLibraryFeature::activate() {
//qDebug() << "MixxxLibraryFeature::activate()";
emit saveModelState();
Expand Down
3 changes: 3 additions & 0 deletions src/library/mixxxlibraryfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class MixxxLibraryFeature final : public LibraryFeature {
public slots:
void activate() override;
void activateChild(const QModelIndex& index) override;
void slotUpdateTrackCount();
#ifdef __ENGINEPRIME__
void onRightClick(const QPoint& globalPos) override;
#endif
Expand All @@ -74,6 +75,8 @@ class MixxxLibraryFeature final : public LibraryFeature {
DlgMissing* m_pMissingView;
DlgHidden* m_pHiddenView;

int m_trackCount;

#ifdef __ENGINEPRIME__
parented_ptr<QAction> m_pExportLibraryAction;

Expand Down