first re-commit.
This commit is contained in:
75
swsongscontrol.cpp
Normal file
75
swsongscontrol.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
|
||||
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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <swsongscontrol.h>
|
||||
#include <raDIYo.h>
|
||||
|
||||
|
||||
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 ??
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user