[mythtv] [patch] setup improvements

Daniel Thor Kristjansson danielk at mrl.nyu.edu
Fri Jan 21 13:52:17 EST 2005


On Fri, 21 Jan 2005, Isaac Richards wrote:
]On Tuesday 18 January 2005 10:25 am, Daniel Thor Kristjansson wrote:
]>    * Two new configuration groups are added. MPEGConfigurationGroup
]>      and pcHDTVConfigurationGroup, these remove configration entries
]>      which have no meaning for these cards, such as the VBI and audio
]>      capture devices. These confuse new users, and are not needed.
]The only thing I'm not sure of about this is if there's some parts of the 
]source that assume that these config entries are filled with something, and 
]are not null..  Could you verify that that's not true, please?

Both HDTVRecorder and MPEGRecorder ignore the vbi and audio devices.
NuppelVideoplayer would break if it saw null strings. But tvrec protects 
it by setting null strings in the database to empty strings when it 
queries the database in the GetDevices call. But this doesn't matter 
in this case since the cardtype will be either "HDTV" or "MPEG".

I've attached an updated version that fixes some formatting.

-- Daniel
-------------- next part --------------
Index: libs/libmyth/settings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/settings.cpp,v
retrieving revision 1.84
diff -u -r1.84 settings.cpp
--- libs/libmyth/settings.cpp	29 May 2004 18:30:43 -0000	1.84
+++ libs/libmyth/settings.cpp	21 Jan 2005 18:39:14 -0000
@@ -630,6 +630,10 @@
                 accept();
             else if (action == "ESCAPE")
                 reject();
+            else if (action == "EDIT")
+                emit editButtonPressed();
+            else if (action == "DELETE")
+                emit deleteButtonPressed();
             else
                 handled = false;
         }
