@@ -32,7 +32,9 @@ 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_pTracksTreeItem(nullptr ),
37+ m_trackCount{0 } {
3638 QString idColumn = LIBRARYTABLE_ID ;
3739 QStringList columns = {
3840 LIBRARYTABLE_ID ,
@@ -114,7 +116,13 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
114116 pLibrary->trackCollectionManager (),
115117 " mixxx.db.model.library" );
116118
119+ connect (m_pLibraryTableModel,
120+ &LibraryTableModel::updateTrackCount,
121+ this ,
122+ &MixxxLibraryFeature::slotUpdateTrackCount);
123+
117124 std::unique_ptr<TreeItem> pRootItem = TreeItem::newRoot (this );
125+ m_pTracksTreeItem = pRootItem.get ();
118126 pRootItem->appendChild (kMissingTitle );
119127 pRootItem->appendChild (kHiddenTitle );
120128
@@ -149,7 +157,8 @@ void MixxxLibraryFeature::bindLibraryWidget(WLibrary* pLibraryWidget,
149157}
150158
151159QVariant MixxxLibraryFeature::title () {
152- return tr (" Tracks" );
160+ const QString title = tr (" Tracks" ) + QStringLiteral (" (%1)" ).arg (m_trackCount);
161+ return title;
153162}
154163
155164TreeItemModel* MixxxLibraryFeature::sidebarModel () const {
@@ -183,6 +192,17 @@ void MixxxLibraryFeature::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) {
183192}
184193#endif
185194
195+ void MixxxLibraryFeature::slotUpdateTrackCount () {
196+ m_trackCount = m_pLibraryTableModel->rowCount ();
197+
198+ if (m_pTracksTreeItem && m_pSidebarModel) {
199+ QModelIndex rootIndex = m_pSidebarModel->getRootIndex ();
200+ QModelIndex tracksIndex = m_pSidebarModel->index (
201+ m_pTracksTreeItem->parentRow (), 0 , rootIndex);
202+ m_pSidebarModel->triggerRepaint (tracksIndex);
203+ }
204+ }
205+
186206void MixxxLibraryFeature::activate () {
187207 // qDebug() << "MixxxLibraryFeature::activate()";
188208 emit saveModelState ();
0 commit comments