Ticket #8328: 126-StartNow.new.2.patch

File 126-StartNow.new.2.patch, 5.4 KB (added by Bill <billstuff2001@…>, 14 years ago)
  • mythtv/programs/mythfrontend/schedulecommon.cpp

    old new void ScheduleCommon::ShowRecordingDialog 
    186186        menuPopup->SetReturnEvent(this, "schedulerecording");
    187187
    188188        QDateTime now = QDateTime::currentDateTime();
     189        QDateTime nowp2 = now.addSecs(2 * 60 * 60); // two hours from now
    189190       
    190         if (recinfo.recstartts < now && recinfo.recendts > now)
     191        if (recinfo.recstartts > now && recinfo.recstartts < nowp2 && recinfo.recstatus == rsWillRecord)
     192            menuPopup->AddButton(tr("Start Now"), qVariantFromValue(recinfo));
     193
     194        if (recinfo.recstatus == rsRecording)
    191195        {
    192             if (recinfo.recstatus != rsRecording)
     196            menuPopup->AddButton(tr("Stop recording"),
     197                                 qVariantFromValue(recinfo));
     198            menuPopup->AddButton(tr("Change Ending Time"),
     199                                 qVariantFromValue(recinfo));
     200        }
     201
     202        if (recinfo.recstartts <= now && recinfo.recendts > now && recinfo.recstatus != rsRecording)
    193203                menuPopup->AddButton(tr("Reactivate"),
    194204                                     qVariantFromValue(recinfo));
    195             else
    196                 menuPopup->AddButton(tr("Stop recording"),
    197                                      qVariantFromValue(recinfo));
    198         }
    199205
    200206        if (recinfo.recendts > now)
    201207        {
    void ScheduleCommon::ShowRecordingDialog 
    229235            }
    230236           
    231237            if (recinfo.rectype != kOverrideRecord &&
    232                 recinfo.rectype != kDontRecord)
     238                recinfo.rectype != kDontRecord &&
     239                recinfo.recstatus != rsRecording)
    233240            {
    234                 if (recinfo.recstatus == rsRecording)
    235                 {
    236                     menuPopup->AddButton(tr("Change Ending Time"),
    237                                          qVariantFromValue(recinfo));
    238                 }
    239                 else
     241                menuPopup->AddButton(tr("Edit Options"),
     242                                     qVariantFromValue(recinfo));
     243
     244                if (recinfo.rectype != kSingleRecord &&
     245                    recinfo.rectype != kFindOneRecord)
    240246                {
    241                     menuPopup->AddButton(tr("Edit Options"),
     247                    menuPopup->AddButton(tr("Add Override"),
    242248                                         qVariantFromValue(recinfo));
    243                    
    244                     if (recinfo.rectype != kSingleRecord &&
    245                         recinfo.rectype != kFindOneRecord)
    246                     {
    247                         menuPopup->AddButton(tr("Add Override"),
    248                                              qVariantFromValue(recinfo));
    249                     }
    250249                }
    251250            }
    252251           
    253             if (recinfo.rectype == kOverrideRecord ||
    254                 recinfo.rectype == kDontRecord)
     252            if ((recinfo.rectype == kOverrideRecord ||
     253                 recinfo.rectype == kDontRecord) &&
     254                (recinfo.recstatus != rsRecording))
    255255            {
    256                 if (recinfo.recstatus == rsRecording)
    257                 {
    258                     menuPopup->AddButton(tr("Change Ending Time"),
    259                                          qVariantFromValue(recinfo));
    260                 }
    261                 else
    262                 {
    263                     menuPopup->AddButton(tr("Edit Override"),
    264                                          qVariantFromValue(recinfo));
    265                     menuPopup->AddButton(tr("Clear Override"),
    266                                          qVariantFromValue(recinfo));
    267                 }
     256                menuPopup->AddButton(tr("Edit Override"),
     257                                     qVariantFromValue(recinfo));
     258                menuPopup->AddButton(tr("Clear Override"),
     259                                     qVariantFromValue(recinfo));
    268260            }
    269261        }       
    270262       
    void ScheduleCommon::customEvent(QEvent  
    522514            {
    523515                MakeOverride(&recInfo);
    524516            }
     517            else if (resulttext == tr("Start Now"))
     518            {
     519                RecordingRule *recrule = new RecordingRule();
     520                if (!recrule->LoadByProgram(static_cast<ProgramInfo*>(&recInfo)))
     521                {
     522                    VERBOSE(VB_IMPORTANT, QString("Failed to load by program info"));
     523                    delete recrule;
     524                    return;
     525                }
     526
     527                if (recInfo.rectype != kSingleRecord &&
     528                    recInfo.rectype != kOverrideRecord &&
     529                    recInfo.rectype != kFindOneRecord)
     530                {
     531                    if (!recrule->MakeOverride())
     532                    {
     533                        VERBOSE(VB_IMPORTANT, QString("Failed to make Override"));
     534                        delete recrule;
     535                        return;
     536                    }
     537                    recrule->m_type = kOverrideRecord;
     538                }
     539
     540                QDateTime now = QDateTime::currentDateTime();
     541                int newoffset = recrule->m_startOffset;
     542                newoffset +=  (now.secsTo(recInfo.recstartts) / 60) + 1;
     543                recrule->m_startOffset = newoffset;
     544
     545                recrule->Save();
     546                delete recrule;
     547
     548            }
    525549        }
    526550    }
    527551}