[mythtv] [PATCH] add 'category' column to 'record', 'recorded', and 'oldrecorded' tables

Kirby Vandivort kvandivo at ks.uiuc.edu
Fri Jun 27 11:15:26 EDT 2003


One thing that i had missed in the update below..  
libs/libmyth/mythcontext.h  needs to have the MYTH_SCHEMA_VERSION rev'd
to 902 also.

On Fri, Jun 27, 2003 at 09:59:49AM -0500, Kirby Vandivort wrote:
> This patch adds the category column to the 'record', 'recorded' and
> 'oldrecorded' tables in the database.  This will be handy in the future
> for sorting lists, auto-recommendations, and other things that haven't
> been thought about yet.
> 
> This should be extended to other fields also;  I had started doing the
> category_type column, but some of the low level data structures don't
> have fields for category_type yet, and I didn't want to delve that deep
> into the code on my first pass.
> 
> Enjoy.
> 
> -- 
> 
> Kirby Vandivort                      Theoretical and Computational Biophysics 
> Email: kvandivo at ks.uiuc.edu          3051 Beckman Institute
> http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
> Phone: (217) 244-5711                405 N. Mathews Ave
> Fax  : (217) 244-6078                Urbana, IL  61801, USA

> Index: database/cvs.sql
> ===================================================================
> RCS file: /var/lib/mythcvs/mythtv/database/cvs.sql,v
> retrieving revision 1.31
> diff -b -u -2 -r1.31 cvs.sql
> --- database/cvs.sql	19 Jun 2003 06:34:27 -0000	1.31
> +++ database/cvs.sql	27 Jun 2003 14:54:22 -0000
> @@ -8,5 +8,5 @@
>  
>  DELETE FROM settings WHERE value='DBSchemaVer';
> -INSERT INTO settings VALUES ('DBSchemaVer', 901, NULL);
> +INSERT INTO settings VALUES ('DBSchemaVer', 902, NULL);
>  
>  #
> @@ -15,4 +15,8 @@
>  #   when a previously executed command is encountered.
>  #
> +
> +ALTER TABLE record ADD COLUMN category VARCHAR(64) NULL;
> +ALTER TABLE recorded ADD COLUMN category VARCHAR(64) NULL;
> +ALTER TABLE oldrecorded ADD COLUMN category VARCHAR(64) NULL;
>  
>  ALTER TABLE program ADD COLUMN category_type VARCHAR(64) NULL;
> Index: libs/libmythtv/programinfo.cpp
> ===================================================================
> RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
> retrieving revision 1.57
> diff -b -u -2 -r1.57 programinfo.cpp
> --- libs/libmythtv/programinfo.cpp	24 Jun 2003 04:16:36 -0000	1.57
> +++ libs/libmythtv/programinfo.cpp	27 Jun 2003 14:54:48 -0000
> @@ -595,16 +595,19 @@
>      QString sqlsubtitle = subtitle;
>      QString sqldescription = description;
> +    QString sqlcategory = category;
>  
>      sqltitle.replace(QRegExp("\""), QString("\\\""));
>      sqlsubtitle.replace(QRegExp("\""), QString("\\\""));
>      sqldescription.replace(QRegExp("\""), QString("\\\""));
> +    sqlcategory.replace(QRegExp("\""), QString("\\\""));
>  
>      QString query;
>      query = QString("INSERT INTO recorded (chanid,starttime,endtime,title,"
> -                    "subtitle,description,hostname) "
> -                    "VALUES(%1,\"%2\",\"%3\",\"%4\",\"%5\",\"%6\",\"%7\");")
> +                    "subtitle,description,hostname,category) "
> +                    "VALUES(%1,\"%2\",\"%3\",\"%4\",\"%5\",\"%6\",\"%7\",\"%8\");")
>                      .arg(chanid).arg(starts).arg(ends).arg(sqltitle.utf8()) 
>                      .arg(sqlsubtitle.utf8()).arg(sqldescription.utf8())
> -                    .arg(gContext->GetHostName());
> +                    .arg(gContext->GetHostName())
> +                    .arg(sqlcategory.utf8());
>  
>      QSqlQuery qquery = db->exec(query);
> Index: libs/libmythtv/scheduledrecording.cpp
> ===================================================================
> RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.cpp,v
> retrieving revision 1.28
> diff -b -u -2 -r1.28 scheduledrecording.cpp
> --- libs/libmythtv/scheduledrecording.cpp	19 Jun 2003 02:20:42 -0000	1.28
> +++ libs/libmythtv/scheduledrecording.cpp	27 Jun 2003 14:54:49 -0000
> @@ -135,4 +135,12 @@
>  };
>  
> +class SRCategory: public LineEditSetting, public SRSetting {
> +public:
> +    SRCategory(const ScheduledRecording& parent):
> +        SRSetting(parent, "category") {
> +        setVisible(false);
> +    };
> +};
> +
>  ScheduledRecording::ScheduledRecording() {
>      addChild(id = new ID());
> @@ -147,4 +155,5 @@
>      addChild(startDate = new SRStartDate(*this));
>      addChild(endDate = new SREndDate(*this));
> +    addChild(category = new SRCategory(*this));
>  
>      m_pginfo = NULL;
> @@ -161,4 +170,5 @@
>      endTime->setValue(proginfo->endts.time());
>      endDate->setValue(proginfo->endts.date());
> +    category->setValue(proginfo->category);
>  }
>  
> @@ -170,5 +180,5 @@
>  "program.title, program.subtitle, program.description, "
>  "channel.channum, channel.callsign, channel.name, "
> -"oldrecorded.starttime IS NOT NULL AS duplicate "
> +"oldrecorded.starttime IS NOT NULL AS duplicate, program.category "
>  "FROM record "
>  " INNER JOIN channel ON (channel.chanid = program.chanid) "
> @@ -233,4 +243,5 @@
>               proginfo->channame = result.value(9).toString();
>               proginfo->duplicate = result.value(10).toInt();
> +             proginfo->category = QString::fromUtf8(result.value(11).toString());
>  
>               // would save many queries to create and populate a
> @@ -245,4 +256,6 @@
>               if (proginfo->description == QString::null)
>                   proginfo->description = "";
> +             if (proginfo->category == QString::null)
> +                 proginfo->category = "";
>  
>               if (proginfo->endts < now)
> @@ -416,12 +429,14 @@
>      QString sqlsubtitle = proginfo.subtitle;
>      QString sqldescription = proginfo.description;
> +    QString sqlcategory = proginfo.category;
>  
>      sqltitle.replace(QRegExp("\""), QString("\\\""));
>      sqlsubtitle.replace(QRegExp("\""), QString("\\\""));
>      sqldescription.replace(QRegExp("\""), QString("\\\""));
> +    sqlcategory.replace(QRegExp("\""), QString("\\\""));
>  
>      QString query = QString("INSERT INTO oldrecorded (chanid,starttime,endtime,title,"
> -                            "subtitle,description) "
> -                            "VALUES(%1,\"%2\",\"%3\",\"%4\",\"%5\",\"%6\");")
> +                            "subtitle,description,category) "
> +                            "VALUES(%1,\"%2\",\"%3\",\"%4\",\"%5\",\"%6\",\"%7\");")
>          .arg(proginfo.chanid)
>          .arg(proginfo.startts.toString(Qt::ISODate))
> @@ -429,5 +444,6 @@
>          .arg(sqltitle.utf8()) 
>          .arg(sqlsubtitle.utf8())
> -        .arg(sqldescription.utf8());
> +        .arg(sqldescription.utf8())
> +        .arg(sqlcategory.utf8());
>  
>      QSqlQuery result = db->exec(query);
> Index: libs/libmythtv/scheduledrecording.h
> ===================================================================
> RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.h,v
> retrieving revision 1.8
> diff -b -u -2 -r1.8 scheduledrecording.h
> --- libs/libmythtv/scheduledrecording.h	18 Jun 2003 23:43:41 -0000	1.8
> +++ libs/libmythtv/scheduledrecording.h	27 Jun 2003 14:54:50 -0000
> @@ -83,4 +83,5 @@
>      class SREndTime* endTime;
>      class SREndDate* endDate;
> +    class SRCategory* category;
>  
>      ProgramInfo* m_pginfo;

> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at snowman.net
> http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-dev


-- 

Kirby Vandivort                      Theoretical and Computational Biophysics 
Email: kvandivo at ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA


More information about the mythtv-dev mailing list