Main Page   Class Hierarchy   Compound List   File List   Compound Members  

channelstore.h

00001 /*
00002  *
00003  * Copyright (C) 2002 George Staikos <staikos@kde.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 
00022 #ifndef _CHANNELSTORE_H
00023 #define _CHANNELSTORE_H
00024 
00025 #include <qstring.h>
00026 #include <qptrlist.h>
00027 #include <qobject.h>
00028 
00029 #include "channelstoreiface.h"
00030 
00031 class Channel;
00032 class QtVision;
00033 
00034 template<class T>
00035 class ChannelPtrList : public QPtrList<T> {
00036 protected:
00037         virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) {
00038         Channel* i1 = static_cast<Channel*>(item1);
00039         Channel* i2 = static_cast<Channel*>(item2);
00040         if (i1 && i2)
00041         if (i1->number() < i2->number()) {
00042                 return -1;
00043         } else if (i1->number() > i2->number()) {
00044                 return 1;
00045         }
00046         return 0;
00047         }
00048 };
00049 
00050 typedef ChannelPtrList<Channel> ChannelList;
00051 
00055 class ChannelStore : public QObject, public virtual QtVisionChannelStoreIface 
00056 {
00057     Q_OBJECT
00058 public:
00059     ChannelStore( QtVision *qtv, QObject *parent, const char *name=0);
00060     virtual ~ChannelStore();
00061 
00062     //ChannelList *channels() { return &_channels; }
00063 
00064     uint count() const { return _channels.count(); }
00065     bool isEmpty() const { return count() ? false : true; }
00066 
00067     bool load( const QString &filename=QString::null, const char *fmt=0 );
00068     bool save( const QString &filename=QString::null, const char *fmt=0 );
00069 
00070     const QString& fileName() const { return _file; }
00071 
00072     DCOPRef channelIfaceAt( int idx );
00073 
00074     Channel *addChannel( ulong freq );
00075     Channel *channelAt( int idx ) { return _channels.at(idx); }
00076     Channel *channelNumber( int n );
00077 
00078     Channel *channelAfter( Channel *channel );
00079     Channel *channelBefore( Channel *channel );
00080 
00081 public slots:
00082     void setName(const QString &filename) { _file = filename; save(); }
00083     bool reload();
00084 
00085     void addChannel( Channel *channel );
00086 
00087     int removeChannel(int idx);
00088     int removeChannelNumber(int n);
00089     int removeChannel(Channel *channel);
00090 
00092     void addChannels( const ChannelStore& nstore);
00093     void clear();
00094 
00095     void renumber( int start );
00097     void renumber();
00098 
00099 signals:
00100     void channelAdded(Channel *x);
00101     void channelRemoved(Channel *x);
00102     void aboutToReload();
00103     void loaded();
00104     void saved();
00105 
00106 private:
00107     ChannelList _channels;
00108     QString _file;
00109     bool silentModifications;
00110     QtVision *_qtv;
00111 };
00112 
00113 
00114 #endif
00115 
00116 
00117 
00118 
00119 

Generated at Thu Jan 30 02:56:02 2003 for QtVision by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001