From 7d2e0fce392413c7a4f4292ccc0dd5e5f45f496f Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 8 Dec 2016 22:26:50 +0100 Subject: Improve and simplify the design/interface of TreeItem --- src/library/banshee/bansheefeature.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/library/banshee') diff --git a/src/library/banshee/bansheefeature.cpp b/src/library/banshee/bansheefeature.cpp index 05ee9c67a3..884c79947c 100644 --- a/src/library/banshee/bansheefeature.cpp +++ b/src/library/banshee/bansheefeature.cpp @@ -91,7 +91,7 @@ void BansheeFeature::activate() { m_isActivated = true; - TreeItem* playlist_root = new TreeItem(); + TreeItem* playlist_root = new TreeItem(this); QList list = m_connection.getPlaylists(); @@ -99,8 +99,8 @@ void BansheeFeature::activate() { foreach (playlist, list) { qDebug() << playlist.name; // append the playlist to the child model - TreeItem *item = new TreeItem(playlist.name, playlist.playlistId, this, playlist_root); - playlist_root->appendChild(item); + playlist_root->appendChild( + new TreeItem(this, playlist.name, playlist.playlistId)); } if (playlist_root) { @@ -123,11 +123,9 @@ void BansheeFeature::activate() { void BansheeFeature::activateChild(const QModelIndex& index) { TreeItem *item = static_cast(index.internalPointer()); - //qDebug() << "BansheeFeature::activateChild " << item->data() << " " << item->dataPath(); - QString playlist = item->dataPath().toString(); - int playlistID = playlist.toInt(); + int playlistID = item->getData().toInt(); if (playlistID > 0) { - qDebug() << "Activating " << item->data().toString(); + qDebug() << "Activating " << item->getLabel(); m_pBansheePlaylistModel->setTableModel(playlistID); emit(showTrackModel(m_pBansheePlaylistModel)); emit(enableCoverArtDisplay(false)); @@ -141,10 +139,9 @@ TreeItemModel* BansheeFeature::getChildModel() { void BansheeFeature::appendTrackIdsFromRightClickIndex(QList* trackIds, QString* pPlaylist) { if (m_lastRightClickedIndex.isValid()) { TreeItem *item = static_cast(m_lastRightClickedIndex.internalPointer()); - *pPlaylist = item->data().toString(); - QString playlistStId = item->dataPath().toString(); - int playlistID = playlistStId.toInt(); - qDebug() << "BansheeFeature::appendTrackIdsFromRightClickIndex " << *pPlaylist << " " << playlistStId; + *pPlaylist = item->getLabel(); + int playlistID = item->getData().toInt(); + qDebug() << "BansheeFeature::appendTrackIdsFromRightClickIndex " << *pPlaylist << " " << playlistID; if (playlistID > 0) { BansheePlaylistModel* pPlaylistModelToAdd = new BansheePlaylistModel(this, m_pTrackCollection, &m_connection); pPlaylistModelToAdd->setTableModel(playlistID); -- cgit v1.2.3