[mythtv] [PATCH] Program Finder starts-with-punctuation support

Corey Mutter mutterc at nc.rr.com
Thu Jan 22 09:44:57 EST 2004


I have a patch against MythTV 0.13.

The wife noticed that '$40-A-Day' didn't show up in the Program Finder. 

This patch adds a 37'th choice: '@', which will show all programs that
begin with a non-alphanumeric character. It uses the MySQL-specific
REGEXP query comparison operator.

I experimented with using 'Other' instead of '@', which is just a 
matter of changing the string assigned to searchData. However, the
screen layout would need to be reworked to allow for the longer string, 
and I couldn't figure out how.

(This patch also reveals '.Hack/Sign' and something starting with 
one of those upside-down exclamation marks, in my guide). 

Corey

diff -ur mythtv-0.13/libs/libmythtv/progfind.cpp mythtv/libs/libmythtv/progfind.cpp
--- mythtv-0.13/libs/libmythtv/progfind.cpp	2004-01-22 09:34:36.000000000 -0500
+++ mythtv/libs/libmythtv/progfind.cpp	2004-01-22 09:34:21.000000000 -0500
@@ -101,7 +101,7 @@
 
     inSearch = 0;
     pastInitial = false;
-    searchCount = 36;
+    searchCount = 37;
     recordingCount = 0;
 
     initData = new QString[(int)(searchCount*showsPerListing)];
@@ -118,6 +118,8 @@
         searchData[curLabel] = (char)charNum;
         curLabel++;
     }
+    gotInitData[curLabel] = 0;
+    searchData[curLabel] = '@';
 
     update_Timer = new QTimer(this);
     connect(update_Timer, SIGNAL(timeout()), SLOT(update_timeout()) );
@@ -980,17 +982,25 @@
     QString thequery;
     QString data;
 
-    thequery = QString("SELECT DISTINCT title "
-                       "FROM program "
-                       "WHERE ( title LIKE '%1%' OR title LIKE 'The %2%' "
-                       "OR title LIKE 'A %3%' ) "
-                       "AND starttime > %4 "
-                       "ORDER BY title;")
-                        .arg(searchData[curSearch])
-                        .arg(searchData[curSearch])
-                        .arg(searchData[curSearch])
-                        .arg(progStart.toString("yyyyMMddhhmm50"));
-
+    if (searchData[curSearch].contains('@')) {
+      thequery = QString("SELECT DISTINCT title FROM program WHERE ( "
+			 "title NOT REGEXP '^[A-Z0-9]' AND "
+			 "title NOT REGEXP '^The [A-Z0-9]' AND "
+			 "title NOT REGEXP '^A [A-Z0-9]' AND "
+			 "starttime > %1 ) ORDER BY title;")
+	.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%' ) "
+			 "AND starttime > %4 "
+			 "ORDER BY title;")
+	.arg(searchData[curSearch])
+	.arg(searchData[curSearch])
+	.arg(searchData[curSearch])
+	.arg(progStart.toString("yyyyMMddhhmm50"));
+    }
     QSqlQuery query = m_db->exec(thequery);
  
     int rows = query.numRowsAffected();
@@ -1411,18 +1421,25 @@
     QDateTime progStart = QDateTime::currentDateTime();
     QString thequery;
     QString data;
-
-    thequery = QString("SELECT DISTINCT title "
-                       "FROM program "
-                       "WHERE ( title LIKE '%1%' OR title LIKE 'The %2%' OR "
-                       "title LIKE 'A %3%' ) "
-                       "AND starttime > %4 "
-                       "ORDER BY title;")
+    if (searchData[charNum].contains('@')) {
+      thequery = QString("SELECT DISTINCT title FROM program WHERE ( "
+			 "title NOT REGEXP '^[A-Z0-9]' AND "
+			 "title NOT REGEXP '^The [A-Z0-9]' AND "
+			 "title NOT REGEXP '^A [A-Z0-9]' AND "
+			 "starttime > %1 ) ORDER BY title;")
+	.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%' ) "
+			 "AND starttime > %4 "
+			 "ORDER BY title;")
                        .arg(searchData[charNum])
                        .arg(searchData[charNum])
                        .arg(searchData[charNum])
                        .arg(progStart.toString("yyyyMMddhhmm50"));
-
+    }
     QSqlQuery query = m_db->exec(thequery);
 
     int rows = query.numRowsAffected();
@@ -1537,4 +1554,3 @@
     if (charNum == curSearch)
         showSearchList();
 }
-

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040122/051ec403/attachment.pgp


More information about the mythtv-dev mailing list