[mythtv] [PATCH] Movie filter in progfinder

Joel Feenstra joelf at altelco.net
Thu Apr 10 20:20:29 EDT 2003


This patch will allow you to press 'm' while in the progfinder which 
will then show only movies. Pressing 'm' again should switch it back to 
the normal view. This is my first patch, so comments are welcome.

Joel Feenstra
-------------- next part --------------
? moviefilter.diff
Index: libs/libmythtv/progfind.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/progfind.cpp,v
retrieving revision 1.21
diff -u -w -r1.21 progfind.cpp
--- libs/libmythtv/progfind.cpp	8 Apr 2003 17:45:51 -0000	1.21
+++ libs/libmythtv/progfind.cpp	10 Apr 2003 23:14:56 -0000
@@ -76,6 +76,7 @@
     accel->connectItem(accel->insertItem(Key_9), this, SLOT(pageDown()));
     accel->connectItem(accel->insertItem(Key_I), this, SLOT(getInfo()));
     accel->connectItem(accel->insertItem(Key_4), this, SLOT(showGuide()));
+    accel->connectItem(accel->insertItem(Key_M), this, SLOT(showMoviesSwitch()));
     accel->connectItem(accel->insertItem(Key_Escape), this, SLOT(escape()));
     connect(this, SIGNAL(killTheApp()), this, SLOT(accept()));
 
@@ -113,6 +114,7 @@
     pastInitial = false;
     searchCount = 36;
     recordingCount = 0;
+    showMoviesOnly = false;
 
     initData = new QString[(int)(searchCount*showsPerListing)];
     gotInitData = new int[searchCount];
@@ -538,6 +540,65 @@
 }
 
 
+void ProgFinder::showMoviesSwitch()
+{
+    if (showMoviesOnly)
+        showMoviesOnly = false;
+    else
+        showMoviesOnly = true;
+
+    while (inSearch > 0)
+    {
+        if (inSearch == 1)
+            showSearchList();
+        else if (inSearch == 2)
+        {
+            showProgramList();
+            clearShowData();
+        }
+        inSearch--;
+    }
+
+    delete [] searchData;
+    delete [] initData; 
+
+    delete [] gotInitData;
+
+
+    curSearch = 10;
+    progData = new QString[1];
+    listCount = 1;
+    if (showsPerListing < 1)
+        showsPerListing = 7;
+    if (showsPerListing % 2 == 0)
+	showsPerListing = showsPerListing + 1;
+
+    inSearch = 0;
+    pastInitial = false;
+    searchCount = 36;
+    recordingCount = 0;
+    
+    initData = new QString[(int)(searchCount*showsPerListing)];
+    gotInitData = new int[searchCount];
+    searchData = new QString[searchCount];
+    int curLabel = 0;
+
+    for (int charNum = 48; charNum < 91; charNum++)
+    {
+        if (charNum == 58)
+        	charNum = 65;
+
+        gotInitData[curLabel] = 0; 
+        searchData[curLabel] = (char)charNum;
+
+    	curLabel++;
+    }
+
+    getSearchData(10);
+    getInitialProgramData();
+}
+
+
 void ProgFinder::cursorLeft()
 {
     inSearch--;
@@ -557,6 +618,7 @@
     update(listRect());
 }
 
+
 void ProgFinder::cursorRight()
 {
     if (inSearch == 2) {
@@ -949,6 +1011,24 @@
     QString thequery;
     QString data;
 
+    if (showMoviesOnly) 	/* filter out normal shows based on number of stars and length and category*/
+    {
+        thequery = QString("SELECT DISTINCT title "
+                           "FROM program "
+                           "WHERE (title LIKE '%1%' OR title LIKE 'The %2%' OR title LIKE 'A %3%') "
+                           "AND starttime > %4 AND (stars > 0 OR "
+                           "(endtime - starttime >= 13000 AND (category LIKE 'Drama' OR category LIKE 'Mystery' "
+                           "OR category LIKE 'Musical' OR category LIKE 'Action' OR category LIKE 'Comedy' "
+                           "OR category LIKE 'War' OR category LIKE 'Romance' OR category LIKE 'Crime' "
+                           "OR category LIKE 'SciFi' OR category LIKE 'Horror'))) "
+                           "ORDER BY title;")
+                            .arg(searchData[curSearch])
+                            .arg(searchData[curSearch])
+                            .arg(searchData[curSearch])
+                            .arg(progStart.toString("yyyyMMddhhmm50"));
+    }
+    else
+    {
     thequery = QString("SELECT DISTINCT title "
                        "FROM program "
                        "WHERE title LIKE '%1%' OR title LIKE 'The %2%' OR title LIKE 'A %3%' "
@@ -958,6 +1038,7 @@
 			.arg(searchData[curSearch])
 			.arg(searchData[curSearch])
 			.arg(progStart.toString("yyyyMMddhhmm50"));
+    }
 
     QSqlQuery query = m_db->exec(thequery);
  
@@ -1375,6 +1456,24 @@
     QString thequery;
     QString data;
 
+    if (showMoviesOnly) 	/* filter out normal shows based on number of stars and length */
+    {
+        thequery = QString("SELECT DISTINCT title "
+                           "FROM program "
+                           "WHERE (title LIKE '%1%' OR title LIKE 'The %2%' OR title LIKE 'A %3%') "
+                           "AND starttime > %4 AND (stars > 0 OR "
+                           "(endtime - starttime >= 13000 AND (category LIKE 'Drama' OR category LIKE 'Mystery' "
+                           "OR category LIKE 'Musical' OR category LIKE 'Action' OR category LIKE 'Comedy' "
+                           "OR category LIKE 'War' OR category LIKE 'Romance' OR category LIKE 'Crime' "
+                           "OR category LIKE 'SciFi' OR category LIKE 'Horror'))) "
+                           "ORDER BY title;")
+                            .arg(searchData[charNum])
+                            .arg(searchData[charNum])
+                            .arg(searchData[charNum])
+                            .arg(progStart.toString("yyyyMMddhhmm50"));
+    }
+    else
+    {
     thequery = QString("SELECT DISTINCT title "
                        "FROM program "
                        "WHERE title LIKE '%1%' OR title LIKE 'The %2%' OR title LIKE 'A %3%' "
@@ -1384,6 +1483,7 @@
 			.arg(searchData[charNum])
 			.arg(searchData[charNum])
 			.arg(progStart.toString("yyyyMMddhhmm50"));
+    }
 
     QSqlQuery query = m_db->exec(thequery);
 
Index: libs/libmythtv/progfind.h
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/progfind.h,v
retrieving revision 1.7
diff -u -w -r1.7 progfind.h
--- libs/libmythtv/progfind.h	8 Apr 2003 17:45:52 -0000	1.7
+++ libs/libmythtv/progfind.h	10 Apr 2003 23:14:56 -0000
@@ -79,6 +79,7 @@
     void showGuide();
     void pageUp();
     void pageDown();
+    void showMoviesSwitch();
 
   protected:
     void paintEvent(QPaintEvent *);
@@ -106,6 +107,7 @@
     bool showInfo;
     bool pastInitial;
     bool running;
+    bool showMoviesOnly;
     int *gotInitData;
 
     QTimer *update_Timer;


More information about the mythtv-dev mailing list