File indexing completed on 2024-05-12 04:52:20

0001 /*
0002  * dvbtab.h
0003  *
0004  * Copyright (C) 2007-2011 Christoph Pfister <christophpfister@gmail.com>
0005  *
0006  * This program is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU General Public License as published by
0008  * the Free Software Foundation; either version 2 of the License, or
0009  * (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License along
0017  * with this program; if not, write to the Free Software Foundation, Inc.,
0018  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0019  */
0020 
0021 #ifndef DVBTAB_H
0022 #define DVBTAB_H
0023 
0024 #include <QPointer>
0025 #include <QTimer>
0026 #include <QList>
0027 #include <QIcon>
0028 #include <config-kaffeine.h>
0029 #include "../tabbase.h"
0030 #include "../mediawidget.h"
0031 #include "dvbrecording.h"
0032 
0033 class QModelIndex;
0034 class QSplitter;
0035 class QAction;
0036 class KActionCollection;
0037 class QMenu;
0038 class DvbChannelTableModel;
0039 class DvbChannelView;
0040 class DvbEpgDialog;
0041 class DvbTimeShiftCleaner;
0042 class MediaWidget;
0043 
0044 class DvbTab : public TabBase
0045 {
0046     Q_OBJECT
0047 public:
0048     DvbTab(QMenu *menu, KActionCollection *collection, MediaWidget *mediaWidget_);
0049     ~DvbTab();
0050 
0051     void playChannel(const QString &nameOrNumber);
0052     void playLastChannel();
0053 
0054     void toggleOsd();
0055     void toggleInstantRecord();
0056     void toggleDisplayMode(MediaWidget::DisplayMode displayMode) override;
0057     void mouse_move(int x, int y) override;
0058 
0059     DvbManager *getManager() const
0060     {
0061         return manager;
0062     }
0063 
0064     void enableDvbDump();
0065 
0066 public slots:
0067     void osdKeyPressed(int key);
0068     void mayCloseApplication(bool *ok, QWidget *parent);
0069 
0070 private slots:
0071     void showChannelDialog();
0072     void toggleEpgDialog();
0073     void showRecordingDialog();
0074     void instantRecord(bool checked);
0075     void recordingRemoved(const DvbSharedRecording &recording);
0076     void configureDvb();
0077     void tuneOsdChannel();
0078     void playChannel(const QModelIndex &index);
0079     void previousChannel();
0080     void nextChannel();
0081     void cleanTimeShiftFiles();
0082     void channelPidsUpdated(const DvbSharedChannel &updatedChannel);
0083 
0084 private:
0085     void activate() override;
0086     void playChannel(const DvbSharedChannel &channel, const QModelIndex &index);
0087     DvbSharedRecording *getInstantRecording(DvbSharedChannel ch);
0088 
0089     MediaWidget *mediaWidget;
0090     DvbManager *manager;
0091     QAction *instantRecordAction;
0092     QList<DvbSharedRecording> instantRecordings;
0093     DvbSharedRecording instantRecording;
0094     QSplitter *splitter;
0095     QWidget *leftWidget;
0096     DvbChannelTableModel *channelProxyModel;
0097     DvbChannelView *channelView;
0098     QPointer<DvbEpgDialog> epgDialog;
0099     QLayout *mediaLayout;
0100     QString osdChannel;
0101     QTimer osdChannelTimer;
0102     QString currentChannel;
0103     QString lastChannel;
0104     QIcon mediaRecordIcon;
0105     QIcon documentSaveIcon;
0106     bool autoHideMenu;
0107 
0108     DvbTimeShiftCleaner *timeShiftCleaner;
0109 };
0110 
0111 #ifndef HAVE_DVB
0112 #error HAVE_DVB must be defined
0113 #endif /* HAVE_DVB */
0114 
0115 #if HAVE_DVB == 0
0116 inline void DvbTab::playChannel(QString const &) { }
0117 inline void DvbTab::playLastChannel() { }
0118 inline void DvbTab::toggleOsd() { }
0119 inline void DvbTab::toggleInstantRecord() { }
0120 inline void DvbTab::osdKeyPressed(int) { }
0121 #endif /* HAVE_DVB == 0 */
0122 
0123 #endif /* DVBTAB_H */