本文整理汇总了C++中KDateTime::addSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::addSecs方法的具体用法?C++ KDateTime::addSecs怎么用?C++ KDateTime::addSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::addSecs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseEventAttribute
void KCalResourceSlox::parseEventAttribute( const QDomElement &e,
Event *event )
{
QString tag = e.tagName();
QString text = decodeText( e.text() );
if ( text.isEmpty() ) return;
if ( tag == fieldName( EventBegin ) ) {
KDateTime dt;
if ( event->allDay() ) {
if ( type() == "ox" )
dt = WebdavHandler::sloxToKDateTime( text, timeSpec() );
else
dt = WebdavHandler::sloxToKDateTime( text ); // ### is this really correct for SLOX?
dt.setDateOnly( true );
} else
dt = WebdavHandler::sloxToKDateTime( text );
event->setDtStart( dt );
} else if ( tag == fieldName( EventEnd ) ) {
KDateTime dt;
if ( event->allDay() ) {
dt = WebdavHandler::sloxToKDateTime( text );
dt = dt.addSecs( -1 );
}
else dt = WebdavHandler::sloxToKDateTime( text );
event->setDtEnd( dt );
} else if ( tag == fieldName( Location ) ) {
event->setLocation( text );
}
}
示例2: testEventComparison
void ComparisonVisitorTest::testEventComparison()
{
const QString summary = QLatin1String( "Testing comparison" );
const QString desc = QLatin1String( "Testing ComparisonVisitor" );
const KDateTime now = KDateTime::currentUtcDateTime();
const KDateTime later = now.addSecs( 3600 );
Event reference;
reference.setSummary( summary );
reference.setDescription( desc );
reference.setDtStart( now );
reference.setDtEnd( later );
// create a copy of the reference incidence
Event event( reference );
IncidenceBase *baseReference = &reference;
IncidenceBase *baseIncidence = &event;
QVERIFY( mComparator.compare( baseIncidence, baseReference ) );
// change a property of Event (but not of IncidenceBase)
event.setHasEndDate( !event.hasEndDate() );
QVERIFY( !mComparator.compare( baseIncidence, baseReference ) );
}
示例3: setMaxMinTimeIf
/******************************************************************************
* If the minimum and maximum date/times fall on the same date, set the minimum
* and maximum times in the time edit box.
*/
void AlarmTimeWidget::setMaxMinTimeIf(const KDateTime& now)
{
int mint = 0;
QTime maxt = time_23_59;
mMinMaxTimeSet = false;
if (mMaxDateTime.isValid())
{
bool set = true;
KDateTime minDT;
if (mMinDateTimeIsNow)
minDT = now.addSecs(60);
else if (mMinDateTime.isValid())
minDT = mMinDateTime;
else
set = false;
if (set && mMaxDateTime.date() == minDT.date())
{
// The minimum and maximum times are on the same date, so
// constrain the time value.
mint = minDT.time().hour()*60 + minDT.time().minute();
maxt = mMaxDateTime.time();
mMinMaxTimeSet = true;
}
}
mTimeEdit->setMinimum(mint);
mTimeEdit->setMaximum(maxt);
mTimeEdit->setWrapping(!mint && maxt == time_23_59);
}
示例4: dateEnd
QDate Event::dateEnd() const
{
KDateTime end = dtEnd().toTimeSpec( dtStart() );
if ( allDay() ) {
return end.date();
} else {
return end.addSecs(-1).date();
}
}
示例5: testFreeBusyComparison
void ComparisonVisitorTest::testFreeBusyComparison()
{
const KDateTime now = KDateTime::currentUtcDateTime();
const KDateTime later = now.addSecs( 3600 );
FreeBusy reference;
reference.setDtStart( now );
reference.setDtEnd( later );
// create a copy of the reference incidence
FreeBusy freebusy( reference );
IncidenceBase *baseReference = &reference;
IncidenceBase *baseIncidence = &freebusy;
QVERIFY( mComparator.compare( baseIncidence, baseReference ) );
// change a property of FreeBusy (but not of IncidenceBase)
freebusy.setDtEnd( freebusy.dtEnd().addSecs( 3600 ) );
QVERIFY( !mComparator.compare( baseIncidence, baseReference ) );
}
示例6:
KCal::Alarm::List ResourceKolab::alarms( const KDateTime& from, const KDateTime& to )
{
KCal::Alarm::List alarms;
KCal::Journal::List notes = mCalendar.journals();
KCal::Journal::List::ConstIterator note;
for ( note = notes.constBegin(); note != notes.constEnd(); ++note )
{
KDateTime preTime = from.addSecs( -1 );
KCal::Alarm::List::ConstIterator it;
for( it = (*note)->alarms().constBegin(); it != (*note)->alarms().constEnd(); ++it )
{
if ( (*it)->enabled() )
{
KDateTime dt = (*it)->nextRepetition( preTime );
if ( dt.isValid() && dt <= to )
alarms.append( *it );
}
}
}
return alarms;
}
示例7: pasteIncidence
Incidence::Ptr pasteIncidence( const Incidence::Ptr &incidence,
KDateTime newDateTime,
const QFlags<PasteFlag> &pasteOptions )
{
Incidence::Ptr inc( incidence );
if ( inc ) {
inc = Incidence::Ptr( inc->clone() );
inc->recreate();
}
if ( inc && newDateTime.isValid() ) {
if ( inc->type() == Incidence::TypeEvent ) {
Event::Ptr event = inc.staticCast<Event>();
if ( pasteOptions & FlagPasteAtOriginalTime ) {
// Set date and preserve time and timezone stuff
const QDate date = newDateTime.date();
newDateTime = event->dtStart();
newDateTime.setDate( date );
}
// in seconds
const int durationInSeconds = event->dtStart().secsTo( event->dtEnd() );
const int durationInDays = event->dtStart().daysTo( event->dtEnd() );
event->setDtStart( newDateTime );
if ( newDateTime.isDateOnly() ) {
event->setDtEnd( newDateTime.addDays( durationInDays ) );
} else {
event->setDtEnd( newDateTime.addSecs( durationInSeconds ) );
}
} else if ( inc->type() == Incidence::TypeTodo ) {
Todo::Ptr aTodo = inc.staticCast<Todo>();
const bool pasteAtDtStart = ( pasteOptions & FlagTodosPasteAtDtStart );
if ( pasteOptions & FlagPasteAtOriginalTime ) {
// Set date and preserve time and timezone stuff
const QDate date = newDateTime.date();
newDateTime = pasteAtDtStart ? aTodo->dtStart() : aTodo->dtDue();
newDateTime.setDate( date );
}
if ( pasteAtDtStart ) {
aTodo->setDtStart( newDateTime );
} else {
aTodo->setDtDue( newDateTime );
}
} else if ( inc->type() == Incidence::TypeJournal ) {
if ( pasteOptions & FlagPasteAtOriginalTime ) {
// Set date and preserve time and timezone stuff
const QDate date = newDateTime.date();
newDateTime = inc->dtStart();
newDateTime.setDate( date );
}
inc->setDtStart( newDateTime );
} else {
kDebug() << "Trying to paste unknown incidence of type" << int( inc->type() );
}
}
return inc;
}
示例8: getDateTime
/******************************************************************************
* Fetch the entered date/time.
* If 'checkExpired' is true and the entered value <= current time, an error occurs.
* If 'minsFromNow' is non-null, it is set to the number of minutes' delay selected,
* or to zero if a date/time was entered.
* In this case, if 'showErrorMessage' is true, output an error message.
* 'errorWidget' if non-null, is set to point to the widget containing the error.
* Reply = invalid date/time if error.
*/
KDateTime AlarmTimeWidget::getDateTime(int* minsFromNow, bool checkExpired, bool showErrorMessage, QWidget** errorWidget) const
{
if (minsFromNow)
*minsFromNow = 0;
if (errorWidget)
*errorWidget = 0;
KDateTime now = KDateTime::currentUtcDateTime();
now.setTime(QTime(now.time().hour(), now.time().minute(), 0));
if (!mAtTimeRadio->isChecked())
{
if (!mDelayTimeEdit->isValid())
{
if (showErrorMessage)
KMessageBox::sorry(const_cast<AlarmTimeWidget*>(this), i18nc("@info", "Invalid time"));
if (errorWidget)
*errorWidget = mDelayTimeEdit;
return KDateTime();
}
int delayMins = mDelayTimeEdit->value();
if (minsFromNow)
*minsFromNow = delayMins;
return now.addSecs(delayMins * 60).toTimeSpec(mTimeSpec);
}
else
{
bool dateOnly = mAnyTimeAllowed && mAnyTimeCheckBox && mAnyTimeCheckBox->isChecked();
if (!mDateEdit->isValid() || !mTimeEdit->isValid())
{
// The date and/or time is invalid
if (!mDateEdit->isValid())
{
if (showErrorMessage)
KMessageBox::sorry(const_cast<AlarmTimeWidget*>(this), i18nc("@info", "Invalid date"));
if (errorWidget)
*errorWidget = mDateEdit;
}
else
{
if (showErrorMessage)
KMessageBox::sorry(const_cast<AlarmTimeWidget*>(this), i18nc("@info", "Invalid time"));
if (errorWidget)
*errorWidget = mTimeEdit;
}
return KDateTime();
}
KDateTime result;
if (dateOnly)
{
result = KDateTime(mDateEdit->date(), mTimeSpec);
if (checkExpired && result.date() < now.date())
{
if (showErrorMessage)
KMessageBox::sorry(const_cast<AlarmTimeWidget*>(this), i18nc("@info", "Alarm date has already expired"));
if (errorWidget)
*errorWidget = mDateEdit;
return KDateTime();
}
}
else
{
result = KDateTime(mDateEdit->date(), mTimeEdit->time(), mTimeSpec);
if (checkExpired && result <= now.addSecs(1))
{
if (showErrorMessage)
KMessageBox::sorry(const_cast<AlarmTimeWidget*>(this), i18nc("@info", "Alarm time has already expired"));
if (errorWidget)
*errorWidget = mTimeEdit;
return KDateTime();
}
}
return result;
}
}