first re-commit.
This commit is contained in:
81
swsendercontrol.cpp
Normal file
81
swsendercontrol.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
|
||||
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 <QTextStream>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
|
||||
#include <swsendercontrol.h>
|
||||
#include <raDIYo.h>
|
||||
|
||||
|
||||
SWSenderControl::SWSenderControl( QWidget* parent, QSettings* settings )
|
||||
: SWListControl( parent, settings )
|
||||
{
|
||||
setHeaderText( "Sender" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird jeweils beim Einblenden aufgerufen.
|
||||
*
|
||||
* Lädt die aktuelle Liste der voreingestellten Internetsender.
|
||||
*/
|
||||
|
||||
void SWSenderControl::onShow()
|
||||
{
|
||||
_contentView->clear();
|
||||
|
||||
QString path = settings().value( raDIYo::KeySenderPath ).toString();
|
||||
QFile senderFile( path );
|
||||
|
||||
// Wir lesen die Hard-Kodierte Senderliste und schreiben sie ggf.
|
||||
// auf Platte
|
||||
if( !senderFile.exists() || senderFile.size() == 0 )
|
||||
{
|
||||
QString senderList = readResource( raDIYo::ResSenderList );
|
||||
// geht nicht gibts nicht
|
||||
Q_ASSERT( senderFile.open( QIODevice::WriteOnly ) );
|
||||
senderFile.write( senderList.toUtf8() );
|
||||
senderFile.close();
|
||||
}
|
||||
|
||||
// geht nicht gibts nicht
|
||||
Q_ASSERT( senderFile.exists() );
|
||||
|
||||
senderFile.open( QIODevice::ReadOnly );
|
||||
QTextStream mediaList( &senderFile );
|
||||
while( !mediaList.atEnd() )
|
||||
{
|
||||
QString line = mediaList.readLine();
|
||||
QStringList entry = line.split( ';');
|
||||
if( entry.size() == 2 )
|
||||
createItem( entry[0], entry[1] );
|
||||
}
|
||||
|
||||
// Es gibt Inhalte
|
||||
if( _contentView->count() > 0 )
|
||||
{
|
||||
// _checkedID nur resetten falls notwendig
|
||||
_checkedID = qMin( _checkedID, _contentView->count() );
|
||||
_contentView->setCurrentRow( _checkedID );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user