Ticket #690: mythtv.watch_recordings.2.diff
File mythtv.watch_recordings.2.diff, 18.2 KB (added by , 18 years ago) |
---|
-
programs/mythfrontend/playbackbox.cpp
99 99 return (dt1 > dt2 ? 1 : -1); 100 100 } 101 101 102 static PlaybackBox::ViewMask viewMaskToggle(PlaybackBox::ViewMask mask, 103 PlaybackBox::ViewMask toggle) 104 { 105 // only works for single-bit toggle values 106 if ((mask & toggle)) 107 return (PlaybackBox::ViewMask)(mask & ~toggle); 108 return (PlaybackBox::ViewMask)(mask | toggle); 109 } 110 111 static QString sortTitle(QString title, PlaybackBox::ViewMask viewmask, 112 PlaybackBox::ViewTitleSort titleSort, int recpriority) 113 { 114 if (title == "") 115 return title; 116 117 QRegExp prefixes = QObject::tr("^(The |A |An )"); 118 QString sTitle = title; 119 120 sTitle.remove(prefixes); 121 if (viewmask == PlaybackBox::VIEW_TITLES && 122 titleSort == PlaybackBox::TitleSortRecPriority) 123 { 124 // Also incorporate recpriority (reverse numeric sort). In 125 // case different episodes of a recording schedule somehow 126 // have different recpriority values (e.g., manual fiddling 127 // with database), the title will appear once for each 128 // distinct recpriority value among its episodes. 129 // 130 // Take advantage of QMap sorting. Positive recpriority values 131 // have a '+' prefix (sorts before '-'). Positive recpriority 132 // values are "inverted" by substracting them from 1000, so 133 // that high recpriorities are sorted first. 134 // 135 // For example (first column is sort key; second column is 136 // recpriority): 137 // 138 // +905 95 139 // +910 90 140 // +911 89 141 // +999 1 142 // -000 0 143 // -005 -5 144 // -010 -10 145 // -099 -99 146 147 QString sortprefix; 148 if (recpriority > 0) 149 sortprefix.sprintf("+%03u", 1000 - recpriority); 150 else 151 sortprefix.sprintf("-%03u", -recpriority); 152 153 sTitle = sortprefix + "-" + sTitle; 154 } 155 return sTitle; 156 } 157 102 158 PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent, 103 159 const char *name) 104 160 : MythDialog(parent, name) … … 147 203 148 204 recGroupPopup = NULL; 149 205 150 // titleView controls showing titles in group list 151 titleView = true; 206 viewMask = VIEW_TITLES; 152 207 153 // useCategories controls showing categories in group list154 useCategories = false;155 156 // useRecGroups controls showing of recording groups in group list157 useRecGroups = false;158 159 208 if (gContext->GetNumSetting("UseArrowAccels", 1)) 160 209 arrowAccel = true; 161 210 else … … 186 235 else 187 236 recGroupType[recGroup] = "recgroup"; 188 237 189 setDefaultView(gContext->GetNumSetting("DisplayGroupDefaultView", 0)); 238 setDefaultView((ViewType)gContext->GetNumSetting("DisplayGroupDefaultView", 239 TitlesOnly)); 190 240 191 241 fullRect = QRect(0, 0, size().width(), size().height()); 192 242 listRect = QRect(0, 0, 0, 0); … … 314 364 } 315 365 } 316 366 317 void PlaybackBox::setDefaultView( intdefaultView)367 void PlaybackBox::setDefaultView(ViewType defaultView) 318 368 { 369 int mask; 370 319 371 switch (defaultView) 320 372 { 321 373 default: 322 case TitlesOnly: titleView = true; useCategories = false; 323 useRecGroups = false; break; 324 case TitlesCategories: titleView = true; useCategories = true; 325 useRecGroups = false; break; 326 case TitlesCategoriesRecGroups: titleView = true; useCategories = true; 327 useRecGroups = true; break; 328 case TitlesRecGroups: titleView = true; useCategories = false; 329 useRecGroups = true; break; 330 case Categories: titleView = false; useCategories = true; 331 useRecGroups = false; break; 332 case CategoriesRecGroups: titleView = false; useCategories = true; 333 useRecGroups = true; break; 334 case RecGroups: titleView = false; useCategories = false; 335 useRecGroups = true; break; 374 case TitlesOnly: 375 mask = VIEW_TITLES; 376 break; 377 case TitlesCategories: 378 mask = VIEW_TITLES | VIEW_CATEGORIES; 379 break; 380 case TitlesCategoriesRecGroups: 381 mask = VIEW_TITLES | VIEW_CATEGORIES | VIEW_RECGROUPS; 382 break; 383 case TitlesRecGroups: 384 mask = VIEW_TITLES | VIEW_RECGROUPS; 385 break; 386 case Categories: 387 mask = VIEW_CATEGORIES; 388 break; 389 case CategoriesRecGroups: 390 mask = VIEW_CATEGORIES | VIEW_RECGROUPS; 391 break; 392 case RecGroups: 393 mask = VIEW_RECGROUPS; 394 break; 336 395 } 396 viewMask = (PlaybackBox::ViewMask)mask; 337 397 } 338 398 339 399 /* blocks until playing has stopped */ … … 1137 1197 1138 1198 tempInfo = plist->at(skip+cnt); 1139 1199 1140 if ( (titleList[titleIndex] == "") || (!(titleView)))1200 if (titleList[titleIndex] == "" || !(viewMask & VIEW_TITLES)) 1141 1201 tempSubTitle = tempInfo->title; 1142 1202 else 1143 1203 tempSubTitle = tempInfo->subtitle; 1144 1204 if (tempSubTitle.stripWhiteSpace().length() == 0) 1145 1205 tempSubTitle = tempInfo->title; 1146 1206 if ((tempInfo->subtitle).stripWhiteSpace().length() > 0 1147 && ((titleList[titleIndex] == "") || (!(titleView)))) 1207 && (titleList[titleIndex] == "" 1208 || !(viewMask & VIEW_TITLES))) 1148 1209 { 1149 1210 tempSubTitle = tempSubTitle + " - \"" + 1150 1211 tempInfo->subtitle + "\""; … … 1355 1416 QString oldprogramid; 1356 1417 QDate oldoriginalAirDate; 1357 1418 QDateTime oldstartts; 1419 int oldrecpriority = 0; 1358 1420 p = progLists[oldtitle].at(progIndex); 1359 1421 if (p) 1360 1422 { … … 1362 1424 oldstartts = p->recstartts; 1363 1425 oldprogramid = p->programid; 1364 1426 oldoriginalAirDate = p->originalAirDate; 1427 oldrecpriority = p->recpriority; 1365 1428 } 1366 1429 1367 1430 QMap<QString, AvailableStatusType> asCache; … … 1381 1444 1382 1445 fillRecGroupPasswordCache(); 1383 1446 1447 ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting( 1448 "DisplayGroupTitleSort", TitleSortAlphabetical); 1449 1384 1450 QMap<QString, QString> sortedList; 1385 QRegExp prefixes = tr("^(The |A |An )");1386 1451 QString sTitle = ""; 1387 1452 1388 1453 bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0); … … 1404 1469 (p->category == recGroup ) && 1405 1470 ( !recGroupPwCache.contains(p->recgroup)))) 1406 1471 { 1407 if ( (titleView) || (useCategories) || (useRecGroups))1472 if (viewMask != VIEW_NONE) 1408 1473 progLists[""].prepend(p); 1409 1474 1410 1475 asKey = p->MakeUniqueKey(); … … 1413 1478 else 1414 1479 p->availableStatus = asAvailable; 1415 1480 1416 if ( titleView) // Normal title view1481 if ((viewMask & VIEW_TITLES)) // Show titles 1417 1482 { 1418 1483 progLists[p->title].prepend(p); 1419 sTitle = p->title;1420 sTitle.remove(prefixes);1484 sTitle = sortTitle(p->title, viewMask, titleSort, 1485 p->recpriority); 1421 1486 sortedList[sTitle] = p->title; 1422 1487 } 1423 1488 1424 if (useRecGroups && p->recgroup != "") // Show recording groups 1489 if ((viewMask & VIEW_RECGROUPS) && 1490 p->recgroup != "") // Show recording groups 1425 1491 { 1426 1492 progLists[p->recgroup].prepend(p); 1427 1493 sortedList[p->recgroup] = p->recgroup; 1428 1494 1429 // If another view is also used, unset autodelete as another group will do it. 1430 if ((useCategories) || (titleView)) 1495 // If another view is also used, unset autodelete as 1496 // another group will do it. 1497 if ((viewMask & ~VIEW_RECGROUPS)) 1431 1498 progLists[p->recgroup].setAutoDelete(false); 1432 1499 } 1433 1500 1434 if (useCategories && p->category != "") // Show categories 1501 if ((viewMask & VIEW_CATEGORIES) && 1502 p->category != "") // Show categories 1435 1503 { 1436 1504 progLists[p->category].prepend(p); 1437 1505 sortedList[p->category] = p->category; 1438 // If another view is also used, unset autodelete as another group will do it 1439 if ((useRecGroups) || (titleView)) 1506 // If another view is also used, unset autodelete as 1507 // another group will do it 1508 if ((viewMask & ~VIEW_CATEGORIES)) 1440 1509 progLists[p->category].setAutoDelete(false); 1441 1510 } 1442 1511 } … … 1457 1526 return 0; 1458 1527 } 1459 1528 1460 titleList = sortedList.values();1461 1462 1529 QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date"); 1463 1530 1464 1531 if (episodeSort == "OrigAirDate") … … 1494 1561 // titles backwards until we find where we were or go past. This 1495 1562 // is somewhat inefficient, but it works. 1496 1563 1497 QString oldsTitle = oldtitle; 1498 oldsTitle.remove(prefixes); 1564 QStringList sTitleList = sortedList.keys(); 1565 titleList = sortedList.values(); 1566 1567 QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort, 1568 oldrecpriority); 1499 1569 titleIndex = titleList.count() - 1; 1500 for ( int i = titleIndex; i >= 0; i--)1570 for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--) 1501 1571 { 1502 sTitle = titleList[i]; 1503 sTitle.remove(prefixes); 1572 sTitle = sTitleList[titleIndex]; 1504 1573 1505 1574 if (oldsTitle > sTitle) 1575 { 1576 if (titleIndex + 1 < (int)titleList.count()) 1577 titleIndex++; 1506 1578 break; 1579 } 1507 1580 1508 titleIndex = i;1509 1510 1581 if (oldsTitle == sTitle) 1511 1582 break; 1512 1583 } … … 2213 2284 2214 2285 if (inTitle) 2215 2286 { 2216 if ( titleView)2287 if ((viewMask & VIEW_TITLES)) 2217 2288 popup->addButton(tr("Toggle playlist for this Category/Title"), 2218 2289 this, SLOT(togglePlayListTitle())); 2219 2290 else … … 3120 3191 if (expectingPopup) 3121 3192 cancelPopup(); 3122 3193 3123 if (titleView) titleView = false; 3124 else titleView = true; 3194 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3125 3195 3126 3196 playList.clear(); 3127 3197 connected = FillList(); … … 3273 3343 } 3274 3344 else if (action == "TOGGLERECORD") 3275 3345 { 3276 if (titleView) titleView = false; 3277 else titleView = true; 3346 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3278 3347 connected = FillList(); 3279 3348 skipUpdate = false; 3280 3349 update(fullRect); … … 3781 3850 int result = recGroupPopup->ExecPopup(); 3782 3851 3783 3852 if (result == MythDialog::Accepted) 3784 setDefaultView( recGroupComboBox->currentItem());3853 setDefaultView((ViewType)recGroupComboBox->currentItem()); 3785 3854 3786 3855 delete recGroupComboBox; 3787 3856 … … 4445 4514 else 4446 4515 recGroupOkButton->setEnabled(false); 4447 4516 } 4517 4518 // 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" … … 302 303 HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView"); 303 304 gc->setLabel(QObject::tr("Default View")); 304 305 305 gc->addSelection(QObject::tr("Show Titles only"), "0"); 306 gc->addSelection(QObject::tr("Show Titles and Categories"), "1"); 307 gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2"); 308 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3"); 309 gc->addSelection(QObject::tr("Show Categories only"), "4"); 310 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5"); 311 gc->addSelection(QObject::tr("Show Recording Groups only"), "6"); 306 gc->addSelection(QObject::tr("Show Titles only"), 307 QString::number(PlaybackBox::TitlesOnly)); 308 gc->addSelection(QObject::tr("Show Titles and Categories"), 309 QString::number(PlaybackBox::TitlesCategories)); 310 gc->addSelection(QObject::tr( 311 "Show Titles, Categories, and Recording Groups"), 312 QString::number(PlaybackBox::TitlesCategoriesRecGroups)); 313 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), 314 QString::number(PlaybackBox::TitlesRecGroups)); 315 gc->addSelection(QObject::tr("Show Categories only"), 316 QString::number(PlaybackBox::Categories)); 317 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), 318 QString::number(PlaybackBox::CategoriesRecGroups)); 319 gc->addSelection(QObject::tr("Show Recording Groups only"), 320 QString::number(PlaybackBox::RecGroups)); 312 321 313 322 gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen " 314 323 "by default.")); … … 2229 2238 return gc; 2230 2239 } 2231 2240 2241 class DefaultViewSettings: public VerticalConfigurationGroup, 2242 public TriggeredConfigurationGroup { 2243 public: 2244 DefaultViewSettings(): 2245 VerticalConfigurationGroup(false, false, true, true), 2246 TriggeredConfigurationGroup(false) { 2247 2248 HostComboBox *defaultView = DefaultView(); 2249 addChild(defaultView); 2250 setTrigger(defaultView); 2251 2252 HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort"); 2253 titleSort->setLabel(tr("Sort Titles")); 2254 titleSort->addSelection(tr("Alphabetically"), 2255 QString::number(PlaybackBox::TitleSortAlphabetical)); 2256 titleSort->addSelection(tr("By Recording Priority"), 2257 QString::number(PlaybackBox::TitleSortRecPriority)); 2258 2259 for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++) 2260 { 2261 if (ii == PlaybackBox::TitlesOnly) 2262 addTarget(QString::number(ii), titleSort); 2263 else 2264 addTarget(QString::number(ii), 2265 new VerticalConfigurationGroup(false, false)); 2266 } 2267 } 2268 }; 2269 2232 2270 static HostCheckBox *PVR350OutputEnable() 2233 2271 { 2234 2272 HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable"); … … 3043 3081 pbox2->addChild(RememberRecGroup()); 3044 3082 pbox2->addChild(UseGroupNameAsAllPrograms()); 3045 3083 pbox2->addChild(LiveTVInAllPrograms()); 3046 pbox2->addChild( DefaultView());3084 pbox2->addChild(new DefaultViewSettings()); 3047 3085 addChild(pbox2); 3048 3086 3049 3087 addChild(new HwDecSettings()); … … 3268 3306 addChild(xboxset); 3269 3307 } 3270 3308 3309 // 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 … … 326 351 int listOrder; 327 352 328 353 bool playingSomething; 329 bool titleView;330 354 331 bool useRecGroups; 332 bool useCategories; 333 void setDefaultView(int defaultView); 355 ViewMask viewMask; 356 void setDefaultView(ViewType defaultView); 334 357 335 358 yuv2rgb_fun conv_yuv2rgba; 336 359 unsigned char *conv_rgba_buf; -
programs/mythbackend/mainserver.cpp
958 958 "recorded.lastmodified, recorded.findid, " 959 959 "recorded.originalairdate, recorded.playgroup, " 960 960 "recorded.basename, recorded.progstart, " 961 "recorded.progend "961 "recorded.progend, recorded.recpriority " 962 962 "FROM recorded " 963 963 "LEFT JOIN record ON recorded.recordid = record.recordid " 964 964 "LEFT JOIN channel ON recorded.chanid = channel.chanid " … … 1070 1070 proginfo->recgroup = query.value(16).toString(); 1071 1071 proginfo->playgroup = query.value(27).toString(); 1072 1072 1073 proginfo->recpriority = query.value(31).toInt(); 1074 1073 1075 proginfo->recstatus = rsRecorded; 1074 1076 if (proginfo->recendts > rectime) 1075 1077 {