Пример #1
0
void KNMusicPlaylist::showIndex(KNMusicModel *musicModel,
                                const QModelIndex &index)
{
    //Check the music model.
    if(musicModel==nullptr)
    {
        return;
    }
    //Clear up the search model.
    if(knMusicGlobal->search())
    {
        knMusicGlobal->search()->clear();
    }
    //Find the music model.
    //Get the playlist list first.
    KNMusicPlaylistListModel *playlistList=m_playlistManager->playlistList();
    //Get the model index of the music model.
    QModelIndex playlistIndex=
            playlistList->playlistIndex(
                static_cast<KNMusicPlaylistModel *>(musicModel));
    //Check validatation of the model index.
    if(playlistIndex.isValid())
    {
        //Select the music data.
        m_playlistList->showPlaylist(playlistIndex);
        //Select the index of the playlist index.
        m_playlistViewer->selectSong(index);
        //Ask to show the tab.
        emit requireShowTab();
    }
}
Пример #2
0
void KNMusicLibraryGenreTab::onActionShowInGenre()
{
    //Clear the search result.
    KNMusicGlobal::musicSearch()->search("");
    //Get the row of the file.
    int musicRow=m_musicLibrary->rowFromFilePath(KNMusicGlobal::soloMenu()->currentFilePath());
    //If the row is available.
    if(musicRow!=-1)
    {
        //Get the genre name of the row.
        QModelIndex categoryIndex=
                proxyCategoryModel()->categoryIndex(
                    m_musicLibrary->itemText(musicRow,
                                             m_categoryModel->categoryIndex()));
        //Check is the catgeory vaild.
        if(categoryIndex.isValid())
        {
            //Change the current category index.
            m_genreList->setCurrentIndex(categoryIndex);
            m_genreList->scrollTo(categoryIndex,
                                  QAbstractItemView::PositionAtCenter);
            //Set the details to display the index of the song.
            m_genreDisplay->scrollToSourceRow(musicRow);
            //Ask to show the genre tab.
            emit requireShowTab();
        }
    }
}
Пример #3
0
inline void KNMusicLibrarySongTab::showAndSelectRow(const int &musicRow)
{
    //Simply scroll to the special position.
    m_treeView->scrollToSourceRow(musicRow);
    //Ask to show the tab.
    emit requireShowTab();
}
Пример #4
0
void KNMusicPlaylist::showAndRenamePlaylist(const QModelIndex &playlistIndex)
{
    //When this function is called, we need to switch to playlist tab.
    emit requireShowTab();
    //Set focus to playlist list.
    m_playlistList->setFocus(Qt::MouseFocusReason);
    //Show that playlist.
    m_playlistList->showPlaylist(playlistIndex);
    //Ask the list view to rename it.
    m_playlistList->renamePlaylist(playlistIndex);
}
Пример #5
0
inline void KNMusicPlugin::addMusicTab(KNMusicTab *musicTab)
{
    //Just add them to a new music category.
    MusicTabItem currentTab;
    currentTab.index=addMusicCategory(musicTab->icon(),
                                      musicTab->caption(),
                                      musicTab->widget());
    currentTab.tab=musicTab;
    //Connect show tab request.
    connect(musicTab, SIGNAL(requireShowTab()),
            m_tabSwitchMapper, SLOT(map()));
    m_tabSwitchMapper->setMapping(musicTab, m_tabList.size());
    //Add tab to list.
    m_tabList.append(currentTab);
    //Connect request to the music tab.
    connect(KNMusicGlobal::musicSearch(), &KNMusicSearchBase::requireSearch,
            musicTab, &KNMusicTab::onActionSearch);
}
Пример #6
0
inline void KNMusicLibraryAlbumTab::showAndSelectRow(const int &musicRow)
{
    //Show and select the index row.
    QModelIndex &&categoryIndex=
            categoryProxyModel()->categoryIndex(
                m_libraryModel->index(musicRow, Album).data(Qt::DisplayRole));
    //Check is the category index valid.
    if(categoryIndex.isValid())
    {
        //Change the current index of the album view.
        m_albumView->locateTo(categoryIndex);
        m_albumView->selectAlbum(
                    categoryProxyModel()->mapToSource(categoryIndex));
        //Set the details to display the index of the song.
        m_albumDetail->scrollToSourceRow(musicRow);
    }
    //Ask to show the tab.
    emit requireShowTab();
}