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

0001 /*
0002  * dvbrecordingdialog_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 DVBRECORDINGDIALOG_P_H
0022 #define DVBRECORDINGDIALOG_P_H
0023 
0024 #include <QDialog>
0025 #include "../tablemodel.h"
0026 #include "dvbrecording.h"
0027 
0028 class QCheckBox;
0029 class QComboBox;
0030 class QLineEdit;
0031 class DateTimeEdit;
0032 class DurationEdit;
0033 class QDialogButtonBox;
0034 
0035 class DvbRecordingLessThan
0036 {
0037 public:
0038     DvbRecordingLessThan()
0039     {
0040         // specify each column exactly once
0041         sortOrder[0] = BeginAscending;
0042         sortOrder[1] = ChannelAscending;
0043         sortOrder[2] = NameAscending;
0044         sortOrder[3] = DurationAscending;
0045     }
0046 
0047     ~DvbRecordingLessThan() { }
0048 
0049     enum SortOrder
0050     {
0051         NameAscending = 0,
0052         NameDescending = 1,
0053         ChannelAscending = 2,
0054         ChannelDescending = 3,
0055         BeginAscending = 4,
0056         BeginDescending = 5,
0057         DurationAscending = 6,
0058         DurationDescending = 7
0059     };
0060 
0061     SortOrder getSortOrder() const
0062     {
0063         return sortOrder[0];
0064     }
0065 
0066     void setSortOrder(SortOrder sortOrder_);
0067 
0068     bool operator()(const DvbSharedRecording &x, const DvbSharedRecording &y) const;
0069 
0070 private:
0071     SortOrder sortOrder[4];
0072 };
0073 
0074 class DvbRecordingTableModelHelper
0075 {
0076 public:
0077     DvbRecordingTableModelHelper() { }
0078     ~DvbRecordingTableModelHelper() { }
0079 
0080     typedef DvbSharedRecording ItemType;
0081     typedef DvbRecordingLessThan LessThanType;
0082 
0083     int columnCount() const
0084     {
0085         return 5;
0086     }
0087 
0088     bool filterAcceptsItem(const DvbSharedRecording &recording) const
0089     {
0090         Q_UNUSED(recording)
0091         return true;
0092     }
0093 };
0094 
0095 class DvbRecordingTableModel : public TableModel<DvbRecordingTableModelHelper>
0096 {
0097     Q_OBJECT
0098 public:
0099     explicit DvbRecordingTableModel(QObject *parent);
0100     ~DvbRecordingTableModel();
0101 
0102     void setRecordingModel(DvbRecordingModel *recordingModel_);
0103 
0104     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0105     QVariant data(const QModelIndex &index, int role) const override;
0106     void sort(int column, Qt::SortOrder order) override;
0107 
0108 private slots:
0109     void recordingAdded(const DvbSharedRecording &recording);
0110     void recordingAboutToBeUpdated(const DvbSharedRecording &recording);
0111     void recordingUpdated(const DvbSharedRecording &recording);
0112     void recordingRemoved(const DvbSharedRecording &recording);
0113 
0114 private:
0115     DvbRecordingModel *recordingModel;
0116 };
0117 
0118 class DvbRecordingEditor : public QDialog
0119 {
0120     Q_OBJECT
0121 public:
0122     DvbRecordingEditor(DvbManager *manager_, const DvbSharedRecording &recording_,
0123         QWidget *parent);
0124     ~DvbRecordingEditor();
0125 
0126 private slots:
0127     void beginChanged(const QDateTime &begin);
0128     void durationChanged(const QTime &duration);
0129     void endChanged(const QDateTime &end);
0130     void repeatNever();
0131     void repeatDaily();
0132     void checkValidity();
0133 
0134 private:
0135     void accept() override;
0136 
0137     DvbManager *manager;
0138     DvbSharedRecording recording;
0139     QLineEdit *nameEdit;
0140     QComboBox *channelBox;
0141     DateTimeEdit *beginEdit;
0142     DurationEdit *durationEdit;
0143     DateTimeEdit *endEdit;
0144     QCheckBox *dayCheckBoxes[7];
0145     QDialogButtonBox *buttonBox;
0146 };
0147 
0148 #endif /* DVBRECORDINGDIALOG_P_H */