void SetlogFeature::slotGetNewPlaylist() { //qDebug() << "slotGetNewPlaylist() succesfully triggered !"; // create a new playlist for today QString set_log_name_format; QString set_log_name; set_log_name = QDate::currentDate().toString(Qt::ISODate); set_log_name_format = set_log_name + " (%1)"; int i = 1; // calculate name of the todays setlog while (m_playlistDao.getPlaylistIdFromName(set_log_name) != -1) { set_log_name = set_log_name_format.arg(++i); } //qDebug() << "Creating session history playlist name:" << set_log_name; m_playlistId = m_playlistDao.createPlaylist(set_log_name, PlaylistDAO::PLHT_SET_LOG); if (m_playlistId == -1) { qDebug() << "Setlog playlist Creation Failed"; qDebug() << "An unknown error occurred while creating playlist: " << set_log_name; } slotPlaylistTableChanged(m_playlistId); // For moving selection emit(showTrackModel(m_pPlaylistTableModel)); }
void SetlogFeature::slotJoinWithPrevious() { //qDebug() << "slotJoinWithPrevious() row:" << m_lastRightClickedIndex.data(); if (m_lastRightClickedIndex.isValid()) { int currentPlaylistId = m_playlistDao.getPlaylistIdFromName( m_lastRightClickedIndex.data().toString()); if (currentPlaylistId >= 0) { bool locked = m_playlistDao.isPlaylistLocked(currentPlaylistId); if (locked) { qDebug() << "Skipping playlist deletion because playlist" << currentPlaylistId << "is locked."; return; } // Add every track from right klicked playlist to that with the next smaller ID int previousPlaylistId = m_playlistDao.getPreviousPlaylist(currentPlaylistId, PlaylistDAO::PLHT_SET_LOG); if (previousPlaylistId >= 0) { m_pPlaylistTableModel->setTableModel(previousPlaylistId); if (currentPlaylistId == m_playlistId) { // mark all the Tracks in the previous Playlist as played m_pPlaylistTableModel->select(); int rows = m_pPlaylistTableModel->rowCount(); for (int i = 0; i < rows; ++i) { QModelIndex index = m_pPlaylistTableModel->index(i,0); if (index.isValid()) { TrackPointer track = m_pPlaylistTableModel->getTrack(index); // Do not update the play count, just set played status. PlayCounter playCounter(track->getPlayCounter()); playCounter.setPlayed(); track->setPlayCounter(playCounter); } } // Change current setlog m_playlistId = previousPlaylistId; } qDebug() << "slotJoinWithPrevious() current:" << currentPlaylistId << " previous:" << previousPlaylistId; if (m_playlistDao.copyPlaylistTracks(currentPlaylistId, previousPlaylistId)) { m_playlistDao.deletePlaylist(currentPlaylistId); slotPlaylistTableChanged(previousPlaylistId); // For moving selection emit(showTrackModel(m_pPlaylistTableModel)); } } } } }
void BasePlaylistFeature::slotPlaylistTableRenamed(int playlistId, QString /* a_strName */) { slotPlaylistTableChanged(playlistId); }