Ticket #96: mythvideo.parental_level.diff
File mythvideo.parental_level.diff, 7.4 KB (added by , 20 years ago) |
---|
-
mythvideo/videofilter.h
24 24 VideoFilterSettings(VideoFilterSettings *other); 25 25 ~VideoFilterSettings(); 26 26 QString BuildClauseFrom(); 27 QString BuildClauseWhere( );27 QString BuildClauseWhere(int parental_level); 28 28 QString BuildClauseOrderBy(); 29 29 void saveAsDefault(); 30 30 … … 87 87 void keyPressEvent(QKeyEvent *e); 88 88 void wireUpTheme(); 89 89 void fillWidgets(); 90 // QString BuildClauseFrom();91 // QString BuildClauseWhere();92 90 93 91 public slots: 94 92 -
mythvideo/videomanager.cpp
192 192 193 193 QString thequery = QString("SELECT intid FROM %1 %2 %3") 194 194 .arg(currentVideoFilter->BuildClauseFrom()) 195 .arg(currentVideoFilter->BuildClauseWhere( ))195 .arg(currentVideoFilter->BuildClauseWhere(0)) 196 196 .arg(currentVideoFilter->BuildClauseOrderBy()); 197 197 MSqlQuery query(MSqlQuery::InitCon()); 198 198 query.exec(thequery); -
mythvideo/videolist.cpp
108 108 109 109 QString thequery = QString("SELECT intid FROM %1 %2 %3") 110 110 .arg(currentVideoFilter->BuildClauseFrom()) 111 .arg(currentVideoFilter->BuildClauseWhere( ))111 .arg(currentVideoFilter->BuildClauseWhere(parental_level)) 112 112 .arg(currentVideoFilter->BuildClauseOrderBy()); 113 113 114 114 MSqlQuery query(MSqlQuery::InitCon()); … … 135 135 (void)addDirNode(video_tree_root, "videos"); 136 136 137 137 // 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. 140 139 // 141 140 QPtrList<Metadata> metaptrs; 142 141 while (query.next()) … … 145 144 Metadata *myData = new Metadata(); 146 145 myData->setID(intid); 147 146 myData->fillDataFromID(); 148 if (myData->ShowLevel() <= parental_level && myData->ShowLevel() != 0) 149 metaptrs.append(myData); 150 else 151 delete myData; 147 metaptrs.append(myData); 152 148 } 153 149 154 150 // -
mythvideo/videofilter.cpp
132 132 return from; 133 133 } 134 134 135 QString VideoFilterSettings::BuildClauseWhere( )135 QString VideoFilterSettings::BuildClauseWhere(int parental_level) 136 136 { 137 QString where = NULL; 138 if (genre!=-1) 137 QString where = "WHERE 1"; 138 QString condition; 139 140 if (genre != -1) 139 141 { 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); 146 144 } 147 145 148 if (country !=-1)146 if (country != -1) 149 147 { 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); 160 151 } 161 152 162 153 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); 169 155 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); 177 158 178 159 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); 185 161 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) 187 169 { 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); 192 172 } 193 173 194 if (browse !=-1)195 {196 if (where)197 where += QString(" AND browse = %1").arg(browse);198 else199 where = QString(" WHERE browse = %1").arg(browse);200 }201 202 203 174 return where; 204 175 } 205 176 … … 225 196 226 197 if (numvideos_text) 227 198 { 228 QString select = QString("SELECT NULL FROM ");229 199 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); 233 203 234 204 235 205 MSqlQuery a_query(MSqlQuery::InitCon()); -
mythvideo/videogallery.cpp
675 675 } else if (currRow > 0 || currCol > 0) { 676 676 currRow = 0; 677 677 currCol = 0; 678 } else {678 } else if (lastTopRow > 0) { 679 679 // "Flip" to last page 680 680 topRow = lastTopRow; 681 681 currRow = lastRow; 682 682 currCol = QMIN(currCol, lastCol); 683 } else { 684 // Only one page's worth of stuff to display; no-op 685 return; 683 686 } 684 687 } 685 688 else if (action == "PAGEDOWN") … … 699 702 } else if (currRow < lastRow || currCol < lastCol) { 700 703 currRow = lastRow; 701 704 currCol = lastCol; 702 } else {705 } else if (topRow > 0) { 703 706 // "Flip" to first page 704 707 topRow = 0; 705 708 currRow = 0; 709 } else { 710 // Only one page's worth of stuff to display; no-op 711 return; 706 712 } 707 713 } 708 714 else if (action == "HOME")