/*************************************************************************** source::worx raDIYo Copyright © 2020-2022 c.holzheuer chris@sourceworx.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ***************************************************************************/ #include #include #include #include #include SWSongsControl::SWSongsControl( QWidget* parent, QSettings* settings ) : SWListControl( parent, settings ) { setHeaderText( "Songs" ); } /** * Überschriebene Methode. Wird jedesmal beim Einblenden des Controls aufgerufen. Lädt * in diesem Fall das Songs-Verzeichnis. * @see loadDir() */ void SWSongsControl::onShow() { const QString& songsDir = settings().value( raDIYo::KeySongsPath ).toString(); loadDir( songsDir ); } /** * Lädt das Songs-Verzeichnis und zeigt den Inhalt im ListWisget an. * @param songsDir Verzeichnispfad. */ void SWSongsControl::loadDir( const QString& songsDir ) { QDir songs( songsDir ); _contentView->clear(); songs.setFilter( QDir::Files ); QFileInfoList list = songs.entryInfoList(); for( auto& entry : list ) { QString lowName = entry.fileName().toLower(); if( lowName.endsWith( ".mp3") ) createItem( entry.fileName(), "file:" + entry.absoluteFilePath() ); } // Es gibt Inhalte if( _contentView->count() > 0 ) { // _checkedID nur resetten falls notwendig _checkedID = qMin( _checkedID, _contentView->count() ); _contentView->setCurrentRow( _checkedID ); } // und sonst ?? }