Ticket #690: mythtv.watch_recordings.5.diff
File mythtv.watch_recordings.5.diff, 19.2 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 … … 181 238 drawTransPixmap = new QPixmap(); 182 239 183 240 bool displayCat = gContext->GetNumSetting("DisplayRecGroupIsCategory", 0); 184 int defaultView = gContext->GetNumSetting("DisplayGroupDefaultView", 0); 241 ViewType defaultView = (ViewType)gContext->GetNumSetting( 242 "DisplayGroupDefaultView", TitlesOnly); 185 243 int initialFilt = gContext->GetNumSetting("QueryInitialFilter", 0); 186 244 187 245 progLists[""]; … … 346 404 } 347 405 } 348 406 349 void PlaybackBox::setDefaultView( intdefaultView)407 void PlaybackBox::setDefaultView(ViewType defaultView) 350 408 { 409 int mask; 410 351 411 switch (defaultView) 352 412 { 353 413 default: 354 case TitlesOnly: titleView = true; useCategories = false; 355 useRecGroups = false; break; 356 case TitlesCategories: titleView = true; useCategories = true; 357 useRecGroups = false; break; 358 case TitlesCategoriesRecGroups: titleView = true; useCategories = true; 359 useRecGroups = true; break; 360 case TitlesRecGroups: titleView = true; useCategories = false; 361 useRecGroups = true; break; 362 case Categories: titleView = false; useCategories = true; 363 useRecGroups = false; break; 364 case CategoriesRecGroups: titleView = false; useCategories = true; 365 useRecGroups = true; break; 366 case RecGroups: titleView = false; useCategories = false; 367 useRecGroups = true; break; 414 case TitlesOnly: 415 mask = VIEW_TITLES; 416 break; 417 case TitlesCategories: 418 mask = VIEW_TITLES | VIEW_CATEGORIES; 419 break; 420 case TitlesCategoriesRecGroups: 421 mask = VIEW_TITLES | VIEW_CATEGORIES | VIEW_RECGROUPS; 422 break; 423 case TitlesRecGroups: 424 mask = VIEW_TITLES | VIEW_RECGROUPS; 425 break; 426 case Categories: 427 mask = VIEW_CATEGORIES; 428 break; 429 case CategoriesRecGroups: 430 mask = VIEW_CATEGORIES | VIEW_RECGROUPS; 431 break; 432 case RecGroups: 433 mask = VIEW_RECGROUPS; 434 break; 368 435 } 436 viewMask = (PlaybackBox::ViewMask)mask; 369 437 } 370 438 371 439 /* blocks until playing has stopped */ … … 571 639 tmp->fillRect(QRect(QPoint(0, 0), size()), 572 640 QBrush(QColor(10, 10, 10), Dense4Pattern)); 573 641 else if (transparentFlag == 1) 574 tmp->drawPixmap(0, 0, *drawTransPixmap, 0, 0, (int)(800*wmult), 575 (int)(600*hmult)); 642 { 643 int ww, hh; 644 645 if (d->IsWideMode()) 646 { 647 ww = 1280; 648 hh = 720; 649 } 650 else 651 { 652 ww = 800; 653 hh = 600; 654 } 655 tmp->drawPixmap(0, 0, *drawTransPixmap, 0, 0, (int)(ww*wmult), 656 (int)(hh*hmult)); 657 } 576 658 */ 577 659 } 578 660 void PlaybackBox::updateCurGroup(QPainter *p) … … 1115 1197 ((titleList[titleIndex] != tempInfo->title) && 1116 1198 ((titleList[titleIndex] == tempInfo->recgroup) || 1117 1199 (titleList[titleIndex] == tempInfo->category))) || 1118 (!( titleView)))1200 (!(viewMask & VIEW_TITLES))) 1119 1201 tempSubTitle = tempInfo->title; 1120 1202 else 1121 1203 tempSubTitle = tempInfo->subtitle; … … 1126 1208 ((titleList[titleIndex] != tempInfo->title) && 1127 1209 ((titleList[titleIndex] == tempInfo->recgroup) || 1128 1210 (titleList[titleIndex] == tempInfo->category))) || 1129 (!( titleView))))1211 (!(viewMask & VIEW_TITLES)))) 1130 1212 { 1131 1213 tempSubTitle = tempSubTitle + " - \"" + 1132 1214 tempInfo->subtitle + "\""; … … 1337 1419 QString oldprogramid; 1338 1420 QDate oldoriginalAirDate; 1339 1421 QDateTime oldstartts; 1422 int oldrecpriority = 0; 1340 1423 p = progLists[oldtitle].at(progIndex); 1341 1424 if (p) 1342 1425 { … … 1344 1427 oldstartts = p->recstartts; 1345 1428 oldprogramid = p->programid; 1346 1429 oldoriginalAirDate = p->originalAirDate; 1430 oldrecpriority = p->recpriority; 1347 1431 } 1348 1432 1349 1433 QMap<QString, AvailableStatusType> asCache; … … 1364 1448 1365 1449 fillRecGroupPasswordCache(); 1366 1450 1451 ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting( 1452 "DisplayGroupTitleSort", TitleSortAlphabetical); 1453 1367 1454 QMap<QString, QString> sortedList; 1368 QRegExp prefixes = tr("^(The |A |An )");1369 1455 QString sTitle = ""; 1370 1456 1371 1457 bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0); … … 1388 1474 (p->category == recGroup ) && 1389 1475 ( !recGroupPwCache.contains(p->recgroup)))) 1390 1476 { 1391 if ( (titleView) || (useCategories) || (useRecGroups))1477 if (viewMask != VIEW_NONE) 1392 1478 progLists[""].prepend(p); 1393 1479 1394 1480 asKey = p->MakeUniqueKey(); … … 1397 1483 else 1398 1484 p->availableStatus = asAvailable; 1399 1485 1400 if ( titleView) // Normal title view1486 if ((viewMask & VIEW_TITLES)) // Show titles 1401 1487 { 1402 1488 progLists[p->title].prepend(p); 1403 sTitle = p->title;1404 sTitle.remove(prefixes);1489 sTitle = sortTitle(p->title, viewMask, titleSort, 1490 p->recpriority); 1405 1491 sTitle = sTitle.lower(); 1406 1492 sortedList[sTitle] = p->title; 1407 1493 } 1408 1494 1409 if (useRecGroups && p->recgroup != "") // Show recording groups 1495 if ((viewMask & VIEW_RECGROUPS) && 1496 p->recgroup != "") // Show recording groups 1410 1497 { 1411 1498 progLists[p->recgroup].prepend(p); 1412 1499 sortedList[p->recgroup.lower()] = p->recgroup; 1413 1500 1414 // If another view is also used, unset autodelete as another group will do it. 1415 if ((useCategories) || (titleView)) 1501 // If another view is also used, unset autodelete as 1502 // another group will do it. 1503 if ((viewMask & ~VIEW_RECGROUPS)) 1416 1504 progLists[p->recgroup].setAutoDelete(false); 1417 1505 } 1418 1506 1419 if (useCategories && p->category != "") // Show categories 1507 if ((viewMask & VIEW_CATEGORIES) && 1508 p->category != "") // Show categories 1420 1509 { 1421 1510 progLists[p->category].prepend(p); 1422 1511 sortedList[p->category.lower()] = p->category; 1423 // If another view is also used, unset autodelete as another group will do it 1424 if ((useRecGroups) || (titleView)) 1512 // If another view is also used, unset autodelete as 1513 // another group will do it 1514 if ((viewMask & ~VIEW_CATEGORIES)) 1425 1515 progLists[p->category].setAutoDelete(false); 1426 1516 } 1427 1517 } … … 1442 1532 return 0; 1443 1533 } 1444 1534 1445 titleList = sortedList.values();1446 1447 1535 QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date"); 1448 1536 1449 1537 if (episodeSort == "OrigAirDate") … … 1479 1567 // titles backwards until we find where we were or go past. This 1480 1568 // is somewhat inefficient, but it works. 1481 1569 1482 QString oldsTitle = oldtitle; 1483 oldsTitle.remove(prefixes); 1570 QStringList sTitleList = sortedList.keys(); 1571 titleList = sortedList.values(); 1572 1573 QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort, 1574 oldrecpriority); 1484 1575 oldsTitle = oldsTitle.lower(); 1485 1576 titleIndex = titleList.count() - 1; 1486 for ( int i = titleIndex; i >= 0; i--)1577 for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--) 1487 1578 { 1488 sTitle = titleList[i]; 1489 sTitle.remove(prefixes); 1579 sTitle = sTitleList[titleIndex]; 1490 1580 sTitle = sTitle.lower(); 1491 1581 1492 1582 if (oldsTitle > sTitle) 1583 { 1584 if (titleIndex + 1 < (int)titleList.count()) 1585 titleIndex++; 1493 1586 break; 1587 } 1494 1588 1495 titleIndex = i;1496 1497 1589 if (oldsTitle == sTitle) 1498 1590 break; 1499 1591 } … … 2230 2322 2231 2323 if (inTitle) 2232 2324 { 2233 if ( titleView)2325 if ((viewMask & VIEW_TITLES)) 2234 2326 popup->addButton(tr("Toggle playlist for this Category/Title"), 2235 2327 this, SLOT(togglePlayListTitle())); 2236 2328 else … … 3152 3244 if (expectingPopup) 3153 3245 cancelPopup(); 3154 3246 3155 if (titleView) titleView = false; 3156 else titleView = true; 3247 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3157 3248 3158 3249 playList.clear(); 3159 3250 connected = FillList(); … … 3402 3493 } 3403 3494 else if (action == "TOGGLERECORD") 3404 3495 { 3405 if (titleView) titleView = false; 3406 else titleView = true; 3496 viewMask = viewMaskToggle(viewMask, VIEW_TITLES); 3407 3497 connected = FillList(); 3408 3498 paintSkipUpdate = false; 3409 3499 update(drawTotalBounds); … … 3871 3961 int result = recGroupPopup->ExecPopup(); 3872 3962 3873 3963 if (result == MythDialog::Accepted) 3874 setDefaultView( recGroupComboBox->currentItem());3964 setDefaultView((ViewType)recGroupComboBox->currentItem()); 3875 3965 3876 3966 delete recGroupComboBox; 3877 3967 -
programs/mythfrontend/globalsettings.cpp
13 13 #include "dbsettings.h" 14 14 #include "langsettings.h" 15 15 #include "mpeg/iso639.h" 16 #include "playbackbox.h" 16 17 #include "globalsettings.h" 17 18 #include "recordingprofile.h" 18 19 #include "scheduledrecording.h" … … 304 305 HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView"); 305 306 gc->setLabel(QObject::tr("Default View")); 306 307 307 gc->addSelection(QObject::tr("Show Titles only"), "0"); 308 gc->addSelection(QObject::tr("Show Titles and Categories"), "1"); 309 gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2"); 310 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3"); 311 gc->addSelection(QObject::tr("Show Categories only"), "4"); 312 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5"); 313 gc->addSelection(QObject::tr("Show Recording Groups only"), "6"); 308 gc->addSelection(QObject::tr("Show Titles only"), 309 QString::number(PlaybackBox::TitlesOnly)); 310 gc->addSelection(QObject::tr("Show Titles and Categories"), 311 QString::number(PlaybackBox::TitlesCategories)); 312 gc->addSelection(QObject::tr( 313 "Show Titles, Categories, and Recording Groups"), 314 QString::number(PlaybackBox::TitlesCategoriesRecGroups)); 315 gc->addSelection(QObject::tr("Show Titles and Recording Groups"), 316 QString::number(PlaybackBox::TitlesRecGroups)); 317 gc->addSelection(QObject::tr("Show Categories only"), 318 QString::number(PlaybackBox::Categories)); 319 gc->addSelection(QObject::tr("Show Categories and Recording Groups"), 320 QString::number(PlaybackBox::CategoriesRecGroups)); 321 gc->addSelection(QObject::tr("Show Recording Groups only"), 322 QString::number(PlaybackBox::RecGroups)); 314 323 315 324 gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen " 316 325 "by default.")); … … 2306 2315 return gc; 2307 2316 } 2308 2317 2318 class DefaultViewSettings: public VerticalConfigurationGroup, 2319 public TriggeredConfigurationGroup { 2320 public: 2321 DefaultViewSettings(): 2322 VerticalConfigurationGroup(false, false, true, true), 2323 TriggeredConfigurationGroup(false) { 2324 2325 HostComboBox *defaultView = DefaultView(); 2326 addChild(defaultView); 2327 setTrigger(defaultView); 2328 2329 HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort"); 2330 titleSort->setLabel(tr("Sort Titles")); 2331 titleSort->addSelection(tr("Alphabetically"), 2332 QString::number(PlaybackBox::TitleSortAlphabetical)); 2333 titleSort->addSelection(tr("By Recording Priority"), 2334 QString::number(PlaybackBox::TitleSortRecPriority)); 2335 2336 for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++) 2337 { 2338 if (ii == PlaybackBox::TitlesOnly) 2339 addTarget(QString::number(ii), titleSort); 2340 else 2341 addTarget(QString::number(ii), 2342 new VerticalConfigurationGroup(false, false)); 2343 } 2344 } 2345 }; 2346 2309 2347 static HostCheckBox *PVR350OutputEnable() 2310 2348 { 2311 2349 HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable"); … … 3124 3162 pbox2->addChild(RememberRecGroup()); 3125 3163 pbox2->addChild(UseGroupNameAsAllPrograms()); 3126 3164 pbox2->addChild(LiveTVInAllPrograms()); 3127 pbox2->addChild( DefaultView());3165 pbox2->addChild(new DefaultViewSettings()); 3128 3166 addChild(pbox2); 3129 3167 3130 3168 addChild(new HwDecSettings()); … … 3351 3389 addChild(xboxset); 3352 3390 } 3353 3391 3392 // 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
960 960 "recorded.basename, recorded.progstart, " 961 961 "recorded.progend, recorded.stars, " 962 962 "recordedprogram.stereo, recordedprogram.hdtv, " 963 "recordedprogram.closecaptioned, transcoded " 963 "recordedprogram.closecaptioned, transcoded, " 964 "recorded.recpriority " 964 965 "FROM recorded " 965 966 "LEFT JOIN record ON recorded.recordid = record.recordid " 966 967 "LEFT JOIN channel ON recorded.chanid = channel.chanid " … … 1079 1080 proginfo->recgroup = query.value(16).toString(); 1080 1081 proginfo->playgroup = query.value(27).toString(); 1081 1082 1083 proginfo->recpriority = query.value(36).toInt(); 1084 1082 1085 proginfo->recstatus = rsRecorded; 1083 1086 if (proginfo->recendts > rectime) 1084 1087 {