Ticket #690: mythtv.watch_recordings.4.diff
File mythtv.watch_recordings.4.diff, 18.5 KB (added by , 18 years ago) |
---|
-
programs/mythfrontend/playbackbox.cpp
104 104 return (dt1 > dt2 ? 1 : -1); 105 105 } 106 106 107 static PlaybackBox::ViewMask viewMaskToggle(PlaybackBox::ViewMask mask, 108 PlaybackBox::ViewMask toggle) 109 { 110 // can only toggle a single bit at a time 111 if ((mask & toggle)) 112 return (PlaybackBox::ViewMask)(mask & ~toggle); 113 return (PlaybackBox::ViewMask)(mask | toggle); 114 } 115 116 static QString sortTitle(QString title, PlaybackBox::ViewMask viewmask, 117 PlaybackBox::ViewTitleSort titleSort, int recpriority) 118 { 119 if (title == "") 120 return title; 121 122 QRegExp prefixes = QObject::tr("^(The |A |An )"); 123 QString sTitle = title; 124 125 sTitle.remove(prefixes); 126 if (viewmask == PlaybackBox::VIEW_TITLES && 127 titleSort == PlaybackBox::TitleSortRecPriority) 128 { 129 // Also incorporate recpriority (reverse numeric sort). In 130 // case different episodes of a recording schedule somehow 131 // have different recpriority values (e.g., manual fiddling 132 // with database), the title will appear once for each 133 // distinct recpriority value among its episodes. 134 // 135 // Take advantage of QMap sorting. Positive recpriority values 136 // have a '+' prefix (sorts before '-'). Positive recpriority 137 // values are "inverted" by substracting them from 1000, so 138 // that high recpriorities are sorted first. 139 // 140 // For example (first column is sort key; second column is 141 // recpriority): 142 // 143 // +905 95 144 // +910 90 145 // +911 89 146 // +999 1 147 // -000 0 148 // -005 -5 149 // -010 -10 150 // -099 -99 151 152 QString sortprefix; 153 if (recpriority > 0) 154 sortprefix.sprintf("+%03u", 1000 - recpriority); 155 else 156 sortprefix.sprintf("-%03u", -recpriority); 157 158 sTitle = sortprefix + "-" + sTitle; 159 } 160 return sTitle; 161 } 162 107 163 PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent, 108 164 const char *name) 109 165 : MythDialog(parent, name), … … 119 175 groupDisplayName(tr("All Programs")), 120 176 recGroup("All Programs"), 121 177 recGroupPassword(""), curGroupPassword(""), 178 viewMask(VIEW_TITLES), 122 179 // Theme parsing 123 180 theme(new XMLParse()), 124 181 // Non-volatile drawing variables … … 180 237 drawTransPixmap = new QPixmap(); 181 238 182 239 bool displayCat = gContext->GetNumSetting("DisplayRecGroupIsCategory", 0); 183 int defaultView = gContext->GetNumSetting("DisplayGroupDefaultView", 0); 240 ViewType defaultView = (ViewType)gContext->GetNumSetting( 241 "DisplayGroupDefaultView", TitlesOnly); 184 242 int initialFilt = gContext->GetNumSetting("QueryInitialFilter", 0); 185 243 186 244 progLists[""]; … … 343 401 } 344 402 } 345 403 346 void PlaybackBox::setDefaultView( intdefaultView)404 void PlaybackBox::setDefaultView(ViewType defaultView) 347 405 { 406 int mask; 407 348 408 switch (defaultView) 349 409 { 350 410 default: 351 case TitlesOnly: titleView = true; useCategories = false; 352 useRecGroups = false; break; 353 case TitlesCategories: titleView = true; useCategories = true; 354 useRecGroups = false; break; 355 case TitlesCategoriesRecGroups: titleView = true; useCategories = true; 356 useRecGroups = true; break; 357 case TitlesRecGroups: titleView = true; useCategories = false; 358 useRecGroups = true; break; 359 case Categories: titleView = false; useCategories = true; 360 useRecGroups = false; break; 361 case CategoriesRecGroups: titleView = false; useCategories = true; 362 useRecGroups = true; break; 363 case RecGroups: titleView = false; useCategories = false; 364 useRecGroups = true; break; 411 case TitlesOnly: 412 mask = VIEW_TITLES; 413 break; 414 case TitlesCategories: 415 mask = VIEW_TITLES | VIEW_CATEGORIES; 416 break; 417 case TitlesCategoriesRecGroups: 418 mask = VIEW_TITLES | VIEW_CATEGORIES | VIEW_RECGROUPS; 419 break; 420 case TitlesRecGroups: 421 mask = VIEW_TITLES | VIEW_RECGROUPS; 422 break; 423 case Categories: 424 mask = VIEW_CATEGORIES; 425 break; 426 case CategoriesRecGroups: 427 mask = VIEW_CATEGORIES | VIEW_RECGROUPS; 428 break; 429 case RecGroups: 430 mask = VIEW_RECGROUPS; 431 break; 365 432 } 433 viewMask = (PlaybackBox::ViewMask)mask; 366 434 } 367 435 368 436 /* blocks until playing has stopped */ … … 1139 1207 ((titleList[titleIndex] != tempInfo->title) && 1140 1208 ((titleList[titleIndex] == tempInfo->recgroup) || 1141 1209 (titleList[titleIndex] == tempInfo->category))) || 1142 (!( titleView)))1210 (!(viewMask & VIEW_TITLES))) 1143 1211 tempSubTitle = tempInfo->title; 1144 1212 else 1145 1213 tempSubTitle = tempInfo->subtitle; … … 1150 1218 ((titleList[titleIndex] != tempInfo->title) && 1151 1219 ((titleList[titleIndex] == tempInfo->recgroup) || 1152 1220 (titleList[titleIndex] == tempInfo->category))) || 1153 (!( titleView))))1221 (!(viewMask & VIEW_TITLES)))) 1154 1222 { 1155 1223 tempSubTitle = tempSubTitle + " - \"" + 1156 1224 tempInfo->subtitle + "\""; … … 1361 1429 QString oldprogramid; 1362 1430 QDate oldoriginalAirDate; 1363 1431 QDateTime oldstartts; 1432 int oldrecpriority = 0; 1364 1433 p = progLists[oldtitle].at(progIndex); 1365 1434 if (p) 1366 1435 { … … 1368 1437 oldstartts = p->recstartts; 1369 1438 oldprogramid = p->programid; 1370 1439 oldoriginalAirDate = p->originalAirDate; 1440 oldrecpriority = p->recpriority; 1371 1441 } 1372 1442 1373 1443 QMap<QString, AvailableStatusType> asCache; … … 1387 1457 1388 1458 fillRecGroupPasswordCache(); 1389 1459 1460 ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting( 1461 "DisplayGroupTitleSort", TitleSortAlphabetical); 1462 1390 1463 QMap<QString, QString> sortedList; 1391 QRegExp prefixes = tr("^(The |A |An )");1392 1464 QString sTitle = ""; 1393 1465 1394 1466 bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0); … … 1410 1482 (p->category == recGroup ) && 1411 1483 ( !recGroupPwCache.contains(p->recgroup)))) 1412 1484 { 1413 if ( (titleView) || (useCategories) || (useRecGroups))1485 if (viewMask != VIEW_NONE) 1414 1486 progLists[""].prepend(p); 1415 1487 1416 1488 asKey = p->MakeUniqueKey(); … … 1419 1491 else 1420 1492 p->availableStatus = asAvailable; 1421 1493 1422 if ( titleView) // Normal title view1494 if ((viewMask & VIEW_TITLES)) // Show titles 1423 1495 { 1424 1496 progLists[p->title].prepend(p); 1425 sTitle = p->title;1426 sTitle.remove(prefixes);1497 sTitle = sortTitle(p->title, viewMask, titleSort, 1498 p->recpriority); 1427 1499 sTitle = sTitle.lower(); 1428 1500 sortedList[sTitle] = p->title; 1429 1501 } 1430 1502 1431 if (useRecGroups && p->recgroup != "") // Show recording groups 1503 if ((viewMask & VIEW_RECGROUPS) && 1504 p->recgroup != "") // Show recording groups 1432 1505 { 1433 1506 progLists[p->recgroup].prepend(p); 1434 1507 sortedList[p->recgroup.lower()] = p->recgroup; 1435 1508 1436 // If another view is also used, unset autodelete as another group will do it. 1437 if ((useCategories) || (titleView)) 1509 // If another view is also used, unset autodelete as 1510 // another group will do it. 1511 if ((viewMask & ~VIEW_RECGROUPS)) 1438 1512 progLists[p->recgroup].setAutoDelete(false); 1439 1513 } 1440 1514 1441 if (useCategories && p->category != "") // Show categories 1515 if ((viewMask & VIEW_CATEGORIES) && 1516 p->category != "") // Show categories 1442 1517 { 1443 1518 progLists[p->category].prepend(p); 1444 1519 sortedList[p->category.lower()] = p->category; 1445 // If another view is also used, unset autodelete as another group will do it 1446 if ((useRecGroups) || (titleView)) 1520 // If another view is also used, unset autodelete as 1521 // another group will do it 1522 if ((viewMask & ~VIEW_CATEGORIES)) 1447 1523 progLists[p->category].setAutoDelete(false); 1448 1524 } 1449 1525 } … … 1464 1540 return 0; 1465 1541 } 1466 1542 1467 titleList = sortedList.values();1468 1469 1543 QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date"); 1470 1544 1471 1545 if (episodeSort == "OrigAirDate") … … 1501 1575 // titles backwards until we find where we were or go past. This 1502 1576 // is somewhat inefficient, but it works. 1503 1577 1504 QString oldsTitle = oldtitle; 1505 oldsTitle.remove(prefixes); 1578 QStringList sTitleList = sortedList.keys(); 1579 titleList = sortedList.values(); 1580 1581 QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort, 1582 oldrecpriority); 1506 1583 oldsTitle = oldsTitle.lower(); 1507 1584 titleIndex = titleList.count() - 1; 1508 for ( int i = titleIndex; i >= 0; i--)1585 for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--) 1509 1586 { 1510 sTitle = titleList[i]; 1511 sTitle.remove(prefixes); 1587 sTitle = sTitleList[titleIndex]; 1512 1588 sTitle = sTitle.lower(); 1513 1589 1514 1590 if (oldsTitle > sTitle) 1591 { 1592 if (titleIndex + 1 < (int)titleList.count()) 1593 titleIndex++; 1515 1594 break; 1595 } 1516 1596 1517 titleIndex = i;1518 1519 1597 if (oldsTitle == sTitle) 1520 1598 break; 1521 1599 } … … 2252 2330 2253 2331 if (inTitle) 2254 2332 { 2255 if ( titleView)2333 if ((viewMask & VIEW_TITLES)) 2256 2334 popup->addButton(tr("Toggle playlist for this Category/Title"), 2257 2335 this, SLOT(togglePlayListTitle())); 2258 2336 else … … 3174 3252 if (expectingPopup) 3175 3253 cancelPopup(); 3176 3254 3177 if (titleView) titleView = false; 3178 else titleView = true; 3255 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3179 3256 3180 3257 playList.clear(); 3181 3258 connected = FillList(); … … 3424 3501 } 3425 3502 else if (action == "TOGGLERECORD") 3426 3503 { 3427 if (titleView) titleView = false; 3428 else titleView = true; 3504 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3429 3505 connected = FillList(); 3430 3506 paintSkipUpdate = false; 3431 3507 update(drawTotalBounds); … … 3984 4060 int result = recGroupPopup->ExecPopup(); 3985 4061 3986 4062 if (result == MythDialog::Accepted) 3987 setDefaultView( recGroupComboBox->currentItem());4063 setDefaultView((ViewType)recGroupComboBox->currentItem()); 3988 4064 3989 4065 delete recGroupComboBox; 3990 4066 -
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.")); … … 2269 2280 return gc; 2270 2281 } 2271 2282 2283 class DefaultViewSettings: public VerticalConfigurationGroup, 2284 public TriggeredConfigurationGroup { 2285 public: 2286 DefaultViewSettings(): 2287 VerticalConfigurationGroup(false, false, true, true), 2288 TriggeredConfigurationGroup(false) { 2289 2290 HostComboBox *defaultView = DefaultView(); 2291 addChild(defaultView); 2292 setTrigger(defaultView); 2293 2294 HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort"); 2295 titleSort->setLabel(tr("Sort Titles")); 2296 titleSort->addSelection(tr("Alphabetically"), 2297 QString::number(PlaybackBox::TitleSortAlphabetical)); 2298 titleSort->addSelection(tr("By Recording Priority"), 2299 QString::number(PlaybackBox::TitleSortRecPriority)); 2300 2301 for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++) 2302 { 2303 if (ii == PlaybackBox::TitlesOnly) 2304 addTarget(QString::number(ii), titleSort); 2305 else 2306 addTarget(QString::number(ii), 2307 new VerticalConfigurationGroup(false, false)); 2308 } 2309 } 2310 }; 2311 2272 2312 static HostCheckBox *PVR350OutputEnable() 2273 2313 { 2274 2314 HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable"); … … 3085 3125 pbox2->addChild(RememberRecGroup()); 3086 3126 pbox2->addChild(UseGroupNameAsAllPrograms()); 3087 3127 pbox2->addChild(LiveTVInAllPrograms()); 3088 pbox2->addChild( DefaultView());3128 pbox2->addChild(new DefaultViewSettings()); 3089 3129 addChild(pbox2); 3090 3130 3091 3131 addChild(new HwDecSettings()); … … 3310 3350 addChild(xboxset); 3311 3351 } 3312 3352 3353 // 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 … … 41 42 Delete, 42 43 } BoxType; 43 44 44 typedef enum 45 { 46 TitlesOnly, 47 TitlesCategories, 48 TitlesCategoriesRecGroups, 49 TitlesRecGroups, 50 Categories, 51 CategoriesRecGroups, 52 RecGroups, 45 // ViewType values cannot change; they are stored in the database. 46 typedef enum { 47 TitlesOnly = 0, 48 TitlesCategories = 1, 49 TitlesCategoriesRecGroups = 2, 50 TitlesRecGroups = 3, 51 Categories = 4, 52 CategoriesRecGroups = 5, 53 RecGroups = 6, 54 ViewTypes, // placeholder value, not in database 53 55 } ViewType; 54 56 57 // Sort function when TitlesOnly. Values are stored in database. 58 typedef enum { 59 TitleSortAlphabetical = 0, 60 TitleSortRecPriority = 1, 61 TitleSortMethods, // placeholder value, not in database 62 } ViewTitleSort; 63 64 typedef enum { 65 VIEW_NONE = 0x00, 66 VIEW_TITLES = 0x01, 67 VIEW_CATEGORIES = 0x02, 68 VIEW_RECGROUPS = 0x04, 69 VIEW_ALL = ~0x00, 70 } ViewMask; 71 55 72 typedef enum 56 73 { 57 74 EndOfRecording, … … 260 277 void updateCurGroup(QPainter *p); 261 278 void updateGroupInfo(QPainter *p, QRect& pr, QPixmap& pix, 262 279 QString cont_name = "group_info"); 263 void setDefaultView( intdefaultView);280 void setDefaultView(ViewType defaultView); 264 281 265 282 // Settings /////////////////////////////////////////////////////////////// 266 283 /// If "Play" this is a recording playback selection UI, … … 292 309 QString recGroup; 293 310 QString recGroupPassword; 294 311 QString curGroupPassword; 312 ViewMask viewMask; 295 313 296 314 // Theme parsing variables 297 315 XMLParse *theme; -
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, recorded.stars "961 "recorded.progend, recorded.stars, 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(32).toInt(); 1074 1073 1075 proginfo->recstatus = rsRecorded; 1074 1076 if (proginfo->recendts > rectime) 1075 1077 {