Ticket #690: mythtv.watch_recordings.diff
File mythtv.watch_recordings.diff, 17.9 KB (added by , 20 years ago) |
---|
-
programs/mythfrontend/playbackbox.cpp
98 98 return (dt1 > dt2 ? 1 : -1); 99 99 } 100 100 101 static PlaybackBox::ViewMask viewMaskToggle(PlaybackBox::ViewMask mask, 102 PlaybackBox::ViewMask toggle) 103 { 104 // only works for single-bit toggle values 105 if ((mask & toggle)) 106 return (PlaybackBox::ViewMask)(mask & ~toggle); 107 return (PlaybackBox::ViewMask)(mask | toggle); 108 } 109 110 static QString sortTitle(QString title, PlaybackBox::ViewMask viewmask, 111 PlaybackBox::ViewTitleSort titleSort, int recpriority) 112 { 113 if (title == "") 114 return title; 115 116 QRegExp prefixes = QObject::tr("^(The |A |An )"); 117 QString sTitle = title; 118 119 sTitle.remove(prefixes); 120 if (viewmask == PlaybackBox::VIEW_TITLES && 121 titleSort == PlaybackBox::TitleSortRecPriority) 122 { 123 // Also incorporate recpriority (reverse numeric sort). 124 // 125 // Take advantage of QMap sorting. Positive recpriority values have a 126 // '+' prefix (sorts before '-'). Positive recpriority values are 127 // "inverted" by substracting them from 1000, so that high 128 // recpriorities are sorted first. 129 // 130 // For example (first column is sort key; second column is 131 // recpriority): 132 // 133 // +905 95 134 // +910 90 135 // +911 89 136 // +999 1 137 // -000 0 138 // -005 -5 139 // -010 -10 140 // -099 -99 141 142 QString sortprefix; 143 if (recpriority > 0) 144 sortprefix.sprintf("+%03u", 1000 - recpriority); 145 else 146 sortprefix.sprintf("-%03u", -recpriority); 147 148 sTitle = sortprefix + "-" + sTitle; 149 } 150 return sTitle; 151 } 152 101 153 PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent, 102 154 const char *name) 103 155 : MythDialog(parent, name) … … 146 198 147 199 recGroupPopup = NULL; 148 200 149 // titleView controls showing titles in group list 150 titleView = true; 201 viewMask = VIEW_TITLES; 151 202 152 // useCategories controls showing categories in group list153 useCategories = false;154 155 // useRecGroups controls showing of recording groups in group list156 useRecGroups = false;157 158 203 if (gContext->GetNumSetting("UseArrowAccels", 1)) 159 204 arrowAccel = true; 160 205 else … … 185 230 else 186 231 recGroupType[recGroup] = "recgroup"; 187 232 188 setDefaultView(gContext->GetNumSetting("DisplayGroupDefaultView", 0)); 233 setDefaultView((ViewType)gContext->GetNumSetting("DisplayGroupDefaultView", 234 TitlesOnly)); 189 235 190 236 fullRect = QRect(0, 0, size().width(), size().height()); 191 237 listRect = QRect(0, 0, 0, 0); … … 313 359 } 314 360 } 315 361 316 void PlaybackBox::setDefaultView( intdefaultView)362 void PlaybackBox::setDefaultView(ViewType defaultView) 317 363 { 364 int mask; 365 318 366 switch (defaultView) 319 367 { 320 368 default: 321 case TitlesOnly: titleView = true; useCategories = false; 322 useRecGroups = false; break; 323 case TitlesCategories: titleView = true; useCategories = true; 324 useRecGroups = false; break; 325 case TitlesCategoriesRecGroups: titleView = true; useCategories = true; 326 useRecGroups = true; break; 327 case TitlesRecGroups: titleView = true; useCategories = false; 328 useRecGroups = true; break; 329 case Categories: titleView = false; useCategories = true; 330 useRecGroups = false; break; 331 case CategoriesRecGroups: titleView = false; useCategories = true; 332 useRecGroups = true; break; 333 case RecGroups: titleView = false; useCategories = false; 334 useRecGroups = true; break; 369 case TitlesOnly: 370 mask = VIEW_TITLES; 371 break; 372 case TitlesCategories: 373 mask = VIEW_TITLES | VIEW_CATEGORIES; 374 break; 375 case TitlesCategoriesRecGroups: 376 mask = VIEW_TITLES | VIEW_CATEGORIES | VIEW_RECGROUPS; 377 break; 378 case TitlesRecGroups: 379 mask = VIEW_TITLES | VIEW_RECGROUPS; 380 break; 381 case Categories: 382 mask = VIEW_CATEGORIES; 383 break; 384 case CategoriesRecGroups: 385 mask = VIEW_CATEGORIES | VIEW_RECGROUPS; 386 break; 387 case RecGroups: 388 mask = VIEW_RECGROUPS; 389 break; 335 390 } 391 viewMask = (PlaybackBox::ViewMask)mask; 336 392 } 337 393 338 394 /* blocks until playing has stopped */ … … 1133 1189 1134 1190 tempInfo = plist->at(skip+cnt); 1135 1191 1136 if ( (titleList[titleIndex] == "") || (!(titleView)))1192 if (titleList[titleIndex] == "" || !(viewMask & VIEW_TITLES)) 1137 1193 tempSubTitle = tempInfo->title; 1138 1194 else 1139 1195 tempSubTitle = tempInfo->subtitle; 1140 1196 if (tempSubTitle.stripWhiteSpace().length() == 0) 1141 1197 tempSubTitle = tempInfo->title; 1142 1198 if ((tempInfo->subtitle).stripWhiteSpace().length() > 0 1143 && ((titleList[titleIndex] == "") || (!(titleView)))) 1199 && (titleList[titleIndex] == "" 1200 || !(viewMask & VIEW_TITLES))) 1144 1201 { 1145 1202 tempSubTitle = tempSubTitle + " - \"" + 1146 1203 tempInfo->subtitle + "\""; … … 1351 1408 QString oldprogramid; 1352 1409 QDate oldoriginalAirDate; 1353 1410 QDateTime oldstartts; 1411 int oldrecpriority = 0; 1354 1412 p = progLists[oldtitle].at(progIndex); 1355 1413 if (p) 1356 1414 { … … 1358 1416 oldstartts = p->recstartts; 1359 1417 oldprogramid = p->programid; 1360 1418 oldoriginalAirDate = p->originalAirDate; 1419 oldrecpriority = p->recpriority; 1361 1420 } 1362 1421 1363 1422 QMap<QString, AvailableStatusType> asCache; … … 1377 1436 1378 1437 fillRecGroupPasswordCache(); 1379 1438 1439 ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting( 1440 "DisplayGroupTitleSort", TitleSortAlphabetical); 1441 1380 1442 QMap<QString, QString> sortedList; 1381 QRegExp prefixes = tr("^(The |A |An )");1382 1443 QString sTitle = ""; 1383 1444 1384 1445 vector<ProgramInfo *> *infoList; … … 1397 1458 (p->category == recGroup ) && 1398 1459 ( !recGroupPwCache.contains(p->recgroup)))) 1399 1460 { 1400 if ( (titleView) || (useCategories) || (useRecGroups))1461 if (viewMask != VIEW_NONE) 1401 1462 progLists[""].prepend(p); 1402 1463 1403 1464 asKey = p->MakeUniqueKey(); … … 1406 1467 else 1407 1468 p->availableStatus = asAvailable; 1408 1469 1409 if ( titleView) // Normal title view1470 if ((viewMask & VIEW_TITLES)) // Show titles 1410 1471 { 1411 1472 progLists[p->title].prepend(p); 1412 sTitle = p->title;1413 sTitle.remove(prefixes);1473 sTitle = sortTitle(p->title, viewMask, titleSort, 1474 p->recpriority); 1414 1475 sortedList[sTitle] = p->title; 1415 1476 } 1416 1477 1417 if ( useRecGroups) // Show recording groups1478 if ((viewMask & VIEW_RECGROUPS)) // Show recording groups 1418 1479 { 1419 1480 progLists[p->recgroup].prepend(p); 1420 1481 sortedList[p->recgroup] = p->recgroup; 1421 1482 1422 // If another view is also used, unset autodelete as another group will do it. 1423 if ((useCategories) || (titleView)) 1483 // If another view is also used, unset autodelete as 1484 // another group will do it. 1485 if ((viewMask & ~VIEW_RECGROUPS)) 1424 1486 progLists[p->recgroup].setAutoDelete(false); 1425 1487 } 1426 1488 1427 if ( useCategories) // Show categories1489 if ((viewMask & VIEW_CATEGORIES)) // Show categories 1428 1490 { 1429 1491 progLists[p->category].prepend(p); 1430 1492 sortedList[p->category] = p->category; 1431 // If another view is also used, unset autodelete as another group will do it 1432 if ((useRecGroups) || (titleView)) 1493 // If another view is also used, unset autodelete as 1494 // another group will do it 1495 if ((viewMask & ~VIEW_CATEGORIES)) 1433 1496 progLists[p->category].setAutoDelete(false); 1434 1497 } 1435 1498 } … … 1450 1513 return 0; 1451 1514 } 1452 1515 1453 titleList = sortedList.values();1454 1455 1516 QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date"); 1456 1517 1457 1518 if (episodeSort == "OrigAirDate") … … 1487 1548 // titles backwards until we find where we were or go past. This 1488 1549 // is somewhat inefficient, but it works. 1489 1550 1490 QString oldsTitle = oldtitle; 1491 oldsTitle.remove(prefixes); 1551 QStringList sTitleList = sortedList.keys(); 1552 titleList = sortedList.values(); 1553 1554 QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort, 1555 oldrecpriority); 1492 1556 titleIndex = titleList.count() - 1; 1493 for ( int i = titleIndex; i >= 0; i--)1557 for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--) 1494 1558 { 1495 sTitle = titleList[i]; 1496 sTitle.remove(prefixes); 1559 sTitle = sTitleList[titleIndex]; 1497 1560 1498 1561 if (oldsTitle > sTitle) 1562 { 1563 if (titleIndex + 1 < (int)titleList.count()) 1564 titleIndex++; 1499 1565 break; 1566 } 1500 1567 1501 titleIndex = i;1502 1503 1568 if (oldsTitle == sTitle) 1504 1569 break; 1505 1570 } … … 2219 2284 2220 2285 if (inTitle) 2221 2286 { 2222 if ( titleView)2287 if ((viewMask & VIEW_TITLES)) 2223 2288 popup->addButton(tr("Toggle playlist for this Category/Title"), 2224 2289 this, SLOT(togglePlayListTitle())); 2225 2290 else … … 3105 3170 if (expectingPopup) 3106 3171 cancelPopup(); 3107 3172 3108 if (titleView) titleView = false; 3109 else titleView = true; 3173 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3110 3174 3111 3175 playList.clear(); 3112 3176 connected = FillList(); … … 3252 3316 } 3253 3317 else if (action == "TOGGLERECORD") 3254 3318 { 3255 if (titleView) titleView = false; 3256 else titleView = true; 3319 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3257 3320 connected = FillList(); 3258 3321 skipUpdate = false; 3259 3322 update(fullRect); … … 3760 3823 int result = recGroupPopup->ExecPopup(); 3761 3824 3762 3825 if (result == MythDialog::Accepted) 3763 setDefaultView( recGroupComboBox->currentItem());3826 setDefaultView((ViewType)recGroupComboBox->currentItem()); 3764 3827 3765 3828 delete recGroupComboBox; 3766 3829 … … 4324 4387 else 4325 4388 recGroupOkButton->setEnabled(false); 4326 4389 } 4390 4391 // vim:set sw=4 ts=4 expandtab: -
programs/mythfrontend/globalsettings.cpp
4 4 #include "dbsettings.h" 5 5 #include "langsettings.h" 6 6 #include "mpeg/iso639.h" 7 #include "playbackbox.h" 7 8 #include "globalsettings.h" 8 9 #include "recordingprofile.h" 9 10 #include "scheduledrecording.h" … … 288 289 HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView"); 289 290 gc->setLabel(QObject::tr("Default View")); 290 291 291 gc->addSelection(QObject::tr("Show Titles only"), "0"); 292 gc->addSelection(QObject::tr("Show Titles and Categories"), "1"); 293 gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2"); 294 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3"); 295 gc->addSelection(QObject::tr("Show Categories only"), "4"); 296 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5"); 297 gc->addSelection(QObject::tr("Show Recording Groups only"), "6"); 292 gc->addSelection(QObject::tr("Show Titles only"), 293 QString::number(PlaybackBox::TitlesOnly)); 294 gc->addSelection(QObject::tr("Show Titles and Categories"), 295 QString::number(PlaybackBox::TitlesCategories)); 296 gc->addSelection(QObject::tr( 297 "Show Titles, Categories, and Recording Groups"), 298 QString::number(PlaybackBox::TitlesCategoriesRecGroups)); 299 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), 300 QString::number(PlaybackBox::TitlesRecGroups)); 301 gc->addSelection(QObject::tr("Show Categories only"), 302 QString::number(PlaybackBox::Categories)); 303 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), 304 QString::number(PlaybackBox::CategoriesRecGroups)); 305 gc->addSelection(QObject::tr("Show Recording Groups only"), 306 QString::number(PlaybackBox::RecGroups)); 298 307 299 308 gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen " 300 309 "by default.")); … … 2217 2226 return gc; 2218 2227 } 2219 2228 2229 class DefaultViewSettings: public VerticalConfigurationGroup, 2230 public TriggeredConfigurationGroup { 2231 public: 2232 DefaultViewSettings(): 2233 VerticalConfigurationGroup(false, false, true, true), 2234 TriggeredConfigurationGroup(false) { 2235 2236 HostComboBox *defaultView = DefaultView(); 2237 addChild(defaultView); 2238 setTrigger(defaultView); 2239 2240 HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort"); 2241 titleSort->setLabel(tr("Sort Titles")); 2242 titleSort->addSelection(tr("Alphabetically"), 2243 QString::number(PlaybackBox::TitleSortAlphabetical)); 2244 titleSort->addSelection(tr("By Recording Priority"), 2245 QString::number(PlaybackBox::TitleSortRecPriority)); 2246 2247 for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++) 2248 { 2249 if (ii == PlaybackBox::TitlesOnly) 2250 addTarget(QString::number(ii), titleSort); 2251 else 2252 addTarget(QString::number(ii), 2253 new VerticalConfigurationGroup(false, false)); 2254 } 2255 } 2256 }; 2257 2220 2258 static HostCheckBox *PVR350OutputEnable() 2221 2259 { 2222 2260 HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable"); … … 3017 3055 pbox2->addChild(QueryInitialFilter()); 3018 3056 pbox2->addChild(RememberRecGroup()); 3019 3057 pbox2->addChild(UseGroupNameAsAllPrograms()); 3020 pbox2->addChild( DefaultView());3058 pbox2->addChild(new DefaultViewSettings()); 3021 3059 addChild(pbox2); 3022 3060 3023 3061 addChild(new HwDecSettings()); … … 3244 3282 addChild(xboxset); 3245 3283 } 3246 3284 3285 // vim:set sw=4 ts=4 expandtab: -
programs/mythfrontend/playbackbox.h
1 1 // -*- Mode: c++ -*- 2 // vim:set sw=4 ts=4 expandtab: 2 3 #ifndef PLAYBACKBOX_H_ 3 4 #define PLAYBACKBOX_H_ 4 5 … … 32 33 Q_OBJECT 33 34 public: 34 35 typedef enum { Play, Delete } BoxType; 35 typedef enum { TitlesOnly, TitlesCategories, TitlesCategoriesRecGroups,36 TitlesRecGroups, Categories, CategoriesRecGroups, RecGroups} ViewType;37 36 37 // ViewType values cannot change; they are stored in the database. 38 typedef enum { 39 TitlesOnly = 0, 40 TitlesCategories = 1, 41 TitlesCategoriesRecGroups = 2, 42 TitlesRecGroups = 3, 43 Categories = 4, 44 CategoriesRecGroups = 5, 45 RecGroups = 6, 46 ViewTypes, // placeholder value, not in database 47 } ViewType; 38 48 49 // Sort function when TitlesOnly. Values are stored in database. 50 typedef enum { 51 TitleSortAlphabetical = 0, 52 TitleSortRecPriority = 1, 53 TitleSortMethods, // placeholder value, not in database 54 } ViewTitleSort; 55 56 typedef enum { 57 VIEW_NONE = 0x00, 58 VIEW_TITLES = 0x01, 59 VIEW_CATEGORIES = 0x02, 60 VIEW_RECGROUPS = 0x04, 61 VIEW_ALL = ~0x00, 62 } ViewMask; 63 39 64 PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0); 40 65 ~PlaybackBox(void); 41 66 … … 322 347 int listOrder; 323 348 324 349 bool playingSomething; 325 bool titleView;326 350 327 bool useRecGroups; 328 bool useCategories; 329 void setDefaultView(int defaultView); 351 ViewMask viewMask; 352 void setDefaultView(ViewType defaultView); 330 353 331 354 yuv2rgb_fun conv_yuv2rgba; 332 355 unsigned char *conv_rgba_buf; -
programs/mythbackend/mainserver.cpp
957 957 "recorded.lastmodified, recorded.findid, " 958 958 "recorded.originalairdate, recorded.timestretch, " 959 959 "recorded.basename, recorded.progstart, " 960 "recorded.progend "960 "recorded.progend, recorded.recpriority " 961 961 "FROM recorded " 962 962 "LEFT JOIN record ON recorded.recordid = record.recordid " 963 963 "LEFT JOIN channel ON recorded.chanid = channel.chanid " … … 1069 1069 1070 1070 proginfo->recgroup = query.value(16).toString(); 1071 1071 1072 proginfo->recpriority = query.value(31).toInt(); 1073 1072 1074 proginfo->recstatus = rsRecorded; 1073 1075 if (proginfo->recendts > rectime) 1074 1076 { … … 3955 3957 recording.setAttribute( "preRollSeconds", gContext->GetNumSetting("RecordPreRoll", 0)); 3956 3958 } 3957 3959 3960 // vim:set sw=4 ts=4 expandtab: