void ITunesFeature::activate(bool forceReload) { //qDebug("ITunesFeature::activate()"); if (!m_isActivated || forceReload) { SettingsDAO settings(m_pTrackCollection->database()); QString dbSetting(settings.getValue(ITDB_PATH_KEY)); // if a path exists in the database, use it if (!dbSetting.isEmpty() && QFile::exists(dbSetting)) { m_dbfile = dbSetting; } else { // No Path in settings, try the default m_dbfile = getiTunesMusicPath(); } QFileInfo dbFile(m_dbfile); if (!m_dbfile.isEmpty() && dbFile.exists()) { // Users of Mixxx <1.12.0 didn't support sandboxing. If we are sandboxed // and using a custom iTunes path then we have to ask for access to this // file. Sandbox::askForAccess(m_dbfile); } else { // if the path we got between the default and the database doesn't // exist, ask for a new one and use/save it if it exists m_dbfile = QFileDialog::getOpenFileName( NULL, tr("Select your iTunes library"), QDir::homePath(), "*.xml"); QFileInfo dbFile(m_dbfile); if (m_dbfile.isEmpty() || !dbFile.exists()) { emit(showTrackModel(m_pITunesTrackModel)); return; } // The user has picked a new directory via a file dialog. This means the // system sandboxer (if we are sandboxed) has granted us permission to // this folder. Create a security bookmark while we have permission so // that we can access the folder on future runs. We need to canonicalize // the path so we first wrap the directory string with a QDir. Sandbox::createSecurityToken(dbFile); settings.setValue(ITDB_PATH_KEY, m_dbfile); } m_isActivated = true; // Usually the maximum number of threads // is > 2 depending on the CPU cores // Unfortunately, within VirtualBox // the maximum number of allowed threads // is 1 at all times We'll need to increase // the number to > 1, otherwise importing the music collection // takes place when the GUI threads terminates, i.e., on // Mixxx shutdown. QThreadPool::globalInstance()->setMaxThreadCount(4); //Tobias decided to use 4 // Let a worker thread do the XML parsing m_future = QtConcurrent::run(this, &ITunesFeature::importLibrary); m_future_watcher.setFuture(m_future); m_title = tr("(loading) iTunes"); // calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pITunesTrackModel)); emit(enableCoverArtDisplay(false)); }
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 RhythmboxFeature::activateChild(const QModelIndex& index) { //qDebug() << "RhythmboxFeature::activateChild()" << index; QString playlist = index.data().toString(); qDebug() << "Activating " << playlist; m_pRhythmboxPlaylistModel->setPlaylist(playlist); emit(showTrackModel(m_pRhythmboxPlaylistModel)); }
void TraktorFeature::activate() { qDebug() << "TraktorFeature::activate()"; if (!m_isActivated) { m_isActivated = true; // Ususally the maximum number of threads // is > 2 depending on the CPU cores // Unfortunately, within VirtualBox // the maximum number of allowed threads // is 1 at all times We'll need to increase // the number to > 1, otherwise importing the music collection // takes place when the GUI threads terminates, i.e., on // Mixxx shutdown. QThreadPool::globalInstance()->setMaxThreadCount(4); //Tobias decided to use 4 // Let a worker thread do the XML parsing m_future = QtConcurrent::run(this, &TraktorFeature::importLibrary, getTraktorMusicDatabase()); m_future_watcher.setFuture(m_future); m_title = tr("(loading) Traktor"); //calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. emit (featureIsLoading(this)); } emit(showTrackModel(m_pTraktorTableModel)); }
void ITunesFeature::activateChild(const QModelIndex& index) { //qDebug() << "ITunesFeature::activateChild()" << index; QString playlist = index.data().toString(); qDebug() << "Activating " << playlist; m_pITunesPlaylistModel->setPlaylist(playlist); emit(showTrackModel(m_pITunesPlaylistModel)); emit(enableCoverArtDisplay(false)); }
void Library::slotShowTrackModel(QAbstractItemModel* model) { //qDebug() << "Library::slotShowTrackModel" << model; TrackModel* trackModel = dynamic_cast<TrackModel*>(model); Q_ASSERT(trackModel); emit(showTrackModel(model)); emit(switchToView(m_sTrackViewName)); emit(restoreSearch(trackModel->currentSearch())); }
void BasePlaylistFeature::activateChild(const QModelIndex& index) { //qDebug() << "BasePlaylistFeature::activateChild()" << index; int playlistId = playlistIdFromIndex(index); if (playlistId != -1 && m_pPlaylistTableModel) { m_pPlaylistTableModel->setTableModel(playlistId); emit(showTrackModel(m_pPlaylistTableModel)); emit(enableCoverArtDisplay(true)); } }
void BansheeFeature::activateChild(const QModelIndex& index) { TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); int playlistID = item->getData().toInt(); if (playlistID > 0) { qDebug() << "Activating " << item->getLabel(); m_pBansheePlaylistModel->setTableModel(playlistID); emit(showTrackModel(m_pBansheePlaylistModel)); emit(enableCoverArtDisplay(false)); } }
void ITunesFeature::activate(bool forceReload) { //qDebug("ITunesFeature::activate()"); if (!m_isActivated || forceReload) { SettingsDAO settings(m_pTrackCollection->getDatabase()); QString dbSetting(settings.getValue(ITDB_PATH_KEY)); // if a path exists in the database, use it if (!dbSetting.isEmpty() && QFile::exists(dbSetting)) { m_dbfile = dbSetting; } else { // No Path in settings, try the default m_dbfile = getiTunesMusicPath(); } // if the path we got between the default and the database doesn't // exist, ask for a new one and use/save it if it exists if (!QFile::exists(m_dbfile)) { m_dbfile = QFileDialog::getOpenFileName( NULL, tr("Select your iTunes library"), QDir::homePath(), "*.xml"); if (m_dbfile.isEmpty() || !QFile::exists(m_dbfile)) { emit(showTrackModel(m_pITunesTrackModel)); return; } settings.setValue(ITDB_PATH_KEY, m_dbfile); } m_isActivated = true; // Ususally the maximum number of threads // is > 2 depending on the CPU cores // Unfortunately, within VirtualBox // the maximum number of allowed threads // is 1 at all times We'll need to increase // the number to > 1, otherwise importing the music collection // takes place when the GUI threads terminates, i.e., on // Mixxx shutdown. QThreadPool::globalInstance()->setMaxThreadCount(4); //Tobias decided to use 4 // Let a worker thread do the XML parsing m_future = QtConcurrent::run(this, &ITunesFeature::importLibrary); m_future_watcher.setFuture(m_future); m_title = tr("(loading) iTunes"); // calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. emit (featureIsLoading(this)); } emit(showTrackModel(m_pITunesTrackModel)); }
void BansheeFeature::activate() { //qDebug("BansheeFeature::activate()"); if (!m_isActivated) { if (!QFile::exists(m_databaseFile)) { // Fall back to default m_databaseFile = BansheeDbConnection::getDatabaseFile(); } if (!QFile::exists(m_databaseFile)) { QMessageBox::warning( NULL, tr("Error loading Banshee database"), tr("Banshee database file not found at\n") + m_databaseFile); qDebug() << m_databaseFile << "does not exist"; } if (!m_connection.open(m_databaseFile)) { QMessageBox::warning( NULL, tr("Error loading Banshee database"), tr("There was an error loading your Banshee database at\n") + m_databaseFile); return; } qDebug() << "Using Banshee Database Schema V" << m_connection.getSchemaVersion(); m_isActivated = true; auto pRootItem = std::make_unique<TreeItem>(this); QList<BansheeDbConnection::Playlist> playlists = m_connection.getPlaylists(); for (const BansheeDbConnection::Playlist& playlist: playlists) { qDebug() << playlist.name; // append the playlist to the child model pRootItem->appendChild(playlist.name, playlist.playlistId); } m_childModel.setRootItem(std::move(pRootItem)); if (m_isActivated) { activate(); } qDebug() << "Banshee library loaded: success"; //calls a slot in the sidebarmodel such that 'isLoading' is removed from the feature title. m_title = tr("Banshee"); emit(featureLoadingFinished(this)); } m_pBansheePlaylistModel->setTableModel(0); // Gets the master playlist emit(showTrackModel(m_pBansheePlaylistModel)); emit(enableCoverArtDisplay(false)); }
void BasePlaylistFeature::activateChild(const QModelIndex& index) { //qDebug() << "BasePlaylistFeature::activateChild()" << index; // Switch the playlist table model's playlist. QString playlistName = index.data().toString(); int playlistId = m_playlistDao.getPlaylistIdFromName(playlistName); if (m_pPlaylistTableModel) { m_pPlaylistTableModel->setTableModel(playlistId); emit(showTrackModel(m_pPlaylistTableModel)); } }
void CrateFeature::activateChild(const QModelIndex& index) { if (!index.isValid()) return; int crateId = crateIdFromIndex(index); if (crateId == -1) { return; } m_crateTableModel.setTableModel(crateId); emit(showTrackModel(&m_crateTableModel)); emit(enableCoverArtDisplay(true)); }
void CrateFeature::activateCrate(int crateId) { //qDebug() << "CrateFeature::activateCrate()" << crateId; QModelIndex index = indexFromCrateId(crateId); if (crateId != -1 && index.isValid()) { m_crateTableModel.setTableModel(crateId); emit(showTrackModel(&m_crateTableModel)); emit(enableCoverArtDisplay(true)); // Update selection emit(featureSelect(this, m_lastRightClickedIndex)); activateChild(m_lastRightClickedIndex); } }
void TraktorFeature::activateChild(const QModelIndex& index) { if (!index.isValid()) return; //access underlying TreeItem object TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); if (item->isPlaylist()) { qDebug() << "Activate Traktor Playlist: " << item->dataPath().toString(); m_pTraktorPlaylistModel->setPlaylist(item->dataPath().toString()); emit(showTrackModel(m_pTraktorPlaylistModel)); } }
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 CrateFeature::slotDuplicateCrate() { int oldCrateId = crateIdFromIndex(m_lastRightClickedIndex); if (oldCrateId == -1) { return; } QString oldName = m_crateDao.crateName(oldCrateId); QString name; bool validNameGiven = false; while (!validNameGiven) { bool ok = false; name = QInputDialog::getText(NULL, tr("Duplicate Crate"), tr("Enter name for new crate:"), QLineEdit::Normal, //: Appendix to default name when duplicating a crate oldName + tr("_copy" , "[noun]"), &ok).trimmed(); if (!ok || name == oldName) { return; } int existingId = m_crateDao.getCrateIdByName(name); if (existingId != -1) { QMessageBox::warning(NULL, tr("Renaming Crate Failed"), tr("A crate by that name already exists.")); } else if (name.isEmpty()) { QMessageBox::warning(NULL, tr("Renaming Crate Failed"), tr("A crate cannot have a blank name.")); } else { validNameGiven = true; } } int newCrateId = m_crateDao.createCrate(name); m_crateDao.copyCrateTracks(oldCrateId, newCrateId); if (newCrateId != -1) { emit(showTrackModel(&m_crateTableModel)); } else { qDebug() << "Error creating crate with name " << name; QMessageBox::warning(NULL, tr("Creating Crate Failed"), tr("An unknown error occurred while creating crate: ") + name); } }
void BasePlaylistFeature::slotDuplicatePlaylist() { int oldPlaylistId = playlistIdFromIndex(m_lastRightClickedIndex); if (oldPlaylistId == -1) { return; } QString oldName = m_playlistDao.getPlaylistName(oldPlaylistId); QString name; bool validNameGiven = false; while (!validNameGiven) { bool ok = false; name = QInputDialog::getText(NULL, tr("Duplicate Playlist"), tr("Enter name for new playlist:"), QLineEdit::Normal, //: Appendix to default name when duplicating a playlist oldName + tr("_copy" , "[noun]"), &ok).trimmed(); if (!ok || oldName == name) { return; } int existingId = m_playlistDao.getPlaylistIdFromName(name); if (existingId != -1) { QMessageBox::warning(NULL, tr("Playlist Creation Failed"), tr("A playlist by that name already exists.")); } else if (name.isEmpty()) { QMessageBox::warning(NULL, tr("Playlist Creation Failed"), tr("A playlist cannot have a blank name.")); } else { validNameGiven = true; } } int newPlaylistId = m_playlistDao.createPlaylist(name); if (newPlaylistId != -1 && m_playlistDao.copyPlaylistTracks(oldPlaylistId, newPlaylistId)) { emit(showTrackModel(m_pPlaylistTableModel)); } }
void BasePlaylistFeature::slotCreatePlaylist() { if (!m_pPlaylistTableModel) { return; } QString name; bool validNameGiven = false; while (!validNameGiven) { bool ok = false; name = QInputDialog::getText(NULL, tr("New Playlist"), tr("Playlist name:"), QLineEdit::Normal, tr("New Playlist"), &ok).trimmed(); if (!ok) return; int existingId = m_playlistDao.getPlaylistIdFromName(name); if (existingId != -1) { QMessageBox::warning(NULL, tr("Playlist Creation Failed"), tr("A playlist by that name already exists.")); } else if (name.isEmpty()) { QMessageBox::warning(NULL, tr("Playlist Creation Failed"), tr("A playlist cannot have a blank name.")); } else { validNameGiven = true; } } int playlistId = m_playlistDao.createPlaylist(name); if (playlistId != -1) { emit(showTrackModel(m_pPlaylistTableModel)); } else { QMessageBox::warning(NULL, tr("Playlist Creation Failed"), tr("An unknown error occurred while creating playlist: ") + name); } }
void CrateFeature::slotCreateCrate() { QString name; bool validNameGiven = false; while (!validNameGiven) { bool ok = false; name = QInputDialog::getText(NULL, tr("Create New Crate"), tr("Enter name for new crate:"), QLineEdit::Normal, tr("New Crate"), &ok).trimmed(); if (!ok) return; int existingId = m_crateDao.getCrateIdByName(name); if (existingId != -1) { QMessageBox::warning(NULL, tr("Creating Crate Failed"), tr("A crate by that name already exists.")); } else if (name.isEmpty()) { QMessageBox::warning(NULL, tr("Creating Crate Failed"), tr("A crate cannot have a blank name.")); } else { validNameGiven = true; } } int crateId = m_crateDao.createCrate(name); if (crateId != -1) { emit(showTrackModel(&m_crateTableModel)); } else { qDebug() << "Error creating crate with name " << name; QMessageBox::warning(NULL, tr("Creating Crate Failed"), tr("An unknown error occurred while creating crate: ") + name); } }
void TraktorFeature::onTrackCollectionLoaded() { TreeItem* root = m_future.result(); if (root) { m_childModel.setRootItem(root); // Tell the rhythmbox track source that it should re-build its index. m_pTrackCollection->getTrackSource("traktor")->buildIndex(); //m_pTraktorTableModel->select(); emit(showTrackModel(m_pTraktorTableModel)); qDebug() << "Traktor library loaded successfully"; } else { QMessageBox::warning( NULL, tr("Error Loading Traktor Library"), tr("There was an error loading your Traktor library. Some of " "your Traktor tracks or playlists may not have loaded.")); } // calls a slot in the sidebarmodel such that 'isLoading' is removed from the feature title. m_title = tr("Traktor"); emit(featureLoadingFinished(this)); activate(); }
void ITunesFeature::onTrackCollectionLoaded() { std::unique_ptr<TreeItem> root(m_future.result()); if (root) { m_childModel.setRootItem(std::move(root)); // Tell the rhythmbox track source that it should re-build its index. m_trackSource->buildIndex(); //m_pITunesTrackModel->select(); emit(showTrackModel(m_pITunesTrackModel)); qDebug() << "Itunes library loaded: success"; } else { QMessageBox::warning( NULL, tr("Error Loading iTunes Library"), tr("There was an error loading your iTunes library. Some of " "your iTunes tracks or playlists may not have loaded.")); } // calls a slot in the sidebarmodel such that 'isLoading' is removed from the feature title. m_title = tr("iTunes"); emit(featureLoadingFinished(this)); activate(); }
void RhythmboxFeature::activate() { qDebug() << "RhythmboxFeature::activate()"; if (!m_isActivated) { m_isActivated = true; // Ususally the maximum number of threads // is > 2 depending on the CPU cores // Unfortunately, within VirtualBox // the maximum number of allowed threads // is 1 at all times We'll need to increase // the number to > 1, otherwise importing the music collection // takes place when the GUI threads terminates, i.e., on // Mixxx shutdown. QThreadPool::globalInstance()->setMaxThreadCount(4); //Tobias decided to use 4 m_track_future = QtConcurrent::run(this, &RhythmboxFeature::importMusicCollection); m_track_watcher.setFuture(m_track_future); m_title = "(loading) Rhythmbox"; //calls a slot in the sidebar model such that 'Rhythmbox (isLoading)' is displayed. emit (featureIsLoading(this)); } emit(showTrackModel(m_pRhythmboxTrackModel)); }
void MixxxLibraryFeature::activate() { qDebug() << "MixxxLibraryFeature::activate()"; emit(showTrackModel(m_pLibraryTableModel)); emit(enableCoverArtDisplay(true)); }
void MixxxLibraryFeature::activate() { qDebug() << "MixxxLibraryFeature::activate()"; emit(showTrackModel(m_pLibraryTableModel)); }