本文整理汇总了C++中KDateTime::setTime方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::setTime方法的具体用法?C++ KDateTime::setTime怎么用?C++ KDateTime::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::setTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dtStart
KDateTime Todo::dtStart( bool first ) const
{
if ( !hasStartDate() ) {
return KDateTime();
}
if ( recurs() && !first ) {
KDateTime dt = d->mDtRecurrence.addDays( dtDue( true ).daysTo( IncidenceBase::dtStart() ) );
dt.setTime( IncidenceBase::dtStart().time() );
return dt;
} else {
return IncidenceBase::dtStart();
}
}
示例2: convertToAppointment
ngwt__Appointment* IncidenceConverter::convertToAppointment( KCal::Event* event )
{
kDebug() <<"IncidenceConverter::convertToAppointment()";
if ( !event )
return 0;
ngwt__Appointment* appointment = soap_new_ngwt__Appointment( soap(), -1 );
appointment->startDate = 0;
appointment->endDate = 0;
appointment->startDay = 0;
appointment->endDay = 0;
appointment->acceptLevel = 0;
appointment->alarm = 0;
appointment->allDayEvent = 0;
appointment->place = 0;
appointment->timezone = 0;
if ( !convertToCalendarItem( event, appointment ) ) {
soap_dealloc( soap(), appointment );
return 0;
}
if ( event->allDay
() ) {
bool *allDayEvent = (bool*)soap_malloc( soap(), 1 );
(*allDayEvent ) = true;
appointment->allDayEvent = allDayEvent;
if ( event->dtStart().isValid() ) {
/* kDebug() << " convertToAppointment() raw start date: " << event->dtStart().toString();*/
KDateTime start = event->dtStart();
start.setTime( QTime( 0, 0, 0 ) );
appointment->startDate = kDateTimeToChar( start, mTimeSpec );
//appointment->startDay = qDateToString( event->dtStart().date()/*.addDays( -1 )*/ );
/* kDebug() << " converted start date: " << appointment->startDate;*/
}
else
kDebug() << " event start date not valid ";
if ( event->hasEndDate() ) {
// kDebug() << " convertToAppointment() raw end date: " << event->dtEnd().toString();
KDateTime end = event->dtEnd();
end = end.addDays( 1 );
end.setTime( QTime( 0, 0, 0 ) );
appointment->endDate = kDateTimeToChar( end, mTimeSpec );
//appointment->endDay = qDateToString( event->dtEnd().date() );
// kDebug() << " converted end date:" << appointment->endDate;
}
else
kDebug() << " event end date not valid ";
} else {
appointment->allDayEvent = 0;
if ( event->dtStart().isValid() )
appointment->startDate = kDateTimeToChar( event->dtStart(), mTimeSpec );
if ( event->hasEndDate() )
appointment->endDate = kDateTimeToChar( event->dtEnd(), mTimeSpec );
}
enum ngwt__AcceptLevel * al = (enum ngwt__AcceptLevel*)soap_malloc(soap(), sizeof(enum ngwt__AcceptLevel));
*al = Busy;
appointment->acceptLevel = al;
KCal::Alarm::List alarms = event->alarms();
if ( !alarms.isEmpty() ) {
ngwt__Alarm* alarm = soap_new_ngwt__Alarm( soap(), -1 );
alarm->__item = alarms.first()->startOffset().asSeconds() * -1;
bool * enabled = (bool *)soap_malloc(soap(), sizeof(bool));
*enabled = alarms.first()->enabled();
alarm->enabled = enabled;
appointment->alarm = alarm;
} else
appointment->alarm = 0;
if ( !event->location().isEmpty() ) {
std::string* location = qStringToString( event->location() );
appointment->place = location;
} else
appointment->place = 0;
appointment->timezone = 0;
return appointment;
}
示例3: kDebug
//@cond PRIVATE
void FreeBusy::Private::init( const Event::List &eventList,
const KDateTime &start, const KDateTime &end )
{
int extraDays, i, x, duration;
duration = start.daysTo( end );
QDate day;
KDateTime tmpStart;
KDateTime tmpEnd;
// Loops through every event in the calendar
Event::List::ConstIterator it;
for ( it = eventList.constBegin(); it != eventList.constEnd(); ++it ) {
Event::Ptr event = *it;
// If this event is transparent it shouldn't be in the freebusy list.
if ( event->transparency() == Event::Transparent ) {
continue;
}
// The code below can not handle all-day events. Fixing this resulted
// in a lot of duplicated code. Instead, make a copy of the event and
// set the period to the full day(s). This trick works for recurring,
// multiday, and single day all-day events.
Event::Ptr allDayEvent;
if ( event->allDay() ) {
// addDay event. Do the hack
kDebug() << "All-day event";
allDayEvent = Event::Ptr( new Event( *event ) );
// Set the start and end times to be on midnight
KDateTime st = allDayEvent->dtStart();
st.setTime( QTime( 0, 0 ) );
KDateTime nd = allDayEvent->dtEnd();
nd.setTime( QTime( 23, 59, 59, 999 ) );
allDayEvent->setAllDay( false );
allDayEvent->setDtStart( st );
allDayEvent->setDtEnd( nd );
kDebug() << "Use:" << st.toString() << "to" << nd.toString();
// Finally, use this event for the setting below
event = allDayEvent;
}
// This whole for loop is for recurring events, it loops through
// each of the days of the freebusy request
for ( i = 0; i <= duration; ++i ) {
day = start.addDays( i ).date();
tmpStart.setDate( day );
tmpEnd.setDate( day );
if ( event->recurs() ) {
if ( event->isMultiDay() ) {
// FIXME: This doesn't work for sub-daily recurrences or recurrences with
// a different time than the original event.
extraDays = event->dtStart().daysTo( event->dtEnd() );
for ( x = 0; x <= extraDays; ++x ) {
if ( event->recursOn( day.addDays( -x ), start.timeSpec() ) ) {
tmpStart.setDate( day.addDays( -x ) );
tmpStart.setTime( event->dtStart().time() );
tmpEnd = event->duration().end( tmpStart );
addLocalPeriod( q, tmpStart, tmpEnd );
break;
}
}
} else {
if ( event->recursOn( day, start.timeSpec() ) ) {
tmpStart.setTime( event->dtStart().time() );
tmpEnd.setTime( event->dtEnd().time() );
addLocalPeriod ( q, tmpStart, tmpEnd );
}
}
}
}
// Non-recurring events
addLocalPeriod( q, event->dtStart(), event->dtEnd() );
}
q->sortList();
}
示例4: 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;
}
}