MythTV  0.26-pre
progdetails.cpp
Go to the documentation of this file.
00001 
00002 // qt
00003 #include <QKeyEvent>
00004 #include <QFile>
00005 #include <QTextStream>
00006 
00007 // myth
00008 #include "mythcorecontext.h"
00009 #include "mythdialogbox.h"
00010 #include "recordingrule.h"
00011 #include "mythdb.h"
00012 #include "mythuihelper.h"
00013 #include "mythmainwindow.h"
00014 
00015 #include "progdetails.h"
00016 #include <mythmiscutil.h>
00017 
00018 
00019 #define LASTPAGE 2
00020 
00021 ProgDetails::ProgDetails(MythScreenStack *parent, const ProgramInfo *progInfo) :
00022     MythScreenType (parent, "progdetails"),
00023     m_progInfo(*progInfo), m_browser(NULL),
00024     m_currentPage(0)
00025 {
00026 }
00027 
00028 bool ProgDetails::Create(void)
00029 {
00030     bool foundtheme = false;
00031 
00032     // Load the theme for this screen
00033     foundtheme = LoadWindowFromXML("schedule-ui.xml", "progdetails", this);
00034 
00035     if (!foundtheme)
00036         return false;
00037 
00038     bool err = false;
00039     UIUtilE::Assign(this, m_browser, "browser", &err);
00040 
00041     if (err)
00042     {
00043         LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'progdetails'");
00044         return false;
00045     }
00046 
00047     BuildFocusList();
00048 
00049     SetFocusWidget(m_browser);
00050 
00051     float zoom = gCoreContext->GetSetting("ProgDetailsZoom", "1.0").toFloat();
00052     m_browser->SetZoom(zoom);
00053 
00054     return true;
00055 }
00056 
00057 QString ProgDetails::getRatings(bool recorded, uint chanid, QDateTime startts)
00058 {
00059     QString table = (recorded) ? "recordedrating" : "programrating";
00060     QString sel = QString(
00061         "SELECT system, rating FROM %1 "
00062         "WHERE chanid  = :CHANID "
00063         "AND starttime = :STARTTIME").arg(table);
00064 
00065     MSqlQuery query(MSqlQuery::InitCon());
00066     query.prepare(sel);
00067     query.bindValue(":CHANID", chanid);
00068     query.bindValue(":STARTTIME", startts);
00069 
00070     if (!query.exec() || !query.isActive())
00071     {
00072         MythDB::DBError("ProgDetails::getRatings", query);
00073         return "";
00074     }
00075 
00076     QMap<QString,QString> main_ratings;
00077     QString advisory;
00078     while (query.next())
00079     {
00080         if (query.value(0).toString().toLower() == "advisory")
00081         {
00082             advisory += query.value(1).toString() + ", ";
00083             continue;
00084         }
00085         main_ratings[query.value(0).toString()] = query.value(1).toString();
00086     }
00087 
00088     advisory = advisory.left(advisory.length() - 2);
00089 
00090     if (main_ratings.empty())
00091         return advisory;
00092 
00093     if (!advisory.isEmpty())
00094         advisory = ": " + advisory;
00095 
00096     if (main_ratings.size() == 1)
00097     {
00098         return *main_ratings.begin() + advisory;
00099     }
00100 
00101     QString ratings;
00102     QMap<QString,QString>::const_iterator it;
00103     for (it = main_ratings.begin(); it != main_ratings.end(); ++it)
00104     {
00105         ratings += it.key() + ": " + *it + ", ";
00106     }
00107 
00108     return ratings + "Advisory" + advisory;
00109 }
00110 
00111 void ProgDetails::Init()
00112 {
00113     updatePage();
00114 }
00115 
00116 ProgDetails::~ProgDetails(void)
00117 {
00118     float zoom = m_browser->GetZoom();
00119     gCoreContext->SaveSetting("ProgDetailsZoom", QString().setNum(zoom));
00120 }
00121 
00122 bool ProgDetails::keyPressEvent(QKeyEvent *event)
00123 {
00124     if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
00125         return true;
00126 
00127     bool handled = false;
00128     QStringList actions;
00129     handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);
00130 
00131     for (int i = 0; i < actions.size() && !handled; i++)
00132     {
00133         QString action = actions[i];
00134         handled = true;
00135 
00136         if (action == "INFO")
00137         {
00138             m_currentPage++;
00139             if (m_currentPage >= LASTPAGE)
00140                 m_currentPage = 0;
00141 
00142             updatePage();
00143         }
00144         else if (action == "MENU")
00145             showMenu();
00146         else
00147             handled = false;
00148     }
00149 
00150     if (!handled && MythScreenType::keyPressEvent(event))
00151         handled = true;
00152 
00153     return handled;
00154 }
00155 
00156 void ProgDetails::updatePage(void)
00157 {
00158     if (m_page[m_currentPage].isEmpty())
00159         loadPage();
00160 
00161     m_browser->SetHtml(m_page[m_currentPage]);
00162 }
00163 
00164 void ProgDetails::addItem(const QString &key, const QString &title, const QString &data)
00165 {
00166     QString escapedKey = "%" + key + "%";
00167 
00168     if (data.isEmpty())
00169     {
00170         removeItem(key);
00171         return;
00172     }
00173 
00174     // find the key in the html and replace with the correct data
00175     for (int x = 0; x < m_html.size(); x++)
00176     {
00177         QString s = m_html[x];
00178         if (s.contains(escapedKey))
00179         {
00180             // replace the label first
00181             s.replace("%" + key + "_LABEL%", title);
00182             // now replace the data
00183             s.replace(escapedKey, data);
00184             m_html[x] = s;
00185         }
00186     }
00187 }
00188 
00189 void ProgDetails::removeItem(const QString &key)
00190 {
00191     // remove all line in the html that have key in them (should only be one line)
00192     for (int x = 0; x < m_html.size(); x++)
00193     {
00194         QString s = m_html[x];
00195         if (s.contains("%" + key + "%"))
00196         {
00197             m_html.removeAll(s);
00198             return;
00199         }
00200     }
00201 }
00202 
00203 void ProgDetails::loadPage(void)
00204 {
00205     loadHTML();
00206 
00207     MSqlQuery query(MSqlQuery::InitCon());
00208     QString category_type, showtype, year, epinum, rating, colorcode,
00209             title_pronounce;
00210     float stars = 0.0;
00211     int partnumber = 0, parttotal = 0;
00212     int audioprop = 0, videoprop = 0, subtype = 0, generic = 0;
00213     bool recorded = false;
00214 
00215     RecordingRule* record = NULL;
00216     if (m_progInfo.GetRecordingRuleID())
00217     {
00218         record = new RecordingRule();
00219         record->LoadByProgram(&m_progInfo);
00220     }
00221 
00222     if (m_progInfo.GetFilesize())
00223         recorded = true;
00224 
00225     if (m_progInfo.GetScheduledEndTime() != m_progInfo.GetScheduledStartTime())
00226     {
00227         QString ptable = "program";
00228         if (recorded)
00229             ptable = "recordedprogram";
00230 
00231         query.prepare(QString("SELECT category_type, airdate, stars,"
00232                       " partnumber, parttotal, audioprop+0, videoprop+0,"
00233                       " subtitletypes+0, syndicatedepisodenumber, generic,"
00234                       " showtype, colorcode, title_pronounce"
00235                       " FROM %1 WHERE chanid = :CHANID AND"
00236                       " starttime = :STARTTIME ;").arg(ptable));
00237 
00238         query.bindValue(":CHANID",    m_progInfo.GetChanID());
00239         query.bindValue(":STARTTIME", m_progInfo.GetScheduledStartTime());
00240 
00241         if (query.exec() && query.next())
00242         {
00243             category_type = query.value(0).toString();
00244             year = query.value(1).toString();
00245             stars = query.value(2).toDouble();
00246             partnumber = query.value(3).toInt();
00247             parttotal = query.value(4).toInt();
00248             audioprop = query.value(5).toInt();
00249             videoprop = query.value(6).toInt();
00250             subtype = query.value(7).toInt();
00251             epinum = query.value(8).toString();
00252             generic = query.value(9).toInt();
00253             showtype = query.value(10).toString();
00254             colorcode = query.value(11).toString();
00255             title_pronounce = query.value(12).toString();
00256         }
00257         else if (!query.isActive())
00258             MythDB::DBError("ProgDetails", query);
00259 
00260         rating = getRatings(
00261             recorded, m_progInfo.GetChanID(),
00262             m_progInfo.GetScheduledStartTime());
00263     }
00264 
00265     if (category_type.isEmpty() && !m_progInfo.GetProgramID().isEmpty())
00266     {
00267         QString prefix = m_progInfo.GetProgramID().left(2);
00268 
00269         if (prefix == "MV")
00270            category_type = "movie";
00271         else if (prefix == "EP")
00272            category_type = "series";
00273         else if (prefix == "SP")
00274            category_type = "sports";
00275         else if (prefix == "SH")
00276            category_type = "tvshow";
00277     }
00278 
00279     addItem("TITLE", tr("Title"),
00280             m_progInfo.toString(ProgramInfo::kTitleSubtitle, " - "));
00281 
00282     addItem("TITLE_PRONOUNCE", tr("Title Pronounce"), title_pronounce);
00283 
00284     QString s = m_progInfo.GetDescription();
00285 
00286     QString attr;
00287 
00288     if (partnumber > 0)
00289         attr += QString(tr("Part %1 of %2, ")).arg(partnumber).arg(parttotal);
00290 
00291     if (!rating.isEmpty() && rating != "NR")
00292         attr += rating + ", ";
00293     if (category_type == "movie")
00294     {
00295         if (!year.isEmpty())
00296             attr += year + ", ";
00297 
00298         if (stars > 0.0)
00299             attr += tr("%n star(s)", "", (int) (stars * 4.0)) + ", ";
00300     }
00301     if (!colorcode.isEmpty())
00302         attr += colorcode + ", ";
00303 
00304     if (audioprop & AUD_MONO)
00305         attr += tr("Mono") + ", ";
00306     if (audioprop & AUD_STEREO)
00307         attr += tr("Stereo") + ", ";
00308     if (audioprop & AUD_SURROUND)
00309         attr += tr("Surround Sound") + ", ";
00310     if (audioprop & AUD_DOLBY)
00311         attr += tr("Dolby Sound") + ", ";
00312     if (audioprop & AUD_HARDHEAR)
00313         attr += tr("Audio for Hearing Impaired") + ", ";
00314     if (audioprop & AUD_VISUALIMPAIR)
00315         attr += tr("Audio for Visually Impaired") + ", ";
00316 
00317     if (videoprop & VID_HDTV)
00318         attr += tr("HDTV") + ", ";
00319     if  (videoprop & VID_WIDESCREEN)
00320         attr += tr("Widescreen") + ", ";
00321     if  (videoprop & VID_AVC)
00322         attr += tr("AVC/H.264") + ", ";
00323     if  (videoprop & VID_720)
00324         attr += tr("720p Resolution") + ", ";
00325     if  (videoprop & VID_1080)
00326         attr += tr("1080i/p Resolution") + ", ";
00327 
00328     if (subtype & SUB_HARDHEAR)
00329         attr += tr("CC","Closed Captioned") + ", ";
00330     if (subtype & SUB_NORMAL)
00331         attr += tr("Subtitles Available") + ", ";
00332     if (subtype & SUB_ONSCREEN)
00333         attr += tr("Subtitled") + ", ";
00334     if (subtype & SUB_SIGNED)
00335         attr += tr("Deaf Signing") + ", ";
00336 
00337     if (generic && category_type == "series")
00338         attr += tr("Unidentified Episode") + ", ";
00339     else if (m_progInfo.IsRepeat())
00340         attr += tr("Repeat") + ", ";
00341 
00342     if (!attr.isEmpty())
00343     {
00344         attr.truncate(attr.lastIndexOf(','));
00345         s += " (" + attr + ")";
00346     }
00347 
00348     addItem("DESCRIPTION", tr("Description"), s);
00349 
00350     s.clear();
00351     if (!m_progInfo.GetCategory().isEmpty())
00352     {
00353         s = m_progInfo.GetCategory();
00354 
00355         query.prepare("SELECT genre FROM programgenres "
00356                       "WHERE chanid = :CHANID AND starttime = :STARTTIME "
00357                       "AND relevance > 0 ORDER BY relevance;");
00358 
00359         query.bindValue(":CHANID",    m_progInfo.GetChanID());
00360         query.bindValue(":STARTTIME", m_progInfo.GetScheduledStartTime());
00361 
00362         if (query.exec())
00363         {
00364             while (query.next())
00365                 s += ", " + query.value(0).toString();
00366         }
00367     }
00368     addItem("CATEGORY", tr("Category"), s);
00369 
00370     s.clear();
00371     if (!category_type.isEmpty())
00372     {
00373         s = category_type;
00374         if (!m_progInfo.GetSeriesID().isEmpty())
00375             s += "  (" + m_progInfo.GetSeriesID() + ")";
00376         if (!showtype.isEmpty())
00377             s += "  " + showtype;
00378     }
00379     addItem("CATEGORY_TYPE", tr("Type", "category_type"), s);
00380 
00381     addItem("EPISODE", tr("Episode Number"), epinum);
00382 
00383     s.clear();
00384     if (m_progInfo.GetOriginalAirDate().isValid() &&
00385         category_type != "movie")
00386     {
00387         s = MythDateToString(m_progInfo.GetOriginalAirDate(), kDateFull | kAddYear);
00388     }
00389     addItem("ORIGINAL_AIRDATE", tr("Original Airdate"), s);
00390 
00391     addItem("PROGRAMID", tr("Program ID"), m_progInfo.GetProgramID());
00392 
00393     QString actors, directors, producers, execProducers;
00394     QString writers, guestStars, hosts, adapters;
00395     QString presenters, commentators, guests;
00396 
00397     if (m_progInfo.GetScheduledEndTime() != m_progInfo.GetScheduledStartTime())
00398     {
00399         if (recorded)
00400             query.prepare("SELECT role,people.name FROM recordedcredits"
00401                           " AS credits"
00402                           " LEFT JOIN people ON credits.person = people.person"
00403                           " WHERE credits.chanid = :CHANID"
00404                           " AND credits.starttime = :STARTTIME"
00405                           " ORDER BY role;");
00406         else
00407             query.prepare("SELECT role,people.name FROM credits"
00408                           " LEFT JOIN people ON credits.person = people.person"
00409                           " WHERE credits.chanid = :CHANID"
00410                           " AND credits.starttime = :STARTTIME"
00411                           " ORDER BY role;");
00412         query.bindValue(":CHANID",    m_progInfo.GetChanID());
00413         query.bindValue(":STARTTIME", m_progInfo.GetScheduledStartTime());
00414 
00415         if (query.exec() && query.size() > 0)
00416         {
00417             QStringList plist;
00418             QString rstr, role, pname;
00419 
00420             while(query.next())
00421             {
00422                 role = query.value(0).toString();
00423                 /* The people.name column uses utf8_bin collation.
00424                  * Qt-MySQL drivers use QVariant::ByteArray for string-type
00425                  * MySQL fields marked with the BINARY attribute (those using a
00426                  * *_bin collation) and QVariant::String for all others.
00427                  * Since QVariant::toString() uses QString::fromAscii()
00428                  * (through QVariant::convert()) when the QVariant's type is
00429                  * QVariant::ByteArray, we have to use QString::fromUtf8()
00430                  * explicitly to prevent corrupting characters.
00431                  * The following code should be changed to use the simpler
00432                  * toString() approach, as above, if we do a DB update to
00433                  * coalesce the people.name values that differ only in case and
00434                  * change the collation to utf8_general_ci, to match the
00435                  * majority of other columns, or we'll have the same problem in
00436                  * reverse.
00437                  */
00438                 pname = QString::fromUtf8(query.value(1)
00439                                           .toByteArray().constData());
00440 
00441                 if (rstr != role)
00442                 {
00443                     if (rstr == "actor")
00444                         actors = plist.join(", ");
00445                     else if (rstr == "director")
00446                         directors = plist.join(", ");
00447                     else if (rstr == "producer")
00448                         producers = plist.join(", ");
00449                     else if (rstr == "executive_producer")
00450                         execProducers = plist.join(", ");
00451                     else if (rstr == "writer")
00452                         writers = plist.join(", ");
00453                     else if (rstr == "guest_star")
00454                         guestStars = plist.join(", ");
00455                     else if (rstr == "host")
00456                         hosts = plist.join(", ");
00457                     else if (rstr == "adapter")
00458                         adapters = plist.join(", ");
00459                     else if (rstr == "presenter")
00460                         presenters = plist.join(", ");
00461                     else if (rstr == "commentator")
00462                         commentators = plist.join(", ");
00463                     else if (rstr == "guest")
00464                         guests =  plist.join(", ");
00465 
00466                     rstr = role;
00467                     plist.clear();
00468                 }
00469 
00470                 plist.append(pname);
00471             }
00472             if (rstr == "actor")
00473                 actors = plist.join(", ");
00474             else if (rstr == "director")
00475                 directors = plist.join(", ");
00476             else if (rstr == "producer")
00477                 producers = plist.join(", ");
00478             else if (rstr == "executive_producer")
00479                 execProducers = plist.join(", ");
00480             else if (rstr == "writer")
00481                 writers = plist.join(", ");
00482             else if (rstr == "guest_star")
00483                 guestStars = plist.join(", ");
00484             else if (rstr == "host")
00485                 hosts = plist.join(", ");
00486             else if (rstr == "adapter")
00487                 adapters = plist.join(", ");
00488             else if (rstr == "presenter")
00489                 presenters = plist.join(", ");
00490             else if (rstr == "commentator")
00491                 commentators = plist.join(", ");
00492             else if (rstr == "guest")
00493                 guests =  plist.join(", ");
00494         }
00495     }
00496     addItem("ACTORS", tr("Actors"), actors);
00497     addItem("DIRECTOR", tr("Director"), directors);
00498     addItem("PRODUCER", tr("Producer"), producers);
00499     addItem("EXECUTIVE_PRODUCER", tr("Executive Producer"), execProducers);
00500     addItem("WRITER", tr("Writer"), writers);
00501     addItem("GUEST_STAR", tr("Guest Star"), guestStars);
00502     addItem("HOST", tr("Host"), hosts);
00503     addItem("ADAPTER", tr("Adapter"), adapters);
00504     addItem("PRESENTER", tr("Presenter"), presenters);
00505     addItem("COMMENTATOR", tr("Commentator"), commentators);
00506     addItem("GUEST", tr("Guest"), guests);
00507 
00508     // Begin MythTV information not found in the listings info
00509 //    msg += "<br>";
00510     QDateTime statusDate;
00511     if (m_progInfo.GetRecordingStatus() == rsWillRecord)
00512         statusDate = m_progInfo.GetScheduledStartTime();
00513 
00514     RecordingType rectype = kSingleRecord; // avoid kNotRecording
00515     RecStatusType recstatus = m_progInfo.GetRecordingStatus();
00516 
00517     if (recstatus == rsPreviousRecording || recstatus == rsNeverRecord ||
00518         recstatus == rsUnknown)
00519     {
00520         query.prepare("SELECT recstatus, starttime "
00521                       "FROM oldrecorded WHERE duplicate > 0 AND "
00522                       "future = 0 AND "
00523                       "((programid <> '' AND programid = :PROGRAMID) OR "
00524                       " (title <> '' AND title = :TITLE AND "
00525                       "  subtitle <> '' AND subtitle = :SUBTITLE AND "
00526                       "  description <> '' AND description = :DECRIPTION));");
00527 
00528         query.bindValue(":PROGRAMID",  m_progInfo.GetProgramID());
00529         query.bindValue(":TITLE",      m_progInfo.GetTitle());
00530         query.bindValue(":SUBTITLE",   m_progInfo.GetSubtitle());
00531         query.bindValue(":DECRIPTION", m_progInfo.GetDescription());
00532 
00533         if (!query.exec())
00534         {
00535             MythDB::DBError("showDetails", query);
00536         }
00537         else if (query.next())
00538         {
00539             if (recstatus == rsUnknown)
00540                 recstatus = RecStatusType(query.value(0).toInt());
00541 
00542             if (recstatus == rsPreviousRecording ||
00543                 recstatus == rsNeverRecord ||
00544                 recstatus == rsRecorded)
00545             {
00546                 statusDate = query.value(1).toDateTime();
00547             }
00548         }
00549     }
00550 
00551     if (recstatus == rsUnknown)
00552     {
00553         if (recorded)
00554         {
00555             recstatus = rsRecorded;
00556             statusDate = m_progInfo.GetScheduledStartTime();
00557         }
00558         else
00559         {
00560             // re-enable "Not Recording" status text
00561             rectype = m_progInfo.GetRecordingRuleType();
00562         }
00563     }
00564 
00565     s = toString(recstatus, rectype);
00566 
00567     if (statusDate.isValid())
00568         s += " " + MythDateTimeToString(statusDate, kDateFull | kAddYear);
00569 
00570     addItem("MYTHTV_STATUS", QString("MythTV " + tr("Status")), s);
00571 
00572     QString recordingRule;
00573     QString lastRecorded;
00574     QString nextRecording;
00575     QString averageTimeShift;
00576     QString watchListScore;
00577     QString watchListStatus;
00578     QString searchPhrase;
00579 
00580     if (m_progInfo.GetRecordingRuleID())
00581     {
00582         recordingRule = QString("%1, ").arg(m_progInfo.GetRecordingRuleID());
00583         if (m_progInfo.GetRecordingRuleType() != kNotRecording)
00584             recordingRule += toString(m_progInfo.GetRecordingRuleType());
00585         if (!(record->m_title.isEmpty()))
00586             recordingRule += QString(" \"%2\"").arg(record->m_title);
00587 
00588         query.prepare("SELECT last_record, next_record, avg_delay "
00589                       "FROM record WHERE recordid = :RECORDID");
00590         query.bindValue(":RECORDID", m_progInfo.GetRecordingRuleID());
00591 
00592         if (query.exec() && query.next())
00593         {
00594             if (query.value(0).toDateTime().isValid())
00595                 lastRecorded = MythDateTimeToString(query.value(0).toDateTime(),
00596                                                     kDateFull | kAddYear);
00597             if (query.value(1).toDateTime().isValid())
00598                 nextRecording = MythDateTimeToString(query.value(1).toDateTime(),
00599                                                     kDateFull | kAddYear);
00600             if (query.value(2).toInt() > 0)
00601                 averageTimeShift = tr("%n hour(s)", "",
00602                                                 query.value(2).toInt());
00603         }
00604         if (recorded)
00605         {
00606             if (m_progInfo.GetRecordingPriority2() > 0)
00607                 watchListScore =
00608                     QString::number(m_progInfo.GetRecordingPriority2());
00609 
00610             if (m_progInfo.GetRecordingPriority2() < 0)
00611             {
00612                 switch (m_progInfo.GetRecordingPriority2())
00613                 {
00614                     case wlExpireOff:
00615                         watchListStatus = tr("Auto-expire off");
00616                         break;
00617                     case wlWatched:
00618                         watchListStatus = tr("Marked as 'watched'");
00619                         break;
00620                     case wlEarlier:
00621                         watchListStatus = tr("Not the earliest episode");
00622                         break;
00623                     case wlDeleted:
00624                         watchListStatus = tr("Recently deleted episode");
00625                         break;
00626                 }
00627             }
00628         }
00629         if (record->m_searchType != kManualSearch &&
00630             record->m_description != m_progInfo.GetDescription())
00631         {
00632             searchPhrase = record->m_description
00633                 .replace("<", "&lt;").replace(">", "&gt;").replace("\n", " ");
00634         }
00635     }
00636     addItem("RECORDING_RULE", tr("Recording Rule"), recordingRule);
00637     addItem("LAST_RECORDED", tr("Last Recorded"), lastRecorded);
00638     addItem("NEXT_RECORDING", tr("Next Recording"), nextRecording);
00639     addItem("AVERAGE_TIME_SHIFT", tr("Average Time Shift"), averageTimeShift);
00640     addItem("WATCH_LIST_SCORE", tr("Watch List Score"), watchListScore);
00641     addItem("WATCH_LIST_STATUS", tr("Watch List Status"), watchListStatus);
00642     addItem("SEARCH_PHRASE", tr("Search Phrase"), searchPhrase);
00643 
00644     s.clear();
00645     if (m_progInfo.GetFindID())
00646     {
00647         QDate fdate(1970, 1, 1);
00648         fdate = fdate.addDays((int)m_progInfo.GetFindID() - 719528);
00649         s = QString("%1 (%2)").arg(m_progInfo.GetFindID())
00650             .arg(MythDateToString(fdate, kDateFull | kAddYear));
00651     }
00652     addItem("FINDID", tr("Find ID"), s);
00653 
00654     QString recordingHost;
00655     QString recordedFilename;
00656     QString recordedFileSize;
00657     QString recordingGroup;
00658     QString storageGroup;
00659     QString playbackGroup;
00660     QString recordingProfile;
00661 
00662     if (recorded)
00663     {
00664         recordingHost = m_progInfo.GetHostname();
00665         recordedFilename = m_progInfo.GetBasename();
00666         recordedFileSize = QString("%1 ")
00667             .arg(m_progInfo.GetFilesize()/((double)(1<<30)),0,'f',2);
00668         recordedFileSize += tr("GB", "GigaBytes");
00669 
00670         query.prepare("SELECT profile FROM recorded"
00671                       " WHERE chanid = :CHANID"
00672                       " AND starttime = :STARTTIME;");
00673         query.bindValue(":CHANID",    m_progInfo.GetChanID());
00674         query.bindValue(":STARTTIME", m_progInfo.GetRecordingStartTime());
00675 
00676         if (query.exec() && query.next())
00677         {
00678             recordingProfile = m_progInfo.i18n(query.value(0).toString());
00679         }
00680         recordingGroup = m_progInfo.i18n(m_progInfo.GetRecordingGroup());
00681         storageGroup   = m_progInfo.i18n(m_progInfo.GetStorageGroup());
00682         playbackGroup  = m_progInfo.i18n(m_progInfo.GetPlaybackGroup());
00683     }
00684     else if (m_progInfo.GetRecordingRuleID())
00685     {
00686         recordingProfile =  record->m_recProfile;
00687     }
00688     addItem("RECORDING_HOST", tr("Recording Host"), recordingHost);
00689     addItem("RECORDED_FILE_NAME", tr("Recorded File Name"), recordedFilename);
00690     addItem("RECORDED_FILE_SIZE", tr("Recorded File Size"), recordedFileSize);
00691     addItem("RECORDING_PROFILE", tr("Recording Profile"), recordingProfile);
00692     addItem("RECORDING_GROUP", tr("Recording Group"), recordingGroup);
00693     addItem("STORAGE_GROUP", tr("Storage Group"), storageGroup);
00694     addItem("PLAYBACK_GROUP", tr("Playback Group"),  playbackGroup);
00695 
00696     m_page[m_currentPage] = m_html.join("\n");
00697 
00698     delete record;
00699 }
00700 
00701 bool ProgDetails::loadHTML(void)
00702 {
00703     m_html.clear();
00704 
00705     QString filename = QString("htmls/progdetails_page%1.html").arg(m_currentPage + 1);
00706     if (!GetMythUI()->FindThemeFile(filename))
00707         return false;
00708 
00709     QFile file(QLatin1String(qPrintable(filename)));
00710 
00711     if (!file.exists())
00712         return false;
00713 
00714     if (file.open( QIODevice::ReadOnly ))
00715     {
00716         QTextStream stream(&file);
00717 
00718         while ( !stream.atEnd() )
00719         {
00720             m_html.append(stream.readLine());
00721         }
00722         file.close();
00723     }
00724     else
00725         return false;
00726 
00727     return true;
00728 }
00729 
00730 void ProgDetails::showMenu(void)
00731 {
00732     QString label = tr("Options");
00733 
00734     MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
00735     MythDialogBox *menuPopup = new MythDialogBox(label, popupStack, "menuPopup");
00736 
00737     if (menuPopup->Create())
00738     {
00739         menuPopup->SetReturnEvent(this, "menu");
00740 
00741         menuPopup->AddButton(tr("Zoom In"));
00742         menuPopup->AddButton(tr("Zoom Out"));
00743         menuPopup->AddButton(tr("Switch Page"));
00744 
00745         popupStack->AddScreen(menuPopup);
00746     }
00747     else
00748     {
00749         delete menuPopup;
00750     }
00751 }
00752 
00753 void ProgDetails::customEvent(QEvent *event)
00754 {
00755     if (event->type() == DialogCompletionEvent::kEventType)
00756     {
00757         DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);
00758 
00759         QString resultid   = dce->GetId();
00760         QString resulttext = dce->GetResultText();
00761 
00762         if (resultid == "menu")
00763         {
00764             if (resulttext == tr("Zoom Out"))
00765                 m_browser->ZoomOut();
00766             else if (resulttext == tr("Zoom In"))
00767                 m_browser->ZoomIn();
00768             else if (resulttext == tr("Switch Page"))
00769             {
00770                 m_currentPage++;
00771                 if (m_currentPage >= LASTPAGE)
00772                     m_currentPage = 0;
00773 
00774                 updatePage();
00775             }
00776         }
00777     }
00778 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends