Ticket #171: mythtv.autoexpire-priority.171.diff
File mythtv.autoexpire-priority.171.diff, 8.8 KB (added by , 19 years ago) |
---|
-
libs/libmythtv/scheduledrecording.h
84 84 85 85 void setStart(const QDateTime& start); 86 86 void setEnd(const QDateTime& end); 87 int getRecPriority(void) const; 87 88 void setRecPriority(int recpriority); 88 89 void setRecGroup(const QString& recgroup); 89 90 -
libs/libmythtv/dbcheck.cpp
10 10 #include "mythdbcon.h" 11 11 12 12 /// This is the DB schema version expected by the running MythTV instance. 13 const QString currentDatabaseVersion = "109 0";13 const QString currentDatabaseVersion = "1091"; 14 14 15 15 static bool UpdateDBVersionNumber(const QString &newnumber); 16 16 static bool performActualUpdate(const QString updates[], QString version, … … 1991 1991 return false; 1992 1992 } 1993 1993 1994 if (dbver == "1090") 1995 { 1996 const QString updates[] = { 1997 "ALTER TABLE recorded ADD COLUMN recpriority INT NOT NULL DEFAULT 0;", 1998 "" 1999 }; 2000 2001 if (!performActualUpdate(updates, "1091", dbver)) 2002 return false; 2003 2004 MSqlQuery recordids(MSqlQuery::InitCon()); 2005 recordids.prepare("SELECT recordid,recpriority FROM record;"); 2006 if (recordids.exec() && recordids.isActive() && recordids.size() > 0) 2007 { 2008 MSqlQuery update(MSqlQuery::InitCon()); 2009 while (recordids.next()) 2010 { 2011 update.prepare(QString( 2012 "UPDATE recorded SET recpriority = %1 WHERE recordid = %2;") 2013 .arg(recordids.value(1).toInt()) 2014 .arg(recordids.value(0).toInt())); 2015 update.exec(); 2016 } 2017 } 2018 } 2019 1994 2020 // Drop xvmc_buffer_settings at some point 1995 2021 // Drop dead DVB tables eventually, too 1996 2022 … … 2480 2506 return true; 2481 2507 } 2482 2508 2509 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
libs/libmythtv/programinfo.cpp
704 704 "channel.callsign,channel.name,channel.commfree, " 705 705 "channel.outputfilters,seriesid,programid,filesize, " 706 706 "lastmodified,stars,previouslyshown,originalairdate, " 707 "hostname,recordid,transcoder,timestretch " 707 "hostname,recordid,transcoder,timestretch, " 708 "recorded.recpriority " 708 709 "FROM recorded " 709 710 "LEFT JOIN channel " 710 711 "ON recorded.chanid = channel.chanid " … … 765 766 proginfo->programflags = proginfo->getProgramFlags(); 766 767 767 768 proginfo->timestretch = query.value(21).toString().toFloat(); 769 proginfo->recpriority = query.value(22).toInt(); 768 770 769 771 return proginfo; 770 772 } … … 1228 1230 " subtitle,description,hostname,category,recgroup," 1229 1231 " autoexpire,recordid,seriesid,programid,stars," 1230 1232 " previouslyshown,originalairdate,findid,transcoder," 1231 " timestretch )"1233 " timestretch,recpriority)" 1232 1234 " VALUES(:CHANID,:STARTS,:ENDS,:TITLE,:SUBTITLE,:DESC," 1233 1235 " :HOSTNAME,:CATEGORY,:RECGROUP,:AUTOEXP,:RECORDID," 1234 1236 " :SERIESID,:PROGRAMID,:STARS,:REPEAT,:ORIGAIRDATE," 1235 " :FINDID,:TRANSCODER,:TIMESTRETCH );");1237 " :FINDID,:TRANSCODER,:TIMESTRETCH,:RECPRIORITY);"); 1236 1238 query.bindValue(":CHANID", chanid); 1237 1239 query.bindValue(":STARTS", starts); 1238 1240 query.bindValue(":ENDS", ends); … … 1252 1254 query.bindValue(":ORIGAIRDATE", originalAirDate); 1253 1255 query.bindValue(":TRANSCODER", record->GetTranscoder()); 1254 1256 query.bindValue(":TIMESTRETCH", timestretch); 1257 query.bindValue(":RECPRIORITY", record->getRecPriority()); 1255 1258 1256 1259 if (!query.exec() || !query.isActive()) 1257 1260 MythContext::DBError("WriteRecordedToDB", query); … … 3525 3528 else 3526 3529 return 0; 3527 3530 } 3531 3532 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
libs/libmythtv/scheduledrecording.cpp
608 609 endDate->setValue(end.date()); 609 610 } 610 611 612 int ScheduledRecording::getRecPriority(void) const { 613 return recpriority->getValue().toInt(); 614 } 615 611 616 void ScheduledRecording::setRecPriority(int newrecpriority) { 612 617 recpriority->setValue(newrecpriority); 613 618 } … … 774 779 recgroup->setChanged(); 775 780 } 776 781 777 778 779 782 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
programs/mythfrontend/globalsettings.cpp
514 514 bc->setLabel(QObject::tr("Auto Expire Method")); 515 515 bc->addSelection(QObject::tr("None"), "0"); 516 516 bc->addSelection(QObject::tr("Oldest Show First"), "1"); 517 bc->addSelection(QObject::tr("Lowest Priority First"), "2"); 517 518 bc->setHelpText(QObject::tr("Method used to determine which recorded " 518 519 "shows to delete first. Set to 'None' to " 519 520 "disable Auto Expire (not recommended).")); -
programs/mythbackend/autoexpire.cpp
467 467 468 468 switch(expMethod) 469 469 { 470 case 1: FillOldestFirst(); break; 470 case 1: 471 case 2: 472 FillOldestFirst(expMethod); 473 break; 471 474 472 475 // default falls through so list is empty so no AutoExpire 473 476 } … … 489 492 if (first->subtitle != "") 490 493 title += ": \"" + first->subtitle + "\""; 491 494 492 cout << title.local8Bit().leftJustify(40, ' ', true) << " " 495 cout << title.local8Bit().leftJustify(39, ' ', true) << " " 496 << QString("%1").arg(first->filesize / 1024 / 1024).local8Bit() 497 .rightJustify(5, ' ', true) << "MiB " 493 498 << first->startts.toString().local8Bit().leftJustify(24, ' ', true) 494 << " " << first->filesize / 1024 / 1024 << " MBytes" 499 << " [" << QString("%1").arg(first->recpriority).local8Bit() 500 .rightJustify(3, ' ', true) << "]" 495 501 << endl; 496 502 } 497 503 } … … 512 518 /** \fn AutoExpire::FillOldestFirst() 513 519 * \brief Creates a list of programs to delete, with the oldest file listed first. 514 520 */ 515 void AutoExpire::FillOldestFirst( void)521 void AutoExpire::FillOldestFirst(int expMethod) 516 522 { 517 523 QString fileprefix = gContext->GetFilePrefix(); 518 524 525 QString orderby; 526 527 switch (expMethod) 528 { 529 default: 530 case 1: // Oldest first 531 orderby = "starttime ASC"; 532 break; 533 534 case 2: // Lowest priority first 535 orderby = "recorded.recpriority ASC, starttime ASC"; 536 break; 537 } 538 519 539 MSqlQuery query(MSqlQuery::InitCon()); 520 540 QString querystr = QString( 521 541 "SELECT recorded.chanid,starttime,endtime,title,subtitle, " 522 "description,hostname,channum,name,callsign,seriesid,programid " 542 "description,hostname,channum,name,callsign,seriesid,programid, " 543 "recorded.recpriority " 523 544 "FROM recorded " 524 545 "LEFT JOIN channel ON recorded.chanid = channel.chanid " 525 546 "WHERE autoexpire > 0 " 526 "ORDER BY autoexpire DESC, starttime ASC"); 527 547 "ORDER BY autoexpire DESC, %1") 548 .arg(orderby); 549 528 550 query.prepare(querystr); 529 551 530 552 if (!query.exec() || !query.isActive() || !query.size()) … … 561 583 562 584 proginfo->seriesid = query.value(10).toString(); 563 585 proginfo->programid = query.value(11).toString(); 586 proginfo->recpriority = query.value(12).toInt(); 564 587 565 588 proginfo->pathname = proginfo->GetRecordFilename(fileprefix); 566 589 -
programs/mythbackend/autoexpire.h
34 34 private: 35 35 void ExpireEpisodesOverMax(void); 36 36 37 void FillOldestFirst( void);37 void FillOldestFirst(int expMethod); 38 38 void SendDeleteMessages(size_t, size_t); 39 39 void ClearExpireList(void); 40 40 void Sleep();