QString OEvent::toRichText()const { QString text, value; // description text += "<b><h3><img src=\"datebook/DateBook\">"; if ( !description().isEmpty() ) { text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); } text += "</h3></b><br><hr><br>"; // location if ( !(value = location()).isEmpty() ) { text += "<b>" + QObject::tr( "Location:" ) + "</b> "; text += Qtopia::escapeString(value) + "<br>"; } // all day event if ( isAllDay() ) { text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; } // multiple day event else if ( isMultipleDay () ) { text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; } // start & end times else { // start time if ( startDateTime().isValid() ) { text += "<b>" + QObject::tr( "Start:") + "</b> "; text += Qtopia::escapeString(startDateTime().toString() ). replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } // end time if ( endDateTime().isValid() ) { text += "<b>" + QObject::tr( "End:") + "</b> "; text += Qtopia::escapeString(endDateTime().toString() ). replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } } // categories if ( categoryNames("Calendar").count() ){ text += "<b>" + QObject::tr( "Category:") + "</b> "; text += categoryNames("Calendar").join(", "); text += "<br>"; } //notes if ( !note().isEmpty() ) { text += "<b>" + QObject::tr( "Note:") + "</b><br>"; text += note(); // text += Qtopia::escapeString(note() ). // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } return text; }
void MGPWorkitem::import(const MDomainObject& o) { SOPInstanceUID(o.value("sopinsuid")); SOPClassUID(o.value("sopclassuid")); status(o.value("status")); inputAvailabilityFlag(o.value("inputavailflag")); priority(o.value("priority")); procedureStepID(o.value("procstepid")); startDateTime(o.value("startdattim")); endDateTime(o.value("enddattim")); resultStudyInstanceUID(o.value("resultstuinsuid")); inputStudyInstanceUID(o.value("inputstuinsuid")); multipleCopiesFlag(o.value("multcopyflag")); description(o.value("description")); patientID(o.value("patientid")); patientName(o.value("patientname")); patientBirthDate(o.value("birthdate")); patientSex(o.value("sex")); workItemCodeValue(o.value("workitemcodevalue")); workItemCodeScheme(o.value("workitemcodescheme")); workItemCodeMeaning(o.value("workitemcodemeaning")); requestedProcAccessionNum(o.value("reqprocAccessionNum")); requestedProcID(o.value("reqprocID")); requestedProcDesc(o.value("reqprocDesc")); requestedProcCodevalue(o.value("reqprocCodevalue")); requestedProcCodemeaning(o.value("reqprocCodemeaning")); requestedProcCodescheme(o.value("reqprocCodescheme")); requestingPhysician(o.value("requestingPhys")); transactionUID(o.value("transactionUID")); }
void CGUIDialogBoxeeLiveTvCtx::LoadTimeSlot() { time_t startTime; time_t endTime; struct tm *loctime; m_model.GetCurrentTimeSlot(startTime, endTime); CStdString timeSlotStr = "[B]"; if (startTime == 0) { timeSlotStr += "NOW"; } else { loctime = localtime(&startTime); CDateTime startDateTime(*loctime); timeSlotStr += startDateTime.GetAsLocalizedTime("", false); } timeSlotStr += " - "; loctime = localtime(&endTime); CDateTime endDateTime(*loctime); timeSlotStr += endDateTime.GetAsLocalizedTime("", false); timeSlotStr += "[/B]"; SET_CONTROL_LABEL(CONTROL_LABEL_EPG,timeSlotStr); }
void Event::dump() const { qDebug() << "[Event" << id() << "] - task " << taskId() << " - start: " << startDateTime() << " - end: " << endDateTime() << " - duration: " << duration() << "seconds - comment:" << comment(); }
bool Event::operator == ( const Event& other ) const { return ( other.id() == id() && other.installationId() == installationId() && other.taskId() == taskId() && other.comment() == comment() && other.startDateTime() == startDateTime() && other.endDateTime() == endDateTime() && other.userId() == userId() && other.reportId() == reportId() ); }
void RecurrenceWidget::set(bool recurring, int frequency, QString period, QDate startDate, QDate endDate, int max) { if (DEBUG) qDebug() << objectName() << "::set(" << recurring << ", " << frequency << ", " << period << ", " << startDate << ", " << endDate << ", " << max << ") entered"; // run from the beginning of the start date to the end of the end date QDateTime startDateTime(startDate); QDateTime endDateTime(endDate.addDays(1)); endDateTime = endDateTime.addMSecs(-1); set(recurring, frequency, period, startDateTime, endDateTime, max); }
bool RecurrenceWidget::modified() const { if (DEBUG) qDebug() << "recurring:" << isRecurring() << _prevRecurring << "\n" << "period:" << period() << _prevPeriod << "\n" << "frequency:" << frequency() << _prevFrequency << "\n" << "startDateTime:" << startDateTime()<< _prevStartDateTime << "\n" << "endDateTime:" << endDateTime() << _prevEndDateTime << "\n" << "max:" << max() << _prevMax << "\n" << "_parentId:" << _parentId << _prevParentId << "\n" << "_parentType:" << _parentType << _prevParentType ; bool returnVal = (isRecurring() != _prevRecurring || period() != _prevPeriod || frequency() != _prevFrequency || startDateTime() != _prevStartDateTime|| endDateTime() != _prevEndDateTime || max() != _prevMax || _parentId != _prevParentId || _parentType != _prevParentType); return returnVal; }
// // Calculate End Time of TimeAlignment (UTC) // void CTzDbStdTimeAlignment::CalculateEndTime(TTime& aEndTime) { TInt endYear; TInt endMonth; TInt endDay; TInt endHour; TInt endMinute; TInt endSecond = 0; TInt endMicrosecond = 0; if (iPersistedEntity.iUntilYear == KMaxTUint16) { aEndTime = Time::MaxTTime(); } else { endYear = iPersistedEntity.iUntilYear; endMonth = iPersistedEntity.iUntilMonth; if (endMonth > EDecember) endMonth = EJanuary; endDay = iPersistedEntity.iUntilDayOfMonth; if (endDay > 31) endDay = 0; if (iPersistedEntity.iUntilTimeInMinutes == KMaxTUint16) { endHour = endMinute = 0; } else { endHour = iPersistedEntity.iUntilTimeInMinutes / 60; endMinute = iPersistedEntity.iUntilTimeInMinutes % 60; } TDateTime endDateTime(endYear,(TMonth)endMonth,endDay,endHour,endMinute,endSecond,endMicrosecond); aEndTime = endDateTime; // convert time to UTC TTzTimeReference taTimeReference(static_cast<TTzTimeReference>(iPersistedEntity.iUntilTimeReference) ); if (taTimeReference == ETzStdTimeReference) { aEndTime -= static_cast<TTimeIntervalMinutes>(iPersistedEntity.iUtcOffset); } // aEndTime is, at this point, the beginning of the the next Std Time Alignment aEndTime -= static_cast<TTimeIntervalSeconds>(1); } }
TInt CTzDbRuleSet::GetLocalTimeOffsetAtEndOfYearL(TInt aYear, TInt aUtcOffset) const { RArray<TTzRuleDefinition*> ruleDefs; CleanupClosePushL(ruleDefs); RArray<TTzRuleUse*> ruleUses; CleanupClosePushL(ruleUses); TDateTime startDateTime(aYear,EJanuary,0,0,0,0,0); TDateTime endDateTime(aYear,EDecember,30,23,59,59,0); FetchRuleDefinitionsL(ruleDefs,ruleUses,aYear,aYear); CVTzActualisedRules* actRules = CVTzActualisedRules::NewL(aYear,aYear); CleanupStack::PushL(actRules); TVTzActualisedRule tDefaultRule(startDateTime,aUtcOffset,ETzUtcTimeReference); ActualiseRuleDefinitionsL(*actRules,ruleDefs,ruleUses,aUtcOffset,startDateTime,endDateTime,tDefaultRule); TInt count = actRules->Count(); TInt finalOffset = (*actRules)[count-1].iNewOffset; CleanupStack::PopAndDestroy(3,&ruleDefs); return finalOffset; }
// Exporting Event data to map. Using the same // encoding as ODateBookAccessBackend_xml does.. // Thus, we could remove the stuff there and use this // for it and for all other places.. // Encoding should happen at one place, only ! (eilers) QMap<int, QString> OEvent::toMap()const { QMap<int, QString> retMap; retMap.insert( OEvent::FUid, QString::number( uid() ) ); retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); OPimAlarm alarm = notifiers().alarms()[0]; retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); if( parent() ) retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); if( children().count() ){ QArray<int> childr = children(); QString buf; for ( uint i = 0; i < childr.count(); i++ ) { if ( i != 0 ) buf += " "; buf += QString::number( childr[i] ); } retMap.insert( OEvent::FRecChildren, buf ); } // Add recurrence stuff if( hasRecurrence() ){ ORecur recur = recurrence(); QMap<int, QString> recFields = recur.toMap(); retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); } else { ORecur recur = recurrence(); QMap<int, QString> recFields = recur.toMap(); retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); } return retMap; }
QDateTime OEvent::endDateTimeInZone()const { /* if no timezone, or all day event or if the current and this timeZone match... */ if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); OTimeZone zone(data->timezone ); return zone.toDateTime( data->end, OTimeZone::current() ); }
bool RecurrenceWidget::save(bool externaltxn, RecurrenceChangePolicy cp, QString *message) { if (! message) message = new QString(); if (DEBUG) qDebug("%s::save(%d, %d, %p) entered with id %d type %s", qPrintable(objectName()), externaltxn, cp, message, _parentId, qPrintable(_parentType)); if (! modified()) return true; if (_parentId < 0 || _parentType.isEmpty()) { *message = tr("Could not save Recurrence information. The " "parent object/event has not been set."); if (! externaltxn) QMessageBox::warning(this, tr("Missing Data"), *message); else qWarning("%s", qPrintable(*message)); return false; } if (! externaltxn && cp == NoPolicy) { cp = getChangePolicy(); if (cp == NoPolicy) return false; } else if (externaltxn && cp == NoPolicy) { *message = tr("You must choose how open events are to be handled"); qWarning("%s", qPrintable(*message)); return false; } XSqlQuery rollbackq; if (! externaltxn) { XSqlQuery beginq("BEGIN;"); rollbackq.prepare("ROLLBACK;"); } XSqlQuery recurq; if (isRecurring()) { if (_id > 0) { if (cp == ChangeFuture) { XSqlQuery futureq; futureq.prepare("SELECT splitRecurrence(:parent_id, :parent_type," " :splitdate) AS newrecurid;"); futureq.bindValue(":parent_id", _parentId); futureq.bindValue(":parent_type", _parentType); futureq.bindValue(":splitdate", startDate()); futureq.exec(); if (futureq.first()) { int result = futureq.value("newrecurid").toInt(); if (result > 0) { _id = result; futureq.prepare("SELECT recur_parent_id" " FROM recur" " WHERE recur_id=:recur_id;"); futureq.bindValue(":recur_id", _id); futureq.exec(); if (futureq.first()) _parentId = futureq.value("recur_parent_id").toInt(); } else if (result < 0) { *message = storedProcErrorLookup("splitRecurrence", result); if (! externaltxn) { rollbackq.exec(); QMessageBox::warning(this, tr("Processing Error"), *message); } else qWarning("%s", qPrintable(*message)); return false; } } // one check for potentially 2 queries if (futureq.lastError().type() != QSqlError::NoError) { *message = futureq.lastError().text(); if (! externaltxn) { rollbackq.exec(); QMessageBox::warning(this, tr("Database Error"), *message); } else qWarning("%s", qPrintable(*message)); return false; } } recurq.prepare("UPDATE recur SET" " recur_parent_id=:recur_parent_id," " recur_parent_type=UPPER(:recur_parent_type)," " recur_period=:recur_period," " recur_freq=:recur_freq," " recur_start=:recur_start," " recur_end=:recur_end," " recur_max=:recur_max" " WHERE (recur_id=:recurid)" " RETURNING recur_id;"); recurq.bindValue(":recurid", _id); } else { recurq.prepare("INSERT INTO recur (" " recur_parent_id, recur_parent_type," " recur_period, recur_freq," " recur_start, recur_end," " recur_max" ") VALUES (" " :recur_parent_id, UPPER(:recur_parent_type)," " :recur_period, :recur_freq," " :recur_start, :recur_end," " :recur_max" ") RETURNING recur_id;"); } recurq.bindValue(":recur_parent_id", _parentId); recurq.bindValue(":recur_parent_type", _parentType); recurq.bindValue(":recur_period", periodCode()); recurq.bindValue(":recur_freq", frequency()); recurq.bindValue(":recur_start", startDateTime()); if (endDate() < _eot.date()) recurq.bindValue(":recur_end", endDateTime()); recurq.bindValue(":recur_max", max()); recurq.exec(); if (recurq.first()) { _id = recurq.value("recur_id").toInt(); _prevParentId = _parentId; _prevParentType = _parentType; _prevEndDateTime = endDateTime(); _prevFrequency = frequency(); _prevMax = max(); _prevPeriod = period(); _prevRecurring = isRecurring(); _prevStartDateTime = startDateTime(); } } else // ! isRecurring() { recurq.prepare("DELETE FROM recur" " WHERE ((recur_parent_id=:recur_parent_id)" " AND (UPPER(recur_parent_type)=UPPER(:recur_parent_type)));"); recurq.bindValue(":recur_parent_id", _parentId); recurq.bindValue(":recur_parent_type", _parentType); recurq.exec(); } if (recurq.lastError().type() != QSqlError::NoError) { *message = recurq.lastError().text(); if (! externaltxn) { rollbackq.exec(); QMessageBox::warning(this, tr("Database Error"), *message); } else qWarning("%s", qPrintable(*message)); return false; } if (cp == ChangeFuture) { int procresult = -1; QString procname = "deleteOpenRecurringItems"; XSqlQuery cfq; cfq.prepare("SELECT deleteOpenRecurringItems(:parentId, :parentType," " :splitdate, false) AS result;"); cfq.bindValue(":parentId", _parentId); cfq.bindValue(":parentType", _parentType); cfq.bindValue(":splitdate", startDate()); cfq.exec(); if (cfq.first()) { procresult = cfq.value("result").toInt(); if (procresult >= 0) { QString procname = "createOpenRecurringItems"; cfq.prepare("SELECT createRecurringItems(:parentId, :parentType)" " AS result;"); cfq.bindValue(":parentId", _parentId); cfq.bindValue(":parentType", _parentType); cfq.exec(); if (cfq.first()) procresult = cfq.value("result").toInt(); } } // error handling for either 1 or 2 queries so not elseif // check cfq.lastError() first to avoid misreporting db errs as -1 if (cfq.lastError().type() != QSqlError::NoError) { *message = cfq.lastError().text(); if (! externaltxn) { rollbackq.exec(); QMessageBox::critical(this, tr("Database Error"), *message); } else qWarning("%s", qPrintable(*message)); return false; } else if (procresult < 0) { *message = storedProcErrorLookup(procname, procresult); if (! externaltxn) { rollbackq.exec(); QMessageBox::critical(this, tr("Processing Error"), *message); } else qWarning("%s", qPrintable(*message)); return false; } } if (! externaltxn) XSqlQuery commitq("COMMIT;"); return true; }
int CGUIDialogBoxeeLiveTvCtx::LoadEPG() { LiveTvModelChannelsType channels = m_model.GetChannels(); LiveTvModelProgramsType programs = m_model.GetPrograms(); int currentChannelIndex = DVBManager::GetInstance().GetCurrentChannel()->GetIndex(); time_t startSlotTime; time_t endSlotTime; m_model.GetCurrentTimeSlot(startSlotTime, endSlotTime); m_listEPG.Clear(); int selectedItem = 0; for (int channelIndex = 0; channelIndex < (int) channels.size(); channelIndex++) { LiveTvModelChannel& channelInfo = channels[channelIndex]; if (!channelInfo.enabled) continue; bool isActive = (currentChannelIndex == channelIndex); std::vector<LiveTvModelProgram>& programsForChannel = programs[channelIndex]; if (programsForChannel.size() > 0) { bool firstProgram = true; foreach (LiveTvModelProgram program, programsForChannel) { time_t startTime = (time_t) program.info.start; struct tm* startLocaltime = localtime(&startTime); CDateTime startDateTime(*startLocaltime); time_t endTime = (time_t) program.info.end; struct tm* endLocaltime = localtime(&endTime); CDateTime endDateTime(*endLocaltime); CFileItemPtr channelItem(new CFileItem(program.info.title)); channelItem->SetProperty("ChannelName", channelInfo.label); channelItem->SetProperty("ChannelNumber", channelInfo.number); channelItem->SetProperty("channel-id", channelInfo.id); channelItem->SetProperty("hasepg", true); channelItem->SetProperty("rating", program.info.rating); channelItem->SetProperty("hasrating", program.info.rating.length() > 0); channelItem->SetProperty("issubitem", !firstProgram); channelItem->SetProperty("program-id", program.info.id); channelItem->SetProperty("starttime", startDateTime.GetAsLocalizedTime("", false)); channelItem->SetProperty("endtime", endDateTime.GetAsLocalizedTime("", false)); channelItem->SetProperty("isnow", program.isNow); channelItem->SetProperty("isnew", program.info.isNew); channelItem->SetProperty("isactive", isActive); channelItem->SetProperty("show-synopsis", program.info.synopsis); channelItem->SetProperty("show-title", program.info.title); channelItem->SetProperty("episode-title", program.info.episodeTitle); channelItem->SetProperty("episode-number", program.info.episodeNumber); channelItem->SetProperty("season-number", program.info.seasonNumber); // In case there are multiple shows on the selected channels, we only want // the first one to be active if (isActive) { selectedItem = m_listEPG.Size(); isActive = false; } if (program.isNow && program.social.watching) { int numOfFriendsWatching = program.social.friends.size(); channelItem->SetProperty("friendswatching", true); channelItem->SetProperty("watching-label", program.social.label); if (numOfFriendsWatching == 1) { channelItem->SetProperty("userthumb-1", program.social.friends[0].thumbSmallUrl); } else if (numOfFriendsWatching == 2) { channelItem->SetProperty("userthumb-1", program.social.friends[0].thumbSmallUrl); channelItem->SetProperty("userthumb-2", program.social.friends[1].thumbSmallUrl); } } m_listEPG.Add(channelItem); firstProgram = false; } }
TBool CTzDbZone::IsTimeInStdTimeAlignment(const TTzStdTimeAlignment& aStdTa, TInt aYear, TInt aMonth, TInt aDay, TInt aHour, TInt aMinute, TTzTimeReference aTimeRef) { TInt found = EFalse; if (aYear > (TInt)KMaxTUint16) { aYear = KMaxTUint16; // KMaxTUint16 (0xFFFF) is the value given to year when the end of a time alignment is unknown } if (aStdTa.iUntilYear > aYear) { found = ETrue; } else if (aStdTa.iUntilYear == aYear) { if ( (aStdTa.iUntilMonth > aMonth) || (aStdTa.iUntilMonth == KMaxTUint8) ) { found = ETrue; } else if (aStdTa.iUntilMonth == aMonth) { // evaluate the day and time the time alignment ends // and see if the received time falls in or out of the t.a. TTime ourTime; if (aYear >= (TInt)KMaxTUint16) { ourTime = Time::MaxTTime(); } else { TDateTime ourDateTime(aYear, (TMonth)aMonth, aDay, aHour, aMinute, 0, 0); ourTime = ourDateTime; // convert ourTime to UTC if (aTimeRef == ETzStdTimeReference) { ourTime -= static_cast<TTimeIntervalMinutes>(aStdTa.iUtcOffset); } } TTime endTime; if (aStdTa.iUntilYear == KMaxTUint16) { endTime = Time::MaxTTime(); } else { TDateTime endDateTime(aStdTa.iUntilYear, (TMonth)aStdTa.iUntilMonth, aStdTa.iUntilDayOfMonth, (aStdTa.iUntilTimeInMinutes / 60), (aStdTa.iUntilTimeInMinutes % 60), 0, 0); endTime = endDateTime; // convert endTime to UTC if (aTimeRef == ETzStdTimeReference) { endTime -= static_cast<TTimeIntervalMinutes>(aStdTa.iUtcOffset); } } // and finally compare both times if (endTime >= ourTime) { found = ETrue; } } } // else if (aStdTa->iUntilYear == aYear) return found; }