summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uwe_klotz@web.de>2016-12-08 22:26:50 +0100
committerUwe Klotz <uwe_klotz@web.de>2016-12-09 23:45:42 +0100
commit7d2e0fce392413c7a4f4292ccc0dd5e5f45f496f (patch)
tree353080c6a7e3ab2b8bba9ff2d8c2b48a18a41c27 /src
parente49571835af3278537630b1d09af94cb54c38e26 (diff)
Improve and simplify the design/interface of TreeItem
Diffstat (limited to 'src')
-rw-r--r--src/library/autodj/autodjfeature.cpp18
-rw-r--r--src/library/banshee/bansheefeature.cpp19
-rw-r--r--src/library/baseexternallibraryfeature.cpp4
-rw-r--r--src/library/baseplaylistfeature.cpp17
-rw-r--r--src/library/browse/browsefeature.cpp79
-rw-r--r--src/library/browse/foldertreemodel.cpp10
-rw-r--r--src/library/cratefeature.cpp12
-rw-r--r--src/library/itunes/itunesfeature.cpp6
-rw-r--r--src/library/mixxxlibraryfeature.cpp10
-rw-r--r--src/library/playlistfeature.cpp2
-rw-r--r--src/library/rhythmbox/rhythmboxfeature.cpp5
-rw-r--r--src/library/setlogfeature.cpp11
-rw-r--r--src/library/sidebarmodel.cpp38
-rw-r--r--src/library/traktor/traktorfeature.cpp19
-rw-r--r--src/library/treeitem.cpp160
-rw-r--r--src/library/treeitem.h136
-rw-r--r--src/library/treeitemmodel.cpp39
-rw-r--r--src/library/treeitemmodel.h2
18 files changed, 287 insertions, 300 deletions
diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp
index 78ce04f40a..f21d4d6210 100644
--- a/src/library/autodj/autodjfeature.cpp
+++ b/src/library/autodj/autodjfeature.cpp
@@ -56,14 +56,15 @@ AutoDJFeature::AutoDJFeature(Library* pLibrary,
// Create the "Crates" tree-item under the root item.
- TreeItem* root = m_childModel.getItem(QModelIndex());
- m_pCratesTreeItem = new TreeItem(tr("Crates"), "", this, root);
+ TreeItem* root = new TreeItem(this);
+ m_pCratesTreeItem = root->appendChild(new TreeItem(this, tr("Crates")));
m_pCratesTreeItem->setIcon(QIcon(":/images/library/ic_library_crates.png"));
- root->appendChild(m_pCratesTreeItem);
// Create tree-items under "Crates".
constructCrateChildModel();
+ m_childModel.setRootItem(root);
+
// Be notified when the status of crates changes.
connect(&m_crateDao, SIGNAL(added(int)),
this, SLOT(slotCrateAdded(int)));
@@ -222,13 +223,9 @@ void AutoDJFeature::slotCrateAutoDjChanged(int crateId, bool added) {
// Add our record of this crate-ID and name.
m_crateList.append(qMakePair(crateId, strName));
- // Create a tree-item for this crate.
- TreeItem* item = new TreeItem(strName, strName, this,
- m_pCratesTreeItem);
-
// Prepare to add it to the "Crates" tree-item.
QList<TreeItem*> lstItems;
- lstItems.append(item);
+ lstItems.append(new TreeItem(this, strName));
// Add it to the "Crates" tree-item.
QModelIndex oCratesIndex = m_childModel.index(0, 0);
@@ -326,8 +323,7 @@ void AutoDJFeature::constructCrateChildModel() {
m_crateList.append(qMakePair(id, name));
// Create the TreeItem for this crate.
- TreeItem* item = new TreeItem(name, name, this, m_pCratesTreeItem);
- m_pCratesTreeItem->appendChild(item);
+ m_pCratesTreeItem->appendChild(new TreeItem(this, name));
}
}
@@ -337,7 +333,7 @@ void AutoDJFeature::onRightClickChild(const QPoint& globalPos,
m_lastRightClickedIndex = index;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
- QString crateName = item->dataPath().toString();
+ QString crateName = item->getLabel();
if (crateName.length() > 0) {
// A crate was right-clicked.
// Bring up the context menu.
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<struct BansheeDbConnection::Playlist> 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<TreeItem*>(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<TrackId>* trackIds, QString* pPlaylist) {
if (m_lastRightClickedIndex.isValid()) {
TreeItem *item = static_cast<TreeItem*>(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);
diff --git a/src/library/baseexternallibraryfeature.cpp b/src/library/baseexternallibraryfeature.cpp
index 27d69ee48e..87807a62e7 100644
--- a/src/library/baseexternallibraryfeature.cpp
+++ b/src/library/baseexternallibraryfeature.cpp
@@ -101,8 +101,8 @@ void BaseExternalLibraryFeature::appendTrackIdsFromRightClickIndex(QList<TrackId
return;
}
- // Qt::UserRole asks TreeItemModel for the TreeItem's dataPath. We need to
- // use the dataPath because models with nested playlists need to use the
+ // Qt::UserRole asks TreeItemModel for the TreeItem's data. We need to
+ // use the data because models with nested playlists need to use the
// full path/name of the playlist.
*pPlaylist = m_lastRightClickedIndex.data(Qt::UserRole).toString();
QScopedPointer<BaseSqlTableModel> pPlaylistModelToAdd(
diff --git a/src/library/baseplaylistfeature.cpp b/src/library/baseplaylistfeature.cpp
index 12d30d8f44..03994d3678 100644
--- a/src/library/baseplaylistfeature.cpp
+++ b/src/library/baseplaylistfeature.cpp
@@ -117,17 +117,17 @@ BasePlaylistFeature::~BasePlaylistFeature() {
int BasePlaylistFeature::playlistIdFromIndex(QModelIndex index) {
TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
- if (item == NULL) {
+ if (item == nullptr) {
return -1;
}
- QString dataPath = item->dataPath().toString();
bool ok = false;
- int playlistId = dataPath.toInt(&ok);
- if (!ok) {
+ int playlistId = item->getData().toInt(&ok);
+ if (ok) {
+ return playlistId;
+ } else {
return -1;
}
- return playlistId;
}
void BasePlaylistFeature::activate() {
@@ -621,8 +621,6 @@ QModelIndex BasePlaylistFeature::constructChildModel(int selected_id) {
buildPlaylistList();
QList<TreeItem*> data_list;
int selected_row = -1;
- // Access the invisible root item
- TreeItem* root = m_childModel.getItem(QModelIndex());
int row = 0;
for (QList<QPair<int, QString> >::const_iterator it = m_playlistList.begin();
@@ -637,7 +635,7 @@ QModelIndex BasePlaylistFeature::constructChildModel(int selected_id) {
}
// Create the TreeItem whose parent is the invisible root item
- TreeItem* item = new TreeItem(playlist_name, QString::number(playlist_id), this, root);
+ TreeItem* item = new TreeItem(this, playlist_name, playlist_id);
item->setBold(m_playlistsSelectedTrackIsIn.contains(playlist_id));
decorateChild(item, playlist_id);
@@ -663,7 +661,8 @@ void BasePlaylistFeature::updateChildModel(int selected_id) {
if (selected_id == playlist_id) {
TreeItem* item = m_childModel.getItem(indexFromPlaylistId(playlist_id));
- item->setData(playlist_name, QString::number(playlist_id));
+ item->setLabel(playlist_name);
+ item->setData(playlist_id);
decorateChild(item, playlist_id);
}
diff --git a/src/library/browse/browsefeature.cpp b/src/library/browse/browsefeature.cpp
index 9f6231b78c..617ecc4312 100644
--- a/src/library/browse/browsefeature.cpp
+++ b/src/library/browse/browsefeature.cpp
@@ -54,16 +54,15 @@ BrowseFeature::BrowseFeature(QObject* parent,
m_proxyModel.setDynamicSortFilter(true);
// The invisible root item of the child model
- TreeItem* rootItem = new TreeItem();
+ TreeItem* rootItem = new TreeItem(this);
- m_pQuickLinkItem = new TreeItem(tr("Quick Links"), QUICK_LINK_NODE, this, rootItem);
- rootItem->appendChild(m_pQuickLinkItem);
+ m_pQuickLinkItem = rootItem->appendChild(
+ new TreeItem(this, tr("Quick Links"), QUICK_LINK_NODE));
// Create the 'devices' shortcut
#if defined(__WINDOWS__)
- TreeItem* devices_link = new TreeItem(
- tr("Devices"), DEVICE_NODE, this, rootItem);
- rootItem->appendChild(devices_link);
+ TreeItem* devices_link = rootItem->appendChild(
+ new TreeItem(this, tr("Devices"), DEVICE_NODE));
// show drive letters
QFileInfoList drives = QDir::drives();
// show drive letters
@@ -81,28 +80,25 @@ BrowseFeature::BrowseFeature(QObject* parent,
if (display_path.endsWith("/")) {
display_path.chop(1);
}
- TreeItem* driveLetter = new TreeItem(
- display_path, // Displays C:
- drive.filePath(), // Displays C:/
- this ,
- devices_link);
- devices_link->appendChild(driveLetter);
+ TreeItem* driveLetter =
+ devices_link->appendChild(
+ new TreeItem(
+ this ,
+ display_path, // Displays C:
+ drive.filePath())); // Displays C:/
}
#elif defined(__APPLE__)
// Apple hides the base Linux file structure But all devices are mounted at
// /Volumes
- TreeItem* devices_link = new TreeItem(
- tr("Devices"), "/Volumes/", this, rootItem);
- rootItem->appendChild(devices_link);
+ TreeItem* devices_link = rootItem->appendChild(
+ new TreeItem(this, tr("Devices"), "/Volumes/"));
#else // LINUX
- TreeItem* devices_link = new TreeItem(
- tr("Removable Devices"), "/media/", this, rootItem);
- rootItem->appendChild(devices_link);
+ TreeItem* devices_link = rootItem->appendChild(
+ new TreeItem(this, tr("Removable Devices"), "/media/"));
// show root directory on UNIX-based operating systems
- TreeItem* root_folder_item = new TreeItem(
- QDir::rootPath(), QDir::rootPath(), this, rootItem);
- rootItem->appendChild(root_folder_item);
+ TreeItem* root_folder_item = rootItem->appendChild(
+ new TreeItem(this, QDir::rootPath(), QDir::rootPath()));
#endif
// Just a word about how the TreeItem objects are used for the BrowseFeature:
@@ -122,8 +118,8 @@ BrowseFeature::BrowseFeature(QObject* parent,
foreach (QString quickLinkPath, m_quickLinkList) {
QString name = extractNameFromPath(quickLinkPath);
qDebug() << "Appending Quick Link: " << name << "---" << quickLinkPath;
- TreeItem *item = new TreeItem(name, quickLinkPath, this, m_pQuickLinkItem);
- m_pQuickLinkItem->appendChild(item);
+ m_pQuickLinkItem->appendChild(
+ new TreeItem(this, name, quickLinkPath));
}
// initialize the model
@@ -142,10 +138,10 @@ void BrowseFeature::slotAddQuickLink() {
return;
}
- QString spath = m_pLastRightClickedItem->dataPath().toString();
+ QVariant vpath = m_pLastRightClickedItem->getData();
+ QString spath = vpath.toString();
QString name = extractNameFromPath(spath);
- TreeItem *item = new TreeItem(name, spath, this, m_pQuickLinkItem);
- m_pQuickLinkItem->appendChild(item);
+ m_pQuickLinkItem->appendChild(new TreeItem(this, name, vpath));
m_quickLinkList.append(spath);
saveQuickLinks();
}
@@ -154,7 +150,7 @@ void BrowseFeature::slotAddToLibrary() {
if (!m_pLastRightClickedItem) {
return;
}
- QString spath = m_pLastRightClickedItem->dataPath().toString();
+ QString spath = m_pLastRightClickedItem->getData().toString();
emit(requestAddDir(spath));
QMessageBox msgBox;
@@ -188,7 +184,7 @@ void BrowseFeature::slotRemoveQuickLink() {
return;
}
- QString spath = m_pLastRightClickedItem->dataPath().toString();
+ QString spath = m_pLastRightClickedItem->getData().toString();
int index = m_quickLinkList.indexOf(spath);
if (index == -1) {
@@ -225,10 +221,10 @@ void BrowseFeature::activate() {
// Single clicks will not populate sub folders
void BrowseFeature::activateChild(const QModelIndex& index) {
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
- qDebug() << "BrowseFeature::activateChild " << item->data() << " "
- << item->dataPath();
+ qDebug() << "BrowseFeature::activateChild " << item->getLabel() << " "
+ << item->getData();
- QString path = item->dataPath().toString();
+ QString path = item->getData().toString();
if (path == QUICK_LINK_NODE || path == DEVICE_NODE) {
m_browseModel.setPath(MDir());
} else {
@@ -258,14 +254,14 @@ void BrowseFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index
return;
}
- QString path = item->dataPath().toString();
+ QString path = item->getData().toString();
if (path == QUICK_LINK_NODE || path == DEVICE_NODE) {
return;
}
QMenu menu(NULL);
- if (item->parent()->dataPath().toString() == QUICK_LINK_NODE) {
+ if (item->parent()->getData().toString() == QUICK_LINK_NODE) {
menu.addAction(m_pRemoveQuickLinkAction);
menu.exec(globalPos);
onLazyChildExpandation(index);
@@ -292,10 +288,10 @@ void BrowseFeature::onLazyChildExpandation(const QModelIndex& index) {
return;
}
- qDebug() << "BrowseFeature::onLazyChildExpandation " << item->data()
- << " " << item->dataPath();
+ qDebug() << "BrowseFeature::onLazyChildExpandation " << item->getLabel()
+ << " " << item->getData();
- QString path = item->dataPath().toString();
+ QString path = item->getData().toString();
// If the item is a build-in node, e.g., 'QuickLink' return
if (path == QUICK_LINK_NODE) {
@@ -303,7 +299,7 @@ void BrowseFeature::onLazyChildExpandation(const QModelIndex& index) {
}
// Before we populate the subtree, we need to delete old subtrees
- m_childModel.removeRows(0, item->childCount(), index);
+ m_childModel.removeRows(0, item->childRows(), index);
// List of subfolders or drive letters
QList<TreeItem*> folders;
@@ -327,10 +323,9 @@ void BrowseFeature::onLazyChildExpandation(const QModelIndex& index) {
display_path.chop(1);
}
TreeItem* driveLetter = new TreeItem(
- display_path, // Displays C:
- drive.filePath(), // Displays C:/
this,
- item);
+ display_path, // Displays C:
+ drive.filePath()); // Displays C:/
folders << driveLetter;
}
} else {
@@ -352,9 +347,9 @@ void BrowseFeature::onLazyChildExpandation(const QModelIndex& index) {
// Once the items are added to the TreeItemModel,
// the models takes ownership of them and ensures their deletion
TreeItem* folder = new TreeItem(
+ this,
one.fileName(),
- one.absoluteFilePath() + "/",
- this, item);
+ one.absoluteFilePath() + "/");
folders << folder;
}
}
diff --git a/src/library/browse/foldertreemodel.cpp b/src/library/browse/foldertreemodel.cpp
index 62b28afc41..3c51828f15 100644
--- a/src/library/browse/foldertreemodel.cpp
+++ b/src/library/browse/foldertreemodel.cpp
@@ -38,14 +38,14 @@ bool FolderTreeModel::hasChildren(const QModelIndex& parent) const {
* However, for, buid-in items such as 'Quick Links' there exist
* child items at init time
*/
- if(item->dataPath().toString() == QUICK_LINK_NODE)
+ if(item->getData().toString() == QUICK_LINK_NODE)
return true;
//Can only happen on Windows
- if(item->dataPath().toString() == DEVICE_NODE)
+ if(item->getData().toString() == DEVICE_NODE)
return true;
- // In all other cases the dataPath() points to a folder
- QString folder = item->dataPath().toString();
+ // In all other cases the getData() points to a folder
+ QString folder = item->getData().toString();
return directoryHasChildren(folder);
}
@@ -63,7 +63,7 @@ bool FolderTreeModel::directoryHasChildren(const QString& path) const {
* QDIR::EntryInfoList returns a full QFileInfolist
*
*
- * QDir dir(item->dataPath().toString());
+ * QDir dir(item->getData().toString());
* QFileInfoList all = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
* return (all.count() > 0);
*
diff --git a/src/library/cratefeature.cpp b/src/library/cratefeature.cpp
index dd884c6ea5..d82043ceb0 100644
--- a/src/library/cratefeature.cpp
+++ b/src/library/cratefeature.cpp
@@ -94,7 +94,7 @@ CrateFeature::CrateFeature(Library* pLibrary,
this, SLOT(slotCrateTableChanged(int)));
// construct child model
- TreeItem *rootItem = new TreeItem();
+ TreeItem *rootItem = new TreeItem(this);
m_childModel.setRootItem(rootItem);
constructChildModel(-1);
@@ -131,9 +131,8 @@ int CrateFeature::crateIdFromIndex(QModelIndex index) {
return -1;
}
- QString dataPath = item->dataPath().toString();
bool ok = false;
- int playlistId = dataPath.toInt(&ok);
+ int playlistId = item->getData().toInt(&ok);
if (!ok) {
return -1;
}
@@ -512,8 +511,6 @@ QModelIndex CrateFeature::constructChildModel(int selected_id) {
buildCrateList();
QList<TreeItem*> data_list;
int selected_row = -1;
- // Access the invisible root item
- TreeItem* root = m_childModel.getItem(QModelIndex());
int row = 0;
for (QList<QPair<int, QString> >::const_iterator it = m_crateList.begin();
@@ -528,8 +525,8 @@ QModelIndex CrateFeature::constructChildModel(int selected_id) {
}
// Create the TreeItem whose parent is the invisible root item
- TreeItem* item = new TreeItem(crate_name, QString::number(crate_id), this, root);
bool locked = m_crateDao.isCrateLocked(crate_id);
+ TreeItem* item = new TreeItem(this, crate_name, crate_id);
item->setIcon(locked ? QIcon(":/images/library/ic_library_locked.png") : QIcon());
item->setBold(m_cratesSelectedTrackIsIn.contains(crate_id));
data_list.append(item);
@@ -554,7 +551,8 @@ void CrateFeature::updateChildModel(int selected_id) {
if (selected_id == crate_id) {
TreeItem* item = m_childModel.getItem(indexFromCrateId(crate_id));
- item->setData(crate_name, QString::number(crate_id));
+ item->setLabel(crate_name);
+ item->setData(crate_id);
bool locked = m_crateDao.isCrateLocked(crate_id);
item->setIcon(locked ? QIcon(":/images/library/ic_library_locked.png") : QIcon());
diff --git a/src/library/itunes/itunesfeature.cpp b/src/library/itunes/itunesfeature.cpp
index 24a4655a31..254a8e50f3 100644
--- a/src/library/itunes/itunesfeature.cpp
+++ b/src/library/itunes/itunesfeature.cpp
@@ -587,7 +587,7 @@ void ITunesFeature::parseTrack(QXmlStreamReader &xml, QSqlQuery &query) {
TreeItem* ITunesFeature::parsePlaylists(QXmlStreamReader &xml) {
qDebug() << "Parse iTunes playlists";
- TreeItem* rootItem = new TreeItem();
+ TreeItem* rootItem = new TreeItem(this);
QSqlQuery query_insert_to_playlists(m_database);
query_insert_to_playlists.prepare("INSERT INTO itunes_playlists (id, name) "
"VALUES (:id, :name)");
@@ -684,9 +684,7 @@ void ITunesFeature::parsePlaylist(QXmlStreamReader &xml, QSqlQuery &query_insert
return;
}
//append the playlist to the child model
- TreeItem *item = new TreeItem(playlistname, playlistname, this, root);
- root->appendChild(item);
-
+ root->appendChild(new TreeItem(this, playlistname));
}
// When processing playlist entries, playlist name and id have
// already been processed and persisted
diff --git a/src/library/mixxxlibraryfeature.cpp b/src/library/mixxxlibraryfeature.cpp
index 60271e3a38..b83c3f8a18 100644
--- a/src/library/mixxxlibraryfeature.cpp
+++ b/src/library/mixxxlibraryfeature.cpp
@@ -108,13 +108,9 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
// These rely on the 'default' track source being present.
m_pLibraryTableModel = new LibraryTableModel(this, pTrackCollection, "mixxx.db.model.library");
- TreeItem* pRootItem = new TreeItem();
- TreeItem* pmissingChildItem = new TreeItem(kMissingTitle, kMissingTitle,
- this, pRootItem);
- TreeItem* phiddenChildItem = new TreeItem(kHiddenTitle, kHiddenTitle,
- this, pRootItem);
- pRootItem->appendChild(pmissingChildItem);
- pRootItem->appendChild(phiddenChildItem);
+ TreeItem* pRootItem = new TreeItem(this);
+ pRootItem->appendChild(new TreeItem(this, kMissingTitle));
+ pRootItem->appendChild(new TreeItem(this, kHiddenTitle));
m_childModel.setRootItem(pRootItem);
}
diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp
index 9f7f81fc1a..8cb747b0e2 100644
--- a/src/library/playlistfeature.cpp
+++ b/src/library/playlistfeature.cpp
@@ -27,7 +27,7 @@ PlaylistFeature::PlaylistFeature(QObject* parent,
"mixxx.db.model.playlist");
//construct child model
- TreeItem *rootItem = new TreeItem();
+ TreeItem *rootItem = new TreeItem(this);
m_childModel.setRootItem(rootItem);
constructChildModel(-1);
}
diff --git a/src/library/rhythmbox/rhythmboxfeature.cpp b/src/library/rhythmbox/rhythmboxfeature.cpp
index 9d9f7d331d..0998b1e2c8 100644
--- a/src/library/rhythmbox/rhythmboxfeature.cpp
+++ b/src/library/rhythmbox/rhythmboxfeature.cpp
@@ -220,7 +220,7 @@ TreeItem* RhythmboxFeature::importPlaylists() {
"INSERT INTO rhythmbox_playlist_tracks (playlist_id, track_id, position) "
"VALUES (:playlist_id, :track_id, :position)");
//The tree structure holding the playlists
- TreeItem* rootItem = new TreeItem();
+ TreeItem* rootItem = new TreeItem(this);
QXmlStreamReader xml(&db);
while (!xml.atEnd() && !m_cancelImport) {
@@ -233,8 +233,7 @@ TreeItem* RhythmboxFeature::importPlaylists() {
QString playlist_name = attr.value("name").toString();
//Construct the childmodel
- TreeItem * item = new TreeItem(playlist_name, playlist_name, this, rootItem);
- rootItem->appendChild(item);
+ rootItem->appendChild(new TreeItem(this, playlist_name));
//Execute SQL statement
query_insert_to_playlists.bindValue(":name", playlist_name);
diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp
index 01e2ba7919..38ab9ae478 100644
--- a/src/library/setlogfeature.cpp
+++ b/src/library/setlogfeature.cpp
@@ -19,6 +19,12 @@ SetlogFeature::SetlogFeature(QObject* parent,
m_pPlaylistTableModel = new PlaylistTableModel(this, pTrackCollection,
"mixxx.db.model.setlog",
true); //show all tracks
+
+ //construct child model
+ TreeItem *rootItem = new TreeItem(this);
+ m_childModel.setRootItem(rootItem);
+ constructChildModel(-1);
+
m_pJoinWithPreviousAction = new QAction(tr("Join with previous"), this);
connect(m_pJoinWithPreviousAction, SIGNAL(triggered()),
this, SLOT(slotJoinWithPrevious()));
@@ -28,11 +34,6 @@ SetlogFeature::SetlogFeature(QObject* parent,
// initialized in a new generic slot(get new history playlist purpose)
emit(slotGetNewPlaylist());
-
- //construct child model
- TreeItem *rootItem = new TreeItem();
- m_childModel.setRootItem(rootItem);
- constructChildModel(-1);
}
SetlogFeature::~SetlogFeature() {
diff --git a/src/library/sidebarmodel.cpp b/src/library/sidebarmodel.cpp
index a87aaa44c6..cc86a1bd77 100644
--- a/src/library/sidebarmodel.cpp
+++ b/src/library/sidebarmodel.cpp
@@ -66,7 +66,7 @@ void SidebarModel::activateDefaultSelection() {
QModelIndex SidebarModel::index(int row, int column,
const QModelIndex& parent) const {
// qDebug() << "SidebarModel::index row=" << row
- // << "column=" << column << "parent=" << parent.data();
+ // << "column=" << column << "parent=" << parent.getData();
if (parent.isValid()) {
/* If we have selected the root of a library feature at position 'row'
* its internal pointer is the current sidebar object model
@@ -92,7 +92,7 @@ QModelIndex SidebarModel::index(int row, int column,
}
QModelIndex SidebarModel::parent(const QModelIndex& index) const {
- //qDebug() << "SidebarModel::parent index=" << index.data();
+ //qDebug() << "SidebarModel::parent index=" << index.getData();
if (index.isValid()) {
// If we have selected the root of a library feature
// its internal pointer is the current sidebar object model
@@ -108,8 +108,8 @@ QModelIndex SidebarModel::parent(const QModelIndex& index) const {
// if we have selected an item at the first level of a childnode
if (tree_item_parent) {
- if (tree_item_parent->data() == "$root") {
- LibraryFeature* feature = tree_item->getFeature();
+ if (tree_item_parent->isRoot()) {
+ LibraryFeature* feature = tree_item->feature();
for (int i = 0; i < m_sFeatures.size(); ++i) {
if (feature == m_sFeatures[i]) {
// create a ModelIndex for parent 'this' having a
@@ -119,7 +119,7 @@ QModelIndex SidebarModel::parent(const QModelIndex& index) const {
}
}
// if we have selected an item at some deeper level of a childnode
- return createIndex(tree_item_parent->row(), 0 , tree_item_parent);
+ return createIndex(tree_item_parent->parentRow(), 0 , tree_item_parent);
}
}
}
@@ -127,7 +127,7 @@ QModelIndex SidebarModel::parent(const QModelIndex& index) const {
}
int SidebarModel::rowCount(const QModelIndex& parent) const {
- //qDebug() << "SidebarModel::rowCount parent=" << parent.data();
+ //qDebug() << "SidebarModel::rowCount parent=" << parent.getData();
if (parent.isValid()) {
if (parent.internalPointer() == this) {
return m_sFeatures[parent.row()]->getChildModel()->rowCount();
@@ -135,7 +135,7 @@ int SidebarModel::rowCount(const QModelIndex& parent) const {
// We support tree models deeper than 1 level
TreeItem* tree_item = (TreeItem*)parent.internalPointer();
if (tree_item) {
- return tree_item->childCount();
+ return tree_item->childRows();
}
return 0;
}
@@ -159,7 +159,7 @@ bool SidebarModel::hasChildren(const QModelIndex& parent) const {
{
TreeItem* tree_item = (TreeItem*)parent.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
return feature->getChildModel()->hasChildren(parent);
}
}
@@ -189,17 +189,17 @@ QVariant SidebarModel::data(const QModelIndex& index, int role) const {
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
if (role == Qt::DisplayRole) {
- return tree_item->data();
+ return tree_item->getLabel();
} else if (role == Qt::ToolTipRole) {
// If it's the "Quick Links" node, display it's name
- if (tree_item->dataPath() == QUICK_LINK_NODE) {
- return tree_item->data();
+ if (tree_item->getData().toString() == QUICK_LINK_NODE) {
+ return tree_item->getLabel();
} else {
- return tree_item->dataPath();
+ return tree_item->getData();
}
- } else if (role == TreeItemModel::kDataPathRole) {
+ } else if (role == TreeItemModel::kDataRole) {
// We use Qt::UserRole to ask for the datapath.
- return tree_item->dataPath();
+ return tree_item->getData();
} else if (role == Qt::FontRole) {
QFont font;
font.setBold(tree_item->isBold());
@@ -228,7 +228,7 @@ void SidebarModel::clicked(const QModelIndex& index) {
} else {
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
feature->activateChild(index);
}
}
@@ -241,7 +241,7 @@ void SidebarModel::doubleClicked(const QModelIndex& index) {
} else {
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
feature->onLazyChildExpandation(index);
}
}
@@ -259,7 +259,7 @@ void SidebarModel::rightClicked(const QPoint& globalPos, const QModelIndex& inde
{
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
feature->activateChild(index);
feature->onRightClickChild(globalPos, index);
}
@@ -277,7 +277,7 @@ bool SidebarModel::dropAccept(const QModelIndex& index, QList<QUrl> urls,
} else {
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
result = feature->dropAcceptChild(index, urls, pSource);
}
}
@@ -295,7 +295,7 @@ bool SidebarModel::dragMoveAccept(const QModelIndex& index, QUrl url) {
} else {
TreeItem* tree_item = (TreeItem*)index.internalPointer();
if (tree_item) {
- LibraryFeature* feature = tree_item->getFeature();
+ LibraryFeature* feature = tree_item->feature();
result = feature->dragMoveAcceptChild(index, url);
}
}
diff --git a/src/library/traktor/traktorfeature.cpp b/src/library/traktor/traktorfeature.cpp
index 2cf48b224e..a0c461d90c 100644
--- a/