Logo Search packages:      
Sourcecode: maxemumtvguide version File versions  Download package

channelmaster.cpp

/***************************************************************************
 *   Copyright (C) 2005 by Robert Maxe                                     *
 *   mutex@spray.se                                                        *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
//-----------------------------------------------------------------------------------------------------------------------
//#include <qstring.h>
//-----------------------------------------------------------------------------------------------------------------------
//#include "channelmaster.h"
//-----------------------------------------------------------------------------------------------------------------------
/*ChannelMaster::ChannelMaster(QPtrList<Channel> *channels)
{
      m_channels = channels;

//    m_channels.setAutoDelete(true);
}
//-----------------------------------------------------------------------------------------------------------------------
ChannelMaster::~ChannelMaster()
{
//    m_channels.clear();
}
//-----------------------------------------------------------------------------------------------------------------------
QString ChannelMaster::channelName(QString id)
{
      QStringList customName;
      QString channelName;
      Channel *channel;

      customName = m_customChannelNames.grep("@" + id);
      if(!customName.isEmpty()) {
            channelName = (*customName.at(0)).section('=', 1, 1);
      } else {
            for(uint i=0; i<m_channels->count(); i++) {
                  channel = m_channels->at(i);
                  if(channel->id() == id) {
                        channelName = channel->name();
                        break;
                  }
            }
      }
      return(channelName);
}
//-----------------------------------------------------------------------------------------------------------------------
void ChannelMaster::setCustomChannelName(QString id, QString customName)
{
      QStringList customNameList;

      customNameList = m_customChannelNames.grep("@" + id);
      if(!customNameList.isEmpty())
            m_customChannelNames.remove(*(customNameList.at(0)));
      if(!customName.isEmpty())
            m_customChannelNames.append("@" + id + "=" + customName);
}
//-----------------------------------------------------------------------------------------------------------------------
bool ChannelMaster::hasCustomChannelName(QString id)
{
      QStringList customNameList;

      customNameList = m_customChannelNames.grep("@" + id);
      return(!customNameList.isEmpty());
}
//-----------------------------------------------------------------------------------------------------------------------
void ChannelMaster::loadSettings(KConfig *cfg)
{
      if(!cfg->hasGroup("Channels"))
            return;
      cfg->setGroup("Channels");

      m_customChannelNames.clear();
      m_customChannelNames = cfg->readListEntry("channels");
}
//-----------------------------------------------------------------------------------------------------------------------
void ChannelMaster::saveSettings(KConfig *cfg)
{
      QPtrListIterator<Channel> it(*m_channels);
      Channel *channel;

      while(it.current()) {
            channel = (Channel*)it.current();
            cfg->setGroup(channel->id());
            cfg->writeEntry("prio", channel->prio());
            ++it;
      }
      cfg->setGroup("Channels");
      cfg->writeEntry("channels", m_customChannelNames);
      cfg->sync();
}
//-----------------------------------------------------------------------------------------------------------------------
Channel* ChannelMaster::channel(QString id)
{
      QPtrListIterator<Channel> it(*m_channels);
      Channel *channel = NULL;

      while(it.current()) {
            channel = (Channel*)it.current();
            if(channel->id().compare(id) == 0)
                  break;
            ++it;
      }
      return(channel);
}*/
//-----------------------------------------------------------------------------------------------------------------------

Generated by  Doxygen 1.6.0   Back to index