void Clock::refreshTime() { if(runClock == true) { if(msec > 0) msec--; else { msec = 99; if(sec > 0) sec--; else { sec = 59; if(min > 0) min--; else { min = MINSET; sec = SECSET; msec = MSECSET; alarmTime(); } } } //QString b=QString("%1").arg(i, 3, 10, QChar('0')); refreshLCD(); } }
// ----------------------------------------------------------------------------- // CPIMAgnEventAdapter::ConvertAlarmToAgnL // Converts alarm from PIM item to a native entry. The alarm is calculated // from the start date of the event and if it is not present, the alarm field // is ignored because there is no possibility to calculate it // ----------------------------------------------------------------------------- // void CPIMAgnEventAdapter::ConvertAlarmToAgnL(const MPIMEventItem& aItem, CCalEntry& aEntry) { JELOG2(EPim); const MPIMItemData& itemData = aItem.ItemData(); // Note that start time must be set before alarm can be calculated // Add start to the item so alarm can be properly converted. The // native entry does not accept alarm value if start is not present if (itemData.CountValues(EPIMEventStart) == 0) { User::Leave(KErrArgument); } else { ConvertDateFieldToAgnL(aItem, aEntry, EPIMEventStart); } __ASSERT_DEBUG(aEntry.StartTimeL().TimeUtcL() != Time::NullTTime(), User::Panic(KPIMPanicCategory, EPIMPanicInvalidState)); // Get alarm value from the Java item. There should be only one alarm // value supported by the PIM API because native entries do not support // multiple alarm values. const TPIMFieldData alarmData = itemData.ValueL(EPIMEventAlarm, 0); TInt value = alarmData.IntegerValue(); // Count the alarm value from the start date of the event TTime entryStart = aEntry.StartTimeL().TimeLocalL(); const TPIMFieldData startData = itemData.ValueL(EPIMEventStart, 0); TPIMDate startTime = startData.DateValue(); ConvertTimeL(startTime, EPIMDateLocal); TTimeIntervalSeconds temp(0); User::LeaveIfError(entryStart.SecondsFrom(startTime, temp)); // Add difference between PIM API start and start which has been // converted to the item (in case if the date has been changed, it is // reflected here) value += temp.Int(); // Check that if the alarm has passed to the following day. In this case, // the alarm is transferred back to 12 o'clock of the current start date TTime alarmTime(entryStart - TTimeIntervalSeconds(value)); // Temporary date. This date is used when calculating if the alarm // value has passed to the following date. TTime startOfNextDay(StartOfDay(startTime + TTimeIntervalDays(1))); if (alarmTime >= startOfNextDay) { alarmTime = StartOfDay(entryStart); alarmTime += TTimeIntervalSeconds(KPIMDefaultAlarmInterval); User::LeaveIfError(entryStart.SecondsFrom(alarmTime, temp)); value = temp.Int(); } // Convert the alarm value to the native entry SetAlarmToEntryL(aEntry, value); }
// ----------------------------------------------------------------------------- // CPIMEventPropertyConverter::ConvertAlarmFieldL // Converts an alarm field from a PIM Event Item to a CParserVCard. // ----------------------------------------------------------------------------- // void CPIMEventPropertyConverter::ConvertAlarmFieldL(const CPIMItem& aItem, // item to convert from CParserVCalEntity& aParser, // parser to insert the property to. TPIMEventField aField, // field to convert TInt aIndex) // index to the field { JELOG2(EPim); const TInt KAlarmInterval = aItem.getInt(aField, aIndex); const TTimeIntervalSeconds KTimeInterval(KAlarmInterval); // Check that there exists start date. If item is not written to // database there might not be start date present if (aItem.CountValuesL(EPIMEventStart) == 0) { return; } // Start date present, so conversion can be made const TPIMDate KStartDate = aItem.GetDateL(EPIMEventStart, 0); TTime alarmTime(KStartDate); alarmTime -= KTimeInterval; TDateTime dateTime = alarmTime.DateTime(); TVersitDateTime* versitDateTime = new(ELeave) TVersitDateTime(dateTime, TVersitDateTime::EIsUTC); CleanupDeletePushL(versitDateTime); CVersitAlarm* versitAlarm = CVersitAlarm::NewL(versitDateTime, NULL, 0, KNullDesC, KNullDesC); // versitDateTime is now owned by versitAlarm CleanupStack::Pop(versitDateTime); CleanupStack::PushL(versitAlarm); CParserPropertyValue* propertyValue = new(ELeave) CParserPropertyValueAlarm(versitAlarm); // versitAlarm is now owned by propertyValue CleanupStack::Pop(versitAlarm); AddPropertyToParserL(propertyValue, KVersitTokenDALARM(), aParser); // Needed cleanup stack items are popped out in the AddPropretyToParserL }
void CTestAgendaAddAppt::AddEntriesL( void ) { TInt count=1; if ( !GetIntFromConfig(ConfigSection(), KCount, count) ) count=1; TBuf<KMaxTestExecuteCommandLength> tempStore; TInt year; TInt month; TInt day; TInt hour; TInt minute; TInt duration; TInt alarm; TPtrC ptrAlarmSound; TPtrC ptrMessage; TBuf<KMaxDateStringLength> dateString; _LIT(KDateString,"%*E%*D%X%*N%*Y %1 %2 '%3"); RPointerArray<CCalEntry> array; CleanupStack::PushL(TCleanupItem(DestroyRPointerArray, &array)); for (TInt entry=0; entry<count && TestStepResult() == EPass; ) { TTime today; today.HomeTime(); tempStore.Format(KYear(), ++entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, year) ) year=today.DateTime().Year(); tempStore.Format(KMonth(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, month) ) month=today.DateTime().Month(); tempStore.Format(KDay(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, day) ) day=today.DateTime().Day(); else --day; tempStore.Format(KHour(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, hour) ) hour=today.DateTime().Hour(); tempStore.Format(KMinute(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, minute) ) minute=0; tempStore.Format(KDuration(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, duration) ) duration=30; tempStore.Format(KMessage(), entry); GetStringFromConfig(ConfigSection(), tempStore, ptrMessage); TTime startTime(TDateTime(year, TMonth(month-1+EJanuary), day, hour, minute,0,0)); startTime.FormatL(dateString,KDateString); INFO_PRINTF2(_L("Start date is %S"), &dateString); TTime endTime = startTime + TTimeIntervalMinutes(duration); endTime.FormatL(dateString,KDateString); INFO_PRINTF2(_L("End date is %S"), &dateString); HBufC8* uid = HBufC8::NewLC(255); TPtr8 uidP = uid->Des(); uidP.Append(count); CCalEntry* calEntry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); CleanupStack::Pop(); //uid CleanupStack::PushL(calEntry); TCalTime calStartTime, calEndTime; calStartTime.SetTimeLocalL(startTime); calEndTime.SetTimeLocalL(endTime); calEntry->SetStartAndEndTimeL(calStartTime, calEndTime); tempStore.Format(KAlarm(), entry); if ( GetIntFromConfig(ConfigSection(), tempStore, alarm) ) { TTimeIntervalMinutes currentTime((hour*60) + minute); TTimeIntervalMinutes alarmTime(currentTime.Int()); CCalAlarm* calAlarm = CCalAlarm::NewL(); CleanupStack::PushL(calAlarm); calAlarm->SetTimeOffset(alarmTime); tempStore.Format(KAlarmSound(), entry); if ( GetStringFromConfig(ConfigSection(), tempStore, ptrAlarmSound) ) calAlarm->SetAlarmSoundNameL(ptrAlarmSound); else calAlarm->SetAlarmSoundNameL(_L("Bells")); calEntry->SetAlarmL(calAlarm); CleanupStack::PopAndDestroy(); //calAlarm } //Store in the array array.AppendL(calEntry); CleanupStack::Pop(); //calEntry } INFO_PRINTF1(_L("About to store appointments now")); TInt success(0); TRAPD(storeError, iCalEntryViewBase->StoreL(array, success)); INFO_PRINTF2(_L("Store result is %d"), storeError); if (success != count && storeError == KErrNone) { SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(&array); }
void TextRoom::readSettings() { QFile file( settings->fileName() ); if ( !file.exists() ) { toggleFullScreen(); writeSettings(); return; } if ( settings->value("WindowState/ShowFullScreen", true).toBool() ) { if ( !isFullScreen() ) showFullScreen(); } else { showNormal(); QPoint pos = settings->value("WindowState/TopLeftPosition", QPoint(100, 100)).toPoint(); QSize size = settings->value("WindowState/WindowSize", QSize(300, 200)).toSize(); resize(size); move(pos); } QString foregroundColor = settings->value("Colors/FontColor", "#808080" ).toString(); QString back = settings->value("Colors/Background", "#000000" ).toString(); QString status_c = settings->value("Colors/StatusColor", "#202020" ).toString(); // oxygen does weird stuff with the background QApplication::setStyle("plastique"); QFont font; font.fromString( settings->value("StatusFont").toString()); defaultFont.fromString( settings->value("DefaultFont").toString() ); statsLabel->setFont( font ); deadlineLabel->setFont ( font ) ; curDir = settings->value("RecentFiles/LastDir", curDir).toString(); lastSearch = settings->value("TextSearch/LastPhrase", lastSearch).toString(); QDateTime today = QDateTime::currentDateTime(); QString todaytext = today.toString("yyyyMMdd"); // Read all the settings-> isAutoSave = settings->value("AutoSave", false).toBool(); isFlowMode = settings->value("FlowMode", false).toBool(); isSound = settings->value("Sound", true).toBool(); isPageCount = settings->value("PageCount", false).toBool(); isCharacterCount = settings->value("CharacterCount", false).toBool(); deadlinetext = settings->value("Deadline", todaytext).toString(); deadline = QDate::fromString(deadlinetext, "yyyyMMdd"); wordcount = settings->value("WordCount", 0).toInt(); editorWidth = settings->value("EditorWidth", 800).toInt(); editorTopSpace = settings->value("EditorTopSpace", 0).toInt(); editorBottomSpace = settings->value("EditorBottomSpace", 0).toInt(); alarm = settings->value("TimedWriting", 0).toInt(); pageCountFormula = settings->value("PageCountFormula", 250).toInt(); dateFormat = settings->value("DateFormat", "d MMMM yyyy dddd").toString(); timeFormatBool = settings->value("24-Hour", true ).toBool(); defaultDir = settings->value("DefaultDirectory", QDir::homePath()).toString(); backgroundImage = settings->value("BackgroundImage", "").toString(); isPlainText = settings->value("PlainText", false).toBool(); language = settings->value("LanguageName", "en_US").toString(); indentValue = settings->value("Indent", 50).toInt(); paragraphSpacing = settings->value("ParagraphSpacing", 20).toInt(); tabStopWidth = settings->value("TabStopWidth", 80).toInt(); cursorWidth = settings->value("CursorWidth", 3).toInt(); textEdit->setLayoutDirection(Qt::LayoutDirectionAuto); textEdit->setTabStopWidth(tabStopWidth); textEdit->setCursorWidth(cursorWidth); loadStyleSheet(foregroundColor, back, status_c); textEdit->setMaximumWidth(editorWidth); textEdit->document()->blockSignals(true); bool modified = textEdit->document()->isModified(); if ( isPlainText ) { QString text( textEdit->document()->toPlainText() ); textEdit->document()->clear(); textEdit->insertPlainText(text); textEdit->setAcceptRichText( false ); } else { textEdit->setAcceptRichText( true ); } indentLines(indentValue); setWindowModified(modified); textEdit->document()->setModified(modified); textEdit->document()->blockSignals(false); if ( timeFormatBool ) { timeFormat = "h:mm"; } else { timeFormat = "h:mm AP"; } horizontalSlider->setVisible( settings->value("ScrollBar", true).toBool() ); isScrollBarVisible = horizontalSlider->isVisible(); vPositionChanged(); topSpacer->changeSize(20, editorTopSpace, QSizePolicy::Maximum, QSizePolicy::Maximum); bottomSpacer->changeSize(20, editorBottomSpace, QSizePolicy::Maximum, QSizePolicy::Maximum); timeOut = alarm * 60000; if (alarm != 0) { QTimer::singleShot(timeOut, this, SLOT(alarmTime())); } if ( (optOpenLastFile = settings->value("RecentFiles/OpenLastFile", true).toBool()) ) { curFile = settings->value("RecentFiles/LastFile", curFile).toString(); if ( (isSaveCursor = settings->value("RecentFiles/SavePosition", true).toBool() )) cPosition = settings->value("RecentFiles/AtPosition", cPosition).toInt(); } wordCountChanged = true; getFileStatus(); sCursor(); }