Index: libs/libmyth/settings.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/settings.h,v
retrieving revision 1.55
diff -u -r1.55 settings.h
--- libs/libmyth/settings.h	29 May 2004 18:30:44 -0000	1.55
+++ libs/libmyth/settings.h	21 Jan 2005 18:39:15 -0000
@@ -169,12 +169,17 @@
 };
 
 class ConfigurationDialogWidget: public MythDialog {
+    Q_OBJECT
 public:
     ConfigurationDialogWidget(MythMainWindow *parent, 
                               const char* widgetName = 0):
         MythDialog(parent, widgetName) {};
 
     virtual void keyPressEvent(QKeyEvent* e);
+
+signals:
+    void editButtonPressed();
+    void deleteButtonPressed();
 };
 
 class ConfigurationDialog: virtual public Configurable {
Index: libs/libmythtv/videosource.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videosource.cpp,v
retrieving revision 1.54
diff -u -r1.54 videosource.cpp
--- libs/libmythtv/videosource.cpp	21 Jan 2005 06:39:38 -0000	1.54
+++ libs/libmythtv/videosource.cpp	21 Jan 2005 18:39:16 -0000
@@ -8,6 +8,7 @@
 #include <qcursor.h>
 #include <qlayout.h>
 #include <qfile.h>
+#include <qmap.h>
 #include <iostream>
 
 #ifdef USING_DVB
@@ -476,19 +477,75 @@
 
 class VideoDevice: public PathSetting, public CCSetting {
 public:
-    VideoDevice(const CaptureCard& parent):
-        PathSetting(true),
-        CCSetting(parent, "videodevice") {
+    VideoDevice(const CaptureCard& parent,
+                uint minor_min=0, uint minor_max=UINT_MAX):
+        PathSetting(true), CCSetting(parent, "videodevice")
+    {
         setLabel(QObject::tr("Video device"));
-        QDir dev("/dev", "video*", QDir::Name, QDir::System);
-        fillSelectionsFromDir(dev);
-        dev.setPath("/dev/v4l");
-        fillSelectionsFromDir(dev);
+
+        // /dev/v4l/video*
+        QDir dev("/dev/v4l", "video*", QDir::Name, QDir::System);
+        fillSelectionsFromDir(dev, minor_min, minor_max, false);
+
+        // /dev/video*
+        dev.setPath("/dev");
+        fillSelectionsFromDir(dev, minor_min, minor_max, false);
+
+        // /dev/dtv/video*
         dev.setPath("/dev/dtv");
-        fillSelectionsFromDir(dev);
+        fillSelectionsFromDir(dev, minor_min, minor_max, false);
+
+        // /dev/dtv*
+        dev.setPath("/dev");
+        dev.setNameFilter("dtv*");
+        fillSelectionsFromDir(dev, minor_min, minor_max, false);
+
+        VERBOSE(VB_IMPORTANT, "");
     };
 
+    void fillSelectionsFromDir(const QDir& dir,
+                               uint minor_min, uint minor_max,
+                               bool allow_duplicates)
+    {
+        const QFileInfoList *il = dir.entryInfoList();
+        if (!il)
+            return;
+        
+        QFileInfoListIterator it( *il );
+        QFileInfo *fi;
+        
+        for(; (fi = it.current()) != 0; ++it)
+        {
+            struct stat st;
+            QString filepath = fi->absFilePath();
+            int err = lstat(filepath, &st);
+            if (0==err)
+            {
+                if (S_ISCHR(st.st_mode))
+                {
+                    uint minor_num = minor(st.st_rdev);
+                    // this is a character device, if in minor range to list
+                    if (minor_min<=minor_num && 
+                        minor_max>=minor_num &&
+                        (allow_duplicates ||
+                         (minor_list.find(minor_num)==minor_list.end())))
+                    {
+                        addSelection(filepath);
+                        minor_list[minor_num]=1;
+                    }
+                }
+            }
+            else
+            {
+                VERBOSE(VB_IMPORTANT,
+                        QString("Could not stat file: %1").arg(filepath));
+            }
+        }
+    }
+
     static QStringList probeInputs(QString device);
+private:
+    QMap<uint, uint> minor_list;
 };
 
 class VbiDevice: public PathSetting, public CCSetting {
@@ -736,6 +793,51 @@
     CaptureCard& parent;
 };
 
+class MPEGConfigurationGroup: public VerticalConfigurationGroup
+{
+  public:
+    MPEGConfigurationGroup(CaptureCard& a_parent):
+        parent(a_parent)
+    {
+        setUseLabel(false);
+
+        VideoDevice* device;
+        TunerCardInput* input;
+
+        addChild(device = new VideoDevice(parent, 0, 15));
+        addChild(input = new TunerCardInput(parent));
+        connect(device, SIGNAL(valueChanged(const QString&)),
+                input, SLOT(fillSelections(const QString&)));
+        input->fillSelections(device->getValue());
+    };
+  private:
+    CaptureCard& parent;
+};
+
+class pcHDTVConfigurationGroup: public VerticalConfigurationGroup
+{
+  public:
+    pcHDTVConfigurationGroup(CaptureCard& a_parent): 
+        parent(a_parent)
+    {
+        setUseLabel(false);
+
+        VerticalConfigurationGroup *atsc = 
+            new VerticalConfigurationGroup(true, true);
+        atsc->setLabel(tr("ATSC (Digital Television)"));
+        VideoDevice *atsc_device = new VideoDevice(parent, 32);
+        TunerCardInput *atsc_input = new TunerCardInput(parent);
+        atsc->addChild(atsc_device);
+        atsc->addChild(atsc_input);
+        addChild(atsc);
+        connect(atsc_device, SIGNAL(valueChanged(const QString&)),
+                atsc_input, SLOT(fillSelections(const QString&)));
+        atsc_input->fillSelections(atsc_device->getValue());
+    };
+  private:
+    CaptureCard& parent;
+};
+
 CaptureCardGroup::CaptureCardGroup(CaptureCard& parent)
 {
     setLabel(QObject::tr("Capture Card Setup"));
@@ -747,13 +849,13 @@
 
     addTarget("V4L", new V4LConfigurationGroup(parent));
     addTarget("DVB", new DVBConfigurationGroup(parent));
+    addTarget("HDTV", new pcHDTVConfigurationGroup(parent));
+    addTarget("MPEG", new MPEGConfigurationGroup(parent));
 }
 
 void CaptureCardGroup::triggerChanged(const QString& value) 
 {
-    QString own = value;
-    if (own == "HDTV" || own == "MPEG" || own == "MJPEG")
-        own = "V4L";
+    QString own = (value == "MJPEG") ? "V4L" : value;
     TriggeredConfigurationGroup::triggerChanged(own);
 }
 
@@ -1027,6 +1129,8 @@
 {
     dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
     connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(menu()));
+    connect(dialog, SIGNAL(editButtonPressed()), this, SLOT(edit()));
+    connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(del()));
     return dialog;
 }
 
@@ -1088,6 +1192,8 @@
 {
     dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
     connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(menu()));
+    connect(dialog, SIGNAL(editButtonPressed()), this, SLOT(edit()));
+    connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(del()));
     return dialog;
 }
 
Index: setup/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/setup/main.cpp,v
retrieving revision 1.50
diff -u -r1.50 main.cpp
--- setup/main.cpp	1 Jan 2005 22:46:53 -0000	1.50
+++ setup/main.cpp	21 Jan 2005 18:39:16 -0000
@@ -161,6 +161,9 @@
     if (dboxProg.exec() == 2)
         clearAllDB();
 
+    REG_KEY("qt", "DELETE", "Delete", "D");
+    REG_KEY("qt", "EDIT", "Edit", "E");
+
     SetupMenu();
 
     cout << "If this is the master backend server:\n";


More information about the mythtv-dev mailing list