Ticket #96: mythvideo.parental_level.diff

File mythvideo.parental_level.diff, 7.4 KB (added by Robert Tsai <rtsai1111>, 16 years ago)
  • mythvideo/videofilter.h

     
    2424        VideoFilterSettings(VideoFilterSettings *other);
    2525        ~VideoFilterSettings();
    2626        QString BuildClauseFrom();
    27         QString BuildClauseWhere();
     27        QString BuildClauseWhere(int parental_level);
    2828        QString BuildClauseOrderBy();
    2929        void saveAsDefault();
    3030
     
    8787    void keyPressEvent(QKeyEvent *e);
    8888    void wireUpTheme();
    8989    void fillWidgets();
    90 //    QString BuildClauseFrom();
    91 //    QString BuildClauseWhere();
    9290
    9391  public slots:
    9492 
  • mythvideo/videomanager.cpp

     
    192192
    193193    QString thequery = QString("SELECT intid FROM %1 %2 %3")
    194194                               .arg(currentVideoFilter->BuildClauseFrom())
    195                                .arg(currentVideoFilter->BuildClauseWhere())
     195                               .arg(currentVideoFilter->BuildClauseWhere(0))
    196196                               .arg(currentVideoFilter->BuildClauseOrderBy());
    197197    MSqlQuery query(MSqlQuery::InitCon());
    198198    query.exec(thequery);
  • mythvideo/videolist.cpp

     
    108108
    109109    QString thequery = QString("SELECT intid FROM %1 %2 %3")
    110110                    .arg(currentVideoFilter->BuildClauseFrom())
    111                     .arg(currentVideoFilter->BuildClauseWhere())
     111                    .arg(currentVideoFilter->BuildClauseWhere(parental_level))
    112112                    .arg(currentVideoFilter->BuildClauseOrderBy());
    113113       
    114114    MSqlQuery query(MSqlQuery::InitCon());
     
    135135        (void)addDirNode(video_tree_root, "videos");
    136136
    137137    //
    138     //  Accumulate query results into the metaptrs list. The "parental_level"
    139     //  filtering really ought to be incorporated into BuildClauseWhere().
     138    //  Accumulate query results into the metaptrs list.
    140139    //
    141140    QPtrList<Metadata> metaptrs;
    142141    while (query.next())
     
    145144        Metadata *myData = new Metadata();
    146145        myData->setID(intid);
    147146        myData->fillDataFromID();
    148         if (myData->ShowLevel() <= parental_level && myData->ShowLevel() != 0)
    149             metaptrs.append(myData);
    150         else
    151             delete myData;
     147        metaptrs.append(myData);
    152148    }
    153149
    154150    //
  • mythvideo/videofilter.cpp

     
    132132    return from;
    133133}
    134134
    135 QString VideoFilterSettings::BuildClauseWhere()
     135QString VideoFilterSettings::BuildClauseWhere(int parental_level)
    136136{
    137     QString where = NULL;
    138     if (genre!=-1)
     137    QString where = "WHERE 1";
     138    QString condition;
     139
     140    if (genre != -1)
    139141    {
    140         QString condition;
    141         if (genre ==0 )
    142             condition = QString(" IS NULL");
    143         else
    144             condition = QString(" = %1").arg(genre);
    145         where = QString(" WHERE videometadatagenre.idgenre %1 ").arg(condition);
     142        condition = genre ? QString("= %1").arg(genre) : QString("IS NULL");
     143        where = QString(" AND videometadatagenre.idgenre %1").arg(condition);
    146144    }
    147145   
    148     if (country!=-1)
     146    if (country != -1)
    149147    {
    150         QString condition;
    151         if (country==0)
    152             condition = QString(" IS NULL");
    153         else
    154             condition = QString(" = %1").arg(country);
    155        
    156         if (where)
    157             where +=  QString(" AND videometadatacountry.idcountry %1 ").arg(condition);
    158         else
    159             where = QString(" WHERE videometadatacountry.idcountry %1 ").arg(condition);
     148        condition = country ? QString("= %1").arg(country) : QString("IS NULL");
     149        where += QString(" AND videometadatacountry.idcountry %1")
     150                                .arg(condition);
    160151    }
    161152   
    162153    if (category != -1)
    163     {
    164         if (where)
    165             where += QString(" AND category = %1").arg(category);
    166         else
    167             where = QString(" WHERE category = %1").arg(category);
    168     }
     154        where += QString(" AND category = %1").arg(category);
    169155   
    170     if (year!=-1)
    171     {
    172         if (where)
    173             where += QString(" AND year = %1").arg(year);
    174         else
    175             where = QString(" WHERE year = %1").arg(year);
    176     }
     156    if (year != -1)
     157        where += QString(" AND year = %1").arg(year);
    177158   
    178159    if (runtime != -2)
    179     {
    180         if (where)
    181             where += QString(" AND FLOOR((length-1)/30) = %1").arg(runtime);
    182         else
    183             where = QString(" WHERE FLOOR((length-1)/30) = %1").arg(runtime);
    184     }
     160        where += QString(" AND FLOOR((length-1)/30) = %1").arg(runtime);
    185161   
    186     if (userrating !=-1)
     162    if (userrating != -1)
     163        where += QString(" AND userrating >= %1").arg(userrating);
     164
     165    if (browse != -1)
     166        where += QString(" AND browse = %1").arg(browse);
     167
     168    if (parental_level)
    187169    {
    188         if (where)
    189             where += QString(" AND userrating >= %1").arg(userrating);
    190         else
    191             where = QString(" WHERE userrating >= %1").arg(userrating);
     170        where += QString(" AND showlevel != 0 AND showlevel <= %1")
     171                                .arg(parental_level);
    192172    }
    193173
    194     if (browse !=-1)
    195     {
    196         if (where)
    197             where += QString(" AND browse = %1").arg(browse);
    198         else
    199             where = QString(" WHERE browse = %1").arg(browse);
    200     }
    201    
    202 
    203174    return where;
    204175}
    205176
     
    225196   
    226197    if (numvideos_text)
    227198    {
    228         QString select = QString("SELECT NULL FROM ");
    229199        QString from = currentSettings->BuildClauseFrom();
    230         QString where = currentSettings->BuildClauseWhere();
    231         QString q_string = QString("%1 %2 %3")
    232                            .arg(select).arg(from).arg(where);
     200        QString where = currentSettings->BuildClauseWhere(0);
     201        QString q_string = QString("SELECT NULL FROM %1 %2")
     202                           .arg(from).arg(where);
    233203       
    234204
    235205        MSqlQuery a_query(MSqlQuery::InitCon());
  • mythvideo/videogallery.cpp

     
    675675        } else if (currRow > 0 || currCol > 0) {
    676676            currRow = 0;
    677677            currCol = 0;
    678         } else {
     678        } else if (lastTopRow > 0) {
    679679            // "Flip" to last page
    680680            topRow = lastTopRow;
    681681            currRow = lastRow;
    682682            currCol = QMIN(currCol, lastCol);
     683        } else {
     684            // Only one page's worth of stuff to display; no-op
     685            return;
    683686        }
    684687    }
    685688    else if (action == "PAGEDOWN")
     
    699702        } else if (currRow < lastRow || currCol < lastCol) {
    700703            currRow = lastRow;
    701704            currCol = lastCol;
    702         } else {
     705        } else if (topRow > 0) {
    703706            // "Flip" to first page
    704707            topRow = 0;
    705708            currRow = 0;
     709        } else {
     710            // Only one page's worth of stuff to display; no-op
     711            return;
    706712        }
    707713    }
    708714    else if (action == "HOME")