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

0001 /*
0002  * dvbepgdialog_p.h
0003  *
0004  * Copyright (C) 2009-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 DVBEPGDIALOG_P_H
0022 #define DVBEPGDIALOG_P_H
0023 
0024 #include "dvbchanneldialog.h"
0025 #include "dvbepg.h"
0026 
0027 class DvbEpgEntryLessThan
0028 {
0029 public:
0030     DvbEpgEntryLessThan() { }
0031     ~DvbEpgEntryLessThan() { }
0032 
0033     enum SortOrder
0034     {
0035     };
0036 
0037     SortOrder getSortOrder() const
0038     {
0039         return SortOrder();
0040     }
0041 
0042     void setSortOrder(SortOrder sortOrder_)
0043     {
0044         Q_UNUSED(sortOrder_)
0045     }
0046 
0047     bool operator()(const DvbSharedEpgEntry &x, const DvbSharedEpgEntry &y) const;
0048 };
0049 
0050 class DvbEpgChannelTableModelHelper
0051 {
0052 public:
0053     DvbEpgChannelTableModelHelper() { }
0054     ~DvbEpgChannelTableModelHelper() { }
0055 
0056     typedef DvbSharedChannel ItemType;
0057     typedef DvbChannelLessThan LessThanType;
0058 
0059     int columnCount() const
0060     {
0061         return 1;
0062     }
0063 
0064     bool filterAcceptsItem(const DvbSharedChannel &channel) const
0065     {
0066         Q_UNUSED(channel)
0067         return true;
0068     }
0069 };
0070 
0071 class DvbEpgChannelTableModel : public TableModel<DvbEpgChannelTableModelHelper>
0072 {
0073     Q_OBJECT
0074 
0075 private:
0076     DvbManager *manager;
0077 
0078 public:
0079     explicit DvbEpgChannelTableModel(QObject *parent);
0080     ~DvbEpgChannelTableModel();
0081 
0082     void setManager(DvbManager *manager);
0083     void setViewMode(bool enableEmptyEpgChannels);
0084 
0085     QVariant data(const QModelIndex &index, int role) const override;
0086     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0087 
0088 private slots:
0089     void epgChannelAdded(const DvbSharedChannel &channel);
0090     void epgChannelRemoved(const DvbSharedChannel &channel);
0091 };
0092 
0093 class DvbEpgTableModelHelper
0094 {
0095 public:
0096     DvbEpgTableModelHelper() : filterType(ChannelFilter) { }
0097     ~DvbEpgTableModelHelper() { }
0098 
0099     typedef DvbSharedEpgEntry ItemType;
0100     typedef DvbEpgEntryLessThan LessThanType;
0101 
0102     enum FilterType {
0103         ChannelFilter,
0104         ContentFilter
0105     };
0106 
0107     int columnCount() const
0108     {
0109         return 4;
0110     }
0111 
0112     bool filterAcceptsItem(const DvbSharedEpgEntry &epgEntry) const;
0113 
0114     DvbSharedChannel channelFilter;
0115     QStringMatcher contentFilter;
0116     FilterType filterType;
0117 
0118 private:
0119     Q_DISABLE_COPY(DvbEpgTableModelHelper)
0120 };
0121 
0122 class DvbEpgTableModel : public TableModel<DvbEpgTableModelHelper>
0123 {
0124     Q_OBJECT
0125 public:
0126     explicit DvbEpgTableModel(QObject *parent);
0127     ~DvbEpgTableModel();
0128 
0129     void setEpgModel(DvbEpgModel *epgModel_);
0130     void setChannelFilter(const DvbSharedChannel &channel);
0131     void setLanguage(QString lang);
0132 
0133     QVariant data(const QModelIndex &index, int role) const override;
0134     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0135 
0136 public slots:
0137     void setContentFilter(const QString &pattern);
0138 
0139 private slots:
0140     void entryAdded(const DvbSharedEpgEntry &entry);
0141     void entryAboutToBeUpdated(const DvbSharedEpgEntry &entry);
0142     void entryUpdated(const DvbSharedEpgEntry &entry);
0143     void entryRemoved(const DvbSharedEpgEntry &entry);
0144 
0145 private:
0146     void customEvent(QEvent *event) override;
0147 
0148     DvbEpgModel *epgModel;
0149     bool contentFilterEventPending;
0150     QString currentLanguage;
0151 };
0152 
0153 #endif /* DVBEPGDIALOG_P_H */