|
|
// -*- c++ -*- /* * * Copyright (C) 2002 Richard Moore* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef CHANNELSCANNER_H #define CHANNELSCANNER_H #include #include class V4LDev; class Channel; class ChannelStore; class ChannelScannerRegion; /** * Channel scanner backend. * * @version $Id: channelscanner.h,v 1.2 2002/03/17 02:08:18 rich Exp $ * @author Richard Moore, rich@kde.org */ class ChannelScanner : public QObject { Q_OBJECT public: ChannelScanner( QObject *parent=0, const char *name=0 ); virtual ~ChannelScanner(); void setDevice( V4LDev *device ); V4LDev *device() const { return dev; } void setStore( ChannelStore *store ); ChannelStore *store() const { return chanStore; } /** * Loads an XML region definition using ChannelScannerRegion. */ bool loadRegionFile( const QString &filename ); /** * Returns the last channel found (or 0 if we haven't found one). */ Channel *channel() const { return chan; } public slots: /** * Scans the current device and stores any channels found in the * current store. This slot only kicks of the scan, so it returns * quickly, the actual scanning is done with timers so the GUI * doesn't block. */ void scan(); signals: /** * Emitted when we start scanning. */ void started(); /** * Emitted when we make one percent of progress. */ void progress( int ); /** * Emitted when the scan is complete. */ void done(); /** * Emitted when the scan is complete. * * @param success true iff we found any channels. */ void done( bool success ); /** * Emitted whenever we find a channel. */ void foundChannel(); protected: /** * Prepare for a scan. Returns true if we're set to go. */ bool first(); /** * Advance the scan by one. Returns true if we can continue, and * false if we hit the end of the range. */ bool next(); /** * Tidy up after the full range has been scanned. */ bool last(); /** * Scans the current frequency and returns true if a channel is found. * Note that this relies on being inside the first(), next(), last() * loop and can't just scan an arbitrary place. */ bool scanCurrent(); /** * Initialise the frequency according to the region settings. */ bool regionFirst(); /** * Advance the frequency according to the region settings. */ bool regionNext(); protected slots: /** * Adds the current frequency as a channel. */ void addChannel(); /** * Scans a chunk of the frequency range, then schedulers a timer to * call itself to process the next chunk. */ void scanChunk(); private: V4LDev *dev; unsigned long freq; unsigned long min; unsigned long max; unsigned long start; int adj; int percentDone; unsigned long lastProgress; unsigned long onePercent; unsigned long oneChunk; ChannelStore *chanStore; Channel *chan; ChannelScannerRegion *region; }; #endif // CHANNELSCANNER_H
Generated by: rich on pegasus on Wed Mar 20 03:16:53 2002, using kdoc 2.0a53. |