@@ -32,7 +32,8 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
3232 m_pLibraryTableModel(nullptr ),
3333 m_pSidebarModel(make_parented<TreeItemModel>(this )),
3434 m_pMissingView(nullptr ),
35- m_pHiddenView(nullptr ) {
35+ m_pHiddenView(nullptr ),
36+ m_trackCount{0 } {
3637 QString idColumn = LIBRARYTABLE_ID ;
3738 QStringList columns = {
3839 LIBRARYTABLE_ID ,
@@ -114,6 +115,11 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
114115 pLibrary->trackCollectionManager (),
115116 " mixxx.db.model.library" );
116117
118+ connect (m_pLibraryTableModel,
119+ &LibraryTableModel::updateTrackCount,
120+ this ,
121+ &MixxxLibraryFeature::slotUpdateTrackCount);
122+
117123 std::unique_ptr<TreeItem> pRootItem = TreeItem::newRoot (this );
118124 pRootItem->appendChild (kMissingTitle );
119125 pRootItem->appendChild (kHiddenTitle );
@@ -149,7 +155,8 @@ void MixxxLibraryFeature::bindLibraryWidget(WLibrary* pLibraryWidget,
149155}
150156
151157QVariant MixxxLibraryFeature::title () {
152- return tr (" Tracks" );
158+ const QString title = tr (" Tracks" ) + QStringLiteral (" (%1)" ).arg (m_trackCount);
159+ return title;
153160}
154161
155162TreeItemModel* MixxxLibraryFeature::sidebarModel () const {
@@ -183,6 +190,14 @@ void MixxxLibraryFeature::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) {
183190}
184191#endif
185192
193+ void MixxxLibraryFeature::slotUpdateTrackCount () {
194+ m_trackCount = m_pLibraryTableModel->rowCount ();
195+
196+ // Force updating the Tracks sidebar item.
197+ // `select` must be false as we don't want to select again
198+ emit featureIsLoading (this , false );
199+ }
200+
186201void MixxxLibraryFeature::activate () {
187202 // qDebug() << "MixxxLibraryFeature::activate()";
188203 emit saveModelState ();
0 commit comments